Exemplo n.º 1
0
int serial_iec_write(unsigned int unit, unsigned int secondary, BYTE data)
{
    if (talk) {
        serial_iec_bus_untalk(unit, (BYTE)secondary, serial_iec_set_st);
        talk = 0;
    }

    if (!listen) {
        serial_iec_bus_listen(unit | 0x20, (BYTE)secondary, serial_iec_set_st);
        listen = 1;
    }

    serial_iec_bus_write(unit, (BYTE)secondary, data, serial_iec_set_st);

    return serial_iec_st;
}
Exemplo n.º 2
0
/* 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;
}