1 /***************************************************************************
2
3 machine.c
4
5 Functions to emulate general aspects of the machine (RAM, ROM, interrupts,
6 I/O ports)
7
8 ***************************************************************************/
9
10 #include "driver.h"
11 #include "cpu/z80/z80.h"
12
13
14
15 static unsigned char buffer0[9],buffer1[9];
16
17
18
READ_HANDLER(docastle_shared0_r)19 READ_HANDLER( docastle_shared0_r )
20 {
21 if (offset == 8) logerror("CPU #0 shared0r clock = %d\n",activecpu_gettotalcycles());
22
23 /* this shouldn't be done, however it's the only way I've found */
24 /* to make dip switches work in Do Run Run. */
25 if (offset == 8)
26 {
27 cpu_set_irq_line(1,IRQ_LINE_NMI,PULSE_LINE);
28 cpu_spinuntil_trigger(500);
29 }
30
31 return buffer0[offset];
32 }
33
34
READ_HANDLER(docastle_shared1_r)35 READ_HANDLER( docastle_shared1_r )
36 {
37 if (offset == 8) logerror("CPU #1 shared1r clock = %d\n",activecpu_gettotalcycles());
38 return buffer1[offset];
39 }
40
41
WRITE_HANDLER(docastle_shared0_w)42 WRITE_HANDLER( docastle_shared0_w )
43 {
44 if (offset == 8) logerror("CPU #1 shared0w %02x %02x %02x %02x %02x %02x %02x %02x %02x clock = %d\n",
45 buffer0[0],buffer0[1],buffer0[2],buffer0[3],buffer0[4],buffer0[5],buffer0[6],buffer0[7],data,activecpu_gettotalcycles());
46
47 buffer0[offset] = data;
48
49 if (offset == 8)
50 /* awake the master CPU */
51 cpu_trigger(500);
52 }
53
54
WRITE_HANDLER(docastle_shared1_w)55 WRITE_HANDLER( docastle_shared1_w )
56 {
57 buffer1[offset] = data;
58
59 if (offset == 8)
60 {
61 logerror("CPU #0 shared1w %02x %02x %02x %02x %02x %02x %02x %02x %02x clock = %d\n",
62 buffer1[0],buffer1[1],buffer1[2],buffer1[3],buffer1[4],buffer1[5],buffer1[6],buffer1[7],data,activecpu_gettotalcycles());
63
64 /* freeze execution of the master CPU until the slave has used the shared memory */
65 cpu_spinuntil_trigger(500);
66 }
67 }
68
69
70
WRITE_HANDLER(docastle_nmitrigger_w)71 WRITE_HANDLER( docastle_nmitrigger_w )
72 {
73 cpu_set_irq_line(1,IRQ_LINE_NMI,PULSE_LINE);
74 }
75