@@ -41,6 +41,9 @@ static void mem_write(int unused, uint16_t addr, uint8_t val) | |||||
{ | { | ||||
if (addr < m.ramstart) { | if (addr < m.ramstart) { | ||||
fprintf(stderr, "Writing to ROM (%d)!\n", addr); | fprintf(stderr, "Writing to ROM (%d)!\n", addr); | ||||
emul_memdump(); | |||||
fprintf(stderr, "Press any key to continue...\n"); | |||||
while (getchar() > 0x100); | |||||
} | } | ||||
m.mem[addr] = val; | m.mem[addr] = val; | ||||
} | } | ||||
@@ -102,6 +105,14 @@ void emul_trace(ushort addr) | |||||
} | } | ||||
} | } | ||||
void emul_memdump() | |||||
{ | |||||
fprintf(stderr, "Dumping memory to memdump. PC %04x\n", m.cpu.PC); | |||||
FILE *fp = fopen("memdump", "w"); | |||||
fwrite(m.mem, 0x10000, 1, fp); | |||||
fclose(fp); | |||||
} | |||||
void emul_printdebug() | void emul_printdebug() | ||||
{ | { | ||||
fprintf(stderr, "Min SP: %04x\n", m.minsp); | fprintf(stderr, "Min SP: %04x\n", m.minsp); | ||||
@@ -31,4 +31,5 @@ bool emul_step(); | |||||
bool emul_steps(unsigned int steps); | bool emul_steps(unsigned int steps); | ||||
void emul_loop(); | void emul_loop(); | ||||
void emul_trace(ushort addr); | void emul_trace(ushort addr); | ||||
void emul_memdump(); | |||||
void emul_printdebug(); | void emul_printdebug(); |
@@ -102,10 +102,7 @@ int main(int argc, char *argv[]) | |||||
char c; | char c; | ||||
if (read(fileno(stdin), &c, 1) == 1) { | if (read(fileno(stdin), &c, 1) == 1) { | ||||
if (c == 5) { | if (c == 5) { | ||||
fprintf(stderr, "Dumping memory to memdump\n"); | |||||
FILE *fp = fopen("memdump", "w"); | |||||
fwrite(m->mem, 0x10000, 1, fp); | |||||
fclose(fp); | |||||
emul_memdump(); | |||||
c = 0; // don't send to RC2014 | c = 0; // don't send to RC2014 | ||||
} | } | ||||
if (c == 4) { // CTRL+D | if (c == 4) { // CTRL+D | ||||