IsoFrieze / DiztinGUIsh

A Super NES ROM Disassembler
GNU General Public License v3.0
270 stars 26 forks source link

add usage map import for other CPUs #56

Open binary1230 opened 3 years ago

binary1230 commented 3 years ago

So our usage map import works great for main CPU

In the BSNES "-usage.bin" files output though, it contains usage info for all of the various kinds of CPUs.

Right now we're just reading the first part of that file (main CPU) and ignoring the rest (SA1, SFX, SPC, etc) looks like this:

We can totally parse that stuff though :)

BSNES code is doing stuff like this:

fp.read(SNES::cpu.usage, 1 << 24);
fp.read(SNES::smp.usage, 1 << 16);

if (SNES::cartridge.has_sa1())
    fp.read(SNES::sa1.usage, 1 << 24);

if (SNES::cartridge.hassuperfx())
    fp.read(SNES::superfx.usage, 1 << 23);

if (SNES::cartridge.mode() == SNES::Cartridge::Mode::SuperGameBoy)
    fp.read(SNES::supergameboy.usage, 1 << 24);

so we'd have to replicate that to read these files. one snag is they're calling SNES::cartridge.has_sa1(), which means we may need the same detection routines that BSNES has to know what data is next in the file. that's... kinda unfortunate, maybe we should add some kind of tagging into the BSNES file format so we don't have to detect the file format/etc.

binary1230 commented 3 years ago

other random note for me, ignore this. (about tracelogs)

// my code in BSNES (prob doing something old now)
void Tracer::outputSgbTrace() {
    char buf[256]; int len;
    if (traceOutputFormatIsText) {

        SNES::supergameboy.disassemble_opcode(buf, SNES::cpu.regs.pc);
                                                   ^^^^^^^^^^^^^^^^^
                                                   should be: SNES::supergameboy.opcode_pc

        len = strlen(buf) + 1; // byte size = string + null term
    } else {
        // TODO: implement // SNES::supergameboy.disassemble_opcode_bin(buf, SNES::cpu.regs.pc, len); // binary
        return; // TODO: not supported just yet
    }
    outputTrace(buf, len);
}

my code always said  SNES::cpu.regs.pc
their code now uses: SNES::supergameboy.opcode_pc
or                   *.opcode_pc

// their code:
    unsigned addr = SNES::supergameboy.opcode_pc;
    if(!traceMask || !(traceMaskSGB[addr >> 3] & (0x80 >> (addr & 7)))) {
      char text[256];
      SNES::supergameboy.disassemble_opcode(text, addr);
      tracefile.print(string() << text << "\n");