Actions

SCHG How-to

Difference between revisions of "Fix the Hidden Points bug in Sonic 1"

From Sonic Retro

(New page: Treat this article as a rough draft for now, I'm going to format it nicer and edit it tomorrow morning, after I review the site suggestions for writing articles. However, all the content i...)
 
m (Text replacement - "\[\[Category:SCHG How-tos.*" to "")
 
(13 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Treat this article as a rough draft for now, I'm going to format it nicer and edit it tomorrow morning, after I review the site suggestions for writing articles. However, all the content is available, so enjoy.<br>
+
{{GuideBy|1337Rooster}}
<br>
+
 
Alright, now this is a very simple fix. Before I go any further, know that I'm using Hivebrain 2005 (ASM68K) split disassembly.<br>
+
Alright, now this is a very simple fix. Before I go any further, know that I'm using [[Media:Sonic 1 (Split and Text by Hivebrain)_(ASM68K).zip|Sonic 1 (Split and Text by Hivebrain) (ASM68K)]].
<br>
+
 
You may not have noticed this, but Sonic 1 has a glitch related to the hidden points earned by jumping after the signpost.<br>
+
You may not have noticed this, but ''[[Sonic 1]]'' has a glitch related to the hidden points earned by jumping after the signpost.
<br>
+
 
To illustrate this bug:<br>
+
'''To illustrate this bug:'''
<center>[[Image:Points_before.PNG|points before]]</center><br>
+
<gallery widths="320px" heights="224px" style="margin-left: auto; margin-right: auto; text-align: center">
It's the end of the stage, lets send Sonic in for more points.<br>
+
Image:Points_before.PNG|It's the end of the stage, let's send Sonic in for more points.
<br>
+
Image:Points_after.PNG|Something is wrong here. We have 13230 points, but 2200+100+100+100+1000+10000=13500.
<center>[[Image:Points_after.PNG|points after]]</center><br>
+
</gallery>
Something is wrong here. We have 12210 points, but 1200+100+1000+10000=12300.<br>
+
 
<br>
+
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.
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.<br>
+
 
<br>
+
So let's fix this.
So lets fix this,<br>
+
 
<br>
+
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'')
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:"<br>
+
 
<br>
+
<syntaxhighlight lang="asm">
<asm>
 
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
; Object 7D - hidden points at the end of a level
 
; Object 7D - hidden points at the end of a level
Line 28: Line 27:
 
move.w Obj7D_Index(pc,d0.w),d1
 
move.w Obj7D_Index(pc,d0.w),d1
 
jmp Obj7D_Index(pc,d1.w)
 
jmp Obj7D_Index(pc,d1.w)
...
+
...</syntaxhighlight>
</asm>
+
''This is the object you want''
This is the object you want<br>
+
 
<br>
+
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'')
If we go through this object's code we will see an array, go to the label "Obj7D_Points:"<br>
+
 
<asm>
+
<syntaxhighlight lang="asm">Obj7D_Points: dc.w 0 ; Bonus points array
Obj7D_Points: dc.w 0 ; Bonus points array
 
 
dc.w 1000
 
dc.w 1000
 
dc.w 100
 
dc.w 100
dc.w 1
+
dc.w 1</syntaxhighlight>
</asm>
+
''This array represents the points sonic earns for the various types of hidden point objects revealed on screen.''
<br>
+
 
This array represents the points sonic earns for the various types of hidden point objects revealed on screen.<br>
+
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.
<br>
+
 
Now I didn't confirm this, but I assume that the game does not store the last digit of your score in memory; in game your is always a multiple of 10.<br>
+
So this array tells us:
<br>
+
 
So this array tells us:<br>
+
* You earn 1000*10 = 10000 points when Sonic reveals a 10000 point object
<ul>
+
* You earn 100*10 = 1000 points when Sonic reveals a 1000 point object
<li>You earn 1000*10 = 10000 points when Sonic reveals a 10000 point object</li>
+
* You earn 1*10 = 10 points when Sonic reveals a 100 point object
<li>You earn 100*10 = 1000 points when Sonic reveals a 1000 point object</li>
+
 
<li>You earn 1*10 = 10 points when Sonic reveals a 100 point object</li>
+
So let's fix this so that we get 100 points instead of 10, simply change that 1 to a 10.
</ul>
+
 
<br>
+
'''Giving us something like this:'''
So lets fix this so that we get 100 points instead of 10, simply change that 1 to a 10. Giving us something like this:<br>
+
 
<asm>
+
<syntaxhighlight lang="asm">Obj7D_Points: dc.w 0 ; Bonus points array
Obj7D_Points: dc.w 0 ; Bonus points array
 
 
dc.w 1000 ; earn 1000*10 points for revealing 10000 object
 
dc.w 1000 ; earn 1000*10 points for revealing 10000 object
 
dc.w 100 ; earn 100*10 points for revealing 1000 object
 
dc.w 100 ; earn 100*10 points for revealing 1000 object
dc.w 10 ; earn 10*10 points for revealing 100 object
+
dc.w 10 ; earn 10*10 points for revealing 100 object</syntaxhighlight>
</asm>
 
<br>
 
Build your ROM and test it out.<br>
 
  
Hopefully it works and you get something like this:<br>
+
Build your ROM and test it out.
<center>[[Image:Points_fixed_before.PNG|points before]]</center><br>
+
 
It's the end of the stage, lets send Sonic in for more points.<br>
+
'''Hopefully it works and you get something like this:'''
<br>
+
<gallery widths="320px" heights="224px" style="margin-left: auto; margin-right: auto; text-align: center">
<center>[[Image:Points_fixed_after.PNG|points after]]</center><br>
+
Image:Points_fixed_before.PNG|It's the end of the stage, let's get those points.
Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.<br>
+
Image:Points_fixed_after.PNG|Yes! We have 15200 points, verifying that 3900+100+100+100+1000+10000=15200.
<br>
+
</gallery>
Entire Object 7D code for reference:<br>
+
 
<asm>
+
'''Entire Object 7D code for reference:'''
; ===========================================================================
+
 
 +
<syntaxhighlight lang="asm">; ===========================================================================
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
; Object 7D - hidden points at the end of a level
 
; Object 7D - hidden points at the end of a level
Line 162: Line 157:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Map_obj7D:
 
Map_obj7D:
include "_maps\obj7D.asm"
+
include "_maps\obj7D.asm"</syntaxhighlight>
</asm>
+
 
--[[User:1337rooster|1337rooster]] 04:25, 26 April 2008 (UTC)
+
{{S1Howtos}}
 +
|Fix the Hidden Points bug in Sonic 1]]

Latest revision as of 10:51, 25 August 2018

(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 | 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 Hidden Points bug in Sonic 1]]