Actions

SCHG How-to

Difference between revisions of "Fix the HUD blinking"

From Sonic Retro

m
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
''by [[Quickman]]''
+
{{GuideBy|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.
 
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.
+
==Hivebrain's 2005 disassembly==
 +
''(Addition by [[User:Vanya|Vanya]])''
  
<asm>
+
Go to "Obj21_Flash:" and replace this:
 +
 
 +
<syntaxhighlight lang="asm">
 +
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
 +
</syntaxhighlight>
 +
 
 +
with this:
 +
 
 +
<syntaxhighlight lang="asm">
 +
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
 +
</syntaxhighlight>
 +
 
 +
==SVN/GitHub disassembly==
 +
 
 +
Open ''_incObj/21 HUD.asm'' and replace this:
 +
 
 +
<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 25: Line 76:
 
move.b d0,obFrame(a0)
 
move.b d0,obFrame(a0)
 
jmp DisplaySprite
 
jmp DisplaySprite
</asm>
+
</syntaxhighlight>
  
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:
+
with this:
  
<asm>
+
<syntaxhighlight lang="asm">
HUD_Flash:
+
HUD_Flash: ; Routine 2
 
moveq #0,d0
 
moveq #0,d0
 
btst #3,(v_framebyte).w
 
btst #3,(v_framebyte).w
 
bne.s @display
 
bne.s @display
 
tst.w (v_rings).w ; do you have any rings?
 
tst.w (v_rings).w ; do you have any rings?
bne.s @rings ; if so, branch
+
bne.s @norings ; if so, branch
 
addq.w #1,d0 ; make ring counter flash red
 
addq.w #1,d0 ; make ring counter flash red
 +
; ===========================================================================
  
@rings:
+
@norings:
 
cmpi.b #9,(v_timemin).w ; have 9 minutes elapsed?
 
cmpi.b #9,(v_timemin).w ; have 9 minutes elapsed?
 
bne.s @display ; if not, branch
 
bne.s @display ; if not, branch
Line 46: Line 98:
 
move.b d0,obFrame(a0)
 
move.b d0,obFrame(a0)
 
jmp DisplaySprite
 
jmp DisplaySprite
</asm>
+
</syntaxhighlight>
 +
 
 +
{{S1Howtos}}
 +
|Fix the HUD Blinking]]

Latest revision as of 16:35, 11 July 2020

(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.

Hivebrain's 2005 disassembly

(Addition by Vanya)

Go to "Obj21_Flash:" and replace this:

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

with this:

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

SVN/GitHub disassembly

Open _incObj/21 HUD.asm and replace 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

with 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	@norings	; if so, branch
		addq.w	#1,d0		; make ring counter flash red
; ===========================================================================

@norings:
		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
SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)

|Fix the HUD Blinking]]