From: notaz Date: Thu, 21 Jun 2007 19:44:28 +0000 (+0000) Subject: bugfixes, r171 release X-Git-Tag: r1~17 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=commitdiff_plain;h=642070a99a18726024c5b214263221a0340e6987 bugfixes, r171 release git-svn-id: file:///home/notaz/opt/svn/fceu@171 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/drivers/common/config.c b/drivers/common/config.c index f82323d..5c72317 100644 --- a/drivers/common/config.c +++ b/drivers/common/config.c @@ -115,12 +115,12 @@ static void SaveParse(CFGSTRUCT *cfgst, FILE *fp) } while(cfgst[x].ptr); } -void SaveFCEUConfig(char *filename, CFGSTRUCT *cfgst) +int SaveFCEUConfig(char *filename, CFGSTRUCT *cfgst) { FILE *fp; fp=fopen(filename,"wb"); - if(fp==NULL) return; + if(fp==NULL) return -1; SaveParse(cfgst,fp); @@ -128,6 +128,7 @@ void SaveFCEUConfig(char *filename, CFGSTRUCT *cfgst) #ifdef GP2X sync(); #endif + return 0; } static void LoadParse(CFGSTRUCT *cfgst, FILE *fp) @@ -146,12 +147,13 @@ static void LoadParse(CFGSTRUCT *cfgst, FILE *fp) } while(cfgst[x].ptr); } -void LoadFCEUConfig(char *filename, CFGSTRUCT *cfgst) +int LoadFCEUConfig(char *filename, CFGSTRUCT *cfgst) { FILE *fp; fp=fopen(filename,"rb"); - if(fp==NULL) return; + if(fp==NULL) return -1; LoadParse(cfgst,fp); fclose(fp); + return 0; } diff --git a/drivers/common/config.h b/drivers/common/config.h index 0689f21..b2d2244 100644 --- a/drivers/common/config.h +++ b/drivers/common/config.h @@ -24,8 +24,8 @@ typedef struct { int len; } CFGSTRUCT; -void SaveFCEUConfig(char *filename, CFGSTRUCT *cfgst); -void LoadFCEUConfig(char *filename, CFGSTRUCT *cfgst); +int SaveFCEUConfig(char *filename, CFGSTRUCT *cfgst); +int LoadFCEUConfig(char *filename, CFGSTRUCT *cfgst); /* Macros for building CFGSTRUCT structures. */ @@ -39,7 +39,7 @@ void LoadFCEUConfig(char *filename, CFGSTRUCT *cfgst); #define ADDCFGSTRUCT(x) { 0,&x,0 } /* Oops. The NAC* macros shouldn't have the # in front of the w, but - fixing this would break configuration files of previous versions and it + fixing this would break configuration files of previous versions and it isn't really hurting much. */ diff --git a/drivers/gp2x/gp2x-video.c b/drivers/gp2x/gp2x-video.c index d8524b6..49850f6 100644 --- a/drivers/gp2x/gp2x-video.c +++ b/drivers/gp2x/gp2x-video.c @@ -176,6 +176,20 @@ void BlitPrepare(int skip) } } + if (Settings.accurate_mode && Settings.scaling < 2) + { + int i, *p = (int *)gp2x_screen + 32/4; + if (srendline > 0) + for (i = srendline; i > 0; i--, p += 320/4) + memset32(p, 0, 256/4); + if (erendline < 239) + { + int *p = (int *)gp2x_screen + erendline*320/4 + 32/4; + for (i = 239-srendline; i > 0; i--, p += 320/4) + memset32(p, 0, 256/4); + } + } + printFps(gp2x_screen); if (Settings.scaling == 3) diff --git a/drivers/gp2x/gp2x.c b/drivers/gp2x/gp2x.c index 92103c0..ab00045 100644 --- a/drivers/gp2x/gp2x.c +++ b/drivers/gp2x/gp2x.c @@ -38,7 +38,8 @@ CFGSTRUCT DriverConfig[]={ AC(Settings.mmuhack), AC(Settings.ramtimings), AC(Settings.gamma), - // TODO + AC(Settings.perfect_vsync), + AC(Settings.accurate_mode), ENDCFGSTRUCT }; diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index b15098c..628f88b 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -128,25 +128,44 @@ static CFGSTRUCT fceuconfig[]={ ENDCFGSTRUCT }; -void SaveConfig(const char *name) +static const char *skip_path(const char *path) { + const char *p; + if (path == NULL) return NULL; + for (p = path+strlen(path)-1; p > path && *p != '/'; p--); + if (*p == '/') p++; + return p; +} + +int SaveConfig(const char *llgn_path) +{ + const char *name = skip_path(llgn_path); char tdir[2048]; + int ret; if (name) sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); + printf("saving cfg to %s ... ", tdir); fflush(stdout); FCEUI_GetNTSCTH(&ntsctint, &ntschue); - SaveFCEUConfig(tdir,fceuconfig); + ret=SaveFCEUConfig(tdir,fceuconfig); + printf(ret == 0 ? "done\n" : "failed\n"); + return ret; } -static void LoadConfig(const char *name) +static int LoadConfig(const char *llgn_path) { + const char *name = skip_path(llgn_path); char tdir[2048]; + int ret; if (name) sprintf(tdir,"%s"PSS"cfg"PSS"%s.cfg",BaseDirectory,name); else sprintf(tdir,"%s"PSS"fceu2.cfg",BaseDirectory); + printf("loading cfg from %s ... ", tdir); fflush(stdout); FCEUI_GetNTSCTH(&ntsctint, &ntschue); /* Get default settings for if no config file exists. */ - LoadFCEUConfig(tdir,fceuconfig); + ret=LoadFCEUConfig(tdir,fceuconfig); FCEUI_SetNTSCTH(ntsccol, ntsctint, ntschue); + printf(ret == 0 ? "done\n" : "failed\n"); + return ret; } static void LoadLLGN(void) @@ -333,7 +352,7 @@ static int DoArgs(int argc, char *argv[]) int CLImain(int argc, char *argv[]) { - int last_arg_parsed; + int last_arg_parsed, ret; /* TODO if(argc<=1) { ShowUsage(argv[0]); @@ -379,7 +398,11 @@ int CLImain(int argc, char *argv[]) { if (fceugi) CloseGame(); - LoadConfig(lastLoadedGameName); + ret=LoadConfig(lastLoadedGameName); + if (ret != 0) + { + LoadConfig(NULL); + } FCEUI_SetEmuMode(Settings.accurate_mode); fceugi=FCEUI_LoadGame(lastLoadedGameName); if (fceugi) diff --git a/drivers/gp2x/main.h b/drivers/gp2x/main.h index 79cc231..4739595 100644 --- a/drivers/gp2x/main.h +++ b/drivers/gp2x/main.h @@ -33,5 +33,5 @@ extern int NoWaiting; extern FCEUGI *fceugi; -void SaveConfig(const char *name); +int SaveConfig(const char *name); diff --git a/drivers/gp2x/menu.c b/drivers/gp2x/menu.c index d3eb71e..ee599b4 100644 --- a/drivers/gp2x/menu.c +++ b/drivers/gp2x/menu.c @@ -166,7 +166,7 @@ void gp2x_text_out15_lim(int x, int y, const char *texto, int max) gp2x_text_out15(x,y,buffer); } -static void gp2x_smalltext16(int x, int y, const char *texto) +static void gp2x_smalltext16(int x, int y, const char *texto, unsigned short color) { int i; unsigned char *src; @@ -187,7 +187,7 @@ static void gp2x_smalltext16(int x, int y, const char *texto) int w = 0x20; while (w) { - if( *src & w ) *dst = 0xffff; + if( *src & w ) *dst = color; dst++; w>>=1; } @@ -198,7 +198,7 @@ static void gp2x_smalltext16(int x, int y, const char *texto) } } -static void gp2x_smalltext16_lim(int x, int y, const char *texto, int max) +static void gp2x_smalltext16_lim(int x, int y, const char *texto, unsigned short color, int max) { char buffer[320/6+1]; @@ -207,7 +207,7 @@ static void gp2x_smalltext16_lim(int x, int y, const char *texto, int max) if (max < 0) max = 0; buffer[max] = 0; - gp2x_smalltext16(x, y, buffer); + gp2x_smalltext16(x, y, buffer, color); } @@ -299,6 +299,22 @@ static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) // -------------- ROM selector -------------- +// rrrr rggg gggb bbbb +static unsigned short file2color(const char *fname) +{ + const char *ext = fname + strlen(fname) - 3; + static const char *rom_exts[] = { "zip", "nes", "fds", "unf", "nez", "nif" }; // nif is for unif + static const char *other_exts[] = { "nsf", "ips", "fcm" }; + int i; + + if (ext < fname) ext = fname; + for (i = 0; i < sizeof(rom_exts)/sizeof(rom_exts[0]); i++) + if (strcasecmp(ext, rom_exts[i]) == 0) return 0xbdff; + for (i = 0; i < sizeof(other_exts)/sizeof(other_exts[0]); i++) + if (strcasecmp(ext, other_exts[i]) == 0) return 0xaff5; + return 0xffff; +} + static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) { int start, i, pos; @@ -310,16 +326,17 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) gp2x_fceu_darken_all(); if(start - 2 >= 0) - gp2x_smalltext16_lim(14, (start - 2)*10, curdir, 53-2); + gp2x_smalltext16_lim(14, (start - 2)*10, curdir, 0xffff, 53-2); for (i = 0; i < n; i++) { pos = start + i; if (pos < 0) continue; if (pos > 23) break; if (namelist[i+1]->d_type == DT_DIR) { - gp2x_smalltext16_lim(14, pos*10, "/", 1); - gp2x_smalltext16_lim(14+6, pos*10, namelist[i+1]->d_name, 53-3); + gp2x_smalltext16_lim(14, pos*10, "/", 0xfff6, 1); + gp2x_smalltext16_lim(14+6, pos*10, namelist[i+1]->d_name, 0xfff6, 53-3); } else { - gp2x_smalltext16_lim(14, pos*10, namelist[i+1]->d_name, 53-2); + unsigned short color = file2color(namelist[i+1]->d_name); + gp2x_smalltext16_lim(14, pos*10, namelist[i+1]->d_name, color, 53-2); } } gp2x_text_out15(5, 120, ">"); @@ -490,9 +507,9 @@ static int clistcallb(char *name, uint32 a, uint8 v, int compare, int s, int typ if (pos < 0) return 1; if (pos > 23) return 0; - gp2x_smalltext16_lim(14, pos*10, s ? "ON " : "OFF", 3); - gp2x_smalltext16_lim(14+6*4, pos*10, type ? "S" : "R", 1); - gp2x_smalltext16_lim(14+6*6, pos*10, name, 53-8); + gp2x_smalltext16_lim(14, pos*10, s ? "ON " : "OFF", 0xffff, 3); + gp2x_smalltext16_lim(14+6*4, pos*10, type ? "S" : "R", 0xffff, 1); + gp2x_smalltext16_lim(14+6*6, pos*10, name, 0xffff, 53-8); return 1; } @@ -509,7 +526,7 @@ static void draw_patchlist(int sel) FCEUI_ListCheats(clistcallb,0); pos = cheat_start + cheat_pos; - if (pos < 24) gp2x_smalltext16_lim(14, pos*10, "done", 4); + if (pos < 24) gp2x_smalltext16_lim(14, pos*10, "done", 0xffff, 4); gp2x_text_out15(5, 120, ">"); menu_flip(); @@ -911,7 +928,7 @@ static void kc_sel_loop(void) if(inp & GP2X_B) { switch (menu_sel) { case 0: key_config_loop(ctrl_actions, 10, 0); return; - case 1: key_config_loop(ctrl_actions, 8, 1); return; + case 1: key_config_loop(ctrl_actions, 10, 1); return; case 2: key_config_loop(emuctrl_actions, sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return; case 3: if (!fceugi) SaveConfig(NULL); return; @@ -1139,7 +1156,7 @@ static void config_commit(void) static int menu_loop_options(void) { static int menu_sel = 0; - int menu_sel_max = 16; + int ret, menu_sel_max = 16; unsigned long inp = 0; if (fceugi) menu_sel_max++; @@ -1161,12 +1178,16 @@ static int menu_loop_options(void) case 15: fcemenu_loop_options(); break; case 16: // done (update and write) config_commit(); - SaveConfig(NULL); + ret = SaveConfig(NULL); + strcpy(menuErrorMsg, ret == 0 ? "default config saved" : "config save failed"); return 1; case 17: // done (update and write for current game) - config_commit(); if (lastLoadedGameName[0]) - SaveConfig(lastLoadedGameName); + { + config_commit(); + ret = SaveConfig(lastLoadedGameName); + strcpy(menuErrorMsg, ret == 0 ? "game config saved" : "config save failed"); + } return 1; } } diff --git a/fce.c b/fce.c index eafba11..a21e5f5 100644 --- a/fce.c +++ b/fce.c @@ -49,6 +49,7 @@ #include "file.h" #include "crc32.h" #include "ppu.h" +#include "ppu098.h" #include "palette.h" #include "movie.h" @@ -1269,7 +1270,6 @@ static void EmLoop(void); int use098code = 0; void (*ResetNES)(void) = 0; -void (*PowerNES)(void) = 0; void (*FCEUI_Emulate)(void) = 0; void FCEUI_SetEmuMode(int is_new) @@ -1278,13 +1278,11 @@ void FCEUI_SetEmuMode(int is_new) if (is_new) { ResetNES=ResetNES098; - PowerNES=PowerNES098; FCEUI_Emulate=FCEUI_Emulate098; } else { ResetNES=ResetNES081; - PowerNES=PowerNES081; FCEUI_Emulate=EmLoop; } } @@ -1530,7 +1528,7 @@ static void FCEU_MemoryRand(uint8 *ptr, uint32 size) } #endif -void PowerNES081(void) +void PowerNES(void) { if(!GameLoaded) return; @@ -1547,6 +1545,13 @@ void PowerNES081(void) ResetMapping(); PowerSound(); PowerPPU(); + + if (use098code) + FCEUPPU_Power(); + + /* Have the external game hardware "powered" after the internal NES stuff. + Needed for the NSF code and VS System code. + */ GameInterface(GI_POWER, 0); if(FCEUGameInfo.type==GIT_VSUNI) FCEU_VSUniPower(); diff --git a/fce.h b/fce.h index f321b50..593d858 100644 --- a/fce.h +++ b/fce.h @@ -28,10 +28,9 @@ void FCEU_ResetVidSys(void); void ResetMapping(void); extern void (*ResetNES)(void); -extern void (*PowerNES)(void); void ResetNES081(void); -void PowerNES081(void); +void PowerNES(void); extern uint64 timestampbase; diff --git a/fceu098.c b/fceu098.c index dd35297..ecc6bfd 100644 --- a/fceu098.c +++ b/fceu098.c @@ -83,16 +83,8 @@ void FCEUI_Emulate098(void) void ResetNES098(void) { ResetNES081(); + // it was decided not to use 098 sound because of problems it causes //FCEUSND_Reset(); FCEUPPU_Reset(); } - -void PowerNES098(void) -{ - PowerNES081(); - // it was decided not to use 098 sound because of problems it causes - //FCEUSND_Power(); - FCEUPPU_Power(); -} - diff --git a/fceu098.h b/fceu098.h index 827eb58..4642532 100644 --- a/fceu098.h +++ b/fceu098.h @@ -1,5 +1,4 @@ int FCEUI_Initialize098(void); void FCEUI_Emulate098(void); void ResetNES098(void); -void PowerNES098(void); diff --git a/out_gp2x/gpfce.man.txt b/out_gp2x/gpfce.man.txt index 61cd3c0..cbaaee8 100644 --- a/out_gp2x/gpfce.man.txt +++ b/out_gp2x/gpfce.man.txt @@ -55,7 +55,7 @@ Palettes can be set on a per-game basis. To do this, put a palette file in the < BigBad.nes BigBad.pal BigBad.zip BigBad.pal BigBad.Better.nes BigBad.Better.pal - + With so many ways to choose a palette, figuring out which one will be active may be difficult. Here's a list of what palettes will be used, in order from highest priority to least priority(if a condition doesn't exist for a higher priority palette, the emulator will continue down its list of palettes). @@ -108,7 +108,7 @@ Patching is supported for all supported formats (iNES, FDS, UNIF, and NSF), but [FCM movies] -Version 0.4 has partial FCM movie support. Most of the movies desync due to different timing, but some of them can be played. There is only playback support. Files should be placed in the ROMs directory along with the ROMs themselves. Naming is the same as for IPS patches (see previous section), buf use .fcm extension instead of .ips. +Version 0.4 has partial FCM movie support. Most of the movies desync due to different timing, but some of them can be played. Note that 'accurate renderer' option solves some desync problems. There is only playback support. Files should be placed in the ROMs directory along with the ROMs themselves. Naming is the same as for IPS patches (see previous section), buf use .fcm extension instead of .ips. [Credits/thanks] diff --git a/out_gp2x/readme.txt b/out_gp2x/readme.txt index 4931dcf..c923df8 100644 --- a/out_gp2x/readme.txt +++ b/out_gp2x/readme.txt @@ -87,7 +87,7 @@ game you wish to associate with and add the extension "pal". Examples: BigBad.nes BigBad.pal BigBad.zip BigBad.pal BigBad.Better.nes BigBad.Better.pal - + With so many ways to choose a palette, figuring out which one will be active may be difficult. Here's a list of what palettes will be used, in order from highest @@ -176,7 +176,8 @@ patched well with the IPS format because they are chunk-based with no fixed offs ------------------------------------------------------------------ Version 0.4 has partial FCM movie support. Most of the movies desync due to -different timing, but some of them can be played. There is only playback support. +different timing, but some of them can be played. Note that 'accurate renderer' +option solves some desync problems. There is only playback support. Files should be placed in the ROMs directory along with the ROMs themselves. Naming is the same as for IPS patches (see previous section), buf use .fcm extension instead of .ips. @@ -188,6 +189,13 @@ extension instead of .ips. ver 0.4 (by notaz) + rev 171 + - Added optional "Accurate renderer", which is the original FCE Ultra + 0.98.x renderer + PPU emulation code. It's much slower, but it can + handle games which need more precise PPU timing emulation (like + Marble Madness). + - Fixed saving and loading of game specific configs. + - Some other minor changes. rev 163 - Added A r k's fast-direction-change fix for usbjoy lib. - Fixed an issue of usbjoys stopping to work when "Perfect vsync" diff --git a/ppu098.c b/ppu098.c index 023975b..fe0e5c2 100644 --- a/ppu098.c +++ b/ppu098.c @@ -370,7 +370,7 @@ static void ResetRL(uint8 *target) Plinef=target; Pline=target; firsttile=0; - linestartts=timestamp*48+X.count; + linestartts=timestamp*48+X6502_GetCycleCount(); tofix=0; FCEUPPU_LineUpdate098(); tofix=1; @@ -489,9 +489,13 @@ static void FASTAPASS(1) RefreshLine098(int lastpixel) if(!ScreenON && !SpriteON) { uint32 tem; + int tiles; tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24); tem|=0x40404040; - FCEU_dwmemset(Pline,tem,numtiles*8); + tiles=numtiles; + if(firsttile+tiles > 256/8) tiles=256/8-firsttile; + if(tiles > 0) + FCEU_dwmemset(Pline,tem,tiles*8); P+=numtiles*8; Pline=P;