øAslickproductions.org/forum/index.php?PHPSESSID=30bpcljig9e61f9onc3766mng2&topic=2092.msg23730e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index0baf-3.htmlslickproductions.org/forum/index.php?topic=2092.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index0baf-3.html.zx=¿h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ0PdÕsOKtext/htmlISO-8859-1gzip0|ÖÕsÿÿÿÿÿÿÿÿWed, 11 Mar 2020 10:53:09 GMT0ó°° ®0®P®€§²ð®<¿h^ÿÿÿÿÿÿÿÿÞ=Õs FF4A (E) Hacking Notes and Mod

Author Topic: FF4A (E) Hacking Notes and Mod  (Read 11395 times)

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
FF4A (E) Hacking Notes and Mod
« on: July 15, 2015, 03:05:10 AM »
Recently I've been hacking the European version of Final Fantasy 4 Advance, and have made notes on its data structures, ASM code and AI scripting as I went along. Since there doesn't seem to be much documentation on this version that I could find, I though I'd share my notes here.

This is a link
to my notes, including modules for use with the Nightmare table editing program (not very flexible, but it's dead easy to use). It includes documentation on item,spell and monster data, encounter sets, encounter setting (eg. what music to play, whether some monsters start out hidden), monster AI, chest contents and more; the bulk of my notes are in "ff4a-structs.txt", which was originally based off of notes by PKT Paladin.

I've started putting some of that knowledge to use in a mod for this game. The purpose of the mod is simply to make the game more challenging and interesting while reducing some of the tedium. It's still incomplete as of this writing but I work on it pretty regularly.

Here is some custom ASM code for the hack I've written that might be helpful or interesting to others:

More variance for encounter RNG
If you've played FF4a before, you probably know how the encounter system is messed up: the same battles tend to occur over and over again, and saving+loading doesn't help. This is mostly due to the fact that the RNG used to determine what you encounter and when is seeded from only one thing: the amount of time you spend on the file loading screen. This tends to produce very similar seeds, leading to the same pattern of encounters recurring.

This code fixes this problem by seeding this RNG with your save file's game clock in addition to the above:
$0827E6: 2188 401A 0F49 6052 3CF0 D3FA 2188 4018
Paste write the above byte sequence to $827E6 in the FF4 Advance (E) ROM.

Allow monsters to use their Magic Defence Multiplier
Normally, a monster's MDef Multiplier in the ROM is never written to their RAM battle data. To undo this, make the following change:
   $93082: Write 0000
Note that all monsters have zero Magic Evasion by default, so you'd need to give them values yourself.

Back Row functions almost properly
In the European version, melee weapons have no penalty to Attack or Precision for attacking from the back row, while the actual long-range weapons (Bows, Harps, Boomerangs and Whips) do receive a penalty. To fix:
      $8A858: 07D1
      $8A868: 00D0
 Currently my code fixes this by making your attack Back Row-Ok if you have any long-ranged weapons equipped, which means that Edge with a katana and boomerang can attack at full power from the back row. A more nuanced fix requires more space (and therefore repointing code).

Modular elemental weaknesses from armor
By default, armor that resists Ice or Fire is hardcoded to give a weakness to the opposing element, unless your equipment protects against Fire,Ice and Lightning all at once. This code ties elemental weaknesses to a byte in armor's affinity data instead:

Equipment (including weapons!) can have elemental weaknesses that apply to the actor (byte 0x1 in affinity data):
Start of Battle $9F440: 4178 0023 0B43 A08C 1FF0 A8FC 4178 0B43 A08D 1FF0 A3FC 4178 0B43 E08D 1FF0 9EFC 4178 0B43 208E 1FF0 99FC 4178 0B43 2222 AB54 28E0
During Battle $9DA2E: 4578 B88C 21F0 ADF9 4078 0543 B88D 21F0 A8F9 4078 0543 F88D 21F0 A3F9 4078 0543 388E 21F0 9EF9 4078 0543 2221 7554 29E0 0000

Monsters' basic attacks can be imbued with elements (byte 0x6 in monster elemental data):
(ASM) $7F7000: 5088 A083 9088 2084 9079 6076 3188 7046 0430 0047
(ASM) Link from $93156: 0148 2BF0 12FE 01707F08

Simple- this lets you have Fiery Hounds attack with a Fire element. Handle with care: elemental physical attacks do triple damage when hitting a weakness!

Reworked Boss Bit vs Status system
By default, enemies with the boss bit show immunity to all status effects in the Bestiary. Normally this is accurate since almost all spells have the boss bit (or rather, don't have the bit that lets them affect bosses), but if you change that, this code will only make a monster's explicit status immunities show on their Bestiary entry.

Updating Bestiary screen:
$121D0: 00000000

That's all I've got for now, but I might have some other things to show at another time.  :cycle:
« Last Edit: August 05, 2015, 12:46:52 PM by Kea »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #1 on: July 15, 2015, 11:43:52 AM »
Recently I've been hacking the European version of Final Fantasy 4 Advance, and have made notes on its data structures, ASM code and AI scripting as I went along. Since there doesn't seem to be much documentation on this version that I could find, I though I'd share my notes here.

This is a link
to my notes, including modules for use with the Nightmare table editing program (not very flexible, but it's dead easy to use). It includes documentation on item,spell and monster data, encounter sets, encounter setting (eg. what music to play, whether some monsters start out hidden), monster AI, chest contents and more; the bulk of my notes are in "ff4a-structs.txt", which was originally based off of notes by PKT Paladin.

I've also written some custom ASM code for a little hack of mine that might be helpful to others.

More variance for encounter RNG
If you've played FF4a before, you probably know how the encounter system is messed up: the same battles tend to occur over and over again, and saving+loading doesn't help. This is mostly due to the fact that the RNG used to determine what you encounter and when is seeded from only one thing: the amount of time you spend on the file loading screen. This tends to produce very similar seeds, leading to the same pattern of encounters recurring.

This code fixes this problem by seeding this RNG with your save file's game clock in addition to the above:
$0827E6: 2188 401A 0F49 6052 3CF0 D3FA 2188 4018
Paste write the above byte sequence to $827E6 in the FF4 Advance (E) ROM.

Allow monsters to use their Magic Defence Multiplier
Normally, a monster's MDef Multiplier in the ROM is never written to their RAM battle data. To undo this, make the following change:
   $93082: Write 0000
Note that all monsters have zero Magic Evasion by default, so you'd need to give them values yourself.

Back Row functions almost properly
In the European version, melee weapons have no penalty to Attack or Precision for attacking from the back row, while the actual long-range weapons (Bows, Harps, Boomerangs and Whips) do receive a penalty. To fix:
      $8A858: 07D1
      $8A868: 00D0
 Currently my code fixes this by making your attack Back Row-Ok if you have any long-ranged weapons equipped, which means that Edge with a katana and boomerang can attack at full power from the back row. A more nuanced fix requires more space (and therefore repointing code).

Modular elemental weaknesses from armor
By default, armor that resists Ice or Fire is hardcoded to give a weakness to the opposing element, unless your equipment protects against Fire,Ice and Lightning all at once. This code ties elemental weaknesses to a byte in armor's affinity data instead:

Equipment (including weapons!) can have elemental weaknesses that apply to the actor (byte 0x1 in affinity data):
Start of Battle $9F440: 4178 0023 0B43 A08C 1FF0 A8FC 4178 0B43 A08D 1FF0 A3FC 4178 0B43 E08D 1FF0 9EFC 4178 0B43 208E 1FF0 99FC 4178 0B43 2222 AB54 28E0
During Battle $9DA2E: 4578 B88C 21F0 ADF9 4078 0543 B88D 21F0 A8F9 4078 0543 F88D 21F0 A3F9 4078 0543 388E 21F0 9EF9 4078 0543 2221 7554 29E0 0000

Monsters' basic attacks can be imbued with elements (byte 0x6 in monster elemental data):
(ASM) $7F7000: 5088 A083 9088 2084 9079 6076 3188 7046 0430 0047
(ASM) Link from $93156: 0148 2BF0 12FE 01707F08

Simple- this lets you have Fiery Hounds attack with a Fire element. Handle with care: elemental physical attacks do triple damage when hitting a weakness!

Reworked Boss Bit vs Status system
By default, enemies with the Boss Bit are protected against all forms of status (but Slow/Sap), and a few other things besides. This code moves it closer to the SNES system, where status spells only fail against a boss if the spell also has a boss bit.

New system: Boss bit only prevents status spells if they have a boss bit too!
Regular status resistances still apply, however.
Byte +$07 of spell data is the boss bit; if bit 00 is set, the spell will fail against enemies with the boss bit.
Status spell logic:
$8B02E: 5B49 084B 795A 0901 5B18 D879 0121 0140 0029 06D1 09E0
$8B054: 2890E008

Updating Bestiary screen:
$121D0: 00000000

That's all I've got for now, but I might have some other things to show at another time.  :cycle:


The European Version is normally considered to be the superior version all around. I'm surprised to know there is still so much wrong with it! Well we are glad to have a compatriot working at other angles to fixing FFIV and maybe we can learn a couple of things from one another.

Quote
Allow monsters to use their Magic Defence Multiplier
Normally, a monster's MDef Multiplier in the ROM is never written to their RAM battle data. To undo this, make the following change:
   $93082: Write 0000
Note that all monsters have zero Magic Evasion by default, so you'd need to give them values yourself.

Wait a moment... are you telling me that FF4A goes a Step further and outright removes Magical Defense Multipliers from enemies? Granted they are non functioning without Magic Evasion, but that... seems so bizarre. So does FF4A actually have the code to properly place Evasion and Magical Evasion in an enemy's stats or is That still busted from the SNES version?

Quote
Back Row functions almost properly
In the European version, melee weapons have no penalty to Attack or Precision for attacking from the back row, while the actual long-range weapons (Bows, Harps, Boomerangs and Whips) do receive a penalty. To fix:
      $8A858: 07D1
      $8A868: 00D0
 Currently my code fixes this by making your attack Back Row-Ok if you have any long-ranged weapons equipped, which means that Edge with a katana and boomerang can attack at full power from the back row. A more nuanced fix requires more space (and therefore repointing code).

Ugh... I had thought this was supposed to be fixed in the European and Japanese version? I guess not... This is a fine fix and the Boomerang/Katana mix makes it the same as what every version of FFIV has allowed. So don't worry. Even Square thought it was too much trouble to bother with.

Quote
Modular elemental weaknesses from armor
By default, armor that resists Ice or Fire is hardcoded to give a weakness to the opposing element, unless your equipment protects against Fire,Ice and Lightning all at once. This code ties elemental weaknesses to a byte in armor's affinity data instead:

Equipment (including weapons!) can have elemental weaknesses that apply to the actor (byte 0x1 in affinity data):
Start of Battle $9F440: 4178 0023 0B43 A08C 1FF0 A8FC 4178 0B43 A08D 1FF0 A3FC 4178 0B43 E08D 1FF0 9EFC 4178 0B43 208E 1FF0 99FC 4178 0B43 2222 AB54 28E0
During Battle $9DA2E: 4578 B88C 21F0 ADF9 4078 0543 B88D 21F0 A8F9 4078 0543 F88D 21F0 A3F9 4078 0543 388E 21F0 9EF9 4078 0543 2221 7554 29E0 0000

This is a really neat idea for those who don't want Weakness tied to basic Element. I may have to consider something similar for FFIV down the line. I've taken a look at your notes and FF4A has a boatload of more room for what to do with Weapons and Armors! FFIV has to rely on a stringent Bonus Index which forces down possibility by a fair amount and has a more open accuracy system where as FFIV has a basic (00 = 00 Accuracy) (63 = 99 Accuracy.) with only 8 Bytes to each weapon instead of 12 and the same 8 bytes for Armor compared to !?20?!. What I think I could do is tie it into that weird unused "item type identifier byte" which to my knowledge doesn't actually do anything. You also managed to put it on Weapons though which would be a much tougher sell all around in normal FFIV.

There is also some interesting notes on spells you have here! Again they've really increased the possibility there. Even allowing easy access to previous Routine-set statuses.

Quote
Monsters' basic attacks can be imbued with elements (byte 0x6 in monster elemental data):
(ASM) $7F7000: 5088 A083 9088 2084 9079 6076 3188 7046 0430 0047
(ASM) Link from $93156: 0148 2BF0 12FE 01707F08

Simple- this lets you have Fiery Hounds attack with a Fire element. Handle with care: elemental physical attacks do triple damage when hitting a weakness!

They removed this functionality? Yes, it was unused in SNES FFIV, but it still functioned to my knowledge if you implemented it on monsters.

I am looking forward to hearing more from you! Your notes may be of use to us here and vice versa.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #2 on: July 15, 2015, 12:46:33 PM »
Quote

Wait a moment... are you telling me that FF4A goes a Step further and outright removes Magical Defense Multipliers from enemies? Granted they are non functioning without Magic Evasion, but that... seems so bizarre. So does FF4A actually have the code to properly place Evasion and Magical Evasion in an enemy's stats or is That still busted from the SNES version?
Yes, the physical Defence Multiplier, Evasion and Magic Evasion are all properly handled in the code; it's just the MDef Multiplier which is specifically coded to not do anything. Why they felt the need to do this when every enemy has a zero in their evades already, well, I couldn't say other than that TOSE didn't do a great job coding this port.

Quote
Ugh... I had thought this was supposed to be fixed in the European and Japanese version? I guess not... This is a fine fix and the Boomerang/Katana mix makes it the same as what every version of FFIV has allowed. So don't worry. Even Square thought it was too much trouble to bother with.
Yeah, the Euro/ JP 1.1 versions just broke the back row in the opposite way. Actually, looking at what the vanilla code does again, it only applies the Back Row penalty if you have two weapons and both of your weapons are back row OK.  :wtf:

So in reality, it's 'just' Bows/Arrows and Edge w/ two Boomerangs that get penalized. I have no idea why they coded it this way other than that they just reversed the check from the 1.0 version because they didn't understand the problem...

Quote
This is a really neat idea for those who don't want Weakness tied to basic Element. I may have to consider something similar for FFIV down the line. I've taken a look at your notes and FF4A has a boatload of more room for what to do with Weapons and Armors! FFIV has to rely on a stringent Bonus Index which forces down possibility by a fair amount and has a more open accuracy system where as FFIV has a basic (00 = 00 Accuracy) (63 = 99 Accuracy.) with only 8 Bytes to each weapon instead of 12 and the same 8 bytes for Armor compared to !?20?!. What I think I could do is tie it into that weird unused "item type identifier byte" which to my knowledge doesn't actually do anything. You also managed to put it on Weapons though which would be a much tougher sell all around in normal FFIV.
Armor and weapons both have the same number of bytes actually - 12 for weapon/armor data, 8 for elemental/status/racial data, and 20 more for general item data. Because of the way the weakness routine is set up it was no added challenge to allow weapons to give elemental weaknesses, it's an item in a slot just like shields.


Quote
Quote
Monsters' basic attacks can be imbued with elements (byte 0x6 in monster elemental data):

They removed this functionality? Yes, it was unused in SNES FFIV, but it still functioned to my knowledge if you implemented it on monsters.

It was indeed removed; fortunately there's a free byte in monster affinity data, so it's easy to add it back in.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #3 on: July 17, 2015, 07:57:52 PM »
I spent some time yesterday figuring out how sprites and palettes are assigned to weapons and managed to make a lot of progress! I haven't figured everything out - I don't yet know how sound effects are selected when you attack - but I'm sure I'll get that done in time. Here's how it works, as I understand it:

When a character is going to physically attack, a table at 0x80CB434 is indexed to using the ID of your currently equipped weapon:

Code: [Select]
Weapon Animation Definitions
$00-01: Weapon sprite/palette ID; must be odd
Leads to two pointers in CAAD4 table...first is sprite data, second is palette
$02-03: Unused - may have been Custom sound effect ID?:
$0C1: Shuriken,Fuma Shuriken, Rising Sun, Scrap Metal
$0F9: Sword of Legend, Light Sword, Excalibur, Caliburn
$0FB: Defender
$0FD: Blood Sword
$0FF: Ancient Sword
$101: Avenger
$103: Gorgon Blade
$105: Holy Lance
$107: Gungnir
$109: Wyvern Lance
$10B: Sasuke's Katana, Mutsunokami, Assassin's Dagger
$10D: Mythril Knife, Mythril Sword
$10F: Dancing Dagger, Triton Dagger
$111: Kunai,Ahura
$113: Kikuichimonji
$115: Murasame
$117: Masamune
$04-05: Weapon hit gfx/palette ID (sword slash, claw hit...gfx that appear on the target)
$06: Weapon hit effect animation?
$07: Unused

Let's say Cecil is attacking with the Flame Sword (ID 0x1C). It's entry looks like this:
00 01 02 03 04 05 06 07
------------------------
6F 00 00 00 85 01 07 00

So, the Flame Sword's Sprite/Palette ID is 0x6F, and it displays weapon effect 0x185 on its targets with animation 0x07.

Sprite/Palette ID 0x6F is indexed in a pointer table at 0x80CAAD4, loading pointers at (0x6F+1)*4 and (0x6F)*4:
[(0x6F+1)*4 + 0x80CAAD4] = 0x81D8300
[(0x6F)*4 + 0x80CAAD4]   = 0x81D8244

At the offset 0x81D8244 is the sprite data for the weapon, LZ77 compressed. Here's what it looks like uncompressed:

I have it using the Sword of Legend's palette here for clarity. Rearranged to start from a different offset, it looks like this:

The green here (hex 0x160) is the transparent color for FF4a. The first two colored squares are unknown to me; they might not be graphical data at all.

Next we have the 16x16 sprite data for the weapon; the colored line below it is a list of each pixel color used in the sprite. Weapon sprites seem to support sixteen colors, but as you can see only seven colors are used (plus a transparent). The uncompressed data takes up 0xA8 bytes in total.

Offset 0x81D8300 contains the Flame Sword's Palette data, which looks like this:
Code: [Select]
03 00 00 00 10 00 00 00
6001 0000 FF7B 1F12 5D04 1600 7F03 5108 6001 6001 6001 6001 6001 6001 6001 6001

I'm not quite sure what the first line is for, but the second line is the 16-colour palette itself.

$02-03 in the table is strange; you can see that there's data there for some weapons, but this data is never read at any point. Who knows what exactly it was used for.

Anyway, now that we have the graphics for the weapon itself, we can do the same for the hit effects. $04-05 in the Animation Defenitions table is similar to $00-01, but $06 determines how those graphics are used. Unlike weapons, the hit effects are split up into multiple smaller tiles, so $06 here determines how to put them together and animate them.

The upshot of all this is that it would be pretty easy to change weapon graphics, and even add some more. Changing the number of items in the game would still be pretty time-consuming, owing to the number of tables needing to be expanded and to all the hardcoded ID-sorting nonsense in the code.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #4 on: July 18, 2015, 01:07:06 AM »
I imagine this is setup very similar to how it is in the SNES version as to my knowledge they would have had no need to change this set up, at least in its basic format. You may want to PM PinkPuff about it since it's been part of FF4kster since near the beginning.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #5 on: July 18, 2015, 01:15:46 PM »
I'll hold off on that for now...I managed to find out where the sound effects for weapons are, they're in a completely different (and redundant...) table.

EDIT: Specifically the table at 0xF96CF; each byte represents the attacking sound effect of the weapon of the corresponding ID. Considering the animation table has a free byte by default, one wonders why they didn't put the sound identifier there.

One funny thing you can do is, since music and sound effects are on the same list, is have weapons that play music or cut the music entirely when you attack with them. The Bell of Silence could live up to its name!
« Last Edit: July 18, 2015, 11:01:28 PM by Kea »

Bahamut ZERO

  • Cagnazzo
  • *
  • Posts: 347
  • Gender: Male
  • If ye're takin a beatin, hop in de back row!
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #6 on: July 19, 2015, 11:07:32 AM »
I'll hold off on that for now...I managed to find out where the sound effects for weapons are, they're in a completely different (and redundant...) table.

EDIT: Specifically the table at 0xF96CF; each byte represents the attacking sound effect of the weapon of the corresponding ID. Considering the animation table has a free byte by default, one wonders why they didn't put the sound identifier there.

One funny thing you can do is, since music and sound effects are on the same list, is have weapons that play music or cut the music entirely when you attack with them. The Bell of Silence could live up to its name!

Oh wow that's awesome! So weapon sounds go off of the weapon's ID on the list in FF4a? As far as I can tell (from playing with FF4kster so much), the SNES version plays it's weapon sounds based on what animation you set to the weapon. That's a really cool difference between the two versions if that's the case!
I update my graphics thread on almost a daily basis, so keep an eye out for new stuff!

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #7 on: July 19, 2015, 01:30:09 PM »
That's right - sound effects and animations are completely separate for weapons. I'm not sure if the same applies to spells, but at first glance they seem to have animation and sound tied together.

The advance version is generally more modular than its SNES counterpart; having eight megabytes of ROM instead of one (and that single MB divided into banks) let the devs be less frugal with their space. Not that the original with its enormous level-up tables was a masterpiece of efficient design itself...

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #8 on: July 20, 2015, 09:38:32 PM »
While investigating how to break the 324 item limit, I think I've found the final piece to the weapon animation puzzle - namely, what swing animations a weapon uses. In general, the animation applied to a weapon's sprite is determined by the weapon's type in item data; that means, for instance, that any weapon with the Boomerang icon (type 0xB) will use the throwing animation.

The exception is axes; some axes use a throwing animation, but most don't. Animations for axes are handled by this code:

Code: [Select]
080ABD8E 0608     lsl     r0,r1,#0x18 @r0 = weapon type
080ABD90 1604     asr     r4,r0,#0x18
080ABD92 2C0C     cmp     r4,#0xC    @0xC = Axe weapon type
080ABD94 D11C     bne     #0x80ABDD0 @If not an axe, skip the following checks
080ABD96 8831     ldrh    r1,[r6]    @Loading attacker's weapon's Item ID
080ABD98 293A     cmp     r1,#0x3A    @ID #0x3A = Ogrekiller
080ABD9A D007     beq     #0x80ABDAC @If weapon is Ogrekiller, do not use
080ABD9C 2096     mov     r0,#0x96   
080ABD9E 0040     lsl     r0,r0,#0x1 @ID #0x12C = Gigant Axe
080ABDA0 4281     cmp     r1,r0     
080ABDA2 D003     beq     #0x80ABDAC
080ABDA4 2947     cmp     r1,#0x47 @ID #0x47 = Poison Axe
080ABDA6 D001     beq     #0x80ABDAC
080ABDA8 2948     cmp     r1,#0x48    @ID #0x48 = Rune Axe
080ABDAA D109     bne     #0x80ABDC0
NoThrow: @If weapon's Item ID was one of the above...
080ABDAC 4A03     ldr     r2,=#0x8FEC
080ABDAE 18A8     add     r0,r5,r2   
080ABDB0 6801     ldr     r1,[r0]   
080ABDB2 2205     mov     r2,#0x5 @Use the Broadsword animation
080ABDB4 4311     orr     r1,r2     
080ABDB6 6001     str     r1,[r0]   
080ABDB8 E004     b       #0x80ABDC4
080ABDBA 0000     .short 0x0000
080ABDBC 8FEC     .long 0x00008FEC
080ABDBE 0000
Throw:
080ABDC0 4322     orr     r2,r4      @If weapon ID was none of the above...
080ABDC2 603A     str     r2,[r7]    @Set animation to weapon's own (ie 0xC)
080ABDC4 4B01     ldr     r3,=#0x8FE8
080ABDC6 18E8     add     r0,r5,r3   
080ABDC8 8801     ldrh    r1,[r0] @Proceed to loading from weapon graphics table

In practice, the only axes that use the throwing animation are the Dwarf Axe and the unused Hand Axe. Why TOSE felt the need to hardcode this is a mystery to me...

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #9 on: July 20, 2015, 10:37:51 PM »
Wow just... wow. This was handled just fine in the original FFIV. This does imply that there might be more weapons which can be turned into throwing variants though for FF4A, even though FFIV handles thrown weapons of any kind just fine... so... I have no idea what TOSE were doing there.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #10 on: July 21, 2015, 04:03:48 PM »
Ha, that's far from the worst thing TOSE has done just in terms of hardcoding item properties. In the US and JP 1.0 versions, all items over a certain ID were considered armor for the purposes of elemental/racial properties. A weapon like Loki's Lute, which was supposed to be effective against all creature types, instead protected the user against all creature types. It's still hardcoded in 1.1, just in a less broken way.   :sad:

I've laid down the framework for allowing a practically unlimited number of items in the game instead of 325. That involved repointing a lot of tables, but most significantly expanding the text table to record the names and descriptions of the new items I plan to add. I'm very thankful to Dragonsbretheren's resources and tutorial on this subject; I might have resorted to using a hex editor otherwise.  :scared:

That all means I won't have to consider cannibalizing the Lunar Ruins equipment. Monster drops and equipment selection in general should be more interesting in my planned hack; I plan to make the majority of monsters drop at least one interesting item.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #11 on: July 21, 2015, 05:28:49 PM »
Ha, that's far from the worst thing TOSE has done just in terms of hardcoding item properties. In the US and JP 1.0 versions, all items over a certain ID were considered armor for the purposes of elemental/racial properties. A weapon like Loki's Lute, which was supposed to be effective against all creature types, instead protected the user against all creature types. It's still hardcoded in 1.1, just in a less broken way.   :sad:

I've laid down the framework for allowing a practically unlimited number of items in the game instead of 325. That involved repointing a lot of tables, but most significantly expanding the text table to record the names and descriptions of the new items I plan to add. I'm very thankful to Dragonsbretheren's resources and tutorial on this subject; I might have resorted to using a hex editor otherwise.  :scared:

That all means I won't have to consider cannibalizing the Lunar Ruins equipment. Monster drops and equipment selection in general should be more interesting in my planned hack; I plan to make the majority of monsters drop at least one interesting item.

That is some very impressive work! Unfortunately it seems nearly impossible to do for the SNES FFIV, but I could see this being a possibility with FF4A due to it having over 255 items to begin with.

That does remind me though... how many drop tables are there in FF4A? In the SNES version there were only 64 because the table was tied to percentage drops ( 00 - Never, 40, 5% - 80 - 25% C0 - 100%) Was it the same in FF4A? Granted you can use events a bit more liberally I imagine, also breaking the 255 limit.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #12 on: July 21, 2015, 06:21:10 PM »
Each monster has its own drop table in FF4A, as well as its own AI index. So you have a lot of monsters with a 0% chance to drop a Potion,Potion,Potion or Potion. Each monster's drop table has a byte listing the probability of dropping any item; by default it only allows four numbers for drop chance (0%,5%,25%, and 100%), so I've had to change the related code to allow additional possibilities.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #13 on: July 21, 2015, 08:17:23 PM »
Each monster has its own drop table in FF4A, as well as its own AI index. So you have a lot of monsters with a 0% chance to drop a Potion,Potion,Potion or Potion. Each monster's drop table has a byte listing the probability of dropping any item; by default it only allows four numbers for drop chance (0%,5%,25%, and 100%), so I've had to change the related code to allow additional possibilities.

Hmm, that is strange...  so the table itself now decides the chance to drop, rather than the drop byte assigned to monsters in default FFIV? Also they all have their own unique AI Indexes? But to my knowledge no enemy really deviates from its basic AI index as laid down in the original FFIV, right? (except for new enemies, of course)

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4 Advance (E) Hacking Notes
« Reply #14 on: July 21, 2015, 09:38:02 PM »
Hmm, that is strange...  so the table itself now decides the chance to drop, rather than the drop byte assigned to monsters in default FFIV? Also they all have their own unique AI Indexes? But to my knowledge no enemy really deviates from its basic AI index as laid down in the original FFIV, right? (except for new enemies, of course)

The overall AI of monsters is the same (as far as I know), but the AI codes themselves are different; there's a code for a generalized status check for instance:

Code: [Select]
$B1 TT CCCC PPPP
-If has any bits set within CC CC of type TT, move to point PPPP in AI script
-Usually used for Confusion routines (enemies use normal battle scripts to act when Confused)
-Also used for Egged monsters - Egg status does not automatically set script
Values for TT:
-0x0: Check normal status
-0x1: Check special status (Barrier,Boss,Reflect,etc)
-0x2: Check turn status bits (was attacked, immune to damage)