Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.

Also, rumble and wii-control code has been cleaned up a bit.
This commit is contained in:
Carl.Kenner 2009-03-20 20:22:22 +00:00
parent 5a653343ff
commit f4715d3c26
16 changed files with 185 additions and 443 deletions

View File

@ -327,6 +327,7 @@ int FileSelector (int method)
ShowFiles (browserList, browser.numEntries, browser.pageIndex, browser.selIndex);
redraw = 0;
updateRumbleFrame();
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
gc_ay = PAD_StickY (0);
@ -441,8 +442,10 @@ int FileSelector (int method)
#ifdef HW_RVL
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
#endif
)
) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
if ( strcmp(browserList[0].filename,"..") == 0 )
{
browser.selIndex = 0;

View File

@ -31,8 +31,6 @@
#include "gba/bios.h"
#include "gba/GBAinline.h"
extern int WarioRumbleMotor;
u8 ZeldaDxLeftPos = 2, ZeldaDxRightPos = 3, ZeldaDxDownPos = 4;
u8 ZeldaDxShieldPos = 5, ZeldaDxSwordPos = 5;
@ -164,11 +162,9 @@ u32 LinksAwakeningInput(unsigned short pad)
SelItem = gbReadMemory(0xDB00 + CursorPos);
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
if (Health < OldHealth)
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -184,7 +180,8 @@ u32 LinksAwakeningInput(unsigned short pad)
{
if (!OnItemScreen)
ZeldaDxSheathSword();
else if (RumbleCount<5) RumbleCount=5;
else
systemGameRumble(5);
J |= VBA_BUTTON_A;
}
}
@ -210,7 +207,7 @@ u32 LinksAwakeningInput(unsigned short pad)
if (SwordCount>0)
{
if (SwordCount == 50)
RumbleCount = 50;
systemGameRumbleOnlyFor(50);
if (!OnItemScreen)
J |= VBA_BUTTON_A;
SwordCount--;
@ -220,7 +217,7 @@ u32 LinksAwakeningInput(unsigned short pad)
if (wp->btns_h & WPAD_BUTTON_UP)
{
J |= VBA_BUTTON_A | VBA_BUTTON_B | VBA_BUTTON_START | VBA_BUTTON_SELECT;
RumbleCount = 5;
systemGameRumbleOnlyFor(5);
QuestScreen = false;
}
@ -229,7 +226,7 @@ u32 LinksAwakeningInput(unsigned short pad)
{
if (OnItemScreen) ZeldaDxSwap(ZeldaDxLeftPos, CursorPos);
else ZeldaDxSwapBItem(ZeldaDxLeftPos);
RumbleCount = 5;
systemGameRumbleOnlyFor(5);
QuestScreen = false;
}
// Right Item
@ -237,7 +234,7 @@ u32 LinksAwakeningInput(unsigned short pad)
{
if (OnItemScreen) ZeldaDxSwap(ZeldaDxRightPos, CursorPos);
else ZeldaDxSwapBItem(ZeldaDxRightPos);
RumbleCount = 5;
systemGameRumbleOnlyFor(5);
QuestScreen = false;
}
// Down Item
@ -245,7 +242,7 @@ u32 LinksAwakeningInput(unsigned short pad)
{
if (OnItemScreen) ZeldaDxSwap(ZeldaDxDownPos, CursorPos);
else ZeldaDxSwapBItem(ZeldaDxDownPos);
RumbleCount = 5;
systemGameRumbleOnlyFor(5);
QuestScreen = false;
}
// B Item
@ -265,8 +262,8 @@ u32 LinksAwakeningInput(unsigned short pad)
BombArrows = false;
}
}*/
if (RumbleCount<5) RumbleCount=5;
DelayCount = 10;
systemGameRumble(5);
DelayCount = 10;
}
else
{
@ -346,14 +343,15 @@ u32 LinksAwakeningInput(unsigned short pad)
if (SelItem==2 || SelItem==5)
{ // toggle bomb arrows
BombArrows = !BombArrows;
RumbleCount = BombArrows?16:4;
if (BombArrows) systemGameRumbleOnlyFor(16);
else systemGameRumbleOnlyFor(4);
if (SelItem==2 && BombArrows)
J |= VBA_BUTTON_A;
}
else if (BombArrows)
{ // switch off bomb arrows
BombArrows = false;
RumbleCount = 4;
systemGameRumbleOnlyFor(4);
J |= VBA_BUTTON_A;
}
QuestScreen = false;
@ -365,19 +363,6 @@ u32 LinksAwakeningInput(unsigned short pad)
QuestScreen = false;
}
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -403,11 +388,9 @@ u32 OracleOfAgesInput(unsigned short pad)
//else if (AButtonItem>=0xD && AButtonItem<=0xE) ZTargetButton = VBA_BUTTON_A;
ZTargetButton = VBA_BUTTON_A;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -487,19 +470,6 @@ u32 OracleOfAgesInput(unsigned short pad)
if (jp & PAD_TRIGGER_L)
J |= ZTargetButton;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -555,11 +525,9 @@ u32 MinishCapInput(unsigned short pad)
else
ZTargetButton = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
int cx, cy, SelRow, SelCol, CursorRow = 0xFF, CursorCol = 0xFF;
@ -797,8 +765,7 @@ u32 MinishCapInput(unsigned short pad)
!= OldCursorCol))
{
// Cursor changed buttons, so rumble
if (RumbleCount < 5)
RumbleCount = 5;
systemGameRumble(5);
}
OldCursorRow = CursorRow;
OldCursorCol = CursorCol;
@ -957,8 +924,7 @@ u32 MinishCapInput(unsigned short pad)
if (wp->btns_h & WPAD_BUTTON_A)
{
J |= VBA_BUTTON_A;
if (RumbleCount<12)
RumbleCount=12;
systemGameRumble(12);
}
}
else if (Subscreen==0x2c)
@ -968,7 +934,6 @@ u32 MinishCapInput(unsigned short pad)
{ // Sleep button returns to menu instead of sleep
if (wp->btns_h & WPAD_BUTTON_A)
{
WPAD_Rumble(pad, 0);
ConfigRequested = 1;
return 0;
}
@ -983,7 +948,7 @@ u32 MinishCapInput(unsigned short pad)
if (fabs(wp->exp.nunchuk.gforce.y)> 0.6)
{
J |= VBA_BUTTON_R;
if (RumbleCount<5) RumbleCount=5;
systemGameRumble(5);
}
}
else if (wp->exp.type == WPAD_EXP_NUNCHUK)
@ -991,7 +956,7 @@ u32 MinishCapInput(unsigned short pad)
if (fabs(wp->exp.nunchuk.gforce.x)> 0.6)
{ // Wiiuse bug!!! Not correct values
J |= SwordButton;
if (RumbleCount<20) RumbleCount=20;
systemGameRumble(20);
}
// CAKTODO hold down attack button to do spin attack
@ -1003,7 +968,7 @@ u32 MinishCapInput(unsigned short pad)
J |= VBA_BUTTON_A;
if (Subscreen==0x2c)
{
if (RumbleCount<10) RumbleCount=10;
systemGameRumble(10);
}
}
// Down Item
@ -1017,7 +982,7 @@ u32 MinishCapInput(unsigned short pad)
J |= VBA_BUTTON_B;
if (Subscreen==0x2c)
{
if (RumbleCount<10) RumbleCount=10;
systemGameRumble(10);
}
}
}
@ -1026,7 +991,7 @@ u32 MinishCapInput(unsigned short pad)
J |= VBA_BUTTON_B;
if (Subscreen==0x2c)
{
if (RumbleCount<10) RumbleCount=10;
systemGameRumble(10);
}
}
// Kinstone (doesn't work in items screen)
@ -1078,18 +1043,6 @@ u32 MinishCapInput(unsigned short pad)
if (jp & PAD_TRIGGER_L)
J |= VBA_BUTTON_A;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1099,11 +1052,9 @@ u32 ALinkToThePastInput(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1120,7 +1071,7 @@ u32 ALinkToThePastInput(unsigned short pad)
if (fabs(wp->exp.nunchuk.gforce.x)> 0.6)
{ // Wiiuse bug!!! Not correct values
J |= VBA_BUTTON_B;
if (RumbleCount<20) RumbleCount=20;
systemGameRumble(20);
}
// CAKTODO hold down attack button to do spin attack
@ -1161,19 +1112,6 @@ u32 ALinkToThePastInput(unsigned short pad)
if ((wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & WPAD_NUNCHUK_BUTTON_C))
J |= VBA_SPEED;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else
WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1183,11 +1121,9 @@ u32 Zelda1Input(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1204,7 +1140,7 @@ u32 Zelda1Input(unsigned short pad)
if (fabs(wp->exp.nunchuk.gforce.x)> 0.6)
{ // Wiiuse bug!!! Not correct values
J |= VBA_BUTTON_A;
if (RumbleCount<20) RumbleCount=20;
systemGameRumble(20);
}
}
// Use item
@ -1241,19 +1177,6 @@ u32 Zelda1Input(unsigned short pad)
if ((wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & WPAD_NUNCHUK_BUTTON_C))
J |= VBA_SPEED;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1263,11 +1186,9 @@ u32 Zelda2Input(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1285,7 +1206,7 @@ u32 Zelda2Input(unsigned short pad)
if (fabs(wp->exp.nunchuk.gforce.x)> 0.6)
{ // Wiiuse bug!!! Not correct values
J |= VBA_BUTTON_B;
if (RumbleCount<20) RumbleCount=20;
systemGameRumble(20);
}
}
// Use item
@ -1324,18 +1245,6 @@ u32 Zelda2Input(unsigned short pad)
if ((wp->exp.type == WPAD_EXP_NUNCHUK) && (wp->btns_h & WPAD_NUNCHUK_BUTTON_C))
J |= VBA_SPEED;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1346,11 +1255,9 @@ u32 MK1Input(unsigned short pad)
u8 Health = gbReadMemory(0xc695);
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 5)
RumbleCount = 5;
systemGameRumble(5);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1379,19 +1286,6 @@ u32 MK1Input(unsigned short pad)
// CAKTODO
}
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1401,11 +1295,9 @@ u32 MK4Input(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1434,19 +1326,6 @@ u32 MK4Input(unsigned short pad)
// CAKTODO
}
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1456,11 +1335,9 @@ u32 MKAInput(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1489,19 +1366,6 @@ u32 MKAInput(unsigned short pad)
// CAKTODO
}
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else
WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1524,11 +1388,9 @@ u32 MKTEInput(unsigned short pad)
}
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
u32 Forwards, Back;
@ -1588,14 +1450,6 @@ u32 MKTEInput(unsigned short pad)
J |= VBA_SPEED;
}
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else
WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
@ -1617,11 +1471,9 @@ u32 MarioKartInput(unsigned short pad)
static u8 OldHealth = 0;
float fraction;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
// Start/Select
@ -1727,19 +1579,6 @@ u32 MarioKartInput(unsigned short pad)
|| jp & PAD_BUTTON_RIGHT)
J |= VBA_BUTTON_R;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
frame++;
return J;
@ -1752,11 +1591,9 @@ u32 LegoStarWars1Input(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1802,20 +1639,6 @@ u32 LegoStarWars1Input(unsigned short pad)
// CAKTODO same as game boy for now
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1825,11 +1648,9 @@ u32 LegoStarWars2Input(unsigned short pad)
u8 Health = 0;
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
WPADData * wp = WPAD_Data(pad);
@ -1878,20 +1699,6 @@ u32 LegoStarWars2Input(unsigned short pad)
// CAKTODO same as game boy for now
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else
WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -1903,11 +1710,9 @@ u32 MetroidZeroInput(unsigned short pad)
u16 Health = CPUReadByte(0x3001536); // 0 = stand, 1 = crouch, 2 = ball
static u16 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
static int Morph = 0;
@ -2110,18 +1915,6 @@ u32 MetroidZeroInput(unsigned short pad)
if (jp & PAD_BUTTON_START)
J |= VBA_BUTTON_START;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2133,11 +1926,9 @@ u32 MetroidFusionInput(unsigned short pad)
u16 Health = CPUReadHalfWord(0x3001310);
static u16 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
static int Morph = 0;
@ -2328,18 +2119,6 @@ u32 MetroidFusionInput(unsigned short pad)
if (jp & PAD_BUTTON_START)
J |= VBA_BUTTON_START;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2352,11 +2131,9 @@ u32 Metroid1Input(unsigned short pad)
u16 Health = CPUReadHalfWord(0x3007306); // Binary Coded Decimal
static u16 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose health!
if (Health < OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
static int Morph = 0;
@ -2469,18 +2246,6 @@ u32 Metroid1Input(unsigned short pad)
if (jp & PAD_BUTTON_START)
J |= VBA_BUTTON_START;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2493,11 +2258,9 @@ u32 Metroid2Input(unsigned short pad)
u8 Health = gbReadMemory(0xD051); // Binary Coded Decimal
static u8 OldHealth = 0;
static int RumbleCount = 0;
// Rumble when they lose (or gain) health! (since I'm not checking energy tanks)
if (Health != OldHealth)
if (RumbleCount < 20)
RumbleCount = 20;
systemGameRumble(20);
OldHealth = Health;
static int Morph = 0;
@ -2636,18 +2399,6 @@ u32 Metroid2Input(unsigned short pad)
if (jp & PAD_BUTTON_START)
J |= VBA_BUTTON_START;
if (RumbleCount>0)
{
WPAD_Rumble(pad, 1);
RumbleCount--;
}
else WPAD_Rumble(pad, 0);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2686,11 +2437,6 @@ u32 TMNTInput(unsigned short pad)
J |= 0; // Double tap D-Pad to roll CAKTODO
// CAKTODO
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2733,11 +2479,6 @@ u32 HarryPotter1GBCInput(unsigned short pad)
// CAKTODO spell gestures
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2777,11 +2518,6 @@ u32 HarryPotter2GBCInput(unsigned short pad)
// CAKTODO spell gestures
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2829,11 +2565,6 @@ u32 HarryPotter1Input(unsigned short pad)
// CAKTODO spell gestures
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2883,11 +2614,6 @@ u32 HarryPotter2Input(unsigned short pad)
// CAKTODO spell gestures
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2937,11 +2663,6 @@ u32 HarryPotter3Input(unsigned short pad)
// point at ceiling for Lumos
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -2991,11 +2712,6 @@ u32 HarryPotter4Input(unsigned short pad)
// point at ceiling for Lumos
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3054,11 +2770,6 @@ u32 HarryPotter5Input(unsigned short pad)
// CAKTODO spell gestures
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3155,11 +2866,6 @@ u32 Mario1DXInput(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3245,11 +2951,6 @@ u32 Mario1ClassicInput(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3329,11 +3030,6 @@ u32 MarioLand1Input(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3439,11 +3135,6 @@ u32 MarioLand2Input(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3490,13 +3181,6 @@ u32 Mario2Input(unsigned short pad)
if (wp->btns_h & WPAD_BUTTON_2)
J |= VBA_BUTTON_R;
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3631,11 +3315,6 @@ u32 MarioWorldInput(unsigned short pad)
J |= StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3725,11 +3404,6 @@ u32 Mario3Input(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3838,11 +3512,6 @@ u32 YoshiIslandInput(unsigned short pad)
// NeedStomp = false;
//}
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3926,11 +3595,6 @@ u32 UniversalGravitationInput(unsigned short pad)
// A bit stupid playing with keyboard or gamecube pad when you need to tilt the wiimote...
J |= StandardKeyboard(pad) | StandardGamecube(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -3941,11 +3605,6 @@ u32 TwistedInput(unsigned short pad)
u32 J = StandardMovement(pad);
WPADData * wp = WPAD_Data(pad);
if (WarioRumbleMotor)
WPAD_Rumble(pad, 1);
else
WPAD_Rumble(pad, 0);
if (wp->exp.type == WPAD_EXP_NUNCHUK)
{
TiltSideways = false;
@ -3991,11 +3650,6 @@ u32 TwistedInput(unsigned short pad)
// A bit stupid playing with keyboard or gamecube pad when you need to tilt the wiimote...
J |= StandardKeyboard(pad) | StandardGamecube(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -4051,11 +3705,6 @@ u32 KirbyTntInput(unsigned short pad)
// A bit stupid playing with keyboard or gamecube pad when you need to tilt the wiimote...
J |= StandardKeyboard(pad) | StandardGamecube(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -4104,11 +3753,6 @@ u32 MohInfiltratorInput(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -4181,11 +3825,6 @@ u32 MohUndergroundInput(unsigned short pad)
if (crouched && (!(J & VBA_BUTTON_L)) && (!(J & VBA_BUTTON_R)))
J |= VBA_BUTTON_L | VBA_BUTTON_R;
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -4248,11 +3887,6 @@ u32 BoktaiInput(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
@ -4318,11 +3952,6 @@ u32 Boktai2Input(unsigned short pad)
J |= StandardGamecube(pad) | StandardKeyboard(pad);
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}

View File

@ -29,8 +29,11 @@
#include "gba/bios.h"
#include "gba/GBAinline.h"
extern bool InMenu;
int rumbleRequest[4] = {0,0,0,0};
static int rumbleCount[4] = {0,0,0,0};
bool cartridgeRumble = false;
int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
unsigned int vbapadmap[10]; // VBA controller buttons
unsigned int gcpadmap[10]; // Gamecube controller Padmap
@ -161,6 +164,57 @@ void DoRumble(int i)
}
}
static void updateRumble() {
bool r = false;
if (InMenu) r = (menuRumbleCount > 0);
else r = cartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);
#ifdef HW_RVL
// Rumble wii remote 0
WPAD_Rumble(0, r);
#endif
PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_RUMBLE);
}
void updateRumbleFrame() {
// If we already rumbled continuously for more than 50 frames,
// then disable rumbling for a while.
if (rumbleCountAlready > 50) {
gameRumbleCount = 0;
menuRumbleCount = 0;
// disable rumbling for 10 more frames
if (rumbleCountAlready > 50+10)
rumbleCountAlready = 0;
else rumbleCountAlready++;
} else if (InMenu) {
if (menuRumbleCount>0)
rumbleCountAlready++;
} else {
if (gameRumbleCount>0 || menuRumbleCount>0 || cartridgeRumble)
rumbleCountAlready++;
}
updateRumble();
if (gameRumbleCount>0 && !InMenu) gameRumbleCount--;
if (menuRumbleCount>0) menuRumbleCount--;
}
void systemCartridgeRumble(bool RumbleOn) {
cartridgeRumble = RumbleOn;
updateRumble();
}
void systemGameRumble(int RumbleForFrames) {
if (RumbleForFrames > gameRumbleCount) gameRumbleCount = RumbleForFrames;
}
void systemGameRumbleOnlyFor(int OnlyRumbleForFrames) {
gameRumbleCount = OnlyRumbleForFrames;
}
void systemMenuRumble(int RumbleForFrames) {
if (RumbleForFrames > menuRumbleCount) menuRumbleCount = RumbleForFrames;
}
/****************************************************************************
* WPAD_Stick
*
@ -617,10 +671,6 @@ static u32 DecodeJoy(unsigned short pad)
return Boktai2Input(pad);
}
}
else
{
ShutoffRumble();
}
#endif
// the function result, J, is a combination of flags for all the VBA buttons that are down
@ -659,13 +709,9 @@ static u32 DecodeJoy(unsigned short pad)
J |= vbapadmap[i];
}
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J;
}
u32 GetJoy(int pad)
{
pad = 0;
@ -699,10 +745,18 @@ u32 GetJoy(int pad)
)
{
ConfigRequested = 1;
updateRumbleFrame();
return 0;
}
else
{
return DecodeJoy(pad);
u32 J = DecodeJoy(pad);
// don't allow up+down or left+right
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
updateRumbleFrame();
return J;
}
}

View File

@ -41,6 +41,9 @@ extern unsigned int kbpadmap[];
void ResetControls();
void ShutoffRumble();
void DoRumble(int i);
void systemGameRumble(int RumbleForFrames);
void systemGameRumbleOnlyFor(int OnlyRumbleForFrames);
void updateRumbleFrame();
s8 WPAD_Stick(u8 chan,u8 right, int axis);
u32 GetJoy(int which);

View File

@ -15,6 +15,7 @@
#include <string.h>
#include <unistd.h>
#include "system.h"
#include "vba.h"
#include "video.h"
#include "menudraw.h"
@ -62,6 +63,7 @@ static int MountCard(int cslot, bool silent, u8 * SysArea)
{
EXI_ProbeReset ();
ret = CARD_Mount (cslot, &SysArea, NULL);
updateRumbleFrame ();
VIDEO_WaitVSync ();
tries++;
}

View File

@ -394,10 +394,14 @@ GetInput (u16 ctrlr_type)
| WPAD_ButtonsHeld(0)
| AnyKeyDown()
#endif
) VIDEO_WaitVSync(); // button 'debounce'
) {
updateRumbleFrame();
VIDEO_WaitVSync(); // button 'debounce'
}
while (pressed == 0 && !AnyKeyDown())
{
updateRumbleFrame();
VIDEO_WaitVSync();
// get input based on controller type
if (ctrlr_type == CTRLR_GCPAD)
@ -424,6 +428,7 @@ GetInput (u16 ctrlr_type)
for (int i=4; i<=231; i++) {
if (DownUsbKeys[i]) {
while (DownUsbKeys[i]) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
return i;
@ -434,7 +439,10 @@ GetInput (u16 ctrlr_type)
#ifdef HW_RVL
| WPAD_ButtonsHeld(0)
#endif
) ) VIDEO_WaitVSync();
) ) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
return pressed;
} // end GetInput()
@ -723,6 +731,7 @@ MainMenu (int selectedMenu)
else
sprintf (menuitems[3], "Game Menu");
updateRumbleFrame();
VIDEO_WaitVSync ();
while (quit == 0)
@ -798,6 +807,7 @@ MainMenu (int selectedMenu)
#endif
))
{
updateRumbleFrame();
VIDEO_WaitVSync();
count++;
}

View File

@ -260,6 +260,7 @@ Credits ()
DrawText (-1, ypos += 15, "the GNU General Public License (GPL) Version 2.");
DrawVersion();
updateRumbleFrame();
showscreen ();
}
@ -306,13 +307,25 @@ WaitButtonA ()
#ifdef HW_RVL
while ( (PAD_ButtonsDown (0) & PAD_BUTTON_A)
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A))
|| (DownUsbKeys[KB_ENTER])) VIDEO_WaitVSync();
|| (DownUsbKeys[KB_ENTER])) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A)
&& !(WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A))
&& !(DownUsbKeys[KB_ENTER])) VIDEO_WaitVSync();
&& !(DownUsbKeys[KB_ENTER])) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
#else
while ( PAD_ButtonsDown (0) & PAD_BUTTON_A ) VIDEO_WaitVSync();
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A) ) VIDEO_WaitVSync();
while ( PAD_ButtonsDown (0) & PAD_BUTTON_A ) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
while (!(PAD_ButtonsDown (0) & PAD_BUTTON_A) ) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
#endif
}
@ -329,7 +342,10 @@ WaitButtonAB ()
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B))
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B))
|| (DownUsbKeys[KB_ENTER]) || (DownUsbKeys[KB_ESC])
) VIDEO_WaitVSync();
) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
while ( TRUE )
{
@ -347,7 +363,10 @@ WaitButtonAB ()
#else
u32 gc_btns;
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B)) ) VIDEO_WaitVSync();
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B)) ) {
updateRumbleFrame();
VIDEO_WaitVSync();
}
while ( TRUE )
{
@ -563,7 +582,7 @@ RunMenu (char items[][50], int maxitems, const char *title, int fontsize, int x)
wp = WPAD_ButtonsDown (0);
#endif
updateRumbleFrame();
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
/*** Look for up ***/
@ -620,6 +639,7 @@ RunMenu (char items[][50], int maxitems, const char *title, int fontsize, int x)
)
{
ret = -1;
updateRumbleFrame();
VIDEO_WaitVSync();
}

View File

@ -40,6 +40,7 @@ extern "C" {
extern bool ROMLoaded;
extern int emulating;
bool InMenu = true;
int ConfigRequested = 0;
int ShutdownRequested = 0;
int ResetRequested = 0;
@ -241,6 +242,7 @@ int main(int argc, char *argv[])
while(1) // main loop
{
InMenu = true;
#ifdef HW_RVL
if(ShutdownRequested)
ShutdownWii();
@ -258,6 +260,7 @@ int main(int argc, char *argv[])
LWP_SuspendThread (devicethread);
ResetVideo_Emu();
InMenu = false;
while (emulating) // emulation loop
{
@ -271,6 +274,7 @@ int main(int argc, char *argv[])
if(ConfigRequested)
{
InMenu = true;
ShutoffRumble();
StopAudio();
ResetVideo_Menu (); // change to menu video mode

View File

@ -755,10 +755,11 @@ static void ApplyPerImagePreferences()
cpuSaveType = 4; // EEPROM + sensor
break;
case 'R': // WarioWare Twisted style sensors
rtcEnable(1);
case 'V': // Drill Dozer
rtcEnableWarioRumble(true);
break;
case 'U': // Boktai solar sensor and clock
rtcEnable(1);
rtcEnable(true);
break;
}
}

View File

@ -180,6 +180,7 @@ showscreen ()
{
VIDEO_SetNextFramebuffer (xfb[whichfb]);
VIDEO_Flush ();
updateRumbleFrame();
VIDEO_WaitVSync ();
}

View File

@ -48,6 +48,10 @@ extern void systemDrawScreen();
extern bool systemReadJoypads();
// return information about the given joystick, -1 for default joystick
extern u32 systemReadJoypad(int);
// this function should turn on or off rumble on the gamepad
extern void systemCartridgeRumble(bool);
// This should be called once per frame
extern void updateRumbleFrame();
extern u32 systemGetClock();
extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *);

View File

@ -2143,6 +2143,7 @@ void gbGetHardwareType()
void gbReset()
{
systemCartridgeRumble(false);
gbGetHardwareType();
oldRegister_WY = 146;
@ -2616,6 +2617,8 @@ void gbReset()
memset(&gbDataMBC5, 0, sizeof(gbDataMBC5));
gbDataMBC5.mapperROMBank = 1;
if (gbRomType >= 0x1c && gbRomType<=0x1e)
gbDataMBC5.isRumbleCartridge = 1;
memset(&gbDataHuC1, 0, sizeof(gbDataHuC1));
gbDataHuC1.mapperROMBank = 1;

View File

@ -540,6 +540,7 @@ mapperMBC5 gbDataMBC5 = {
0 // is rumble cartridge?
};
extern int ConfigRequested;
// MBC5 ROM write registers
void mapperMBC5ROM(u16 address, u8 value)
{
@ -580,10 +581,11 @@ void mapperMBC5ROM(u16 address, u8 value)
gbMemoryMap[0x07] = &gbRom[tmpAddress + 0x3000];
}
break;
case 0x4000: // RAM bank select
if(gbDataMBC5.isRumbleCartridge)
case 0x4000: // RAM bank select, plus rumble
if(gbDataMBC5.isRumbleCartridge) {
systemCartridgeRumble(value & 0x08);
value &= 0x07;
else
} else
value &= 0x0f;
if(value == gbDataMBC5.mapperRAMBank)
break;

View File

@ -3052,6 +3052,7 @@ void CPUInit(const char *biosFileName, bool useBiosFile)
void CPUReset()
{
systemCartridgeRumble(false);
if(gbaSaveType == 0) {
if(eepromInUse)
gbaSaveType = 3;

View File

@ -32,8 +32,7 @@ typedef struct {
static RTCCLOCKDATA rtcClockData;
static bool rtcEnabled = false;
int WarioRumbleMotor = 0;
static bool rtcWarioRumbleEnabled = false;
void rtcEnable(bool e)
{
@ -45,6 +44,12 @@ bool rtcIsEnabled()
return rtcEnabled;
}
void rtcEnableWarioRumble(bool e)
{
if (e) rtcEnable(true);
rtcWarioRumbleEnabled = e;
}
u16 rtcRead(u32 address)
{
if(rtcEnabled) {
@ -103,14 +108,13 @@ bool rtcWrite(u32 address, u16 value)
rtcClockData.byte2 = (u8)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
} else if(address == 0x80000c6) {
rtcClockData.byte1 = (u8)value; // 0=read/1=write (for each of 4 low bits)
if (!(value & 8)) WarioRumbleMotor = 0;
// rumble is off when not writing to that pin
if (rtcWarioRumbleEnabled && !(value & 8)) systemCartridgeRumble(false);
} else if(address == 0x80000c4) { // 4 bits of I/O Port Data (upper bits not used)
// WarioWare Twisted rumble
if(rtcClockData.byte1 & 8) {
WarioRumbleMotor = value & 8;
} else {
WarioRumbleMotor = 0; // rumble is off when not writing to that pin
if(rtcWarioRumbleEnabled && (rtcClockData.byte1 & 8)) {
systemCartridgeRumble(value & 8);
}
// Boktai solar sensor

View File

@ -4,6 +4,7 @@
u16 rtcRead(u32 address);
bool rtcWrite(u32 address, u16 value);
void rtcEnable(bool);
void rtcEnableWarioRumble(bool);
bool rtcIsEnabled();
void rtcReset();