News: 11 March 2016 - Forum Rules, Mobile Version
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia

Author Topic: ASM Compiler? Help with spaghetti code problem  (Read 635 times)

Yakibomb

  • Jr. Member
  • **
  • Posts: 16
  • SMRPG Hacker
    • View Profile
    • youtube.com
ASM Compiler? Help with spaghetti code problem
« 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.

jonk

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: ASM Compiler? Help with spaghetti code problem
« Reply #1 on: November 05, 2017, 09:10:30 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

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • My personal website of short stories and comics
Re: ASM Compiler? Help with spaghetti code problem
« Reply #2 on: November 09, 2017, 02:52:18 pm »
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." - Linus Torvalds