BG bug in Sonic 1

Discussion in 'Discussion and Q&A Archive' started by Psycho RFG, Nov 27, 2011.

Thread Status:
Not open for further replies.
  1. Psycho RFG

    Psycho RFG Well-Known Member Member

    Joined:
    Feb 22, 2011
    Messages:
    234
    I found a new bug in my hack... but it's not my hack bug, because I have tested and it's happening in the original Sonic 1 too.


    The best way to see it is in any Green Hill Zone act, and pass over a checkpoint, then lose a life and start from the lamp post and go back to the start of the level.... you will notice bad bg at the very begining like this:


    [​IMG]


    Has this been comented before? Why is this happening? any fix?
     
  2. MarkeyJester

    MarkeyJester ♡ ! Member

    Joined:
    Jun 27, 2009
    Messages:
    2,867
    I commented on this once before, what happens is there's a position for that BG section which isn't calculated based on the current X position, instead it's changed based on if the X position has changed or not (it's difficult to explain, sorry).


    But basically, the position of that BG is saved when you pass the lamppost, and is then restored when you get restored to the lamppost, however, Sonic doesn't always pass the lamppost being in EXACTLY the same position as the post, instead he's usually a few minor pixels away from the post (moving at the speed of 1 to 10 pixels per frame), but being restored to the post, you don't get restored to the EXACT position as you hit the lamppost, instead you get stored to the position OF the lamppost.


    This misaligns the BG section's position with Sonic and the screen, so the BG will therefore always be misaligned from there on, and it gets worse the more times you hit another lamppost, die, and then restore from there.


    Because the BG position of that section isn't "calculated based on", it means trying to work out the position of what the BG will be at the lamppost itself, won't be easy, you'd have more luck storing Sonic's current X position and restoring that to Sonic and the screen instead of the lamppost's position. Of course, that will mean that Sonic will never start at exactly the same position as the post (he will always be off by a few pixels).


    Sorry if it doesn't make much sense, it's hard to explain.
     
  3. SSGD

    SSGD "I can't believe what cool boots you have on!" Member

    Joined:
    Nov 14, 2011
    Messages:
    125
    Location:
    Room 101
    So essentially the alignment between background and foreground is out of sync with one another due to memory state of the game remembering sonics position after he runs past a checkpoint. So with this in mind, if I were to look up the checkpoint lamppost data in the ASM file would the be anything there that could be tweaked to fix this bug? Or would the problem lie in another place like background alignment itself?
     
  4. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    Wow, that's a good find, never noticed that bug before. And I've fixed it in my hack without even realising it lol (if it happens in Sonic 2 or not I do not know, going to find out now though!)


    EDIT: Seems to not happen in Sonic 2 anyway.
     
    Last edited by a moderator: Nov 27, 2011
  5. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    With MJ's explanation, knowing how the problem happens, there are several solutions/fixes/workaround to avoid it.


    1- There's probably a way to calculate the background's coordinates depending on the lamppost rather than Sonic (ie simulating another camera's movement when you hit the lamppost, but don't display it on screen).


    2- If you can't do it the way described above, to have Sonic both restored exactly at the lamppost and with the right background alignment, you could use an array containing the background's position for every lamppost in the game.


    3- To have the background aligned, but Sonic not exactly at the lamppost, save Sonic's position when he hits the lamppost, and restore that position rather than using the lamppost's coordinates.


    4- To have the background glitch not visible, yet the background not perfectly aligned, and Sonic at the lamppost's coordinates, you can modify the saved coordinates of the background to move it to the left by a few pixels.


    5- I think this is what happens in S3K, although I didn't check thoroughly: have the beginning of the level unreachable from the first lamppost, hide it behind Plane A, or resize the screen like a boss does.


    There are probably other ways to deal with it.


    It all depends on how critical you think the problem is and the efforts you want to put in fixing it.
     
  6. Psycho RFG

    Psycho RFG Well-Known Member Member

    Joined:
    Feb 22, 2011
    Messages:
    234
    OK, thanks to all for your replys. Specially MarkeyJester for the explanation and SpirituInsanum for the possible ways to fix it. I found where the bg info is saved, but no idea of what is each one for:



    Code:
    
      move.w ($FFFFF708).w,($FFFFFE44).w  ; bg position
    
      move.w ($FFFFF70C).w,($FFFFFE46).w  ; bg position
    
      move.w ($FFFFF710).w,($FFFFFE48).w  ; bg position
    
      move.w ($FFFFF714).w,($FFFFFE4A).w  ; bg position
    
      move.w ($FFFFF718).w,($FFFFFE4C).w  ; bg position
    
      move.w ($FFFFF71C).w,($FFFFFE4E).w  ; bg position
    
    


    Well, about SpirituInsanum options, the first option looks the better, but no idea of how to proceed with it... The option 4 looks the easiest, althought not too much accurate... anyway this 2 options I think could be the best way to fix this.

    [/CODE]
     
    Last edited by a moderator: Nov 27, 2011
  7. SpirituInsanum

    SpirituInsanum Well-Known Member Member

    Joined:
    Feb 11, 2010
    Messages:
    642
    Most people never noticed the problem in 20 years, so I doubt many people really care about a pixel perfect alignment. Unless you really want it fixed, say, for the challenge, options 3 and 4 are definitely the easiest ways to deal with it.
     
  8. redhotsonic

    redhotsonic Also known as RHS Member

    Joined:
    Aug 10, 2007
    Messages:
    2,969
    Location:
    England
    If the bug only happens when you hit a starpost and you go ALL the way back to the beginning, it's hardly worth fixing. No one will notice. I didn't until you just mentioned it.
     
  9. Psycho RFG

    Psycho RFG Well-Known Member Member

    Joined:
    Feb 22, 2011
    Messages:
    234
    I noticed this sometimes, but never knew where it come from.... So now while I was doing my hack, after a few tries, I finally noticed it was something about the lamp post. I know is not a very important bug, but it will be good to fix now we know what is causing this.


    I have never worked with this so if someone can guide me on how to do it, I will be very thankfull. I think option 4 is what I should try.
     
Thread Status:
Not open for further replies.