mirror of https://github.com/mgba-emu/mgba.git
GB: Add Rumble
This commit is contained in:
parent
a260b4cf91
commit
90b18239b0
|
@ -92,6 +92,7 @@ struct mCore {
|
||||||
|
|
||||||
void (*setRTC)(struct mCore*, struct mRTCSource*);
|
void (*setRTC)(struct mCore*, struct mRTCSource*);
|
||||||
void (*setRotation)(struct mCore*, struct mRotationSource*);
|
void (*setRotation)(struct mCore*, struct mRotationSource*);
|
||||||
|
void (*setRumble)(struct mCore*, struct mRumble*);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||||
|
|
|
@ -244,6 +244,11 @@ static void _GBCoreSetRotation(struct mCore* core, struct mRotationSource* rotat
|
||||||
gb->memory.rotation = rotation;
|
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 mCore* GBCoreCreate(void) {
|
||||||
struct GBCore* gbcore = malloc(sizeof(*gbcore));
|
struct GBCore* gbcore = malloc(sizeof(*gbcore));
|
||||||
struct mCore* core = &gbcore->d;
|
struct mCore* core = &gbcore->d;
|
||||||
|
@ -284,5 +289,6 @@ struct mCore* GBCoreCreate(void) {
|
||||||
core->getGameCode = _GBCoreGetGameCode;
|
core->getGameCode = _GBCoreGetGameCode;
|
||||||
core->setRTC = _GBCoreSetRTC;
|
core->setRTC = _GBCoreSetRTC;
|
||||||
core->setRotation = _GBCoreSetRotation;
|
core->setRotation = _GBCoreSetRotation;
|
||||||
|
core->setRumble = _GBCoreSetRumble;
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,14 @@ void GBMemoryReset(struct GB* gb) {
|
||||||
case 0x19:
|
case 0x19:
|
||||||
case 0x1A:
|
case 0x1A:
|
||||||
case 0x1B:
|
case 0x1B:
|
||||||
|
gb->memory.mbc = _GBMBC5;
|
||||||
|
gb->memory.mbcType = GB_MBC5;
|
||||||
|
break;
|
||||||
case 0x1C:
|
case 0x1C:
|
||||||
case 0x1D:
|
case 0x1D:
|
||||||
case 0x1E:
|
case 0x1E:
|
||||||
gb->memory.mbc = _GBMBC5;
|
gb->memory.mbc = _GBMBC5;
|
||||||
gb->memory.mbcType = GB_MBC5;
|
gb->memory.mbcType = GB_MBC5_RUMBLE;
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x20:
|
||||||
gb->memory.mbc = _GBMBC6;
|
gb->memory.mbc = _GBMBC6;
|
||||||
|
@ -529,9 +532,11 @@ void _GBMBC5(struct GBMemory* memory, uint16_t address, uint8_t value) {
|
||||||
_switchBank(memory, bank);
|
_switchBank(memory, bank);
|
||||||
break;
|
break;
|
||||||
case 0x2:
|
case 0x2:
|
||||||
if (value < 0x10) {
|
if (memory->mbcType == GB_MBC5_RUMBLE) {
|
||||||
_switchSramBank(memory, value);
|
memory->rumble->setRumble(memory->rumble, (value >> 3) & 1);
|
||||||
|
value &= ~8;
|
||||||
}
|
}
|
||||||
|
_switchSramBank(memory, value & 0xF);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -65,6 +65,7 @@ enum GBMemoryBankControllerType {
|
||||||
GB_MMM01 = 0x10,
|
GB_MMM01 = 0x10,
|
||||||
GB_HuC1 = 0x11,
|
GB_HuC1 = 0x11,
|
||||||
GB_HuC3 = 0x12,
|
GB_HuC3 = 0x12,
|
||||||
|
GB_MBC5_RUMBLE = 0x105
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GBMemory;
|
struct GBMemory;
|
||||||
|
@ -145,6 +146,7 @@ struct GBMemory {
|
||||||
uint8_t rtcRegs[5];
|
uint8_t rtcRegs[5];
|
||||||
struct mRTCSource* rtc;
|
struct mRTCSource* rtc;
|
||||||
struct mRotationSource* rotation;
|
struct mRotationSource* rotation;
|
||||||
|
struct mRumble* rumble;
|
||||||
};
|
};
|
||||||
|
|
||||||
void GBMemoryInit(struct GB* gb);
|
void GBMemoryInit(struct GB* gb);
|
||||||
|
|
|
@ -277,6 +277,11 @@ static void _GBACoreSetRotation(struct mCore* core, struct mRotationSource* rota
|
||||||
gba->rotationSource = rotation;
|
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 mCore* GBACoreCreate(void) {
|
||||||
struct GBACore* gbacore = malloc(sizeof(*gbacore));
|
struct GBACore* gbacore = malloc(sizeof(*gbacore));
|
||||||
struct mCore* core = &gbacore->d;
|
struct mCore* core = &gbacore->d;
|
||||||
|
@ -317,5 +322,6 @@ struct mCore* GBACoreCreate(void) {
|
||||||
core->getGameCode = _GBACoreGetGameCode;
|
core->getGameCode = _GBACoreGetGameCode;
|
||||||
core->setRTC = _GBACoreSetRTC;
|
core->setRTC = _GBACoreSetRTC;
|
||||||
core->setRotation = _GBACoreSetRotation;
|
core->setRotation = _GBACoreSetRotation;
|
||||||
|
core->setRumble = _GBACoreSetRumble;
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,12 +324,11 @@ bool retro_load_game(const struct retro_game_info* game) {
|
||||||
blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768);
|
blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768);
|
||||||
blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768);
|
blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768);
|
||||||
|
|
||||||
|
core->setRumble(core, &rumble);
|
||||||
|
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
if (core->platform(core) == PLATFORM_GBA) {
|
if (core->platform(core) == PLATFORM_GBA) {
|
||||||
struct GBA* gba = core->board;
|
struct GBA* gba = core->board;
|
||||||
if (rumbleCallback) {
|
|
||||||
gba->rumble = &rumble;
|
|
||||||
}
|
|
||||||
gba->luminanceSource = &lux;
|
gba->luminanceSource = &lux;
|
||||||
|
|
||||||
const char* sysDir = 0;
|
const char* sysDir = 0;
|
||||||
|
|
|
@ -90,6 +90,7 @@ GameController::GameController(QObject* parent)
|
||||||
mRTCGenericSourceInit(&controller->m_rtc, context->core);
|
mRTCGenericSourceInit(&controller->m_rtc, context->core);
|
||||||
context->core->setRTC(context->core, &controller->m_rtc.d);
|
context->core->setRTC(context->core, &controller->m_rtc.d);
|
||||||
context->core->setRotation(context->core, controller->m_inputController->rotationSource());
|
context->core->setRotation(context->core, controller->m_inputController->rotationSource());
|
||||||
|
context->core->setRumble(context->core, controller->m_inputController->rumble());
|
||||||
|
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
GBA* gba = static_cast<GBA*>(context->core->board);
|
GBA* gba = static_cast<GBA*>(context->core->board);
|
||||||
|
@ -101,7 +102,6 @@ GameController::GameController(QObject* parent)
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
case PLATFORM_GBA:
|
case PLATFORM_GBA:
|
||||||
gba->luminanceSource = &controller->m_lux;
|
gba->luminanceSource = &controller->m_lux;
|
||||||
gba->rumble = controller->m_inputController->rumble();
|
|
||||||
gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0];
|
gba->audio.psg.forceDisableCh[0] = !controller->m_audioChannels[0];
|
||||||
gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1];
|
gba->audio.psg.forceDisableCh[1] = !controller->m_audioChannels[1];
|
||||||
gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2];
|
gba->audio.psg.forceDisableCh[2] = !controller->m_audioChannels[2];
|
||||||
|
|
|
@ -521,10 +521,8 @@ void _guiFinish(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _setup(struct mGUIRunner* runner) {
|
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->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_A, GBA_KEY_A);
|
||||||
_mapKey(&runner->core->inputMap, GCN1_INPUT, PAD_BUTTON_B, GBA_KEY_B);
|
_mapKey(&runner->core->inputMap, GCN1_INPUT, PAD_BUTTON_B, GBA_KEY_B);
|
||||||
|
|
Loading…
Reference in New Issue