1
0
mirror of https://github.com/rcornwell/sims.git synced 2026-05-04 15:07:17 +00:00

KA10: Code cleanup.

This commit is contained in:
Richard Cornwell
2018-11-07 18:36:28 -05:00
parent 384b8de9d3
commit 3d23322e3d
10 changed files with 304 additions and 269 deletions

View File

@@ -77,6 +77,10 @@
#define HOPPER_LOW 0100000 /* less 200 cards 20 */
#define TEST 0400000 /* In test mode 18 */
#define STATUS u3
#define COL u4
#define BUFFER up7
t_stat cp_devio(uint32 dev, uint64 *data);
t_stat cp_srv(UNIT *);
t_stat cp_reset(DEVICE *);
@@ -112,49 +116,49 @@ DEVICE cp_dev = {
t_stat cp_devio(uint32 dev, uint64 *data) {
UNIT *uptr = &cp_unit;
uint16 *image = (uint16 *)(uptr->up7);
uint16 *image = (uint16 *)(uptr->BUFFER);
switch(dev & 3) {
case CONI:
*data = uptr->u3;
*data = uptr->STATUS;
sim_debug(DEBUG_CONI, &cp_dev, "CP: CONI %012llo\n", *data);
break;
case CONO:
clr_interrupt(dev);
sim_debug(DEBUG_CONO, &cp_dev, "CP: CONO %012llo\n", *data);
uptr->u3 &= ~PIA;
uptr->u3 |= *data & PIA;
uptr->STATUS &= ~PIA;
uptr->STATUS |= *data & PIA;
if (*data & CLR_PUNCH) {
uptr->u3 &= ~(TROUBLE|ERROR|END_CARD|END_CARD_EN|TROUBLE_EN);
uptr->STATUS &= ~(TROUBLE|ERROR|END_CARD|END_CARD_EN|TROUBLE_EN);
break;
}
if (*data & SET_DATA_REQ) {
uptr->u3 |= DATA_REQ;
set_interrupt(dev, uptr->u3);
uptr->STATUS |= DATA_REQ;
set_interrupt(dev, uptr->STATUS);
}
if (*data & CLR_DATA_REQ)
uptr->u3 &= ~DATA_REQ;
uptr->STATUS &= ~DATA_REQ;
if (*data & CLR_END_CARD)
uptr->u3 &= ~END_CARD;
uptr->STATUS &= ~END_CARD;
if (*data & EN_END_CARD)
uptr->u3 |= END_CARD_EN;
uptr->STATUS |= END_CARD_EN;
if (*data & DIS_END_CARD)
uptr->u3 &= ~END_CARD_EN;
uptr->STATUS &= ~END_CARD_EN;
if (*data & EN_TROUBLE)
uptr->u3 |= TROUBLE_EN;
uptr->STATUS |= TROUBLE_EN;
if (*data & DIS_TROUBLE)
uptr->u3 &= ~TROUBLE_EN;
if (*data & EJECT && uptr->u3 & CARD_IN_PUNCH) {
uptr->u4 = 80;
uptr->u3 &= ~DATA_REQ;
uptr->STATUS &= ~TROUBLE_EN;
if (*data & EJECT && uptr->STATUS & CARD_IN_PUNCH) {
uptr->COL = 80;
uptr->STATUS &= ~DATA_REQ;
sim_activate(uptr, uptr->wait);
}
if ((uptr->u3 & (TROUBLE|TROUBLE_EN)) == (TROUBLE|TROUBLE_EN))
set_interrupt(CP_DEVNUM, uptr->u3);
if ((uptr->u3 & (END_CARD|END_CARD_EN)) == (END_CARD|END_CARD_EN))
set_interrupt(CP_DEVNUM, uptr->u3);
if ((uptr->STATUS & (TROUBLE|TROUBLE_EN)) == (TROUBLE|TROUBLE_EN))
set_interrupt(CP_DEVNUM, uptr->STATUS);
if ((uptr->STATUS & (END_CARD|END_CARD_EN)) == (END_CARD|END_CARD_EN))
set_interrupt(CP_DEVNUM, uptr->STATUS);
if (*data & PUNCH_ON) {
uptr->u3 |= PUNCH_ON;
uptr->STATUS |= PUNCH_ON;
sim_activate(uptr, uptr->wait);
}
break;
@@ -162,11 +166,11 @@ t_stat cp_devio(uint32 dev, uint64 *data) {
*data = 0;
break;
case DATAO:
image[uptr->u4++] = *data & 0xfff;
uptr->u3 &= ~DATA_REQ;
image[uptr->COL++] = *data & 0xfff;
uptr->STATUS &= ~DATA_REQ;
clr_interrupt(dev);
sim_debug(DEBUG_DATAIO, &cp_dev, "CP: DATAO %012llo %d\n", *data,
uptr->u4);
uptr->COL);
sim_activate(uptr, uptr->wait);
break;
}
@@ -177,41 +181,41 @@ t_stat cp_devio(uint32 dev, uint64 *data) {
t_stat
cp_srv(UNIT *uptr) {
if (uptr->u3 & PUNCH_ON) {
uint16 *image = (uint16 *)(uptr->up7);
if (uptr->STATUS & PUNCH_ON) {
uint16 *image = (uint16 *)(uptr->BUFFER);
uptr->u3 |= CARD_IN_PUNCH;
if (uptr->u3 & DATA_REQ) {
uptr->STATUS |= CARD_IN_PUNCH;
if (uptr->STATUS & DATA_REQ) {
sim_activate(uptr, uptr->wait);
return SCPE_OK;
}
if (uptr->u4 < 80) {
if ((uptr->u3 & DATA_REQ) == 0) {
uptr->u3 |= DATA_REQ;
set_interrupt(CP_DEVNUM, uptr->u3);
if (uptr->COL < 80) {
if ((uptr->STATUS & DATA_REQ) == 0) {
uptr->STATUS |= DATA_REQ;
set_interrupt(CP_DEVNUM, uptr->STATUS);
}
sim_activate(uptr, uptr->wait);
return SCPE_OK;
}
uptr->u4 = 0;
uptr->u3 &= ~(PUNCH_ON|CARD_IN_PUNCH);
uptr->u3 |= END_CARD;
uptr->COL = 0;
uptr->STATUS &= ~(PUNCH_ON|CARD_IN_PUNCH);
uptr->STATUS |= END_CARD;
switch(sim_punch_card(uptr, image)) {
case CDSE_EOF:
case CDSE_EMPTY:
uptr->u3 |= PICK_FAIL|TROUBLE;
uptr->STATUS |= PICK_FAIL|TROUBLE;
break;
/* If we get here, something is wrong */
case CDSE_ERROR:
uptr->u3 |= EJECT_FAIL|TROUBLE;
uptr->STATUS |= EJECT_FAIL|TROUBLE;
break;
case CDSE_OK:
break;
}
if ((uptr->u3 & (TROUBLE|TROUBLE_EN)) == (TROUBLE|TROUBLE_EN))
set_interrupt(CP_DEVNUM, uptr->u3);
if (uptr->u3 & END_CARD_EN)
set_interrupt(CP_DEVNUM, uptr->u3);
if ((uptr->STATUS & (TROUBLE|TROUBLE_EN)) == (TROUBLE|TROUBLE_EN))
set_interrupt(CP_DEVNUM, uptr->STATUS);
if (uptr->STATUS & END_CARD_EN)
set_interrupt(CP_DEVNUM, uptr->STATUS);
}
return SCPE_OK;
@@ -225,10 +229,10 @@ cp_attach(UNIT * uptr, CONST char *file)
if ((r = sim_card_attach(uptr, file)) != SCPE_OK)
return r;
if (uptr->up7 == 0) {
uptr->up7 = calloc(80, sizeof(uint16));
uptr->u3 = 0;
uptr->u4 = 0;
if (uptr->BUFFER == 0) {
uptr->BUFFER = calloc(80, sizeof(uint16));
uptr->STATUS = 0;
uptr->COL = 0;
}
return SCPE_OK;
}
@@ -236,13 +240,13 @@ cp_attach(UNIT * uptr, CONST char *file)
t_stat
cp_detach(UNIT * uptr)
{
uint16 *image = (uint16 *)(uptr->up7);
uint16 *image = (uint16 *)(uptr->BUFFER);
if (uptr->u3 & CARD_IN_PUNCH)
if (uptr->STATUS & CARD_IN_PUNCH)
sim_punch_card(uptr, image);
if (uptr->up7 != 0)
free(uptr->up7);
uptr->up7 = 0;
if (uptr->BUFFER != 0)
free(uptr->BUFFER);
uptr->BUFFER = 0;
return sim_card_detach(uptr);
}

View File

@@ -3115,7 +3115,7 @@ ldb_ptr:
/* Set flag1 to sign and make positive */
if (AR & DNMASK) {
AR = (AR ^ DFMASK) + 1;
AR = (AR ^ DFMASK) + 1;
flag1 = 1;
} else {
flag1 = 0;

View File

@@ -76,6 +76,11 @@
#define RDY_READ_EN 00200000
#define TROUBLE_EN 00400000
#define STATUS u3
#define COL u4
#define DATA u5
#define BUFFER up7
t_stat cr_devio(uint32 dev, uint64 *data);
t_stat cr_srv(UNIT *);
t_stat cr_reset(DEVICE *);
@@ -113,11 +118,11 @@ t_stat cr_devio(uint32 dev, uint64 *data) {
switch(dev & 3) {
case CONI:
if (uptr->flags & UNIT_ATT &&
(uptr->u3 & (READING|CARD_IN_READ|END_CARD)) == 0)
uptr->u3 |= RDY_READ;
*data = uptr->u3;
if (uptr->u3 & RDY_READ_EN && uptr->u3 & RDY_READ)
set_interrupt(dev, uptr->u3);
(uptr->STATUS & (READING|CARD_IN_READ|END_CARD)) == 0)
uptr->STATUS |= RDY_READ;
*data = uptr->STATUS;
if (uptr->STATUS & RDY_READ_EN && uptr->STATUS & RDY_READ)
set_interrupt(dev, uptr->STATUS);
sim_debug(DEBUG_CONI, &cr_dev, "CR: CONI %012llo\n", *data);
break;
@@ -125,39 +130,39 @@ t_stat cr_devio(uint32 dev, uint64 *data) {
clr_interrupt(dev);
sim_debug(DEBUG_CONO, &cr_dev, "CR: CONO %012llo\n", *data);
if (*data & CLR_READER) {
uptr->u3 = 0;
uptr->STATUS = 0;
sim_cancel(uptr);
break;
}
uptr->u3 &= ~(PIA);
uptr->u3 |= *data & PIA;
uptr->u3 &= ~(*data & (CLR_DRDY|CLR_END_CARD|CLR_EOF|CLR_DATA_MISS));
uptr->STATUS &= ~(PIA);
uptr->STATUS |= *data & PIA;
uptr->STATUS &= ~(*data & (CLR_DRDY|CLR_END_CARD|CLR_EOF|CLR_DATA_MISS));
if (*data & EN_TROUBLE)
uptr->u3 |= TROUBLE_EN;
uptr->STATUS |= TROUBLE_EN;
if (*data & EN_READY)
uptr->u3 |= RDY_READ_EN;
uptr->STATUS |= RDY_READ_EN;
if (*data & READ_CARD) {
uptr->u3 |= READING;
uptr->u3 &= ~(CARD_IN_READ|RDY_READ|DATA_RDY);
uptr->u4 = 0;
uptr->STATUS |= READING;
uptr->STATUS &= ~(CARD_IN_READ|RDY_READ|DATA_RDY);
uptr->COL = 0;
sim_activate(uptr, uptr->wait);
}
if (uptr->flags & UNIT_ATT &&
(uptr->u3 & (READING|CARD_IN_READ|END_CARD)) == 0)
uptr->u3 |= RDY_READ;
if (uptr->u3 & RDY_READ_EN && uptr->u3 & RDY_READ)
set_interrupt(dev, uptr->u3);
if (uptr->u3 & TROUBLE_EN &&
(uptr->u3 & (END_CARD|END_FILE|DATA_MISS|TROUBLE)) != 0)
set_interrupt(dev, uptr->u3);
(uptr->STATUS & (READING|CARD_IN_READ|END_CARD)) == 0)
uptr->STATUS |= RDY_READ;
if (uptr->STATUS & RDY_READ_EN && uptr->STATUS & RDY_READ)
set_interrupt(dev, uptr->STATUS);
if (uptr->STATUS & TROUBLE_EN &&
(uptr->STATUS & (END_CARD|END_FILE|DATA_MISS|TROUBLE)) != 0)
set_interrupt(dev, uptr->STATUS);
break;
case DATAI:
clr_interrupt(dev);
if (uptr->u3 & DATA_RDY) {
*data = uptr->u5;
if (uptr->STATUS & DATA_RDY) {
*data = uptr->DATA;
sim_debug(DEBUG_DATAIO, &cr_dev, "CR: DATAI %012llo\n", *data);
uptr->u3 &= ~DATA_RDY;
uptr->STATUS &= ~DATA_RDY;
} else
*data = 0;
break;
@@ -170,48 +175,48 @@ t_stat cr_devio(uint32 dev, uint64 *data) {
/* Handle transfer of data for card reader */
t_stat
cr_srv(UNIT *uptr) {
uint16 *image = (uint16 *)(uptr->up7);
uint16 *image = (uint16 *)(uptr->BUFFER);
/* Check if new card requested. */
if ((uptr->u3 & (READING|CARD_IN_READ)) == READING) {
if ((uptr->STATUS & (READING|CARD_IN_READ)) == READING) {
switch(sim_read_card(uptr, image)) {
case CDSE_EOF:
uptr->u3 |= END_FILE;
if (uptr->u3 & TROUBLE_EN)
set_interrupt(CR_DEVNUM, uptr->u3);
uptr->STATUS |= END_FILE;
if (uptr->STATUS & TROUBLE_EN)
set_interrupt(CR_DEVNUM, uptr->STATUS);
return SCPE_OK;
case CDSE_EMPTY:
return SCPE_OK;
case CDSE_ERROR:
uptr->u3 |= TROUBLE;
if (uptr->u3 & TROUBLE_EN)
set_interrupt(CR_DEVNUM, uptr->u3);
uptr->STATUS |= TROUBLE;
if (uptr->STATUS & TROUBLE_EN)
set_interrupt(CR_DEVNUM, uptr->STATUS);
return SCPE_OK;
case CDSE_OK:
uptr->u3 |= CARD_IN_READ;
uptr->STATUS |= CARD_IN_READ;
break;
}
uptr->u4 = 0;
uptr->COL = 0;
sim_activate(uptr, uptr->wait);
return SCPE_OK;
}
/* Copy next column over */
if (uptr->u3 & CARD_IN_READ) {
if (uptr->u4 >= 80) {
uptr->u3 &= ~(CARD_IN_READ|READING);
uptr->u3 |= END_CARD;
set_interrupt(CR_DEVNUM, uptr->u3);
if (uptr->STATUS & CARD_IN_READ) {
if (uptr->COL >= 80) {
uptr->STATUS &= ~(CARD_IN_READ|READING);
uptr->STATUS |= END_CARD;
set_interrupt(CR_DEVNUM, uptr->STATUS);
sim_activate(uptr, uptr->wait);
return SCPE_OK;
}
uptr->u5 = image[uptr->u4++];
if (uptr->u3 & DATA_RDY) {
uptr->u3 |= DATA_MISS;
uptr->DATA = image[uptr->COL++];
if (uptr->STATUS & DATA_RDY) {
uptr->STATUS |= DATA_MISS;
}
uptr->u3 |= DATA_RDY;
sim_debug(DEBUG_DATA, &cr_dev, "CR Char > %d %03x\n", uptr->u4, uptr->u5);
set_interrupt(CR_DEVNUM, uptr->u3);
uptr->STATUS |= DATA_RDY;
sim_debug(DEBUG_DATA, &cr_dev, "CR Char > %d %03x\n", uptr->COL, uptr->DATA);
set_interrupt(CR_DEVNUM, uptr->STATUS);
sim_activate(uptr, uptr->wait);
}
return SCPE_OK;
@@ -224,9 +229,9 @@ cr_attach(UNIT * uptr, CONST char *file)
if ((r = sim_card_attach(uptr, file)) != SCPE_OK)
return r;
if (uptr->up7 == 0) {
uptr->up7 = malloc(sizeof(uint16)*80);
uptr->u3 |= RDY_READ;
if (uptr->BUFFER == 0) {
uptr->BUFFER = malloc(sizeof(uint16)*80);
uptr->STATUS |= RDY_READ;
}
return SCPE_OK;
}
@@ -234,9 +239,9 @@ cr_attach(UNIT * uptr, CONST char *file)
t_stat
cr_detach(UNIT * uptr)
{
if (uptr->up7 != 0)
free(uptr->up7);
uptr->up7 = 0;
if (uptr->BUFFER != 0)
free(uptr->BUFFER);
uptr->BUFFER = 0;
return sim_card_detach(uptr);
}

View File

@@ -51,6 +51,10 @@ const char *cty_description (DEVICE *dptr);
#define KEY_TST 04000
#define CTY_DEVNUM 0120
#define STATUS u3
#define DATA u4
#define PIA u5
t_stat cty_devio(uint32 dev, uint64 *data);
DIB cty_dib = { CTY_DEVNUM, 1, cty_devio, NULL};
@@ -82,40 +86,40 @@ t_stat cty_devio(uint32 dev, uint64 *data) {
uint64 res;
switch(dev & 3) {
case CONI:
res = cty_unit[0].u5 | (cty_unit[0].u3 & (TEL_RDY | TEL_BSY));
res |= cty_unit[1].u3 & (KEY_RDY | KEY_BSY);
res |= cty_unit[0].u3 & KEY_TST;
res = cty_unit[0].PIA | (cty_unit[0].STATUS & (TEL_RDY | TEL_BSY));
res |= cty_unit[1].STATUS & (KEY_RDY | KEY_BSY);
res |= cty_unit[0].STATUS & KEY_TST;
*data = res;
sim_debug(DEBUG_CONI, &cty_dev, "CTY %03o CONI %06o\n", dev, (uint32)*data);
break;
case CONO:
res = *data;
cty_unit[0].u5 = res & 07;
cty_unit[1].u5 = res & 07;
cty_unit[0].u5 &= ~(KEY_TST);
cty_unit[0].u3 &= ~((res >> 4) & (TEL_RDY | TEL_BSY));
cty_unit[0].u3 |= (res & (TEL_RDY | TEL_BSY | KEY_TST));
cty_unit[1].u3 &= ~((res >> 4) & (KEY_RDY | KEY_BSY));
cty_unit[1].u3 |= (res & (KEY_RDY | KEY_BSY));
if ((cty_unit[0].u3 & TEL_RDY) || (cty_unit[1].u3 & KEY_RDY))
set_interrupt(dev, cty_unit[0].u5);
cty_unit[0].PIA = res & 07;
cty_unit[1].PIA = res & 07;
cty_unit[0].PIA &= ~(KEY_TST);
cty_unit[0].STATUS &= ~((res >> 4) & (TEL_RDY | TEL_BSY));
cty_unit[0].STATUS |= (res & (TEL_RDY | TEL_BSY | KEY_TST));
cty_unit[1].STATUS &= ~((res >> 4) & (KEY_RDY | KEY_BSY));
cty_unit[1].STATUS |= (res & (KEY_RDY | KEY_BSY));
if ((cty_unit[0].STATUS & TEL_RDY) || (cty_unit[1].STATUS & KEY_RDY))
set_interrupt(dev, cty_unit[0].PIA);
else
clr_interrupt(dev);
sim_debug(DEBUG_CONO, &cty_dev, "CTY %03o CONO %06o\n", dev, (uint32)*data);
break;
case DATAI:
res = cty_unit[1].u4 & 0xff;
cty_unit[1].u3 &= ~KEY_RDY;
if ((cty_unit[0].u3 & TEL_RDY) == 0)
res = cty_unit[1].DATA & 0xff;
cty_unit[1].STATUS &= ~KEY_RDY;
if ((cty_unit[0].STATUS & TEL_RDY) == 0)
clr_interrupt(dev);
*data = res;
sim_debug(DEBUG_DATAIO, &cty_dev, "CTY %03o DATAI %06o\n", dev, (uint32)*data);
break;
case DATAO:
cty_unit[0].u4 = *data & 0x7f;
cty_unit[0].u3 &= ~TEL_RDY;
cty_unit[0].u3 |= TEL_BSY;
if ((cty_unit[1].u3 & KEY_RDY) == 0)
cty_unit[0].DATA = *data & 0x7f;
cty_unit[0].STATUS &= ~TEL_RDY;
cty_unit[0].STATUS |= TEL_BSY;
if ((cty_unit[1].STATUS & KEY_RDY) == 0)
clr_interrupt(dev);
sim_activate(&cty_unit[0], cty_unit[0].wait);
sim_debug(DEBUG_DATAIO, &cty_dev, "CTY %03o DATAO %06o\n", dev, (uint32)*data);
@@ -131,16 +135,16 @@ t_stat ctyo_svc (UNIT *uptr)
t_stat r;
int32 ch;
if (uptr->u4 != 0) {
ch = sim_tt_outcvt ( uptr->u4, TT_GET_MODE (uptr->flags)) ;
if (uptr->DATA != 0) {
ch = sim_tt_outcvt ( uptr->DATA, TT_GET_MODE (uptr->flags)) ;
if ((r = sim_putchar_s (ch)) != SCPE_OK) { /* output; error? */
sim_activate (uptr, uptr->wait); /* try again */
return ((r == SCPE_STALL)? SCPE_OK: r); /* !stall? report */
}
}
uptr->u3 &= ~TEL_BSY;
uptr->u3 |= TEL_RDY;
set_interrupt(CTY_DEVNUM, uptr->u5);
uptr->STATUS &= ~TEL_BSY;
uptr->STATUS |= TEL_RDY;
set_interrupt(CTY_DEVNUM, uptr->PIA);
return SCPE_OK;
}
@@ -154,10 +158,10 @@ t_stat ctyi_svc (UNIT *uptr)
return ch;
if (ch & SCPE_BREAK) /* ignore break */
return SCPE_OK;
uptr->u4 = 0177 & sim_tt_inpcvt(ch, TT_GET_MODE (uptr->flags));
uptr->u4 = ch & 0177;
uptr->u3 |= KEY_RDY;
set_interrupt(CTY_DEVNUM, uptr->u5);
uptr->DATA = 0177 & sim_tt_inpcvt(ch, TT_GET_MODE (uptr->flags));
uptr->DATA = ch & 0177;
uptr->STATUS |= KEY_RDY;
set_interrupt(CTY_DEVNUM, uptr->PIA);
return SCPE_OK;
}
@@ -165,8 +169,8 @@ t_stat ctyi_svc (UNIT *uptr)
t_stat cty_reset (DEVICE *dptr)
{
cty_unit[0].u3 &= ~(TEL_RDY | TEL_BSY);
cty_unit[1].u3 &= ~(KEY_RDY | KEY_BSY);
cty_unit[0].STATUS &= ~(TEL_RDY | TEL_BSY);
cty_unit[1].STATUS &= ~(KEY_RDY | KEY_BSY);
clr_interrupt(CTY_DEVNUM);
sim_clock_coschedule (&cty_unit[1], tmxr_poll);

View File

@@ -322,6 +322,7 @@ extern DEVICE dk_dev;
extern DEVICE pd_dev;
extern DEVICE dpy_dev;
extern DEVICE imx_dev;
extern DEVICE imp_dev;
extern DEVICE tk10_dev;
extern DEVICE mty_dev;
extern DEVICE wcnsls_dev; /* MIT Spacewar Consoles */
@@ -410,5 +411,3 @@ extern uint18 PC;
extern uint32 FLAGS;
#endif

View File

@@ -116,9 +116,10 @@
#define MT_BRFUL 000000010 /* BR register full */
#define MT_STOP 000000020 /* DF10 End of Channel */
#define MT_LASTWD 000000040 /* Last data word of record */
/* in u3 is device address */
/* in u4 is current buffer position */
/* in u5 */
#define CNTRL u3
#define CPOS u5 /* Character position */
#define BPOS u6 /* Position in buffer */
t_stat mt_devio(uint32 dev, uint64 *data);
t_stat mt_srv(UNIT *);
@@ -213,7 +214,7 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
switch(dev & 07) {
case CONI:
res = (uint64)(pia & (NEXT_UNIT_ENAB|FLAG_PIA|DATA_PIA));
res |= (uint64)(uptr->u3 & 077300);
res |= (uint64)(uptr->CNTRL & 077300);
res |= ((uint64)unit) << 15;
res |= ((uint64)next_unit) << 18;
res |= ((uint64)wr_eor) << 21;
@@ -243,18 +244,18 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
if (pia & NEXT_UNIT_ENAB) {
set_interrupt(dev, pia >> 3);
}
uptr->u3 = (int32)(*data & 077300);
uptr->CNTRL = (int32)(*data & 077300);
mt_df10.buf = 0;
sim_debug(DEBUG_CONO, dptr,
"MT CONO %03o start %o %o %o %012llo %012llo PC=%06o\n",
dev, uptr->u3, unit, pia, *data, status, PC);
dev, uptr->CNTRL, unit, pia, *data, status, PC);
if ((uptr->flags & UNIT_ATT) != 0) {
/* Check if Write */
int cmd = (uptr->u3 & FUNCTION) >> 9;
uptr->u3 &= ~(MT_BRFUL|MT_BUFFUL|MT_STOP);
int cmd = (uptr->CNTRL & FUNCTION) >> 9;
uptr->CNTRL &= ~(MT_BRFUL|MT_BUFFUL|MT_STOP);
switch(cmd & 07) {
case NOP_CLR:
uptr->u3 &= ~MT_BUSY;
uptr->CNTRL &= ~MT_BUSY;
wr_eor = 0;
status |= NEXT_UNIT;
if (cmd & 010) {
@@ -282,7 +283,7 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
case READ:
case CMP:
CLR_BUF(uptr);
uptr->u5 = 0;
uptr->CPOS = 0;
break;
case SPC_REV:
@@ -300,7 +301,7 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
}
}
status |= IDLE_UNIT;
uptr->u3 |= MT_BUSY;
uptr->CNTRL |= MT_BUSY;
sim_activate(uptr, 1000);
} else {
sim_activate(uptr, 9999999);
@@ -312,13 +313,13 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
/* Xfer data */
clr_interrupt(MT_DEVNUM);
*data = hold_reg;
uptr->u3 &= ~MT_BUFFUL;
uptr->CNTRL &= ~MT_BUFFUL;
status &= ~DATA_REQUEST;
if (uptr->u3 & MT_BRFUL) {
if (uptr->CNTRL & MT_BRFUL) {
hold_reg = mt_df10.buf;
mt_df10.buf = 0;
uptr->u3 &= ~MT_BRFUL;
uptr->u3 |= MT_BUFFUL;
uptr->CNTRL &= ~MT_BRFUL;
uptr->CNTRL |= MT_BUFFUL;
if ((dptr->flags & MTDF_TYPEB) == 0) {
status |= DATA_REQUEST;
set_interrupt_mpx(MT_DEVNUM, pia, mt_mpx_lvl);
@@ -332,20 +333,20 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
hold_reg = *data;
status &= ~DATA_REQUEST;
clr_interrupt(MT_DEVNUM);
uptr->u3 |= MT_BUFFUL;
uptr->CNTRL |= MT_BUFFUL;
sim_debug(DEBUG_DATA, dptr, "MT %03o <%012llo, %012llo\n",
dev, hold_reg, mt_df10.buf);
break;
case CONI|04:
res = status;
if ((uptr->u3 & MT_BUSY) == 0)
if ((uptr->CNTRL & MT_BUSY) == 0)
res |= NEXT_UNIT;
if ((uptr->u3 & (06000|MT_STOP)) == 02000 && (status & JOB_DONE) != 0)
if ((uptr->CNTRL & (06000|MT_STOP)) == 02000 && (status & JOB_DONE) != 0)
res |= RLC_ERR;
if ((uptr->flags & MTUF_7TRK) != 0)
res |= SEVEN_CHAN;
if ((uptr->flags & UNIT_ATT) != 0 && (uptr->u3 & MT_MOTION) == 0)
if ((uptr->flags & UNIT_ATT) != 0 && (uptr->CNTRL & MT_MOTION) == 0)
res |= IDLE_UNIT;
if ((uptr->flags & MTUF_WLK) != 0)
res |= WRITE_LOCK;
@@ -366,7 +367,7 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
case CONO|04:
if (*data & 1) {
uptr->u3 |= MT_STOP;
uptr->CNTRL |= MT_STOP;
hri_mode = 0;
sim_debug(DEBUG_DETAIL, dptr, "MT stop %03o %012llo\n", dev, status);
}
@@ -380,7 +381,7 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
status &= ~(WT_CW_DONE);
}
sim_debug(DEBUG_CONO, dptr, "MT CONO %03o control %o %o %012llo %012llo\n",
dev, uptr->u3, unit, hold_reg, mt_df10.buf);
dev, uptr->CNTRL, unit, hold_reg, mt_df10.buf);
break;
case DATAI|04:
@@ -403,27 +404,27 @@ t_stat mt_devio(uint32 dev, uint64 *data) {
void mt_df10_read(DEVICE *dptr, UNIT *uptr) {
if (dptr->flags & MTDF_TYPEB) {
if (!df10_read(&mt_df10)) {
uptr->u3 |= MT_STOP;
uptr->CNTRL |= MT_STOP;
}
sim_debug(DEBUG_DATA, dptr, "MT <%012llo %o\n", mt_df10.buf, uptr->u5);
sim_debug(DEBUG_DATA, dptr, "MT <%012llo %o\n", mt_df10.buf, uptr->CPOS);
} else {
if (uptr->u3 & MT_BUFFUL) {
if (uptr->CNTRL & MT_BUFFUL) {
mt_df10.buf = hold_reg;
if ((uptr->u3 & MT_STOP) == 0) {
if ((uptr->CNTRL & MT_STOP) == 0) {
status |= DATA_REQUEST;
set_interrupt_mpx(MT_DEVNUM, pia, mt_mpx_lvl);
}
} else {
if ((uptr->u3 & MT_STOP) == 0) {
if ((uptr->CNTRL & MT_STOP) == 0) {
status |= DATA_LATE;
uptr->u3 |= MT_STOP;
uptr->CNTRL |= MT_STOP;
}
return;
}
}
uptr->u3 &= ~MT_BUFFUL;
uptr->u3 |= MT_BRFUL;
uptr->u5 = 0;
uptr->CNTRL &= ~MT_BUFFUL;
uptr->CNTRL |= MT_BRFUL;
uptr->CPOS = 0;
}
/* Wrapper to handle writing of hold register or via DF10 */
@@ -433,24 +434,24 @@ void mt_df10_write(DEVICE *dptr, UNIT *uptr) {
hold_reg = mt_df10.buf;
status |= DATA_REQUEST;
} else if (!df10_write(&mt_df10)) {
uptr->u3 |= MT_STOP;
uptr->CNTRL |= MT_STOP;
return;
}
sim_debug(DEBUG_DATA, dptr, "MT >%012llo %o\n", mt_df10.buf, uptr->u5);
uptr->u3 &= ~(MT_BUFFUL|MT_BRFUL);
sim_debug(DEBUG_DATA, dptr, "MT >%012llo %o\n", mt_df10.buf, uptr->CPOS);
uptr->CNTRL &= ~(MT_BUFFUL|MT_BRFUL);
} else {
if ((uptr->u3 & MT_BUFFUL) == 0) {
if ((uptr->CNTRL & MT_BUFFUL) == 0) {
hold_reg = mt_df10.buf;
status |= DATA_REQUEST;
uptr->u3 &= ~(MT_BRFUL);
uptr->u3 |= MT_BUFFUL;
uptr->CNTRL &= ~(MT_BRFUL);
uptr->CNTRL |= MT_BUFFUL;
set_interrupt_mpx(MT_DEVNUM, pia, mt_mpx_lvl);
} else {
uptr->u3 |= MT_BRFUL;
uptr->CNTRL |= MT_BRFUL;
}
}
mt_df10.buf = 0;
uptr->u5 = 0;
uptr->CPOS = 0;
}
@@ -500,7 +501,7 @@ t_stat mt_error(UNIT * uptr, t_stat r, DEVICE * dptr)
set_interrupt(MT_DEVNUM+4, pia >> 3);
}
status |= JOB_DONE;
uptr->u3 &= ~MT_BUSY;
uptr->CNTRL &= ~MT_BUSY;
sim_debug(DEBUG_EXP, dptr, "Setting status %d %012llo\n", r, status);
set_interrupt(MT_DEVNUM+4, pia >> 3);
return SCPE_OK;
@@ -511,7 +512,7 @@ t_stat mt_srv(UNIT * uptr)
{
DEVICE *dptr = find_dev_from_unit(uptr);
int unit = (uptr - dptr->units) & 7;
int cmd = (uptr->u3 & FUNCTION) >> 9;
int cmd = (uptr->CNTRL & FUNCTION) >> 9;
t_mtrlnt reclen;
t_stat r = SCPE_ARG; /* Force error if not set */
uint8 ch;
@@ -519,25 +520,25 @@ t_stat mt_srv(UNIT * uptr)
int cc_max;
if ((uptr->flags & UNIT_ATT) == 0) {
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
return mt_error(uptr, MTSE_UNATT, dptr); /* attached? */
}
if ((cmd & 6) != 0 && (uptr->u3 & DENS_MSK) != DENS_800) {
uptr->u3 &= ~MT_MOTION;
if ((cmd & 6) != 0 && (uptr->CNTRL & DENS_MSK) != DENS_800) {
uptr->CNTRL &= ~MT_MOTION;
return mt_error(uptr, MTSE_FMT, dptr); /* wrong density? */
}
if (uptr->flags & MTUF_7TRK) {
cc_max = 6;
} else {
cc_max = (4 + ((uptr->u3 & CORE_DUMP) != 0));
cc_max = (4 + ((uptr->CNTRL & CORE_DUMP) != 0));
}
switch(cmd) {
case NOP_IDLE:
sim_debug(DEBUG_DETAIL, dptr, "MT%o Idle\n", unit);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
return mt_error(uptr, MTSE_OK, dptr);
case NOP_CLR:
@@ -547,32 +548,32 @@ t_stat mt_srv(UNIT * uptr)
case REWIND:
status &= ~IDLE_UNIT;
sim_debug(DEBUG_DETAIL, dptr, "MT%o rewind\n", unit);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
status |= BOT_FLAG;
return mt_error(uptr, sim_tape_rewind(uptr), dptr);
case UNLOAD:
status &= ~IDLE_UNIT;
sim_debug(DEBUG_DETAIL, dptr, "MT%o unload\n", unit);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
return mt_error(uptr, sim_tape_detach(uptr), dptr);
case READ:
case READ_NOEOR:
if (uptr->u3 & MT_STOP) {
if ((uptr->u3 & MT_LASTWD) == 0)
if (uptr->CNTRL & MT_STOP) {
if ((uptr->CNTRL & MT_LASTWD) == 0)
status |= RLC_ERR;
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
return mt_error(uptr, MTSE_OK, dptr);
}
if (BUF_EMPTY(uptr)) {
uptr->u3 |= MT_MOTION;
uptr->CNTRL |= MT_MOTION;
status &= ~(IDLE_UNIT|BOT_FLAG|EOF_FLAG|EOT_FLAG|PARITY_ERR|CHAR_COUNT);
if ((r = sim_tape_rdrecf(uptr, &mt_buffer[0], &reclen,
BUFFSIZE)) != MTSE_OK) {
sim_debug(DEBUG_DETAIL, dptr, "MT%o read error %d\n", unit, r);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
if (dptr->flags & MTDF_TYPEB && r == MTSE_TMK) {
df10_write(&mt_df10);
df10_writecw(&mt_df10);
@@ -581,45 +582,45 @@ t_stat mt_srv(UNIT * uptr)
}
sim_debug(DEBUG_DETAIL, dptr, "MT%o read %d\n", unit, reclen);
uptr->hwmark = reclen;
uptr->u6 = 0;
uptr->BPOS = 0;
}
if (uptr->u3 & MT_BRFUL) {
if (uptr->CNTRL & MT_BRFUL) {
status |= DATA_LATE;
sim_debug(DEBUG_EXP, dptr, "data late\n");
break;
}
if ((uint32)uptr->u6 < uptr->hwmark) {
if ((uint32)uptr->BPOS < uptr->hwmark) {
if (uptr->flags & MTUF_7TRK) {
cc = 6 * (5 - uptr->u5);
ch = mt_buffer[uptr->u6];
if ((((uptr->u3 & ODD_PARITY) ? 0x40 : 0) ^
cc = 6 * (5 - uptr->CPOS);
ch = mt_buffer[uptr->BPOS];
if ((((uptr->CNTRL & ODD_PARITY) ? 0x40 : 0) ^
parity_table[ch & 0x3f]) != 0) {
status |= PARITY_ERR;
}
mt_df10.buf |= (uint64)(ch & 0x3f) << cc;
} else {
if ((uptr->u3 & ODD_PARITY) == 0)
if ((uptr->CNTRL & ODD_PARITY) == 0)
status |= PARITY_ERR;
cc = (8 * (3 - uptr->u5)) + 4;
ch = mt_buffer[uptr->u6];
cc = (8 * (3 - uptr->CPOS)) + 4;
ch = mt_buffer[uptr->BPOS];
if (cc < 0)
mt_df10.buf |= (uint64)(ch & 0x3f);
else
mt_df10.buf |= (uint64)(ch & 0xff) << cc;
}
uptr->u6++;
uptr->u5++;
if ((uptr->u6 + cc_max) >= uptr->hwmark)
uptr->u3 |= MT_LASTWD;
uptr->BPOS++;
uptr->CPOS++;
if ((uptr->BPOS + cc_max) >= uptr->hwmark)
uptr->CNTRL |= MT_LASTWD;
status &= ~CHAR_COUNT;
status |= (uint64)(uptr->u5) << 18;
if (uptr->u5 == cc_max)
status |= (uint64)(uptr->CPOS) << 18;
if (uptr->CPOS == cc_max)
mt_df10_write(dptr, uptr);
} else {
if ((cmd & 010) == 0) {
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
uptr->u3 &= ~(MT_MOTION|MT_BUSY);
uptr->CNTRL &= ~(MT_MOTION|MT_BUSY);
return mt_error(uptr, MTSE_OK, dptr);
} else {
CLR_BUF(uptr);
@@ -629,87 +630,87 @@ t_stat mt_srv(UNIT * uptr)
case CMP:
case CMP_NOEOR:
if (uptr->u3 & MT_STOP) {
if (uptr->CNTRL & MT_STOP) {
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
return mt_error(uptr, MTSE_OK, dptr);
}
if (BUF_EMPTY(uptr)) {
uptr->u3 |= MT_MOTION;
uptr->CNTRL |= MT_MOTION;
status &= ~(IDLE_UNIT|BOT_FLAG|EOF_FLAG|EOT_FLAG|PARITY_ERR|CHAR_COUNT);
if ((r = sim_tape_rdrecf(uptr, &mt_buffer[0], &reclen,
BUFFSIZE)) != MTSE_OK) {
sim_debug(DEBUG_DETAIL, dptr, "MT%o read error %d\n", unit, r);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
if (dptr->flags & MTDF_TYPEB && r == MTSE_TMK)
mt_df10_read(dptr, uptr);
return mt_error(uptr, r, dptr);
}
sim_debug(DEBUG_DETAIL, dptr, "MT%o compare %d\n", unit, reclen);
uptr->hwmark = reclen;
uptr->u6 = 0;
uptr->BPOS = 0;
if ((dptr->flags & MTDF_TYPEB) == 0) {
status |= DATA_REQUEST;
set_interrupt_mpx(MT_DEVNUM, pia, mt_mpx_lvl);
}
break;
}
if (uptr->u6 >= (int32)uptr->hwmark) {
if (uptr->BPOS >= (int32)uptr->hwmark) {
if (cmd == CMP_NOEOR) {
CLR_BUF(uptr);
uptr->u3 &= ~MT_LASTWD;
uptr->CNTRL &= ~MT_LASTWD;
} else {
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
uptr->u3 &= ~(MT_MOTION|MT_BUSY);
uptr->CNTRL &= ~(MT_MOTION|MT_BUSY);
return mt_error(uptr, MTSE_INVRL, dptr);
}
} else if ((uptr->u3 & MT_BRFUL) == 0) {
} else if ((uptr->CNTRL & MT_BRFUL) == 0) {
/* Write out first character. */
mt_df10_read(dptr, uptr);
}
if ((uptr->u3 & MT_BRFUL) != 0) {
if ((uptr->CNTRL & MT_BRFUL) != 0) {
if (uptr->flags & MTUF_7TRK) {
ch = mt_buffer[uptr->u6];
if ((((uptr->u3 & ODD_PARITY) ? 0x40 : 0) ^
ch = mt_buffer[uptr->BPOS];
if ((((uptr->CNTRL & ODD_PARITY) ? 0x40 : 0) ^
parity_table[ch & 0x3f]) != (ch & 0x40)) {
status |= PARITY_ERR;
}
mt_buffer[uptr->u6] &= 0x3f;
cc = 6 * (5 - uptr->u5);
mt_buffer[uptr->BPOS] &= 0x3f;
cc = 6 * (5 - uptr->CPOS);
ch = (mt_df10.buf >> cc) & 0x3f;
} else {
if ((uptr->u3 & ODD_PARITY) == 0)
if ((uptr->CNTRL & ODD_PARITY) == 0)
status |= PARITY_ERR;
/* Write next char out */
cc = (8 * (3 - uptr->u5)) + 4;
cc = (8 * (3 - uptr->CPOS)) + 4;
if (cc < 0)
ch = mt_df10.buf & 0x3f;
else
ch = (mt_df10.buf >> cc) & 0xff;
}
if (mt_buffer[uptr->u6] != ch) {
if (mt_buffer[uptr->BPOS] != ch) {
status |= READ_CMP;
if ((dptr->flags & MTDF_TYPEB) == 0) {
uptr->u6 = uptr->hwmark;
uptr->BPOS = uptr->hwmark;
status &= ~CHAR_COUNT;
status |= (uint64)(uptr->u5+1) << 18;
uptr->u3 &= ~(MT_MOTION|MT_BUSY);
status |= (uint64)(uptr->CPOS+1) << 18;
uptr->CNTRL &= ~(MT_MOTION|MT_BUSY);
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
return mt_error(uptr, MTSE_OK, dptr);
}
}
uptr->u6++;
uptr->u5++;
if (uptr->u6 == uptr->hwmark)
uptr->u3 |= MT_LASTWD;
if (uptr->u5 == cc_max) {
uptr->u5 = 0;
uptr->u3 &= ~MT_BRFUL;
uptr->BPOS++;
uptr->CPOS++;
if (uptr->BPOS == uptr->hwmark)
uptr->CNTRL |= MT_LASTWD;
if (uptr->CPOS == cc_max) {
uptr->CPOS = 0;
uptr->CNTRL &= ~MT_BRFUL;
}
status &= ~CHAR_COUNT;
status |= (uint64)(uptr->u5+1) << 18;
status |= (uint64)(uptr->CPOS+1) << 18;
}
break;
@@ -717,12 +718,12 @@ t_stat mt_srv(UNIT * uptr)
case WRITE_LONG:
/* Writing and Type A, request first data word */
if (BUF_EMPTY(uptr)) {
uptr->u3 |= MT_MOTION;
uptr->CNTRL |= MT_MOTION;
status &= ~(IDLE_UNIT|BOT_FLAG|EOF_FLAG|EOT_FLAG|PARITY_ERR|CHAR_COUNT);
sim_debug(DEBUG_EXP, dptr, "MT%o Init write\n", unit);
uptr->hwmark = 0;
uptr->u5 = 0;
uptr->u6 = 0;
uptr->CPOS = 0;
uptr->BPOS = 0;
status |= (uint64)(1) << 18;
if ((dptr->flags & MTDF_TYPEB) == 0) {
status |= DATA_REQUEST;
@@ -731,45 +732,45 @@ t_stat mt_srv(UNIT * uptr)
break;
}
/* Force error if we exceed buffer size */
if (uptr->u6 >= BUFFSIZE)
if (uptr->BPOS >= BUFFSIZE)
return mt_error(uptr, MTSE_RECE, dptr);
if ((uptr->u3 & MT_BRFUL) == 0)
if ((uptr->CNTRL & MT_BRFUL) == 0)
mt_df10_read(dptr, uptr);
if ((uptr->u3 & MT_BRFUL) != 0) {
if ((uptr->CNTRL & MT_BRFUL) != 0) {
if (uptr->flags & MTUF_7TRK) {
cc = 6 * (5 - uptr->u5);
cc = 6 * (5 - uptr->CPOS);
ch = (mt_df10.buf >> cc) & 0x3f;
ch |= ((uptr->u3 & ODD_PARITY) ? 0x40 : 0) ^
ch |= ((uptr->CNTRL & ODD_PARITY) ? 0x40 : 0) ^
parity_table[ch & 0x3f];
} else {
/* Write next char out */
cc = (8 * (3 - uptr->u5)) + 4;
cc = (8 * (3 - uptr->CPOS)) + 4;
if (cc < 0)
ch = mt_df10.buf & 0x3f;
else
ch = (mt_df10.buf >> cc) & 0xff;
}
mt_buffer[uptr->u6] = ch;
uptr->u6++;
uptr->hwmark = uptr->u6;
uptr->u5++;
if (uptr->u5 == cc_max) {
uptr->u5 = 0;
uptr->u3 &= ~MT_BRFUL;
mt_buffer[uptr->BPOS] = ch;
uptr->BPOS++;
uptr->hwmark = uptr->BPOS;
uptr->CPOS++;
if (uptr->CPOS == cc_max) {
uptr->CPOS = 0;
uptr->CNTRL &= ~MT_BRFUL;
}
status &= ~CHAR_COUNT;
status |= (uint64)(uptr->u5+1) << 18;
status |= (uint64)(uptr->CPOS+1) << 18;
}
if ((uptr->u3 & (MT_STOP|MT_BRFUL|MT_BUFFUL)) == MT_STOP) {
if ((uptr->CNTRL & (MT_STOP|MT_BRFUL|MT_BUFFUL)) == MT_STOP) {
/* Write out the block */
wr_eor = 1;
reclen = uptr->hwmark;
status &= ~(BOT_FLAG|EOF_FLAG|EOT_FLAG|CHAR_COUNT);
r = sim_tape_wrrecf(uptr, &mt_buffer[0], reclen);
sim_debug(DEBUG_DETAIL, dptr, "MT%o Write %d\n", unit, reclen);
uptr->u6 = 0;
uptr->BPOS = 0;
uptr->hwmark = 0;
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
return mt_error(uptr, r, dptr); /* Record errors */
@@ -779,18 +780,18 @@ t_stat mt_srv(UNIT * uptr)
case WTM:
if ((uptr->flags & MTUF_WLK) != 0)
return mt_error(uptr, MTSE_WRP, dptr);
if (uptr->u5 == 0) {
if (uptr->CPOS == 0) {
status &= ~(IDLE_UNIT|BOT_FLAG|EOT_FLAG);
sim_debug(DEBUG_DETAIL, dptr, "MT%o WTM\n", unit);
r = sim_tape_wrtmk(uptr);
if (r != MTSE_OK)
return mt_error(uptr, r, dptr);
uptr->u5++;
uptr->CPOS++;
wr_eor = 1;
} else {
wr_eor = 0;
status |= EOF_FLAG;
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
return mt_error(uptr, MTSE_OK, dptr);
}
break;
@@ -798,7 +799,7 @@ t_stat mt_srv(UNIT * uptr)
case ERG:
if ((uptr->flags & MTUF_WLK) != 0)
return mt_error(uptr, MTSE_WRP, dptr);
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
status &= ~(IDLE_UNIT|BOT_FLAG|EOT_FLAG);
sim_debug(DEBUG_DETAIL, dptr, "MT%o ERG\n", unit);
return mt_error(uptr, sim_tape_wrgap(uptr, 35), dptr);
@@ -808,7 +809,7 @@ t_stat mt_srv(UNIT * uptr)
case SPC_REV:
case SPC_FWD:
sim_debug(DEBUG_DETAIL, dptr, "MT%o space %o\n", unit, cmd);
uptr->u3 |= MT_MOTION;
uptr->CNTRL |= MT_MOTION;
status &= ~(IDLE_UNIT|BOT_FLAG|EOT_FLAG);
/* Always skip at least one record */
if ((cmd & 7) == SPC_FWD)
@@ -822,7 +823,7 @@ t_stat mt_srv(UNIT * uptr)
case MTSE_BOT: /* beginning of tape */
case MTSE_EOM: /* end of medium */
/* Stop motion if we recieve any of these */
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
status &= ~DATA_REQUEST;
clr_interrupt(MT_DEVNUM);
return mt_error(uptr, r, dptr);
@@ -830,14 +831,14 @@ t_stat mt_srv(UNIT * uptr)
/* Clear tape mark, command, idle since we will need to change dir */
if ((cmd & 010) == 0) {
mt_df10_read(dptr, uptr);
if ((uptr->u3 & MT_BRFUL) == 0) {
if ((uptr->CNTRL & MT_BRFUL) == 0) {
status &= ~DATA_LATE;
uptr->u3 &= ~MT_MOTION;
uptr->CNTRL &= ~MT_MOTION;
if (dptr->flags & MTDF_TYPEB)
df10_writecw(&mt_df10);
return mt_error(uptr, MTSE_OK, dptr);
}
uptr->u3 &= ~MT_BRFUL;
uptr->CNTRL &= ~MT_BRFUL;
}
uptr->hwmark = 0;
sim_activate(uptr, 5000);
@@ -853,12 +854,12 @@ void mt_read_word(UNIT *uptr) {
mt_df10.buf = 0;
for(i = 0; i <= 4; i++) {
cc = (8 * (3 - i)) + 4;
ch = mt_buffer[uptr->u6];
ch = mt_buffer[uptr->BPOS];
if (cc < 0)
mt_df10.buf |= (uint64)(ch & 0x3f);
else
mt_df10.buf |= (uint64)(ch & 0xff) << cc;
uptr->u6++;
uptr->BPOS++;
}
}
@@ -877,11 +878,11 @@ mt_boot(int32 unit_num, DEVICE * dptr)
r = sim_tape_rewind(uptr);
if (r != SCPE_OK)
return r;
uptr->u3 = 022200; /* Read 800 BPI, Core */
uptr->CNTRL = 022200; /* Read 800 BPI, Core */
r = sim_tape_rdrecf(uptr, &mt_buffer[0], &reclen, BUFFSIZE);
if (r != SCPE_OK)
return r;
uptr->u6 = 0;
uptr->BPOS = 0;
uptr->hwmark = reclen;
mt_read_word(uptr);
@@ -890,11 +891,11 @@ mt_boot(int32 unit_num, DEVICE * dptr)
while (wc != 0) {
wc = (wc + 1) & RMASK;
addr = (addr + 1) & RMASK;
if ((uint32)uptr->u6 >= uptr->hwmark) {
if ((uint32)uptr->BPOS >= uptr->hwmark) {
r = sim_tape_rdrecf(uptr, &mt_buffer[0], &reclen, BUFFSIZE);
if (r != SCPE_OK)
return r;
uptr->u6 = 0;
uptr->BPOS = 0;
uptr->hwmark = reclen;
}
mt_read_word(uptr);
@@ -910,9 +911,9 @@ mt_boot(int32 unit_num, DEVICE * dptr)
PC = mt_df10.buf & RMASK;
/* If not at end of record and TMA continue record read */
if ((uint32)uptr->u6 < uptr->hwmark) {
uptr->u3 |= MT_MOTION|MT_BUSY;
uptr->u3 &= ~(MT_BRFUL|MT_BUFFUL);
if ((uint32)uptr->BPOS < uptr->hwmark) {
uptr->CNTRL |= MT_MOTION|MT_BUSY;
uptr->CNTRL &= ~(MT_BRFUL|MT_BUFFUL);
hold_reg = mt_df10.buf = 0;
if ((dptr->flags & MTDF_TYPEB) != 0) {
mt_df10.cia = 020;
@@ -992,7 +993,7 @@ mt_reset(DEVICE * dptr)
if (MT_DENS(uptr->dynflags) == MT_DENS_NONE)
uptr->dynflags = MT_200_VALID | MT_556_VALID |
MT_800_VALID | (MT_DENS_800 << UNIT_V_DF_TAPE);
uptr->u3 = 0;
uptr->CNTRL = 0;
sim_cancel(uptr);
}
mt_df10.devnum = mt_dib.dev_num;
@@ -1015,7 +1016,7 @@ mt_attach(UNIT * uptr, CONST char *file)
t_stat
mt_detach(UNIT * uptr)
{
uptr->u5 = 0;
uptr->CPOS = 0;
return sim_tape_detach(uptr);
}

View File

@@ -28,6 +28,12 @@
#include "sim_tmxr.h"
#include "ka10_defs.h"
#ifndef NUM_DEVS_MTY
#define NUM_DEVS_MTY 0
#endif
#if (NUM_DEVS_MTY > 0)
#define MTY_NAME "MTY"
#define MTY_DEVNUM 0400
#define MTY_LINES 32
@@ -298,3 +304,4 @@ static const char *mty_description (DEVICE *dptr)
{
return "Morton box: Terminal multiplexor";
}
#endif

View File

@@ -33,6 +33,12 @@
#include <time.h>
#include "ka10_defs.h"
#ifndef NUM_DEVS_PD
#define NUM_DEVS_PD 0
#endif
#if (NUM_DEVS_PD > 0)
#define PD_DEVNUM 0500
#define PD_OFF (1 << DEV_V_UF)
@@ -118,3 +124,4 @@ t_stat pd_show_on(FILE *st, UNIT *uptr, int32 val, CONST void *desc)
return SCPE_OK;
}
#endif

View File

@@ -69,7 +69,7 @@ const char *ptr_description (DEVICE *dptr);
DIB ptp_dib = { PP_DEVNUM, 1, &ptp_devio, NULL };
UNIT ptp_unit = {
UDATA (&ptp_svc, UNIT_ATTABLE+UNIT_TEXT+UNIT_RO, 0), SERIAL_OUT_WAIT
UDATA (&ptp_svc, UNIT_ATTABLE+UNIT_TEXT, 0), SERIAL_OUT_WAIT
};
REG ptp_reg[] = {

View File

@@ -28,6 +28,12 @@
#include "sim_tmxr.h"
#include "ka10_defs.h"
#ifndef NUM_DEVS_TK10
#define NUM_DEVS_TK10 0
#endif
#if (NUM_DEVS_TK10 > 0)
#define TK10_NAME "TK"
#define TK10_DEVNUM 0600 /* Also known as NTY. */
#define TK10_LINES 16
@@ -321,3 +327,5 @@ static const char *tk10_description (DEVICE *dptr)
{
return "Knight kludge: TTY scanner";
}
#endif