From 89479049110687545245067655c852dbfcac64a2 Mon Sep 17 00:00:00 2001 From: "Carl.Kenner" Date: Thu, 28 May 2009 14:15:56 +0000 Subject: [PATCH] Fixes for issues 96 and 113. Stops constant rumbling and stops palette flickering in Megaman 1 (by disabling palettes for that game). --- source/ngc/input.cpp | 35 +++++++++++++++++++++++------------ source/ngc/menu.cpp | 3 ++- source/ngc/vbasupport.cpp | 3 ++- source/vba/System.h | 1 + source/vba/gb/gbMemory.cpp | 5 ++++- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/source/ngc/input.cpp b/source/ngc/input.cpp index f23b10b..c987a21 100644 --- a/source/ngc/input.cpp +++ b/source/ngc/input.cpp @@ -37,7 +37,7 @@ GuiTrigger userInput[4]; static int rumbleCount[4] = {0,0,0,0}; #endif -bool cartridgeRumble = false; +bool cartridgeRumble = false, possibleCartridgeRumble = false; int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0; unsigned int vbapadmap[10]; // VBA controller buttons @@ -173,11 +173,19 @@ void DoRumble(int i) } #endif +static int SilenceNeeded = 0; + static void updateRumble() { bool r = false; if (ConfigRequested) r = (menuRumbleCount > 0); - else r = cartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0); + else r = cartridgeRumble || possibleCartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0); + + if (SilenceNeeded>0) { + if (r) SilenceNeeded = 5; + else SilenceNeeded--; + if (SilenceNeeded>0) r = false; + } #ifdef HW_RVL // Rumble wii remote 0 @@ -189,27 +197,30 @@ static void updateRumble() 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++; + if (rumbleCountAlready > 70) { + SilenceNeeded = 5; + rumbleCountAlready = 0; } else if (ConfigRequested) { - if (menuRumbleCount>0) - rumbleCountAlready++; + if (menuRumbleCount>0) rumbleCountAlready++; + else rumbleCountAlready=0; } else { - if (gameRumbleCount>0 || menuRumbleCount>0 || cartridgeRumble) + if (gameRumbleCount>0 || menuRumbleCount>0 || possibleCartridgeRumble) rumbleCountAlready++; + else rumbleCountAlready=0; } updateRumble(); if (gameRumbleCount>0 && !ConfigRequested) gameRumbleCount--; if (menuRumbleCount>0) menuRumbleCount--; } +void systemPossibleCartridgeRumble(bool RumbleOn) { + possibleCartridgeRumble = RumbleOn; + updateRumble(); +} + void systemCartridgeRumble(bool RumbleOn) { cartridgeRumble = RumbleOn; + possibleCartridgeRumble = false; updateRumble(); } diff --git a/source/ngc/menu.cpp b/source/ngc/menu.cpp index a102448..d92fe6d 100644 --- a/source/ngc/menu.cpp +++ b/source/ngc/menu.cpp @@ -2781,7 +2781,8 @@ static int MenuSettingsVideo() case 5: if (GCSettings.colorize) GCSettings.colorize = 0; else GCSettings.colorize = 1; - if (GCSettings.colorize) LoadPalette(RomTitle); + if (strcmp(RomTitle, "MEGAMAN")==0) StopColorizing(); + else if (GCSettings.colorize) LoadPalette(RomTitle); else StopColorizing(); break; diff --git a/source/ngc/vbasupport.cpp b/source/ngc/vbasupport.cpp index 75a731d..d1ba162 100644 --- a/source/ngc/vbasupport.cpp +++ b/source/ngc/vbasupport.cpp @@ -800,7 +800,8 @@ static void gbApplyPerImagePreferences() // 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) if ((Colour != 0x80) && (Colour != 0xC0)) { - if (GCSettings.colorize) LoadPalette(RomTitle); + if (strcmp(RomTitle, "MEGAMAN")==0) StopColorizing(); + else if (GCSettings.colorize) LoadPalette(RomTitle); else StopColorizing(); } } diff --git a/source/vba/System.h b/source/vba/System.h index 64cd0b6..733e3d0 100644 --- a/source/vba/System.h +++ b/source/vba/System.h @@ -50,6 +50,7 @@ extern bool systemReadJoypads(); extern u32 systemReadJoypad(int); // this function should turn on or off rumble on the gamepad extern void systemCartridgeRumble(bool); +extern void systemPossibleCartridgeRumble(bool); // This should be called once per frame extern void updateRumbleFrame(); extern u32 systemGetClock(); diff --git a/source/vba/gb/gbMemory.cpp b/source/vba/gb/gbMemory.cpp index aed86d5..9a06954 100644 --- a/source/vba/gb/gbMemory.cpp +++ b/source/vba/gb/gbMemory.cpp @@ -586,9 +586,12 @@ void mapperMBC5ROM(u16 address, u8 value) // rumble cartridge. As long as the RAM is less than or equal to 256Kbit // we know that the last address line is not used for real RAM addresses, // so it must be a rumble signal instead. - if(gbDataMBC5.isRumbleCartridge || gbRamSizeMask <= 0x7FFF) { + if(gbDataMBC5.isRumbleCartridge) { systemCartridgeRumble(value & 0x08); value &= 0x07; + } else if (gbRamSizeMask <= 0x7FFF) { + systemPossibleCartridgeRumble(value & 0x08); + value &= 0x07; } else value &= 0x0f; if(value == gbDataMBC5.mapperRAMBank)