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 "../libpicofe/plat.h"
11 #include "../../video.h"
13 static const struct in_default_bind in_sdl_defbinds[] = {
14 { SDLK_UP, IN_BINDTYPE_PLAYER12, NKEYB_UP },
15 { SDLK_DOWN, IN_BINDTYPE_PLAYER12, NKEYB_DOWN },
16 { SDLK_LEFT, IN_BINDTYPE_PLAYER12, NKEYB_LEFT },
17 { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, NKEYB_RIGHT },
18 { SDLK_z, IN_BINDTYPE_PLAYER12, NKEYB_B },
19 { SDLK_x, IN_BINDTYPE_PLAYER12, NKEYB_A },
20 { SDLK_a, IN_BINDTYPE_PLAYER12, NKEYB_B_TURBO },
21 { SDLK_s, IN_BINDTYPE_PLAYER12, NKEYB_A_TURBO },
22 { SDLK_c, IN_BINDTYPE_PLAYER12, NKEYB_SELECT },
23 { SDLK_v, IN_BINDTYPE_PLAYER12, NKEYB_START },
24 { SDLK_ESCAPE, IN_BINDTYPE_EMU, EACTB_ENTER_MENU },
28 static SDL_Surface *screen;
29 static char fps_str[32];
30 static SDL_Color psdl[256];
32 struct plat_target plat_target;
34 static int changemode(int bpp)
36 const SDL_VideoInfo *vinf;
39 vinf = SDL_GetVideoInfo();
41 if(vinf->hw_available)
42 flags |= SDL_HWSURFACE;
45 flags |= SDL_HWPALETTE;
47 screen = SDL_SetVideoMode(320, 240, bpp, flags);
54 SDL_WM_SetCaption("FCE Ultra", "FCE Ultra");
58 void platform_init(void)
60 memset(&Settings, 0, sizeof(Settings));
61 Settings.frameskip = -1; // auto
62 Settings.sound_rate = 44100;
63 Settings.turbo_rate_add = (8*2 << 24) / 60 + 1; // 8Hz turbofire
65 Settings.sstate_confirm = 1;
67 if (SDL_Init(SDL_INIT_NOPARACHUTE | SDL_INIT_VIDEO))
69 printf("Could not initialize SDL: %s.\n", SDL_GetError());
75 if (changemode(8) != 0)
79 void platform_late_init(void)
81 in_sdl_init(in_sdl_defbinds);
86 static void flip(void)
89 XBuf = screen->pixels;
92 void CleanSurface(void)
94 memset(screen->pixels, 0, 320 * 240 * screen->format->BytesPerPixel);
114 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
120 SDL_SetPalette(screen, SDL_PHYSPAL, &psdl[index], index, 1);
123 void FCEUD_GetPalette(uint8 index, uint8 * r, uint8 * g, uint8 * b)
125 // dummy, will break snapshots
129 void BlitPrepare(int skip)
135 if (eoptions & EO_CLIPSIDES)
137 int i, *p = (int *) ((char *)screen->pixels + 32);
138 for (i = 240; i; i--, p += 320/4)
140 p[0] = p[1] = p[62] = p[63] = 0;
144 if (Settings.accurate_mode && Settings.scaling < 2)
146 int i, *p = (int *)screen->pixels + 32/4;
148 for (i = srendline; i > 0; i--, p += 320/4)
152 int *p = (int *)screen->pixels + erendline*320/4 + 32/4;
153 for (i = 239-srendline; i > 0; i--, p += 320/4)
159 void BlitScreen(int skip)
165 void platform_apply_config(void)
169 void platform_set_volume(int val)
173 void plat_video_menu_enter(int is_rom_loaded)
178 void plat_video_menu_begin(void)
180 g_menuscreen_ptr = screen->pixels;
183 void plat_video_menu_end(void)
188 void plat_video_menu_leave(void)
191 SDL_SetPalette(screen, SDL_PHYSPAL, psdl, 0, 256);
194 char *DriverUsage="";
196 ARGPSTRUCT DriverArgs[]={
200 void DoDriverArgs(void)
204 void GetBaseDirectory(char *BaseDirectory)
206 strcpy(BaseDirectory, "fceultra");
209 void platform_finish(void)