Properly Angled Running Animations - RetroKoH/S1Fixed GitHub Wiki
(Original guide by Mercury)
Source: ReadySonic
Commit: 129efea
So, this is not a bugfix that changes anything overly substantial, but it always bothered me to no end to run towards the loop in GHZ1 and see Sonic angled downward despite running on a relatively shallow angle. Later games fixed this, and the remake of Sonic 1 fixed this, so we will too!
Open _incObj/Sonic Animate.asm and scroll down to .walkrunroll. We are going to add these three lines:
.walkrunroll:
move.b 2(a1,d1.w),d0 ; read the next byte in the script
sub.b d0,obAniFrame(a0) ; jump back d0 bytes in the script
sub.b d0,d1
move.b 1(a1,d1.w),d0 ; read sprite number
bra.s .next
; ===========================================================================
.end_FD:
addq.b #1,d0 ; is the end flag = $FD ?
bne.s .end ; if not, branch
move.b 2(a1,d1.w),obAnim(a0) ; read next byte, run that animation
.end:
rts
; ===========================================================================
.walkrunroll:
subq.b #1,obTimeFrame(a0) ; subtract 1 from frame duration
bpl.s .delay ; if time remains, branch
addq.b #1,d0 ; is animation walking/running?
bne.w .rolljump ; if not, branch
moveq #0,d1
move.b obAngle(a0),d0 ; get Sonic's angle
+ bmi.s .ble
+ beq.s .ble
+ subq.b #1,d0
+.ble:
move.b obStatus(a0),d2
andi.b #1,d2 ; is Sonic mirrored horizontally?
bne.s .flip ; if yes, branch
Sonic will now handle angles properly.