示例#1
0
BYTE cartridge_read_ram123(WORD addr)
{
    switch (mem_cartridge_type) {
        case CARTRIDGE_VIC20_GENERIC:
            vic20_cpu_last_data = generic_ram123_read(addr);
            break;
        case CARTRIDGE_VIC20_UM:
            vic20_cpu_last_data = vic_um_ram123_read(addr);
            break;
        case CARTRIDGE_VIC20_FP:
            vic20_cpu_last_data = vic_fp_ram123_read(addr);
            break;
        case CARTRIDGE_VIC20_MEGACART:
            vic20_cpu_last_data = megacart_ram123_read(addr);
            break;
        case CARTRIDGE_VIC20_FINAL_EXPANSION:
            vic20_cpu_last_data = finalexpansion_ram123_read(addr);
            break;
        default:
            vic20_cpu_last_data = vic20_v_bus_last_data;
            break;
    }
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#2
0
static BYTE via_read(WORD addr)
{
    if ( (addr & 0x30) == 0x00 ) {  /* $910x (unconnected V-bus) */
        vic20_cpu_last_data = vic20_v_bus_last_data;
    } else {
        BYTE temp_bus = 0xff;

        if (addr & 0x10) {          /* $911x (VIA2) */
            temp_bus &= via2_read(addr);
        }
        if (addr & 0x20) {          /* $912x (VIA1) */
            temp_bus &= via1_read(addr);
        }
        vic20_cpu_last_data = temp_bus;
    }
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#3
0
static BYTE read_unconnected_v_bus(WORD addr)
{
    vic20_cpu_last_data = vic20_v_bus_last_data;
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#4
0
static BYTE chargen_read(WORD addr)
{
    vic20_cpu_last_data = vic20memrom_chargen_read(addr);
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#5
0
static BYTE ram_read_v_bus(WORD addr)
{
    vic20_cpu_last_data = mem_ram[addr];
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#6
0
BYTE zero_read(WORD addr)
{
    vic20_cpu_last_data = mem_ram[addr & 0xff];
    vic20_mem_v_bus_read(addr);
    return vic20_cpu_last_data;
}
示例#7
0
static inline BYTE io_read(io_source_list_t *list, WORD addr)
{
    io_source_list_t *current = list->next;
    int io_source_counter = 0;
    BYTE realval = 0;
    BYTE retval = 0;
    unsigned int lowest_order = 0xffffffff;

    while (current) {
        if (current->device->read != NULL) {
            if ((addr >= current->device->start_address) && (addr <= current->device->end_address)) {
                retval = current->device->read((WORD)(addr & current->device->address_mask));
                if (current->device->io_source_valid) {
                    if (current->device->io_source_prio == 1) {
                        return retval;
                    }
                    if (io_source_collision_handling == IO_COLLISION_METHOD_DETACH_LAST) {
                        if (current->device->order < lowest_order) {
                            lowest_order = current->device->order;
                            realval = retval;
                        }
                    }
                    if (io_source_collision_handling == IO_COLLISION_METHOD_AND_WIRES) {
                        realval &= retval;
                    }
                    if (current->device->io_source_prio != -1) {
                        io_source_counter++;
                    }
                }
            }
        }
        current = current->next;
    }

    if (io_source_counter == 0) {
        vic20_mem_v_bus_read(addr);
        return vic20_cpu_last_data;
    }

    if (io_source_counter == 1) {
        vic20_cpu_last_data = retval;
        vic20_mem_v_bus_read(addr);
        return vic20_cpu_last_data;
    }

    if (io_source_collision_handling == IO_COLLISION_METHOD_DETACH_ALL) {
        io_source_msg_detach_all(addr, io_source_counter, list);
        vic20_mem_v_bus_read(addr);
        return vic20_cpu_last_data;
    }

    if (io_source_collision_handling == IO_COLLISION_METHOD_DETACH_LAST) {
        io_source_msg_detach_last(addr, io_source_counter, list, lowest_order);
        vic20_cpu_last_data = realval;
        vic20_mem_v_bus_read(addr);
        return vic20_cpu_last_data;
    }

    if (io_source_collision_handling == IO_COLLISION_METHOD_AND_WIRES) {
        io_source_log_collisions(addr, io_source_counter, list);
        vic20_cpu_last_data = realval;
        vic20_mem_v_bus_read(addr);
        return vic20_cpu_last_data;
    }
    return vic20_cpu_last_data;
}