Skip to content

Commit 8bd7484

Browse files
committed
I650: changes derived from review comments.
I will probably later merge these into the main commit.
1 parent dcecaff commit 8bd7484

4 files changed

Lines changed: 56 additions & 62 deletions

File tree

I650/i650_cdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ uint32 cdp_cmd(UNIT * uptr, uint16 cmd, uint16 addr)
14031403
image[i] = 0;
14041404
} else {
14051405
// punch char
1406-
h = sim_ascii_to_hol(c);
1406+
h = ascii_to_hol(c);
14071407
image[i] = h;
14081408
}
14091409
}

I650/i650_cdr.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int decode_8word_wiring(uint16 image[80], int bCheckForHiPunch)
103103
// read word digits
104104
for (iDigit=0;iDigit<10;iDigit++) {
105105
c1 = image[iCol++];
106-
c2 = sim_hol_to_ascii(c1); // convert to ascii
106+
c2 = hol_to_ascii(c1); // convert to ascii
107107
if ((c1 == 0xA00) || (c2 == '?')) {
108108
c1 = 0xA00; c2 = '?'; // the punched value +0 should be represented by ascii ?
109109
}
@@ -120,7 +120,7 @@ int decode_8word_wiring(uint16 image[80], int bCheckForHiPunch)
120120
if ((iCol==10) &&
121121
(c2 == '-')) NegPunch= 1; // allow a minus on col 10
122122
c1 = c1 & 0x3FF; // remove X and Y punches
123-
c2 = sim_hol_to_ascii(c1); // convert to ascii again
123+
c2 = hol_to_ascii(c1); // convert to ascii again
124124
c2 = c2 - '0'; // convert ascii to binary digit
125125
if (c2 > 9) c2 = 0; // nondigits chars interpreted as zero
126126
d = d * 10 + c2;
@@ -174,7 +174,7 @@ void decode_soap_symb_info(uint16 image[80])
174174
i2=0;
175175
for (i=40;i<80;i++) {
176176
c1 = image[i];
177-
c2 = sim_hol_to_ascii(c1);
177+
c2 = hol_to_ascii(c1);
178178
c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' ';
179179
if (c2 == '~') c2 = ' ';
180180
if ((i==47) || (i==50) || (i==56)) buf[i2++] = ' '; // add space separation between op, da, ia fields
@@ -267,7 +267,7 @@ void decode_soap_wiring(uint16 image[80], int bMultiPass)
267267
// keep 026 fortran charset
268268
for (i=0;i<80;i++) {
269269
c1 = image[i];
270-
c2 = sim_hol_to_ascii(c1);
270+
c2 = hol_to_ascii(c1);
271271
c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' ';
272272
if (c2 == '~') c2 = ' ';
273273
buf[i] = (char) c2;
@@ -348,7 +348,7 @@ void decode_supersoap_wiring(uint16 image[80])
348348
// keep 026 fortran charset
349349
for (i=0;i<80;i++) {
350350
c1 = image[i];
351-
c2 = sim_hol_to_ascii(c1);
351+
c2 = hol_to_ascii(c1);
352352
c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' ';
353353
if (c2 == '~') c2 = ' ';
354354
buf[i] = (char) c2;
@@ -456,7 +456,7 @@ void decode_is_wiring(uint16 image[80])
456456
// keep 0..9,+,-,<space>, replace anything else by <space>
457457
for (i=0;i<80;i++) {
458458
c1 = image[i];
459-
c2 = sim_hol_to_ascii(c1);
459+
c2 = hol_to_ascii(c1);
460460
buf[i] = (strchr("+-0123456789", c2)) ? ((char) (c2)):' ';
461461
}
462462
buf[80] = 0; // terminate string
@@ -582,7 +582,7 @@ void decode_it_wiring(uint16 image[80])
582582
// keep 026 fortran charset
583583
for (i=0;i<80;i++) {
584584
c1 = image[i];
585-
c2 = sim_hol_to_ascii(c1);
585+
c2 = hol_to_ascii(c1);
586586
c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' ';
587587
if (c2 == '~') c2 = ' ';
588588
buf[i] = (char) c2;
@@ -732,7 +732,7 @@ int decode_ra_wiring(uint16 image[80], int HiPunch)
732732
for (i=0;i<80;i++) {
733733
IsNeg = hbuf[i]=0;
734734
c1 = image[i];
735-
c2 = sim_hol_to_ascii(c1);
735+
c2 = hol_to_ascii(c1);
736736
c2 = toupper(c2);
737737
if ((c1 == 0xA00) || (c2 == '?') || c2 == '+') {
738738
hbuf[i]=1; c2='0'; // '0' or blank + HiPunch Y(12)
@@ -888,7 +888,7 @@ int decode_fds_wiring(uint16 image[80], int HiPunch)
888888
for (i=0;i<80;i++) {
889889
IsNeg =0;
890890
c1 = image[i];
891-
c2 = sim_hol_to_ascii(c1);
891+
c2 = hol_to_ascii(c1);
892892
c2 = toupper(c2);
893893
if ((c1 == 0xA00) || (c2 == '?') || c2 == '+') {
894894
c2='0'; // '0' or blank + HiPunch Y(12)
@@ -1063,7 +1063,7 @@ void decode_fortransit_wiring(uint16 image[80])
10631063
// keep 026 fortran charset
10641064
for (i=0;i<80;i++) {
10651065
c1 = image[i];
1066-
c2 = sim_hol_to_ascii(c1);
1066+
c2 = hol_to_ascii(c1);
10671067
c2 = toupper(c2);
10681068
c2 = (strchr(mem_to_ascii, c2)) ? c2:' ';
10691069
if (c2 == '~') c2 = ' ';
@@ -1156,7 +1156,7 @@ uint32 cdr_cmd(UNIT * uptr, uint16 cmd, uint16 addr)
11561156

11571157
// make local copy of card for debug output
11581158
for (i=0; i<80; i++)
1159-
cbuf[i] = sim_hol_to_ascii(image[i]);
1159+
cbuf[i] = hol_to_ascii(image[i]);
11601160
cbuf[80] = 0; // terminate string
11611161
sim_debug(DEBUG_DETAIL, &cpu_dev, "Read Card: %s\n", sim_trim_endspc(cbuf));
11621162

I650/i650_defs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ extern struct card_wirings {
172172
extern char digits_ascii[31];
173173
extern char mem_to_ascii[101];
174174
extern int ascii_to_NN(int ch);
175-
extern uint16 sim_ascii_to_hol(char c);
176-
extern char sim_hol_to_ascii(uint16 hol);
175+
extern uint16 ascii_to_hol(char c);
176+
extern char hol_to_ascii(uint16 hol);
177177

178178
/* Generic devices common to all */
179179
extern DEVICE cpu_dev;

I650/i650_sys.c

Lines changed: 42 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ char digits_ascii[31] = {
135135
'!', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', /* 0-9 w/Negative Punch X(11) */
136136
0};
137137

138-
uint16 ascii_to_hol[128] = {
138+
uint16 ascii_to_hol_tab[128] = {
139139
/* Control */
140140
0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000, /*0-37*/
141141
/*Control*/
@@ -179,19 +179,19 @@ uint16 ascii_to_hol[128] = {
179179
0x604, 0x602, 0x601, 0x406, 0x806, 0x006, 0x005,0xf000
180180
};
181181

182-
uint16 sim_ascii_to_hol(char c)
182+
uint16 ascii_to_hol(char c)
183183
{
184-
return ascii_to_hol[c & 127];
184+
return ascii_to_hol_tab[c & 127];
185185
}
186186

187-
char sim_hol_to_ascii(uint16 hol)
187+
char hol_to_ascii(uint16 hol)
188188
{
189189
int c;
190190
hol = hol & 0x0fff; // ignore extra high bits, if any
191191
if (hol == 0xa00) return '?'; // +0
192192
if (hol == 0x600) return '!'; // -0
193193
for (c=31;c<127;c++) {
194-
if (ascii_to_hol[c] == hol) {
194+
if (ascii_to_hol_tab[c] == hol) {
195195
// take in consideration the aliases between hol and ascii to return
196196
// char as for 026 FORT charset
197197
// hol = 0x022 -> 8-4 punches -> "-" or "'" or "@". Must be "-"
@@ -761,26 +761,18 @@ static t_stat deck_close(DEVICE *dptr)
761761

762762
// Read a card from the first UNIT of any cdr DEVICE, but in particular from
763763
// one created by deck_open().
764-
static t_stat deck_card_read(DEVICE *dptr, uint16 CardImage[80])
764+
static t_stat read_card(DEVICE *dptr, uint16 CardImage[80])
765765
{
766766
UNIT *uptr = dptr->units;
767767
t_stat r = sim_read_card(uptr, CardImage);
768768

769-
if (r == CDSE_EMPTY) {
770-
r = CDSE_EOF;
771-
}
772-
773-
for (int i = 0; i < 80; i++) {
774-
CardImage[i] &= 0xFFF;
775-
}
776-
777769
return r;
778770
}
779771

780772

781773
// Write a card to the first unit of any cdr DEVICE, but in particular to
782774
// one created by deck_open().
783-
static t_stat deck_card_write(DEVICE *dptr, uint16 CardImage[80])
775+
static t_stat write_card(DEVICE *dptr, uint16 CardImage[80])
784776
{
785777
UNIT *uptr = dptr->units;
786778

@@ -800,7 +792,7 @@ void deck_print_echo(uint16 CardImage[80], int bPrint, int bEcho)
800792
// read card, check and, store in line
801793
for (i=0;i<80;i++) {
802794
hol = CardImage[i];
803-
c = sim_hol_to_ascii(hol);
795+
c = hol_to_ascii(hol);
804796
c = toupper(c); // IBM 407 can only print uppercase
805797
if ((c == '?') || (c == '!')) c = '0'; // remove Y(12) or X(11) punch on zero
806798
if (strchr(mem_to_ascii, c) == 0) c = ' '; // space if not in IBM 650 character set
@@ -829,14 +821,11 @@ static t_stat deck_split_cmd(CONST char *cptr)
829821
char fn0[4*CBUFSIZE];
830822
char fn1[4*CBUFSIZE];
831823
char fn2[4*CBUFSIZE];
832-
833824
char gbuf[4*CBUFSIZE];
834-
DEVICE *dptr;
835-
UNIT *uptr;
825+
DEVICE *dev0, *dev1, *dev2;
836826
t_stat r;
837827
int bSplit5CD = 0;
838828
int bSplitPAT = 0;
839-
840829
int nCards, nCards1, tail;
841830

842831
while (sim_isspace (*cptr)) cptr++; // trim leading spc
@@ -868,6 +857,9 @@ static t_stat deck_split_cmd(CONST char *cptr)
868857
(gbuf[3] < '1') || (gbuf[3] > '3') ) {
869858
// is a file
870859
} else {
860+
DEVICE *dptr;
861+
UNIT *uptr;
862+
871863
// is cdp1 cdp2 or cdp3 device
872864
dptr = find_unit (gbuf, &uptr); /* locate unit */
873865
if (dptr == NULL) /* found dev? */
@@ -895,8 +887,6 @@ static t_stat deck_split_cmd(CONST char *cptr)
895887
return sim_messagef (SCPE_ARG, "Destination file name (%s) same as source file name\n", fn0);
896888
}
897889

898-
DEVICE *dev0, *dev1, *dev2;
899-
900890
r = deck_open(&dev0, fn0, 0);
901891
if (r != SCPE_OK) return sim_messagef (r, "Cannot open source deck (%s)\n", fn0);
902892

@@ -923,8 +913,8 @@ static t_stat deck_split_cmd(CONST char *cptr)
923913
for (;;) {
924914
uint16 CardImage[80];
925915

926-
r = deck_card_read(dev0, CardImage);
927-
if (r == CDSE_EOF) {
916+
r = read_card(dev0, CardImage);
917+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
928918
break;
929919
} else if (r != CDSE_OK) {
930920
sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0);
@@ -957,7 +947,7 @@ static t_stat deck_split_cmd(CONST char *cptr)
957947
devDest = dev2;
958948
nc2++;
959949
}
960-
r = deck_card_write(devDest, CardImage);
950+
r = write_card(devDest, CardImage);
961951
if (r != CDSE_OK) {
962952
sim_messagef(r, "Cannot write card (%s)\n", bFound ? fn2 : fn1);
963953
break;
@@ -990,9 +980,10 @@ static t_stat deck_split_cmd(CONST char *cptr)
990980
nc1 = nc2 = 0;
991981
for (;;) {
992982
uint16 CardImage[80];
983+
DEVICE *devDest;
993984

994-
r = deck_card_read(dev0, CardImage);
995-
if (r == CDSE_EOF) {
985+
r = read_card(dev0, CardImage);
986+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
996987
break;
997988
} else if (r != CDSE_OK) {
998989
sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0);
@@ -1006,15 +997,14 @@ static t_stat deck_split_cmd(CONST char *cptr)
1006997
}
1007998
bFound = (bFound == 8) ? 1:0; // is an availability table load card?
1008999
// store in appropiate output deck
1009-
DEVICE *devDest;
10101000
if (bFound==0) {
10111001
devDest = dev1;
10121002
nc1++;
10131003
} else {
10141004
devDest = dev2;
10151005
nc2++;
10161006
}
1017-
r = deck_card_write(devDest, CardImage);
1007+
r = write_card(devDest, CardImage);
10181008
if (r != CDSE_OK) {
10191009
sim_messagef(r, "Cannot write card (%s)\n", bFound ? fn2 : fn1);
10201010
break;
@@ -1043,8 +1033,8 @@ static t_stat deck_split_cmd(CONST char *cptr)
10431033
for (;;) {
10441034
uint16 CardImage[80];
10451035

1046-
r = deck_card_read(dev0, CardImage);
1047-
if (r == CDSE_EOF) {
1036+
r = read_card(dev0, CardImage);
1037+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
10481038
break;
10491039
} else if (r != CDSE_OK) {
10501040
sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0);
@@ -1066,28 +1056,32 @@ static t_stat deck_split_cmd(CONST char *cptr)
10661056
}
10671057
if (nCards1 > nCards) nCards1 = nCards;
10681058

1069-
for (int i = 0; i < nCards1; i++) {
1070-
uint16 CardImage[80];
1059+
{
1060+
int i;
10711061

1072-
r = deck_card_read(dev0, CardImage);
1073-
if (r != CDSE_OK) {
1074-
sim_messagef(r, "Cannot read enough cards from source deck (%s)\n", fn0);
1075-
break;
1062+
for (i = 0; i < nCards1; i++) {
1063+
uint16 CardImage[80];
1064+
1065+
r = read_card(dev0, CardImage);
1066+
if (r != CDSE_OK) {
1067+
sim_messagef(r, "Cannot read enough cards from source deck (%s)\n", fn0);
1068+
break;
1069+
}
1070+
write_card(dev1, CardImage);
10761071
}
1077-
deck_card_write(dev1, CardImage);
10781072
}
10791073

10801074
for (;;) {
10811075
uint16 CardImage[80];
10821076

1083-
r = deck_card_read(dev0, CardImage);
1084-
if (r == CDSE_EOF) {
1077+
r = read_card(dev0, CardImage);
1078+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
10851079
break;
10861080
} else if (r != CDSE_OK) {
10871081
sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0);
10881082
break;
10891083
}
1090-
deck_card_write(dev2, CardImage);
1084+
write_card(dev2, CardImage);
10911085
}
10921086

10931087
// decks are no longer needed
@@ -1145,6 +1139,7 @@ static t_stat deck_join_cmd(CONST char *cptr)
11451139
cptr = cptr0; // restore cptr to scan source filenames
11461140
nDeck = nCards = 0;
11471141
while (1) {
1142+
DEVICE *cdrSrc;
11481143

11491144
while (sim_isspace (*cptr)) cptr++; // trim leading spc
11501145
if (cptrAS == cptr) break; // break if reach "AS"
@@ -1154,7 +1149,6 @@ static t_stat deck_join_cmd(CONST char *cptr)
11541149

11551150
// read source deck
11561151
nCards1 = nCards;
1157-
DEVICE *cdrSrc;
11581152
r = deck_open(&cdrSrc, fnSrc, 0);
11591153
if (r != SCPE_OK) {
11601154
deck_close(devDest);
@@ -1164,14 +1158,14 @@ static t_stat deck_join_cmd(CONST char *cptr)
11641158
for (;;) {
11651159
uint16 image[80];
11661160

1167-
r = deck_card_read(cdrSrc, image);
1168-
if (r == CDSE_EOF) {
1161+
r = read_card(cdrSrc, image);
1162+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
11691163
break;
11701164
} else if (r != CDSE_OK) {
11711165
sim_messagef(r, "Cannot read card from deck to print (%s)\n", fnSrc);
11721166
break;
11731167
}
1174-
r = deck_card_write(devDest, image);
1168+
r = write_card(devDest, image);
11751169
if (r != CDSE_OK) {
11761170
sim_messagef(r, "Cannot write card (%s)\n", fnDest);
11771171
break;
@@ -1196,6 +1190,7 @@ static t_stat deck_join_cmd(CONST char *cptr)
11961190
static t_stat deck_print_cmd(CONST char *cptr)
11971191
{
11981192
char fn[4*CBUFSIZE];
1193+
DEVICE *cdr;
11991194
t_stat r;
12001195

12011196
int nCards;
@@ -1207,15 +1202,14 @@ static t_stat deck_print_cmd(CONST char *cptr)
12071202

12081203
// read deck to be printed (-1 to convert to ascii value, not hol)
12091204
nCards = 0;
1210-
DEVICE *cdr;
12111205
r = deck_open(&cdr, fn, 0);
12121206
if (r != SCPE_OK) return sim_messagef(r, "Cannot read deck to print (%s)\n", fn);
12131207

12141208
for (;;) {
12151209
uint16 image[80];
12161210

1217-
r = deck_card_read(cdr, image);
1218-
if (r == CDSE_EOF) {
1211+
r = read_card(cdr, image);
1212+
if (r == CDSE_EOF || r == CDSE_EMPTY) {
12191213
break;
12201214
} else if (r != CDSE_OK) {
12211215
sim_messagef(r, "Cannot read card from deck to print (%s)\n", fn);

0 commit comments

Comments
 (0)