Actions

SCHG How-to

Extend the level index past $10 in Sonic 2

From Sonic Retro

Revision as of 16:41, 29 April 2008 by SOTI (talk | contribs) (fixed asm tag)

WARNING: I strongly recommend you port the sonic1 sound driver first before proceeding. A lot of major data shifting will occur in this tutorial and it will make the rom size a lot bigger than it was before. This will break the sonic2 or even sonic2 beta sound driver, thus so you definitely want the sonic 1 sound driver due to the fact that it can take the shifting and still work properly.


You probably noticed that all the indexes in the game stop at $10 and when you try to extend it, by extending the MLLB, you get weird glitches or even crashes, that is because you haven't extended all the indexes that need to be extended.

first we will look at the data that defines the titlecard layout:

<asm>

word_13CD4

Obj34_TitleCardData: dc.b 8, 0, $80, $1B dc.w $240, $120, $B8

dc.b $A, $11, $40, $1C dc.w $28, $148, $D0

dc.b $C, $12, $18, $1C dc.w $68, $188, $D0

dc.b 2, 0, 0, 0 dc.w 0, 0, 0

dc.b 4, $15, $48, 8 dc.w $2A8, $168,$120

dc.b 6, $16, 8, $15 dc.w $80, $F0, $F0 </asm>

we want to change it to:

<asm>

word_13CD4

Obj34_TitleCardData: dc.b 8, 0, $80, $1B; Index 0 is the start of Zone names dc.w $240, $120, $B8

dc.b $A, $21, $40, $1C; Use index $21 to load the "ZONE" string dc.w $28, $148, $D0

dc.b $C, $22, $28, $1C; Use index $22 as the index for act 1, $23 for act 2, $24 for act 3 dc.w $68, $188, $D0

dc.b 2, 0, 0, 0; I have no idea what this is. dc.w 0, 0, 0

dc.b 4, $25, $48, 8; Use index $25 for "SONIC THE HEDGEHOG" string dc.w $2A8, $168,$120

dc.b 6, $26, 8, $15; Use index $26 for red panel edge dc.w $80, $F0, $F0 </asm>

then we look for: <asm> loc_13DEE: jsr sub_13D10(pc) move.b (Current_Zone).w,d0 cmpi.b #$10,d0 beq.s BranchTo9_DeleteObject cmpi.b #6,d0 beq.s BranchTo9_DeleteObject cmpi.b #$E,d0 beq.s BranchTo9_DeleteObject move.b (Current_Act).w,d1 addi.b #$12,d1 cmpi.b #5,d0 bne.s loc_13E18 moveq #$14,d1 </asm>

and change it to: <asm> loc_13DEE: jsr sub_13D10(pc) move.b (Current_Zone).w,d0 cmpi.b #$10,d0 beq.s BranchTo9_DeleteObject; do not load act number if sky chase zone cmpi.b #6,d0 beq.s BranchTo9_DeleteObject; do not load act number if wing fortress zone cmpi.b #$E,d0 beq.s BranchTo9_DeleteObject; do not load act number if death egg zone move.b (Current_Act).w,d1 addi.b #$22,d1; reference to act 1 mappings for normal zones as well as $04 (MTZ 1 - 2) cmpi.b #5,d0 bne.s loc_13E18 moveq #$24,d1; reference to act 3 mappings for $05 (MTZ 3 - 4) to load the "3" artwork reguardless of which act is really loaded. </asm>

That change allows us to make room for our extra 16 levels.

Next we locate: <asm>

loc_157D2

LoadTitleCard: bsr.s LoadTitleCard0 moveq #0,d0 move.b (Current_Zone).w,d0 move.b byte_15820(pc,d0.w),d0 lea word_15832(pc),a0 lea (a0,d0.w),a0 move.l #$7BC00002,d0 </asm>

and replace it with: <asm>

loc_157D2

LoadTitleCard: bsr.s LoadTitleCard0 moveq #0,d0 move.b (Current_Zone).w,d0 add.w d0,d0 move.w Off_FontIndexes(pc,d0.w),d0 lea Off_FontIndexes(pc,d0.w),a0 move.l #$7BC00002,d0 </asm>

Next we locate: <asm>

unknown

byte_15820: dc.b 0, 0, 0, 0,$10,$10,$98,$20,$2C, 0,$3C,$46,$58,$68,$A8,$7A dc.b $8A, 0 ; 16

unknown

word_15832: dc.w $2A06,$3804, 4,$2604, $C04,$1804,$1C02,$FFFF dc.w $2A06,$4004,$3804,$3004,$2604,$1C02,$3C04,$FFFF; 8 dc.w $1804,$1C02,$2604,$4004,$3004,$FFFF,$1804,$1C02; 16 dc.w $C04,$3004, 4,$2604, $804,$FFFF,$1C02,$2604; 24 dc.w $804, 4,$FFFF,$2A06,$5604,$3C04,$4004,$1C02; 32 dc.w $804, 4,$4804,$FFFF, $804, 4,$3C04,$1C02; 40 dc.w $1404,$1804,$4004,$FFFF, $804,$1804,$2A06,$1C02; 48 dc.w 4,$2604,$3004,$4004,$FFFF, 4,$3404,$4404; 56 dc.w $4004,$1C02, $804,$3804,$FFFF,$3C04,$2204,$5604; 64 dc.w $804,$1804, 4,$FFFF,$4C06,$1C02,$1404,$1004; 72 dc.w $3804,$4004,$3C04,$FFFF, $C04, 4,$4004,$1804; 80 dc.w $1404,$FFFF ; 88 </asm>

