Please login or register.

Login with username, password and session length
FFT Hack Template Spreadsheet  (Read 1424 times)
Pages: [1]
French Maid
Xifanie (Webmistress) [Posts: 4250]
  • View Profile
  • Final Fantasy Hacktics
  • http://steamcommunity.com/id/Xifanie
  • share
  • [January 01, 2017, 02:16:12 AM]
FFT Hack Template Spreadsheet
« on: January 01, 2017, 02:16:12 AM »
FFT Hack Template Spreadsheet

Downloads
Download the latest version (0.06b) - BLANK
Download the latest version (0.06b) - Xifanie's Hacks
Download "FFT File List.txt"
Download the latest update files

What is it?
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!

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")
*optional

Overview

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
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
« Last Edit: June 09, 2017, 11:22:35 PM by Xifanie »
    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [January 01, 2017, 02:17:09 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #1 on: January 01, 2017, 02:17:09 AM »
    SHEETS

    Tutorial
    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.


    Code
    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
    Column B: Patch Name

    DESCRIPTION
    Column B: Patch's Description (can be spread across multiple lines)

    COMMENT
    Column B: Comment (can be spread across multiple lines)

    MEMLOCATION
    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

    MEMLOCATION-1 and MEMLOCATION-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.

    MEMVARIABLE
    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!

    LOCATION
    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

    VARIABLE
    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!


    Hacks

    Hack Table
    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.

    Auto-Replace Table
    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"


    Hack Settings and Tables
    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.


    Calculations
    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.


    LoadFFTText
    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.


    How to create a new sheet with a Developer Toolbar
    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:
    Code: [Select]
    Private Sub Worksheet_Activate()
        Call HackToolbar("Developer")
    End Sub

    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [January 01, 2017, 02:17:39 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #2 on: January 01, 2017, 02:17:39 AM »
    SPREADSHEET FUNCTIONS AND VBA

    Spreadsheet Functions
    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
    Gets the upper half-word of a word to use with the lui opcode (ex: 0x8016AB6C --> 0x8017)

    Function LowerAddress As String
    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)

    Function ReverseBytes As String
    Converts a Little-Endian hex string to Big-Endian

    Function RangeAddress As String
    Outputs an array of ranges that can be used by VBA code (such as the LoadFFTText functions)


    VBA Subs and Functions
    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
    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.

    Function Open_ISO As Integer
    Readies your FFT ISO for binary read/write. Use with:
    Code: [Select]
    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.

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

    Function GetFileMatch As Long
    *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:
    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

    Function Create_Sort_Index As Long()
    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.

    Function Sort_Array As Variant
    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.

    Function Get_File_Data As Byte()
    Gets ISO Data and returns it into an array of bytes. (requires Open_ISO)

    Sub Save_File_Data
    Saves an array of bytes back into the ISO. (requires Open_ISO)

    Function ReadReg As Variant
    Gets the value of a specified registry key. If it doesn't exist, it will return a default value.

    Sub WriteReg
    Writes a value to a specified registry key.

    Function DecToHex As String
    Converts a long decimal value into a hex string with a given number of digits.

    Function DecToBin As String
    Converts a long decimal value into a binary string with a given number of digits.

    Function HexToDec As Long
    Converts a hex string into a long decimal value. (unsigned/signed)

    Function HexToBin As String
    Converts a hex string into a binary string with a given number of digits.

    Function BinToDec As Long
    Converts a binary string into into a long decimal value. (unsigned)

    Function BinToHex As String
    Converts a binary string into a hex string with a given number of digits.

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

    Function ReverseBytes As String
    Converts a Little-Endian hex string to Big-Endian.

    Function bAND As Long
    Performs a bitwise AND on two long decimal variables.

    Function bOR As Long
    Performs a bitwise OR on two long decimal variables.

    Function bXOR As Long
    Performs a bitwise XOR on two long decimal variables.

    Function bNOT As Long
    Performs a bitwise NOT on two long decimal variables.

    Function Smart_Trim As String
    Trims out leading and trailing spaces, carriage returns and tab characters.

    Function Get_Filename_From_Path As String
    Returns the filename from a file path.

    Function Get_Directory_Path_From_Path As String
    Returns the directory path from a file/directory path.


    About FFT File List.txt
    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.
    « Last Edit: May 13, 2017, 11:57:29 PM by Xifanie »
    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [January 01, 2017, 02:19:44 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #3 on: January 01, 2017, 02:19:44 AM »
    placeholder

    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    Internet Cool
    Dokurider [Posts: 2806]
    • View Profile
    • http://steamcommunity.com/profiles/76561198023738783/
    • share
    • [January 24, 2017, 12:16:45 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #4 on: January 24, 2017, 12:16:45 AM »
    Xifanie, I can't seem to import any .xml into the spreadsheet unless at least one hack contains an Variable line.
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [January 24, 2017, 08:31:58 PM]
    Re: FFT Hack Template Spreadsheet
    « Reply #5 on: January 24, 2017, 08:31:58 PM »
    Posted a new version; should be fixed now.

    To update manually, you only have to reimport the SharedXifiSheets module.

    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [April 23, 2017, 07:05:44 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #6 on: April 23, 2017, 07:05:44 AM »
    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
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    Internet Cool
    Dokurider [Posts: 2806]
    • View Profile
    • http://steamcommunity.com/profiles/76561198023738783/
    • share
    • [May 02, 2017, 02:44:52 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #7 on: May 02, 2017, 02:44:52 AM »
    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?).
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [May 13, 2017, 11:55:26 PM]
    Re: FFT Hack Template Spreadsheet
    « Reply #8 on: May 13, 2017, 11:55:26 PM »
    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)
    « Last Edit: May 14, 2017, 12:16:16 AM by Xifanie »
    • Modding version: PSX
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    May I kill him?
    Pride [Posts: 817]
    • View Profile
    • share
    • [May 15, 2017, 09:20:32 AM]
    Re: FFT Hack Template Spreadsheet
    « Reply #9 on: May 15, 2017, 09: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.

    • Modding version: PSX
  • Check out my ASM thread. Who doesn't like hax?
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [June 09, 2017, 11:17:55 PM]
    Re: FFT Hack Template Spreadsheet
    « Reply #10 on: June 09, 2017, 11:17:55 PM »
    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
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    French Maid
    Xifanie (Webmistress) [Posts: 4250]
    • View Profile
    • Final Fantasy Hacktics
    • http://steamcommunity.com/id/Xifanie
    • share
    • [June 09, 2017, 11:18:10 PM]
    Re: FFT Hack Template Spreadsheet
    « Reply #11 on: June 09, 2017, 11:18:10 PM »
    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
  • <R999> My target market is not FFT mod players
    <Raijinili> remember that? it was awful
    May I kill him?
    Pride [Posts: 817]
    • View Profile
    • share
    • [June 10, 2017, 08:52:52 PM]
    Re: FFT Hack Template Spreadsheet
    « Reply #12 on: June 10, 2017, 08:52:52 PM »
    Yayyy!!

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