fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/cpu/e8080/internal.h *
7 * Created: 2012-11-28 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2012-2025 Hampa Hug <hampa@hampa.ch> *
9 *****************************************************************************/
10
11/*****************************************************************************
12 * This program is free software. You can redistribute it and / or modify it *
13 * under the terms of the GNU General Public License version 2 as published *
14 * by the Free Software Foundation. *
15 * *
16 * This program is distributed in the hope that it will be useful, but *
17 * WITHOUT ANY WARRANTY, without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
19 * Public License for more details. *
20 *****************************************************************************/
21
22
23#ifndef PCE_E8080_INTERNAL_H
24#define PCE_E8080_INTERNAL_H 1
25
26
27#include "e8080.h"
28
29
30#define e8080_set_clk(cpu, cnt, clk) do { \
31 (cpu)->pc = ((cpu)->pc + (cnt)) & 0xffff; \
32 (cpu)->delay += (clk); \
33 } while (0)
34
35#define e8080_get_inst1(c) do { \
36 (c)->inst[1] = e8080_get_mem8 (c, (c->pc + 1) & 0xffff); \
37 } while (0)
38
39#define e8080_get_inst2(c) do { \
40 (c)->inst[2] = e8080_get_mem8 (c, (c->pc + 2) & 0xffff); \
41 } while (0)
42
43#define e8080_get_inst12(c) do { \
44 (c)->inst[1] = e8080_get_mem8 (c, (c->pc + 1) & 0xffff); \
45 (c)->inst[2] = e8080_get_mem8 (c, (c->pc + 2) & 0xffff); \
46 } while (0)
47
48#define e8080_get_inst23(c) do { \
49 (c)->inst[2] = e8080_get_mem8 (c, (c->pc + 2) & 0xffff); \
50 (c)->inst[3] = e8080_get_mem8 (c, (c->pc + 3) & 0xffff); \
51 } while (0)
52
53#define e8080_uint16(lo, hi) \
54 ((((hi) & 0xff) << 8) | ((lo) & 0xff))
55
56#define e8080_sext8(v) (((v) & 0x80) ? ((v) | 0xff00) : ((v) & 0x007f))
57
58#define e8080_get_ixd(c, i) (((c)->ix + e8080_sext8 ((c)->inst[(i)])) & 0xffff)
59#define e8080_get_iyd(c, i) (((c)->iy + e8080_sext8 ((c)->inst[(i)])) & 0xffff)
60
61#define e8080_inc_r(c) do { \
62 (c)->r = ((c)->r & 0x80) | (((c)->r + 1) & 0x7f); \
63 } while (0)
64
65
66enum {
67 ARG_NONE,
68 ARG_STR,
69 ARG_OPC8,
70 ARG_IMM8,
71 ARG_IM16,
72 ARG_AD16,
73 ARG_JMP8,
74 ARG_JP16,
75 ARG_IXD,
76 ARG_IYD,
77 ARG_BIT
78};
79
80typedef struct {
81 unsigned char opcode;
82 const char *mnemonic;
83 const char *arg1s;
84 const char *arg2s;
85 unsigned char arg1;
86 unsigned char arg2;
87 unsigned char size;
88 unsigned char cycles;
89 unsigned short flags;
90} e8080_dop_t;
91
92
93int e8080_hook_exec (e8080_t *c);
94int e8080_hook_undefined (e8080_t *c);
95int e8080_hook_rst (e8080_t *c);
96
97
98void e8080_set_psw_szp (e8080_t *c, unsigned char val, unsigned set, unsigned reset);
99void e8080_set_psw_log (e8080_t *c, unsigned char val);
100void e8080_set_psw_inc (e8080_t *c, unsigned char val);
101void e8080_set_psw_dec (e8080_t *c, unsigned char val);
102void e8080_set_psw_add (e8080_t *c, unsigned char s1, unsigned char s2);
103void e8080_set_psw_sub (e8080_t *c, unsigned char s1, unsigned char s2);
104void e8080_set_psw_adc (e8080_t *c, unsigned char s1, unsigned char s2, unsigned char s3);
105void e8080_set_psw_sbb (e8080_t *c, unsigned char s1, unsigned char s2, unsigned char s3);
106
107void z80_set_psw_rot (e8080_t *c, unsigned char val, int cf);
108void z80_set_psw_inc (e8080_t *c, unsigned char val);
109void z80_set_psw_dec (e8080_t *c, unsigned char val);
110void z80_set_psw_add (e8080_t *c, unsigned d, unsigned char s1, unsigned char s2);
111void z80_set_psw_add16 (e8080_t *c, unsigned long d, unsigned s1, unsigned s2);
112void z80_set_psw_add16_2 (e8080_t *c, unsigned long d, unsigned s1, unsigned s2);
113void z80_set_psw_sub (e8080_t *c, unsigned d, unsigned char s1, unsigned char s2);
114void z80_set_psw_sub16_2 (e8080_t *c, unsigned long d, unsigned s1, unsigned s2);
115
116
117void z80_op_cb (e8080_t *c);
118void z80_op_dd (e8080_t *c);
119void z80_op_ed (e8080_t *c);
120void z80_op_fd (e8080_t *c);
121void z80_op_dd_cb (e8080_t *c);
122void z80_op_fd_cb (e8080_t *c);
123
124
125void e8080_set_opcodes (e8080_t *c);
126void z80_set_opcodes (e8080_t *c);
127
128
129#endif