and replace it with: <asm>; offset index to loaded artwork index for titlecards Off_FontIndexes: dc.w FontIndex_EHZ-Off_FontIndexes dc.w FontIndex_LZ-Off_FontIndexes dc.w FontIndex_WZ-Off_FontIndexes dc.w FontIndex_DHZ-Off_FontIndexes dc.w FontIndex_MTZ-Off_FontIndexes dc.w FontIndex_MTZ-Off_FontIndexes dc.w FontIndex_WFZ-Off_FontIndexes dc.w FontIndex_HTZ-Off_FontIndexes dc.w FontIndex_HPZ-Off_FontIndexes dc.w FontIndex_GCZ-Off_FontIndexes dc.w FontIndex_OOZ-Off_FontIndexes dc.w FontIndex_MCZ-Off_FontIndexes dc.w FontIndex_CNZ-Off_FontIndexes dc.w FontIndex_CPZ-Off_FontIndexes dc.w FontIndex_DEZ-Off_FontIndexes dc.w FontIndex_ARZ-Off_FontIndexes dc.w FontIndex_SCZ-Off_FontIndexes dc.w FontIndex_Lev11-Off_FontIndexes dc.w FontIndex_Lev12-Off_FontIndexes dc.w FontIndex_Lev13-Off_FontIndexes dc.w FontIndex_Lev14-Off_FontIndexes dc.w FontIndex_Lev15-Off_FontIndexes dc.w FontIndex_Lev16-Off_FontIndexes dc.w FontIndex_Lev17-Off_FontIndexes dc.w FontIndex_Lev18-Off_FontIndexes dc.w FontIndex_Lev19-Off_FontIndexes dc.w FontIndex_Lev1A-Off_FontIndexes dc.w FontIndex_Lev1B-Off_FontIndexes dc.w FontIndex_Lev1C-Off_FontIndexes dc.w FontIndex_Lev1D-Off_FontIndexes dc.w FontIndex_Lev1E-Off_FontIndexes dc.w FontIndex_Lev1F-Off_FontIndexes dc.w FontIndex_Lev20-Off_FontIndexes

Letters displayed on EHZ titlecard

FontIndex_EHZ: dc.w $2A06,$3804, 4,$2604, $C04,$1804,$1C02,$FFFF

Letters displayed on LZ titlecard

FontIndex_LZ: dc.w $2604, 4, $404,$3804,$1C02,$4004,$1804,$FFFF

Letters displayed on WZ titlecard

FontIndex_WZ: dc.w $4C06, $C04,$FFFF

Letters displayed on DHZ titlecard

FontIndex_DHZ: dc.w $C04,$4404,$3C04,$4004,$1804,$1C02,$2604,$FFFF

Letters displayed on MTZ titlecard

FontIndex_MTZ: dc.w $2A06,$4004,$3804,$3004,$2604,$1C02,$3C04,$FFFF

Letters displayed on WFZ titlecard

FontIndex_WFZ: dc.w $4C06,$1C02,$1404,$1004,$3804,$4004,$3C04,$FFFF

Letters displayed on HTZ titlecard

FontIndex_HTZ: dc.w $1804,$1C02,$2604,$4004,$3004,$FFFF

Letters displayed on HPZ titlecard

FontIndex_HPZ: dc.w $1804,$1C02, $C04,$3004, 4,$2604, $804,$FFFF

Letters displayed on GCZ titlecard

FontIndex_GCZ: dc.w $1404, $804,$1C02, $C04,$4004,$5604,$FFFF

Letters displayed on OOZ titlecard

FontIndex_OOZ: dc.w $1C02,$2604, $804, 4,$FFFF

Letters displayed on MCZ titlecard

FontIndex_MCZ: dc.w $2A06,$5604,$3C04,$4004,$1C02, $804, 4,$4804 dc.w $FFFF

Letters displayed on CNZ titlecard

FontIndex_CNZ: dc.w $804, 4,$3C04,$1C02,$1404,$1804,$4004,$FFFF

Letters displayed on CPZ titlecard

FontIndex_CPZ: dc.w $804,$1804,$2A06,$1C02, 4,$2604,$3004,$4004 dc.w $FFFF

Letters displayed on DEZ titlecard

FontIndex_DEZ: dc.w $C04, 4,$4004,$1804,$1404,$FFFF

Letters displayed on ARZ titlecard

FontIndex_ARZ: dc.w 4,$3404,$4404,$4004,$1C02, $804,$3804,$FFFF

Letters displayed on SCZ titlecard

FontIndex_SCZ: dc.w $3C04,$2204,$5604, $804,$1804, 4,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev11: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev12: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev13: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev14: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev15: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev16: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev17: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev18: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev19: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1A: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1B: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1C: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1D: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1E: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev1F: dc.w $4606,$2604,$4804,$FFFF

Letters displayed on New Level titlecard

FontIndex_Lev20: dc.w $4606,$2604,$4804,$FFFF </asm>

The original 8-bit proprietary offset index just won't cut it for the scope of this tutorial, so we replaced it with a much friendlier 16-bit relative offset index. also, we changed the order of the text artwork loading data to something much easier to manage, and added not only the ESE names for the empty levels that were already there, and you may choose to change again later, but also the slots for the new levels too. (they will read "NEW LEVEL ZONE" until you give the levels names and change the data here and mappings for those level titlecards.

