Actions

SCHG How-to

Difference between revisions of "Fix a remember sprite related bug"

From Sonic Retro

(Another Sonic 1 bug fix involving objects that remember they were collected/destroyed)
 
m (Grammar corrections and added category + S1Howtos template)
Line 3: Line 3:
 
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.
 
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.
+
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.
+
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==
 
==Preventing the problem==
Line 41: Line 41:
  
 
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.
 
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.
 +
 +
{{S1Howtos}}
 +
[[Category:SCHG How-tos|{{PAGENAME}}]]

Revision as of 10:39, 24 November 2014

(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:": <asm>loc_DA10: bsr.w loc_DA3C beq.s loc_DA02

loc_DA16:</asm> Change it to this: <asm>loc_DA10: bsr.w loc_DA3C beq.s loc_DA02 tst.b $04(a0) ; MJ: was this object a remember state? bpl.s loc_DA16 ; MJ: if not, branch subq.b #$01,(a2) ; MJ: move right counter back

loc_DA16:</asm> This will ensure the remember counter for moving right is restored correctly if the SST was full.

Goto "loc_DA3C:", and find this: <asm> bset #7,2(a2,d2.w)</asm> Change "bset" to "btst".

Next goto "OPL_MakeItem:", and find this: <asm> move.b (a0)+,d0 bpl.s loc_DA80</asm> Place this directly under the bpl instruction:

<asm> bset #$07,$02(a2,d2.w) ; MJ: set as removed</asm> 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.

SCHG How-To Guide: Sonic the Hedgehog (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix the SEGA Sound | Display the Press Start Button Text | Fix the Level Select Menu | Fix the Hidden Points Bug | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix the Walk-Jump Bug | Correct Drowning Bugs | Fix the Death Boundary Bug | Fix the Camera Follow Bug | Fix Song Restoration Bugs | Fix the HUD Blinking | Fix the Level Select Graphics Bug | Fix a remember sprite related bug
Changing Design Choices
Change Spike Behavior | Collide with Water After Being Hurt | Fix Special Stage Jumping Physics | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Remove the Speed Cap | Port the REV01 Background Effects | Port Sonic 2's Level Art Loader | Retain Rings Between Acts | Add Sonic 2 (Simon Wai Prototype) Level Select | Improve ObjectMove Subroutines | Port Sonic 2 Level Select
Adding Features
Add Spin Dash ( Part 1 / Part 2 / Part 3 / Part 4 ) | Add Eggman Monitor | Add Super Sonic | Add the Air Roll
Sound Features
Expand the Sound Index | Play Different Songs Per Act | Port Sonic 2 Final Sound Driver | Port Sonic 3's Sound Driver | Port Flamewing's Sonic 3 & Knuckles Sound Driver | Change The SEGA Sound
Extending the Game
Load Chunks From ROM | Add Extra Characters | Make an Alternative Title Screen | Use Dynamic Tilesets | Make GHZ Load Alternate Art | Make Ending Load Alternate Art | Add a New Zone | Set Up the Goggle Monitor | Add New Moves | Add a Dynamic Collision System | Dynamic Special Stage Walls System | Extend Sprite Mappings and Art Limit | Enigma Credits | Use Dynamic Palettes
Miscellaneous
Convert the Hivebrain 2005 Disassembly to ASM68K
Split Disassembly Guides
Set Up a Split Disassembly | Basic Level Editing | Basic Art Editing | Basic ASM Editing (Spin Dash)