PDP8: Extend LOAD logic to advise about additional loadable binary content

- As discussed in #1017
- Additionally, fix binary read of rubout characters to ignore diagnostic
  messages
This commit is contained in:
Mark Pizzolato 2021-03-05 08:11:07 -08:00
parent a1785ac1d0
commit c496d53844

View file

@ -177,50 +177,86 @@ int32 c, rubout;
rubout = 0; /* clear toggle */
while ((c = getc (fi)) != EOF) { /* read char */
if (rubout) /* toggle set? */
if (rubout) /* skipping chars */
if (c == 0377) /* ending rubout? */
rubout = 0; /* clr, skip */
else if (c == 0377) /* rubout? */
else
continue; /* skip charactder */
if (c == 0377) /* rubout? */
rubout = 1; /* set, skip */
else if (c > 0200) /* channel 8 set? */
else
if (c > 0200) /* channel 8 set? */
*newf = (c & 070) << 9; /* change field */
else return c; /* otherwise ok */
else
return c; /* otherwise ok */
}
return EOF;
}
t_stat sim_load_bin (FILE *fi)
t_stat sim_load_bin (FILE *fi, t_bool do_load)
{
int32 hi, lo, wd, csum, t;
uint32 field, newf, origin;
uint32 field, newf, origin, words;
int32 sections_read = 0;
for (;;) {
csum = origin = field = newf = 0; /* init */
csum = origin = field = newf = words = 0; /* init */
do { /* skip leader */
if ((hi = sim_bin_getc (fi, &newf)) == EOF) {
if (sections_read != 0) {
sim_printf ("%d sections sucessfully read\n\r", sections_read);
return SCPE_OK;
}
if (sections_read != 0)
return sim_messagef (SCPE_OK, "%d section%s sucessfully read\n",
sections_read, (sections_read != 1) ? "s" : "");
else
return SCPE_FMT;
return (!do_load) ? SCPE_ARG : sim_messagef (SCPE_FMT, "unexpected binary loader data format\n");
}
} while ((hi == 0) || (hi >= 0200));
for (;;) { /* data blocks */
if ((lo = sim_bin_getc (fi, &newf)) == EOF) /* low char */
return SCPE_FMT;
if ((lo = sim_bin_getc (fi, &newf)) == EOF) { /* low char */
if (sections_read != 0)
sim_messagef (SCPE_OK, "%d section%s sucessfully read\n",
sections_read, (sections_read != 1) ? "s" : "");
if (words != 0)
sim_messagef (SCPE_OK, "%d %swords stored\n", words, (sections_read != 0) ? "additional " : "");
return (!do_load) ? SCPE_FMT : sim_messagef (SCPE_FMT, "unexpected binary loader data format\n");
}
wd = (hi << 6) | lo; /* form word */
t = hi; /* save for csum */
if ((hi = sim_bin_getc (fi, &newf)) == EOF) /* next char */
return SCPE_FMT;
if ((hi = sim_bin_getc (fi, &newf)) == EOF) { /* next char */
if (sections_read != 0)
sim_messagef (SCPE_OK, "%d section%s sucessfully read\n",
sections_read, (sections_read != 1) ? "s" : "");
if (words != 0)
sim_messagef (SCPE_OK, "%d %swords stored\n", words, (sections_read != 0) ? "additional " : "");
return (!do_load) ? SCPE_FMT : sim_messagef (SCPE_FMT, "unexpected binary loader data format\n");
}
if (hi == 0200) { /* end of tape? */
if ((csum - wd) & 07777) { /* valid csum? */
if (sections_read != 0)
sim_printf ("%d sections sucessfully read\n\r", sections_read);
return SCPE_CSUM;
sim_messagef (SCPE_OK, "%d section%s sucessfully read\n",
sections_read, (sections_read != 1) ? "s" : "");
if (words != 0)
sim_messagef (SCPE_OK, "%d %swords stored\n", words, (sections_read != 0) ? "additional " : "");
return (!do_load) ? SCPE_CSUM : sim_messagef (SCPE_CSUM, "unexpected binary loader checksum\n");
}
if (!(sim_switches & SWMASK ('A'))) { /* Don't Load all sections? */
if (do_load) { /* Loaded initial section? */
int32 saved_switches = sim_switches;
t_stat extra;
sim_switches |= SWMASK ('Q');
extra = sim_load_bin (fi, FALSE); /* Check for more sections */
sim_switches = saved_switches;
if (extra == SCPE_OK) {
sim_messagef (SCPE_OK, "initial section loaded - more sections are available\n");
sim_messagef (SCPE_OK, "use LOAD -A <filename> to load all sections\n");;
}
else
if (extra != SCPE_ARG)
sim_messagef (SCPE_OK, "initial section loaded - badly formatted additional binary data exists\n");
}
if (!(sim_switches & SWMASK ('A'))) /* Load all sections? */
return SCPE_OK;
}
sections_read++;
break;
}
@ -230,9 +266,11 @@ for (;;) {
else { /* no, data */
if ((field | origin) >= MEMSIZE)
return SCPE_NXM;
if (do_load)
M[field | origin] = wd;
origin = (origin + 1) & 07777;
}
++words;
field = newf; /* update field */
}
}
@ -253,7 +291,7 @@ if (flag != 0)
if ((sim_switches & SWMASK ('R')) || /* RIM format? */
(match_ext (fnam, "RIM") && !(sim_switches & SWMASK ('B'))))
return sim_load_rim (fileref);
else return sim_load_bin (fileref); /* no, BIN */
else return sim_load_bin (fileref, TRUE); /* no, BIN */
}
/* Symbol tables */