Multiple boss fixes in sonic 2

Discussion in 'Tutorials Archive' started by redhotsonic, Jun 9, 2012.

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

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Before people tell me off for the multiple posts in-a-row, I asked OrdosAlpha first, and he said it's okay to do so.


    Boss index


    For Esrael's orginal 3 bug fixes to boss, and to view my better alternative solution, and for story, read on!


    For 4 other CNZ boss bug fixes, Click here!


    For CPZ boss bug fix, and for a laugh, Click here!


    For ARZ boss Eggman-laugh bug fix, Click here!


    Over at SonicRetro, Esrael posted a fix for a glitch to 3 bosses. ARZ's hammer, MCZ's drill, and CNZ's catcher. If all these bosses are facing left, there's no problem. If the bosses are facing right, the pieces fall off incorrectly. Esrael has kindly demonstrated with pictures here.


    [​IMG]


    [​IMG]


    [​IMG].


    Esrael showed people how to make them fall off properly, like his hack, Delta, is demonstrating. His fixes worked, but I posted and showed everyone a shorter and quicker way to fix it. I then went a bit bug-happy and showed everyone a lot of fixes for multiple boss bugs. I'm now about to show everyone here at SSRG. There's 9 in total!


    Just in case, here is Esrael's orignial post, in case you want to see how he did it:






    Here's my fixes.


    ARZ boss


    Change all this:



    loc_30850:
    cmpi.w #$78,($FFFFF75C).w


    bgt.s return_3088A


    subi.w #1,y_radius(a0)


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1



    To this:



    loc_30850:
    cmpi.w #$78,($FFFFF75C).w


    bgt.s return_3088A


    subi.w #1,y_radius(a0) ; Make hammer fall to the left


    btst #0,render_flags(a0) ; Is Eggman facing left?


    beq.s + ; Yes? Branch and continue


    addi.w #2,y_radius(a0) ; So he's facing right? Make hammer fall to the right instead


    +


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1



    Done


    MCZ boss


    Change all this:



    loc_31358:
    cmpi.w #$78,($FFFFF75C).w


    bgt.s return_313C4


    subi.w #1,status(a0)


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1


    addi.w #$38,objoff_2E(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_3A(a0)


    move.w objoff_3A(a0),routine(a0)


    cmpi.w #$6F0,routine(a0)


    blt.s loc_31392


    move.w #0,objoff_2E(a0)


    loc_31392:


    addi.w #1,x_vel(a0)


    move.l objoff_34(a0),d0


    move.w objoff_30(a0),d1


    addi.w #$38,objoff_30(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_34(a0)


    move.w objoff_34(a0),y_vel(a0)


    cmpi.w #$6F0,y_vel(a0)


    blt.s return_313C4


    move.w #0,objoff_30(a0)


    return_313C4:


    rts



    To this:



    loc_31358:
    cmpi.w #$78,($FFFFF75C).w


    bgt.w return_313C4


    subi.w #1,status(a0) ; Make drill face to the left


    btst #0,render_flags(a0) ; Is Eggman facing left?


    beq.s + ; Yes? Branch and continue


    addi.w #2,status(a0) ; So he's facing right? Make drill face to the right instead


    +


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1


    addi.w #$38,objoff_2E(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_3A(a0)


    move.w objoff_3A(a0),routine(a0)


    cmpi.w #$6F0,routine(a0)


    blt.s loc_31392


    move.w #0,objoff_2E(a0)


    loc_31392:


    addi.w #1,x_vel(a0) ; Make drill fall to the left


    btst #0,render_flags(a0) ; Is Eggman facing left?


    beq.s + ; Yes? Branch and continue


    subi.w #2,x_vel(a0) ; So he's facing right? Make drill fall to the right instead


    +


    move.l objoff_34(a0),d0


    move.w objoff_30(a0),d1


    addi.w #$38,objoff_30(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_34(a0)


    move.w objoff_34(a0),y_vel(a0)


    cmpi.w #$6F0,y_vel(a0)


    blt.s return_313C4


    move.w #0,objoff_30(a0)


    return_313C4:


    rts



    Done


    CNZ boss


    Change all this:



    loc_31EAE:
    cmpi.w #$78,($FFFFF75C).w


    bgt.s return_31F22


    subi.w #1,status(a0)


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1


    addi.w #$38,objoff_2E(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_3A(a0)


    move.w objoff_3A(a0),routine(a0)


    cmpi.w #$6F0,routine(a0)


    blt.s loc_31EE8


    move.w #0,objoff_2E(a0)


    loc_31EE8:


    cmpi.w #$3C,($FFFFF75C).w


    bgt.s return_31F22


    addi.w #1,x_vel(a0)


    move.l objoff_34(a0),d0


    move.w objoff_30(a0),d1


    addi.w #$38,objoff_30(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_34(a0)


    move.w objoff_34(a0),y_vel(a0)


    cmpi.w #$6F0,y_vel(a0)


    blt.s return_31F22


    move.w #0,objoff_30(a0)


    return_31F22:


    rts



    To this:



    loc_31EAE:
    cmpi.w #$78,($FFFFF75C).w


    bgt.w return_31F22


    subi.w #1,status(a0) ; Make catcher face to the left


    btst #0,render_flags(a0) ; Is Eggman facing left?


    beq.s + ; Yes? Branch and continue


    addi.w #2,status(a0) ; So he's facing right? Make catcher face to the right instead


    +


    move.l objoff_3A(a0),d0


    move.w objoff_2E(a0),d1


    addi.w #$38,objoff_2E(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_3A(a0)


    move.w objoff_3A(a0),routine(a0)


    cmpi.w #$6F0,routine(a0)


    blt.s loc_31EE8


    move.w #0,objoff_2E(a0)


    loc_31EE8:


    cmpi.w #$3C,($FFFFF75C).w


    bgt.s return_31F22


    addi.w #1,x_vel(a0) ; Make catcher fall to the left


    btst #0,render_flags(a0) ; Is Eggman facing left?


    beq.s + ; Yes? Branch and continue


    subi.w #2,x_vel(a0) ; So he's facing right? Make catcher fall to the right instead


    +


    move.l objoff_34(a0),d0


    move.w objoff_30(a0),d1


    addi.w #$38,objoff_30(a0)


    ext.l d1


    asl.l #8,d1


    add.l d1,d0


    move.l d0,objoff_34(a0)


    move.w objoff_34(a0),y_vel(a0)


    cmpi.w #$6F0,y_vel(a0)


    blt.s return_31F22


    move.w #0,objoff_30(a0)


    return_31F22:


    rts



    Done


    Read on the rest of my posts, or use the index above, to see more fixes to more bugs.


    EDIT: Added index as couldn't before until I made the posts.
     
    Last edited by a moderator: Jun 9, 2012
  2. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Another 4 CNZ boss BUG


    As we're on fixing boss bugs, ever noticed the other 4 bugs on CNZ's boss? If not, read on. The very first hit on the CNZ boss, it will NEVER make the boss-hit sound. Also, you know Eggman normally shows his hurt face when you hit him? The very first hit, he delays showing his hurt face (about 2 seconds later after the first hit). Also, during his first hit, he will flash a lot longer, and until he stops flashing, you cannot hit him again!


    So, that's the 4 bugs, all happening on the first hit:

    • Never plays boss hit sound
    • Eggman's hurt face delayed
    • Eggman flashes a hell of a lot longer
    • Because he flashes a lot longer, you cannot hit a second time for a while




    The rest of the hits, he's fine though. To solve all these bugs, the fix is EXTREMELY simple =P


    Go to "loc_31904:". You should see this near the middle of the coding:



    move.b #$80,objoff_14(a0)



    Delete it.


    There, done.


    Explaination


    objoff_14 is part of the countdown timer. Normally, this timer is at 0. When you hit Eggman, the countdown timer is set to $30, then starts counting down. Whilst it's counting down, Eggman will flash. You cannot hit him whilst flashing (that's not a bug). At "loc_31CDC", it tests objoff_14 for 0. If not equal, it will branch away. NORMALLY, when you hit Eggman, as soon as you hit him, it will set objoff_14 to $30, play the sound and display Eggman's hurt face, and then countdown from $30. But because at "loc_31904" where Eggman is being created, it has set this timer to $80. So on the first hit, it's got a lot to countdown (until it reaches 0). Because of this, he flashes for AGES. And because of this, you cannot hit him a second time for a while. Because it's $80, it cannot branch to the playsound and set objoff_14 to $30. Eventually, it's counted down to 0, then he's fine the rest of the time.


    At "loc_31C92", it compares the objoff_14 at $2F. If so, branch to display Eggman's hurt face. On the first hit, because it's counting down from $80, it takes ages to $2F, and that's why Eggman has a delay on showing his hurt face on the first hit.


    Because we've deleted the command, objoff_14 is already set at 0. So, it is ready for action. So now, on the first hit, he will now play the sound and set the timer to $30, he will display his hurt face immediately (because it's only a byte away), and because it's counting down from $30, he will not flash as long, and you can get back to hitting him quicker. All 4 bugs, fixed!


    Why the hell did they set objoff_14 to $80 when being created in the first place, I have no idea.


    This may help you on your hack =)


    Cheers,


    redhotsonic
     
    Last edited by a moderator: Jun 9, 2012
  3. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    CPZ boss bug


    As many of you are aware, during the CPZ boss, when Eggman drops the blue gunge on you, if you are "ducking" you cannot get hurt, making it too easy to avoid Eggman's attacks.


    [​IMG]


    Sonic unhurt from gunge


    To fix this so you will get hurt whilst ducking, follow this.


    Go to "loc_2E692:" and you'll see this:



    loc_2E692:
    addq.b #2,routine_secondary(a0)


    move.b #$20,y_radius(a0)


    move.b #$19,anim(a0)


    move.w #0,y_vel(a0)


    movea.l objoff_34(a0),a1 ; a1=object


    movea.l $34(a1),a1


    btst #2,$2D(a1)


    beq.s loc_2E6CA


    bclr #2,$2D(a1)


    move.b #6,routine_secondary(a0)


    move.w #9,objoff_2A(a0)



    See that command?



    move.b #$20,y_radius(a0)



    Change #$20 to #$16. So you have this in the end:



    loc_2E692:
    addq.b #2,routine_secondary(a0)


    move.b #$16,y_radius(a0)


    move.b #$19,anim(a0)


    move.w #0,y_vel(a0)


    movea.l objoff_34(a0),a1 ; a1=object


    movea.l $34(a1),a1


    btst #2,$2D(a1)


    beq.s loc_2E6CA


    bclr #2,$2D(a1)


    move.b #6,routine_secondary(a0)


    move.w #9,objoff_2A(a0)



    Done


    Explanation


    The gunge's y_radius is #$20. This is fine normally. But when Sonic "ducks", Sonic's y_radius is "shortened". So, now, when the gunge is falling and hits the ground, it actually doesn't touch Sonic.


    Because we have "lowered" the gunge's y_radius, it's distance from the floor has grown just a little bit. Because of this, the gunge now falls down, just a little bit more, and because of this, it will now hit Sonic when he's "ducking". And it will still hurt Sonic in any other position also.


    Something Cool for CPZ boss!


    THIS IS JUST FOR LAUGHS, but I thought I'd share it anyway! Back at the label "loc_2E692:". See these two lines?



    btst #2,$2D(a1)
    beq.s loc_2E6CA



    Comment them out! And everytime Eggman drops the gunge, this will happen!


    [​IMG]


    Well, I found it funny =P
     
  4. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    ARZ boss bug


    [​IMG]


    With this boss, as soon as you're hurt, Eggman won't laugh instantly. Instead, he waits for you to hit the ground, then he laughs. Same goes for Tails. All the other boss, Eggman laughs instantly. So let's fix this.


    Go to "loc_30770:" (part of the ARZ boss code) and you'll see this:



    loc_30770:
    lea ($FFFFF740).w,a1


    move.b #$31,3(a1)


    loc_3077A:



    Under the "move.b #$31,3(a1)", insert this line:



    move.b #1,objoff_36(a0) ; move 1 to checker



    So you have something like this:



    loc_30770:
    lea ($FFFFF740).w,a1


    move.b #$31,3(a1)


    move.b #1,objoff_36(a0) ; move 1 to checker


    loc_3077A:



    Next, go to "loc_3075C:" and you'll see this:



    loc_3075C:
    bsr.w loc_3078E


    cmpi.b #4,(MainCharacter+routine).w


    beq.s loc_30770


    cmpi.b #4,(Sidekick+routine).w


    bne.s loc_3077A



    After the "bsr.w loc_3078E" command, insert these two lines:



    tst.b objoff_36(a0) ; Is checker 0?
    bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state



    So you have something like this:



    loc_3075C:
    bsr.w loc_3078E


    tst.b objoff_36(a0) ; Is checker 0?


    bne.s loc_3077A ; If not, branch and do not check for Sonic/Tails hurt state


    cmpi.b #4,(MainCharacter+routine).w


    beq.s loc_30770


    cmpi.b #4,(Sidekick+routine).w


    bne.s loc_3077A



    Next, go to "return_3078C:" and you'll see this:



    return_3078C:
    rts



    Change it to this:



    return_3078C:
    cmpi.b #$17,($FFFFF743).w ; Has Eggman stopped laughing?


    bne.s + ; If not, branch


    clr.b objoff_36(a0) ; If so, clear checker, so Eggman can check to see if Sonic/Tails are hurt again


    +


    rts



    Done


    [​IMG]


    Explanation


    Most of you have probably noticed that Eggman didn't laugh instantly. BUT, did any of you notice that when hurt, Eggman's animation is actually frozen? Yup, that's right. Normally, his mustache is moving (due to wind I guess), but as soon as you're hurt, his mustache isn't moving anymore. He's frozen and until you hit the ground, he will remain that way. When you've hit the ground, he will then laugh, then carry on with his normal animations.


    It's important to know, for this boss, the animations are working another way rather than they normally do. instead of "anim" being set, $FFFFF743 (or $FFFFF740+3) is being set. This RAM adress counts down every frame, to make Eggman animate. Every odd number dispalys one part of his anim, and every even number displays another part of his anim. His mustache for instance. Every odd number displays 1 part and every even displays another, making his mustache move.


    Anyway, the reason for Eggman's animation freezing is because when Sonic/Tails gets hurt, their routine is set to 4 (hurt routine). Eggman checks this, and if hurt, move $31 to his animation. But at this moment in time, the RAM address CANNOT countdown. It tries to, but it can't. The reason why, is because as Sonic and tails are hurt, until they land on the floor, their routine will stay at 4. Because Eggman is continuously seeing them at routine 4, it constantly writes $31 to $FFFFF743. That's why the RAM cannot countdown. And because it's constantly at $31, it's only able to display one part of his animation, and that's why Eggman's anim is frozen.


    As soon as Sonic/Tails lands, their routine is set back to normal. Eggman now stops writing $31 to $FFFFF743, letting the RAM address able to countdown, now displaying his laugh animation.


    So, what have we done to fix this? We've added a new check using objoff_36(a0) (not used in ARZ boss so it's free to use). As soon as Sonic/Tails gets hurt, it now moves #1 to objoff_36(a0). We've added a check before the Sonic/Tails hurt check. If objoff_36(a0) is now equals 1, to branch away from the hurt check, leaving $FFFFF743 free to countdown. Eggman now displays his laugh instantly.


    After Eggman's laugh, $FFFFF743 is set back to $17 and counts down again (Eggman's normal animation). We've done one more check to see if $FFFFF743 equals $17 and if so, to clear objoff_36(a0). Now that objoff_36(a0) is now 0 again, Eggman can now check to see when Sonic/Tails gets hurt again, and laugh when so.


    Everything is fine once again!


    Long explanation, eh? =P


    redhotsonic
     
  5. EMK-20218

    EMK-20218 The Fuss Maker Exiled

    Joined:
    Aug 8, 2008
    Messages:
    1,067
    Location:
    Jardim Capelinha, São Paulo
    Man, I'm really impressed with the recent guides of Sonic 2 you're posting actually. These looks really magic! Also magic would be the CPZ boss liquid on his face everytime he fails on attacking. This is a thing which could be really fun to see working. My dream will be finally realized. Thank you very much for these guides!
     
Thread Status:
Not open for further replies.