fix(cpu): break cycle execution loop if waiting for key

This commit is contained in:
Stevan Freeborn
2026-07-18 15:16:07 -05:00
parent d975c16ed7
commit 35572cb76a
+3
View File
@@ -278,6 +278,9 @@ int main(int argc, char *argv[]) {
} }
for(int i = 0; i < CYCLES_PER_FRAME; i++) { for(int i = 0; i < CYCLES_PER_FRAME; i++) {
if (chip->waiting_for_key) {
break;
}
// read 2 bytes at a time from memory // read 2 bytes at a time from memory
// reading first 1 byte shifting left 1 byte ORing 2 byte // reading first 1 byte shifting left 1 byte ORing 2 byte
uint16_t opcode = (chip->memory[chip->pc] << 8) | (chip->memory[chip->pc + 1]); uint16_t opcode = (chip->memory[chip->pc] << 8) | (chip->memory[chip->pc + 1]);