don't click here

ASM oops

Discussion in 'Engineering & Reverse Engineering' started by XPointZPoint, Feb 17, 2023.

  1. XPointZPoint

    XPointZPoint

    That's no good! Member
    56
    13
    8
    i was adding smooth sprites to sonic 1, but i never expected this to happen 0.o
    unfortunately, the sprite sheet i got the extra frames from don't have rotated versions, so i'll have to manually rotate them myself



    oh yeah, here's the sonic animation file (sonic walk is the issue):
    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; Animation script - Sonic
    3. ; ---------------------------------------------------------------------------
    4.         dc.w SonAni_Walk-SonicAniData
    5.         dc.w SonAni_Run-SonicAniData
    6.         dc.w SonAni_Roll-SonicAniData
    7.         dc.w SonAni_Roll2-SonicAniData
    8.         dc.w SonAni_Push-SonicAniData
    9.         dc.w SonAni_Wait-SonicAniData
    10.         dc.w SonAni_Balance-SonicAniData
    11.         dc.w SonAni_LookUp-SonicAniData
    12.         dc.w SonAni_Duck-SonicAniData
    13.         dc.w SonAni_Warp1-SonicAniData
    14.         dc.w SonAni_Warp2-SonicAniData
    15.         dc.w SonAni_Warp3-SonicAniData
    16.         dc.w SonAni_Warp4-SonicAniData
    17.         dc.w SonAni_Stop-SonicAniData
    18.         dc.w SonAni_Float1-SonicAniData
    19.         dc.w SonAni_Float2-SonicAniData
    20.         dc.w SonAni_Spring-SonicAniData
    21.         dc.w SonAni_LZHang-SonicAniData
    22.         dc.w SonAni_Leap1-SonicAniData
    23.         dc.w SonAni_Leap2-SonicAniData
    24.         dc.w SonAni_Surf-SonicAniData
    25.         dc.w SonAni_Bubble-SonicAniData
    26.         dc.w SonAni_Death1-SonicAniData
    27.         dc.w SonAni_Drown-SonicAniData
    28.         dc.w SonAni_Death2-SonicAniData
    29.         dc.w SonAni_Shrink-SonicAniData
    30.         dc.w SonAni_Hurt-SonicAniData
    31.         dc.w SonAni_LZSlide-SonicAniData
    32.         dc.w SonAni_Blank-SonicAniData
    33.         dc.w SonAni_Float3-SonicAniData
    34.         dc.w SonAni_Float4-SonicAniData
    35.         dc.w SonAni_Spindash-SonicAniData    ;1F
    36. SonAni_Walk:    dc.b $FF, $61, $08, $62, $9,    $A, $B,    $6, $7, $FF
    37. SonAni_Run:    dc.b $FF, $1E, $1F, $20, $21, $FF, $FF,    $FF
    38. SonAni_Roll:    dc.b $FE, $2E, $2F, $30, $31, $32, $FF,    $FF
    39. SonAni_Roll2:    dc.b $FE, $2E, $2F, $32, $30, $31, $32,    $FF
    40. SonAni_Push:    dc.b $FD, $45, $46, $47, $48, $FF, $FF,    $FF
    41. SonAni_Wait:    dc.b $17, $01, $01,    $01, $01, $01, $01, $01, $01, $01, $01, $5E, $5F, $60, $02, $02, $02, $02, $03, $04, $FE, 2, 0
    42. SonAni_Balance:    dc.b $1F, $3A, $3B, $FF
    43. SonAni_LookUp:    dc.b $3F, 5, $FF, 0
    44. SonAni_Duck:    dc.b $3F, $39, $FF, 0
    45. SonAni_Warp1:    dc.b $3F, $33, $FF, 0
    46. SonAni_Warp2:    dc.b $3F, $34, $FF, 0
    47. SonAni_Warp3:    dc.b $3F, $35, $FF, 0
    48. SonAni_Warp4:    dc.b $3F, $36, $FF, 0
    49. SonAni_Stop:    dc.b 7,    $37, $38, $FF
    50. SonAni_Float1:    dc.b 7,    $3C, $3F, $FF
    51. SonAni_Float2:    dc.b 7,    $3C, $3D, $53, $3E, $54, $FF, 0
    52. SonAni_Spring:    dc.b $2F, $40, $FD, 0
    53. SonAni_LZHang:    dc.b 4,    $41, $42, $FF
    54. SonAni_Leap1:    dc.b $F, $43, $43, $43,    $FE, 1
    55. SonAni_Leap2:    dc.b $F, $43, $44, $FE,    1, 0
    56. SonAni_Surf:    dc.b $3F, $49, $FF, 0
    57. SonAni_Bubble:    dc.b $B, $56, $56, $A, $B, $FD,    0, 0
    58. SonAni_Death1:    dc.b $20, $4B, $FF, 0
    59. SonAni_Drown:    dc.b $2F, $4C, $FF, 0
    60. SonAni_Death2:    dc.b 3,    $4D, $FF, 0
    61. SonAni_Shrink:    dc.b 3,    $4E, $4F, $50, $51, $52, 0, $FE, 1, 0
    62. SonAni_Hurt:    dc.b 3,    $55, $FF, 0
    63. SonAni_LZSlide:    dc.b 7, $55, $57, $FF
    64. SonAni_Blank:    dc.b $77, 0, $FD, 0
    65. SonAni_Float3:    dc.b 3,    $3C, $3D, $53, $3E, $54, $FF, 0
    66. SonAni_Float4:    dc.b 3,    $3C, $FD, 0
    67. SonAni_Spindash:    dc.b 0, $58, $59, $58, $5A, $58, $5B, $58, $5C, $58, $5D, $FF
    68.         even
    one thing i forgot to mention, i already tried the expand art limit tutorial and the best i got was sonic looking like a garbled mess
     
    Last edited by a moderator: Feb 17, 2023
  2. Devon

    Devon

    A̸ ̴S̴ ̵C̵ ̷E̶ ̸N̸ ̴D̶ ̵E̶ ̸D̶ Tech Member
    1,274
    1,452
    93
    your mom
    Angled sprites are retrieved by taking the current sprite found in the animation data and adding the current octant times the number of walking/running frames.

    In Sonic_Animate, you will see this code (I documented it to make it easier to understand):
    Code (Text):
    1.         ; d0 = octant modifier (0, 2, 4, 6)
    2.         ; d2 = Sonic's current speed
    3.         lea     (SonAni_Run).l,a1       ; Running animation
    4.         cmpi.w  #$600,d2                ; Is Sonic at running speed?
    5.         bcc.s   .running                ; If yes, branch
    6.  
    7.         lea     (SonAni_Walk).l,a1      ; Walking animation
    8.         move.b  d0,d1                   ; Make octant modifier a multiple of 3
    9.         lsr.b   #1,d1                   ; (0, 3, 6, 9)
    10.         add.b   d1,d0
    11.  
    12. .running:
    13.         add.b   d0,d0                   ; Multiple octant modifer by 2
    14.         move.b  d0,d3                   ; (Becomes multiple of 4 for running (0, 4, 8, 12),
    15.                                         ;  multiple of 6 for walking (0, 6, 12, 18))
    16.  
    17.         ...
    18.  
    19.         bsr.w   .loadframe              ; Get frame from animation
    20.         add.b   d3,obFrame(a0)          ; Add octant modifier to frame
    Some changes will need to be made.

    The first issue I notice is that the walking, running, and pushing sprites need to use the same number of bytes. The two rolling animations also need to have the same number of bytes as each other, too. The reason for this is that when it switches between those animations, it doesn't actually resent the animation data offset, because the animation ID isn't actually being changed (0 = walking/running/pushing, 2 = rolling, fast and slow) so if you were on the third frame of running, for instance, and you go back to walking, it'll go to the third frame of walking. The shorter animations pad it out with FFs so that if it jumps out of bounds, it'll hit a reset flag, and properly go back to the start of the animation.

    Second, the animation handler needs to be updated to handle 8 walking frames instead of 6 for an octant. You can achieve this easily by changing the "make octant of modifier of 3" code to just:
    Code (Text):
    1.         add.b   d0,d0                  ; Make octant modifier a multiple of 4 (0, 4, 8, 12)
    This will make the octant modifier a multiple of 4 (0, 4, 8, 12), which will then be updated to a multiple of 8 (0, 8, 16, 24) once it hits the .running label (see Sonic 2 and 3K for reference).

    Third, you need to put the walking frames together like how it's done in the stock game. As in, you must have the frames for the first octant first, and then the second, then third, then fourth, because the animation handler relies on the fact that the walking frames are put together like that. Unless you want to make some kind of table that translates a base frame ID + modifier into a proper frame ID, but that's probably not worth the trouble, honestly.
     
    • Like Like x 1
    • Informative Informative x 1
    • List
  3. XPointZPoint

    XPointZPoint

    That's no good! Member
    56
    13
    8
    i cant quite seem to find the code you mentioned in the reply, btw, im using hivebrain, if that makes a difference
     
  4. Devon

    Devon

    A̸ ̴S̴ ̵C̵ ̷E̶ ̸N̸ ̴D̶ ̵E̶ ̸D̶ Tech Member
    1,274
    1,452
    93
    your mom
    It's in Sonic_Animate, particularly under loc_13A9C.