static void CPUHandler(const v810_timestamp_t timestamp, uint32 PC) { std::vector<PCFX_BPOINT>::iterator bpit; for(bpit = BreakPointsPC.begin(); bpit != BreakPointsPC.end(); bpit++) { if(PC >= bpit->A[0] && PC <= bpit->A[1]) { FoundBPoint = TRUE; break; } } fx_vdc_chips[0]->ResetSimulate(); fx_vdc_chips[1]->ResetSimulate(); PCFX_V810.CheckBreakpoints(PCFXDBG_CheckBP, mem_peekhword, NULL); // FIXME: mem_peekword if(PCFX_LoggingOn) { // FIXME: There is a little race condition if a user turns on logging right between jump instruction and the first // instruction at 0xFFF0000C, in which case the call-from address will be wrong. static uint32 lastPC = ~0; if(PC == 0xFFF0000C) { static const char *font_sizes[6] = { "KANJI16x16", "KANJI12x12", "ANK8x16", "ANK6x12", "ANK8x8", "ANK8x12" }; // FIXME, overflow possible and speed PCFXDBG_DoLog("ROMFONT", "0x%08x->0xFFF0000C, PR7=0x%08x=%s, PR6=0x%04x = %s", lastPC, PCFX_V810.GetPR(7), (PCFX_V810.GetPR(7) > 5) ? "?" : font_sizes[PCFX_V810.GetPR(7)], PCFX_V810.GetPR(6) & 0xFFFF, PCFXDBG_ShiftJIS_to_UTF8(PCFX_V810.GetPR(6) & 0xFFFF)); setvbuf(stdout, NULL, _IONBF, 0); printf("%s", PCFXDBG_ShiftJIS_to_UTF8(PCFX_V810.GetPR(6) & 0xFFFF)); } else if(PC == 0xFFF00008) DoSyscallLog(); lastPC = PC; } CPUHookContinuous |= FoundBPoint; if(CPUHookContinuous && CPUHook) { ForceEventUpdates(timestamp); CPUHook(PC, FoundBPoint); } FoundBPoint = false; }
static void DoSyscallLog(void) { uint32 ws = 0; unsigned int which = 0; unsigned int nargs = 0; const char *func_name = "<unknown>"; char argsbuffer[2048]; for(unsigned int i = 0; i < sizeof(SysDefs) / sizeof(syscall_t); i++) { if(SysDefs[i].number == PCFX_V810.GetPR(10)) { nargs = SysDefs[i].arguments; func_name = SysDefs[i].name; which = i; break; } } { char *pos = argsbuffer; argsbuffer[0] = 0; pos += trio_sprintf(pos, "("); for(unsigned int i = 0; i < nargs; i++) { if(SysDefs[which].argument_types[i] == SVT_STRINGPTR) { uint8 quickiebuf[64 + 1]; int qbuf_index = 0; bool error_thing = FALSE; do { uint32 A = PCFX_V810.GetPR(6 + i) + qbuf_index; quickiebuf[qbuf_index] = 0; if(A >= 0x80000000 && A < 0xF0000000) { error_thing = TRUE; break; } quickiebuf[qbuf_index] = mem_peekbyte(ws, A); } while(quickiebuf[qbuf_index] && ++qbuf_index < 64); if(qbuf_index == 64) error_thing = TRUE; quickiebuf[64] = 0; if(error_thing) pos += trio_sprintf(pos, "0x%08x, ", PCFX_V810.GetPR(6 + i)); else { uint8 quickiebuf_utf8[64 * 6 + 1]; char *in_ptr, *out_ptr; size_t ibl, obl; ibl = qbuf_index; obl = sizeof(quickiebuf_utf8) - 1; in_ptr = (char *)quickiebuf; out_ptr = (char *)quickiebuf_utf8; if(iconv(sjis_ict, (ICONV_CONST char **)&in_ptr, &ibl, &out_ptr, &obl) == (size_t) -1) { pos += trio_sprintf(pos, "0x%08x, ", PCFX_V810.GetPR(6 + i)); } else { *out_ptr = 0; pos += trio_sprintf(pos, "@0x%08x=\"%s\", ", PCFX_V810.GetPR(6 + i), quickiebuf_utf8); } } } else pos += trio_sprintf(pos, "0x%08x, ", PCFX_V810.GetPR(6 + i)); } // Get rid of the trailing comma and space if(nargs) pos-=2; trio_sprintf(pos, ");"); } PCFXDBG_DoLog("SYSCALL", "0x%02x, %s: %s", PCFX_V810.GetPR(10), func_name, argsbuffer); }