Beispiel #1
0
/* FIXME: resetting the c64 should be handled in the upper layer */
static int set_mmc64_enabled(int val, void *param)
{
    LOG(("MMC64: set_enabled: '%s' %d to %d", mmc64_bios_filename, mmc64_enabled, val));
    if (!mmc64_enabled && val) {
        /* activate mmc64 */
        if (param) {
            /* if the param is != NULL, then we should load the default image file */
            LOG(("MMC64: set_enabled(1) '%s'", mmc64_bios_filename));
            if (mmc64_bios_filename) {
                if (*mmc64_bios_filename) {
                    if (cartridge_attach_image(CARTRIDGE_MMC64, mmc64_bios_filename) < 0) {
                        LOG(("MMC64: set_enabled(1) did not register"));
                        return -1;
                    }
                    /* mmc64_enabled = 1; */ /* cartridge_attach_image will end up calling set_mmc64_enabled again */
                    return 0;
                }
            }
        } else {
            LOG(("MMC64: set_enabled(0) '%s'", mmc64_bios_filename));
            cart_power_off();
            /* if the param is == NULL, then we should actually set the resource */
            if (c64export_add(&export_res) < 0) {
                LOG(("MMC64: set_enabled(0) did not register"));
                return -1;
            } else {
                LOG(("MMC64: set_enabled registered"));

                if (mmc64_activate() < 0) {
                    return -1;
                }
                mmc64_enabled = 1;
                cart_set_port_exrom_slot0(1);
                cart_port_config_changed_slot0();
                mmc64_clockport_list_item = io_source_register(mmc64_current_clockport_device);
                mmc64_io1_list_item = io_source_register(&mmc64_io1_device);
                mmc64_io2_list_item = io_source_register(&mmc64_io2_device);
                mmc64_reset();
            }
        }
    } else if (mmc64_enabled && !val) {
        /* remove mmc64 */
        if (mmc64_deactivate() < 0) {
            return -1;
        }
        cart_power_off();
        c64export_remove(&export_res);
        mmc64_enabled = 0;
        cart_set_port_exrom_slot0(0);
        cart_port_config_changed_slot0();
        io_source_unregister(mmc64_clockport_list_item);
        io_source_unregister(mmc64_io1_list_item);
        io_source_unregister(mmc64_io2_list_item);
        mmc64_clockport_list_item = NULL;
        mmc64_io1_list_item = NULL;
        mmc64_io2_list_item = NULL;
    }
    LOG(("MMC64: set_enabled done: '%s' %d : %d", mmc64_bios_filename, val, mmc64_enabled));
    return 0;
}
Beispiel #2
0
static int set_expert_enabled(int val, void *param)
{
    DBG(("EXPERT: set enabled: %d:%d\n", expert_enabled, val));

    if (expert_enabled && !val) {
        DBG(("EXPERT: disable\n"));
        if (expert_deactivate() < 0) {
            return -1;
        }
        io_source_unregister(expert_io1_list_item);
        expert_io1_list_item = NULL;
        c64export_remove(&export_res);
        expert_enabled = 0;
        cart_power_off();
    } else if (!expert_enabled && val) {
        DBG(("EXPERT: enable\n"));
        if (expert_activate() < 0) {
            return -1;
        }
        expert_io1_list_item = io_source_register(&expert_io1_device);
        if (c64export_add(&export_res) < 0) {
            DBG(("EXPERT: set enabled: error\n"));
            io_source_unregister(expert_io1_list_item);
            expert_io1_list_item = NULL;
            expert_enabled = 0;
            return -1;
        }
        expert_enabled = 1;
        resources_set_int("ExpertCartridgeMode", cartmode);
        cart_power_off();
    }
    
    return 0;
}
Beispiel #3
0
void megacart_detach(void)
{
    /* try to write back NvRAM contents if write back is enabled
       and cartridge is not from a snapshot */
    if (nvram_writeback && !cartridge_is_from_snapshot) {
        try_nvram_save(nvram_filename);
    }

    mem_cart_blocks = 0;
    mem_initialize_memory();
    lib_free(cart_ram);
    lib_free(cart_nvram);
    lib_free(cart_rom);
    cart_ram = NULL;
    cart_nvram = NULL;
    cart_rom = NULL;

    if (megacart_io2_list_item != NULL) {
        io_source_unregister(megacart_io2_list_item);
        megacart_io2_list_item = NULL;
    }

    if (megacart_io3_list_item != NULL) {
        io_source_unregister(megacart_io3_list_item);
        megacart_io3_list_item = NULL;
    }
}
Beispiel #4
0
void warpspeed_detach(void)
{
    c64export_remove(&export_res_warpspeed);
    io_source_unregister(warpspeed_io1_list_item);
    io_source_unregister(warpspeed_io2_list_item);
    warpspeed_io1_list_item = NULL;
    warpspeed_io2_list_item = NULL;
}
Beispiel #5
0
void ross_detach(void)
{
    export_remove(&export_res);
    io_source_unregister(ross_io1_list_item);
    io_source_unregister(ross_io2_list_item);
    ross_io1_list_item = NULL;
    ross_io2_list_item = NULL;
}
Beispiel #6
0
void mach5_detach(void)
{
    c64export_remove(&export_res);
    io_source_unregister(mach5_io1_list_item);
    io_source_unregister(mach5_io2_list_item);
    mach5_io1_list_item = NULL;
    mach5_io2_list_item = NULL;
}
Beispiel #7
0
void kcs_detach(void)
{
    c64export_remove(&export_res_kcs);
    io_source_unregister(kcs_io1_list_item);
    io_source_unregister(kcs_io2_list_item);
    kcs_io1_list_item = NULL;
    kcs_io2_list_item = NULL;
}
Beispiel #8
0
void freezemachine_detach(void)
{
    c64export_remove(&export_res);
    io_source_unregister(freezemachine_io1_list_item);
    io_source_unregister(freezemachine_io2_list_item);
    freezemachine_io1_list_item = NULL;
    freezemachine_io2_list_item = NULL;
}
Beispiel #9
0
void actionreplay2_detach(void)
{
    c64export_remove(&export_res);
    io_source_unregister(actionreplay2_io1_list_item);
    io_source_unregister(actionreplay2_io2_list_item);
    actionreplay2_io1_list_item = NULL;
    actionreplay2_io2_list_item = NULL;
}
Beispiel #10
0
void final_v1_detach(void)
{
    c64export_remove(&export_res_v1);
    io_source_unregister(final1_io1_list_item);
    io_source_unregister(final1_io2_list_item);
    final1_io1_list_item = NULL;
    final1_io2_list_item = NULL;
}
Beispiel #11
0
void epyxfastload_detach(void)
{
    alarm_destroy(epyxrom_alarm);
    c64export_remove(&export_res_epyx);
    io_source_unregister(epyxfastload_io1_list_item);
    io_source_unregister(epyxfastload_io2_list_item);
    epyxfastload_io1_list_item = NULL;
    epyxfastload_io2_list_item = NULL;
}
Beispiel #12
0
void c64io_vicii_deinit(void)
{
    if (vicii_d000_list_item != NULL) {
        io_source_unregister(vicii_d000_list_item);
        vicii_d000_list_item = NULL;
    }

    if (vicii_d100_list_item != NULL) {
        io_source_unregister(vicii_d100_list_item);
        vicii_d100_list_item = NULL;
    }
}
int set_cs256k_enabled(int value)
{
    int val = value ? 1 : 0;

    if (val == cs256k_enabled) {
        return 0;
    }

    if (!val) {
        if (cs256k_enabled) {
            if (cs256k_deactivate() < 0) {
                return -1;
            }
        }
        cs256k_enabled = 0;
        io_source_unregister(cs256k_list_item);
        cs256k_list_item = NULL;
        plus4_pio1_init(-1);
    } else {
        if (!cs256k_enabled) {
            if (cs256k_activate() < 0) {
                return -1;
            }
        }
        cs256k_enabled = 1;
        cs256k_list_item = io_source_register(&cs256k_device);
        plus4_pio1_init(1);
    }
    return 0;
}
static int set_sid_address(int val, void *param)
{
    switch (val) {
        case 0x8f00:
        case 0xe900:
            break;
        default:
            return -1;
    }

    if (sidcart_address == val) {
        return 0;
    }

    if (sidcart_sound_chip.chip_enabled) {
        io_source_unregister(sidcart_list_item);
        if (val == 0x8f00) {
            sidcart_list_item = io_source_register(&sidcart_8f00_device);
        } else {
            sidcart_list_item = io_source_register(&sidcart_e900_device);
        }
    }

    sidcart_address = val;

    return 0;
}
static int set_sidcart_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (val == sidcart_sound_chip.chip_enabled) {
        return 0;
    }

    if (val) {
        if (sidcart_address == 0x8f00) {
            sidcart_list_item = io_source_register(&sidcart_8f00_device);
        } else {
            sidcart_list_item = io_source_register(&sidcart_e900_device);
        }
    } else {
        io_source_unregister(sidcart_list_item);
        sidcart_list_item = NULL;
    }

    sidcart_sound_chip.chip_enabled = val;
