• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 09:48:14 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.


FFT Hack Template Spreadsheet

Started by Xifanie, December 31, 2016, 10:16:12 pm

Xifanie

December 31, 2016, 10:16:12 pm Last Edit: April 19, 2020, 02:20:02 am by Xifanie
FFT Hack Template Spreadsheet

Downloads
[indent=2]
Download the latest version (0.07b) - BLANK
Download the latest version (0.06b) - Xifanie's Hacks
Download "FFT File List.txt"
Download the latest update files
  • Download the latest update files
  • In VBA (Alt+F11), remove all the forms from your spreadsheet and remove the "SharedXifiSheets" module
  • Either manually import each form (.frm) and the "SharedXifiSheets" module (.bas), or drag and drop them in Excel
  • Save
Note: Do not delete your "Self" module!
Note2: You cannot import .frx files. They contain the form's code and will be automatically imported alongside their .frm counterpart.
[/indent]

What is it?
[indent=2]It's an Excel spreadsheet LOADED with new functions to help you to create and test your ASM hacks in the most user-friendly environment I could think of. You can also easily import your old hacks and it will be nicely reformatted for you, allowing a smooth transition to this tool.
It will forever change the way you make ASM Hacks![/indent]

Requirements
  • Windows OS
  • Microsoft Excel 2007+ (non-negotiable, forget about alternatives)
  • *pSX 1.13 (to use the "Save to Savestate" function)
  • *FFTText Editor spreadsheet (to use the Load "FFTText function")
  • *ISO Manager (to create your own "FFT File List.txt")
[indent=2]*optional[/indent]

Overview
[indent=2]
An ASM coding friendly environment



With an XML import/export function that aims to retain as much information as it can



A TON of functions to help you out!



Save directly to your ISO, to your Savestate (only if the appropriate files are loaded), or even to XML with 3 different output options




A function that find console-breaking errors for you!



A function that allows you to import code from your ISO, your savestate, or even from the wiki!



A function to import data from your ISO or from a savestate, in the format that you want!



A function that lets you see where the free space is, and which hacks are conflicting!
(Restricted to the hacks currently present in the spreadsheet)



And much, much more!
[/indent]

Getting Started
  • Get yourself familiarized with each sheet's functions
  • Open up the "Add-Ins" toolbar/ribbon
  • Click the Configuration icon and configure away!
  • Import an existing XML and look at branches/jump's formulas; use the same format for your own hacks. The colours are optional.
  • Try out essential functions such as "Insert Line(s)"
  • ASM Away!
  • Use the "Analyze Code" function to detect and fix console-breaking errors
  • Test your ASMs faster with "Save to ISO" and "Save to Savestate"
  • Finally, release as XML (Save to .xml) and share for everyone to use your hack

Known Bugs
  • Excel 2010 might crap out an annoying, but not spreadsheet breaking, 32bit ShellExecute function error (possibly only on W10)
  • Unable to properly parse XMLs containing ASM and not opcodes stored as Hex (Glain.xml)
  • Might get a run time error whenever the last MEMLOCATION uses hex instead of an op code when attempting to save

Changelog
[indent=2]

1.06b- Fixed Save to Savestate, re-introduced Concatenate Cells function
1.05b- Fixed a few bugs, improved functions, introduced LEAddress() function
1.04b- Fixed a bug where replace variables would not work when saving
1.03b- Fixed a bug where you could only import hacks if they had both Location and Variable fields
1.02b- Initial Release
[/indent]
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Xifanie

SHEETS


Tutorial
[indent=2]This sheet is entirely optional. This sheet is only meant to provide information on how to use your spreadsheet, if you wish to release it in this format and not only in XML format.[/indent]


Code
[indent=2]This is where all the magic happens.
You can import an .xml to see how you should format it, but using this example as a base and the detailed information below, you should be fine.


PATCH
[indent=2]Column B: Patch Name[/indent]

DESCRIPTION
[indent=2]Column B: Patch's Description (can be spread across multiple lines)[/indent]

