Actions

SCHG How-to

Fix the Hidden Points bug in Sonic 1

From Sonic Retro

(Original guide by 1337Rooster)

Alright, now this is a very simple fix. Before I go any further, know that I'm using Sonic 1 (Split and Text by Hivebrain) (ASM68K).

You may not have noticed this, but Sonic 1 has a glitch related to the hidden points earned by jumping after the signpost.

To illustrate this bug:

The reason this occurs is because the game only registers 10 points instead of 100 for the 100 point marker displayed on screen. So, you should feel ripped off because Sonic is 90 points short.

So let's fix this.

We want to look at Object 7D which is the object for the hidden points earned after the signpost. So hunt down the label Obj7D: (Hint for GitHub Disassembly users: Look for file called _incObj/7D Hidden Bonuses.asm)

; ---------------------------------------------------------------------------
; Object 7D - hidden points at the end of a level
; ---------------------------------------------------------------------------

Obj7D:					; XREF: Obj_Index
		moveq	#0,d0
		move.b	$24(a0),d0
		move.w	Obj7D_Index(pc,d0.w),d1
		jmp	Obj7D_Index(pc,d1.w)
		...

This is the object you want

If we go through this object's code we will see an array, go to the label Obj7D_Points: (Hint for GitHub Disassembly users: Look for label called @points)

Obj7D_Points:	dc.w 0			; Bonus	points array
		dc.w 1000
		dc.w 100
		dc.w 1

This array represents the points sonic earns for the various types of hidden point objects revealed on screen.

The last digit of your score isn't actually stored in memory. Instead, it's always assumed to be zero, forcing all scores to be multiples of 10. The game simply appends the zero to the end when it updates the display.

So this array tells us:

  • You earn 1000*10 = 10000 points when Sonic reveals a 10000 point object
  • You earn 100*10 = 1000 points when Sonic reveals a 1000 point object
  • You earn 1*10 = 10 points when Sonic reveals a 100 point object

So let's fix this so that we get 100 points instead of 10, simply change that 1 to a 10.

Giving us something like this:

Obj7D_Points:	dc.w 0			; Bonus	points array
		dc.w 1000		; earn 1000*10 points for revealing 10000 object
		dc.w 100		; earn 100*10 points for revealing 1000 object
		dc.w 10			; earn 10*10 points for revealing 100 object

Build your ROM and test it out.

Hopefully it works and you get something like this:

Entire Object 7D code for reference:

; ===========================================================================
; ---------------------------------------------------------------------------
; Object 7D - hidden points at the end of a level
; ---------------------------------------------------------------------------

Obj7D:					; XREF: Obj_Index
		moveq	#0,d0
		move.b	$24(a0),d0
		move.w	Obj7D_Index(pc,d0.w),d1
		jmp	Obj7D_Index(pc,d1.w)
; ===========================================================================
Obj7D_Index:	dc.w Obj7D_Main-Obj7D_Index
		dc.w Obj7D_DelayDel-Obj7D_Index
; ===========================================================================

Obj7D_Main:				; XREF: Obj7D_Index
		moveq	#$10,d2
		move.w	d2,d3
		add.w	d3,d3
		lea	($FFFFD000).w,a1
		move.w	8(a1),d0
		sub.w	8(a0),d0
		add.w	d2,d0
		cmp.w	d3,d0
		bcc.s	Obj7D_ChkDel
		move.w	$C(a1),d1
		sub.w	$C(a0),d1
		add.w	d2,d1
		cmp.w	d3,d1
		bcc.s	Obj7D_ChkDel
		tst.w	($FFFFFE08).w
		bne.s	Obj7D_ChkDel
		tst.b	($FFFFF7CD).w
		bne.s	Obj7D_ChkDel
		addq.b	#2,$24(a0)
		move.l	#Map_obj7D,4(a0)
		move.w	#$84B6,2(a0)
		ori.b	#4,1(a0)
		move.b	#0,$18(a0)
		move.b	#$10,$19(a0)
		move.b	$28(a0),$1A(a0)
		move.w	#119,$30(a0)	; set display time to 2	seconds
		move.w	#$C9,d0
		jsr	(PlaySound_Special).l ;	play bonus sound
		moveq	#0,d0
		move.b	$28(a0),d0
		add.w	d0,d0
		move.w	Obj7D_Points(pc,d0.w),d0 ; load	bonus points array
		jsr	AddPoints

Obj7D_ChkDel:
		move.w	8(a0),d0
		andi.w	#$FF80,d0
		move.w	($FFFFF700).w,d1
		subi.w	#$80,d1
		andi.w	#$FF80,d1
		sub.w	d1,d0
		cmpi.w	#$280,d0
		bhi.s	Obj7D_Delete
		rts	
; ===========================================================================

Obj7D_Delete:
		jmp	DeleteObject
; ===========================================================================
Obj7D_Points:	dc.w 0			; Bonus	points array
		dc.w 1000
		dc.w 100
		dc.w 10
; ===========================================================================

Obj7D_DelayDel:				; XREF: Obj7D_Index
		subq.w	#1,$30(a0)	; subtract 1 from display time
		bmi.s	Obj7D_Delete2	; if time is zero, branch
		move.w	8(a0),d0
		andi.w	#-$80,d0
		move.w	($FFFFF700).w,d1
		subi.w	#$80,d1
		andi.w	#-$80,d1
		sub.w	d1,d0
		cmpi.w	#$280,d0
		bhi.s	Obj7D_Delete2
		jmp	DisplaySprite
; ===========================================================================

Obj7D_Delete2:
		jmp	DeleteObject
; ===========================================================================
; ---------------------------------------------------------------------------
; Sprite mappings - hidden points at the end of	a level
; ---------------------------------------------------------------------------
Map_obj7D:
	include "_maps\obj7D.asm"
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
Changing Design Choices
Change Spike Behavior | 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
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor
Sound Features
Expand Music Index From $94 to $9F | Extend Music Slots | Play Different Songs Per Act | Expand Music Index to Start at $00 | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ 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
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)