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 = ðernetcart_device; if (export_add(&export_res) < 0) { return -1; } ethernetcart_enabled = 1; ethernetcart_list_item = io_source_register(ðernetcart_device); } } return 0; }
int vic_fp_bin_attach(const char *filename) { if (!cart_ram) { cart_ram = lib_malloc(CART_RAM_SIZE); } if (!cart_rom) { cart_rom = lib_malloc(CART_ROM_SIZE); } util_string_set(&cartfile, filename); if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { vic_fp_detach(); return -1; } if (export_add(&export_res) < 0) { return -1; } flash040core_init(&flash_state, maincpu_alarm_context, FLASH040_TYPE_032B_A0_1_SWAP, cart_rom); mem_cart_blocks = VIC_CART_RAM123 | VIC_CART_BLK1 | VIC_CART_BLK2 | VIC_CART_BLK3 | VIC_CART_BLK5 | VIC_CART_IO2; mem_initialize_memory(); vfp_list_item = io_source_register(&vfp_device); return 0; }
static int magicdesk_common_attach(void) { if (export_add(&export_res) < 0) { return -1; } magicdesk_list_item = io_source_register(&magicdesk_device); return 0; }
static int rex_common_attach(void) { if (export_add(&export_res_rex) < 0) { return -1; } rex_list_item = io_source_register(&rex_device); return 0; }
static int sidcart_enable(void) { if (export_add(&export_res) < 0) { return -1; } sidcart_list_item = io_source_register(&sidcart_device); return 0; }
static int simon_common_attach(void) { if (export_add(&export_res_simon) < 0) { return -1; } simon_list_item = io_source_register(&simon_device); return 0; }
static int acia1_enable(void) { if (export_add(&export_res) < 0) { return -1; } acia_list_item = io_source_register(&acia_device); return 0; }
static int ross_common_attach(void) { if (export_add(&export_res) < 0) { return -1; } ross_io1_list_item = io_source_register(&ross_io1_device); ross_io2_list_item = io_source_register(&ross_io2_device); return 0; }
static int freezemachine_common_attach(void) { if (export_add(&export_res) < 0) { return -1; } freezemachine_io1_list_item = io_source_register(&freezemachine_io1_device); freezemachine_io2_list_item = io_source_register(&freezemachine_io2_device); return 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; }
/** * export_create - create an in-core nfs_export record from an export entry * @xep: export entry to lookup * @canonical: if set, e_hostname is known to be canonical DNS name * * Returns a freshly instantiated export record, or NULL if * a problem occurred. */ nfs_export * export_create(struct exportent *xep, int canonical) { nfs_client *clp; nfs_export *exp; if (!(clp = client_lookup(xep->e_hostname, canonical))) { /* bad export entry; complaint already logged */ return NULL; } exp = (nfs_export *) xmalloc(sizeof(*exp)); export_init(exp, clp, xep); export_add(exp); return exp; }
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 (rrnetmk3_cart_enabled()) { tfe_current_device = &rrnet_io1_mk3_device; } } /* if adapter is already enabled then reset the LAN chip */ if (tfe_enabled) { io_source_unregister(tfe_list_item); export_remove(&export_res); export_res.io1 = tfe_current_device; if (export_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(); } }
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; }
static int set_ieee488_enabled(int value, void *param) { int val = value ? 1 : 0; if (!ieee488_enabled && val) { if (export_add(&export_res) < 0) { return -1; } ieee488_list_item = io_source_register(&ieee488_device); ieee488_enabled = 1; } else if (ieee488_enabled && !val) { export_remove(&export_res); io_source_unregister(ieee488_list_item); ieee488_list_item = NULL; ieee488_enabled = 0; } ui_update_menus(); return 0; }
int behrbonz_bin_attach(const char *filename) { if (!cart_rom) { cart_rom = lib_malloc(CART_ROM_SIZE); } if (zfile_load(filename, cart_rom, (size_t)CART_ROM_SIZE) < 0) { behrbonz_detach(); return -1; } if (export_add(&export_res) < 0) { return -1; } mem_cart_blocks = VIC_CART_BLK1 | VIC_CART_BLK2 | VIC_CART_BLK3 | VIC_CART_BLK5 | VIC_CART_IO3; mem_initialize_memory(); behrbonz_io3_list_item = io_source_register(&behrbonz_io3_device); return 0; }
int ramcart_snapshot_read_module(snapshot_t *s) { uint8_t vmajor, vminor; snapshot_module_t *m; m = snapshot_module_open(s, snap_module_name, &vmajor, &vminor); if (m == NULL) { return -1; } /* Do not accept versions higher than current */ if (vmajor > SNAP_MAJOR || vminor > SNAP_MINOR) { snapshot_set_error(SNAPSHOT_MODULE_HIGHER_VERSION); goto fail; } if (0 || (SMR_B_INT(m, &ramcart_enabled) < 0) || (SMR_B_INT(m, &ramcart_readonly) < 0) || (SMR_DW_INT(m, &ramcart_size) < 0) || (SMR_B_INT(m, &ramcart_size_kb) < 0) || (SMR_BA(m, ramcart, 2) < 0)) { goto fail; } ramcart_ram = lib_malloc(ramcart_size); if (SMR_BA(m, ramcart_ram, ramcart_size) < 0) { snapshot_module_close(m); lib_free(ramcart_ram); ramcart_ram = NULL; return -1; } snapshot_module_close(m); /* ramcart_filetype = 0; */ ramcart_write_image = 0; ramcart_enabled = 1; /* FIXME: ugly code duplication to avoid cart_config_changed calls */ ramcart_io1_list_item = io_source_register(&ramcart_io1_device); ramcart_io2_list_item = io_source_register(&ramcart_io2_device); if (export_add(&export_res) < 0) { lib_free(ramcart_ram); ramcart_ram = NULL; io_source_unregister(ramcart_io1_list_item); io_source_unregister(ramcart_io2_list_item); ramcart_io1_list_item = NULL; ramcart_io2_list_item = NULL; ramcart_enabled = 0; return -1; } return 0; fail: snapshot_module_close(m); return -1; }