How to Fix the Sonic 2 Continue Cheat Bug

Discussion in 'Tutorials Archive' started by Pacca, May 27, 2015.

Thread Status:
Not open for further replies.
  1. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Sonic 2 has a cheat code which gives you a ridiculous amount of continues (it's activated by playing, 01, 01, 02, 04 on the options menu). It has a serious flaw, though; using it sends an invalid command to the sound driver, resulting in it playing Oil Ocean Zones theme constantly, with no sound effects. This can only be stopped by restarting the emulator/console itself, make you lose those wonderful continues in the process. Similar buggy effects will occur here, even if you port a new driver (on the Clone Driver V2, activating the glitch causes the entire game to freeze; this likely applies to any Sonic 1 driver port, including the old clone driver and an unmodified S1 driver port). This means that the bug isn't actually the drivers fault. So lets fix it!

    In the Github disassembly, go to "CheckCheats:". you should see something like this a little ways below the label:

    ; The next line causes the bug where the OOZ music plays until reset.
    ; Remove "&$7F" to fix the bug.
    move.b #SndID_ContinueJingle&$7F,d0 ; Play the continue jingle
    jsrto (PlayMusic).l, JmpTo_PlayMusic

    Do what the comments say here, and the bug will be fixed.

    In the Xenowhirl Disassembly, go to "loc_9746:" . You should see something like this a little ways below the label.

    move.b #$F,(Continue_count).w
    move.b #$3F,d0
    bsr.w JmpTo_PlayMusic
    bra.s loc_97AA

    Change the "3" in "#$3F" to a "B", and the bug will be gone.

    Why does the bug exist at all, you might ask? Well, the Sonic 2 sound driver expects the sound effects to be the values from the sound test +$80. This means that if you wanted to play sound 1, you actually need to send the sound driver $81 for it to work (1+$80). The issue here is that they forgot to add $80 to the continue sound, so loading it results in the Sound driver breaking, as it was not built to except values in this range, and the value simply doesn't apply to a normal song, effect, or driver command (driver commands are things like the Sega Sound and the Speed Shoes effect). Because of this, unexpected things occur, and the Sonic 2 driver suddenly crashes and fails to except new sound commands, all the while playing Oil Ocean Zones theme (not sure why it's that one in particular).

    EDIT: It seems that Oil Oceans theme is the Song you select to play in the cheat immediately before activating the glitch; this is probably way glitch makes it play that song in particular.
     
    Last edited: Jan 13, 2016
  2. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    To undo your confusion on why it plays OOZ's music, it's because the normal command to play it is performed, and then the crashing of the SoundDriver's updating ability.

    (In case you didn't notice, "01, 01, 02, 04" ends in 04, and 04 is Oil Ocean Zone's music.)
     
     
  3. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I found that out independently, actually; I added it moments before you posted :p
     
  4. Niko

    Niko All's well that ends well, right? Member

    Joined:
    Mar 1, 2014
    Messages:
    245
    Location:
    $C800
    Not so sure about that..
    You "Edited 8 minutes ago by Pacguy64."
    And I "Posted 11 minutes ago."
     
  5. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    I was writing it as you posted :p
     
Thread Status:
Not open for further replies.