finished debug menu, working on timing issues.
This commit is contained in:
@ -12,6 +12,7 @@ typedef struct {
|
|||||||
u16 dissasembly_scroll;
|
u16 dissasembly_scroll;
|
||||||
u16 dissasembly_target;
|
u16 dissasembly_target;
|
||||||
u16 dissasembly_pc;
|
u16 dissasembly_pc;
|
||||||
|
u16 breakpoint;
|
||||||
} debug_context;
|
} debug_context;
|
||||||
|
|
||||||
void debug_update();
|
void debug_update();
|
||||||
|
@ -76,6 +76,7 @@ void bus_write(u16 address, u8 value) {
|
|||||||
return;
|
return;
|
||||||
} else if (address < 0xFE00) {
|
} else if (address < 0xFE00) {
|
||||||
//reserved echo ram...
|
//reserved echo ram...
|
||||||
|
wram_write((address & 0x1FFF) | 0xC000, value);
|
||||||
return;
|
return;
|
||||||
} else if (address < 0xFEA0) {
|
} else if (address < 0xFEA0) {
|
||||||
//OAM
|
//OAM
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <dbg.h>
|
#include <dbg.h>
|
||||||
#include <timer.h>
|
#include <timer.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
static cpu_context ctx = {0};
|
static cpu_context ctx = {0};
|
||||||
#define CPU_DEBUG 1
|
#define CPU_DEBUG 1
|
||||||
@ -68,12 +69,17 @@ bool cpu_step() {
|
|||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
fetch_data(&ctx);
|
fetch_data(&ctx);
|
||||||
|
if(debug_get_context()->breakpoint && pc == debug_get_context()->breakpoint) {
|
||||||
|
emu_get_context()->paused = true;
|
||||||
|
emu_get_context()->debug = true;
|
||||||
|
debug_get_context()->state = DS_DISASSEMBLE;
|
||||||
|
}
|
||||||
while(emu_get_context()->paused && !emu_get_context()->step)
|
while(emu_get_context()->paused && !emu_get_context()->step)
|
||||||
delay(10);
|
delay(10);
|
||||||
if(emu_get_context()->paused) {
|
if(emu_get_context()->paused) {
|
||||||
emu_get_context()->step--;
|
emu_get_context()->step--;
|
||||||
if(emu_get_context()->step == 0) {
|
if(emu_get_context()->step == 0) {
|
||||||
printf("debug!\n");
|
//printf("debug!\n");
|
||||||
emu_get_context()->debug = true;
|
emu_get_context()->debug = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
lib/debug.c
13
lib/debug.c
@ -51,16 +51,13 @@ void debug_update() {
|
|||||||
} else if(!strcmp(cmd, "da")) {
|
} else if(!strcmp(cmd, "da")) {
|
||||||
scanf("%d", &ctx.dissasembly_target);
|
scanf("%d", &ctx.dissasembly_target);
|
||||||
ctx.state = DS_DISASSEMBLE;
|
ctx.state = DS_DISASSEMBLE;
|
||||||
} else if(!strcmp(cmd, "du")) {
|
} else if(cmd[0] == 'b' && cmd[1] == 'p') {
|
||||||
ctx.dissasembly_target--;
|
scanf("%X", &ctx.breakpoint);
|
||||||
ctx.state = DS_DISASSEMBLE;
|
//printf("Set breakpoint to %04X\n", ctx.breakpoint);
|
||||||
} else if(!strcmp(cmd, "dd")) {
|
|
||||||
scanf("%d", &ctx.dissasembly_target);
|
|
||||||
ctx.state = DS_DISASSEMBLE;
|
|
||||||
} else if(cmd[0] == 's') {
|
} else if(cmd[0] == 's') {
|
||||||
int steps;
|
int steps;
|
||||||
scanf("%d", &steps);
|
scanf("%d", &steps);
|
||||||
printf("adding %d steps\n", steps);
|
//printf("adding %d steps\n", steps);
|
||||||
emu_get_context()->step += steps;
|
emu_get_context()->step += steps;
|
||||||
emu_get_context()->debug = false;
|
emu_get_context()->debug = false;
|
||||||
}
|
}
|
||||||
@ -73,7 +70,7 @@ void debug_update() {
|
|||||||
fetch_instruction(&cpu_ctx);
|
fetch_instruction(&cpu_ctx);
|
||||||
fetch_data(&cpu_ctx);
|
fetch_data(&cpu_ctx);
|
||||||
char inst[16];
|
char inst[16];
|
||||||
inst_to_str(cpu_get_context(), inst);
|
inst_to_str(&cpu_ctx, inst);
|
||||||
sprintf(dissasembly[i], "%04X: %s", pc, inst);
|
sprintf(dissasembly[i], "%04X: %s", pc, inst);
|
||||||
if(pc == cpu_get_context()->inst_pc) {
|
if(pc == cpu_get_context()->inst_pc) {
|
||||||
ctx.dissasembly_scroll = i - 5;
|
ctx.dissasembly_scroll = i - 5;
|
||||||
|
@ -132,6 +132,8 @@ int emu_run(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void emu_cycles(int cpu_cycles) {
|
void emu_cycles(int cpu_cycles) {
|
||||||
|
if(emu_get_context()->paused && !emu_get_context()->step)
|
||||||
|
return;
|
||||||
for (int i = 0; i < cpu_cycles; i++){
|
for (int i = 0; i < cpu_cycles; i++){
|
||||||
for(int n = 0; n < 4; n++){
|
for(int n = 0; n < 4; n++){
|
||||||
ctx.ticks++;
|
ctx.ticks++;
|
||||||
|
Reference in New Issue
Block a user