Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - LightPhoenix

Pages: 1
1
Final Fantasy V Research & Development / Character Glow and Palettes
« on: February 15, 2013, 08:21:02 PM »
Another minor thing, but could be useful.  I was screwing around with palette information mainly to create a new status.  I eventually coded up a rough FF6-style glow effect.

All character palette information (afaik) is handled by a function located at C1/B1AC.  This function is relatively straightforward.  First, it checks to see if the character is Wounded; if so it uses the default character palette.  Otherwise, it loads the class palette.  Then it runs two sets of checks; one for Status 0/1 (palette changes) and a second for Status 2 (glowing effects).  As coded, once a palette change effect is handled, the function skips to the glow effect.  In order: Stone, Zombie, Poison, Aging, Berserk.  Similarly, once a glow effect is set, the function skips to the end.  In order: Wall, Armor, Shell, Stop, Haste, Slow.  There's no reason multiple palette changes couldn't be applied with simple code changes, and some relatively simple coding could even allow multiple glow colors.

Palette information is stored at 7E/7F89,Y for each character, and is 0x20 bytes long (16 2-byte values).  Note that "glow" effects are really just changing the palette outline (at 7F8B) in a simple on/off manner.  I have a basic list of what each 16-bit value controls, but not with me: I'll update this post when I can grab the notebook.

[EDIT]My list isn't as detailed as I thought it was, but for the sake of reference:
Code: [Select]
7F8B: Outline (ie Glow)
7F8F: Eyes
7F91: Skin A (see Berserk/Zombie)
7F93: Hair A (see Old)
7F99: Skin B
7F9B: Hair B (shadow)
7F9D: Hair C (highlight)

2
This is a minor bit of information that anyone modding spells will find useful.  Again, this was just sitting around, and I figured I should share it.

The determination of what spells can be used in battle is performed whenever the equipped commands change.  This code can be found at C2/E6E0, and is relatively straight-forward.  The code loops over the character's equipped abilities, sets the level for each magic type, and then saves this data in three bytes per character (see below).  There is special handling for Red and X-Magic that sets both the White and Black magic levels.  This data is saved to 7E/053D-3F and copied to 7E/203D-3F for use in battle.

