GB: Fix up debugger a bit

This commit is contained in:
Jeffrey Pfau 2016-05-30 12:12:00 -07:00
parent 0c59856fe3
commit f40b9ec82e
6 changed files with 80 additions and 5 deletions

View File

@ -16,6 +16,7 @@
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 @@ struct CLIDebuggerSystem* GBCLIDebuggerCreate(struct mCore* core) {
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;
@ -62,6 +63,19 @@ static bool _GBCLIDebuggerCustom(struct CLIDebuggerSystem* debugger) {
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) {
UNUSED(dv);
debugger->d.state = DEBUGGER_CUSTOM;

View File

@ -9,6 +9,64 @@
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,

View File

@ -101,9 +101,12 @@ enum GBIORegisters {
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);
void GBIOReset(struct GB* gb);

View File

@ -12,7 +12,7 @@
mLOG_DEFINE_CATEGORY(GBA_IO, "GBA I/O");
const char* GBAIORegisterNames[] = {
const char* const GBAIORegisterNames[] = {
// Video
"DISPCNT",
0,

View File

@ -155,7 +155,7 @@ enum GBAIORegisters {
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);

View File

@ -87,7 +87,7 @@ void LR35902CLIDebuggerCreate(struct CLIDebuggerSystem* debugger) {
debugger->disassemble = NULL;
debugger->lookupPlatformIdentifier = _lookupPlatformIdentifier;
debugger->platformName = "GB-Z80";
debugger->platformCommands = NULL;
debugger->platformCommands = _lr35902Commands;
}
#endif