summaryrefslogtreecommitdiff
path: root/z80.h
diff options
context:
space:
mode:
Diffstat (limited to 'z80.h')
-rw-r--r--z80.h57
1 files changed, 44 insertions, 13 deletions
diff --git a/z80.h b/z80.h
index 000b950..eb3ec71 100644
--- a/z80.h
+++ b/z80.h
@@ -2,11 +2,11 @@
z80 - Z80 emulation
- Copyright (C) 2006 Ian Cowburn <ianc@noddybox.co.uk>
+ Copyright (C) 2021 Ian Cowburn <ianc@noddybox.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ along with this program; if not, see <http://www.gnu.org/licenses/>
-------------------------------------------------------------------------
@@ -27,6 +26,8 @@
#ifndef Z80_H
#define Z80_H "$Id$"
+#include <stdio.h>
+
/* Configuration
*/
#include "z80_config.h"
@@ -55,20 +56,30 @@ 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.
+/* A Z80 16-bit register made up of 2 8-bit registers.
*/
+#ifdef Z80_LITTLE_ENDIAN
+typedef struct
+{
+ Z80Byte lo;
+ Z80Byte hi;
+} Z80RegPair;
+#endif
+
+#ifdef Z80_BIG_ENDIAN
+typedef struct
+{
+ Z80Byte hi;
+ Z80Byte lo;
+} Z80RegPair;
+#endif
+
typedef union
{
Z80Word w;
- Z80Byte b[2];
+ Z80RegPair b;
} Z80Reg;
-extern int Z80_HI_WORD;
-extern int Z80_LO_WORD;
-
-
/* The processor
*/
struct Z80Private;
@@ -133,13 +144,23 @@ typedef int (*Z80Callback)(Z80 *cpu, Z80Val data);
*/
typedef enum
{
- eZ80_Instruction, /* data = no cycles since reset */
+ eZ80_Instruction, /* data = cycles as returned by Z80Cycles */
eZ80_EDHook, /* data = byte after ED opcode (only for NOP opcodes) */
eZ80_Halt, /* data = 1 halt raised, 0 halt cleared by int */
eZ80_RETI, /* data = ignored */
eZ80_NO_CALLBACK /* leave at end */
} Z80CallbackReason;
+/* Defines cycle timers
+*/
+typedef enum
+{
+ Z80_TIMER_1,
+ Z80_TIMER_2,
+ Z80_TIMER_3,
+ Z80_NO_TIMERS
+} Z80Timer;
+
/* Flags in the F register
*/
@@ -234,6 +255,11 @@ void Z80Exec(Z80 *cpu);
Z80Val Z80Cycles(Z80 *cpu);
void Z80ResetCycles(Z80 *cpu, Z80Val cycles);
+/* Timers that count in cycle counts
+*/
+Z80Val Z80GetTimer(Z80 *cpu, Z80Timer timer);
+void Z80SetTimer(Z80 *cpu, Z80Timer timer, Z80Val cycles);
+
/* Set address to label mappings for the disassembler
*/
@@ -245,6 +271,11 @@ void Z80SetLabels(Z80Label labels[]);
*/
const char *Z80Disassemble(Z80 *cpu, Z80Word *addr);
+/* Allows the CPU state to be saved/loaded from a stream
+*/
+void Z80SaveSnapshot(Z80 *cpu, FILE *fp);
+void Z80LoadSnapshot(Z80 *cpu, FILE *fp);
+
#endif
/* END OF FILE */