mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:28:06 +11:00
Add emul_memdump() and stop automatically on ROM write
This commit is contained in:
parent
6f082b0b13
commit
b69ca4488e
11
emul/emul.c
11
emul/emul.c
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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…
Reference in New Issue
Block a user