Conflicts:
	libretro/libretro.c
This commit is contained in:
twinaphex 2014-07-18 02:13:53 +02:00
commit d3697fee7c
21 changed files with 276 additions and 171 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 MiB

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

View File

@ -292,14 +292,6 @@ void md_cart_init(void)
while (cart.romsize > size) while (cart.romsize > size)
size <<= 1; size <<= 1;
/* total ROM size is not a factor of 2 */
/* TODO: handle all possible ROM configurations using cartridge database */
if ((size < MAXROMSIZE) && (cart.romsize < size))
{
/* ROM is padded up to 2^k bytes */
memset(cart.rom + cart.romsize, 0xff, size - cart.romsize);
}
/* Sonic & Knuckles */ /* Sonic & Knuckles */
if (strstr(rominfo.international,"SONIC & KNUCKLES")) if (strstr(rominfo.international,"SONIC & KNUCKLES"))
{ {
@ -307,6 +299,22 @@ void md_cart_init(void)
size = 0x400000; size = 0x400000;
} }
/* total ROM size is not a factor of 2 */
/* TODO: handle all possible ROM configurations using cartridge database */
if (cart.romsize < size)
{
if (size < MAXROMSIZE)
{
/* ROM is padded up to 2^k bytes */
memset(cart.rom + cart.romsize, 0xff, size - cart.romsize);
}
else
{
/* ROM is padded up to max ROM size */
memset(cart.rom + cart.romsize, 0xff, MAXROMSIZE - cart.romsize);
}
}
/* ROM is mirrored each 2^k bytes */ /* ROM is mirrored each 2^k bytes */
cart.mask = size - 1; cart.mask = size - 1;

View File