Code: [Select]
7E053D XX          1st Player Sword/White Display                                     
7E053E XX          1st Player Black/Dimen Display                                     
7E053F XX          1st Player Summon/Misc Display
(Layout borrowed from samurai goroh's FFV document)

This data is further parsed in battle menus at a beefy bit of code that starts (I think) at C2/4287.  I haven't quite deciphered it yet, but the basic mechanism of action is that the spell level (7E/203D-F) and learned spells (7E/0950) mask the spells you can't cast.

The determination of what spells can be used out of battle is contained in a three byte lookup table starting at C0/EEF4.  I have not verified everything, but the data format appears to be as follows: Spell Number/Index, Magic Type, Row * 3.  I do not know if the second and third bytes actually perform any function.  It's very simple: if the Spell Number is in this list, it can be cast outside of battle.

3
Hey everyone.  I have a bunch of stuff that I've researched to varying degrees that I wanted to share.  Most of it is minor but useful stuff.  However, I wanted to share my research on the FF5 menus with everyone.  I haven't seen this info readily available anywhere, although I'm sure it's been looked into before.  It's not complete by any means, but it's been sitting around for a month or two without being worked on.

Menu drawing seems to start at subroutine C2/C16A.  The chosen menu ID (MID) is one byte stored in $43.  The enumeration of menus starts at 01, not 00.  The values range from 01 to 0D; no sanity checks are run on the value, so you can crash the game changing it.  The MID is used as the index for a lookup table at C0/F5E7, which gets the address for a MVN for the menu data.  The menu data is a set of twelve addresses stored at C0/F601, grouped into three sets of four.  I've provided this data below.  Each group of three uses a separate function, as indicated in the column headers.  The numbers in the header indicate the destination in RAM (bank 7E) where the data is written to.

Code: [Select]
         | Fxn C2/C1B8         | Fxn C2/C1F7         | Fxn C2/C1A6
         | 2000 3000 4000 5000 | 7000 7080 7100 7180 | 7200 7280 7600 7500 
Menu ID  | BG1  BG2  BG3  BG4  | ???  ???  ???  ???  | Msk1 Msk2 Ctrl Sett   
--------------------------------------------------------------------------
01 Main  | 0000 0000 AD3F AD65 | 0000 0000 B816 B822 | AC86 AC98 A300 ABBA
02 Abil  | 0000 ADE3 ADF4 AE5E | 0000 B82C B82F B84F | ACCE 0000 A382 ABCB
03 Job   | 0000 0000 AEEA AF0F | 0000 0000 B85C B862 | 0000 0000 A434 ABDC
04 Equip | 0000 AF3C AF4D B02B | 0000 B868 B87A B88C | ACDA 0000 A4EE ABED
05 Stats | 0000 0000 B095 B0D3 | 0000 0000 B89A B8A0 | ACE6 0000 A598 ABFE
06 Store | 0000 B19F B1EB B237 | 0000 B8B0 B8BB B8D1 | ACF2 0000 A5A2 AC0F
07 Item  | 0000 0000 B363 B3B7 | 0000 0000 B8C9 B8D1 | ACF2 AD01 A73C AC20
08 Magic | 0000 0000 B3D6 B3F3 | 0000 0000 B8E0 B8E6 | 0000 0000 A856 AC31
09 Confg | 0000 0000 B66E 0000 | 0000 0000 B93E 0000 | 0000 0000 AA38 AC75
0A Find  | 0000 0000 B636 0000 | 0000 0000 B919 0000 | 0000 0000 AA26 AC64
0B Save  | 0000 B536 AD3F 0000 | 0000 B8FD B816 B905 | AD1F 0000 A978 AC42
0C Load  | 0000 B56A AD3F 0000 | 0000 B8FD B816 B905 | AD1F 0000 A9AA AC42
0D Name  | 0000 0000 B5F5 B620 | 0000 0000 B90F 0000 | AD10 0000 A9E4 AC53

Each address is a location in the C3 bank that indicates the data to get for use in the functions.  A value of 0000 indicates no data; this iteration of the function will be skipped.

The first set of four draws the actual windows to the background layers.  The data is a list of instructions on how to draw the menu windows.  The data format is one byte for the instruction with a number of parameter bytes following, depending on the instruction.  The lookup for number of bytes per instruction is located at C3/AD31.  There are 7 instructions, 00 through 06.  I don't know the exact differences between some instructions, but a rough guide:

Code: [Select]
00 | End of Inst. List  | 0b |
01 | Fill Current Layer | 2b | Char#, Color
02 | Draw Box           | 6b | Char#, Color, X, Y, Width, Height
03 | Draw Bordered Box  | 6b | Char#, Color, X, Y, Width, Height
04 | Draw Text          | 5b | String#, Color, X, Y, Removed (Note: Color non-functional)
05 | Change Layer       | 2b |
06 | Draw Indented Box  | 6b | Char#, Color, X, Y, Width, Height (Calls 03/02)

The second set of four I have not as of yet decoded.  The data is parsed into what seems like a longer instruction set, but I have not discovered how it works.

The third set of four control, in order, window masks one and two, menu control, and window mask settings.  See Anomie's register doc for information on the window masks.

The interesting bit is the presumptive cursor control and selection handling.  There is a two byte header indicating the length in bytes of the data set, followed by a set of eight byte instructions.  Each instruction has the following format (based on the item menu):

Code: [Select]
00 | Instruction Type
01 | Instruction Parameter
02 | Cursor Position X
03 | Cursor Position Y
04 | Up Button Parameter
05 | Down Button Parameter
06 | Left Button Parameter
07 | Right Button Parameter

The instruction set is implicitly enumerated (ie, order matters).  The Up/Down/Left/Right parameters go to the indicated instruction.  Cursor position is self-explanatory.  The instruction type and parameter indicate what to do.  In the case of a cursor selection, it indicates what to do when the accept button is pressed.  In the case of a special instruction (for example, scrolling the menu up/down), it indicates a passed parameter.

4
Pandora's Box / Issue With Patching, Could Use Some Help
« on: October 13, 2011, 12:47:39 AM »
I was hoping to try PB, but I can't get xdelta to patch the game.  I've confirmed with NRST and the readme file that I have the correct ROM - both the CDC32 and MD5 match.  I downloaded the 2b patch from the website.  When I run either xdelta program listed in the readme, it gives me the following error: xdelta3: target window checksum mismatch: XD3_INVALID_INPUT.  I don't have much experience with the XDelta format, but I'm assuming this means the ROM is incorrect?  Any advice would be welcome, as I'm eager to see what's been done.

5
Final Fantasy V Research & Development / Replacing Command Abilities
« on: December 24, 2010, 09:59:54 PM »
(Merry Christmas!)

There are up to six things we have to do in order to replace an ability with a new one:

1) Spell Entry
2) Animation Entry
3) Effect Code (in C2)
4) Animation Code (in C1)
5) Text
6) Job Info

