For both my past projects, I'd have .segment "ROMxx" peppered throughout multiple source files, and some equates in the corresponding modules for bank numbers which corresponded to the segment numbers. As you can imagine, that was hard to maintain. Now I'm managing all banks/segments with a single enum, like this:
I then use this in conjunction with a macro
.macro setseg num
.segment .sprintf("%s%d", "ROM", num)
.endmacro
And use it like this:
setseg SOUND_ENGINE_BANK
//etc. etc.
.include "envelopes.inc"
.include "sfx.inc"
As a result, I can change the layout of what data is where in the ROM just by rearranging the above enum.
I'm doing something similar for chr-rom as well. Quite convenient.
Code:
//These are all in 8kb units, the smallest mmc3 can swap (i.e. each enum corresponds to a rom number in my cfg file that is an 8kb rom)
.enum
SOUND_ENGINE_BANK
ROBOT_ADVENTURE1_BANK
ROBOT_ADVENTURE2_BANK
ROBOT_ADVENTURE3_BANK
ROBOT_ADVENTURE4_BANK
ROBOT_ADVENTURE5_BANK
ENTITIES_BANK0
UNUSED_BANK7
UNUSED_BANK8
UNUSED_BANK9
UNUSED_BANK10
UNUSED_BANK11
UNUSED_BANK12
UNUSED_BANK13
UNUSED_BANK14
UNUSED_BANK15
UNUSED_BANK16
UNUSED_BANK17
UNUSED_BANK18
UNUSED_BANK19
UNUSED_BANK20
UNUSED_BANK21
UNUSED_BANK22
UNUSED_BANK23
UNUSED_BANK24
UNUSED_BANK25
UNUSED_BANK26
UNUSED_BANK27
UNUSED_BANK28
UNUSED_BANK29
UNUSED_BANK30
UNUSED_BANK31
MAP_BANK0
UNUSED_BANK33
UNUSED_BANK34
UNUSED_BANK35
UNUSED_BANK36
UNUSED_BANK37
UNUSED_BANK38
UNUSED_BANK39
UNUSED_BANK40
UNUSED_BANK41
UNUSED_BANK42
UNUSED_BANK43
UNUSED_BANK44
UNUSED_BANK45
UNUSED_BANK46
UNUSED_BANK47
NAMETABLE_BANK
UNUSED_BANK49
UNUSED_BANK50
UNUSED_BANK51
UNUSED_BANK52
UNUSED_BANK53
UNUSED_BANK54
UNUSED_BANK55
OVERLAY_BANK
UNUSED_BANK57
UNUSED_BANK58
UNUSED_BANK59
UNUSED_BANK60
UNUSED_BANK61
CODE
.endenum
.enum
SOUND_ENGINE_BANK
ROBOT_ADVENTURE1_BANK
ROBOT_ADVENTURE2_BANK
ROBOT_ADVENTURE3_BANK
ROBOT_ADVENTURE4_BANK
ROBOT_ADVENTURE5_BANK
ENTITIES_BANK0
UNUSED_BANK7
UNUSED_BANK8
UNUSED_BANK9
UNUSED_BANK10
UNUSED_BANK11
UNUSED_BANK12
UNUSED_BANK13
UNUSED_BANK14
UNUSED_BANK15
UNUSED_BANK16
UNUSED_BANK17
UNUSED_BANK18
UNUSED_BANK19
UNUSED_BANK20
UNUSED_BANK21
UNUSED_BANK22
UNUSED_BANK23
UNUSED_BANK24
UNUSED_BANK25
UNUSED_BANK26
UNUSED_BANK27
UNUSED_BANK28
UNUSED_BANK29
UNUSED_BANK30
UNUSED_BANK31
MAP_BANK0
UNUSED_BANK33
UNUSED_BANK34
UNUSED_BANK35
UNUSED_BANK36
UNUSED_BANK37
UNUSED_BANK38
UNUSED_BANK39
UNUSED_BANK40
UNUSED_BANK41
UNUSED_BANK42
UNUSED_BANK43
UNUSED_BANK44
UNUSED_BANK45
UNUSED_BANK46
UNUSED_BANK47
NAMETABLE_BANK
UNUSED_BANK49
UNUSED_BANK50
UNUSED_BANK51
UNUSED_BANK52
UNUSED_BANK53
UNUSED_BANK54
UNUSED_BANK55
OVERLAY_BANK
UNUSED_BANK57
UNUSED_BANK58
UNUSED_BANK59
UNUSED_BANK60
UNUSED_BANK61
CODE
.endenum
I then use this in conjunction with a macro
Code:
.macro setseg num
.segment .sprintf("%s%d", "ROM", num)
.endmacro
And use it like this:
Code:
setseg SOUND_ENGINE_BANK
//etc. etc.
.include "envelopes.inc"
.include "sfx.inc"
As a result, I can change the layout of what data is where in the ROM just by rearranging the above enum.
I'm doing something similar for chr-rom as well. Quite convenient.