Skip to content

Commit f063f89

Browse files
committed
Account for DECtape record boundaries.
1 parent 9e2fdc3 commit f063f89

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

dta-word.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717

1818
#include "dis.h"
1919

20+
static int position = 0;
21+
22+
static void
23+
rewind_dta_word (FILE *f)
24+
{
25+
position = 0;
26+
rewind (f);
27+
}
28+
2029
static inline int
2130
get_byte (FILE *f)
2231
{
@@ -36,19 +45,18 @@ get_half (FILE *f)
3645
static word_t
3746
get_dta_word (FILE *f)
3847
{
39-
word_t word, h1, h2;
48+
word_t word;
4049

4150
if (feof (f))
4251
return -1;
4352

44-
h1 = get_half (f);
45-
h2 = get_half (f);
46-
47-
//fprintf (stderr, "%06llo %06llo\n", h1, h2);
48-
word = (h1 << 18);
49-
word += h2;
50-
//word = (get_half (f) << 18);
51-
//word += get_half (f);
53+
word = (get_half (f) << 18);
54+
word += get_half (f);
55+
56+
if ((position % 128) == 0)
57+
word |= START_RECORD;
58+
59+
position++;
5260
return word;
5361
}
5462

@@ -71,7 +79,7 @@ write_dta_word (FILE *f, word_t word)
7179
struct word_format dta_word_format = {
7280
"dta",
7381
get_dta_word,
74-
NULL,
82+
rewind_dta_word,
7583
write_dta_word,
7684
NULL
7785
};

0 commit comments

Comments
 (0)