#ifdef HAVE_RESID
    sid_set_enable(val);
#endif
    sound_state_changed = 1;

    return 0;
}
Beispiel #16
0
void cartio_shutdown(void)
{
    io_source_list_t *current;

    current = vic20io2_head.next;
    while (current) {
        io_source_unregister(current);
        current = vic20io2_head.next;
    }

    current = vic20io3_head.next;
    while (current) {
        io_source_unregister(current);
        current = vic20io3_head.next;
    }
}
static int set_ethernetcart_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (!val) {
        /* Ethernet Cart should be deactived */
        if (ethernetcart_enabled) {
            ethernetcart_enabled = 0;
            if (ethernetcart_deactivate() < 0) {
                return -1;
            }
            io_source_unregister(ethernetcart_list_item);
            ethernetcart_list_item = NULL;
            export_remove(&export_res);
        }
    } else {
        if (!ethernetcart_enabled) {
            if (ethernetcart_activate() < 0) {
                return -1;
            }
            export_res.io1 = &ethernetcart_device;
            if (export_add(&export_res) < 0) {
                return -1;
            }
            ethernetcart_enabled = 1;
            ethernetcart_list_item = io_source_register(&ethernetcart_device);
        }
    }
    return 0;
}
Beispiel #18
0
static void acia_disable(void)
{
    if (_acia_enabled) {
        io_source_unregister(acia_list_item);
        acia_list_item = NULL;
    }
}
Beispiel #19
0
static void debugcart_disable(void)
{
    /*cbm2export_remove(&export_res);*/
    fprintf(stdout, "DBGCART: disabled\n");
    io_source_unregister(debugcart_list_item);
    debugcart_list_item = NULL;
}
Beispiel #20
0
static int set_sfx_soundsampler_enabled(int val, void *param)
{
    if (sfx_soundsampler_sound_chip.chip_enabled != val) {
        if (val) {
            if (c64export_add(&export_res) < 0) {
                return -1;
            }
            if (machine_class == VICE_MACHINE_VIC20) {
                if (sfx_soundsampler_io_swap) {
                    sfx_soundsampler_device.start_address = 0x9c00;
                    sfx_soundsampler_device.end_address = 0x9fff;
                } else {
                    sfx_soundsampler_device.start_address = 0x9800;
                    sfx_soundsampler_device.end_address = 0x9bff;
                }
            }
            sfx_soundsampler_list_item = io_source_register(&sfx_soundsampler_device);
            sfx_soundsampler_sound_chip.chip_enabled = 1;
        } else {
            c64export_remove(&export_res);
            io_source_unregister(sfx_soundsampler_list_item);
            sfx_soundsampler_list_item = NULL;
            sfx_soundsampler_sound_chip.chip_enabled = 0;
        }
    }
    return 0;
}
static int set_digiblaster_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (digiblaster_sound_chip.chip_enabled == val) {
        return 0;
    }

    if (val) {
        if (sidcart_address == 0xfd40) {
            digiblaster_list_item = io_source_register(&digiblaster_fd5e_device);
        } else {
            digiblaster_list_item = io_source_register(&digiblaster_fe9e_device);
        }
        sampler_start(SAMPLER_OPEN_MONO, "DigiBlaster");
    } else {
        io_source_unregister(digiblaster_list_item);
        digiblaster_list_item = NULL;
        sampler_stop();
    }

    digiblaster_sound_chip.chip_enabled = val ? 1 : 0;

    return 0;
}
Beispiel #22
0
void easyflash_detach(void)
{
    if (easyflash_crt_write) {
        easyflash_flush_image();
    }
    flash040core_shutdown(easyflash_state_low);
    flash040core_shutdown(easyflash_state_high);
    lib_free(easyflash_state_low);
    lib_free(easyflash_state_high);
    lib_free(easyflash_filename);
    easyflash_filename = NULL;
    io_source_unregister(easyflash_io1_list_item);
    io_source_unregister(easyflash_io2_list_item);
    easyflash_io1_list_item = NULL;
    easyflash_io2_list_item = NULL;
    c64export_remove(&export_res);
}
static void sidcart_disable(void)
{
    if (sidcart_list_item != NULL) {
        export_remove(&export_res);
        io_source_unregister(sidcart_list_item);
        sidcart_list_item = NULL;
    }
}
Beispiel #24
0
void machine_sid2_enable(int val)
{
    if (stereo_sid_list_item != NULL) {
        io_source_unregister(stereo_sid_list_item);
        stereo_sid_list_item = NULL;
    }
    if (triple_sid_list_item != NULL) {
        io_source_unregister(triple_sid_list_item);
        triple_sid_list_item = NULL;
    }

    if (val >= 1) {
        stereo_sid_list_item = io_source_register(&stereo_sid_device);
    }
    if (val >= 2) {
        triple_sid_list_item = io_source_register(&triple_sid_device);
    }
}
void digiblaster_set_address(WORD addr)
{
    if (digiblaster_sound_chip.chip_enabled) {
        io_source_unregister(digiblaster_list_item);
        if (addr == 0xfd40) {
            digiblaster_list_item = io_source_register(&digiblaster_fd5e_device);
        } else {
            digiblaster_list_item = io_source_register(&digiblaster_fe9e_device);
        }
    }
}
Beispiel #26
0
static int set_ramcart_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (!ramcart_enabled && val) {
        cart_power_off();
        if (ramcart_activate() < 0) {
            return -1;
        }
        if (export_add(&export_res) < 0) {
            return -1;
        }
        ramcart_io1_list_item = io_source_register(&ramcart_io1_device);
        ramcart_io2_list_item = io_source_register(&ramcart_io2_device);
        ramcart_enabled = 1;
        if (machine_class == VICE_MACHINE_C128) {
            ramcart_exrom_check();
        } else {
            cart_set_port_exrom_slot1(1);
            cart_port_config_changed_slot1();
        }
    } else if (ramcart_enabled && !val) {
        cart_power_off();
        if (ramcart_deactivate() < 0) {
            return -1;
        }
        io_source_unregister(ramcart_io1_list_item);
        io_source_unregister(ramcart_io2_list_item);
        ramcart_io1_list_item = NULL;
        ramcart_io2_list_item = NULL;
        export_remove(&export_res);
        ramcart_enabled = 0;
        if (machine_class == VICE_MACHINE_C128) {
            ramcart_exrom_check();
        } else {
            cart_set_port_exrom_slot1(0);
            cart_port_config_changed_slot1();
        }
    }
    return 0;
}
Beispiel #27
0
void behrbonz_detach(void)
{
    mem_cart_blocks = 0;
    mem_initialize_memory();
    lib_free(cart_rom);
    cart_rom = NULL;

    export_remove(&export_res);
    if (behrbonz_io3_list_item != NULL) {
        io_source_unregister(behrbonz_io3_list_item);
        behrbonz_io3_list_item = NULL;
    }
}
Beispiel #28
0
static int set_tfe_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (!tfe_cannot_use) {
        if (!val) {
            /* TFE should be deactived */
            if (tfe_enabled) {
                tfe_enabled = 0;
                if (tfe_deactivate() < 0) {
                    DBG(("TFE: set disabled: error\n"));
                    return -1;
                }
                io_source_unregister(tfe_list_item);
                tfe_list_item = NULL;
                export_remove(&export_res);
            }
            tfe_clockport_changed();
            return 0;
        } else {
            if (!tfe_enabled) {
                tfe_enabled = 1;
                if (tfe_activate() < 0) {
                    return -1;
                }
                export_res.io1 = tfe_current_device;
                if (export_add(&export_res) < 0) {
                    DBG(("TFE: set enabled: error\n"));
                    tfe_list_item = NULL;
                    tfe_enabled = 0;
                    return -1;
                }
                if (machine_class == VICE_MACHINE_VIC20) {
                    /* set correct addresses for masC=uerade */
                    if (tfe_io_swap) {
                        tfe_current_device->start_address = 0x9c00;
                        tfe_current_device->end_address = 0x9fff;
                    } else {
                        tfe_current_device->start_address = 0x9800;
                        tfe_current_device->end_address = 0x9bff;
                    }
                }
                tfe_list_item = io_source_register(tfe_current_device);
            }
            tfe_clockport_changed();
            return 0;
        }
    }
    return 0;
}
Beispiel #29
0
int machine_sid3_check_range(unsigned int sid3_adr)
{
    if (machine_class == VICE_MACHINE_C128) {
        if ((sid3_adr >= 0xd400 && sid3_adr <= 0xd4e0) || (sid3_adr >= 0xd700 && sid3_adr <= 0xdfe0)) {
            sid_triple_address_start = sid3_adr;
            triple_sid_device.start_address = sid3_adr;
            sid_triple_address_end = sid3_adr + 0x1f;
            triple_sid_device.end_address = sid3_adr + 0x1f;
            if (triple_sid_list_item != NULL) {
                io_source_unregister(triple_sid_list_item);
                triple_sid_list_item = io_source_register(&triple_sid_device);
            } else {
                if (sid_stereo >= 2) {
                    triple_sid_list_item = io_source_register(&triple_sid_device);
                }
            }
            return 0;
        }
    } else {
        if (sid3_adr >= 0xd400 && sid3_adr <= 0xdfe0) {
            sid_triple_address_start = sid3_adr;
            triple_sid_device.start_address = sid3_adr;
            sid_triple_address_end = sid3_adr + 0x1f;
            triple_sid_device.end_address = sid3_adr + 0x1f;
            if (triple_sid_list_item != NULL) {
                io_source_unregister(triple_sid_list_item);
                triple_sid_list_item = io_source_register(&triple_sid_device);
            } else {
                if (sid_stereo >= 2) {
                    triple_sid_list_item = io_source_register(&triple_sid_device);
                }
            }
            return 0;
        }
    }
    return -1;
}
Beispiel #30
0
int expert_snapshot_read_module(snapshot_t *s)
{
    BYTE vmajor, vminor;
    snapshot_module_t *m;

    m = snapshot_module_open(s, SNAP_MODULE_NAME, &vmajor, &vminor);
    if (m == NULL) {
        return -1;
    }

    if ((vmajor != CART_DUMP_VER_MAJOR) || (vminor != CART_DUMP_VER_MINOR)) {
        snapshot_module_close(m);
        return -1;
    }

    expert_ram = lib_malloc(EXPERT_RAM_SIZE);

    if (0
        || (SMR_B_INT(m, &cartmode) < 0)
        || (SMR_B_INT(m, &expert_register_enabled) < 0)
        || (SMR_B_INT(m, &expert_ram_writeable) < 0)
        || (SMR_B_INT(m, &expert_ramh_enabled) < 0)
        || (SMR_BA(m, expert_ram, EXPERT_RAM_SIZE) < 0)) {
        snapshot_module_close(m);
        lib_free(expert_ram);
        expert_ram = NULL;
        return -1;
    }

    snapshot_module_close(m);

    expert_filetype = 0;
    expert_write_image = 0;
    expert_enabled = 1;

    /* FIXME: ugly code duplication to avoid cart_config_changed calls */
    expert_io1_list_item = io_source_register(&expert_io1_device);

    if (c64export_add(&export_res) < 0) {
        lib_free(expert_ram);
        expert_ram = NULL;
        io_source_unregister(expert_io1_list_item);
        expert_io1_list_item = NULL;
        expert_enabled = 0;
        return -1;
    }

    return 0;
}