News: 11 March 2016 - Forum Rules

Author Topic: Dash in FF4...is ASM the answer?  (Read 4234 times)

Spooniest

  • Hero Member
  • *****
  • Posts: 3417
  • Kuru zotsu!!
    • View Profile
Dash in FF4...is ASM the answer?
« on: July 25, 2012, 11:59:17 pm »
Right now I'm trying to figure out if there's a way to add a "dash button" to Final Fantasy IV (J). Do I need to learn Assembly, or am I barking up the wrong tree?

EDIT: I've found my first lead, in the form of a PAR code:

7E06AC02
7E06AD10

This enables fast walking, not only in towns and dungeons, but also quite comically during story scenes. Nothing spectacular, but a good start. I should note that this is much faster than I would have liked, and of course, I want to include the functionality of having to press the cancel button in order to activate the ability.

EDIT 2: I figured something out:

7E06AC02
7E06AD10

If I edit the code in blue to 7E06AC01, I get a Cecil that walks at the speed I want, but again, this is everywhere, in towns, dungeons, on the world map, during story scenes, everywhere.
« Last Edit: July 26, 2012, 01:14:57 am by Spooniest »
Yamero~~!

Azkadellia

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 868
  • 提交向你的情妇!
    • View Profile
    • Princess Translations
Re: Dash in FF4...is ASM the answer?
« Reply #1 on: July 26, 2012, 01:50:46 am »
AFAIK, You'd have to hook into the controller routine to check for a button press, then have the code redirected to the walking speed (is what I get from the concept).

There's also the matter of screen scrolling needing to be updated as well (see the Phantasy Star 3 hack thread for that).
Current Projects: On hold indefinitely.
I do the Twitter thing now: https://twitter.com/MistressSaeko (expect lots of game streaming announcements)
Mistress of the RHDN Discord server.

Spooniest

  • Hero Member
  • *****
  • Posts: 3417
  • Kuru zotsu!!
    • View Profile
Re: Dash in FF4...is ASM the answer?
« Reply #2 on: July 26, 2012, 01:53:00 am »
Yes, I was reading it, but is ASM capable of doing such a thing?

EDIT:

This is from the readme file in MasterZED's "Dash Button" patch for Final Fantasy 3/6. Of course, I have no idea what it means, but I thought it might be relevant.

Quote
------------------------------------------------------------------------------------------
2. Relevant offsets and disassembly
------------------------------------------------------------------------------------------

Sprint Shoes check

Accumulator = 8-bit, Index registers = 16-bit, Data Bank register = 00h

NOTE: This check is exactly the same between FF6j, FF3us v1.0 and FF3us v1.1.

$C0/4E21 AD B8 1E    LDA $1EB8   ;Load event flag offset for no sprinting
$C0/4E24 29 02       AND #$02    ;AND for no sprinting flag only
$C0/4E26 D0 0B       BNE $4E33   ;Branch if flag set
$C0/4E28 AD DF 11    LDA $11DF   ;Load offset with Sprint Shoes bit
$C0/4E2B 29 20       AND #$20    ;AND for Sprint Shoes bit only
$C0/4E2D F0 04       BEQ $4E33   ;If no Sprint Shoes, branch
$C0/4E2F A9 03       LDA #$03    ;Load Sprint Shoes walking speed...
$C0/4E31 80 02       BRA $4E35   ;and branch
$C0/4E33 A9 02       LDA #$02    ;Load normal walking speed
$C0/4E35 99 75 08    STA $0875,y ;Store walking speed

FF3SpntA changes

$C0/4E21 AD 19 42    LDA $4219   ;Load 2nd byte for controller 1
$C0/4E24 29 80       AND #$80    ;AND for B button only
$C0/4E26 D0 07       BNE $4E2F   ;Branch if button pressed/held

FF3SpntB changes

$C0/4E28 20 74 D6    JSR $D674   ;Jump to subroutine at $C0:D674
$C0/4E2B 80 08       BRA $4E35   ;Branch to walking speed storage

Subroutine $D674:

$C0/D674 A9 02       LDA #$02    ;Load normal walking speed
$C0/D676 48          PHA         ;Push walking speed onto the stack
$C0/D677 AD 19 42    LDA $4219   ;Load 2nd byte for controller 1
$C0/D67A 29 80       AND #$80    ;AND for B button only
$C0/D67C F0 03       BEQ $D681   ;Branch if button not pressed or held
$C0/D67E 68          PLA         ;Pull walking speed from the stack
$C0/D67F 1A          INC         ;Increment for Sprint Shoes speed
$C0/D680 48          PHA         ;Push walking speed back onto the stack
$C0/D681 AD DF 11    LDA $11DF   ;Load offset with Sprint Shoes bit
$C0/D684 29 20       AND #$20    ;AND for Sprint Shoes bit only
$C0/D686 F0 03       BEQ $D68B   ;If no Sprint Shoes, branch
$C0/D688 68          PLA         ;Pull walking speed from the stack
$C0/D689 1A          INC         ;Increment for Sprint Shoes/max speed
$C0/D68A 48          PHA         ;Push walking speed back onto the stack
$C0/D68B 68          PLA         ;Pull walking speed from the stack
$C0/D68C 60          RTS         ;Return from subfunction

FF3SpntC changes

$C0/4E21 20 74 D6    JSR $D674   ;Jump to subroutine at $C0:D674
$C0/4E24 80 0F       BRA $4E35   ;Branch to walking speed storage

Subroutine $D674:

$C0/D674 A9 02       LDA #$02    ;Load normal walking speed
$C0/D676 48          PHA         ;Push walking speed onto the stack
$C0/D677 AD 19 42    LDA $4219   ;Load 2nd byte for controller 1
$C0/D67A 29 80       AND #$80    ;AND for B button only
$C0/D67C F0 03       BEQ $D681   ;Branch if button not pressed or held
$C0/D67E 68          PLA         ;Pull walking speed from the stack
$C0/D67F 1A          INC         ;Increment for Sprint Shoes speed
$C0/D680 48          PHA         ;Push walking speed back onto the stack
$C0/D681 AD DF 11    LDA $11DF   ;Load offset with Sprint Shoes bit
$C0/D684 29 20       AND #$20    ;AND for Sprint Shoes bit only
$C0/D686 F0 03       BEQ $D68B   ;If no Sprint Shoes, branch
$C0/D688 68          PLA         ;Pull walking speed from the stack
$C0/D689 1A          INC         ;Increment for Sprint Shoes/max speed
$C0/D68A 48          PHA         ;Push walking speed back onto the stack
$C0/D68B 68          PLA         ;Pull walking speed from the stack
$C0/D68C 60          RTS         ;Return from subfunction
« Last Edit: July 26, 2012, 02:30:31 am by Spooniest »
Yamero~~!

LostTemplar

  • Hero Member
  • *****
  • Posts: 910
    • View Profile
    • au-ro-ra.net
Re: Dash in FF4...is ASM the answer?
« Reply #3 on: July 26, 2012, 03:03:24 am »
Yes, I was reading it, but is ASM capable of doing such a thing?

By changing the assembler code you can do just about anything, and it's usually the only way to accomplish more complex things (like making a dash button).

It's probably going to look like the code you posted, only that in FF4 you're going to have to code everything yourself because you can't just hijack some other routine (here: the Sprint Shoes check routine). If the walking speed is fixed, you will need to introduce a new variable that stores the current speed, and load it from that variable instead of the fixed value. Then, you have to insert a routine that checks if the B button is pressed and accordingly set the walking speed to the correct value.

Spooniest

  • Hero Member
  • *****
  • Posts: 3417
  • Kuru zotsu!!
    • View Profile
Re: Dash in FF4...is ASM the answer?
« Reply #4 on: July 26, 2012, 05:16:06 am »
Wouldn't I also have to set a flag check to see if the party is on the world map, in order to keep the speed of walking back at the default level when on the world map?

And wouldn't I have to do something about the animation of the walking sprites, to speed it up when you have the B button pressed?
Yamero~~!

LostTemplar

  • Hero Member
  • *****
  • Posts: 910
    • View Profile
    • au-ro-ra.net
Re: Dash in FF4...is ASM the answer?
« Reply #5 on: July 26, 2012, 05:25:08 am »
That all depends on how the engine handles it. But you're right, if the game only uses one fixed walking speed all through the game, you probably have to change a lot more. For example, if the dungeons/towns and the world map use the same walking code, then yes, you'd have to check whether you're on the world map or not. However, the code might be separate. If you're lucky, then the animation is handled automatically, otherwise you'd have to change the delay between the animation frames as well. I guess it usually should be though, because the instants when the sprite's position is changed should coincide with the animation.

justin3009

  • Hero Member
  • *****
  • Posts: 1666
  • Welp
    • View Profile
Re: Dash in FF4...is ASM the answer?
« Reply #6 on: July 26, 2012, 10:35:34 am »
For the flag to check, I'm sure there's a certain byte that's always used either in World Map or Towns/Dungeons and such.  In any case, you'd just have to check if that byte is actually active or not.  If not, simply do not load the routine.

I haven't really played FF4 but I'm going to assume there isn't a problem with screen scrolling if the characters are faster.  If there truly isn't, then you have no need to worry about that.  All you'd have to do is do an ASM check to see if the Cancel button is being pressed, in which case, you store a new value to 7E06AC.  Then when it's not being pressed, it sets it back to its normal speed (Which would be where the routine ends if it's a World Map essentially).
'We have to find some way to incorporate the general civilians in the plot.'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'