/* Receive one byte from the serial bus. */ int serial_trap_receive(void) { BYTE data; if (serial_truedrive && ((TrapDevice & 0x0f) != 4) && ((TrapDevice & 0x0f) != 5)) { return 0; } data = serial_iec_bus_read(TrapDevice, TrapSecondary, serial_set_st); mem_store(tmp_in, data); /* If at EOF, call specified callback function. */ if ((serial_get_st() & 0x40) && eof_callback_func != NULL) { eof_callback_func(); } /* Set registers like the Kernal routine does. */ MOS6510_REGS_SET_A(&maincpu_regs, data); MOS6510_REGS_SET_SIGN(&maincpu_regs, (data & 0x80) ? 1 : 0); MOS6510_REGS_SET_ZERO(&maincpu_regs, data ? 0 : 1); MOS6510_REGS_SET_CARRY(&maincpu_regs, 0); MOS6510_REGS_SET_INTERRUPT(&maincpu_regs, 0); return 1; }
/* Send one byte on the serial bus. */ int serial_trap_send(void) { BYTE data; if (serial_truedrive && ((TrapDevice & 0x0f) != 4) && ((TrapDevice & 0x0f) != 5)) { return 0; } data = mem_read(BSOUR); /* BSOUR - character for serial bus */ serial_iec_bus_write(TrapDevice, TrapSecondary, data, serial_set_st); MOS6510_REGS_SET_CARRY(&maincpu_regs, 0); MOS6510_REGS_SET_INTERRUPT(&maincpu_regs, 0); return 1; }
void maincpu_set_carry(int c) { MOS6510_REGS_SET_CARRY(&maincpu_regs, c); }
/* Command Serial Bus to TALK, LISTEN, UNTALK, or UNLISTEN, and send the Secondary Address to Serial Bus under Attention. */ int serial_trap_attention(void) { BYTE b; serial_t *p; /* * Which Secondary Address ? */ b = mem_read(((BYTE)(BSOUR))); /* BSOUR - character for serial bus */ if (((b & 0xf0) == 0x20) || ((b & 0xf0) == 0x40)) { if (serial_truedrive && ((b & 0x0f) != 4 ) && ((b & 0x0f) != 5)) { /* Set TrapDevice even if the trap is not taken; needed for other traps. */ TrapDevice = b; return 0; } } else { if (serial_truedrive && ((TrapDevice & 0x0f) != 4) && ((TrapDevice & 0x0f) != 5)) { return 0; } } /* do a flush if unlisten for close and command channel */ if (b == 0x3f) { serial_iec_bus_unlisten(TrapDevice, TrapSecondary, serial_set_st); } else if (b == 0x5f) { serial_iec_bus_untalk(TrapDevice, TrapSecondary, serial_set_st); } else { switch (b & 0xf0) { case 0x20: case 0x40: TrapDevice = b; break; case 0x60: TrapSecondary = b; switch (TrapDevice & 0xf0) { case 0x20: serial_iec_bus_listen(TrapDevice, TrapSecondary, serial_set_st); break; case 0x40: serial_iec_bus_talk(TrapDevice, TrapSecondary, serial_set_st); break; } break; case 0xe0: TrapSecondary = b; serial_iec_bus_close(TrapDevice, TrapSecondary, serial_set_st); break; case 0xf0: TrapSecondary = b; serial_iec_bus_open(TrapDevice, TrapSecondary, serial_set_st); break; } } p = serial_device_get(TrapDevice & 0x0f); if (!(p->inuse)) { serial_set_st(0x80); } MOS6510_REGS_SET_CARRY(&maincpu_regs, 0); MOS6510_REGS_SET_INTERRUPT(&maincpu_regs, 0); if (attention_callback_func) { attention_callback_func(); } return 1; }