Develop and Download Open Source Software

Browse CVS Repository

Contents of /mame32jp/mame32jp/src/cpuexec.h

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Wed Apr 24 03:53:20 2002 UTC (21 years, 11 months ago) by zero
Branch: MAIN
CVS Tags: ver_0_60_1, ver0_59_13, ver0_59_14, ver0_60_2, ver0_60_3, ver0_60_4, ver0_60_5, HEAD
Changes since 1.4: +0 -0 lines
File MIME type: text/x-chdr
*** empty log message ***

1 /***************************************************************************
2
3 cpuexec.h
4
5 Core multi-CPU execution engine.
6
7 ***************************************************************************/
8
9 #ifndef CPUEXEC_H
10 #define CPUEXEC_H
11
12 #include "osd_cpu.h"
13 #include "memory.h"
14 #include "timer.h"
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20
21 /*************************************
22 *
23 * CPU description for drivers
24 *
25 *************************************/
26
27 struct MachineCPU
28 {
29 int cpu_type; /* see #defines below. */
30 int cpu_clock; /* in Hertz */
31 const void *memory_read; /* struct Memory_ReadAddress */
32 const void *memory_write; /* struct Memory_WriteAddress */
33 const void *port_read;
34 const void *port_write;
35 void (*vblank_interrupt)(void); /* for interrupts tied to VBLANK */
36 int vblank_interrupts_per_frame;/* usually 1 */
37 void (*timed_interrupt)(void); /* for interrupts not tied to VBLANK */
38 int timed_interrupts_per_second;
39 void * reset_param; /* parameter for cpu_reset */
40 const char *tag;
41 };
42
43
44
45 /*************************************
46 *
47 * CPU flag constants
48 *
49 *************************************/
50
51 enum
52 {
53 /* flags for CPU go into upper byte */
54 CPU_FLAGS_MASK = 0xff00,
55
56 /* set this if the CPU is used as a slave for audio. It will not be emulated if */
57 /* sound is disabled, therefore speeding up a lot the emulation. */
58 CPU_AUDIO_CPU = 0x8000,
59
60 /* the Z80 can be wired to use 16 bit addressing for I/O ports */
61 CPU_16BIT_PORT = 0x4000
62 };
63
64
65
66 /*************************************
67 *
68 * Core CPU execution
69 *
70 *************************************/
71
72 /* Prepare CPUs for execution */
73 int cpu_init(void);
74
75 /* Run CPUs until the user quits */
76 void cpu_run(void);
77
78 /* Clean up after quitting */
79 void cpu_exit(void);
80
81 /* Force a reset after the current timeslice */
82 void machine_reset(void);
83
84
85
86 /*************************************
87 *
88 * Save/restore
89 *
90 *************************************/
91
92 /* Load or save the game state */
93 enum
94 {
95 LOADSAVE_NONE,
96 LOADSAVE_SAVE,
97 LOADSAVE_LOAD
98 };
99 void cpu_loadsave_schedule(int type, char id);
100 void cpu_loadsave_reset(void);
101
102
103
104 /*************************************
105 *
106 * Optional watchdog
107 *
108 *************************************/
109
110 /* 8-bit watchdog read/write handlers */
111 WRITE_HANDLER( watchdog_reset_w );
112 READ_HANDLER( watchdog_reset_r );
113
114 /* 16-bit watchdog read/write handlers */
115 WRITE16_HANDLER( watchdog_reset16_w );
116 READ16_HANDLER( watchdog_reset16_r );
117
118 /* 32-bit watchdog read/write handlers */
119 WRITE32_HANDLER( watchdog_reset32_w );
120 READ32_HANDLER( watchdog_reset32_r );
121
122
123
124 /*************************************
125 *
126 * CPU halt/reset lines
127 *
128 *************************************/
129
130 /* Set the logical state (ASSERT_LINE/CLEAR_LINE) of the RESET line on a CPU */
131 void cpu_set_reset_line(int cpu,int state);
132
133 /* Set the logical state (ASSERT_LINE/CLEAR_LINE) of the HALT line on a CPU */
134 void cpu_set_halt_line(int cpu,int state);
135
136 /* Returns status (1=running, 0=suspended for some reason) of a CPU */
137 int cpu_getstatus(int cpunum);
138
139
140
141 /*************************************
142 *
143 * Timing helpers
144 *
145 *************************************/
146
147 /* Returns the number of cycles run so far this timeslice */
148 int cycles_currently_ran(void);
149
150 /* Returns the number of cycles left to run in this timeslice */
151 int cycles_left_to_run(void);
152
153 /* Returns the number of CPU cycles which take place in one video frame */
154 int cpu_gettotalcycles(void);
155
156 /* Returns the number of CPU cycles before the next interrupt handler call */
157 int cpu_geticount(void);
158
159 /* Scales a given value by the ratio of fcount / fperiod */
160 int cpu_scalebyfcount(int value);
161
162
163
164 /*************************************
165 *
166 * Video timing
167 *
168 *************************************/
169
170 /* Initialize the refresh timer */
171 void cpu_init_refresh_timer(void);
172
173 /* Returns the current scanline number */
174 int cpu_getscanline(void);
175
176 /* Returns the amount of time until a given scanline */
177 double cpu_getscanlinetime(int scanline);
178
179 /* Returns the duration of a single scanline */
180 double cpu_getscanlineperiod(void);
181
182 /* Returns the current horizontal beam position in pixels */
183 int cpu_gethorzbeampos(void);
184
185 /* Returns the current VBLANK state */
186 int cpu_getvblank(void);
187
188 /* Returns the number of the video frame we are currently playing */
189 int cpu_getcurrentframe(void);
190
191
192
193 /*************************************
194 *
195 * Synchronization
196 *
197 *************************************/
198
199 /* generate a trigger now */
200 void cpu_trigger(int trigger);
201
202 /* generate a trigger after a specific period of time */
203 void cpu_triggertime(double duration, int trigger);
204
205 /* generate a trigger corresponding to an interrupt on the given CPU */
206 void cpu_triggerint(int cpunum);
207
208 /* burn CPU cycles until a timer trigger */
209 void cpu_spinuntil_trigger(int trigger);
210
211 /* yield our timeslice until a timer trigger */
212 void cpu_yielduntil_trigger(int trigger);
213
214 /* burn CPU cycles until the next interrupt */
215 void cpu_spinuntil_int(void);
216
217 /* yield our timeslice until the next interrupt */
218 void cpu_yielduntil_int(void);
219
220 /* burn CPU cycles until our timeslice is up */
221 void cpu_spin(void);
222
223 /* yield our current timeslice */
224 void cpu_yield(void);
225
226 /* burn CPU cycles for a specific period of time */
227 void cpu_spinuntil_time(double duration);
228
229 /* yield our timeslice for a specific period of time */
230 void cpu_yielduntil_time(double duration);
231
232
233
234 /*************************************
235 *
236 * Core timing
237 *
238 *************************************/
239
240 /* Returns the number of times the interrupt handler will be called before
241 the end of the current video frame. This is can be useful to interrupt
242 handlers to synchronize their operation. If you call this from outside
243 an interrupt handler, add 1 to the result, i.e. if it returns 0, it means
244 that the interrupt handler will be called once. */
245 int cpu_getiloops(void);
246
247
248
249 /*************************************
250 *
251 * Z80 daisy chain
252 *
253 *************************************/
254
255 /* fix me - where should this stuff go? */
256
257 /* daisy-chain link */
258 typedef struct
259 {
260 void (*reset)(int); /* reset callback */
261 int (*interrupt_entry)(int); /* entry callback */
262 void (*interrupt_reti)(int); /* reti callback */
263 int irq_param; /* callback paramater */
264 } Z80_DaisyChain;
265
266 #define Z80_MAXDAISY 4 /* maximum of daisy chan device */
267
268 #define Z80_INT_REQ 0x01 /* interrupt request mask */
269 #define Z80_INT_IEO 0x02 /* interrupt disable mask(IEO) */
270
271 #define Z80_VECTOR(device,state) (((device)<<8)|(state))
272
273
274 #ifdef __cplusplus
275 }
276 #endif
277
278 #endif /* CPUEXEC_H */

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26