Actions

SCHG How-to

Difference between revisions of "Extend the level index past $10 in Sonic 2"

From Sonic Retro

Line 270: Line 270:
 
dc.w $4606,$2604,$4804,$FFFF
 
dc.w $4606,$2604,$4804,$FFFF
 
</asm>
 
</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.

Revision as of 06:18, 29 April 2008

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, $18, $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>

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.