• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 27, 2024, 11:44:39 am

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


Lessons Learned by a noob

Started by mrgudenheim, January 07, 2024, 11:42:01 am

mrgudenheim

January 07, 2024, 11:42:01 am Last Edit: January 31, 2024, 12:38:57 am by mrgudenheim Reason: Added instructions for patching TLW using the resources
While making a mod for the first time, the tutorial link index (https://ffhacktics.com/smf/index.php?topic=9204.0) was awesome, but also a little overwhelming. This post is to summarize the things I learned with the help of discord and poking around in files, the forum, and the wiki.

What is event editing (aka eventing) and how is it different than (assembly) ASM hacks?

While all changes mods make end up as assembly, event editing seems somewhat unique in that all events get compiled into a large blob, so mix and matching event edits is far less feasible. Event editing is performed with either "easyvent editor super perfect" or "JuraviS". Some complex events, such as TLW NewGame+ and Credits events, should only be compiled with JuraviS. "Events" include things such as cutscenes, dialogue in battle, game over, bethla sluice trigger, deep dungeon unlocking deeper levels, TLW Remix "Preparation menu", etc.


What are conditionals and how to edit them?

World conditionals tell the game when to trigger events. These can be edited using a spreadsheet to create the xml. I used the conditionals v4 spreadsheet from the TLW resources. Note, TLW conditionals spreadsheet has hidden columns, rows, and sheets, but you don't need them to make edits.
What are event conditionals? I don't know, I didn't try to mess with them.

https://ffhacktics.com/wiki/Process_Scenario_Conditionals
https://ffhacktics.com/wiki/Process_Scenario_Conditional


Learning about xml files

Each xml patch can have the following:

A name and description - used by FFTorgASM so people know what they are applying

file - The file that will be edited. Files can be seen by opening the FFT iso with CDmage. If you know the memory you want to overwrite with a hack, the appropriate file can be found with https://ffhacktics.com/wiki/Routine_Locations

offset (ie. memory location in the file) - this is where the assembly will be overwritten. Multiple offsets can be given by separating them with commas

offsetMode - When set to  RAM, the offset is actually a different location. Routine's documented on the wiki use the RAM location. Mentioned near the end of Glain's tutorial (https://ffhacktics.com/smf/index.php?topic=8408.msg166663#msg166663). RAM location to file location needs to substract the value from this table: https://ffhacktics.com/wiki/Routine_Locations

mode - mode="Data" seems to overwrite the hex directly, while mode="ASM" allows code functions (https://ffhacktics.com/wiki/R3000_instruction_set https://ffhacktics.com/wiki/PSX_instruction_set) and variable symbols, which then get converted to hex by FFTorgASM. ASM mode is usually (always?) used with offsetMode="RAM".

The "jal" instruction goes to another function. Search the wiki for the memory value without the leading 0x to find what it does. For example, for the instruction "jal    0x8017e7e4" search the wiki for "8017e7e4".

Some of the most common memory locations can be looked up on the wiki quick links:
https://ffhacktics.com/wiki/Battle_Stats
https://ffhacktics.com/wiki/World_Stats
https://ffhacktics.com/wiki/Variables

Some hacks use psuedo instructions (https://cseweb.ucsd.edu/classes/fa12/cse141/project/pseudo.html) which aren't on the wiki pages, but follow similar naming conventions. Examples include:
move - is an addu instruction where the source register is r0
li = "load immediate" behaves like lui, "load upper immediate" but instead of just setting the upper half of a register, it sets both halves. This takes 2 instructions,
Lui
Ori

If FFTorgASM says an xml can't be loaded because of a bad string input, check to make sure all locations that use offsetmode="RAM" also use mode="ASM".

mode="DATA" example:
<Location file="MAP_MAP107_GNS" offset="30, 44, 58, 6C" mode="DATA"> B9 </Location>
mode="ASM" example:
<Location file="BATTLE_BIN" offset="00070d84" mode="ASM" offsetMode="RAM">
    ori r2, r0, 0x00    # make it so the map can't update when a crystal is laid
</Location>



XML Variables

Each variable needs a "default" value and a "name" that FFTorgASM will show. There seem to be two ways to do variables:

1. Directly write the value at the offset

2. Set symbol="true" so the variable name can be referenced later in the patch. Variables are referenced with %NameNoSpaces


Directly writing variable example:
<Variable file="MAP_MAP107_GNS" offset="30" default="B0" name="NOGIAS Light Level" />

Symbol variable example:
<Variable name="Always On" bytes="1" default="00" symbol="true" />
<Location file="BATTLE_BIN" offset="158210" offsetMode="RAM" mode="ASM">
    ori r1,r0,%AlwaysOn <!-- check if the player turned it Always On -->
</Location>

How to Patch TLW to a vanilla ISO using resources:
1. Make a backup of a vanilla ISO
2. Open the vanilla ISO in ShiShi and expand it (File -> Expand ISO). It may not look like anything is happening, but the "Max SPR size" should change from 4something to 6something. If you don't expand the ISO some of the sprite images will give error saying they are too large when you attempt to import them.
3. Import all the sprites. For each sprite, select the correct sprite number from the top dropdown in ShiShi and then Sprite->Import BMP. Set the sprites SHP and SEQ to match the file name (Type 1, 2 or MON). For example, to import Balthier's sprite, first select the "19 - Rafa (Guest)" in ShiShi, then import the file, then set SHP and SEQ to TYPE1.
"Sprite->Import all sprites" did not work for me.
4. Import all other images. Go to the "Other Images" tab. Image->Import all images
5. Use CDmage to open the ISO and navigate to EVENTS and find the TEST.evt file. Right click the file within CDmage and import the TLW TEST.EVT
Order of steps 6 and 7 does not matter as far as I know.
6. Use FFTPatcher (I used 0.497) to patch "TLW FFTPatcher" - File->Open patch,  PSX->Patch ISO
7. Use FFTactext to patch "TLW Tactext" files. File->Open .ffttext then ISO->Patch ISO
8. Use FFTorgASM in each folder ("AMS FFTP 0.495 B1" and DATA FFTP 0.482) to patch all the ASM.
8a) Highlight "all" in the list on the left. Press "Check all" button. All boxes should have a check mark.
8b) Optionally open the conflict checker - there shouldn't be any conflicts.
8c) Press "Patch..." then press "Patch..." on the new window.
Some people have said they had success with all the xml files being patched at once with the latest FFTorgASM instead of in two separate rounds with the two different versions of FFTorgASM.
  • Modding version: PSX

theradiostar

Registered an account just to say THANK YOU for the "How to Patch TLW" section. Being a complete noob (but still wanting to make a couple changes) I was completely lost on how to do so. Thanks again!
  • Modding version: PSX & WotL