Some changes and fixes for Sonic 2

Discussion in 'Engineering & Reverse Engineering' started by Esrael, Jun 7, 2012.

  1. Alex Field

    Alex Field

    シュート! カオス・エメラルド・ザが消えようとしている! Member
    174
    108
    43
    Downunda, Mobius
    Sonic the Hedgehog 2+, Sonic the Hedgehog 3+
    Make sense, although I do have another scrolling bug; for whatever reason, going backwards in certain levels (Death Egg or even Hidden Palace if you restored it) causes parts of the background to disappear. Even stranger, it doesn't happen to HPZ in the prototypes.
     
  2. Clownacy

    Clownacy

    Tech Member
    888
    175
    43
    It's been a long time since I looked into that, but I believe that the solution was to make the background repeat all the way to the right end of the layout file. Levels like Mystic Cave Zone do this, presumably for its single-player variant which uses dynamic background loading. If I remember right, the Sonic 1 level layout format avoids the need for this for some reason. I'll look into this issue when I get a chance.

    EDIT: Oooooh, I get it: Sonic 1's layout loading code was modified in Sonic 2's prototypes to specifically repeat the layouts to fill the full width of the level. This means that the game automatically repeated the game's backgrounds, and whatever tool Alex Field used to convert Hidden Palace Zone's layout failed to recreate this behaviour, likely because it was emulating Sonic 1's behaviour instead.
     
    Last edited: Apr 25, 2022
  3. Alex Field

    Alex Field

    シュート! カオス・エメラルド・ザが消えようとしている! Member
    174
    108
    43
    Downunda, Mobius
    Sonic the Hedgehog 2+, Sonic the Hedgehog 3+
    I do remember seeing that (mainly when converting HPZ to the final format; trying to extend its background is a nightmare); there's also one last bug, the worst of them all.

    ...

    Sonic's arm not appearing fast enough on the title screen.
     
  4. Clownacy

    Clownacy

    Tech Member
    888
    175
    43
    That appears to be a weird prototype leftover in Sonic's animation script: at the end of 'byte_1368E', there's a reference to sprite 8, which is just an incomplete duplicate of sprite $12, which Sonic is set to when his arm spawns. Because this duplicate sprite is here, it creates an extra frame before Sonic's arm appears where he's using the sprite that should be used after the arms appears. Not only that, but because this earlier frame is incomplete, Sonic ends up missing *both* of his arms during this frame.

    EDIT: Speaking of buggy sprites: sprite 5 appears to be one pixel too high, causing Sonic's lower half to be visibly cut-off for a few frames.
     
    Last edited: Apr 22, 2022
  5. Alex Field

    Alex Field

    シュート! カオス・エメラルド・ザが消えようとしている! Member
    174
    108
    43
    Downunda, Mobius
    Sonic the Hedgehog 2+, Sonic the Hedgehog 3+
    Not sure what they were going to do there, unless they were going to make a sprite with both the body AND the face.

    Also, I might've already mentioned this, but the Obj0E never sets Tails' priority during the intro, meaning a few pixels of his hair (fur?) gets covered by Sonic (yet the priority IS set when skipping it...).
     
  6. Alex Field

    Alex Field

    シュート! カオス・エメラルド・ザが消えようとしている! Member
    174
    108
    43
    Downunda, Mobius
    Sonic the Hedgehog 2+, Sonic the Hedgehog 3+
    I used LevelConverter; should probably tell MainMemory to fix it.
     
  7. Clownacy

    Clownacy

    Tech Member
    888
    175
    43
    Here's a blink-and-you-miss-it bug: the Egg Prison sprite is incomplete: sprites 1 and 2 have their 'total sprite pieces' value set too low, causing part of the sprite to not appear:
    Vanilla:
    upload_2022-5-3_22-22-7.png
    Fixed:
    upload_2022-5-3_22-22-39.png
    To fix this, hex-edit the file 'mappings/sprite/obj3E.bin' so that bytes $47 and $89 are 08 instead of 07.

    Issues like this suggest that the mappings were written in assembly (likely macros): they weren't machine-produced binary files like they are in the disassemblies. Other indicators of this are Obj63's mappings, whose frames aren't sorted from first to last, and the unfinished mappings of Marble Zone's sideway spike pistons in Sonic 1, which have a similar bug to this one.
     
    Last edited: May 3, 2022
    • Informative Informative x 8
    • Like Like x 2
    • List
  8. Brainulator

    Brainulator

    Regular garden-variety member Member
    They were indeed written in assembly, whether by hand or by a program; the Sonic 2 Nick Arcade prototype's symbol lists contain names for both the mapping table (suffixed with "pat", as in "pattern") and the mappings themselves (suffixed with "sp" and then the frame number). I've considered requesting that the Sonic 2 disassembly shift to ASM mappings for this reason.
     
    • Informative Informative x 3
    • List
  9. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,603
    198
    43
    SonLVL
    I wouldn't really consider this a bug? The program is just converting the data that is in the file. I guess I could add a hack for LevelConverter with S2NA layouts.
     
  10. DeltaWooloo

    DeltaWooloo

    Be a boss-man and come to my big and tall man shop Member
    Quick question: has anyone managed to figure out the issue caused by this bug and a fix for it? When Sonic spin-dashes off a see-saw in Hill Top Zone, the spindash isn't cleared, and he spin-dashes when on-ground.

    blastem_20220516_213218.png

    So, logically, you should be able to clear the spindash flag before Sonic springs up. First, I tried finding a proper fix here, which did not work. Then, I tried reproducing the same bug in Sonic 1 and tinkered around with its see-saw object to see if I could fit it, but no dice.
     
  11. nineko

    nineko

    I am the Holy Cat Tech Member
    6,100
    338
    63
    italy
    The best part about that bug is that something similar still happens in Ice Cap Zone, so Sega never fixed it.

    I've seen many hacks (of both Sonic 1 and Sonic 2) which fix it, though. Puto even fixed it in my hack.
     
  12. DeltaWooloo

    DeltaWooloo

    Be a boss-man and come to my big and tall man shop Member
    Indeed quite many Sonic 1 hacks fix this issue. But the way it's handled is by clearing the spindash in mid-air, even though Sonic 2 retains your spindash if you perform it while a platform collapses. So it feels like a feature rather than a bug since you don't lose the spindash, and the way the SCHG guide documents it fixes the see-saw bug but doesn't fix the bug as mentioned earlier/feature Sonic 2 has.
     
  13. Clownacy

    Clownacy

    Tech Member
    888
    175
    43
    I fixed it in my Fine2uned hack by adding 'clr.b spindash_flag(a2)' to the start of 'Obj14_LaunchCharacter'.
     
    • Like Like x 1
    • Informative Informative x 1
    • List
  14. Hitaxas

    Hitaxas

    Retro 80's themed Twich streamer Member
    Here is a change to something that some may consider a bug, but is actually more like an oversight.

    When Sonic jumps and lands from the jump while holding down, for one frame, he is in his walking animation. This is something that also happens in Sonic 1, Sonic 3 and Sonic & Knuckles.

    As a visual example:
    https://twitter.com/SonicPhysics/status/1385881293406318596

    This is quite easy to fix/change.

    Navigate to


    Code (Text):
    1. Sonic_ResetOnFloor:


    As you can see, in all of the code for Sonic to reset on the floor, he is always set to walk.
    The code for him to roll on the ground is only initiated after this reset, and therefore he is briefly put into the walk animation.

    To resolve this, we need to add a new supplementary subroutine.

    Under the aforementioned label, under the branch to


    Code (Text):
    1. Sonic_ResetOnFloor_Part3

    And before the line that sets his walk animation

    add this directional input check


    Code (Text):
    1.     btst    #1,(Ctrl_1_Held_Logical).w            ; is down being pressed?
    2.     bne.w    Sonic_ResetOnFloor_ContRolling        ; if yes, branch    

    After this, head to the bottom of


    Code (Text):
    1. Sonic_ResetOnFloor_Part3

    And add


    Code (Text):
    1. bra.w    return_1B11E

    Now, after the end of Sonic_ResetOnFloor_Part3,
    and before the label for return_1B11E, add this chunk of code


    Code (Text):
    1.  
    2. ;=====================================================================================================================
    3. ; (Hitaxas) Fix for awful uncurling frame when a character lands on the ground from a jump
    4. ; or if they walked off an object or edge of a floor while holding down.
    5. ; this "bug" is present in S1-S3K.
    6. ;=====================================================================================================================
    7. Sonic_ResetOnFloor_ContRolling:
    8.     move.b  #AniIDSonAni_Roll,anim(a0)      ; play rolling animation
    9.  
    10. ;---------------------------------------------------------------------------------------------------------------------
    11. ; check if character was already rolling, used for instances where they roll off one floor to land on another
    12. ;---------------------------------------------------------------------------------------------------------------------
    13.     btst    #2,status(a0)                   ; was status set to rolling?
    14.     beq.w   Sonic_ResetOnFloor_Part3        ; if it was, branch
    15.  
    16. ;---------------------------------------------------------------------------------------------------------------------
    17. ; force character into rolling status, and play sound.
    18. ;---------------------------------------------------------------------------------------------------------------------
    19.     bset    #2,status(a0)                   ; otherwise, set roll status
    20.     move.b  #$E,y_radius(a0)                ; adjust character's y_radius
    21.     move.b  #7,x_radius(a0)                 ; same for x_radius
    22.     addq.w  #5,$C(a0)                       ; move character 5 pixels down, so they aren't floating
    23.     move.w  #SndID_Roll,d0
    24.     jsr     (PlaySound).l                   ; play rolling sound - required because this is not part of the normal roll code                        
    25.  
    26. ;---------------------------------------------------------------------------------------------------------------------
    27. ; clear status flags and act like a true reset on floor. This is nearly identical to part 3
    28. ; but without forcing character into walking animation.
    29. ;---------------------------------------------------------------------------------------------------------------------  
    30.     bclr    #1,status(a0)                   ; clear in air status
    31.     bclr    #5,status(a0)                   ; clear pushing status
    32.     bclr    #4,status(a0)                   ; clear rolljump status
    33.     move.b  #0,jumping(a0)                  ; clear jumping flag
    34.     move.w  #0,(Chain_Bonus_counter).w
    35.     move.b  #0,flip_angle(a0)
    36.     move.b  #0,flips_remaining(a0)
    37.     move.w  #0,(Sonic_Look_delay_counter).w
    38.  
    The final results should look like so:

    [​IMG]