From 2d2247c26080ed9009b3d8c650cfc647fd1fb162 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 27 Mar 2008 22:42:54 +0000 Subject: [PATCH] read-ahead turn off, cfg file, minor adjustments git-svn-id: file:///home/notaz/opt/svn/PicoDrive@399 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Cart.c | 3 + Pico/carthw/svp/compiler.c | 53 ++++++------------ platform/base_readme.txt | 26 +++++---- platform/common/emu.c | 9 +-- platform/gizmondo/menu.c | 4 +- platform/gp2x/emu.c | 2 +- platform/gp2x/game.cfg | 109 +++++++++++++++++++++++++++++++++++++ platform/gp2x/gp2x.c | 29 ++++++++++ platform/gp2x/menu.c | 4 +- platform/psp/menu.c | 4 +- 10 files changed, 186 insertions(+), 57 deletions(-) create mode 100644 platform/gp2x/game.cfg diff --git a/Pico/Cart.c b/Pico/Cart.c index fadf558..d6f6dd6 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -137,6 +137,9 @@ zip_failed: if (f == NULL) goto cso_failed; + /* we use our own buffering */ + setvbuf(f, NULL, _IONBF, 0); + cso = malloc(sizeof(*cso)); if (cso == NULL) goto cso_failed; diff --git a/Pico/carthw/svp/compiler.c b/Pico/carthw/svp/compiler.c index f8bece3..911da17 100644 --- a/Pico/carthw/svp/compiler.c +++ b/Pico/carthw/svp/compiler.c @@ -151,11 +151,10 @@ int ssp_get_iram_context(void) val1 = iram_context_map[(val>>1)&0x3f]; if (val1 == 0) { - printf("val: %02x PC=%04x\n", (val>>1)&0x3f, rPC); + elprintf(EL_ANOMALY, "svp: iram ctx val: %02x PC=%04x\n", (val>>1)&0x3f, rPC); //debug_dump2file(name, svp->iram_rom, 0x800); - exit(1); + //exit(1); } -// elprintf(EL_ANOMALY, "iram_context: %02i", val1); return val1; } @@ -233,11 +232,11 @@ static void hostreg_sspreg_changed(int sspreg) void tr_unhandled(void) { - FILE *f = fopen("tcache.bin", "wb"); - fwrite(tcache, 1, (tcache_ptr - tcache)*4, f); - fclose(f); - printf("unhandled @ %04x\n", known_regs.gr[SSP_PC].h<<1); - exit(1); + //FILE *f = fopen("tcache.bin", "wb"); + //fwrite(tcache, 1, (tcache_ptr - tcache)*4, f); + //fclose(f); + elprintf(EL_ANOMALY, "unhandled @ %04x\n", known_regs.gr[SSP_PC].h<<1); + //exit(1); } /* update P, if needed. Trashes r0 */ @@ -364,7 +363,7 @@ static void tr_flush_dirty_pmcrs(void) EOP_STR_IMM(1,7,0x400+SSP_PMC*4); if (known_regs.emu_status & (SSP_PMC_SET|SSP_PMC_HAVE_ADDR)) { - printf("!! SSP_PMC_SET|SSP_PMC_HAVE_ADDR set on flush\n"); + elprintf(EL_ANOMALY, "!! SSP_PMC_SET|SSP_PMC_HAVE_ADDR set on flush\n"); tr_unhandled(); } } @@ -644,7 +643,7 @@ static int tr_cond_check(int op) EOP_TST_IMM(6, 0, 8); return f ? A_COND_NE : A_COND_EQ; default: - printf("unimplemented cond?\n"); + elprintf(EL_ANOMALY, "unimplemented cond?\n"); tr_unhandled(); return 0; } @@ -653,12 +652,12 @@ static int tr_cond_check(int op) static int tr_neg_cond(int cond) { switch (cond) { - case A_COND_AL: printf("neg for AL?\n"); exit(1); + case A_COND_AL: elprintf(EL_ANOMALY, "neg for AL?\n"); exit(1); case A_COND_EQ: return A_COND_NE; case A_COND_NE: return A_COND_EQ; case A_COND_MI: return A_COND_PL; case A_COND_PL: return A_COND_MI; - default: printf("bad cond for neg\n"); exit(1); + default: elprintf(EL_ANOMALY, "bad cond for neg\n"); exit(1); } return 0; } @@ -1668,7 +1667,7 @@ static void emit_block_prologue(void) */ static void emit_block_epilogue(int cycles, int cond, int pc, int end_pc) { - if (cycles > 0xff) { printf("large cycle count: %i\n", cycles); cycles = 0xff; } + if (cycles > 0xff) { elprintf(EL_ANOMALY, "large cycle count: %i\n", cycles); cycles = 0xff; } EOP_SUB_IMM(11,11,0,cycles); // sub r11, r11, #cycles if (cond < 0 || (end_pc >= 0x400 && pc < 0x400)) { @@ -1703,7 +1702,7 @@ void *ssp_translate_block(int pc) unsigned int *block_start; int ret, end_cond = A_COND_AL, jump_pc = -1; - printf("translate %04x -> %04x\n", pc<<1, (tcache_ptr-tcache)<<2); + //printf("translate %04x -> %04x\n", pc<<1, (tcache_ptr-tcache)<<2); block_start = tcache_ptr; known_regb = 0; dirty_regb = KRREG_P; @@ -1724,8 +1723,8 @@ void *ssp_translate_block(int pc) ret = translate_op(op, &pc, imm, &end_cond, &jump_pc); if (ret <= 0) { - printf("NULL func! op=%08x (%02x)\n", op, op1); - exit(1); + elprintf(EL_ANOMALY, "NULL func! op=%08x (%02x)\n", op, op1); + //exit(1); } ccount += ret & 0xffff; @@ -1744,15 +1743,15 @@ void *ssp_translate_block(int pc) emit_block_epilogue(ccount, end_cond, jump_pc, pc); if (tcache_ptr - tcache > SSP_TCACHE_SIZE/4) { - printf("tcache overflow!\n"); + elprintf(EL_ANOMALY, "tcache overflow!\n"); fflush(stdout); exit(1); } // stats nblocks++; - printf("%i blocks, %i bytes, k=%.3f\n", nblocks, (tcache_ptr - tcache)*4, - (double)(tcache_ptr - tcache) / (double)n_in_ops); + //printf("%i blocks, %i bytes, k=%.3f\n", nblocks, (tcache_ptr - tcache)*4, + // (double)(tcache_ptr - tcache) / (double)n_in_ops); #ifdef DUMP_BLOCK { @@ -1806,22 +1805,6 @@ int ssp1601_dyn_startup(void) void ssp1601_dyn_reset(ssp1601_t *ssp) { - // debug - { - int i, u; - FILE *f = fopen("tcache.bin", "wb"); - fwrite(tcache, 1, (tcache_ptr - tcache)*4, f); - fclose(f); - - for (i = 0; i < 0x5090/2; i++) - if (ssp_block_table[i]) - printf("%06x -> __:%04x\n", (ssp_block_table[i] - tcache)*4, i<<1); - for (u = 1; u < 15; u++) - for (i = 0; i < 0x800/2; i++) - if (ssp_block_table_iram[u][i]) - printf("%06x -> %02i:%04x\n", (ssp_block_table_iram[u][i] - tcache)*4, u, i<<1); - } - ssp1601_reset(ssp); ssp->drc.iram_dirty = 1; ssp->drc.iram_context = 0; diff --git a/platform/base_readme.txt b/platform/base_readme.txt index a50f80d..3d59588 100644 --- a/platform/base_readme.txt +++ b/platform/base_readme.txt @@ -391,14 +391,10 @@ This enables 8 channel PCM sound source. It is required for some games to run, because they monitor state of this audio chip. @@2. "ReadAhead buffer" -#ifdef GP2X -This option is for dealing with slow SD card access in GP2X, which makes FMV -games unplayable. It will allow emulator not to access SD card for longer periods -of time, but it will take more time to fill the buffer. -#endif -#ifdef GIZ -This option can prefetch more data from the CD then read by the game - not really -useful for Gizmondo (this is a workaround for SD access problems on GP2X port). +This option can prefetch more data from the CD image then requested by game +(to avoid accessing card later), what can improve performance in some cases. +#ifndef PSP +"OFF" is the recommended setting. #endif @@2. "Save RAM cart" @@ -616,6 +612,7 @@ Additional thanks * A_SN for his gamma code. * craigix for supplying the GP2X hardware and making this port possible. * Alex for the icon. +* Exophase and Rokas for various ideas. * All the people from gp32x boards for their support. #endif #ifdef GIZ @@ -638,14 +635,21 @@ Changelog --------- 1.40 + Added support for SVP (Sega Virtua Processor) to emulate Virtua Racing, - wrote ARM recompiler and some HLE code for VR. + wrote ARM recompiler and some HLE code for VR. Credits to Exophase and + Rokas for various ideas. * Changed config file format, files are now human-readable. Game specific configs are now held in single file (but old game config files are still - read). + read when new one is missing). * Fixed a bug where some key combos didn't work as expected. * Fixed a regression in renderer (some graphic glitches in rare cases). - * Adjusted fast rernderer to work with more games, including VR. + * Adjusted fast renderer to work with more games, including VR. * Fixed a problem where SegaCD RAM cart data was getting lost on reset. + * Greatly reduced SegaCD FMV game slowdowns by disabling read-ahead in the + Linux kernel and C library (thanks to Rokas and Exophase for ideas again). + Be sure to keep "ReadAhead buffer" OFF to avoid slowdowns. + + PicoDrive now comes with a game config file for some games which need + special settings, so they should now work out-of-the-box. More games will + be added with later updates. 1.35b * PSP: mp3 code should no longer fail on 1.5 firmware. diff --git a/platform/common/emu.c b/platform/common/emu.c index ab17a1f..50cfd2e 100644 --- a/platform/common/emu.c +++ b/platform/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) @@ -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"); @@ -544,7 +545,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 diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index d461286..7e753df 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -921,9 +921,9 @@ static void cd_menu_loop_options(void) selected_id == MA_CDOPT_READAHEAD) { if (inp & BTN_LEFT) { PicoCDBuffers >>= 1; - if (PicoCDBuffers < 64) PicoCDBuffers = 0; + if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { - if (PicoCDBuffers < 64) PicoCDBuffers = 64; + if (PicoCDBuffers < 2) PicoCDBuffers = 2; else PicoCDBuffers <<= 1; if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M } diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 3ee96f2..e329b5a 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -141,7 +141,7 @@ void emu_prepareDefaultConfig(void) defaultConfig.s_PsndRate = 44100; defaultConfig.s_PicoRegion = 0; // auto defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP - defaultConfig.s_PicoCDBuffers = 64; + defaultConfig.s_PicoCDBuffers = 0; defaultConfig.Frameskip = -1; // auto defaultConfig.CPUclock = 200; defaultConfig.volume = 50; diff --git a/platform/gp2x/game.cfg b/platform/gp2x/game.cfg new file mode 100644 index 0000000..40809c8 --- /dev/null +++ b/platform/gp2x/game.cfg @@ -0,0 +1,109 @@ +# +# Sega/Mega CD games +# + +[CD|GM MK-4432 -00|U|ADVENTURES OF BA] +Scale/Rot. fx (slow) = 1 +Better sync (slow) = 1 + +[CD|GM T-60055-00|U|AH3-THUNDERSTRIKE] +Scale/Rot. fx (slow) = 1 + +[CD|GM MK-4401 -00|U|BATMAN RETURNS] +Scale/Rot. fx (slow) = 1 + +[CD|GM T-115075-00|U|BCRACERS] +Scale/Rot. fx (slow) = 1 + +[CD|GM MK-4402|U|COBRA COMMAND] +Better sync (slow) = 1 + +[CD|GM MK-4651 -00|U|DARK WIZARD] +Better sync (slow) = 1 + +[CD|GM T-121015-00|U|DRAGONS LAIR] +Renderer = 16bit accurate + +[CD|GM T-60094|J|JAGUAR XJ220] +Renderer = 16bit accurate + +[CD|GM T-127015-00|U|LUNAR] +Scale/Rot. fx (slow) = 1 + +[CD|GM T-111065 -0|U|MAD DOG II THE LOST GOLD] +Renderer = 16bit accurate + +[CD|GM T-11105 -00|U|MAD DOG MCCREE] +Renderer = 16bit accurate + +[CD|GM T-81025-00|U|MORTAL KOMBAT] +Renderer = 16bit accurate +Better sync (slow) = 1 + +[CD|GM T-04903-01|U|NIGHT TRAP] +Renderer = 16bit accurate + +[CD|GM T-113025-00|U|NOVASTORM] +Better sync (slow) = 1 + +[CD|GM T-127035-00|U|Popful MAIL] +Better sync (slow) = 1 + +[CD|MK 4603-50|JUE|ROAD AVENGER] +Renderer = 16bit accurate +Better sync (slow) = 1 + +[CD|GM T-50085|U|ROAD RASH] +Renderer = 16bit accurate +Better sync (slow) = 1 + +[CD|GM MK-4416 -00|E|ROBO ALESTE] +Renderer = 16bit accurate + +[CD|GM T-06201-03|U|SEWER SHARK] +Renderer = 16bit accurate + +[CD|GM T-113045-00|E|SHADOW OF THE BEAST TWO] +Renderer = 16bit accurate + +[CD|GM MK-4404|U|SOL-FEACE] +Better sync (slow) = 1 + +[CD|GM MK-4407-00|E|SONIC THE HEDGEHOG-CD] +Scale/Rot. fx (slow) = 1 + +[CD|GM MK-4407 -00|U|SONIC THE HEDGEHOG-CD] +Scale/Rot. fx (slow) = 1 + +[CD|GM T-22025-00|U|THE 3RD WORLD WAR] +Better sync (slow) = 1 + +[CD|GM MK- 4430 -|E|YUMEMI MISTERY MANSION] +Renderer = 16bit accurate + +# +# Virtua Racing +# +[MD|GM MK-1229 -00|U|Virtua Racing] +Renderer = 8bit fast +Show FPS = 1 +GP2X CPU clocks = 235 + +[MD|GM G-7001 -00|J|Virtua Racing] +Renderer = 8bit fast +Show FPS = 1 +GP2X CPU clocks = 235 + +[MD|GM MK-1229 -00|E|Virtua Racing] +Renderer = 8bit fast +Show FPS = 1 +GP2X CPU clocks = 235 + +[MD|GM MK-1229 -00|E|VIRTUA RACING \00\00\00\00\00\00\00\00\00] +Renderer = 8bit fast +Show FPS = 1 +GP2X CPU clocks = 235 + +# +# Genesis/MegaDrive games +# diff --git a/platform/gp2x/gp2x.c b/platform/gp2x/gp2x.c index 7a5156c..6db1d41 100644 --- a/platform/gp2x/gp2x.c +++ b/platform/gp2x/gp2x.c @@ -284,6 +284,31 @@ void Reset940(int yes, int bank) gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03); } +static void proc_set(const char *path, const char *val) +{ + FILE *f; + char tmp[16]; + + f = fopen(path, "w"); + if (f == NULL) { + printf("failed to open: %s\n", path); + return; + } + + fprintf(f, "0\n"); + fclose(f); + + printf("\"%s\" is set to: ", path); + f = fopen(path, "r"); + if (f == NULL) { + printf("(open failed)\n"); + return; + } + + fgets(tmp, sizeof(tmp), f); + printf("%s", tmp); + fclose(f); +} /* common */ @@ -337,6 +362,10 @@ void gp2x_init(void) /* init usb joys -GnoStiC */ gp2x_usbjoy_init(); + /* disable Linux read-ahead */ + proc_set("/proc/sys/vm/max-readahead", "0\n"); + proc_set("/proc/sys/vm/min-readahead", "0\n"); + printf("exitting init()\n"); fflush(stdout); } diff --git a/platform/gp2x/menu.c b/platform/gp2x/menu.c index df5ff8a..5039cab 100644 --- a/platform/gp2x/menu.c +++ b/platform/gp2x/menu.c @@ -960,9 +960,9 @@ static void cd_menu_loop_options(void) selected_id == MA_CDOPT_READAHEAD) { if (inp & GP2X_LEFT) { PicoCDBuffers >>= 1; - if (PicoCDBuffers < 64) PicoCDBuffers = 0; + if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { - if (PicoCDBuffers < 64) PicoCDBuffers = 64; + if (PicoCDBuffers < 2) PicoCDBuffers = 2; else PicoCDBuffers <<= 1; if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M } diff --git a/platform/psp/menu.c b/platform/psp/menu.c index 19151cc..ca40cfe 100644 --- a/platform/psp/menu.c +++ b/platform/psp/menu.c @@ -936,9 +936,9 @@ static void cd_menu_loop_options(void) selected_id == MA_CDOPT_READAHEAD) { if (inp & BTN_LEFT) { PicoCDBuffers >>= 1; - if (PicoCDBuffers < 64) PicoCDBuffers = 0; + if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { - if (PicoCDBuffers < 64) PicoCDBuffers = 64; + if (PicoCDBuffers < 2) PicoCDBuffers = 2; else PicoCDBuffers <<= 1; if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M } -- 2.39.2