SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit cdc3321c3613911d3e91a8f7c5713461466bb47e parent eaccd792ed75738603c97fc6367e9bf8bfb41573 Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 19 Dec 2021 00:28:24 +0200 Add an API to allow illegal inputs Diffstat:
| M | Core/gb.h | 1 | + |
| M | Core/joypad.c | 17 | ++++++++++++----- |
| M | Core/joypad.h | 1 | + |
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Core/gb.h b/Core/gb.h @@ -657,6 +657,7 @@ struct GB_gameboy_internal_s { bool objects_disabled; bool background_disabled; bool joyp_accessed; + bool illegal_inputs_allowed; /* Timing */ uint64_t last_sync; diff --git a/Core/joypad.c b/Core/joypad.c @@ -30,11 +30,13 @@ void GB_update_joyp(GB_gameboy_t *gb) gb->io_registers[GB_IO_JOYP] |= (!gb->keys[current_player][i]) << i; } /* Forbid pressing two opposing keys, this breaks a lot of games; even if it's somewhat possible. */ - if (!(gb->io_registers[GB_IO_JOYP] & 1)) { - gb->io_registers[GB_IO_JOYP] |= 2; - } - if (!(gb->io_registers[GB_IO_JOYP] & 4)) { - gb->io_registers[GB_IO_JOYP] |= 8; + if (likely(!gb->illegal_inputs_allowed)) { + if (!(gb->io_registers[GB_IO_JOYP] & 1)) { + gb->io_registers[GB_IO_JOYP] |= 2; + } + if (!(gb->io_registers[GB_IO_JOYP] & 4)) { + gb->io_registers[GB_IO_JOYP] |= 8; + } } break; @@ -131,3 +133,8 @@ void GB_clear_joyp_accessed(GB_gameboy_t *gb) { gb->joyp_accessed = false; } + +void GB_set_allow_illegal_inputs(GB_gameboy_t *gb, bool allow) +{ + gb->illegal_inputs_allowed = allow; +} diff --git a/Core/joypad.h b/Core/joypad.h @@ -36,6 +36,7 @@ void GB_set_key_mask_for_player(GB_gameboy_t *gb, GB_key_mask_t mask, unsigned p void GB_icd_set_joyp(GB_gameboy_t *gb, uint8_t value); bool GB_get_joyp_accessed(GB_gameboy_t *gb); void GB_clear_joyp_accessed(GB_gameboy_t *gb); +void GB_set_allow_illegal_inputs(GB_gameboy_t *gb, bool allow); #ifdef GB_INTERNAL
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.