/* 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; }
int serial_iec_read(unsigned int unit, unsigned int secondary, BYTE *data) { if (listen) { serial_iec_bus_unlisten(unit, (BYTE)secondary, serial_iec_set_st); listen = 0; } if (!talk) { serial_iec_bus_talk(unit | 0x40, (BYTE)secondary, serial_iec_set_st); talk = 1; } *data = serial_iec_bus_read(unit, (BYTE)secondary, serial_iec_set_st); return serial_iec_st; }