Prefix all macros and symbols in song data
pinobatch opened this issue · 0 comments
As described in the ASM6 manual, ASM6's excuse for a linker is include
, which behaves the same way as the C language preprocessor's #include
. Because ASM6 lacks file-local symbols, song data symbols and macros from pentlyseq.inc
, such as N_C
, D_8
, and playPatTri
, escape the context of the audio driver and may collide with labels used by the main program. The solution suggested in "Namespacing symbols used by an ASM6 library" on NESdev BBS is to prefix everything.
Thus pentlyas.py
needs a command-line option to stop emitting this:
PPDAT_scale:
.byte N_C|D_8, N_D|D_8, N_E|D_8, N_F|D_8, N_G|D_8, N_A|D_8, N_B|D_8, N_CH|D_8
.byte N_B|D_8, N_A|D_8, N_G|D_8, N_F|D_8, N_E|D_8, N_D|D_8, N_C|D_4
.byte PATEND
And start emitting this:
PPDAT_scale:
.byte PENTLY_N_C|PENTLY_D_8
.byte PENTLY_N_D|PENTLY_D_8
.byte PENTLY_N_E|PENTLY_D_8
.byte PENTLY_N_F|PENTLY_D_8
.byte PENTLY_N_G|PENTLY_D_8
.byte PENTLY_N_A|PENTLY_D_8
.byte PENTLY_N_B|PENTLY_D_8
.byte PENTLY_N_CH|PENTLY_D_8
.byte PENTLY_N_B|PENTLY_D_8
.byte PENTLY_N_A|PENTLY_D_8
.byte PENTLY_N_G|PENTLY_D_8
.byte PENTLY_N_F|PENTLY_D_8
.byte PENTLY_N_E|PENTLY_D_8
.byte PENTLY_N_D|PENTLY_D_8
.byte PENTLY_N_C|PENTLY_D_4
.byte PENTLY_PATEND
This would affect sfxdef
, sfxframe
, drumdef
, instdef
, songdef
, patdef
, playPat*
, stopPat*
, waitRows
, fine
, segno
, dalSegno
, setTempo
, setBeatDuration
, attackOn*
, and noteOn*
macros, as well as CON_*
,N_*
, D_*
, and pattern effect command constants.
To keep things from becoming too inconvenient for ca65 users, have pentlyseq.inc
continue to define the old macros and symbols in terms of the prefixed macros unless PENTLY_USE_PREFIXED_DATA
is defined and enabled.
- Prefix constants and define unprefixed constants in terms of prefixed ones
- Prefix macros and define unprefixed macros in terms of prefixed ones
- Emit prefixed constants and macros