diff options
| author | Julian Blake Kongslie | 2022-03-20 17:25:39 -0700 |
|---|---|---|
| committer | Julian Blake Kongslie | 2022-03-20 17:25:39 -0700 |
| commit | d5ecb005e4b71786e63f03cb819a358b6bf0219c (patch) | |
| tree | f8e0fa3cc76d2a428d0ead9df271226d73cdb619 /tool | |
| parent | Add a few useful memory images. (diff) | |
| download | multipdp8-d5ecb005e4b71786e63f03cb819a358b6bf0219c.tar.xz | |
Support loading RIMs and multi-word lines via the UART loader.
Diffstat (limited to 'tool')
| -rw-r--r-- | tool/p8bin2uart.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/tool/p8bin2uart.c b/tool/p8bin2uart.c index 0eec14e..14cb207 100644 --- a/tool/p8bin2uart.c +++ b/tool/p8bin2uart.c | |||
| @@ -47,6 +47,8 @@ uint16_t mem[32768]; | |||
| 47 | int | 47 | int |
| 48 | load(FILE *fp) | 48 | load(FILE *fp) |
| 49 | { | 49 | { |
| 50 | bool binfile = false; | ||
| 51 | bool sawdata = false; | ||
| 50 | enum { Addr, Data, Leader, Fetch, Skip , Start } s = Start; | 52 | enum { Addr, Data, Leader, Fetch, Skip , Start } s = Start; |
| 51 | int c = 0, n, v = 0; | 53 | int c = 0, n, v = 0; |
| 52 | uint16_t a = 0, d = 0, t = 0, u = 0; | 54 | uint16_t a = 0, d = 0, t = 0, u = 0; |
| @@ -66,7 +68,7 @@ load(FILE *fp) | |||
| 66 | fetch: | 68 | fetch: |
| 67 | if (c == 0200) { | 69 | if (c == 0200) { |
| 68 | if ((d & 0x8000) != 0) { | 70 | if ((d & 0x8000) != 0) { |
| 69 | if ((d & 07777) != (t & 07777)) | 71 | if (binfile && (d & 07777) != (t & 07777)) |
| 70 | fprintf(stderr, "\nbad checksum %05o\n", t & 07777); | 72 | fprintf(stderr, "\nbad checksum %05o\n", t & 07777); |
| 71 | else | 73 | else |
| 72 | v = 1; | 74 | v = 1; |
| @@ -77,6 +79,8 @@ load(FILE *fp) | |||
| 77 | u = 0; | 79 | u = 0; |
| 78 | if (d & 0x8000) { | 80 | if (d & 0x8000) { |
| 79 | mem[a] = d & 07777; | 81 | mem[a] = d & 07777; |
| 82 | binfile |= sawdata; | ||
| 83 | sawdata = true; | ||
| 80 | a = (a & ~07777) | ((a + 1) & 07777); | 84 | a = (a & ~07777) | ((a + 1) & 07777); |
| 81 | d = 0; | 85 | d = 0; |
| 82 | } | 86 | } |
| @@ -89,6 +93,7 @@ load(FILE *fp) | |||
| 89 | if ((c & 0300) == 0100) { | 93 | if ((c & 0300) == 0100) { |
| 90 | u = c; | 94 | u = c; |
| 91 | a = (a & ~07777) | (c & 077) << 6; | 95 | a = (a & ~07777) | (c & 077) << 6; |
| 96 | sawdata = false; | ||
| 92 | s = Addr; | 97 | s = Addr; |
| 93 | break; | 98 | break; |
| 94 | } | 99 | } |
| @@ -197,8 +202,8 @@ dump(unsigned int wordsperline) | |||
| 197 | int | 202 | int |
| 198 | main(int argc, char *argv[]) | 203 | main(int argc, char *argv[]) |
| 199 | { | 204 | { |
| 200 | if (argc != 3) { | 205 | if (argc < 3) { |
| 201 | fprintf(stderr, "usage: p8 wordsperline filename.bin\n"); | 206 | fprintf(stderr, "usage: p8 wordsperline filename.bin|rim [... filename.bin|rim]\n"); |
| 202 | exit(EXIT_FAILURE); | 207 | exit(EXIT_FAILURE); |
| 203 | } | 208 | } |
| 204 | char *end; | 209 | char *end; |
| @@ -207,14 +212,17 @@ main(int argc, char *argv[]) | |||
| 207 | perror(argv[1]); | 212 | perror(argv[1]); |
| 208 | exit(EXIT_FAILURE); | 213 | exit(EXIT_FAILURE); |
| 209 | } | 214 | } |
| 210 | FILE *fp = fopen(argv[2], "rb"); | 215 | for (int i = 2; i < argc; ++i) { |
| 211 | if (!fp) { | 216 | fprintf(stderr, "Loading %s...\n", argv[i]); |
| 212 | perror(argv[2]); | 217 | FILE *fp = fopen(argv[i], "rb"); |
| 213 | exit(EXIT_FAILURE); | 218 | if (!fp) { |
| 219 | perror(argv[i]); | ||
| 220 | exit(EXIT_FAILURE); | ||
| 221 | } | ||
| 222 | if (!load(fp)) | ||
| 223 | exit(EXIT_FAILURE); | ||
| 224 | fclose(fp); | ||
| 214 | } | 225 | } |
| 215 | if (!load(fp)) | ||
| 216 | exit(EXIT_FAILURE); | ||
| 217 | fclose(fp); | ||
| 218 | dump(wordsperline); | 226 | dump(wordsperline); |
| 219 | exit(EXIT_SUCCESS); | 227 | exit(EXIT_SUCCESS); |
| 220 | } | 228 | } |
