summaryrefslogtreecommitdiff
path: root/include/z80.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/z80.h')
-rw-r--r--include/z80.h115
1 files changed, 60 insertions, 55 deletions
diff --git a/include/z80.h b/include/z80.h
index 0b7424b..000b950 100644
--- a/include/z80.h
+++ b/include/z80.h
@@ -27,14 +27,13 @@
#ifndef Z80_H
#define Z80_H "$Id$"
-/* ---------------------------------------- TYPES
+/* Configuration
*/
+#include "z80_config.h"
-/* The processor
-*/
-struct Z80;
-typedef struct Z80 Z80;
+/* ---------------------------------------- TYPES
+*/
/* Large unsigned type
*/
@@ -56,6 +55,53 @@ typedef signed char Z80Relative;
typedef unsigned short Z80Word;
+/* A Z80 16-bit register. To access the HI/LO component use the indexes
+ Z80_HI_WORD and Z80_LO_WORD which will be initialised once Z80Init has been
+ called.
+*/
+typedef union
+{
+ Z80Word w;
+ Z80Byte b[2];
+} Z80Reg;
+
+extern int Z80_HI_WORD;
+extern int Z80_LO_WORD;
+
+
+/* The processor
+*/
+struct Z80Private;
+
+typedef struct
+{
+ Z80Word PC;
+
+ Z80Reg AF;
+ Z80Reg BC;
+ Z80Reg DE;
+ Z80Reg HL;
+
+ Z80Word AF_;
+ Z80Word BC_;
+ Z80Word DE_;
+ Z80Word HL_;
+
+ Z80Reg IX;
+ Z80Reg IY;
+
+ Z80Word SP;
+
+ Z80Byte IFF1;
+ Z80Byte IFF2;
+ Z80Byte IM;
+ Z80Byte I;
+ Z80Byte R;
+
+ struct Z80Private *priv;
+} Z80;
+
+
/* Interfaces used to handle memory
*/
typedef Z80Byte (*Z80ReadMemory)(Z80 *cpu, Z80Word address);
@@ -95,36 +141,6 @@ typedef enum
} Z80CallbackReason;
-/* Get/settable state of the Z80
-*/
-typedef struct
-{
- Z80Word PC;
- Z80Word SP;
-
- Z80Val cycle;
-
- Z80Word AF;
- Z80Word BC;
- Z80Word DE;
- Z80Word HL;
-
- Z80Word AF_; /* Alternate registers */
- Z80Word BC_;
- Z80Word DE_;
- Z80Word HL_;
-
- Z80Word IX;
- Z80Word IY;
-
- Z80Byte IFF1;
- Z80Byte IFF2;
- Z80Byte IM;
- Z80Byte I;
- Z80Byte R;
-} Z80State;
-
-
/* Flags in the F register
*/
typedef enum
@@ -157,11 +173,16 @@ typedef struct
/* Initialises the processor.
*/
+#ifdef ENABLE_ARRAY_MEMORY
+Z80 *Z80Init(Z80ReadPort read_port,
+ Z80WritePort write_port);
+#else
Z80 *Z80Init(Z80ReadMemory read_memory,
Z80WriteMemory write_memory,
Z80ReadPort read_port,
Z80WritePort write_port,
Z80ReadMemory read_for_disassem);
+#endif
/* Resets the processor.
@@ -169,21 +190,6 @@ Z80 *Z80Init(Z80ReadMemory read_memory,
void Z80Reset(Z80 *cpu);
-/* Sets the PC
-*/
-void Z80SetPC(Z80 *cpu, Z80Word PC);
-
-
-/* Gets the PC
-*/
-Z80Word Z80GetPC(Z80 *cpu);
-
-
-/* Sets the cycle count to the specified count
-*/
-void Z80ResetCycles(Z80 *cpu, Z80Val cycles);
-
-
/* Lodge a callback to be invoked after special events. Returns FALSE
if the callback couldn't be lodged (there is a max of 10 callbacks per
reason).
@@ -223,11 +229,10 @@ int Z80SingleStep(Z80 *cpu);
void Z80Exec(Z80 *cpu);
-/* Interrogate the state of the Z80
+/* Manipulate the cylce count of the Z80
*/
Z80Val Z80Cycles(Z80 *cpu);
-void Z80GetState(Z80 *cpu, Z80State *state);
-void Z80SetState(Z80 *cpu, const Z80State *state);
+void Z80ResetCycles(Z80 *cpu, Z80Val cycles);
/* Set address to label mappings for the disassembler
@@ -235,8 +240,8 @@ void Z80SetState(Z80 *cpu, const Z80State *state);
void Z80SetLabels(Z80Label labels[]);
-/* Simple disassembly of memory accessed through read_for_disassem.
- addr is updated on exit.
+/* Simple disassembly of memory accessed through read_for_disassem, or
+ Z80_MEMORY as appropriate. addr is updated on exit.
*/
const char *Z80Disassemble(Z80 *cpu, Z80Word *addr);