1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "../common/vidblit.h"
28 #define _sline srendline
29 #define _eline erendline
36 static int exs,eys,eefx;
37 #define NWIDTH (256-((eoptions&EO_CLIPSIDES)?16:0))
38 #define NOFFSET (32-8+(eoptions&EO_CLIPSIDES?8:0))
40 static void CleanSurface(void)
44 x=screen->pitch*screen->h;
46 if(SDL_MUSTLOCK(screen))
47 SDL_LockSurface(screen);
49 memset((uint8*)screen->pixels, 0x80, x);
51 if(SDL_MUSTLOCK(screen))
52 SDL_UnlockSurface(screen);
54 SDL_UpdateRect(screen, 0, 0, 0, 0);
57 static int paletterefresh;
63 SDL_QuitSubSystem(SDL_INIT_VIDEO);
70 const SDL_VideoInfo *vinf;
74 if(_fullscreen && _fshack)
75 setenv("SDL_VIDEODRIVER",_fshack,1);
79 unsetenv("SDL_VIDEODRIVER");
81 setenv("SDL_VIDEODRIVER",_fshacksave,1);
84 if(SDL_InitSubSystem(SDL_INIT_VIDEO)==-1)
92 tlines=_eline-_sline+1;
94 vinf=SDL_GetVideoInfo();
96 if(vinf->hw_available)
100 flags|=SDL_FULLSCREEN;
101 flags|=SDL_HWPALETTE;
108 if(_xres<NWIDTH*exs || _yres<tlines*eys)
110 puts("xscale and/or yscale out of bounds.");
114 screen = SDL_SetVideoMode(_xres, _yres, 8, flags);
121 screen = SDL_SetVideoMode(NWIDTH*exs, tlines*eys, 8, flags);
125 puts(SDL_GetError());
132 SDL_WM_SetCaption("FCE Ultra","FCE Ultra");
140 _fullscreen=!_fullscreen;
144 _fullscreen=!_fullscreen;
147 puts("Gah, bailing out.");
152 static SDL_Color psdl[256];
154 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
164 void FCEUD_GetPalette(uint8 index, uint8 *r, uint8 *g, uint8 *b)
171 static void RedoPalette(void)
173 SDL_SetPalette(screen,SDL_PHYSPAL,psdl,0,256);
177 void UnlockConsole(){}
178 void BlitScreen(uint8 *XBuf)
191 if(SDL_MUSTLOCK(screen))
192 SDL_LockSurface(screen);
198 xo=(((screen->w-NWIDTH*exs))>>1);
200 if(screen->h>(tlines*eys))
202 yo=((screen->h-tlines*eys)>>1);
203 dest+=yo*screen->pitch;
207 Blit8To8(XBuf+NOFFSET,dest, NWIDTH, tlines, screen->pitch,exs,eys,eefx);
209 if(SDL_MUSTLOCK(screen))
210 SDL_UnlockSurface(screen);
212 SDL_UpdateRect(screen, xo, yo, NWIDTH*exs, tlines*eys);
215 uint32 PtoV(uint16 x, uint16 y)
223 if(eoptions&EO_CLIPSIDES)