don't click here

Utility Sonic 2 - Simon Wai Disassembly

Discussion in 'Engineering & Reverse Engineering' started by Alex Field, May 21, 2022.

  1. Current Post (as of November 2022):
    A heavily modified version of Esrael's famous 2007 disassembly, with the following features and enhancements.
    • Converted to AS, allowing for more accurate building and AS-exclusive features.*
    • Sonic 2 Final-styled GitHub organization, labeling, constants and macros.
    • As of December 3, 2022, ALL levels in the game (barring empty pits) can be fully edited in SonLVL with the provided INI files, including all of their unique objects.
    • Disassembled sound driver and music (still needs documentation, and sound effects will need to be split so they won't break when shifted around).
    • A WIP Wiki, including information for hexadecimal level editing if you can't or (for whatever reason) don't want to use SonLVL.
    Download here!

    *OrionNavattan, who fixed errors from the conversion to AS, stated that a bit-perfect ROM currently isn't possible due to how the music and sound driver are split, as well as padding weirdness; however, everything up to $4EC6C is bit-perfect, so there shouldn't be any difference in gameplay.
    Original Post (May 2022):
    So, the last major disassembly of Sonic 2 Simon Wai was by SuperEgg and Nayr in 2012, and that version had several accuracy issues; the only accurate one was from Esrael, and that was from c. 2007.

    So why not post it to GitHub, port it to AS and update it?

    It's still a work-in-progress, however several objects and routines have been relabeled/tabbed, and some mappings split. The ROM itself still isn't identical, however the only differences come down to small byte differences, which itself is weirdness caused by the assembler (presumably) automatically enabling zero-offset optimization.

    Might as well mention some of the interesting things this prototype has:
    • The compression used for Green Hill Zone's chunks in the Nick Arcade build, and also Kid Chameleon is still present, albeit unused; I've decided to dub it "Chameleon Compression". It is another variation of the LZSS algorithm, and uses extreme unrolling to achieve fast decompression speeds.
    • Obj03 (path swappers) are coded in an... interesting way, using a table to determine which character is passing by it instead of the "lea" method.
    • The sound driver is already compressed with Saxman, but the music isn't; this confirms that the 68k version is the original, while the Z80-variant is a port.
    • The bizarre object in Slot $0F is also still present, and has the same effects; interestingly, the RAM address it changes was changed from $FFE9 to $FFD9.
    For some of the features it has:
    • Updated labels and variable names to be consistent with Sonic 2 Github.
    • SonLVL support; currently fully supports GHZ, HTZ and WZ (which has no unique objects... or objects at all), and partially supports MTZ.
    • Z80 sound driver disassembled (thanks, SuperEgg!).
     
    Last edited: Dec 3, 2022
  2. It has been... several months since I've done ROM hacking due to personal issues, but hopefully I can start at least semi-regular work on this disassembly again; since it'll still be a few days until the next update, I'm gonna share some weirdness this build has that I don't see documented elsewhere:
    • Casino Night Zone Act 2 is specifically programmed to use a different palette from the first act, and in fact the entry it uses in the palette table was actually meant for Blue Lake/Ocean Zone (although that stage likely never entered actual production); this, combined with Act 2 having a different background earlier in development (as proven by the earlier build chunk data) suggests that CNZ was meant to be similar to Scrap Brain Zone from the first game in terms of divergence.
    • For some reason, between the title screen and level game modes is a chunk of development code; the first part is similar to loadZoneBlockMaps but with the registers reversed, while the rest converts Sonic 1's layout data to Sonic 2's format; the latter code is present here as well below loadLevelLayouts, and even in the final game, completely untouched and abandoned.
    • Speaking of loadZoneBlockMaps, the code to handle loading chunks in the "Chameleon compression" (named so since the only other game it was used in was Kid Chameleon, being another LZSS fork), used for Sonic 1's Green Hill in the Nick Arcade prototype is still present, along with the compression itself. Rather than remove it, it (alongside code to load blocks in Enigma format much like the first game) is simply skipped over with a branch command. Even funnier, it gets skipped over by ANOTHER unused function, which instead loads the chunks uncompressed (as they were in Nick Arcade, unlike here and final where they are Kosinski compressed).
    • Saxman compression is used for the sound driver in this build, but the music itself is uncompressed, confirming the compression was first programmed on the 68000 and then ported to the Z80 later.
     
    • Informative Informative x 1
    • List
  3. saxman

    saxman

    Oldbie Tech Member
    I like when people dig into these games and point out interesting tidbits. But I am confused on two points:

    * How are you sure that palette was intended for Ocean Lake? It would be better to use the zone ID since that zone clearly doesn't exist (unlike Wood Zone and Hidden Palace, which both existed; or even Genocide City since it has a level select entry we can rely on). But also, I have no idea which ID you're indicating.

    * I was pretty sure the music in all the early builds of Sonic 2 was Z80-based. Am I mistaken?

    As a side note, if I named the Kid Chameleon compression today, I might be tempted to name it STI compression (though I don't know if it actually made its way into other STI games or not). In the past, I think I leaned toward "Kid" compression, but never actually came out and called it that publicly.
     
    Last edited: Oct 7, 2023
  4. Music is Z80-based in all builds (excluding Nick Arcade since that still used the Sonic 1 driver), however the music is completely uncompressed in this build, while the final game uses Saxman compression most of the time (with exceptions like the credits theme). Sorry if it was a bit hard to understand.

    As for the Ocean Lake thing, really it depends on if you think the zone was ever reserved for it, as the music choice clearly suggests it was not meant for Sky Fortress at this point despite its' music existing by now. I actually asked Yamaguchi some time ago on stages like Ocean Wind, and he stated that some stages never made it past the concept phase.

    EDIT: Forgot to mention, but zone ID 06 uses the palette that CNZ2 loads; I am under the belief that zone IDs in the Simon Wai build were created when the 18 zone plan was still a thing, and that they simply created the blank IDs for when stages got properly implemented.
     
    Last edited: Oct 7, 2023
    • Informative Informative x 1
    • List