Previous 15994 Revisions Next

r2396 Monday 14th April, 2008 at 17:48:37 UTC by Curt Coder
[CDP1802] Added machine parameter to the callback functions, and macros for the callbacks.
[src/emu/cpu/cdp1802]cdp1802.c cdp1802.h
[src/mess/drivers]studio2.c tmc600.c vip.c
[src/mess/video]cdp1864.c cdp1864.h

src/emu/cpu/cdp1802/cdp1802.c
r2395r2396
33#include "deprecat.h"
44#include "cdp1802.h"
55
6#define CDP1802_CYCLES_RESET       8
7#define CDP1802_CYCLES_INIT         8 // really 9, but needs to be 8 to synchronize cdp1861 video timings
8#define CDP1802_CYCLES_FETCH      8
9#define CDP1802_CYCLES_EXECUTE      8
10#define CDP1802_CYCLES_DMA         8
11#define CDP1802_CYCLES_INTERRUPT   8
12
13enum {
14   CDP1802_STATE_0_FETCH,
15   CDP1802_STATE_1_RESET,
16   CDP1802_STATE_1_INIT,
17   CDP1802_STATE_1_EXECUTE,
18   CDP1802_STATE_2_DMA_IN,
19   CDP1802_STATE_2_DMA_OUT,
20   CDP1802_STATE_3_INT
21};
22
623typedef struct
724{
8   CDP1802_CONFIG *config;
25   const cdp1802_interface *intf;
926
1027   UINT8 p, x, d, b, t;
1128   UINT16 r[16];
r2395r2396
4966
5067static void cdp1802_init(int index, int clock, const void *config, int (*irqcallback)(int))
5168{
52   cdp1802.config = (CDP1802_CONFIG *) config;
69   cdp1802.intf = (cdp1802_interface *) config;
5370
5471   cdp1802.mode = CDP1802_MODE_RESET;
5572   cdp1802.prevmode = cdp1802.mode;
r2395r2396
160177
161178static void cdp1802_sample_ef(void)
162179{
163   if (cdp1802.config->ef_r)
180   if (cdp1802.intf->ef_r)
164181   {
165      cdp1802.ef = cdp1802.config->ef_r() & 0x0f;
182      cdp1802.ef = cdp1802.intf->ef_r(Machine) & 0x0f;
166183   }
167184   else
168185   {
r2395r2396
172189
173190static void cdp1802_output_state_code(void)
174191{
175   if (cdp1802.config->sc_w)
192   if (cdp1802.intf->sc_w)
176193   {
177194      switch (cdp1802.state)
178195      {
179196      case CDP1802_STATE_0_FETCH:
180         cdp1802.config->sc_w(CDP1802_STATE_CODE_S0_FETCH);
197         cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S0_FETCH);
181198         break;
182199
183200      case CDP1802_STATE_1_EXECUTE:
184         cdp1802.config->sc_w(CDP1802_STATE_CODE_S1_EXECUTE);
201         cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S1_EXECUTE);
185202         break;
186203
187204      case CDP1802_STATE_2_DMA_IN:
188205      case CDP1802_STATE_2_DMA_OUT:
189         cdp1802.config->sc_w(CDP1802_STATE_CODE_S2_DMA);
206         cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S2_DMA);
190207         break;
191208
192209      case CDP1802_STATE_3_INT:
193         cdp1802.config->sc_w(CDP1802_STATE_CODE_S3_INTERRUPT);
210         cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S3_INTERRUPT);
194211         break;
195212      }
196213   }
r2395r2396
477494         case 0xa:
478495            Q = 0;
479496
480            if (cdp1802.config->q_w)
497            if (cdp1802.intf->q_w)
481498            {
482               cdp1802.config->q_w(Q);
499               cdp1802.intf->q_w(Machine, Q);
483500            }
484501            break;
485502
486503         case 0xb:
487504            Q = 1;
488505
489            if (cdp1802.config->q_w)
506            if (cdp1802.intf->q_w)
490507            {
491               cdp1802.config->q_w(Q);
508               cdp1802.intf->q_w(Machine, Q);
492509            }
493510            break;
494511
r2395r2396
719736
720737    case CDP1802_STATE_2_DMA_IN:
721738
722      if (cdp1802.config->dma_r)
739      if (cdp1802.intf->dma_r)
723740      {
724         MW(R[0], cdp1802.config->dma_r());
741         MW(R[0], cdp1802.intf->dma_r(Machine));
725742      }
726743
727744      R[0] = R[0] + 1;
r2395r2396
752769
753770    case CDP1802_STATE_2_DMA_OUT:
754771
755      if (cdp1802.config->dma_w)
772      if (cdp1802.intf->dma_w)
756773      {
757           cdp1802.config->dma_w(M(R[0]));
774           cdp1802.intf->dma_w(Machine, M(R[0]));
758775      }
759776
760777      R[0] = R[0] + 1;
r2395r2396
812829   cdp1802_ICount = cycles;
813830
814831   cdp1802.prevmode = cdp1802.mode;
815   cdp1802.mode = cdp1802.config->mode_r();
832   cdp1802.mode = cdp1802.intf->mode_r(Machine);
816833
817834   do
818835   {
src/emu/cpu/cdp1802/cdp1802.h
r2395r2396
33
44#include "cpuintrf.h"
55
6#define CDP1802_CYCLES_RESET       8
7#define CDP1802_CYCLES_INIT         8 // really 9, but needs to be 8 to synchronize cdp1861 video timings
8#define CDP1802_CYCLES_FETCH      8
9#define CDP1802_CYCLES_EXECUTE      8
10#define CDP1802_CYCLES_DMA         8
11#define CDP1802_CYCLES_INTERRUPT   8
12
136enum {
147   CDP1802_INPUT_LINE_INT,
158   CDP1802_INPUT_LINE_DMAIN,
r2395r2396
2316   EF4 = 0x08
2417};
2518
26enum {
27   CDP1802_STATE_0_FETCH,
28   CDP1802_STATE_1_RESET,
29   CDP1802_STATE_1_INIT,
30   CDP1802_STATE_1_EXECUTE,
31   CDP1802_STATE_2_DMA_IN,
32   CDP1802_STATE_2_DMA_OUT,
33   CDP1802_STATE_3_INT
19typedef enum _cdp1802_control_mode cdp1802_control_mode;
20enum _cdp1802_control_mode {
21   CDP1802_MODE_LOAD,
22   CDP1802_MODE_RESET,
23   CDP1802_MODE_PAUSE,
24   CDP1802_MODE_RUN
3425};
3526
36enum {
27typedef enum _cdp1802_state cdp1802_state;
28enum _cdp1802_state {
3729   CDP1802_STATE_CODE_S0_FETCH,
3830   CDP1802_STATE_CODE_S1_EXECUTE,
3931   CDP1802_STATE_CODE_S2_DMA,
4032   CDP1802_STATE_CODE_S3_INTERRUPT
4133};
4234
43enum {
44   CDP1802_MODE_LOAD,
45   CDP1802_MODE_RESET,
46   CDP1802_MODE_PAUSE,
47   CDP1802_MODE_RUN
48};
49
5035// CDP1802 Registers
5136
5237enum {
r2395r2396
8368
8469void cdp1802_get_info(UINT32 state, cpuinfo *info);
8570
71typedef cdp1802_control_mode (*cdp1802_mode_read_func)(running_machine *machine);
72#define CDP1802_MODE_READ(name) cdp1802_control_mode name(running_machine *machine)
73
74typedef UINT8 (*cdp1802_ef_read_func)(running_machine *machine);
75#define CDP1802_EF_READ(name) UINT8 name(running_machine *machine)
76
77typedef void (*cdp1802_sc_write_func)(running_machine *machine, cdp1802_state state);
78#define CDP1802_SC_WRITE(name) void name(running_machine *machine, cdp1802_state state)
79
80typedef void (*cdp1802_q_write_func)(running_machine *machine, int level);
81#define CDP1802_Q_WRITE(name) void name(running_machine *machine, int level)
82
83typedef UINT8 (*cdp1802_dma_read_func)(running_machine *machine);
84#define CDP1802_DMA_READ(name) UINT8 name(running_machine *machine)
85
86typedef void (*cdp1802_dma_write_func)(running_machine *machine, UINT8 data);
87#define CDP1802_DMA_WRITE(name) void name(running_machine *machine, UINT8 data)
88
89/* interface */
90typedef struct _cdp1802_interface cdp1802_interface;
91struct _cdp1802_interface
92{
93   /* if specified, this gets called for every change of the mode pins (pins 2 and 3) */
94   cdp1802_mode_read_func   mode_r;
95
96   /* if specified, this gets called for every change read of the external flags (pins 21 thru 24) */
97   cdp1802_ef_read_func   ef_r;
98
99   /* if specified, this gets called for every change of the processor state (pins 5 and 6) */
100   cdp1802_sc_write_func   sc_w;
101
102   /* if specified, this gets called for every change of the Q pin (pin 4) */
103   cdp1802_q_write_func   q_w;
104
105   /* if specified, this gets called for every DMA read */
106   cdp1802_dma_read_func   dma_r;
107   
108   /* if specified, this gets called for every DMA write */
109   cdp1802_dma_write_func   dma_w;
110};
111
86112#ifdef ENABLE_DEBUGGER
87113offs_t cdp1802_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
88114#endif
89115
90typedef struct
91{
92   UINT8 (*mode_r)(void);
93   UINT8 (*ef_r)(void);
94   void (*sc_w)(int state);
95   void (*q_w)(int level);
96   UINT8 (*dma_r)(void);
97   void (*dma_w)(UINT8 data);
98} CDP1802_CONFIG;
99
100116#endif
src/mess/video/cdp1864.c
r2395r2396
11#include "driver.h"
2#include "deprecat.h"
32#include "cpu/cdp1802/cdp1802.h"
43#include "sound/beep.h"
54#include "video/cdp1864.h"
65
7
86static bitmap_t *cdptmpbitmap;
97
108static emu_timer *cdp1864_int_timer;
r2395r2396
115113   }
116114}
117115
118void cdp1864_dma_w(UINT8 data)
116CDP1802_DMA_WRITE( cdp1864_dma_w )
119117{
120   int sx = video_screen_get_hpos(Machine->primary_screen) + 4;
121   int y = video_screen_get_vpos(Machine->primary_screen);
118   int sx = video_screen_get_hpos(machine->primary_screen) + 4;
119   int y = video_screen_get_vpos(machine->primary_screen);
122120   int x;
123121
124122   for (x = 0; x < 8; x++)
src/mess/video/cdp1864.h
r2395r2396
7878VIDEO_START( cdp1864 );
7979VIDEO_UPDATE( cdp1864 );
8080
81 READ8_HANDLER( cdp1864_dispon_r );
81READ8_HANDLER( cdp1864_dispon_r );
8282
83void cdp1864_dma_w(UINT8 data);
83CDP1802_DMA_WRITE( cdp1864_dma_w );
8484
8585void cdp1864_audio_output_enable(int value);
8686
src/mess/drivers/vip.c
r2395r2396
1515*/
1616
1717#include "driver.h"
18#include "deprecat.h"
1918#include "cpu/cdp1802/cdp1802.h"
2019#include "devices/cassette.h"
2120#include "devices/snapquik.h"
r2395r2396
10099   cdp1861_efx = level;
101100}
102101
103static void vip_dma_w(UINT8 data)
104{
105   const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG);
106
107   cdp1861_dma_w(cdp1861, data);
108}
109
110102static const cdp1861_interface vip_cdp1861_intf =
111103{
112104   SCREEN_TAG,
r2395r2396
130122static int vip_run;
131123static int vip_reset;
132124
133static UINT8 vip_mode_r(void)
125static CDP1802_MODE_READ( vip_mode_r )
134126{
135   if (input_port_read(Machine, "RUN") & 0x01)
127   if (input_port_read(machine, "RUN") & 0x01)
136128   {
137129      if (!vip_run)
138130      {
r2395r2396
147139   {
148140      if (!vip_reset)
149141      {
150         const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG);
142         const device_config *cdp1861 = device_list_find_by_tag(machine->config->devicelist, CDP1861, CDP1861_TAG);
151143         cdp1861->reset(cdp1861);
152144         vip_reset = 1;
153145         vip_run = 0;
r2395r2396
157149   }
158150}
159151
160static UINT8 vip_ef_r(void)
152static CDP1802_EF_READ( vip_ef_r )
161153{
162154   int ef = 0x0f;
163155
164156   if (cdp1861_efx) ef -= EF1;
165157   // EF2 = tape (high when tone read)
166   if (input_port_read(Machine, "KEYPAD") & (1 << keylatch)) ef -= EF3;
158   if (input_port_read(machine, "KEYPAD") & (1 << keylatch)) ef -= EF3;
167159
168160   return ef;
169161}
170162
171static void vip_q_w(int level)
163static CDP1802_Q_WRITE( vip_q_w )
172164{
173165   beep_set_state(0, level);
174166   // PWR Q TAPE
175167   set_led_status(1, level);
176168}
177169
178static const CDP1802_CONFIG vip_config =
170static CDP1802_DMA_WRITE( vip_dma_w )
179171{
172   const device_config *cdp1861 = device_list_find_by_tag(machine->config->devicelist, CDP1861, CDP1861_TAG);
173
174   cdp1861_dma_w(cdp1861, data);
175}
176
177static const cdp1802_interface vip_config =
178{
180179   vip_mode_r,
181180   vip_ef_r,
182181   NULL,
r2395r2396
189188
190189static MACHINE_START( vip )
191190{
192   UINT8 *ram= memory_region(REGION_CPU1);
191   UINT8 *ram = memory_region(REGION_CPU1);
193192   UINT16 addr;
194193
195194   state_save_register_global(keylatch);
src/mess/drivers/tmc600.c
r2395r2396
8282*/
8383
8484#include "driver.h"
85#include "deprecat.h"
8685#include "devices/printer.h"
8786#include "devices/basicdsk.h"
8887#include "devices/cassette.h"
r2395r2396
224223
225224/* CDP1802 Interface */
226225
227static UINT8 tmc600_mode_r(void)
226static CDP1802_MODE_READ( tmc600_mode_r )
228227{
229   if (input_port_read(Machine, "RUN") & 0x01)
228   if (input_port_read(machine, "RUN") & 0x01)
230229   {
231230      return CDP1802_MODE_RESET;
232231   }
r2395r2396
236235   }
237236}
238237
239static UINT8 tmc600_ef_r(void)
238static CDP1802_EF_READ( tmc600_ef_r )
240239{
241240   int flags = 0x0f;
242241   char port[4];
r2395r2396
250249
251250   // keyboard
252251   sprintf(port, "IN%d", keylatch / 8);
253   flags -= (~input_port_read(Machine, port) & (1 << (keylatch % 8))) ? EF3 : 0;
252   flags -= (~input_port_read(machine, port) & (1 << (keylatch % 8))) ? EF3 : 0;
254253
255254   return flags;
256255}
257256
258static void tmc600_q_w(int level)
257static const cdp1802_interface tmc600_cdp1802_config =
259258{
260}
261
262static const CDP1802_CONFIG tmc600_cdp1802_config =
263{
264259   tmc600_mode_r,
265260   tmc600_ef_r,
266261   NULL,
267   tmc600_q_w,
268262   NULL,
263   NULL,
269264   NULL
270265};
271266
src/mess/drivers/studio2.c
r2395r2396
195195   cdp1861_efx = level;
196196}
197197
198static void studio2_dma_w(UINT8 data)
199{
200   const device_config *cdp1861 = device_list_find_by_tag(Machine->config->devicelist, CDP1861, CDP1861_TAG);
201
202   cdp1861_dma_w(cdp1861, data);
203}
204
205198static const cdp1861_interface studio2_cdp1861_intf =
206199{
207200   SCREEN_TAG,
r2395r2396
224217
225218static int cdp1802_mode = CDP1802_MODE_RESET;
226219
227static UINT8 studio2_mode_r(void)
220static CDP1802_MODE_READ( studio2_mode_r )
228221{
229222   return cdp1802_mode;
230223}
231224
232static UINT8 studio2_ef_r(void)
225static CDP1802_EF_READ( studio2_ef_r )
233226{
234227   int ef = 0x0f;
235228
236229   if (cdp1861_efx) ef -= EF1;
237230
238   if (input_port_read(Machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
239   if (input_port_read(Machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
231   if (input_port_read(machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
232   if (input_port_read(machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
240233
241234   return ef;
242235}
243236
244static void studio2_q_w(int level)
237static CDP1802_Q_WRITE( studio2_q_w )
245238{
246239   beep_set_state(0, level);
247240}
248241
249static const CDP1802_CONFIG studio2_config =
242static CDP1802_DMA_WRITE( studio2_dma_w )
250243{
244   const device_config *cdp1861 = device_list_find_by_tag(machine->config->devicelist, CDP1861, CDP1861_TAG);
245
246   cdp1861_dma_w(cdp1861, data);
247}
248
249static const cdp1802_interface studio2_config =
250{
251251   studio2_mode_r,
252252   studio2_ef_r,
253253   NULL,
r2395r2396
256256   studio2_dma_w
257257};
258258
259static UINT8 mpt02_ef_r(void)
259static CDP1802_EF_READ( mpt02_ef_r )
260260{
261261   int ef = 0x0f;
262262
263263   if (cdp1864_efx) ef -= EF1;
264264
265   if (input_port_read(Machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
266   if (input_port_read(Machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
265   if (input_port_read(machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
266   if (input_port_read(machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
267267
268268   return ef;
269269}
270270
271static const CDP1802_CONFIG mpt02_config =
271static const cdp1802_interface mpt02_config =
272272{
273273   studio2_mode_r,
274274   mpt02_ef_r,
r2395r2396
278278   cdp1864_dma_w
279279};
280280
281/* Machine Initialization */
281/* machine Initialization */
282282
283283static MACHINE_START( studio2 )
284284{
r2395r2396
299299   cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE);
300300}
301301
302/* Machine Drivers */
302/* machine Drivers */
303303
304304static MACHINE_DRIVER_START( studio2 )
305305

Previous 15994 Revisions Next


© 1998-2018 The MESS Team