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)
{
}
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);
}
}
fceugi=FCEUI_LoadGame(lastLoadedGameName);
if (fceugi)
{
+ char infostring[32];
LoadConfig(lastLoadedGameName);
if (Settings.region_force)
FCEUI_SetVidSystem(Settings.region_force - 1);
//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
{
static int deempcnt[8];
FCEUGI FCEUGameInfo;
-void (*GameInterface)(int h);
+void (*GameInterface)(int h, void *param);
void FP_FASTAPASS(1) (*PPU_hook)(uint32 A);
int GameLoaded=0;
void CloseGame(void)
{
+ FCEUI_StopMovie();
if(GameLoaded)
{
if(FCEUGameInfo.type!=GIT_NSF)
#ifdef NETWORK
if(FSettings.NetworkPlay) KillNetplay();
#endif
- GameInterface(GI_CLOSE);
+ GameInterface(GI_CLOSE, 0);
CloseGenie();
GameLoaded=0;
}
void ResetNES(void)
{
if(!GameLoaded) return;
- GameInterface(GI_RESETM2);
+ GameInterface(GI_RESETM2, 0);
ResetSound();
ResetPPU();
X6502_Reset();
memset(RAM,0x00,0x800);
#endif
ResetMapping();
- GameInterface(GI_POWER);
+ GameInterface(GI_POWER, 0);
PowerSound();
PowerPPU();
timestampbase=0;
#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);
#define GI_RESETM2 1
#define GI_POWER 2
#define GI_CLOSE 3
+#define GI_INFOSTRING 11
#include "git.h"
extern FCEUGI FCEUGameInfo;
\r
#define DC_INC 1\r
\r
-void FDSGI(int h)\r
+void FDSGI(int h, void *param)\r
{\r
switch(h)\r
{\r
case GI_CLOSE: FDSClose();break;\r
case GI_POWER: FDSInit();break;\r
+ case GI_INFOSTRING: sprintf(param, "FDS, Sides: %d", TotalSides);break;\r
}\r
}\r
\r
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;
unzCloseCurrentFile(tz);
unzClose(tz);
-
+
return tmp;
}
#endif
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
{
return gzread(desctable[(stream&255)-1],ptr,size*nmemb);
}
else if(stream&0x8000)
- {
+ {
ZIPWRAP *wz;
uint32 total=size*nmemb;
return gzwrite(desctable[(stream&255)-1],ptr,size*nmemb);
}
else if(stream&0x8000)
- {
+ {
return 0;
}
else
if(stream&0x4000)
{
return gzseek(desctable[(stream&255)-1],offset,whence);
- }
+ }
else if(stream&0x8000)
{
ZIPWRAP *wz;
return (-1);
wz->location+=offset;
break;
- }
+ }
return 0;
}
else
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
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)
x[3]=t[0];
*(uint32*)Bufo=*(uint32*)x;
#else
- *(uint32*)Bufo=*(uint32*)t;
+ memcpy(Bufo, &t, 4);
#endif
return 1;
}
{
#ifdef ZLIB
if(stream&0x4000)
- return gzgetc(desctable[(stream&255)-1]);
+ return gzgetc(desctable[(stream&255)-1]);
else if(stream&0x8000)
{
ZIPWRAP *wz;
return(trainerpoo[A&0x1FF]);\r
}\r
\r
-static void iNESGI(int h)\r
+static void iNESGI(int h, void *param)\r
{\r
switch(h)\r
{\r
if(trainerpoo) {FCEU_gfree(trainerpoo);trainerpoo=0;}\r
}\r
break;\r
- }\r
+ case GI_INFOSTRING:\r
+ {\r
+ int MapperNo;\r
+ MapperNo = (head.ROM_type>>4);\r
+ MapperNo|=(head.ROM_type2&0xF0);\r
+ sprintf(param, "iNES, %s, Mapper: %d%s%s", PAL?"PAL":"NTSC",\r
+ MapperNo, (head.ROM_type&2)?", BB":"", (head.ROM_type&4)?", T":"");\r
+ }\r
+ break;\r
+ }\r
}\r
\r
uint32 iNESGameCRC32=0;\r
return(0);\r
}\r
\r
-iNES_HEADER *iNESGetHead(void)\r
-{\r
- return &head;\r
-}\r
-\r
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};
void FCEU_DoSimpleCommand(int cmd)
{
+ printf("FCEU_DoSimpleCommand: %i\n", cmd);
switch(cmd)
{
case FCEUNPCMD_FDSINSERT: FCEU_FDSInsert();break;
else
{
// unsupported version
+ printf("movie: unsupported version\n");
fclose(fp);
return;
}
}
#endif
- if(!FCEUSS_LoadFP(fp,1)) return;
+ // Loading new savestates doesn't work and even breaks FDS
+ //if(!FCEUSS_LoadFP(fp,1)) return;
ResetInputTypes();
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_ */
void NSFMMC5_Close(void);\r
static uint8 *ExWRAM=0;\r
\r
-void NSFGI(int h)\r
+void NSFGI(int h, void *param)\r
{\r
switch(h)\r
{\r
break;\r
case GI_RESETM2:\r
case GI_POWER: NSF_init();break;\r
+ case GI_INFOSTRING:\r
+ sprintf(param, "NSF, %s", PAL?"PAL":"NTSC");\r
+ break;\r
}\r
}\r
\r
void DrawNSF(uint8 *XBuf)\r
{\r
char snbuf[16];\r
+ int32 mul=0;\r
int x;\r
\r
if(vismode==0) return;\r
for (x=0;x<240;x++)\r
memset(XBuf+SCREEN_OFFS+x*SCREEN_WIDTH,0,256);\r
\r
+ if(FSettings.SoundVolume)\r
+ mul=8192*240/(16384*FSettings.SoundVolume/50)/8;\r
+\r
{\r
- int32 *Bufpl;\r
- int32 mul=0;\r
+ int16 *Bufpl;\r
\r
int l;\r
l=GetSoundBuffer(&Bufpl);\r
\r
if(special==0)\r
{\r
- if(FSettings.SoundVolume)\r
- mul=8192*240/(16384*FSettings.SoundVolume/50);\r
for(x=0;x<256;x++)\r
{\r
uint32 y;\r
}\r
else if(special==1)\r
{\r
- if(FSettings.SoundVolume)\r
- mul=8192*240/(8192*FSettings.SoundVolume/50);\r
for(x=0;x<256;x++)\r
{\r
double r;\r
else if(special==2)\r
{\r
static double theta=0;\r
- if(FSettings.SoundVolume)\r
- mul=8192*240/(16384*FSettings.SoundVolume/50);\r
for(x=0;x<128;x++)\r
{\r
double xc,yc;\r
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)
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)];
return(end);
}
-int GetSoundBuffer(int32 **W)
+int GetSoundBuffer(int16 **W)
{
- *W=WaveNSF;
+ *W=WaveFinalMono;
return inbuf;
}
uint8 FCEU_GetJoyJoy(void);
-int GetSoundBuffer(int32 **W);
+int GetSoundBuffer(int16 **W);
int FlushEmulateSound(void);
extern uint32 Wave[2048];
extern int32 WaveFinal[2048];
\r
static int vramo;\r
static int mirrortodo;\r
-static uint8 *boardname;\r
-static uint8 *sboardname;\r
+static char *boardname;\r
+static char *sboardname;\r
\r
static uint32 CHRRAMSize;\r
uint8 *UNIFchrrama=0;\r
\r
static int SetBoardName(int fp)\r
{\r
- if(!(boardname=(uint8 *)FCEU_malloc(uchead.info+1)))\r
+ if(!(boardname=FCEU_malloc(uchead.info+1)))\r
return(0);\r
FCEU_fread(boardname,1,uchead.info,fp);\r
boardname[uchead.info]=0;\r
\r
while(bmap[x].name)\r
{\r
- if(!strcmp((char *)sboardname,(char *)bmap[x].name))\r
+ if(!strcmp(sboardname,(char *)bmap[x].name))\r
{\r
if(!malloced[16])\r
{\r
return(0);\r
}\r
\r
-static void UNIFGI(int h)\r
+static void UNIFGI(int h, void *param)\r
{\r
switch(h)\r
{\r
UNIFCart.Close();\r
FreeUNIF();\r
break;\r
+ case GI_INFOSTRING:\r
+ {\r
+ char board[24];\r
+ strncpy(board, sboardname, 20);\r
+ board[20] = 0;\r
+ sprintf(param, "UNIF, %s, %s%s", board, PAL?"PAL":"NTSC", UNIFCart.battery?", BB":"");\r
+ }\r
+ break;\r
}\r
}\r
\r
void FCEU_VSUniToggleDIP(int); /* For movies and netplay */\r
void FCEU_VSUniCoin(void);\r
void FCEU_VSUniSwap(uint8 *j0, uint8 *j1);\r
+\r
+extern uint8 coinon;\r
+\r