COMMENT
[indent=2]Column B: Comment (can be spread across multiple lines)[/indent]

MEMLOCATION
[indent=2]Column C: Location's File Name
Column D: Location's Memory Address (NOT the File Offset) [Can be spread across multiple lines]
Column E: Opcode or Hex Data (Can be spread across multiple lines)
Column F: Hex Backup; this value is printed when you import data. If it gets wrongly recognized as an opcode, you can simply copy/paste the data in this column back into Column E. If you have no need for the data in this column anymore, feel free to click "Clear Hex Backup" in your toolbar. This will automatically delete its contents and hide the column.
Column G: Comment
[/indent]

MEMLOCATION-1 and MEMLOCATION-2
[indent=2]The same as MEMLOCATION, except that it will be automatically trimmed by 1 or 2 bytes ("-1" and "-2" respectively).
Use this alongside MEMVARIABLE when the variable is part of an opcode, and you still wish the opcode to be on your sheet and to compile properly.
Refer to the above screenshot for more information.[/indent]

MEMVARIABLE
[indent=2]Column B: Variable's Name
Column C: Variable's File Name
Column D: Variable's Memory Address (NOT the File Offset) [Can be spread across multiple lines]
Column E: Hex Data in Big-Endian; meaning don't flip the bytes!
[/indent]

LOCATION
[indent=2]Column C: Location's File Name or [Sector]
Column D: Location's File/Sector Offset (Can be spread across multiple lines)
Column E: Hex Data (Can be spread across multiple lines) [it will still accept opcodes, but if you want to use opcodes you should really be using MEMLOCATION with Memory Addresses instead]
Column F: Hex Backup; this value is printed when you import data. If it gets wrongly recognized as an opcode, you can simply copy/paste the data in this column back into Column E. If you have no need for the data in this column anymore, feel free to click "Clear Hex Backup" in your toolbar. This will automatically delete its contents and hide the column.
Column G: Comment
[/indent]

VARIABLE
[indent=2]Column B: Variable's Name
Column C: Variable's File Name or [Sector]
Column D: Variable's File Offset [Can be spread across multiple lines]
Column E: Hex Data in Big-Endian; meaning don't flip the bytes!
[/indent]
[/indent]


Hacks
[indent=2]

Hack Table
[indent=2]Determines whether the hacks will be saved to ISO/Savestate/XML.
If the "Apply?" column is set to "No" or if the hack is simply not present in the list, the hack will not be parsed.
If it is set to "Yes", then it will be.

NOTE: If your hack isn't in the list, press "Update Hack List" in the Add-Ins toolbar/ribbon.
[/indent]

Auto-Replace Table
[indent=2]Allows you to make terms be auto-replaced by a specific value in your opcodes (or hex, even).
For example: With "Power_Level" and "0x2329"
"ori r2, r0, %Power_Level%" would be parsed as "ori r2, r0, 0x2329"
[/indent]
[/indent]


Hack Settings and Tables
[indent=2]This is where you will place any checkbox, list, table, etc. for the user to interact with that will modify the outcome of the hack.
This sheet uses the Developer toolbar by default. It would be very nice if I could make any new sheet come with a Developer Toolbar, but that's not possible without being very impractical at the same time. If you want another sheet like that, you should either copy this one or give a new sheet a Developer Toolbar.[/indent]


Calculations
[indent=2]This sheet is meant to handle any calculation that are unnecessary to use the spreadsheet, but used when saving to ISO/Savestate/XML. If you have a large number of calculations to perform to compile data for the Code Sheet, you should place them in this sheet because automatic calculation is turned off by default, and it will be only recalculated when attempting the aforementioned saving to ISO/Savestate/XML. It is unlikely most people will have a use for this Sheet, but hey, it's there.[/indent]


LoadFFTText
[indent=2]This page has a table that you can edit as you wish to fetch text from your FFTText Editor spreadsheet and a few other things. Look up the wiki to know how to use each function, and what to type for each parameter. For any parameter that requires a range, just use my new "=RangeAddress()" function. Simply press the "Load FFTText" button under the Add-Ins toolbar to make all those functions run all at once, in the order you typed them.[/indent]


