From: notaz Date: Sun, 27 May 2007 19:40:52 +0000 (+0000) Subject: infoprint, FDS moviefix, alignment bugfixing X-Git-Tag: r1~43 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4980f9edd806014286d57aee1cbe5e73b803e46;p=fceu.git infoprint, FDS moviefix, alignment bugfixing git-svn-id: file:///home/notaz/opt/svn/fceu@139 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/boards/n106.c b/boards/n106.c index 6ccfe2b..d54af02 100644 --- a/boards/n106.c +++ b/boards/n106.c @@ -23,8 +23,8 @@ static uint16 IRQCount; static uint8 IRQa; -static uint8 WRAM[8192]; -static uint8 IRAM[128]; +static uint8 WRAM[8192] __attribute__ ((aligned (4))); +static uint8 IRAM[128] __attribute__ ((aligned (4))); static DECLFR(AWRAM) { diff --git a/drivers/gp2x/input.c b/drivers/gp2x/input.c index cc8132b..99a0867 100644 --- a/drivers/gp2x/input.c +++ b/drivers/gp2x/input.c @@ -98,15 +98,18 @@ static void do_emu_acts(uint32 acts) } else if (acts & (1 << 27)) // FDS insert/eject { - FCEU_DoSimpleCommand(FCEUNPCMD_FDSINSERT); + if(FCEUGameInfo.type == GIT_FDS) + FCEU_DoSimpleCommand(FCEUNPCMD_FDSINSERT); } else if (acts & (1 << 26)) // FDS select { - FCEU_DoSimpleCommand(FCEUNPCMD_FDSSELECT); + if(FCEUGameInfo.type == GIT_FDS) + FCEU_DoSimpleCommand(FCEUNPCMD_FDSSELECT); } else if (acts & (1 << 25)) // VS Unisystem insert coin { - FCEU_DoSimpleCommand(FCEUNPCMD_VSUNICOIN); + if(FCEUGameInfo.type == GIT_VSUNI) + FCEU_DoSimpleCommand(FCEUNPCMD_VSUNICOIN); } } diff --git a/drivers/gp2x/main.c b/drivers/gp2x/main.c index a399e1e..4eaf3f6 100644 --- a/drivers/gp2x/main.c +++ b/drivers/gp2x/main.c @@ -389,6 +389,7 @@ int CLImain(int argc, char *argv[]) fceugi=FCEUI_LoadGame(lastLoadedGameName); if (fceugi) { + char infostring[32]; LoadConfig(lastLoadedGameName); if (Settings.region_force) FCEUI_SetVidSystem(Settings.region_force - 1); @@ -396,15 +397,8 @@ int CLImain(int argc, char *argv[]) //RefreshThrottleFPS(); InitOtherInput(); - // additional print for gpfce - // TODO: handlers for other formats then iNES - { - int MapperNo; - iNES_HEADER *head = iNESGetHead(); // TODO: ReMake - MapperNo = (head->ROM_type>>4); - MapperNo|=(head->ROM_type2&0xF0); - FCEU_DispMessage("%s, Mapper: %d%s%s", PAL?"PAL":"NTSC", MapperNo, (head->ROM_type&2)?", BB":"", (head->ROM_type&4)?", T":""); - } + GameInterface(GI_INFOSTRING, infostring); + FCEU_DispMessage("%s", infostring); } else { diff --git a/fce.c b/fce.c index 814c80e..becc308 100644 --- a/fce.c +++ b/fce.c @@ -95,7 +95,7 @@ static uint8 deemp=0; static int deempcnt[8]; FCEUGI FCEUGameInfo; -void (*GameInterface)(int h); +void (*GameInterface)(int h, void *param); void FP_FASTAPASS(1) (*PPU_hook)(uint32 A); @@ -1045,6 +1045,7 @@ void ResetMapping(void) int GameLoaded=0; void CloseGame(void) { + FCEUI_StopMovie(); if(GameLoaded) { if(FCEUGameInfo.type!=GIT_NSF) @@ -1052,7 +1053,7 @@ void CloseGame(void) #ifdef NETWORK if(FSettings.NetworkPlay) KillNetplay(); #endif - GameInterface(GI_CLOSE); + GameInterface(GI_CLOSE, 0); CloseGenie(); GameLoaded=0; } @@ -1466,7 +1467,7 @@ static void PowerPPU(void) void ResetNES(void) { if(!GameLoaded) return; - GameInterface(GI_RESETM2); + GameInterface(GI_RESETM2, 0); ResetSound(); ResetPPU(); X6502_Reset(); @@ -1499,7 +1500,7 @@ void PowerNES(void) memset(RAM,0x00,0x800); #endif ResetMapping(); - GameInterface(GI_POWER); + GameInterface(GI_POWER, 0); PowerSound(); PowerPPU(); timestampbase=0; diff --git a/fce.h b/fce.h index 04d050a..7914fc4 100644 --- a/fce.h +++ b/fce.h @@ -72,7 +72,7 @@ extern writefunc BWrite[0x10000]; #define PPU_status (PPU[2]) -extern void (*GameInterface)(int h); +extern void (*GameInterface)(int h, void *param); extern void FP_FASTAPASS(1) (*PPU_hook)(uint32 A); extern void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void); extern void (*GameStateRestore)(int version); @@ -80,6 +80,7 @@ extern void (*GameStateRestore)(int version); #define GI_RESETM2 1 #define GI_POWER 2 #define GI_CLOSE 3 +#define GI_INFOSTRING 11 #include "git.h" extern FCEUGI FCEUGameInfo; diff --git a/fds.c b/fds.c index a8e3d40..e5e4d5b 100644 --- a/fds.c +++ b/fds.c @@ -85,12 +85,13 @@ static uint8 SelectDisk,InDisk; #define DC_INC 1 -void FDSGI(int h) +void FDSGI(int h, void *param) { switch(h) { case GI_CLOSE: FDSClose();break; case GI_POWER: FDSInit();break; + case GI_INFOSTRING: sprintf(param, "FDS, Sides: %d", TotalSides);break; } } diff --git a/file.c b/file.c index d9d3a52..0f47c2a 100644 --- a/file.c +++ b/file.c @@ -51,8 +51,8 @@ void *MakeZipWrap(void *tz) if(!(tmp=FCEU_malloc(sizeof(ZIPWRAP)))) goto doret; - - unzGetCurrentFileInfo(tz,&ufo,0,0,0,0,0,0); + + unzGetCurrentFileInfo(tz,&ufo,0,0,0,0,0,0); tmp->location=0; tmp->size=ufo.uncompressed_size; @@ -68,7 +68,7 @@ void *MakeZipWrap(void *tz) unzCloseCurrentFile(tz); unzClose(tz); - + return tmp; } #endif @@ -109,13 +109,13 @@ int FASTAPASS(2) FCEU_fopen(char *path, char *mode) break; } if(unzGoToNextFile(tz)!=UNZ_OK) - { + { if(unzGoToFirstFile(tz)!=UNZ_OK) goto zpfail; - break; + break; } } if(unzOpenCurrentFile(tz)!=UNZ_OK) - goto zpfail; + goto zpfail; } else { @@ -204,7 +204,7 @@ size_t FASTAPASS(3) FCEU_fread(void *ptr, size_t size, size_t nmemb, int stream) return gzread(desctable[(stream&255)-1],ptr,size*nmemb); } else if(stream&0x8000) - { + { ZIPWRAP *wz; uint32 total=size*nmemb; @@ -242,7 +242,7 @@ size_t FASTAPASS(3) FCEU_fwrite(void *ptr, size_t size, size_t nmemb, int stream return gzwrite(desctable[(stream&255)-1],ptr,size*nmemb); } else if(stream&0x8000) - { + { return 0; } else @@ -256,7 +256,7 @@ int FASTAPASS(3) FCEU_fseek(int stream, long offset, int whence) if(stream&0x4000) { return gzseek(desctable[(stream&255)-1],offset,whence); - } + } else if(stream&0x8000) { ZIPWRAP *wz; @@ -271,7 +271,7 @@ int FASTAPASS(3) FCEU_fseek(int stream, long offset, int whence) return (-1); wz->location+=offset; break; - } + } return 0; } else @@ -287,8 +287,8 @@ long FASTAPASS(1) FCEU_ftell(int stream) return gztell(desctable[(stream&255)-1]); } else if(stream&0x8000) - { - return (((ZIPWRAP *)desctable[(stream&255)-1])->location); + { + return (((ZIPWRAP *)desctable[(stream&255)-1])->location); } else #endif @@ -312,25 +312,25 @@ void FASTAPASS(1)FCEU_rewind(int stream) fseek(desctable[stream-1],0,SEEK_SET); #else rewind(desctable[stream-1]); - #endif + #endif } int FASTAPASS(2) FCEU_read32(void *Bufo, int stream) { #ifdef ZLIB if(stream&0xC000) - { - uint8 t[4]; + { + uint32 t; #ifndef LSB_FIRST uint8 x[4]; #endif if(stream&0x8000) - { + { ZIPWRAP *wz; wz=(ZIPWRAP*)desctable[(stream&255)-1]; if(wz->location+4>wz->size) {return 0;} - *(uint32 *)t=*(uint32 *)(wz->data+wz->location); + memcpy(&t, wz->data+wz->location, 4); wz->location+=4; } else if(stream&0x4000) @@ -342,7 +342,7 @@ int FASTAPASS(2) FCEU_read32(void *Bufo, int stream) x[3]=t[0]; *(uint32*)Bufo=*(uint32*)x; #else - *(uint32*)Bufo=*(uint32*)t; + memcpy(Bufo, &t, 4); #endif return 1; } @@ -357,7 +357,7 @@ int FASTAPASS(1) FCEU_fgetc(int stream) { #ifdef ZLIB if(stream&0x4000) - return gzgetc(desctable[(stream&255)-1]); + return gzgetc(desctable[(stream&255)-1]); else if(stream&0x8000) { ZIPWRAP *wz; diff --git a/ines.c b/ines.c index 8e244ae..ad1e926 100644 --- a/ines.c +++ b/ines.c @@ -80,7 +80,7 @@ static DECLFR(TrainerRead) return(trainerpoo[A&0x1FF]); } -static void iNESGI(int h) +static void iNESGI(int h, void *param) { switch(h) { @@ -121,7 +121,16 @@ static void iNESGI(int h) if(trainerpoo) {FCEU_gfree(trainerpoo);trainerpoo=0;} } break; - } + case GI_INFOSTRING: + { + int MapperNo; + MapperNo = (head.ROM_type>>4); + MapperNo|=(head.ROM_type2&0xF0); + sprintf(param, "iNES, %s, Mapper: %d%s%s", PAL?"PAL":"NTSC", + MapperNo, (head.ROM_type&2)?", BB":"", (head.ROM_type&4)?", T":""); + } + break; + } } uint32 iNESGameCRC32=0; @@ -1110,8 +1119,3 @@ static int NewiNES_Init(int num) return(0); } -iNES_HEADER *iNESGetHead(void) -{ - return &head; -} - diff --git a/input.c b/input.c index ba07072..0d4a9af 100644 --- a/input.c +++ b/input.c @@ -46,8 +46,6 @@ static uint8 joy_readbit[2]; static uint8 joy[4]={0,0,0,0}; static uint8 LastStrobe; -extern int coinon; - static int FSDisable=0; /* Set to 1 if NES-style four-player adapter is disabled. */ static int JPAttrib[2]={0,0}; static int JPType[2]={0,0}; @@ -350,6 +348,7 @@ void FCEUI_SetInputFC(int type, void *ptr, int attrib) void FCEU_DoSimpleCommand(int cmd) { + printf("FCEU_DoSimpleCommand: %i\n", cmd); switch(cmd) { case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break; diff --git a/movie.c b/movie.c index e44724b..2875dba 100644 --- a/movie.c +++ b/movie.c @@ -440,6 +440,7 @@ strcpy(origname,fname); else { // unsupported version + printf("movie: unsupported version\n"); fclose(fp); return; } @@ -485,7 +486,8 @@ strcpy(origname,fname); } #endif - if(!FCEUSS_LoadFP(fp,1)) return; + // Loading new savestates doesn't work and even breaks FDS + //if(!FCEUSS_LoadFP(fp,1)) return; ResetInputTypes(); diff --git a/movie.h b/movie.h index df7de25..643773f 100644 --- a/movie.h +++ b/movie.h @@ -21,5 +21,6 @@ int FCEUMOV_PostLoad(void); extern int current; // > 0 for recording, < 0 for playback extern uint32 framecount; void FCEUI_LoadMovie(char *fname, int _read_only); +void FCEUI_StopMovie(void); #endif /* __MOVIE_H_ */ diff --git a/nsf.c b/nsf.c index cff242b..ea77c6a 100644 --- a/nsf.c +++ b/nsf.c @@ -100,7 +100,7 @@ static NSF_HEADER NSFHeader; void NSFMMC5_Close(void); static uint8 *ExWRAM=0; -void NSFGI(int h) +void NSFGI(int h, void *param) { switch(h) { @@ -123,6 +123,9 @@ void NSFGI(int h) break; case GI_RESETM2: case GI_POWER: NSF_init();break; + case GI_INFOSTRING: + sprintf(param, "NSF, %s", PAL?"PAL":"NTSC"); + break; } } @@ -403,6 +406,7 @@ static int special=0; void DrawNSF(uint8 *XBuf) { char snbuf[16]; + int32 mul=0; int x; if(vismode==0) return; @@ -410,17 +414,17 @@ void DrawNSF(uint8 *XBuf) for (x=0;x<240;x++) memset(XBuf+SCREEN_OFFS+x*SCREEN_WIDTH,0,256); + if(FSettings.SoundVolume) + mul=8192*240/(16384*FSettings.SoundVolume/50)/8; + { - int32 *Bufpl; - int32 mul=0; + int16 *Bufpl; int l; l=GetSoundBuffer(&Bufpl); if(special==0) { - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); for(x=0;x<256;x++) { uint32 y; @@ -431,8 +435,6 @@ void DrawNSF(uint8 *XBuf) } else if(special==1) { - if(FSettings.SoundVolume) - mul=8192*240/(8192*FSettings.SoundVolume/50); for(x=0;x<256;x++) { double r; @@ -449,8 +451,6 @@ void DrawNSF(uint8 *XBuf) else if(special==2) { static double theta=0; - if(FSettings.SoundVolume) - mul=8192*240/(16384*FSettings.SoundVolume/50); for(x=0;x<128;x++) { double xc,yc; diff --git a/sound.c b/sound.c index 7e130fa..370664b 100644 --- a/sound.c +++ b/sound.c @@ -869,8 +869,6 @@ void SetNESSoundMap(void) SetReadHandler(0x4015,0x4015,Read_PSG); } -static int32 WaveNSF[2048]; - int32 highp; // 0 through 65536, 0 = no high pass, 65536 = max high pass int32 lowp; // 0 through 65536, 65536 = max low pass(total attenuation) @@ -923,17 +921,6 @@ int FlushEmulateSound(void) GameExpSound.Fill(end&0xF); FilterSound(Wave,WaveFinalMono,end>>4); -// printf("count %d, num ints %d\n", end, (end >> 4)); - if(FCEUGameInfo.type==GIT_NSF) - { - int x;//,s=0,si=end/1024; - for(x=0;x<1024;x++) - { - //WaveNSF[x]=WaveFinal[s>>4]; - WaveNSF[x]=WaveFinalMono[x]; - //s+=si; - } - } if(end&0xF) Wave[0]=Wave[(end>>4)]; @@ -948,9 +935,9 @@ int FlushEmulateSound(void) return(end); } -int GetSoundBuffer(int32 **W) +int GetSoundBuffer(int16 **W) { - *W=WaveNSF; + *W=WaveFinalMono; return inbuf; } diff --git a/sound.h b/sound.h index b995633..c8d2618 100644 --- a/sound.h +++ b/sound.h @@ -70,7 +70,7 @@ extern int32 fhinc; uint8 FCEU_GetJoyJoy(void); -int GetSoundBuffer(int32 **W); +int GetSoundBuffer(int16 **W); int FlushEmulateSound(void); extern uint32 Wave[2048]; extern int32 WaveFinal[2048]; diff --git a/unif.c b/unif.c index dda5d7f..60928fd 100644 --- a/unif.c +++ b/unif.c @@ -62,8 +62,8 @@ static CartInfo UNIFCart; static int vramo; static int mirrortodo; -static uint8 *boardname; -static uint8 *sboardname; +static char *boardname; +static char *sboardname; static uint32 CHRRAMSize; uint8 *UNIFchrrama=0; @@ -274,7 +274,7 @@ static int LoadPRG(int fp) static int SetBoardName(int fp) { - if(!(boardname=(uint8 *)FCEU_malloc(uchead.info+1))) + if(!(boardname=FCEU_malloc(uchead.info+1))) return(0); FCEU_fread(boardname,1,uchead.info,fp); boardname[uchead.info]=0; @@ -470,7 +470,7 @@ static int InitializeBoard(void) while(bmap[x].name) { - if(!strcmp((char *)sboardname,(char *)bmap[x].name)) + if(!strcmp(sboardname,(char *)bmap[x].name)) { if(!malloced[16]) { @@ -498,7 +498,7 @@ static int InitializeBoard(void) return(0); } -static void UNIFGI(int h) +static void UNIFGI(int h, void *param) { switch(h) { @@ -517,6 +517,14 @@ static void UNIFGI(int h) UNIFCart.Close(); FreeUNIF(); break; + case GI_INFOSTRING: + { + char board[24]; + strncpy(board, sboardname, 20); + board[20] = 0; + sprintf(param, "UNIF, %s, %s%s", board, PAL?"PAL":"NTSC", UNIFCart.battery?", BB":""); + } + break; } } diff --git a/vsuni.h b/vsuni.h index 14fb715..c44d839 100644 --- a/vsuni.h +++ b/vsuni.h @@ -5,3 +5,6 @@ void FCEU_VSUniDraw(uint8 *XBuf); void FCEU_VSUniToggleDIP(int); /* For movies and netplay */ void FCEU_VSUniCoin(void); void FCEU_VSUniSwap(uint8 *j0, uint8 *j1); + +extern uint8 coinon; +