Extend the water tables in Sonic 2
From Sonic Retro
(Original guide by Dani)
If you have tried to add water to a zone ID between $00 and $07, you may have noticed strange effects with the water, such as the entire level filling with water or no water showing up at all (only the water line). To correct this problem, several changes need to be done to your disassembly. (This guide will use the Xenowhirl 2007 Sonic 2 disassembly; other disassemblies may vary.)
Xenowhirl's 2007 disassembly
First, find the section marked loc_402C and find the following line:
subi.w #$800,d0
and either comment it out or delete it entirely.
Next, locate the following:
WaterHeight:
dc.w $600, $600, $600, $600
dc.w $600, $600, $600, $600
dc.w $600, $600, $600, $710
dc.w $600, $600, $410, $510
and change it to:
WaterHeight:
dc.w $600, $600; EHZ
dc.w $600, $600; Zone 01
dc.w $600, $600; WZ
dc.w $600, $600; Zone 03
dc.w $600, $600; MZ
dc.w $600, $600; MZ3
dc.w $600, $600; WFZ
dc.w $600, $600; HTZ
dc.w $600, $600; HPZ
dc.w $600, $600; Zone 09
dc.w $600, $600; OOZ
dc.w $600, $600; MCZ
dc.w $600, $600; CNZ
dc.w $600, $710; CPZ
dc.w $600, $600; DEZ
dc.w $410, $510; ARZ
dc.w $600, $600; SCZ
Next, in the section marked DynamicWater, locate the following line:
subi.w #$800,d0
and either comment it out or delete it entirely.
Next, locate this section:
Dynamic_water_routine_table:
dc.w DynamicWaterNull - Dynamic_water_routine_table; 0
dc.w DynamicWaterNull - Dynamic_water_routine_table; 1
dc.w DynamicWaterNull - Dynamic_water_routine_table; 2
dc.w DynamicWaterNull - Dynamic_water_routine_table; 3
dc.w DynamicWaterNull - Dynamic_water_routine_table; 4
dc.w DynamicWaterNull - Dynamic_water_routine_table; 5
dc.w DynamicWaterNull - Dynamic_water_routine_table; 6
dc.w DynamicWaterNull - Dynamic_water_routine_table; 7
dc.w DynamicWaterNull - Dynamic_water_routine_table; 8
dc.w DynamicWaterNull - Dynamic_water_routine_table; 9
dc.w DynamicWaterNull - Dynamic_water_routine_table; 10
dc.w DynamicWaterCPZ2 - Dynamic_water_routine_table; 11 ; the only one that does anything
dc.w DynamicWaterNull - Dynamic_water_routine_table; 12
dc.w DynamicWaterNull - Dynamic_water_routine_table; 13
dc.w DynamicWaterNull - Dynamic_water_routine_table; 14
dc.w DynamicWaterNull - Dynamic_water_routine_table; 15
and replace the section with:
Dynamic_water_routine_table:
dc.w DynamicWaterNull - Dynamic_water_routine_table; EHZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; EHZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; 01-1
dc.w DynamicWaterNull - Dynamic_water_routine_table; 01-2
dc.w DynamicWaterNull - Dynamic_water_routine_table; WZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; WZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; 03-1
dc.w DynamicWaterNull - Dynamic_water_routine_table; 03-2
dc.w DynamicWaterNull - Dynamic_water_routine_table; MZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; MZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; MZ3
dc.w DynamicWaterNull - Dynamic_water_routine_table; 05-2
dc.w DynamicWaterNull - Dynamic_water_routine_table; WFZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; WFZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; HTZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; HTZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; HPZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; HPZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; 09-1
dc.w DynamicWaterNull - Dynamic_water_routine_table; 09-2
dc.w DynamicWaterNull - Dynamic_water_routine_table; OOZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; OOZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; MCZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; MCZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; CNZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; CNZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; CPZ1
dc.w DynamicWaterCPZ2 - Dynamic_water_routine_table; CPZ2 ; the only one that does anything
dc.w DynamicWaterNull - Dynamic_water_routine_table; DEZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; DEZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; ARZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; ARZ2
dc.w DynamicWaterNull - Dynamic_water_routine_table; SCZ1
dc.w DynamicWaterNull - Dynamic_water_routine_table; SCZ2
Once these changes have been made, you will be able to add water to any zone in Sonic the Hedgehog 2. If you run into any problems, please let me know and/or get it working and edit this article.
Hg disassembly
Near the top of s2.asm, you should see the following:
useFullWaterTables = 0
; | If 1, zone offset tables for water levels cover all level slots instead of only slots 8-$F
; | Set to 1 if you've shifted level IDs around or you want water in levels with a level slot below 8
Simply change the 0 to 1 and you're done. You can then use the WaterHeight table inbetween the lines "if useFullWaterTables" and "else", which has slots for all the levels.
|Extend the water tables in Sonic 2]]