@ -255,8 +255,8 @@ static const rominfo_t game_list[] =
{0x41C948BF, 0, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Sports Pad Soccer */ {0x41C948BF, 0, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Sports Pad Soccer */
/* games requiring homemade multitap */ /* games requiring homemade multitap */
{0xFAB6F52F, 0, 0, SYSTEM_MS4PLAY, MAPPER_NONE, SYSTEM_SMS2, REGION_USA}, /* BOom (v1.0) */ {0xFAB6F52F, 0, 0, SYSTEM_MASTERTAP, MAPPER_NONE, SYSTEM_SMS2, REGION_USA}, /* BOom (v1.0) */
{0x143AB50B, 0, 0, SYSTEM_MS4PLAY, MAPPER_NONE, SYSTEM_SMS2, REGION_USA}, /* BOom (v1.1) */ {0x143AB50B, 0, 0, SYSTEM_MASTERTAP, MAPPER_NONE, SYSTEM_SMS2, REGION_USA}, /* BOom (v1.1) */
/* games supporting YM2413 FM */ /* games supporting YM2413 FM */
{0x1C951F8E, 0, 1, SYSTEM_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* After Burner */ {0x1C951F8E, 0, 1, SYSTEM_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* After Burner */

View File

@ -253,17 +253,17 @@ void jcart_write(unsigned int address, unsigned int data)
/* Master System multitap ports handler (original design by Furrtek) */ /* Master System multitap ports handler (original design by Furrtek) */
/* cf. http://www.smspower.org/uploads/Homebrew/BOoM-SMS-sms4p_2.png */ /* cf. http://www.smspower.org/uploads/Homebrew/BOoM-SMS-sms4p_2.png */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
unsigned char ms4play_1_read(void) unsigned char mastertap_1_read(void)
{ {
return gamepad_read(flipflop[0].Counter); return gamepad_read(flipflop[0].Counter);
} }
unsigned char ms4play_2_read(void) unsigned char mastertap_2_read(void)
{ {
return gamepad_read(flipflop[1].Counter + 4); return gamepad_read(flipflop[1].Counter + 4);
} }
void ms4play_1_write(unsigned char data, unsigned char mask) void mastertap_1_write(unsigned char data, unsigned char mask)
{ {
/* update bits set as output only */ /* update bits set as output only */
data = (flipflop[0].Latch & ~mask) | (data & mask); data = (flipflop[0].Latch & ~mask) | (data & mask);
@ -278,7 +278,7 @@ void ms4play_1_write(unsigned char data, unsigned char mask)
flipflop[0].Latch = data; flipflop[0].Latch = data;
} }
void ms4play_2_write(unsigned char data, unsigned char mask) void mastertap_2_write(unsigned char data, unsigned char mask)
{ {
/* update bits set as output only */ /* update bits set as output only */
data = (flipflop[1].Latch & ~mask) | (data & mask); data = (flipflop[1].Latch & ~mask) | (data & mask);

View File

@ -53,9 +53,9 @@ extern void wayplay_1_write(unsigned char data, unsigned char mask);
extern void wayplay_2_write(unsigned char data, unsigned char mask); extern void wayplay_2_write(unsigned char data, unsigned char mask);
extern unsigned int jcart_read(unsigned int address); extern unsigned int jcart_read(unsigned int address);
extern void jcart_write(unsigned int address, unsigned int data); extern void jcart_write(unsigned int address, unsigned int data);
extern unsigned char ms4play_1_read(void); extern unsigned char mastertap_1_read(void);
extern unsigned char ms4play_2_read(void); extern unsigned char mastertap_2_read(void);
extern void ms4play_1_write(unsigned char data, unsigned char mask); extern void mastertap_1_write(unsigned char data, unsigned char mask);
extern void ms4play_2_write(unsigned char data, unsigned char mask); extern void mastertap_2_write(unsigned char data, unsigned char mask);
#endif #endif

View File

@ -170,7 +170,7 @@ void input_init(void)
break; break;
} }
case SYSTEM_MS4PLAY: case SYSTEM_MASTERTAP:
{ {
for (i=0; i<4; i++) for (i=0; i<4; i++)
{ {
@ -289,7 +289,7 @@ void input_init(void)
break; break;
} }
case SYSTEM_MS4PLAY: case SYSTEM_MASTERTAP:
{ {
for (i=4; i<8; i++) for (i=4; i<8; i++)
{ {

View File

@ -54,7 +54,7 @@
#define SYSTEM_LIGHTPHASER (7) /* Sega Light Phaser (Master System) */ #define SYSTEM_LIGHTPHASER (7) /* Sega Light Phaser (Master System) */
#define SYSTEM_PADDLE (8) /* Sega Paddle Control (Master System) */ #define SYSTEM_PADDLE (8) /* Sega Paddle Control (Master System) */
#define SYSTEM_SPORTSPAD (9) /* Sega Sports Pad (Master System) */ #define SYSTEM_SPORTSPAD (9) /* Sega Sports Pad (Master System) */
#define SYSTEM_MS4PLAY (10) /* Multi Tap -- Master System homemade */ #define SYSTEM_MASTERTAP (10) /* Multi Tap -- Master System homemade */
#define SYSTEM_TEAMPLAYER (11) /* Multi Tap -- Sega TeamPlayer */ #define SYSTEM_TEAMPLAYER (11) /* Multi Tap -- Sega TeamPlayer */
#define SYSTEM_WAYPLAY (12) /* Multi Tap -- EA 4-Way Play (use both ports) */ #define SYSTEM_WAYPLAY (12) /* Multi Tap -- EA 4-Way Play (use both ports) */

View File

@ -122,10 +122,10 @@ void io_init(void)
break; break;
} }
case SYSTEM_MS4PLAY: case SYSTEM_MASTERTAP:
{ {
port[0].data_w = ms4play_1_write; port[0].data_w = mastertap_1_write;
port[0].data_r = ms4play_1_read; port[0].data_r = mastertap_1_read;
break; break;
} }
@ -216,10 +216,10 @@ void io_init(void)
break; break;
} }
case SYSTEM_MS4PLAY: case SYSTEM_MASTERTAP:
{ {
port[1].data_w = ms4play_2_write; port[1].data_w = mastertap_2_write;
port[1].data_r = ms4play_2_read; port[1].data_r = mastertap_2_read;
break; break;
} }

View File

@ -3812,8 +3812,13 @@ void parse_satb_m5(int line)
do do
{ {
/* Read Y position & size from internal SAT */ /* Read Y position from internal SAT cache */
ypos = (q[link] >> im2_flag) & 0x1FF; ypos = (q[link] >> im2_flag) & 0x1FF;
/* Check if sprite Y position has been reached */
if (line >= ypos)
{
/* Read sprite size from internal SAT cache */
size = q[link + 1] >> 8; size = q[link + 1] >> 8;
/* Sprite height */ /* Sprite height */
@ -3822,8 +3827,8 @@ void parse_satb_m5(int line)
/* Y range */ /* Y range */
ypos = line - ypos; ypos = line - ypos;
/* Sprite is visble on this line ? */ /* Check if sprite is visible on current line */
if ((ypos >= 0) && (ypos < height)) if (ypos < height)
{ {
/* Sprite overflow */ /* Sprite overflow */
if (count == max) if (count == max)
@ -3844,12 +3849,13 @@ void parse_satb_m5(int line)
/* Next sprite entry */ /* Next sprite entry */
object_info++; object_info++;
} }
}
/* Read link data from internal SAT */ /* Read link data from internal SAT cache */
link = (q[link + 1] & 0x7F) << 2; link = (q[link + 1] & 0x7F) << 2;
/* Last sprite */ /* Stop parsing if link data points to first entry (#0) or after the last entry (#64 in H32 mode, #80 in H40 mode) */
if (link == 0) break; if ((link == 0) || (link >= bitmap.viewport.w)) break;
} }
while (--total); while (--total);

View File

@ -3,7 +3,7 @@
* *
* Cheats menu * Cheats menu
* *
* Copyright Eke-Eke (2010-2012) * Copyright Eke-Eke (2010-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -46,7 +46,7 @@
#define BG_COLOR_1 {0x49,0x49,0x49,0xff} #define BG_COLOR_1 {0x49,0x49,0x49,0xff}
#define BG_COLOR_2 {0x66,0x66,0x66,0xff} #define BG_COLOR_2 {0x66,0x66,0x66,0xff}
#define MAX_CHEATS (150) #define MAX_CHEATS (350)
#define MAX_DESC_LENGTH (63) #define MAX_DESC_LENGTH (63)
#ifdef HW_RVL #ifdef HW_RVL
@ -853,25 +853,34 @@ void CheatMenu(void)
while (update != -1) while (update != -1)
{ {
/* update arrows buttons */ /* update arrows buttons */
if (offset > 0) m->arrows[0]->state |= BUTTON_VISIBLE; if (offset > 0)
else m->arrows[0]->state &= ~BUTTON_VISIBLE; m->arrows[0]->state |= BUTTON_VISIBLE;
if ((offset + 10) < (maxcheats + 1)) m->arrows[1]->state |= BUTTON_VISIBLE; else
else m->arrows[1]->state &= ~BUTTON_VISIBLE; m->arrows[0]->state &= ~BUTTON_VISIBLE;
if (((offset + 10) < (maxcheats + 1)) && ((offset + 10) < MAX_CHEATS))
m->arrows[1]->state |= BUTTON_VISIBLE;
else
m->arrows[1]->state &= ~BUTTON_VISIBLE;
/* draw menu */ /* draw menu */
GUI_DrawMenu(m); GUI_DrawMenu(m);
/* restore cheats offset */ /* check if browsing cheats list */
if (!(menu_cheats.bg_images[6].state & IMAGE_VISIBLE)) if (!(m->bg_images[6].state & IMAGE_VISIBLE))
{ {
/* restore cheats list offset */
m->offset = offset; m->offset = offset;
m->max_items = maxcheats + 1; m->max_items = (maxcheats < MAX_CHEATS) ? (maxcheats + 1) : MAX_CHEATS;
m->max_buttons = 10; m->max_buttons = 10;
m->helpers[1] = NULL;
} }
/* update menu */ /* update menu */
update = GUI_UpdateMenu(m); update = GUI_UpdateMenu(m);
/* check if browsing cheats list */
if (!(m->bg_images[6].state & IMAGE_VISIBLE))
{
/* update selected cheat */ /* update selected cheat */
if ((m->selected < 10) && (selection != m->selected)) if ((m->selected < 10) && (selection != m->selected))
{ {
@ -879,12 +888,17 @@ void CheatMenu(void)
string_offset = 0; string_offset = 0;
} }
/* save offset then restore default */ /* save cheats list offset */
if (!(m->bg_images[6].state & IMAGE_VISIBLE)) if (offset != m->offset)
{ {
offset = m->offset; offset = m->offset;
string_offset = 0;
}
/* restore default GUI settings */
m->offset = 0; m->offset = 0;
m->max_items = m->max_buttons = 30; m->max_items = m->max_buttons = 30;
m->helpers[1] = &action_select;
} }
@ -1193,6 +1207,8 @@ void CheatMenu(void)
{ {
/* Special inputs */ /* Special inputs */
if (m_input.keys & PAD_TRIGGER_R) if (m_input.keys & PAD_TRIGGER_R)
{
if (GUI_WaitConfirm("Warning","Delete Cheat Entry ?"))
{ {
/* sort cheat list */ /* sort cheat list */
for (i = offset + selection + 1; i < maxcheats; i++) for (i = offset + selection + 1; i < maxcheats; i++)
@ -1224,6 +1240,7 @@ void CheatMenu(void)
/* reset scrolling */ /* reset scrolling */
string_offset = 0; string_offset = 0;
} }
}
else if (m_input.keys & PAD_TRIGGER_L) else if (m_input.keys & PAD_TRIGGER_L)
{ {
/* cheat ON/OFF */ /* cheat ON/OFF */

View File

@ -3,7 +3,7 @@
* *
* Cheats menu * Cheats menu
* *
* Copyright Eke-Eke (2010-2012) * Copyright Eke-Eke (2010-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -1770,9 +1770,18 @@ static void *MsgBox_Thread(gui_message *message_box)
/* draw exit message */ /* draw exit message */
if (message_box->buttonA) if (message_box->buttonA)
{ {
FONT_writeCenter("Press to continue.",18,166,166+message_box->window->width,248+22,(GXColor)WHITE); if (message_box->buttonB)
{
FONT_writeCenter(" Confirm Cancel ",18,166,166+message_box->window->width,248+18+8,(GXColor)WHITE);
gxDrawTexture(message_box->buttonA, 166+56, 248+8+(18-message_box->buttonA->height)/2,message_box->buttonA->width, message_box->buttonA->height,255);
gxDrawTexture(message_box->buttonB, 166+166, 248+8+(18-message_box->buttonB->height)/2,message_box->buttonB->width, message_box->buttonB->height,255);
}
else
{
FONT_writeCenter("Press to continue.",18,166,166+message_box->window->width,248+18+4,(GXColor)WHITE);
gxDrawTexture(message_box->buttonA, 166+116, 248+4+(18-message_box->buttonA->height)/2,message_box->buttonA->width, message_box->buttonA->height,255); gxDrawTexture(message_box->buttonA, 166+116, 248+4+(18-message_box->buttonA->height)/2,message_box->buttonA->width, message_box->buttonA->height,255);
} }
}
/* update display */ /* update display */
gxSetScreen(); gxSetScreen();
@ -1936,6 +1945,7 @@ void GUI_MsgBoxClose(void)
gxTextureClose(&message_box.window); gxTextureClose(&message_box.window);
gxTextureClose(&message_box.top); gxTextureClose(&message_box.top);
gxTextureClose(&message_box.buttonA); gxTextureClose(&message_box.buttonA);
gxTextureClose(&message_box.buttonB);
gxTextureClose(&message_box.throbber); gxTextureClose(&message_box.throbber);
} }
} }
@ -1964,6 +1974,32 @@ void GUI_WaitPrompt(char *title, char *msg)
GUI_MsgBoxClose(); GUI_MsgBoxClose();
} }
int GUI_WaitConfirm(char *title, char *msg)
{
/* clear unused texture */
gxTextureClose(&message_box.throbber);
/* open or update message box */
GUI_MsgBoxOpen(title, msg, 0);
/* allocate texture */
message_box.buttonA = gxTextureOpenPNG(Key_A_png,0);
message_box.buttonB = gxTextureOpenPNG(Key_B_png,0);
/* wait for button A or Button B*/
while (m_input.keys & (PAD_BUTTON_A | PAD_BUTTON_B))
VIDEO_WaitVSync();
while (!(m_input.keys & (PAD_BUTTON_A | PAD_BUTTON_B)))
VIDEO_WaitVSync();
int ret = m_input.keys & PAD_BUTTON_A;
/* always close message box */
GUI_MsgBoxClose();
return ret;
}
/* Basic Fading */ /* Basic Fading */
void GUI_FadeOut() void GUI_FadeOut()
{ {

View File

@ -120,11 +120,11 @@ typedef struct
typedef struct typedef struct
{ {
char title[64]; /* menu title */ char title[64]; /* menu title */
s8 selected; /* index of selected item */ int selected; /* index of selected item */
s8 offset; /* items list offset */ int offset; /* items list offset */
u8 max_items; /* total number of items */ int max_items; /* total number of items */
u8 max_buttons; /* total number of buttons */ int max_buttons; /* total number of buttons */
u8 max_images; /* total number of background images */ int max_images; /* total number of background images */
u8 screenshot; /* game screen background */ u8 screenshot; /* game screen background */
gui_item *items; /* menu items */ gui_item *items; /* menu items */
gui_butn *buttons; /* menu buttons */ gui_butn *buttons; /* menu buttons */
@ -144,6 +144,7 @@ typedef struct
gx_texture *window; /* pointer to box texture */ gx_texture *window; /* pointer to box texture */
gx_texture *top; /* pointer to box title texture */ gx_texture *top; /* pointer to box title texture */
gx_texture *buttonA; /* pointer to button A texture */ gx_texture *buttonA; /* pointer to button A texture */
gx_texture *buttonB; /* pointer to button A texture */
gx_texture *throbber; /* pointer to throbber texture */ gx_texture *throbber; /* pointer to throbber texture */
} gui_message; } gui_message;
@ -238,6 +239,7 @@ extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
extern void GUI_MsgBoxUpdate(char *title, char *msg); extern void GUI_MsgBoxUpdate(char *title, char *msg);
extern void GUI_MsgBoxClose(void); extern void GUI_MsgBoxClose(void);
extern void GUI_WaitPrompt(char *title, char *msg); extern void GUI_WaitPrompt(char *title, char *msg);
extern int GUI_WaitConfirm(char *title, char *msg);
extern void GUI_FadeOut(); extern void GUI_FadeOut();
extern GXColor *GUI_GetBgColor(void); extern GXColor *GUI_GetBgColor(void);
extern void GUI_SetBgColor(u8 color); extern void GUI_SetBgColor(u8 color);

View File

@ -108,7 +108,7 @@ extern const u8 Ctrl_paddle_png[];
extern const u8 Ctrl_sportspad_png[]; extern const u8 Ctrl_sportspad_png[];
extern const u8 Ctrl_none_png[]; extern const u8 Ctrl_none_png[];
extern const u8 Ctrl_teamplayer_png[]; extern const u8 Ctrl_teamplayer_png[];
extern const u8 Ctrl_ms4play_png[]; extern const u8 Ctrl_mastertap_png[];
extern const u8 Ctrl_pad_auto_png[]; extern const u8 Ctrl_pad_auto_png[];
extern const u8 Ctrl_pad2b_png[]; extern const u8 Ctrl_pad2b_png[];
extern const u8 Ctrl_pad3b_png[]; extern const u8 Ctrl_pad3b_png[];
@ -2062,7 +2062,7 @@ static void ctrlmenu(void)
{NULL,Ctrl_lightphaser_png,"","Select Port 1 device", 89,109,88,92}, {NULL,Ctrl_lightphaser_png,"","Select Port 1 device", 89,109,88,92},
{NULL,Ctrl_paddle_png ,"","Select Port 1 device", 86,117,96,84}, {NULL,Ctrl_paddle_png ,"","Select Port 1 device", 86,117,96,84},
{NULL,Ctrl_sportspad_png ,"","Select Port 1 device", 95,117,76,84}, {NULL,Ctrl_sportspad_png ,"","Select Port 1 device", 95,117,76,84},
{NULL,Ctrl_ms4play_png ,"","Select Port 1 device", 94,100,80,100}, {NULL,Ctrl_mastertap_png ,"","Select Port 1 device", 96,104,76,96},
{NULL,Ctrl_teamplayer_png ,"","Select Port 1 device", 94,109,80,92}, {NULL,Ctrl_teamplayer_png ,"","Select Port 1 device", 94,109,80,92},
{NULL,Ctrl_4wayplay_png ,"","Select Port 1 device", 98,110,72,92} {NULL,Ctrl_4wayplay_png ,"","Select Port 1 device", 98,110,72,92}
}, },
@ -2077,7 +2077,7 @@ static void ctrlmenu(void)
{NULL,Ctrl_lightphaser_png,"","Select Port 2 device", 89,279,88,92}, {NULL,Ctrl_lightphaser_png,"","Select Port 2 device", 89,279,88,92},
{NULL,Ctrl_paddle_png ,"","Select Port 2 device", 86,287,96,84}, {NULL,Ctrl_paddle_png ,"","Select Port 2 device", 86,287,96,84},
{NULL,Ctrl_sportspad_png ,"","Select Port 2 device", 95,287,76,84}, {NULL,Ctrl_sportspad_png ,"","Select Port 2 device", 95,287,76,84},
{NULL,Ctrl_ms4play_png ,"","Select Port 1 device", 94,270,80,100}, {NULL,Ctrl_mastertap_png ,"","Select Port 1 device", 96,274,76,96},
{NULL,Ctrl_teamplayer_png ,"","Select Port 2 device", 94,279,80,92}, {NULL,Ctrl_teamplayer_png ,"","Select Port 2 device", 94,279,80,92},
{NULL,Ctrl_4wayplay_png ,"","Select Port 2 device", 98,280,72,92} {NULL,Ctrl_4wayplay_png ,"","Select Port 2 device", 98,280,72,92}
} }
@ -2438,7 +2438,7 @@ static void ctrlmenu(void)
case DEVICE_PAD3B: case DEVICE_PAD3B:
case DEVICE_PAD6B: case DEVICE_PAD6B:
{ {
if (input.system[index/4] == SYSTEM_MS4PLAY) if (input.system[index/4] == SYSTEM_MASTERTAP)
{ {
/* force 2-buttons pad */ /* force 2-buttons pad */
items = items_special[3]; items = items_special[3];
@ -3138,16 +3138,20 @@ static int savemenu(void)
case 7: /* delete file */ case 7: /* delete file */
{ {
if (slots[slot].valid) if (slots[slot].valid)
{
if (GUI_WaitConfirm("Warning","Delete Save File ?"))
{ {
if (slot_delete(slot,config.s_device) >= 0) if (slot_delete(slot,config.s_device) >= 0)
{ {
/* hide screenshot */ /* hide screenshot */
gxTextureClose(&bg_saves[0].texture); gxTextureClose(&bg_saves[0].texture);
bg_saves[0].state &= ~IMAGE_VISIBLE; bg_saves[0].state &= ~IMAGE_VISIBLE;
bg_saves[1].state |= IMAGE_VISIBLE;
slots[slot].valid = 0; slots[slot].valid = 0;
update = -1; update = -1;
} }
} }
}
break; break;
} }

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * Genesis Plus GX input support
* *
* Copyright Eke-Eke (2007-2013) * Copyright Eke-Eke (2007-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -490,23 +490,29 @@ static int wpad_StickX(WPADData *data, u8 right)
if (js) if (js)
{ {
/* raw X value */ /* raw X position */
int x = js->pos.x; int pos = js->pos.x;
/* value returned is sometime above calibrated limits */ /* X range calibration */
if (x > js->max.x) return 127; int min = js->min.x;
if (x < js->min.x) return -128; int max = js->max.x;
int center = js->center.x;
/* value returned could be above calibration limits */
if (pos > max) return 127;
if (pos < min) return -128;
/* adjust against center position */ /* adjust against center position */
x -= js->center.x; pos -= center;
/* return interpolated range [-128;127] */ /* return interpolated range [-128;127] */
if (x > 0) if (pos > 0)
{ {
return (int)(127.0 * ((float)x / (float)(js->max.x - js->center.x))); return (int)(127.0 * ((float)pos / (float)(max - center)));
} }
else
{ {
return (int)(128.0 * ((float)x / (float)(js->center.x - js->min.x))); return (int)(128.0 * ((float)pos / (float)(center - min)));
} }
} }
@ -533,23 +539,29 @@ static int wpad_StickY(WPADData *data, u8 right)
if (js) if (js)
{ {
/* raw Y value */ /* raw Y position */
int y = js->pos.y; int pos = js->pos.y;
/* value returned is sometime above calibrated limits */ /* Y range calibration */
if (y > js->max.y) return 127; int min = js->min.y;
if (y < js->min.y) return -128; int max = js->max.y;
int center = js->center.y;
/* value returned could be above calibration limits */
if (pos > max) return 127;
if (pos < min) return -128;
/* adjust against center position */ /* adjust against center position */
y -= js->center.y; pos -= center;
/* return interpolated range [-128;127] */ /* return interpolated range [-128;127] */
if (y > 0) if (pos > 0)
{ {
return (int)(127.0 * ((float)y / (float)(js->max.y - js->center.y))); return (int)(127.0 * ((float)pos / (float)(max - center)));
} }
else
{ {
return (int)(128.0 * ((float)y / (float)(js->center.y - js->min.y))); return (int)(128.0 * ((float)pos / (float)(center - min)));
} }
} }
@ -1113,6 +1125,39 @@ int gx_input_FindDevices(void)
if (wpad == (config.input[player].device - 1)) if (wpad == (config.input[player].device - 1))
{ {
found++; found++;
/* some 3rd party classic controllers return invalid factory calibration data */
if (wpad == EXP_CLASSIC)
{
/* WPAD data */
WPADData *data = WPAD_Data(config.input[player].port);
/* Left analog stick */
struct joystick_t* js = &data->exp.classic.ljs;
/* Check acquired calibration data */
if ((js->max.x <= js->center.x) || (js->min.x >= js->center.x) ||
(js->max.y <= js->center.y) || (js->min.y >= js->center.y))
{
/* Reset to default values */
js->min.x = js->min.y = 0;
js->max.x = js->max.y = 64;
js->center.x = js->center.y = 32;
}
/* Right analog stick */
js = &data->exp.classic.rjs;
/* Check acquired calibration data */
if ((js->max.x <= js->center.x) || (js->min.x >= js->center.x) ||
(js->max.y <= js->center.y) || (js->min.y >= js->center.y))
{
/* Reset to default values */
js->min.x = js->min.y = 0;
js->max.x = js->max.y = 32;
js->center.x = js->center.y = 16;
}
}
} }
break; break;
} }
@ -1528,44 +1573,31 @@ void gx_input_UpdateMenu(void)
} }
#ifdef HW_RVL #ifdef HW_RVL
/* Wiimote direction keys */ /* Wiimote & Classic Controller direction keys */
WPAD_IR(0, &m_input.ir); WPAD_IR(0, &m_input.ir);
if (m_input.ir.valid) if (m_input.ir.valid)
{ {
/* Wiimote is handled vertically */ /* Wiimote is handled vertically */
if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_UP; if (pw & (WPAD_BUTTON_UP|WPAD_CLASSIC_BUTTON_UP)) pp |= PAD_BUTTON_UP;
else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; else if (pw & (WPAD_BUTTON_DOWN|WPAD_CLASSIC_BUTTON_DOWN)) pp |= PAD_BUTTON_DOWN;
else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; else if (pw & (WPAD_BUTTON_LEFT|WPAD_CLASSIC_BUTTON_LEFT)) pp |= PAD_BUTTON_LEFT;
else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; else if (pw & (WPAD_BUTTON_RIGHT|WPAD_CLASSIC_BUTTON_RIGHT)) pp |= PAD_BUTTON_RIGHT;
} }
else else
{ {
/* Wiimote is handled horizontally */ /* Wiimote is handled horizontally */
if (pw & WPAD_BUTTON_UP) pp |= PAD_BUTTON_LEFT; if (pw & (WPAD_BUTTON_UP|WPAD_CLASSIC_BUTTON_LEFT)) pp |= PAD_BUTTON_LEFT;
else if (pw & WPAD_BUTTON_DOWN) pp |= PAD_BUTTON_RIGHT; else if (pw & (WPAD_BUTTON_DOWN|WPAD_CLASSIC_BUTTON_RIGHT)) pp |= PAD_BUTTON_RIGHT;
else if (pw & WPAD_BUTTON_LEFT) pp |= PAD_BUTTON_DOWN; else if (pw & (WPAD_BUTTON_LEFT|WPAD_CLASSIC_BUTTON_DOWN)) pp |= PAD_BUTTON_DOWN;
else if (pw & WPAD_BUTTON_RIGHT) pp |= PAD_BUTTON_UP; else if (pw & (WPAD_BUTTON_RIGHT|WPAD_CLASSIC_BUTTON_UP)) pp |= PAD_BUTTON_UP;
} }
/* Classic Controller direction keys */ /* WPAD button keys */
if (pw & WPAD_CLASSIC_BUTTON_UP) pp |= PAD_BUTTON_UP; if (pw & (WPAD_BUTTON_2|WPAD_BUTTON_A|WPAD_CLASSIC_BUTTON_A)) pp |= PAD_BUTTON_A;
else if (pw & WPAD_CLASSIC_BUTTON_DOWN) pp |= PAD_BUTTON_DOWN; if (pw & (WPAD_BUTTON_1|WPAD_BUTTON_B|WPAD_CLASSIC_BUTTON_B)) pp |= PAD_BUTTON_B;
else if (pw & WPAD_CLASSIC_BUTTON_LEFT) pp |= PAD_BUTTON_LEFT; if (pw & (WPAD_BUTTON_HOME|WPAD_CLASSIC_BUTTON_HOME)) pp |= PAD_TRIGGER_Z;
else if (pw & WPAD_CLASSIC_BUTTON_RIGHT) pp |= PAD_BUTTON_RIGHT; if (pw & (WPAD_BUTTON_PLUS|WPAD_CLASSIC_BUTTON_PLUS|WPAD_CLASSIC_BUTTON_FULL_L)) pp |= PAD_TRIGGER_L;
if (pw & (WPAD_BUTTON_MINUS|WPAD_CLASSIC_BUTTON_MINUS|WPAD_CLASSIC_BUTTON_FULL_L)) pp |= PAD_TRIGGER_R;
/* WPAD buttons */
if (pw & WPAD_BUTTON_A) pp |= PAD_BUTTON_A;
if (pw & WPAD_BUTTON_B) pp |= PAD_BUTTON_B;
if (pw & WPAD_BUTTON_2) pp |= PAD_BUTTON_A;
if (pw & WPAD_BUTTON_1) pp |= PAD_BUTTON_B;
if (pw & WPAD_BUTTON_HOME) pp |= PAD_TRIGGER_Z;
if (pw & WPAD_BUTTON_PLUS) pp |= PAD_TRIGGER_L;
if (pw & WPAD_BUTTON_MINUS) pp |= PAD_TRIGGER_R;
if (pw & WPAD_CLASSIC_BUTTON_FULL_L) pp |= PAD_TRIGGER_L;
if (pw & WPAD_CLASSIC_BUTTON_FULL_R) pp |= PAD_TRIGGER_R;
if (pw & WPAD_CLASSIC_BUTTON_A) pp |= PAD_BUTTON_A;
if (pw & WPAD_CLASSIC_BUTTON_B) pp |= PAD_BUTTON_B;
if (pw & WPAD_CLASSIC_BUTTON_HOME) pp |= PAD_TRIGGER_Z;
#endif #endif
/* Update menu inputs */ /* Update menu inputs */

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * Genesis Plus GX input support
* *
* Copyright Eke-Eke (2007-2013) * Copyright Eke-Eke (2007-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -667,8 +667,8 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y)
int ywidth = square[3] - square[7]; int ywidth = square[3] - square[7];
/* adjust texture coordinates to EFB */ /* adjust texture coordinates to EFB */
x = (((x + bitmap.viewport.x) * xwidth) / vwidth) + square[6] - w/2; x = (((x + bitmap.viewport.x) * xwidth) / (bitmap.viewport.w+2*bitmap.viewport.x)) + square[6] - w/2;
y = (((y + bitmap.viewport.y) * ywidth) / vheight) + square[7] - h/2; y = (((y + bitmap.viewport.y) * ywidth) / (bitmap.viewport.h+2*bitmap.viewport.y)) + square[7] - h/2;
/* load texture object */ /* load texture object */
GXTexObj texObj; GXTexObj texObj;

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB