Final Fantasy IV Research & Development / Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« on: December 27, 2013, 06:00:03 PM »The last thing I want to present is unnecessarily long code.What? You mean you don't want to be like the FFIV developers?
Thanks for taking a look at this for me as well.Assuming this is not tongue-in-cheek (since you didn't ask, I just kinda butted in), no problem. This kinda stuff is fun for me compared to where I am in my little preview project - writing in character palettes using SNESPal. Ugh!
So here's the updated code. I tested it and it works, though as before, I did not test the resultant character's attacks on the pertinent monsters.
$03/D8B0 AD 97 26 LDA $2697 [$7E:2697] ;Load caster's Wisdom into A
$03/D8B3 A2 00 00 LDX #$0000 ;Load 0000 into X
$03/D8B6 C9 50 CMP #$50 ;Compare caster's Wisdom with 50(H), or 80(Dec)
$03/D8B8 90 02 BCC $02 [$D8BC] ;If it is less, skip the next op
$03/D8BA A9 50 LDA #$50 ;If it is 50 or more, load 50 into A
$03/D8BC C9 14 CMP #$14 ;Compare caster's Wisdom with 14(H), or 20(Dec)
$03/D8BE 90 06 BCC $06 [$D8C6] ;If it is less, skip ahead to 03/D8C6
$03/D8C0 E8 INX ;Increase X by 1
$03/D8C1 38 SEC
$03/D8C2 E9 0A SBC #$0A ;Subtract 0A, or 10(Dec), from A
$03/D8C4 80 F6 BRA $F6 [$D8BC] ;Loop back up to 03/D8BC
$03/D8C6 A9 80 LDA #$80 ;load 01 into A
$03/D8C8 E0 00 00 CPX #$0000 ;Compare X with 0000
$03/D8CB F0 06 BEQ $06 [$D8D3] ;if X is 0000 (first time around, this means caster's wisdom is less than 20), then skip ahead to 03/D8D3
$03/D8CD CA DEX ;Decrease X by 1
$03/D8CE 4A LSR A ;Divide A by 2, or more appropriately here, shift the bits in A one spot to the right
$03/D8CF 09 80 ORA #$80 ;OR A with 80, or more appropriately here, set A's bit 7 to 1
$03/D8D1 80 F5 BRA $F5 [$D8C8] ;Loop back up to 03/D8C8
$03/D8D3 0D 1A 27 ORA $271A [$7E:271A] ;OR A with Target's "strong against" byte
$03/D8D6 8D 1A 27 STA $271A [$7E:271A] ;Store A in target's "strong against" byte
$03/D8D9 60 RTS