SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit b580e63c3712a70ec4e4c56122bbbbe54401f161 parent d263a8f6f83d8fd7379cc6ec26667138e5034c1c Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 10 Oct 2021 02:55:12 +0300 Fix 7-part SGB commands Diffstat:
| M | Core/sgb.c | 25 | +++++++++++++------------ |
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/Core/sgb.c b/Core/sgb.c @@ -434,9 +434,6 @@ void GB_sgb_write(GB_gameboy_t *gb, uint8_t value) return; } if (gb->sgb->disable_commands) return; - if (gb->sgb->command_write_index >= sizeof(gb->sgb->command) * 8) { - return; - } uint16_t command_size = (gb->sgb->command[0] & 7 ?: 1) * SGB_PACKET_SIZE * 8; if ((gb->sgb->command[0] & 0xF1) == 0xF1) { @@ -468,10 +465,12 @@ void GB_sgb_write(GB_gameboy_t *gb, uint8_t value) gb->sgb->ready_for_stop = false; } else { - gb->sgb->command_write_index++; - gb->sgb->ready_for_pulse = false; - if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) { - gb->sgb->ready_for_stop = true; + if (gb->sgb->command_write_index < sizeof(gb->sgb->command) * 8) { + gb->sgb->command_write_index++; + gb->sgb->ready_for_pulse = false; + if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) { + gb->sgb->ready_for_stop = true; + } } } break; @@ -485,11 +484,13 @@ void GB_sgb_write(GB_gameboy_t *gb, uint8_t value) memset(gb->sgb->command, 0, sizeof(gb->sgb->command)); } else { - gb->sgb->command[gb->sgb->command_write_index / 8] |= 1 << (gb->sgb->command_write_index & 7); - gb->sgb->command_write_index++; - gb->sgb->ready_for_pulse = false; - if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) { - gb->sgb->ready_for_stop = true; + if (gb->sgb->command_write_index < sizeof(gb->sgb->command) * 8) { + gb->sgb->command[gb->sgb->command_write_index / 8] |= 1 << (gb->sgb->command_write_index & 7); + gb->sgb->command_write_index++; + gb->sgb->ready_for_pulse = false; + if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) { + gb->sgb->ready_for_stop = true; + } } } break;
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.