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.
| 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:
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):
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.