X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fcommon%2Femu.c;h=b828595feb536e80b2d56289217ece89c1c0957b;hb=9c9cda8c39bd2a6b99b8420a3034c454bc713954;hp=d92c598e8c825e5fc990d3b2eb78ca0bca8f4ad3;hpb=2446536be520914616403876d7e49621ac6f4b95;p=picodrive.git diff --git a/platform/common/emu.c b/platform/common/emu.c index d92c598..b828595 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -10,7 +10,7 @@ #include #include #include -#ifndef NO_SYNC +#ifdef __GP2X__ #include #endif @@ -28,15 +28,20 @@ #include #include +#ifndef _WIN32 +#define PATH_SEP "/" +#define PATH_SEP_C '/' +#else +#define PATH_SEP "\\" +#define PATH_SEP_C '\\' +#endif #define STATUS_MSG_TIMEOUT 2000 void *g_screen_ptr; -#if !SCREEN_SIZE_FIXED -int g_screen_width = SCREEN_WIDTH; -int g_screen_height = SCREEN_HEIGHT; -#endif +int g_screen_width = 320; +int g_screen_height = 240; char *PicoConfigFile = "config.cfg"; currentConfig_t currentConfig, defaultConfig; @@ -535,7 +540,8 @@ void emu_prep_defconfig(void) memset(&defaultConfig, 0, sizeof(defaultConfig)); defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_EN_CD_LEDS; defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 | - POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES | + POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX | + POPT_EN_SVP_DRC|POPT_ACC_SPRITES | POPT_EN_32X|POPT_EN_PWM; defaultConfig.s_PsndRate = 44100; defaultConfig.s_PicoRegion = 0; // auto @@ -547,6 +553,8 @@ void emu_prep_defconfig(void) defaultConfig.gamma = 100; defaultConfig.scaling = 0; defaultConfig.turbo_rate = 15; + defaultConfig.msh2_khz = PICO_MSH2_HZ / 1000; + defaultConfig.ssh2_khz = PICO_SSH2_HZ / 1000; // platform specific overrides pemu_prep_defconfig(); @@ -560,8 +568,6 @@ void emu_set_defconfig(void) PicoRegionOverride = currentConfig.s_PicoRegion; PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder; PicoCDBuffers = currentConfig.s_PicoCDBuffers; - p32x_msh2_multiplier = MSH2_MULTI_DEFAULT; - p32x_ssh2_multiplier = SSH2_MULTI_DEFAULT; } int emu_read_config(const char *rom_fname, int no_defaults) @@ -580,33 +586,29 @@ int emu_read_config(const char *rom_fname, int no_defaults) } else { - char *sect = emu_make_rom_id(rom_fname); + char ext[16]; + int vol; if (config_slot != 0) - sprintf(cfg, "game.%i.cfg", config_slot); - else strcpy(cfg, "game.cfg"); - - ret = -1; - if (config_havesect(cfg, sect)) - { - // read user's config - int vol = currentConfig.volume; - emu_set_defconfig(); - ret = config_readsect(cfg, sect); - currentConfig.volume = vol; // make vol global (bah) - } + snprintf(ext, sizeof(ext), ".%i.cfg", config_slot); else + strcpy(ext, ".cfg"); + + fname_ext(cfg, sizeof(cfg), "cfg"PATH_SEP, ext, rom_fname); + + // read user's config + vol = currentConfig.volume; + ret = config_readsect(cfg, NULL); + currentConfig.volume = vol; // make vol global (bah) + + if (ret != 0) { // read global config, and apply game_def.cfg on top make_config_cfg(cfg); config_readsect(cfg, NULL); - emu_make_path(cfg, "game_def.cfg", sizeof(cfg)); - ret = config_readsect(cfg, sect); - } - if (ret == 0) - { - lprintf("loaded cfg from sect \"%s\"\n", sect); + emu_make_path(cfg, "game_def.cfg", sizeof(cfg)); + ret = config_readsect(cfg, emu_make_rom_id(rom_fname)); } } @@ -631,7 +633,7 @@ int emu_read_config(const char *rom_fname, int no_defaults) int emu_write_config(int is_game) { - char cfg[512], *game_sect = NULL; + char cfg[512]; int ret, write_lrom = 0; if (!is_game) @@ -639,17 +641,20 @@ int emu_write_config(int is_game) make_config_cfg(cfg); write_lrom = 1; } else { + char ext[16]; + if (config_slot != 0) - sprintf(cfg, "game.%i.cfg", config_slot); - else strcpy(cfg, "game.cfg"); - game_sect = emu_make_rom_id(rom_fname_loaded); - lprintf("emu_write_config: sect \"%s\"\n", game_sect); + snprintf(ext, sizeof(ext), ".%i.cfg", config_slot); + else + strcpy(ext, ".cfg"); + + romfname_ext(cfg, sizeof(cfg), "cfg"PATH_SEP, ext); } lprintf("emu_write_config: %s ", cfg); - ret = config_writesect(cfg, game_sect); + ret = config_write(cfg); if (write_lrom) config_writelrom(cfg); -#ifndef NO_SYNC +#ifdef __GP2X__ sync(); #endif lprintf((ret == 0) ? "(ok)\n" : "(failed)\n"); @@ -859,7 +864,7 @@ int emu_save_load_game(int load, int sram) ret = fwrite(sram_data, 1, sram_size, sramFile); ret = (ret != sram_size) ? -1 : 0; fclose(sramFile); -#ifndef NO_SYNC +#ifdef __GP2X__ sync(); #endif } @@ -870,7 +875,7 @@ int emu_save_load_game(int load, int sram) { ret = PicoState(saveFname, !load); if (!ret) { -#ifndef NO_SYNC +#ifdef __GP2X__ if (!load) sync(); #endif emu_status_msg(load ? "STATE LOADED" : "STATE SAVED"); @@ -1171,6 +1176,7 @@ void emu_init(void) mkdir_path(path, pos, "mds"); mkdir_path(path, pos, "srm"); mkdir_path(path, pos, "brm"); + mkdir_path(path, pos, "cfg"); pprof_init(); @@ -1197,7 +1203,7 @@ void emu_finish(void) char cfg[512]; make_config_cfg(cfg); config_writelrom(cfg); -#ifndef NO_SYNC +#ifdef __GP2X__ sync(); #endif }