all repos — mgba @ f40b9ec82edbb852f2ac0677fda01b5728a3bfba

mGBA Game Boy Advance Emulator

GB: Fix up debugger a bit
Jeffrey Pfau jeffrey@endrift.com
Mon, 30 May 2016 12:12:00 -0700
commit

f40b9ec82edbb852f2ac0677fda01b5728a3bfba

parent

0c59856fe364ff949eaee7f76f266292d600dada

6 files changed, 80 insertions(+), 5 deletions(-)

jump to
M src/gb/cli.csrc/gb/cli.c

@@ -16,6 +16,7 @@ #ifdef USE_CLI_DEBUGGER

static void _GBCLIDebuggerInit(struct CLIDebuggerSystem*); static bool _GBCLIDebuggerCustom(struct CLIDebuggerSystem*); +static uint32_t _GBCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv); static void _frame(struct CLIDebugger*, struct CLIDebugVector*);

@@ -31,7 +32,7 @@ LR35902CLIDebuggerCreate(&debugger->d);

debugger->d.init = _GBCLIDebuggerInit; debugger->d.deinit = NULL; debugger->d.custom = _GBCLIDebuggerCustom; - debugger->d.lookupIdentifier = NULL; + debugger->d.lookupIdentifier = _GBCLIDebuggerLookupIdentifier; debugger->d.name = "Game Boy"; debugger->d.commands = _GBCLIDebuggerCommands;

@@ -60,6 +61,19 @@ gbDebugger->inVblank = GBRegisterSTATGetMode(((struct GB*) gbDebugger->core->board)->memory.io[REG_STAT]) == 1;

return true; } return false; +} + +static uint32_t _GBCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem* debugger, const char* name, struct CLIDebugVector* dv) { + UNUSED(debugger); + int i; + for (i = 0; i < REG_MAX; ++i) { + const char* reg = GBIORegisterNames[i]; + if (reg && strcasecmp(reg, name) == 0) { + return GB_BASE_IO | i; + } + } + dv->type = CLIDV_ERROR_TYPE; + return 0; } static void _frame(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
M src/gb/io.csrc/gb/io.c

@@ -9,6 +9,64 @@ #include "gb/gb.h"

mLOG_DEFINE_CATEGORY(GB_IO, "GB I/O"); +const char* const GBIORegisterNames[] = { + [REG_JOYP] = "JOYP", + [REG_SB] = "SB", + [REG_SC] = "SC", + [REG_DIV] = "DIV", + [REG_TIMA] = "TIMA", + [REG_TMA] = "TMA", + [REG_TAC] = "TAC", + [REG_IF] = "IF", + [REG_NR10] = "NR10", + [REG_NR11] = "NR11", + [REG_NR12] = "NR12", + [REG_NR13] = "NR13", + [REG_NR14] = "NR14", + [REG_NR21] = "NR21", + [REG_NR22] = "NR22", + [REG_NR23] = "NR23", + [REG_NR24] = "NR24", + [REG_NR30] = "NR30", + [REG_NR31] = "NR31", + [REG_NR32] = "NR32", + [REG_NR33] = "NR33", + [REG_NR34] = "NR34", + [REG_NR41] = "NR41", + [REG_NR42] = "NR42", + [REG_NR43] = "NR43", + [REG_NR44] = "NR44", + [REG_NR50] = "NR50", + [REG_NR51] = "NR51", + [REG_NR52] = "NR52", + [REG_LCDC] = "LCDC", + [REG_STAT] = "STAT", + [REG_SCY] = "SCY", + [REG_SCX] = "SCX", + [REG_LY] = "LY", + [REG_LYC] = "LYC", + [REG_DMA] = "DMA", + [REG_BGP] = "BGP", + [REG_OBP0] = "OBP0", + [REG_OBP1] = "OBP1", + [REG_WY] = "WY", + [REG_WX] = "WX", + [REG_KEY1] = "KEY1", + [REG_VBK] = "VBK", + [REG_HDMA1] = "HDMA1", + [REG_HDMA2] = "HDMA2", + [REG_HDMA3] = "HDMA3", + [REG_HDMA4] = "HDMA4", + [REG_HDMA5] = "HDMA5", + [REG_RP] = "RP", + [REG_BCPS] = "BCPS", + [REG_BCPD] = "BCPD", + [REG_OCPS] = "OCPS", + [REG_OCPD] = "OCPD", + [REG_SVBK] = "SVBK", + [REG_IE] = "IE", +}; + static const uint8_t _registerMask[] = { [REG_SC] = 0x7E, // TODO: GBC differences [REG_IF] = 0xE0,
M src/gb/io.hsrc/gb/io.h

@@ -101,8 +101,11 @@ REG_UNK73 = 0x73,

REG_UNK74 = 0x74, REG_UNK75 = 0x75, REG_UNK76 = 0x76, - REG_UNK77 = 0x77 + REG_UNK77 = 0x77, + REG_MAX = 0x100 }; + +extern const char* const GBIORegisterNames[]; struct GB; void GBIOInit(struct GB* gb);
M src/gba/io.csrc/gba/io.c

@@ -12,7 +12,7 @@ #include "gba/video.h"

mLOG_DEFINE_CATEGORY(GBA_IO, "GBA I/O"); -const char* GBAIORegisterNames[] = { +const char* const GBAIORegisterNames[] = { // Video "DISPCNT", 0,
M src/gba/io.hsrc/gba/io.h

@@ -155,7 +155,7 @@ };

mLOG_DECLARE_CATEGORY(GBA_IO); -extern const char* GBAIORegisterNames[]; +extern const char* const GBAIORegisterNames[]; void GBAIOInit(struct GBA* gba); void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value);
M src/lr35902/debugger/cli-debugger.csrc/lr35902/debugger/cli-debugger.c

@@ -87,7 +87,7 @@ debugger->printStatus = _printStatus;

debugger->disassemble = NULL; debugger->lookupPlatformIdentifier = _lookupPlatformIdentifier; debugger->platformName = "GB-Z80"; - debugger->platformCommands = NULL; + debugger->platformCommands = _lr35902Commands; } #endif