Example #1
0
static int warpspeed_common_attach(void)
{
    if (c64export_add(&export_res_warpspeed) < 0) {
        return -1;
    }

    warpspeed_io1_list_item = c64io_register(&warpspeed_io1_device);
    warpspeed_io2_list_item = c64io_register(&warpspeed_io2_device);

    return 0;
}
Example #2
0
File: stb.c Project: AreaScout/vice
static int stb_common_attach(void)
{
    /* add export */
    if (c64export_add(&export_res) < 0) {
        return -1;
    }

    stb_list_item = io_source_register(&stb_device);

    return 0;
}
Example #3
0
int actionreplay_bin_attach(const char *filename, BYTE *rawcart)
{
    if (util_file_load(filename, rawcart, 0x8000,
        UTIL_FILE_LOAD_SKIP_ADDRESS) < 0)
        return -1;

    if (c64export_add(&export_res) < 0)
        return -1;

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

    if (sfx_soundexpander_sound_chip.chip_enabled != val) {
        if (val) {
            if (c64export_add(&export_res_sound) < 0) {
                return -1;
            }
            if (c64export_add(&export_res_piano) < 0) {
                return -1;
            }
            if (machine_class == VICE_MACHINE_VIC20) {
                if (sfx_soundexpander_io_swap) {
                    sfx_soundexpander_sound_device.start_address = 0x9800;
                    sfx_soundexpander_sound_device.end_address = 0x9bff;
                    sfx_soundexpander_piano_device.start_address = 0x9800;
                    sfx_soundexpander_piano_device.end_address = 0x9bff;
                } else {
                    sfx_soundexpander_sound_device.start_address = 0x9c00;
                    sfx_soundexpander_sound_device.end_address = 0x9fff;
                    sfx_soundexpander_piano_device.start_address = 0x9c00;
                    sfx_soundexpander_piano_device.end_address = 0x9fff;
                }
            }
            sfx_soundexpander_sound_list_item = io_source_register(&sfx_soundexpander_sound_device);
            sfx_soundexpander_piano_list_item = io_source_register(&sfx_soundexpander_piano_device);
            sfx_soundexpander_sound_chip.chip_enabled = 1;
        } else {
            c64export_remove(&export_res_sound);
            c64export_remove(&export_res_piano);
            io_source_unregister(sfx_soundexpander_sound_list_item);
            io_source_unregister(sfx_soundexpander_piano_list_item);
            sfx_soundexpander_sound_list_item = NULL;
            sfx_soundexpander_piano_list_item = NULL;
            sfx_soundexpander_sound_chip.chip_enabled = 0;
        }
    }
    return 0;
}
Example #5
0
static int easyflash_common_attach(const char *filename)
{
    if (c64export_add(&export_res) < 0) {
        return -1;
    }

    easyflash_io1_list_item = io_source_register(&easyflash_io1_device);
    easyflash_io2_list_item = io_source_register(&easyflash_io2_device);

    easyflash_filename = lib_stralloc(filename);

    return 0;
}
Example #6
0
static int epyxfastload_common_attach(void)
{
    if (c64export_add(&export_res_epyx) < 0) {
        return -1;
    }

    epyxrom_alarm = alarm_new(maincpu_alarm_context, "EPYXCartRomAlarm", epyxfastload_alarm_handler, NULL);
    epyxrom_alarm_time = CLOCK_MAX;

    epyxfastload_io1_list_item = io_source_register(&epyxfastload_io1_device);
    epyxfastload_io2_list_item = io_source_register(&epyxfastload_io2_device);

    return 0;
}
Example #7
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;
                c64export_remove(&export_res);
            }
            return 0;
        } else {
            if (!tfe_enabled) {
                tfe_enabled = 1;
                if (tfe_activate() < 0) {
                    return -1;
                }
                export_res.io1 = tfe_current_device;
                if (c64export_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);
            }

            return 0;
        }
    }
    return 0;
}
Example #8
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;
}
Example #9
0
static int set_ramcart_enabled(int val, void *param)
{
	if(!ramcart_enabled && val)
	{
		cart_power_off();
		if (ramcart_activate() < 0)
			return -1;

		if (c64export_add(&export_res) < 0)
			return -1;

		ramcart_io1_list_item = c64io_register(&ramcart_io1_device);
		ramcart_io2_list_item = c64io_register(&ramcart_io2_device);
		ramcart_enabled = 1;
		/* FIXME */
		export.exrom = 1;
Example #10
0
static int set_sfx_soundsampler_enabled(int val, void *param)
{
    if (sfx_soundsampler_enabled != val) {
        if (val) {
            if (c64export_add(&export_res) < 0) {
                return -1;
            }
            sfx_soundsampler_list_item = c64io_register(&sfx_soundsampler_device);
            sfx_soundsampler_enabled = 1;
        } else {
            c64export_remove(&export_res);
            c64io_unregister(sfx_soundsampler_list_item);
            sfx_soundsampler_list_item = NULL;
            sfx_soundsampler_enabled = 0;
        }
    }
    return 0;
}
Example #11
0
void tfe_clockport_changed(void)
{
    if (!tfe_as_rr_net) {
        tfe_current_device = &tfe_io1_device;
    } else {
        tfe_current_device = &rrnet_io1_device;
        if (mmc64_cart_enabled() && (mmc64_hw_clockport == 0xde02) && mmc64_clockport_enabled) {
            tfe_current_device = &rrnet_io1_mmc64_device;
        }
        if (mmc64_cart_enabled() && (mmc64_hw_clockport == 0xdf12) && mmc64_clockport_enabled) {
            tfe_current_device = &rrnet_io2_mmc64_device;
        }
        if (retroreplay_cart_enabled() && rr_clockport_enabled) {
            tfe_current_device = &rrnet_io1_retroreplay_device;
        }
        if (mmcreplay_cart_enabled() && mmcr_clockport_enabled) {
            tfe_current_device = &rrnet_io1_mmcreplay_device;
        }
    }
    /* if adapter is already enabled then reset the LAN chip */
    if (tfe_enabled) {
        io_source_unregister(tfe_list_item);
        c64export_remove(&export_res);
        export_res.io1 = tfe_current_device;
        if (c64export_add(&export_res) < 0) {
            DBG(("TFE: set tfe_clockport_changed: error\n"));
            tfe_list_item = NULL;
            tfe_enabled = 0;
            return;
        }
        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_reset();
    }
}
Example #12
0
static int set_ds12c887rtc_enabled(int val, void *param)
{
    if (!ds12c887rtc_enabled && val) {
        if (c64export_add(&export_res) < 0) {
            return -1;
        }
        ds12c887rtc_list_item = io_source_register(&ds12c887rtc_device);
        ds12c887rtc_context = ds12c887_init((BYTE *)ds12c887rtc_ram, &ds12c887rtc_offset);
        ds12c887rtc_enabled = 1;
    } else if (ds12c887rtc_enabled && !val) {
        if (ds12c887rtc_list_item != NULL) {
            c64export_remove(&export_res);
            io_source_unregister(ds12c887rtc_list_item);
            ds12c887rtc_list_item = NULL;
            ds12c887_destroy(ds12c887rtc_context);
        }
        ds12c887rtc_enabled = 0;
    }
    return 0;
}
Example #13
0
int stardos_crt_attach(FILE *fd, BYTE *rawcart)
{
    BYTE chipheader[0x10];

    if (fread(chipheader, 0x10, 1, fd) < 1)
        return -1;

    if (fread(&rawcart[0x0000], 0x2000, 1, fd) < 1)
        return -1;

    if (fread(chipheader, 0x10, 1, fd) < 1)
        return -1;

    if (fread(&rawcart[0x2000], 0x2000, 1, fd) < 1)
        return -1;

    if (c64export_add(&export_res) < 0)
        return -1;

    return 0;
}
Example #14
0
int actionreplay_crt_attach(FILE *fd, BYTE *rawcart)
{
    BYTE chipheader[0x10];
    int i;

    for (i = 0; i <= 3; i++) {
        if (fread(chipheader, 0x10, 1, fd) < 1)
            return -1;

        if (chipheader[0xb] > 3)
            return -1;

        if (fread(&rawcart[chipheader[0xb] << 13], 0x2000, 1, fd) < 1)
            return -1;
    }

    if (c64export_add(&export_res) < 0)
        return -1;

    return 0;
}
Example #15
0
int comal80_crt_attach(FILE *fd, BYTE *rawcart)
{
    BYTE chipheader[0x10];

    while (1) {
        if (fread(chipheader, 0x10, 1, fd) < 1)
            break;

        if (chipheader[0xc] != 0x80 && chipheader[0xe] != 0x40
            && chipheader[0xb] > 3)
            return -1;

        if (fread(&rawcart[chipheader[0xb] << 14], 0x4000, 1, fd) < 1)
            return -1;
    }

    if (c64export_add(&export_res) < 0)
        return -1;

    return 0;
}
Example #16
0
static int set_digimax_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    if (!digimax_sound_chip.chip_enabled && val) {
        if (!digimax_is_userport()) {
            if (c64export_add(&export_res) < 0) {
                return -1;
            }
            digimax_list_item = io_source_register(&digimax_device);
        }
        digimax_sound_chip.chip_enabled = 1;
    } else if (digimax_sound_chip.chip_enabled && !val) {
        if (digimax_list_item != NULL) {
            c64export_remove(&export_res);
            io_source_unregister(digimax_list_item);
            digimax_list_item = NULL;
        }
        digimax_sound_chip.chip_enabled = 0;
    }
    return 0;
}
Example #17
0
static int set_sfx_soundsampler_enabled(int value, void *param)
{
    int val = value ? 1 : 0;

    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_io1_device.start_address = 0x9800;
                    sfx_soundsampler_io1_device.end_address = 0x9bff;
                    sfx_soundsampler_io2_device.start_address = 0x9c00;
                    sfx_soundsampler_io2_device.end_address = 0x9fff;
                } else {
                    sfx_soundsampler_io1_device.start_address = 0x9c00;
                    sfx_soundsampler_io1_device.end_address = 0x9fff;
                    sfx_soundsampler_io2_device.start_address = 0x9800;
                    sfx_soundsampler_io2_device.end_address = 0x9bff;
                }
            }
            sfx_soundsampler_io1_list_item = io_source_register(&sfx_soundsampler_io1_device);
            sfx_soundsampler_io2_list_item = io_source_register(&sfx_soundsampler_io2_device);
            sfx_soundsampler_sound_chip.chip_enabled = 1;
            sampler_start(SAMPLER_OPEN_MONO);
        } else {
            c64export_remove(&export_res);
            io_source_unregister(sfx_soundsampler_io1_list_item);
            io_source_unregister(sfx_soundsampler_io2_list_item);
            sfx_soundsampler_io1_list_item = NULL;
            sfx_soundsampler_io2_list_item = NULL;
            sfx_soundsampler_sound_chip.chip_enabled = 0;
            sampler_stop();
        }
    }
    return 0;
}