2 releases
Uses old Rust 2015
0.1.1 | Jul 31, 2016 |
---|---|
0.1.0 | Jul 29, 2016 |
#28 in #z80
130KB
3.5K
SLoC
rz80 (work in progress)
Z80 chip family emulator library written in Rust.
Usage
# Cargo.toml
[dependencies]
rz80 = "0.1.0"
Examples
Run the ZEXDOC and ZEXALL conformance tests:
> cargo test --release -- --nocapture --ignored
Run the Z1013 home computer emulator:
> cargo run --release --example z1013
In the Z1013 emulator, start the BASIC interpreter with:
# J 300[Enter]
The BASIC interpreter will startup and ask for MEMORY SIZE, just hit Enter.
Enter and run a simple Hello World program:
>AUTO[Enter]
10 FOR I=0 TO 10[Enter]
20 PRINT "HELLO WORLD!"[Enter]
30 NEXT[Enter]
40 [Escape]
OK
>LIST[Enter]
...
>RUN[Enter]
...
>BYE[Enter]
lib.rs
:
rz80 is a Z80 chip family emulation library written in Rust which can be used as basis for writing a full Z80-based computer emulator.
Overview
The rz80 library provides chip emulators for the Z80 CPU, PIO (parallel in/out), CTC (counter/timer channels) and a Bus trait which defines how the chips are wired together in a specific emulated system.
Writing a home computer emulator usually involves the following steps
- import the required chips
- import ROM dumps using the include_bytes! macro
- define a State struct which holds emulator state required in addition to the chip state
- define a System struct which embeds all chips and the State struct wrapped in RefCells
- write a System::poweron() function which initializes the embedded chips and state objects, initializes the memory map and sets the CPU PC register to the ROM dump start address
- write a video-decoder function which generates a linear RGBA8 framebuffer each frame
- implement the Bus trait on the System struct, this usually involves:
- the keyboard emulation
- memory bank switching
- forward interrupt requests between the various hardware components
- sound generation
- implement the main loop which creates a window, forwards keyboard input, and steps the chips emulators forward
Very simple 8-bit home computer systems (similar to the ZX81) don't require any additional code, more complex home computers will require additional custom chips emulations that are not part of the rz80 library.
Check out the two included example emulators:
> cargo run --release --example z1013
> cargo run --release --example kc87