News:

11 March 2016 - Forum Rules

Main Menu

ASM Compiler? Help with spaghetti code problem

Started by Yakibomb, November 05, 2017, 06:25:37 PM

Previous topic - Next topic

Yakibomb

Hello! I'm working on a hack for a Super NES game (Super Mario RPG). I've documented and added a lot of different things to one area in the ROM, but now it's become a huge JSR/JMP spaghetti-code fiesta and it's hard to figure out what each thing does and where.

Is there any program or tool to help organize the code? I've looked around but have had no luck.

jonk

Quote from: Yakibomb on November 05, 2017, 06:25:37 PM
Hello! I'm working on a hack for a Super NES game (Super Mario RPG). I've documented and added a lot of different things to one area in the ROM, but now it's become a huge JSR/JMP spaghetti-code fiesta and it's hard to figure out what each thing does and where.

Is there any program or tool to help organize the code? I've looked around but have had no luck.
I've written a few modest tools to help out with exactly this kind of thing. My son is making lots of code hacks to some SNES games and, of course, some prior subroutines need substantial expansion and more room which wasn't present there. So he either had to hack in a JMP/JSR into the existing routine, which transferred to his own code placed in some "blank areas" or else just completely replace all the call addresses to his new address and just write the code there (which meant that the old code location was now a "hole" that might be used for something else.)

So part of what I did was to modify an existing assembler and linker tool so that it supported creating and naming regions within the ROM (and it supports overlapped memory just fine in cases where memory is banked.) Now, he just writes assembly code in text files. The assembler generates the output, examines the mapping information, and then automatically locates the code as appropriate and patches the ROM (the tool will first copy the earlier ROM so that he doesn't lose the original.) All he does is "run the assembler" and the new ROM file is ready to go without any other tool use. It's directly patched. Just load and go, to test.

Don't know if that's what you are looking for, or if perhaps I misunderstood. But something like that? Or what did I miss?
An equal right to an opinion isn't a right to an equal opinion. -- 1995, me
Saying religion is the source of morality is like saying a squirrel is the source of acorns.  -- 2002, me

pianohombre

Just put all the new assembly in an ASM file and link it using an assembler like Asar. You can use labels in the program next to the jumps (which the linker replaces with memory addresses). Then, you can comment the code using semi-colons so it will be nice and tidy.
"Programming in itself is beauty,
whether or not the operating system actually functions." - Steve Wozniak