Romhacking.net

Romhacking => ROM Hacking Discussion => Topic started by: Zeemis on March 20, 2018, 12:19:04 pm

Title: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 20, 2018, 12:19:04 pm
Is it possible to expand FF5's GBA rom to allow for more enemy sprites, as well as palettes?
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Bregalad on March 20, 2018, 01:21:47 pm
Yes. The (E) version is already expanded as opposed to the (J) and (U) versions. (32 MB instead of 16 if I remember well), because they had to fit the script in 5 languages.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 20, 2018, 02:15:42 pm
Thank you. It's too bad that Greiga Master's "Final Fantasy V Editor (https://www.romhacking.net/utilities/898/)" can't use the E version and take advantage of all that extra space. I am pretty sure it has to do with the editor looking for the (U) version's offsets, based on this error I get upon opening it:

(https://i.imgur.com/5JsZi88.png)

Code: [Select]
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: srcOffset
   at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
   at FFVEditor.MonsterEditor.openToolStripMenuItem_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8825 (WinRelRS3.050727-8800)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
FFVEditor
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/Graham/Desktop/FF5A%20editor/FFVEditor.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8825 (WinRelRS3.050727-8800)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8825 (WinRelRS3.050727-8800)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8825 (WinRelRS3.050727-8800)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.8827 (WinRelRS3.050727-8800)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.


Title: Re: FF5 GBA ~ Expanding for Size?
Post by: KingMike on March 20, 2018, 02:58:08 pm
As I understand EXPANDING a GBA ROM is dead simple: just add more space to the ROM but USING that extra space would not be.
I assume the game's programming would have to be modified to direct it to read from expanded space.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 20, 2018, 07:47:14 pm
It's too bad that Greiga Master's "Final Fantasy V Editor (https://www.romhacking.net/utilities/898/)" can't use the E version and take advantage of all that extra space. I am pretty sure it has to do with the editor looking for the (U) version's offsets
Yes only (U) version.

What do you try to accomplish, Zeemis? I have some experience with (e) version and extended with monster graphics in (u).
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 20, 2018, 07:57:03 pm
Yes only (U) version.

What do you try to accomplish, Zeemis? I have some experience with (e) version and extended with monster graphics in (u).

I haven't created a project thread yet, mainly because I'm still doing some research and learning what's possible and what's not; however, I'm working on replacing all enemies and bosses in FF5 GBA with monsters from past Final Fantasy games. I'm using graphics from Pictologica Final Fantasy (http://finalfantasy.wikia.com/wiki/Pictlogica_Final_Fantasy), Final Fantasy: Record Keeper (http://finalfantasy.wikia.com/wiki/Final_Fantasy_Record_Keeper), as well as the various graphics from past games that already have sprites. The idea is to have not only new enemies, but also enemies that follow a theme per environment. As an example, the boss "Hein (http://finalfantasy.wikia.com/wiki/Hein_(Final_Fantasy_III))" from FF3 is the boss you encounter Ship Graveyard, following the theme of undead.

Here's an example of a boss I finalized, it's Schizo from FF7:
(https://i.imgur.com/fbk05Vq.png)
(https://i.imgur.com/uG5eh0A.png)
(https://i.imgur.com/wFreS6u.png)
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 20, 2018, 08:36:57 pm
I've seen Record Keeper, but haven't try it. I play FF Brave Exvius, they have some shared events with Record Keeper :)

So you try to replace, not add. That's probably easier. You will need to change graphics, AI scripts and couple of lookup tables.

Graphics is fairly easy - you must compress the tiles (keep in mind aligning), add the palette. The (u) pack together both, but since you have separate pointers for both, they could be hold in separate regions. Keep in mind that Square adds a small header of 8 bytes to before compression. First 4 bytes are kind of Type of resource .... 1 is for tiles, 2 - palette, 3 - tile map.

AI ... I don't know a tool to do it. As for the LUT, you will probably do it on hand. Keep in mind that FF5 holds LUT on 2 places. I have no clue what for  ::)

You may use use my Viewer (https://www.romhacking.net/forum/index.php?topic=22672.0) to check the results. It is using (u) version for GBA.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 20, 2018, 11:08:02 pm
Maybe I'm entirely wrong; however, doesn't Greiga Master's FFV GBA editor allow me to replace graphics from existing or new offsets?
(https://snag.gy/gvzuBL.jpg)

Wouldn't this mean I could simply expand the rom and the editor can point the game to the new graphic location of where I store it?

------------------
So I don't know if it's working as intended yet, further testing is needed; although, I have successfully added 10,000 bytes to the end of the (U) version with Hex Workshop and cross checked to see if I got the error on this new version with the non-expanded version. I can confirm that after opening both the expanded version and non-expanded version into the same editor on two separate instances and replacing the same monster on both version with the same graphic, the expanded version did not give me that error I showed above in this post.

As said although, I'll have to test further to see if it shows up in-game.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Bregalad on March 21, 2018, 03:43:31 am
As I understand EXPANDING a GBA ROM is dead simple: just add more space to the ROM but USING that extra space would not be.
I assume the game's programming would have to be modified to direct it to read from expanded space.

Both expanding and using extra space in GBA ROMs are dead simple. Just make pointers point past the previous end of the ROM and it'll work. It's really dead simple compared to NES for instance.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 21, 2018, 04:21:22 am
Maybe I'm entirely wrong; however, doesn't Greiga Master's FFV GBA editor allow me to replace graphics from existing or new offsets?
Wouldn't this mean I could simply expand the rom and the editor can point the game to the new graphic location of where I store it?
TBH I have never used the tool for editing. I hope it recalculate the LUT. However I doubt it adds the 8 byte headers. As I said these headers are added at the beginning of uncompressed part to both Tiles and Palettes.
That mean, that you must get Tiles for a monster, add an 8 byte header, compress the result and then store the result in the ROM.
Similar is with Palettes: get the Palette of a monster, add 8 byte header and store the result in the ROM (no compression)


Keep in Mind that the header is not a constant. As I said the first 4 bytes hold some kind of TypeID, but second 4 bytes have specific info:
 - For Tiles (1): the number of tiles.
 - For Palette (2): the number of palette entries.

Let me illustrate it with Gobin:
(http://www.bwass.org/bucket/FF5u - Goblin Data.png)
The Tiles data starts after the orange box. The header has 1 (tiles) followed by $14 = 20 tiles (a Goblin image is 4x5 tiles)
That is the reason that in most tools you will see the Goblin image distorted. That is one of the reasons to start my own tool - Visual SAK (http://www.romhacking.net/forum/index.php?topic=25707.0)  :beer:
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: FAST6191 on March 21, 2018, 07:13:03 am
As I understand EXPANDING a GBA ROM is dead simple: just add more space to the ROM but USING that extra space would not be.
I assume the game's programming would have to be modified to direct it to read from expanded space.

As Bregalad said it is almost trivial.
The GBA has 32 megabytes of space mapped directly to the the pretty damn fast memory (such that most things don't copy it to RAM to use), no size indicators, mapper types or the like to worry about. Most ROMs are 16 megabytes or less, and even those in the 32 megabyte range (256Mbit if you want to use the GBA scene's preferred parlance) usually still have a lot to play with (Mother 3 being the exception).
If you understand pointers (and most of those will be direct pointers right there in the ROM, no calculated/relative/inferred/offset to speak of really, in the form of 08XXXXXX, and 09XXXXXX for the upper 16 megs -- http://problemkaputt.de/gbatek.htm#gbamemorymap and technically http://problemkaputt.de/gbatek.htm#gbasystemcontrol as well) then you can point things wherever you like.

Technically there are bankswitching options for homebrew/flash carts and a handful of commercial videos https://mgba.io/2015/10/20/dumping-the-undumped/ but nothing any hacker is likely to encounter or really want to use.

Now whether the premade tools referenced in this thread handle it properly is a different matter. Some of the pokemon tools did not handle adding to the end of the ROM so well but do it yourself and their "free space finders" would do what needed doing.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 21, 2018, 12:52:55 pm
Really wish Greiga Master's editor could REMOVE enemies from a battle! Unfortunately, you cannot simply select the enemy drop down box and click "None", or untick "Visible". You also can't select the monster and click "Delete" or "Backspace" on your keyboard, really hoping I'm missing something here lol. Still trying to figure out what makes an enemy have the aerial shadowing effect because it's not related to the "Aerial" tickable box under Statuses lol.
(https://snag.gy/CTgx2B.jpg)
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 21, 2018, 02:23:23 pm
Quote
Battle editing lets a player changes battles by changing enemies or increase the amount of enemies in a fight and more so long as they pay attention to some rules.
Maybe there is no 'reducing' coded, at all  :laugh:

But seriously I don't know did somebody actually used the tool for editing at the time of developing, but it misses plenty of things to be actually used for a hack  :(

BTW did you try your changes in an emulator? Did you get the header thingy? Does the AI editing actually work? I've always wondered if I had to do an AI edit, what interface it will need ...
Anyway if you have any questions I will gladly help  :beer:
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 21, 2018, 02:36:56 pm
Maybe there is no 'reducing' coded, at all  :laugh:

But seriously I don't know did somebody actually used the tool for editing at the time of developing, but it misses plenty of things to be actually used for a hack  :(

BTW did you try your changes in an emulator? Did you get the header thingy? Does the AI editing actually work? I've always wondered if I had to do an AI edit, what interface it will need ...
Anyway if you have any questions I will gladly help  :beer:


So my workflow is a bit tedious, but is showing results. I'll add and make changes in the editor, then load up the game in the emulator from a save and test out each enemy's AI, battle formation, and anything else. The editor is unfortunately pretty limited, and pretty incomplete. I cannot change dialog, which I'm sure is easy, but the editor doesn't support it unfortunately. What this means is some bosses have cinematic dialog before you get into battle, like the Siren whom I turned into "Hein".

I haven't done anything with the header, no problems yet. The editor may account for that, but I don't really know. I know that I inserted 10,000 additional bytes and the editor is now placing my enemy sprites there and not spitting out fatal errors or whatever lol.

AI editing works fine; however, you can definitely tell it's not as complex as Final Fantasy 6's. What it does support that FF6 doesn't really is multiple boss forms.

I wish Greiga Master or someone else would continue working on this editor like Lord J did for FF3usME. What I want to ultimately do is create a patch for FF5 Steam so friends can play it. I also plan to add in all the final bosses from FF1~FF10 into the Seal Temple at the end.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 21, 2018, 02:59:25 pm
What I want to ultimately do is create a patch for FF5 Steam so friends can play it. I also plan to add in all the final bosses from FF1~FF10 into the Seal Temple at the end.
Steam ... now that is an interesting thing. I have no interest in SNES/GBA editing, but Steam is completely different story. :laugh:

I assume its true that Steam hold GBA ROM inside ... so after you do the changes in an actual GBA ROM, you will transfer all changes there?  ::)
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 21, 2018, 03:00:44 pm
Steam ... now that is an interesting thing. I have no interest in SNES/GBA editing, but Steam is completely different story. :laugh:

I assume its true that Steam hold GBA ROM inside ... so after you do the changes in an actual GBA ROM, you will transfer all changes there?  ::)

Exactly. The Steam version of FF5 supposably is just a glorified FF5 GBA rom with fancy graphics programmed to overlay the GBA graphics. It does use a rom from what I understand.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 21, 2018, 03:24:32 pm
I've heard that tale many times, and I sure hope its true ...
Unfortunately I have never seen a proof, something like: in this file at that address is the ROM (or parts of it).

I wish you luck!!! if you can pull this, that will be the best thing done for with FF5.

On Topic:
Adding a new battle message could be a challenge. FF5a uses an interesting text hub - all the text in the game is put in one place and is accesses by index. When I say all, I mean ALL. Spell names, weapon names, battle message,... everything that is not per-rendered as GFX. In order to add, you might have to move the whole hub in the resized part, changes number of ASM,...
It might be easier to replace existing battle messages with what you need. You just need to keep the new message not longer then older ...

Check 'Text' tab in my Viewer. The is a '5' in the bottom. That is the index trough which you might see all messages.
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 22, 2018, 12:21:29 am
I figured out how to remove enemies FINALLY from battle formations, you have to select the enemy you want and change it to the "None/(Null Enemy)".... I never would have figured this out if I hadn't been looking through the enemies at the lower end of the list lol.

(https://i.snag.gy/mUThR3.jpg)
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 22, 2018, 04:12:22 am
I figured out how to remove enemies FINALLY from battle formations, you have to select the enemy you want and change it to the "None/(Null Enemy)".... I never would have figured this out if I hadn't been looking through the enemies at the lower end of the list lol.
Good finding, thanks for sharing it!  :laugh:

Actually I searched for None, because I know entry 0 is already used by Monsters. Unfortunately I made the noob mistake to search at beginning or the end of the list. Who would think it will be $FF :(

BTW if you prefer to Add monsters rather replacing existing ones, you may use the ones with entry numbers: $270-$27F, $29A-$29F
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 22, 2018, 10:16:46 am
Good finding, thanks for sharing it!  :laugh:

Actually I searched for None, because I know entry 0 is already used by Monsters. Unfortunately I made the noob mistake to search at beginning or the end of the list. Who would think it will be $FF :(

BTW if you prefer to Add monsters rather replacing existing ones, you may use the ones with entry numbers: $270-$27F, $29A-$29F

I am mostly replacing existing monsters, but adding new sprites. You should join the Romhacking discord btw, on the main page click "Chat" and we can talk more there. :)

March 24, 2018, 12:46:47 am - (Auto Merged - Double Posts are not allowed before 7 days.)
So I'm working on the water crystal boss replacement for Garula, I'm implementing Cagnazzo from FFIV to replace it. Using the boss "Liquid Flame" as a template and expanding upon it, I did manage to get it to change form while it's in it's raised water shield phase when attacked with Lightning magic. I am struggling to figure out how to make it counter all magic and silence, and then counter all physical damage with Encircle although, I'm using the documentation found on Slickproduction's Wiki.

Take a look at the Ai so far, it's not entirely right. The first bit at the top just says that Cagnazzo will either use "Fight", "Specality" or "Ice" while in this form. The next part states that after a certain amount of damage is done, or time elapsed, he'll change forms to the raised water form. The third part should be countering all magic with Silence (mute in the editor), and the last bit counters all physical damage with Encircle.

Code: [Select]
Conditions:06 01 2B F0
Uninterrupted:
   Mute
   ENDFF

From what I understand:
06 = React
00 = to or no operation?
2B = Element Type
04 = Lightning

What I'm trying to figure out is how to make it react to all Magic and all Physical damage instead of just an element (2B). I've been heavily reading over Jorgur's documents, and looking through his "Common List", I've found the information for reacting to elements (lightning being bit 04). What I also found was the reaction bit for Action Types:
Code: [Select]
80 Physical
40 Aerial (weapons)
20 Song
10 Summon
08 Dimen
04 Black
02 White
01 Blue

I that by looking at the Frost Bull's AI script, the bit 2B means "element"; however, I have no idea what the bit for "action type" is. It unfortunately isn't documented. :/
(https://i.imgur.com/8zZMI6b.png)
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Squall_FF8 on March 24, 2018, 05:20:48 am
Sorry I wasn't around last 24h ...

You need a good tool to grasp the AI. I will strongly suggest to get my Viewer (https://www.romhacking.net/forum/index.php?topic=22672.0). It is the best tool for visualizing AI for FF5 (and probably in every other FF)

Open your ROM there. In 'Monsters' tab you will see every bit of info available in the ROM. On right is the AI panel. It has two ways of visualizations:
 - Structured - in each row you will see AI commands (great for fast grasping of what AI does)
 - Detail - every byte of AI is on separate row (good for detail info how each command is coded)
Please share how my Viewer parse your current script here!

Dueling Knight uses both counters you need. Here is his script:
Quote
00 00 00 00: Default:
FE:          {
80:            Attack
FF:          }

07 01 2B 00: React on: NOT Magic -
FE:          {
81:            Special
FE:          }

07 00 2B 00: React on:  Magic -
FE:          {
FD F7 09 F0:   {No Interupt for: 9}
FD F6 02 15:   {Display: Magic is forbidden here!}
80:            Attack
80:            Attack
80:            Attack
80:            Attack
FF:          }
So you need 07 01 2B 00 for physical and 07 00 2B 00 - for magical. Keep in mind that 06 and 07 reaction is considered the same (we never found is there any difference) so you may use 06 variant (as Skull Eater)

Unfortunately slick's Wiki has mistakes and many unknowns. I have done a lot of digging when I was codding my AI parser. It's much better but even it is not 100%. I will also suggest to try Detail for byte by byte parsing, while keeping the structures of commands. Here is the same script in Detail:
Quote
00: <Non condition block>
00:
00:
00:
FE: <Condition End>
80:   Attack
FF: <Block End>

07: <React on block>
01:   NOT
2B:   Magic - Fire Ice Poison Earth
00:
FE: <Condition End>
81:   Special
FE: <Condition End>

07: <React on block>
00:   
2B:   Magic - Fire Ice Poison Earth
00:
FE: <Condition End>
FD:   <Action Group>
F7:     No interupt for:
09:       09
F0:
FD:   <Action Group>
F6:     Display Text:
02:       02
15:       Magic is forbidden here!
80:   Attack
80:   Attack
80:   Attack
80:   Attack
FF: <Block End>
Title: Re: FF5 GBA ~ Expanding for Size?
Post by: Zeemis on March 24, 2018, 10:57:51 am
Is there a way to make it so an enemy will react 50% of the time instead of 100%, as well as target the one who attacked?