You will find a link to the archive with the extra data files (sprite 34 mappings included) at the end of the tutorial.

Now we want to locate: <asm>

off_19F4

PalCycle: dc.w PalCycle_EHZ - PalCycle ; 0 dc.w PalCycle_Null - PalCycle ; 1 dc.w PalCycle_Level2 - PalCycle ; 2 dc.w PalCycle_Null - PalCycle ; 3 dc.w PalCycle_MTZ - PalCycle ; 4 dc.w PalCycle_MTZ - PalCycle ; 5 dc.w PalCycle_WFZ - PalCycle ; 6 dc.w PalCycle_HTZ - PalCycle ; 7 dc.w PalCycle_HPZ - PalCycle ; 8 dc.w PalCycle_Null - PalCycle ; 9 dc.w PalCycle_OOZ - PalCycle ; 10 dc.w PalCycle_MCZ - PalCycle ; 11 dc.w PalCycle_CNZ - PalCycle ; 12 dc.w PalCycle_CPZ - PalCycle ; 13 dc.w PalCycle_CPZ - PalCycle ; 14 dc.w PalCycle_ARZ - PalCycle ; 15 dc.w PalCycle_WFZ - PalCycle ; 16 </asm>

and replace it with: <asm>

off_19F4

PalCycle: dc.w PalCycle_EHZ - PalCycle ; 00 dc.w PalCycle_Null - PalCycle ; 01 dc.w PalCycle_Level2 - PalCycle ; 02 dc.w PalCycle_Null - PalCycle ; 03 dc.w PalCycle_MTZ - PalCycle ; 04 dc.w PalCycle_MTZ - PalCycle ; 05 dc.w PalCycle_WFZ - PalCycle ; 06 dc.w PalCycle_HTZ - PalCycle ; 07 dc.w PalCycle_HPZ - PalCycle ; 08 dc.w PalCycle_Null - PalCycle ; 09 dc.w PalCycle_OOZ - PalCycle ; 0A dc.w PalCycle_MCZ - PalCycle ; 0B dc.w PalCycle_CNZ - PalCycle ; 0C dc.w PalCycle_CPZ - PalCycle ; 0D dc.w PalCycle_CPZ - PalCycle ; 0E dc.w PalCycle_ARZ - PalCycle ; 0F dc.w PalCycle_WFZ - PalCycle ; 10 dc.w PalCycle_Null - PalCycle ; 11 dc.w PalCycle_Null - PalCycle ; 12 dc.w PalCycle_Null - PalCycle ; 13 dc.w PalCycle_Null - PalCycle ; 14 dc.w PalCycle_Null - PalCycle ; 15 dc.w PalCycle_Null - PalCycle ; 16 dc.w PalCycle_Null - PalCycle ; 17 dc.w PalCycle_Null - PalCycle ; 18 dc.w PalCycle_Null - PalCycle ; 19 dc.w PalCycle_Null - PalCycle ; 1A dc.w PalCycle_Null - PalCycle ; 1B dc.w PalCycle_Null - PalCycle ; 1C dc.w PalCycle_Null - PalCycle ; 1D dc.w PalCycle_Null - PalCycle ; 1E dc.w PalCycle_Null - PalCycle ; 1F dc.w PalCycle_Null - PalCycle ; 20 </asm>

That inserts empty slots for the cycling palettes of out new levels.

Next we locate: <asm> PalPointers: palptr Pal_SEGA, Normal_palette, $1F palptr Pal_Title, Normal_palette_line2, 7 palptr Pal_UNK1, Normal_palette, $1F palptr Pal_BGND, Normal_palette, $F palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_WZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_MTZ, Normal_palette_line2, $17 palptr Pal_MTZ, Normal_palette_line2, $17 palptr Pal_WFZ, Normal_palette_line2, $17 palptr Pal_HTZ, Normal_palette_line2, $17 palptr Pal_HPZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_OOZ, Normal_palette_line2, $17 palptr Pal_MCZ, Normal_palette_line2, $17 palptr Pal_CNZ, Normal_palette_line2, $17 palptr Pal_CPZ, Normal_palette_line2, $17 palptr Pal_DEZ, Normal_palette_line2, $17 palptr Pal_ARZ, Normal_palette_line2, $17 palptr Pal_SCZ, Normal_palette_line2, $17 palptr Pal_HPZ_U, Normal_palette, $1F palptr Pal_CPZ_U, Normal_palette, $1F palptr Pal_ARZ_U, Normal_palette, $1F palptr Pal_SS, Normal_palette, $17 palptr Pal_UNK2, Normal_palette_line2, 7 palptr Pal_UNK3, Normal_palette_line2, 7 palptr Pal_SS1, Normal_palette_line4, 7 palptr Pal_SS2, Normal_palette_line4, 7 palptr Pal_SS3, Normal_palette_line4, 7 palptr Pal_SS4, Normal_palette_line4, 7 palptr Pal_SS5, Normal_palette_line4, 7 palptr Pal_SS6, Normal_palette_line4, 7 palptr Pal_SS7, Normal_palette_line4, 7 palptr Pal_UNK4, Normal_palette_line4, 7 palptr Pal_UNK5, Normal_palette_line4, 7 palptr Pal_UNK6, Normal_palette_line4, 7 palptr Pal_OOZ_B, Normal_palette_line2, 7 palptr Pal_Menu, Normal_palette, $1F palptr Pal_UNK7, Normal_palette, $1F

----------------------------------------------------------------------------

