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
22 /* SVGA High Level Routines
34 #define M_PI 3.14159265358979323846
57 static char errmsg[65];
59 void FCEU_PrintError(char *format, ...)
66 vsprintf(temp,format,ap);
67 FCEUD_PrintError(temp);
72 void FCEU_DispMessage(char *format, ...)
77 vsprintf(errmsg,format,ap);
82 printf("%s\n", errmsg);
85 void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall)
87 FSettings.UsrFirstSLine[0]=ntscf;
88 FSettings.UsrLastSLine[0]=ntscl;
89 FSettings.UsrFirstSLine[1]=palf;
90 FSettings.UsrLastSLine[1]=pall;
93 FSettings.FirstSLine=FSettings.UsrFirstSLine[1];
94 FSettings.LastSLine=FSettings.UsrLastSLine[1];
98 FSettings.FirstSLine=FSettings.UsrFirstSLine[0];
99 FSettings.LastSLine=FSettings.UsrLastSLine[0];
104 void FCEUI_SetVidSystem(int a)
111 int FCEUI_GetCurrentVidSystem(int *slstart, int *slend)
114 *slstart=FSettings.FirstSLine;
116 *slend=FSettings.LastSLine;
121 void FCEUI_SetNetworkPlay(int type)
123 FSettings.NetworkPlay=type;
127 void FCEUI_SetGameGenie(int a)
129 FSettings.GameGenie=a?1:0;
140 uint8 CommandQueue=0;
142 static int controlselect=0;
143 static int ntsccol=0;
144 static int ntsctint=46+10;
145 static int ntschue=72;
146 static int controllength=0;
149 void FCEUI_SetSnapName(int a)
151 FSettings.SnapName=a;
154 void FCEUI_SaveExtraDataUnderBase(int a)
156 FSettings.SUnderBase=a;
160 void FCEUI_SelectState(int w)
162 // if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
163 // CommandQueue=42+w;
166 void FCEUI_SaveState(void)
168 // if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
175 void FCEUI_LoadState(void)
177 // if(netplay!=2 && FCEUGameInfo.type!=GIT_NSF)
183 int32 FCEUI_GetDesiredFPS(void)
186 return(838977920); // ~50.007
188 return(1008307711); // ~60.1
191 static int dosnapsave=0;
192 void FCEUI_SaveSnapshot(void)
197 /* I like the sounds of breaking necks. */
198 static void ReallySnap(void)
200 int x=SaveSnapshot();
202 FCEU_DispMessage("Error saving screen snapshot.");
204 FCEU_DispMessage("Screen snapshot %d saved.",x-1);
207 void DriverInterface(int w, void *d)
211 case DES_NTSCCOL:ntsccol=*(int *)d;FCEU_ResetPalette();break;
212 case DES_RESET:if(netplay!=2) CommandQueue=30;break;
213 case DES_POWER:if(netplay!=2) CommandQueue=31;break;
214 case DES_GETNTSCTINT:*(int*)d=ntsctint;break;
215 case DES_GETNTSCHUE:*(int*)d=ntschue;break;
216 case DES_SETNTSCTINT:ntsctint=*(int*)d;if(ntsccol)FCEU_ResetPalette();break;
217 case DES_SETNTSCHUE:ntschue=*(int*)d;if(ntsccol)FCEU_ResetPalette();break;
219 case DES_FDSINSERT:if(netplay!=2) CommandQueue=2;break;
220 case DES_FDSEJECT:if(netplay!=2) CommandQueue=3;break;
221 case DES_FDSSELECT:if(netplay!=2) CommandQueue=1;break;
223 case DES_NSFINC:NSFControl(1);break;
224 case DES_NSFDEC:NSFControl(2);break;
225 case DES_NSFRES:NSFControl(0);break;
227 case DES_VSUNIDIPSET:CommandQueue=10+(int)d;break;
228 case DES_VSUNITOGGLEDIPVIEW:CommandQueue=10;break;
229 case DES_VSUNICOIN:CommandQueue=19;break;
230 case DES_NTSCSELHUE:if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF){controlselect=1;controllength=360;}break;
231 case DES_NTSCSELTINT:if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF){controlselect=2;controllength=360;}break;
234 if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF)
241 which=controlselect==1?ntschue:ntsctint;
254 if(ntsccol && FCEUGameInfo.type!=GIT_VSUNI && !PAL && FCEUGameInfo.type!=GIT_NSF)
259 switch(controlselect)
262 if(ntschue>128) ntschue=128;
266 if(ntsctint>128) ntsctint=128;
281 void FCEU_PutImageDummy(void)
283 if(FCEUGameInfo.type!=GIT_NSF)
285 if(controllength) controllength--;
287 if(howlong) howlong--; /* DrawMessage() */
290 extern uint64 frcount;
298 void FCEU_PutImage(void)
300 if(FCEUGameInfo.type==GIT_NSF)
303 /* Save snapshot after NSF screen is drawn. Why would we want to
314 /* Save snapshot before overlay stuff is written. */
320 if(FCEUGameInfo.type==GIT_VSUNI)
321 FCEU_VSUniDraw(XBuf);
323 //FCEU_DrawSaveStates(XBuf);
324 //FCEU_DrawMovies(XBuf);
325 //FCEU_DrawNTSCControlBars(XBuf);
326 //FCEU_DrawRecordingStatus(XBuf);
328 //if(controllength) {controllength--;DrawBars();}
333 extern uint64 frcount;
341 void DoCommand(uint8 c)
345 case 1:FDSControl(FDS_SELECT);break;
346 case 2:FDSControl(FDS_IDISK);break;
347 case 3:FDSControl(FDS_EJECT);break;
349 case 10:DIPS^=2;break;
350 case 11:vsdip^=1;DIPS|=2;break;
351 case 12:vsdip^=2;DIPS|=2;break;
352 case 13:vsdip^=4;DIPS|=2;break;
353 case 14:vsdip^=8;DIPS|=2;break;
354 case 15:vsdip^=0x10;DIPS|=2;break;
355 case 16:vsdip^=0x20;DIPS|=2;break;
356 case 17:vsdip^=0x40;DIPS|=2;break;
357 case 18:vsdip^=0x80;DIPS|=2;break;
358 case 19:coinon=6;break;
359 case 30:ResetNES();break;
360 case 31:PowerNES();break;
361 case 40:CheckStates();StateShow=0;SaveState();break;
362 case 41:CheckStates();StateShow=0;LoadState();break;
363 case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49:
364 case 50: case 51:StateShow=180;CurrentState=c-42;CheckStates();break;