X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Fmenu.c;h=80fdff81d33376d4ac69916c93abf8370754eeaa;hb=9b8ad40b4854013fa97627e706327d9a174a4fa9;hp=c2e18fa853c2d762138ed42c4e1fadda0ee0e57d;hpb=5a31ef07776f196cbf25748eee78da65b2b89928;p=libpicofe.git diff --git a/common/menu.c b/common/menu.c index c2e18fa..80fdff8 100644 --- a/common/menu.c +++ b/common/menu.c @@ -12,11 +12,11 @@ #include "fonts.h" #include "readpng.h" #include "lprintf.h" -#include "common.h" #include "input.h" #include "emu.h" #include "plat.h" #include "posix.h" +#include #include #include @@ -33,10 +33,14 @@ static int menu_error_time = 0; static unsigned char *menu_font_data = NULL; static int menu_text_color = 0xffff; // default to white static int menu_sel_color = -1; // disabled + +/* note: these might become non-constant in future */ #if MENU_X2 static const int me_mfont_w = 16, me_mfont_h = 20; +static const int me_sfont_w = 12, me_sfont_h = 20; #else static const int me_mfont_w = 8, me_mfont_h = 10; +static const int me_sfont_w = 6, me_sfont_h = 10; #endif // draws text to current bbp16 screen @@ -113,35 +117,41 @@ void text_out16(int x, int y, const char *texto, ...) text_out16_(x,y,buffer,menu_text_color); } - +/* draws in 6x8 font, might multiply size by integer */ static void smalltext_out16_(int x, int y, const char *texto, int color) { - int i; unsigned char *src; unsigned short *dst; + int multiplier = me_sfont_w / 6; + int i; - for (i = 0;; i++, x += 6) + for (i = 0;; i++, x += me_sfont_w) { unsigned char c = (unsigned char) texto[i]; int h = 8; - if (!c) break; + if (!c || c == '\n') + break; src = fontdata6x8[c]; dst = (unsigned short *)g_screen_ptr + x + y * g_screen_width; while (h--) { - int w = 0x20; - while (w) + int m, w2, h2; + for (h2 = multiplier; h2 > 0; h2--) { - if( *src & w ) *dst = color; - dst++; - w>>=1; + for (m = 0x20; m; m >>= 1) { + if (*src & m) + for (w2 = multiplier; w2 > 0; w2--) + *dst++ = color; + else + dst += multiplier; + } + + dst += g_screen_width - me_sfont_w; } src++; - - dst += g_screen_width - 6; } } } @@ -252,14 +262,17 @@ void menu_init(void) } // load custom font and selector (stored as 1st symbol in font table) - readpng(menu_font_data, "skin/font.png", READPNG_FONT); + emu_make_path(buff, "skin/font.png", sizeof(buff)); + readpng(menu_font_data, buff, READPNG_FONT); // default selector symbol is '>' memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2, me_mfont_w * me_mfont_h / 2); - readpng(menu_font_data, "skin/selector.png", READPNG_SELECTOR); + emu_make_path(buff, "skin/selector.png", sizeof(buff)); + readpng(menu_font_data, buff, READPNG_SELECTOR); // load custom colors - f = fopen("skin/skin.txt", "r"); + emu_make_path(buff, "skin/skin.txt", sizeof(buff)); + f = fopen(buff, "r"); if (f != NULL) { lprintf("found skin.txt\n"); @@ -314,11 +327,11 @@ static int me_count(const menu_entry *ent) return ret; } -static void me_draw(const menu_entry *entries, int sel) +static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) { const menu_entry *ent; int x, y, w = 0, h = 0; - int offs, opt_offs = 27 * me_mfont_w; + int offs, col2_offs = 27 * me_mfont_w; const char *name; int asel = 0; int i, n; @@ -343,9 +356,9 @@ static void me_draw(const menu_entry *entries, int sel) if (ent->beh != MB_NONE) { - if (wt > opt_offs) - opt_offs = wt + me_mfont_w; - wt = opt_offs; + if (wt > col2_offs) + col2_offs = wt + me_mfont_w; + wt = col2_offs; switch (ent->beh) { case MB_NONE: break; @@ -405,10 +418,10 @@ static void me_draw(const menu_entry *entries, int sel) case MB_NONE: break; case MB_OPT_ONOFF: - text_out16(x + opt_offs, y, (*(int *)ent->var & ent->mask) ? "ON" : "OFF"); + text_out16(x + col2_offs, y, (*(int *)ent->var & ent->mask) ? "ON" : "OFF"); break; case MB_OPT_RANGE: - text_out16(x + opt_offs, y, "%i", *(int *)ent->var); + text_out16(x + col2_offs, y, "%i", *(int *)ent->var); break; case MB_OPT_CUSTOM: case MB_OPT_CUSTONOFF: @@ -418,7 +431,7 @@ static void me_draw(const menu_entry *entries, int sel) if (ent->generate_name) name = ent->generate_name(ent->id, &offs); if (name != NULL) - text_out16(x + opt_offs + offs * me_mfont_w, y, "%s", name); + text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", name); break; } @@ -436,6 +449,9 @@ static void me_draw(const menu_entry *entries, int sel) menu_error_msg[0] = 0; } + if (draw_more != NULL) + draw_more(); + plat_video_menu_end(); } @@ -462,12 +478,12 @@ static int me_process(menu_entry *entry, int is_next) static void debug_menu_loop(void); -static void me_loop(menu_entry *menu, int *menu_sel) +static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void)) { int ret, inp, sel = *menu_sel, menu_sel_max; menu_sel_max = me_count(menu) - 1; - if (menu_sel_max < 1) { + if (menu_sel_max < 0) { lprintf("no enabled menu entries\n"); return; } @@ -476,12 +492,12 @@ static void me_loop(menu_entry *menu, int *menu_sel) sel++; /* make sure action buttons are not pressed on entering menu */ - me_draw(menu, sel); + me_draw(menu, sel, NULL); while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU)); for (;;) { - me_draw(menu, sel); + me_draw(menu, sel, draw_more); inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT| PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R, 70); if (inp & (PBTN_MENU|PBTN_MBACK)) @@ -527,6 +543,9 @@ static void me_loop(menu_entry *menu, int *menu_sel) /* ***************************************** */ +/* platform specific options and handlers */ +#include "../gp2x/menu.c" + static void draw_menu_credits(void) { const char *creds, *p; @@ -585,15 +604,15 @@ static void cdload_progress_cb(int percent) int ln, len = percent * g_screen_width / 100; unsigned short *dst = (unsigned short *)g_screen_ptr + g_screen_width * 10 * 2; - memset(dst, 0xff, g_screen_width * (10 - 2) * 2); + memset(dst, 0xff, g_screen_width * (me_sfont_h - 2) * 2); - smalltext_out16(1, 3 * 10, "Processing CD image / MP3s", 0xffff); - smalltext_out16(1, 4 * 10, rom_fname_loaded, 0xffff); - dst += g_screen_width * 30; + smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff); + smalltext_out16(1, 4 * me_sfont_h, rom_fname_loaded, 0xffff); + dst += g_screen_width * me_sfont_h * 3; if (len > g_screen_width) len = g_screen_width; - for (ln = (10 - 2); ln > 0; ln--, dst += g_screen_width) + for (ln = (me_sfont_h - 2); ln > 0; ln--, dst += g_screen_width) memset(dst, 0xff, len * 2); plat_video_menu_end(); @@ -610,12 +629,12 @@ void menu_romload_prepare(const char *rom_name) /* fill both buffers, callbacks won't update in full */ plat_video_menu_begin(); smalltext_out16(1, 1, "Loading", 0xffff); - smalltext_out16(1, 10, p, 0xffff); + smalltext_out16(1, me_sfont_h, p, 0xffff); plat_video_menu_end(); plat_video_menu_begin(); smalltext_out16(1, 1, "Loading", 0xffff); - smalltext_out16(1, 10, p, 0xffff); + smalltext_out16(1, me_sfont_h, p, 0xffff); plat_video_menu_end(); PicoCartLoadProgressCB = load_progress_cb; @@ -626,11 +645,49 @@ void menu_romload_prepare(const char *rom_name) void menu_romload_end(void) { PicoCartLoadProgressCB = PicoCDLoadProgressCB = NULL; - smalltext_out16(1, (cdload_called ? 6 : 3) * 10, + smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h, "Starting emulation...", 0xffff); plat_video_menu_end(); } +// -------------- del confirm --------------- + +static void do_delete(const char *fpath, const char *fname) +{ + int len, mid, inp; + const char *nm; + char tmp[64]; + + plat_video_menu_begin(); + + if (!rom_loaded) + menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0); + + len = strlen(fname); + if (len > g_screen_width/6) + len = g_screen_width/6; + + mid = g_screen_width / 2; + text_out16(mid - me_mfont_w * 15 / 2, 8 * me_mfont_h, "About to delete"); + smalltext_out16(mid - len * me_sfont_w / 2, 9 * me_mfont_h + 5, fname, 0xbdff); + text_out16(mid - me_mfont_w * 13 / 2, 11 * me_mfont_h, "Are you sure?"); + + nm = in_get_key_name(-1, -PBTN_MA3); + snprintf(tmp, sizeof(tmp), "(%s - confirm, ", nm); + len = strlen(tmp); + nm = in_get_key_name(-1, -PBTN_MBACK); + snprintf(tmp + len, sizeof(tmp) - len, "%s - cancel)", nm); + len = strlen(tmp); + + text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp); + plat_video_menu_end(); + + while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MA2)); + inp = in_menu_wait(PBTN_MA3|PBTN_MBACK, 100); + if (inp & PBTN_MA3) + remove(fpath); +} + // -------------- ROM selector -------------- // rrrr rggg gggb bbbb @@ -651,9 +708,9 @@ static unsigned short file2color(const char *fname) static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) { - int max_cnt, start, i, pos; + int max_cnt, start, i, x, pos; - max_cnt = g_screen_height / 10; + max_cnt = g_screen_height / me_sfont_h; start = max_cnt / 2 - sel; n--; // exclude current dir (".") @@ -664,21 +721,22 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel) menu_darken_bg((short *)g_screen_ptr + g_screen_width * max_cnt/2 * 10, g_screen_width * 8, 0); + x = 5 + me_mfont_w + 1; if (start - 2 >= 0) - smalltext_out16(14, (start - 2)*10, curdir, 0xffff); + smalltext_out16(14, (start - 2) * me_sfont_h, curdir, 0xffff); for (i = 0; i < n; i++) { pos = start + i; if (pos < 0) continue; if (pos >= max_cnt) break; if (namelist[i+1]->d_type == DT_DIR) { - smalltext_out16(14, pos*10, "/", 0xfff6); - smalltext_out16(14+6, pos*10, namelist[i+1]->d_name, 0xfff6); + smalltext_out16(x, pos * me_sfont_h, "/", 0xfff6); + smalltext_out16(x + me_sfont_w, pos * me_sfont_h, namelist[i+1]->d_name, 0xfff6); } else { unsigned short color = file2color(namelist[i+1]->d_name); - smalltext_out16(14, pos*10, namelist[i+1]->d_name, color); + smalltext_out16(x, pos * me_sfont_h, namelist[i+1]->d_name, color); } } - smalltext_out16(5, max_cnt/2 * 10, ">", 0xffff); + smalltext_out16(5, max_cnt/2 * me_sfont_h, ">", 0xffff); plat_video_menu_end(); } @@ -777,7 +835,7 @@ rescan: ret = rom_fname_reload; break; } -// do_delete(rom_fname_reload, namelist[sel+1]->d_name); // TODO + do_delete(rom_fname_reload, namelist[sel+1]->d_name); if (n > 0) { while (n--) free(namelist[n]); free(namelist); @@ -855,14 +913,14 @@ static void draw_patchlist(int sel) if (pos < 0) continue; if (pos >= max_cnt) break; active = PicoPatches[i].active; - smalltext_out16(14, pos*10, active ? "ON " : "OFF", active ? 0xfff6 : 0xffff); - smalltext_out16(14+6*4, pos*10, PicoPatches[i].name, active ? 0xfff6 : 0xffff); + smalltext_out16(14, pos * me_sfont_h, active ? "ON " : "OFF", active ? 0xfff6 : 0xffff); + smalltext_out16(14+6*4, pos * me_sfont_h, PicoPatches[i].name, active ? 0xfff6 : 0xffff); } pos = start + i; if (pos < max_cnt) - smalltext_out16(14, pos * 10, "done", 0xffff); + smalltext_out16(14, pos * me_sfont_h, "done", 0xffff); - text_out16(5, max_cnt / 2 * 10, ">"); + text_out16(5, max_cnt / 2 * me_sfont_h, ">"); plat_video_menu_end(); } @@ -900,7 +958,7 @@ static void state_check_slots(void) state_slot_flags = 0; for (slot = 0; slot < 10; slot++) { - if (emu_checkSaveFile(slot)) + if (emu_check_save_file(slot)) state_slot_flags |= 1 << slot; } } @@ -913,7 +971,7 @@ static void draw_savestate_bg(int slot) void *tmp_vram, *file; char *fname; - fname = emu_GetSaveFName(1, 0, slot); + fname = emu_get_save_fname(1, 0, slot); if (!fname) return; tmp_vram = malloc(sizeof(Pico.vram)); @@ -948,7 +1006,7 @@ static void draw_savestate_bg(int slot) } /* do a frame and fetch menu bg */ - emu_forcedFrame(POPT_EN_SOFTSCALE); + pemu_forced_frame(POPT_EN_SOFTSCALE); plat_video_menu_enter(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); @@ -965,7 +1023,7 @@ static void draw_savestate_menu(int menu_sel, int is_loading) if (state_slot_flags & (1 << menu_sel)) draw_savestate_bg(menu_sel); - w = 13 * me_mfont_w + me_mfont_w * 2; + w = (13 + 2) * me_mfont_w; h = (1+2+10+1) * me_mfont_h; x = g_screen_width / 2 - w / 2; if (x < 0) x = 0; @@ -1018,7 +1076,7 @@ static int menu_loop_savestate(int is_loading) if (inp & PBTN_MOK) { // save/load if (menu_sel < 10) { state_slot = menu_sel; - if (emu_SaveLoadGame(is_loading, 0)) { + if (emu_save_load_game(is_loading, 0)) { me_update_msg(is_loading ? "Load failed" : "Save failed"); return 0; } @@ -1035,8 +1093,8 @@ static int menu_loop_savestate(int is_loading) static char *action_binds(int player_idx, int action_mask, int dev_id) { + int k, count, can_combo, type; const int *binds; - int k, count; static_buff[0] = 0; @@ -1044,26 +1102,39 @@ static char *action_binds(int player_idx, int action_mask, int dev_id) if (binds == NULL) return static_buff; - count = in_get_dev_bind_count(dev_id); + count = in_get_dev_info(dev_id, IN_INFO_BIND_COUNT); + can_combo = in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS); + + type = IN_BINDTYPE_EMU; + if (player_idx >= 0) { + can_combo = 0; + type = IN_BINDTYPE_PLAYER12; + } + if (player_idx == 1) + action_mask <<= 16; + for (k = 0; k < count; k++) { const char *xname; - if (!(binds[k] & action_mask)) - continue; + int len; - if (player_idx >= 0 && ((binds[k] >> 16) & 3) != player_idx) + if (!(binds[IN_BIND_OFFS(k, type)] & action_mask)) continue; xname = in_get_key_name(dev_id, k); - if (static_buff[0]) - strncat(static_buff, " + ", sizeof(static_buff)); - strncat(static_buff, xname, sizeof(static_buff)); + len = strlen(static_buff); + if (len) { + strncat(static_buff, can_combo ? " + " : ", ", + sizeof(static_buff) - len - 1); + len += can_combo ? 3 : 2; + } + strncat(static_buff, xname, sizeof(static_buff) - len - 1); } return static_buff; } -static int count_bound_keys(int dev_id, int action_mask, int player_idx) +static int count_bound_keys(int dev_id, int action_mask, int bindtype) { const int *binds; int k, keys = 0; @@ -1073,16 +1144,11 @@ static int count_bound_keys(int dev_id, int action_mask, int player_idx) if (binds == NULL) return 0; - count = in_get_dev_bind_count(dev_id); + count = in_get_dev_info(dev_id, IN_INFO_BIND_COUNT); for (k = 0; k < count; k++) { - if (!(binds[k] & action_mask)) - continue; - - if (player_idx >= 0 && ((binds[k] >> 16) & 3) != player_idx) - continue; - - keys++; + if (binds[IN_BIND_OFFS(k, bindtype)] & action_mask) + keys++; } return keys; @@ -1091,6 +1157,7 @@ static int count_bound_keys(int dev_id, int action_mask, int player_idx) static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel, int dev_id, int dev_count, int is_bind) { + char buff[64], buff2[32]; const char *dev_name; int x, y, w, i; @@ -1122,15 +1189,19 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ x = g_screen_width / 2 - w / 2; - if (dev_count > 1) { - text_out16(x, g_screen_height - 4 * me_mfont_h, "Viewing binds for:"); - text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name); + if (!is_bind) { + snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK)); + snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2, + in_get_key_name(-1, -PBTN_MA2)); + text_out16(x, g_screen_height - 4 * me_mfont_h, buff); } + else + text_out16(x, g_screen_height - 4 * me_mfont_h, "Press a button to bind/unbind"); - if (is_bind) - text_out16(x, g_screen_height - 2 * me_mfont_h, "Press a button to bind/unbind"); - else if (dev_count > 1) + if (dev_count > 1) { + text_out16(x, g_screen_height - 3 * me_mfont_h, dev_name); text_out16(x, g_screen_height - 2 * me_mfont_h, "Press left/right for other devs"); + } plat_video_menu_end(); } @@ -1138,7 +1209,8 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx) { int i, sel = 0, menu_sel_max = opt_cnt - 1; - int dev_id, dev_count, kc, is_down, mkey, unbind; + int dev_id, dev_count, kc, is_down, mkey; + int unbind, bindtype, mask_shift; for (i = 0, dev_id = -1, dev_count = 0; i < IN_MAX_DEVS; i++) { if (in_get_dev_name(i, 1, 0) != NULL) { @@ -1153,10 +1225,15 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ return; } + mask_shift = 0; + if (player_idx == 1) + mask_shift = 16; + bindtype = player_idx >= 0 ? IN_BINDTYPE_PLAYER12 : IN_BINDTYPE_EMU; + for (;;) { draw_key_config(opts, opt_cnt, player_idx, sel, dev_id, dev_count, 0); - mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK, 100); + mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MBACK|PBTN_MOK|PBTN_MA2, 100); switch (mkey) { case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue; case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue; @@ -1182,6 +1259,9 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ return; while (in_menu_wait_any(30) & PBTN_MOK); break; + case PBTN_MA2: + in_unbind_all(dev_id, opts[sel].mask << mask_shift, bindtype); + continue; default:continue; } @@ -1191,14 +1271,15 @@ static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_ for (is_down = 1; is_down; ) kc = in_update_keycode(&dev_id, &is_down, -1); - unbind = count_bound_keys(dev_id, opts[sel].mask, player_idx) >= 2; + i = count_bound_keys(dev_id, opts[sel].mask << mask_shift, bindtype); + unbind = (i > 0); - in_bind_key(dev_id, kc, opts[sel].mask, unbind); - if (player_idx >= 0) { - /* FIXME */ - in_bind_key(dev_id, kc, 3 << 16, 1); - in_bind_key(dev_id, kc, player_idx << 16, 0); - } + /* allow combos if device supports them */ + if (i == 1 && bindtype == IN_BINDTYPE_EMU && + in_get_dev_info(dev_id, IN_INFO_DOES_COMBOS)) + unbind = 0; + + in_bind_key(dev_id, kc, opts[sel].mask << mask_shift, bindtype, unbind); } } @@ -1222,25 +1303,21 @@ me_bind_action me_ctrl_actions[15] = { "Z ", 0x0100 } }; -// player2_flag, reserved, ?, ?, -// ?, ?, fast forward, menu -// "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE", -// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE" me_bind_action emuctrl_actions[] = { - { "Load State ", 1<<28 }, - { "Save State ", 1<<27 }, - { "Prev Save Slot ", 1<<25 }, - { "Next Save Slot ", 1<<24 }, - { "Switch Renderer ", 1<<26 }, - { "Volume Down ", 1<<30 }, - { "Volume Up ", 1<<29 }, - { "Fast forward ", 1<<22 }, - { "Enter Menu ", 1<<23 }, - { "Pico Next page ", 1<<21 }, - { "Pico Prev page ", 1<<20 }, - { "Pico Switch input", 1<<19 }, - { NULL, 0 } + { "Load State ", PEV_STATE_LOAD }, + { "Save State ", PEV_STATE_SAVE }, + { "Prev Save Slot ", PEV_SSLOT_PREV }, + { "Next Save Slot ", PEV_SSLOT_NEXT }, + { "Switch Renderer ", PEV_SWITCH_RND }, + { "Volume Down ", PEV_VOL_DOWN }, + { "Volume Up ", PEV_VOL_UP }, + { "Fast forward ", PEV_FF }, + { "Enter Menu ", PEV_MENU }, + { "Pico Next page ", PEV_PICO_PNEXT }, + { "Pico Prev page ", PEV_PICO_PPREV }, + { "Pico Switch input", PEV_PICO_SWINP }, + { NULL, 0 } }; static int key_config_loop_wrap(menu_id id, int keys) @@ -1306,7 +1383,9 @@ static menu_entry e_menu_keyconfig[] = static int menu_loop_keyconfig(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_keyconfig, &sel); + + me_enable(e_menu_keyconfig, MA_OPT_SAVECFG_GAME, rom_loaded); + me_loop(e_menu_keyconfig, &sel, NULL); return 0; } @@ -1352,78 +1431,52 @@ static menu_entry e_menu_cd_options[] = static int menu_loop_cd_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_cd_options, &sel); + me_loop(e_menu_cd_options, &sel, NULL); return 0; } // ------------ adv options menu ------------ -// TODO FIXME fix if and mv -static const char *mgn_aopt_sqhack(menu_id id, int *offs) -{ - *offs = -10; - sprintf(static_buff, "%s, %s", 111 ? " active" : "inactive", - (currentConfig.EmuOpt & 0x10) ? "ON" : "OFF"); - return static_buff; -} - static menu_entry e_menu_adv_options[] = { - mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_USE_SRAM), + mee_onoff ("SRAM/BRAM saves", MA_OPT_SRAM_STATES, currentConfig.EmuOpt, EOPT_EN_SRAM), mee_onoff ("Disable sprite limit", MA_OPT2_NO_SPRITE_LIM, PicoOpt, POPT_DIS_SPRITE_LIM), - mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), mee_onoff ("Emulate Z80", MA_OPT2_ENABLE_Z80, PicoOpt, POPT_EN_Z80), mee_onoff ("Emulate YM2612 (FM)", MA_OPT2_ENABLE_YM2612, PicoOpt, POPT_EN_FM), mee_onoff ("Emulate SN76496 (PSG)", MA_OPT2_ENABLE_SN76496,PicoOpt, POPT_EN_PSG), mee_onoff ("gzip savestates", MA_OPT2_GZIP_STATES, currentConfig.EmuOpt, EOPT_GZIP_SAVES), mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG), - mee_label ("- needs restart -"), - mee_onoff ("craigix's RAM timings", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, 0x0100), - mee_onoff_cust("Squidgehack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, 0x0010, mgn_aopt_sqhack), - mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET), + MENU_GP2X_OPTIONS_ADV mee_end, }; static int menu_loop_adv_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_adv_options, &sel); + me_loop(e_menu_adv_options, &sel, NULL); return 0; } // ------------ gfx options menu ------------ -static const char *mgn_opt_scaling(menu_id id, int *offs) -{ - *offs = -12; - switch (currentConfig.scaling) { - default: return " OFF"; - case 1: return "hw horizontal"; - case 2: return "hw horiz. + vert."; - case 3: return "sw horizontal"; - } -} - -static const char *mgn_aopt_gamma(menu_id id, int *offs) +static int mh_opt_render(menu_id id, int keys) { - sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); - return static_buff; + plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 1); + return 0; } static menu_entry e_menu_gfx_options[] = { - mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), - mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), - mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, 0x1000), - mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, 0x2000), + mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), + MENU_GP2X_OPTIONS_GFX mee_end, }; static int menu_loop_gfx_options(menu_id id, int keys) { static int sel = 0; - me_loop(e_menu_gfx_options, &sel); + me_loop(e_menu_gfx_options, &sel, NULL); return 0; } @@ -1431,20 +1484,6 @@ static int menu_loop_gfx_options(menu_id id, int keys) static menu_entry e_menu_options[]; -/* TODO: move to plat */ -static int mh_opt_render(menu_id id, int keys) -{ - if (keys & PBTN_LEFT) { - if (PicoOpt&0x10) PicoOpt&= ~0x10; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; - } else { - if (PicoOpt&0x10) return 0; - else if (!(currentConfig.EmuOpt &0x80))PicoOpt|= 0x10; - else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80; - } - return 0; -} - static int sndrate_prevnext(int rate, int dir) { static const int rates[] = { 8000, 11025, 16000, 22050, 44100 }; @@ -1539,14 +1578,14 @@ static int mh_saveloadcfg(menu_id id, int keys) switch (id) { case MA_OPT_SAVECFG: case MA_OPT_SAVECFG_GAME: - if (emu_WriteConfig(id == MA_OPT_SAVECFG_GAME ? 1 : 0)) + if (emu_write_config(id == MA_OPT_SAVECFG_GAME ? 1 : 0)) me_update_msg("config saved"); else me_update_msg("failed to write config"); break; case MA_OPT_LOADCFG: - ret = emu_ReadConfig(1, 1); - if (!ret) ret = emu_ReadConfig(0, 1); + ret = emu_read_config(1, 1); + if (!ret) ret = emu_read_config(0, 1); if (ret) me_update_msg("config loaded"); else me_update_msg("failed to load config"); break; @@ -1557,15 +1596,11 @@ static int mh_saveloadcfg(menu_id id, int keys) return 1; } -static const char *mgn_opt_renderer(menu_id id, int *offs) +static int mh_restore_defaults(menu_id id, int keys) { - *offs = -6; - if (PicoOpt & POPT_ALT_RENDERER) - return " 8bit fast"; - else if (currentConfig.EmuOpt & 0x80) - return "16bit accurate"; - else - return " 8bit accurate"; + emu_set_defconfig(); + me_update_msg("defaults restored"); + return 1; } static const char *mgn_opt_fskip(menu_id id, int *offs) @@ -1640,22 +1675,18 @@ static menu_entry e_menu_options[] = mee_range ("Save slot", MA_OPT_SAVE_SLOT, state_slot, 0, 9), mee_range_cust("Frameskip", MA_OPT_FRAMESKIP, currentConfig.Frameskip, -1, 16, mgn_opt_fskip), mee_cust ("Region", MA_OPT_REGION, mh_opt_misc, mgn_opt_region), - mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer), - mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, 0x002), - mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, 0x004), + mee_onoff ("Show FPS", MA_OPT_SHOW_FPS, currentConfig.EmuOpt, EOPT_SHOW_FPS), + mee_onoff ("Enable sound", MA_OPT_ENABLE_SOUND, currentConfig.EmuOpt, EOPT_EN_SOUND), mee_cust ("Sound Quality", MA_OPT_SOUND_QUALITY, mh_opt_misc, mgn_opt_sound), mee_cust ("Confirm savestate", MA_OPT_CONFIRM_STATES,mh_opt_misc, mgn_opt_c_saves), -#if defined(__GP2X__) - mee_range ("GP2X CPU clocks", MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 400), -#elif defined(PSP) - mee_range ("PSP CPU clock", MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, ) -#endif + mee_range (cpu_clk_name, MA_OPT_CPU_CLOCKS, currentConfig.CPUclock, 20, 900), mee_handler ("[Display options]", menu_loop_gfx_options), mee_handler ("[Advanced options]", menu_loop_adv_options), mee_handler ("[Sega/Mega CD options]", menu_loop_cd_options), mee_handler_mkname_id(MA_OPT_SAVECFG, mh_saveloadcfg, mgn_savecfg), mee_handler_id("Save cfg for current game only", MA_OPT_SAVECFG_GAME, mh_saveloadcfg), mee_handler_mkname_id(MA_OPT_LOADCFG, mh_saveloadcfg, mgn_loadcfg), + mee_handler ("Restore defaults", mh_restore_defaults), mee_end, }; @@ -1666,7 +1697,7 @@ static int menu_loop_options(menu_id id, int keys) me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, rom_loaded); me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current); - me_loop(e_menu_options, &sel); + me_loop(e_menu_options, &sel, NULL); if (PicoRegionOverride) // force setting possibly changed.. @@ -1677,26 +1708,23 @@ static int menu_loop_options(menu_id id, int keys) // ------------ debug menu ------------ -#include -#include - #include extern void SekStepM68k(void); static void mplayer_loop(void) { - emu_startSound(); + pemu_sound_start(); while (1) { PDebugZ80Frame(); if (in_menu_wait_any(0) & PBTN_MA3) break; - emu_waitSound(); + pemu_sound_wait(); } - emu_endSound(); + pemu_sound_stop(); } static void draw_text_debug(const char *str, int skip, int from) @@ -1707,17 +1735,21 @@ static void draw_text_debug(const char *str, int skip, int from) p = str; while (skip-- > 0) { - while (*p && *p != '\n') p++; - if (*p == 0 || p[1] == 0) return; + while (*p && *p != '\n') + p++; + if (*p == 0 || p[1] == 0) + return; p++; } str = p; - for (line = from; line < g_screen_height / 10; line++) + for (line = from; line < g_screen_height / me_sfont_h; line++) { - while (*p && *p != '\n') p++; - smalltext_out16(1, line*10, str, 0xffff); - if (*p == 0) break; + smalltext_out16(1, line * me_sfont_h, str, 0xffff); + while (*p && *p != '\n') + p++; + if (*p == 0) + break; p++; str = p; } } @@ -1731,8 +1763,9 @@ static void draw_frame_debug(void) if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); - emu_forcedFrame(0); - smalltext_out16(4, g_screen_height - 8, layer_str, 0xffff); + pemu_forced_frame(0); + smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, 0xffff); + smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff); } static void debug_menu_loop(void) @@ -1747,17 +1780,17 @@ static void debug_menu_loop(void) { case 0: plat_video_menu_begin(); tmp = PDebugMain(); - emu_platformDebugCat(tmp); + plat_debug_cat(tmp); draw_text_debug(tmp, 0, 0); if (dumped) { - smalltext_out16(g_screen_width - 6 * me_mfont_h, + smalltext_out16(g_screen_width - 6 * me_sfont_h, g_screen_height - me_mfont_h, "dumped", 0xffff); dumped = 0; } break; case 1: draw_frame_debug(); break; case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2); - emu_forcedFrame(0); + pemu_forced_frame(0); menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0); PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width + g_screen_width/2 - 320/2, g_screen_width); break; @@ -1850,7 +1883,7 @@ static int main_menu_handler(menu_id id, int keys) break; case MA_MAIN_RESET_GAME: if (rom_loaded) { - emu_ResetGame(); + emu_reset_game(); return 1; } break; @@ -1915,7 +1948,7 @@ void menu_loop(void) plat_video_menu_enter(rom_loaded); in_set_blocking(1); - me_loop(e_menu_main, &sel); + me_loop(e_menu_main, &sel, menu_main_plat_draw); if (rom_loaded) { if (engineState == PGS_Menu) @@ -1939,7 +1972,7 @@ static int mh_tray_load_cd(menu_id id, int keys) if (ret_name == NULL) return 0; - cd_type = emu_cdCheck(NULL, ret_name); + cd_type = emu_cd_check(NULL, ret_name); if (cd_type != CIT_NOT_CD) ret = Insert_CD(ret_name, cd_type); if (ret != 0) { @@ -1973,7 +2006,7 @@ int menu_loop_tray(void) plat_video_menu_enter(rom_loaded); in_set_blocking(1); - me_loop(e_menu_tray, &sel); + me_loop(e_menu_tray, &sel, NULL); if (engineState != PGS_RestartRun) { engineState = PGS_RestartRun; @@ -1999,6 +2032,24 @@ void me_update_msg(const char *msg) // ------------ util ------------ +/* GP2X/wiz for now, probably extend later */ +void menu_plat_setup(int is_wiz) +{ + int i; + + if (!is_wiz) { + me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0); + return; + } + + me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0); + me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 0); + me_enable(e_menu_gfx_options, MA_OPT2_A_SN_GAMMA, 0); + + i = me_id2offset(e_menu_gfx_options, MA_OPT_SCALING); + e_menu_gfx_options[i].max = 1; /* only off and sw */ +} + /* TODO: rename */ void menu_darken_bg(void *dst, int pixels, int darker) {