Pal_SEGA: BINCLUDE "art/palettes/Sega screen.bin" ; SEGA screen palette (Sonic and initial background) Pal_Title: BINCLUDE "art/palettes/Title screen.bin" ; Title screen Palette Pal_UNK1: BINCLUDE "art/palettes/Unknown 1.bin" ; Unknown palette 1 (leftover S1 level select palette?) Pal_BGND: BINCLUDE "art/palettes/SonicAndTails.bin" ; "Sonic and Miles" background palette (also usually the primary palette line) Pal_EHZ: BINCLUDE "art/palettes/EHZ.bin" ; Emerald Hill Zone palette Pal_WZ: BINCLUDE "art/palettes/Wood Zone.bin" ; Wood Zone palette Pal_MTZ: BINCLUDE "art/palettes/MTZ.bin" ; Metropolis Zone palette Pal_WFZ: BINCLUDE "art/palettes/WFZ.bin" ; Wing Fortress Zone palette Pal_HTZ: BINCLUDE "art/palettes/HTZ.bin" ; Hill Top Zone palette Pal_HPZ: BINCLUDE "art/palettes/HPZ.bin" ; Hidden Palace Zone palette Pal_HPZ_U: BINCLUDE "art/palettes/HPZ underwater.bin" ; Hidden Palace Zone underwater palette Pal_OOZ: BINCLUDE "art/palettes/OOZ.bin" ; Oil Ocean Zone palette Pal_MCZ: BINCLUDE "art/palettes/MCZ.bin" ; Mystic Cave Zone palette Pal_CNZ: BINCLUDE "art/palettes/CNZ.bin" ; Casino Night Zone palette Pal_CPZ: BINCLUDE "art/palettes/CPZ.bin" ; Chemical Plant Zone palette Pal_CPZ_U: BINCLUDE "art/palettes/CPZ underwater.bin" ; Chemical Plant Zone underwater palette Pal_DEZ: BINCLUDE "art/palettes/DEZ.bin" ; Death Egg Zone palette Pal_ARZ: BINCLUDE "art/palettes/ARZ.bin" ; Aquatic Ruin Zone palette Pal_ARZ_U: BINCLUDE "art/palettes/ARZ underwater.bin" ; Aquatic Ruin Zone underwater palette Pal_SCZ: BINCLUDE "art/palettes/SCZ.bin" ; Sky Chase Zone palette Pal_UNK2: BINCLUDE "art/palettes/Unknown 2.bin" ; Unknown palette 2 Pal_UNK3: BINCLUDE "art/palettes/Unknown 3.bin" ; Unknown palette 3 Pal_OOZ_B: BINCLUDE "art/palettes/OOZ Boss.bin" ; Oil Ocean Zone boss palette Pal_Menu: BINCLUDE "art/palettes/Menu.bin" ; Menu palette Pal_SS: BINCLUDE "art/palettes/Special Stage Main.bin" ; Special Stage palette Pal_SS1: BINCLUDE "art/palettes/Special Stage 1.bin" ; Special Stage 1 palette Pal_SS2: BINCLUDE "art/palettes/Special Stage 2.bin" ; Special Stage 2 palette Pal_SS3: BINCLUDE "art/palettes/Special Stage 3.bin" ; Special Stage 3 palette Pal_SS4: BINCLUDE "art/palettes/Special Stage 4.bin" ; Special Stage 4 palette Pal_SS5: BINCLUDE "art/palettes/Special Stage 5.bin" ; Special Stage 5 palette Pal_SS6: BINCLUDE "art/palettes/Special Stage 6.bin" ; Special Stage 6 palette Pal_SS7: BINCLUDE "art/palettes/Special Stage 7.bin" ; Special Stage 7 palette Pal_UNK4: BINCLUDE "art/palettes/Special Stage 1 2p.bin" ; Special Stage 1 2p palette Pal_UNK5: BINCLUDE "art/palettes/Special Stage 2 2p.bin" ; Special Stage 2 2p palette Pal_UNK6: BINCLUDE "art/palettes/Special Stage 3 2p.bin" ; Special Stage 3 2p palette Pal_UNK7: BINCLUDE "art/palettes/Special Stage Results Screen.bin" ; Special Stage Results Screen palette </asm>

