Damage Death Boundary Bug at the top of the level in Sonic 1

Discussion in 'Discussion & Q&A' started by Miles Sebas Prower, Sep 2, 2023.

  1. Miles Sebas Prower

    Miles Sebas Prower Newcomer Member

    Joined:
    Aug 22, 2023
    Messages:
    21
    Location:
    Alvarenga, Charallave
    Okay, so, I was just doing some bug fixes for my Sonic 1 rom hack Sonic 1 Fixed Version (A Sonic 1 rom hack based off the 2013 release/mobile version of Sonic 1), when I got to checking out some bugs related to the level boundary, I selected SLZ Act 1 because it's where I could check out some bugs related to it, I had a ring and took damage from the badnik at the top of the level and it was then that I noticed another bug related to level boundaries, besides Sonic disappearing, and what I need to fix is a bug where if you take damage at the top of the level (Mostly noticeable in SLZ Act 1), you will drop the rings as usual, or lose the shield if you have it, but if you were to bounce to the top of the level after taking damage, the game kills you as if you reached to the bottom of the level even tho you're at the top of the level. Does anyone know why this happens and how this can be fixed, so that the game won't think you reached the bottom of the level when you're at the top?
    For it, I'm specifically using the Hivebrain 2005 disassembly
     
    Last edited: Sep 2, 2023
  2. JGamer2151

    JGamer2151 Well-Known Member/Lurker Member

    Joined:
    Dec 1, 2020
    Messages:
    96
    Miles Sebas Prower likes this.
  3. Miles Sebas Prower

    Miles Sebas Prower Newcomer Member

    Joined:
    Aug 22, 2023
    Messages:
    21
    Location:
    Alvarenga, Charallave
    I used the guide already, but the other bug that has to do with level boundaries isn't that, the other bug related to it is that if you have at least a ring, and you happen to take damage at the top of the level (Mostly noticeable in SLZ Act 1), you will lose the rings and drop them as usual, but if you are to bounce to the top of the level in the hurt state after taking damage, the game is going to kill you, as if you fell to the bottom of the level even tho you are at the top of the level. That's the bug related to level boundaries
     
  4. Miles Sebas Prower

    Miles Sebas Prower Newcomer Member

    Joined:
    Aug 22, 2023
    Messages:
    21
    Location:
    Alvarenga, Charallave
    Sorry for what just happened, poor signal in where I am
     
  5. Devon

    Devon I'm a loser, baby, so why don't you kill me? Member

    Joined:
    Aug 26, 2013
    Messages:
    1,377
    Location:
    your mom
    The problem lies here in Sonic_HurtStop:
    Code:
    Sonic_HurtStop:
            move.w    ($FFFFF72E).w,d0
            addi.w    #$E0,d0
            cmp.w    $C(a0),d0
            bcs.w    KillSonic
    It checks if Sonic's Y position is below the stage's bottom boundary, except that it uses an unsigned branch, which means that it only understands positive numbers. If Sonic's Y position were to go negative, it would be interpreted as a large number (i.e. -1 is $FFFF, signed numbers work by basically assigning the latter half of the number range to be negative numbers so $8000 to $FFFF is -$8000 to -1 for 16 bit values), which is technically below the bottom boundary according to that branch, so Sonic dies.

    To fix this, change the bcs to a blt, which is basically the signed version of that branch, where the negative number range is seen as negative instead of larger numbers.
     
    Last edited: Sep 4, 2023
    ProjectFM likes this.
  6. Devon

    Devon I'm a loser, baby, so why don't you kill me? Member

    Joined:
    Aug 26, 2013
    Messages:
    1,377
    Location:
    your mom
    (It's not your internet connection, the server seems to be shitting itself a bit)
     
    Miles Sebas Prower likes this.
  7. JGamer2151

    JGamer2151 Well-Known Member/Lurker Member

    Joined:
    Dec 1, 2020
    Messages:
    96
    Ah yes, this is exactly what I was thinking about a while back, albeit it was based on the older 2005 Hivebrain one wherein the instruction used bcc instead of bcs, and the way how it was fixed that way was to use bge or bpl instructions instead. However, this was decades ago, and a lot of things changed since then.

    I have this exact same problem about a week ago when I was trying to post a reply on this site, and after the website loaded properly I accidentally posted three more of the same post than I should’ve have. I sure hope those accidental posts gets moved to the trash soon…

    And yes, I think it might be the server's problem on that…
     
  8. Devon

    Devon I'm a loser, baby, so why don't you kill me? Member

    Joined:
    Aug 26, 2013
    Messages:
    1,377
    Location:
    your mom
    The instruction never changed in the newer disassembly, and in fact the code I posted was from the 2005 disassembly. The guide you posted was for a different issue where Sonic when he's in his death animation (hence why the fix is applied in GameOver and not Sonic_HurtStop) disappears if he gets bounced past the top of the stage due to a similar unsigned branch issue. The issue that Miles Sebas Prower was talking about has to do with Sonic when he's merely hurt.
     
  9. Miles Sebas Prower

    Miles Sebas Prower Newcomer Member

    Joined:
    Aug 22, 2023
    Messages:
    21
    Location:
    Alvarenga, Charallave
    Yes, that's the issue I was meaning by that and by what I said, also, I got the issue fixed, thanks
     
  10. JGamer2151

    JGamer2151 Well-Known Member/Lurker Member

    Joined:
    Dec 1, 2020
    Messages:
    96
    Sorry about that. I was a bit confused.
     
  11. Miles Sebas Prower

    Miles Sebas Prower Newcomer Member

    Joined:
    Aug 22, 2023
    Messages:
    21
    Location:
    Alvarenga, Charallave
    It's fine, I'm sure you were confused at the beginning and mistook it for the bug that makes Sonic disappear if he bounces to the top in his death animation, since we all make mistakes
     
    JGamer2151 likes this.