aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaphaël Zumer <rzumer@tebako.net>2019-12-10 17:54:34 -0500
committerRaphaël Zumer <rzumer@tebako.net>2019-12-10 17:54:35 -0500
commitca9f183d24c028cbbbecbe07aefb37bdcd04a581 (patch)
tree2f6b5020a994d29263179a982dd242dd9698a146 /src
parentf6cd66e5b1eb02f1664a4de083085fb81e6816b6 (diff)
Hook up solar sensor control to the UI
It uses hardcoded keypad left and right arrows.
Diffstat (limited to 'src')
-rw-r--r--src/GBACart.cpp8
-rw-r--r--src/GBACart.h2
-rw-r--r--src/libui_sdl/main.cpp15
3 files changed, 21 insertions, 4 deletions
diff --git a/src/GBACart.cpp b/src/GBACart.cpp
index 5b81900..a7ddf9b 100644
--- a/src/GBACart.cpp
+++ b/src/GBACart.cpp
@@ -462,6 +462,7 @@ const char SOLAR_SENSOR_GAMECODES[10][5] =
bool CartInserted;
+bool HasSolarSensor;
u8* CartROM;
u32 CartROMSize;
u32 CartCRC;
@@ -488,6 +489,7 @@ void DeInit()
void Reset()
{
CartInserted = false;
+ HasSolarSensor = false;
if (CartROM) delete[] CartROM;
CartROM = NULL;
CartROMSize = 0;
@@ -529,10 +531,10 @@ bool LoadROM(const char* path, const char* sram)
for (int i = 0; i < sizeof(SOLAR_SENSOR_GAMECODES)/sizeof(SOLAR_SENSOR_GAMECODES[0]); i++)
{
- if (strcmp(gamecode, SOLAR_SENSOR_GAMECODES[i]) == 0) CartGPIO.has_solar_sensor = true;
+ if (strcmp(gamecode, SOLAR_SENSOR_GAMECODES[i]) == 0) HasSolarSensor = true;
}
- if (CartGPIO.has_solar_sensor)
+ if (HasSolarSensor)
{
printf("GBA solar sensor support detected!\n");
}
@@ -570,7 +572,7 @@ void WriteGPIO(u32 addr, u16 val)
case 0xC4:
CartGPIO.data &= ~CartGPIO.direction;
CartGPIO.data |= val & CartGPIO.direction;
- if (CartGPIO.has_solar_sensor) GBACart_SolarSensor::Process(&CartGPIO);
+ if (HasSolarSensor) GBACart_SolarSensor::Process(&CartGPIO);
break;
case 0xC6:
CartGPIO.direction = val;
diff --git a/src/GBACart.h b/src/GBACart.h
index 32a2171..032c4fc 100644
--- a/src/GBACart.h
+++ b/src/GBACart.h
@@ -45,13 +45,13 @@ namespace GBACart
struct GPIO
{
- bool has_solar_sensor;
u16 data;
u16 direction;
u16 control;
};
extern bool CartInserted;
+extern bool HasSolarSensor;
extern u8* CartROM;
extern u32 CartROMSize;
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 31b0488..1b7cfe6 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -38,6 +38,7 @@
#include "DlgWifiSettings.h"
#include "../NDS.h"
+#include "../GBACart.h"
#include "../GPU.h"
#include "../SPU.h"
#include "../Wifi.h"
@@ -1291,6 +1292,20 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
{
if (evt->Modifiers == 0x0) UndoStateLoad();
}
+ else if (evt->Scancode == 0x4B) // Keypad left
+ {
+ if (GBACart::CartInserted && GBACart::HasSolarSensor)
+ {
+ if (GBACart_SolarSensor::LightLevel > 0) GBACart_SolarSensor::LightLevel--;
+ }
+ }
+ else if (evt->Scancode == 0x4D) // Keypad right
+ {
+ if (GBACart::CartInserted && GBACart::HasSolarSensor)
+ {
+ if (GBACart_SolarSensor::LightLevel < 10) GBACart_SolarSensor::LightLevel++;
+ }
+ }
for (int i = 0; i < 12; i++)
if (EventMatchesKey(evt, Config::KeyMapping[i], false))