From 71d13501431fcd27e983c1e5624144f5924e08ec Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 7 Apr 2020 13:37:52 -0400 Subject: [PATCH] emul/hw/rc2014: add memdump command Why didn't I think of adding it before? --- emul/hw/rc2014/README.md | 4 ++++ emul/hw/rc2014/classic.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/emul/hw/rc2014/README.md b/emul/hw/rc2014/README.md index 2cef11f..d4ac64b 100644 --- a/emul/hw/rc2014/README.md +++ b/emul/hw/rc2014/README.md @@ -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`. diff --git a/emul/hw/rc2014/classic.c b/emul/hw/rc2014/classic.c index 1f58e49..561c259 100644 --- a/emul/hw/rc2014/classic.c +++ b/emul/hw/rc2014/classic.c @@ -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;