diff --git a/source/ngc/gameinput.cpp b/source/ngc/gameinput.cpp index 85015e4..71cd2ab 100644 --- a/source/ngc/gameinput.cpp +++ b/source/ngc/gameinput.cpp @@ -41,214 +41,6 @@ void DebugPrintf(const char *format, ...) { va_end( args ); } -u32 LegoStarWars1Input(unsigned short pad) { - u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DPadWASD(pad); - // Rumble when they lose health! - u8 Health = 0; - static u8 OldHealth = 0; - if (Health < OldHealth) - systemGameRumble(20); - OldHealth = Health; - -#ifdef HW_RVL - if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start - if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars - if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump - if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack - if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_R; // force power, special ability - if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_L; // build, use force (supposed to be J too) - if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward - - WPADData * wp = WPAD_Data(pad); - - // Start/Select - if (wp->btns_h & WPAD_BUTTON_PLUS) - J |= VBA_BUTTON_START; - - if (wp->exp.type == WPAD_EXP_NONE) { - J |= DecodeWiimote(pad); - } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { - // build, use force - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) - J |= VBA_BUTTON_L; - // change characters - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) - J |= VBA_BUTTON_SELECT; - // Jump - if (wp->btns_h & WPAD_BUTTON_A) - J |= VBA_BUTTON_A; - // Shoot - if (wp->btns_h & WPAD_BUTTON_B) - J |= VBA_BUTTON_B; - // Light saber - if (fabs(wp->gforce.x)> 1.5 ) - J |= VBA_BUTTON_B; - // Force power, special ability - if (wp->btns_h & WPAD_BUTTON_MINUS) - J |= VBA_BUTTON_R; - if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) - J |= VBA_SPEED; - } else if (wp->exp.type == WPAD_EXP_CLASSIC) { - J |= DecodeClassic(pad); - } else J |= DecodeWiimote(pad); -#endif - return J; -} - -u32 LegoStarWars2Input(unsigned short pad) { - u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DPadWASD(pad); - // Rumble when they lose health! - u8 Health = 0; - static u8 OldHealth = 0; - if (Health < OldHealth) - systemGameRumble(20); - OldHealth = Health; - -#ifdef HW_RVL - if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start - if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars - if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump - if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack - if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_L; // force power, special ability - if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_R; // build, use force (supposed to be J too) - if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward - - WPADData * wp = WPAD_Data(pad); - - // Start/Select - if (wp->btns_h & WPAD_BUTTON_PLUS) - J |= VBA_BUTTON_START; - - if (wp->exp.type == WPAD_EXP_NONE) { - J |= DecodeWiimote(pad); - } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { - // build, force transform, pull lever - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) - J |= VBA_BUTTON_R; - // change characters - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C || wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) - J |= VBA_BUTTON_SELECT; - // grapple - if (fabs(wp->gforce.y)> 1.6 ) - J |= VBA_BUTTON_R; - // Jump - if (wp->btns_h & WPAD_BUTTON_A) - J |= VBA_BUTTON_A; - // Shoot - if (wp->btns_h & WPAD_BUTTON_B) - J |= VBA_BUTTON_B; - // Light saber - if (fabs(wp->gforce.x)> 1.5 ) - J |= VBA_BUTTON_B; - // Force power, vehicle special ability - if (wp->btns_h & WPAD_BUTTON_MINUS) - J |= VBA_BUTTON_L; - if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) - J |= VBA_SPEED; - - } else if (wp->exp.type == WPAD_EXP_CLASSIC) { - J |= DecodeClassic(pad); - } -#endif - return J; -} - -u32 SWObiWanInput(unsigned short pad) { - u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); - // Rumble when they lose health! - u8 Health = gbReadMemory(0xCFF2); - static u8 OldHealth = 0; - if (Health < OldHealth) - systemGameRumble(20); - OldHealth = Health; - -#ifdef HW_RVL - WPADData * wp = WPAD_Data(pad); - - // Start/Select - if (wp->btns_h & WPAD_BUTTON_PLUS) - J |= VBA_BUTTON_START; - if (wp->btns_h & WPAD_BUTTON_MINUS) - J |= VBA_BUTTON_SELECT; - - if (wp->exp.type == WPAD_EXP_NONE) { - J |= DecodeWiimote(pad); - } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { - // use the force - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { - gbWriteMemory(0xCFF1, 2); - J |= VBA_BUTTON_A; - } - // Jump - if (wp->btns_h & WPAD_BUTTON_A) - J |= VBA_BUTTON_B; - // Shoot - if (wp->btns_h & WPAD_BUTTON_B) { - gbWriteMemory(0xCFF1, 0); - J |= VBA_BUTTON_A; - } - // Light saber - if (fabs(wp->gforce.x)> 1.5 ) { - gbWriteMemory(0xCFF1, 1); - J |= VBA_BUTTON_A; - } - if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) - J |= VBA_SPEED; - } else if (wp->exp.type == WPAD_EXP_CLASSIC) { - J |= DecodeClassic(pad); - } -#endif - return J; -} - -u32 SWEpisode2Input(unsigned short pad) { - u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); - // Rumble when they lose health! - u8 Health = CPUReadByte(0x3002fb3); - static u8 OldHealth = 0; - if (Health < OldHealth) - systemGameRumble(6); - OldHealth = Health; - -#ifdef HW_RVL - WPADData * wp = WPAD_Data(pad); - - // Start/Select - if (wp->btns_h & WPAD_BUTTON_PLUS) - J |= VBA_BUTTON_START; - if (wp->btns_h & WPAD_BUTTON_MINUS) - J |= VBA_BUTTON_SELECT; - - if (wp->exp.type == WPAD_EXP_NONE) { - J |= DecodeWiimote(pad); - } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { - // Jump - if (wp->btns_h & WPAD_BUTTON_A) - J |= VBA_BUTTON_B; - // Shoot (N/A) - if (wp->btns_h & WPAD_BUTTON_B) { - J |= VBA_BUTTON_A; - } - // Light saber - if (fabs(wp->gforce.x)> 1.5 ) { - J |= VBA_BUTTON_A; - } - if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) - J |= VBA_SPEED; - // CAKTODO - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { - J |= VBA_BUTTON_L; - } - if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { - J |= VBA_BUTTON_R; - } - } else if (wp->exp.type == WPAD_EXP_CLASSIC) { - J |= DecodeClassic(pad); - } -#endif - return J; -} - u32 TMNTInput(unsigned short pad) { u32 J = StandardMovement(pad) | StandardDPad(pad) | DecodeKeyboard(pad); static u32 LastDir = VBA_RIGHT; diff --git a/source/ngc/gameinput.h b/source/ngc/gameinput.h index 49a6c07..2be9d87 100644 --- a/source/ngc/gameinput.h +++ b/source/ngc/gameinput.h @@ -77,8 +77,15 @@ #define LSW2 gid('B','L','7') #define SWOBIWAN gid('B','O','W') +#define SWJPB gid('A','S','W') #define SWEP2 gid('A','S','2') +#define SWEP3 gid('B','E','3') +#define SWEP4 0xFF0011 +#define SWEP5 0xFF0012 +#define SWEP6 0xFF0013 +#define SWTRILOGY gid('B','C','K') #define SWNDA gid('A','2','W') +#define SWYODA gid('A','Y','D') #define MK1 0xFF0002 #define MK2 0xFF0003 @@ -141,6 +148,13 @@ u32 LegoStarWars2Input(unsigned short pad); u32 SWObiWanInput(unsigned short pad); u32 SWEpisode2Input(unsigned short pad); u32 SWNDAInput(unsigned short pad); +u32 SWEpisode3Input(unsigned short pad); +u32 SWEpisode4Input(unsigned short pad); +u32 SWEpisode5Input(unsigned short pad); +u32 SWEpisode6Input(unsigned short pad); +u32 SWJediPowerBattlesInput(unsigned short pad); +u32 SWTrilogyInput(unsigned short pad); +u32 SWYodaStoriesInput(unsigned short pad); u32 MarioKartInput(unsigned short pad); u32 MK1Input(unsigned short pad); u32 MK12Input(unsigned short pad); diff --git a/source/ngc/input.cpp b/source/ngc/input.cpp index c987a21..9e66936 100644 --- a/source/ngc/input.cpp +++ b/source/ngc/input.cpp @@ -832,8 +832,24 @@ static u32 DecodeJoy(unsigned short pad) // Star Wars case SWOBIWAN: return SWObiWanInput(pad); + case SWJPB: + return SWJediPowerBattlesInput(pad); case SWEP2: return SWEpisode2Input(pad); + case SWEP3: + return SWEpisode3Input(pad); + case SWEP4: + return SWEpisode4Input(pad); + case SWEP5: + return SWEpisode5Input(pad); + case SWEP6: + return SWEpisode6Input(pad); + case SWTRILOGY: + return SWTrilogyInput(pad); + case SWNDA: + return SWNDAInput(pad); + case SWYODA: + return SWYodaStoriesInput(pad); // Mortal Kombat case MK1: diff --git a/source/ngc/inputstarwars.cpp b/source/ngc/inputstarwars.cpp new file mode 100644 index 0000000..155d5dc --- /dev/null +++ b/source/ngc/inputstarwars.cpp @@ -0,0 +1,670 @@ +/**************************************************************************** + * Visual Boy Advance GX + * + * Carl Kenner May 2009 + * + * inputstarwars.cpp + * + * Wii/Gamecube controls for Star Wars games + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vba.h" +#include "button_mapping.h" +#include "audio.h" +#include "video.h" +#include "input.h" +#include "gameinput.h" +#include "vbasupport.h" +#include "wiiusbsupport.h" +#include "gba/GBA.h" +#include "gba/bios.h" +#include "gba/GBAinline.h" + +u32 LegoStarWars1Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DPadWASD(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(20); + OldHealth = Health; + +#ifdef HW_RVL + if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start + if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars + if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump + if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack + if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_R; // force power, special ability + if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_L; // build, use force (supposed to be J too) + if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward + + WPADData * wp = WPAD_Data(pad); + + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // build, use force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) + J |= VBA_BUTTON_L; + // change characters + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) + J |= VBA_BUTTON_SELECT; + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Shoot + if (wp->btns_h & WPAD_BUTTON_B) + J |= VBA_BUTTON_B; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) + J |= VBA_BUTTON_B; + // Force power, special ability + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_R; + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + J |= DecodeClassic(pad); + } else J |= DecodeWiimote(pad); +#endif + return J; +} + +u32 LegoStarWars2Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DPadWASD(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(20); + OldHealth = Health; + +#ifdef HW_RVL + if (DownUsbKeys[KB_ENTER]) J |= VBA_BUTTON_START; // start + if (DownUsbKeys[KB_K] || DownUsbKeys[KB_LCTRL]) J |= VBA_BUTTON_SELECT; // change chars + if (DownUsbKeys[KB_U]) J |= VBA_BUTTON_A; // jump + if (DownUsbKeys[KB_H]) J |= VBA_BUTTON_B; // attack + if (DownUsbKeys[KB_J]) J |= VBA_BUTTON_L; // force power, special ability + if (DownUsbKeys[KB_I]) J |= VBA_BUTTON_R; // build, use force (supposed to be J too) + if (DownUsbKeys[KB_SPACE]) J |= VBA_SPEED; // fast forward + + WPADData * wp = WPAD_Data(pad); + + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // build, force transform, pull lever + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) + J |= VBA_BUTTON_R; + // change characters + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C || wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_BUTTON_SELECT; + // grapple + if (fabs(wp->gforce.y)> 1.6 ) + J |= VBA_BUTTON_R; + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Shoot + if (wp->btns_h & WPAD_BUTTON_B) + J |= VBA_BUTTON_B; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) + J |= VBA_BUTTON_B; + // Force power, vehicle special ability + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_L; + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWObiWanInput(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = gbReadMemory(0xCFF2); + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(20); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // use the force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + gbWriteMemory(0xCFF1, 2); + J |= VBA_BUTTON_A; + } + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_B; + // Shoot + if (wp->btns_h & WPAD_BUTTON_B) { + gbWriteMemory(0xCFF1, 0); + J |= VBA_BUTTON_A; + } + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + gbWriteMemory(0xCFF1, 1); + J |= VBA_BUTTON_A; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWEpisode2Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = CPUReadByte(0x3002fb3); + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_B; + // Shoot (N/A) + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_A; + } + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_A; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // CAKTODO + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_L; + } + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + J |= VBA_BUTTON_R; + } + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWEpisode3Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0;//CPUReadByte(0x3002fb3); + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Shoot (N/A) + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_B; + } + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_B; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // CAKTODO + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_L; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + J |= VBA_BUTTON_R; + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWJediPowerBattlesInput(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0;//CPUReadByte(0x3002fb3); + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_B; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_A; + } + // Shoot ? + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_A; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_R; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + J |= VBA_BUTTON_L; + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWTrilogyInput(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0;//CPUReadByte(0x3002fb3); + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_B; + } + // Shoot + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_B; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_L; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + J |= VBA_BUTTON_R; + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWEpisode4Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_B; + } + // Shoot / run + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_B; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_B; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWEpisode5Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_B; + } + // Shoot / run + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_B; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_B; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWEpisode6Input(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_A; + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_B; + } + // Shoot / run + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_B; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_B; + } + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWYodaStoriesInput(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0;//gbReadMemory(0xD58A); // actually health bar progress + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Drag object, get out of dialog + if (wp->btns_h & WPAD_BUTTON_A) + J |= VBA_BUTTON_B; + + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + // should change weapon here + J |= VBA_BUTTON_A; + } + // Shoot / run + if (wp->btns_h & WPAD_BUTTON_B) { + // should change weapon here + J |= VBA_BUTTON_A; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + // should change weapon here + J |= VBA_BUTTON_A; + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} + +u32 SWNDAInput(unsigned short pad) { + u32 J = StandardMovement(pad) | DecodeGamecube(pad) | DecodeKeyboard(pad); + // Rumble when they lose health! + u8 Health = 0; + static u8 OldHealth = 0; + if (Health < OldHealth) + systemGameRumble(6); + OldHealth = Health; + +#ifdef HW_RVL + WPADData * wp = WPAD_Data(pad); + + if (wp->exp.type == WPAD_EXP_NONE) { + J |= DecodeWiimote(pad); + } else if (wp->exp.type == WPAD_EXP_NUNCHUK) { + // Jump attack, the only kind of jumping in this game + // Note, this only works if you press B first, then A + if (wp->btns_h & WPAD_BUTTON_A) { + J &= ~(VBA_DOWN | VBA_LEFT | VBA_RIGHT); + J |= VBA_BUTTON_A | VBA_UP; + } + // Light saber + if (fabs(wp->gforce.x)> 1.5 ) { + J |= VBA_BUTTON_A; + } + // Activate light saber + if (wp->btns_h & WPAD_BUTTON_B) { + J |= VBA_BUTTON_A; + } + if (wp->btns_h & WPAD_BUTTON_1 || wp->btns_h & WPAD_BUTTON_2) + J |= VBA_SPEED; + // Force + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_Z) { + J |= VBA_BUTTON_R; + } + // Block + if (wp->btns_h & WPAD_NUNCHUK_BUTTON_C) { + J |= VBA_BUTTON_B; + } + // Change force power + if (wp->btns_h & (WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT | WPAD_BUTTON_UP | WPAD_BUTTON_DOWN)) { + J |= VBA_BUTTON_L; + } + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + } else if (wp->exp.type == WPAD_EXP_CLASSIC) { + // Start/Select + if (wp->btns_h & WPAD_BUTTON_PLUS) + J |= VBA_BUTTON_START; + if (wp->btns_h & WPAD_BUTTON_MINUS) + J |= VBA_BUTTON_SELECT; + J |= DecodeClassic(pad); + } +#endif + return J; +} diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index d1ba162..25ff412 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -796,6 +796,12 @@ static void gbApplyPerImagePreferences() RomIdCode = CVBELMONT; else if (strcmp(RomTitle, "CASTLEVANIA") == 0 || strcmp(RomTitle, "CV3 GER") == 0) RomIdCode = CVLEGENDS; + else if (strcmp(RomTitle, "STAR WARS") == 0) + RomIdCode = SWEP4; + else if (strcmp(RomTitle, "EMPIRE STRIKES") == 0) + RomIdCode = SWEP5; + else if (strcmp(RomTitle, "SRJ DMG") == 0) + RomIdCode = SWEP6; } // look for matching palettes if a monochrome gameboy game // (or if a Super Gameboy game, but the palette will be ignored later in that case)