How to create a new sheet with a Developer Toolbar
[indent=2]
You could also pre-emptively make a copy of the "Hack Settings and Tables" sheet
1) Create a new sheet
2) Head into the VBA Editor (Alt+F11)
3) On the left page, you'll see your spreadsheet name... under that will be a folder called "Microsoft Excel Objects", and under that will be the sheet's name. Double click it.
4) Paste the following code inside the sheet's code page:
Private Sub Worksheet_Activate()
    Call HackToolbar("Developer")
End Sub
[/indent]
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Xifanie

December 31, 2016, 10:17:39 pm #2 Last Edit: May 13, 2017, 07:57:29 pm by Xifanie
SPREADSHEET FUNCTIONS AND VBA


Spreadsheet Functions
[indent=2]
WARNING: VBA Functions on a spreadsheet are several thousand times slower than native Excel functions. Try to limit their use; use them smartly!


Function UpperAddress As String
[indent=2]Gets the upper half-word of a word to use with the lui opcode (ex: 0x8016AB6C --> 0x8017)[/indent]


Function LowerAddress As String
[indent=2]Gets the lower half-word of a word to use with the addiu/ori opcodes (ex: 0x8016AB6C --> 0xAB6C)
Set the second parameter to TRUE if you wish to force the result as a Signed Hex value if applicable (ex: 0x8016AB6C --> -0x5494)[/indent]


Function ReverseBytes As String
[indent=2]Converts a Little-Endian hex string to Big-Endian[/indent]


Function RangeAddress As String
[indent=2]Outputs an array of ranges that can be used by VBA code (such as the LoadFFTText functions)[/indent]

[/indent]

VBA Subs and Functions
[indent=2]
On a spreadsheet, use the native Excel functions instead of these instead of the ones listed below (see DEC2HEX/DEC2BIN/HEX2DEC/HEX2BIN/BIN2DEC/BIN2HEX)
Also look at the "Self" VBA Module for customizable custom functions



Sub VBATime
[indent=2]Enables or Disables VBA related enhancements to make writing to the spreadsheet way faster.
Make sure to disable it afterwards before the end of your sub with "VBATime false", otherwise it will be extremely hard or impossible to use the spreadsheet.[/indent]


Function Open_ISO As Integer
[indent=2]Readies your FFT ISO for binary read/write. Use with:
Dim ISO_File as Integer
ISO_File = Open_ISO
If ISO_File = -1 Then Exit Sub

Then use "ISO_File" in the Subs/Functions that request it.
If the user has canceled the ISO selection, the Sub/Function will automatically terminate.[/indent]


Function Import_Files_List As Boolean
[indent=2]Loads FFT File List.txt's contents. At the beginning of your sub/function, place:
If Not Import_Files_List Then Exit Sub
If the file cannot be loaded or has errors, an error will be displayed and the current Sub/Function will be terminated.[/indent]


Function GetFileMatch As Long
[indent=2]*Requires Import_Files_List
Gets the Match ID of a filename in FFT File List.txt's contents to use with the File_Sectors/File_Offsets/etc. arrays based on its full filename, its filename, or its XML filename.

Valid arrays to use with a File Match ID:
[indent=2]







Array NameDescriptionExample
File_Full_NamesThe file's full path"EVENT\ATTACK.OUT"
File_NamesThe file's name"ATTACK.OUT"
File_XML_NamesThe file's XML name"EVENT_ATTACK_OUT"
File_SectorsThe file's Sector Offset2448
File_OffsetsThe file's Memory Offset, i.e. where it is loaded in RAM1830912 (0x001BF000)
File_OriginalIf true, the file matches a vanilla ISO's name and Sectortrue
[/indent]
[/indent]


Function Create_Sort_Index As Long()
[indent=2]Creates an array to be used with Sort_Array.
This array is an index that specifies which entries to include and in what order.
It can ignore or include duplicates, ignore or include null values, and either sort from A-Z, Z-A, or not sort at all.
This index can then be used with Sort_Array to quickly rearrange one or more arrays.[/indent]


