1 /* FCE Ultra - NES/Famicom Emulator
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "../../video.h"
30 static char fps_str[32];
31 static int framesEmulated, framesRendered;
33 int gp2x_palette[256];
34 unsigned short gp2x_palette16[256];
43 static void gp2x_text(unsigned char *screen, int x, int y, char *text, int color, int flip)
48 screen=screen+x+y*320;
55 screen[l*320+0]=(fontdata8x8[((text[i])*8)+l]&0x80)?color:0;
56 screen[l*320+1]=(fontdata8x8[((text[i])*8)+l]&0x40)?color:0;
57 screen[l*320+2]=(fontdata8x8[((text[i])*8)+l]&0x20)?color:0;
58 screen[l*320+3]=(fontdata8x8[((text[i])*8)+l]&0x10)?color:0;
59 screen[l*320+4]=(fontdata8x8[((text[i])*8)+l]&0x08)?color:0;
60 screen[l*320+5]=(fontdata8x8[((text[i])*8)+l]&0x04)?color:0;
61 screen[l*320+6]=(fontdata8x8[((text[i])*8)+l]&0x02)?color:0;
62 screen[l*320+7]=(fontdata8x8[((text[i])*8)+l]&0x01)?color:0;
70 void CleanSurface(void)
75 memset32(gp2x_screen, 0, 320*240*2/4);
93 puts("Initialized GP2X VIDEO via minimal");
107 // 16: rrrr rggg gggb bbbb
108 void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b)
110 gp2x_palette[index] = (r << 16) | (g << 8) | b;
111 gp2x_palette16[index] = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
112 gp2x_video_setpalette(gp2x_palette, index + 1);
118 void FCEUD_GetPalette(uint8 index, uint8 * r, uint8 * g, uint8 * b)
120 int pix = gp2x_palette[index];
121 *r = (uint8) (pix >> 16);
122 *g = (uint8) (pix >> 8);
127 static INLINE void printFps(uint8 *screen)
129 struct timeval tv_now;
130 static int prevsec, needfpsflip = 0;
132 gettimeofday(&tv_now, 0);
133 if (prevsec != tv_now.tv_sec)
135 sprintf(fps_str, "%2i/%2i", framesRendered, framesEmulated);
136 framesEmulated = framesRendered = 0;
138 prevsec = tv_now.tv_sec;
141 if (!Settings.showfps || !screen) return;
143 if (Settings.scaling == 0)
148 for (sep=1; sep < 5; sep++)
149 if (fps_str[sep] == '/' || fps_str[sep] == 0) break;
151 gp2x_text(screen, 0, 0, fps_str, FPS_COLOR, 0);
152 gp2x_text(screen, 0, 10, fps_str+sep+1, FPS_COLOR, 0);
158 gp2x_text(screen+32, 0, srendline, fps_str, FPS_COLOR, 0);
163 void BlitScreen(uint8 *buf)
174 printFps(gp2x_screen);
176 if (eoptions & EO_CLIPSIDES)
178 int i, *p = (int *) ((char *)gp2x_screen + 32);
179 for (i = 240; i; i--, p += 320/4)
181 p[0] = p[1] = p[62] = p[63] = 0;
185 if (Settings.scaling == 3)
187 soft_scale((char *)gp2x_screen + 32, gp2x_palette16, srendline, erendline-srendline);
189 memset32((int *)((char *)gp2x_screen + 32), 0, srendline*320*2/4);