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"
24 int CLImain(int argc, char *argv[]);
27 CFGSTRUCT DriverConfig[]={
28 ACA(Settings.KeyBinds),
29 ACA(Settings.JoyBinds),
30 AC(Settings.turbo_rate_add),
31 AC(Settings.sound_rate),
34 AC(Settings.frameskip),
35 AC(Settings.sstate_confirm),
36 AC(Settings.region_force),
37 AC(Settings.cpuclock),
39 AC(Settings.ramtimings),
41 AC(Settings.perfect_vsync),
42 AC(Settings.accurate_mode),
48 "-joyx y Use joystick y as virtual joystick x.\n\
51 Otherwise, x = playback rate.\n\
52 -showfps x Display fps counter if x is nonzero\n\
53 -mmuhack x Enable squidge's MMU hack if x is nonzero (GP2X).\n\
54 -ramtimings x Enable RAM overclocking if x is nonzero (GP2X).\n\
57 "-connect s Connect to server 's' for TCP/IP network play.\n\
58 -server Be a host/server for TCP/IP network play.\n\
59 -netport x Use TCP/IP port x for network play."
64 static int docheckie[2]={0,0};
66 ARGPSTRUCT DriverArgs[]={
67 {"-sound",0,&Settings.sound_rate,0},
68 {"-showfps",0,&Settings.showfps,0},
69 {"-mmuhack",0,&Settings.mmuhack,0},
70 {"-ramtimings",0,&Settings.ramtimings,0},
71 {"-menu",0,&ext_menu,0x4001},
72 {"-menustate",0,&ext_state,0x4001},
74 {"-connect",&docheckie[0],&netplayhost,0x4001},
75 {"-server",&docheckie[1],0,0},
76 {"-netport",0,&Port,0},
83 void GetBaseDirectory(char *BaseDirectory)
85 strcpy(BaseDirectory, "fceultra");
88 static void SetDefaults(void)
90 memset(&Settings,0,sizeof(Settings));
91 Settings.cpuclock = 150;
92 Settings.frameskip = -1; // auto
94 Settings.sound_rate = 22050;
95 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
97 Settings.sstate_confirm = 1;
98 // default controls, RLDU SEBA
99 Settings.KeyBinds[ 0] = 0x010; // GP2X_UP
100 Settings.KeyBinds[ 4] = 0x020; // GP2X_DOWN
101 Settings.KeyBinds[ 2] = 0x040; // GP2X_LEFT
102 Settings.KeyBinds[ 6] = 0x080; // GP2X_RIGHT
103 Settings.KeyBinds[13] = 0x001; // GP2X_B
104 Settings.KeyBinds[14] = 0x002; // GP2X_X
105 Settings.KeyBinds[12] = 0x100; // GP2X_A
106 Settings.KeyBinds[15] = 0x200; // GP2X_Y
107 Settings.KeyBinds[ 8] = 0x008; // GP2X_START
108 Settings.KeyBinds[ 9] = 0x004; // GP2X_SELECT
109 Settings.KeyBinds[10] = 0x80000000; // GP2X_L
110 Settings.KeyBinds[11] = 0x40000000; // GP2X_R
111 Settings.KeyBinds[27] = 0xc0000000; // GP2X_PUSH
114 void DoDriverArgs(void)
119 else if(docheckie[1])
123 FCEUI_SetNetworkPlay(netplay);
129 int mmuhack_status = 0;
133 int main(int argc, char *argv[])
138 printf("Starting GPFCE - Port version " GP2X_PORT_VERSION " r%i (" __DATE__ ")\n", GP2X_PORT_REV);
139 puts("Based on FCE Ultra "VERSION_STRING" and 0.98.1x versions");
140 puts("Original port by Zheng Zhu");
141 puts("Menu/optimization/misc work by notaz\n");
148 ret = CLImain(argc,argv);
150 // unscale the screen, in case it is bad.
151 gp2x_video_RGB_setscaling(320, 240);
153 if (mmuhack_status > 0)
164 /* optional GP2X stuff to be done after config is loaded */
165 void gp2x_opt_setup(void)
167 if (Settings.mmuhack) {
169 printf("squidge hack code finished and returned %s\n", ret > 0 ? "ok" : "fail");
171 mmuhack_status = ret;
173 if (Settings.ramtimings) {
174 printf("setting RAM timings.. "); fflush(stdout);
175 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
176 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
177 printf("done.\n"); fflush(stdout);
181 void gp2x_opt_update(void)
183 static int prev_cpuclock = 200, prev_gamma = 100, prev_vsync = 0, prev_pal = 0;
184 if (Settings.cpuclock != 0 && Settings.cpuclock != prev_cpuclock)
186 set_FCLK(Settings.cpuclock);
187 prev_cpuclock = Settings.cpuclock;
190 if (Settings.gamma != 0 && Settings.gamma != prev_gamma)
192 set_gamma(Settings.gamma);
193 prev_gamma = Settings.gamma;
196 if (Settings.perfect_vsync != prev_vsync || (Settings.perfect_vsync && prev_pal != PAL))
198 if (Settings.perfect_vsync)
200 set_LCD_custom_rate(PAL ? LCDR_100_02 : LCDR_120_20);
205 unset_LCD_custom_rate();
207 prev_vsync = Settings.perfect_vsync;