Event Script Assembler Macros - Printable Version +- FF6 Hacking (https://www.ff6hacking.com/forums) +-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html) +--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html) +--- Thread: Event Script Assembler Macros (/thread-4385.html) |
Event Script Assembler Macros - Everything - 04-04-2024 I've been working on a set of assembler macros for writing and modifying FF6 events using an assembler. Essentially this allows you to write events in an easily readable text file and then convert them to binary automatically (just like how an assembler converts asm files into machine code). It's still a WIP, but it's now integrated into my ff6 repo on GitHub. It can also be used to generate standalone events without building the whole ROM. src/event/README.md contains more details and an incomplete list of event command descriptions, include/event_cmd.inc contains the macro definitions that are used to convert the event script commands into binary using the assembler, and src/event/event_main.asm contains the actual event script code. Currently, only the beginning and end of the event script get generated using the new macros. The rest is still imported as a raw binary that gets ripped from a vanilla ROM. Eventually, I'd like to generate the entire event script using just assembly files (like how the CPU code is generated). As an example, here's the script for the event that occurs when you use a Warp Stone or cast Warp (at CA/0108). The indentations are for readability only, they're not required. Code: ; ca/0108 Compare to Imzogelmo's event script dump, which has a bit more detail, but can't be easily converted back into binary. Code: CA/0108: F4 Play sound effect 76 So, why make this? The main reason is so that the assembler has access to event addresses/labels for my ff6 disassembly, but it can also be used to write shorter standalone events. Hackers often write events using an event editor built into one of the ROM editors (ZoneDoctor and FF6Tools have one) or by generating the raw binary code manually. These methods have issues of their own, but more importantly for me there's no easy way to reference event addresses in the CPU code, event triggers, NPCs, etc. I also think writing events this way is easier to read and understand. Another cool thing is that I'm pretty sure this is how the original devs wrote these scripts. The editors they used were probably pretty primitive, so they would have relied heavily on macro assemblers to do most of the script and data generation when developing the game. Like with anything new, there's going to be a learning curve if you want to write events with this. If you're already proficient with other methods for writing event code, this might not be worth learning. Also, Because ff6 contains such a large amount of code and data, the more familiar assemblers like Asar and xkas aren't really suitable. Instead, I've been using ca65 which is better suited to large projects, but nonetheless has issues of its own and is less familiar to most hacking folks. My next goals are to implement the remaining event commands, finish the documentation, convert the rest of the event script into this format, and then do lots of testing with custom events. I don't have as much time to spend on this stuff as I used to so if anyone would like to contribute or help out in any way I would really appreciate it. Let me know here or on GitHub and sorry in advance if I'm slow to reply. RE: Event Script Assembler Macros - madsiur - 04-04-2024 Awesome!! Edit: (I might have some time in the future to contribute again) RE: Event Script Assembler Macros - Everything - 04-27-2024 Big update - I finished making a full disassembly of the event script. The ff6 repo now contains an assembly file (src/event/event_main.asm) which can be assembled into a byte-for-byte copy of the vanilla event script, with all event addresses being properly linked to allow for insertion and deletion of event commands, as well as relocation of the entire script within the ROM. What's still missing is properly linking all of the event triggers, NPCs, and map startup event pointers to the event script, so the game will probably still crash if the script is modified. This was a big milestone though, and more updates will hopefully be coming soon. One thing I could use some help with is to separate the event script into multiple assembly files, which means I need to map out where the events for different parts of the game are located in the script. I started a list below, and if anyone can help fill out the rest of this by parsing through the script it would be very helpful. Code: CA/0000-CA/004E system events |