don't click here

Sonic 2 Timer Reversal

Discussion in 'Engineering & Reverse Engineering' started by xenoSonic, Jun 11, 2005.

  1. xenoSonic

    xenoSonic

    Tech Member
    27
    0
    0
    I figured out, with some help, how to do this a while back. It makes sense that if there's a time limit, the time remaining on that limit should be displayed, not the time elapsed.

    I had wanted to keep it as a unique feature for my hack, but I've decided to share my notes on how to do this ^_^ And yes, this requires use of hex :P


    Part 1: Setting things up

    This is where everything is set to respond to the timer reaching 0:00, instead of 9:59.
    Simply make the following changes to your ROM:

    Code (Text):
    1. $040816:0000 }
    2. $04082E:0000 } timer flashes
    3. $04086C:0000 } at minute 0
    4. $040884:0000 }
    5. $040DEC:0000 = 0 mins for time over
    6. $040DEE:003B = 0 secs for time over
    Part 2: Starting the timer at 9:59

    This simply initialises the timer to 9:59. The code also takes into account star posts, so they remember the time at which they were activated.
    Find a blank space in your ROM, 40 (28 in hex) bytes long, where XXXXXX is the offset of this blank space.

    Code (Text):
    1. $004234: 4EF900XXXXXX       //jump to offset $XXXXXX
    At offset $XXXXXX, add the following data (one continuous data string; I split it into separate lines to explain the code):

    Code (Text):
    1. $XXXXXX: 4EB900017AA4       //do the code what was replaced
    2.  
    3. 0C780000FE2266140C780000FE24660C   //check if time is 0:00 before updating (for starposts)
    4. 31FC3C3CFE2431FC0009FE22     //copy 9 to mins, 59 to secs, if the above is true
    5. 4EF90000423A       //return to start point
    EDIT: The reason for checking the time is 0:00 is so that the star posts "remember" the time you passed them. If this check wasn't in place, the time would always restart at 9:59 (thus allowing the player to pass one at 0:01 left, die, then get a fresh 9:59). As the game clears the timer to 0:00 before loading a level, the code sets the time to 9:59 only when a level loads.


    Part 3: The Countdown

    This bit starts the timer counting backwards. Find another blank space in your ROM, 18 (12 in hex) bytes long, where YYYYYY is the offset of this space.

    Code (Text):
    1. $040E12: 4EF900YYYYYY
    At offset $YYYYYY, add the following data:

    Code (Text):
    1. 0C780000FE2431FC3C3CFE244EF900040E18     //restarts the seconds at 59 after reaching 00
    Then finally, make the following changes:

    Code (Text):
    1. $040E00:5321 = seconds count down
    2. $040E0C:5321 = minutes count down
    This may seem obvious, but when adding data, make sure you are overwriting what's there, and ALWAYS make a backup!

    Hope this helps anyone who wishes to utilise a countdown timer.


    EDIT: Corrections made to code/data; incompatabilities with Kega now resolved.


    EDIT: A minor 'bug' exists that causes the timer to not update correctly when resuming at a starpost after a time-over. The game clears the stored time on a time-over event, and thus the timer isn't set properly. To prevent the game clearing the stored time after a time-over, go to offset $014034 and write "4E714E71".
     
  2. Kles

    Kles

    Member
    Didn't LOst do something like this in his one hack?
     
  3. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Nope. But LOst helped Xeno do this, and it's some excellent work.

    xenoSonic for member pls.
     
  4. Shadow Fire

    Shadow Fire

    Ultimate victory! Member
    1,557
    0
    16
    The Land of Darkness
    Sonic: The Lost Land (Series), The GCN (site)
    Screw that...

    xeno for Techie! XD
     
  5. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Nope.

    Not yet, anyway. Only time will tell...
     
  6. Syren

    Syren

    Member
    4,330
    0
    0
    Teesside, UK
    Reintergration
    Hey, this is handy for people who know nothing about ASM, it kinda gives an insight on something slightly easy. ^_^ Thanks! I might actually do something with this!
     
  7. xenoSonic

    xenoSonic

    Tech Member
    27
    0
    0
  8. Tweaker

    Tweaker

    Banned
    12,387
    2
    0
    Okay, I concur. xenoSonic for Tech Member!

    This is some great work, seriously. As if there wasn't enough in your hack, you take it even further. Great job. :thumbsup: