1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 1998 BERO
5 * Copyright (C) 2002 Ben Parnell
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
57 #include "drivers/gp2x/asmutils.h"
63 static void (*RefreshLine)(uint8 *P, uint32 vofs) = NULL;
64 static void PRefreshLine(void);
66 static void ResetPPU(void);
67 static void PowerPPU(void);
69 uint64 timestampbase=0;
75 uint32 MMC5HackVROMMask;
76 uint8 *MMC5HackExNTARAMPtr;
77 uint8 *MMC5HackVROMPTR;
78 uint8 MMC5HackCHRMode=0;
80 uint8 MMC5HackSPScroll;
83 uint8 *MMC5SPRVPage[8];
84 uint8 *MMC5BGVPage[8];
87 uint8 VRAMBuffer,PPUGenLatch;
93 /* Color deemphasis emulation. Joy... */
95 static int deempcnt[8];
100 void (*GameInterface)(int h);
102 void FP_FASTAPASS(1) (*PPU_hook)(uint32 A);
104 void (*GameStateRestore)(int version);
105 void (*GameHBIRQHook)(void), (*GameHBIRQHook2)(void);
107 readfunc ARead[0x10000];
108 writefunc BWrite[0x10000];
109 static readfunc *AReadG;
110 static writefunc *BWriteG;
114 static void asmcpu_update(int32 cycles)
116 // some code from x6502.c
130 if((PSG[0x10]&0x80) && !(PSG[0x10]&0x40))
132 extern uint8 SIRQStat;
134 X6502_IRQBegin(FCEU_IQDPCM);
140 void asmcpu_unpack(void)
142 nes_registers[0] = X.A << 24;
143 nes_registers[1] = X.X;
144 nes_registers[2] = X.Y;
146 nes_registers[3] = X.PC;
148 nes_registers[4] = X.S << 24;
149 nes_registers[4]|= X.IRQlow << 8;
150 nes_registers[7] = (uint32)X.count << 16;
153 nes_registers[4]|= X.P & 0x5d;
154 nes_registers[5] = X.P << 24; // N
155 if (!(X.P&0x02)) nes_registers[5] |= 1; // Z
158 void asmcpu_pack(void)
160 X.A = nes_registers[0] >> 24;
161 X.X = nes_registers[1];
162 X.Y = nes_registers[2];
163 X.PC= nes_registers[3] - pc_base;
164 X.S = nes_registers[4] >> 24;
165 X.IRQlow = nes_registers[4] >> 8;
166 X.count = (int32) nes_registers[7] >> 16;
169 X.P = nes_registers[4] & 0x5d;
170 if ( nes_registers[5]&0x80000000) X.P |= 0x80; // N
171 if (!(nes_registers[5]&0x000000ff)) X.P |= 0x02; // Z
185 int AllocGenieRW(void)
187 if(!(AReadG=FCEU_malloc(0x8000*sizeof(readfunc))))
189 if(!(BWriteG=FCEU_malloc(0x8000*sizeof(writefunc))))
195 void FlushGenieRW(void)
201 for(x=0;x<0x8000;x++)
203 ARead[x+0x8000]=AReadG[x];
204 BWrite[x+0x8000]=BWriteG[x];
214 readfunc FASTAPASS(1) GetReadHandler(int32 a)
216 if(a>=0x8000 && RWWrap)
217 return AReadG[a-0x8000];
222 void FASTAPASS(3) SetReadHandler(int32 start, int32 end, readfunc func)
230 for(x=end;x>=start;x--)
233 AReadG[x-0x8000]=func;
239 for(x=end;x>=start;x--)
243 writefunc FASTAPASS(1) GetWriteHandler(int32 a)
245 if(RWWrap && a>=0x8000)
246 return BWriteG[a-0x8000];
251 void FASTAPASS(3) SetWriteHandler(int32 start, int32 end, writefunc func)
259 for(x=end;x>=start;x--)
262 BWriteG[x-0x8000]=func;
267 for(x=end;x>=start;x--)
274 uint32 TempAddr,RefreshAddr;
277 /* scanline is equal to the current visible scanline we're on. */
281 uint8 GameMemBlock[131072] __attribute__ ((aligned (4)));
282 uint8 NTARAM[0x800] __attribute__ ((aligned (4)));
283 uint8 PALRAM[0x20] __attribute__ ((aligned (4)));
284 #if !defined(ASM_6502) || defined(DEBUG_ASM_6502)
285 uint8 RAM[0x800] __attribute__ ((aligned (4)));
294 #define MMC5BGVRAMADR(V) &MMC5BGVPage[(V)>>10][(V)]
295 #define VRAMADR(V) &VPage[(V)>>10][(V)]
297 static int linestartts;
300 static void ResetRL(void)
302 linestartts=timestamp*48+X6502_GetCycleCount();
306 static INLINE void Fixit1(void);
308 static void TryFixit1(void)
310 #define TOFIXNUM (272-0x4)
313 if (scanline < 240 && tofix)
315 lastpixel = (timestamp*48-linestartts)>>4;
316 if (PAL) lastpixel += lastpixel>>4;
318 //printf("lastpixel: %i\n", lastpixel);
320 if(lastpixel>=TOFIXNUM)
357 ret|=PPUGenLatch&0x1F;
361 //dprintf("r [2002] %02x",ret);
376 uint32 tmp=RefreshAddr&0x3FFF;
382 if(PPU_hook) PPU_hook(tmp);
383 PPUGenLatch=VRAMBuffer;
386 VRAMBuffer=VPage[tmp>>10][tmp];
390 VRAMBuffer=vnapage[(tmp>>10)&0x3][tmp&0x3FF];
393 if (INC32) RefreshAddr+=32;
395 if(PPU_hook) PPU_hook(RefreshAddr&0x3fff);
396 dprintf("r [2007] %02x",ret);
418 //printf("$%04x:$%02x, %d\n",X.PC,V,scanline);
446 //printf("$%02x:$%02x\n",PPUSPL,V);
486 TempAddr|=(V&0x3f)<<8;
493 RefreshAddr=TempAddr;
495 PPU_hook(RefreshAddr);
503 uint32 tmp=RefreshAddr&0x3FFF;
509 PALRAM[0x00]=PALRAM[0x04]=PALRAM[0x08]=PALRAM[0x0C]=V&0x3f;
510 else if(tmp&3) PALRAM[(tmp&0x1f)]=V&0x3f;
514 if(PPUCHRRAM&(1<<(tmp>>10)))
515 VPage[tmp>>10][tmp]=V;
519 if(PPUNTARAM&(1<<((tmp&0xF00)>>10)))
520 vnapage[((tmp&0xF00)>>10)][tmp&0x3FF]=V;
522 if (INC32) RefreshAddr+=32;
524 if(PPU_hook) PPU_hook(RefreshAddr&0x3fff);
533 B2004(0x2004,X.DB=ARead[t+x](t+x));
534 X6502_AddCycles(512);
537 void BGRender(uint8 *target)
540 vofs=((PPU[0]&0x10)<<8) | ((RefreshAddr>>12)&7);
546 RefreshLine(target-XOffset, vofs);
557 *(uint32 *)target=*(uint32 *)(target+4)=tem;
562 int FSkip_setting=-1; // auto
564 void FCEUI_FrameSkip(int x)
570 /* This is called at the beginning of each visible scanline */
571 static void Loop6502(void)
575 uint8 *target=XBuf+scanline*320+32;
577 if(ScreenON || SpriteON)
579 /* PRefreshLine() will not get called on skipped frames. This
580 could cause a problem, but the solution would be rather complex,
581 due to the current sprite 0 hit code.
589 if(scanline>=FSettings.FirstSLine && scanline<=Settings.LastSLine)
599 tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24);
601 FCEU_dwmemset(target,tem,264);
606 if (SpriteON && scanline)
607 RefreshSprite(target);
615 ((uint32 *)target)[x]=((uint32*)target)[x]&0xF0F0F0F0;
618 if((PPU[1]>>5)==0x7) block_or(target, 256, 0xc0);
619 else if(PPU[1]&0xE0) block_andor(target, 256, 0x3f, 0x40);
620 else block_andor(target, 256, 0x3f, 0x80);
624 ((uint32 *)target)[x]=(((uint32*)target)[x])|0xc0c0c0c0;
627 ((uint32 *)target)[x]=(((uint32*)target)[x]&0x3f3f3f3f)|0x40404040;
630 ((uint32 *)target)[x]=(((uint32*)target)[x]&0x3f3f3f3f)|0x80808080;
633 ((uint32 *)target)[-2]=((uint32 *)target)[-1]=0;
634 ((uint32 *)target)[64]=((uint32 *)target)[65]=0;
641 tem=Pal[0]|(Pal[0]<<8)|(Pal[0]<<16)|(Pal[0]<<24);
642 FCEU_dwmemset(target,tem,256);
644 if(InputScanlineHook)
645 InputScanlineHook(target, scanline);
648 #define PAL(c) ((c)+cc)
651 static void PRefreshLine(void)
657 if (BGAdrHI) vofs = 0x1000;
659 vofs+=(RefreshAddr>>12)&7;
665 zz2=(uint8)((RefreshAddr>>10)&3);
666 PPU_hook(0x2000|(RefreshAddr&0xFFF));
667 no = vnapage[zz2][(RefreshAddr&0x3ff)];
668 PPU_hook((no<<4)+vofs);
669 if((RefreshAddr&0x1f)==0x1f)
676 /* This high-level graphics MMC5 emulation code was written
677 for MMC5 carts in "CL" mode. It's probably not totally
678 correct for carts in "SL" mode.
680 static void RefreshLine_MMC5Hack1(uint8 *P, uint32 vofs)
684 tochange=MMC5HackSPMode&0x1F;
686 for(X1=33;X1;X1--,P+=8)
692 if((tochange<=0 && MMC5HackSPMode&0x40) ||
693 (tochange>0 && !(MMC5HackSPMode&0x40)))
698 ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
699 if(ys>=0x1E) ys-=0x1E;
700 vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
702 C = MMC5HackVROMPTR+vadr;
703 C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12);
705 cc=MMC5HackExNTARAMPtr[0x3c0+(xs>>2)+((ys&0x1C)<<1)];
706 cc=((cc >> ((xs&2) + ((ys&0x2)<<1))) &3) <<2;
711 zz2=(RefreshAddr>>10)&3;
712 vadr=(vnapage[zz2][RefreshAddr&0x3ff]<<4)+vofs;
713 C = MMC5BGVRAMADR(vadr);
714 cc=vnapage[zz2][0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)];
715 cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
719 if((RefreshAddr&0x1f)==0x1f)
727 static void RefreshLine_MMC5Hack2(uint8 *P, uint32 vofs)
731 tochange=MMC5HackSPMode&0x1F;
733 for(X1=33;X1;X1--,P+=8)
740 if((tochange<=0 && MMC5HackSPMode&0x40) ||
741 (tochange>0 && !(MMC5HackSPMode&0x40)))
746 ys=((scanline>>3)+MMC5HackSPScroll)&0x1F;
747 if(ys>=0x1E) ys-=0x1E;
748 vadr=(MMC5HackExNTARAMPtr[xs|(ys<<5)]<<4)+(vofs&7);
750 C = MMC5HackVROMPTR+vadr;
751 C += ((MMC5HackSPPage & 0x3f & MMC5HackVROMMask) << 12);
753 cc=MMC5HackExNTARAMPtr[0x3c0+(xs>>2)+((ys&0x1C)<<1)];
754 cc=((cc >> ((xs&2) + ((ys&0x2)<<1))) &3) <<2;
759 zz2=(RefreshAddr>>10)&3;
760 vadr = (vnapage[zz2][RefreshAddr & 0x3ff] << 4) + vofs;
761 C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f &
762 MMC5HackVROMMask) << 12) + (vadr & 0xfff);
763 vadr = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>> 4;
767 if((RefreshAddr&0x1f)==0x1f)
775 static void RefreshLine_MMC5Hack3(uint8 *P, uint32 vofs)
779 for(X1=33;X1;X1--,P+=8)
787 zz2=(RefreshAddr>>10)&3;
788 vadr = (vnapage[zz2][RefreshAddr & 0x3ff] << 4) + vofs;
789 C += (((MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff]) & 0x3f &
790 MMC5HackVROMMask) << 12) + (vadr & 0xfff);
791 vadr = (MMC5HackExNTARAMPtr[RefreshAddr & 0x3ff] & 0xC0)>> 4;
795 if((RefreshAddr&0x1f)==0x1f)
802 static void RefreshLine_MMC5Hack4(uint8 *P, uint32 vofs)
806 for(X1=33;X1;X1--,P+=8)
813 zz2=(RefreshAddr>>10)&3;
814 vadr=(vnapage[zz2][RefreshAddr&0x3ff]<<4)+vofs;
815 C = MMC5BGVRAMADR(vadr);
816 cc=vnapage[zz2][0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)];
817 cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
821 if((RefreshAddr&0x1f)==0x1f)
828 static void RefreshLine_PPU_hook(uint8 *P, uint32 vofs)
832 for(X1=33;X1;X1--,P+=8)
839 zz2=(RefreshAddr>>10)&3;
840 PPU_hook(0x2000|(RefreshAddr&0xFFF));
841 cc=vnapage[zz2][0x3c0+(zz>>2)+((RefreshAddr&0x380)>>4)];
842 cc=((cc >> ((zz&2) + ((RefreshAddr&0x40)>>4))) &3) <<2;
843 vadr=(vnapage[zz2][RefreshAddr&0x3ff]<<4)+vofs;
850 if((RefreshAddr&0x1f)==0x1f)
857 static void RefreshLine_normal(uint8 *P, uint32 vofs) // vofs is 0x107 max
860 uint32 rfraddr = RefreshAddr;
861 uint8 *page = vnapage[(rfraddr>>10)&3];
864 if ((rfraddr&0xc)!=0)
865 cc2=*(uint32 *) (page + ((rfraddr&0x380)>>4) + ((rfraddr&0x10)>>2) + 0x3c0);
867 for (X1=33;X1;X1--,P+=8)
872 vadr=(page[rfraddr&0x3ff]<<4)+vofs;
874 if ((rfraddr&0xc)==0)
875 cc2=*(uint32 *) (page + ((rfraddr&0x380)>>4) + ((rfraddr&0x10)>>2) + 0x3c0);
876 cc=((cc2 >> ((rfraddr&2) + ((rfraddr&0x40)>>4) + ((rfraddr&0xc)<<1))) & 3) << 2;
880 if((rfraddr&0x1f)==0x1f) {
882 page = vnapage[(rfraddr>>10)&3];
886 RefreshAddr = rfraddr;
889 static void SetRefreshLine(void)
891 if(MMC5Hack && geniestage!=1)
893 if(MMC5HackCHRMode==0 && (MMC5HackSPMode&0x80))
895 if (RefreshLine != RefreshLine_MMC5Hack1) printf("set refr RefreshLine_MMC5Hack1\n");
896 RefreshLine = RefreshLine_MMC5Hack1;
898 else if(MMC5HackCHRMode==1 && (MMC5HackSPMode&0x80))
900 if (RefreshLine != RefreshLine_MMC5Hack2) printf("set refr RefreshLine_MMC5Hack2\n");
901 RefreshLine = RefreshLine_MMC5Hack2;
903 else if(MMC5HackCHRMode==1)
905 if (RefreshLine != RefreshLine_MMC5Hack3) printf("set refr RefreshLine_MMC5Hack3\n");
906 RefreshLine = RefreshLine_MMC5Hack3;
910 if (RefreshLine != RefreshLine_MMC5Hack4) printf("set refr RefreshLine_MMC5Hack4\n");
911 RefreshLine = RefreshLine_MMC5Hack4;
913 } // End if(MMC5Hack)
916 if (RefreshLine != RefreshLine_PPU_hook) printf("set refr RefreshLine_PPU_hook\n");
917 RefreshLine = RefreshLine_PPU_hook;
921 if (RefreshLine != RefreshLine_normal) printf("set refr RefreshLine_normal\n");
922 RefreshLine = RefreshLine_normal;
929 if(ScreenON || SpriteON)
931 uint32 rad=RefreshAddr;
933 rad|=TempAddr&0x041f;
935 //PPU_hook(RefreshAddr,-1);
942 if(ScreenON || SpriteON)
944 uint32 rad=RefreshAddr;
946 if((rad&0x7000)==0x7000)
949 if((rad&0x3E0)==0x3A0)
956 if((rad&0x3E0)==0x3e0)
964 //PPU_hook(RefreshAddr,-1);
969 /* This is called at the beginning of all h-blanks on visible lines. */
970 static void DoHBlank(void)
972 if(ScreenON || SpriteON)
974 if(GameHBIRQHook && (ScreenON || SpriteON) && ((PPU[0]&0x38)!=0x18))
984 X6502_Run(6); // Tried 65, caused problems with Slalom(maybe others)
988 if(GameHBIRQHook2 && (ScreenON || SpriteON))
991 //fprintf(stderr,"%3d: $%04x\n",scanline,RefreshAddr);
999 // ============================//
1001 // ===========================//
1003 void ResetMapping(void)
1007 SetReadHandler(0x0000,0xFFFF,ANull);
1008 SetWriteHandler(0x0000,0xFFFF,BNull);
1010 SetReadHandler(0,0x7FF,ARAML);
1011 SetWriteHandler(0,0x7FF,BRAML);
1013 SetReadHandler(0x800,0x1FFF,ARAMH); /* Part of a little */
1014 SetWriteHandler(0x800,0x1FFF,BRAMH); /* hack for a small speed boost. */
1016 for(x=0x2000;x<0x4000;x+=8)
1036 BWrite[0x4014]=B4014;
1042 void CloseGame(void)
1046 if(FCEUGameInfo.type!=GIT_NSF)
1047 FCEU_FlushGameCheats(0,0);
1049 if(FSettings.NetworkPlay) KillNetplay();
1051 GameInterface(GI_CLOSE);
1057 void ResetGameLoaded(void)
1059 if(GameLoaded) CloseGame();
1062 GameHBIRQHook=GameHBIRQHook2=0;
1063 GameExpSound.Fill=0;
1064 GameExpSound.RChange=0;
1065 if(GameExpSound.Kill)
1066 GameExpSound.Kill();
1067 GameExpSound.Kill=0;
1073 FCEUGameInfo.name=0;
1074 FCEUGameInfo.type=GIT_CART;
1075 FCEUGameInfo.vidsys=GIV_USER;
1076 FCEUGameInfo.input[0]=FCEUGameInfo.input[1]=-1;
1077 FCEUGameInfo.inputfc=-1;
1080 char lastLoadedGameName [2048];
1081 int UNIFLoad(const char *name, int fp);
1082 int iNESLoad(const char *name, int fp);
1083 int FDSLoad(const char *name, int fp);
1084 int NSFLoad(int fp);
1086 FCEUGI *FCEUI_LoadGame(char *name)
1095 strncpy(name2, name, sizeof(name2));
1096 name2[sizeof(name2)-1] = 0;
1098 fp=FCEU_fopen(name2,"rb");
1101 FCEU_PrintError("Error opening \"%s\"!",name);
1106 char *p = name2 + strlen(name2) - 4;
1107 if (strcmp(p, ".fcm") == 0)
1110 printf("movie detected\n");
1113 fp=FCEU_fopen(name2,"rb");
1115 printf("no ROM for movie\n");
1122 strcpy(lastLoadedGameName, name2);
1125 if(iNESLoad(name2,fp))
1129 if(FDSLoad(name2,fp))
1131 if(UNIFLoad(name2,fp))
1134 FCEU_PrintError("An error occurred while loading the file.");
1143 if(FCEUGameInfo.type!=GIT_NSF)
1144 if(FSettings.GameGenie)
1149 if(FSettings.NetworkPlay) InitNetplay();
1152 if(FCEUGameInfo.type!=GIT_NSF)
1154 FCEU_LoadGamePalette();
1155 FCEU_LoadGameCheats(0);
1158 FCEU_ResetPalette();
1162 FCEUI_LoadMovie(name, 1);
1163 return(&FCEUGameInfo);
1167 void FCEU_ResetVidSys(void)
1171 if(FCEUGameInfo.vidsys==GIV_NTSC)
1173 else if(FCEUGameInfo.vidsys==GIV_PAL)
1181 FSettings.FirstSLine=FSettings.UsrFirstSLine[1];
1182 FSettings.LastSLine=FSettings.UsrLastSLine[1];
1187 FSettings.FirstSLine=FSettings.UsrFirstSLine[0];
1188 FSettings.LastSLine=FSettings.UsrLastSLine[0];
1190 printf("PAL = %i\n", PAL);
1191 SetSoundVariables();
1194 int FCEUI_Initialize(void)
1196 if(!InitVirtualVideo())
1198 memset(&FSettings,0,sizeof(FSettings));
1199 FSettings.UsrFirstSLine[0]=8;
1200 FSettings.UsrFirstSLine[1]=0;
1201 FSettings.UsrLastSLine[0]=FSettings.UsrLastSLine[1]=239;
1202 FSettings.SoundVolume=100;
1206 void MMC5_hb(int); /* Ugh ugh ugh. */
1207 static INLINE void Thingo(void)
1211 if(MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
1213 // check: Battletoads & Double Dragon
1220 // sky glitches in SMB1 if done wrong
1221 X6502_Run(tosprite);
1223 X6502_Run(256-tosprite);
1235 uint32 scanlines_per_frame = PAL ? 312 : 262;
1237 FCEU_ApplyPeriodicCheats();
1240 if(ppudead) /* Needed for Knight Rider, possibly others. */
1242 //memset(XBuf, 0, 320*240);
1243 X6502_Run(scanlines_per_frame*(256+85));
1251 PPU[3]=PPUSPL=0; /* Not sure if this is correct. According
1252 to Matt Conte and my own tests, it is. Timing is probably
1253 off, though. NOTE: Not having this here
1254 breaks a Super Donkey Kong game. */
1256 X6502_Run(12); /* I need to figure out the true nature and length
1259 if(FCEUGameInfo.type==GIT_NSF)
1264 // Note: this is needed for asm core
1265 // Warning: using 'scanline' var here breaks Castlevania III
1268 X6502_Run(256+85-12);
1269 for (lines=scanlines_per_frame-242-1;lines;lines--)
1272 // X6502_Run((scanlines_per_frame-242)*(256+85)-12);
1277 if(ScreenON || SpriteON)
1282 for(x=0;x<42;x++) {PPU_hook(0x2000); PPU_hook(0);} // ugh
1289 if(ScreenON || SpriteON)
1291 RefreshAddr=TempAddr;
1292 if(PPU_hook) PPU_hook(RefreshAddr&0x3fff);
1300 if(FCEUGameInfo.type==GIT_NSF)
1302 // run scanlines for asm core to fuction
1303 for(scanline=0;scanline<240;scanline++)
1312 for(scanline=0;scanline<240;) // scanline is incremented in DoLine. Evil. :/
1317 if(MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline);
1318 for(x=1,max=0,maxref=0;x<7;x++)
1327 SetNESDeemph(maxref,0);
1334 ssize=FlushEmulateSound();
1336 timestampbase += timestamp;
1342 FCEU_PutImageDummy();
1344 FCEUD_Update(0,WaveFinalMono,ssize);
1350 FCEUD_Update(XBuf+8,WaveFinalMono,ssize);
1364 #include <sys/time.h>
1367 void FCEUI_Emulate(void)
1370 uint64 starttime,end;
1373 gettimeofday(&tv,0);
1374 starttime=((uint64)tv.tv_sec*1000000)+tv.tv_usec;
1379 // Probably won't work well on Windows port; for
1380 // debugging/speed testing.
1384 gettimeofday(&tv,0);
1385 end=((uint64)tv.tv_sec*1000000)+tv.tv_usec;
1386 w=frcount*10000000000LL/(end-starttime);
1389 printf("Average FPS: %d.%04d\n",i,frac);
1395 void FCEUI_CloseGame(void)
1400 static void ResetPPU(void)
1402 VRAMBuffer=PPU[0]=PPU[1]=PPU[2]=PPU[3]=0;
1405 RefreshAddr=TempAddr=0;
1411 static void PowerPPU(void)
1413 memset(NTARAM,0x00,0x800);
1414 memset(PALRAM,0x00,0x20);
1415 memset(SPRAM,0x00,0x100);
1421 if(!GameLoaded) return;
1422 GameInterface(GI_RESETM2);
1430 if(!GameLoaded) return;
1432 FCEU_CheatResetRAM();
1433 FCEU_CheatAddRAM(2,0,RAM);
1437 memset(RAM,0x00,0x800);
1439 GameInterface(GI_POWER);
1447 /* savestate stuff */
1448 uint16 TempAddrT,RefreshAddrT;
1450 SFORMAT FCEUPPU_STATEINFO[]={
1451 { NTARAM, 0x800, "NTAR"},
1452 { PALRAM, 0x20, "PRAM"},
1453 { SPRAM, 0x100, "SPRA"},
1454 { PPU, 0x4, "PPUR"},
1455 { &XOffset, 1, "XOFF"},
1456 { &vtoggle, 1, "VTOG"},
1457 { &RefreshAddrT, 2|RLSB, "RADD"},
1458 { &TempAddrT, 2|RLSB, "TADD"},
1459 { &VRAMBuffer, 1, "VBUF"},
1460 { &PPUGenLatch, 1, "PGEN"},
1462 { &kook, 1, "KOOK"},
1463 { &ppudead, 1, "DEAD"},
1464 { &PPUSPL, 1, "PSPL"},