-// platform specific things for common menu code
+/* random common definitions */
-/* TODO: get rid of this file */
-
-#ifdef __GP2X__
-#include "../gp2x/gp2x.h"
-
-// TODO merge
#define PBTN_UP (1 << 0)
#define PBTN_DOWN (1 << 1)
#define PBTN_LEFT (1 << 2)
#define PBTN_RIGHT (1 << 3)
-#define PBTN_NORTH (1 << 4)
-#define PBTN_SOUTH (1 << 5)
-#define PBTN_WEST (1 << 6)
-#define PBTN_EAST (1 << 7)
-#define PBTN_L (1 << 8)
-#define PBTN_R (1 << 9)
-
-/* menu nav */
-#define PBTN_MOK PBTN_EAST
-#define PBTN_MBACK PBTN_SOUTH
-#define PBTN_MENU (1 << 10)
-
-#if 0
-#define PBTN_UP GP2X_UP
-#define PBTN_DOWN GP2X_DOWN
-#define PBTN_LEFT GP2X_LEFT
-#define PBTN_RIGHT GP2X_RIGHT
-
-#define PBTN_NORTH GP2X_Y
-#define PBTN_SOUTH GP2X_X
-#define PBTN_WEST GP2X_A
-#define PBTN_EAST GP2X_B
-#define PBTN_L GP2X_L
-#define PBTN_R GP2X_R
-
-/* menu nav */
-#define PBTN_MOK GP2X_B
-#define PBTN_MBACK GP2X_X
-#define PBTN_MENU GP2X_SELECT
-#endif
-#define GP2X_Y 0 /* FIXME */
-
-void gp2x_pd_clone_buffer2(void);
-void menu_darken_bg(void *dst, int pixels, int darker);
-void menu_flip(void);
-
-#define SCREEN_WIDTH 320
-#define SCREEN_HEIGHT 240
-#define SCREEN_BUFFER gp2x_screen
-
-#define menu_draw_begin() \
- gp2x_pd_clone_buffer2()
-#define clear_screen() \
- memset(gp2x_screen, 0, 320*240*2)
-#define darken_screen() \
- menu_darken_bg(gp2x_screen, 320*240, 0)
-#define menu_draw_end() \
- menu_flip()
-
-// ------------------------------------
-
-#elif defined(__GIZ__)
-
-#include "../gizmondo/giz.h"
-
-#define PBTN_NORTH PBTN_STOP
-#define PBTN_SOUTH PBTN_PLAY
-#define PBTN_WEST PBTN_REW
-#define PBTN_EAST PBTN_FWD
-
-void menu_draw_begin(int use_bgbuff);
-void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
-void menu_draw_end(void);
-
-#define SCREEN_WIDTH 321
-#define SCREEN_HEIGHT 240
-#define SCREEN_BUFFER ((giz_screen != NULL) ? giz_screen : menu_screen)
-extern void *menu_screen;
-extern void *giz_screen;
-
-#define menu_draw_begin() \
- menu_draw_begin(1)
-#define clear_screen() \
- memset(SCREEN_BUFFER, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2)
-#define darken_screen() \
- menu_darken_bg(menu_screen, menu_screen, SCREEN_WIDTH*SCREEN_HEIGHT, 0)
+#define PBTN_MOK (1 << 4)
+#define PBTN_MBACK (1 << 5)
+#define PBTN_MA2 (1 << 6) /* menu action 2 */
+#define PBTN_MA3 (1 << 7)
-// ------------------------------------
-
-#elif defined(PSP)
-
-#include "../psp/psp.h"
-
-#define PBTN_NORTH PBTN_TRIANGLE
-#define PBTN_SOUTH PBTN_X
-#define PBTN_WEST PBTN_SQUARE
-#define PBTN_EAST PBTN_CIRCLE
-
-void menu_draw_begin(void);
-void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
-void menu_draw_end(void);
-
-#define SCREEN_WIDTH 512
-#define SCREEN_HEIGHT 272
-#define SCREEN_BUFFER psp_screen
-
-#define clear_screen() \
- memset(SCREEN_BUFFER, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2)
-#define darken_screen() \
- menu_darken_bg(psp_screen, psp_screen, SCREEN_WIDTH*SCREEN_HEIGHT, 0)
-
-// ------------------------------------
-
-#elif defined(PANDORA)
-
-#define PBTN_UP (1 << 0)
-#define PBTN_DOWN (1 << 1)
-#define PBTN_LEFT (1 << 2)
-#define PBTN_RIGHT (1 << 3)
-
-#define PBTN_NORTH (1 << 4)
-#define PBTN_SOUTH (1 << 5)
-#define PBTN_WEST (1 << 6)
-#define PBTN_EAST (1 << 7)
#define PBTN_L (1 << 8)
#define PBTN_R (1 << 9)
-/* menu nav */
-#define PBTN_MOK PBTN_EAST
-#define PBTN_MBACK PBTN_SOUTH
#define PBTN_MENU (1 << 10)
-void gp2x_pd_clone_buffer2(void);
-void menu_darken_bg(void *dst, int pixels, int darker);
-void menu_flip(void);
-
-extern void *gp2x_screen;
-
-#define SCREEN_WIDTH 800
-#define SCREEN_HEIGHT 480
-#define SCREEN_BUFFER gp2x_screen
-
-#define menu_draw_begin() \
- gp2x_pd_clone_buffer2()
-#define clear_screen() \
- memset(gp2x_screen, 0, 800*480*2)
-#define darken_screen() \
- menu_darken_bg(gp2x_screen, 800*480, 0)
-#define menu_draw_end() \
- menu_flip()
-
-#endif
#include <zlib/zlib.h>\r
\r
\r
+void *g_screen_ptr;\r
+\r
+#if !SCREEN_SIZE_FIXED\r
+int g_screen_width = SCREEN_WIDTH;\r
+int g_screen_height = SCREEN_HEIGHT;\r
+#endif\r
+\r
char *PicoConfigFile = "config.cfg";\r
currentConfig_t currentConfig, defaultConfig;\r
char noticeMsg[64] = { 0, };\r
#endif\r
}\r
\r
-#ifndef UIQ3\r
-void emu_textOut8(int x, int y, const char *text)\r
-{\r
- int i,l,len=strlen(text);\r
- unsigned char *screen = (unsigned char *)SCREEN_BUFFER + x + y*SCREEN_WIDTH;\r
-\r
- /* always using built-in font */\r
- for (i = 0; i < len; i++)\r
- {\r
- for (l=0;l<8;l++)\r
- {\r
- unsigned char fd = fontdata8x8[((text[i])*8)+l];\r
- if (fd&0x80) screen[l*SCREEN_WIDTH+0]=0xf0;\r
- if (fd&0x40) screen[l*SCREEN_WIDTH+1]=0xf0;\r
- if (fd&0x20) screen[l*SCREEN_WIDTH+2]=0xf0;\r
- if (fd&0x10) screen[l*SCREEN_WIDTH+3]=0xf0;\r
- if (fd&0x08) screen[l*SCREEN_WIDTH+4]=0xf0;\r
- if (fd&0x04) screen[l*SCREEN_WIDTH+5]=0xf0;\r
- if (fd&0x02) screen[l*SCREEN_WIDTH+6]=0xf0;\r
- if (fd&0x01) screen[l*SCREEN_WIDTH+7]=0xf0;\r
- }\r
- screen += 8;\r
- }\r
+/* always using built-in font */\r
+\r
+#define mk_text_out(name, type, val) \\r
+void name(int x, int y, const char *text) \\r
+{ \\r
+ int i, l, len = strlen(text); \\r
+ type *screen = (type *)g_screen_ptr + x + y * g_screen_width; \\r
+ \\r
+ for (i = 0; i < len; i++, screen += 8) \\r
+ { \\r
+ for (l = 0; l < 8; l++) \\r
+ { \\r
+ unsigned char fd = fontdata8x8[text[i] * 8 + l];\\r
+ type *s = screen + l * g_screen_width; \\r
+ if (fd&0x80) s[0] = val; \\r
+ if (fd&0x40) s[1] = val; \\r
+ if (fd&0x20) s[2] = val; \\r
+ if (fd&0x10) s[3] = val; \\r
+ if (fd&0x08) s[4] = val; \\r
+ if (fd&0x04) s[5] = val; \\r
+ if (fd&0x02) s[6] = val; \\r
+ if (fd&0x01) s[7] = val; \\r
+ } \\r
+ } \\r
}\r
\r
-void emu_textOut16(int x, int y, const char *text)\r
-{\r
- int i,l,len=strlen(text);\r
- unsigned short *screen = (unsigned short *)SCREEN_BUFFER + x + y*SCREEN_WIDTH;\r
+mk_text_out(emu_textOut8, unsigned char, 0xf0)\r
+mk_text_out(emu_textOut16, unsigned short, 0xffff)\r
\r
- for (i = 0; i < len; i++)\r
- {\r
- for (l=0;l<8;l++)\r
- {\r
- unsigned char fd = fontdata8x8[((text[i])*8)+l];\r
- if(fd&0x80) screen[l*SCREEN_WIDTH+0]=0xffff;\r
- if(fd&0x40) screen[l*SCREEN_WIDTH+1]=0xffff;\r
- if(fd&0x20) screen[l*SCREEN_WIDTH+2]=0xffff;\r
- if(fd&0x10) screen[l*SCREEN_WIDTH+3]=0xffff;\r
- if(fd&0x08) screen[l*SCREEN_WIDTH+4]=0xffff;\r
- if(fd&0x04) screen[l*SCREEN_WIDTH+5]=0xffff;\r
- if(fd&0x02) screen[l*SCREEN_WIDTH+6]=0xffff;\r
- if(fd&0x01) screen[l*SCREEN_WIDTH+7]=0xffff;\r
- }\r
- screen += 8;\r
- }\r
-}\r
-#endif\r
+#undef mk_text_out\r
\r
#ifdef PSP\r
#define MAX_COMBO_KEY 23\r
#define MAX_COMBO_KEY 31\r
#endif\r
\r
+// FIXME\r
void emu_findKeyBindCombos(void)\r
{\r
int act, u;\r
extern "C" {
#endif
+extern void *g_screen_ptr;
+
+#if SCREEN_SIZE_FIXED
+#define g_screen_width SCREEN_WIDTH
+#define g_screen_height SCREEN_HEIGHT
+#else
+extern int g_screen_width;
+extern int g_screen_height;
+#endif
+
+
#define EOPT_USE_SRAM (1<<0)
#define EOPT_SHOW_FPS (1<<1)
#define EOPT_EN_SOUND (1<<2)
-// (c) Copyright 2006,2007 notaz, All rights reserved.\r
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
static void text_out16_(int x, int y, const char *text, int color)\r
{\r
int i, l, u, tr, tg, tb, len;\r
- unsigned short *dest = (unsigned short *)SCREEN_BUFFER + x + y*SCREEN_WIDTH;\r
+ unsigned short *dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width;\r
tr = (color & 0xf800) >> 8;\r
tg = (color & 0x07e0) >> 3;\r
tb = (color & 0x001f) << 3;\r
{\r
unsigned char *src = menu_font_data + (unsigned int)text[i]*4*10;\r
unsigned short *dst = dest;\r
- for (l = 0; l < 10; l++, dst += SCREEN_WIDTH-8)\r
+ for (l = 0; l < 10; l++, dst += g_screen_width - 8)\r
{\r
for (u = 8/2; u > 0; u--, src++)\r
{\r
{\r
va_list args;\r
char buffer[256];\r
- int maxw = (SCREEN_WIDTH - x) / 8;\r
+ int maxw = (g_screen_width - x) / 8;\r
\r
if (maxw < 0)\r
return;\r
if (!c) break;\r
\r
src = fontdata6x8[c];\r
- dst = (unsigned short *)SCREEN_BUFFER + x + y*SCREEN_WIDTH;\r
+ dst = (unsigned short *)g_screen_ptr + x + y * g_screen_width;\r
\r
while (h--)\r
{\r
}\r
src++;\r
\r
- dst += SCREEN_WIDTH-6;\r
+ dst += g_screen_width - 6;\r
}\r
}\r
}\r
\r
void smalltext_out16(int x, int y, const char *texto, int color)\r
{\r
- char buffer[SCREEN_WIDTH/6+1];\r
- int maxw = (SCREEN_WIDTH - x) / 6;\r
+ char buffer[128];\r
+ int maxw = (g_screen_width - x) / 6;\r
\r
if (maxw < 0)\r
return;\r
if (menu_sel_color < 0) return; // no selection hilight\r
\r
if (y > 0) y--;\r
- dest = (unsigned short *)SCREEN_BUFFER + x + y*SCREEN_WIDTH + 14;\r
+ dest = (unsigned short *)g_screen_ptr + x + y * g_screen_width + 14;\r
for (h = 11; h > 0; h--)\r
{\r
dst = dest;\r
for (i = w; i > 0; i--)\r
*dst++ = menu_sel_color;\r
- dest += SCREEN_WIDTH;\r
+ dest += g_screen_width;\r
}\r
}\r
\r
h = n * 10;\r
w += 16; /* selector */\r
\r
- if (w > SCREEN_WIDTH) {\r
- lprintf("width %d > %d\n", w, SCREEN_WIDTH);\r
- w = SCREEN_WIDTH;\r
+ if (w > g_screen_width) {\r
+ lprintf("width %d > %d\n", w, g_screen_width);\r
+ w = g_screen_width;\r
}\r
- if (h > SCREEN_HEIGHT) {\r
- lprintf("height %d > %d\n", w, SCREEN_HEIGHT);\r
- h = SCREEN_HEIGHT;\r
+ if (h > g_screen_height) {\r
+ lprintf("height %d > %d\n", w, g_screen_height);\r
+ h = g_screen_height;\r
}\r
\r
- x = SCREEN_WIDTH / 2 - w / 2;\r
- y = SCREEN_HEIGHT / 2 - h / 2;\r
+ x = g_screen_width / 2 - w / 2;\r
+ y = g_screen_height / 2 - h / 2;\r
\r
/* draw */\r
plat_video_menu_begin();\r
/* display message if we have one */\r
if (menuErrorMsg[0] != 0) {\r
static int msg_redraws = 0;\r
- if (SCREEN_HEIGHT - h >= 2*10)\r
+ if (g_screen_height - h >= 2*10)\r
text_out16(5, 226, menuErrorMsg);\r
else\r
lprintf("menu msg doesn't fit!\n");\r
p++;\r
}\r
\r
- x = SCREEN_WIDTH / 2 - w * 8 / 2;\r
- y = SCREEN_HEIGHT / 2 - h * 10 / 2;\r
+ x = g_screen_width / 2 - w * 8 / 2;\r
+ y = g_screen_height / 2 - h * 10 / 2;\r
if (x < 0) x = 0;\r
if (y < 0) y = 0;\r
\r
plat_video_menu_begin();\r
\r
- for (p = creds; *p != 0 && y <= SCREEN_HEIGHT - 10; y += 10) {\r
+ for (p = creds; *p != 0 && y <= g_screen_height - 10; y += 10) {\r
text_out16(x, y, p);\r
\r
for (; *p != 0 && *p != '\n'; p++)\r
\r
static void load_progress_cb(int percent)\r
{\r
- int ln, len = percent * SCREEN_WIDTH / 100;\r
- unsigned short *dst = (unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH * 10 * 2;\r
+ int ln, len = percent * g_screen_width / 100;\r
+ unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * 10 * 2;\r
\r
- if (len > SCREEN_WIDTH)\r
- len = SCREEN_WIDTH;\r
- for (ln = 10 - 2; ln > 0; ln--, dst += SCREEN_WIDTH)\r
+ if (len > g_screen_width)\r
+ len = g_screen_width;\r
+ for (ln = 10 - 2; ln > 0; ln--, dst += g_screen_width)\r
memset(dst, 0xff, len * 2);\r
plat_video_menu_end();\r
}\r
\r
static void cdload_progress_cb(int percent)\r
{\r
- int ln, len = percent * SCREEN_WIDTH / 100;\r
- unsigned short *dst = (unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH * 10 * 2;\r
+ int ln, len = percent * g_screen_width / 100;\r
+ unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * 10 * 2;\r
\r
- memset(dst, 0xff, SCREEN_WIDTH * (10 - 2) * 2);\r
+ memset(dst, 0xff, g_screen_width * (10 - 2) * 2);\r
\r
smalltext_out16(1, 3 * 10, "Processing CD image / MP3s", 0xffff);\r
smalltext_out16(1, 4 * 10, rom_fname_loaded, 0xffff);\r
- dst += SCREEN_WIDTH * 30;\r
+ dst += g_screen_width * 30;\r
\r
- if (len > SCREEN_WIDTH)\r
- len = SCREEN_WIDTH;\r
- for (ln = (10 - 2); ln > 0; ln--, dst += SCREEN_WIDTH)\r
+ if (len > g_screen_width)\r
+ len = g_screen_width;\r
+ for (ln = (10 - 2); ln > 0; ln--, dst += g_screen_width)\r
memset(dst, 0xff, len * 2);\r
\r
plat_video_menu_end();\r
{\r
int max_cnt, start, i, pos;\r
\r
- max_cnt = SCREEN_HEIGHT / 10;\r
+ max_cnt = g_screen_height / 10;\r
start = max_cnt / 2 - sel;\r
n--; // exclude current dir (".")\r
\r
// if (!rom_loaded)\r
// menu_darken_bg(gp2x_screen, 320*240, 0);\r
\r
- menu_darken_bg((short *)SCREEN_BUFFER + SCREEN_WIDTH * max_cnt/2 * 10, SCREEN_WIDTH * 8, 0);\r
+ menu_darken_bg((short *)g_screen_ptr + g_screen_width * max_cnt/2 * 10, g_screen_width * 8, 0);\r
\r
if (start - 2 >= 0)\r
smalltext_out16(14, (start - 2)*10, curdir, 0xffff);\r
{\r
draw_dirlist(curr_path, namelist, n, sel);\r
inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|\r
- PBTN_L|PBTN_R|PBTN_WEST|PBTN_MOK|PBTN_MBACK|PBTN_MENU, 33); // TODO L R\r
+ PBTN_L|PBTN_R|PBTN_MA2|PBTN_MOK|PBTN_MBACK|PBTN_MENU, 33);\r
if (inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
if (inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
if (inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
if (inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; }\r
if (inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
if (inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
- if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_WEST)) == (PBTN_MENU|PBTN_WEST)) // enter dir/select || delete\r
+ if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_MA2)) == (PBTN_MENU|PBTN_MA2))\r
{\r
again:\r
if (namelist[sel+1]->d_type == DT_REG)\r
{\r
int max_cnt, start, i, pos, active;\r
\r
- max_cnt = SCREEN_HEIGHT / 10;\r
+ max_cnt = g_screen_height / 10;\r
start = max_cnt / 2 - sel;\r
\r
plat_video_menu_begin();\r
\r
w = 13 * 8 + 16;\r
h = (1+2+10+1) * 10;\r
- x = SCREEN_WIDTH / 2 - w / 2;\r
+ x = g_screen_width / 2 - w / 2;\r
if (x < 0) x = 0;\r
- y = SCREEN_HEIGHT / 2 - h / 2;\r
+ y = g_screen_height / 2 - h / 2;\r
if (y < 0) y = 0;\r
\r
plat_video_menu_begin();\r
menu_draw_selection(x - 16, y + menu_sel * 10, 13 * 8 + 4);\r
\r
/* draw all 10 slots */\r
- y += 10;\r
for (i = 0; i < 10; i++, y += 10)\r
{\r
text_out16(x, y, "SLOT %i (%s)", i, (state_slot_flags & (1 << i)) ? "USED" : "free");\r
int x, y = 30, w, i;\r
const char *dev_name;\r
\r
- x = SCREEN_WIDTH / 2 - 32*8 / 2;\r
+ x = g_screen_width / 2 - 32*8 / 2;\r
if (x < 0) x = 0;\r
\r
plat_video_menu_begin();\r
w = strlen(dev_name) * 8;\r
if (w < 30 * 8)\r
w = 30 * 8;\r
- if (w > SCREEN_WIDTH)\r
- w = SCREEN_WIDTH;\r
+ if (w > g_screen_width)\r
+ w = g_screen_width;\r
\r
- x = SCREEN_WIDTH / 2 - w / 2;\r
+ x = g_screen_width / 2 - w / 2;\r
\r
if (dev_count > 1) {\r
- text_out16(x, SCREEN_HEIGHT - 4*10, "Viewing binds for:");\r
- text_out16(x, SCREEN_HEIGHT - 3*10, dev_name);\r
+ text_out16(x, g_screen_height - 4*10, "Viewing binds for:");\r
+ text_out16(x, g_screen_height - 3*10, dev_name);\r
}\r
\r
if (is_bind)\r
- text_out16(x, SCREEN_HEIGHT - 2*10, "Press a button to bind/unbind");\r
+ text_out16(x, g_screen_height - 2*10, "Press a button to bind/unbind");\r
else if (dev_count > 1)\r
- text_out16(x, SCREEN_HEIGHT - 2*10, "Press left/right for other devs");\r
+ text_out16(x, g_screen_height - 2*10, "Press left/right for other devs");\r
\r
plat_video_menu_end();\r
}\r
while (1)\r
{\r
PDebugZ80Frame();\r
- if (in_menu_wait_any(0) & PBTN_NORTH) break;\r
+ if (in_menu_wait_any(0) & PBTN_MA3)\r
+ break;\r
emu_waitSound();\r
}\r
\r
}\r
\r
str = p;\r
- for (line = from; line < SCREEN_HEIGHT/10; line++)\r
+ for (line = from; line < g_screen_height / 10; line++)\r
{\r
while (*p && *p != '\n') p++;\r
smalltext_out16(1, line*10, str, 0xffff);\r
if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6);\r
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6);\r
\r
- clear_screen();\r
+ memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
emu_forcedFrame(0);\r
- smalltext_out16(4, SCREEN_HEIGHT-8, layer_str, 0xffff);\r
+ smalltext_out16(4, g_screen_height - 8, layer_str, 0xffff);\r
}\r
\r
static void debug_menu_loop(void)\r
emu_platformDebugCat(tmp);\r
draw_text_debug(tmp, 0, 0);\r
if (dumped) {\r
- smalltext_out16(SCREEN_WIDTH-6*10, SCREEN_HEIGHT-8, "dumped", 0xffff);\r
+ smalltext_out16(g_screen_width - 6*10, g_screen_height - 8, "dumped", 0xffff);\r
dumped = 0;\r
}\r
break;\r
case 1: draw_frame_debug(); break;\r
- case 2: clear_screen();\r
+ case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
emu_forcedFrame(0);\r
- darken_screen();\r
- PDebugShowSpriteStats((unsigned short *)SCREEN_BUFFER + (SCREEN_HEIGHT/2 - 240/2)*SCREEN_WIDTH +\r
- SCREEN_WIDTH/2 - 320/2, SCREEN_WIDTH); break;\r
- case 3: clear_screen();\r
- PDebugShowPalette(SCREEN_BUFFER, SCREEN_WIDTH);\r
- PDebugShowSprite((unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH*120+SCREEN_WIDTH/2+16,\r
- SCREEN_WIDTH, spr_offs);\r
+ menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);\r
+ PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width +\r
+ g_screen_width/2 - 320/2, g_screen_width); break;\r
+ case 3: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
+ PDebugShowPalette(g_screen_ptr, g_screen_width);\r
+ PDebugShowSprite((unsigned short *)g_screen_ptr + g_screen_width*120 + g_screen_width/2 + 16,\r
+ g_screen_width, spr_offs);\r
draw_text_debug(PDebugSpriteList(), spr_offs, 6);\r
break;\r
}\r
plat_video_menu_end();\r
\r
- inp = in_menu_wait(PBTN_EAST|PBTN_MBACK|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R |\r
+ inp = in_menu_wait(PBTN_MOK|PBTN_MBACK|PBTN_MA2|PBTN_MA3|PBTN_L|PBTN_R |\r
PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT, 70);\r
if (inp & PBTN_MBACK) return;\r
if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; }\r
switch (mode)\r
{\r
case 0:\r
- if (inp & PBTN_EAST) SekStepM68k();\r
- if (inp & PBTN_NORTH) {\r
- while (inp & PBTN_NORTH) inp = in_menu_wait_any(-1);\r
+ if (inp & PBTN_MOK)\r
+ SekStepM68k();\r
+ if (inp & PBTN_MA3) {\r
+ while (inp & PBTN_MA3)\r
+ inp = in_menu_wait_any(-1);\r
mplayer_loop();\r
}\r
- if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) {\r
+ if ((inp & (PBTN_MA2|PBTN_LEFT)) == (PBTN_MA2|PBTN_LEFT)) {\r
mkdir("dumps", 0777);\r
PDebugDumpMem();\r
- while (inp & PBTN_WEST) inp = in_menu_wait_any(-1);\r
+ while (inp & PBTN_MA2) inp = in_menu_wait_any(-1);\r
dumped = 1;\r
}\r
break;\r
if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON;\r
if (inp & PBTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON;\r
if (inp & PBTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON;\r
- if (inp & PBTN_EAST) {\r
+ if (inp & PBTN_MOK) {\r
PsndOut = NULL; // just in case\r
PicoSkipFrame = 1;\r
PicoFrame();\r
PicoSkipFrame = 0;\r
- while (inp & PBTN_EAST) inp = in_menu_wait_any(-1);\r
+ while (inp & PBTN_MOK) inp = in_menu_wait_any(-1);\r
}\r
break;\r
case 3:\r
fp = fopen(binpath, "rb");\r
if(!fp)\r
{\r
- memset(gp2x_screen, 0, 320*240*2);\r
+ memset(g_screen_ptr, 0, 320*240*2);\r
text_out16(10, 100, "failed to open required file:");\r
text_out16(10, 110, CODE940_FILE);\r
gp2x_video_flip2();\r
#include "emu.h"\r
#include "gp2x.h"\r
#include "menu.h"\r
-#include "../linux/usbjoy.h"\r
#include "../common/arm_utils.h"\r
#include "../common/fonts.h"\r
#include "../common/emu.h"\r
void osd_text(int x, int y, const char *text)\r
{\r
int len = strlen(text)*8;\r
+ int *p, i, h, offs;\r
\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
- int *p, i, h;\r
- x &= ~3; // align x\r
len = (len+3) >> 2;\r
for (h = 0; h < 8; h++) {\r
- p = (int *) ((unsigned char *) gp2x_screen+x+320*(y+h));\r
- for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
+ offs = (x + g_screen_width * (y+h)) & ~3;\r
+ p = (int *) ((char *)g_screen_ptr + offs);\r
+ for (i = len; i; i--, p++)\r
+ *p = 0xe0e0e0e0;\r
}\r
emu_textOut8(x, y, text);\r
} else {\r
- int *p, i, h;\r
- x &= ~1; // align x\r
len = (len+1) >> 1;\r
for (h = 0; h < 8; h++) {\r
- p = (int *) ((unsigned short *) gp2x_screen+x+320*(y+h));\r
- for (i = len; i; i--, p++) *p = (*p>>2)&0x39e7;\r
+ offs = (x + g_screen_width * (y+h)) & ~1;\r
+ p = (int *) ((short *)g_screen_ptr + offs);\r
+ for (i = len; i; i--, p++)\r
+ *p = (*p >> 2) & 0x39e7;\r
}\r
emu_textOut16(x, y, text);\r
}\r
// 8-bit modes\r
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
- *(unsigned int *)((char *)gp2x_screen + 320*2+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + 320*3+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + 320*4+ 4) = col_g;\r
- *(unsigned int *)((char *)gp2x_screen + 320*2+12) =\r
- *(unsigned int *)((char *)gp2x_screen + 320*3+12) =\r
- *(unsigned int *)((char *)gp2x_screen + 320*4+12) = col_r;\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*2+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*3+ 4) =\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*4+ 4) = col_g;\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*2+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*3+12) =\r
+ *(unsigned int *)((char *)g_screen_ptr + 320*4+12) = col_r;\r
} else {\r
// 16-bit modes\r
- unsigned int *p = (unsigned int *)((short *)gp2x_screen + 320*2+4);\r
+ unsigned int *p = (unsigned int *)((short *)g_screen_ptr + 320*2+4);\r
unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
*p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;\r
\r
static void draw_pico_ptr(void)\r
{\r
- unsigned short *p = (unsigned short *)gp2x_screen;\r
+ unsigned short *p = (unsigned short *)g_screen_ptr;\r
\r
// only if pen enabled and for 16bit modes\r
if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
static int EmuScanBegin16(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned short *) gp2x_screen + 320 * num;\r
+ DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
}\r
static int EmuScanBegin8(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned char *) gp2x_screen + 320 * num;\r
+ DrawLineDest = (unsigned char *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
}\r
if (PicoRead16Hook == PicoSVPRead16)\r
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
// do actual copy\r
- vidCpyM2((unsigned char *)gp2x_screen+320*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)g_screen_ptr+320*8, PicoDraw2FB+328*8);\r
}\r
else if (!(emu_opt&0x80))\r
{\r
if (!(PicoOpt&0x10)) {\r
if (!(Pico.video.reg[1]&8)) {\r
if (currentConfig.EmuOpt&0x80) {\r
- DrawLineDest = (unsigned short *) gp2x_screen + 320*8;\r
+ DrawLineDest = (unsigned short *) g_screen_ptr + 320*8;\r
} else {\r
- DrawLineDest = (unsigned char *) gp2x_screen + 320*8;\r
+ DrawLineDest = (unsigned char *) g_screen_ptr + 320*8;\r
}\r
} else {\r
- DrawLineDest = gp2x_screen;\r
+ DrawLineDest = g_screen_ptr;\r
}\r
}\r
}\r
// 8-bit renderers\r
gp2x_memset_all_buffers(320*232, 0xe0, 320*8);\r
osd_text(4, 232, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+320*232, 320*232, 320*8);\r
+ gp2x_memcpy_all_buffers((char *)g_screen_ptr+320*232, 320*232, 320*8);\r
} else {\r
// 16bit accurate renderer\r
gp2x_memset_all_buffers(320*232*2, 0, 320*8*2);\r
osd_text(4, 232, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+320*232*2, 320*232*2, 320*8*2);\r
+ gp2x_memcpy_all_buffers((char *)g_screen_ptr+320*232*2, 320*232*2, 320*8*2);\r
}\r
gettimeofday(¬iceMsgTime, 0);\r
noticeMsgTime.tv_sec -= 2;\r
if (do_it) {\r
osd_text(4, 232, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
PicoStateProgressCB = emu_state_cb;\r
- gp2x_memcpy_all_buffers(gp2x_screen, 0, 320*240*2);\r
+ gp2x_memcpy_all_buffers(g_screen_ptr, 0, 320*240*2);\r
emu_SaveLoadGame((which & 0x1000) >> 12, 0);\r
PicoStateProgressCB = NULL;\r
}\r
{\r
unsigned int keys, keys2, allActions[2] = { 0, 0 }, events;\r
static unsigned int prevEvents = 0;\r
- int joy, i;\r
\r
keys = gp2x_joystick_read(0);\r
- if (keys & GP2X_SELECT) {\r
+ if (keys & GP2X_SELECT)\r
engineState = select_exits ? PGS_Quit : PGS_Menu;\r
- // wait until select is released, so menu would not resume game\r
- while (gp2x_joystick_read(1) & GP2X_SELECT) usleep(50*1000);\r
- }\r
\r
keys &= CONFIGURABLE_KEYS;\r
keys2 = keys;\r
}\r
#endif\r
\r
- // add joy inputs\r
- if (num_of_joys > 0)\r
- {\r
- usbjoy_update();\r
- for (joy = 0; joy < num_of_joys; joy++) {\r
- int btns = usbjoy_check2(joy);\r
- for (i = 0; i < 32; i++) {\r
- if (btns & (1 << i)) {\r
- int acts = currentConfig.JoyBinds[joy][i];\r
- int pl = (acts >> 16) & 1;\r
- allActions[pl] |= acts;\r
- }\r
- }\r
- }\r
- }\r
-\r
PicoPad[0] = allActions[0] & 0xfff;\r
PicoPad[1] = allActions[1] & 0xfff;\r
\r
clearArea(1);\r
} else vidCpyM2 = vidCpyM2_40col;\r
\r
- vidCpyM2((unsigned char *)gp2x_screen+320*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)g_screen_ptr+320*8, PicoDraw2FB+328*8);\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
gp2x_video_setpalette(localPal, 0x40);\r
*/\r
#define CONV(X) (((X>>1)&0x7fe0)|(X&0x1f)) // 555?\r
\r
for (i = 0; i < 320*240; i++)\r
- if(oldscr[i] != CONV(((unsigned short *)gp2x_screen)[i])) break;\r
+ if(oldscr[i] != CONV(((unsigned short *)g_screen_ptr)[i])) break;\r
if (i < 320*240)\r
{\r
for (i = 0; i < 320*240; i++)\r
- oldscr[i] = CONV(((unsigned short *)gp2x_screen)[i]);\r
+ oldscr[i] = CONV(((unsigned short *)g_screen_ptr)[i]);\r
sprintf(name, "%05i.tga", Pico.m.frame_count);\r
f = fopen(name, "wb");\r
if (!f) { printf("!f\n"); exit(1); }\r
#include <errno.h>\r
\r
#include "gp2x.h"\r
-#include "../linux/usbjoy.h"\r
#include "../linux/sndout_oss.h"\r
#include "../common/arm_utils.h"\r
#include "../common/arm_linux.h"\r
static int touchdev = -1;\r
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };\r
\r
-void *gp2x_screen;\r
-\r
#define FRAMEBUFF_WHOLESIZE (0x30000*4) // 320*240*2 + some more\r
#define FRAMEBUFF_ADDR0 (0x4000000-FRAMEBUFF_WHOLESIZE)\r
#define FRAMEBUFF_ADDR1 (FRAMEBUFF_ADDR0+0x30000)\r
gp2x_memregs[0x2912>>1] = lsw;\r
\r
// jump to other buffer:\r
- gp2x_screen = gp2x_screens[++screensel&3];\r
+ g_screen_ptr = gp2x_screens[++screensel&3];\r
}\r
\r
/* doulblebuffered flip */\r
gp2x_memregs[0x2912>>1] = 0;\r
\r
// jump to other buffer:\r
- gp2x_screen = gp2x_screens[++screensel&1];\r
+ g_screen_ptr = gp2x_screens[++screensel&1];\r
}\r
\r
\r
void gp2x_video_flush_cache(void)\r
{\r
// since we are using the mmu hack, we must flush the cache first\r
- cache_flush_d_inval_i(gp2x_screen, (char *)gp2x_screen + 320*240*2);\r
+ cache_flush_d_inval_i(g_screen_ptr, (char *)g_screen_ptr + 320*240*2);\r
}\r
\r
\r
\r
void gp2x_pd_clone_buffer2(void)\r
{\r
- memcpy(gp2x_screen, gp2x_screens[2], 320*240*2);\r
+ memcpy(g_screen_ptr, gp2x_screens[2], 320*240*2);\r
}\r
\r
\r
-unsigned long gp2x_joystick_read(int allow_usb_joy)\r
+unsigned long gp2x_joystick_read(int unused)\r
{\r
int i;\r
unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF); // GPIO M\r
if(value==0x7F) value=0xBE;\r
value = ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16)); // C D\r
\r
- if (allow_usb_joy && num_of_joys > 0) {\r
- // check the usb joy as well..\r
- usbjoy_update();\r
- for (i = 0; i < num_of_joys; i++)\r
- value |= usbjoy_check(i);\r
- }\r
-\r
return value;\r
}\r
\r
gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED, memdev, FRAMEBUFF_ADDR0);\r
if(gp2x_screens[0] == MAP_FAILED)\r
{\r
- perror("mmap(gp2x_screen)");\r
+ perror("mmap(g_screen_ptr)");\r
exit(1);\r
}\r
printf("framebuffers point to %p\n", gp2x_screens[0]);\r
gp2x_screens[2] = (char *) gp2x_screens[1]+0x30000;\r
gp2x_screens[3] = (char *) gp2x_screens[2]+0x30000;\r
\r
- gp2x_screen = gp2x_screens[0];\r
+ g_screen_ptr = gp2x_screens[0];\r
screensel = 0;\r
\r
gp2x_screenaddr_old[0] = gp2x_memregs[0x290E>>1];\r
// snd\r
sndout_oss_init();\r
\r
- /* init usb joys -GnoStiC */\r
- usbjoy_init();\r
-\r
// touchscreen\r
touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);\r
if (touchdev >= 0) {\r
if (touchdev >= 0) close(touchdev);\r
\r
sndout_oss_exit();\r
- usbjoy_deinit();\r
\r
printf("all done, running ");\r
\r
void Reset940(int yes, int bank);\r
\r
\r
-extern void *gp2x_screen;\r
extern int memdev;\r
\r
\r
#include "../common/plat.h"
#include "../common/readpng.h"
#include "../common/menu.h"
+#include "../common/emu.h"
void plat_video_menu_enter(int is_rom_loaded)
if (is_rom_loaded)
{
// darken the active framebuffer
- memset(gp2x_screen, 0, 320*8*2);
- menu_darken_bg((char *)gp2x_screen + 320*8*2, 320*224, 1);
- memset((char *)gp2x_screen + 320*232*2, 0, 320*8*2);
+ memset(g_screen_ptr, 0, 320*8*2);
+ menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1);
+ memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2);
}
else
{
// should really only happen once, on startup..
- readpng(gp2x_screen, "skin/background.png", READPNG_BG);
+ readpng(g_screen_ptr, "skin/background.png", READPNG_BG);
}
// copy to buffer2
- gp2x_memcpy_buffers((1<<2), gp2x_screen, 0, 320*240*2);
+ gp2x_memcpy_buffers((1<<2), g_screen_ptr, 0, 320*240*2);
// switch to 16bpp
gp2x_video_changemode2(16);
#define REDUCE_IO_CALLS 0\r
#define SIMPLE_WRITE_SOUND 0\r
\r
+#define SCREEN_SIZE_FIXED 1\r
+#define SCREEN_WIDTH 320\r
+#define SCREEN_HEIGHT 240\r
+\r
// draw.c\r
#define OVERRIDE_HIGHCOL 0\r
\r
LDFLAGS += `pkg-config --libs gthread-2.0`
# frontend
-OBJS += platform/gp2x/main.o platform/gp2x/emu.o platform/gp2x/plat.o usbjoy.o blit.o \
+OBJS += platform/gp2x/main.o platform/gp2x/emu.o platform/gp2x/plat.o blit.o \
in_evdev.o plat.o sndout_oss.o gp2x.o 940ctl_ym2612.o log_io.o
# common
#include "../gp2x/emu.h"
#include "../gp2x/gp2x.h"
#include "../gp2x/version.h"
+#include "../common/emu.h"
#include "sndout_oss.h"
-#include "usbjoy.h"
#include "log_io.h"
-void *gp2x_screen;
unsigned long current_keys = 0;
static int current_bpp = 8;
static int current_pal[256];
static const char *verstring = "PicoDrive " VERSION;
+static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
// dummies
char *ext_menu = 0, *ext_state = 0;
return 0;
}
-/*
-void gdk_drawable_get_size (GdkDrawable *drawable,
- gint *width,
- gint *height);
-**/
-
static void size_allocate_event(GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
{
- gint w, h;
- gdk_drawable_get_size(gtk_items.window, &w, &h);
- printf("%dx%d %dx%d\n", allocation->width, allocation->height, w, h);
+ // printf("%dx%d\n", allocation->width, allocation->height);
+ scr_w = allocation->width - 2;
+ scr_h = allocation->height - 2;
+ scr_changed = 1;
}
static void *gtk_threadf(void *targ)
g_signal_connect (G_OBJECT (gtk_items.window), "size_allocate",
G_CALLBACK (size_allocate_event), NULL);
- gtk_container_set_border_width (GTK_CONTAINER (gtk_items.window), 2);
+ gtk_container_set_border_width (GTK_CONTAINER (gtk_items.window), 1);
gtk_window_set_title ((GtkWindow *) gtk_items.window, verstring);
box = gtk_hbox_new(FALSE, 0);
/* --- */
+static void realloc_screen(void)
+{
+ 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);
+ free(old);
+ scr_changed = 0;
+}
+
void gp2x_init(void)
{
printf("entering init()\n"); fflush(stdout);
- gp2x_screen = malloc(320*240*2 + 320*2);
- memset(gp2x_screen, 0, 320*240*2 + 320*2);
+ realloc_screen();
+ memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
// snd
sndout_oss_init();
gtk_initf();
- usbjoy_init();
-
printf("exitting init()\n"); fflush(stdout);
}
void gp2x_deinit(void)
{
- free(gp2x_screen);
+ free(g_screen_ptr);
sndout_oss_exit();
- usbjoy_deinit();
}
/* video */
{
GdkPixbuf *pixbuf;
unsigned char *image;
- int i;
+ int pixel_count, i;
+
+ pixel_count = g_screen_width * g_screen_height;
gdk_threads_enter();
- image = malloc (320*240*3);
+ image = malloc(pixel_count * 3);
if (image == NULL)
{
gdk_threads_leave();
if (current_bpp == 8)
{
- unsigned char *pixels = gp2x_screen;
+ unsigned char *pixels = g_screen_ptr;
int pix;
- for (i = 0; i < 320*240; i++)
+ for (i = 0; i < pixel_count; i++)
{
pix = current_pal[pixels[i]];
image[3 * i + 0] = pix >> 16;
}
else
{
- unsigned short *pixels = gp2x_screen;
+ unsigned short *pixels = g_screen_ptr;
- for (i = 0; i < 320*240; i++)
+ for (i = 0; i < pixel_count; i++)
{
/* in: rrrr rggg gggb bbbb */
/* out: rrrr r000 gggg gg00 bbbb b000 */
}
pixbuf = gdk_pixbuf_new_from_data (image, GDK_COLORSPACE_RGB,
- FALSE, 8, 320, 240, 320*3, finalize_image, NULL);
+ FALSE, 8, g_screen_width, g_screen_height,
+ g_screen_width * 3, finalize_image, NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (gtk_items.pixmap1), pixbuf);
g_object_unref (pixbuf);
gdk_threads_leave();
+
+ if (scr_changed)
+ realloc_screen();
}
void gp2x_video_flip2(void)
void gp2x_memcpy_buffers(int buffers, void *data, int offset, int len)
{
- if ((char *)gp2x_screen + offset != data)
- memcpy((char *)gp2x_screen + offset, data, 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 *)gp2x_screen + offset, data, len);
+ memcpy((char *)g_screen_ptr + offset, data, len);
}
void gp2x_memset_all_buffers(int offset, int byte, int len)
{
- memset((char *)gp2x_screen + offset, byte, len);
+ memset((char *)g_screen_ptr + offset, byte, len);
}
void gp2x_pd_clone_buffer2(void)
{
- memset(gp2x_screen, 0, 320*240*2);
+ memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
}
/* joy */
unsigned long gp2x_joystick_read(int allow_usb_joy)
{
- unsigned long value = current_keys;
- int i;
-
- if (allow_usb_joy && num_of_joys > 0) {
- // check the usb joy as well..
- usbjoy_update();
- for (i = 0; i < num_of_joys; i++)
- value |= usbjoy_check(i);
- }
-
- return value;
+ return current_keys;
}
int gp2x_touchpad_read(int *x, int *y)
#define REDUCE_IO_CALLS 0
#define SIMPLE_WRITE_SOUND 0
+#define SCREEN_SIZE_FIXED 0
+#define SCREEN_WIDTH 320
+#define SCREEN_HEIGHT 240
+
// draw.c
#define OVERRIDE_HIGHCOL 0
\r
#define PICO_PEN_ADJUST_X 4\r
#define PICO_PEN_ADJUST_Y 2\r
-static int pico_pen_x = SCREEN_WIDTH/2, pico_pen_y = 240/2;\r
+static int pico_pen_x = 0, pico_pen_y = 240/2;\r
\r
static void emu_msg_cb(const char *msg);\r
static void emu_msg_tray_open(void);\r
defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds\r
defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC;\r
defaultConfig.s_PicoOpt |= POPT_ACC_SPRITES|POPT_EN_MCD_GFX;\r
-// defaultConfig.s_PicoOpt &= ~POPT_EN_SVP_DRC; // crashes :(\r
defaultConfig.EmuOpt &= ~8; // no save gzip\r
defaultConfig.s_PsndRate = 44100;\r
defaultConfig.s_PicoRegion = 0;\r
static void textOut16(int x, int y, const char *text)\r
{\r
int i,l,len=strlen(text);\r
- unsigned int *screen = (unsigned int *)((unsigned short *)SCREEN_BUFFER + (x&~1) + y*SCREEN_WIDTH);\r
+ unsigned int *screen = (unsigned int *)((unsigned short *)g_screen_ptr + (x&~1) + y*g_screen_width);\r
\r
for (i = 0; i < len; i++)\r
{\r
for (l=0;l<16;)\r
{\r
unsigned char fd = fontdata8x8[((text[i])*8)+l/2];\r
- unsigned int *d = &screen[l*SCREEN_WIDTH/2];\r
+ unsigned int *d = &screen[l*g_screen_width/2];\r
if (fd&0x80) d[0]=0xffffffff;\r
if (fd&0x40) d[1]=0xffffffff;\r
if (fd&0x20) d[2]=0xffffffff;\r
if (fd&0x04) d[5]=0xffffffff;\r
if (fd&0x02) d[6]=0xffffffff;\r
if (fd&0x01) d[7]=0xffffffff;\r
- l++; d = &screen[l*SCREEN_WIDTH/2];\r
+ l++; d = &screen[l*g_screen_width/2];\r
if (fd&0x80) d[0]=0xffffffff;\r
if (fd&0x40) d[1]=0xffffffff;\r
if (fd&0x20) d[2]=0xffffffff;\r
x &= ~3; // align x\r
len = (len+3) >> 2;\r
for (h = 0; h < 8; h++) {\r
- p = (int *) ((unsigned char *) gp2x_screen+x+SCREEN_WIDTH*(y+h));\r
+ p = (int *) ((unsigned char *) gp2x_screen+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
}\r
emu_textOut8(x, y, text);\r
x &= ~1; // align x\r
len++;\r
for (h = 0; h < 16; h++) {\r
- p = (int *) ((unsigned short *) gp2x_screen+x+SCREEN_WIDTH*(y+h));\r
+ p = (int *) ((unsigned short *) gp2x_screen+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
}\r
textOut16(x, y, text);\r
// 8-bit modes\r
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*2+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*3+ 4) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*4+ 4) = col_g;\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*2+12) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*3+12) =\r
- *(unsigned int *)((char *)gp2x_screen + SCREEN_WIDTH*4+12) = col_r;\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*2+ 4) =\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*3+ 4) =\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*4+ 4) = col_g;\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*2+12) =\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*3+12) =\r
+ *(unsigned int *)((char *)gp2x_screen + g_screen_width*4+12) = col_r;\r
} else {\r
// 16-bit modes\r
- unsigned int *p = (unsigned int *)((short *)gp2x_screen + SCREEN_WIDTH*2+4);\r
+ unsigned int *p = (unsigned int *)((short *)gp2x_screen + g_screen_width*2+4);\r
unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += SCREEN_WIDTH/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += SCREEN_WIDTH/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
+ *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += g_screen_width/2 - 12/2;\r
*p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\r
}\r
}\r
if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))\r
p += 32;\r
\r
- p += SCREEN_WIDTH * (pico_pen_y + PICO_PEN_ADJUST_Y);\r
+ p += g_screen_width * (pico_pen_y + PICO_PEN_ADJUST_Y);\r
p += pico_pen_x + PICO_PEN_ADJUST_X;\r
p[0] ^= 0xffff;\r
p[319] ^= 0xffff;\r
static int EmuScanBegin8(unsigned int num)\r
{\r
if (!(Pico.video.reg[1]&8)) num += 8;\r
- DrawLineDest = (unsigned char *) gp2x_screen + SCREEN_WIDTH * num;\r
+ DrawLineDest = (unsigned char *) gp2x_screen + g_screen_width * num;\r
\r
return 0;\r
}\r
if (PicoRead16Hook == PicoSVPRead16)\r
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
// do actual copy\r
- vidCpyM2((unsigned char *)gp2x_screen+SCREEN_WIDTH*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)gp2x_screen+g_screen_width*8, PicoDraw2FB+328*8);\r
}\r
else if (!(emu_opt&0x80))\r
{\r
}\r
\r
if (notice || (emu_opt & 2)) {\r
- int h = SCREEN_HEIGHT-16;\r
+ int h = g_screen_height-16;\r
if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8)) h -= 16;\r
if (notice) osd_text(4, h, notice);\r
if (emu_opt & 2)\r
{\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
// 8-bit renderers\r
- if (full) gp2x_memset_all_buffers(0, 0xe0, SCREEN_WIDTH*240);\r
- else gp2x_memset_all_buffers(SCREEN_WIDTH*232, 0xe0, SCREEN_WIDTH*8);\r
+ if (full) gp2x_memset_all_buffers(0, 0xe0, g_screen_width*240);\r
+ else gp2x_memset_all_buffers(g_screen_width*232, 0xe0, g_screen_width*8);\r
} else {\r
// 16bit accurate renderer\r
- if (full) gp2x_memset_all_buffers(0, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2);\r
- else gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, 0, SCREEN_WIDTH*16*2);\r
+ if (full) gp2x_memset_all_buffers(0, 0, g_screen_width*g_screen_height*2);\r
+ else gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
}\r
}\r
\r
{\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
// 8-bit renderers\r
- gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16), 0xe0, SCREEN_WIDTH*16);\r
- osd_text(4, SCREEN_HEIGHT-16, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+SCREEN_WIDTH*(SCREEN_HEIGHT-16),\r
- SCREEN_WIDTH*(SCREEN_HEIGHT-16), SCREEN_WIDTH*16);\r
+ gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16), 0xe0, g_screen_width*16);\r
+ osd_text(4, g_screen_height-16, msg);\r
+ gp2x_memcpy_all_buffers((char *)gp2x_screen+g_screen_width*(g_screen_height-16),\r
+ g_screen_width*(g_screen_height-16), g_screen_width*16);\r
} else {\r
// 16bit accurate renderer\r
- gp2x_memset_all_buffers(SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, 0, SCREEN_WIDTH*16*2);\r
- osd_text(4, SCREEN_HEIGHT-16, msg);\r
- gp2x_memcpy_all_buffers((char *)gp2x_screen+SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2,\r
- SCREEN_WIDTH*(SCREEN_HEIGHT-16)*2, SCREEN_WIDTH*16*2);\r
+ gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
+ osd_text(4, g_screen_height-16, msg);\r
+ gp2x_memcpy_all_buffers((char *)gp2x_screen+g_screen_width*(g_screen_height-16)*2,\r
+ g_screen_width*(g_screen_height-16)*2, g_screen_width*16*2);\r
}\r
gettimeofday(¬iceMsgTime, 0);\r
noticeMsgTime.tv_sec -= 2;\r
#endif\r
}\r
if (do_it) {\r
- osd_text(4, SCREEN_HEIGHT-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
+ osd_text(4, g_screen_height-16, (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
PicoStateProgressCB = emu_state_cb;\r
- gp2x_memcpy_all_buffers(gp2x_screen, 0, SCREEN_WIDTH*SCREEN_HEIGHT*2);\r
+ gp2x_memcpy_all_buffers(gp2x_screen, 0, g_screen_width*g_screen_height*2);\r
emu_SaveLoadGame((which & 0x1000) >> 12, 0);\r
PicoStateProgressCB = NULL;\r
}\r
clearArea(1);\r
} else vidCpyM2 = vidCpyM2_40col;\r
\r
- vidCpyM2((unsigned char *)gp2x_screen+SCREEN_WIDTH*8, PicoDraw2FB+328*8);\r
+ vidCpyM2((unsigned char *)gp2x_screen+g_screen_width*8, PicoDraw2FB+328*8);\r
vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
gp2x_video_setpalette(localPal, 0x40);\r
*/\r
modes = ((Pico.video.reg[12]&1)<<2)|(Pico.video.reg[1]&8);\r
if (modes != oldmodes)\r
{\r
- int scalex = SCREEN_WIDTH;\r
+ int scalex = g_screen_width;\r
osd_fps_x = OSD_FPS_X;\r
if (modes & 4) {\r
vidCpyM2 = vidCpyM2_40col;\r
#define REDUCE_IO_CALLS 0\r
#define SIMPLE_WRITE_SOUND 0\r
\r
+#define SCREEN_SIZE_FIXED 1\r
+#define SCREEN_WIDTH 800\r
+#define SCREEN_HEIGHT 480\r
+\r
// draw.c\r
#define OVERRIDE_HIGHCOL 0\r
\r
#define REDUCE_IO_CALLS 1 // another workaround\r
#define SIMPLE_WRITE_SOUND 0\r
\r
+#define SCREEN_SIZE_FIXED 1\r
+#define SCREEN_WIDTH 512\r
+#define SCREEN_HEIGHT 272\r
+\r
// draw.c\r
#define USE_BGR555 1\r
#define OVERRIDE_HIGHCOL 1\r