Fix 7-part SGB commands
This commit is contained in:
parent
d263a8f6f8
commit
b580e63c37
25
Core/sgb.c
25
Core/sgb.c
@ -434,9 +434,6 @@ void GB_sgb_write(GB_gameboy_t *gb, uint8_t value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gb->sgb->disable_commands) 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;
|
uint16_t command_size = (gb->sgb->command[0] & 7 ?: 1) * SGB_PACKET_SIZE * 8;
|
||||||
if ((gb->sgb->command[0] & 0xF1) == 0xF1) {
|
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;
|
gb->sgb->ready_for_stop = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gb->sgb->command_write_index++;
|
if (gb->sgb->command_write_index < sizeof(gb->sgb->command) * 8) {
|
||||||
gb->sgb->ready_for_pulse = false;
|
gb->sgb->command_write_index++;
|
||||||
if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) {
|
gb->sgb->ready_for_pulse = false;
|
||||||
gb->sgb->ready_for_stop = true;
|
if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) {
|
||||||
|
gb->sgb->ready_for_stop = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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));
|
memset(gb->sgb->command, 0, sizeof(gb->sgb->command));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gb->sgb->command[gb->sgb->command_write_index / 8] |= 1 << (gb->sgb->command_write_index & 7);
|
if (gb->sgb->command_write_index < sizeof(gb->sgb->command) * 8) {
|
||||||
gb->sgb->command_write_index++;
|
gb->sgb->command[gb->sgb->command_write_index / 8] |= 1 << (gb->sgb->command_write_index & 7);
|
||||||
gb->sgb->ready_for_pulse = false;
|
gb->sgb->command_write_index++;
|
||||||
if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) {
|
gb->sgb->ready_for_pulse = false;
|
||||||
gb->sgb->ready_for_stop = true;
|
if (((gb->sgb->command_write_index) & (SGB_PACKET_SIZE * 8 - 1)) == 0) {
|
||||||
|
gb->sgb->ready_for_stop = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user