Browse Source

Add emul_memdump() and stop automatically on ROM write

pull/102/head
Virgil Dupras 4 years ago
parent
commit
b69ca4488e
3 changed files with 13 additions and 4 deletions
  1. +11
    -0
      emul/emul.c
  2. +1
    -0
      emul/emul.h
  3. +1
    -4
      emul/hw/rc2014/classic.c

+ 11
- 0
emul/emul.c View File

@@ -41,6 +41,9 @@ static void mem_write(int unused, uint16_t addr, uint8_t val)
{
if (addr < m.ramstart) {
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;
}
@@ -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()
{
fprintf(stderr, "Min SP: %04x\n", m.minsp);


+ 1
- 0
emul/emul.h View File

@@ -31,4 +31,5 @@ bool emul_step();
bool emul_steps(unsigned int steps);
void emul_loop();
void emul_trace(ushort addr);
void emul_memdump();
void emul_printdebug();

+ 1
- 4
emul/hw/rc2014/classic.c View File

@@ -102,10 +102,7 @@ int main(int argc, char *argv[])
char c;
if (read(fileno(stdin), &c, 1) == 1) {
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
}
if (c == 4) { // CTRL+D


Loading…
Cancel
Save