1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-09-29 14:30:55 +10:00

Add emul_memdump() and stop automatically on ROM write

This commit is contained in:
Virgil Dupras 2020-04-09 08:26:41 -04:00
parent 6f082b0b13
commit b69ca4488e
3 changed files with 13 additions and 4 deletions

View File

@ -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);

View File

@ -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();

View File

@ -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"); emul_memdump();
FILE *fp = fopen("memdump", "w");
fwrite(m->mem, 0x10000, 1, fp);
fclose(fp);
c = 0; // don't send to RC2014 c = 0; // don't send to RC2014
} }
if (c == 4) { // CTRL+D if (c == 4) { // CTRL+D