Function Sort_Array As Variant
[indent=2]Creates a new array from an existing one, reordering and trimming out undesired values.
Should ideally be used with Create_Sort_Index.
Returns an array of the same data type that was parsed.[/indent]


Function Get_File_Data As Byte()
[indent=2]Gets ISO Data and returns it into an array of bytes. (requires Open_ISO)[/indent]


Sub Save_File_Data
[indent=2]Saves an array of bytes back into the ISO. (requires Open_ISO)[/indent]


Function ReadReg As Variant
[indent=2]Gets the value of a specified registry key. If it doesn't exist, it will return a default value.[/indent]


Sub WriteReg
[indent=2]Writes a value to a specified registry key.[/indent]


Function DecToHex As String
[indent=2]Converts a long decimal value into a hex string with a given number of digits.[/indent]


Function DecToBin As String
[indent=2]Converts a long decimal value into a binary string with a given number of digits.[/indent]


Function HexToDec As Long
[indent=2]Converts a hex string into a long decimal value. (unsigned/signed)[/indent]


Function HexToBin As String
[indent=2]Converts a hex string into a binary string with a given number of digits.[/indent]


Function BinToDec As Long
[indent=2]Converts a binary string into into a long decimal value. (unsigned)[/indent]


Function BinToHex As String
[indent=2]Converts a binary string into a hex string with a given number of digits.[/indent]


Function HexDecToDec As Long
[indent=2]Converts a string from hex (if the string starts with "0x") or from decimal into a long decimal value. (unsigned/signed)[/indent]


Function ReverseBytes As String
[indent=2]Converts a Little-Endian hex string to Big-Endian.[/indent]


Function bAND As Long
[indent=2]Performs a bitwise AND on two long decimal variables.[/indent]


Function bOR As Long
[indent=2]Performs a bitwise OR on two long decimal variables.[/indent]


Function bXOR As Long
[indent=2]Performs a bitwise XOR on two long decimal variables.[/indent]


Function bNOT As Long
[indent=2]Performs a bitwise NOT on two long decimal variables.[/indent]


Function Smart_Trim As String
[indent=2]Trims out leading and trailing spaces, carriage returns and tab characters.[/indent]


Function Get_Filename_From_Path As String
[indent=2]Returns the filename from a file path.[/indent]


Function Get_Directory_Path_From_Path As String
[indent=2]Returns the directory path from a file/directory path.[/indent]


[/indent]

About FFT File List.txt
[indent=2]This file is necessary to load for anything that requests information about a file on the ISO like "SCUS_942.21", such as its Sector Offset or its Memory Offset.
This file needs to be placed in the same folder as your active spreadsheet. You can either download the "FFT File List.txt" in this topic, or generate one that suits your purposes with my ISO Manager.[/indent]
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Xifanie

  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Dokurider

Xifanie, I can't seem to import any .xml into the spreadsheet unless at least one hack contains an Variable line.

Xifanie

Posted a new version; should be fixed now.

To update manually, you only have to reimport the SharedXifiSheets module.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Xifanie

New version.

For an unknown reason, the Auto Replace function was not working properly at the moment of saving. I fixed it, but I have no idea why it didn't work yet does now. I just tried to move the procedure that fetched the Auto Replace table's data further down in the code, and it magically started working again.

I have no idea.

VBA sucks.

To update manually, you only have to reimport the SharedXifiSheets module.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Dokurider

Hey Xif I've been meaning to inform you of this for a while now and I finally managed to settle down enough write this out.

Opcode to Hex conversion doesn't convert branch functions correctly when linked to another cell. {="beq r2, r0, "&D185, where D185 being 0x8019E834}, for instance will convert to 0D7A4010 instead of it's correct hex (This looks like the hex for jump opcode?).

Xifanie