and replace it with: <asm> PalPointers: palptr Pal_SEGA, Normal_palette, $1F palptr Pal_Title, Normal_palette_line2, 7 palptr Pal_UNK1, Normal_palette, $1F palptr Pal_BGND, Normal_palette, $F palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_WZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_MTZ, Normal_palette_line2, $17 palptr Pal_MTZ, Normal_palette_line2, $17 palptr Pal_WFZ, Normal_palette_line2, $17 palptr Pal_HTZ, Normal_palette_line2, $17 palptr Pal_HPZ, Normal_palette_line2, $17 palptr Pal_EHZ, Normal_palette_line2, $17 palptr Pal_OOZ, Normal_palette_line2, $17 palptr Pal_MCZ, Normal_palette_line2, $17 palptr Pal_CNZ, Normal_palette_line2, $17 palptr Pal_CPZ, Normal_palette_line2, $17 palptr Pal_DEZ, Normal_palette_line2, $17 palptr Pal_ARZ, Normal_palette_line2, $17 palptr Pal_SCZ, Normal_palette_line2, $17 palptr Pal_HPZ_U, Normal_palette, $1F palptr Pal_CPZ_U, Normal_palette, $1F palptr Pal_ARZ_U, Normal_palette, $1F palptr Pal_SS, Normal_palette, $17 palptr Pal_UNK2, Normal_palette_line2, 7 palptr Pal_UNK3, Normal_palette_line2, 7 palptr Pal_SS1, Normal_palette_line4, 7 palptr Pal_SS2, Normal_palette_line4, 7 palptr Pal_SS3, Normal_palette_line4, 7 palptr Pal_SS4, Normal_palette_line4, 7 palptr Pal_SS5, Normal_palette_line4, 7 palptr Pal_SS6, Normal_palette_line4, 7 palptr Pal_SS7, Normal_palette_line4, 7 palptr Pal_UNK4, Normal_palette_line4, 7 palptr Pal_UNK5, Normal_palette_line4, 7 palptr Pal_UNK6, Normal_palette_line4, 7 palptr Pal_OOZ_B, Normal_palette_line2, 7 palptr Pal_Menu, Normal_palette, $1F palptr Pal_UNK7, Normal_palette, $1F palptr Pal_Lev11, Normal_palette_line2, $17 palptr Pal_Lev12, Normal_palette_line2, $17 palptr Pal_Lev13, Normal_palette_line2, $17 palptr Pal_Lev14, Normal_palette_line2, $17 palptr Pal_Lev15, Normal_palette_line2, $17 palptr Pal_Lev16, Normal_palette_line2, $17 palptr Pal_Lev17, Normal_palette_line2, $17 palptr Pal_Lev18, Normal_palette_line2, $17 palptr Pal_Lev19, Normal_palette_line2, $17 palptr Pal_Lev1A, Normal_palette_line2, $17 palptr Pal_Lev1B, Normal_palette_line2, $17 palptr Pal_Lev1C, Normal_palette_line2, $17 palptr Pal_Lev1D, Normal_palette_line2, $17 palptr Pal_Lev1E, Normal_palette_line2, $17 palptr Pal_Lev1F, Normal_palette_line2, $17 palptr Pal_Lev20, Normal_palette_line2, $17

----------------------------------------------------------------------------

Pal_SEGA: BINCLUDE "art/palettes/Sega screen.bin" ; SEGA screen palette (Sonic and initial background) Pal_Title: BINCLUDE "art/palettes/Title screen.bin" ; Title screen Palette Pal_UNK1: BINCLUDE "art/palettes/Unknown 1.bin" ; Unknown palette 1 (leftover S1 level select palette?) Pal_BGND: BINCLUDE "art/palettes/SonicAndTails.bin" ; "Sonic and Miles" background palette (also usually the primary palette line) Pal_EHZ: BINCLUDE "art/palettes/EHZ.bin" ; Emerald Hill Zone palette Pal_WZ: BINCLUDE "art/palettes/Wood Zone.bin" ; Wood Zone palette Pal_MTZ: BINCLUDE "art/palettes/MTZ.bin" ; Metropolis Zone palette Pal_WFZ: BINCLUDE "art/palettes/WFZ.bin" ; Wing Fortress Zone palette Pal_HTZ: BINCLUDE "art/palettes/HTZ.bin" ; Hill Top Zone palette Pal_HPZ: BINCLUDE "art/palettes/HPZ.bin" ; Hidden Palace Zone palette Pal_HPZ_U: BINCLUDE "art/palettes/HPZ underwater.bin" ; Hidden Palace Zone underwater palette Pal_OOZ: BINCLUDE "art/palettes/OOZ.bin" ; Oil Ocean Zone palette Pal_MCZ: BINCLUDE "art/palettes/MCZ.bin" ; Mystic Cave Zone palette Pal_CNZ: BINCLUDE "art/palettes/CNZ.bin" ; Casino Night Zone palette Pal_CPZ: BINCLUDE "art/palettes/CPZ.bin" ; Chemical Plant Zone palette Pal_CPZ_U: BINCLUDE "art/palettes/CPZ underwater.bin" ; Chemical Plant Zone underwater palette Pal_DEZ: BINCLUDE "art/palettes/DEZ.bin" ; Death Egg Zone palette Pal_ARZ: BINCLUDE "art/palettes/ARZ.bin" ; Aquatic Ruin Zone palette Pal_ARZ_U: BINCLUDE "art/palettes/ARZ underwater.bin" ; Aquatic Ruin Zone underwater palette Pal_SCZ: BINCLUDE "art/palettes/SCZ.bin" ; Sky Chase Zone palette Pal_Lev11: BINCLUDE "art/palettes/Lev11.bin" ; New Level palette Pal_Lev12: BINCLUDE "art/palettes/Lev12.bin" ; New Level palette Pal_Lev13: BINCLUDE "art/palettes/Lev13.bin" ; New Level palette Pal_Lev14: BINCLUDE "art/palettes/Lev14.bin" ; New Level palette Pal_Lev15: BINCLUDE "art/palettes/Lev15.bin" ; New Level palette Pal_Lev16: BINCLUDE "art/palettes/Lev16.bin" ; New Level palette Pal_Lev17: BINCLUDE "art/palettes/Lev17.bin" ; New Level palette Pal_Lev18: BINCLUDE "art/palettes/Lev18.bin" ; New Level palette Pal_Lev19: BINCLUDE "art/palettes/Lev19.bin" ; New Level palette Pal_Lev1A: BINCLUDE "art/palettes/Lev1A.bin" ; New Level palette Pal_Lev1B: BINCLUDE "art/palettes/Lev1B.bin" ; New Level palette Pal_Lev1C: BINCLUDE "art/palettes/Lev1C.bin" ; New Level palette Pal_Lev1D: BINCLUDE "art/palettes/Lev1D.bin" ; New Level palette Pal_Lev1E: BINCLUDE "art/palettes/Lev1E.bin" ; New Level palette Pal_Lev1F: BINCLUDE "art/palettes/Lev1F.bin" ; New Level palette Pal_Lev20: BINCLUDE "art/palettes/Lev20.bin" ; New Level palette Pal_UNK2: BINCLUDE "art/palettes/Unknown 2.bin" ; Unknown palette 2 Pal_UNK3: BINCLUDE "art/palettes/Unknown 3.bin" ; Unknown palette 3 Pal_OOZ_B: BINCLUDE "art/palettes/OOZ Boss.bin" ; Oil Ocean Zone boss palette Pal_Menu: BINCLUDE "art/palettes/Menu.bin" ; Menu palette Pal_SS: BINCLUDE "art/palettes/Special Stage Main.bin" ; Special Stage palette Pal_SS1: BINCLUDE "art/palettes/Special Stage 1.bin" ; Special Stage 1 palette Pal_SS2: BINCLUDE "art/palettes/Special Stage 2.bin" ; Special Stage 2 palette Pal_SS3: BINCLUDE "art/palettes/Special Stage 3.bin" ; Special Stage 3 palette Pal_SS4: BINCLUDE "art/palettes/Special Stage 4.bin" ; Special Stage 4 palette Pal_SS5: BINCLUDE "art/palettes/Special Stage 5.bin" ; Special Stage 5 palette Pal_SS6: BINCLUDE "art/palettes/Special Stage 6.bin" ; Special Stage 6 palette Pal_SS7: BINCLUDE "art/palettes/Special Stage 7.bin" ; Special Stage 7 palette Pal_UNK4: BINCLUDE "art/palettes/Special Stage 1 2p.bin" ; Special Stage 1 2p palette Pal_UNK5: BINCLUDE "art/palettes/Special Stage 2 2p.bin" ; Special Stage 2 2p palette Pal_UNK6: BINCLUDE "art/palettes/Special Stage 3 2p.bin" ; Special Stage 3 2p palette Pal_UNK7: BINCLUDE "art/palettes/Special Stage Results Screen.bin" ; Special Stage Results Screen palette </asm>

