Actions

SCHG How-to

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.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Spin Dash Code and Add Spin Dash Speeds | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Add beta spindash to Sonic 2 | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs