mirror of https://github.com/mgba-emu/mgba.git
GB: Rotation support
This commit is contained in:
parent
5bd0bacb8b
commit
dffb5eec30
|
@ -91,6 +91,7 @@ struct mCore {
|
||||||
void (*getGameCode)(struct mCore*, char* title);
|
void (*getGameCode)(struct mCore*, char* title);
|
||||||
|
|
||||||
void (*setRTC)(struct mCore*, struct mRTCSource*);
|
void (*setRTC)(struct mCore*, struct mRTCSource*);
|
||||||
|
void (*setRotation)(struct mCore*, struct mRotationSource*);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||||
|
|
|
@ -239,6 +239,11 @@ static void _GBCoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
|
||||||
gb->memory.rtc = rtc;
|
gb->memory.rtc = rtc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _GBCoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
|
||||||
|
struct GB* gb = core->board;
|
||||||
|
gb->memory.rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -278,5 +283,6 @@ struct mCore* GBCoreCreate(void) {
|
||||||
core->getGameTitle = _GBCoreGetGameTitle;
|
core->getGameTitle = _GBCoreGetGameTitle;
|
||||||
core->getGameCode = _GBCoreGetGameCode;
|
core->getGameCode = _GBCoreGetGameCode;
|
||||||
core->setRTC = _GBCoreSetRTC;
|
core->setRTC = _GBCoreSetRTC;
|
||||||
|
core->setRotation = _GBCoreSetRotation;
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,6 +272,11 @@ static void _GBACoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
|
||||||
gba->rtcSource = rtc;
|
gba->rtcSource = rtc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _GBACoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
|
||||||
|
struct GBA* gba = core->board;
|
||||||
|
gba->rotationSource = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -311,5 +316,6 @@ struct mCore* GBACoreCreate(void) {
|
||||||
core->getGameTitle = _GBACoreGetGameTitle;
|
core->getGameTitle = _GBACoreGetGameTitle;
|
||||||
core->getGameCode = _GBACoreGetGameCode;
|
core->getGameCode = _GBACoreGetGameCode;
|
||||||
core->setRTC = _GBACoreSetRTC;
|
core->setRTC = _GBACoreSetRTC;
|
||||||
|
core->setRotation = _GBACoreSetRotation;
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifdef M_CORE_GBA
|
||||||
#include "gba/gba.h"
|
#include "gba/gba.h"
|
||||||
#include "gba/gui/gui-runner.h"
|
#include "gba/gui/gui-runner.h"
|
||||||
#include "gba/input.h"
|
#include "gba/input.h"
|
||||||
#include "gba/video.h"
|
#include "gba/video.h"
|
||||||
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
#include "gb/gb.h"
|
||||||
|
#endif
|
||||||
#include "util/gui.h"
|
#include "util/gui.h"
|
||||||
#include "util/gui/file-select.h"
|
#include "util/gui/file-select.h"
|
||||||
#include "util/gui/font.h"
|
#include "util/gui/font.h"
|
||||||
|
@ -249,9 +254,7 @@ static void _guiFinish(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _setup(struct mGUIRunner* runner) {
|
static void _setup(struct mGUIRunner* runner) {
|
||||||
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
runner->core->setRotation(runner->core, &rotation.d);
|
||||||
((struct GBA*) runner->core->board)->rotationSource = &rotation.d;
|
|
||||||
}
|
|
||||||
if (hasSound != NO_SOUND) {
|
if (hasSound != NO_SOUND) {
|
||||||
runner->core->setAVStream(runner->core, &stream);
|
runner->core->setAVStream(runner->core, &stream);
|
||||||
}
|
}
|
||||||
|
@ -279,13 +282,26 @@ static void _setup(struct mGUIRunner* runner) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _gameLoaded(struct mGUIRunner* runner) {
|
static void _gameLoaded(struct mGUIRunner* runner) {
|
||||||
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
switch (runner->core->platform(runner->core)) {
|
||||||
|
#ifdef M_CORE_GBA
|
||||||
|
case PLATFORM_GBA:
|
||||||
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_TILT) {
|
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_TILT) {
|
||||||
HIDUSER_EnableAccelerometer();
|
HIDUSER_EnableAccelerometer();
|
||||||
}
|
}
|
||||||
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_GYRO) {
|
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_GYRO) {
|
||||||
HIDUSER_EnableGyroscope();
|
HIDUSER_EnableGyroscope();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
case PLATFORM_GB:
|
||||||
|
if (((struct GB*) runner->core->board)->memory.mbcType == GB_MBC7) {
|
||||||
|
HIDUSER_EnableAccelerometer();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
osSetSpeedupEnable(true);
|
osSetSpeedupEnable(true);
|
||||||
|
|
||||||
|
@ -318,13 +334,26 @@ static void _gameUnloaded(struct mGUIRunner* runner) {
|
||||||
}
|
}
|
||||||
osSetSpeedupEnable(false);
|
osSetSpeedupEnable(false);
|
||||||
|
|
||||||
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
switch (runner->core->platform(runner->core)) {
|
||||||
|
#ifdef M_CORE_GBA
|
||||||
|
case PLATFORM_GBA:
|
||||||
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_TILT) {
|
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_TILT) {
|
||||||
HIDUSER_DisableAccelerometer();
|
HIDUSER_DisableAccelerometer();
|
||||||
}
|
}
|
||||||
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_GYRO) {
|
if (((struct GBA*) runner->core->board)->memory.hw.devices & HW_GYRO) {
|
||||||
HIDUSER_DisableGyroscope();
|
HIDUSER_DisableGyroscope();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
case PLATFORM_GB:
|
||||||
|
if (((struct GB*) runner->core->board)->memory.mbcType == GB_MBC7) {
|
||||||
|
HIDUSER_DisableAccelerometer();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,16 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "core/config.h"
|
#include "core/config.h"
|
||||||
#include "core/directories.h"
|
#include "core/directories.h"
|
||||||
#include "gba/audio.h"
|
#ifdef M_CORE_GBA
|
||||||
#include "gba/bios.h"
|
#include "gba/bios.h"
|
||||||
#include "gba/core.h"
|
#include "gba/core.h"
|
||||||
#include "gba/gba.h"
|
#include "gba/gba.h"
|
||||||
#include "gba/serialize.h"
|
#include "gba/serialize.h"
|
||||||
#include "gba/sharkport.h"
|
#include "gba/sharkport.h"
|
||||||
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
#include "gb/gb.h"
|
||||||
|
#endif
|
||||||
#include "util/vfs.h"
|
#include "util/vfs.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +89,19 @@ 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());
|
||||||
|
|
||||||
if (context->core->platform(context->core) == PLATFORM_GBA) {
|
#ifdef M_CORE_GBA
|
||||||
GBA* gba = static_cast<GBA*>(context->core->board);
|
GBA* gba = static_cast<GBA*>(context->core->board);
|
||||||
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
GB* gb = static_cast<GB*>(context->core->board);
|
||||||
|
#endif
|
||||||
|
switch (context->core->platform(context->core)) {
|
||||||
|
#ifdef M_CORE_GBA
|
||||||
|
case PLATFORM_GBA:
|
||||||
gba->luminanceSource = &controller->m_lux;
|
gba->luminanceSource = &controller->m_lux;
|
||||||
gba->rumble = controller->m_inputController->rumble();
|
gba->rumble = controller->m_inputController->rumble();
|
||||||
gba->rotationSource = controller->m_inputController->rotationSource();
|
|
||||||
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];
|
||||||
|
|
|
@ -523,8 +523,8 @@ void _guiFinish(void) {
|
||||||
void _setup(struct mGUIRunner* runner) {
|
void _setup(struct mGUIRunner* runner) {
|
||||||
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
||||||
((struct GBA*) runner->core->board)->rumble = &rumble;
|
((struct GBA*) runner->core->board)->rumble = &rumble;
|
||||||
((struct GBA*) runner->core->board)->rotationSource = &rotation;
|
|
||||||
}
|
}
|
||||||
|
runner->core->setRotation(runner->core, &rotation);
|
||||||
|
|
||||||
_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