That inserts our new palettes, which we will be using when we start on the main level load block.

next we find: <asm>

loc_40AE

Level_GetBgm: tst.w (Demo_mode_flag).w bmi.s loc_4114 moveq #0,d0 move.b (Current_Zone).w,d0 lea MusicList(pc),a1 tst.w (Two_player_mode).w beq.s Level_PlayBgm lea MusicList2(pc),a1 </asm>

and replace it with: <asm>

loc_40AE

Level_GetBgm: tst.w (Demo_mode_flag).w bmi.s loc_4114 moveq #0,d0 move.b (Current_Zone).w,d0 lea MusicList(pc),a1 tst.w (Two_player_mode).w beq.s Level_PlayBgm jsr Level_2PlayerBGMList </asm>


now we want to find: <asm>

----------------------------------------------------------------------------
1P Music Playlist
----------------------------------------------------------------------------
byte_3EA0

MusicList: dc.b 2+$80 ; 0 ; EHZ dc.b 2+$80 ; 1 dc.b 5+$80 ; 2 dc.b 4+$80 ; 3 dc.b 5+$80 ; 4 ; MTZ1,2 dc.b 5+$80 ; 5 ; MTZ3 dc.b $F+$80 ; 6 ; WFZ dc.b 6+$80 ; 7 ; HTZ dc.b $10+$80 ; 8 dc.b $D+$80 ; 9 dc.b 4+$80 ; 10 ; OOZ dc.b $B+$80 ; 11 ; MCZ dc.b $9+$80 ; 12 ; CNZ dc.b $E+$80 ; 13 ; CPZ dc.b $A+$80 ; 14 ; DEZ dc.b 7+$80 ; 15 ; ARZ dc.b $D+$80 ; 16 ; SCZ dc.b 0 ; 17

----------------------------------------------------------------------------
2P Music Playlist
----------------------------------------------------------------------------
byte_3EB2

MusicList2: dc.b $C+$80 ; 0  ; EHZ 2P dc.b 2+$80 ; 1 dc.b 5+$80 ; 2 dc.b 4+$80 ; 3 dc.b 5+$80 ; 4 dc.b 5+$80 ; 5 dc.b $F+$80 ; 6 dc.b 6+$80 ; 7 dc.b $10+$80 ; 8 dc.b $D+$80 ; 9 dc.b 4+$80 ; 10 dc.b 3+$80 ; 11 ; MCZ 2P dc.b 8+$80 ; 12 ; CNZ 2P dc.b $E+$80 ; 13 dc.b $A+$80 ; 14 dc.b 7+$80 ; 15 dc.b $D+$80 ; 16 dc.b 0 ; 17 </asm>

and replace it with: <asm>

----------------------------------------------------------------------------
2P Music Playlist
----------------------------------------------------------------------------
byte_3EB2

