-// vim:shiftwidth=2:expandtab
+/*
+ * GINGE - GINGE Is Not Gp2x Emulator
+ * (C) notaz, 2010-2011
+ *
+ * This work is licensed under the MAME license, see COPYING file for details.
+ */
#include <string.h>
#ifdef LOADER
#include "../loader/realfuncs.h"
#if defined(PND)
-#include "fbdev.c"
+#include "libpicofe/linux/fbdev.c"
static struct vout_fbdev *fbdev;
+static unsigned short host_pal[256];
void *host_video_flip(void)
{
if (fbdev_name == NULL)
fbdev_name = "/dev/fb1";
- fbdev = vout_fbdev_init(fbdev_name, &w, &h, no_dblbuf);
+ w = h = 0;
+ fbdev = vout_fbdev_init(fbdev_name, &w, &h, 16, no_dblbuf ? 1 : 3);
if (fbdev == NULL)
return -1;
return 0;
}
+void host_video_finish(void)
+{
+ vout_fbdev_finish(fbdev);
+ fbdev = NULL;
+}
+
+void host_video_update_pal16(unsigned short *pal)
+{
+ memcpy(host_pal, pal, sizeof(host_pal));
+}
+
+void host_video_update_pal32(unsigned int *pal)
+{
+ unsigned short *dstp = host_pal;
+ int i;
+
+ for (i = 0; i < 256; i++, pal++, dstp++) {
+ unsigned int t = *pal;
+ *dstp = ((t >> 8) & 0xf800) | ((t >> 5) & 0x07e0) | ((t >> 3) & 0x001f);
+ }
+}
+
+void host_video_change_bpp(int bpp)
+{
+}
+
+void host_video_blit4(const unsigned char *src, int w, int h, int stride)
+{
+ unsigned short *dst = host_screen;
+ unsigned short *hpal = host_pal;
+ int i, u;
+
+ for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
+ for (u = 0; i < w / 2; u++) {
+ dst[u*2 + 0] = hpal[src[u] >> 4];
+ dst[u*2 + 1] = hpal[src[u] & 0x0f];
+ }
+ }
+
+ host_video_flip();
+}
+
+void host_video_blit8(const unsigned char *src, int w, int h, int stride)
+{
+ unsigned short *dst = host_screen;
+ unsigned short *hpal = host_pal;
+ int i, u;
+
+ for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride) {
+ for (u = 0; u < w; u += 4) {
+ dst[u + 0] = hpal[src[u + 0]];
+ dst[u + 1] = hpal[src[u + 1]];
+ dst[u + 2] = hpal[src[u + 2]];
+ dst[u + 3] = hpal[src[u + 3]];
+ }
+ }
+
+ host_video_flip();
+}
+
+void host_video_blit16(const unsigned short *src, int w, int h, int stride)
+{
+ unsigned short *dst = host_screen;
+ int i;
+
+ for (i = 0; i < 240; i++, dst += host_stride / 2, src += stride / 2)
+ memcpy(dst, src, w*2);
+
+ host_video_flip();
+}
+
#elif defined(WIZ)
-#include "warm.c"
+#include "warm/warm.c"
#include "wiz_video.c"
void *host_video_flip(void)
if (ret != 0)
return ret;
+ vout_gp2x_set_mode(16, !no_dblbuf);
host_video_flip();
return 0;
}
-#endif
-
-static unsigned short host_pal[256];
-
-static void host_update_pal(unsigned int *pal)
+void host_video_finish(void)
{
- unsigned short *dstp = host_pal;
- int i;
-
- for (i = 0; i < 256; i++, pal++, dstp++) {
- unsigned int t = *pal;
- *dstp = ((t >> 8) & 0xf800) | ((t >> 5) & 0x07e0) | ((t >> 3) & 0x001f);
- }
+ vout_gp2x_finish();
}
-void host_video_blit4(const unsigned char *src, int w, int h, unsigned int *pal)
+void host_video_update_pal16(unsigned short *pal)
{
- unsigned short *dst = host_screen;
- unsigned short *hpal = host_pal;
- int i, u;
+ vout_gp2x_set_palette16(pal, 256);
+}
- if (pal != NULL)
- host_update_pal(pal);
+void host_video_update_pal32(unsigned int *pal)
+{
+ vout_gp2x_set_palette32(pal, 256);
+}
- for (i = 0; i < 240; i++, dst += host_stride / 2 - 320) {
- for (u = 320 / 2; u > 0; u--, src++) {
- *dst++ = hpal[*src >> 4];
- *dst++ = hpal[*src & 0x0f];
- }
- }
+void host_video_change_bpp(int bpp)
+{
+ vout_gp2x_set_mode(bpp, 1);
+}
+#ifdef LOADER
+void host_video_blit4(const unsigned char *src, int w, int h, int stride)
+{
+ memcpy(host_screen, src, 320*240/2); // FIXME
host_video_flip();
}
-void host_video_blit8(const unsigned char *src, int w, int h, unsigned int *pal)
+void host_video_blit8(const unsigned char *src, int w, int h, int stride)
{
- unsigned short *dst = host_screen;
- unsigned short *hpal = host_pal;
- int i, u;
-
- if (pal != NULL)
- host_update_pal(pal);
-
- for (i = 0; i < 240; i++, dst += host_stride / 2 - 320) {
- for (u = 320 / 4; u > 0; u--) {
- *dst++ = hpal[*src++];
- *dst++ = hpal[*src++];
- *dst++ = hpal[*src++];
- *dst++ = hpal[*src++];
- }
+ if (probably_caanoo) {
+ unsigned char *dst = host_screen;
+ int i;
+ for (i = 0; i < 240; i++, dst += 320, src += stride)
+ memcpy(dst, src, w);
+ }
+ else {
+ extern void rotated_blit8(void *dst, const void *linesx4);
+ rotated_blit8(host_screen, src);
}
host_video_flip();
}
-void host_video_blit16(const unsigned short *src, int w, int h)
+void host_video_blit16(const unsigned short *src, int w, int h, int stride)
{
- unsigned short *dst = host_screen;
- int i;
-
- for (i = 0; i < 240; i++, dst += host_stride / 2, src += 320)
- memcpy(dst, src, 320*2);
+ if (probably_caanoo) {
+ unsigned short *dst = host_screen;
+ int i;
+ for (i = 0; i < 240; i++, dst += 320, src += stride / 2)
+ memcpy(dst, src, w*2);
+ }
+ else {
+ extern void rotated_blit16(void *dst, const void *linesx4);
+ rotated_blit16(host_screen, src);
+ }
host_video_flip();
}
+#endif // LOADER
+#endif // WIZ
+
+// vim:shiftwidth=2:expandtab