As an example, I will be replacing the command "Pray" with "Psych" and giving it to a Black Mage at JLvl 4.  For simplicity, the ability will function almost exactly like the spell.  The one change will be the MP cost, which will be 0.

Note: I'll be assuming people reading this will be familiar with the basics of the data format.  All that information is on the site here.  Please feel free to share this information.

1) Spell Entry

Many abilities in the game are actually spells that are called via code (see Part 3).  In fact, the code interpreting these is for all intents and purposes identical.  We could simply copy the spell data for Psych to the ability data for Pray, change the MP cost, and skip straight to editing text.  In fact, for this simple change, that's pretty much what we're going to do.  That won't always be the case, as I'll demonstrate with a subsequent example.

So, copy the Psych data to D1/5AE8 (where the Pray ability is located), and change the MP to 0.  Easy!  You'll want to note the ability offset as well, which is 21.

2) Animation Entry

We don't just want our Psych ability to act like Psych, we want it to look like it as well.  Luckily, we're using an animation that already exists, so we don't actually have to do much here.  However, if you wanted to add a new animation, you could do so by editing the animation data table.

We do want to know the offset of our animation though; it's 35.

3) Effect Code

All abilities call a snippet of code that sets up the animation and effect.  This uses indirect addressing; there's a lookup table at C2/4A92 that is a list of addresses.  This maps to the list of command abilities, with one big caveat: subtract one from the ability number to get the offset.  I don't know why they skip ability number 00 (Nothing), but it does.  So, Pray is ability number 21, so we want entry 0x20.  Our Pray code is at C2/1169.  NOTE: If you have InstructrTrepe's function offset list, several of the addresses for the commands are wrong.  I've verified this in code and with breakpoints.  Use the lookup table to be certain.

Here's our Pray code.  I've noted the functions of each subroutine.
Code: [Select]
C2/1169: A9 21        LDA #$21
C2/116B: 20 AA 16     JSR $16AA   Load Ability Parameters
C2/116E: 20 5F 17     JSR $175F   Get Selection
C2/1171: 20 A9 02     JSR $02A9   Separate Enemy/Ally Targets
C2/1174: 20 C2 02     JSR $02C2   Count Targets
C2/1177: A9 21        LDA #$21
C2/1179: 20 FA 16     JSR $16FA   Queue Banner
C2/117C: A9 20        LDA #$20
C2/117E: 20 E1 16     JSR $16E1   Queue Ability Animation
C2/1181: 20 1A 17     JSR $171A   Get Attack Type
C2/1184: 20 35 17     JSR $1735   Increment Effect Counter
C2/1187: 4C E3 98     JMP $98E3   Run Effect

As you can see, there are three functions that take a parameter (16AA, 16FA, 16E1).  We don't need to change the ability or the banner.  Now, you may be thinking we need to change the input for Queue Ability Animation.  It makes sense, right?  Unfortunately, it's also incorrect.  We'll leave it at #20.

4) Animation Code

So why exactly did we leave the input for QAA at #20?  The detailed answer is a little complex, and not strictly necessary to understand for this basic example.  However, that parameter actually indicates the value for a lookup table at C1/8D88, which leads to the following code:
Code: [Select]
C1/9909 20 93 9D    JSR $9D93   
C1/990C A9 0B       LDA #$0B
C1/990E 20 EC 96    JSR $96EC
C1/9911 A2 D8 00    LDX #$00D8 Anim: Pray
C1/9914 20 9C B6    JSR $B69C Run Animation
C1/9917 7B          TDC       
C1/9918 4C EC 96    JMP $96EC    Continue Animations

