emul/hw/rc2014: add memdump command

Why didn't I think of adding it before?
This commit is contained in:
Virgil Dupras 2020-04-07 13:37:52 -04:00
parent a09e552ccc
commit 71d1350143
2 changed files with 11 additions and 0 deletions

View File

@ -9,3 +9,7 @@ Run `make` to build.
Run `./classic /path/to/rom` (for example, `os.bin` from RC2014's recipe).
Serial I/O is hooked to stdin/stdout. `CTRL+D` to quit.
## Memory dump
You can press `CTRL+E` to dump the whole 64K of memory into `memdump`.

View File

@ -101,6 +101,13 @@ int main(int argc, char *argv[])
if (!tosend) {
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);
c = 0; // don't send to RC2014
}
if (c == 4) { // CTRL+D
// Stop here
break;