øAslickproductions.org/forum/index.php?PHPSESSID=so1iojs5ocdn0o2vf0tti7fbu6&topic=1831.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index6b34.htmlslickproductions.org/forum/index.php?PHPSESSID=so1iojs5ocdn0o2vf0tti7fbu6&board=21.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index6b34.html.zxwôg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿȰU5'OKtext/htmlISO-8859-1gzip@øÕ5'ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 20:27:59 GMT0ó°° ®0®P®€§²ð®wôg^ÿÿÿÿÿÿÿÿq)5' FF3us - 255 hours on timer

Author Topic: FF3us - 255 hours on timer  (Read 8642 times)

Leviathan Mist

  • Schizophrenic Madman
  • *
  • Posts: 362
  • Gender: Male
  • Game over.
    • View Profile
    • Retro Gaming Central
FF3us - 255 hours on timer
« on: May 29, 2013, 04:22:01 AM »


This is an improvement hack for Final Fantasy III US (SNES). It raises the maximum value for the in-game timer from 99:59 to 255:59.

I finally got around to doing this. Thanks for the help, Leno :P

Odbarc

  • Hell's Rider
  • *
  • Posts: 424
  • Gender: Male
  • FF6 obsessed
    • View Profile
    • Newage3.com, a text based web game RPG I Admin.
Re: FF3us - 255 hours on timer
« Reply #1 on: June 02, 2013, 08:03:53 PM »
Neat. May prove to be vital for hacks which have a longer than the default-game length intended.

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF3us - 255 hours on timer
« Reply #2 on: June 02, 2013, 08:09:33 PM »
Excellent, thank you.  I was looking for that data to change myself.  Saved me any further work on it. :)

Now, any idea if it's possible to change the byte data value over to an integer (2 byte)?  :D

Leviathan Mist

  • Schizophrenic Madman
  • *
  • Posts: 362
  • Gender: Male
  • Game over.
    • View Profile
    • Retro Gaming Central
Re: FF3us - 255 hours on timer
« Reply #3 on: June 03, 2013, 06:58:02 PM »
Excellent, thank you.  I was looking for that data to change myself.  Saved me any further work on it. :)

Now, any idea if it's possible to change the byte data value over to an integer (2 byte)?  :D

I looked into that a bit, but gave up when I realized that I'd basically have to write a whole new formula for both the in-game timer and the SRAM timer data. I'm not good enough to formulate assembly code from scratch yet :P

The problem is that the game stores data in RAM for seconds, minutes, and hours - each one being a single byte. I'm not sure if you could find a fourth byte to use for hours, and even if you did, I'm not sure how much of the game you'd have to edit to make it work. In theory, you could rework the formula to turn the seconds/minutes/hours bytes into a single 3-byte seconds counter instead, which would give you a total of 16777215 seconds, or 4660 hours before it rolls over. That would require a complete formula rewrite for the timer itself.

Also keep in mind that Step Mine's spell cost is affected by timer data, so the formula for Step Mine would have to be altered as well.

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF3us - 255 hours on timer
« Reply #4 on: June 03, 2013, 10:40:25 PM »
Is it possible to show the seconds?  :D

Leviathan Mist

  • Schizophrenic Madman
  • *
  • Posts: 362
  • Gender: Male
  • Game over.
    • View Profile
    • Retro Gaming Central
Re: FF3us - 255 hours on timer
« Reply #5 on: June 04, 2013, 12:02:37 PM »
Is it possible to show the seconds?  :D

That is indeed possible, and would be relatively easy provided you had enough space. The area for the menu timer that would need to be modified is here (courtesy of the co-opted C3 Bank Disassembly doc):

