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:
$040816:0000 } $04082E:0000 } timer flashes $04086C:0000 } at minute 0 $040884:0000 } $040DEC:0000 = 0 mins for time over $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.
$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):
$XXXXXX: 4EB900017AA4 //do the code what was replaced 0C780000FE2266140C780000FE24660C //check if time is 0:00 before updating (for starposts) 31FC3C3CFE2431FC0009FE22 //copy 9 to mins, 59 to secs, if the above is true 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.
At offset $YYYYYY, add the following data:
0C780000FE2431FC3C3CFE244EF900040E18 //restarts the seconds at 59 after reaching 00
Then finally, make the following changes:
$040E00:5321 = seconds count down $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".