2 #include "../common/platform.h"
3 #include "../common/args.h"
4 #include "../common/settings.h"
5 #include "../common/input.h"
6 #include "../common/main.h"
7 #include "../libpicofe/menu.h"
8 #include "../libpicofe/input.h"
9 #include "../libpicofe/in_sdl.h"
10 #include "../../video.h"
12 static const struct in_default_bind in_sdl_defbinds[] = {
13 { SDLK_UP, IN_BINDTYPE_PLAYER12, NKEYB_UP },
14 { SDLK_DOWN, IN_BINDTYPE_PLAYER12, NKEYB_DOWN },
15 { SDLK_LEFT, IN_BINDTYPE_PLAYER12, NKEYB_LEFT },
16 { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, NKEYB_RIGHT },
17 { SDLK_z, IN_BINDTYPE_PLAYER12, NKEYB_B },
18 { SDLK_x, IN_BINDTYPE_PLAYER12, NKEYB_A },
19 { SDLK_a, IN_BINDTYPE_PLAYER12, NKEYB_B_TURBO },
20 { SDLK_s, IN_BINDTYPE_PLAYER12, NKEYB_A_TURBO },
21 { SDLK_c, IN_BINDTYPE_PLAYER12, NKEYB_SELECT },
22 { SDLK_v, IN_BINDTYPE_PLAYER12, NKEYB_START },
23 { SDLK_ESCAPE, IN_BINDTYPE_EMU, EACTB_ENTER_MENU },
27 static SDL_Surface *screen;
28 static char fps_str[32];
29 static SDL_Color psdl[256];
31 static int changemode(int bpp)
33 const SDL_VideoInfo *vinf;
36 vinf = SDL_GetVideoInfo();
38 if(vinf->hw_available)
39 flags |= SDL_HWSURFACE;
42 flags |= SDL_HWPALETTE;
44 screen = SDL_SetVideoMode(320, 240, bpp, flags);
51 SDL_WM_SetCaption("FCE Ultra", "FCE Ultra");
55 void platform_init(void)
57 memset(&Settings, 0, sizeof(Settings));
58 Settings.frameskip = -1; // auto
59 Settings.sound_rate = 44100;
60 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
62 Settings.sstate_confirm = 1;
64 if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO))
66 printf("Could not initialize SDL: %s.\n", SDL_GetError());
72 if (changemode(8) != 0)
76 void platform_late_init(void)
78 in_sdl_init(in_sdl_defbinds);
83 static void flip(void)
86 XBuf = screen->pixels;
89 void CleanSurface(void)
91 memset(screen->pixels, 0, 320 * 240 * screen->format->BytesPerPixel);
111 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
117 SDL_SetPalette(screen, SDL_PHYSPAL, &psdl[index], index, 1);
120 void FCEUD_GetPalette(uint8 index, uint8 * r, uint8 * g, uint8 * b)
122 // dummy, will break snapshots
126 void BlitPrepare(int skip)
132 if (eoptions & EO_CLIPSIDES)
134 int i, *p = (int *) ((char *)screen->pixels + 32);
135 for (i = 240; i; i--, p += 320/4)
137 p[0] = p[1] = p[62] = p[63] = 0;
141 if (Settings.accurate_mode && Settings.scaling < 2)
143 int i, *p = (int *)screen->pixels + 32/4;
145 for (i = srendline; i > 0; i--, p += 320/4)
149 int *p = (int *)screen->pixels + erendline*320/4 + 32/4;
150 for (i = 239-srendline; i > 0; i--, p += 320/4)
156 void BlitScreen(int skip)
162 void platform_apply_config(void)
166 void platform_set_volume(int val)
170 void plat_video_menu_enter(int is_rom_loaded)
175 void plat_video_menu_begin(void)
177 g_menuscreen_ptr = screen->pixels;
180 void plat_video_menu_end(void)
185 void plat_video_menu_leave(void)
188 SDL_SetPalette(screen, SDL_PHYSPAL, psdl, 0, 256);
191 char *DriverUsage="";
193 ARGPSTRUCT DriverArgs[]={
197 void DoDriverArgs(void)
201 void GetBaseDirectory(char *BaseDirectory)
203 strcpy(BaseDirectory, "fceultra");
206 void platform_finish(void)