From 19ad893bc112b478b2e48686edd0a4c08ad9462d Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Thu, 13 Sep 2018 22:58:46 -0400 Subject: [PATCH] ICL1900: Patches to make E4BM work with CP, TP, LP. --- ICL1900/icl1900_cp.c | 17 +++++++--- ICL1900/icl1900_cr.c | 9 +++--- ICL1900/icl1900_defs.h | 2 +- ICL1900/icl1900_lp.c | 20 ++++++------ ICL1900/icl1900_mt.c | 7 +++- ICL1900/icl1900_mta.c | 6 ++-- ICL1900/icl1900_sys.c | 72 +++++++++++++++++++++++++----------------- ICL1900/icl1900_tp.c | 4 +-- ICL1900/icl1900_tr.c | 5 ++- 9 files changed, 85 insertions(+), 57 deletions(-) diff --git a/ICL1900/icl1900_cp.c b/ICL1900/icl1900_cp.c index 7334e54..bf0afb5 100644 --- a/ICL1900/icl1900_cp.c +++ b/ICL1900/icl1900_cp.c @@ -32,7 +32,7 @@ #define NUM_DEVS_CDP 0 #endif -#define UNIT_V_TYPE (UNIT_V_UF + 8) +#define UNIT_V_TYPE (UNIT_V_UF + 7) #define UNIT_TYPE (0xf << UNIT_V_TYPE) #define GET_TYPE(x) ((UNIT_TYPE & (x)) >> UNIT_V_TYPE) #define SET_TYPE(x) (UNIT_TYPE & ((x) << UNIT_V_TYPE)) @@ -70,8 +70,8 @@ CONST char *cdp_description (DEVICE *dptr); DIB cdp_dib = { CHAR_DEV, &cdp_cmd, &cdp_nsi_cmd, &cdp_nsi_status }; UNIT cdp_unit[] = { - { UDATA (&cdp_svc, UNIT_CDP(10), 0), 10000 }, { UDATA (&cdp_svc, UNIT_CDP(12), 0), 10000 }, + { UDATA (&cdp_svc, UNIT_CDP(13), 0), 10000 }, }; @@ -88,7 +88,7 @@ DEVICE cdp_dev = { "CP", cdp_unit, NULL, cdp_mod, NUM_DEVS_CDP, 8, 22, 1, 8, 22, NULL, NULL, NULL, NULL, &sim_card_attach, &sim_card_detach, - &cdp_dib, DEV_DISABLE | DEV_CARD | DEV_DEBUG, 0, dev_debug, + &cdp_dib, DEV_DISABLE | DEV_CARD | DEV_DEBUG, 0, card_debug, NULL, NULL, &cdp_help, NULL, NULL, &cdp_description }; @@ -126,17 +126,20 @@ void cdp_cmd(int dev, uint32 cmd, uint32 *resp) { if ((uptr->flags & UNIT_ATT) == 0) return; if (cmd == 020) { /* Send Q */ - *resp = uptr->STATUS & 001; /* TERMINATE */ + *resp = uptr->STATUS & TERMINATE; /* TERMINATE */ if ((uptr->flags & UNIT_ATT) != 0 || uptr->STATUS & 07700) *resp |= 040; if ((uptr->flags & BUSY) == 0) *resp |= STOPPED; + sim_debug(DEBUG_STATUS, &cdp_dev, "STATUS: %02o %02o\n", cmd, *resp); + uptr->STATUS &= ~TERMINATE; + chan_clr_done(dev); } else if (cmd == 024) { /* Send P */ *resp = uptr->STATUS & 016; /* IMAGE, ERROR, OPAT */ if ((uptr->flags & UNIT_ATT) != 0) *resp |= 1; uptr->STATUS &= (BUSY|DISC); - chan_clr_done(dev); + sim_debug(DEBUG_STATUS, &cdp_dev, "STATUS: %02o %02o\n", cmd, *resp); } else if (cmd == 032) { if ((uptr->flags & UNIT_ATT) == 0) return; @@ -185,6 +188,7 @@ void cdp_nsi_cmd(int dev, uint32 cmd) { if (cmd & 02) { if (uptr->STATUS & BUSY) uptr->STATUS |= DISC; + sim_debug(DEBUG_CMD, &cdp_dev, "Stop: %02o %08o\n", cmd, uptr->STATUS); return; } @@ -195,6 +199,7 @@ void cdp_nsi_cmd(int dev, uint32 cmd) { return; } uptr->STATUS = BUSY; + sim_debug(DEBUG_CMD, &cdp_dev, "Start: %02o %08o\n", cmd, uptr->STATUS); chan_clr_done(dev); sim_activate(uptr, uptr->wait); } @@ -236,6 +241,7 @@ void cdp_nsi_status(int dev, uint32 *resp) { if ((uptr->flags & UNIT_ATT) == 0) *resp |= 2; uptr->STATUS &= BUSY|DISC; + sim_debug(DEBUG_STATUS, &cdp_dev, "STATUS: %02o\n", *resp); chan_clr_done(dev); } @@ -266,6 +272,7 @@ t_stat cdp_svc (UNIT *uptr) break; } image[i] = mem_to_hol[ch]; + sim_debug(DEBUG_DATA, &cdp_dev, "Data: %02o %04x\n", ch, image[i]); } switch(sim_punch_card(uptr, image)) { case CDSE_EMPTY: diff --git a/ICL1900/icl1900_cr.c b/ICL1900/icl1900_cr.c index 379fbc3..21db71c 100644 --- a/ICL1900/icl1900_cr.c +++ b/ICL1900/icl1900_cr.c @@ -32,7 +32,7 @@ #define NUM_DEVS_CDR 0 #endif -#define UNIT_V_TYPE (UNIT_V_UF + 8) +#define UNIT_V_TYPE (UNIT_V_UF + 7) #define UNIT_TYPE (0xf << UNIT_V_TYPE) #define GET_TYPE(x) ((UNIT_TYPE & (x)) >> UNIT_V_TYPE) #define SET_TYPE(x) (UNIT_TYPE & ((x) << UNIT_V_TYPE)) @@ -78,8 +78,8 @@ CONST char *cdr_description (DEVICE *dptr); DIB cdr_dib = { CHAR_DEV, &cdr_cmd, &cdr_nsi_cmd, &cdr_nsi_status }; UNIT cdr_unit[] = { - { UDATA (&cdr_svc, UNIT_CDR(8), 0), 10000 }, - { UDATA (&cdr_svc, UNIT_CDR(9), 0), 10000 }, + { UDATA (&cdr_svc, UNIT_CDR(10), 0), 10000 }, + { UDATA (&cdr_svc, UNIT_CDR(11), 0), 10000 }, }; @@ -282,6 +282,7 @@ t_stat cdr_svc (UNIT *uptr) case CDSE_EMPTY: case CDSE_EOF: sim_card_detach(uptr); + uptr->STATUS |= OPAT; sim_debug(DEBUG_DATA, &cdr_dev, "EOF: %d\n", i); break; case CDSE_ERROR: @@ -302,7 +303,7 @@ t_stat cdr_svc (UNIT *uptr) sim_debug(DEBUG_DATA, &cdr_dev, "col: %04x %02o '%c'\n", image[i], ch, mem_to_ascii[ch]); if (ch == 0xff) { uptr->STATUS |= ERROR; - break; + ch = 077; } } sim_debug(DEBUG_DATA, &cdr_dev, "DATA: %03o\n", ch); diff --git a/ICL1900/icl1900_defs.h b/ICL1900/icl1900_defs.h index be71751..1c66a81 100755 --- a/ICL1900/icl1900_defs.h +++ b/ICL1900/icl1900_defs.h @@ -234,7 +234,7 @@ t_opcode; #define NMASK 037777400 #define MMASK 037777000 -#define UNIT_V_ADDR 24 +#define UNIT_V_ADDR (UNIT_V_UF + 9) #define UNIT_M_ADDR (077 << UNIT_V_ADDR) #define GET_UADDR(x) ((UNIT_M_ADDR & (x)) >> UNIT_V_ADDR) #define UNIT_ADDR(x) (UNIT_M_ADDR & ((x) << UNIT_V_ADDR)) diff --git a/ICL1900/icl1900_lp.c b/ICL1900/icl1900_lp.c index f18e647..b4ee0c6 100644 --- a/ICL1900/icl1900_lp.c +++ b/ICL1900/icl1900_lp.c @@ -84,8 +84,8 @@ CONST char *lpr_description (DEVICE *dptr); DIB lpr_dib = { CHAR_DEV, &lpr_cmd, &lpr_nsi_cmd, &lpr_nsi_status }; UNIT lpr_unit[] = { - { UDATA (&lpr_svc, UNIT_LPR(13), 0), 10000 }, { UDATA (&lpr_svc, UNIT_LPR(14), 0), 10000 }, + { UDATA (&lpr_svc, UNIT_LPR(15), 0), 10000 }, }; @@ -220,7 +220,7 @@ void lpr_nsi_cmd(int dev, uint32 cmd) { chan_set_done(GET_UADDR(uptr->flags)); return; } - uptr->CMD |= 0; + uptr->CMD |= AUTO; uptr->STATUS = BUSY; sim_activate(uptr, uptr->wait); chan_clr_done(GET_UADDR(uptr->flags)); @@ -304,16 +304,16 @@ t_stat lpr_svc (UNIT *uptr) len = 120; else if (LW_160(uptr->flags)) len = 160; - for (i = 0; i < len && eor == 0; i++) { + i = 0; + while (eor == 0 && i flags), &ch, 0); - sim_debug(DEBUG_DATA, &lpr_dev, "DATA: %03o\n", ch); - switch (ch & 060) { - case 000: ch = 0060 | (ch & 017); break; - case 020: ch = 0040 | (ch & 017); break; - case 040: ch = 0100 | (ch & 017); break; - case 060: ch = 0120 | (ch & 017); break; + if (uptr->CMD & AUTO) { + uptr->CMD |= (int32)ch << 8; + uptr->CMD &= ~AUTO; + } else { + sim_debug(DEBUG_DATA, &lpr_dev, "DATA: %03o\n", ch); + buffer[i++] = mem_to_ascii[ch]; } - buffer[i] = ch; } buffer[i++] = '\r'; buffer[i++] = '\n'; diff --git a/ICL1900/icl1900_mt.c b/ICL1900/icl1900_mt.c index 84e73d5..96187f7 100644 --- a/ICL1900/icl1900_mt.c +++ b/ICL1900/icl1900_mt.c @@ -581,8 +581,13 @@ mt_boot(int32 unit_num, DEVICE * dptr) t_stat mt_attach(UNIT * uptr, CONST char *file) { + t_stat r; uptr->STATUS = 0; - return sim_tape_attach_ex(uptr, file, 0, 0); + if ((r = sim_tape_attach_ex(uptr, file, 0, 0)) == SCPE_OK) { + if (uptr->flags & UNIT_RO) + uptr->flags |= MTUF_WLK; + } + return r; } t_stat diff --git a/ICL1900/icl1900_mta.c b/ICL1900/icl1900_mta.c index 4d03301..c2a7491 100644 --- a/ICL1900/icl1900_mta.c +++ b/ICL1900/icl1900_mta.c @@ -668,8 +668,10 @@ mta_attach(UNIT * uptr, CONST char *file) return r; uptr->STATUS &= ~OFFLINE; uptr->STATUS = ACCEPT; -// chan_set_done(unit + GET_UADDR(dptr->flags)); - return SCPE_OK; + if (uptr->flags & UNIT_RO) + uptr->flags |= MTUF_WLK; + chan_set_done(unit + GET_UADDR(dptr->flags)); + return r; } t_stat diff --git a/ICL1900/icl1900_sys.c b/ICL1900/icl1900_sys.c index a8f9520..eb325cf 100755 --- a/ICL1900/icl1900_sys.c +++ b/ICL1900/icl1900_sys.c @@ -124,7 +124,7 @@ uint8 mem_to_ascii[64] = { /* x0 x1 x2 x3 x4 x5 x6 x7 */ '0', '1', '2', '3', '4', '5', '6', '7', /* 0x */ '8', '9', ':', ';', '<', '=', '>', '?', /* 1x */ - ' ', '!', '"', '#', '\\', '%', '&', '\'', /* 2x */ + ' ', '!', '"', '#', '~', '%', '&', '\'', /* 2x */ '(', ')', '*', '+', ',', '-', '.', '/', /* 3x */ '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 4x */ 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 5x */ @@ -157,7 +157,7 @@ const char ascii_to_mem[128] = { /* P Q R S T U V W */ 060, 061, 062, 063, 064, 065, 066, 067, /* X Y Z [ \ ] ^ _ */ - 070, 071, 072, 073, 024, 075, 076, 077, + 070, 071, 072, 073, -1, 075, 076, 077, /* ` a b c d e f g */ -1, 041, 042, 043, 044, 045, 046, 047, /* 14 -1 177 */ /* h i j k l m n o */ @@ -165,49 +165,59 @@ const char ascii_to_mem[128] = { /* p q r s t u v w */ 060, 061, 062, 063, 064, 065, 066, 067, /* x y z { | } ~ del*/ - 070, 071, 072, 024, -1, -1, -1, -1, + 070, 071, 072, 024, -1, -1, 024, -1, }; +/* + * Translate internal code to Holerith for punch cards. + * This uses IBM029 encoding rather then ICL1900 punch codes. + * + * Char 029 ICL1900 + * # 8+3 8+3 + * @ 8+4 8+4 + * ( 12+8+5 8+5 + * ) 11+8+5 8+6 + * ] 10+8+6 8+7 + * + 12+10 12+8+2 + * . 12+8+3 12+8+3 + * : 8+5 12+8+4 + * ; 11+8+6 12+8+5 + * ' 8+5 12+8+6 + * ! 10+8+2 12+8+7 + * [ 12+8+4 11+8+2 + * $ 11+8+3 11+8+3 + * * 11+8+4 11+8+4 + * > 8+6 11+8+5 + * = 10+8+5 11+8+6 + * ^ 10+8+7 11+8+7 + * lb 11+8+6 10+8+2 \ + * , 10+8+3 10+8+3 + * % 10+8+4 10+8+4 + * ? 8+2 10+8+5 + * = 10+8+5 10+8+6 + * _ 8+6 10+8+7 + */ uint16 mem_to_hol[64] = { /* 0 1 2 3 4 5 6 7 */ 0x200, 0x100, 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, /* 0x */ /* 8 9 : ; < = > ? */ - 0x002, 0x001, 0x812, 0x822, 0x40A, 0x20A, 0x412, 0x212, /* 1x */ - /* bl ! " # lb, % & ` */ - 0x000, 0x206, 0x600, 0x042, 0x242, 0x222, 0x800, 0x80a, /* 2x */ + 0x002, 0x001, 0x082, 0x40A, 0x80A, 0x00A, 0x20A, 0x206, /* 1x */ + /* bl ! " # ~ % & ' */ + 0x000, 0x482, 0x006, 0x042, 0x806, 0x222, 0x800, 0x012, /* 2x */ /* ( ) * + , - . / */ - 0x012, 0x00a, 0x422, 0xA00, 0x282, 0x400, 0x842, 0x300, /* 3x */ + 0x812, 0x412, 0x422, 0x80A, 0x242, 0x400, 0x842, 0x300, /* 3x */ /* @ A B C D E F G */ - 0x012, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, /* 4x */ + 0x022, 0x900, 0x880, 0x840, 0x820, 0x810, 0x808, 0x804, /* 4x */ /* H I J K L M N O */ 0x802, 0x801, 0x500, 0x480, 0x440, 0x420, 0x410, 0x408, /* 5x */ /* P Q R S T U V W */ 0x404, 0x402, 0x401, 0x280, 0x240, 0x220, 0x210, 0x208, /* 6x */ /* X Y Z [ $ ] ^ _ */ - 0x204, 0x202, 0x201, 0x482, 0x442, 0x006, 0x406, 0x206, /* 7x */ + 0x204, 0x202, 0x201, 0xA00, 0x442, 0x882, 0x406, 0x212, /* 7x */ }; uint8 hol_to_mem[4096]; - - -/* 2+8 22 12+2+8 33 11+2+8 73 0+2+8 24 - 3+8 23 12+3+8 36 11+3+8 74 0+3+8 34 - 4+8 40 12+4+8 13 11+4+8 32 0+4+8 25 - 5+8 30 12+5+8 12 11+5+8 16 0+5+8 17 - 6+8 31 12+6+8 27 11+6+8 14 0+6+8 15 - 7+8 75 12+7+8 21 11+7+8 76 0+7+8 77 - - 0-9 00 -> 11 - 12+0 -> 26 - 12+n -> 40+n - 11 -> 35 - 11+0 -> 22 - 11+n -> 51+n - 10 -> 0 - 10+1 -> 37 - 10+n -> 61 -*/ /* Load a card image file into memory. */ @@ -222,8 +232,9 @@ sim_load(FILE * fileref, CONST char *cptr, CONST char *fnam, int flag) int checksum; if (match_ext(fnam, "card")) { + fgets(buffer, 100, fileref); - addr = 0; + addr = 020; while (fgets(buffer, 100, fileref)) { /* Convert bits into image */ memset(image, 0, sizeof(image)); @@ -235,7 +246,9 @@ sim_load(FILE * fileref, CONST char *cptr, CONST char *fnam, int flag) fprintf(stderr, "Char %c: %s", buffer[j], buffer); return SCPE_FMT; } + fprintf(stderr, "'%c' %02o ", buffer[j], image[j]); } + fprintf(stderr, "\n\r"); for (j = 0; j < 64; ) { data = 0; for (k = 0; k < 4; k++) @@ -245,6 +258,7 @@ sim_load(FILE * fileref, CONST char *cptr, CONST char *fnam, int flag) M[addr++] = data; } } + return SCPE_OK; } else if (match_ext(fnam, "txt")) { while (fgets(buffer, 100, fileref)) { diff --git a/ICL1900/icl1900_tp.c b/ICL1900/icl1900_tp.c index 85eb3e3..7761b61 100644 --- a/ICL1900/icl1900_tp.c +++ b/ICL1900/icl1900_tp.c @@ -116,8 +116,8 @@ CONST char *ptp_description (DEVICE *dptr); DIB ptp_dib = { CHAR_DEV, &ptp_cmd, &ptp_nsi_cmd, &ptp_nsi_status }; UNIT ptp_unit[] = { - { UDATA (&ptp_svc, UNIT_PTP(6), 0), 10000 }, - { UDATA (&ptp_svc, UNIT_PTP(7), 0), 10000 }, + { UDATA (&ptp_svc, UNIT_PTP(8), 0), 10000 }, + { UDATA (&ptp_svc, UNIT_PTP(9), 0), 10000 }, }; diff --git a/ICL1900/icl1900_tr.c b/ICL1900/icl1900_tr.c index 73d506a..5e3927a 100644 --- a/ICL1900/icl1900_tr.c +++ b/ICL1900/icl1900_tr.c @@ -31,6 +31,8 @@ #define NUM_DEVS_PTR 0 #endif +#if (NUM_DEVS_PTR > 0) + #define PP_V_MODE (UNIT_V_UF + 0) #define PP_M_MODE (1 << PP_V_MODE) #define UNIT_V_TYPE (UNIT_V_UF + 1) @@ -43,7 +45,6 @@ #define PP_MODE_7B 0 #define PP_MODE_7P 1 - #define CMD u3 #define STATUS u4 #define HOLD u5 @@ -66,8 +67,6 @@ #define BETA_SHIFT 075 #define DELTA_SHIFT 076 -#if (NUM_DEVS_PTR > 0) - #define T1915_1 0 #define T1915_2 1 #define T1916_1 2