Bugfix: What button do we press?
For the very first post in this blog, I decided that we should take a look at the very first bug that can be seen in Sonic 1, which is a little ironic because it's a bug that, in fact, can't be seen! Look at the Title Screen and ask yourself if anything seems amiss:
It all looks good, right? Sonic looks normal, as does the title and the background, right? Ok. Now look at the title screen a second time:
Wait, where did this come from? "PRESS START BUTTON"... A keen eye that's seen Sonic Mania, or the Mobile release of Sonic 1 will recognize the font style of these letters, so what's the deal? Did I just photoshop, or hack, this prompt into existence? Well, not exactly. I mean, I did some minor hacking to make it appear, but the fact is that they've always been there the entire time, but were never seen due to a minor glitch.
How do we fix it?
Fixing this is quite easy. Assuming you are using the updated Sonic Retro GitHub disassembly (), go to TitLoad_Text: and find this piece of code:
The 3rd line move.w #7,d1 needs to be slightly changed. Here is what your code should look like:
Why does this happen?
This is the result of a small mishap. Literally one digit rendered an object invisible! But, why? Well, before the Title Screen, you see blue text saying SONIC TEAM PRESENTS. The object that shows this text occupied Object Slot 3 (v_objspace+$80) and was supposed to be cleared after it was shown. That's what Tit_ClrObj2: does. The problem is that it's not fully cleared. Every object is $40 (64) bytes, meaning that the instruction that clears 4 bytes must be repeated $F (15) more times. Only half the RAM gets cleared and the sprite is unable to appear. I'll cover object RAM in another post that could explain this a little more.
This is merely a microcosm of what programming can be like. The smallest typos can cause the biggest mistakes. Luckily for Sonic Team, this cluster of leftover object data didn't have any major impact.
It all looks good, right? Sonic looks normal, as does the title and the background, right? Ok. Now look at the title screen a second time:
Wait, where did this come from? "PRESS START BUTTON"... A keen eye that's seen Sonic Mania, or the Mobile release of Sonic 1 will recognize the font style of these letters, so what's the deal? Did I just photoshop, or hack, this prompt into existence? Well, not exactly. I mean, I did some minor hacking to make it appear, but the fact is that they've always been there the entire time, but were never seen due to a minor glitch.
How do we fix it?
Fixing this is quite easy. Assuming you are using the updated Sonic Retro GitHub disassembly (), go to TitLoad_Text: and find this piece of code:
lea (v_objspace+$80).w,a1 ; load object slot 3 into a1 register
moveq #0,d0 ; d0 = 0. We are going to clear slot 3
move.w #7,d1 ; HERE IS THE PROBLEM
Tit_ClrObj2:
move.l d0,(a1)+ ; clear 4 bytes of object ram in slot 3
dbf d1,Tit_ClrObj2 ; Repeats 7 more times (d1)
move.b #id_TitleSonic,(v_objspace+$40).w ; loads big Sonic object into slot 2
The 3rd line move.w #7,d1 needs to be slightly changed. Here is what your code should look like:
lea (v_objspace+$80).w,a1 ; load object slot 3 into a1 register
moveq #0,d0 ; d0 = 0. We are going to clear slot 3
move.w #$F,d1 ; ($40 / 4) - 1
Tit_ClrObj2:
move.l d0,(a1)+ ; clear 4 bytes of object ram in slot 3
dbf d1,Tit_ClrObj2 ; Repeats $F more times (d1)
move.b #id_TitleSonic,(v_objspace+$40).w ; loads big Sonic object into slot 2
Why does this happen?
This is the result of a small mishap. Literally one digit rendered an object invisible! But, why? Well, before the Title Screen, you see blue text saying SONIC TEAM PRESENTS. The object that shows this text occupied Object Slot 3 (v_objspace+$80) and was supposed to be cleared after it was shown. That's what Tit_ClrObj2: does. The problem is that it's not fully cleared. Every object is $40 (64) bytes, meaning that the instruction that clears 4 bytes must be repeated $F (15) more times. Only half the RAM gets cleared and the sprite is unable to appear. I'll cover object RAM in another post that could explain this a little more.
This is merely a microcosm of what programming can be like. The smallest typos can cause the biggest mistakes. Luckily for Sonic Team, this cluster of leftover object data didn't have any major impact.
Comments
Post a Comment