peanut-gb: detect when ROM has halted forever

Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
Mahyar Koshkouei
2022-03-23 23:40:51 +00:00
parent 41c55df139
commit 25d1e99571
2 changed files with 23 additions and 2 deletions
+15 -2
View File
@@ -128,11 +128,24 @@ int main(void)
gb_init_serial(&gb, gb_serial_tx, gb_serial_rx);
while(1)
gb_run_frame(&gb);
uint_fast32_t instrs = 0;
uint64_t start_time = time_us_64();
uint64_t end_time;
while(!gb.direct.ended)
{
__gb_step_cpu(&gb);
instrs++;
}
end_time = time_us_64();
puts("\nEmulation Ended");
printf("Instructions: %u\n"
"Time: %llu us\n", instrs, end_time-start_time);
/* Sleep forever. */
sleep:
stdio_flush();
while(1)
__wfi();