-// (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
\r
va_start(args, texto);\r
vsnprintf(buffer, sizeof(buffer), texto, args);\r
va_end(args);\r
\r
- if (maxw > 255)\r
- maxw = 255;\r
+ if (maxw > sizeof(buffer) - 1)\r
+ maxw = sizeof(buffer) - 1;\r
buffer[maxw] = 0;\r
\r
text_out16_(x,y,buffer,menu_text_color);\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
+ char buffer[128];\r
+ int maxw = (g_screen_width - x) / 6;\r
+\r
+ if (maxw < 0)\r
+ return;\r
\r
strncpy(buffer, texto, sizeof(buffer));\r
- buffer[sizeof(buffer) - 1] = 0;\r
+ if (maxw > sizeof(buffer) - 1)\r
+ maxw = sizeof(buffer) - 1;\r
+ buffer[maxw] = 0;\r
\r
smalltext_out16_(x, y, buffer, color);\r
}\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