MusicList2: dc.b $C+$80 ; 00  ; EHZ 2P dc.b 2+$80 ; 01 dc.b 5+$80 ; 02 dc.b 4+$80 ; 03 dc.b 5+$80 ; 04 dc.b 5+$80 ; 05 dc.b $F+$80 ; 06 dc.b 6+$80 ; 07 dc.b $10+$80 ; 08 dc.b $D+$80 ; 09 dc.b 4+$80 ; 0A dc.b 3+$80 ; 0B ; MCZ 2P dc.b 8+$80 ; 0C ; CNZ 2P dc.b $E+$80 ; 0D dc.b $A+$80 ; 0E dc.b 7+$80 ; 0F dc.b $D+$80 ; 10 dc.b 2+$80 ; 11 dc.b 2+$80 ; 12 dc.b 2+$80 ; 13 dc.b 2+$80 ; 14 dc.b 2+$80 ; 15 dc.b 2+$80 ; 16 dc.b 2+$80 ; 17 dc.b 2+$80 ; 18 dc.b 2+$80 ; 19 dc.b 2+$80 ; 1A dc.b 2+$80 ; 1B dc.b 2+$80 ; 1C dc.b 2+$80 ; 1D dc.b 2+$80 ; 1E dc.b 2+$80 ; 1F dc.b 2+$80 ; 20 dc.b 0

Level_2PlayerBGMList: lea MusicList2(pc),a1 rts

----------------------------------------------------------------------------
1P Music Playlist
----------------------------------------------------------------------------
byte_3EA0

MusicList: dc.b 2+$80 ; 00 ; EHZ dc.b 2+$80 ; 01 dc.b 5+$80 ; 02 dc.b 4+$80 ; 03 dc.b 5+$80 ; 04 ; MTZ1,2 dc.b 5+$80 ; 05 ; MTZ3 dc.b $F+$80 ; 06 ; WFZ dc.b 6+$80 ; 07 ; HTZ dc.b $10+$80 ; 08 dc.b $D+$80 ; 09 dc.b 4+$80 ; 0A ; OOZ dc.b $B+$80 ; 0B ; MCZ dc.b $9+$80 ; 0C; CNZ dc.b $E+$80 ; 0D ; CPZ dc.b $A+$80 ; 0E ; DEZ dc.b 7+$80 ; 0F ; ARZ dc.b $D+$80 ; 10 ; SCZ dc.b 2+$80 ; 11 dc.b 2+$80 ; 12 dc.b 2+$80 ; 13 dc.b 2+$80 ; 14 dc.b 2+$80 ; 15 dc.b 2+$80 ; 16 dc.b 2+$80 ; 17 dc.b 2+$80 ; 18 dc.b 2+$80 ; 19 dc.b 2+$80 ; 1A dc.b 2+$80 ; 1B dc.b 2+$80 ; 1C dc.b 2+$80 ; 1D dc.b 2+$80 ; 1E dc.b 2+$80 ; 1F dc.b 2+$80 ; 20 dc.b 0 </asm>

That updates our music list for both 2 player and 1 player modes, and fixes an error that sometimes occurs during the build process relating to somwthing not fitting in a signed byte, which can easily happen when you have a lot of added zones.

Before we go any further, I will note that if you tried to compile now, you would have some "jump distance too big" errors, lets fix them:

first, we will find: <asm> GameModesArray: ;; bra.w SegaScreen ; $00 SEGA screen mode bra.w TitleScreen ; $04 Title screen mode bra.w Level ; $08 Demo mode bra.w Level ; $0C Zone play mode bra.w SpecialStage ; $10 Special stage play mode bra.w ContinueScreen ; $14 Continue mode bra.w TwoPlayerResults ; $18 2P results mode bra.w LevelSelectMenu2P ; $1C 2P level select mode bra.w JmpTo_EndingSequence ; $20 End sequence mode bra.w OptionsMenu ; $24 Options mode bra.w LevelSelectMenu ; $28 Level select mode

===========================================================================

</asm>

and replace it with: <asm> GameModesArray: ;; bra.w SegaScreen ; $00 SEGA screen mode bra.w TitleScreen ; $04 Title screen mode bra.w Level ; $08 Demo mode bra.w Level ; $0C Zone play mode bra.w SpecialStage ; $10 Special stage play mode bra.w ContinueScreen ; $14 Continue mode bra.w Jmpto_TwoPlayerResults ; $18 2P results mode bra.w LevelSelectMenu2P ; $1C 2P level select mode bra.w JmpTo_EndingSequence ; $20 End sequence mode bra.w OptionsMenu ; $24 Options mode bra.w LevelSelectMenu ; $28 Level select mode

===========================================================================

Jmpto_TwoPlayerResults: jmp TwoPlayerResults </asm>

then we we will find: <asm> MenuScreen: bsr.w Pal_FadeFrom move #$2700,sr move.w ($FFFFF60C).w,d0 andi.b #-$41,d0 move.w d0,(VDP_control_port).l bsr.w ClearScreen lea (VDP_control_port).l,a6 move.w #$8004,(a6) move.w #$8230,(a6) move.w #$8407,(a6) move.w #$8230,(a6) move.w #$8700,(a6) move.w #$8C81,(a6) move.w #$9001,(a6) </asm>

we want to change it to: <asm> MenuScreen: bsr.w Pal_FadeFrom move #$2700,sr move.w ($FFFFF60C).w,d0 andi.b #-$41,d0 move.w d0,(VDP_control_port).l bsr.w JumpTo_ClearScreen lea (VDP_control_port).l,a6 move.w #$8004,(a6) move.w #$8230,(a6) move.w #$8407,(a6) move.w #$8230,(a6) move.w #$8700,(a6) move.w #$8C81,(a6) move.w #$9001,(a6) jmp Cont_MenuScreen

JumpTo_ClearScreen: jmp ClearScreen

Cont_MenuScreen: </asm>

