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

View File

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

View File

@ -29,8 +29,11 @@
#include "gba/bios.h" #include "gba/bios.h"
#include "gba/GBAinline.h" #include "gba/GBAinline.h"
extern bool InMenu;
int rumbleRequest[4] = {0,0,0,0}; int rumbleRequest[4] = {0,0,0,0};
static int rumbleCount[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 vbapadmap[10]; // VBA controller buttons
unsigned int gcpadmap[10]; // Gamecube controller Padmap 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 * WPAD_Stick
* *
@ -617,10 +671,6 @@ static u32 DecodeJoy(unsigned short pad)
return Boktai2Input(pad); return Boktai2Input(pad);
} }
} }
else
{
ShutoffRumble();
}
#endif #endif
// the function result, J, is a combination of flags for all the VBA buttons that are down // 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]; J |= vbapadmap[i];
} }
if ((J & 48) == 48)
J &= ~16;
if ((J & 192) == 192)
J &= ~128;
return J; return J;
} }
u32 GetJoy(int pad) u32 GetJoy(int pad)
{ {
pad = 0; pad = 0;
@ -699,10 +745,18 @@ u32 GetJoy(int pad)
) )
{ {
ConfigRequested = 1; ConfigRequested = 1;
updateRumbleFrame();
return 0; return 0;
} }
else 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 ResetControls();
void ShutoffRumble(); void ShutoffRumble();
void DoRumble(int i); void DoRumble(int i);
void systemGameRumble(int RumbleForFrames);
void systemGameRumbleOnlyFor(int OnlyRumbleForFrames);
void updateRumbleFrame();
s8 WPAD_Stick(u8 chan,u8 right, int axis); s8 WPAD_Stick(u8 chan,u8 right, int axis);
u32 GetJoy(int which); u32 GetJoy(int which);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -48,6 +48,10 @@ extern void systemDrawScreen();
extern bool systemReadJoypads(); extern bool systemReadJoypads();
// return information about the given joystick, -1 for default joystick // return information about the given joystick, -1 for default joystick
extern u32 systemReadJoypad(int); 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 u32 systemGetClock();
extern void systemMessage(int, const char *, ...); extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *); extern void systemSetTitle(const char *);

View File

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

View File

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

View File

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

View File

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

View File

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