Cycle-accurate emulator 👌

Description

To become a rock star emulator Boytacean has to provide cycle-accurate emulation.

Many tests would allow testing of the cycle-accurate components.

More information can be found here (Game Boy emulator testing).

There is also some good feedback in a Boytacean Reddit post reply that brings some insights on why some games fail to be emulated.

There's a good comparison of emulators that can be used as a reference for the tests they pass: https://daid.github.io/GBEmulatorShootout/.

Some of the Blargg tests may help in the implementation of a more accurate emulator, listed per order of interest here:

  1. https://github.com/retrio/gb-test-roms/blob/master/interrupt_time/interrupt_time.s
  2. https://github.com/retrio/gb-test-roms/blob/master/mem_timing/readme.txt

A good emulator to obtain inspiration is:

https://github.com/7thSamurai/Azayaka

Sameboy also adopts the same pre-emptive cycle jumping strategy as we can see here:

https://github.com/LIJI32/SameBoy/blob/master/Core/sm83_cpu.c#L353C9-L353C26

Challenges

One of the most significant issues preventing Boytacean from reaching cycle accuracy is the inability to trigger the clock from every single component - most notably the CPU.

It must be possible to trigger a new clock at every stage of the CPU processing. This ability must exist without any significant performance impact.

image

Related

Reference

image

Edited by João Magalhães