don't click here

Sonic 2 Time Bonuses

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

  1. xenoSonic

    xenoSonic

    Tech Member
    27
    0
    0
    If you've implemented the reverse timer, and finished a level, you'll notice that the time bonus still operates as if the timer was still counting upwards. There is a routine at offset $019480 that handles the time bonuses.

    I have tried to figure out how to get this to follow the timer backwards, but it's proving tricky, so I've come up with another solution that will allow the editing and setting of time bonuses whichever direction the timer is going. Again, this will require the use of hex, and some thinking.

    The following are my notes, and are much less of a 'guide' than how to set the timer going backwards.


    Code (Text):
    1. $019480 - time bonus code starts here
    2. $019494:00XX - XX-second interval per point-break
    3. $019496:72YY - There are YY point-breaks
    4. $0194D2 to $0194FC - The values for the bonuses.  These values are multiplied by 10 (0A in hex), to get the true point allocation.
    The default values for XX and YY are 0F and 14 respectively, and the amount of values between $0194D2 and $0194FC reflect this. If you wish to add more, then a little bit of programming will be required.

    To do this, find a blank space in your ROM, large enough to house your new point value 'array' (if you require point breaks every 10 seconds, and need this to happen for the full 10 minutes, you will need 60 (3C in hex) bytes of free space, plus an additional 6 bytes (which will be explained later)), where ZZZZZZ is the offset of this blank space.

    Code (Text):
    1. $0194A0: add 4EF900ZZZZZZ - this adds a pointer to offset $ZZZZZZ.
    2. $ZZZZZZ: add 31FB00##F7D24EF9000194A6 - ## = how many bytes to skip to get to the bonus point list.
    3. $ZZZZZZ + ##: this is where the values for the bonuses go.  Make sure you add enough values to cover the time period you wish to allocate bonuses for, and  remember, the value you input is multiplied by 10 (0A)!.
    IMPORTANT NOTE: if you are using the reverse timer, you will need to put this list in reverse order, and pad the beginning with 0000's until the full 10 minutes are accounted for (example below). This is due to how the code for allocating the bonuses works - it always starts from 0:00 and counts upwards (I haven't yet figured out how to get this code to follow the timer backwards).

    Now, when you've input all the relevant values, you need to point the game back to the original programming (this is where that extra 6 bytes of free space comes in). Add the following data here:
    Code (Text):
    1. 4EF9000194FC
    Reverse Timer bonus example

    Here, I'm using a 20-second interval between point breaks, and I'm only allocating bonuses for finishing between 9:59 and 5:00 on the timer.

    Code (Text):
    1. $019494:0014 - 20-second interval
    2. $019496:721E - 30 intervals (the full 10 minutes)
    3. $0194D2 - $0194FC - ignored, a new list is required.
    Code (Text):
    1. $0194A0: 4EF9000EBEA0 - points to offset $0EBEA0.
    2. $0EBEA0: 31FB000EF7D24EF9000194A6 - jump 0E bytes to the bonus point list
    The following data is the point value list. Make sure all the data is one continuous string, I've separated it to different lines so you can see what's going on:

    Code (Text):
    1. $0EBEB0:
    2.   000000000000 //0:00 to 1:00 (breaks at 0:20, 0:40, 1:00)
    3.   000000000000 //1:00 to 2:00 (breaks at 1:20, 1:40, 2:00)
    4.   000000000000 //2:00 to 3:00 (breaks at 2:20, 2:40, 3:00)
    5.   000000000000 //3:00 to 4:00 (breaks at 3:20, 3:40, 4:00)
    6.   000000000000 //4:00 to 5:00 (breaks at 4:20, 4:40, 5:00)
    7.   000A0014001E //5:00 to 6:00 (breaks at 5:20, 5:40, 6:00)
    8.   00280032003C //6:00 to 7:00 (breaks at 6:20, 6:40, 7:00)
    9.   00460050005A //7:00 to 8:00 (breaks at 7:20, 7:40, 8:00)
    10.   006400FA01F4 //8:00 to 9:00 (breaks at 8:20, 8:40, 9:00)
    11.   03E809C41388 //9:00 to 9:59 (breaks at 9:20, 9:40, 9:59)
    This achieves the following break system:

    Code (Text):
    1. 9:59 - 9:40: 50,000 pts
    2. 9:39 - 9:20: 25,000 pts
    3. 9:19 - 9:00: 10,000 pts
    4. 8:59 - 8:40: 5,000 pts
    5. 8:39 - 8:20: 2,500 pts
    6. 8:19 - 8:00: 1,000 pts
    7. 7:59 - 7:40: 900 pts
    8. 7:39 - 7:20: 800 pts
    9. 7:19 - 7:00: 700 pts
    10. 6:59 - 6:40: 600 pts
    11. 6:39 - 6:20: 500 pts
    12. 6:19 - 6:00: 400 pts
    13. 5:59 - 5:40: 300 pts
    14. 5:39 - 5:20: 200 pts
    15. 5:19 - 5:00: 100 pts
    16. 4:59 - 0:00: 0 pts

    This is not easy to explain, but I've done the best I can. I hope this helps!


    EDIT (10th March 2006): A typo has been corrected that caused the new time bonuses code to crash the game: 4EF0000194A6 was wrong, it should read 4EF9000194A6