mirror of https://github.com/mgba-emu/mgba.git
Switch: Option to use built-in brightness sensor for Boktai
This commit is contained in:
parent
9b0e4af7b4
commit
9ac838d14d
1
CHANGES
1
CHANGES
|
@ -12,6 +12,7 @@ Features:
|
||||||
- Experimental high level "XQ" audio for most GBA games
|
- Experimental high level "XQ" audio for most GBA games
|
||||||
- Interframe blending for games that use flicker effects
|
- Interframe blending for games that use flicker effects
|
||||||
- Frame inspector for dissecting and debugging rendering
|
- Frame inspector for dissecting and debugging rendering
|
||||||
|
- Switch: Option to use built-in brightness sensor for Boktai
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
- GBA: All IRQs have 7 cycle delay (fixes mgba.io/i/539, mgba.io/i/1208)
|
- GBA: All IRQs have 7 cycle delay (fixes mgba.io/i/539, mgba.io/i/1208)
|
||||||
- GBA: Reset now reloads multiboot ROMs
|
- GBA: Reset now reloads multiboot ROMs
|
||||||
|
|
|
@ -99,6 +99,8 @@ static u8 vmode;
|
||||||
static u32 vwidth;
|
static u32 vwidth;
|
||||||
static u32 vheight;
|
static u32 vheight;
|
||||||
static bool interframeBlending = false;
|
static bool interframeBlending = false;
|
||||||
|
static bool useLightSensor = true;
|
||||||
|
static struct mGUIRunnerLux lightSensor;
|
||||||
|
|
||||||
static enum ScreenMode {
|
static enum ScreenMode {
|
||||||
SM_PA,
|
SM_PA,
|
||||||
|
@ -268,6 +270,10 @@ static void _setup(struct mGUIRunner* runner) {
|
||||||
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
||||||
runner->core->setAVStream(runner->core, &stream);
|
runner->core->setAVStream(runner->core, &stream);
|
||||||
|
|
||||||
|
if (runner->core->platform(runner->core) == PLATFORM_GBA && useLightSensor) {
|
||||||
|
runner->core->setPeripheral(runner->core, mPERIPH_GBA_LUMINANCE, &lightSensor.d);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned mode;
|
unsigned mode;
|
||||||
if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) {
|
if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) {
|
||||||
screenMode = mode;
|
screenMode = mode;
|
||||||
|
@ -292,6 +298,19 @@ static void _gameLoaded(struct mGUIRunner* runner) {
|
||||||
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
|
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
|
||||||
interframeBlending = fakeBool;
|
interframeBlending = fakeBool;
|
||||||
}
|
}
|
||||||
|
if (mCoreConfigGetIntValue(&runner->config, "useLightSensor", &fakeBool)) {
|
||||||
|
if (useLightSensor != fakeBool) {
|
||||||
|
useLightSensor = fakeBool;
|
||||||
|
|
||||||
|
if (runner->core->platform(runner->core) == PLATFORM_GBA) {
|
||||||
|
if (useLightSensor) {
|
||||||
|
runner->core->setPeripheral(runner->core, mPERIPH_GBA_LUMINANCE, &lightSensor.d);
|
||||||
|
} else {
|
||||||
|
runner->core->setPeripheral(runner->core, mPERIPH_GBA_LUMINANCE, &runner->luminanceSource.d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rumble.up = 0;
|
rumble.up = 0;
|
||||||
rumble.down = 0;
|
rumble.down = 0;
|
||||||
|
@ -543,6 +562,18 @@ int32_t _readGyroZ(struct mRotationSource* source) {
|
||||||
return sixaxis.gyroscope.z * -1.1e9f;
|
return sixaxis.gyroscope.z * -1.1e9f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _lightSensorSample(struct GBALuminanceSource* lux) {
|
||||||
|
struct mGUIRunnerLux* runnerLux = (struct mGUIRunnerLux*) lux;
|
||||||
|
float luxLevel = 0;
|
||||||
|
appletGetCurrentIlluminance(&luxLevel);
|
||||||
|
runnerLux->luxLevel = cbrtf(luxLevel) * 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t _lightSensorRead(struct GBALuminanceSource* lux) {
|
||||||
|
struct mGUIRunnerLux* runnerLux = (struct mGUIRunnerLux*) lux;
|
||||||
|
return 0xFF - runnerLux->luxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
static int _batteryState(void) {
|
static int _batteryState(void) {
|
||||||
u32 charge;
|
u32 charge;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
|
@ -690,6 +721,9 @@ int main(int argc, char* argv[]) {
|
||||||
rotation.readTiltY = _readTiltY;
|
rotation.readTiltY = _readTiltY;
|
||||||
rotation.readGyroZ = _readGyroZ;
|
rotation.readGyroZ = _readGyroZ;
|
||||||
|
|
||||||
|
lightSensor.d.readLuminance = _lightSensorRead;
|
||||||
|
lightSensor.d.sample = _lightSensorSample;
|
||||||
|
|
||||||
stream.videoDimensionsChanged = NULL;
|
stream.videoDimensionsChanged = NULL;
|
||||||
stream.postVideoFrame = NULL;
|
stream.postVideoFrame = NULL;
|
||||||
stream.postAudioFrame = NULL;
|
stream.postAudioFrame = NULL;
|
||||||
|
@ -707,6 +741,9 @@ int main(int argc, char* argv[]) {
|
||||||
audoutBuffer[i].data_offset = 0;
|
audoutBuffer[i].data_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool illuminanceAvailable = false;
|
||||||
|
appletIsIlluminanceAvailable(&illuminanceAvailable);
|
||||||
|
|
||||||
struct mGUIRunner runner = {
|
struct mGUIRunner runner = {
|
||||||
.params = {
|
.params = {
|
||||||
1280, 720,
|
1280, 720,
|
||||||
|
@ -829,8 +866,19 @@ int main(int argc, char* argv[]) {
|
||||||
},
|
},
|
||||||
.nStates = 6
|
.nStates = 6
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.title = "Use built-in brightness sensor for Boktai",
|
||||||
|
.data = "useLightSensor",
|
||||||
|
.submenu = 0,
|
||||||
|
.state = illuminanceAvailable,
|
||||||
|
.validStates = (const char*[]) {
|
||||||
|
"Off",
|
||||||
|
"On",
|
||||||
|
},
|
||||||
|
.nStates = 2
|
||||||
|
},
|
||||||
},
|
},
|
||||||
.nConfigExtra = 4,
|
.nConfigExtra = 5,
|
||||||
.setup = _setup,
|
.setup = _setup,
|
||||||
.teardown = NULL,
|
.teardown = NULL,
|
||||||
.gameLoaded = _gameLoaded,
|
.gameLoaded = _gameLoaded,
|
||||||
|
|
Loading…
Reference in New Issue