Previous 15994 Revisions Next

r5253 Thursday 16th July, 2009 at 12:53:58 UTC by Curt Coder
[CDP1802] Refactored Q and DMA callbacks to use devcb.
[src/emu/cpu/cdp1802]cdp1802.c cdp1802.h
[src/mess/drivers]comx35.c studio2.c tmc1800.c tmc2000e.c tmc600.c vip.c
[src/mess/machine]pecom.c

src/emu/cpu/cdp1802/cdp1802.c
r5252r5253
2929    const address_space *program;
3030    const address_space *io;
3131
32   devcb_resolved_write_line   out_q_func;
33   devcb_resolved_read8      in_dma_func;
34   devcb_resolved_write8      out_dma_func;
35
3236   /* registers */
3337   UINT8 d;            /* data register (accumulator) */
3438   int df;               /* data flag (ALU carry) */
r5252r5253
549553         case 0xa:
550554            Q = 0;
551555
552            if (cpustate->intf->q_w)
553            {
554               cpustate->intf->q_w(device, Q);
555            }
556            devcb_call_write_line(&cpustate->out_q_func, Q);
556557            break;
557558
558559         case 0xb:
559560            Q = 1;
560561
561            if (cpustate->intf->q_w)
562            {
563               cpustate->intf->q_w(device, Q);
564            }
562            devcb_call_write_line(&cpustate->out_q_func, Q);
565563            break;
566564
567565         case 0xc:
r5252r5253
791789
792790    case CDP1802_STATE_2_DMA_IN:
793791
794      if (cpustate->intf->dma_r)
795      {
796         RAM_W(R[0], cpustate->intf->dma_r(device, R[0]));
797      }
792      RAM_W(R[0], devcb_call_read8(&cpustate->in_dma_func, R[0]));
798793
799794      R[0] = R[0] + 1;
800795
r5252r5253
824819
825820    case CDP1802_STATE_2_DMA_OUT:
826821
827      if (cpustate->intf->dma_w)
828      {
829           cpustate->intf->dma_w(device, R[0], RAM_R(R[0]));
830      }
822      devcb_call_write8(&cpustate->out_dma_func, R[0], RAM_R(R[0]));
831823
832824      R[0] = R[0] + 1;
833825
r5252r5253
954946
955947   cpustate->intf = (cdp1802_interface *) device->static_config;
956948
957   /* set up the state table */
949   /* resolve callbacks */
950   devcb_resolve_write_line(&cpustate->out_q_func, &cpustate->intf->out_q_func, device);
951   devcb_resolve_read8(&cpustate->in_dma_func, &cpustate->intf->in_dma_func, device);
952   devcb_resolve_write8(&cpustate->out_dma_func, &cpustate->intf->out_dma_func, device);
958953
954   /* set up the state table */
959955   cpustate->state_table = state_table_template;
960956   cpustate->state_table.baseptr = cpustate;
961957   cpustate->state_table.subtypemask = 1;
962958
963959   /* find address spaces */
964
965960   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
966961   cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
967962
968963   /* set initial values */
969
970964   cpustate->p = mame_rand(device->machine) & 0x0f;
971965   cpustate->x = mame_rand(device->machine) & 0x0f;
972966   cpustate->d = mame_rand(device->machine);
r5252r5253
987981   cpustate->dmaout = CLEAR_LINE;
988982
989983   /* register for state saving */
990
991984   state_save_register_device_item(device, 0, cpustate->p);
992985   state_save_register_device_item(device, 0, cpustate->x);
993986   state_save_register_device_item(device, 0, cpustate->d);
src/emu/cpu/cdp1802/cdp1802.h
r5252r5253
1818*/
1919
2020#include "cpuintrf.h"
21#include "devcb.h"
2122
2223enum
2324{
r5252r5253
7071typedef void (*cdp1802_sc_write_func)(const device_config *device, cdp1802_state_code state);
7172#define CDP1802_SC_WRITE(name) void name(const device_config *device, cdp1802_state_code state)
7273
73typedef void (*cdp1802_q_write_func)(const device_config *device, int level);
74#define CDP1802_Q_WRITE(name) void name(const device_config *device, int level)
75
76typedef UINT8 (*cdp1802_dma_read_func)(const device_config *device, UINT16 ma);
77#define CDP1802_DMA_READ(name) UINT8 name(const device_config *device, UINT16 ma)
78
79typedef void (*cdp1802_dma_write_func)(const device_config *device, UINT16 ma, UINT8 data);
80#define CDP1802_DMA_WRITE(name) void name(const device_config *device, UINT16 ma, UINT8 data)
81
8274/* interface */
8375typedef struct _cdp1802_interface cdp1802_interface;
8476struct _cdp1802_interface
r5252r5253
9385   cdp1802_sc_write_func   sc_w;
9486
9587   /* if specified, this gets called for every change of the Q pin (pin 4) */
96   cdp1802_q_write_func   q_w;
88   devcb_write_line      out_q_func;
9789
9890   /* if specified, this gets called for every DMA read */
99   cdp1802_dma_read_func   dma_r;
91   devcb_read8            in_dma_func;
10092
10193   /* if specified, this gets called for every DMA write */
102   cdp1802_dma_write_func   dma_w;
94   devcb_write8         out_dma_func;
10395};
10496#define CDP1802_INTERFACE(name) const cdp1802_interface (name) =
10597
src/mess/machine/pecom.c
r5252r5253
137137   return flags;
138138}
139139
140static CDP1802_Q_WRITE( pecom64_q_w )
140static WRITE_LINE_DEVICE_HANDLER( pecom64_q_w )
141141{   
142   cassette_output(cassette_device_image(device->machine), level ? -1.0 : +1.0);
142   cassette_output(cassette_device_image(device->machine), state ? -1.0 : +1.0);
143143}
144144
145145static CDP1802_SC_WRITE( pecom64_sc_w )
r5252r5253
167167   pecom64_mode_r,
168168   pecom64_ef_r,
169169   pecom64_sc_w,
170   pecom64_q_w,
171   NULL,
172   NULL
170   DEVCB_LINE(pecom64_q_w),
171   DEVCB_NULL,
172   DEVCB_NULL
173173};
src/mess/drivers/vip.c
r5252r5253
505505   return flags;
506506}
507507
508static CDP1802_Q_WRITE( vip_q_w )
508static WRITE_LINE_DEVICE_HANDLER( vip_q_w )
509509{
510510   const device_config *discrete = devtag_get_device(device->machine, "discrete");
511   vip_state *state = device->machine->driver_data;
511   vip_state *driver_state = device->machine->driver_data;
512512
513513   /* sound output */
514   discrete_sound_w(discrete, NODE_01, level);
514   discrete_sound_w(discrete, NODE_01, state);
515515
516516   if (input_port_read(device->machine, "SOUND") == VIP_SOUND_CDP1863)
517517   {
518518      /* CDP1863 output enable */
519      cdp1863_oe_w(state->cdp1863, level);
519      cdp1863_oe_w(driver_state->cdp1863, state);
520520   }
521521
522522   /* Q led */
523   set_led_status(VIP_LED_Q, level);
523   set_led_status(VIP_LED_Q, state);
524524
525525   /* tape output */
526   cassette_output(state->cassette, level ? 1.0 : -1.0);
526   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
527527}
528528
529static CDP1802_DMA_WRITE( vip_dma_w )
529static WRITE8_DEVICE_HANDLER( vip_dma_w )
530530{
531531   vip_state *state = device->machine->driver_data;
532532
r5252r5253
538538
539539   case VIP_VIDEO_CDP1862:
540540      {
541         UINT8 color = state->colorram[ma & 0xff];
541         UINT8 color = state->colorram[offset & 0xff];
542542         
543543         int rdata = BIT(color, 0);
544544         int gdata = BIT(color, 2);
r5252r5253
555555   vip_mode_r,
556556   vip_ef_r,
557557   NULL,
558   vip_q_w,
559   NULL,
560   vip_dma_w
558   DEVCB_LINE(vip_q_w),
559   DEVCB_NULL,
560   DEVCB_HANDLER(vip_dma_w)
561561};
562562
563563/* Machine Initialization */
src/mess/drivers/tmc600.c
r5252r5253
246246   return flags;
247247}
248248
249static CDP1802_Q_WRITE( tmc600_q_w )
249static WRITE_LINE_DEVICE_HANDLER( tmc600_q_w )
250250{
251   tmc600_state *state = device->machine->driver_data;
251   tmc600_state *driver_state = device->machine->driver_data;
252252
253   cassette_output(state->cassette, level ? +1.0 : -1.0);
253   cassette_output(driver_state->cassette, state ? +1.0 : -1.0);
254254}
255255
256256static CDP1802_INTERFACE( tmc600_cdp1802_config )
r5252r5253
258258   tmc600_mode_r,
259259   tmc600_ef_r,
260260   NULL,
261   tmc600_q_w,
262   NULL,
263   NULL
261   DEVCB_LINE(tmc600_q_w),
262   DEVCB_NULL,
263   DEVCB_NULL
264264};
265265
266266/* Machine Initialization */
src/mess/drivers/studio2.c
r5252r5253
372372   return ef;
373373}
374374
375static CDP1802_Q_WRITE( studio2_q_w )
375static WRITE_LINE_DEVICE_HANDLER( studio2_q_w )
376376{
377377   const device_config *speaker = devtag_get_device(device->machine, "beep");
378   beep_set_state(speaker, level);
378   beep_set_state(speaker, state);
379379}
380380
381static CDP1802_DMA_WRITE( studio2_dma_w )
381static WRITE8_DEVICE_HANDLER( studio2_dma_w )
382382{
383383   studio2_state *state = device->machine->driver_data;
384384
r5252r5253
390390   studio2_mode_r,
391391   studio2_ef_r,
392392   NULL,
393   studio2_q_w,
394   NULL,
395   studio2_dma_w
393   DEVCB_LINE(studio2_q_w),
394   DEVCB_NULL,
395   DEVCB_HANDLER(studio2_dma_w)
396396};
397397
398398static CDP1802_EF_READ( mpt02_ef_r )
r5252r5253
409409   return ef;
410410}
411411
412static CDP1802_DMA_WRITE( mpt02_dma_w )
412static WRITE8_DEVICE_HANDLER( mpt02_dma_w )
413413{
414414   studio2_state *state = device->machine->driver_data;
415415
416   UINT8 color = state->color_ram[ma / 4]; // 0x04 = R, 0x02 = B, 0x01 = G
416   UINT8 color = state->color_ram[offset / 4]; // 0x04 = R, 0x02 = B, 0x01 = G
417417
418418   int rdata = BIT(color, 2);
419419   int gdata = BIT(color, 0);
r5252r5253
427427   studio2_mode_r,
428428   mpt02_ef_r,
429429   NULL,
430   studio2_q_w,
431   NULL,
432   mpt02_dma_w
430   DEVCB_LINE(studio2_q_w),
431   DEVCB_NULL,
432   DEVCB_HANDLER(mpt02_dma_w)
433433};
434434
435435/* Machine Initialization */
src/mess/drivers/tmc1800.c
r5252r5253
485485   return flags;
486486}
487487
488static CDP1802_Q_WRITE( tmc1800_q_w )
488static WRITE_LINE_DEVICE_HANDLER( tmc1800_q_w )
489489{
490   tmc1800_state *state = device->machine->driver_data;
490   tmc1800_state *driver_state = device->machine->driver_data;
491491
492492   /* tape output */
493   cassette_output(state->cassette, level ? 1.0 : -1.0);
493   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
494494}
495495
496static CDP1802_DMA_WRITE( tmc1800_dma_w )
496static WRITE8_DEVICE_HANDLER( tmc1800_dma_w )
497497{
498498   tmc1800_state *state = device->machine->driver_data;
499499
r5252r5253
505505   tmc1800_mode_r,
506506   tmc1800_ef_r,
507507   NULL,
508   tmc1800_q_w,
509   NULL,
510   tmc1800_dma_w
508   DEVCB_LINE(tmc1800_q_w),
509   DEVCB_NULL,
510   DEVCB_HANDLER(tmc1800_dma_w)
511511};
512512
513513static CDP1802_INTERFACE( osc1000b_config )
r5252r5253
515515   tmc1800_mode_r,
516516   tmc1800_ef_r,
517517   NULL,
518   tmc1800_q_w,
519   NULL,
520   NULL
518   DEVCB_LINE(tmc1800_q_w),
519   DEVCB_NULL,
520   DEVCB_NULL
521521};
522522
523523// Telmac 2000
r5252r5253
572572   return flags;
573573}
574574
575static CDP1802_Q_WRITE( tmc2000_q_w )
575static WRITE_LINE_DEVICE_HANDLER( tmc2000_q_w )
576576{
577   tmc2000_state *state = device->machine->driver_data;
577   tmc2000_state *driver_state = device->machine->driver_data;
578578
579579   /* CDP1864 audio output enable */
580   cdp1864_aoe_w(state->cdp1864, level);
580   cdp1864_aoe_w(driver_state->cdp1864, state);
581581
582582   /* set Q led status */
583   set_led_status(1, level);
583   set_led_status(1, state);
584584
585585   /* tape output */
586   cassette_output(state->cassette, level ? 1.0 : -1.0);
586   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
587587}
588588
589static CDP1802_DMA_WRITE( tmc2000_dma_w )
589static WRITE8_DEVICE_HANDLER( tmc2000_dma_w )
590590{
591591   tmc2000_state *state = device->machine->driver_data;
592592
593   UINT8 color = ~(state->colorram[ma & 0x1ff]) & 0x07;
593   UINT8 color = ~(state->colorram[offset & 0x1ff]) & 0x07;
594594   
595595   int rdata = BIT(color, 2);
596596   int gdata = BIT(color, 0);
r5252r5253
604604   tmc2000_mode_r,
605605   tmc2000_ef_r,
606606   NULL,
607   tmc2000_q_w,
608   NULL,
609   tmc2000_dma_w
607   DEVCB_LINE(tmc2000_q_w),
608   DEVCB_NULL,
609   DEVCB_HANDLER(tmc2000_dma_w)
610610};
611611
612612// OSCOM Nano
r5252r5253
688688   return flags;
689689}
690690
691static CDP1802_Q_WRITE( oscnano_q_w )
691static WRITE_LINE_DEVICE_HANDLER( oscnano_q_w )
692692{
693   oscnano_state *state = device->machine->driver_data;
693   oscnano_state *driver_state = device->machine->driver_data;
694694
695695   /* CDP1864 audio output enable */
696   cdp1864_aoe_w(state->cdp1864, level);
696   cdp1864_aoe_w(driver_state->cdp1864, state);
697697
698698   /* set Q led status */
699   set_led_status(1, level);
699   set_led_status(1, state);
700700
701701   /* tape output */
702   cassette_output(state->cassette, level ? 1.0 : -1.0);
702   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
703703}
704704
705static CDP1802_DMA_WRITE( oscnano_dma_w )
705static WRITE8_DEVICE_HANDLER( oscnano_dma_w )
706706{
707707   oscnano_state *state = device->machine->driver_data;
708708
r5252r5253
714714   oscnano_mode_r,
715715   oscnano_ef_r,
716716   NULL,
717   oscnano_q_w,
718   NULL,
719   oscnano_dma_w
717   DEVCB_LINE(oscnano_q_w),
718   DEVCB_NULL,
719   DEVCB_HANDLER(oscnano_dma_w)
720720};
721721
722722/* Machine Initialization */
src/mess/drivers/comx35.c
r5252r5253
236236   if (!state->cdp1871_efxa) flags -= EF3;
237237
238238   // cassette input, expansion device flag
239   if ((cassette_input(state->cassette) < +0.0) || !state->cdp1802_ef4) flags -= EF4;
239   if ((state->cassette && (cassette_input(state->cassette) < +0.0)) || !state->cdp1802_ef4) flags -= EF4;
240240
241241   return flags;
242242}
r5252r5253
280280   }
281281}
282282
283static CDP1802_Q_WRITE( comx35_q_w )
283static WRITE_LINE_DEVICE_HANDLER( comx35_q_w )
284284{
285   comx35_state *state = device->machine->driver_data;
285   comx35_state *driver_state = device->machine->driver_data;
286286
287   state->cdp1802_q = level;
287   driver_state->cdp1802_q = state;
288288
289   if (state->iden && level)
289   if (driver_state->iden && state)
290290   {
291291      // enable interrupts
292      state->iden = 0;
292      driver_state->iden = 0;
293293   }
294294
295295   // cassette output
296   cassette_output(state->cassette, level ? +1.0 : -1.0);
296   if (driver_state->cassette) cassette_output(driver_state->cassette, state ? +1.0 : -1.0);
297297}
298298
299299static CDP1802_INTERFACE( comx35_cdp1802_config )
r5252r5253
301301   comx35_mode_r,
302302   comx35_ef_r,
303303   comx35_sc_w,
304   comx35_q_w,
305   NULL,
306   NULL
304   DEVCB_LINE(comx35_q_w),
305   DEVCB_NULL,
306   DEVCB_NULL
307307};
308308
309309/* CDP1871 Interface */
src/mess/drivers/tmc2000e.c
r5252r5253
198198   return flags;
199199}
200200
201static CDP1802_Q_WRITE( tmc2000e_q_w )
201static WRITE_LINE_DEVICE_HANDLER( tmc2000e_q_w )
202202{
203   tmc2000e_state *state = device->machine->driver_data;
203   tmc2000e_state *driver_state = device->machine->driver_data;
204204
205205   // turn CDP1864 sound generator on/off
206206
207   cdp1864_aoe_w(state->cdp1864, level);
207   cdp1864_aoe_w(driver_state->cdp1864, state);
208208
209209   // set Q led status
210210
211   set_led_status(1, level);
211   set_led_status(1, state);
212212
213213   // tape out
214214
215   cassette_output(state->cassette, level ? -1.0 : +1.0);
215   cassette_output(driver_state->cassette, state ? -1.0 : +1.0);
216216
217217   // floppy control (FDC-6)
218218}
219219
220static CDP1802_DMA_WRITE( tmc2000e_dma_w )
220static WRITE8_DEVICE_HANDLER( tmc2000e_dma_w )
221221{
222222   tmc2000e_state *state = device->machine->driver_data;
223223
224   UINT8 color = (state->colorram[ma & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
224   UINT8 color = (state->colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
225225   
226226   int rdata = BIT(color, 2);
227227   int gdata = BIT(color, 0);
r5252r5253
235235   tmc2000e_mode_r,
236236   tmc2000e_ef_r,
237237   NULL,
238   tmc2000e_q_w,
239   NULL,
240   tmc2000e_dma_w
238   DEVCB_LINE(tmc2000e_q_w),
239   DEVCB_NULL,
240   DEVCB_HANDLER(tmc2000e_dma_w)
241241};
242242
243243/* Machine Initialization */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team