2 * GINGE - GINGE Is Not Gp2x Emulator
5 * This work is licensed under the MAME license, see COPYING file for details.
9 #include "../loader/realfuncs.h"
14 static void *host_screen;
15 static int host_stride;
19 #include "libpicofe/linux/fbdev.c"
21 static struct vout_fbdev *fbdev;
22 static unsigned short host_pal[256];
24 void *host_video_flip(void)
26 host_screen = vout_fbdev_flip(fbdev);
30 int host_video_init(int *stride, int no_dblbuf)
32 const char *fbdev_name;
35 fbdev_name = getenv("FBDEV");
36 if (fbdev_name == NULL)
37 fbdev_name = "/dev/fb1";
40 fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, no_dblbuf ? 1 : 3);
46 *stride = host_stride;
52 void host_video_finish(void)
54 vout_fbdev_finish(fbdev);
58 void host_video_update_pal16(unsigned short *pal)
60 memcpy(host_pal, pal, sizeof(host_pal));
63 void host_video_update_pal32(unsigned int *pal)
65 unsigned short *dstp = host_pal;
68 for (i = 0; i < 256; i++, pal++, dstp++) {
69 unsigned int t = *pal;
70 *dstp = ((t >> 8) & 0xf800) | ((t >> 5) & 0x07e0) | ((t >> 3) & 0x001f);
74 void host_video_change_bpp(int bpp)
78 void host_video_blit4(const unsigned char *src, int w, int h, int stride)
80 unsigned short *dst = host_screen;
81 unsigned short *hpal = host_pal;
84 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
85 for (u = 0; i < w / 2; u++) {
86 dst[u*2 + 0] = hpal[src[u] >> 4];
87 dst[u*2 + 1] = hpal[src[u] & 0x0f];
94 void host_video_blit8(const unsigned char *src, int w, int h, int stride)
96 unsigned short *dst = host_screen;
97 unsigned short *hpal = host_pal;
100 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
101 for (u = 0; u < w; u += 4) {
102 dst[u + 0] = hpal[src[u + 0]];
103 dst[u + 1] = hpal[src[u + 1]];
104 dst[u + 2] = hpal[src[u + 2]];
105 dst[u + 3] = hpal[src[u + 3]];
112 void host_video_blit16(const unsigned short *src, int w, int h, int stride)
114 unsigned short *dst = host_screen;
117 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride / 2)
118 memcpy(dst, src, w*2);
125 #include "warm/warm.c"
126 #include "wiz_video.c"
128 void *host_video_flip(void)
131 host_screen = g_screen_ptr;
135 int host_video_init(int *stride, int no_dblbuf)
139 host_stride = 320 * 2;
141 *stride = host_stride;
143 ret = vout_gp2x_init(no_dblbuf);
147 vout_gp2x_set_mode(16, !no_dblbuf);
152 void host_video_finish(void)
157 void host_video_update_pal16(unsigned short *pal)
159 vout_gp2x_set_palette16(pal, 256);
162 void host_video_update_pal32(unsigned int *pal)
164 vout_gp2x_set_palette32(pal, 256);
167 void host_video_change_bpp(int bpp)
169 vout_gp2x_set_mode(bpp, 1);
173 void host_video_blit4(const unsigned char *src, int w, int h, int stride)
175 memcpy(host_screen, src, 320*240/2); // FIXME
179 void host_video_blit8(const unsigned char *src, int w, int h, int stride)
181 if (probably_caanoo) {
182 unsigned char *dst = host_screen;
184 for (i = 0; i < 240; i++, dst += 320, src += stride)
188 extern void rotated_blit8(void *dst, const void *linesx4);
189 rotated_blit8(host_screen, src);
195 void host_video_blit16(const unsigned short *src, int w, int h, int stride)
197 if (probably_caanoo) {
198 unsigned short *dst = host_screen;
200 for (i = 0; i < 240; i++, dst += 320, src += stride / 2)
201 memcpy(dst, src, w*2);
204 extern void rotated_blit16(void *dst, const void *linesx4);
205 rotated_blit16(host_screen, src);
214 // vim:shiftwidth=2:expandtab