The important lines are the LDX and subroutine $B69C.  All abilities call bits of code like this, which are animation handlers.  For Pray, this is pretty simple.  Go ahead and change that #00D8 to #0035.

5) Text

This is relatively straight-forward.  Change the ability name at E0/1237; this also changes the text for the menu and the banner.  Change the description at D1/776A, but make sure to keep it at 24 bytes (use padding if needed).  The lookup table for description addresses starts at D1/716C.

If you went on to Part 6, then pulled up the menu, you'd notice that the job level information is still indicating Chemist L4.  Interestingly, this is not text, but a byte value that indicates job and level.  This data is located at C0/F739, and uses the same ability offset.  Bytes 0-4 indicate the job number, and bytes 5-7 indicate the level.  So we go to offset 21 at C0/F75A, which is currently set at #90.  Parsing that code, it's job number 10 (Chemist) and level 4.  We're going to change that to 8A (job A, level 4).

6) Job Info

If you've made it this far, you shouldn't have a problem with this next part.  Calculate or lookup the offset for the job info table (38), go to the data, and change the learned ability to #21.  Now you're ready to go!

6
Submissions / FF5 Doc: Spell Animation Guide v0.8
« on: October 24, 2010, 11:24:44 PM »
Not much to say, standard txt file.  More info on the FF5 forum.

[attachment deleted by admin]

7
I came upon this during a foray into how jobs are added in game.  There's not much, but I figured I'd throw it out here if someone wanted to look into it.

At the Wind Shrine, jobs are set at a function that roughly starts at C0/BEE9.  The actual set is at C0/BEFA.  Anyway, while I was looking at this, I noticed data streaming at 7E/0BDE-E3.  In code it's referenced as $DE, but the bank is set to 0B.  The data here was C6 06 C6 07 C6 0A.  As jobs were added, this data shifted left; ie after one job was set, it moved to C6 08 C6 0A C6 0B.

Anyway, it's very tenuous but I figured I'd throw it out there.  I don't have any other notes, and it was hastily scribbled down, not even a half of a page.  I'm too busy with the battle animations to really devote time to it right now.  Hopefully someone can do something with it.

8
Final Fantasy V Research & Development / Spell Animation Guide v0.85
« on: January 20, 2010, 02:50:13 PM »
Version 0.85 is out!

I didn't get nearly as far as I wanted to this month, so I'm calling it version 0.85.  Unfortunately my work schedule for the next three to four weeks is brutal, and I can't guarantee I'll make much progress on the guide.  I also don't get any time off for the holidays (I work at a hospital).  Nonetheless, my plan is to update this on or around January 1st.

I'm proud to say that of the main 128 functions, only two are unknown.  F7 is a complete unknown to me right now; it's used in Exploder, and may be an enemy-only function.  Removing it from the Blue spell has absolutely no discernible effect.  FC runs based on the target, sets a flag, and that's all I know.  I think it's a flag to change rows, since it's used in Pull.  Of the F5/F6 functions, I'd estimate about a third of them are known, including most of the F5 functions.  In particular, Missile and Roulette functions are giving me a bit of trouble.

I'd like people who read through to comment on anything confusing or unclear.  If there's any issues, I can try to clarify or fix anything.

9
Final Fantasy V Research & Development / Investigating the Battle System
« on: October 02, 2009, 01:04:24 PM »
I've just started looking into hacking FF5, and a question I've had is how the battle system knows which attack type to call, both generally and particularly with regards to Fight.  Anyway, this might be something already known, but I haven't seen documentation on it, so I thought I'd share.

I'd been going off of instructrtrepe's C2 bank, since it was better commented.  The attack type subroutines start at C2:6870, and process from there.  This is common knowledge, it seems.  However, how does the system know which type to call?  Given the variable size of the subroutines, I figured it had to be an index of addresses.  Keeping in mind little-endian coding, I did a search for two addresses in sequence - 6EE1 (Atk Type 31/Swords) and 6F1E (AT 32/Knives).  Sure enough, it turns out that there is an index of every attack type subroutine two-byte addresses starting at C2:7B21 through C2:7C0C.  Incidentally, this information is incorrectly presented as code in instructrtrepe's assembly file.  Lenophis' dump does not present the section as code.

I'm still looking into things, but I thought I'd share since I didn't see it anywhere on the site.

Pages: 1