diff --git a/I650/i650_cdp.c b/I650/i650_cdp.c index 3cfa31fd9..d63d445d4 100644 --- a/I650/i650_cdp.c +++ b/I650/i650_cdp.c @@ -1403,7 +1403,7 @@ uint32 cdp_cmd(UNIT * uptr, uint16 cmd, uint16 addr) image[i] = 0; } else { // punch char - h = sim_ascii_to_hol(c); + h = ascii_to_hol(c); image[i] = h; } } diff --git a/I650/i650_cdr.c b/I650/i650_cdr.c index aad48028e..cccf08b88 100644 --- a/I650/i650_cdr.c +++ b/I650/i650_cdr.c @@ -103,7 +103,7 @@ int decode_8word_wiring(uint16 image[80], int bCheckForHiPunch) // read word digits for (iDigit=0;iDigit<10;iDigit++) { c1 = image[iCol++]; - c2 = sim_hol_to_ascii(c1); // convert to ascii + c2 = hol_to_ascii(c1); // convert to ascii if ((c1 == 0xA00) || (c2 == '?')) { c1 = 0xA00; c2 = '?'; // the punched value +0 should be represented by ascii ? } @@ -120,7 +120,7 @@ int decode_8word_wiring(uint16 image[80], int bCheckForHiPunch) if ((iCol==10) && (c2 == '-')) NegPunch= 1; // allow a minus on col 10 c1 = c1 & 0x3FF; // remove X and Y punches - c2 = sim_hol_to_ascii(c1); // convert to ascii again + c2 = hol_to_ascii(c1); // convert to ascii again c2 = c2 - '0'; // convert ascii to binary digit if (c2 > 9) c2 = 0; // nondigits chars interpreted as zero d = d * 10 + c2; @@ -174,7 +174,7 @@ void decode_soap_symb_info(uint16 image[80]) i2=0; for (i=40;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' '; if (c2 == '~') c2 = ' '; 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) // keep 026 fortran charset for (i=0;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' '; if (c2 == '~') c2 = ' '; buf[i] = (char) c2; @@ -348,7 +348,7 @@ void decode_supersoap_wiring(uint16 image[80]) // keep 026 fortran charset for (i=0;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' '; if (c2 == '~') c2 = ' '; buf[i] = (char) c2; @@ -456,7 +456,7 @@ void decode_is_wiring(uint16 image[80]) // keep 0..9,+,-,, replace anything else by for (i=0;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); buf[i] = (strchr("+-0123456789", c2)) ? ((char) (c2)):' '; } buf[80] = 0; // terminate string @@ -582,7 +582,7 @@ void decode_it_wiring(uint16 image[80]) // keep 026 fortran charset for (i=0;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = (strchr(mem_to_ascii, toupper(c2))) ? c2:' '; if (c2 == '~') c2 = ' '; buf[i] = (char) c2; @@ -732,7 +732,7 @@ int decode_ra_wiring(uint16 image[80], int HiPunch) for (i=0;i<80;i++) { IsNeg = hbuf[i]=0; c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = toupper(c2); if ((c1 == 0xA00) || (c2 == '?') || c2 == '+') { hbuf[i]=1; c2='0'; // '0' or blank + HiPunch Y(12) @@ -888,7 +888,7 @@ int decode_fds_wiring(uint16 image[80], int HiPunch) for (i=0;i<80;i++) { IsNeg =0; c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = toupper(c2); if ((c1 == 0xA00) || (c2 == '?') || c2 == '+') { c2='0'; // '0' or blank + HiPunch Y(12) @@ -1063,7 +1063,7 @@ void decode_fortransit_wiring(uint16 image[80]) // keep 026 fortran charset for (i=0;i<80;i++) { c1 = image[i]; - c2 = sim_hol_to_ascii(c1); + c2 = hol_to_ascii(c1); c2 = toupper(c2); c2 = (strchr(mem_to_ascii, c2)) ? c2:' '; if (c2 == '~') c2 = ' '; @@ -1156,7 +1156,7 @@ uint32 cdr_cmd(UNIT * uptr, uint16 cmd, uint16 addr) // make local copy of card for debug output for (i=0; i<80; i++) - cbuf[i] = sim_hol_to_ascii(image[i]); + cbuf[i] = hol_to_ascii(image[i]); cbuf[80] = 0; // terminate string sim_debug(DEBUG_DETAIL, &cpu_dev, "Read Card: %s\n", sim_trim_endspc(cbuf)); diff --git a/I650/i650_defs.h b/I650/i650_defs.h index c6fd127cd..e02a4153e 100644 --- a/I650/i650_defs.h +++ b/I650/i650_defs.h @@ -172,8 +172,8 @@ extern struct card_wirings { extern char digits_ascii[31]; extern char mem_to_ascii[101]; extern int ascii_to_NN(int ch); -extern uint16 sim_ascii_to_hol(char c); -extern char sim_hol_to_ascii(uint16 hol); +extern uint16 ascii_to_hol(char c); +extern char hol_to_ascii(uint16 hol); /* Generic devices common to all */ extern DEVICE cpu_dev; diff --git a/I650/i650_sys.c b/I650/i650_sys.c index ec6c48702..461d1c8f0 100644 --- a/I650/i650_sys.c +++ b/I650/i650_sys.c @@ -135,7 +135,7 @@ char digits_ascii[31] = { '!', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', /* 0-9 w/Negative Punch X(11) */ 0}; -uint16 ascii_to_hol[128] = { +uint16 ascii_to_hol_tab[128] = { /* Control */ 0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000, /*0-37*/ /*Control*/ @@ -179,19 +179,19 @@ uint16 ascii_to_hol[128] = { 0x604, 0x602, 0x601, 0x406, 0x806, 0x006, 0x005,0xf000 }; -uint16 sim_ascii_to_hol(char c) +uint16 ascii_to_hol(char c) { - return ascii_to_hol[c & 127]; + return ascii_to_hol_tab[c & 127]; } -char sim_hol_to_ascii(uint16 hol) +char hol_to_ascii(uint16 hol) { int c; hol = hol & 0x0fff; // ignore extra high bits, if any if (hol == 0xa00) return '?'; // +0 if (hol == 0x600) return '!'; // -0 for (c=31;c<127;c++) { - if (ascii_to_hol[c] == hol) { + if (ascii_to_hol_tab[c] == hol) { // take in consideration the aliases between hol and ascii to return // char as for 026 FORT charset // hol = 0x022 -> 8-4 punches -> "-" or "'" or "@". Must be "-" @@ -761,26 +761,18 @@ static t_stat deck_close(DEVICE *dptr) // Read a card from the first UNIT of any cdr DEVICE, but in particular from // one created by deck_open(). -static t_stat deck_card_read(DEVICE *dptr, uint16 CardImage[80]) +static t_stat read_card(DEVICE *dptr, uint16 CardImage[80]) { UNIT *uptr = dptr->units; t_stat r = sim_read_card(uptr, CardImage); - if (r == CDSE_EMPTY) { - r = CDSE_EOF; - } - - for (int i = 0; i < 80; i++) { - CardImage[i] &= 0xFFF; - } - return r; } // Write a card to the first unit of any cdr DEVICE, but in particular to // one created by deck_open(). -static t_stat deck_card_write(DEVICE *dptr, uint16 CardImage[80]) +static t_stat write_card(DEVICE *dptr, uint16 CardImage[80]) { UNIT *uptr = dptr->units; @@ -800,7 +792,7 @@ void deck_print_echo(uint16 CardImage[80], int bPrint, int bEcho) // read card, check and, store in line for (i=0;i<80;i++) { hol = CardImage[i]; - c = sim_hol_to_ascii(hol); + c = hol_to_ascii(hol); c = toupper(c); // IBM 407 can only print uppercase if ((c == '?') || (c == '!')) c = '0'; // remove Y(12) or X(11) punch on zero 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) char fn0[4*CBUFSIZE]; char fn1[4*CBUFSIZE]; char fn2[4*CBUFSIZE]; - char gbuf[4*CBUFSIZE]; - DEVICE *dptr; - UNIT *uptr; + DEVICE *dev0, *dev1, *dev2; t_stat r; int bSplit5CD = 0; int bSplitPAT = 0; - int nCards, nCards1, tail; while (sim_isspace (*cptr)) cptr++; // trim leading spc @@ -868,6 +857,9 @@ static t_stat deck_split_cmd(CONST char *cptr) (gbuf[3] < '1') || (gbuf[3] > '3') ) { // is a file } else { + DEVICE *dptr; + UNIT *uptr; + // is cdp1 cdp2 or cdp3 device dptr = find_unit (gbuf, &uptr); /* locate unit */ if (dptr == NULL) /* found dev? */ @@ -895,8 +887,6 @@ static t_stat deck_split_cmd(CONST char *cptr) return sim_messagef (SCPE_ARG, "Destination file name (%s) same as source file name\n", fn0); } - DEVICE *dev0, *dev1, *dev2; - r = deck_open(&dev0, fn0, 0); if (r != SCPE_OK) return sim_messagef (r, "Cannot open source deck (%s)\n", fn0); @@ -923,8 +913,8 @@ static t_stat deck_split_cmd(CONST char *cptr) for (;;) { uint16 CardImage[80]; - r = deck_card_read(dev0, CardImage); - if (r == CDSE_EOF) { + r = read_card(dev0, CardImage); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { 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) devDest = dev2; nc2++; } - r = deck_card_write(devDest, CardImage); + r = write_card(devDest, CardImage); if (r != CDSE_OK) { sim_messagef(r, "Cannot write card (%s)\n", bFound ? fn2 : fn1); break; @@ -990,9 +980,10 @@ static t_stat deck_split_cmd(CONST char *cptr) nc1 = nc2 = 0; for (;;) { uint16 CardImage[80]; + DEVICE *devDest; - r = deck_card_read(dev0, CardImage); - if (r == CDSE_EOF) { + r = read_card(dev0, CardImage); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0); @@ -1006,7 +997,6 @@ static t_stat deck_split_cmd(CONST char *cptr) } bFound = (bFound == 8) ? 1:0; // is an availability table load card? // store in appropiate output deck - DEVICE *devDest; if (bFound==0) { devDest = dev1; nc1++; @@ -1014,7 +1004,7 @@ static t_stat deck_split_cmd(CONST char *cptr) devDest = dev2; nc2++; } - r = deck_card_write(devDest, CardImage); + r = write_card(devDest, CardImage); if (r != CDSE_OK) { sim_messagef(r, "Cannot write card (%s)\n", bFound ? fn2 : fn1); break; @@ -1043,8 +1033,8 @@ static t_stat deck_split_cmd(CONST char *cptr) for (;;) { uint16 CardImage[80]; - r = deck_card_read(dev0, CardImage); - if (r == CDSE_EOF) { + r = read_card(dev0, CardImage); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { 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) } if (nCards1 > nCards) nCards1 = nCards; - for (int i = 0; i < nCards1; i++) { - uint16 CardImage[80]; + { + int i; - r = deck_card_read(dev0, CardImage); - if (r != CDSE_OK) { - sim_messagef(r, "Cannot read enough cards from source deck (%s)\n", fn0); - break; + for (i = 0; i < nCards1; i++) { + uint16 CardImage[80]; + + r = read_card(dev0, CardImage); + if (r != CDSE_OK) { + sim_messagef(r, "Cannot read enough cards from source deck (%s)\n", fn0); + break; + } + write_card(dev1, CardImage); } - deck_card_write(dev1, CardImage); } for (;;) { uint16 CardImage[80]; - r = deck_card_read(dev0, CardImage); - if (r == CDSE_EOF) { + r = read_card(dev0, CardImage); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { sim_messagef(r, "Cannot read card from source deck (%s)\n", fn0); break; } - deck_card_write(dev2, CardImage); + write_card(dev2, CardImage); } // decks are no longer needed @@ -1145,6 +1139,7 @@ static t_stat deck_join_cmd(CONST char *cptr) cptr = cptr0; // restore cptr to scan source filenames nDeck = nCards = 0; while (1) { + DEVICE *cdrSrc; while (sim_isspace (*cptr)) cptr++; // trim leading spc if (cptrAS == cptr) break; // break if reach "AS" @@ -1154,7 +1149,6 @@ static t_stat deck_join_cmd(CONST char *cptr) // read source deck nCards1 = nCards; - DEVICE *cdrSrc; r = deck_open(&cdrSrc, fnSrc, 0); if (r != SCPE_OK) { deck_close(devDest); @@ -1164,14 +1158,14 @@ static t_stat deck_join_cmd(CONST char *cptr) for (;;) { uint16 image[80]; - r = deck_card_read(cdrSrc, image); - if (r == CDSE_EOF) { + r = read_card(cdrSrc, image); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { sim_messagef(r, "Cannot read card from deck to print (%s)\n", fnSrc); break; } - r = deck_card_write(devDest, image); + r = write_card(devDest, image); if (r != CDSE_OK) { sim_messagef(r, "Cannot write card (%s)\n", fnDest); break; @@ -1196,6 +1190,7 @@ static t_stat deck_join_cmd(CONST char *cptr) static t_stat deck_print_cmd(CONST char *cptr) { char fn[4*CBUFSIZE]; + DEVICE *cdr; t_stat r; int nCards; @@ -1207,15 +1202,14 @@ static t_stat deck_print_cmd(CONST char *cptr) // read deck to be printed (-1 to convert to ascii value, not hol) nCards = 0; - DEVICE *cdr; r = deck_open(&cdr, fn, 0); if (r != SCPE_OK) return sim_messagef(r, "Cannot read deck to print (%s)\n", fn); for (;;) { uint16 image[80]; - r = deck_card_read(cdr, image); - if (r == CDSE_EOF) { + r = read_card(cdr, image); + if (r == CDSE_EOF || r == CDSE_EMPTY) { break; } else if (r != CDSE_OK) { sim_messagef(r, "Cannot read card from deck to print (%s)\n", fn);