-/* faking/emulating gp2x.c by using gtk */
+/* faking/emulating gp2x by using gtk */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
// dummies
-char *ext_menu = 0, *ext_state = 0;
int mix_32_to_16l_level;
/* gtk */
gtk_main_quit ();
}
+/* faking GP2X pad */
+enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
+ GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
+ GP2X_A=1<<12, GP2X_B=1<<13, GP2X_X=1<<14, GP2X_Y=1<<15,
+ GP2X_VOL_UP=1<<23, GP2X_VOL_DOWN=1<<22, GP2X_PUSH=1<<27 };
+
static gint key_press_event (GtkWidget *widget, GdkEventKey *event)
{
switch (event->hardware_keycode)
static void size_allocate_event(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
{
// printf("%dx%d\n", allocation->width, allocation->height);
- scr_w = allocation->width - 2;
- scr_h = allocation->height - 2;
- scr_changed = 1;
+ if (scr_w != allocation->width - 2 || scr_h != allocation->height - 2) {
+ scr_w = allocation->width - 2;
+ scr_h = allocation->height - 2;
+ scr_changed = 1;
+ }
}
static void *gtk_threadf(void *targ)
void *old = g_screen_ptr;
g_screen_width = scr_w;
g_screen_height = scr_h;
- g_screen_ptr = malloc(g_screen_width * g_screen_height * 2);
+ g_screen_ptr = calloc(g_screen_width * g_screen_height * 2, 1);
free(old);
scr_changed = 0;
}
-void gp2x_init(void)
+void plat_init(void)
{
printf("entering init()\n"); fflush(stdout);
printf("exitting init()\n"); fflush(stdout);
}
-void gp2x_deinit(void)
+void plat_finish(void)
{
free(g_screen_ptr);
sndout_oss_exit();
memcpy(current_pal, pal, len*4);
}
-void gp2x_video_flush_cache(void)
-{
-}
-
void gp2x_video_RGB_setscaling(int v_offs, int W, int H)
{
}
-void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
-{
- if ((char *)g_screen_ptr + offset != data)
- memcpy((char *)g_screen_ptr + offset, data, len);
-}
-
-void gp2x_memcpy_all_buffers(void *data, int offset, int len)
-{
- memcpy((char *)g_screen_ptr + offset, data, len);
-}
-
-
void gp2x_memset_all_buffers(int offset, int byte, int len)
{
memset((char *)g_screen_ptr + offset, byte, len);
}
-void gp2x_pd_clone_buffer2(void)
-{
- memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
-}
-
/* joy */
-unsigned long gp2x_joystick_read(int allow_usb_joy)
-{
- return current_keys;
-}
-
int gp2x_touchpad_read(int *x, int *y)
{
return -1;
/* 940 */
int crashed_940 = 0;
-void Pause940(int yes)
+void pause940(int yes)
{
}
-void Reset940(int yes, int bank)
+void reset940(int yes, int bank)
{
}