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...)
 
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>
+
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>
 
<br>
 
<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>
+
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>
 
<br>
 
<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>
<br>
 
To illustrate this bug:<br>
 
 
<center>[[Image:Points_before.PNG|points before]]</center><br>
 
<center>[[Image:Points_before.PNG|points before]]</center><br>
It's the end of the stage, lets send Sonic in for more points.<br>
+
<i>It's the end of the stage, lets send Sonic in for more points.</i><br>
 
<br>
 
<br>
 
<center>[[Image:Points_after.PNG|points after]]</center><br>
 
<center>[[Image:Points_after.PNG|points after]]</center><br>
Something is wrong here. We have 12210 points, but 1200+100+1000+10000=12300.<br>
+
<i>Something is wrong here. We have 12210 points, but 1200+100+1000+10000=12300.</i><br>
 
<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.<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.<br>
Line 16: Line 14:
 
So lets fix this,<br>
 
So lets fix this,<br>
 
<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:"<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 <b>Obj7D:</b><br>
 
<br>
 
<br>
 
<asm>
 
<asm>
Line 30: Line 28:
 
...
 
...
 
</asm>
 
</asm>
This is the object you want<br>
+
<i>This is the object you want</i><br>
 
<br>
 
<br>
If we go through this object's code we will see an array, go to the label "Obj7D_Points:"<br>
+
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
Line 39: Line 37:
 
dc.w 1
 
dc.w 1
 
</asm>
 
</asm>
<br>
+
<i>This array represents the points sonic earns for the various types of hidden point objects revealed on screen.</i><br>
This array represents the points sonic earns for the various types of hidden point objects revealed on screen.<br>
 
 
<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.<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>
Line 51: Line 48:
 
</ul>
 
</ul>
 
<br>
 
<br>
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>
+
So lets fix this so that we get 100 points instead of 10, simply change that 1 to a 10.<br>
 +
<br>
 +
<b>Giving us something like this:</b><br>
 
<asm>
 
<asm>
 
Obj7D_Points: dc.w 0 ; Bonus points array
 
Obj7D_Points: dc.w 0 ; Bonus points array
Line 61: Line 60:
 
Build your ROM and test it out.<br>
 
Build your ROM and test it out.<br>
  
Hopefully it works and you get something like this:<br>
+
<b>Hopefully it works and you get something like this:</b><br>
 
<center>[[Image:Points_fixed_before.PNG|points before]]</center><br>
 
<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>
+
<i>It's the end of the stage, lets get those points.</i><br>
 
<br>
 
<br>
 
<center>[[Image:Points_fixed_after.PNG|points after]]</center><br>
 
<center>[[Image:Points_fixed_after.PNG|points after]]</center><br>
Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.<br>
+
<i>Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.</i><br>
 
<br>
 
<br>
Entire Object 7D code for reference:<br>
+
<b>Entire Object 7D code for reference:</b><br>
 
<asm>
 
<asm>
 
; ===========================================================================
 
; ===========================================================================

Revision as of 10:27, 26 April 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:

points before

It's the end of the stage, lets send Sonic in for more points.

points after

Something is wrong here. We have 12210 points, but 1200+100+1000+10000=12300.

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 lets 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 lets 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:

points before

It's the end of the stage, lets get those points.

points after

Yes! We have 11400 points, verifying that 300+100+1000+10000=11400.

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> --1337rooster 04:25, 26 April 2008 (UTC)