Actions

SCHG How-to

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

From Sonic Retro

(Wikification, +cat)
Line 1: Line 1:
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>
+
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 <b>Sonic 1</b> 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>
+
 
<b>To illustrate this bug:</b><br>
+
'''To illustrate this bug:'''
<center>[[Image:Points_before.PNG|points before]]</center><br>
+
<gallery widths="319px" heights="232px" style="margin-left: auto; margin-right: auto; text-align: center">
<i>It's the end of the stage, lets send Sonic in for more points.</i><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 12210 points, but 1200+100+1000+10000=12300.
<center>[[Image:Points_after.PNG|points after]]</center><br>
+
</gallery>
<i>Something is wrong here. We have 12210 points, but 1200+100+1000+10000=12300.</i><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:'''
We want to look at Object 7D which is the object for the hidden points earned after the signpost. So hunt down the label <b>Obj7D:</b><br>
+
 
<br>
+
<asm>; ---------------------------------------------------------------------------
<asm>
 
; ---------------------------------------------------------------------------
 
 
; Object 7D - hidden points at the end of a level
 
; Object 7D - hidden points at the end of a level
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
Line 26: Line 24:
 
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)
...
+
...</asm>
</asm>
+
''This is the object you want''
<i>This is the object you want</i><br>
+
 
<br>
+
If we go through this object's code we will see an array, go to the label '''Obj7D_Points:'''
If we go through this object's code we will see an array, go to the label <b>Obj7D_Points:</b><br>
+
 
<asm>
+
<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</asm>
</asm>
+
''This array represents the points sonic earns for the various types of hidden point objects revealed on screen.''
<i>This array represents the points sonic earns for the various types of hidden point objects revealed on screen.</i><br>
+
 
<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.
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>
+
 
<br>
+
So this array tells us:
So this array tells us:<br>
+
 
<ul>
+
* You earn 1000*10 = 10000 points when Sonic reveals a 10000 point object
<li>You earn 1000*10 = 10000 points when Sonic reveals a 10000 point object</li>
+
* You earn 100*10 = 1000 points when Sonic reveals a 1000 point object
<li>You earn 100*10 = 1000 points when Sonic reveals a 1000 point object</li>
+
* You earn 1*10 = 10 points when Sonic reveals a 100 point object
<li>You earn 1*10 = 10 points when Sonic reveals a 100 point object</li>
+
 
</ul>
+
So let's fix this so that we get 100 points instead of 10, simply change that 1 to a 10.
<br>
+
 
So lets fix this so that we get 100 points instead of 10, simply change that 1 to a 10.<br>
+
'''Giving us something like this:'''
<br>
+
 
<b>Giving us something like this:</b><br>
+
<asm>Obj7D_Points: dc.w 0 ; Bonus points array
<asm>
 
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</asm>
</asm>
 
<br>
 
Build your ROM and test it out.<br>
 
  
<b>Hopefully it works and you get something like this:</b><br>
+
Build your ROM and test it out.
<center>[[Image:Points_fixed_before.PNG|points before]]</center><br>
+
 
<i>It's the end of the stage, lets get those points.</i><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.
<i>Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.</i><br>
+
Image:Points_fixed_after.PNG|Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.
<br>
+
</gallery>
<b>Entire Object 7D code for reference:</b><br>
+
 
<asm>
+
'''Entire Object 7D code for reference:'''
; ===========================================================================
+
 
 +
<asm>; ===========================================================================
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
; Object 7D - hidden points at the end of a level
 
; Object 7D - hidden points at the end of a level
Line 161: Line 154:
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
 
Map_obj7D:
 
Map_obj7D:
include "_maps\obj7D.asm"
+
include "_maps\obj7D.asm"</asm>
</asm>
+
 
--[[User:1337rooster|1337rooster]] 04:25, 26 April 2008 (UTC)
+
[[Category:SCHG How-tos|F]]

Revision as of 05:20, 9 September 2008

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:

<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) ...</asm> 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:

<asm>Obj7D_Points: dc.w 0 ; Bonus points array dc.w 1000 dc.w 100 dc.w 1</asm> This array represents the points sonic earns for the various types of hidden point objects revealed on screen.

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.

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:

<asm>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</asm>

Build your ROM and test it out.

Hopefully it works and you get something like this:

Entire Object 7D code for reference:

<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)

===========================================================================

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"</asm>