Difference between revisions of "Fix the HUD blinking"
From Sonic Retro
Scarred Sun (talk | contribs) m (Text replacement - "</asm>" to "</syntaxhighlight>") |
Scarred Sun (talk | contribs) m (Text replacement - "<asm>" to "<syntaxhighlight lang="asm">") |
||
Line 5: | Line 5: | ||
If you're using the SVN disassembly, open ''_incObj/21 HUD.asm''. The older disassembly by Hivebrain has it as Obj21_Flash in the main sonic.asm file, and will have some labels different, but I assume because you're using an older disassembly you know what you're doing. We want the second routine, which looks like this. | If you're using the SVN disassembly, open ''_incObj/21 HUD.asm''. The older disassembly by Hivebrain has it as Obj21_Flash in the main sonic.asm file, and will have some labels different, but I assume because you're using an older disassembly you know what you're doing. We want the second routine, which looks like this. | ||
− | <asm> | + | <syntaxhighlight lang="asm"> |
HUD_Flash: ; Routine 2 | HUD_Flash: ; Routine 2 | ||
tst.w (v_rings).w ; do you have any rings? | tst.w (v_rings).w ; do you have any rings? | ||
Line 28: | Line 28: | ||
When execution flows through this routine, the first thing that happens is it checks whether you have any rings. Only if you have none is the remainder of the code (which flashes the RINGS and, if appropriate, TIME counters) executed. To fix the bug, we need to revise the routine so it first checks if you have rings, and skips flashing the RINGS counter if you do to check the game time and, if appropriate, flash the TIME counter. The result should resemble this: | When execution flows through this routine, the first thing that happens is it checks whether you have any rings. Only if you have none is the remainder of the code (which flashes the RINGS and, if appropriate, TIME counters) executed. To fix the bug, we need to revise the routine so it first checks if you have rings, and skips flashing the RINGS counter if you do to check the game time and, if appropriate, flash the TIME counter. The result should resemble this: | ||
− | <asm> | + | <syntaxhighlight lang="asm"> |
HUD_Flash: ; Routine 2 | HUD_Flash: ; Routine 2 | ||
moveq #0,d0 | moveq #0,d0 | ||
Line 52: | Line 52: | ||
Here is the code for the 2005 Hivebrain (ASM68K) version. It's simple enough to find, but extra documentation never hurt anybody. | Here is the code for the 2005 Hivebrain (ASM68K) version. It's simple enough to find, but extra documentation never hurt anybody. | ||
− | <asm> | + | <syntaxhighlight lang="asm"> |
Obj21_Flash: ; XREF: Obj21_Main | Obj21_Flash: ; XREF: Obj21_Main | ||
tst.w ($FFFFFE20).w ; do you have any rings? | tst.w ($FFFFFE20).w ; do you have any rings? | ||
Line 76: | Line 76: | ||
And this is the fixed version: | And this is the fixed version: | ||
− | <asm> | + | <syntaxhighlight lang="asm"> |
Obj21_Flash: ; XREF: Obj21_Main | Obj21_Flash: ; XREF: Obj21_Main | ||
moveq #0,d0 | moveq #0,d0 |
Revision as of 21:45, 20 December 2015
(Original guide by Quickman)
There's a bug in the HUD in Sonic 1 - the timer is supposed to blink if there's less than a minute left to go, which it does if you have no rings, but as soon as you collect a ring it stops blinking. That's silly, so let's fix it.
If you're using the SVN disassembly, open _incObj/21 HUD.asm. The older disassembly by Hivebrain has it as Obj21_Flash in the main sonic.asm file, and will have some labels different, but I assume because you're using an older disassembly you know what you're doing. We want the second routine, which looks like this.
HUD_Flash: ; Routine 2
tst.w (v_rings).w ; do you have any rings?
beq.s @norings ; if not, branch
clr.b obFrame(a0) ; make all counters yellow
jmp DisplaySprite
; ===========================================================================
@norings:
moveq #0,d0
btst #3,(v_framebyte).w
bne.s @display
addq.w #1,d0 ; make ring counter flash red
cmpi.b #9,(v_timemin).w ; have 9 minutes elapsed?
bne.s @display ; if not, branch
addq.w #2,d0 ; make time counter flash red
@display:
move.b d0,obFrame(a0)
jmp DisplaySprite
When execution flows through this routine, the first thing that happens is it checks whether you have any rings. Only if you have none is the remainder of the code (which flashes the RINGS and, if appropriate, TIME counters) executed. To fix the bug, we need to revise the routine so it first checks if you have rings, and skips flashing the RINGS counter if you do to check the game time and, if appropriate, flash the TIME counter. The result should resemble this:
HUD_Flash: ; Routine 2
moveq #0,d0
btst #3,(v_framebyte).w
bne.s @display
tst.w (v_rings).w ; do you have any rings?
bne.s @rings ; if so, branch
addq.w #1,d0 ; make ring counter flash red
@rings:
cmpi.b #9,(v_timemin).w ; have 9 minutes elapsed?
bne.s @display ; if not, branch
addq.w #2,d0 ; make time counter flash red
@display:
move.b d0,obFrame(a0)
jmp DisplaySprite
Hivebrain Disassembly
(Addition by Vanya)
Here is the code for the 2005 Hivebrain (ASM68K) version. It's simple enough to find, but extra documentation never hurt anybody.
Obj21_Flash: ; XREF: Obj21_Main
tst.w ($FFFFFE20).w ; do you have any rings?
beq.s Obj21_Flash2 ; if not, branch
clr.b $1A(a0) ; make all counters yellow
jmp DisplaySprite
; ===========================================================================
Obj21_Flash2:
moveq #0,d0
btst #3,($FFFFFE05).w
bne.s Obj21_Display
addq.w #1,d0 ; make ring counter flash red
cmpi.b #9,($FFFFFE23).w ; have 9 minutes elapsed?
bne.s Obj21_Display ; if not, branch
addq.w #2,d0 ; make time counter flash red
Obj21_Display:
move.b d0,$1A(a0)
jmp DisplaySprite
And this is the fixed version:
Obj21_Flash: ; XREF: Obj21_Main
moveq #0,d0
btst #3,($FFFFFE05).w
bne.s Obj21_Display
tst.w ($FFFFFE20).w ; do you have any rings?
bne.s Obj21_Flash2 ; if not, branch
addq.w #1,d0 ; make ring counter flash red
Obj21_Flash2:
cmpi.b #9,($FFFFFE23).w ; have 9 minutes elapsed?
bne.s Obj21_Display ; if not, branch
addq.w #2,d0 ; make time counter flash red
Obj21_Display:
move.b d0,$1A(a0)
jmp DisplaySprite