Esempio n. 1
0
/* read_* functions must return 0xff if nothing to read!!! */
static BYTE read_ciapa(cia_context_t *cia_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    /* this reads the 8 bit IEEE488 data bus, but joystick 1 and 2 buttons
       can pull down inputs pa6 and pa7 resp. */
    byte = parallel_bus;
    if (parallel_debug) {
        log_message(LOG_DEFAULT,
                    "read: parallel_bus=%02x, pra=%02x, ddra=%02x -> %02x\n",
                    parallel_bus, cia_context->c_cia[CIA_PRA],
                    cia_context->c_cia[CIA_DDRA], byte);
    }
    if (machine_class == VICE_MACHINE_CBM5x0) {
        byte = ((byte & ~(cia_context->c_cia[CIA_DDRA]))
                | (cia_context->c_cia[CIA_PRA] & cia_context->c_cia[CIA_DDRA]))
               & ~(((joystick_value[1] & 0x10) ? 0x40 : 0)
                   | ((joystick_value[2] & 0x10) ? 0x80 : 0));
    } else {
        byte = ((byte & ~(cia_context->c_cia[CIA_DDRA]))
                | (cia_context->c_cia[CIA_PRA] & cia_context->c_cia[CIA_DDRA]));
    }
    return byte;
}
Esempio n. 2
0
static BYTE iecbus_cpu_read_conf3(CLOCK clock)
{
    drivecpu_execute_all(clock);
    serial_iec_device_exec(clock);

    return iecbus.cpu_port;
}
Esempio n. 3
0
static BYTE read_pa(tpi_context_t *tpi_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    byte = 0xff;
    if (ieee_is_out) {
        if (parallel_nrfd)
            byte &= 0x7f;
        if (parallel_ndac)
            byte &= 0xbf;
    } else {
        if (parallel_dav)
            byte &= 0xef;
        if (parallel_eoi)
            byte &= 0xdf;
    }
    if (ieee_is_dev) {
        if (parallel_atn)
            byte &= 0xf7;
    }

    byte = (byte & ~(tpi_context->c_tpi)[TPI_DDPA])
           | (tpi_context->c_tpi[TPI_PA] & tpi_context->c_tpi[TPI_DDPA]);

    return byte;
}
Esempio n. 4
0
int scpu64_snapshot_write(const char *name, int save_roms, int save_disks, int event_mode)
{
    snapshot_t *s;

    s = snapshot_create(name, ((BYTE)(SNAP_MAJOR)), ((BYTE)(SNAP_MINOR)), machine_get_name());
    if (s == NULL) {
        return -1;
    }

    sound_snapshot_prepare();

    /* Execute drive CPUs to get in sync with the main CPU.  */
    drivecpu_execute_all(maincpu_clk);

    if (maincpu_snapshot_write_module(s) < 0
            || scpu64_snapshot_write_module(s, save_roms) < 0
            || ciacore_snapshot_write_module(machine_context.cia1, s) < 0
            || ciacore_snapshot_write_module(machine_context.cia2, s) < 0
            || sid_snapshot_write_module(s) < 0
            || drive_snapshot_write_module(s, save_disks, save_roms) < 0
            || vicii_snapshot_write_module(s) < 0
            || scpu64_glue_snapshot_write_module(s) < 0
            || event_snapshot_write_module(s, event_mode) < 0
            || keyboard_snapshot_write_module(s)
            || joystick_snapshot_write_module(s)) {
        snapshot_close(s);
        ioutil_remove(name);
        return -1;
    }

    snapshot_close(s);
    return 0;
}
Esempio n. 5
0
static void read_ciaicr(cia_context_t *cia_context)
{
    if (burst_mod == BURST_MOD_CIA2) {
        drivecpu_execute_all(maincpu_clk);
    }
    parallel_cable_cpu_execute(DRIVE_PC_STANDARD);
}
Esempio n. 6
0
static void iecbus_cpu_write_conf3(BYTE data, CLOCK clock)
{
    unsigned int dnr;

    drivecpu_execute_all(clock);
    serial_iec_device_exec(clock);

    DEBUG_IEC_CPU_WRITE(data);

    iec_update_cpu_bus(data);

    if (iec_old_atn != (iecbus.cpu_bus & 0x10)) {
        iec_old_atn = iecbus.cpu_bus & 0x10;

        for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
            if (iecbus_device[8 + dnr] == IECBUS_DEVICE_TRUEDRIVE) {
                switch (drive_context[dnr]->drive->type) {
                    case DRIVE_TYPE_1581:
                        if (!iec_old_atn) {
                            ciacore_set_flag(drive_context[dnr]->cia1581);
                        }
                        break;
                    case DRIVE_TYPE_2000:
                    case DRIVE_TYPE_4000:
                        viacore_signal(drive_context[dnr]->via4000, VIA_SIG_CA2,
                                       iec_old_atn ? 0 : VIA_SIG_RISE);
                        break;
                    default:
                        viacore_signal(drive_context[dnr]->via1d1541, VIA_SIG_CA1,
                                       iec_old_atn ? 0 : VIA_SIG_RISE);
                }
            }
        }
    }

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        if (iecbus_device[8 + dnr] == IECBUS_DEVICE_TRUEDRIVE) {
            unsigned int unit;
            unit = dnr + 8;
            switch (drive_context[dnr]->drive->type) {
                case DRIVE_TYPE_1581:
                case DRIVE_TYPE_2000:
                case DRIVE_TYPE_4000:
                    iecbus.drv_bus[unit] = (((iecbus.drv_data[unit] << 3) & 0x40)
                                            | ((iecbus.drv_data[unit] << 6)
                                               & ((iecbus.drv_data[unit]
                                                   | iecbus.cpu_bus) << 3) & 0x80));
                    break;
                default:
                    iecbus.drv_bus[unit] = (((iecbus.drv_data[unit] << 3) & 0x40)
                                            | ((iecbus.drv_data[unit] << 6)
                                               & ((~iecbus.drv_data[unit]
                                                   ^ iecbus.cpu_bus) << 3) & 0x80));
            }
        }
    }

    iec_update_ports();
}
Esempio n. 7
0
static void read_sdr(cia_context_t *cia_context)
{
    if (burst_mod == BURST_MOD_CIA2) {
        drivecpu_execute_all(maincpu_clk);
    }
    /* FIXME: in the upcomming userport system this call needs to be conditional */
    cia_context->c_cia[CIA_SDR] = userport_joystick_read_sdr(cia_context->c_cia[CIA_SDR]);
}
Esempio n. 8
0
/* Only the second drive is enabled.  */
static BYTE iecbus_cpu_read_conf2(CLOCK clock)
{
    drivecpu_execute_all(clock);

    DEBUG_IEC_CPU_READ(iecbus.cpu_port);

    return iecbus.cpu_port;
}
Esempio n. 9
0
static BYTE read_prb(via_context_t *via_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    byte = (parallel_bus & ~(via_context->via[VIA_DDRB]))
           | (via_context->via[VIA_PRB] & via_context->via[VIA_DDRB]);
    return byte;
}
Esempio n. 10
0
void parallel_cable_cpu_write(BYTE data)
{
    if (!(drive_context[0]->drive->enable)
        && !(drive_context[1]->drive->enable))
        return;

    drivecpu_execute_all(last_write_cycle);

    parallel_cable_cpu_value = data;
}
Esempio n. 11
0
BYTE parallel_cable_cpu_read(void)
{
    if (!(drive_context[0]->drive->enable)
        && !(drive_context[1]->drive->enable))
        return 0;

    drivecpu_execute_all(maincpu_clk);

    return parallel_cable_cpu_value & parallel_cable_drive_value[0]
        & parallel_cable_drive_value[1];
}
Esempio n. 12
0
static BYTE read_pb(tpi_context_t *tpi_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    byte = ieee_is_out ? 0xff : parallel_bus;
    byte = (byte & ~(tpi_context->c_tpi)[TPI_DDPB]) | (tpi_context->c_tpi[TPI_PB] & tpi_context->c_tpi[TPI_DDPB]);

    return byte;
}
Esempio n. 13
0
static BYTE read_pa(void)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    if (parallel_debug)
        log_message(mypia_log,
                "read pia2 port A %x, parallel_bus=%x, gives %x.",
                mypia.port_a, parallel_bus,
                ((parallel_bus & ~mypia.ddr_a)
                | (mypia.port_a & mypia.ddr_a)));

    byte = (parallel_bus & ~mypia.ddr_a) | (mypia.port_a & mypia.ddr_a);
    return byte;
}
Esempio n. 14
0
static BYTE read_prb(via_context_t *via_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    byte = 255
        - (parallel_atn  ? 0x80 : 0)
        - (parallel_ndac ? 0x40 : 0)
        - (parallel_nrfd ? 0x20 : 0)
        - (parallel_dav  ? 0x10 : 0)
        - (parallel_eoi  ? 0x08 : 0);

    /* none of the load changes output register value -> std. masking */
    byte = ((byte & ~(via_context->via[VIA_DDRB]))
           | (via_context->via[VIA_PRB] & via_context->via[VIA_DDRB]));
    return byte;
}
Esempio n. 15
0
static BYTE read_pa(tpi_context_t *tpi_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    byte = 0x07;
    byte += parallel_atn ? 0 : 8;
    byte += parallel_dav ? 0 : 16;
    byte += parallel_eoi ? 0 : 32;
    byte += parallel_ndac ? 0 : 64;
    byte += parallel_nrfd ? 0 : 128;

    byte = (byte & ~(tpi_context->c_tpi)[TPI_DDPA])
           | (tpi_context->c_tpi[TPI_PA] & tpi_context->c_tpi[TPI_DDPA]);

    return byte;
}
Esempio n. 16
0
static BYTE read_prb(via_context_t *via_context)
{
    BYTE byte;

    drivecpu_execute_all(maincpu_clk);

    /* read parallel IEC interface line states */
    byte = 255
           - (parallel_nrfd ? 64 : 0)
           - (parallel_ndac ? 1 : 0)
           - (parallel_dav ? 128 : 0);
    /* vertical retrace */
    byte -= crtc_offscreen() ? 32 : 0;

    /* none of the load changes output register value -> std. masking */
    byte = ((byte & ~(via_context->via[VIA_DDRB]))
            | (via_context->via[VIA_PRB] & via_context->via[VIA_DDRB]));
    return byte;
}
Esempio n. 17
0
static void iecbus_cpu_write_conf3(BYTE data, CLOCK clock)
{
    unsigned int dnr;

    drivecpu_execute_all(clock);
    serial_iec_device_exec(clock);

    iec_update_cpu_bus(data);

    if (iec_old_atn != (iecbus.cpu_bus & 0x10))
    {
        iec_old_atn = iecbus.cpu_bus & 0x10;

        for (dnr = 0; dnr < DRIVE_NUM; dnr++)
            if( iecbus_device[8+dnr] == IECBUS_DEVICE_TRUEDRIVE )
            {
                if (drive_context[dnr]->drive->type != DRIVE_TYPE_1581)
                    viacore_signal(drive_context[dnr]->via1d1541, VIA_SIG_CA1,
                                   iec_old_atn ? 0 : VIA_SIG_RISE);
                else if (!iec_old_atn)
                    ciacore_set_flag(drive_context[dnr]->cia1581);
            }
    }

    for (dnr = 0; dnr < DRIVE_NUM; dnr++)
        if( iecbus_device[8+dnr] == IECBUS_DEVICE_TRUEDRIVE )
        {
            unsigned int unit;
            unit = dnr + 8;
            if (drive_context[dnr]->drive->type != DRIVE_TYPE_1581)
                iecbus.drv_bus[unit] = (((iecbus.drv_data[unit] << 3) & 0x40)
                                        | ((iecbus.drv_data[unit] << 6)
                                           & ((~iecbus.drv_data[unit]
                                               ^ iecbus.cpu_bus) << 3) & 0x80));
            else
                iecbus.drv_bus[unit] = (((iecbus.drv_data[unit] << 3) & 0x40)
                                        | ((iecbus.drv_data[unit] << 6)
                                           & ((iecbus.drv_data[unit]
                                               | iecbus.cpu_bus) << 3) & 0x80));
        }

    iec_update_ports();
}
Esempio n. 18
0
static void read_sdr(cia_context_t *cia_context)
{
    drivecpu_execute_all(maincpu_clk);
}
Esempio n. 19
0
/* Only the first drive is enabled.  */
static BYTE iecbus_cpu_read_conf1(CLOCK clock)
{
    drivecpu_execute_all(clock);

    return iecbus.cpu_port;
}
Esempio n. 20
0
static void read_sdr(cia_context_t *cia_context)
{
    if (burst_mod == BURST_MOD_CIA1) {
        drivecpu_execute_all(maincpu_clk);
    }
}