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"
22 static struct vout_fbdev *fbdev;
23 static unsigned short host_pal[256];
25 static int get_layer_size(int *x, int *y, int *w, int *h)
27 struct omapfb_plane_info pi;
30 ret = ioctl(vout_fbdev_get_fd(fbdev), OMAPFB_QUERY_PLANE, &pi);
32 perror("OMAPFB_QUERY_PLANE");
40 printf("layer: %d,%d %dx%d\n", *x, *y, *w, *h);
45 void *host_video_flip(void)
47 host_screen = vout_fbdev_flip(fbdev);
51 int host_video_init(int *stride, int no_dblbuf)
53 const char *fbdev_name;
56 fbdev_name = getenv("FBDEV");
57 if (fbdev_name == NULL)
58 fbdev_name = "/dev/fb1";
61 fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, no_dblbuf ? 1 : 3);
67 *stride = host_stride;
73 void host_video_finish(void)
75 vout_fbdev_finish(fbdev);
79 void host_video_update_pal16(unsigned short *pal)
81 memcpy(host_pal, pal, sizeof(host_pal));
84 void host_video_update_pal32(unsigned int *pal)
86 unsigned short *dstp = host_pal;
89 for (i = 0; i < 256; i++, pal++, dstp++) {
90 unsigned int t = *pal;
91 *dstp = ((t >> 8) & 0xf800) | ((t >> 5) & 0x07e0) | ((t >> 3) & 0x001f);
95 void host_video_change_bpp(int bpp)
99 void host_video_blit4(const unsigned char *src, int w, int h, int stride)
101 unsigned short *dst = host_screen;
102 unsigned short *hpal = host_pal;
105 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
106 for (u = 0; i < w / 2; u++) {
107 dst[u*2 + 0] = hpal[src[u] >> 4];
108 dst[u*2 + 1] = hpal[src[u] & 0x0f];
115 void host_video_blit8(const unsigned char *src, int w, int h, int stride)
117 unsigned short *dst = host_screen;
118 unsigned short *hpal = host_pal;
121 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
122 for (u = 0; u < w; u += 4) {
123 dst[u + 0] = hpal[src[u + 0]];
124 dst[u + 1] = hpal[src[u + 1]];
125 dst[u + 2] = hpal[src[u + 2]];
126 dst[u + 3] = hpal[src[u + 3]];
133 void host_video_blit16(const unsigned short *src, int w, int h, int stride)
135 unsigned short *dst = host_screen;
138 for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride / 2)
139 memcpy(dst, src, w*2);
144 void host_video_normalize_ts(int *x1024, int *y1024)
146 static int lx, ly, lw = 800, lh = 480, checked;
149 get_layer_size(&lx, &ly, &lw, &lh);
150 checked = 1; // XXX: might change, so may need to recheck
152 *x1024 = (*x1024 - lx) * 1024 / lw;
153 *y1024 = (*y1024 - ly) * 1024 / lh;
158 #include "warm/warm.c"
159 #include "wiz_video.c"
161 void *host_video_flip(void)
164 host_screen = g_screen_ptr;
168 int host_video_init(int *stride, int no_dblbuf)
172 host_stride = 320 * 2;
174 *stride = host_stride;
176 ret = vout_gp2x_init(no_dblbuf);
180 vout_gp2x_set_mode(16, !no_dblbuf);
185 void host_video_finish(void)
190 void host_video_update_pal16(unsigned short *pal)
192 vout_gp2x_set_palette16(pal, 256);
195 void host_video_update_pal32(unsigned int *pal)
197 vout_gp2x_set_palette32(pal, 256);
200 void host_video_change_bpp(int bpp)
202 vout_gp2x_set_mode(bpp, 1);
206 void host_video_blit4(const unsigned char *src, int w, int h, int stride)
208 memcpy(host_screen, src, 320*240/2); // FIXME
212 void host_video_blit8(const unsigned char *src, int w, int h, int stride)
214 if (probably_caanoo) {
215 unsigned char *dst = host_screen;
217 for (i = 0; i < 240; i++, dst += 320, src += stride)
221 extern void rotated_blit8(void *dst, const void *linesx4);
222 rotated_blit8(host_screen, src);
228 void host_video_blit16(const unsigned short *src, int w, int h, int stride)
230 if (probably_caanoo) {
231 unsigned short *dst = host_screen;
233 for (i = 0; i < 240; i++, dst += 320, src += stride / 2)
234 memcpy(dst, src, w*2);
237 extern void rotated_blit16(void *dst, const void *linesx4);
238 rotated_blit16(host_screen, src);
245 void host_video_normalize_ts(int *x1024, int *y1024)
247 *x1024 = *x1024 * 1024 / 320;
248 *y1024 = *y1024 * 1024 / 240;
253 // vim:shiftwidth=2:expandtab