Enabling CPU trace and hex edit
This commit is contained in:
+39
@@ -31,6 +31,45 @@ EMSCRIPTEN_KEEPALIVE void ReadBuffer(
|
||||
*dest = vbRead(&sims[sim], address, VB_U8, debug);
|
||||
}
|
||||
|
||||
// Execute one instruction
|
||||
static uint32_t SingleStepPC;
|
||||
static int SingleStepProc(VB *emu, int fetch, VB_ACCESS *acc) {
|
||||
if (fetch == 0 && vbGetProgramCounter(emu, VB_PC) != SingleStepPC)
|
||||
return 1;
|
||||
acc->value = vbRead(emu, acc->address, acc->type, 0);
|
||||
return 0;
|
||||
}
|
||||
EMSCRIPTEN_KEEPALIVE void SingleStep(int sim) {
|
||||
uint32_t clocks = 400000; // 1/50s
|
||||
VB *emu = &sims[sim];
|
||||
SingleStepPC = vbGetProgramCounter(emu, VB_PC);
|
||||
emu->onFetch = &SingleStepProc;
|
||||
vbEmulate(emu, NULL, &clocks);
|
||||
emu->onFetch = NULL;
|
||||
}
|
||||
|
||||
// Attempt to execute until the following instruction
|
||||
static uint32_t RunNextPC;
|
||||
static int RunNextProcB(VB *emu, int fetch, VB_ACCESS *acc) {
|
||||
if (fetch == 0 && vbGetProgramCounter(emu, VB_PC) == RunNextPC)
|
||||
return 1;
|
||||
acc->value = vbRead(emu, acc->address, acc->type, 0);
|
||||
return 0;
|
||||
}
|
||||
static int RunNextProcA(VB *emu, VB_INSTRUCTION *inst) {
|
||||
RunNextPC = vbGetProgramCounter(emu, VB_PC) + inst->size;
|
||||
emu->onExecute = NULL;
|
||||
emu->onFetch = &RunNextProcB;
|
||||
return 0;
|
||||
}
|
||||
EMSCRIPTEN_KEEPALIVE void RunNext(int sim) {
|
||||
uint32_t clocks = 400000; // 1/50s
|
||||
VB *emu = &sims[sim];
|
||||
emu->onExecute = &RunNextProcA;
|
||||
vbEmulate(emu, NULL, &clocks);
|
||||
emu->onFetch = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////// Core Commands ////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user