Difference between revisions of "Fix the Hidden Points bug in Sonic 1"
From Sonic Retro
(Wikification, +cat) |
m (Text replacement - "\[\[Category:SCHG How-tos.*" to "") |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{GuideBy|1337Rooster}} | ||
+ | |||
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)]]. | 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)]]. | ||
− | You may not have noticed this, but ''Sonic 1'' has a glitch related to the hidden points earned by jumping after the signpost. | + | 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:''' | '''To illustrate this bug:''' | ||
− | <gallery widths=" | + | <gallery widths="320px" heights="224px" style="margin-left: auto; margin-right: auto; text-align: center"> |
Image:Points_before.PNG|It's the end of the stage, let's send Sonic in for more points. | Image:Points_before.PNG|It's the end of the stage, let's send Sonic in for more points. | ||
− | Image:Points_after.PNG|Something is wrong here. We have | + | Image:Points_after.PNG|Something is wrong here. We have 13230 points, but 2200+100+100+100+1000+10000=13500. |
</gallery> | </gallery> | ||
Line 13: | Line 15: | ||
So let's fix this. | 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:''' | + | 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'') |
− | <asm>; --------------------------------------------------------------------------- | + | <syntaxhighlight lang="asm"> |
+ | ; --------------------------------------------------------------------------- | ||
; Object 7D - hidden points at the end of a level | ; Object 7D - hidden points at the end of a level | ||
; --------------------------------------------------------------------------- | ; --------------------------------------------------------------------------- | ||
Line 24: | 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> |
''This is the object you want'' | ''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:''' | + | 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'') |
− | <asm>Obj7D_Points: dc.w 0 ; Bonus points array | + | <syntaxhighlight lang="asm">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> |
''This array represents the points sonic earns for the various types of hidden point objects revealed on screen.'' | ''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: | So this array tells us: | ||
Line 47: | Line 50: | ||
'''Giving us something like this:''' | '''Giving us something like this:''' | ||
− | <asm>Obj7D_Points: dc.w 0 ; Bonus points array | + | <syntaxhighlight lang="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</syntaxhighlight> |
Build your ROM and test it out. | Build your ROM and test it out. | ||
Line 57: | Line 60: | ||
<gallery widths="320px" heights="224px" style="margin-left: auto; margin-right: auto; text-align: center"> | <gallery widths="320px" heights="224px" style="margin-left: auto; margin-right: auto; text-align: center"> | ||
Image:Points_fixed_before.PNG|It's the end of the stage, let's get those points. | Image:Points_fixed_before.PNG|It's the end of the stage, let's get those points. | ||
− | Image:Points_fixed_after.PNG|Yes! We have | + | Image:Points_fixed_after.PNG|Yes! We have 15200 points, verifying that 3900+100+100+100+1000+10000=15200. |
</gallery> | </gallery> | ||
'''Entire Object 7D code for reference:''' | '''Entire Object 7D code for reference:''' | ||
− | <asm>; =========================================================================== | + | <syntaxhighlight lang="asm">; =========================================================================== |
; --------------------------------------------------------------------------- | ; --------------------------------------------------------------------------- | ||
; Object 7D - hidden points at the end of a level | ; Object 7D - hidden points at the end of a level | ||
Line 154: | Line 157: | ||
; --------------------------------------------------------------------------- | ; --------------------------------------------------------------------------- | ||
Map_obj7D: | Map_obj7D: | ||
− | include "_maps\obj7D.asm"</ | + | include "_maps\obj7D.asm"</syntaxhighlight> |
− | + | {{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"
|Fix the Hidden Points bug in Sonic 1]]