static int spec128_reset( void ) { int error; error = machine_load_rom( 0, 0, settings_current.rom_128_0, settings_default.rom_128_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 2, 1, settings_current.rom_128_1, settings_default.rom_128_1, 0x4000 ); if( error ) return error; error = periph_setup( spec128_peripherals, spec128_peripherals_count ); if( error ) return error; error = spec128_common_reset( 1 ); if( error ) return error; periph_setup_kempston( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface1( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_setup_plusd( PERIPH_PRESENT_OPTIONAL ); periph_setup_beta128( PERIPH_PRESENT_OPTIONAL ); periph_update(); periph_register_beta128(); beta_builtin = 0; return 0; }
static int specplus2_reset( void ) { int error; error = machine_load_rom( 0, settings_current.rom_plus2_0, settings_default.rom_plus2_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 1, settings_current.rom_plus2_1, settings_default.rom_plus2_1, 0x4000 ); if( error ) return error; error = spec128_common_reset( 1 ); if( error ) return error; periph_clear(); machines_periph_128(); periph_update(); beta_builtin = 0; spec48_common_display_setup(); return 0; }
static int spec48_reset( void ) { int error; error = machine_load_rom( 0, 0, settings_current.rom_48, settings_default.rom_48, 0x4000 ); if( error ) return error; error = periph_setup( peripherals, peripherals_count ); if( error ) return error; periph_setup_kempston( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface1( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_setup_plusd( PERIPH_PRESENT_OPTIONAL ); periph_setup_beta128( PERIPH_PRESENT_OPTIONAL ); periph_setup_fuller( PERIPH_PRESENT_OPTIONAL ); periph_setup_melodik( PERIPH_PRESENT_OPTIONAL ); periph_update(); periph_register_beta128(); beta_builtin = 0; memory_current_screen = 5; memory_screen_mask = 0xffff; return spec48_common_reset(); }
static int specplus3e_reset( void ) { int error; error = machine_load_rom( 0, settings_current.rom_plus3e_0, settings_default.rom_plus3e_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 1, settings_current.rom_plus3e_1, settings_default.rom_plus3e_1, 0x4000 ); if( error ) return error; error = machine_load_rom( 2, settings_current.rom_plus3e_2, settings_default.rom_plus3e_2, 0x4000 ); if( error ) return error; error = machine_load_rom( 3, settings_current.rom_plus3e_3, settings_default.rom_plus3e_3, 0x4000 ); if( error ) return error; error = specplus3_plus2a_common_reset(); if( error ) return error; periph_clear(); machines_periph_plus3(); periph_set_present( PERIPH_TYPE_UPD765, PERIPH_PRESENT_ALWAYS ); periph_update(); specplus3_765_reset(); specplus3_menu_items(); spec48_common_display_setup(); return 0; }
static int spec16_reset( void ) { int error; error = machine_load_rom( 0, settings_current.rom_16, settings_default.rom_16, 0x4000 ); if( error ) return error; ensure_empty_mapping(); periph_clear(); machines_periph_48(); periph_update(); /* The one RAM page is contended */ memory_ram_set_16k_contention( 5, 1 ); memory_map_16k( 0x0000, memory_map_rom, 0 ); memory_map_16k( 0x4000, memory_map_ram, 5 ); memory_map_16k( 0x8000, empty_mapping, 0 ); memory_map_16k( 0xc000, empty_mapping, 0 ); memory_current_screen = 5; memory_screen_mask = 0xffff; spec48_common_display_setup(); return 0; }
static int specplus2a_reset( void ) { int error; error = machine_load_rom( 0, 0, settings_current.rom_plus2a_0, settings_default.rom_plus2a_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 2, 1, settings_current.rom_plus2a_1, settings_default.rom_plus2a_1, 0x4000 ); if( error ) return error; error = machine_load_rom( 4, 2, settings_current.rom_plus2a_2, settings_default.rom_plus2a_2, 0x4000 ); if( error ) return error; error = machine_load_rom( 6, 3, settings_current.rom_plus2a_3, settings_default.rom_plus2a_3, 0x4000 ); if( error ) return error; error = specplus3_plus2a_common_reset(); if( error ) return error; error = periph_setup( peripherals, peripherals_count ); if( error ) return error; periph_setup_kempston( PERIPH_PRESENT_OPTIONAL ); periph_update(); return 0; }
static int tc2068_reset( void ) { size_t i, j; int error; error = machine_load_rom( 0, settings_current.rom_tc2068_0, settings_default.rom_tc2068_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 1, settings_current.rom_tc2068_1, settings_default.rom_tc2068_1, 0x2000 ); if( error ) return error; /* 0x0000: ROM 0 */ scld_home_map_16k( 0x0000, memory_map_rom, 0 ); /* 0x4000: RAM 5, contended */ memory_ram_set_16k_contention( 5, 1 ); scld_home_map_16k( 0x4000, memory_map_ram, 5 ); /* 0x8000: RAM 2, not contended */ memory_ram_set_16k_contention( 2, 0 ); scld_home_map_16k( 0x8000, memory_map_ram, 2 ); /* 0xc000: RAM 0, not contended */ memory_ram_set_16k_contention( 0, 0 ); scld_home_map_16k( 0xc000, memory_map_ram, 0 ); periph_clear(); machines_periph_timex(); periph_update(); for( i = 0; i < 8; i++ ) for( j = 0; j < MEMORY_PAGES_IN_8K; j++ ) { memory_page *dock_page, *exrom_page; dock_page = &timex_dock[i * MEMORY_PAGES_IN_8K + j]; *dock_page = tc2068_empty_mapping[j]; dock_page->page_num = i; exrom_page = &timex_exrom[i * MEMORY_PAGES_IN_8K + j]; *exrom_page = memory_map_rom[MEMORY_PAGES_IN_16K + j]; exrom_page->source = memory_source_exrom; exrom_page->page_num = i; } tc2068_tc2048_common_reset(); error = dck_reset(); if( error ) { ui_error( UI_ERROR_INFO, "Ignoring Timex dock file '%s'", settings_current.dck_file ); } return 0; }
static int pentagon_reset(void) { int error; int i; error = machine_load_rom( 0, 0, settings_current.rom_pentagon512_0, settings_default.rom_pentagon512_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 2, 1, settings_current.rom_pentagon512_1, settings_default.rom_pentagon512_1, 0x4000 ); if( error ) return error; error = machine_load_rom( 4, 2, settings_current.rom_pentagon512_3, settings_default.rom_pentagon512_3, 0x4000 ); if( error ) return error; error = machine_load_rom_bank( beta_memory_map_romcs, 0, 0, settings_current.rom_pentagon512_2, settings_default.rom_pentagon512_2, 0x4000 ); if( error ) return error; error = spec128_common_reset( 0 ); if( error ) return error; error = periph_setup( pentagon_peripherals, pentagon_peripherals_count ); if( error ) return error; periph_setup_kempston( PERIPH_PRESENT_OPTIONAL ); periph_setup_beta128( PERIPH_PRESENT_ALWAYS ); periph_update(); beta_builtin = 1; beta_active = 1; machine_current->ram.last_byte2 = 0; machine_current->ram.special = 0; /* Mark the least 384K as present/writeable */ for( i = 16; i < 64; i++ ) memory_map_ram[i].writable = 1; spec48_common_display_setup(); return 0; }
static int spec48_ntsc_reset( void ) { int error; error = machine_load_rom( 0, settings_current.rom_48, settings_default.rom_48, 0x4000 ); if( error ) return error; periph_clear(); machines_periph_48(); periph_update(); memory_current_screen = 5; memory_screen_mask = 0xffff; spec48_common_display_setup(); return spec48_common_reset(); }
static int tc2068_reset( void ) { size_t i; int error; error = machine_load_rom( 0, 0, settings_current.rom_tc2068_0, settings_default.rom_tc2068_0, 0x4000 ); if( error ) return error; error = machine_load_rom( 2, -1, settings_current.rom_tc2068_1, settings_default.rom_tc2068_1, 0x2000 ); if( error ) return error; error = periph_setup( tc2068_peripherals, tc2068_peripherals_count ); if( error ) return error; periph_setup_kempston( PERIPH_PRESENT_OPTIONAL ); periph_setup_interface2( PERIPH_PRESENT_OPTIONAL ); periph_update(); for( i = 0; i < 8; i++ ) { timex_dock[i] = fake_mapping; timex_dock[i].page_num = i; memory_map_dock[i] = &timex_dock[i]; timex_exrom[i] = memory_map_rom[2]; timex_exrom[i].bank = MEMORY_BANK_EXROM; timex_exrom[i].page_num = i; memory_map_exrom[i] = &timex_exrom[i]; } error = dck_reset(); if( error ) { ui_error( UI_ERROR_INFO, "Ignoring Timex dock file '%s'", settings_current.dck_file ); } return tc2068_tc2048_common_reset(); }
static int tc2048_reset( void ) { size_t i, j; int error; error = machine_load_rom( 0, settings_current.rom_tc2048, settings_default.rom_tc2048, 0x4000 ); if( error ) return error; /* 0x0000: ROM 0 */ scld_home_map_16k( 0x0000, memory_map_rom, 0 ); /* 0x4000: RAM 5, contended */ memory_ram_set_16k_contention( 5, 1 ); scld_home_map_16k( 0x4000, memory_map_ram, 5 ); /* 0x8000: RAM 2, not contended */ memory_ram_set_16k_contention( 2, 0 ); scld_home_map_16k( 0x8000, memory_map_ram, 2 ); /* 0xc000: RAM 0, not contended */ memory_ram_set_16k_contention( 0, 0 ); scld_home_map_16k( 0xc000, memory_map_ram, 0 ); periph_clear(); machines_periph_48(); /* ULA uses full decoding */ periph_set_present( PERIPH_TYPE_ULA, PERIPH_PRESENT_NEVER ); periph_set_present( PERIPH_TYPE_ULA_FULL_DECODE, PERIPH_PRESENT_ALWAYS ); /* As does the ZX Printer */ periph_set_present( PERIPH_TYPE_ZXPRINTER, PERIPH_PRESENT_NEVER ); periph_set_present( PERIPH_TYPE_ZXPRINTER_FULL_DECODE, PERIPH_PRESENT_OPTIONAL ); /* SCLD always present */ periph_set_present( PERIPH_TYPE_SCLD, PERIPH_PRESENT_ALWAYS ); /* TC2048 has a built-in Kempston joystick, which uses the "loose" decoding */ periph_set_present( PERIPH_TYPE_KEMPSTON, PERIPH_PRESENT_NEVER ); periph_set_present( PERIPH_TYPE_KEMPSTON_LOOSE, PERIPH_PRESENT_ALWAYS ); /* SpeccyBoot doesn't seem to work on the TC2048 */ periph_set_present( PERIPH_TYPE_SPECCYBOOT, PERIPH_PRESENT_NEVER ); periph_update(); beta_builtin = 0; for( i = 0; i < 8; i++ ) for( j = 0; j < MEMORY_PAGES_IN_8K; j++ ) { memory_page *dock_page, *exrom_page; dock_page = &timex_dock[i * MEMORY_PAGES_IN_8K + j]; *dock_page = tc2068_empty_mapping[j]; dock_page->page_num = i; exrom_page = &timex_exrom[i * MEMORY_PAGES_IN_8K + j]; *exrom_page = tc2068_empty_mapping[j]; exrom_page->page_num = i; } tc2068_tc2048_common_reset(); return 0; }
/* Open `filename' and do something sensible with it; autoload tapes if `autoload' is true and return the type of file found in `type' */ int utils_open_file( const char *filename, int autoload, libspectrum_id_t *type_ptr) { utils_file file; libspectrum_id_t type; libspectrum_class_t class; int error; error = 0; if( rzx_recording ) error = rzx_stop_recording(); if( rzx_playback ) error = rzx_stop_playback( 1 ); if( error ) return error; /* Read the file into a buffer */ if( utils_read_file( filename, &file ) ) return 1; /* See if we can work out what it is */ if( libspectrum_identify_file_with_class( &type, &class, filename, file.buffer, file.length ) ) { utils_close_file( &file ); return 1; } switch( class ) { case LIBSPECTRUM_CLASS_UNKNOWN: ui_error( UI_ERROR_ERROR, "utils_open_file: couldn't identify `%s'", filename ); utils_close_file( &file ); return 1; case LIBSPECTRUM_CLASS_RECORDING: error = rzx_start_playback_from_buffer( file.buffer, file.length ); break; case LIBSPECTRUM_CLASS_SNAPSHOT: error = snapshot_read_buffer( file.buffer, file.length, type ); pokemem_find_pokfile( filename ); break; case LIBSPECTRUM_CLASS_TAPE: error = tape_read_buffer( file.buffer, file.length, type, filename, autoload ); pokemem_find_pokfile( filename ); break; case LIBSPECTRUM_CLASS_DISK_PLUS3: if( !( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_PLUS3_DISK ) ) { error = machine_select( LIBSPECTRUM_MACHINE_PLUS3 ); if( error ) break; } error = specplus3_disk_insert( SPECPLUS3_DRIVE_A, filename, autoload ); break; case LIBSPECTRUM_CLASS_DISK_DIDAKTIK: error = didaktik80_disk_insert( DIDAKTIK80_DRIVE_A, filename, autoload ); break; case LIBSPECTRUM_CLASS_DISK_PLUSD: if( periph_is_active( PERIPH_TYPE_DISCIPLE ) ) error = disciple_disk_insert( DISCIPLE_DRIVE_1, filename, autoload ); else error = plusd_disk_insert( PLUSD_DRIVE_1, filename, autoload ); break; case LIBSPECTRUM_CLASS_DISK_OPUS: error = opus_disk_insert( OPUS_DRIVE_1, filename, autoload ); break; case LIBSPECTRUM_CLASS_DISK_TRDOS: if( !( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TRDOS_DISK ) && !periph_is_active( PERIPH_TYPE_BETA128 ) ) { error = machine_select( LIBSPECTRUM_MACHINE_PENT ); if( error ) break; } /* Check that we actually got a Beta capable machine to insert the disk */ if( ( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TRDOS_DISK ) || periph_is_active( PERIPH_TYPE_BETA128 ) ) { error = beta_disk_insert( BETA_DRIVE_A, filename, autoload ); } break; case LIBSPECTRUM_CLASS_DISK_GENERIC: if( machine_current->machine == LIBSPECTRUM_MACHINE_PLUS3 || machine_current->machine == LIBSPECTRUM_MACHINE_PLUS2A ) error = specplus3_disk_insert( SPECPLUS3_DRIVE_A, filename, autoload ); else if( machine_current->machine == LIBSPECTRUM_MACHINE_PENT || machine_current->machine == LIBSPECTRUM_MACHINE_PENT512 || machine_current->machine == LIBSPECTRUM_MACHINE_PENT1024 || machine_current->machine == LIBSPECTRUM_MACHINE_SCORP ) error = beta_disk_insert( BETA_DRIVE_A, filename, autoload ); else if( periph_is_active( PERIPH_TYPE_BETA128 ) ) error = beta_disk_insert( BETA_DRIVE_A, filename, autoload ); else if( periph_is_active( PERIPH_TYPE_DISCIPLE ) ) error = disciple_disk_insert( DISCIPLE_DRIVE_1, filename, autoload ); else if( periph_is_active( PERIPH_TYPE_PLUSD ) ) error = plusd_disk_insert( PLUSD_DRIVE_1, filename, autoload ); break; case LIBSPECTRUM_CLASS_CARTRIDGE_IF2: error = if2_insert( filename ); break; case LIBSPECTRUM_CLASS_MICRODRIVE: error = if1_mdr_insert( -1, filename ); break; case LIBSPECTRUM_CLASS_CARTRIDGE_TIMEX: if( !( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK ) ) { error = machine_select( LIBSPECTRUM_MACHINE_TC2068 ); if( error ) break; } /* Check that we actually got a Dock capable machine to insert the cart */ if( machine_current->capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK ) { error = dck_insert( filename ); } break; case LIBSPECTRUM_CLASS_HARDDISK: if( !settings_current.simpleide_active && !settings_current.zxatasp_active && !settings_current.divide_enabled && !settings_current.zxcf_active ) { settings_current.zxcf_active = 1; periph_update(); } if( settings_current.zxcf_active ) { error = zxcf_insert( filename ); } else if( settings_current.zxatasp_active ) { error = zxatasp_insert( filename, LIBSPECTRUM_IDE_MASTER ); } else if( settings_current.simpleide_active ) { error = simpleide_insert( filename, LIBSPECTRUM_IDE_MASTER ); } else { error = divide_insert( filename, LIBSPECTRUM_IDE_MASTER ); } if( error ) return error; break; case LIBSPECTRUM_CLASS_AUXILIARY: if( type == LIBSPECTRUM_ID_AUX_POK ) { ui_pokemem_selector( filename ); } break; default: ui_error( UI_ERROR_ERROR, "utils_open_file: unknown class %d", type ); error = 1; break; } if( error ) { utils_close_file( &file ); return error; } utils_close_file( &file ); if( type_ptr ) *type_ptr = type; return 0; }