mirror of https://github.com/mgba-emu/mgba.git
GB, GBA: Fix broken opposing button filter (fixes #1191)
This commit is contained in:
parent
eec39a4324
commit
479bee3707
1
CHANGES
1
CHANGES
|
@ -109,6 +109,7 @@ Bugfixes:
|
||||||
- GBA Video: Fix caching with background toggling (fixes mgba.io/i/1118)
|
- GBA Video: Fix caching with background toggling (fixes mgba.io/i/1118)
|
||||||
- Wii: Fix drawing caching regression (fixes mgba.io/i/1185)
|
- Wii: Fix drawing caching regression (fixes mgba.io/i/1185)
|
||||||
- Switch: Fix incorrect mapping for fast forward cap
|
- Switch: Fix incorrect mapping for fast forward cap
|
||||||
|
- GB, GBA: Fix broken opposing button filter (fixes mgba.io/i/1191)
|
||||||
Misc:
|
Misc:
|
||||||
- mGUI: Add SGB border configuration option
|
- mGUI: Add SGB border configuration option
|
||||||
- mGUI: Add support for different settings types
|
- mGUI: Add support for different settings types
|
||||||
|
|
|
@ -117,6 +117,8 @@ struct GB {
|
||||||
bool earlyExit;
|
bool earlyExit;
|
||||||
struct mTimingEvent eiPending;
|
struct mTimingEvent eiPending;
|
||||||
unsigned doubleSpeed;
|
unsigned doubleSpeed;
|
||||||
|
|
||||||
|
bool allowOpposingDirections;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GBCartridge {
|
struct GBCartridge {
|
||||||
|
|
|
@ -210,8 +210,12 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf
|
||||||
mCoreConfigCopyValue(&core->config, config, "gb.model");
|
mCoreConfigCopyValue(&core->config, config, "gb.model");
|
||||||
mCoreConfigCopyValue(&core->config, config, "sgb.model");
|
mCoreConfigCopyValue(&core->config, config, "sgb.model");
|
||||||
mCoreConfigCopyValue(&core->config, config, "cgb.model");
|
mCoreConfigCopyValue(&core->config, config, "cgb.model");
|
||||||
|
mCoreConfigCopyValue(&core->config, config, "allowOpposingDirections");
|
||||||
|
|
||||||
|
int fakeBool = 0;
|
||||||
|
mCoreConfigGetIntValue(config, "allowOpposingDirections", &fakeBool);
|
||||||
|
gb->allowOpposingDirections = fakeBool;
|
||||||
|
|
||||||
int fakeBool;
|
|
||||||
if (mCoreConfigGetIntValue(config, "sgb.borders", &fakeBool)) {
|
if (mCoreConfigGetIntValue(config, "sgb.borders", &fakeBool)) {
|
||||||
gb->video.sgbBorders = fakeBool;
|
gb->video.sgbBorders = fakeBool;
|
||||||
gb->video.renderer->enableSGBBorder(gb->video.renderer, fakeBool);
|
gb->video.renderer->enableSGBBorder(gb->video.renderer, fakeBool);
|
||||||
|
|
19
src/gb/io.c
19
src/gb/io.c
|
@ -105,6 +105,7 @@ static const uint8_t _registerMask[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t _readKeys(struct GB* gb);
|
static uint8_t _readKeys(struct GB* gb);
|
||||||
|
static uint8_t _readKeysFiltered(struct GB* gb);
|
||||||
|
|
||||||
static void _writeSGBBits(struct GB* gb, int bits) {
|
static void _writeSGBBits(struct GB* gb, int bits) {
|
||||||
if (!bits) {
|
if (!bits) {
|
||||||
|
@ -557,10 +558,26 @@ static uint8_t _readKeys(struct GB* gb) {
|
||||||
return gb->memory.io[REG_JOYP];
|
return gb->memory.io[REG_JOYP];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t _readKeysFiltered(struct GB* gb) {
|
||||||
|
uint8_t keys = _readKeys(gb);
|
||||||
|
if (!gb->allowOpposingDirections && (keys & 0x30) == 0x20) {
|
||||||
|
unsigned rl = keys & 0x03;
|
||||||
|
unsigned ud = keys & 0x0C;
|
||||||
|
keys &= 0xF0;
|
||||||
|
if (rl != 0x03) {
|
||||||
|
keys |= rl;
|
||||||
|
}
|
||||||
|
if (ud != 0x0C) {
|
||||||
|
keys |= ud;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t GBIORead(struct GB* gb, unsigned address) {
|
uint8_t GBIORead(struct GB* gb, unsigned address) {
|
||||||
switch (address) {
|
switch (address) {
|
||||||
case REG_JOYP:
|
case REG_JOYP:
|
||||||
return _readKeys(gb);
|
return _readKeysFiltered(gb);
|
||||||
case REG_IE:
|
case REG_IE:
|
||||||
return gb->memory.ie;
|
return gb->memory.ie;
|
||||||
case REG_WAVE_0:
|
case REG_WAVE_0:
|
||||||
|
|
|
@ -239,6 +239,11 @@ static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fakeBool = 0;
|
||||||
|
mCoreConfigGetIntValue(config, "allowOpposingDirections", &fakeBool);
|
||||||
|
gba->allowOpposingDirections = fakeBool;
|
||||||
|
|
||||||
|
mCoreConfigCopyValue(&core->config, config, "allowOpposingDirections");
|
||||||
mCoreConfigCopyValue(&core->config, config, "gba.bios");
|
mCoreConfigCopyValue(&core->config, config, "gba.bios");
|
||||||
|
|
||||||
#ifndef DISABLE_THREADING
|
#ifndef DISABLE_THREADING
|
||||||
|
|
Loading…
Reference in New Issue