now we want to locate: <asm> MenuScreen_LevelSelect: lea (Metablock_Table).l,a1 lea (MapEng_LevSel).l,a0 move.w #0,d0 bsr.w EniDec lea (Metablock_Table).l,a1 move.l #$40000003,d0 moveq #$27,d1 moveq #$1B,d2 bsr.w JmpTo_ShowVDPGraphics moveq #0,d3 bsr.w loc_965A lea ($FFFF08C0).l,a1 lea (MapEng_LevSelIcon).l,a0 move.w #$90,d0 bsr.w EniDec bsr.w loc_9688 clr.w (Player_mode).w clr.w (Results_Screen_2P).w clr.b (Level_started_flag).w clr.w ($FFFFF7F0).w lea (word_87C6).l,a2 bsr.w JmpTo2_Dynamic_Normal moveq #$26,d0 bsr.w PalLoad1 lea (Normal_palette_line3).w,a1 lea (Second_palette_line3).w,a2 moveq #7,d1 </asm>

and change it to: <asm> MenuScreen_LevelSelect: lea (Metablock_Table).l,a1 lea (MapEng_LevSel).l,a0 move.w #0,d0 bsr.w JumpTo_EniDec lea (Metablock_Table).l,a1 move.l #$40000003,d0 moveq #$27,d1 moveq #$1B,d2 bsr.w JmpTo_ShowVDPGraphics moveq #0,d3 bsr.w loc_965A lea ($FFFF08C0).l,a1 lea (MapEng_LevSelIcon).l,a0 move.w #$90,d0 bsr.w JumpTo_EniDec bsr.w loc_9688 clr.w (Player_mode).w clr.w (Results_Screen_2P).w clr.b (Level_started_flag).w clr.w ($FFFFF7F0).w lea (word_87C6).l,a2 bsr.w JmpTo2_Dynamic_Normal moveq #$26,d0 bsr.w PalLoad1 lea (Normal_palette_line3).w,a1 lea (Second_palette_line3).w,a2 moveq #7,d1 jmp loc_9366

JumpTo_EniDec: jmp EniDec </asm>

next we want to find: <asm> sub_9EF4: tst.b ($FFFFF660).w beq.w return_A0BE bsr.w Pal_FadeFrom lea (VDP_control_port).l,a6 move.w #$8004,(a6) move.w #$8230,(a6) move.w #$8407,(a6) move.w #$9001,(a6) move.w #$9200,(a6) move.w #$8B03,(a6) move.w #$8700,(a6) clr.b (Water_move).w move.w #$8C81,(a6) bsr.w JmpTo_ClearScreen </asm>

and change it to: <asm> JmpTo_Pal_FadeFrom: jmp Pal_FadeFrom

sub_9EF4: tst.b ($FFFFF660).w beq.w return_A0BE bsr.w JmpTo_Pal_FadeFrom lea (VDP_control_port).l,a6 move.w #$8004,(a6) move.w #$8230,(a6) move.w #$8407,(a6) move.w #$9001,(a6) move.w #$9200,(a6) move.w #$8B03,(a6) move.w #$8700,(a6) clr.b (Water_move).w move.w #$8C81,(a6) bsr.w JmpTo_ClearScreen </asm>

now we want to find: <asm> loc_9FE6: bsr.w JmpTo_ClearScreen bsr.w sub_B262 bsr.w Pal_FadeTo move.w #$18E,d0 btst #6,(Graphics_Flags).w beq.s loc_A002 move.w #$144,d0 </asm>

and change it to: <asm> loc_9FE6: bsr.w JmpTo_ClearScreen bsr.w sub_B262 bsr.w JmpTo_Pal_FadeTo move.w #$18E,d0 btst #6,(Graphics_Flags).w beq.s loc_A002 move.w #$144,d0 jmp loc_A002

JmpTo_Pal_FadeTo: jmp Pal_FadeTo </asm>

now we want to find: <asm> loc_A002: move.b #$18,(Delay_Time).w bsr.w DelayProgram dbf d0,loc_A002 bsr.w Pal_FadeFrom lea (off_B2CA).l,a1 addq.w #1,($FFFFFF4C).w move.w ($FFFFFF4C).w,d0 lsl.w #2,d0 move.l (a1,d0.w),d0 bpl.s loc_9FE6 bsr.w Pal_FadeFrom bsr.w JmpTo_ClearScreen </asm>

and we want to to change it to: <asm> loc_A002: move.b #$18,(Delay_Time).w bsr.w DelayProgram dbf d0,loc_A002 bsr.w JmpTo_Pal_FadeFrom lea (off_B2CA).l,a1 addq.w #1,($FFFFFF4C).w move.w ($FFFFFF4C).w,d0 lsl.w #2,d0 move.l (a1,d0.w),d0 bpl.s loc_9FE6 bsr.w JmpTo_Pal_FadeFrom bsr.w JmpTo_ClearScreen </asm>

now we find: <asm> bcs.s Obj17_Main moveq #0,d6

loc_10372

Obj17_MakeHelix: bsr.w SingleObjLoad2 </asm>

and change it to: <asm> bcs.s JumpTo_Obj17_Main moveq #0,d6 jmp Obj17_MakeHelix

JumpTo_Obj17_Main: jmp Obj17_Main JumpTo_SingleObjLoad2: jmp SingleObjLoad2

loc_10372

Obj17_MakeHelix: bsr.w JumpTo_SingleObjLoad2 </asm>

after that, your rom will build correctly, but we are not done yet with the extending...