Final Fantasy IV Research & Development / Re: FFIV Job System (Culmination of all of our works and hacks)
« on: April 27, 2015, 11:00:43 AM »Just a warning: It will require the use of 19 NPCs from each list (Overworld and Underworld/Moon).
So, first, an explanation of how I did what I did in TfW...
In vanilla FFIIUS, when you enter any location (that is, place that might contain NPCs - anywhere but a world map), the game runs the following 12 times (once for each possible NPC):
$00/BEE3 BF 00 83 13 LDA $138300,x[$13:8300];Load NPC ID into A
$00/BEE7 20 B7 C0 JSR $C0B7 [$00:C0B7] ;Jump to routine that loads all of the pertinent details of that NPCNow, in TfW, I only have one variable NPC ("Your Hired Help"), which may be any one of seven NPCs. To illustrate, this is a snippet of my FF4kster config file:
245 No Hired Party!!!
246 Hired Ninja!!!
247 Hired W Mage!!!
248 Hired B Mage!!!
249 Hired Dragoon!!!
250 Hired Bard!!!
251 Mog!!!
252 Heart Bubble !!!
253 Mysidia White Mage praying
254 Mysidia Black Mage praying
255 Your Hired Help!!!("!!!" signals an NPC I've used, and lets me know during the editing process that I should leave that one alone)Here, we're concerned with NPCs 245-251, and 255.
So, instead of the above code from vanilla, when a player in TfW enters a location, the game runs the following:
$00/BEE3 22 B0 8D 14 JSL $148DB0[$14:8DB0] ;jump to custom
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$14/8DB0 BF 00 83 13 LDA $138300,x[$13:8AFD];load NPC ID
$14/8DB4 C9 FF CMP #$FF
$14/8DB6 D0 35 BNE $35 [$8DED] ;if not FF, branch to end
$14/8DB8 AD 99 12 LDA $1299 [$00:1299] ;otherwise, load "hired help" logging flags
$14/8DBB C9 20 CMP #$20
$14/8DBD D0 04 BNE $04 [$8DC3]
$14/8DBF A9 FB LDA #$FB ;if flag 205 is set, load Mog
$14/8DC1 80 2A BRA $2A [$8DED]
$14/8DC3 C9 10 CMP #$10
$14/8DC5 D0 04 BNE $04 [$8DCB]
$14/8DC7 A9 FA LDA #$FA ;if flag 204 is set, load Avon
$14/8DC9 80 22 BRA $22 [$8DED]
$14/8DCB C9 08 CMP #$08
$14/8DCD D0 04 BNE $04 [$8DD3]
$14/8DCF A9 F9 LDA #$F9 ;if flag 203 is set, load Lando
$14/8DD1 80 1A BRA $1A [$8DED]
$14/8DD3 C9 04 CMP #$04
$14/8DD5 D0 04 BNE $04 [$8DDB]
$14/8DD7 A9 F8 LDA #$F8 ;if flag 202 is set, load Cinna
$14/8DD9 80 12 BRA $12 [$8DED]
$14/8DDB C9 02 CMP #$02
$14/8DDD D0 04 BNE $04 [$8DE3]
$14/8DDF A9 F7 LDA #$F7 ;if flag 201 is set, load Ruby
$14/8DE1 80 0A BRA $0A [$8DED]
$14/8DE3 C9 01 CMP #$01
$14/8DE5 D0 04 BNE $04 [$8DEB]
$14/8DE7 A9 F6 LDA #$F6 ;if flag 200 is set, load Blank
$14/8DE9 80 02 BRA $02 [$8DED]
$14/8DEB A9 F5 LDA #$F5 ;otherwise, load "nobody"
$14/8DED 6B RTL
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$00/BEE7 20 B7 C0 JSR $C0B7 [$00:C0B7] ;Jump to routine that loads all of the pertinent details of that NPCThere's also this:
$00/BE6F BF 00 83 13 LDA $138300,x[$13:8300]Which deals specifically with loading NPC images when exiting the menu screen back to gameplay. This also needs to be changed to JSL $148DB0, or else when you exit the menu, "hired" NPCs will have the right palette, but will use the main character's sprite instead of their own.
So that's how I did it in my project.
For this one, it'll take more NPCs, but the amount of custom code will be about the same (possibly a bit less).
As I said, you'll need to use 19 NPCs per set to make this work.
They will be known as:
Character in Slot 2
Character in Slot 3
Character in Slot 4
Character in Slot 5
"nobody"
DK Cecil
Kain
C Rydia
Tellah
Edward
Rosa
Yang
Palom
Porom
P Cecil
Cid
Edge
FuSoYa
A Rydia
Assuming that you're using the Shadow party hack for this project, I would suggest using NPCs FC-FF (252-255) as "Character in Slot (2-5)," NPCs EA-F7 (235-247) for "nobody" through FuSoYa, and 251 for A Rydia. Rydia being separated from the rest will make the coding a little more efficient. You'll see why...
So, you'll need a JSL to custom in the same two places - $BEE3 and $BE6F.
Your custom assembly will look like this:
BF 00 83 13 LDA $138300,x ;Load NPC ID
C9 FF CMP #$FC ;is it "character in Slot (something)?"
90 18 BCC $18 ;if not, skip to end
38 SEC
E9 FC SBC #$FC ;subtract FC from A
C2 20 REP #$20
0A ASL A
0A ASL A
0A ASL A
0A ASL A
0A ASL A
0A ASL A ;multiply result by 0x40
DA PHX ;stack X
AA TAX ;Transfer A to X
7B TDC
EB XBA
E2 20 SEP #$20 ;clear A and set it back to 8-bits
BD 40 10 LDA $1040,x ;Load Character ID into A
18 CLC
69 EA ADC #$EA ;Add 0xEA to A, making it the value of the appropriate NPC
FA PLX ;pull X back off the stack
6B RTLDoing all that should make it so that NPC FC will always be the character in slot 2 (and nobody if there is no character there), FD will always be the character in slot 3, and so on.
You'll probably also want to rewrite the "change charcter graphic to XX" event code so that it always changes character graphic to that of the character in slot 1 (why not, since the possible party variations make it essentially worthless anyway). You'd have to rework any scene that calls for the character graphic to be that of a particular character, but you'll probably have to do that anyway in this hack.
I think that should do it!
We have EVEN MORE themes now, but some old ones are gone...
