GB: Add Rumble
Jeffrey Pfau jeffrey@endrift.com
Sat, 20 Feb 2016 18:46:39 -0800
8 files changed,
27 insertions(+),
10 deletions(-)
M
src/core/core.h
→
src/core/core.h
@@ -92,6 +92,7 @@ void (*getGameCode)(struct mCore*, char* title);
void (*setRTC)(struct mCore*, struct mRTCSource*); void (*setRotation)(struct mCore*, struct mRotationSource*); + void (*setRumble)(struct mCore*, struct mRumble*); }; #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
M
src/gb/core.c
→
src/gb/core.c
@@ -244,6 +244,11 @@ struct GB* gb = core->board;
gb->memory.rotation = rotation; } +static void _GBCoreSetRumble(struct mCore* core, struct mRumble* rumble) { + struct GB* gb = core->board; + gb->memory.rumble = rumble; +} + struct mCore* GBCoreCreate(void) { struct GBCore* gbcore = malloc(sizeof(*gbcore)); struct mCore* core = &gbcore->d;@@ -284,5 +289,6 @@ core->getGameTitle = _GBCoreGetGameTitle;
core->getGameCode = _GBCoreGetGameCode; core->setRTC = _GBCoreSetRTC; core->setRotation = _GBCoreSetRotation; + core->setRumble = _GBCoreSetRumble; return core; }
M
src/gb/memory.c
→
src/gb/memory.c
@@ -132,11 +132,14 @@ mLOG(GB_MBC, WARN, "Unknown MBC type: %02X", cart->type);
case 0x19: case 0x1A: case 0x1B: + gb->memory.mbc = _GBMBC5; + gb->memory.mbcType = GB_MBC5; + break; case 0x1C: case 0x1D: case 0x1E: gb->memory.mbc = _GBMBC5; - gb->memory.mbcType = GB_MBC5; + gb->memory.mbcType = GB_MBC5_RUMBLE; break; case 0x20: gb->memory.mbc = _GBMBC6;@@ -529,9 +532,11 @@ case 0x1:
_switchBank(memory, bank); break; case 0x2: - if (value < 0x10) { - _switchSramBank(memory, value); + if (memory->mbcType == GB_MBC5_RUMBLE) { + memory->rumble->setRumble(memory->rumble, (value >> 3) & 1); + value &= ~8; } + _switchSramBank(memory, value & 0xF); break; default: // TODO
M
src/gb/memory.h
→
src/gb/memory.h
@@ -65,6 +65,7 @@ GB_MBC7 = 7,
GB_MMM01 = 0x10, GB_HuC1 = 0x11, GB_HuC3 = 0x12, + GB_MBC5_RUMBLE = 0x105 }; struct GBMemory;@@ -145,6 +146,7 @@ int rtcLatched;
uint8_t rtcRegs[5]; struct mRTCSource* rtc; struct mRotationSource* rotation; + struct mRumble* rumble; }; void GBMemoryInit(struct GB* gb);
M
src/gba/core.c
→
src/gba/core.c
@@ -277,6 +277,11 @@ struct GBA* gba = core->board;
gba->rotationSource = rotation; } +static void _GBACoreSetRumble(struct mCore* core, struct mRumble* rumble) { + struct GBA* gba = core->board; + gba->rumble = rumble; +} + struct mCore* GBACoreCreate(void) { struct GBACore* gbacore = malloc(sizeof(*gbacore)); struct mCore* core = &gbacore->d;@@ -317,5 +322,6 @@ core->getGameTitle = _GBACoreGetGameTitle;
core->getGameCode = _GBACoreGetGameCode; core->setRTC = _GBACoreSetRTC; core->setRotation = _GBACoreSetRotation; + core->setRumble = _GBACoreSetRumble; return core; }
M
src/platform/libretro/libretro.c
→
src/platform/libretro/libretro.c
@@ -324,12 +324,11 @@
blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768); blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768); + core->setRumble(core, &rumble); + #ifdef M_CORE_GBA if (core->platform(core) == PLATFORM_GBA) { struct GBA* gba = core->board; - if (rumbleCallback) { - gba->rumble = &rumble; - } gba->luminanceSource = &lux; const char* sysDir = 0;
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -90,6 +90,7 @@ }
mRTCGenericSourceInit(&controller->m_rtc, context->core); context->core->setRTC(context->core, &controller->m_rtc.d); context->core->setRotation(context->core, controller->m_inputController->rotationSource()); + context->core->setRumble(context->core, controller->m_inputController->rumble()); #ifdef M_CORE_GBA GBA* gba = static_cast<GBA*>(context->core->board);@@ -101,7 +102,6 @@ switch (context->core->platform(context->core)) {
#ifdef M_CORE_GBA case PLATFORM_GBA: gba->luminanceSource = &controller->m_lux; - gba->rumble = controller->m_inputController->rumble(); gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0]; gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1]; gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2];
M
src/platform/wii/main.c
→
src/platform/wii/main.c
@@ -521,10 +521,8 @@ }
} void _setup(struct mGUIRunner* runner) { - if (runner->core->platform(runner->core) == PLATFORM_GBA) { - ((struct GBA*) runner->core->board)->rumble = &rumble; - } runner->core->setRotation(runner->core, &rotation); + runner->core->setRumble(runner->core, &rumble); _mapKey(&runner->core->inputMap, GCN1_INPUT, PAD_BUTTON_A, GBA_KEY_A); _mapKey(&runner->core->inputMap, GCN1_INPUT, PAD_BUTTON_B, GBA_KEY_B);