Code: [Select]
C3/326C: AD8811  LDA $1188
C3/326F: 8910    BIT #$10
C3/3271: F016    BEQ $3289
C3/3273: AC8911  LDY $1189      (is $1189 the elapsed time in seconds?)
C3/3276: 20B232  JSR $32B2      (if so, this gives minutes)
C3/3279: 20B232  JSR $32B2      (and this would give hours)
C3/327C: A5E7    LDA $E7        (load A with hours)
C3/327E: 8D6318  STA $1863      (put hours in $1863)
C3/3281: AD1642  LDA $4216      (remainder is excess minutes)
C3/3284: 8D6418  STA $1864      (put that in $1864)
C3/3287: 800C    BRA $3295
C3/3289: AC1B02  LDY $021B      (Hours and minutes)
C3/328C: 8C6318  STY $1863      (store in SRAM)
C3/328F: AD1D02  LDA $021D      (Seconds amd frames)
C3/3292: 8D6518  STA $1865      (store in SRAM)
C3/3295: A920    LDA #$20
C3/3297: 8529    STA $29        (set text color to white)
C3/3299: AD6318  LDA $1863      (hours)
C3/329C: 20E004  JSR $04E0      (convert leading 0's to spaces)
C3/329F: A2FB7C  LDX #$7CFB     (The position, I believe)
C3/32A2: 20B604  JSR $04B6      (2 digits to display)
C3/32A5: AD6418  LDA $1864      (minutes)
C3/32A8: 20F904  JSR $04F9      (convert minutes to a displayable format)
C3/32AB: A2017D  LDX #$7D01
C3/32AE: 20B604  JSR $04B6      (JMP fool!, 2 digits to display)
C3/32B1: 60      RTS

You'd need to add the function for seconds display right before the RTS at C3/32B1. You'd also need to resize the timer window, and reposition hours and minutes. Here's how I would change it:

Code: [Select]
LDA $1863     
JSR $04E0     
LDX #$7CF5     (This will move the Hours counter 3 spaces to the left)
JSR $04C0      (This will change the counter from a 2-digit display to a 3-digit display)
LDA $1864     
JSR $04F9      (convert minutes to a displayable format)
LDX #$7CFB (This will move the minutes counter 3 spaces to the left)
JSR $04B6
LDA $1865 (seconds)
JSR $04F9 (convert to displayable format)
LDX #$7D01 (place where the minutes counter used to go)
JSR $04B6 (limit to 2 digits)
RTS

I'm not sure how this would affect the timer during timed events, such as catching Ultros in the opera house or the floating continent escape. There's a process which converts the timer from hours/minutes to minutes/seconds, but I can't remember where it's at.

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,688
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: FF3us - 255 hours on timer
« Reply #6 on: June 04, 2013, 10:59:16 PM »
That shouldn't be affected at all, since that timer is event-driven, which puts it in bank C0.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF3us - 255 hours on timer
« Reply #7 on: June 05, 2013, 04:41:30 AM »
if you're in a battle, C2/B936 converts the timer into minutes and seconds for display.

looking at Variable $628F, it seems that this function is called every 61 frames rather than every 60?  meaning the display update will lag 1 frame behind each actual second update.  and if you're in a battle for over 60 seconds, you might see a 2-second decrement in this timer display..

maybe i'm misreading something here.  i'll test it in an emulator going frame-by-frame.

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF3us - 255 hours on timer
« Reply #8 on: June 05, 2013, 05:14:57 AM »
hah; confirmed.  the 2-second jump will occur 61 seconds into the battle, but maybe sooner..  i'm not sure on what frame alignments a battle can start, but suppose the real timer is at 20 seconds and 0 frames when a battle commences.  the initial display will indicate those 20 seconds.  then the display is updated 61 frames later, when the real timer is at 18 seconds and 59 frames -- meaning you'll see the seconds go from 20 to 18 without the 19.

those monkeys were apparently confused by C2/B925, even though it's right above C2/B936.  i think changing the "LDA #$3C" at the start of the latter function to "LDA #$3B" oughta solve it.  that said, i still need to do the frame-by-frame check, and verify that there are indeed 61 frames between display updates.

Leviathan Mist

  • Schizophrenic Madman
  • *
  • Posts: 362
  • Gender: Male
  • Game over.
    • View Profile
    • Retro Gaming Central
Re: FF3us - 255 hours on timer
« Reply #9 on: June 05, 2013, 05:24:41 PM »
 :wtf: were they thinking?

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF3us - 255 hours on timer
« Reply #10 on: June 05, 2013, 06:53:41 PM »
Oh cool, thanks!  I will play with it maybe this weekend.  But since I'm a novice with assembly I do have a question.  How do I relocate the subroutine in question to another place in the ROM so I can expand on it?   I didn't see a pointer. 

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF3us - 255 hours on timer
« Reply #11 on: June 05, 2013, 08:58:22 PM »
Quote from: assassin
that said, i still need to do the frame-by-frame check, and verify that there are indeed 61 frames between display updates.

confirmed this as well.

:wtf: were they thinking?

i did call them "monkeys" for it, but i can understand their mistake.  they want to update the display every 60 frames, so they set a "frame delay" variable to 60 in Function C2/B936.  if Function C2/B925 worked like:

- decrement frame delay variable
- branch to C2/B936 if the variable is zero

their delay would be as intended.  but the function does the variable check *before* decrementing it.  apparently, this is to make the timer display update the very first time C2/B925 is called in a battle.  i think that the frame delay variable is a default of zero to start a battle (as are many other variables), so my hypothetical order above wouldn't work right in that case.

anyway, Square's order means that C2/B936 won't be called on a frame where the variable goes from 1-->0, but on the frame _after_ that.  to compensate for that extra 1-frame wait, they should have made Variable $628F one smaller, at 59.

and that's what i shall do, in The Easiest Patch Ever (tm).

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF3us - 255 hours on timer
« Reply #12 on: June 05, 2013, 10:20:57 PM »
Assassin, any thoughts on my post?  :D

assassin

  • Bane of Retards
  • *
  • Posts: 1,033
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: FF3us - 255 hours on timer
« Reply #13 on: June 05, 2013, 11:54:58 PM »
it was horrible! ;)  either:

1) change all references to $326C to have your new function's address, wherever that may be.  suppose it were located at C3/1234.  you'd change C3/311F to "20 34 12    JSR $1234", and C3/354B to "4C 34 12   JMP $1234".  C3/3143 and C3/3167, which enter Function C3/326C midway through at C3/3295, would also need to be adjusted.

so more generally, the format of the (non-relative) calls and branch instructions is: opcode (20h for the JSR, which is a call, or 4Ch for the jump JMP), low byte of offset, high byte of offset.  for a far call or jump, it's: opcode (22h for JSL, or 5Ch for JML), low byte of offset, high byte of offset, bank.

2) keep the original function in the same place, and just branch to free space to finish executing the added part.  so you'd include the first 7 instructions of Leviathan Mist's new code as written, then the first "JSR $04B6" would become "JMP $1234".  then at C3/1234, you'd have everything from the "JSR $04B6" through the end of his function.

this has the advantage of using less free space and not having to modify the functions that call or jump to C3/326C.  a disadvantage is that it's slightly slower due to the added "JMP $1234" instruction, but i doubt that matters.  hell, changing the "JSR $04B6" right before the "RTS" to a "JMP $04B6" like the disassembly recommends will make up for some of that.

JCE3000GT

  • Master of FF4
  • *
  • Posts: 1,429
  • Gender: Male
  • Vladof
    • View Profile
    • BlitzKrieg Innovations
Re: FF3us - 255 hours on timer
« Reply #14 on: June 07, 2013, 10:27:08 PM »
Ok, I will dissect this and see if I can get it to work.  :)  Will let you know if I cannot get it to work...