5 #include "../../driver.h"
6 #include "../common/config.h"
7 #include "../common/args.h"
9 #include "gp2x-video.h"
11 #include "unix-netplay.h"
16 #include "squidgehack.h"
18 int CLImain(int argc, char *argv[]);
20 //#define SOUND_RATE 44100
21 #define SOUND_RATE 22050
24 CFGSTRUCT DriverConfig[]={
25 ACA(Settings.KeyBinds),
26 ACA(Settings.JoyBinds),
27 AC(Settings.turbo_rate_add),
28 AC(Settings.sound_rate),
31 AC(Settings.frameskip),
32 AC(Settings.sstate_confirm),
33 AC(Settings.region_force),
34 AC(Settings.cpuclock),
36 AC(Settings.ramtimings),
44 "-joyx y Use joystick y as virtual joystick x.\n\
47 Otherwise, x = playback rate.\n\
48 -showfps x Display fps counter if x is nonzero\n\
49 -mmuhack x Enable squidge's MMU hack if x is nonzero (GP2X).\n\
50 -ramtimings x Enable RAM overclocking if x is nonzero (GP2X).\n\
53 "-connect s Connect to server 's' for TCP/IP network play.\n\
54 -server Be a host/server for TCP/IP network play.\n\
55 -netport x Use TCP/IP port x for network play."
60 static int docheckie[2]={0,0};
62 ARGPSTRUCT DriverArgs[]={
63 {"-sound",0,&Settings.sound_rate,0},
64 {"-showfps",0,&Settings.showfps,0},
65 {"-mmuhack",0,&Settings.mmuhack,0},
66 {"-ramtimings",0,&Settings.ramtimings,0},
67 {"-menu",0,&ext_menu,0x4001},
68 {"-menustate",0,&ext_state,0x4001},
70 {"-connect",&docheckie[0],&netplayhost,0x4001},
71 {"-server",&docheckie[1],0,0},
72 {"-netport",0,&Port,0},
79 void GetBaseDirectory(char *BaseDirectory)
81 strcpy(BaseDirectory, "fceultra");
84 static void SetDefaults(void)
86 memset(&Settings,0,sizeof(Settings));
87 Settings.cpuclock = 150;
88 Settings.frameskip = -1; // auto
90 Settings.sound_rate = SOUND_RATE;
91 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
93 // default controls, RLDU SEBA
94 Settings.KeyBinds[ 0] = 0x010; // GP2X_UP
95 Settings.KeyBinds[ 4] = 0x020; // GP2X_DOWN
96 Settings.KeyBinds[ 2] = 0x040; // GP2X_LEFT
97 Settings.KeyBinds[ 6] = 0x080; // GP2X_RIGHT
98 Settings.KeyBinds[13] = 0x001; // GP2X_B
99 Settings.KeyBinds[14] = 0x002; // GP2X_X
100 Settings.KeyBinds[12] = 0x100; // GP2X_A
101 Settings.KeyBinds[15] = 0x200; // GP2X_Y
102 Settings.KeyBinds[ 8] = 0x008; // GP2X_START
103 Settings.KeyBinds[ 9] = 0x004; // GP2X_SELECT
106 void DoDriverArgs(void)
111 else if(docheckie[1])
115 FCEUI_SetNetworkPlay(netplay);
124 void KillMouse(void){}
126 void GetMouseData(uint32 *d)
130 int InitKeyboard(void)
135 int UpdateKeyboard(void)
140 void KillKeyboard(void)
145 char *GetKeyboard(void)
152 int mmuhack_status = 0;
156 int main(int argc, char *argv[])
161 puts("Starting GPFCE - Port version " GP2X_PORT_VERSION " (" __DATE__ ")");
162 puts("Based on FCE Ultra "VERSION_STRING"...");
163 puts("Ported by Zheng Zhu");
164 puts("Additional optimization/misc work by notaz\n");
171 ret = CLImain(argc,argv);
173 // unscale the screen, in case this is bad.
174 gp2x_video_RGB_setscaling(0, 320, 240);
176 if (mmuhack_status > 0)
187 /* optional GP2X stuff to be done after config is loaded */
188 void gp2x_opt_setup(void)
190 if (Settings.mmuhack) {
192 printf("squidge hack code finished and returned %s\n", ret > 0 ? "ok" : "fail");
194 mmuhack_status = ret;
196 if (Settings.ramtimings) {
197 printf("setting RAM timings.. "); fflush(stdout);
198 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
199 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
200 printf("done.\n"); fflush(stdout);
204 void gp2x_cpuclock_gamma_update(void)
206 static int prev_cpuclock = 200, prev_gamma = 100;
207 if (Settings.cpuclock != 0 && Settings.cpuclock != prev_cpuclock)
209 set_FCLK(Settings.cpuclock);
210 prev_cpuclock = Settings.cpuclock;
213 if (Settings.gamma != 0 && Settings.gamma != prev_gamma)
215 set_gamma(Settings.gamma);
216 prev_gamma = Settings.gamma;