X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmenu.c;h=7acfa53da6edeef4e78b7fc0802d80098a808187;hb=6d741b3258179dadc7890f45e155b0a6871ebdc5;hp=a8d1f9e742ace69b32902ca31fce5167d3cd50cf;hpb=c7a4ff64287b12487c7e9cc13ce3b7d2aa6e1f06;p=libpicofe.git diff --git a/gp2x/menu.c b/gp2x/menu.c index a8d1f9e..7acfa53 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -14,8 +14,9 @@ #include "emu.h" #include "menu.h" #include "usbjoy.h" -#include "../common/arm_utils.h" +#include "../common/emu.h" #include "../common/menu.h" +#include "../common/arm_utils.h" #include "../common/readpng.h" #include "version.h" @@ -27,11 +28,7 @@ #error "need d_type for file browser #endif -extern char romFileName[PATH_MAX]; -extern char *rom_data; extern int mmuhack_status; -extern int state_slot; -extern int config_slot, config_slot_current; static const char *gp2xKeyNames[] = { "UP", "???", "LEFT", "???", "DOWN", "???", "RIGHT", "???", @@ -40,8 +37,6 @@ static const char *gp2xKeyNames[] = { "???", "???", "???", "PUSH", "???", "???", "???", "???" }; -char menuErrorMsg[40] = {0, }; - static void menu_darken_bg(void *dst, int pixels, int darker); static void menu_prepare_bg(int use_game_bg); @@ -177,7 +172,7 @@ void menu_romload_end(void) static unsigned short file2color(const char *fname) { const char *ext = fname + strlen(fname) - 3; - static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso" }; + static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso" }; static const char *other_exts[] = { "gmv", "pat" }; int i; @@ -452,7 +447,7 @@ static void state_check_slots(void) for (slot = 0; slot < 10; slot++) { - if (emu_check_save_file(slot)) + if (emu_checkSaveFile(slot)) { state_slot_flags |= 1 << slot; } @@ -480,10 +475,10 @@ static void draw_savestate_bg(int slot) if (strcmp(fname + strlen(fname) - 3, ".gz") == 0) { file = gzopen(fname, "rb"); - emu_set_save_cbs(1); + emu_setSaveStateCbs(1); } else { file = fopen(fname, "rb"); - emu_set_save_cbs(0); + emu_setSaveStateCbs(0); } if (file) { @@ -501,7 +496,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forced_frame(); + emu_forcedFrame(); menu_prepare_bg(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); @@ -617,33 +612,57 @@ static char *action_binds(int player_idx, int action_mask) } } + // limit.. + strkeys[20] = 0; + return strkeys; } -static void unbind_action(int action) +static void unbind_action(int action, int pl_idx, int joy) { int i, u; - for (i = 0; i < 32; i++) - currentConfig.KeyBinds[i] &= ~action; - for (u = 0; u < 4; u++) - for (i = 0; i < 32; i++) - currentConfig.JoyBinds[u][i] &= ~action; + if (joy <= 0) + { + for (i = 0; i < 32; i++) { + if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue; + currentConfig.KeyBinds[i] &= ~action; + } + } + if (joy < 0) + { + for (u = 0; u < 4; u++) + for (i = 0; i < 32; i++) { + if (pl_idx >= 0 && (currentConfig.JoyBinds[u][i]&0x30000) != (pl_idx<<16)) continue; + currentConfig.JoyBinds[u][i] &= ~action; + } + } + else if (joy > 0) + { + for (i = 0; i < 32; i++) { + if (pl_idx >= 0 && (currentConfig.JoyBinds[joy-1][i]&0x30000) != (pl_idx<<16)) continue; + currentConfig.JoyBinds[joy-1][i] &= ~action; + } + } } -static int count_bound_keys(int action, int joy) +static int count_bound_keys(int action, int pl_idx, int joy) { int i, keys = 0; if (joy) { - for (i = 0; i < 32; i++) + for (i = 0; i < 32; i++) { + if (pl_idx >= 0 && (currentConfig.JoyBinds[joy-1][i]&0x30000) != (pl_idx<<16)) continue; if (currentConfig.JoyBinds[joy-1][i] & action) keys++; + } } else { - for (i = 0; i < 32; i++) + for (i = 0; i < 32; i++) { + if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue; if (currentConfig.KeyBinds[i] & action) keys++; + } } return keys; } @@ -657,7 +676,7 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i gp2x_pd_clone_buffer2(); if (player_idx >= 0) { text_out16(80, 20, "Player %i controls", player_idx + 1); - x = 100; + x = 80; } else { text_out16(80, 20, "Emulator controls"); x = 40; @@ -706,16 +725,16 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i } // if we are here, we want to bind/unbind something if ((inp & GP2X_SELECT) && !prev_select) - unbind_action(opts[sel].mask); + unbind_action(opts[sel].mask, player_idx, -1); prev_select = inp & GP2X_SELECT; inp &= CONFIGURABLE_KEYS; inp &= ~GP2X_SELECT; for (i = 0; i < 32; i++) if (inp & (1 << i)) { - if (count_bound_keys(opts[sel].mask, 0) >= 2) + if (count_bound_keys(opts[sel].mask, player_idx, 0) >= 2) currentConfig.KeyBinds[i] &= ~opts[sel].mask; // allow to unbind only else currentConfig.KeyBinds[i] ^= opts[sel].mask; - if (player_idx >= 0) { + if (player_idx >= 0 && (currentConfig.KeyBinds[i] & opts[sel].mask)) { currentConfig.KeyBinds[i] &= ~(3 << 16); currentConfig.KeyBinds[i] |= player_idx << 16; } @@ -725,12 +744,14 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i { for (i = 0; i < 32; i++) if (inp & (1 << i)) { - if (count_bound_keys(opts[sel].mask, joy) >= 1) // disallow combos for usbjoy - currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask; - else currentConfig.JoyBinds[joy-1][i] ^= opts[sel].mask; - if (player_idx >= 0) { - currentConfig.JoyBinds[joy-1][i] &= ~(3 << 16); - currentConfig.JoyBinds[joy-1][i] |= player_idx << 16; + int *bind = ¤tConfig.JoyBinds[joy-1][i]; + if ((*bind & opts[sel].mask) && (player_idx < 0 || player_idx == ((*bind>>16)&3))) + currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask; + else { + // override + unbind_action(opts[sel].mask, player_idx, joy); + *bind = opts[sel].mask; + if (player_idx >= 0) *bind |= player_idx << 16; } } } @@ -902,17 +923,17 @@ static void cd_menu_loop_options(void) menu_id selected_id; char *bios, *p; - if (find_bios(4, &bios)) { // US + if (emu_findBios(4, &bios)) { // US for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.us, p, sizeof(bios_names.us)); bios_names.us[sizeof(bios_names.us)-1] = 0; } else strcpy(bios_names.us, "NOT FOUND"); - if (find_bios(8, &bios)) { // EU + if (emu_findBios(8, &bios)) { // EU for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.eu, p, sizeof(bios_names.eu)); bios_names.eu[sizeof(bios_names.eu)-1] = 0; } else strcpy(bios_names.eu, "NOT FOUND"); - if (find_bios(1, &bios)) { // JP + if (emu_findBios(1, &bios)) { // JP for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.jp, p, sizeof(bios_names.jp)); bios_names.jp[sizeof(bios_names.jp)-1] = 0; } else strcpy(bios_names.jp, "NOT FOUND"); @@ -946,21 +967,21 @@ static void cd_menu_loop_options(void) if (inp & GP2X_START) { // BIOS testers switch (selected_id) { case MA_CDOPT_TESTBIOS_USA: - if (find_bios(4, &bios)) { // test US + if (emu_findBios(4, &bios)) { // test US strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; } break; case MA_CDOPT_TESTBIOS_EUR: - if (find_bios(8, &bios)) { // test EU + if (emu_findBios(8, &bios)) { // test EU strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; } break; case MA_CDOPT_TESTBIOS_JAP: - if (find_bios(1, &bios)) { // test JP + if (emu_findBios(1, &bios)) { // test JP strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; @@ -1231,9 +1252,8 @@ static void menu_options_save(void) PicoRegionOverride = currentConfig.PicoRegion; if (!(PicoOpt & 0x20)) { // unbind XYZ MODE, just in case - unbind_action(0xf00); + unbind_action(0xf00, -1, -1); } - scaling_update(); } static int menu_loop_options(void) @@ -1374,7 +1394,7 @@ static void draw_menu_credits(void) text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); y = tl_y; text_out16(tl_x, y, "Credits:"); - text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,"); + text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,"); text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); @@ -1671,7 +1691,7 @@ int menu_loop_tray(void) selfname = romsel_loop(curr_path); if (selfname) { int ret = -1, cd_type; - cd_type = emu_cd_check(NULL); + cd_type = emu_cdCheck(NULL); if (cd_type > 0) ret = Insert_CD(romFileName, cd_type == 2); if (ret != 0) {