From d1b4f1b10953cddf33591b8fc84b7248f04b88f8 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Thu, 23 Apr 2009 01:01:07 +0000 Subject: [PATCH] + fixed lightgun autodetection for Lethal Enforcers II + improved Mouse emulation + cleaned inputs functions a little bit + added preliminar Menu options (bg color, sfx/music volume) --- history.txt | 3 +- source/cart_hw/cart_hw.c | 2 +- source/gen_input.c | 4 +- source/gen_input.h | 10 - source/gx/config.c | 33 ++- source/gx/config.h | 13 +- source/gx/gui/legal.c | 3 +- source/gx/gui/menu.c | 234 +++++++++------ source/gx/gx_audio.c | 2 +- source/gx/gx_input.c | 606 ++++++++++++++++++--------------------- source/gx/gx_input.h | 11 +- source/gx/gx_video.c | 1 - source/gx/gx_video.h | 1 - source/gx/osd.h | 5 + 14 files changed, 477 insertions(+), 451 deletions(-) diff --git a/history.txt b/history.txt index f735008..95296ba 100644 --- a/history.txt +++ b/history.txt @@ -9,7 +9,8 @@ Genesis Plus GX 1.3.2 (??/??/????) (Eke-Eke) * removed now outdated Gens YM2612 core * improved MAME YM2612 emulation accuracy (SSG-EG, CSM mode and more), thanks to Nemesis for his tests on real hardware * fixed FM context restore when loading savesates -* improved sprites masking: fixes 3D level in Mickey Mania +* improved sprites masking emulation: fixes 3D level in Mickey Mania +* fixed lightgun games detection: fixes cursor position in Lethal Enforcers II * various code cleanup & optimization [Gamecube/Wii] diff --git a/source/cart_hw/cart_hw.c b/source/cart_hw/cart_hw.c index 84bd24c..83de8d2 100644 --- a/source/cart_hw/cart_hw.c +++ b/source/cart_hw/cart_hw.c @@ -282,7 +282,7 @@ void cart_hw_init() /********************************************** KONAMI JUSTIFIER ***********************************************/ - if (strstr(rominfo.international,"LETHAL ENFORCERS II") != NULL) + else if (strstr(rominfo.international,"LETHAL ENFORCERSII") != NULL) { /* save current setting */ if (old_system[0] == -1) old_system[0] = input.system[0]; diff --git a/source/gen_input.c b/source/gen_input.c index f64f42f..2ee542d 100644 --- a/source/gen_input.c +++ b/source/gen_input.c @@ -30,7 +30,7 @@ t_input input; * *****************************************************************************/ /* H counter values for a 256-pixel wide display (342 pixel max.) */ -uint8 hc_256[171] = { +static uint8 hc_256[171] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, @@ -46,7 +46,7 @@ uint8 hc_256[171] = { }; /* H counter values for a 320-pixel wide display (420 pixels max.) */ -uint8 hc_320[210] = { +static uint8 hc_320[210] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, diff --git a/source/gen_input.h b/source/gen_input.h index 10be101..47786dc 100644 --- a/source/gen_input.h +++ b/source/gen_input.h @@ -58,16 +58,6 @@ #define SYSTEM_TEAMPLAYER (5) /* Sega TeamPlayer */ #define SYSTEM_WAYPLAY (6) /* EA 4-Way Play (use both ports) */ -/* Players Inputs */ -#define PLAYER_1A (0) -#define PLAYER_1B (1) -#define PLAYER_1C (2) -#define PLAYER_1D (3) -#define PLAYER_2A (4) -#define PLAYER_2B (5) -#define PLAYER_2C (6) -#define PLAYER_2D (7) - typedef struct { uint8 dev[MAX_DEVICES]; /* Can be any of the DEVICE_* values */ diff --git a/source/gx/config.c b/source/gx/config.c index b76aaec..055e1c1 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -22,12 +22,6 @@ ***************************************************************************/ #include "shared.h" -#ifdef HW_RVL -#define CONFIG_VERSION "GENPLUS 1.3.2W" -#else -#define CONFIG_VERSION "GENPLUS 1.3.2G" -#endif - void config_save() { char pathname[MAXPATHLEN]; @@ -61,10 +55,10 @@ void config_load() if (fp == NULL) return; /* read version */ - char version[15]; - fread(version, 15, 1, fp); + char version[16]; + fread(version, 16, 1, fp); fclose(fp); - if (strcmp(version,CONFIG_VERSION)) return; + if (strcmp(version,VERSION)) return; /* read file */ fp = fopen(pathname, "rb"); @@ -75,7 +69,7 @@ void config_load() void config_setDefault(void) { /* version TAG */ - strncpy(config.version,CONFIG_VERSION,15); + strncpy(config.version,VERSION,16); /* sound options */ config.psg_preamp = 150; @@ -85,17 +79,11 @@ void config_setDefault(void) config.filter = 1; /* system options */ - config.state_auto = -1; -#ifdef HW_RVL - config.sram_auto = 0; /* let's assume we always have a FAT device by default */ -#else - config.sram_auto = -1; -#endif config.region_detect = 0; config.force_dtack = 0; config.bios_enabled = 0; - /* display options */ + /* video options */ config.xshift = 0; config.yshift = 0; config.xscale = 0; @@ -110,5 +98,16 @@ void config_setDefault(void) gx_input_setDefault(); config.gun_cursor = 1; config.invert_mouse = 0; + + /* menu options */ +#ifdef HW_RVL + config.sram_auto = 0; /* let's assume we always have a FAT device by default */ +#else + config.sram_auto = -1; +#endif + config.state_auto = -1; + config.bg_color = 0; + config.bgm_volume = 100.0; + config.sfx_volume = 100.0; } diff --git a/source/gx/config.h b/source/gx/config.h index 000a949..0c47359 100644 --- a/source/gx/config.h +++ b/source/gx/config.h @@ -30,14 +30,12 @@ ****************************************************************************/ typedef struct { - char version[15]; + char version[16]; int32 psg_preamp; int32 fm_preamp; uint8 boost; uint8 filter; uint8 hq_fm; - int8 sram_auto; - int8 state_auto; uint8 region_detect; uint8 force_dtack; uint8 bios_enabled; @@ -51,11 +49,16 @@ typedef struct uint8 render; uint8 ntsc; uint8 bilinear; + uint8 gun_cursor; + uint8 invert_mouse; uint16 pad_keymap[4][MAX_KEYS]; uint32 wpad_keymap[4*3][MAX_KEYS]; t_input_config input[MAX_DEVICES]; - uint8 gun_cursor; - uint8 invert_mouse; + int8 bg_color; + float bgm_volume; + float sfx_volume; + int8 sram_auto; + int8 state_auto; } t_config; /* Global data */ diff --git a/source/gx/gui/legal.c b/source/gx/gui/legal.c index 1ad1865..4fb6b60 100644 --- a/source/gx/gui/legal.c +++ b/source/gx/gui/legal.c @@ -72,7 +72,8 @@ void legal () gxSetScreen (); sleep (1); - WriteCentre (ypos, "Press any button to skip intro"); + GXColor color = {0x66,0x99,0xcc,0xff}; + FONT_writeCenter("Press any button to skip intro",fheight,0,640,ypos,color); gxSetScreen (); int count = 100; while (count > 0) diff --git a/source/gx/gui/menu.c b/source/gx/gui/menu.c index 226ea93..2aa0ad5 100644 --- a/source/gx/gui/menu.c +++ b/source/gx/gui/menu.c @@ -30,12 +30,35 @@ #include "filesel.h" #include +#include + +/* Global datas */ +t_input_menu m_input; #ifdef HW_RVL gx_texture *w_pointer; #endif -t_input_menu m_input; +#define BG_COLOR_MAX 14 + +/* various background colors */ +static GXColor bg_colors[BG_COLOR_MAX]= +{ + {0xd6,0xcb,0xba,0xff}, /* light gold */ + {0xbb,0xb0,0x99,0xff}, /* gold */ + {0x66,0x66,0x66,0xff}, /* faded grey */ + {0xcc,0xcc,0xcc,0xff}, /* light grey */ + {0xd4,0xd0,0xc8,0xff}, /* cream */ + {0xb8,0xc7,0xda,0xff}, /* light blue */ + {0xc0,0xcf,0xe7,0xff}, /* sky blue */ + {0x98,0xb1,0xd8,0xff}, /* sea blue */ + {0x7b,0x8c,0xa6,0xff}, /* violet */ + {0xa9,0xc7,0xc6,0xff}, /* green blue */ + {0x7d,0xa4,0x9f,0xff}, /* darker green blue */ + {0x22,0x52,0x74,0xff}, /* dark blue */ + {0x33,0x33,0x33,0xff}, /* dark grey */ + {0x00,0x00,0x00,0xff} /* black */ +}; /*****************************************************************************/ /* Generic Buttons data */ @@ -174,14 +197,12 @@ static gui_item items_audio[5] = }; /* System options menu */ -static gui_item items_system[6] = +static gui_item items_system[4] = { {NULL,NULL,"Console Region: AUTO","Select system region", 0,0,0,0}, {NULL,NULL,"System Lockups: OFF", "Enable/disable original system lock-ups",0,0,0,0}, {NULL,NULL,"System BIOS: OFF", "Enable/disable TMSS BIOS support", 0,0,0,0}, - {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 0,0,0,0}, - {NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 0,0,0,0}, - {NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Freeze State", 0,0,0,0} + {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 0,0,0,0} }; /* Video options menu */ @@ -197,6 +218,16 @@ static gui_item items_video[8] = {NULL,NULL,"DISPLAY SIZE", "Adjust display size", 0,0,0,0} }; +/* Preferences menu */ +static gui_item items_prefs[5] = +{ + {NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 0,0,0,0}, + {NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Savestate", 0,0,0,0}, + {NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 0,0,0,0}, + {NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 0,0,0,0}, + {NULL,NULL,"BG Color: DEFAULT", "Change background color", 0,0,0,0} +}; + /*****************************************************************************/ /* Menu Buttons description */ /*****************************************************************************/ @@ -315,7 +346,7 @@ static gui_menu menu_system = { "System Options", 0,0, - 6,4,6, + 4,4,6, {1,1}, items_system, buttons_list, @@ -355,6 +386,21 @@ static gui_menu menu_audio = FALSE }; +/* Sound Options menu */ +static gui_menu menu_prefs = +{ + "Sound Options", + 0,0, + 5,4,6, + {1,1}, + items_prefs, + buttons_list, + bg_list, + {&action_cancel, &action_select}, + {&arrow_up,&arrow_down}, + FALSE +}; + /*****************************************************************************/ /* Generic GUI routines */ /*****************************************************************************/ @@ -477,7 +523,7 @@ void GUI_DrawMenu(gui_menu *menu) } else { - gxClearScreen((GXColor)BACKGROUND); + gxClearScreen(bg_colors[config.bg_color]); } /* background elements */ @@ -623,7 +669,7 @@ void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out) } else { - gxClearScreen((GXColor)BACKGROUND); + gxClearScreen(bg_colors[config.bg_color]); } /* background elements */ @@ -707,7 +753,7 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) { int i, ret, quit = 0; s32 selected = 0; - s32 old, voice; + s32 old; butn_data *data = &button_text_data; u8 delete_me[2]; s16 p; @@ -752,7 +798,7 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) GUI_DrawMenu(parent); /* draw window */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,216); + gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ @@ -779,7 +825,7 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) GUI_DrawMenu(parent); /* draw window */ - gxDrawTexture(window,xwindow,ywindow,window->width,window->height,216); + gxDrawTexture(window,xwindow,ywindow,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow,top->width,top->height,255); /* draw title */ @@ -854,8 +900,8 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) { if (selected >= 0) { - voice = ASND_GetFirstUnusedVoice(); - if(voice >= 0) ASND_SetVoice(voice,VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,255,255,NULL); + ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, + ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } @@ -884,7 +930,7 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) GUI_DrawMenu(parent); /* draw window + header */ - gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,216); + gxDrawTexture(window,xwindow,ywindow-yoffset,window->width,window->height,230); gxDrawTexture(top,xwindow,ywindow-yoffset,top->width,top->height,255); /* draw title */ @@ -909,31 +955,6 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items) return ret; } - -#define MAX_COLORS 14 -#define VERSION "Version 1.03" - -/* it's hard to choose a nice background color ;-) */ -static GXColor background_colors[MAX_COLORS]= -{ - {0x00,0x00,0x00,0xff}, /* black */ - {0x33,0x33,0x33,0xff}, /* dark grey */ - {0x66,0x66,0x66,0xff}, /* faded grey */ - {0xcc,0xcc,0xcc,0xff}, /* light grey */ - {0xd4,0xd0,0xc8,0xff}, /* cream */ - {0xb8,0xc7,0xda,0xff}, /* light blue */ - {0xc0,0xcf,0xe7,0xff}, /* sky blue */ - {0x98,0xb1,0xd8,0xff}, /* sea blue */ - {0x7b,0x8c,0xa6,0xff}, /* violet */ - {0xa9,0xc7,0xc6,0xff}, /* green blue */ - {0x7d,0xa4,0x9f,0xff}, /* darker green blue */ - {0x22,0x52,0x74,0xff}, /* dark blue */ - {0xd6,0xcb,0xba,0xff}, /* light gold */ - {0xbb,0xb0,0x99,0xff} /* gold */ -}; - -static s8 color_cnt = 0; - int GUI_RunMenu(gui_menu *menu) { int selected,quit=0; @@ -1077,26 +1098,6 @@ int GUI_RunMenu(gui_menu *menu) { quit = 2; } - else if (p & PAD_TRIGGER_R) - { - /* swap menu background color (debug) */ - color_cnt++; - if (color_cnt >= MAX_COLORS) color_cnt = 0; - BACKGROUND.r = background_colors[color_cnt].r; - BACKGROUND.g = background_colors[color_cnt].g; - BACKGROUND.b = background_colors[color_cnt].b; - BACKGROUND.a = background_colors[color_cnt].a; - } - else if (p & PAD_TRIGGER_L) - { - /* swap menu background color (debug) */ - color_cnt--; - if (color_cnt < 0) color_cnt = MAX_COLORS - 1; - BACKGROUND.r = background_colors[color_cnt].r; - BACKGROUND.g = background_colors[color_cnt].g; - BACKGROUND.b = background_colors[color_cnt].b; - BACKGROUND.a = background_colors[color_cnt].a; - } /* selected item has changed ? */ if (menu->selected != selected) @@ -1107,7 +1108,8 @@ int GUI_RunMenu(gui_menu *menu) button = &menu->buttons[selected]; if (button->state & BUTTON_OVER_SFX) { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,200,200,NULL); + ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, + ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } else if (selected < (max_buttons + 2)) @@ -1116,7 +1118,8 @@ int GUI_RunMenu(gui_menu *menu) button = menu->arrows[selected-max_buttons]; if (button->state & BUTTON_OVER_SFX) { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,200,200,NULL); + ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size, + ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } @@ -1147,7 +1150,8 @@ int GUI_RunMenu(gui_menu *menu) button = &menu->buttons[selected]; if (button->state & BUTTON_SELECT_SFX) { - ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_select_pcm,button_select_pcm_size,200,200,NULL); + ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_select_pcm,button_select_pcm_size, + ((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL); } } @@ -1183,7 +1187,7 @@ static void drawmenu (char items[][25], int maxitems, int selected) memset(&texture,0,sizeof(gx_texture)); /* draw background items */ - gxClearScreen ((GXColor)BACKGROUND); + gxClearScreen (bg_colors[config.bg_color]); texture= gxTextureOpenPNG(Bg_main_png); if (texture) { @@ -1282,6 +1286,81 @@ static int domenu (char items[][25], int maxitems, u8 fastmove) return ret; } +/**************************************************************************** + * Preferences menu + * + ****************************************************************************/ +static void prefmenu () +{ + int ret, quit = 0; + gui_menu *m = &menu_prefs; + gui_item *items = m->items; + + GUI_InitMenu(m); + + while (quit == 0) + { + if (config.sram_auto == 0) sprintf (items[0].text, "SRAM Auto: FAT"); + else if (config.sram_auto == 1) sprintf (items[0].text, "SRAM Auto: MCARD A"); + else if (config.sram_auto == 2) sprintf (items[0].text, "SRAM Auto: MCARD B"); + else sprintf (items[0].text, "SRAM Auto: OFF"); + if (config.state_auto == 0) sprintf (items[1].text, "Savestate Auto: FAT"); + else if (config.state_auto == 1) sprintf (items[1].text, "Savestate Auto: MCARD A"); + else if (config.state_auto == 2) sprintf (items[1].text, "Savestate Auto: MCARD B"); + else sprintf (items[3].text, "Savestate Auto: OFF"); + sprintf (items[2].text, "SFX Volume: %1.2f", config.sfx_volume); + sprintf (items[3].text, "BGM Volume: %1.2f", config.bgm_volume); + if (config.bg_color) sprintf (items[4].text, "BG Color: Type %d", config.bg_color); + else sprintf (items[4].text, "BG Color: DEFAULT"); + + ret = GUI_RunMenu(m); + + switch (ret) + { + case 0: /*** SRAM auto load/save ***/ + config.sram_auto ++; + if (config.sram_auto > 2) config.sram_auto = -1; + break; + + case 1: /*** Savestate auto load/save ***/ + config.state_auto ++; + if (config.state_auto > 2) config.state_auto = -1; + break; + + case 2: /*** Sound effects volume ***/ + case -4: + if (ret < 0) config.sfx_volume --; + else config.sfx_volume ++; + if (config.sfx_volume < 0) config.sfx_volume = 100.0; + else if (config.sfx_volume > 100) config.sfx_volume = 0.0; + break; + + case 3: /*** Background music volume ***/ + case -5: + if (ret < 0) config.bgm_volume --; + else config.bgm_volume ++; + if (config.bgm_volume < 0) config.bgm_volume = 100.0; + else if (config.bgm_volume > 100) config.bgm_volume = 0.0; + SetVolumeOgg(((int)config.bgm_volume * 255) / 100); + break; + + case 4: /*** Background color ***/ + case -6: + if (ret < 0) config.bg_color --; + else config.bg_color ++; + if (config.bg_color < 0) config.bg_color = BG_COLOR_MAX - 1; + if (config.bg_color >= BG_COLOR_MAX) config.bg_color = 0; + break; + + case -1: + quit = 1; + break; + } + } + + GUI_DeleteMenu(m); +} + /**************************************************************************** * Sound Option menu * @@ -1380,14 +1459,6 @@ static void systemmenu () sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); sprintf (items[2].text, "System BIOS: %s", (config.bios_enabled & 1) ? "ON":"OFF"); sprintf (items[3].text, "SVP Cycles: %d", SVP_cycles); - if (config.sram_auto == 0) sprintf (items[4].text, "Auto SRAM: FAT"); - else if (config.sram_auto == 1) sprintf (items[4].text, "Auto SRAM: MCARD A"); - else if (config.sram_auto == 2) sprintf (items[4].text, "Auto SRAM: MCARD B"); - else sprintf (items[4].text, "Auto SRAM: OFF"); - if (config.state_auto == 0) sprintf (items[5].text, "Auto FREEZE: FAT"); - else if (config.state_auto == 1) sprintf (items[5].text, "Auto FREEZE: MCARD A"); - else if (config.state_auto == 2) sprintf (items[5].text, "Auto FREEZE: MCARD B"); - else sprintf (items[5].text, "Auto FREEZE: OFF"); ret = GUI_RunMenu(m); @@ -1439,16 +1510,6 @@ static void systemmenu () if (SVP_cycles > 1500) SVP_cycles = 0; break; - case 4: /*** SRAM autoload/autosave ***/ - config.sram_auto ++; - if (config.sram_auto > 2) config.sram_auto = -1; - break; - - case 5: /*** FreezeState autoload/autosave ***/ - config.state_auto ++; - if (config.state_auto > 2) config.state_auto = -1; - break; - case -1: quit = 1; break; @@ -1848,8 +1909,13 @@ static void inputsmenu(void) case 7: if (config.input[player].device < 0) break; - gx_input_config(config.input[player].port, config.input[player].device, input.padtype[player]); - break; + if (input.padtype[player] == DEVICE_3BUTTON) /* 3-buttons */ + gx_input_config(config.input[player].port, config.input[player].device, 4); + else if (config.input[player].device == 0) /* 6-buttons w/o MODE */ + gx_input_config(config.input[player].port, 0, 7); + else /* 6-buttons */ + gx_input_config(config.input[player].port, config.input[player].device, 8); + break; case -1: /* remove duplicate assigned inputs */ @@ -1898,7 +1964,7 @@ static void optionmenu(void) inputsmenu(); break; case 4: - /*TODO */ + prefmenu(); break; case -1: quit = 1; diff --git a/source/gx/gx_audio.c b/source/gx/gx_audio.c index cf3a7cb..b4d2394 100644 --- a/source/gx/gx_audio.c +++ b/source/gx/gx_audio.c @@ -180,6 +180,6 @@ void gx_audio_stop(void) { PauseOgg(0); PlayOgg(mem_open((char *)Bg_music_ogg, Bg_music_ogg_size), 0, OGG_INFINITE_TIME); - SetVolumeOgg(255); + SetVolumeOgg(((int)config.bgm_volume * 255) / 100); } } diff --git a/source/gx/gx_input.c b/source/gx/gx_input.c index 4a2a049..757f7f3 100644 --- a/source/gx/gx_input.c +++ b/source/gx/gx_input.c @@ -25,17 +25,21 @@ #include "font.h" #include "menu.h" -/* configurable keys */ +/* analog sensitivity */ +#define ANALOG_SENSITIVITY 30 + +/* Menu request flag */ +u8 ConfigRequested = 0; + +/* configurable Genesis keys */ #define KEY_BUTTONA 0 #define KEY_BUTTONB 1 #define KEY_BUTTONC 2 #define KEY_START 3 -#define KEY_MENU 4 #define KEY_BUTTONX 5 // 6-buttons only #define KEY_BUTTONY 6 // 6-buttons only #define KEY_BUTTONZ 7 // 6-buttons only - -u8 ConfigRequested = 1; +#define KEY_MODE 8 // 6-buttons only static const char *keys_name[MAX_KEYS] = { @@ -43,210 +47,177 @@ static const char *keys_name[MAX_KEYS] = "Button B", "Button C", "Button START ", - "Menu", "Button X", "Button Y", "Button Z", }; -/* gamepad available buttons */ -static const u16 pad_keys[8] = -{ - PAD_TRIGGER_Z, - PAD_TRIGGER_R, - PAD_TRIGGER_L, - PAD_BUTTON_A, - PAD_BUTTON_B, - PAD_BUTTON_X, - PAD_BUTTON_Y, - PAD_BUTTON_START, -}; - #ifdef HW_RVL -/* directional buttons mapping */ +/* default directionnal buttons map */ #define PAD_UP 0 #define PAD_DOWN 1 #define PAD_LEFT 2 #define PAD_RIGHT 3 -static int held_cnt = 0; - static u32 wpad_dirmap[3][4] = { - {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE only */ - {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */ + {WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE */ + {WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */ {WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */ }; -/* wiimote/expansion available buttons */ -static u32 wpad_keys[20] = -{ - WPAD_BUTTON_2, - WPAD_BUTTON_1, - WPAD_BUTTON_B, - WPAD_BUTTON_A, -/* WPAD_BUTTON_MINUS, used for mode */ - WPAD_BUTTON_HOME, - WPAD_BUTTON_PLUS, - WPAD_NUNCHUK_BUTTON_Z, - WPAD_NUNCHUK_BUTTON_C, - WPAD_CLASSIC_BUTTON_ZR, - WPAD_CLASSIC_BUTTON_X, - WPAD_CLASSIC_BUTTON_A, - WPAD_CLASSIC_BUTTON_Y, - WPAD_CLASSIC_BUTTON_B, - WPAD_CLASSIC_BUTTON_ZL, - WPAD_CLASSIC_BUTTON_FULL_R, - WPAD_CLASSIC_BUTTON_PLUS, - WPAD_CLASSIC_BUTTON_HOME, - WPAD_CLASSIC_BUTTON_MINUS, - WPAD_CLASSIC_BUTTON_FULL_L, -}; +static int held_cnt = 0; + #endif -/******************************* - gamepad support -*******************************/ -static void pad_config(int num, int padtype) +/***************************************************************************************/ +/* Gamecube PAD support */ +/***************************************************************************************/ +static void pad_config(int chan, int max_keys) { - int i,j; - int max = (padtype == DEVICE_6BUTTON) ? MAX_KEYS : (MAX_KEYS - 3); - u16 p; - u8 quit; + int i; + u16 p,key; char msg[30]; - u32 pad = PAD_ScanPads() & (1< bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w; if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0; else if (input.analog[i-4][1] > bitmap.viewport.h) input.analog[i-4][1] = bitmap.viewport.h; } - - /* PEN tablet position (x,y) */ else if ((system_hw == SYSTEM_PICO) && (i == 0)) { - input.analog[0][0] += x / sensitivity; - input.analog[0][1] -= y / sensitivity; + /* PEN tablet position (x,y) */ + input.analog[0][0] += x / ANALOG_SENSITIVITY; + input.analog[0][1] -= y / ANALOG_SENSITIVITY; if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; else if (input.analog[0][1] > 0x3f3) input.analog[0][1] = 0x3f3; } - - /* MOUSE quantity of movement (-256,256) */ else if (input.dev[i] == DEVICE_MOUSE) { - input.analog[2][0] = (x / sensitivity) * 2; - input.analog[2][1] = (y / sensitivity) * 2; - if (config.invert_mouse) input.analog[2][1] = 0 - input.analog[2][1]; + /* MOUSE relative movement (-255,255) */ + input.analog[2][0] = (x / ANALOG_SENSITIVITY) * 2; + input.analog[2][1] = (y / ANALOG_SENSITIVITY) * 2; + if (config.invert_mouse) input.analog[2][1] = -input.analog[2][1]; } - /* GAMEPAD directional buttons */ + /* Gamepad device */ else { - if ((p & PAD_BUTTON_UP) || (y > sensitivity)) input.pad[i] |= INPUT_UP; - else if ((p & PAD_BUTTON_DOWN) || (y < -sensitivity)) input.pad[i] |= INPUT_DOWN; - if ((p & PAD_BUTTON_LEFT) || (x < -sensitivity)) input.pad[i] |= INPUT_LEFT; - else if ((p & PAD_BUTTON_RIGHT) || (x > sensitivity)) input.pad[i] |= INPUT_RIGHT; + if ((p & PAD_BUTTON_UP) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; + else if ((p & PAD_BUTTON_DOWN) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; + if ((p & PAD_BUTTON_LEFT) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; + else if ((p & PAD_BUTTON_RIGHT) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; } } -/******************************* - wiimote support -*******************************/ + +/***************************************************************************************/ +/* Wii WPAD support */ +/***************************************************************************************/ #ifdef HW_RVL -static s8 WPAD_StickX(u8 chan,u8 right) +static s8 WPAD_StickX(WPADData *data,u8 right) { float mag = 0.0; float ang = 0.0; - WPADData *data = WPAD_Data(chan); switch (data->exp.type) { @@ -285,11 +256,10 @@ static s8 WPAD_StickX(u8 chan,u8 right) } -static s8 WPAD_StickY(u8 chan, u8 right) +static s8 WPAD_StickY(WPADData *data, u8 right) { float mag = 0.0; float ang = 0.0; - WPADData *data = WPAD_Data(chan); switch (data->exp.type) { @@ -327,96 +297,135 @@ static s8 WPAD_StickY(u8 chan, u8 right) return (s8)(val * 128.0f); } -static void wpad_config(u8 num, u8 exp, u8 padtype) +static void wpad_config(u8 chan, u8 exp, u8 max_keys) { - int i,j; - int max = (padtype == DEVICE_6BUTTON) ? MAX_KEYS : (MAX_KEYS - 3); - u8 quit; + int i; char msg[30]; - u32 current = 255; + u32 key,p = 255; - /* check wiimote status */ - WPAD_Probe(num, ¤t); - if (((exp > WPAD_EXP_NONE) && (current != exp)) || (current == 255)) + /* Check if device is connected */ + WPAD_Probe(chan, &p); + if (((exp > WPAD_EXP_NONE) && (p != exp)) || (p == 255)) { - if (exp == WPAD_EXP_NONE) sprintf(msg, "WIIMOTE #%d is not connected !", num+1); - if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", num+1); - if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", num+1); + if (exp == WPAD_EXP_NONE) sprintf(msg, "WIIMOTE #%d is not connected !", chan+1); + if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1); + if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1); WaitPrompt(msg); return; } - /* index for wpad_keymap */ - u8 index = exp + (num * 3); + VIDEO_SetPostRetraceCallback(NULL); + VIDEO_Flush(); /* loop on each mapped keys */ - for (i=0; ibtns_h; + + /* Soft RESET */ + if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) || + ((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS))) { - x = WPAD_StickX(num,0); - y = WPAD_StickY(num,0); + set_softreset(); } - /* IR structure */ - struct ir_t ir; + /* Menu Request */ + else if ((p & WPAD_BUTTON_HOME) || (p & WPAD_CLASSIC_BUTTON_HOME)) + { + ConfigRequested = 1; + return; + } - /* retrieve current key mapping */ - u32 *wpad_keymap = config.wpad_keymap[exp + (3 * num)]; + /* Retrieve current key mapping */ + u32 *wpad_keymap = config.wpad_keymap[exp + (3 * chan)]; - /* BUTTONS */ + /* Generic buttons */ if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_A; if (p & wpad_keymap[KEY_BUTTONB]) input.pad[i] |= INPUT_B; if (p & wpad_keymap[KEY_BUTTONC]) input.pad[i] |= INPUT_C; @@ -424,20 +433,29 @@ static void wpad_update(s8 num, u8 i, u32 exp) if (p & wpad_keymap[KEY_BUTTONY]) input.pad[i] |= INPUT_Y; if (p & wpad_keymap[KEY_BUTTONZ]) input.pad[i] |= INPUT_Z; if (p & wpad_keymap[KEY_START]) input.pad[i] |= INPUT_START; + if (p & wpad_keymap[KEY_MODE]) input.pad[i] |= INPUT_MODE; - /* MODE Button (FIXED) */ - if (((exp == WPAD_EXP_CLASSIC) && (p & WPAD_CLASSIC_BUTTON_MINUS)) || - ((exp != WPAD_EXP_CLASSIC) && (p & WPAD_BUTTON_MINUS))) - input.pad[i] |= INPUT_MODE; + /* Analog sticks */ + s8 x = 0; + s8 y = 0; + if (exp != WPAD_EXP_NONE) + { + x = WPAD_StickX(data,0); + y = WPAD_StickY(data,0); + } - /* LIGHTGUN screen position (X,Y) */ + /* IR structure */ + struct ir_t ir; + + /* Analog devices */ if (input.dev[i] == DEVICE_LIGHTGUN) { + /* Lightgun cursor position (x,y) */ if (x || y) { - /* analog stick */ - input.analog[i-4][0] += x / sensitivity; - input.analog[i-4][1] -= y / sensitivity; + /* analog stick relative positions */ + input.analog[i-4][0] += x / ANALOG_SENSITIVITY; + input.analog[i-4][1] -= y / ANALOG_SENSITIVITY; if (input.analog[i-4][0] < 0) input.analog[i-4][0] = 0; else if (input.analog[i-4][0] > bitmap.viewport.w) input.analog[i-4][0] = bitmap.viewport.w; if (input.analog[i-4][1] < 0) input.analog[i-4][1] = 0; @@ -446,25 +464,26 @@ static void wpad_update(s8 num, u8 i, u32 exp) if (exp != WPAD_EXP_CLASSIC) { - /* wiimote IR */ - WPAD_IR(num, &ir); + /* IR tracking */ + WPAD_IR(chan, &ir); if (ir.valid) { input.analog[i-4][0] = (ir.x * bitmap.viewport.w) / 640; input.analog[i-4][1] = (ir.y * bitmap.viewport.h) / 480; + + /* default button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } } } - - /* PEN tablet position (x,y) */ else if ((system_hw == SYSTEM_PICO) && (i == 0)) { + /* PEN tablet position (x,y) */ if (x || y) { - /* analog stick */ - input.analog[0][0] += x / sensitivity; - input.analog[0][1] -= y / sensitivity; + /* analog stick relative positions */ + input.analog[0][0] += x / ANALOG_SENSITIVITY; + input.analog[0][1] -= y / ANALOG_SENSITIVITY; if (input.analog[0][0] < 0x17c) input.analog[0][0] = 0x17c; else if (input.analog[0][0] > 0x3c) input.analog[0][0] = 0x3c; if (input.analog[0][1] < 0x1fc) input.analog[0][1] = 0x1fc; @@ -473,117 +492,68 @@ static void wpad_update(s8 num, u8 i, u32 exp) if (exp != WPAD_EXP_CLASSIC) { - /* wiimote IR */ - WPAD_IR(num, &ir); + /* IR tracking */ + WPAD_IR(chan, &ir); if (ir.valid) { input.analog[0][0] = 0x3c + (ir.x * (0x17c - 0x3c + 1)) / 640; input.analog[0][1] = 0x1fc + (ir.y * (0x3f3 - 0x1fc + 1)) / 480; + + /* default button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } } } - - /* MOUSE quantity of movement (-255,255) */ else if (input.dev[i] == DEVICE_MOUSE) { - /* by default, use analog stick values */ - input.analog[2][0] = (x * 2) / sensitivity; - input.analog[2][1] = - (y * 2) / sensitivity; - + /* Mouse relative movement (-255,255) */ + if (x || y) + { + /* analog stick relative positions */ + input.analog[2][0] = (x * 2) / ANALOG_SENSITIVITY; + input.analog[2][1] = -(y * 2) / ANALOG_SENSITIVITY; + } + if (exp != WPAD_EXP_CLASSIC) { - /* wiimote IR */ - WPAD_IR(num, &ir); + /* IR tracking */ + WPAD_IR(chan, &ir); if (ir.valid) { - /* get wiimote orientation */ - struct orient_t orient; - WPAD_Orientation(num,&orient); - - /* horizontal axis (yaw is between -180 and 180 degrees) */ - input.analog[2][0] = ((int)orient.yaw * 255) / 90; - - /* vertical axis (pitch is between -180 and 180 degrees) */ - input.analog[2][1] = ((int)orient.pitch * 255) / 90; - - /*input.analog[2][0] = ir.x - old_x; - if (input.analog[2][0] > 256) - { - input.analog[2][0] = 256; - old_x += 256; - } - else if (input.analog[2][0] < -256) - { - input.analog[2][0] = -256; - old_x -= 256; - } - else - { - old_x = ir.x; - } - - input.analog[2][1] = ir.y - old_y; - if (input.analog[2][1] > 256) - { - input.analog[2][1] = 256; - old_y += 256; - } - else if (input.analog[2][1] < -256) - { - input.analog[2][1] = -256; - old_y -= 256; - } - else - { - old_y = ir.y; - }*/ + /* calculate mouse values */ + input.analog[2][0] = (ir.x - old_x); + input.analog[2][1] = (ir.y - old_y); + old_x = ir.x; + old_y = ir.y; + if (input.analog[2][0] > 255) input.analog[2][0] = 255; + else if (input.analog[2][0] < -255) input.analog[2][0] = -255; + if (input.analog[2][1] > 255) input.analog[2][1] = 255; + else if (input.analog[2][1] < -255) input.analog[2][1] = -255; + /* default button */ if (p & WPAD_BUTTON_B) input.pad[i] |= INPUT_B; } -/* else - { - old_x += input.analog[2][0]; - old_y += input.analog[2][1]; - } -*/ } /* Invert Y coordinate */ - if (!config.invert_mouse) - { - input.analog[2][1] = -input.analog[2][1]; - } + if (!config.invert_mouse) input.analog[2][1] = -input.analog[2][1]; } - /* GAMEPAD directional buttons */ + /* Gamepad device */ else { - if ((p & wpad_dirmap[exp][PAD_UP]) || (y > sensitivity)) input.pad[i] |= INPUT_UP; - else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -sensitivity)) input.pad[i] |= INPUT_DOWN; - if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -sensitivity)) input.pad[i] |= INPUT_LEFT; - else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > sensitivity)) input.pad[i] |= INPUT_RIGHT; - } - - /* SOFTRESET */ - if (((p & WPAD_CLASSIC_BUTTON_PLUS) && (p & WPAD_CLASSIC_BUTTON_MINUS)) || - ((p & WPAD_BUTTON_PLUS) && (p & WPAD_BUTTON_MINUS))) - { - set_softreset(); - } - - /* MENU */ - if (p & wpad_keymap[KEY_MENU]) - { - ConfigRequested = 1; + if ((p & wpad_dirmap[exp][PAD_UP]) || (y > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_UP; + else if ((p & wpad_dirmap[exp][PAD_DOWN]) || (y < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_DOWN; + if ((p & wpad_dirmap[exp][PAD_LEFT]) || (x < -ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_LEFT; + else if ((p & wpad_dirmap[exp][PAD_RIGHT]) || (x > ANALOG_SENSITIVITY)) input.pad[i] |= INPUT_RIGHT; } } #endif -/***************************************************************** - Generic input handlers -******************************************************************/ +/***************************************************************************************/ +/* GX Input interface */ +/***************************************************************************************/ void gx_input_init(void) { PAD_Init (); @@ -594,6 +564,7 @@ void gx_input_init(void) WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); #endif + VIDEO_SetPostRetraceCallback(gx_input_updateMenu); VIDEO_Flush(); } @@ -609,51 +580,51 @@ void gx_input_setDefault(void) config.pad_keymap[i][KEY_BUTTONB] = PAD_BUTTON_A; config.pad_keymap[i][KEY_BUTTONC] = PAD_BUTTON_X; config.pad_keymap[i][KEY_START] = PAD_BUTTON_START; - config.pad_keymap[i][KEY_MENU] = PAD_TRIGGER_Z; config.pad_keymap[i][KEY_BUTTONX] = PAD_TRIGGER_L; config.pad_keymap[i][KEY_BUTTONY] = PAD_BUTTON_Y; config.pad_keymap[i][KEY_BUTTONZ] = PAD_TRIGGER_R; + config.pad_keymap[i][KEY_MODE] = PAD_TRIGGER_R; } #ifdef HW_RVL for (i=0; i<4; i++) { - /* WIIMOTE */ + /* Wiimote */ config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONA] = WPAD_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONB] = WPAD_BUTTON_2; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONC] = WPAD_BUTTON_1; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_START] = WPAD_BUTTON_PLUS; - config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_MENU] = WPAD_BUTTON_HOME; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONX] = 0; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONY] = 0; config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_BUTTONZ] = 0; + config.wpad_keymap[i*3 + WPAD_EXP_NONE][KEY_MODE] = 0; - /* WIIMOTE + NUNCHUK */ + /* Wiimote + Nunchuk */ config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONA] = WPAD_NUNCHUK_BUTTON_Z; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONB] = WPAD_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONC] = WPAD_BUTTON_B; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_START] = WPAD_BUTTON_PLUS; - config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_MENU] = WPAD_BUTTON_HOME; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONX] = WPAD_NUNCHUK_BUTTON_C; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONY] = WPAD_BUTTON_1; config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_BUTTONZ] = WPAD_BUTTON_2; + config.wpad_keymap[i*3 + WPAD_EXP_NUNCHUK][KEY_MODE] = WPAD_BUTTON_MINUS; - /* CLASSIC CONTROLLER */ + /* Classic Controller */ config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONA] = WPAD_CLASSIC_BUTTON_Y; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONB] = WPAD_CLASSIC_BUTTON_B; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONC] = WPAD_CLASSIC_BUTTON_A; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_START] = WPAD_CLASSIC_BUTTON_PLUS; - config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_MENU] = WPAD_CLASSIC_BUTTON_HOME; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONX] = WPAD_CLASSIC_BUTTON_ZL; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONY] = WPAD_CLASSIC_BUTTON_X; config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_BUTTONZ] = WPAD_CLASSIC_BUTTON_ZR; + config.wpad_keymap[i*3 + WPAD_EXP_CLASSIC][KEY_MODE] = WPAD_CLASSIC_BUTTON_MINUS; } #endif - /* default device assignation */ + /* Set default device assignation */ for (i=0; i 0) - wpad_update(config.input[num].port,i, config.input[num].device - 1); + else if (config.input[player].device > 0) + wpad_update(config.input[player].port,i, config.input[player].device - 1); #endif - num ++; + player ++; } } } @@ -752,7 +718,7 @@ void gx_input_updateEmu(void) /* Menu inputs update function (done by Video Interrupt callback) */ void gx_input_updateMenu(u32 cnt) { - /* get gamepad inputs */ + /* PAD status */ PAD_ScanPads(); s16 p = PAD_ButtonsDown(0); s8 x = PAD_StickX(0); @@ -763,32 +729,27 @@ void gx_input_updateMenu(u32 cnt) else if (y < -60) p |= PAD_BUTTON_DOWN; #ifdef HW_RVL - /* get wiimote + expansions inputs */ + /* WPAD status */ WPAD_ScanPads(); - u32 q = WPAD_ButtonsDown(0); - u32 h = WPAD_ButtonsHeld(0); - x = WPAD_StickX(0, 0); - y = WPAD_StickY(0, 0); + WPADData *data = WPAD_Data(0); + u32 q = data->btns_d; + u32 h = data->btns_h; + + /* fast scrolling/selection */ + h &= (WPAD_BUTTON_UP|WPAD_BUTTON_DOWN|WPAD_BUTTON_LEFT|WPAD_BUTTON_RIGHT|WPAD_BUTTON_A); + + /* wait for the key to be held for a short period */ + if (h) held_cnt++; + else held_cnt = 0; + if (held_cnt > 14) + { + /* update pressed status */ + held_cnt = 0; + q |= h; + } /* Wiimote orientation */ WPAD_IR(0, &m_input.ir); - - /* held buttons */ - if (h & WPAD_BUTTON_UP) held_cnt++; - else if (h & WPAD_BUTTON_DOWN) held_cnt++; - else if (h & WPAD_BUTTON_LEFT) held_cnt++; - else if (h & WPAD_BUTTON_RIGHT) held_cnt++; - else if (h & WPAD_BUTTON_A) held_cnt++; - else held_cnt = 0; - - /* delays buttons state update */ - if (held_cnt > 13) - { - held_cnt = 0; - q |= (h & (WPAD_BUTTON_UP|WPAD_BUTTON_DOWN|WPAD_BUTTON_LEFT|WPAD_BUTTON_RIGHT|WPAD_BUTTON_A)); - } - - /* wiimote directions */ if (m_input.ir.valid) { if (q & WPAD_BUTTON_UP) p |= PAD_BUTTON_UP; @@ -804,19 +765,21 @@ void gx_input_updateMenu(u32 cnt) else if (q & WPAD_BUTTON_RIGHT) p |= PAD_BUTTON_UP; } - /* analog sticks */ + /* Analog sticks */ + x = WPAD_StickX(data, 0); + y = WPAD_StickY(data, 0); if (y > 70) p |= PAD_BUTTON_UP; else if (y < -70) p |= PAD_BUTTON_DOWN; if (x < -60) p |= PAD_BUTTON_LEFT; else if (x > 60) p |= PAD_BUTTON_RIGHT; - /* classic controller directions */ + /* Classic controller */ if (q & WPAD_CLASSIC_BUTTON_UP) p |= PAD_BUTTON_UP; else if (q & WPAD_CLASSIC_BUTTON_DOWN) p |= PAD_BUTTON_DOWN; if (q & WPAD_CLASSIC_BUTTON_LEFT) p |= PAD_BUTTON_LEFT; else if (q & WPAD_CLASSIC_BUTTON_RIGHT) p |= PAD_BUTTON_RIGHT; - /* wiimote keys */ + /* Supported keys */ if (q & WPAD_BUTTON_MINUS) p |= PAD_TRIGGER_L; if (q & WPAD_BUTTON_PLUS) p |= PAD_TRIGGER_R; if (q & WPAD_BUTTON_A) p |= PAD_BUTTON_A; @@ -824,8 +787,6 @@ void gx_input_updateMenu(u32 cnt) if (q & WPAD_BUTTON_2) p |= PAD_BUTTON_A; if (q & WPAD_BUTTON_1) p |= PAD_BUTTON_B; if (q & WPAD_BUTTON_HOME) p |= PAD_TRIGGER_Z; - - /* classic controller keys */ if (q & WPAD_CLASSIC_BUTTON_FULL_L) p |= PAD_TRIGGER_L; if (q & WPAD_CLASSIC_BUTTON_FULL_R) p |= PAD_TRIGGER_R; if (q & WPAD_CLASSIC_BUTTON_A) p |= PAD_BUTTON_A; @@ -833,5 +794,6 @@ void gx_input_updateMenu(u32 cnt) if (q & WPAD_CLASSIC_BUTTON_HOME) p |= PAD_TRIGGER_Z; #endif + /* Update menu inputs */ m_input.keys = p; } diff --git a/source/gx/gx_input.h b/source/gx/gx_input.h index f4be9bf..8c99cdc 100644 --- a/source/gx/gx_input.h +++ b/source/gx/gx_input.h @@ -31,25 +31,26 @@ #define MAX_INPUTS 8 #endif -/* number of configurable keys */ +/* Genesis controller keys */ #define MAX_KEYS 8 -/* wrapper for genesis plus */ +/* Genesis Plus wrapper */ #define update_input() gx_input_updateEmu() -/* key configuration structure */ +/* Key configuration structure */ typedef struct { s8 device; u8 port; } t_input_config; -extern u8 ConfigRequested; extern void gx_input_init(void); extern void gx_input_setDefault(void); -extern void gx_input_config(u8 num, u8 type, u8 padtype); +extern void gx_input_config(u8 num, u8 type, u8 max_keys); extern void gx_input_updateEmu(void); extern void gx_input_updateMenu(u32 cnt); +extern u8 ConfigRequested; + #endif diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index c4cacda..0c4c2d6 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -925,7 +925,6 @@ void gxResetAngle(f32 angle) GX_Flush(); } -GXColor BACKGROUND = {0xd4,0xd0,0xc8,0xff}; void gxSetScreen () { diff --git a/source/gx/gx_video.h b/source/gx/gx_video.h index 51d91cc..6574f44 100644 --- a/source/gx/gx_video.h +++ b/source/gx/gx_video.h @@ -44,7 +44,6 @@ extern int whichfb; extern GXRModeObj *vmode; extern u8 *texturemem; extern u8 gc_pal; -extern GXColor BACKGROUND; /* GX video emulation functions */ extern void gx_video_init(void); diff --git a/source/gx/osd.h b/source/gx/osd.h index 9151ed0..7408125 100644 --- a/source/gx/osd.h +++ b/source/gx/osd.h @@ -22,6 +22,11 @@ #include "config.h" #define DEFAULT_PATH "/genplus" +#ifdef HW_RVL +#define VERSION "v1.3.2 (WII)" +#else +#define VERSION "v1.3.2 (GCN)" +#endif /* globals */ extern void error(char *format, ...);