README.md
This commit is contained in:
28
README.md
28
README.md
@@ -7,7 +7,7 @@ This is a very accurate [Z80](http://en.wikipedia.org/wiki/Zilog_Z80) [emulator]
|
||||
If you are looking for an accurate Zilog Z80 CPU emulator for your project maybe you have found the correct one. I use this core in the [ZX Spectrum emulator](http://github.com/redcode/mZX) I started as hobby.
|
||||
|
||||
|
||||
## Building
|
||||
# Building
|
||||
|
||||
In order to compile you must install [Z](http://github.com/redcode/Z), a **header only** library which provides types, macros, inline functions, and a lot of utilities to detect the particularities of the compiler and the target system at compile time. This is the only dependency, the standard C library and its headers are not used and the emulator doesn't need to be dynamically linked against any library.
|
||||
|
||||
@@ -38,9 +38,9 @@ CPU_Z80_HIDE_ABI | Makes the `abi_emulation_cpu_z80` private.
|
||||
CPU_Z80_USE_LOCAL_HEADER | Use this if you have imported _Z80.h_ and _Z80.c_ to your project. _Z80.c_ will include `"Z80.h"` instead of `<emulation/CPU/Z80.h>`.
|
||||
|
||||
|
||||
## API
|
||||
# API
|
||||
|
||||
### `z80_power`
|
||||
## `z80_power`
|
||||
Changes the CPU power status.
|
||||
|
||||
**Prototype**
|
||||
@@ -51,7 +51,7 @@ void z80_power(Z80 *object, zboolean state);
|
||||
* `object` → A pointer to a Z80 emulator instance object.
|
||||
* `state` → `TRUE` for power ON, `FALSE` otherwise.
|
||||
|
||||
### `z80_reset`
|
||||
## `z80_reset`
|
||||
Resets the CPU by reinitializing its variables and sets its registers to the state they would be in a real Z80 CPU after a pulse in the `RESET` line.
|
||||
|
||||
**Prototype**
|
||||
@@ -62,7 +62,7 @@ void z80_reset(Z80 *object);
|
||||
**Parameters**
|
||||
* `object` → A pointer to a Z80 emulator instance object.
|
||||
|
||||
### `z80_run`
|
||||
## `z80_run`
|
||||
Runs the CPU for a given number of ```cycles```.
|
||||
|
||||
**Prototype**
|
||||
@@ -80,7 +80,7 @@ The number of cycles executed.
|
||||
**Discusion**
|
||||
Given the fact that one Z80 instruction needs between 4 and 23 cycles to be executed, it is not always possible to run the CPU the exact number of cycles specfified.
|
||||
|
||||
### `z80_nmi`
|
||||
## `z80_nmi`
|
||||
Performs a non-maskable interrupt. This is equivalent to a pulse in the `NMI` line of a real Z80 CPU.
|
||||
|
||||
**Prototype**
|
||||
@@ -91,7 +91,7 @@ void z80_nmi(Z80 *object);
|
||||
**Parameters**
|
||||
* `object` → A pointer to a Z80 emulator instance object.
|
||||
|
||||
### `z80_int`
|
||||
## `z80_int`
|
||||
Changes the state of the maskable interrupt. This is equivalent to a change in the `INT` line of a real Z80 CPU.
|
||||
|
||||
**Prototype**
|
||||
@@ -104,10 +104,10 @@ void z80_int(Z80 *object, zboolean state);
|
||||
* `state` → `TRUE` = set line high, `FALSE` = set line low.
|
||||
|
||||
|
||||
## Callbacks
|
||||
# Callbacks
|
||||
Before using an instance of the Z80 emulator, its callback pointers must be initialized with the pointers to the functions that your program must provide in order to make possible for the CPU to access the emulated machine's resources. All callbacks are mandatory except `halt`, which is optional and must be set to `NULL` if not used.
|
||||
|
||||
### `read`
|
||||
## `read`
|
||||
Called when the CPU needs to read 8 bits from memory.
|
||||
|
||||
**Prototype**
|
||||
@@ -122,7 +122,7 @@ zuint8 (* read)(void *context, zuint16 address);
|
||||
**Return value**
|
||||
The 8 bits read from memory.
|
||||
|
||||
### `write`
|
||||
## `write`
|
||||
Called when the CPU needs to write 8 bits to memory.
|
||||
|
||||
**Prototype**
|
||||
@@ -135,7 +135,7 @@ void (* write)(void *context, zuint16 address, zuint8 value);
|
||||
* `address` → The memory address to write.
|
||||
* `value` → The value to write in `address`.
|
||||
|
||||
### `in`
|
||||
## `in`
|
||||
Called when the CPU needs to read 8 bits from an I/O port.
|
||||
|
||||
**Prototype**
|
||||
@@ -150,7 +150,7 @@ zuint8 (* in)(void *context, zuint16 port);
|
||||
**Return value**
|
||||
The 8 bits read from the I/O port.
|
||||
|
||||
### `out`
|
||||
## `out`
|
||||
Called when the CPU needs to write 8 bits to an I/O port.
|
||||
|
||||
**Prototype**
|
||||
@@ -163,7 +163,7 @@ void (* out)(void *context, zuint16 port, zuint8 value);
|
||||
* `port` → The number of the I/O port.
|
||||
* `value` → The value to write.
|
||||
|
||||
### `int_data`
|
||||
## `int_data`
|
||||
Called when the CPU starts executing a maskable interrupt and the interruption mode is 0. This callback must return the instruction that the CPU would read from the data bus in this case.
|
||||
|
||||
**Prototype**
|
||||
@@ -177,7 +177,7 @@ zuint32 (* int_data)(void *context);
|
||||
**Return value**
|
||||
A 32-bit value containing the bytes of an instruction. The instruction must begin at the most significant byte of the value.
|
||||
|
||||
### `halt`
|
||||
## `halt`
|
||||
Called when the CPU enters or exits the halt state.
|
||||
|
||||
**Prototype**
|
||||
|
||||
Reference in New Issue
Block a user