5 #include "../../driver.h"
6 #include "../common/config.h"
7 #include "../common/args.h"
8 #include "../common/platform.h"
9 #include "../common/settings.h"
10 #include "../common/revision.h"
11 #include "gp2x-video.h"
13 #include "unix-netplay.h"
18 #include "squidgehack.h"
23 "-mmuhack x Enable squidge's MMU hack if x is nonzero (GP2X).\n\
24 -ramtimings x Enable RAM overclocking if x is nonzero (GP2X).\n\
27 ARGPSTRUCT DriverArgs[]={
28 {"-mmuhack",0,&Settings.mmuhack,0},
29 {"-ramtimings",0,&Settings.ramtimings,0},
30 {"-menu",0,&ext_menu,0x4001},
31 {"-menustate",0,&ext_state,0x4001},
35 void GetBaseDirectory(char *BaseDirectory)
37 strcpy(BaseDirectory, "fceultra");
40 static void SetDefaults(void)
42 memset(&Settings,0,sizeof(Settings));
43 Settings.cpuclock = 150;
44 Settings.frameskip = -1; // auto
46 Settings.sound_rate = 22050;
47 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
49 Settings.sstate_confirm = 1;
50 // default controls, RLDU SEBA
51 Settings.KeyBinds[ 0] = 0x010; // GP2X_UP
52 Settings.KeyBinds[ 4] = 0x020; // GP2X_DOWN
53 Settings.KeyBinds[ 2] = 0x040; // GP2X_LEFT
54 Settings.KeyBinds[ 6] = 0x080; // GP2X_RIGHT
55 Settings.KeyBinds[13] = 0x001; // GP2X_B
56 Settings.KeyBinds[14] = 0x002; // GP2X_X
57 Settings.KeyBinds[12] = 0x100; // GP2X_A
58 Settings.KeyBinds[15] = 0x200; // GP2X_Y
59 Settings.KeyBinds[ 8] = 0x008; // GP2X_START
60 Settings.KeyBinds[ 9] = 0x004; // GP2X_SELECT
61 Settings.KeyBinds[10] = 0x80000000; // GP2X_L
62 Settings.KeyBinds[11] = 0x40000000; // GP2X_R
63 Settings.KeyBinds[27] = 0xc0000000; // GP2X_PUSH
66 void DoDriverArgs(void)
71 int mmuhack_status = 0;
74 void platform_init(void)
76 printf("Starting GPFCE " REV " (" __DATE__ ")\n");
77 puts("Based on FCE Ultra "VERSION_STRING" and 0.98.1x versions");
78 puts("Original port by Zheng Zhu");
79 puts("Menu/optimization/misc work by notaz\n");
87 void platform_finish(void)
89 // unscale the screen, in case it is bad.
90 gp2x_video_RGB_setscaling(320, 240);
92 if (mmuhack_status > 0)
102 void platform_set_volume(int val) // 0-100
104 platform_set_volume(val, val);
107 /* optional GP2X stuff to be done after config is loaded */
108 void platform_late_init(void)
110 if (Settings.mmuhack) {
112 printf("squidge hack code finished and returned %s\n", ret > 0 ? "ok" : "fail");
114 mmuhack_status = ret;
116 if (Settings.ramtimings) {
117 printf("setting RAM timings.. "); fflush(stdout);
118 // craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
119 set_RAM_Timings(6, 4, 1, 1, 1, 2, 2);
120 printf("done.\n"); fflush(stdout);
124 void platform_apply_config(void)
126 static int prev_cpuclock = 200, prev_gamma = 100, prev_vsync = 0, prev_pal = 0;
127 if (Settings.cpuclock != 0 && Settings.cpuclock != prev_cpuclock)
129 set_FCLK(Settings.cpuclock);
130 prev_cpuclock = Settings.cpuclock;
133 if (Settings.gamma != 0 && Settings.gamma != prev_gamma)
135 set_gamma(Settings.gamma);
136 prev_gamma = Settings.gamma;
139 if (Settings.perfect_vsync != prev_vsync || (Settings.perfect_vsync && prev_pal != PAL))
141 if (Settings.perfect_vsync)
143 set_LCD_custom_rate(PAL ? LCDR_100_02 : LCDR_120_20);
148 unset_LCD_custom_rate();
150 prev_vsync = Settings.perfect_vsync;
153 gp2x_video_changemode(Settings.scaling == 3 ? 15 : 8);
154 switch (Settings.scaling & 3) {
155 case 0: gp2x_video_set_offs(0); gp2x_video_RGB_setscaling(320, 240); break;
156 case 1: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(256, 240); break;
157 case 2: gp2x_video_set_offs(32+srendline*320); gp2x_video_RGB_setscaling(256, erendline-srendline); break;
158 case 3: gp2x_video_set_offs(32); gp2x_video_RGB_setscaling(320, 240); break;