mirror of
https://github.com/open-simh/simh.git
synced 2026-04-28 12:57:40 +00:00
SIM_CARD: Fixed to better detect mixed binary and ascii decks.
This commit is contained in:
committed by
Paul Koning
parent
c3f55fc692
commit
9c2c1117e8
79
sim_card.c
79
sim_card.c
@@ -53,11 +53,11 @@
|
|||||||
of card.
|
of card.
|
||||||
|
|
||||||
ASCII mode recognizes some additional forms of input which allows the
|
ASCII mode recognizes some additional forms of input which allows the
|
||||||
intermixing of binary cards with text cards.
|
intermixing of binary cards with text cards.
|
||||||
|
|
||||||
Lines beginning with ~raw are taken as a number of 4 digit octal values
|
Lines beginning with ~raw are taken as a number of 4 digit octal values
|
||||||
with represent each column of the card from 12 row down to 9 row. If there
|
with represent each column of the card from 12 row down to 9 row. If there
|
||||||
is not enough octal numbers to span a full card the remainder of the
|
is not enough octal numbers to span a full card the remainder of the
|
||||||
card will not be punched.
|
card will not be punched.
|
||||||
|
|
||||||
Also ~eor, will generate a 7/8/9 punch card. An ~eof will gernerate a
|
Also ~eor, will generate a 7/8/9 punch card. An ~eof will gernerate a
|
||||||
@@ -66,7 +66,10 @@
|
|||||||
A single line of ~ will set the EOF flag when that card is read.
|
A single line of ~ will set the EOF flag when that card is read.
|
||||||
|
|
||||||
For autodetection of card format, there can be no parity errors.
|
For autodetection of card format, there can be no parity errors.
|
||||||
All undeterminate formats are treated as ASCII.
|
All undeterminate formats are treated as ASCII. CBN and BCD cards
|
||||||
|
must also contain short or full records, if the record is not terminate
|
||||||
|
early by a EOR flag, then only up to record size (80 for BCD and
|
||||||
|
160 for CBN will be read).
|
||||||
|
|
||||||
Auto output format is ASCII if card has only printable characters
|
Auto output format is ASCII if card has only printable characters
|
||||||
or card format binary.
|
or card format binary.
|
||||||
@@ -153,7 +156,7 @@ static const uint16 ascii_to_hol_026[128] = {
|
|||||||
/* p q r s t u v w */
|
/* p q r s t u v w */
|
||||||
0xC04, 0xC02, 0xC01, 0x680, 0x640, 0x620, 0x610, 0x608,
|
0xC04, 0xC02, 0xC01, 0x680, 0x640, 0x620, 0x610, 0x608,
|
||||||
/* x y z { | } ~ del */
|
/* x y z { | } ~ del */
|
||||||
/* T79 X78 Y79 79 */
|
/* T79 X78 X79 79 */
|
||||||
0x604, 0x602, 0x601, 0x406, 0x806, 0x805, 0x005, 0xf000
|
0x604, 0x602, 0x601, 0x406, 0x806, 0x805, 0x005, 0xf000
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -683,6 +686,7 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
int col;
|
int col;
|
||||||
|
|
||||||
sim_debug(DEBUG_CARD, dptr, "Read card ");
|
sim_debug(DEBUG_CARD, dptr, "Read card ");
|
||||||
|
memset(image, 0, 160);
|
||||||
if ((uptr->flags & UNIT_CARD_MODE) == MODE_AUTO) {
|
if ((uptr->flags & UNIT_CARD_MODE) == MODE_AUTO) {
|
||||||
mode = MODE_TEXT; /* Default is text */
|
mode = MODE_TEXT; /* Default is text */
|
||||||
|
|
||||||
@@ -697,27 +701,29 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
int odd = 0;
|
int odd = 0;
|
||||||
int even = 0;
|
int even = 0;
|
||||||
|
|
||||||
/* Clear record mark */
|
|
||||||
buf->buffer[0] &= 0x7f;
|
|
||||||
/* Check all chars for correct parity */
|
/* Check all chars for correct parity */
|
||||||
for(i = 0, temp = 0; i < buf->len; i++) {
|
for(i = 0, temp = 0; i < buf->len; i++) {
|
||||||
uint8 ch = buf->buffer[i];
|
uint8 ch = buf->buffer[i] & 0177;
|
||||||
/* Stop at EOR */
|
|
||||||
if (ch & 0x80)
|
|
||||||
break;
|
|
||||||
/* Try matching parity */
|
/* Try matching parity */
|
||||||
if (sim_parity_table[(ch & 077)] == (ch & 0100))
|
if (sim_parity_table[(ch & 077)] == (ch & 0100))
|
||||||
even++;
|
even++;
|
||||||
else
|
else
|
||||||
odd++;
|
odd++;
|
||||||
|
/* Check if we hit end of record. */
|
||||||
|
if ((i == 79 && even == 80) || (i == 159 && odd == 160)) {
|
||||||
|
ch = buf->buffer[i+1];
|
||||||
|
/* If we have EOR then all ok */
|
||||||
|
if (ch & 0x80)
|
||||||
|
break;
|
||||||
|
if (ch == '\r' || ch == '\n' || ch >= ' ')
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Restore it */
|
if (even == 0 && odd == 160)
|
||||||
buf->buffer[0] |= 0x80;
|
|
||||||
if (i == 160 && odd == i)
|
|
||||||
mode = MODE_CBN;
|
mode = MODE_CBN;
|
||||||
else if (i < 80 && even == i)
|
else if (odd == 80 && even == 0)
|
||||||
mode = MODE_BCD;
|
mode = MODE_BCD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if modes match */
|
/* Check if modes match */
|
||||||
if ((uptr->flags & UNIT_CARD_MODE) != MODE_AUTO &&
|
if ((uptr->flags & UNIT_CARD_MODE) != MODE_AUTO &&
|
||||||
@@ -788,6 +794,10 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
sim_debug(DEBUG_CARD, dptr, "-eoi-");
|
sim_debug(DEBUG_CARD, dptr, "-eoi-");
|
||||||
(*image)[0] = 017; /* 6/7/8/9 punch */
|
(*image)[0] = 017; /* 6/7/8/9 punch */
|
||||||
i = 4;
|
i = 4;
|
||||||
|
} else if (_cmpcard(&buf->buffer[0], "78")) {
|
||||||
|
sim_debug(DEBUG_CARD, dptr, "-78-");
|
||||||
|
(*image)[0] = 06; /* 7/8 punch */
|
||||||
|
i = 3;
|
||||||
} else {
|
} else {
|
||||||
/* Convert text line into card image */
|
/* Convert text line into card image */
|
||||||
for (col = 0, i = 0; col < 80 && i < buf->len; i++) {
|
for (col = 0, i = 0; col < 80 && i < buf->len; i++) {
|
||||||
@@ -889,14 +899,16 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
(*image)[col++] |= c;
|
(*image)[col++] |= c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < buf->len && col >= 80 && (buf->buffer[i] & 0x80) == 0) {
|
|
||||||
(*image)[0] |= CARD_ERR;
|
|
||||||
}
|
|
||||||
/* Record over length of card, skip until next */
|
/* Record over length of card, skip until next */
|
||||||
while ((buf->buffer[i] & 0x80) == 0) {
|
if ((uptr->flags & UNIT_CARD_MODE) != MODE_AUTO) {
|
||||||
if (i > buf->len)
|
if (i < buf->len && col >= 80 && (buf->buffer[i] & 0x80) == 0) {
|
||||||
break;
|
(*image)[0] |= CARD_ERR;
|
||||||
i++;
|
while ((buf->buffer[i] & 0x80) == 0) {
|
||||||
|
if (i > buf->len)
|
||||||
|
break;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -909,9 +921,6 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear record mark */
|
|
||||||
buf->buffer[0] &= 0x7f;
|
|
||||||
|
|
||||||
/* Convert text line into card image */
|
/* Convert text line into card image */
|
||||||
for (col = 0, i = 0; col < 80 && i < buf->len; i++) {
|
for (col = 0, i = 0; col < 80 && i < buf->len; i++) {
|
||||||
if (buf->buffer[i] & 0x80)
|
if (buf->buffer[i] & 0x80)
|
||||||
@@ -924,17 +933,17 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
|||||||
(*image)[col++] = sim_bcd_to_hol(c);
|
(*image)[col++] = sim_bcd_to_hol(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < buf->len && col >= 80 && (buf->buffer[i] & 0x80) == 0) {
|
|
||||||
(*image)[0] |= CARD_ERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Record over length of card, skip until next */
|
/* Record over length of card, skip until next */
|
||||||
while ((buf->buffer[i] & 0x80) == 0) {
|
if ((uptr->flags & UNIT_CARD_MODE) != MODE_AUTO) {
|
||||||
if (i > buf->len)
|
if (i < buf->len && col >= 80 && (buf->buffer[i] & 0x80) == 0) {
|
||||||
break;
|
(*image)[0] |= CARD_ERR;
|
||||||
i++;
|
while ((buf->buffer[i] & 0x80) == 0) {
|
||||||
|
if (i > buf->len)
|
||||||
|
break;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sim_debug(DEBUG_CARD, dptr, "]\n");
|
sim_debug(DEBUG_CARD, dptr, "]\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1424,7 +1433,7 @@ t_stat sim_card_attach_help(FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, cons
|
|||||||
}
|
}
|
||||||
if (uptr == NULL)
|
if (uptr == NULL)
|
||||||
uptr = dptr->units;
|
uptr = dptr->units;
|
||||||
fprintf (st, "%s Card %s%s%sAttach Help\n\n", dptr->name,
|
fprintf (st, "%s Card %s%s%sAttach Help\n\n", dptr->name,
|
||||||
readers ? "Reader " : "", readers & punches ? "& " : "", punches ? "Punch ": "");
|
readers ? "Reader " : "", readers & punches ? "& " : "", punches ? "Punch ": "");
|
||||||
if (0 == (uptr-dptr->units)) {
|
if (0 == (uptr-dptr->units)) {
|
||||||
if (dptr->numunits > 1) {
|
if (dptr->numunits > 1) {
|
||||||
|
|||||||
@@ -53,7 +53,11 @@
|
|||||||
of card.
|
of card.
|
||||||
|
|
||||||
For autodetection of BCD card format, there can be no parity errors.
|
For autodetection of BCD card format, there can be no parity errors.
|
||||||
All undeterminate formats are treated as ASCII.
|
All undeterminate formats are treated as ASCII. CBN and BCD cards
|
||||||
|
must also contain short or full records, if the record is not terminate
|
||||||
|
early by a EOR flag, then only up to record size (80 for BCD and
|
||||||
|
160 for CBN will be read).
|
||||||
|
|
||||||
|
|
||||||
ASCII mode recognizes some additional forms of input which allows the
|
ASCII mode recognizes some additional forms of input which allows the
|
||||||
intermixing of binary cards with text cards.
|
intermixing of binary cards with text cards.
|
||||||
|
|||||||
Reference in New Issue
Block a user