Пример #1
0
static void pia_reset(void)
{
    mypia.port_a = 0;   /* port A output; piacore assumes input */
    mypia.port_b = 0;   /* port B output; piacore assumes input */
    store_pa(0xff);
    store_pb(0xff);
}
Пример #2
0
static void undump_pb(BYTE byte)
{
    store_pb(byte);
}
Пример #3
0
void REGPARM2 mypia_store(WORD addr, BYTE byte)
{

    if (mycpu_rmw_flag) {
        myclk --;
        mycpu_rmw_flag = 0;
        mypia_store(addr, pia_last_read);
        myclk ++;
    }

    addr &= 3;

    switch (addr) {
      case P_PORT_A: /* port A */
        if (mypia.ctrl_a & 4) {
            mypia.port_a = byte;
        } else {
            mypia.ddr_a = byte;
        }
        byte = mypia.port_a | ~mypia.ddr_a;
        store_pa(byte);
        break;

      case P_PORT_B: /* port B */
        if (mypia.ctrl_b & 4) {
            mypia.port_b = byte;
        } else {
            mypia.ddr_b = byte;
        }
        byte = mypia.port_b | ~mypia.ddr_b;
        store_pb(byte);
        if (IS_CB2_HANDSHAKE()) {
            pia_set_cb2(0);
            mypia.cb_state = 0;
            if (IS_CB2_PULSE_MODE()) {
                pia_set_cb2(1);
                mypia.cb_state = 1;
            }
        }
        break;

        /* Control */

      case P_CTRL_A: /* Control A */
        if ((byte & 0x38) == 0x30 ) {   /* set output low */
            pia_set_ca2(0);
            mypia.ca_state = 0;
        } else
        if ((byte & 0x38) == 0x38) {    /* set output high */
            pia_set_ca2(1);
            mypia.ca_state = 1;
        } else                          /* change to toggle/pulse */
        if ((mypia.ctrl_a & 0x30) == 0x30) {
            pia_set_ca2(1);
            mypia.ca_state = 1;
        }

        mypia.ctrl_a = (mypia.ctrl_a & 0xc0) | (byte & 0x3f);

        if (mypia.ctrl_a & 0x20) mypia.ctrl_a &= 0xbf;

        mypia_update_irq();

        break;

      case P_CTRL_B: /* Control B */
        if ((byte & 0x38) == 0x30 ) {   /* set output low */
            pia_set_cb2(0);
            mypia.cb_state = 0;
        } else
        if ((byte & 0x38) == 0x38) {    /* set output high */
            pia_set_cb2(1);
            mypia.cb_state = 1;
        } else                          /* change to toggle/pulse */
        if ((mypia.ctrl_b & 0x30) == 0x30) {
            pia_set_cb2(1);
            mypia.cb_state = 1;
        }

        mypia.ctrl_b = (mypia.ctrl_b & 0xc0) | (byte & 0x3f);

        if (mypia.ctrl_b & 0x20) mypia.ctrl_b &= 0xbf;

        mypia_update_irq();

        break;
    }  /* switch */
}