X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Femu.c;h=e4cce672d70f188718d329d10a8e365025306132;hb=dd5fd4778d797a1ef4767604b1c57c924ed0f64b;hp=02640bbbe4fce6e9945b13c3dd63844d7c1b7c08;hpb=8e708f920ffd20b026aed616e58c8c8e94c8fb8d;p=libpicofe.git diff --git a/common/emu.c b/common/emu.c index 02640bb..e4cce67 100644 --- a/common/emu.c +++ b/common/emu.c @@ -89,8 +89,8 @@ static void get_ext(char *file, char *ext) strlwr_(ext); } -char *biosfiles_us[] = { "us_scd2_9306", "SegaCDBIOS9303", "us_scd1_9210" }; -char *biosfiles_eu[] = { "eu_mcd2_9306", "eu_mcd2_9303", "eu_mcd1_9210" }; +char *biosfiles_us[] = { "us_scd1_9210", "us_scd2_9306", "SegaCDBIOS9303" }; +char *biosfiles_eu[] = { "eu_mcd1_9210", "eu_mcd2_9306", "eu_mcd2_9303" }; char *biosfiles_jp[] = { "jp_mcd1_9112", "jp_mcd1_9111" }; int emu_findBios(int region, char **bios_file) @@ -235,7 +235,7 @@ char *emu_makeRomId(void) static char id_string[3+0x11+0x11+0x30+16]; int pos, swab = 1; - if (PicoMCD & 1) { + if (PicoAHW & PAHW_MCD) { strcpy(id_string, "CD|"); swab = 0; } @@ -278,7 +278,8 @@ int emu_ReloadRom(void) free(movie_data); movie_data = 0; } - if (!strcmp(ext, ".gmv")) { + if (!strcmp(ext, ".gmv")) + { // check for both gmv and rom int dummy; FILE *movie_file = fopen(romFileName, "rb"); @@ -324,14 +325,14 @@ int emu_ReloadRom(void) get_ext(romFileName, ext); } - if ((PicoMCD & 1) && Pico_mcd != NULL) + if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL) Stop_CD(); // check for MegaCD image cd_state = emu_cdCheck(&cd_region); if (cd_state > 0) { - PicoMCD |= 1; + PicoAHW |= PAHW_MCD; // valid CD image, check for BIOS.. // we need to have config loaded at this point @@ -345,7 +346,7 @@ int emu_ReloadRom(void) } if (!emu_findBios(cd_region, &used_rom_name)) { // bios_help() ? - PicoMCD &= ~1; + PicoAHW &= ~PAHW_MCD; return 0; } @@ -353,8 +354,8 @@ int emu_ReloadRom(void) } else { - if (PicoMCD & 1) Stop_CD(); - PicoMCD &= ~1; + if (PicoAHW & PAHW_MCD) Stop_CD(); + PicoAHW &= ~PAHW_MCD; } rom = pm_open(used_rom_name); @@ -387,7 +388,7 @@ int emu_ReloadRom(void) } // load config for this ROM (do this before insert to get correct region) - if (!(PicoMCD&1)) + if (!(PicoAHW & PAHW_MCD)) memcpy(id_header, rom_data + 0x100, sizeof(id_header)); if (!cfg_loaded) { ret = emu_ReadConfig(1, 1); @@ -424,16 +425,16 @@ int emu_ReloadRom(void) // additional movie stuff if (movie_data) { if(movie_data[0x14] == '6') - PicoOpt |= 0x20; // 6 button pad - else PicoOpt &= ~0x20; - PicoOpt |= 0x10040; // accurate timing, no VDP fifo timing + PicoOpt |= POPT_6BTN_PAD; // 6 button pad + else PicoOpt &= ~POPT_6BTN_PAD; + PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing if(movie_data[0xF] >= 'A') { if(movie_data[0x16] & 0x80) { PicoRegionOverride = 8; } else { PicoRegionOverride = 4; } - PicoReset(0); + PicoReset(); // TODO: bits 6 & 5 } movie_data[0x18+30] = 0; @@ -441,7 +442,7 @@ int emu_ReloadRom(void) } else { - PicoOpt &= ~0x10000; + PicoOpt &= ~POPT_DIS_VDP_FIFO; if(Pico.m.pal) { strcpy(noticeMsg, "PAL SYSTEM / 50 FPS"); } else { @@ -480,6 +481,18 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext) } +static void make_config_cfg(char *cfg) +{ + strncpy(cfg, PicoConfigFile, 511); + if (config_slot != 0) + { + char *p = strrchr(cfg, '.'); + if (p == NULL) p = cfg + strlen(cfg); + sprintf(p, ".%i.cfg", config_slot); + } + cfg[511] = 0; +} + int emu_ReadConfig(int game, int no_defaults) { char cfg[512]; @@ -490,14 +503,7 @@ int emu_ReadConfig(int game, int no_defaults) { if (!no_defaults) emu_setDefaultConfig(); - strncpy(cfg, PicoConfigFile, 511); - if (config_slot != 0) - { - char *p = strrchr(cfg, '.'); - if (p == NULL) p = cfg + strlen(cfg); - sprintf(p, ".%i.cfg", config_slot); - } - cfg[511] = 0; + make_config_cfg(cfg); ret = config_readsect(cfg, NULL); } else @@ -510,14 +516,25 @@ int emu_ReadConfig(int game, int no_defaults) else strcpy(cfg, "game.cfg"); ret = -1; - if (config_havesect(cfg, sect)) { + if (config_havesect(cfg, sect)) + { + // read user's config + int vol = currentConfig.volume; emu_setDefaultConfig(); ret = config_readsect(cfg, sect); + currentConfig.volume = vol; // make vol global (bah) + } + else + { + // read global config, and apply game_def.cfg on top + make_config_cfg(cfg); + config_readsect(cfg, NULL); + ret = config_readsect("game_def.cfg", sect); } if (ret != 0) { - // fall back to old + // fall back to old game specific cfg char extbuf[16]; if (config_slot != 0) sprintf(extbuf, ".%i.pbcfg", config_slot); @@ -542,7 +559,7 @@ int emu_ReadConfig(int game, int no_defaults) PsndRate = currentConfig.s_PsndRate; PicoRegionOverride = currentConfig.s_PicoRegion; PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder; - PicoCDBuffers = currentConfig.s_PicoCDBuffers; + // PicoCDBuffers = currentConfig.s_PicoCDBuffers; // ignore in this case } } else @@ -756,11 +773,11 @@ char *emu_GetSaveFName(int load, int is_sram, int slot) if (is_sram) { - romfname_ext(saveFname, (PicoMCD&1) ? "brm/" : "srm/", (PicoMCD&1) ? ".brm" : ".srm"); + romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm"); if (load) { if (try_ropen_file(saveFname)) return saveFname; // try in current dir.. - romfname_ext(saveFname, NULL, (PicoMCD&1) ? ".brm" : ".srm"); + romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); if (try_ropen_file(saveFname)) return saveFname; return NULL; // give up } @@ -838,8 +855,9 @@ int emu_SaveLoadGame(int load, int sram) int sram_size; unsigned char *sram_data; int truncate = 1; - if (PicoMCD&1) { - if (PicoOpt&0x8000) { // MCD RAM cart? + if (PicoAHW & PAHW_MCD) + { + if (PicoOpt&POPT_EN_MCD_RAMCART) { sram_size = 0x12000; sram_data = SRam.data; if (sram_data) @@ -856,12 +874,13 @@ int emu_SaveLoadGame(int load, int sram) } if (!sram_data) return 0; // SRam forcefully disabled for this game - if (load) { + if (load) + { sramFile = fopen(saveFname, "rb"); if(!sramFile) return -1; fread(sram_data, 1, sram_size, sramFile); fclose(sramFile); - if ((PicoMCD&1) && (PicoOpt&0x8000)) + if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART)) memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4); } else { // sram save needs some special processing