Some changes and fixes for Sonic 2

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

  1. Esrael

    Esrael

    Tech Member
    187
    0
    0
    Brazil, São Paulo, Guarulhos
    Neto Assembler Editor / Sonic 2 Delta / Neto Boot Loader
    Sorry if was done before, but I don't find it in forums.

    If you pay attention after defeating some bosses in Sonic 2 you will notice some strange things.
    I am not good in explanations. But look in to pictures to understand what I am saying.


    Edit:
    When the boss is defeated, it falls apart. If it is facing left, it falls apart properly. However, if it is facing the other way, the pieces still fall as if it was facing the other way. This behaviour is obviously wrong. The following code checks which way he is facing, and properly calls for the right routine so that he falls apart properly!
    Thanks to Irixion for better explanation:

    Using Sonic 2 Delta for comparisons.

    (All codes translated to use with Xenowhirl, 2007 version.)

    [​IMG]
    ARZ Boss:
    Find:
    Code (ASM):
    1.  
    2. loc_30850:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_3088A
    5.     subi.w  #1,y_radius(a0)    ; <----------
    6.     move.l  objoff_3A(a0),d0
    7.     move.w  objoff_2E(a0),d1
    8.  
    Make the following changes:

    Code (ASM):
    1.  
    2. loc_30850:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_3088A
    5.     bsr     NGHz_Boss_Fix_EjectHammer ; subi.w  #1,y_radius(a0)    ; <----------
    6.     move.l  objoff_3A(a0),d0
    7.     move.w  objoff_2E(a0),d1
    8.         ....
    9. return_3088A:
    10.     rts
    11. ;===============================================================================                
    12. NGHz_Boss_Fix_EjectHammer:  ; Esrael L. G. Neto Rotina para corrigir o bug ao ejetar o martelo  
    13.                 btst    #$00, $0001(A0)
    14.                 bne.s   NGHz_Boss_Fix_EjectHammer_Mirror                                               
    15.                 subi.w  #$0001, $0016(A0)       ; Ejeta o Martelo
    16.                 rts
    17. NGHz_Boss_Fix_EjectHammer_Mirror:
    18.                 addi.w  #$0001, $0016(A0)       ; Ejeta o Martelo                          
    19.                 rts
    20. ;===============================================================================    
    21.  
    [​IMG]

    MCz Boss

    Find:
    Code (ASM):
    1.  
    2. loc_31358:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_313C4
    5.     subi.w  #1,status(a0)  <------------
    6.  
    7.         ....
    8.  
    9. loc_31392:
    10.     addi.w  #1,x_vel(a0)   <------------
    11.     move.l  objoff_34(a0),d0
    12.  
    13.  
    Make the following changes:

    Code (ASM):
    1.  
    2. loc_31358:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_313C4
    5.     bsr     MCz_Boss_Fix_EjectDrill ; subi.w    #1,status(a0)  <------------
    6.  
    7.        ....
    8.  
    9. loc_31392:
    10.     bsr     MCz_Boss_Fix_EjectDrill ; addi.w    #1,x_vel(a0)   <------------
    11.     move.l  objoff_34(a0),d0
    12.         ......
    13. return_313C4:
    14.         rts  
    15. ;===============================================================================                
    16. MCz_Boss_Fix_EjectDrill:  ; Esrael L. G. Neto Rotina para corrigir o bug ao ejetar as blocas  
    17.                 btst    #$00, $0001(A0)
    18.                 bne.s   MCz_Boss_Fix_EjectDrill_Mirror                                             
    19.                 addi.w  #$0001, $0010(A0)       ; Ejeta a bloca da frente da Nave
    20.                 subi.w  #$0001, $0022(A0)       ; Ejeta a bloca de trás da Nave
    21.                 rts
    22. MCz_Boss_Fix_EjectDrill_Mirror:
    23.                 subi.w  #$0001, $0010(A0)       ; Ejeta a bloca da frente da Nave
    24.                 addi.w  #$0001, $0022(A0)       ; Ejeta a bloca de trás da Nave                        
    25.                 rts
    26. ;===============================================================================    
    27.  
    [​IMG]

    CNz Boss

    Find:
    Code (ASM):
    1.  
    2. loc_31EAE:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_31F22
    5.     subi.w  #1,status(a0)  ; <------------------
    6.     move.l  objoff_3A(a0),d0
    7.         ....
    8. loc_31EE8:
    9.     cmpi.w  #$3C,($FFFFF75C).w
    10.     bgt.s   return_31F22
    11.     addi.w  #1,x_vel(a0)    ; <--------------
    12.     move.l  objoff_34(a0),d0
    13.  
    Make the following changes:

    Code (ASM):
    1.  
    2. loc_31EAE:
    3.     cmpi.w  #$78,($FFFFF75C).w
    4.     bgt.s   return_31F22
    5.     bsr.s   Obj51_Fix_Eject_Left_Catcher ; subi.w   #1,status(a0)  ; <------------------
    6.     move.l  objoff_3A(a0),d0
    7.         ....
    8. loc_31EE8:
    9.     cmpi.w  #$3C,($FFFFF75C).w
    10.     bgt.s   return_31F22
    11.     bsr.s   Obj51_Fix_Eject_Right_Catcher ; addi.w  #1,x_vel(a0)    ; <--------------
    12.     move.l  objoff_34(a0),d0
    13.         .....
    14. return_31F22:
    15.     rts
    16.  
    17. ;===============================================================================
    18. ; Eject Catcher Fix                                   Added by Esrael L. G. Neto
    19. ; [ Begin ]
    20. ;===============================================================================
    21. Obj51_Fix_Eject_Left_Catcher:
    22.                 btst    #$00, $0001(A0)
    23.                 bne.s   Obj51_Eject_Left_Catcher_Mirror
    24.                 subi.w  #$0001, $0022(a0)       ; Eject Left Catcher From Ship
    25.                 rts
    26. Obj51_Eject_Left_Catcher_Mirror:
    27.                 addi.w  #$0001, $0022(a0)       ; Eject Left Catcher From Ship
    28.                 rts    
    29.  
    30. Obj51_Fix_Eject_Right_Catcher:
    31.                 btst    #$00, $0001(A0)
    32.                 bne.s   Obj51_Eject_Right_Catcher_Mirror
    33.                 addi.w  #$0001, $0010(A0)       ; Eject Right Catcher From Ship
    34.                 rts
    35. Obj51_Eject_Right_Catcher_Mirror:
    36.                 subi.w  #$0001, $0010(A0)       ; Eject Right Catcher From Ship
    37.                 rts        
    38. ;===============================================================================                
    39. ; Eject Catcher Fix                                   Added by Esrael L. G. Neto
    40. ; [ End ]
    41. ;===============================================================================
    42.  




    Debug Crash if you try placing an object after you death the game will Crash

    In debug routine find this block:

    Code (ASM):
    1.  
    2. loc_41C12:
    3.     btst    #5,(Ctrl_1_Press).w
    4.     beq.s   loc_41C56
    5.     jsr (SingleObjLoad).l
    6.  

    And insert the following code:

    Code (ASM):
    1.  
    2. loc_41C12:
    3.     btst    #5,(Ctrl_1_Press).w
    4.     beq.s   loc_41C56
    5. ;----------------------------------------------------
    6.     ; Debug crash fix ; Neto - Sonic 2D
    7.     cmpi.b  #$06, ($FFFFB024).w  
    8.     bne.s   Player_Ok                              
    9.     rts                                          
    10. Player_Ok:                
    11. ;---------------------------------------------------                                   
    12.     jsr (SingleObjLoad).l
    13.  

    Edit: asm tags
    Edit: 28/05/2019 - Fixed broken links

    Best regards:
    ----------------------
    Neto.
     
  2. Nicely done! :o I never noticed this until you brought it up.


    Edit: Thought I'd whip an en explanation that you can paste into your post.


    When the boss is defeated, it falls apart. If it is facing left, it falls apart properly. However, if it is facing the other way, the pieces still fall as if it was facing the other way. This behaviour is obviously wrong. The following code checks which way he is facing, and properly calls for the right routine so that he falls apart properly!
     
  3. Uberham

    Uberham

    King Of Oblivion Member
    I like the crossover drills :(
     
  4. Someone with wiki skills ought to put this on SCHG. Boggles my mind how I never noticed this @[email protected]
     
  5. KingofHarts

    KingofHarts

    Member
    1,618
    0
    16
    Project Sonic 8x16
    I wont be able to until tomorrow, but I can do it.
    Provided it isn't already done by then...

    I remember Esreal pointing this out in his Delta hack thread, and I thought he meant something else entirely... I feel stupid now. LOL
     
  6. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,584
    0
    16
    United Kingdom
    YouTuber
    I see you're joining me on the bug hunting =P

    Except for the ARZ boss bug, I've fixed all these already. Nice find and will apply the ARZ bug today. Cheers for that, mate.


    For ARZ boss bug, keep reading this post.
    For MCZ boss and 5 CNZ boss bugs, click here
    For CPZ boss bug, click here




    EDIT: Looking at your ARZ boss fix, I will say, there is another "quicker" and "shorter" way to fix the ARZ boss bug. This can be followed for the other bosses as well. It's just quicker on the processor rather than it branching to a subroutine and such. Just thought I'd let you know about it in case.



    Change:

    Code (ASM):
    1. loc_30850:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.s   return_3088A
    4.     subi.w  #1,y_radius(a0)
    5.     move.l  objoff_3A(a0),d0
    6.     move.w  objoff_2E(a0),d1

    To this:


    Code (ASM):
    1. loc_30850:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.s   return_3088A
    4.     subi.w  #1,y_radius(a0)     ; Make hammer fall to the left
    5.     btst    #0,render_flags(a0) ; Is Eggman facing left?
    6.     beq.s   +           ; Yes?  Branch and continue
    7.     addi.w  #2,y_radius(a0)     ; So he's facing right?  Make hammer fall to the right instead
    8. +
    9.     move.l  objoff_3A(a0),d0
    10.     move.w  objoff_2E(a0),d1


    This works also, and it's just quicker and it save space as it doesn't have to contain a subroutine. You can do something similar to this with the other bosses.
     
  7. Esrael

    Esrael

    Tech Member
    187
    0
    0
    Brazil, São Paulo, Guarulhos
    Neto Assembler Editor / Sonic 2 Delta / Neto Boot Loader

    Thanks, Is possible to optimize all codes, but I Make these to show new code separated from original.
    And I make translation of Sonic 2 Delta codes since I am using revision 2 of Sonic 2.
    I use the following code in Sonic 2 Delta for ARz Boss:


    (Original Sonic 2 rev 2 code with fix in Sonic 2 Delta)
    Code (ASM):
    1.  
    2. Offset_0x03036E:
    3.                 cmpi.w  #$0078, ($FFFFF75C).w
    4.                 bgt.s   Offset_0x0303A6
    5.               ; subq.w  #$01, $0016(A0)
    6. ;===============================================================================
    7. ; Faz com que o martelo seja ejetado para fora independente da direção da nave
    8. ; [ Início ]                                                   ; Neto - Sonic 2D
    9. ;===============================================================================    
    10.                 btst    #$00, $0001(A0)
    11.                 bne.s   ARz_Boss_Fix_EjectHammer_Mirror                                            
    12.                 subq.w  #$0001, $0016(A0)       ; Ejeta o Martelo
    13.                 bra.s   ARz_Boss_Fix_EjectHammer_Exit
    14. ARz_Boss_Fix_EjectHammer_Mirror:
    15.                 addq.w  #$0001, $0016(A0)       ; Ejeta o Martelo                          
    16. ARz_Boss_Fix_EjectHammer_Exit:                  
    17. ;===============================================================================
    18. ; Faz com que o martelo seja ejetado para fora independente da direção da nave
    19. ; [ Término ]                                                  ; Neto - Sonic 2D
    20. ;===============================================================================            
    21.                 move.l  $003A(A0), D0
    22.                 move.w  $002E(A0), D1
    23.  
    I can't find your links to other fixes.
     
  8. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,584
    0
    16
    United Kingdom
    YouTuber
    Either way is good. Just saying the way I did it will be quicker and will save you some ROM space (okay, hardly much space, but every little helps, right? =P )


    You couldn't find my other fixes, because I hadn't posted them. I was saying that to do it my way for MCZ and CNZ boss, just follow the same principle I showed you for ARZ boss. But I'll post them here now if you like =)




    MCZ boss


    Change all this:

    Code (ASM):
    1. loc_31358:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.s   return_313C4
    4.     subi.w  #1,status(a0)
    5.     move.l  objoff_3A(a0),d0
    6.     move.w  objoff_2E(a0),d1
    7.     addi.w  #$38,objoff_2E(a0)
    8.     ext.l   d1
    9.     asl.l   #8,d1
    10.     add.l   d1,d0
    11.     move.l  d0,objoff_3A(a0)
    12.     move.w  objoff_3A(a0),routine(a0)
    13.     cmpi.w  #$6F0,routine(a0)
    14.     blt.s   loc_31392
    15.     move.w  #0,objoff_2E(a0)
    16.  
    17. loc_31392:
    18.     addi.w  #1,x_vel(a0)
    19.     move.l  objoff_34(a0),d0
    20.     move.w  objoff_30(a0),d1
    21.     addi.w  #$38,objoff_30(a0)
    22.     ext.l   d1
    23.     asl.l   #8,d1
    24.     add.l   d1,d0
    25.     move.l  d0,objoff_34(a0)
    26.     move.w  objoff_34(a0),y_vel(a0)
    27.     cmpi.w  #$6F0,y_vel(a0)
    28.     blt.s   return_313C4
    29.     move.w  #0,objoff_30(a0)
    30.  
    31. return_313C4:
    32.     rts

    To this:

    Code (ASM):
    1. loc_31358:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.w   return_313C4
    4.     subi.w  #1,status(a0)       ; Make drill face to the left
    5.         btst    #0,render_flags(a0)     ; Is Eggman facing left?
    6.         beq.s   +                       ; Yes?  Branch and continue
    7.         addi.w  #2,status(a0)       ; So he's facing right?  Make drill face to the right instead
    8. +
    9.     move.l  objoff_3A(a0),d0
    10.     move.w  objoff_2E(a0),d1
    11.     addi.w  #$38,objoff_2E(a0)
    12.     ext.l   d1
    13.     asl.l   #8,d1
    14.     add.l   d1,d0
    15.     move.l  d0,objoff_3A(a0)
    16.     move.w  objoff_3A(a0),routine(a0)
    17.     cmpi.w  #$6F0,routine(a0)
    18.     blt.s   loc_31392
    19.     move.w  #0,objoff_2E(a0)
    20.  
    21. loc_31392:
    22.     addi.w  #1,x_vel(a0)        ; Make drill fall to the left
    23.         btst    #0,render_flags(a0)     ; Is Eggman facing left?
    24.         beq.s   +                       ; Yes?  Branch and continue
    25.         subi.w  #2,x_vel(a0)        ; So he's facing right?  Make drill fall to the right instead
    26. +
    27.     move.l  objoff_34(a0),d0
    28.     move.w  objoff_30(a0),d1
    29.     addi.w  #$38,objoff_30(a0)
    30.     ext.l   d1
    31.     asl.l   #8,d1
    32.     add.l   d1,d0
    33.     move.l  d0,objoff_34(a0)
    34.     move.w  objoff_34(a0),y_vel(a0)
    35.     cmpi.w  #$6F0,y_vel(a0)
    36.     blt.s   return_313C4
    37.     move.w  #0,objoff_30(a0)
    38.  
    39. return_313C4:
    40.     rts
    Done




    CNZ boss


    Change all this:

    Code (ASM):
    1. loc_31EAE:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.s   return_31F22
    4.     subi.w  #1,status(a0)
    5.     move.l  objoff_3A(a0),d0
    6.     move.w  objoff_2E(a0),d1
    7.     addi.w  #$38,objoff_2E(a0)
    8.     ext.l   d1
    9.     asl.l   #8,d1
    10.     add.l   d1,d0
    11.     move.l  d0,objoff_3A(a0)
    12.     move.w  objoff_3A(a0),routine(a0)
    13.     cmpi.w  #$6F0,routine(a0)
    14.     blt.s   loc_31EE8
    15.     move.w  #0,objoff_2E(a0)
    16.  
    17. loc_31EE8:
    18.     cmpi.w  #$3C,($FFFFF75C).w
    19.     bgt.s   return_31F22
    20.     addi.w  #1,x_vel(a0)
    21.     move.l  objoff_34(a0),d0
    22.     move.w  objoff_30(a0),d1
    23.     addi.w  #$38,objoff_30(a0)
    24.     ext.l   d1
    25.     asl.l   #8,d1
    26.     add.l   d1,d0
    27.     move.l  d0,objoff_34(a0)
    28.     move.w  objoff_34(a0),y_vel(a0)
    29.     cmpi.w  #$6F0,y_vel(a0)
    30.     blt.s   return_31F22
    31.     move.w  #0,objoff_30(a0)
    32.  
    33. return_31F22:
    34.     rts

    To this:

    Code (ASM):
    1. loc_31EAE:
    2.     cmpi.w  #$78,($FFFFF75C).w
    3.     bgt.w   return_31F22
    4.     subi.w  #1,status(a0)       ; Make catcher face to the left
    5.         btst    #0,render_flags(a0)     ; Is Eggman facing left?
    6.         beq.s   +                       ; Yes?  Branch and continue
    7.         addi.w  #2,status(a0)       ; So he's facing right?  Make catcher face to the right instead
    8. +
    9.     move.l  objoff_3A(a0),d0
    10.     move.w  objoff_2E(a0),d1
    11.     addi.w  #$38,objoff_2E(a0)
    12.     ext.l   d1
    13.     asl.l   #8,d1
    14.     add.l   d1,d0
    15.     move.l  d0,objoff_3A(a0)
    16.     move.w  objoff_3A(a0),routine(a0)
    17.     cmpi.w  #$6F0,routine(a0)
    18.     blt.s   loc_31EE8
    19.     move.w  #0,objoff_2E(a0)
    20.  
    21. loc_31EE8:
    22.     cmpi.w  #$3C,($FFFFF75C).w
    23.     bgt.s   return_31F22
    24.     addi.w  #1,x_vel(a0)        ; Make catcher fall to the left
    25.         btst    #0,render_flags(a0)     ; Is Eggman facing left?
    26.         beq.s   +                       ; Yes?  Branch and continue
    27.         subi.w  #2,x_vel(a0)        ; So he's facing right?  Make catcher fall to the right instead
    28. +
    29.     move.l  objoff_34(a0),d0
    30.     move.w  objoff_30(a0),d1
    31.     addi.w  #$38,objoff_30(a0)
    32.     ext.l   d1
    33.     asl.l   #8,d1
    34.     add.l   d1,d0
    35.     move.l  d0,objoff_34(a0)
    36.     move.w  objoff_34(a0),y_vel(a0)
    37.     cmpi.w  #$6F0,y_vel(a0)
    38.     blt.s   return_31F22
    39.     move.w  #0,objoff_30(a0)
    40.  
    41. return_31F22:
    42.     rts
    Done



    Another 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:

    Code (ASM):
    1.     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
     
  9. dsrb

    dsrb

    Member
    3,150
    0
    0
    Did anyone ever make the CPZ boss's blue gunk able to hurt Sonic when he's ducking? I think there's something of a debate over whether it's intentional, muddied by the fact that it does hurt Tails and (I'm assuming) Knuckles, but anyway. It's (like most of them) not the kind of boss I think needs an easy method like that. :P
     
  10. Esrael

    Esrael

    Tech Member
    187
    0
    0
    Brazil, São Paulo, Guarulhos
    Neto Assembler Editor / Sonic 2 Delta / Neto Boot Loader

    Thanks, for replying.
    I made these change in old versions of Sonic 2 Delta, but never find anyone to notice these little details and searched in the forums before posting.
    This will help others to fix these on yours hacks no just me.
    Thanks and all Help are welcome.
     
  11. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,584
    0
    16
    United Kingdom
    YouTuber

    You're welcome. I'm glad I could be an assistance. Especially to you, Esrael.




    Sure, there is an easy fix. I've applied it myself, and it seems to work. And it hasn't affected anything else. So, here goes.




    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:

    Code (ASM):
    1. loc_2E692:
    2.     addq.b  #2,routine_secondary(a0)
    3.     move.b  #$20,y_radius(a0)
    4.     move.b  #$19,anim(a0)
    5.     move.w  #0,y_vel(a0)
    6.     movea.l objoff_34(a0),a1 ; a1=object
    7.     movea.l $34(a1),a1
    8.     btst    #2,$2D(a1)
    9.     beq.s   loc_2E6CA
    10.     bclr    #2,$2D(a1)
    11.     move.b  #6,routine_secondary(a0)
    12.     move.w  #9,objoff_2A(a0)

    See that command?

    Code (ASM):
    1.     move.b  #$20,y_radius(a0)
    Change #$20 to #$16. So you have this in the end:

    Code (ASM):
    1. loc_2E692:
    2.     addq.b  #2,routine_secondary(a0)
    3.     move.b  #$16,y_radius(a0)
    4.     move.b  #$19,anim(a0)
    5.     move.w  #0,y_vel(a0)
    6.     movea.l objoff_34(a0),a1 ; a1=object
    7.     movea.l $34(a1),a1
    8.     btst    #2,$2D(a1)
    9.     beq.s   loc_2E6CA
    10.     bclr    #2,$2D(a1)
    11.     move.b  #6,routine_secondary(a0)
    12.     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?

    Code (ASM):
    1.     btst    #2,$2D(a1)
    2.     beq.s   loc_2E6CA
    Comment them out! And everytime Eggman drops the gunge, this will happen!

    [​IMG]


    Well, I found it funny =P
     
  12. amphobius

    amphobius

    where are the japanese shaman girls, lintahlo? Member
    ...That's a bug? That always seemed intentional. Hell, I found it cool that you could do that even.
     
  13. E-122-Psi

    E-122-Psi

    Member
    1,791
    0
    0
    Maybe it was intended when he drops the gunge over himself. It would likely be more complex to recognise when the player is directly beside Robotnik when it drops though.
     
  14. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,584
    0
    16
    United Kingdom
    YouTuber
    "For fuck sake, RHS! Stop it with all these bug fixes!" Is what you lot are probably thinking =P


    But as this subject seems to be on bosses, I thought I'd post another one here. Another ARZ glitch.




    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:

    Code (ASM):
    1. loc_30770:
    2.     lea ($FFFFF740).w,a1
    3.     move.b  #$31,3(a1)
    4.  
    5. loc_3077A:

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

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

    So you have something like this:

    Code (ASM):
    1. loc_30770:
    2.     lea ($FFFFF740).w,a1
    3.     move.b  #$31,3(a1)
    4.     move.b  #1,objoff_36(a0)    ; move 1 to checker
    5.  
    6. loc_3077A:


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

    Code (ASM):
    1. loc_3075C:
    2.     bsr.w   loc_3078E
    3.     cmpi.b  #4,(MainCharacter+routine).w
    4.     beq.s   loc_30770
    5.     cmpi.b  #4,(Sidekick+routine).w
    6.     bne.s   loc_3077A
    After the "bsr.w loc_3078E" command, insert these two lines:

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

    So you have something like this:

    Code (ASM):
    1. loc_3075C:
    2.     bsr.w   loc_3078E
    3.     tst.b   objoff_36(a0)       ; Is checker 0?
    4.     bne.s   loc_3077A       ; If not, branch and do not check for Sonic/Tails hurt state
    5.     cmpi.b  #4,(MainCharacter+routine).w
    6.     beq.s   loc_30770
    7.     cmpi.b  #4,(Sidekick+routine).w
    8.     bne.s   loc_3077A


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

    Code (ASM):
    1. return_3078C:
    2.     rts

    Change it to this:

    Code (ASM):
    1. return_3078C:
    2.     cmpi.b  #$17,($FFFFF743).w  ; Has Eggman stopped laughing?
    3.     bne.s   +           ; If not, branch
    4.     clr.b   objoff_36(a0)       ; If so, clear checker, so Eggman can check to see if Sonic/Tails are hurt again
    5. +
    6.     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
     
  15. KingofHarts

    KingofHarts

    Member
    1,618
    0
    16
    Project Sonic 8x16
  16. saxman

    saxman

    Oldbie Tech Member
    You guys are amazing! I really like these bug fixes. I have implemented a bunch in my ROM, mostly ones that I have found and fixed. However, lately I've been looking at posts about different bug fixes I wasn't aware of. These, for example, I didn't really notice until I saw this topic. I will gladly credit both Esrael and RHS when my work has been made public.

    On a side note... although I personally don't believe in special labels for members (such as "Tech Member"), since Retro does it, I will gladly put this out there: RHS should be a tech member! Is anyone up stairs listening? This takes talent!
     
  17. KingofHarts

    KingofHarts

    Member
    1,618
    0
    16
    Project Sonic 8x16
    Preach on, brother... this, 1000x over.
     
  18. Esrael

    Esrael

    Tech Member
    187
    0
    0
    Brazil, São Paulo, Guarulhos
    Neto Assembler Editor / Sonic 2 Delta / Neto Boot Loader
    Looking into Boss code I find a way of Making this work as it was planned or not.

    find the code:
    Code (ASM):
    1.  
    2.  loc_2DAD4:
    3.     move.w  d0,(a1)
    4.     subq.b  #1,objoff_3E(a0)
    5.     bne.s   return_2DAE8
    6.     move.b  #$F,collision_flags(a0)
    7.     bclr    #1,objoff_2D(a0)
    8.  
    9. return_2DAE8:
    10.     rts
    11.  
    and add

    Code (ASM):
    1.  
    2.  loc_2DAD4:
    3.     move.w  d0,(a1)
    4.         bset    #1,objoff_2D(a0)   ; Add this line to code
    5.     subq.b  #1,objoff_3E(a0)
    6.     bne.s   return_2DAE8
    7.     move.b  #$F,collision_flags(a0)
    8.     bclr    #1,objoff_2D(a0)
    9.  
    10. return_2DAE8:
    11.     rts
    12.  
    After you made the changes. Wait for robotnik filling the bootle and hit he. You will see the animation working.

    Download Sonic 2 Delta with CPz boss Change

    [​IMG][​IMG]

    Edit: 28/05/2019 - Fixed broken links

    Best regards:
    ----------------------
    Neto.
     
  19. Endri

    Endri

    Officer I don't have my drivers license with me. C Tech Member
    This is clever, and makes perfect sense! I believe this behavior is definitely how it was originally planned.

    And, by the way *bows to the master* I can't believe that you are actually back in here, after such a long time, Esrael! It was all thanks to you that I got into the fabulous world of Sonic hacking back then.

    Thank you, my master! :eng101:
     
  20. McAleeCh

    McAleeCh

    Oldbie
    931
    1
    18
    I remember finding the graphics for that extra boss behaviour in the old "MD8123" Sonic 2 proto back in my "Knuckles Prower" days - I had no idea that the graphics existed in the final, or that code that referenced them was commented out, though! Amazing find, and great to see your tweak to return it to what was almost certainly the intended behaviour. = ) Never thought I'd see this in action!

    One thing, though - the existing code seems to display the art slightly too far to the right for some reason. If you check out the old .GIF animation I made back when I originally found the graphics to show how it might look in action (currently viewable on the Sonic CulT S2 Proto Lost Sprites page), you can see that the graphics are actually designed to perfectly mask Robotnik's body, even including the small bits you can see through the shine in his Eggmobile's windscreen! For some reason though, the code you've found looks like it gets this alignment wrong by a few pixels - the whole graphic is 3 pixels too far to the right. Is there any way of shifting the goo-covered Robotnik sprite to the left by 3 pixels in order to fix this? = )