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"
22 int CLImain(int argc, char *argv[]);
25 CFGSTRUCT DriverConfig[]={
26 ACA(Settings.KeyBinds),
27 ACA(Settings.JoyBinds),
28 AC(Settings.turbo_rate_add),
29 AC(Settings.sound_rate),
32 AC(Settings.frameskip),
33 AC(Settings.sstate_confirm),
34 AC(Settings.region_force),
35 AC(Settings.cpuclock),
37 AC(Settings.ramtimings),
45 "-joyx y Use joystick y as virtual joystick x.\n\
48 Otherwise, x = playback rate.\n\
49 -showfps x Display fps counter if x is nonzero\n\
50 -mmuhack x Enable squidge's MMU hack if x is nonzero (GP2X).\n\
51 -ramtimings x Enable RAM overclocking if x is nonzero (GP2X).\n\
54 "-connect s Connect to server 's' for TCP/IP network play.\n\
55 -server Be a host/server for TCP/IP network play.\n\
56 -netport x Use TCP/IP port x for network play."
61 static int docheckie[2]={0,0};
63 ARGPSTRUCT DriverArgs[]={
64 {"-sound",0,&Settings.sound_rate,0},
65 {"-showfps",0,&Settings.showfps,0},
66 {"-mmuhack",0,&Settings.mmuhack,0},
67 {"-ramtimings",0,&Settings.ramtimings,0},
68 {"-menu",0,&ext_menu,0x4001},
69 {"-menustate",0,&ext_state,0x4001},
71 {"-connect",&docheckie[0],&netplayhost,0x4001},
72 {"-server",&docheckie[1],0,0},
73 {"-netport",0,&Port,0},
80 void GetBaseDirectory(char *BaseDirectory)
82 strcpy(BaseDirectory, "fceultra");
85 static void SetDefaults(void)
87 memset(&Settings,0,sizeof(Settings));
88 Settings.cpuclock = 150;
89 Settings.frameskip = -1; // auto
91 Settings.sound_rate = 22050;
92 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
94 // default controls, RLDU SEBA
95 Settings.KeyBinds[ 0] = 0x010; // GP2X_UP
96 Settings.KeyBinds[ 4] = 0x020; // GP2X_DOWN
97 Settings.KeyBinds[ 2] = 0x040; // GP2X_LEFT
98 Settings.KeyBinds[ 6] = 0x080; // GP2X_RIGHT
99 Settings.KeyBinds[13] = 0x001; // GP2X_B
100 Settings.KeyBinds[14] = 0x002; // GP2X_X
101 Settings.KeyBinds[12] = 0x100; // GP2X_A
102 Settings.KeyBinds[15] = 0x200; // GP2X_Y
103 Settings.KeyBinds[ 8] = 0x008; // GP2X_START
104 Settings.KeyBinds[ 9] = 0x004; // GP2X_SELECT
107 void DoDriverArgs(void)
112 else if(docheckie[1])
116 FCEUI_SetNetworkPlay(netplay);
122 int mmuhack_status = 0;
126 int main(int argc, char *argv[])
131 printf("Starting GPFCE - Port version " GP2X_PORT_VERSION " r%i (" __DATE__ ")\n", GP2X_PORT_REV);
132 puts("Based on FCE Ultra "VERSION_STRING" and 0.98.1x versions");
133 puts("Original port by Zheng Zhu");
134 puts("Menu/optimization/misc work by notaz\n");
141 ret = CLImain(argc,argv);
143 // unscale the screen, in case this is bad.
144 gp2x_video_RGB_setscaling(0, 320, 240);
146 if (mmuhack_status > 0)
157 /* optional GP2X stuff to be done after config is loaded */
158 void gp2x_opt_setup(void)
160 if (Settings.mmuhack) {
162 printf("squidge hack code finished and returned %s\n", ret > 0 ? "ok" : "fail");
164 mmuhack_status = ret;
166 if (Settings.ramtimings) {
167 printf("setting RAM timings.. "); fflush(stdout);
168 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
169 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
170 printf("done.\n"); fflush(stdout);
174 void gp2x_cpuclock_gamma_update(void)
176 static int prev_cpuclock = 200, prev_gamma = 100;
177 if (Settings.cpuclock != 0 && Settings.cpuclock != prev_cpuclock)
179 set_FCLK(Settings.cpuclock);
180 prev_cpuclock = Settings.cpuclock;
183 if (Settings.gamma != 0 && Settings.gamma != prev_gamma)
185 set_gamma(Settings.gamma);
186 prev_gamma = Settings.gamma;