9 #include "unix-netplay.h"
12 //extern int soundvol;
13 int CLImain(int argc, char *argv[]);
14 extern int gp2x_in_sound_thread;
15 extern void pthread_yield(void);
16 extern void SetVideoScaling(int, int, int);
18 //#define SOUND_RATE 44100
19 #define SOUND_RATE 22050
22 CFGSTRUCT DriverConfig[]={
46 //-fshack x Set the environment variable SDL_VIDEODRIVER to \"x\" when
47 // entering full screen mode and x is not \"0\".
50 "-xres x Set horizontal resolution to x for full screen mode.\n\
51 -yres x Set vertical resolution to x for full screen mode.\n\
52 -xscale(fs) x Multiply width by x.\n\
53 -yscale(fs) x Multiply height by x.\n\
54 -efx(fs) x Enable scanlines effect if x is non zero. yscale must be >=2\n\
55 and preferably a multiple of 2.\n\
56 -fs x Select full screen mode if x is non zero.\n\
57 -joyx y Use joystick y as virtual joystick x.\n\
60 Otherwise, x = playback rate.\n\
63 "-f8bit x Force 8-bit sound.\n\
68 "-lbufsize x Internal FCE Ultra sound buffer size. Size = 2^x samples.\n\
69 -ebufsize x External SDL sound buffer size. Size = 2^x samples.\n\
72 "-connect s Connect to server 's' for TCP/IP network play.\n\
73 -server Be a host/server for TCP/IP network play.\n\
74 -netport x Use TCP/IP port x for network play.";
77 static int docheckie[2]={0,0};
79 ARGPSTRUCT DriverArgs[]={
80 {"-joy1",0,&joy[0],0},{"-joy2",0,&joy[1],0},
81 {"-joy3",0,&joy[2],0},{"-joy4",0,&joy[3],0},
82 {"-xscale",0,&_xscale,0},
83 {"-yscale",0,&_yscale,0},
85 {"-xscalefs",0,&_xscalefs,0},
86 {"-yscalefs",0,&_yscalefs,0},
87 {"-efxfs",0,&_efxfs,0},
90 {"-fs",0,&_fullscreen,0},
91 //{"-fshack",0,&_fshack,0x4001},
92 {"-sound",0,&_sound,0},
94 {"-f8bit",0,&_f8bit,0},
96 {"-lbufsize",0,&_lbufsize,0},
97 {"-ebufsize",0,&_ebufsize,0},
100 {"-connect",&docheckie[0],&netplayhost,0x4001},
101 {"-server",&docheckie[1],0,0},
102 {"-netport",0,&Port,0},
111 void GetBaseDirectory(char *BaseDirectory)
116 ol="/mnt/sd/roms/nes";
123 strncpy(BaseDirectory,ol,2047);
124 BaseDirectory[2047]=0;
126 strcat(BaseDirectory,"/fceultra");
128 strcat(BaseDirectory,"/.fceultra");
133 static void SetDefaults(void)
138 _sound=SOUND_RATE; // 48000 wrong
145 _xscale=_yscale=_xscalefs=_yscalefs=1;
147 //_fshack=_fshacksave=0;
148 memset(joy,0,sizeof(joy));
151 void DoDriverArgs(void)
170 else if(docheckie[1])
174 FCEUI_SetNetworkPlay(netplay);
180 memset(joyBMap[x],0,sizeof(joyBMap[0]));
181 memset(joyAMap[x],0,sizeof(joyAMap[0]));
188 void KillMouse(void){}
189 void GetMouseData(uint32 *d)
195 t=SDL_GetMouseState(&x,&y);
207 int InitKeyboard(void)
212 int UpdateKeyboard(void)
217 void KillKeyboard(void)
222 char *GetKeyboard(void)
226 return (char *)(SDL_GetKeyState(0));
231 #include "unix-basedir.h"
233 extern int swapbuttons;
235 int main(int argc, char *argv[])
238 puts("Starting GPFCE - Port version 0.2 05-29-2006");
239 puts("Based on FCE Ultra "VERSION_STRING"...");
240 puts("Ported by Zheng Zhu\n");
243 //gp2x_init (1000, 8, SOUND_RATE, 16, 1, 60);
246 //gp2x_init (1000, 8, SOUND_RATE<<1, 16, 0, 60);
248 gp2x_init (1000, 8, SOUND_RATE, 16, 0, 60);
251 int ret=CLImain(argc,argv);
253 // unscale the screen, in case this is bad.
254 SetVideoScaling(320, 320, 240);
257 // make sure sound thread has exited cleanly
258 while (gp2x_in_sound_thread) pthread_yield();
259 printf("Sound thread exited\n");
260 printf("Exiting main(). terminated");
261 if (showfps && swapbuttons)
263 execl("./selector","./selector","./gpfce_showfps_swapbuttons_config",NULL);
267 execl("./selector","./selector","./gpfce_showfps_config",NULL);
269 else if (swapbuttons)
271 execl("./selector","./selector","./gpfce_swapbuttons_config",NULL);
275 execl("./selector","./selector","./gpfce_config",NULL);
279 gp2x_init (1000, 8, SOUND_RATE, 16, 1, 60);
283 printf("Could not initialize SDL: %s.\n", SDL_GetError());
289 if(getenv("SDL_VIDEODRIVER"))
291 if((_fshacksave=malloc(strlen(getenv("SDL_VIDEODRIVER"))+1)))
292 strcpy(_fshacksave,getenv("SDL_VIDEODRIVER"));
299 int ret=CLImain(argc,argv);
301 // make sure sound thread has exited cleanly
302 while (gp2x_in_sound_thread) pthread_yield();
303 printf("Sound thread exited\n");
304 printf("Exiting main(). terminated");