Difference between revisions of "Fix a remember sprite related bug"
From Sonic Retro
m (Grammar corrections and added category + S1Howtos template) |
m (Text replacement - "\[\[Category:SCHG How-tos.*" to "") |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 9: | Line 9: | ||
==Preventing the problem== | ==Preventing the problem== | ||
− | To fix the issue, go to "loc_DA10:": | + | To fix the issue, go to "loc_DA10:", and after this line: |
− | <asm> | + | <syntaxhighlight lang="asm"> |
− | |||
beq.s loc_DA02 | beq.s loc_DA02 | ||
+ | </syntaxhighlight> | ||
− | + | add this: | |
− | + | ||
− | <asm> | + | <syntaxhighlight lang="asm"> |
− | + | tst.b $04(a0) ; was this object a remember state? | |
− | + | bpl.s loc_DA16 ; if not, branch | |
− | tst.b $04(a0) | + | subq.b #$01,(a2) ; move right counter back |
− | bpl.s loc_DA16 | + | </syntaxhighlight> |
− | subq.b #$01,(a2) | ||
− | |||
This will ensure the remember counter for moving right is restored correctly if the SST was full. | This will ensure the remember counter for moving right is restored correctly if the SST was full. | ||
− | + | Go to "loc_DA3C:", and find this: | |
− | <asm> bset #7,2(a2,d2.w)</ | + | |
+ | <syntaxhighlight lang="asm"> bset #7,2(a2,d2.w)</syntaxhighlight> | ||
+ | |||
Change "bset" to "btst". | Change "bset" to "btst". | ||
− | Next | + | Next, go to "OPL_MakeItem:", and after this line: |
− | <asm> | + | |
− | bpl.s loc_DA80</ | + | <syntaxhighlight lang="asm"> |
− | + | bpl.s loc_DA80 | |
− | + | </syntaxhighlight> | |
− | <asm> | + | |
+ | Add this: | ||
+ | |||
+ | <syntaxhighlight lang="asm"> | ||
+ | bset #$07,$02(a2,d2.w) ; set as removed | ||
+ | </syntaxhighlight> | ||
+ | |||
These changes will ensure that if the object couldn't load, it doesn't set the remember "removed" flag. | These changes will ensure that if the object couldn't load, it doesn't set the remember "removed" flag. | ||
Line 43: | Line 49: | ||
{{S1Howtos}} | {{S1Howtos}} | ||
− | + | |{{PAGENAME}}]] |
Latest revision as of 11:11, 25 August 2018
(Original guide by MarkeyJester)
The object position loading routine (ObjPosLoad) loads a vertical strip of objects every 80 (hex) pixels, and as the screen scrolls along, the next 80 pixel strip is attended to. It runs through an object one at a time in this strip, checking and setting the remember flag values and loading the objects, until it's reached the end of the strip.
If however, the object RAM is full, the routine attempts to stop searching through the object list, however, it does not do this properly: When running right, it doesn't deset the remember flag and doesn't restore the remember counter; When running left, it doesn't deset the remember flag, full stop. This can lead to objects loading that are set as destroyed, or vise versa.
This issue generally never occurs in the original Sonic the Hedgehog title; Sonic Team were not reckless enough to fill an area in a level with too many objects. So, naturally, you won't see it much.
Preventing the problem
To fix the issue, go to "loc_DA10:", and after this line:
beq.s loc_DA02
add this:
tst.b $04(a0) ; was this object a remember state?
bpl.s loc_DA16 ; if not, branch
subq.b #$01,(a2) ; move right counter back
This will ensure the remember counter for moving right is restored correctly if the SST was full.
Go to "loc_DA3C:", and find this:
bset #7,2(a2,d2.w)
Change "bset" to "btst".
Next, go to "OPL_MakeItem:", and after this line:
bpl.s loc_DA80
Add this:
bset #$07,$02(a2,d2.w) ; set as removed
These changes will ensure that if the object couldn't load, it doesn't set the remember "removed" flag.
Final note
That'll solve the issue of rings, monitors, etc not remembering correctly under this circumstance. HOWEVER!! This will NOT fix the disappearing issue 100%. If there is no space in the object RAM, then objects will simply not load, the only way around that is to ensure that there are not so many objects placed within a single area. You must also keep in mind that certain objects create their own objects that also fill up the object RAM, such as the breakable wall in Green Hill Zone, which create multiple smaller object fragments.
|Fix a remember sprite related bug]]