May 13, 2017, 07:55:26 pm #8 Last Edit: May 13, 2017, 08:16:16 pm by Xifanie
Newly reported bugs:

  • Excel 2010 might crap out an annoying, but not spreadsheet breaking, 32bit ShellExecute function error (possibly only on W10)



Bug Fixes:

  • Opcode -> Hex and Hex -> Opcode returned results that didn't take into account the current Memory Address in the previous column

  • MEMVariables were not properly saved to ISO (thanks to Pride for the bug report)



Esthetic Changes:

  • Changes all "FFT Image" instances to "PSX Image" as this spreadsheet it means to support any game; not just FFT

  • Clear All Hacks now also hides the Hex Backup column



Functions:

  • Added =LEAddress(), short for Little-Endian Address. Converts a Memory Address to a Little-Endian 4 bytes hex word. (Ex: =LEAddress("0x80164920") returns 20491680)

  • =LowerAddress() gained an optional second parameter where if true, it will convert the result to a negative number if applicable. (Ex: =LowerAddress("0x8014AB9C0", TRUE) returns -0x4640)

  • Removed the "Concatenate Cells" function because Pride showed me that =_xlfn.CONCAT() did the job way better. Apparently this was a mistake as Excel 2007/2010 do not support this function. I'll be reverting this in the next version.



TO UPDATE MANUALLY:

  • Reimport SharedXifiSheets.bas

  • Import Game.bas

  • Reimport configuration.frm (this is extremely optional, all it does is change some strings, feel free to skip)


  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Pride

Mentioned it in chat but I'll post it here. I seem to get a run time error whenever the last memlocation uses hex instead of an op code when I try to save it. I think this was the reason I originally got a few run time errors when I was first using the sheet.
  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

Xifanie

Quote from: Pride on May 15, 2017, 05:20:32 am
Mentioned it in chat but I'll post it here. I seem to get a run time error whenever the last memlocation uses hex instead of an op code when I try to save it. I think this was the reason I originally got a few run time errors when I was first using the sheet.


I'm unable to reproduce this :/
I'll be adding it to the bug list though.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Xifanie

Newly reported bugs:

  • Might get a run time error whenever the last MEMLOCATION uses hex instead of an op code when attempting to save



Bug Fixes:

  • Save to Savestate did not save anything to savestates anymore (thanks to Pride for the bug report)



Functions:

  • Re-introduced the "Concatenate Cells" function.



TO UPDATE MANUALLY:

  • Reimport SharedXifiSheets.bas


  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Pride

  • Modding version: PSX
Check out my ASM thread. Who doesn't like hax?

stardragoon9

I can't find the "Custom Toolbar" or the "Add-Ins" Toolbar Ribbon you've mentioned

And i get a error message everytime i click on something.

  • Modding version: PSX

Xifanie

I think it's a Windows 10 only issue, Windows 10 64-bit only, potentially?

I'm not sure how to make it work, tbh. I just copy/pasted that code back in the day. :v

I do have W10 on my desktop, but what I really lack is the time to look into this to fix it.
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

stardragoon9

Quote from: Xifanie on September 26, 2018, 09:18:46 pm
I think it's a Windows 10 only issue, Windows 10 64-bit only, potentially?

I'm not sure how to make it work, tbh. I just copy/pasted that code back in the day. :v

I do have W10 on my desktop, but what I really lack is the time to look into this to fix it.


My OS is Windows 7-64 Bit with Office 2013 Suite,is there also a specific version of office recommanded?
  • Modding version: PSX

Xifanie

...really? I guess what matters is a 32bit version of Excel then. I've been sticking to 2007 to maximize the compatibility of my spreadsheets >>;

Unfortunately, this also means that I cannot test. But I did find this to try:
https://access-programmers.co.uk/forums/showpost.php?s=efb1c6cbe0ae53a7a111943af9eafe0d&p=1407189&postcount=3
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Orkney

Hi,

I'm two years late, but i usualy put a "PtrSafe" just before the word "Function" and it solves the problem for me.
(But i must say i don't meet the problem with this specific workbook)
Unfortunately, I've no idea of what it does..
  • Modding version: PSX