Skip to content

Commit

Permalink
Support for reading tape errors and gaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Mar 19, 2022
1 parent 135ab6c commit 269d3ed
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tape-word.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ static int reclen = 0;
static int beginning_of_tape = 1;
static int marks = 0;

static int get_tape_record (FILE *f, word_t **buffer);

static int
get_byte (FILE *f)
{
Expand Down Expand Up @@ -79,6 +81,18 @@ static void write_reclen (FILE *f, int n)
fputc ((n >> 24) & 0377, f);
}

static int tape_error (int code, FILE *f, word_t **buffer)
{
fprintf (stderr, "Tape error %06x.\n", code);
return get_tape_record (f, buffer);
}

static int tape_gap (int code, FILE *f, word_t **buffer)
{
fprintf (stderr, "Tape gap (%06x).\n", code);
return get_tape_record (f, buffer);
}

int get_9track_record (FILE *f, word_t **buffer)
{
int i, x, reclen;
Expand All @@ -87,6 +101,11 @@ int get_9track_record (FILE *f, word_t **buffer)
reclen = get_reclen (f);
if (reclen == 0)
return 0;
else if (((reclen >> 24) & 0xFF) == 0x80)
return tape_error (reclen & 0xFFFFFF, f, buffer);
else if (((reclen >> 24) & 0xFF) == 0xFF)
return tape_gap (reclen & 0xFFFFFF, f, buffer);

if (reclen % 5)
{
fprintf (stderr, "Not a CORE DUMP tape image.\n"
Expand Down Expand Up @@ -185,6 +204,11 @@ int get_7track_record (FILE *f, word_t **buffer)
reclen = get_reclen (f);
if (reclen == 0)
return 0;
else if (((reclen >> 24) & 0xFF) == 0x80)
return tape_error (reclen & 0xFFFFFF, f, buffer);
else if (((reclen >> 24) & 0xFF) == 0xFF)
return tape_gap (reclen & 0xFFFFFF, f, buffer);

if (reclen % 6)
{
fprintf (stderr, "Not a 7-track tape image.\n"
Expand Down

0 comments on commit 269d3ed

Please sign in to comment.