comparison mame_z80/z80.h @ 1507:2455662378ed mame_interp

Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
author Michael Pavone <pavone@retrodev.com>
date Sat, 30 Dec 2017 18:27:06 -0800
parents
children 2e57910fd641
comparison
equal deleted inserted replaced
1506:ded16f3d7eb4 1507:2455662378ed
1 // license:BSD-3-Clause
2 // copyright-holders:Juergen Buchmueller
3 #pragma once
4
5 #ifndef __Z80_H__
6 #define __Z80_H__
7
8 #include "../backend.h"
9
10 typedef struct
11 {
12 cpu_options gen;
13 memmap_chunk const *iomap;
14 uint32_t io_chunks;
15 uint32_t io_address_mask;
16 } z80_options;
17
18 #define LSB_FIRST
19
20 typedef union
21 {
22 #ifdef LSB_FIRST
23 struct { uint8_t l,h,h2,h3; } b;
24 struct { uint16_t l,h; } w;
25 struct { int8_t l,h,h2,h3; } sb;
26 struct { int16_t l,h; } sw;
27 #else
28 struct { uint8_t h3,h2,h,l; } b;
29 struct { int8_t h3,h2,h,l; } sb;
30 struct { uint16_t h,l; } w;
31 struct { int16_t h,l; } sw;
32 #endif
33 uint32_t d;
34 int32_t sd;
35 } PAIR;
36
37 #define ZNUM_MEM_AREAS 4
38 typedef struct z80_device z80_device;
39 //typedefs for compatibility with existing BlastEm code
40 typedef z80_device z80_context;
41 typedef void (*z80_ctx_fun)(z80_context * context);
42
43 struct z80_device
44 {
45 z80_options *options;
46 uint8_t * mem_pointers[ZNUM_MEM_AREAS];
47 void *system;
48 z80_ctx_fun next_int_pulse;
49
50 PAIR m_prvpc;
51 PAIR m_pc;
52 PAIR m_sp;
53 PAIR m_af;
54 PAIR m_bc;
55 PAIR m_de;
56 PAIR m_hl;
57 PAIR m_ix;
58 PAIR m_iy;
59 PAIR m_wz;
60 PAIR m_af2;
61 PAIR m_bc2;
62 PAIR m_de2;
63 PAIR m_hl2;
64 uint8_t m_r;
65 uint8_t m_r2;
66 uint8_t m_iff1;
67 uint8_t m_iff2;
68 uint8_t m_halt;
69 uint8_t m_im;
70 uint8_t m_i;
71 uint8_t m_nmi_state; /* nmi line state */
72 uint8_t m_nmi_pending; /* nmi pending */
73 uint8_t m_irq_state; /* irq line state */
74 int m_wait_state; // wait line state
75 int busreq; // bus request line state
76 int busack; // bus ack line state
77 int reset;
78 uint8_t m_after_ei; /* are we in the EI shadow? */
79 uint8_t m_after_ldair; /* same, but for LD A,I or LD A,R */
80 uint32_t m_ea;
81
82 int m_icount;
83 uint32_t current_cycle;
84 uint32_t nmi_start;
85 uint32_t int_pulse_start;
86 uint32_t int_pulse_end;
87 uint16_t bank_reg;
88 uint8_t m_rtemp;
89 uint8_t int_is_nmi;
90 uint8_t im2_vector;
91 const uint8_t * m_cc_op;
92 const uint8_t * m_cc_cb;
93 const uint8_t * m_cc_ed;
94 const uint8_t * m_cc_xy;
95 const uint8_t * m_cc_xycb;
96 const uint8_t * m_cc_ex;
97 };
98
99 #define z80_invalidate_code_range(Z, S, E)
100 #define z80_handle_code_write(A, Z)
101
102 void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, memmap_chunk const * io_chunks, uint32_t num_io_chunks, uint32_t clock_divider, uint32_t io_address_mask);
103 z80_context *init_z80_context(z80_options *opts);
104 void z80_assert_reset(z80_context *z80, uint32_t cycle);
105 void z80_clear_reset(z80_context *z80, uint32_t cycle);
106 void z80_assert_busreq(z80_context *z80, uint32_t cycle);
107 void z80_clear_busreq(z80_context *z80, uint32_t cycle);
108 void z80_run(z80_context *z80, uint32_t target_cycle);
109 uint8_t z80_get_busack(z80_context * context, uint32_t cycle);
110 void z80_adjust_cycles(z80_context * context, uint32_t deduction);
111 void z80_serialize(z80_context *context, serialize_buffer *buf);
112 void z80_deserialize(deserialize_buffer *buf, void *vcontext);
113 void z80_options_free(z80_options *opts);
114 void z80_assert_nmi(z80_context *context, uint32_t cycle);
115
116 #endif /* __Z80_H__ */