From 869fee3eaa0b8bdb0347d0c682a660168f104a01 Mon Sep 17 00:00:00 2001 From: redcode Date: Tue, 6 Nov 2018 06:36:15 +0100 Subject: [PATCH] README.md --- README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 92196ac..5f9c531 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Name | Description ### `Z80` emulator instance This structure contains the state of the emulated CPU and callback pointers necessary to interconnect the emulator with external logic. There is no constructor function, so, before using an object of this type, some of its members must be initialized, in particular the following: `context`, `read`, `write`, `in`, `out`, `int_data` and `halt`. -
+ ```C zusize cycles; ``` @@ -64,7 +64,7 @@ zusize cycles; Number of cycles executed in the current call to `z80_run`. **Details** `z80run` sets this variable to `0` before starting to execute instructions and its value persists after returning. The callbacks can use this variable to know during what cycle they are being called. -
+ ```C void *context; ``` @@ -72,7 +72,7 @@ void *context; The value used as the first argument when calling a callback. **Details** This variable should be initialized before using the emulator and can be used to reference the context/instance of the machine being emulated. -
+ ```C zuint8 (* read)(void *context, zuint16 address); ``` @@ -83,7 +83,7 @@ Callback: Called when the CPU needs to read 8 bits from memory. `address` → The memory address to read from. **Returns** The 8 bits read from memory. -
+ ```C void (* write)(void *context, zuint16 address, zuint8 value); ``` @@ -93,7 +93,7 @@ Callback: Called when the CPU needs to write 8 bits to memory. `context` → The value of the member `context`. `address` → The memory address to write to. `value` → The value to write. -
+ ```C zuint8 (* in)(void *context, zuint16 port); ``` @@ -104,7 +104,7 @@ Callback: Called when the CPU needs to read 8 bits from an I/O port. `port` → The number of the I/O port to read from. **Returns** The 8 bits read from the I/O port. -
+ ```C void (* out)(void *context, zuint16 port, zuint8 value); ``` @@ -114,7 +114,7 @@ Callback: Called when the CPU needs to write 8 bits to an I/O port. `context` → The value of the member `context`. `port` → The number of the I/O port to write to. `value` → The value to write. -
+ ```C zuint32 (* int_data)(void *context); ``` @@ -124,7 +124,7 @@ Callback: Called when the CPU needs to read one instruction from the data bus to `context` → The value of the member `context`. **Returns** A 32-bit value containing the bytes of an instruction. The instruction must begin at the most significant byte (big endian). -
+ ```C void (* halt)(void *context, zboolean state); ``` @@ -135,7 +135,7 @@ This callback is **optional** and must be set to `NULL` if not used. **Parameters** `context` → The value of the member `context`. `state` → `TRUE` if halted; `FALSE` otherwise. -
+ ```C ZZ80State state; ``` @@ -143,7 +143,7 @@ ZZ80State state; CPU registers and internal bits. **Details** It contains the state of the registers, as well as the interrupt flip-flops, variables related to interrupts and other necessary flags. This is what a debugger should use as data source. -
+ ```C zuint8 r7; ``` @@ -151,7 +151,7 @@ zuint8 r7; Backup of the 7th bit of the R register. **Details** The value of the R register is incremented as instructions are executed, but its most significant bit remains unchanged. For optimization reasons, this bit is saved at the beginning of the execution of `z80_run` and restored before returning. If an instruction directly affects the R register, this variable is also updated accordingly. -
+ ```C Z16Bit xy; ``` @@ -159,7 +159,7 @@ Z16Bit xy; Temporay IX/IY register for instructions with `DDh`/`FDh` prefix. **Details** Since instructions with prefix `DDh` and `FDh` behave similarly, differing only in the use of register IX or IY, for reasons of size optimization, a single register is used that acts as both. During opcode analysis, the IX or IY register is copied to this variable and, once the instruction emulation is complete, its contents are copied back to the appropriate register. -
+ ```C Z32Bit data; ``` @@ -167,7 +167,7 @@ Z32Bit data; Temporary storage for opcode fetching. **Details** This is an internal private variable. -
+ ### Public Functions @@ -179,7 +179,7 @@ Changes the CPU power status. **Parameters** `object` → A pointer to a Z80 emulator instance. `state` → `TRUE` = power ON; `FALSE` = power OFF. -
+ ```C void z80_reset(Z80 *object); ``` @@ -189,7 +189,7 @@ Resets the CPU. This is equivalent to a pulse in the `RESET` line of a real Z80. **Parameters** `object` → A pointer to a Z80 emulator instance. -
+ ```C zusize z80_run(Z80 *object, zusize cycles); ``` @@ -202,7 +202,7 @@ Given the fact that one Z80 instruction needs between 4 and 23 cycles to be exec `cycles` → The number of `cycles` to be executed. **Returns** The number of cycles executed. -
+ ```C void z80_nmi(Z80 *object); ``` @@ -212,7 +212,7 @@ Performs a non-maskable interrupt. This is equivalent to a pulse in the `NMI` line of a real Z80. **Parameters** `object` → A pointer to a Z80 emulator instance. -
+ ```C void z80_int(Z80 *object, zboolean state); ```