X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=c3ef87f56f06d3c13ab5a9de511f13a4a2feadf6;hb=13b692eb4ee66fd0c7d4d45bdead750a4defa90e;hp=ed02ff8d9287d59ecfdd63d4584ea25803a87e49;hpb=7695af0a5bf50329be07289f8eb8b9a59636963e;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index ed02ff8..c3ef87f 100644 --- a/common/menu.c +++ b/common/menu.c @@ -12,17 +12,35 @@ #include "fonts.h" #include "readpng.h" #include "lprintf.h" +#include "common.h" +#include "input.h" +#include "emu.h" -#if defined(__GP2X__) -#include "../gp2x/gp2x.h" -#define SCREEN_WIDTH 320 -#define SCREEN_BUFFER gp2x_screen -#elif defined(__GIZ__) -#include "../gizmondo/giz.h" -#define SCREEN_WIDTH 321 -#define SCREEN_BUFFER menu_screen -extern unsigned char menu_screen[321*240*2]; -#endif + +char menuErrorMsg[64] = { 0, }; + +// PicoPad[] format: MXYZ SACB RLDU +me_bind_action me_ctrl_actions[15] = +{ + { "UP ", 0x0001 }, + { "DOWN ", 0x0002 }, + { "LEFT ", 0x0004 }, + { "RIGHT ", 0x0008 }, + { "A ", 0x0040 }, + { "B ", 0x0010 }, + { "C ", 0x0020 }, + { "A turbo", 0x4000 }, + { "B turbo", 0x1000 }, + { "C turbo", 0x2000 }, + { "START ", 0x0080 }, + { "MODE ", 0x0800 }, + { "X ", 0x0400 }, + { "Y ", 0x0200 }, + { "Z ", 0x0100 } +}; + + +#ifndef UIQ3 static unsigned char menu_font_data[10240]; static int menu_text_color = 0xffff; // default to white @@ -158,7 +176,12 @@ static int parse_hex_color(char *buff) { char *endp = buff; int t = (int) strtoul(buff, &endp, 16); - if (endp != buff) return ((t>>8)&0xf800) | ((t>>5)&0x07e0) | ((t>>3)&0x1f); + if (endp != buff) +#ifdef PSP + return ((t<<8)&0xf800) | ((t>>5)&0x07e0) | ((t>>19)&0x1f); +#else + return ((t>>8)&0xf800) | ((t>>5)&0x07e0) | ((t>>3)&0x1f); +#endif return -1; } @@ -311,5 +334,167 @@ int me_process(menu_entry *entries, int count, menu_id id, int is_next) } } +// ------------ debug menu ------------ + +#include +#include + +#include +#include + +void SekStepM68k(void); + +static void mplayer_loop(void) +{ + emu_startSound(); + + while (1) + { + PDebugZ80Frame(); + if (in_menu_wait_any(0) & PBTN_NORTH) break; + emu_waitSound(); + } + + emu_endSound(); +} + +static void draw_text_debug(const char *str, int skip, int from) +{ + const char *p; + int len, line; + + p = str; + while (skip-- > 0) + { + while (*p && *p != '\n') p++; + if (*p == 0 || p[1] == 0) return; + p++; + } + + str = p; + for (line = from; line < SCREEN_HEIGHT/10; line++) + { + while (*p && *p != '\n') p++; + len = p - str; + if (len > 55) len = 55; + smalltext_out16_lim(1, line*10, str, 0xffff, len); + if (*p == 0) break; + p++; str = p; + } +} + +static void draw_frame_debug(void) +{ + char layer_str[48] = "layers: "; + if (PicoDrawMask & PDRAW_LAYERB_ON) memcpy(layer_str + 8, "B", 1); + if (PicoDrawMask & PDRAW_LAYERA_ON) memcpy(layer_str + 10, "A", 1); + if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6); + if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); + + clear_screen(); + emu_forcedFrame(0); + smalltext_out16(4, SCREEN_HEIGHT-8, layer_str, 0xffff); +} + +void debug_menu_loop(void) +{ + int inp, mode = 0; + int spr_offs = 0, dumped = 0; + char *tmp; + + while (1) + { + switch (mode) + { + case 0: menu_draw_begin(); + tmp = PDebugMain(); + emu_platformDebugCat(tmp); + draw_text_debug(tmp, 0, 0); + if (dumped) { + smalltext_out16(SCREEN_WIDTH-6*10, SCREEN_HEIGHT-8, "dumped", 0xffff); + dumped = 0; + } + break; + case 1: draw_frame_debug(); break; + case 2: clear_screen(); + emu_forcedFrame(0); + darken_screen(); + PDebugShowSpriteStats((unsigned short *)SCREEN_BUFFER + (SCREEN_HEIGHT/2 - 240/2)*SCREEN_WIDTH + + SCREEN_WIDTH/2 - 320/2, SCREEN_WIDTH); break; + case 3: clear_screen(); + PDebugShowPalette(SCREEN_BUFFER, SCREEN_WIDTH); + PDebugShowSprite((unsigned short *)SCREEN_BUFFER + SCREEN_WIDTH*120+SCREEN_WIDTH/2+16, + SCREEN_WIDTH, spr_offs); + draw_text_debug(PDebugSpriteList(), spr_offs, 6); + break; + } + menu_draw_end(); + + inp = in_menu_wait(PBTN_EAST|PBTN_MBACK|PBTN_WEST|PBTN_NORTH|PBTN_L|PBTN_R|PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT); + if (inp & PBTN_MBACK) return; + if (inp & PBTN_L) { mode--; if (mode < 0) mode = 3; } + if (inp & PBTN_R) { mode++; if (mode > 3) mode = 0; } + switch (mode) + { + case 0: + if (inp & PBTN_EAST) SekStepM68k(); + if (inp & PBTN_NORTH) { + while (inp & PBTN_NORTH) inp = in_menu_wait_any(-1); + mplayer_loop(); + } + if ((inp & (PBTN_WEST|PBTN_LEFT)) == (PBTN_WEST|PBTN_LEFT)) { + mkdir("dumps", 0777); + PDebugDumpMem(); + while (inp & PBTN_WEST) inp = in_menu_wait_any(-1); + dumped = 1; + } + break; + case 1: + if (inp & PBTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; + if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; + if (inp & PBTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; + if (inp & PBTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; + if (inp & PBTN_EAST) { + PsndOut = NULL; // just in case + PicoSkipFrame = 1; + PicoFrame(); + PicoSkipFrame = 0; + while (inp & PBTN_EAST) inp = in_menu_wait_any(-1); + } + break; + case 3: + if (inp & PBTN_DOWN) spr_offs++; + if (inp & PBTN_UP) spr_offs--; + if (spr_offs < 0) spr_offs = 0; + break; + } + } +} + +#endif // !UIQ3 + +// ------------ util ------------ + +const char *me_region_name(unsigned int code, int auto_order) +{ + static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" }; + static const char *names_short[] = { "", " JP", " JP", " US", " EU" }; + int u, i = 0; + if (code) { + code <<= 1; + while((code >>= 1)) i++; + if (i > 4) return "unknown"; + return names[i]; + } else { + static char name[24]; + strcpy(name, "Auto:"); + for (u = 0; u < 3; u++) { + i = 0; code = ((auto_order >> u*4) & 0xf) << 1; + while((code >>= 1)) i++; + strcat(name, names_short[i]); + } + return name; + } +}