/* * Determines the save name for the specified rom file * * romfile The name of the rom file * buffer The buffer to write the save name to */ extern "C" void wii_snapshot_handle_get_name( const char *romfile, char *buffer ) { char filename[WII_MAX_PATH]; Util_splitpath( romfile, NULL, filename ); snprintf( buffer, WII_MAX_PATH, "%s%s.%s", wii_get_saves_dir(), filename, WII_SAVE_GAME_EXT ); }
/* * Starts the emulator for the specified snapshot file. * * savefile The name of the save file to load. */ BOOL wii_start_snapshot( char *savefile ) { BOOL succeeded = FALSE; BOOL seterror = FALSE; // Determine the extension char ext[WII_MAX_PATH]; Util_getextension( savefile, ext ); if( !strcmp( ext, WII_SAVE_GAME_EXT ) ) { char savename[WII_MAX_PATH]; // Get the save name (without extension) Util_splitpath( savefile, NULL, savename ); int namelen = strlen( savename ); int extlen = strlen( WII_SAVE_GAME_EXT ); if( namelen > extlen ) { // build the associated rom name savename[namelen - extlen - 1] = '\0'; char romfile[WII_MAX_PATH]; snprintf( romfile, WII_MAX_PATH, "%s%s", wii_get_roms_dir(), savename ); int exists = Util_fileexists( romfile ); // Ensure the rom exists if( !exists ) { wii_set_status_message( "Unable to find associated ROM file." ); seterror = TRUE; } else { // launch the emulator for the save wii_start_emulation( romfile, savefile ); succeeded = TRUE; } } } if( !succeeded && !seterror ) { wii_set_status_message( "The file selected is not a valid saved state file." ); } return succeeded; }
int Atari800_Initialise(int *argc, char *argv[]) { int i, j; const char *rom_filename = NULL; const char *rom2_filename = NULL; const char *run_direct = NULL; #ifndef BASIC const char *state_file = NULL; #endif #ifdef __PLUS /* Atari800Win PLus doesn't use configuration files, it reads configuration from the Registry */ #ifndef _WX_ int bUpdateRegistry = (*argc > 1); #endif int bTapeFile = FALSE; int nCartType = CARTRIDGE_type; /* It is necessary because of the CARTRIDGE_Start (there must not be the registry-read value available at startup) */ CARTRIDGE_type = CARTRIDGE_NONE; #ifndef _WX_ /* Print the time info in the "Log file" window */ Misc_PrintTime(); /* Force screen refreshing */ g_nTestVal = _GetRefreshRate() - 1; g_ulAtariState = ATARI_UNINITIALIZED; #endif /* _WX_ */ #elif defined(MACOSX) #else /* __PLUS */ const char *rtconfig_filename = NULL; int got_config; int help_only = FALSE; if (*argc > 1) { for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-config") == 0) { rtconfig_filename = argv[++i]; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "-version") == 0 || strcmp(argv[i], "--version") == 0) { printf("%s\n", Atari800_TITLE); return FALSE; } else if (strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "--help") == 0) { argv[j++] = "-help"; } else if (strcmp(argv[i], "-verbose") == 0) { verbose = TRUE; } else { argv[j++] = argv[i]; } } *argc = j; } got_config = CFG_LoadConfig(rtconfig_filename); /* try to find ROM images if the configuration file is not found or it does not specify some ROM paths (blank paths count as specified) */ CFG_FindROMImages("", TRUE); /* current directory */ #if defined(unix) || defined(__unix__) || defined(__linux__) CFG_FindROMImages("/usr/share/atari800", TRUE); #endif if (*argc > 0 && argv[0] != NULL) { char atari800_exe_dir[FILENAME_MAX]; char atari800_exe_rom_dir[FILENAME_MAX]; /* the directory of the Atari800 program */ Util_splitpath(argv[0], atari800_exe_dir, NULL); CFG_FindROMImages(atari800_exe_dir, TRUE); /* "rom" and "ROM" subdirectories of this directory */ Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "rom"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); /* skip "ROM" on systems that are known to be case-insensitive */ #if !defined(DJGPP) && !defined(WIN32) Util_catpath(atari800_exe_rom_dir, atari800_exe_dir, "ROM"); CFG_FindROMImages(atari800_exe_rom_dir, TRUE); #endif } /* finally if nothing is found, set some defaults to make the configuration file easier to edit */ if (Util_filenamenotset(CFG_osa_filename)) strcpy(CFG_osa_filename, "atariosa.rom"); if (Util_filenamenotset(CFG_osb_filename)) strcpy(CFG_osb_filename, "atariosb.rom"); if (Util_filenamenotset(CFG_xlxe_filename)) strcpy(CFG_xlxe_filename, "atarixl.rom"); if (Util_filenamenotset(CFG_5200_filename)) strcpy(CFG_5200_filename, "5200.rom"); if (Util_filenamenotset(CFG_basic_filename)) strcpy(CFG_basic_filename, "ataribas.rom"); /* if no configuration file read, try to save one with the defaults */ if (!got_config) CFG_WriteConfig(); #endif /* __PLUS */ for (i = j = 1; i < *argc; i++) { if (strcmp(argv[i], "-atari") == 0) { if (Atari800_machine_type != Atari800_MACHINE_OSA) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } } else if (strcmp(argv[i], "-xl") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 64; } else if (strcmp(argv[i], "-xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = 128; } else if (strcmp(argv[i], "-320xe") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_COMPY_SHOP; } else if (strcmp(argv[i], "-rambo") == 0) { Atari800_machine_type = Atari800_MACHINE_XLXE; MEMORY_ram_size = MEMORY_RAM_320_RAMBO; } else if (strcmp(argv[i], "-5200") == 0) { Atari800_machine_type = Atari800_MACHINE_5200; MEMORY_ram_size = 16; } else if (strcmp(argv[i], "-nobasic") == 0) Atari800_disable_basic = TRUE; else if (strcmp(argv[i], "-basic") == 0) Atari800_disable_basic = FALSE; else if (strcmp(argv[i], "-nopatch") == 0) ESC_enable_sio_patch = FALSE; else if (strcmp(argv[i], "-nopatchall") == 0) #ifdef D_PATCH ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_d_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #else ESC_enable_sio_patch = Devices_enable_h_patch = Devices_enable_p_patch = Devices_enable_r_patch = FALSE; #endif else if (strcmp(argv[i], "-pal") == 0) Atari800_tv_mode = Atari800_TV_PAL; else if (strcmp(argv[i], "-ntsc") == 0) Atari800_tv_mode = Atari800_TV_NTSC; else if (strcmp(argv[i], "-a") == 0) { Atari800_machine_type = Atari800_MACHINE_OSA; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-b") == 0) { Atari800_machine_type = Atari800_MACHINE_OSB; MEMORY_ram_size = 48; } else if (strcmp(argv[i], "-emuos") == 0) emuos_mode = 2; else if (strcmp(argv[i], "-c") == 0) { if (MEMORY_ram_size == 48) MEMORY_ram_size = 52; } else { /* parameters that take additional argument follow here */ int i_a = (i + 1 < *argc); /* is argument available? */ int a_m = FALSE; /* error, argument missing! */ if (strcmp(argv[i], "-osa_rom") == 0) { if (i_a) Util_strlcpy(CFG_osa_filename, argv[++i], sizeof(CFG_osa_filename)); else a_m = TRUE; } #if 0 /* TBD what to do with R device */ #ifdef R_IO_DEVICE else if (strcmp(argv[i], "-rdevice") == 0) { Devices_enable_r_patch = TRUE; #ifdef R_SERIAL if (i_a && i + 2 < *argc && *argv[i + 1] != '-') { /* optional serial device name */ struct stat statbuf; if (! stat(argv[i + 1], &statbuf)) { if (S_ISCHR(statbuf.st_mode)) { /* only accept devices as serial device */ Util_strlcpy(RDevice_serial_device, argv[++i], FILENAME_MAX); RDevice_serial_enabled = TRUE; } } } #endif /* R_SERIAL */ } #endif #endif else if (strcmp(argv[i], "-osb_rom") == 0) { if (i_a) Util_strlcpy(CFG_osb_filename, argv[++i], sizeof(CFG_osb_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-xlxe_rom") == 0) { if (i_a) Util_strlcpy(CFG_xlxe_filename, argv[++i], sizeof(CFG_xlxe_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-5200_rom") == 0) { if (i_a) Util_strlcpy(CFG_5200_filename, argv[++i], sizeof(CFG_5200_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-basic_rom") == 0) { if (i_a) Util_strlcpy(CFG_basic_filename, argv[++i], sizeof(CFG_basic_filename)); else a_m = TRUE; } else if (strcmp(argv[i], "-cart") == 0) { if (i_a) rom_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-cart2") == 0) { if (i_a) rom2_filename = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-run") == 0) { if (i_a) run_direct = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-mosaic") == 0) { int total_ram = Util_sscandec(argv[++i]); MEMORY_mosaic_enabled = TRUE; MEMORY_mosaic_maxbank = (total_ram - 48)/4 - 1; if (((total_ram - 48) % 4 != 0) || (MEMORY_mosaic_maxbank > 0x3e) || (MEMORY_mosaic_maxbank < 0)) { Log_print("Invalid Mosaic total RAM size"); return FALSE; } if (MEMORY_axlon_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } } else if (strcmp(argv[i], "-axlon") == 0) { int total_ram = Util_sscandec(argv[++i]); int banks = ((total_ram) - 32) / 16; MEMORY_axlon_enabled = TRUE; if (((total_ram - 32) % 16 != 0) || ((banks != 8) && (banks != 16) && (banks != 32) && (banks != 64) && (banks != 128) && (banks != 256))) { Log_print("Invalid Axlon total RAM size"); return FALSE; } if (MEMORY_mosaic_enabled) { Log_print("Axlon and Mosaic can not both be enabled, because they are incompatible"); return FALSE; } MEMORY_axlon_bankmask = banks - 1; } else if (strcmp(argv[i], "-axlon0f") == 0) { MEMORY_axlon_0f_mirror = TRUE; } #ifndef BASIC /* The BASIC version does not support state files, because: 1. It has no ability to save state files, because of lack of UI. 2. It uses a simplified emulation, so the state files would be incompatible with other versions. 3. statesav is not compiled in to make the executable smaller. */ else if (strcmp(argv[i], "-state") == 0) { if (i_a) state_file = argv[++i]; else a_m = TRUE; } else if (strcmp(argv[i], "-refresh") == 0) { if (i_a) { Atari800_refresh_rate = Util_sscandec(argv[++i]); if (Atari800_refresh_rate < 1) { Log_print("Invalid refresh rate, using 1"); Atari800_refresh_rate = 1; } } else a_m = TRUE; } #endif /* BASIC */ #ifdef STEREO_SOUND else if (strcmp(argv[i], "-stereo") == 0) { POKEYSND_stereo_enabled = TRUE; } else if (strcmp(argv[i], "-nostereo") == 0) { POKEYSND_stereo_enabled = FALSE; } #endif /* STEREO_SOUND */ else { /* all options known to main module tried but none matched */ if (strcmp(argv[i], "-help") == 0) { #if !defined(__PLUS) && !defined(MACOSX) help_only = TRUE; Log_print("\t-config <file> Specify Alternate Configuration File"); #endif Log_print("\t-atari Emulate Atari 800"); Log_print("\t-xl Emulate Atari 800XL"); Log_print("\t-xe Emulate Atari 130XE"); Log_print("\t-320xe Emulate Atari 320XE (COMPY SHOP)"); Log_print("\t-rambo Emulate Atari 320XE (RAMBO)"); Log_print("\t-5200 Emulate Atari 5200 Games System"); Log_print("\t-nobasic Turn off Atari BASIC ROM"); Log_print("\t-basic Turn on Atari BASIC ROM"); Log_print("\t-pal Enable PAL TV mode"); Log_print("\t-ntsc Enable NTSC TV mode"); Log_print("\t-osa_rom <file> Load OS A ROM from file"); Log_print("\t-osb_rom <file> Load OS B ROM from file"); Log_print("\t-xlxe_rom <file> Load XL/XE ROM from file"); Log_print("\t-5200_rom <file> Load 5200 ROM from file"); Log_print("\t-basic_rom <fil> Load BASIC ROM from file"); Log_print("\t-cart <file> Install cartridge (raw or CART format)"); Log_print("\t-run <file> Run Atari program (COM, EXE, XEX, BAS, LST)"); #ifndef BASIC Log_print("\t-state <file> Load saved-state file"); Log_print("\t-refresh <rate> Specify screen refresh rate"); #endif Log_print("\t-nopatch Don't patch SIO routine in OS"); Log_print("\t-nopatchall Don't patch OS at all, H: device won't work"); Log_print("\t-a Use OS A"); Log_print("\t-b Use OS B"); Log_print("\t-c Enable RAM between 0xc000 and 0xcfff in Atari 800"); Log_print("\t-axlon <n> Use Atari 800 Axlon memory expansion: <n> k total RAM"); Log_print("\t-axlon0f Use Axlon shadow at 0x0fc0-0x0fff"); Log_print("\t-mosaic <n> Use 400/800 Mosaic memory expansion: <n> k total RAM"); #ifdef R_IO_DEVICE Log_print("\t-rdevice [<dev>] Enable R: emulation (using serial device <dev>)"); #endif Log_print("\t-v Show version/release number"); } /* copy this option for platform/module specific evaluation */ argv[j++] = argv[i]; } /* this is the end of the additional argument check */ if (a_m) { printf("Missing argument for '%s'\n", argv[i]); return FALSE; } } }
/* * React to the "select" event for the specified node * * node The node */ void wii_menu_handle_select_node( TREENODE *node ) { char buff[WII_MAX_PATH]; Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { emu->getMenuManager().selectNode( node ); } if( node->node_type == NODETYPE_ROM || node->node_type == NODETYPE_RESUME || node->node_type == NODETYPE_LOAD_STATE || node->node_type == NODETYPE_RESET ) { // Essentially blanks the screen //wii_gx_push_callback( NULL, FALSE, NULL ); switch( node->node_type ) { case NODETYPE_LOAD_STATE: wii_start_snapshot(); break; case NODETYPE_ROM: snprintf( buff, sizeof(buff), "%s%s", wii_get_roms_dir(), node->name ); last_rom_index = wii_menu_get_current_index(); loading_game = TRUE; wii_start_emulation( buff, "", false, false ); loading_game = FALSE; break; case NODETYPE_RESUME: wii_resume_emulation(); break; case NODETYPE_RESET: wii_reset_emulation(); break; default: /* do nothing */ break; } //wii_gx_pop_callback(); } else { LOCK_RENDER_MUTEX(); switch( node->node_type ) { case NODETYPE_VOLUME: wii_volume += 10; if( wii_volume > 150 ) { wii_volume = 0; } break; case NODETYPE_SAVE_STATE: wii_save_snapshot( NULL, TRUE ); break; case NODETYPE_CARTRIDGE_SAVE_STATES_SLOT: wii_snapshot_next(); break; case NODETYPE_SELECT_LANG: language_index++; if( language_index >= language_menu->child_count ) { language_index = 0; } select_language(); break; case NODETYPE_DOUBLE_STRIKE: wii_double_strike_mode ^= 1; break; case NODETYPE_FULL_WIDESCREEN: wii_full_widescreen++; if( wii_full_widescreen > WS_AUTO ) { wii_full_widescreen = 0; } break; case NODETYPE_16_9_CORRECTION: wii_16_9_correction ^= 1; break; case NODETYPE_GX_VI_SCALER: wii_gx_vi_scaler ^= 1; break; case NODETYPE_AUTO_LOAD_SAVE: wii_auto_load_save_state ^= 1; break; case NODETYPE_TOP_MENU_EXIT: wii_top_menu_exit ^= 1; break; case NODETYPE_CHEATS: wii_cheats ^= 1; break; case NODETYPE_REWIND: wii_rewind ^= 1; if( wii_rewind ) { wii_set_status_message( "Note: Enabling rewind may affect performance." ); } break; case NODETYPE_REWIND_BUTTON: wii_rewind_add_buttons ^= 1; break; case NODETYPE_WIIMOTE_MENU_ORIENT: wii_mote_menu_vertical ^= 1; break; case NODETYPE_DEBUG_MODE: wii_debug ^= 1; break; case NODETYPE_TRAP_FILTER: wii_trap_filter ^= 1; break; case NODETYPE_FILTER: wii_filter ^= 1; break; case NODETYPE_ROOT_DRIVE: case NODETYPE_UPDIR: case NODETYPE_DIR: if( node->node_type == NODETYPE_ROOT_DRIVE ) { char path[WII_MAX_PATH]; snprintf( path, sizeof(path), "%s/", node->name ); wii_set_roms_dir( path ); mount_pending = TRUE; } else if( node->node_type == NODETYPE_UPDIR ) { const char* romsDir = wii_get_roms_dir(); int len = strlen( romsDir ); if( len > 1 && romsDir[len-1] == '/' ) { char dirpart[WII_MAX_PATH] = ""; char filepart[WII_MAX_PATH] = ""; Util_splitpath( romsDir, dirpart, filepart ); len = strlen(dirpart); if( len > 0 ) { dirpart[len] = '/'; dirpart[len+1] = '\0'; } wii_set_roms_dir( dirpart ); } } else { char newDir[WII_MAX_PATH]; snprintf( newDir, sizeof(newDir), "%s%s/", wii_get_roms_dir(), node->name ); wii_set_roms_dir( newDir ); } games_read = FALSE; last_rom_index = 1; break; case NODETYPE_ADVANCED: case NODETYPE_VIDEO_SETTINGS: case NODETYPE_CARTRIDGE_SAVE_STATES: case NODETYPE_LOAD_ROM: wii_menu_push( node ); if( node->node_type == NODETYPE_LOAD_ROM ) { if( games_read ) { wii_menu_move( node, last_rom_index ); } } else if( node->node_type == NODETYPE_CARTRIDGE_SAVE_STATES ) { // Initialize the "current" value prior to displaying // the menu... BOOL foo; wii_snapshot_current( &foo ); } break; case NODETYPE_CARTRIDGE_SETTINGS_CURRENT: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { TREENODE* menu = emu->getMenuManager().getCartridgeSettingsMenu(); if( menu != NULL ) { wii_menu_push( menu ); } } } break; case NODETYPE_EMULATOR_SETTINGS: { Emulator* emu = emuRegistry.getCurrentEmulator(); if( emu != NULL ) { TREENODE* menu = emu->getMenuManager().getEmulatorMenu(); if( menu != NULL ) { wii_menu_push( menu ); } } } break; default: /* do nothing */ break; } UNLOCK_RENDER_MUTEX(); } }