Skip to content

Low (signal) level cycle-accurate (hopefully?) Z80 emulator

License

Notifications You must be signed in to change notification settings

itsmevjnk/llz80emu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llz80emu

llz80emu is a clock-accurate Zilog Z80 emulator written in C++.

The emulator's behaviour is modeled using information from the following sources:

To maintain emulation performance and simplicity, the inner operation (ie. during instruction execution) is not accurately modeled; however, the emulator should have the same number of cycles and behaviour for instructions as a real Z80 CPU.

The emulator passes the JSMoo unit test suite, albeit with some instruction timing discrepancies, as well as raddad772's Z80 unit tests to a slightly lesser degree due to instruction timing discrepancies (TODO: check in more detail). The emulator also passes all zexall tests.

Installation

The emulator can be compiled using Visual Studio with the provided solution file, as well as with CMake.

Usage

llz80emu is provided as a library; ie. a frontend is required to do anything useful with it.

The emulator provides the following publicly accessible methods in the z80emu class:

  • z80emu::z80emu(bool clk): Instantiate a Z80 emulator object with the specified initial CLK pin state.
  • void z80emu::set_clkpin(bool state): Set the CLK pin state without triggering the CPU's operation.
  • z80_pins_t z80emu::clock(z80_pinbits_t state): Emulate the CPU on a state transition (rising/falling edge) of the CLK pin. Input pins' states are to be provided through the state argument, and the method returns the new pins' states and directions (see pins.h).
  • void z80emu::trigger_nmi(): Trigger the NMI pin on the CPU. This method is to be called on the falling edge of the NMI pin.
  • z80_pins_t z80emu::get_pins(): Retrieve the emulator's pins' states and directions, without clocking the CPU.
  • z80_registers_t z80emu::get_regs(): Retrieve the emulator's register values.
  • void z80emu::set_regs(const z80_registers_t& regs): Set the emulator's register values.

Contributing

Pull requests and discussions/bug reports through Issues are welcome.

License

MIT

About

Low (signal) level cycle-accurate (hopefully?) Z80 emulator

Resources

License

Stars

Watchers

Forks

Packages

No packages published