Hooked up the GBA tilt sensor to the wx gui
This commit is contained in:
parent
0844ac6bbf
commit
d3146f3011
|
@ -743,6 +743,7 @@ void utilGBAFindSave(const int size)
|
|||
detectedSaveType = 3;
|
||||
}
|
||||
rtcEnable(rtcFound);
|
||||
rtcEnableRumble(!rtcFound);
|
||||
saveType = detectedSaveType;
|
||||
flashSetSize(flashSize);
|
||||
}
|
||||
|
|
|
@ -3923,8 +3923,7 @@ void CPULoop(int ticks)
|
|||
// read default joystick
|
||||
joy = systemReadJoypad(-1);
|
||||
P1 = 0x03FF ^ (joy & 0x3FF);
|
||||
if(cpuEEPROMSensorEnabled)
|
||||
systemUpdateMotionSensor();
|
||||
systemUpdateMotionSensor();
|
||||
UPDATE_REG(0x130, P1);
|
||||
u16 P1CNT = READ16LE(((u16 *)&ioMem[0x132]));
|
||||
// this seems wrong, but there are cases where the game
|
||||
|
|
|
@ -406,20 +406,18 @@ static inline u8 CPUReadByte(u32 address)
|
|||
goto unreadable;
|
||||
case 14:
|
||||
case 15:
|
||||
if(cpuSramEnabled | cpuFlashEnabled)
|
||||
return flashRead(address);
|
||||
if(cpuEEPROMSensorEnabled) {
|
||||
switch(address & 0x00008f00) {
|
||||
case 0x8200:
|
||||
return systemGetSensorX() & 255;
|
||||
case 0x8300:
|
||||
return (systemGetSensorX() >> 8)|0x80;
|
||||
case 0x8400:
|
||||
return systemGetSensorY() & 255;
|
||||
case 0x8500:
|
||||
return systemGetSensorY() >> 8;
|
||||
}
|
||||
switch(address & 0x00008f00) {
|
||||
case 0x8200:
|
||||
return systemGetSensorX() & 255;
|
||||
case 0x8300:
|
||||
return (systemGetSensorX() >> 8)|0x80;
|
||||
case 0x8400:
|
||||
return systemGetSensorY() & 255;
|
||||
case 0x8500:
|
||||
return systemGetSensorY() >> 8;
|
||||
}
|
||||
if (cpuSramEnabled | cpuFlashEnabled)
|
||||
return flashRead(address);
|
||||
// default
|
||||
default:
|
||||
unreadable:
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
|||
|
||||
static RTCCLOCKDATA rtcClockData;
|
||||
static bool rtcEnabled = true;
|
||||
static bool rtcRumbleEnabled = false;
|
||||
|
||||
void rtcEnable(bool e)
|
||||
{
|
||||
|
@ -45,9 +46,13 @@ bool rtcIsEnabled()
|
|||
return rtcEnabled;
|
||||
}
|
||||
|
||||
void rtcEnableRumble(bool e)
|
||||
{
|
||||
rtcRumbleEnabled = e;
|
||||
}
|
||||
|
||||
u16 rtcRead(u32 address)
|
||||
{
|
||||
if(rtcEnabled) {
|
||||
switch(address){
|
||||
case 0x80000c8:
|
||||
return rtcClockData.byte2;
|
||||
|
@ -71,16 +76,16 @@ u16 rtcRead(u32 address)
|
|||
else if (rtcClockData.byte1 == 0x0b) {
|
||||
//sprintf(DebugStr, "Reading Twisted Sensor bit %d", rtcClockData.reserved[11]);
|
||||
u16 v = systemGetSensorZ();
|
||||
v = 0x6C0 + v;
|
||||
return ((v >> rtcClockData.reserved[11]) & 1) << 2;
|
||||
}
|
||||
// Real Time Clock
|
||||
else {
|
||||
else if (rtcEnabled) {
|
||||
//sprintf(DebugStr, "Reading RTC %02x, %02x, %02x", rtcClockData.byte0, rtcClockData.byte1, rtcClockData.byte2);
|
||||
return rtcClockData.byte0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return READ16LE((&rom[address & 0x1FFFFFE]));
|
||||
}
|
||||
|
@ -95,20 +100,17 @@ static u8 toBCD(u8 value)
|
|||
|
||||
bool rtcWrite(u32 address, u16 value)
|
||||
{
|
||||
if(!rtcEnabled)
|
||||
return false;
|
||||
|
||||
if(address == 0x80000c8) {
|
||||
rtcClockData.byte2 = (u8)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
|
||||
}
|
||||
else if (address == 0x80000c6) {
|
||||
rtcClockData.byte1 = (u8)value; // 0=read/1=write (for each of 4 low bits)
|
||||
// rumble is off when not writing to that pin
|
||||
if (/*rtcWarioRumbleEnabled &&*/ !(value & 8)) systemCartridgeRumble(false);
|
||||
if (rtcRumbleEnabled && !(value & 8)) systemCartridgeRumble(false);
|
||||
}
|
||||
else if (address == 0x80000c4) { // 4 bits of I/O Port Data (upper bits not used)
|
||||
// WarioWare Twisted rumble
|
||||
if (/*rtcWarioRumbleEnabled &&*/ (rtcClockData.byte1 & 8)) {
|
||||
if (rtcRumbleEnabled && (rtcClockData.byte1 & 8)) {
|
||||
systemCartridgeRumble(value & 8);
|
||||
}
|
||||
// Boktai solar sensor
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
u16 rtcRead(u32 address);
|
||||
bool rtcWrite(u32 address, u16 value);
|
||||
void rtcEnable(bool);
|
||||
void rtcEnableRumble(bool e);
|
||||
bool rtcIsEnabled();
|
||||
void rtcReset();
|
||||
|
||||
|
|
|
@ -106,21 +106,22 @@ const char * const joynames[NUM_KEYS] = {
|
|||
("A"), ("B"), ("L"), ("R"),
|
||||
("Select"), ("Start"),
|
||||
("MotionUp"), ("MotionDown"), ("MotionLeft"), ("MotionRight"),
|
||||
("AutoA"), ("AutoB"),
|
||||
("MotionIn"), ("MotionOut"), ("AutoA"), ("AutoB"),
|
||||
("Speed"), ("Capture"), ("GS")
|
||||
};
|
||||
|
||||
wxJoyKeyBinding defkeys[NUM_KEYS * 2] = {
|
||||
{ WXK_UP }, { 1, WXJB_AXIS_MINUS, 1 }, { WXK_DOWN }, { 1, WXJB_AXIS_PLUS, 1 },
|
||||
{ WXK_LEFT }, { 0, WXJB_AXIS_MINUS, 1 }, { WXK_RIGHT }, { 0, WXJB_AXIS_PLUS, 1 },
|
||||
{ wxT('X') }, { 0, WXJB_BUTTON, 1 }, { wxT('Z') }, { 1, WXJB_BUTTON, 1 },
|
||||
{ wxT('A') }, { 2, WXJB_BUTTON, 1 }, { wxT('S') }, { 3, WXJB_BUTTON, 1 },
|
||||
{ WXK_BACK }, { 4, WXJB_BUTTON, 1 }, { WXK_RETURN }, { 5, WXJB_BUTTON, 1 },
|
||||
{ WXK_NUMPAD_UP }, { 2, WXJB_AXIS_PLUS, 1 }, { WXK_NUMPAD_DOWN }, { 2, WXJB_AXIS_MINUS, 1 },
|
||||
{ WXK_NUMPAD_LEFT }, { 3, WXJB_AXIS_MINUS, 1 }, { WXK_NUMPAD_RIGHT }, { 3, WXJB_AXIS_PLUS, 1 },
|
||||
{ wxT('W') }, { 0 }, { wxT('Q') }, { 0 },
|
||||
{ WXK_SPACE }, { 0 }, { WXK_F11 }, { 0 },
|
||||
{ 0 } , { 0 }
|
||||
{ WXK_UP }, { 1, WXJB_AXIS_MINUS, 1 }, { WXK_DOWN }, { 1, WXJB_AXIS_PLUS, 1 },
|
||||
{ WXK_LEFT }, { 0, WXJB_AXIS_MINUS, 1 }, { WXK_RIGHT }, { 0, WXJB_AXIS_PLUS, 1 },
|
||||
{ wxT('X') }, { 0, WXJB_BUTTON, 1 }, { wxT('Z') }, { 1, WXJB_BUTTON, 1 },
|
||||
{ wxT('A') }, { 2, WXJB_BUTTON, 1 }, { wxT('S') }, { 3, WXJB_BUTTON, 1 },
|
||||
{ WXK_BACK }, { 4, WXJB_BUTTON, 1 }, { WXK_RETURN }, { 5, WXJB_BUTTON, 1 },
|
||||
{ WXK_NUMPAD_UP }, { 2, WXJB_AXIS_PLUS, 1 }, { WXK_NUMPAD_DOWN }, { 2, WXJB_AXIS_MINUS, 1 },
|
||||
{ WXK_NUMPAD_LEFT }, { 3, WXJB_AXIS_MINUS, 1 }, { WXK_NUMPAD_RIGHT }, { 3, WXJB_AXIS_PLUS, 1 },
|
||||
{ WXK_NUMPAD_PAGEUP }, { 4, WXJB_AXIS_PLUS, 1 }, { WXK_NUMPAD_PAGEDOWN }, { 4, WXJB_AXIS_MINUS, 1 },
|
||||
{ wxT('W') }, { 0 }, { wxT('Q') }, { 0 },
|
||||
{ WXK_SPACE }, { 0 }, { WXK_F11 }, { 0 },
|
||||
{ 0 } , { 0 }
|
||||
};
|
||||
|
||||
wxAcceleratorEntry_v sys_accels;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef WX_OPTS_H
|
||||
#define WX_OPTS_H
|
||||
|
||||
#define NUM_KEYS 19
|
||||
#define NUM_KEYS 21
|
||||
extern const char * const joynames[NUM_KEYS];
|
||||
extern wxJoyKeyBinding defkeys[NUM_KEYS * 2]; // keyboard + joystick defaults
|
||||
|
||||
|
|
|
@ -913,7 +913,7 @@ void GameArea::OnIdle(wxIdleEvent &event)
|
|||
static uint32_t bmask[NUM_KEYS] = {
|
||||
KEYM_UP, KEYM_DOWN, KEYM_LEFT, KEYM_RIGHT, KEYM_A, KEYM_B, KEYM_L, KEYM_R,
|
||||
KEYM_SELECT, KEYM_START, KEYM_MOTION_UP, KEYM_MOTION_DOWN, KEYM_MOTION_LEFT,
|
||||
KEYM_MOTION_RIGHT, KEYM_AUTO_A, KEYM_AUTO_B, KEYM_SPEED, KEYM_CAPTURE,
|
||||
KEYM_MOTION_RIGHT, KEYM_MOTION_IN, KEYM_MOTION_OUT, KEYM_AUTO_A, KEYM_AUTO_B, KEYM_SPEED, KEYM_CAPTURE,
|
||||
KEYM_GS
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ int RGB_LOW_BITS_MASK;
|
|||
|
||||
// these are local, though.
|
||||
int joypress[4], autofire;
|
||||
static int sensorx[4], sensory[4];
|
||||
static int sensorx[4], sensory[4], sensorz[4];
|
||||
bool pause_next;
|
||||
bool turbo;
|
||||
|
||||
|
@ -531,6 +531,36 @@ void systemUpdateMotionSensor()
|
|||
if(sensory[i] > 2047)
|
||||
sensory[i] = 2047;
|
||||
}
|
||||
|
||||
const int lowZ = -1800;
|
||||
const int centerZ = 0;
|
||||
const int highZ = 1800;
|
||||
const int accelZ = 3;
|
||||
if (joypress[i] & KEYM_MOTION_IN) {
|
||||
sensorz[i] += accelZ;
|
||||
if (sensorz[i] > highZ)
|
||||
sensorz[i] = highZ;
|
||||
if (sensorz[i] < centerZ)
|
||||
sensorz[i] = centerZ + (accelZ * 300);
|
||||
}
|
||||
else if (joypress[i] & KEYM_MOTION_OUT) {
|
||||
sensorz[i] -= accelZ;
|
||||
if (sensorz[i] < lowZ)
|
||||
sensorz[i] = lowZ;
|
||||
if (sensorz[i] > centerZ)
|
||||
sensorz[i] = centerZ - (accelZ * 300);
|
||||
}
|
||||
else if (sensorz[i] > centerZ) {
|
||||
sensorz[i] -= (accelZ * 100);
|
||||
if (sensorz[i] < centerZ)
|
||||
sensorz[i] = centerZ;
|
||||
}
|
||||
else {
|
||||
sensorz[i] += (accelZ * 100);
|
||||
if (sensorz[i] > centerZ)
|
||||
sensorz[i] = centerZ;
|
||||
}
|
||||
|
||||
}
|
||||
systemUpdateSolarSensor();
|
||||
}
|
||||
|
@ -547,7 +577,7 @@ int systemGetSensorY()
|
|||
|
||||
int systemGetSensorZ()
|
||||
{
|
||||
return sensory[gopts.default_stick - 1];
|
||||
return sensorz[gopts.default_stick - 1] / 10;
|
||||
}
|
||||
|
||||
class PrintDialog : public wxEvtHandler, public wxPrintout
|
||||
|
|
|
@ -616,6 +616,8 @@ extern int joypress[4], autofire;
|
|||
#define KEYM_MOTION_DOWN (1<<16)
|
||||
#define KEYM_MOTION_LEFT (1<<17)
|
||||
#define KEYM_MOTION_RIGHT (1<<18)
|
||||
#define KEYM_MOTION_IN (1<<19)
|
||||
#define KEYM_MOTION_OUT (1<<20)
|
||||
|
||||
#include "filters.h"
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@
|
|||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Motion Left</label>
|
||||
<label>Motion Left/Dark</label>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
|
@ -239,26 +239,6 @@
|
|||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Motion Right</label>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="MotionRight" subclass="wxJoyKeyTextCtrl">
|
||||
<style>wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB</style>
|
||||
</object>
|
||||
<flag>wxALL|wxGROW</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>GameShark</label>
|
||||
|
@ -273,6 +253,20 @@
|
|||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Motion Right/Light</label>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="MotionRight" subclass="wxJoyKeyTextCtrl">
|
||||
<style>wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB</style>
|
||||
</object>
|
||||
<flag>wxALL|wxGROW</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Speed Up</label>
|
||||
|
@ -287,6 +281,40 @@
|
|||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Spin Left</label>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="MotionIn" subclass="wxJoyKeyTextCtrl">
|
||||
<style>wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB</style>
|
||||
</object>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="spacer">
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Spin Right</label>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="MotionOut" subclass="wxJoyKeyTextCtrl">
|
||||
<style>wxTE_PROCESS_ENTER|wxTE_PROCESS_TAB</style>
|
||||
</object>
|
||||
<flag>wxALL|wxGROW</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticText">
|
||||
<label>Screenshot</label>
|
||||
|
|
Loading…
Reference in New Issue