1
0
mirror of https://github.com/open-simh/simh.git synced 2026-01-11 23:53:30 +00:00

Imlac: Add support for loading paper tapes.

"load -p" loads a paper tape image.
This commit is contained in:
Lars Brinkhoff 2025-06-01 12:44:54 +02:00 committed by Paul Koning
parent ae2e3b02fd
commit aa1f31dad0

View File

@ -150,6 +150,74 @@ load_stty (FILE *fileref)
}
}
static t_stat
get_word (FILE *fileref, uint16 *x)
{
int c = Fgetc (fileref);
if (c == EOF)
return SCPE_IOERR;
*x = c << 8;
c = Fgetc (fileref);
if (c == EOF)
return SCPE_IOERR;
*x |= c;
return SCPE_OK;
}
static t_stat
load_ptr (FILE *fileref)
{
int verbose = sim_switches & SWMASK ('V');
uint16 x, addr;
uint32 csum;
int c, i, count;
/* Discard block loader. */
for (c = 0; c != 2;) {
c = Fgetc (fileref);
if (c == EOF)
return SCPE_IOERR;
}
for (i = 0; i < 123; i++) {
c = Fgetc (fileref);
if (c == EOF)
return SCPE_IOERR;
}
for (;;) {
c = Fgetc (fileref);
if (c == EOF)
return SCPE_IOERR;
if (c == 0)
continue;
count = c;
if (get_word (fileref, &addr) != SCPE_OK)
return SCPE_IOERR;
/* Address all ones means done. */
if (addr == 0177777)
return SCPE_OK;
csum = 0;
for (i = 0; i < count; i++) {
if (get_word (fileref, &x) != SCPE_OK)
return SCPE_IOERR;
M[(addr++) & memmask] = x;
csum += x;
if (csum & 0200000) {
csum++;
csum &= 0177777;
}
}
if (get_word (fileref, &x) != SCPE_OK)
return SCPE_IOERR;
if (x != csum)
return SCPE_CSUM;
}
}
t_stat
sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
{
@ -160,7 +228,7 @@ sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
else if (sim_switches & SWMASK ('M'))
;
else if (sim_switches & SWMASK ('P'))
;
return load_ptr (fileref);
else
return SCPE_ARG;
return SCPE_OK;