-// (c) Copyright 2006,2007 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * PicoDrive\r
+ * (C) notaz, 2006-2008\r
+ *\r
+ * This work is licensed under the terms of MAME license.\r
+ * See COPYING file in the top-level directory.\r
+ */\r
\r
// don't like to use loads of #ifdefs, so duplicating GP2X code\r
// horribly instead\r
#include <stdio.h>\r
#include <string.h>\r
#include <stdlib.h>\r
+#include <wchar.h>\r
#include <unistd.h> // for getcwd cegcc implementation\r
+#include <dirent.h> // for opendir\r
#include <windows.h>\r
\r
+#include "kgsdk/Framework.h"\r
+#include "kgsdk/Framework2D.h"\r
+\r
#include "giz.h"\r
#include "emu.h"\r
#include "menu.h"\r
#include "../common/arm_utils.h"\r
#include "../common/menu.h"\r
+#include "../common/emu.h"\r
#include "../common/readpng.h"\r
-#include "version.h"\r
-#include "kgsdk/Framework.h"\r
-#include "kgsdk/Framework2D.h"\r
+#include "../common/input.h"\r
+#include "../common/version.h"\r
\r
-#include <Pico/PicoInt.h>\r
-#include <Pico/Patch.h>\r
-#include <zlib/zlib.h>\r
+#include <pico/pico_int.h>\r
+#include <pico/patch.h>\r
+#include <zlib.h>\r
\r
-extern char romFileName[MAX_PATH];\r
-extern char *rom_data;\r
-extern int state_slot;\r
-extern int config_slot, config_slot_current;\r
\r
#define gizKeyUnkn "???"\r
-static const char * const gizKeyNames[] = {\r
+const char * const keyNames[] = {\r
"LEFT", "RIGHT", "UP", "DOWN", "STOP", "PLAY", "FORWARD", "REWIND",\r
- "LEFT_SHOULDER", "RIGHT_SHOULDER", "HOME", "VOLUME", "BRIGHTNESS", "ALARM", "POWER", gizKeyUnkn,\r
- gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn,\r
+ "L", "R", "HOME", "VOLUME", "BRIGHTNESS", "ALARM", "POWER", gizKeyUnkn,\r
gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn,\r
+ gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn\r
};\r
\r
-static unsigned char bg_buffer[321*240*2];\r
-char menuErrorMsg[40] = {0, };\r
+static unsigned char *bg_buffer = gfx_buffer + 321*240*2;\r
+unsigned char *menu_screen = gfx_buffer; /* draw here and blit later, to avoid flicker */\r
\r
-static void menu_darken_bg(void *dst, const void *src, int pixels, int darker);\r
+void menu_darken_bg(void *dst, const void *src, int pixels, int darker);\r
static void menu_prepare_bg(int use_game_bg);\r
\r
-static unsigned int inp_prev = 0;\r
-static int inp_prevjoy = 0;\r
-\r
-static unsigned long wait_for_input(unsigned int interesting)\r
+void menu_draw_begin(int use_bgbuff)\r
{\r
- unsigned int ret;\r
- static int repeats = 0, wait = 50;\r
- int release = 0, i;\r
-\r
- if (repeats == 2 || repeats == 4) wait /= 2;\r
- if (repeats == 6) wait = 15;\r
-\r
- for (i = 0; i < 6 && inp_prev == Framework_PollGetButtons(); i++) {\r
- if (i == 0) repeats++;\r
- Sleep(wait);\r
- }\r
-\r
- while ( !((ret = Framework_PollGetButtons()) & interesting) ) {\r
- Sleep(50);\r
- release = 1;\r
- }\r
-\r
- if (release || ret != inp_prev) {\r
- repeats = 0;\r
- wait = 50;\r
- }\r
- inp_prev = ret;\r
- inp_prevjoy = 0;\r
-\r
- // we don't need diagonals in menus\r
- if ((ret&BTN_UP) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT;\r
- if ((ret&BTN_UP) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT;\r
- if ((ret&BTN_DOWN) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT;\r
- if ((ret&BTN_DOWN) && (ret&BTN_RIGHT)) ret &= ~BTN_RIGHT;\r
-\r
- return ret;\r
+ if (use_bgbuff)\r
+ memcpy((int *)menu_screen, (int *)bg_buffer, 321*240*2);\r
}\r
\r
\r
-static void menu_draw_begin(int use_bgbuff)\r
+void menu_draw_end(void)\r
{\r
+ giz_screen = fb_lock(0);\r
if (giz_screen == NULL)\r
{\r
- Framework2D_WaitVSync();\r
- giz_screen = Framework2D_LockBuffer();\r
+ lprintf("%s: Framework2D_LockBuffer() returned NULL\n", __FUNCTION__);\r
+ return;\r
}\r
- else\r
- {\r
- lprintf("%s: screen was not NULL\n", __FUNCTION__);\r
- }\r
- memcpy32(giz_screen, (int *)bg_buffer, 321*240*2/4);\r
-}\r
-\r
-\r
-static void menu_draw_end(void)\r
-{\r
- Framework2D_UnlockBuffer();\r
+ memcpy(giz_screen, (int *)menu_screen, 321*240*2);\r
+ fb_unlock();\r
giz_screen = NULL;\r
+ fb_flip();\r
}\r
\r
\r
unsigned short *dst;\r
\r
menu_draw_begin(0);\r
- dst = (unsigned short *)giz_screen + 321*20;\r
+ dst = (unsigned short *)menu_screen + 321*20;\r
\r
if (len > 320) len = 320;\r
- for (ln = 10; ln > 0; ln--, dst += 320)\r
+ for (ln = 10; ln > 0; ln--, dst += 321)\r
memset(dst, 0xff, len*2);\r
menu_draw_end();\r
}\r
const char *p = rom_name + strlen(rom_name);\r
while (p > rom_name && *p != '/') p--;\r
\r
- if (rom_data == NULL)\r
- memset(giz_screen, 0, 321*240*2);\r
+ if (!rom_loaded)\r
+ memset(menu_screen, 0, 321*240*2);\r
menu_draw_begin(1);\r
\r
smalltext_out16(1, 1, "Loading", 0xffff);\r
\r
// -------------- ROM selector --------------\r
\r
+#define DT_DIR 1\r
+#define DT_REG 2\r
+\r
+struct my_dirent\r
+{\r
+ unsigned char d_type;\r
+ char d_name[0];\r
+};\r
+\r
// rrrr rggg gggb bbbb\r
-#if 0\r
+#if 1\r
static unsigned short file2color(const char *fname)\r
{\r
const char *ext = fname + strlen(fname) - 3;\r
- static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso" };\r
+ static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso" };\r
static const char *other_exts[] = { "gmv", "pat" };\r
int i;\r
\r
return 0xffff;\r
}\r
\r
-static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)\r
+static void draw_dirlist(char *curdir, struct my_dirent **namelist, int n, int sel)\r
{\r
int start, i, pos;\r
\r
\r
menu_draw_begin(1);\r
\r
- if (rom_data == NULL) {\r
- menu_darken_bg(giz_screen, giz_screen, 321*240, 0);\r
+ if (!rom_loaded) {\r
+ menu_darken_bg(menu_screen, menu_screen, 321*240, 0);\r
}\r
\r
- menu_darken_bg((char *)giz_screen + 321*120*2, (char *)giz_screen + 321*120*2, 321*8, 0);\r
+ menu_darken_bg((char *)menu_screen + 321*120*2, (char *)menu_screen + 321*120*2, 321*8, 0);\r
\r
if(start - 2 >= 0)\r
smalltext_out16_lim(14, (start - 2)*10, curdir, 0xffff, 53-2);\r
\r
static int scandir_cmp(const void *p1, const void *p2)\r
{\r
- struct dirent **d1 = (struct dirent **)p1, **d2 = (struct dirent **)p2;\r
- if ((*d1)->d_type == (*d2)->d_type) return alphasort(d1, d2);\r
+ struct my_dirent **d1 = (struct my_dirent **)p1, **d2 = (struct my_dirent **)p2;\r
+ if ((*d1)->d_type == (*d2)->d_type) return strcasecmp((*d1)->d_name, (*d2)->d_name);\r
if ((*d1)->d_type == DT_DIR) return -1; // put before\r
if ((*d2)->d_type == DT_DIR) return 1;\r
- return alphasort(d1, d2);\r
+ return strcasecmp((*d1)->d_name, (*d2)->d_name);\r
}\r
\r
static char *filter_exts[] = {\r
- ".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",\r
- ".jpg", ".gpe", ".cue"\r
+ ".mp3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",\r
+ ".jpg", ".cue", ".exe", ".dll"\r
};\r
\r
-static int scandir_filter(const struct dirent *ent)\r
+static int scandir_filter(const struct my_dirent *ent)\r
{\r
const char *p;\r
int i;\r
\r
for (i = 0; i < sizeof(filter_exts)/sizeof(filter_exts[0]); i++)\r
{\r
- if (strcmp(p, filter_exts[i]) == 0) return 0;\r
+ if (strcasecmp(p, filter_exts[i]) == 0) return 0;\r
}\r
\r
return 1;\r
}\r
\r
+static int cstr2wstr(wchar_t *dst, const char *src)\r
+{\r
+ int i, len;\r
+ for (i = len = strlen(src); i >= 0; i--)\r
+ dst[i] = src[i];\r
+ return len;\r
+}\r
+\r
+static void wstr2cstr(char *dst, const wchar_t *src)\r
+{\r
+ int i;\r
+ for (i = wcslen(src); i >= 0; i--)\r
+ dst[i] = src[i];\r
+}\r
+\r
+static int my_scandir(const char *dir, struct my_dirent ***namelist_out,\r
+ int(*filter)(const struct my_dirent *),\r
+ int(*compar)(const void *, const void *))\r
+{\r
+ wchar_t *wdir;\r
+ int i, len, ret = -1, name_alloc = 4, name_count = 0;\r
+ struct my_dirent **namelist = NULL, *ent;\r
+ WIN32_FIND_DATA finddata;\r
+ HANDLE fh = INVALID_HANDLE_VALUE;\r
+ BOOL bRet;\r
+\r
+ wdir = malloc(sizeof(wdir[0]) * MAX_PATH);\r
+ if (wdir == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
+\r
+ namelist = malloc(sizeof(*namelist) * name_alloc);\r
+ if (namelist == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
+\r
+ // try to read first..\r
+ len = cstr2wstr(wdir, dir);\r
+ for (i = 0; i < len; i++)\r
+ if (wdir[i] == '/') wdir[i] = '\\';\r
+ if (wdir[len-1] != '\\') wdir[len++] = '\\';\r
+ wdir[len++] = '*';\r
+ wdir[len++] = 0;\r
+ /*if (wdir[len-1] == '\\') wdir[len-1] = 0;*/\r
+\r
+ bRet = 1;\r
+ fh = FindFirstFile(wdir, &finddata);\r
+ if (fh == INVALID_HANDLE_VALUE)\r
+ {\r
+ if (GetLastError() != ERROR_NO_MORE_FILES)\r
+ {\r
+ lprintf("FindFirstFile(\"%s\") failed with %lu\n", dir, GetLastError());\r
+ goto fail;\r
+ }\r
+ bRet = 0;\r
+ }\r
+\r
+ // add "." and ".."\r
+ ent = malloc(sizeof(*ent) + 3);\r
+ ent->d_type = DT_DIR; strcpy(ent->d_name, ".");\r
+ namelist[name_count++] = ent;\r
+ ent = malloc(sizeof(*ent) + 3);\r
+ ent->d_type = DT_DIR; strcpy(ent->d_name, "..");\r
+ namelist[name_count++] = ent;\r
+\r
+ while (bRet)\r
+ {\r
+ ent = malloc(sizeof(*ent) + wcslen(finddata.cFileName) + 1);\r
+ ent->d_type = (finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? DT_DIR : DT_REG;\r
+ wstr2cstr(ent->d_name, finddata.cFileName);\r
+ if (filter == NULL || filter(ent))\r
+ namelist[name_count++] = ent;\r
+ else free(ent);\r
+\r
+ if (name_count >= name_alloc)\r
+ {\r
+ void *tmp;\r
+ name_alloc *= 2;\r
+ tmp = realloc(namelist, sizeof(*namelist) * name_alloc);\r
+ if (tmp == NULL) { lprintf("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
+ namelist = tmp;\r
+ }\r
+\r
+ bRet = FindNextFile(fh, &finddata);\r
+ }\r
+\r
+ // sort\r
+ if (compar != NULL && name_count > 3) qsort(&namelist[2], name_count - 2, sizeof(namelist[0]), compar);\r
+\r
+ // all done.\r
+ ret = name_count;\r
+ *namelist_out = namelist;\r
+ goto end;\r
+\r
+fail:\r
+ if (namelist != NULL)\r
+ {\r
+ while (name_count--)\r
+ free(namelist[name_count]);\r
+ free(namelist);\r
+ }\r
+end:\r
+ if (fh != INVALID_HANDLE_VALUE) FindClose(fh);\r
+ if (wdir != NULL) free(wdir);\r
+ return ret;\r
+}\r
+\r
+\r
static char *romsel_loop(char *curr_path)\r
{\r
- struct dirent **namelist;\r
+ struct my_dirent **namelist;\r
DIR *dir;\r
int n, sel = 0;\r
unsigned long inp = 0;\r
fname = p+1;\r
}\r
\r
- n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+ n = my_scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
if (n < 0) {\r
- // try root\r
- n = scandir("/", &namelist, scandir_filter, scandir_cmp);\r
+ // try root..\r
+ n = my_scandir("/", &namelist, scandir_filter, scandir_cmp);\r
if (n < 0) {\r
// oops, we failed\r
- lprintf("dir: "); lprintf(curr_path); lprintf("\n");\r
- perror("scandir");\r
+ lprintf("scandir failed, dir: "); lprintf(curr_path); lprintf("\n");\r
return NULL;\r
}\r
}\r
for (;;)\r
{\r
draw_dirlist(curr_path, namelist, n, sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_PLAY|BTN_STOP);\r
- if(inp & BTN_UP ) { sel--; if (sel < 0) sel = n-2; }\r
- if(inp & BTN_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
- if(inp & BTN_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
- if(inp & BTN_L) { sel-=24; if (sel < 0) sel = 0; }\r
- if(inp & BTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
- if(inp & BTN_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
- if(inp & BTN_PLAY) { // enter dir/select\r
- again:\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\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_PLAY) { // enter dir/select\r
if (namelist[sel+1]->d_type == DT_REG) {\r
strcpy(romFileName, curr_path);\r
strcat(romFileName, "/");\r
ret = romsel_loop(newdir);\r
free(newdir);\r
break;\r
- } else {\r
- // unknown file type, happens on NTFS mounts. Try to guess.\r
- FILE *tstf; int tmp;\r
- strcpy(romFileName, curr_path);\r
- strcat(romFileName, "/");\r
- strcat(romFileName, namelist[sel+1]->d_name);\r
- tstf = fopen(romFileName, "rb");\r
- if (tstf != NULL)\r
- {\r
- if (fread(&tmp, 1, 1, tstf) > 0 || ferror(tstf) == 0)\r
- namelist[sel+1]->d_type = DT_REG;\r
- else namelist[sel+1]->d_type = DT_DIR;\r
- fclose(tstf);\r
- goto again;\r
- }\r
}\r
}\r
- if(inp & BTN_STOP) break; // cancel\r
+ if(inp & PBTN_STOP) break; // cancel\r
}\r
\r
if (n > 0) {\r
\r
return ret;\r
}\r
-#endif\r
+#else\r
static char *romsel_loop(char *curr_path)\r
{\r
return NULL;\r
}\r
+#endif\r
\r
// ------------ patch/gg menu ------------\r
\r
for(;;)\r
{\r
draw_patchlist(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_L|BTN_R|BTN_PLAY|BTN_STOP);\r
- if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }\r
- if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }\r
- if(inp &(BTN_LEFT|BTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }\r
- if(inp &(BTN_RIGHT|BTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }\r
- if(inp & BTN_PLAY) { // action\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_PLAY|PBTN_STOP);\r
+ if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; }\r
+ if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; }\r
+ if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; }\r
+ if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; }\r
+ if(inp & PBTN_PLAY) { // action\r
if (menu_sel < PicoPatchCount)\r
PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active;\r
else return;\r
}\r
- if(inp & BTN_STOP) return;\r
+ if(inp & PBTN_STOP) return;\r
}\r
\r
}\r
\r
for (slot = 0; slot < 10; slot++)\r
{\r
- if (emu_check_save_file(slot))\r
+ if (emu_checkSaveFile(slot))\r
{\r
state_slot_flags |= 1 << slot;\r
}\r
\r
if (strcmp(fname + strlen(fname) - 3, ".gz") == 0) {\r
file = gzopen(fname, "rb");\r
- emu_set_save_cbs(1);\r
+ emu_setSaveStateCbs(1);\r
} else {\r
file = fopen(fname, "rb");\r
- emu_set_save_cbs(0);\r
+ emu_setSaveStateCbs(0);\r
}\r
\r
if (file) {\r
- if (PicoMCD & 1) {\r
+ if (PicoIn.AHW & 1) {\r
PicoCdLoadStateGfx(file);\r
} else {\r
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file\r
areaClose(file);\r
}\r
\r
- emu_forced_frame();\r
+ emu_forcedFrame(POPT_EN_SOFTSCALE);\r
menu_prepare_bg(1);\r
\r
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));\r
for(;;)\r
{\r
draw_savestate_menu(menu_sel, is_loading);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP);\r
- if(inp & BTN_UP ) {\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+ if(inp & PBTN_UP ) {\r
do {\r
menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max;\r
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);\r
}\r
- if(inp & BTN_DOWN) {\r
+ if(inp & PBTN_DOWN) {\r
do {\r
menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0;\r
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);\r
}\r
- if(inp & BTN_PLAY) { // save/load\r
+ if(inp & PBTN_PLAY) { // save/load\r
if (menu_sel < 10) {\r
state_slot = menu_sel;\r
+ PicoStateProgressCB = emu_stateCb; /* also suitable for menu */\r
if (emu_SaveLoadGame(is_loading, 0)) {\r
strcpy(menuErrorMsg, is_loading ? "Load failed" : "Save failed");\r
return 1;\r
return 0;\r
} else return 1;\r
}\r
- if(inp & BTN_STOP) return 1;\r
+ if(inp & PBTN_STOP) return 1;\r
}\r
}\r
\r
if (currentConfig.KeyBinds[i] & action_mask)\r
{\r
if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue;\r
- if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, gizKeyNames[i]); break; }\r
- else strcpy(strkeys, gizKeyNames[i]);\r
+ if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; }\r
+ else strcpy(strkeys, keyNames[i]);\r
}\r
}\r
\r
currentConfig.KeyBinds[i] &= ~action;\r
}\r
\r
-static int count_bound_keys(int action)\r
+static int count_bound_keys(int action, int pl_idx)\r
{\r
int i, keys = 0;\r
\r
for (i = 0; i < 32; i++)\r
+ {\r
+ if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue;\r
if (currentConfig.KeyBinds[i] & action) keys++;\r
+ }\r
\r
return keys;\r
}\r
\r
-typedef struct { char *name; int mask; } bind_action_t;\r
-\r
-static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_idx, int sel)\r
+static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel)\r
{\r
- int x, y, tl_y = 40, i;\r
+ int x, y, tl_y = 30, i;\r
\r
menu_draw_begin(1);\r
if (player_idx >= 0) {\r
- text_out16(80, 20, "Player %i controls", player_idx + 1);\r
- x = 100;\r
+ text_out16(80, 10, "Player %i controls", player_idx + 1);\r
+ x = 80;\r
} else {\r
- text_out16(80, 20, "Emulator controls");\r
+ text_out16(80, 10, "Emulator controls");\r
x = 40;\r
}\r
\r
text_out16(x, y, "Done");\r
\r
if (sel < opt_cnt) {\r
- text_out16(30, 180, "Press a button to bind/unbind");\r
- text_out16(30, 190, "Use SELECT to clear");\r
- text_out16(30, 200, "To bind UP/DOWN, hold SELECT");\r
- text_out16(30, 210, "Select \"Done\" to exit");\r
+ text_out16(30, 195, "Press a button to bind/unbind");\r
+ text_out16(30, 205, "Use HOME to clear");\r
+ text_out16(30, 215, "To bind UP/DOWN, hold HOME");\r
+ text_out16(30, 225, "Select \"Done\" to exit");\r
} else {\r
- text_out16(30, 190, "Use Options -> Save cfg");\r
- text_out16(30, 200, "to save controls");\r
- text_out16(30, 210, "Press B or X to exit");\r
+ text_out16(30, 205, "Use Options -> Save cfg");\r
+ text_out16(30, 215, "to save controls");\r
+ text_out16(30, 225, "Press PLAY or STOP to exit");\r
}\r
menu_draw_end();\r
}\r
\r
-static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_idx)\r
+static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)\r
{\r
int sel = 0, menu_sel_max = opt_cnt, prev_select = 0, i;\r
unsigned long inp = 0;\r
for (;;)\r
{\r
draw_key_config(opts, opt_cnt, player_idx, sel);\r
- inp = wait_for_input(CONFIGURABLE_KEYS);\r
- if (!(inp & BTN_HOME)) {\r
+ inp = in_menu_wait(CONFIGURABLE_KEYS|PBTN_HOME);\r
+ if (!(inp & PBTN_HOME)) {\r
prev_select = 0;\r
- if(inp & BTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }\r
- if(inp & BTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; }\r
+ if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }\r
+ if(inp & PBTN_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; }\r
}\r
if (sel >= opt_cnt) {\r
- if (inp & (BTN_PLAY|BTN_STOP)) break;\r
+ if (inp & (PBTN_PLAY|PBTN_STOP)) break;\r
else continue;\r
}\r
// if we are here, we want to bind/unbind something\r
- if ((inp & BTN_HOME) && !prev_select)\r
+ if ((inp & PBTN_HOME) && !prev_select)\r
unbind_action(opts[sel].mask);\r
- prev_select = inp & BTN_HOME;\r
+ prev_select = inp & PBTN_HOME;\r
inp &= CONFIGURABLE_KEYS;\r
- inp &= ~BTN_HOME;\r
+ inp &= ~PBTN_HOME;\r
for (i = 0; i < 32; i++)\r
if (inp & (1 << i)) {\r
- if (count_bound_keys(opts[sel].mask) >= 2)\r
- currentConfig.KeyBinds[i] &= ~opts[sel].mask; // allow to unbind only\r
+ if (count_bound_keys(opts[sel].mask, player_idx) >= 2)\r
+ currentConfig.KeyBinds[i] &= ~opts[sel].mask; // allow to unbind only\r
else currentConfig.KeyBinds[i] ^= opts[sel].mask;\r
- if (player_idx >= 0) {\r
+ if (player_idx >= 0 && (currentConfig.KeyBinds[i] & opts[sel].mask)) {\r
currentConfig.KeyBinds[i] &= ~(3 << 16);\r
currentConfig.KeyBinds[i] |= player_idx << 16;\r
}\r
}\r
}\r
\r
+menu_entry ctrlopt_entries[] =\r
+{\r
+ { "Player 1", MB_NONE, MA_CTRL_PLAYER1, NULL, 0, 0, 0, 1, 0 },\r
+ { "Player 2", MB_NONE, MA_CTRL_PLAYER2, NULL, 0, 0, 0, 1, 0 },\r
+ { "Emulator controls", MB_NONE, MA_CTRL_EMU, NULL, 0, 0, 0, 1, 0 },\r
+ { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoIn.opt, 0x020, 0, 0, 1, 1 },\r
+ { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, ¤tConfig.turbo_rate, 0, 1, 30, 1, 1 },\r
+ { "Done", MB_NONE, MA_CTRL_DONE, NULL, 0, 0, 0, 1, 0 },\r
+};\r
+\r
+#define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0]))\r
+const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT;\r
+\r
static void draw_kc_sel(int menu_sel)\r
{\r
int tl_x = 25+40, tl_y = 60, y;\r
menu_draw_begin(1);\r
menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 138);\r
\r
- text_out16(tl_x, y, "Player 1");\r
- text_out16(tl_x, (y+=10), "Player 2");\r
- text_out16(tl_x, (y+=10), "Emulator controls");\r
- text_out16(tl_x, (y+=10), "Done");\r
+ me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL);\r
\r
menu_draw_end();\r
}\r
\r
\r
-// PicoPad[] format: MXYZ SACB RLDU\r
-static bind_action_t ctrl_actions[] =\r
-{\r
- { "UP ", 0x001 },\r
- { "DOWN ", 0x002 },\r
- { "LEFT ", 0x004 },\r
- { "RIGHT ", 0x008 },\r
- { "A ", 0x040 },\r
- { "B ", 0x010 },\r
- { "C ", 0x020 },\r
- { "START ", 0x080 },\r
- { "MODE ", 0x800 },\r
- { "X ", 0x400 },\r
- { "Y ", 0x200 },\r
- { "Z ", 0x100 },\r
-};\r
-\r
// player2_flag, ?, ?, ?, ?, ?, ?, menu\r
// "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE",\r
// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"\r
-static bind_action_t emuctrl_actions[] =\r
+me_bind_action emuctrl_actions[] =\r
{\r
{ "Load State ", 1<<28 },\r
{ "Save State ", 1<<27 },\r
{ "Switch Renderer", 1<<26 },\r
{ "Volume Down ", 1<<30 },\r
{ "Volume Up ", 1<<29 },\r
- { "Enter Menu ", 1<<23 },\r
+ { NULL, 0 }\r
};\r
\r
static void kc_sel_loop(void)\r
{\r
- int menu_sel = 3, menu_sel_max = 3;\r
+ int menu_sel = 5, menu_sel_max = 5;\r
unsigned long inp = 0;\r
- int is_6button = currentConfig.PicoOpt & 0x020;\r
+ menu_id selected_id;\r
\r
while (1)\r
{\r
draw_kc_sel(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP);\r
- if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
- if (inp & BTN_PLAY) {\r
- switch (menu_sel) {\r
- case 0: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 0); return;\r
- case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;\r
- case 2: key_config_loop(emuctrl_actions,\r
- sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;\r
- case 3: if (rom_data == NULL) emu_WriteConfig(0); return;\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP);\r
+ selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel);\r
+ if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise\r
+ me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0);\r
+ if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ if (inp & PBTN_PLAY) {\r
+ int is_6button = PicoIn.opt & 0x020;\r
+ switch (selected_id) {\r
+ case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return;\r
+ case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return;\r
+ case MA_CTRL_EMU: key_config_loop(emuctrl_actions,\r
+ sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return;\r
+ case MA_CTRL_DONE: if (!rom_loaded) emu_WriteConfig(0); return;\r
default: return;\r
}\r
}\r
- if (inp & BTN_STOP) return;\r
+ if (inp & PBTN_STOP) return;\r
}\r
}\r
\r
\r
menu_entry cdopt_entries[] =\r
{\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1 },\r
- { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1 },\r
- { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, ¤tConfig.PicoOpt, 0x0800, 0, 0, 1 },\r
- { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, ¤tConfig.PicoOpt, 0x0400, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1 },\r
- { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, ¤tConfig.PicoOpt, 0x8000, 0, 0, 1 },\r
- { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,¤tConfig.PicoOpt, 0x1000, 0, 0, 1 },\r
- { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, ¤tConfig.PicoOpt, 0x2000, 0, 0, 1 },\r
- { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },\r
+ { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },\r
+ { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoIn.opt, 0x0800, 0, 0, 1, 1 },\r
+ { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoIn.opt, 0x0400, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },\r
+ { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoIn.opt, 0x8000, 0, 0, 1, 1 },\r
+ { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoIn.opt, 0x1000, 0, 0, 1, 1 },\r
+ { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoIn.opt, 0x2000, 0, 0, 1, 1 },\r
+ { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
#define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]))\r
+const int cdopt_entry_count = CDOPT_ENTRY_COUNT;\r
\r
\r
struct bios_names_t\r
menu_id selected_id;\r
char *bios, *p;\r
\r
- if (find_bios(4, &bios)) { // US\r
- for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;\r
+ if (emu_findBios(4, &bios)) { // US\r
+ for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);\r
+ if (*p == '/') p++;\r
strncpy(bios_names.us, p, sizeof(bios_names.us)); bios_names.us[sizeof(bios_names.us)-1] = 0;\r
} else strcpy(bios_names.us, "NOT FOUND");\r
\r
- if (find_bios(8, &bios)) { // EU\r
- for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;\r
+ if (emu_findBios(8, &bios)) { // EU\r
+ for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);\r
+ if (*p == '/') p++;\r
strncpy(bios_names.eu, p, sizeof(bios_names.eu)); bios_names.eu[sizeof(bios_names.eu)-1] = 0;\r
} else strcpy(bios_names.eu, "NOT FOUND");\r
\r
- if (find_bios(1, &bios)) { // JP\r
- for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++;\r
+ if (emu_findBios(1, &bios)) { // JP\r
+ for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--);\r
+ if (*p == '/') p++;\r
strncpy(bios_names.jp, p, sizeof(bios_names.jp)); bios_names.jp[sizeof(bios_names.jp)-1] = 0;\r
} else strcpy(bios_names.jp, "NOT FOUND");\r
\r
for(;;)\r
{\r
draw_cd_menu_options(menu_sel, &bios_names);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW);\r
- if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel);\r
- if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise\r
- if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) &&\r
+ if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise\r
+ if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&\r
selected_id == MA_CDOPT_READAHEAD) {\r
- if (inp & BTN_LEFT) {\r
+ if (inp & PBTN_LEFT) {\r
PicoCDBuffers >>= 1;\r
- if (PicoCDBuffers < 64) PicoCDBuffers = 0;\r
+ if (PicoCDBuffers < 2) PicoCDBuffers = 0;\r
} else {\r
- if (PicoCDBuffers < 64) PicoCDBuffers = 64;\r
+ if (PicoCDBuffers < 2) PicoCDBuffers = 2;\r
else PicoCDBuffers <<= 1;\r
if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M\r
}\r
}\r
}\r
- if (inp & BTN_PLAY) { // toggleable options\r
+ if (inp & PBTN_PLAY) { // toggleable options\r
if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) &&\r
selected_id == MA_CDOPT_DONE) {\r
return;\r
}\r
switch (selected_id) { // BIOS testers\r
case MA_CDOPT_TESTBIOS_USA:\r
- if (find_bios(4, &bios)) { // test US\r
+ if (emu_findBios(4, &bios)) { // test US\r
strcpy(romFileName, bios);\r
engineState = PGS_ReloadRom;\r
return;\r
}\r
break;\r
case MA_CDOPT_TESTBIOS_EUR:\r
- if (find_bios(8, &bios)) { // test EU\r
+ if (emu_findBios(8, &bios)) { // test EU\r
strcpy(romFileName, bios);\r
engineState = PGS_ReloadRom;\r
return;\r
}\r
break;\r
case MA_CDOPT_TESTBIOS_JAP:\r
- if (find_bios(1, &bios)) { // test JP\r
+ if (emu_findBios(1, &bios)) { // test JP\r
strcpy(romFileName, bios);\r
engineState = PGS_ReloadRom;\r
return;\r
break;\r
}\r
}\r
- if (inp & (BTN_STOP|BTN_REW)) return;\r
+ if (inp & (PBTN_STOP|PBTN_REW)) return;\r
}\r
}\r
\r
\r
menu_entry opt2_entries[] =\r
{\r
- { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, ¤tConfig.PicoOpt,0x0004, 0, 0, 1 },\r
- { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, ¤tConfig.PicoOpt,0x0001, 0, 0, 1 },\r
- { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,¤tConfig.PicoOpt,0x0002, 0, 0, 1 },\r
- { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1 },\r
- { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1 },\r
- { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 },\r
+ { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoIn.opt, 0x40000, 0, 0, 1, 1 },\r
+ { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoIn.opt, 0x00004, 0, 0, 1, 1 },\r
+ { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoIn.opt, 0x00001, 0, 0, 1, 1 },\r
+ { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoIn.opt, 0x00002, 0, 0, 1, 1 },\r
+ { "Emulate YM2413 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2413, &PicoIn.opt, 0x00020, 0, 0, 1, 1 },\r
+ { "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, ¤tConfig.EmuOpt, 0x8000, 0, 0, 1, 1 },\r
+ { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1, 1 },\r
+ { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1, 1 },\r
+ { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1, 1 },\r
+ { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoIn.opt, 0x20000, 0, 0, 1, 1 },\r
+ { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoIn.opt, 0x80000, 0, 0, 1, 1 },\r
+ { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
#define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0]))\r
+const int opt2_entry_count = OPT2_ENTRY_COUNT;\r
\r
\r
static void draw_amenu_options(int menu_sel)\r
for(;;)\r
{\r
draw_amenu_options(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW);\r
- if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel);\r
- if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise\r
- if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) &&\r
+ if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise\r
+ if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) &&\r
selected_id == MA_OPT2_GAMMA) {\r
- while ((inp = Framework_PollGetButtons(1)) & (BTN_LEFT|BTN_RIGHT)) {\r
- currentConfig.gamma += (inp & BTN_LEFT) ? -1 : 1;\r
+ while ((inp = Framework_PollGetButtons()) & (PBTN_LEFT|PBTN_RIGHT)) {\r
+ currentConfig.gamma += (inp & PBTN_LEFT) ? -1 : 1;\r
if (currentConfig.gamma < 1) currentConfig.gamma = 1;\r
if (currentConfig.gamma > 300) currentConfig.gamma = 300;\r
draw_amenu_options(menu_sel);\r
}\r
}\r
}\r
- if (inp & BTN_PLAY) { // toggleable options\r
+ if (inp & PBTN_PLAY) { // toggleable options\r
if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) &&\r
selected_id == MA_OPT2_DONE) {\r
return;\r
}\r
}\r
- if (inp & (BTN_STOP|BTN_REW)) return;\r
+ if (inp & (PBTN_STOP|PBTN_REW)) return;\r
}\r
}\r
\r
\r
menu_entry opt_entries[] =\r
{\r
- { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 },\r
- { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x001, 0, 3, 1 },\r
- { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x040, 0, 0, 1 },\r
- { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x080, 0, 0, 1 },\r
- { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1 },\r
- { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1 },\r
- { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 },\r
- { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x020, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1 },\r
- { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },\r
- { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },\r
- { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },\r
- { "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },\r
- { "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1 },\r
+ { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 },\r
+ { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoIn.opt, 0x080, 0, 0, 0, 1 },\r
+ { "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, ¤tConfig.EmuOpt, 0x4000, 0, 0, 1, 1 },\r
+ { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x0001, 0, 3, 1, 1 },\r
+ { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1, 1 },\r
+ { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 },\r
+ { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x0004, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 },\r
+ { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1, 1 },\r
+ { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1, 1 },\r
+ { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1, 0 },\r
+ { "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1, 0 },\r
+ { "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
#define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))\r
-\r
-\r
-static const char *region_name(unsigned int code)\r
-{\r
- static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };\r
- static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
- int u, i = 0;\r
- if (code) {\r
- code <<= 1;\r
- while((code >>= 1)) i++;\r
- if (i > 4) return "unknown";\r
- return names[i];\r
- } else {\r
- static char name[24];\r
- strcpy(name, "Auto:");\r
- for (u = 0; u < 3; u++) {\r
- i = 0; code = ((PicoAutoRgnOrder >> u*4) & 0xf) << 1;\r
- while((code >>= 1)) i++;\r
- strcat(name, names_short[i]);\r
- }\r
- return name;\r
- }\r
-}\r
+const int opt_entry_count = OPT_ENTRY_COUNT;\r
\r
\r
static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *param)\r
switch (entry->id)\r
{\r
case MA_OPT_RENDERER:\r
- if (currentConfig.PicoOpt&0x10)\r
+ if (PicoIn.opt&0x10)\r
str = " 8bit fast";\r
else if (currentConfig.EmuOpt&0x80)\r
str = "16bit accurate";\r
text_out16(x, y, "Frameskip %s", str24);\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- str = (currentConfig.PicoOpt&0x08)?"stereo":"mono";\r
- text_out16(x, y, "Sound Quality: %5iHz %s", currentConfig.PsndRate, str);\r
+ str = (PicoIn.opt&0x08)?"stereo":"mono";\r
+ text_out16(x, y, "Sound Quality: %5iHz %s", PicoIn.sndRate, str);\r
break;\r
case MA_OPT_REGION:\r
- text_out16(x, y, "Region: %s", region_name(currentConfig.PicoRegion));\r
+ text_out16(x, y, "Region: %s", me_region_name(PicoIn.regionOverride, PicoIn.autoRgnOrder));\r
break;\r
case MA_OPT_CONFIRM_STATES:\r
switch ((currentConfig.EmuOpt >> 9) & 5) {\r
\r
static int sndrate_prevnext(int rate, int dir)\r
{\r
- int i, rates[] = { 8000, 11025, 16000, 22050, 44100 };\r
+ int i, rates[] = { 11025, 22050, 44100 };\r
\r
for (i = 0; i < 5; i++)\r
if (rates[i] == rate) break;\r
\r
i += dir ? 1 : -1;\r
- if (i > 4) return dir ? 44100 : 22050;\r
- if (i < 0) return dir ? 11025 : 8000;\r
+ if (i > 2) return dir ? 44100 : 22050;\r
+ if (i < 0) return dir ? 22050 : 11025;\r
return rates[i];\r
}\r
\r
static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 };\r
int i;\r
if (right) {\r
- if (!currentConfig.PicoRegion) {\r
+ if (!PicoIn.regionOverride) {\r
for (i = 0; i < 6; i++)\r
- if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
- if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1];\r
- else currentConfig.PicoRegion=1;\r
+ if (rgn_orders[i] == PicoIn.autoRgnOrder) break;\r
+ if (i < 5) PicoIn.autoRgnOrder = rgn_orders[i+1];\r
+ else PicoIn.regionOverride=1;\r
}\r
- else currentConfig.PicoRegion<<=1;\r
- if (currentConfig.PicoRegion > 8) currentConfig.PicoRegion = 8;\r
+ else PicoIn.regionOverride<<=1;\r
+ if (PicoIn.regionOverride > 8) PicoIn.regionOverride = 8;\r
} else {\r
- if (!currentConfig.PicoRegion) {\r
+ if (!PicoIn.regionOverride) {\r
for (i = 0; i < 6; i++)\r
- if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
- if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1];\r
+ if (rgn_orders[i] == PicoIn.autoRgnOrder) break;\r
+ if (i > 0) PicoIn.autoRgnOrder = rgn_orders[i-1];\r
}\r
- else currentConfig.PicoRegion>>=1;\r
+ else PicoIn.regionOverride>>=1;\r
}\r
}\r
\r
static void menu_options_save(void)\r
{\r
- PicoOpt = currentConfig.PicoOpt;\r
- PsndRate = currentConfig.PsndRate;\r
- PicoRegionOverride = currentConfig.PicoRegion;\r
- if (!(PicoOpt & 0x20)) {\r
+ if (PicoIn.regionOverride) {\r
+ // force setting possibly changed..\r
+ Pico.m.pal = (PicoIn.regionOverride == 2 || PicoIn.regionOverride == 8) ? 1 : 0;\r
+ }\r
+ if (!(PicoIn.opt & 0x20)) {\r
// unbind XYZ MODE, just in case\r
unbind_action(0xf00);\r
}\r
- scaling_update();\r
}\r
\r
static int menu_loop_options(void)\r
unsigned long inp = 0;\r
menu_id selected_id;\r
\r
- currentConfig.PicoOpt = PicoOpt;\r
- currentConfig.PsndRate = PsndRate;\r
- currentConfig.PicoRegion = PicoRegionOverride;\r
-\r
- me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_data != NULL);\r
+ me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);\r
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;\r
if (menu_sel > menu_sel_max) menu_sel = menu_sel_max;\r
while (1)\r
{\r
draw_menu_options(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_LEFT|BTN_RIGHT|BTN_PLAY|BTN_STOP|BTN_REW);\r
- if (inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if (inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_PLAY|PBTN_STOP|PBTN_REW);\r
+ if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);\r
- if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise\r
- if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0)) {\r
+ if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise\r
+ if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) {\r
switch (selected_id) {\r
case MA_OPT_RENDERER:\r
- if (inp & BTN_LEFT) {\r
- if ( currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10;\r
- else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80;\r
- else if ( currentConfig.EmuOpt &0x80) break;\r
+ if (inp & PBTN_LEFT) {\r
+ if ((PicoIn.opt&0x10) || !(currentConfig.EmuOpt &0x80)) {\r
+ PicoIn.opt&= ~0x10;\r
+ currentConfig.EmuOpt |= 0x80;\r
+ }\r
} else {\r
- if ( currentConfig.PicoOpt&0x10) break;\r
- else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|= 0x10;\r
- else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;\r
+ if (!(PicoIn.opt&0x10) || (currentConfig.EmuOpt &0x80)) {\r
+ PicoIn.opt|= 0x10;\r
+ currentConfig.EmuOpt &= ~0x80;\r
+ }\r
}\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {\r
- currentConfig.PsndRate = 8000; currentConfig.PicoOpt|= 0x08;\r
- } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 8000 && (currentConfig.PicoOpt&0x08)) {\r
- currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;\r
- } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT);\r
+ if ((inp & PBTN_RIGHT) && PicoIn.sndRate == 44100 &&\r
+ !(PicoIn.opt&0x08))\r
+ {\r
+ PicoIn.sndRate = 11025;\r
+ PicoIn.opt |= 8;\r
+ } else if ((inp & PBTN_LEFT) && PicoIn.sndRate == 11025 &&\r
+ (PicoIn.opt&0x08) && !(PicoIn.AHW&1))\r
+ {\r
+ PicoIn.sndRate = 44100;\r
+ PicoIn.opt &= ~8;\r
+ } else\r
+ PicoIn.sndRate = sndrate_prevnext(PicoIn.sndRate, inp & PBTN_RIGHT);\r
break;\r
case MA_OPT_REGION:\r
- region_prevnext(inp & BTN_RIGHT);\r
+ region_prevnext(inp & PBTN_RIGHT);\r
break;\r
case MA_OPT_CONFIRM_STATES: {\r
int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2);\r
- n += (inp & BTN_LEFT) ? -1 : 1;\r
+ n += (inp & PBTN_LEFT) ? -1 : 1;\r
if (n < 0) n = 0; else if (n > 3) n = 3;\r
n |= n << 1; n &= ~2;\r
currentConfig.EmuOpt &= ~0xa00;\r
break;\r
}\r
case MA_OPT_SAVE_SLOT:\r
- if (inp & BTN_RIGHT) {\r
+ if (inp & PBTN_RIGHT) {\r
state_slot++; if (state_slot > 9) state_slot = 0;\r
} else {state_slot--; if (state_slot < 0) state_slot = 9;\r
}\r
case MA_OPT_SAVECFG:\r
case MA_OPT_SAVECFG_GAME:\r
case MA_OPT_LOADCFG:\r
- config_slot += (inp&BTN_RIGHT) ? 1 : -1;\r
+ config_slot += (inp&PBTN_RIGHT) ? 1 : -1;\r
if (config_slot > 9) config_slot = 0;\r
if (config_slot < 0) config_slot = 9;\r
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
}\r
}\r
}\r
- if (inp & BTN_PLAY) {\r
+ if (inp & PBTN_PLAY) {\r
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1))\r
{\r
switch (selected_id)\r
}\r
}\r
}\r
- if(inp & (BTN_STOP|BTN_REW)) {\r
+ if(inp & (PBTN_STOP|PBTN_REW)) {\r
menu_options_save();\r
return 0; // done (update, no write)\r
}\r
\r
static void draw_menu_credits(void)\r
{\r
- int tl_x = 15, tl_y = 64, y;\r
+ int tl_x = 15, tl_y = 56, y;\r
menu_draw_begin(1);\r
\r
- text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
+ text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006-2008");\r
+\r
y = tl_y;\r
text_out16(tl_x, y, "Credits:");\r
- text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,");\r
+ text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,");\r
text_out16(tl_x, (y+=10), " base code of PicoDrive");\r
text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core");\r
text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores");\r
- text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs");\r
- text_out16(tl_x, (y+=10), "Stephane Dallongeville:");\r
- text_out16(tl_x, (y+=10), " opensource Gens");\r
- text_out16(tl_x, (y+=10), "Haze: Genesis hw info");\r
- text_out16(tl_x, (y+=10), "Reesy: TODO");\r
- text_out16(tl_x, (y+=10), "TODO: gizmondo hardware");\r
+ text_out16(tl_x, (y+=10), "Reesy: kgsdk wrapper, sound code");\r
+ text_out16(tl_x, (y+=10), "jens.l: gizmondo hardware");\r
text_out16(tl_x, (y+=10), "ketchupgun: skin design");\r
\r
+ text_out16(tl_x, (y+=20), "special thanks (for docs, ideas)");\r
+ text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,");\r
+ text_out16(tl_x, (y+=10), " Stephane Dallongeville,");\r
+ text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,");\r
+ text_out16(tl_x, (y+=10), " Nemesis, Tasco Deluxe");\r
+\r
menu_draw_end();\r
}\r
\r
\r
menu_entry main_entries[] =\r
{\r
- { "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0 },\r
- { "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0 },\r
- { "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0 },\r
- { "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0 },\r
- { "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1 },\r
- { "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1 },\r
- { "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1 },\r
- { "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1 },\r
- { "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0 },\r
- { "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1 }\r
+ { "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0, 0 },\r
+ { "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0, 0 },\r
+ { "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0, 0 },\r
+ { "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0, 0 },\r
+ { "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1, 0 },\r
+ { "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0, 0 },\r
+ { "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1, 0 }\r
};\r
\r
#define MAIN_ENTRY_COUNT (sizeof(main_entries) / sizeof(main_entries[0]))\r
\r
// error\r
if (menuErrorMsg[0]) {\r
- memset((char *)giz_screen + 321*224*2, 0, 321*16*2);\r
+ memset((char *)menu_screen + 321*224*2, 0, 321*16*2);\r
text_out16(5, 226, menuErrorMsg);\r
}\r
menu_draw_end();\r
int ret, menu_sel_max;\r
unsigned long inp = 0;\r
\r
- me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_data != NULL);\r
- me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE, rom_data != NULL);\r
- me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE, rom_data != NULL);\r
- me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME, rom_data != NULL);\r
+ me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESUME_GAME, rom_loaded);\r
+ me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_SAVE_STATE, rom_loaded);\r
+ me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_LOAD_STATE, rom_loaded);\r
+ me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_RESET_GAME, rom_loaded);\r
me_enable(main_entries, MAIN_ENTRY_COUNT, MA_MAIN_PATCHES, PicoPatches != NULL);\r
\r
menu_sel_max = me_count_enabled(main_entries, MAIN_ENTRY_COUNT) - 1;\r
\r
/* make sure action buttons are not pressed on entering menu */\r
draw_menu_root(menu_sel);\r
- while (Framework_PollGetButtons(1) & (BTN_PLAY|BTN_STOP|BTN_HOME)) Sleep(50);\r
+\r
+ while (Framework_PollGetButtons() & (PBTN_PLAY|PBTN_STOP|PBTN_HOME)) Sleep(50);\r
\r
for (;;)\r
{\r
draw_menu_root(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP|BTN_HOME|BTN_L|BTN_R);\r
- if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
- if(inp &(BTN_HOME|BTN_STOP)){\r
- if (rom_data) {\r
- while (Framework_PollGetButtons(1) & (BTN_HOME|BTN_STOP)) Sleep(50); // wait until select is released\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY|PBTN_STOP|PBTN_HOME|PBTN_L|PBTN_R);\r
+ if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop();\r
+ if( inp & (PBTN_HOME|PBTN_STOP)) {\r
+ if (rom_loaded) {\r
+ while (Framework_PollGetButtons() & (PBTN_HOME|PBTN_STOP)) Sleep(50); // wait until released\r
engineState = PGS_Running;\r
break;\r
}\r
}\r
- if(inp & BTN_PLAY) {\r
+ if(inp & PBTN_PLAY) {\r
switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel))\r
{\r
case MA_MAIN_RESUME_GAME:\r
- if (rom_data) {\r
- while (Framework_PollGetButtons(1) & BTN_PLAY) Sleep(50);\r
+ if (rom_loaded) {\r
+ while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);\r
engineState = PGS_Running;\r
return;\r
}\r
break;\r
case MA_MAIN_SAVE_STATE:\r
- if (rom_data) {\r
+ if (rom_loaded) {\r
if(savestate_menu_loop(0))\r
continue;\r
engineState = PGS_Running;\r
}\r
break;\r
case MA_MAIN_LOAD_STATE:\r
- if (rom_data) {\r
+ if (rom_loaded) {\r
if(savestate_menu_loop(1))\r
continue;\r
+ while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);\r
engineState = PGS_Running;\r
return;\r
}\r
break;\r
case MA_MAIN_RESET_GAME:\r
- if (rom_data) {\r
+ if (rom_loaded) {\r
emu_ResetGame();\r
+ while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);\r
engineState = PGS_Running;\r
return;\r
}\r
{\r
char curr_path[MAX_PATH], *selfname;\r
FILE *tstf;\r
- if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(loadedRomFName, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, currentConfig.lastRomFile);\r
+ strcpy(curr_path, loadedRomFName);\r
}\r
else\r
getcwd(curr_path, MAX_PATH);\r
case MA_MAIN_CREDITS:\r
draw_menu_credits();\r
Sleep(500);\r
- inp = wait_for_input(BTN_PLAY|BTN_STOP);\r
+ inp = in_menu_wait(PBTN_PLAY|PBTN_STOP);\r
break;\r
case MA_MAIN_EXIT:\r
engineState = PGS_Quit;\r
return;\r
case MA_MAIN_PATCHES:\r
- if (rom_data && PicoPatches) {\r
+ if (rom_loaded && PicoPatches) {\r
patches_menu_loop();\r
PicoPatchApply();\r
strcpy(menuErrorMsg, "Patches applied");\r
}\r
\r
// warning: alignment\r
-static void menu_darken_bg(void *dst, const void *src, int pixels, int darker)\r
+void menu_darken_bg(void *dst, const void *src, int pixels, int darker)\r
{\r
- unsigned int *dest = dst;\r
- const unsigned int *srce = src;\r
+ u32 *dest = dst;\r
+ const u32 *srce = src;\r
pixels /= 2;\r
if (darker)\r
{\r
while (pixels--)\r
{\r
- unsigned int p = *srce++;\r
+ u32 p = *srce++;\r
*dest++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3);\r
}\r
}\r
{\r
while (pixels--)\r
{\r
- unsigned int p = *srce++;\r
+ u32 p = *srce++;\r
*dest++ = (p&0xf79ef79e)>>1;\r
}\r
}\r
if (use_game_bg)\r
{\r
// darken the active framebuffer\r
+ if (giz_screen == NULL)\r
+ giz_screen = fb_lock(1);\r
memset(bg_buffer, 0, 321*8*2);\r
menu_darken_bg(bg_buffer + 321*8*2, (char *)giz_screen + 321*8*2, 321*224, 1);\r
memset(bg_buffer + 321*232*2, 0, 321*8*2);\r
+ fb_unlock();\r
+ giz_screen = NULL;\r
}\r
else\r
{\r
+ int i;\r
// should really only happen once, on startup..\r
readpng(bg_buffer, "skin/background.png", READPNG_BG);\r
+ // adjust 320 width to 321\r
+ for (i = 239; i > 0; i--)\r
+ memmove(bg_buffer + 321*2*i, bg_buffer + 320*2*i, 320*2);\r
}\r
}\r
\r
static void menu_gfx_prepare(void)\r
{\r
- menu_prepare_bg(rom_data != NULL);\r
+ menu_prepare_bg(rom_loaded);\r
\r
menu_draw_begin(1);\r
menu_draw_end();\r
\r
menu_gfx_prepare();\r
\r
- if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(loadedRomFName, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, currentConfig.lastRomFile);\r
+ strcpy(curr_path, loadedRomFName);\r
}\r
else\r
{\r
\r
/* make sure action buttons are not pressed on entering menu */\r
draw_menu_tray(menu_sel);\r
- while (Framework_PollGetButtons(1) & BTN_PLAY) Sleep(50);\r
+ while (Framework_PollGetButtons() & PBTN_PLAY) Sleep(50);\r
\r
for (;;)\r
{\r
draw_menu_tray(menu_sel);\r
- inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY);\r
- if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
- if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
- if(inp & BTN_PLAY ) {\r
+ inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_PLAY);\r
+ if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
+ if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
+ if(inp & PBTN_PLAY) {\r
switch (menu_sel) {\r
case 0: // select image\r
selfname = romsel_loop(curr_path);\r
if (selfname) {\r
- int ret = -1, cd_type;\r
- cd_type = emu_cd_check(NULL);\r
- if (cd_type > 0)\r
- ret = Insert_CD(romFileName, cd_type == 2);\r
+ int ret = -1;\r
+ cd_track_type cd_type;\r
+ cd_type = emu_cdCheck(NULL, romFileName);\r
+ if (cd_type >= 0 && cd_type != CT_UNKNOWN)\r
+ ret = Insert_CD(romFileName, cd_type);\r
if (ret != 0) {\r
sprintf(menuErrorMsg, "Load failed, invalid CD image?");\r
lprintf("%s\n", menuErrorMsg);\r