Previous 15994 Revisions Next

r4387 Wednesday 4th March, 2009 at 22:48:29 UTC by Wilbert Pol
[COCO family] Changed drivers to new 6821 pia implementations. The drivers still assert.
[src/mess/drivers]coco.c
[src/mess/includes]coco.h
[src/mess/machine]coco.c
[src/mess/video]coco.c coco3.c

src/mess/video/coco.c
r4386r4387
1717***************************************************************************/
1818
1919#include "driver.h"
20#include "machine/6821pia.h"
20#include "machine/6821new.h"
2121#include "machine/6883sam.h"
2222#include "video/m6847.h"
2323#include "includes/coco.h"
r4386r4387
2929 *
3030 *************************************/
3131
32static const device_config *pia_1;
33
3234ATTR_CONST UINT8 coco_get_attributes(UINT8 c)
3335{
3436   UINT8 result = 0x00;
35   UINT8 pia1_pb = pia_get_output_b(1);
37   UINT8 pia1_pb = pianew_get_output_b(pia_1);
3638
3739   if (c & 0x40)      result |= M6847_INV;
3840   if (c & 0x80)      result |= M6847_AS;
r4386r4387
4850
4951static void coco_horizontal_sync_callback(running_machine *machine, int data)
5052{
51   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
53   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
5254
53   pia_0_ca1_w(space, 0, data);
55   pia_ca1_w(pia_0, 0, data);
5456}
5557
5658
5759
5860static void coco_field_sync_callback(running_machine *machine, int data)
5961{
60   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
62   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
6163
62   pia_0_cb1_w(space, 0, data);
64   pia_cb1_w(pia_0, 0, data);
6365}
6466
6567static const UINT8 *get_video_ram_coco(running_machine *machine,int scanline)
r4386r4387
7274{
7375   m6847_config cfg;
7476
77   pia_1 = devtag_get_device( machine, PIA6821, "pia_1" );
78
7579   memset(&cfg, 0, sizeof(cfg));
7680   cfg.type = type;
7781
src/mess/video/coco3.c
r4386r4387
2828#include <math.h>
2929
3030#include "driver.h"
31#include "machine/6821pia.h"
3231#include "machine/6883sam.h"
3332#include "video/m6847.h"
3433#include "includes/coco.h"
src/mess/includes/coco.h
r4386r4387
1212#include "devices/snapquik.h"
1313#include "machine/wd17xx.h"
1414#include "machine/6883sam.h"
15#include "machine/6821new.h"
1516
1617
1718/***************************************************************************
r4386r4387
6364
6465/*----------- defined in machine/coco.c -----------*/
6566extern const wd17xx_interface dgnalpha_wd17xx_interface;
67extern const pia6821_interface coco_pia_intf[];
68extern const pia6821_interface coco2_pia_intf[];
69extern const pia6821_interface coco3_pia_intf[];
70extern const pia6821_interface dragon32_pia_intf[];
71extern const pia6821_interface dragon64_pia_intf[];
72extern const pia6821_interface dgnalpha_pia_intf[];
6673extern const sam6883_interface coco_sam_intf;
6774extern const sam6883_interface coco3_sam_intf;
6875extern UINT8 coco3_gimereg[16];
r4386r4387
9097READ8_HANDLER ( coco3_gime_r );
9198WRITE8_HANDLER ( coco3_gime_w );
9299offs_t coco3_mmu_translate(int bank, int offset);
93WRITE8_HANDLER( coco_pia_1_w );
100WRITE8_DEVICE_HANDLER( coco_pia_1_w );
94101void coco3_horizontal_sync_callback(running_machine *machine,int data);
95102void coco3_field_sync_callback(running_machine *machine,int data);
96103void coco3_gime_field_sync_callback(running_machine *machine);
src/mess/machine/coco.c
r4386r4387
8484#include "driver.h"
8585#include "debug/debugcpu.h"
8686#include "cpu/m6809/m6809.h"
87#include "machine/6821pia.h"
87#include "machine/6821new.h"
8888#include "includes/coco.h"
8989#include "includes/cococart.h"
9090#include "machine/6883sam.h"
r4386r4387
124124static emu_timer *mux_sel2_timer;
125125static UINT8 mux_sel1, mux_sel2;
126126
127static WRITE8_HANDLER ( d_pia1_pb_w );
128static WRITE8_HANDLER ( d_pia1_pa_w );
129static READ8_HANDLER ( d_pia1_pa_r );
130static WRITE8_HANDLER ( d_pia0_pa_w );
131static WRITE8_HANDLER ( d_pia0_pb_w );
132static WRITE8_HANDLER ( d_pia1_cb2_w);
133static WRITE8_HANDLER ( d_pia0_cb2_w);
134static WRITE8_HANDLER ( d_pia1_ca2_w);
135static WRITE8_HANDLER ( d_pia0_ca2_w);
136static void d_pia0_irq_a(running_machine *machine, int state);
137static void d_pia0_irq_b(running_machine *machine, int state);
138static void d_pia1_firq_a(running_machine *machine, int state);
139static void d_pia1_firq_b(running_machine *machine, int state);
127static WRITE8_DEVICE_HANDLER ( d_pia1_pb_w );
128static WRITE8_DEVICE_HANDLER ( d_pia1_pa_w );
129static READ8_DEVICE_HANDLER ( d_pia1_pa_r );
130static WRITE8_DEVICE_HANDLER ( d_pia0_pa_w );
131static WRITE8_DEVICE_HANDLER ( d_pia0_pb_w );
132static WRITE8_DEVICE_HANDLER ( d_pia1_cb2_w);
133static WRITE8_DEVICE_HANDLER ( d_pia0_cb2_w);
134static WRITE8_DEVICE_HANDLER ( d_pia1_ca2_w);
135static WRITE8_DEVICE_HANDLER ( d_pia0_ca2_w);
136static WRITE_LINE_DEVICE_HANDLER( d_pia0_irq_a );
137static WRITE_LINE_DEVICE_HANDLER( d_pia0_irq_b );
138static WRITE_LINE_DEVICE_HANDLER( d_pia1_firq_a );
139static WRITE_LINE_DEVICE_HANDLER( d_pia1_firq_b );
140140static SAM6883_SET_PAGE_ONE_MODE( d_sam_set_pageonemode );
141141static SAM6883_SET_MPU_RATE( d_sam_set_mpurate );
142142static SAM6883_SET_MEMORY_SIZE( d_sam_set_memorysize);
143143static SAM6883_SET_MAP_TYPE( d_sam_set_maptype );
144144
145145/* CoCo 1 specific */
146static READ8_HANDLER ( d_pia1_pb_r_coco );
146static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco );
147147
148148/* CoCo 2 specific */
149static READ8_HANDLER ( d_pia1_pb_r_coco2 );
149static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco2 );
150150
151151/* CoCo 3 specific */
152152UINT8 coco3_gimereg[16];
r4386r4387
155155static UINT8 coco3_interupt_line;
156156static UINT8 gime_firq, gime_irq;
157157
158static void coco3_pia0_irq_a(running_machine *machine, int state);
159static void coco3_pia0_irq_b(running_machine *machine, int state);
160static void coco3_pia1_firq_a(running_machine *machine, int state);
161static void coco3_pia1_firq_b(running_machine *machine, int state);
158static WRITE_LINE_DEVICE_HANDLER( coco3_pia0_irq_a );
159static WRITE_LINE_DEVICE_HANDLER( coco3_pia0_irq_b );
160static WRITE_LINE_DEVICE_HANDLER( coco3_pia1_firq_a );
161static WRITE_LINE_DEVICE_HANDLER( coco3_pia1_firq_b );
162162
163163static SAM6883_SET_MAP_TYPE( coco3_sam_set_maptype );
164164static SAM6883_GET_RAMBASE( coco3_sam_get_rambase );
165165
166166/* Dragon 32 specific */
167static READ8_HANDLER ( d_pia1_pb_r_dragon32 );
167static READ8_DEVICE_HANDLER ( d_pia1_pb_r_dragon32 );
168168
169169/* Dragon 64 / 64 Plus / Tano (Alpha) specific */
170static WRITE8_HANDLER ( dragon64_pia1_pb_w );
170static WRITE8_DEVICE_HANDLER ( dragon64_pia1_pb_w );
171171
172172/* Dragon 64 / Alpha shared */
173173static void dragon_page_rom(running_machine *machine, int romswitch);
174174
175175/* Dragon Alpha specific */
176static WRITE8_HANDLER ( dgnalpha_pia2_pa_w );
177static void d_pia2_firq_a(running_machine *machine, int state);
178static void d_pia2_firq_b(running_machine *machine, int state);
176static WRITE8_DEVICE_HANDLER ( dgnalpha_pia2_pa_w );
177static WRITE_LINE_DEVICE_HANDLER( d_pia2_firq_a );
178static WRITE_LINE_DEVICE_HANDLER( d_pia2_firq_b );
179179static int dgnalpha_just_reset;      /* Reset flag used to ignore first NMI after reset */
180180
181181/* Dragon Plus specific */
r4386r4387
260260
261261/* ----------------------------------------------------------------------- */
262262
263static const pia6821_interface coco_pia_intf[] =
263const pia6821_interface coco_pia_intf[] =
264264{
265265   /* PIA 0 */
266266   {
267      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
268      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
269      /*irqs    : A/B            */ d_pia0_irq_a, d_pia0_irq_b
267      /*inputs : A/B,CA/B1,CA/B2 */
268      DEVCB_NULL,
269      DEVCB_NULL,
270      DEVCB_NULL,
271      DEVCB_NULL,
272      DEVCB_NULL,
273      DEVCB_NULL,
274      /*outputs: A/B,CA/B2      */
275      DEVCB_HANDLER(d_pia0_pa_w),
276      DEVCB_HANDLER(d_pia0_pb_w),
277      DEVCB_HANDLER(d_pia0_ca2_w),
278      DEVCB_HANDLER(d_pia0_cb2_w),
279      /*irqs    : A/B            */
280      DEVCB_LINE(d_pia0_irq_a),
281      DEVCB_LINE(d_pia0_irq_b)
270282   },
271283
272284   /* PIA 1 */
273285   {
274      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_coco, 0, 0, 0, 0,
275      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, d_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
276      /*irqs    : A/B            */ d_pia1_firq_a, d_pia1_firq_b
286      /*inputs : A/B,CA/B1,CA/B2 */
287      DEVCB_HANDLER(d_pia1_pa_r),
288      DEVCB_HANDLER(d_pia1_pb_r_coco),
289      DEVCB_NULL,
290      DEVCB_NULL,
291      DEVCB_NULL,
292      DEVCB_NULL,
293      /*outputs: A/B,CA/B2      */
294      DEVCB_HANDLER(d_pia1_pa_w),
295      DEVCB_HANDLER(d_pia1_pb_w),
296      DEVCB_HANDLER(d_pia1_ca2_w),
297      DEVCB_HANDLER(d_pia1_cb2_w),
298      /*irqs    : A/B            */
299      DEVCB_LINE(d_pia1_firq_a),
300      DEVCB_LINE(d_pia1_firq_b)
277301   }
278302};
279303
280static const pia6821_interface coco2_pia_intf[] =
304const pia6821_interface coco2_pia_intf[] =
281305{
282306   /* PIA 0 */
283307   {
284      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
285      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
286      /*irqs    : A/B            */ d_pia0_irq_a, d_pia0_irq_b
308      /*inputs : A/B,CA/B1,CA/B2 */
309      DEVCB_NULL,
310      DEVCB_NULL,
311      DEVCB_NULL,
312      DEVCB_NULL,
313      DEVCB_NULL,
314      DEVCB_NULL,
315      /*outputs: A/B,CA/B2      */
316      DEVCB_HANDLER(d_pia0_pa_w),
317      DEVCB_HANDLER(d_pia0_pb_w),
318      DEVCB_HANDLER(d_pia0_ca2_w),
319      DEVCB_HANDLER(d_pia0_cb2_w),
320      /*irqs    : A/B            */
321      DEVCB_LINE(d_pia0_irq_a),
322      DEVCB_LINE(d_pia0_irq_b)
287323   },
288324
289325   /* PIA 1 */
290326   {
291      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_coco2, 0, 0, 0, 0,
292      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, d_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
293      /*irqs    : A/B            */ d_pia1_firq_a, d_pia1_firq_b
327      /*inputs : A/B,CA/B1,CA/B2 */
328      DEVCB_HANDLER(d_pia1_pa_r),
329      DEVCB_HANDLER(d_pia1_pb_r_coco2),
330      DEVCB_NULL,
331      DEVCB_NULL,
332      DEVCB_NULL,
333      DEVCB_NULL,
334      /*outputs: A/B,CA/B2      */
335      DEVCB_HANDLER(d_pia1_pa_w),
336      DEVCB_HANDLER(d_pia1_pb_w),
337      DEVCB_HANDLER(d_pia1_ca2_w),
338      DEVCB_HANDLER(d_pia1_cb2_w),
339      /*irqs    : A/B            */
340      DEVCB_LINE(d_pia1_firq_a),
341      DEVCB_LINE(d_pia1_firq_b)
294342   }
295343};
296344
297static const pia6821_interface coco3_pia_intf[] =
345const pia6821_interface coco3_pia_intf[] =
298346{
299347   /* PIA 0 */
300348   {
301      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
302      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
303      /*irqs    : A/B            */ coco3_pia0_irq_a, coco3_pia0_irq_b
349      /*inputs : A/B,CA/B1,CA/B2 */
350      DEVCB_NULL,
351      DEVCB_NULL,
352      DEVCB_NULL,
353      DEVCB_NULL,
354      DEVCB_NULL,
355      DEVCB_NULL,
356      /*outputs: A/B,CA/B2      */
357      DEVCB_HANDLER(d_pia0_pa_w),
358      DEVCB_HANDLER(d_pia0_pb_w),
359      DEVCB_HANDLER(d_pia0_ca2_w),
360      DEVCB_HANDLER(d_pia0_cb2_w),
361      /*irqs    : A/B            */
362      DEVCB_LINE(coco3_pia0_irq_a),
363      DEVCB_LINE(coco3_pia0_irq_b)
304364   },
305365
306366   /* PIA 1 */
307367   {
308      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_coco2, 0, 0, 0, 0,
309      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, d_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
310      /*irqs    : A/B            */ coco3_pia1_firq_a, coco3_pia1_firq_b
368      /*inputs : A/B,CA/B1,CA/B2 */
369      DEVCB_HANDLER(d_pia1_pa_r),
370      DEVCB_HANDLER(d_pia1_pb_r_coco2),
371      DEVCB_NULL,
372      DEVCB_NULL,
373      DEVCB_NULL,
374      DEVCB_NULL,
375      /*outputs: A/B,CA/B2      */
376      DEVCB_HANDLER(d_pia1_pa_w),
377      DEVCB_HANDLER(d_pia1_pb_w),
378      DEVCB_HANDLER(d_pia1_ca2_w),
379      DEVCB_HANDLER(d_pia1_cb2_w),
380      /*irqs    : A/B            */
381      DEVCB_LINE(coco3_pia1_firq_a),
382      DEVCB_LINE(coco3_pia1_firq_b)
311383   }
312384};
313385
314static const pia6821_interface dragon32_pia_intf[] =
386const pia6821_interface dragon32_pia_intf[] =
315387{
316388   /* PIA 0 */
317389   {
318      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
319      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
320      /*irqs    : A/B            */ d_pia0_irq_a, d_pia0_irq_b
390      /*inputs : A/B,CA/B1,CA/B2 */
391      DEVCB_NULL,
392      DEVCB_NULL,
393      DEVCB_NULL,
394      DEVCB_NULL,
395      DEVCB_NULL,
396      DEVCB_NULL,
397      /*outputs: A/B,CA/B2      */
398      DEVCB_HANDLER(d_pia0_pa_w),
399      DEVCB_HANDLER(d_pia0_pb_w),
400      DEVCB_HANDLER(d_pia0_ca2_w),
401      DEVCB_HANDLER(d_pia0_cb2_w),
402      /*irqs    : A/B            */
403      DEVCB_LINE(d_pia0_irq_a),
404      DEVCB_LINE(d_pia0_irq_b)
321405   },
322406
323407   /* PIA 1 */
324408   {
325      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_dragon32, 0, 0, 0, 0,
326      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, d_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
327      /*irqs    : A/B            */ d_pia1_firq_a, d_pia1_firq_b
409      /*inputs : A/B,CA/B1,CA/B2 */
410      DEVCB_HANDLER(d_pia1_pa_r),
411      DEVCB_HANDLER(d_pia1_pb_r_dragon32),
412      DEVCB_NULL,
413      DEVCB_NULL,
414      DEVCB_NULL,
415      DEVCB_NULL,
416      /*outputs: A/B,CA/B2      */
417      DEVCB_HANDLER(d_pia1_pa_w),
418      DEVCB_HANDLER(d_pia1_pb_w),
419      DEVCB_HANDLER(d_pia1_ca2_w),
420      DEVCB_HANDLER(d_pia1_cb2_w),
421      /*irqs    : A/B            */
422      DEVCB_LINE(d_pia1_firq_a),
423      DEVCB_LINE(d_pia1_firq_b)
328424   }
329425};
330426
331static const pia6821_interface dragon64_pia_intf[] =
427const pia6821_interface dragon64_pia_intf[] =
332428{
333429   /* PIA 0 */
334430   {
335      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
336      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
337      /*irqs    : A/B            */ d_pia0_irq_a, d_pia0_irq_b
431      /*inputs : A/B,CA/B1,CA/B2 */
432      DEVCB_NULL,
433      DEVCB_NULL,
434      DEVCB_NULL,
435      DEVCB_NULL,
436      DEVCB_NULL,
437      DEVCB_NULL,
438      /*outputs: A/B,CA/B2      */
439      DEVCB_HANDLER(d_pia0_pa_w),
440      DEVCB_HANDLER(d_pia0_pb_w),
441      DEVCB_HANDLER(d_pia0_ca2_w),
442      DEVCB_HANDLER(d_pia0_cb2_w),
443      /*irqs    : A/B            */
444      DEVCB_LINE(d_pia0_irq_a),
445      DEVCB_LINE(d_pia0_irq_b)
338446   },
339447
340448   /* PIA 1 */
341449   {
342      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_coco, 0, 0, 0, 0,
343      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, dragon64_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
344      /*irqs    : A/B            */ d_pia1_firq_a, d_pia1_firq_b
450      /*inputs : A/B,CA/B1,CA/B2 */
451      DEVCB_HANDLER(d_pia1_pa_r),
452      DEVCB_HANDLER(d_pia1_pb_r_coco),
453      DEVCB_NULL,
454      DEVCB_NULL,
455      DEVCB_NULL,
456      DEVCB_NULL,
457      /*outputs: A/B,CA/B2      */
458      DEVCB_HANDLER(d_pia1_pa_w),
459      DEVCB_HANDLER(dragon64_pia1_pb_w),
460      DEVCB_HANDLER(d_pia1_ca2_w),
461      DEVCB_HANDLER(d_pia1_cb2_w),
462      /*irqs    : A/B            */
463      DEVCB_LINE(d_pia1_firq_a),
464      DEVCB_LINE(d_pia1_firq_b)
345465   }
346466};
347467
348static const pia6821_interface dgnalpha_pia_intf[] =
468const pia6821_interface dgnalpha_pia_intf[] =
349469{
350470   /* PIA 0 and 1 as Dragon 64 */
351471   /* PIA 0 */
352472   {
353      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
354      /*outputs: A/B,CA/B2      */ d_pia0_pa_w, d_pia0_pb_w, d_pia0_ca2_w, d_pia0_cb2_w,
355      /*irqs    : A/B            */ d_pia0_irq_a, d_pia0_irq_b
473      /*inputs : A/B,CA/B1,CA/B2 */
474      DEVCB_NULL,
475      DEVCB_NULL,
476      DEVCB_NULL,
477      DEVCB_NULL,
478      DEVCB_NULL,
479      DEVCB_NULL,
480      /*outputs: A/B,CA/B2      */
481      DEVCB_HANDLER(d_pia0_pa_w),
482      DEVCB_HANDLER(d_pia0_pb_w),
483      DEVCB_HANDLER(d_pia0_ca2_w),
484      DEVCB_HANDLER(d_pia0_cb2_w),
485      /*irqs    : A/B            */
486      DEVCB_LINE(d_pia0_irq_a),
487      DEVCB_LINE(d_pia0_irq_b)
356488   },
357489
358490   /* PIA 1 */
359491   {
360      /*inputs : A/B,CA/B1,CA/B2 */ d_pia1_pa_r, d_pia1_pb_r_coco, 0, 0, 0, 0,
361      /*outputs: A/B,CA/B2      */ d_pia1_pa_w, d_pia1_pb_w, d_pia1_ca2_w, d_pia1_cb2_w,
362      /*irqs    : A/B            */ d_pia1_firq_a, d_pia1_firq_b
492      /*inputs : A/B,CA/B1,CA/B2 */
493      DEVCB_HANDLER(d_pia1_pa_r),
494      DEVCB_HANDLER(d_pia1_pb_r_coco),
495      DEVCB_NULL,
496      DEVCB_NULL,
497      DEVCB_NULL,
498      DEVCB_NULL,
499      /*outputs: A/B,CA/B2      */
500      DEVCB_HANDLER(d_pia1_pa_w),
501      DEVCB_HANDLER(d_pia1_pb_w),
502      DEVCB_HANDLER(d_pia1_ca2_w),
503      DEVCB_HANDLER(d_pia1_cb2_w),
504      /*irqs    : A/B            */
505      DEVCB_LINE(d_pia1_firq_a),
506      DEVCB_LINE(d_pia1_firq_b)
363507   },
364508
365509   /* PIA 2 */
366510   {
367      /*inputs : A/B,CA/B1,CA/B2 */ 0, 0, 0, 0, 0, 0,
368      /*outputs: A/B,CA/B2      */ dgnalpha_pia2_pa_w, 0, 0, 0,
369      /*irqs    : A/B               */ d_pia2_firq_a, d_pia2_firq_b
511      /*inputs : A/B,CA/B1,CA/B2 */
512      DEVCB_NULL,
513      DEVCB_NULL,
514      DEVCB_NULL,
515      DEVCB_NULL,
516      DEVCB_NULL,
517      DEVCB_NULL,
518      /*outputs: A/B,CA/B2      */
519      DEVCB_HANDLER(dgnalpha_pia2_pa_w),
520      DEVCB_NULL,
521      DEVCB_NULL,
522      DEVCB_NULL,
523      /*irqs    : A/B               */
524      DEVCB_LINE(d_pia2_firq_a),
525      DEVCB_LINE(d_pia2_firq_b)
370526   }
371527
372528};
r4386r4387
449605static void pak_load_trailer(running_machine *machine, const pak_decodedtrailer *trailer)
450606{
451607   const device_config *sam = devtag_get_device(machine, SAM6883, "sam");
608   const device_config *pia_0 = devtag_get_device(machine, PIA6821, "pia_0");
609   const device_config *pia_1 = devtag_get_device(machine, PIA6821, "pia_1");
610
452611   cpu_set_reg(machine->cpu[0], M6809_PC, trailer->reg_pc);
453612   cpu_set_reg(machine->cpu[0], M6809_X, trailer->reg_x);
454613   cpu_set_reg(machine->cpu[0], M6809_Y, trailer->reg_y);
r4386r4387
465624    * startup. I wish I had a better solution
466625    */
467626
468   pia_write(0, 1, 0x00);
469   pia_write(0, 3, 0x00);
470   pia_write(0, 0, 0x00);
471   pia_write(0, 2, 0xff);
472   pia_write(1, 1, 0x00);
473   pia_write(1, 3, 0x00);
474   pia_write(1, 0, 0xfe);
475   pia_write(1, 2, 0xf8);
627   pia_w(pia_0, 1, 0x00);
628   pia_w(pia_0, 3, 0x00);
629   pia_w(pia_0, 0, 0x00);
630   pia_w(pia_0, 2, 0xff);
631   pia_w(pia_1, 1, 0x00);
632   pia_w(pia_1, 3, 0x00);
633   pia_w(pia_1, 0, 0xfe);
634   pia_w(pia_1, 2, 0xf8);
476635
477   pia_write(0, 1, trailer->pia[1]);
478   pia_write(0, 0, trailer->pia[0]);
479   pia_write(0, 3, trailer->pia[3]);
480   pia_write(0, 2, trailer->pia[2]);
636   pia_w(pia_0, 1, trailer->pia[1]);
637   pia_w(pia_0, 0, trailer->pia[0]);
638   pia_w(pia_0, 3, trailer->pia[3]);
639   pia_w(pia_0, 2, trailer->pia[2]);
481640
482   pia_write(1, 1, trailer->pia[5]);
483   pia_write(1, 0, trailer->pia[4]);
484   pia_write(1, 3, trailer->pia[7]);
485   pia_write(1, 2, trailer->pia[6]);
641   pia_w(pia_1, 1, trailer->pia[5]);
642   pia_w(pia_1, 0, trailer->pia[4]);
643   pia_w(pia_1, 3, trailer->pia[7]);
644   pia_w(pia_1, 2, trailer->pia[6]);
486645
487646   /* For some reason, specifying use of high ram seems to screw things up;
488647    * I'm not sure whether it is because I'm using the wrong method to get
r4386r4387
756915
757916static void d_recalc_irq(running_machine *machine)
758917{
759   UINT8 pia0_irq_a = pia_get_irq_a(0);
760   UINT8 pia0_irq_b = pia_get_irq_b(0);
918   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
919   UINT8 pia0_irq_a = pianew_get_irq_a(pia_0);
920   UINT8 pia0_irq_b = pianew_get_irq_b(pia_0);
761921
762922   if (pia0_irq_a || pia0_irq_b)
763923      cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, ASSERT_LINE);
r4386r4387
767927
768928static void d_recalc_firq(running_machine *machine)
769929{
770   UINT8 pia1_firq_a = pia_get_irq_a(1);
771   UINT8 pia1_firq_b = pia_get_irq_b(1);
772   UINT8 pia2_firq_a = pia_get_irq_a(2);
773   UINT8 pia2_firq_b = pia_get_irq_b(2);
930   const device_config *pia_1 = devtag_get_device( machine, PIA6821, "pia_1" );
931   const device_config *pia_2 = devtag_get_device( machine, PIA6821, "pia_2" );
932   UINT8 pia1_firq_a = pianew_get_irq_a(pia_1);
933   UINT8 pia1_firq_b = pianew_get_irq_b(pia_1);
934   UINT8 pia2_firq_a = pianew_get_irq_a(pia_2);
935   UINT8 pia2_firq_b = pianew_get_irq_b(pia_2);
774936
775937   if (pia1_firq_a || pia1_firq_b || pia2_firq_a || pia2_firq_b)
776938      cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, ASSERT_LINE);
r4386r4387
794956      d_recalc_firq(machine);
795957}
796958
797static void d_pia0_irq_a(running_machine *machine, int state)
959static WRITE_LINE_DEVICE_HANDLER( d_pia0_irq_a )
798960{
799   d_recalc_irq(machine);
961   d_recalc_irq(device->machine);
800962}
801963
802static void d_pia0_irq_b(running_machine *machine, int state)
964static WRITE_LINE_DEVICE_HANDLER( d_pia0_irq_b )
803965{
804   d_recalc_irq(machine);
966   d_recalc_irq(device->machine);
805967}
806968
807static void d_pia1_firq_a(running_machine *machine, int state)
969static WRITE_LINE_DEVICE_HANDLER( d_pia1_firq_a )
808970{
809   d_recalc_firq(machine);
971   d_recalc_firq(device->machine);
810972}
811973
812static void d_pia1_firq_b(running_machine *machine, int state)
974static WRITE_LINE_DEVICE_HANDLER( d_pia1_firq_b )
813975{
814   d_recalc_firq(machine);
976   d_recalc_firq(device->machine);
815977}
816978
817979/* Dragon Alpha second PIA IRQ lines also cause FIRQ */
818static void d_pia2_firq_a(running_machine *machine, int state)
980static WRITE_LINE_DEVICE_HANDLER( d_pia2_firq_a )
819981{
820   d_recalc_firq(machine);
982   d_recalc_firq(device->machine);
821983}
822984
823static void d_pia2_firq_b(running_machine *machine, int state)
985static WRITE_LINE_DEVICE_HANDLER( d_pia2_firq_b )
824986{
825   d_recalc_firq(machine);
987   d_recalc_firq(device->machine);
826988}
827989
828static void coco3_pia0_irq_a(running_machine *machine, int state)
990static WRITE_LINE_DEVICE_HANDLER( coco3_pia0_irq_a )
829991{
830   coco3_recalc_irq(machine);
992   coco3_recalc_irq(device->machine);
831993}
832994
833static void coco3_pia0_irq_b(running_machine *machine, int state)
995static WRITE_LINE_DEVICE_HANDLER( coco3_pia0_irq_b )
834996{
835   coco3_recalc_irq(machine);
997   coco3_recalc_irq(device->machine);
836998}
837999
838static void coco3_pia1_firq_a(running_machine *machine, int state)
1000static WRITE_LINE_DEVICE_HANDLER( coco3_pia1_firq_a )
8391001{
840   coco3_recalc_firq(machine);
1002   coco3_recalc_firq(device->machine);
8411003}
8421004
843static void coco3_pia1_firq_b(running_machine *machine, int state)
1005static WRITE_LINE_DEVICE_HANDLER( coco3_pia1_firq_b )
8441006{
845   coco3_recalc_firq(machine);
1007   coco3_recalc_firq(device->machine);
8461008}
8471009
8481010static void coco3_raise_interrupt(running_machine *machine, UINT8 mask, int state)
r4386r4387
8811043
8821044void coco3_horizontal_sync_callback(running_machine *machine,int data)
8831045{
884   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1046   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
8851047
886   pia_0_ca1_w(space, 0, data);
1048   pia_ca1_w(pia_0, 0, data);
8871049   coco3_raise_interrupt(machine, COCO3_INT_HBORD, data);
8881050}
8891051
r4386r4387
8911053
8921054void coco3_field_sync_callback(running_machine *machine,int data)
8931055{
894   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1056   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
8951057
896   pia_0_cb1_w(space, 0, data);
1058   pia_cb1_w(pia_0, 0, data);
8971059}
8981060
8991061void coco3_gime_field_sync_callback(running_machine *machine)
r4386r4387
11351297   return state->cococart_device;
11361298}
11371299
1138static int get_soundmux_status(void)
1300static int get_soundmux_status(running_machine *machine)
11391301{
1302   const device_config *pia_1 = devtag_get_device( machine, PIA6821, "pia_1" );
1303
11401304   int soundmux_status = 0;
1141   if (pia_get_output_cb2(1))
1305   if (pianew_get_output_cb2(pia_1))
11421306      soundmux_status |= SOUNDMUX_STATUS_ENABLE;
11431307   if (mux_sel1)
11441308      soundmux_status |= SOUNDMUX_STATUS_SEL1;
r4386r4387
11551319    * switch on or off.
11561320    */
11571321   cassette_state new_state;
1158   int soundmux_status = get_soundmux_status();
1322   int soundmux_status = get_soundmux_status(machine);
11591323
11601324   switch(soundmux_status) {
11611325   case SOUNDMUX_STATUS_ENABLE | SOUNDMUX_STATUS_SEL1:
r4386r4387
11811345static void coco_sound_update(running_machine *machine)
11821346{
11831347   const device_config *dac_device = devtag_get_device(machine, SOUND, "dac");
1348   const device_config *pia_1 = devtag_get_device( machine, PIA6821, "pia_1" );
11841349
11851350   /* Call this function whenever you need to update the sound. It will
11861351    * automatically mute any devices that are switched out.
11871352    */
1188   UINT8 dac = pia_get_output_a(1) & 0xFC;
1189   UINT8 pia1_pb1 = (pia_get_output_b(1) & 0x02) ? 0x80 : 0x00;
1190   int soundmux_status = get_soundmux_status();
1353   UINT8 dac = pianew_get_output_a(pia_1) & 0xFC;
1354   UINT8 pia1_pb1 = (pianew_get_output_b(pia_1) & 0x02) ? 0x80 : 0x00;
1355   int soundmux_status = get_soundmux_status(machine);
11911356
11921357   switch(soundmux_status)
11931358   {
r4386r4387
12531418  PIA0 CB2      - SEL2 (Used by sound mux and joystick)
12541419***************************************************************************/
12551420
1256static WRITE8_HANDLER ( d_pia0_ca2_w )
1421static WRITE8_DEVICE_HANDLER ( d_pia0_ca2_w )
12571422{
12581423   timer_adjust_oneshot(mux_sel1_timer, JOYSTICK_MUX_DELAY, data);
12591424}
r4386r4387
12651430   soundmux_update(machine);
12661431}
12671432
1268static WRITE8_HANDLER ( d_pia0_cb2_w )
1433static WRITE8_DEVICE_HANDLER ( d_pia0_cb2_w )
12691434{
12701435   timer_adjust_oneshot(mux_sel2_timer, JOYSTICK_MUX_DELAY, data);
12711436}
r4386r4387
12941459
12951460static UINT8 coco_update_keyboard(running_machine *machine)
12961461{
1462   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
1463   const device_config *pia_1 = devtag_get_device( machine, PIA6821, "pia_1" );
12971464   UINT8 porta = 0x7F, port_za = 0x7f;
12981465   int joyval;
12991466   static const int joy_rat_table[] = {15, 24, 42, 33 };
13001467   static const int dclg_table[] = {0, 14, 30, 49 };
13011468   attotime dclg_time = attotime_zero;
13021469   UINT8 pia0_pb;
1303   UINT8 dac = pia_get_output_a(1) & 0xFC;
1470   UINT8 dac = pianew_get_output_a(pia_1) & 0xFC;
13041471   int joystick_axis, joystick;
1305   pia0_pb = pia_get_output_b(0);
1472   pia0_pb = pianew_get_output_b(pia_0);
13061473   joystick_axis = mux_sel1;
13071474   joystick = mux_sel2;
13081475
r4386r4387
13151482   if ((input_port_read(machine, "row5") | pia0_pb) != 0xff) porta &= ~0x20;
13161483   if ((input_port_read(machine, "row6") | pia0_pb) != 0xff) porta &= ~0x40;
13171484
1318   if ((input_port_read(machine, "row0") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x01;
1319   if ((input_port_read(machine, "row1") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x02;
1320   if ((input_port_read(machine, "row2") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x04;
1321   if ((input_port_read(machine, "row3") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x08;
1322   if ((input_port_read(machine, "row4") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x10;
1323   if ((input_port_read(machine, "row5") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x20;
1324   if ((input_port_read(machine, "row6") | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x40;
1485   if ((input_port_read(machine, "row0") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x01;
1486   if ((input_port_read(machine, "row1") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x02;
1487   if ((input_port_read(machine, "row2") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x04;
1488   if ((input_port_read(machine, "row3") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x08;
1489   if ((input_port_read(machine, "row4") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x10;
1490   if ((input_port_read(machine, "row5") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x20;
1491   if ((input_port_read(machine, "row6") | pianew_get_port_b_z_mask(pia_0)) != 0xff) port_za &= ~0x40;
13251492
13261493   switch(get_input_device(machine, joystick ? INPUTPORT_LEFT_JOYSTICK : INPUTPORT_RIGHT_JOYSTICK))
13271494   {
r4386r4387
13921559   porta &= ~input_port_read_safe(machine, "joystick_buttons", 0);
13931560   port_za &= ~input_port_read_safe(machine, "joystick_buttons", 0);
13941561
1395   pia_set_input_a(0, porta, port_za);
1562   pianew_set_input_a(pia_0, porta, port_za);
13961563   return porta;
13971564}
13981565
r4386r4387
14101577
14111578
14121579/* three functions that update the keyboard in varying ways */
1413static WRITE8_HANDLER ( d_pia0_pb_w )               { (*update_keyboard)(space->machine); }
1580static WRITE8_DEVICE_HANDLER ( d_pia0_pb_w )               { (*update_keyboard)(device->machine); }
14141581INPUT_CHANGED(coco_keyboard_changed)               { (*update_keyboard)(field->port->machine); }
14151582static TIMER_CALLBACK(coco_update_keyboard_timerproc)   { (*update_keyboard)(machine); }
14161583
1417static WRITE8_HANDLER ( d_pia0_pa_w )
1584static WRITE8_DEVICE_HANDLER ( d_pia0_pa_w )
14181585{
1419   if (get_input_device(space->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
1420      coco_hiresjoy_w(space->machine, data & 0x04);
1586   if (get_input_device(device->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
1587      coco_hiresjoy_w(device->machine, data & 0x04);
14211588}
14221589
14231590
r4386r4387
14421609  PIA1 CB2      - SNDEN (Sound Enable)
14431610***************************************************************************/
14441611
1445static WRITE8_HANDLER ( d_pia1_cb2_w )
1612static WRITE8_DEVICE_HANDLER ( d_pia1_cb2_w )
14461613{
1447   soundmux_update(space->machine);
1614   soundmux_update(device->machine);
14481615}
14491616
14501617/* Printer output functions used by d_pia1_pa_w */
r4386r4387
14591626/* Printer output for the Dragon, output to Paralel port */
14601627static void printer_out_dragon(running_machine *machine, int data)
14611628{
1629   const device_config *pia_0 = devtag_get_device( machine, PIA6821, "pia_0" );
1630
14621631   /* If strobe bit is high send data from pia0 port b to dragon parallel printer */
14631632   if (data & 0x02)
14641633   {
1465      printer_output(printer_image(machine), pia_get_output_b(0));
1634      printer_output(printer_image(machine), pianew_get_output_b(pia_0));
14661635   }
14671636}
14681637
1469static WRITE8_HANDLER ( d_pia1_pa_w )
1638static WRITE8_DEVICE_HANDLER ( d_pia1_pa_w )
14701639{
14711640   /*
14721641    *   This port appears at $FF20
r4386r4387
14751644    *  7-2:   DAC to speaker or cassette
14761645    *    1:   Serial out (CoCo), Printer strobe (Dragon)
14771646    */
1478   UINT8 dac = pia_get_output_a(1) & 0xFC;
1647   UINT8 dac = pianew_get_output_a(device) & 0xFC;
14791648   static int dclg_previous_bit;
14801649
1481   coco_sound_update(space->machine);
1650   coco_sound_update(device->machine);
14821651
1483   if (get_input_device(space->machine, INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN)
1652   if (get_input_device(device->machine, INPUTPORT_SERIAL) == INPUTDEVICE_DIECOM_LIGHTGUN)
14841653   {
14851654      int dclg_this_bit = ((data & 2) >> 1);
14861655
r4386r4387
15231692   }
15241693   else
15251694   {
1526      cassette_output(cassette_device_image(space->machine), ((int) dac - 0x80) / 128.0);
1695      cassette_output(cassette_device_image(device->machine), ((int) dac - 0x80) / 128.0);
15271696   }
15281697
1529   (*update_keyboard)(space->machine);
1698   (*update_keyboard)(device->machine);
15301699
1531   if (get_input_device(space->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE)
1532      coco_hiresjoy_w(space->machine, dac >= 0x80);
1700   if (get_input_device(device->machine, INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_INTERFACE)
1701      coco_hiresjoy_w(device->machine, dac >= 0x80);
15331702
15341703   /* Handle printer output, serial for CoCos, Paralell for Dragons */
15351704
1536   printer_out(space->machine, data);
1705   printer_out(device->machine, data);
15371706}
15381707
15391708/*
r4386r4387
15441713 * semigraphics modes
15451714 */
15461715
1547static WRITE8_HANDLER( d_pia1_pb_w )
1716static WRITE8_DEVICE_HANDLER( d_pia1_pb_w )
15481717{
15491718   m6847_video_changed();
15501719
r4386r4387
15541723    *
15551724    * Source:  Page 31 of the Tandy Color Computer Serice Manual
15561725    */
1557   coco_sound_update(space->machine);
1726   coco_sound_update(device->machine);
15581727}
15591728
1560static WRITE8_HANDLER( dragon64_pia1_pb_w )
1729static WRITE8_DEVICE_HANDLER( dragon64_pia1_pb_w )
15611730{
15621731   int ddr;
15631732
1564   d_pia1_pb_w(space, 0, data);
1733   d_pia1_pb_w(device, 0, data);
15651734
1566   ddr = ~pia_get_port_b_z_mask(1);
1735   ddr = ~pianew_get_port_b_z_mask(device);
15671736
15681737   /* If bit 2 of the pia1 ddrb is 1 then this pin is an output so use it */
15691738   /* to control the paging of the 32k and 64k basic roms */
r4386r4387
15711740   /* always be high (enabling 32k basic rom) */
15721741   if (ddr & 0x04)
15731742   {
1574      dragon_page_rom(space->machine, data & 0x04);
1743      dragon_page_rom(device->machine, data & 0x04);
15751744   }
15761745}
15771746
r4386r4387
15861755   CB1            DRQ from WD2797 disk controler.
15871756***************************************************************************/
15881757
1589static WRITE8_HANDLER( dgnalpha_pia2_pa_w )
1758static WRITE8_DEVICE_HANDLER( dgnalpha_pia2_pa_w )
15901759{
1591   const device_config *ay8912 = devtag_get_device(space->machine, SOUND, "ay8912");
1760   const device_config *ay8912 = devtag_get_device(device->machine, SOUND, "ay8912");
15921761   int   bc_flags;      /* BCDDIR/BC1, as connected to PIA2 port a bits 0 and 1 */
15931762
15941763   /* If bit 2 of the pia2 ddra is 1 then this pin is an output so use it */
r4386r4387
15971766   /* always be high (enabling boot rom) */
15981767   /* PIA FIXME if (pia_get_ddr_a(2) & 0x04) */
15991768   {
1600      dragon_page_rom(space->machine, data & 0x04);   /* bit 2 controls boot or basic rom */
1769      dragon_page_rom(device->machine, data & 0x04);   /* bit 2 controls boot or basic rom */
16011770   }
16021771
16031772   /* Bits 0 and 1 for pia2 port a control the BCDIR and BC1 lines of the */
r4386r4387
16091778      case 0x00   :       /* Inactive, do nothing */
16101779         break;
16111780      case 0x01   :       /* Write to selected port */
1612         ay8910_data_w(ay8912, 0, pia_get_output_b(2));
1781         ay8910_data_w(ay8912, 0, pianew_get_output_b(device));
16131782         break;
16141783      case 0x02   :       /* Read from selected port */
1615         pia_set_input_b(2, ay8910_r(ay8912, 0));
1784         /* TODO FIXME 6821pia devicification
1785         pianew_set_input_b(device, ay8910_r(ay8912, 0));
1786         */
16161787         break;
16171788      case 0x03   :      /* Select port to write to */
1618         ay8910_address_w(ay8912, 0, pia_get_output_b(2));
1789         ay8910_address_w(ay8912, 0, pianew_get_output_b(device));
16191790         break;
16201791   }
16211792}
r4386r4387
16481819   /* The NMI line on the alphaAlpha is gated through IC16 (early PLD), and is gated by pia2 CA2  */
16491820   /* The DRQ line goes through pia2 cb1, in exactly the same way as DRQ from DragonDos does */
16501821   /* for pia1 cb1 */
1822   const device_config *pia_2 = devtag_get_device( device->machine, PIA6821, "pia_2" );
16511823
1652   const address_space *space = cpu_get_address_space( device->machine->cpu[0], ADDRESS_SPACE_PROGRAM );
1653
16541824   switch(state)
16551825   {
16561826      case WD17XX_IRQ_CLR:
r4386r4387
16631833         }
16641834         else
16651835         {
1666            if (pia_get_output_ca2_z(2))
1836            if (pianew_get_output_ca2_z(pia_2))
16671837               cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, ASSERT_LINE);
16681838         }
16691839         break;
16701840      case WD17XX_DRQ_CLR:
1671         pia_2_cb1_w(space, 0, CARTLINE_CLEAR);
1841         pia_cb1_w(pia_2, 0, CARTLINE_CLEAR);
16721842         break;
16731843      case WD17XX_DRQ_SET:
1674         pia_2_cb1_w(space, 0, CARTLINE_ASSERTED);
1844         pia_cb1_w(pia_2, 0, CARTLINE_ASSERTED);
16751845         break;
16761846   }
16771847}
r4386r4387
17351905{
17361906}
17371907
1738static WRITE8_HANDLER ( d_pia1_ca2_w )
1908static WRITE8_DEVICE_HANDLER ( d_pia1_ca2_w )
17391909{
17401910   cassette_change_state(
1741      cassette_device_image(space->machine),
1911      cassette_device_image(device->machine),
17421912      data ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,
17431913      CASSETTE_MASK_MOTOR);
17441914}
17451915
17461916
17471917
1748static READ8_HANDLER ( d_pia1_pa_r )
1918static READ8_DEVICE_HANDLER ( d_pia1_pa_r )
17491919{
1750   return (cassette_input(cassette_device_image(space->machine)) >= 0) ? 1 : 0;
1920   return (cassette_input(cassette_device_image(device->machine)) >= 0) ? 1 : 0;
17511921}
17521922
17531923
17541924
1755static READ8_HANDLER ( d_pia1_pb_r_coco )
1925static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco )
17561926{
1927   const device_config *pia_0 = devtag_get_device( device->machine, PIA6821, "pia_0" );
1928
17571929   /* This handles the reading of the memory sense switch (pb2) for the CoCo 1,
17581930    * and serial-in (pb0). Serial-in not yet implemented. */
17591931   int result;
r4386r4387
17661938      the full 64K, as this uses Color Basic 1.2, which can configure 64K rams */
17671939
17681940   if (mess_ram_size > 0x8000)      /* 1 bank of 64K rams */
1769      result = (pia_get_output_b(0) & 0x80) >> 5;
1941      result = (pianew_get_output_b(pia_0) & 0x80) >> 5;
17701942   else if (mess_ram_size >= 0x4000)   /* 1 or 2 banks of 16K rams */
17711943      result = 0x04;
17721944   else
r4386r4387
17751947   return result;
17761948}
17771949
1778static READ8_HANDLER ( d_pia1_pb_r_dragon32 )
1950static READ8_DEVICE_HANDLER ( d_pia1_pb_r_dragon32 )
17791951{
17801952   /* This handles the reading of the memory sense switch (pb2) for the Dragon 32,
17811953    * and pb0, is the printer /busy line. */
r4386r4387
17941966   return result;
17951967}
17961968
1797static READ8_HANDLER ( d_pia1_pb_r_coco2 )
1969static READ8_DEVICE_HANDLER ( d_pia1_pb_r_coco2 )
17981970{
1971   const device_config *pia_0 = devtag_get_device( device->machine, PIA6821, "pia_0" );
1972
17991973   /* This handles the reading of the memory sense switch (pb2) for the CoCo 2 and 3,
18001974    * and serial-in (pb0). Serial-in not yet implemented.
18011975    */
r4386r4387
18061980   else if (mess_ram_size <= 0x4000)
18071981      result = 0x04;               /* 16K: wire pia1_pb2 high */
18081982   else
1809      result = (pia_get_output_b(0) & 0x40) >> 4;      /* 32/64K: wire output of pia0_pb6 to input pia1_pb2  */
1983      result = (pianew_get_output_b(pia_0) & 0x40) >> 4;      /* 32/64K: wire output of pia0_pb6 to input pia1_pb2  */
18101984   return result;
18111985}
18121986
r4386r4387
26242798
26252799void coco_cart_w(const device_config *device, int data)
26262800{
2627   const address_space *space = cpu_get_address_space( device->machine->cpu[0], ADDRESS_SPACE_PROGRAM );
2628   pia_1_cb1_w(space, 0, data ? ASSERT_LINE : CLEAR_LINE);
2801   const device_config *pia_1 = devtag_get_device( device->machine, PIA6821, "pia_1" );
2802
2803   pia_cb1_w(pia_1, 0, data ? ASSERT_LINE : CLEAR_LINE);
26292804}
26302805
26312806
r4386r4387
26692844   also call twiddle Q lines, if necessary
26702845-------------------------------------------------*/
26712846
2672WRITE8_HANDLER(coco_pia_1_w)
2847WRITE8_DEVICE_HANDLER(coco_pia_1_w)
26732848{
2674   pia_1_w(space, offset, data);
2675   coco_cartridge_twiddle_q_lines(cococart_device(space->machine));
2849   pia_w(device, offset, data);
2850   coco_cartridge_twiddle_q_lines(cococart_device(device->machine));
26762851}
26772852
26782853
r4386r4387
26832858typedef struct _machine_init_interface machine_init_interface;
26842859struct _machine_init_interface
26852860{
2686   const pia6821_interface *piaintf;         /* PIA initializer */
2687   int   piaintf_count;                     /* PIA count */
26882861   timer_fired_func recalc_interrupts_;         /* recalculate inturrupts callback */
26892862   void (*printer_out_)(running_machine *machine, int data);            /* printer output callback */
26902863};
r4386r4387
26992872static void generic_init_machine(running_machine *machine, const machine_init_interface *init)
27002873{
27012874   coco_state *state = (coco_state *) machine->driver_data;
2702   int i;
27032875
27042876   /* locate devices */
27052877   state->cococart_device = devtag_get_device(machine, DEVICE_TYPE_WILDCARD, "coco_cartslot");
r4386r4387
27352907   /* setup printer output callback */
27362908   printer_out = init->printer_out_;
27372909
2738   /* setup PIAs */
2739   for (i = 0; i < init->piaintf_count; i++)
2740      pia_config(machine, i, &init->piaintf[i]);
2741   pia_reset();
2742
27432910   debug_cpu_set_dasm_override(machine->cpu[0], coco_dasm_override);
27442911
27452912   state_save_register_global(machine, mux_sel1);
r4386r4387
27652932
27662933   /* Setup machine initialization */
27672934   memset(&init, 0, sizeof(init));
2768   init.piaintf         = dragon32_pia_intf;
2769   init.piaintf_count      = ARRAY_LENGTH(dragon32_pia_intf);
27702935   init.recalc_interrupts_   = d_recalc_interrupts;
27712936   init.printer_out_      = printer_out_dragon;
27722937
r4386r4387
27792944
27802945   /* Setup machine initialization */
27812946   memset(&init, 0, sizeof(init));
2782   init.piaintf         = dragon64_pia_intf;
2783   init.piaintf_count      = ARRAY_LENGTH(dragon64_pia_intf);
27842947   init.recalc_interrupts_   = d_recalc_interrupts;
27852948   init.printer_out_      = printer_out_dragon;
27862949
r4386r4387
27932956
27942957   /* Setup machine initialization */
27952958   memset(&init, 0, sizeof(init));
2796   init.piaintf         = dragon64_pia_intf;
2797   init.piaintf_count      = ARRAY_LENGTH(dragon64_pia_intf);
27982959   init.recalc_interrupts_   = d_recalc_interrupts;
27992960   init.printer_out_      = printer_out_dragon;
28002961
r4386r4387
28072968
28082969   /* Setup machine initialization */
28092970   memset(&init, 0, sizeof(init));
2810   init.piaintf         = dgnalpha_pia_intf;
2811   init.piaintf_count      = ARRAY_LENGTH(dgnalpha_pia_intf);
28122971   init.recalc_interrupts_   = d_recalc_interrupts;
28132972   init.printer_out_      = printer_out_dragon;
28142973
r4386r4387
28312990
28322991   /* Setup machine initialization */
28332992   memset(&init, 0, sizeof(init));
2834   init.piaintf         = coco_pia_intf;
2835   init.piaintf_count      = ARRAY_LENGTH(coco_pia_intf);
28362993   init.recalc_interrupts_   = d_recalc_interrupts;
28372994   init.printer_out_      = printer_out_coco;
28382995
r4386r4387
28453002
28463003   /* Setup machine initialization */
28473004   memset(&init, 0, sizeof(init));
2848   init.piaintf         = coco2_pia_intf;
2849   init.piaintf_count      = ARRAY_LENGTH(coco2_pia_intf);
28503005   init.recalc_interrupts_   = d_recalc_interrupts;
28513006   init.printer_out_      = printer_out_coco;
28523007
r4386r4387
28963051
28973052   /* Setup machine initialization */
28983053   memset(&init, 0, sizeof(init));
2899   init.piaintf         = coco3_pia_intf;
2900   init.piaintf_count      = ARRAY_LENGTH(coco3_pia_intf);
29013054   init.recalc_interrupts_   = coco3_recalc_interrupts;
29023055   init.printer_out_      = printer_out_coco;
29033056   
src/mess/drivers/coco.c
r4386r4387
1414#include "cpu/m6809/m6809.h"
1515#include "cpu/hd6309/hd6309.h"
1616#include "sound/wave.h"
17#include "machine/6821pia.h"
17#include "machine/6821new.h"
1818#include "video/m6847.h"
1919#include "machine/msm6242.h"
2020#include "machine/ds1315.h"
r4386r4387
5858   AM_RANGE(0xD000, 0xDFFF) AM_RAMBANK(14)
5959   AM_RANGE(0xE000, 0xEFFF) AM_RAMBANK(15)
6060   AM_RANGE(0xF000, 0xFEFF) AM_RAMBANK(16)
61   AM_RANGE(0xff00, 0xff1f) AM_READWRITE(pia_0_r,         pia_0_w)
62   AM_RANGE(0xff20, 0xff3f) AM_READWRITE(pia_1_r,         coco_pia_1_w)
61   AM_RANGE(0xff00, 0xff1f) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
62   AM_RANGE(0xff20, 0xff3f) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
6363   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(COCO_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
6464   AM_RANGE(0xff90, 0xffbf) AM_NOP
6565   AM_RANGE(0xffc0, 0xffdf) AM_DEVWRITE(SAM6883, "sam", sam6883_w)
r4386r4387
8585   AM_RANGE(0xD000, 0xDFFF) AM_RAMBANK(14)
8686   AM_RANGE(0xE000, 0xEFFF) AM_RAMBANK(15)
8787   AM_RANGE(0xF000, 0xFEFF) AM_RAMBANK(16)
88   AM_RANGE(0xff00, 0xff1f) AM_READWRITE(pia_0_r,         pia_0_w)
89   AM_RANGE(0xff20, 0xff3f) AM_READWRITE(pia_1_r,         coco_pia_1_w)
88   AM_RANGE(0xff00, 0xff1f) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
89   AM_RANGE(0xff20, 0xff3f) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
9090   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(DRAGON_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
9191   AM_RANGE(0xff90, 0xffbf) AM_NOP
9292   AM_RANGE(0xffc0, 0xffdf) AM_DEVWRITE(SAM6883, "sam", sam6883_w)
r4386r4387
113113   AM_RANGE(0xc000, 0xdfff) AM_RAMBANK(7)
114114   AM_RANGE(0xe000, 0xfdff) AM_RAMBANK(8)
115115   AM_RANGE(0xfe00, 0xfeff) AM_RAMBANK(9)
116   AM_RANGE(0xff00, 0xff1f) AM_READWRITE(pia_0_r,            pia_0_w)
117   AM_RANGE(0xff20, 0xff3f) AM_READWRITE(pia_1_r,            coco_pia_1_w)
116   AM_RANGE(0xff00, 0xff1f) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
117   AM_RANGE(0xff20, 0xff3f) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
118118   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(COCO_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
119119   AM_RANGE(0xff80, 0xff85) AM_DEVREADWRITE(COCO_VHD, "vhd", coco_vhd_io_r, coco_vhd_io_w)
120120   AM_RANGE(0xff90, 0xff9f) AM_READWRITE(coco3_gime_r,         coco3_gime_w)
r4386r4387
144144   AM_RANGE(0xD000, 0xDFFF) AM_RAMBANK(14)
145145   AM_RANGE(0xE000, 0xEFFF) AM_RAMBANK(15)
146146   AM_RANGE(0xF000, 0xFEFF) AM_RAMBANK(16)
147   AM_RANGE(0xff00, 0xff03) AM_READWRITE(pia_0_r,            pia_0_w)      AM_MIRROR(0x0018)
147   AM_RANGE(0xff00, 0xff03) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)      AM_MIRROR(0x0018)
148148   AM_RANGE(0xff04, 0xff07) AM_DEVREADWRITE(ACIA6551, "acia", acia_6551_r,         acia_6551_w)   AM_MIRROR(0x0018)
149   AM_RANGE(0xff20, 0xff3f) AM_READWRITE(pia_1_r,            coco_pia_1_w)
149   AM_RANGE(0xff20, 0xff3f) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
150150   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(DRAGON_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
151151   AM_RANGE(0xff90, 0xffbf) AM_NOP
152152   AM_RANGE(0xffc0, 0xffdf) AM_DEVWRITE(SAM6883, "sam", sam6883_w)
r4386r4387
178178   AM_RANGE(0xD000, 0xDFFF) AM_RAMBANK(14)
179179   AM_RANGE(0xE000, 0xEFFF) AM_RAMBANK(15)
180180   AM_RANGE(0xF000, 0xFEFF) AM_RAMBANK(16)
181   AM_RANGE(0xff00, 0xff03) AM_READWRITE(pia_0_r,pia_0_w)      AM_MIRROR(0x0018)
181   AM_RANGE(0xff00, 0xff03) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r,pia_w)      AM_MIRROR(0x0018)
182182   AM_RANGE(0xff04, 0xff07) AM_DEVREADWRITE(ACIA6551, "acia", acia_6551_r,acia_6551_w)   AM_MIRROR(0x0018)
183   AM_RANGE(0xff20, 0xff3f) AM_READWRITE(pia_1_r, coco_pia_1_w)
183   AM_RANGE(0xff20, 0xff3f) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
184184   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(DRAGON_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
185185   AM_RANGE(0xff90, 0xffbf) AM_NOP
186186   AM_RANGE(0xffc0, 0xffdf) AM_DEVWRITE(SAM6883, "sam", sam6883_w)
r4386r4387
256256   AM_RANGE(0xD000, 0xDFFF) AM_RAMBANK(14)
257257   AM_RANGE(0xE000, 0xEFFF) AM_RAMBANK(15)
258258   AM_RANGE(0xF000, 0xFEFF) AM_RAMBANK(16)
259   AM_RANGE(0xff00, 0xff03) AM_READWRITE(pia_0_r,         pia_0_w)
259   AM_RANGE(0xff00, 0xff03) AM_DEVREADWRITE(PIA6821, "pia_0", pia_r, pia_w)
260260   AM_RANGE(0xff04, 0xff07) AM_DEVREADWRITE(ACIA6551, "acia", acia_6551_r,      acia_6551_w)
261   AM_RANGE(0xff20, 0xff23) AM_READWRITE(pia_1_r,         coco_pia_1_w)
262   AM_RANGE(0xff24, 0xff27) AM_READWRITE(pia_2_r,         pia_2_w)    /* Third PIA on Dragon Alpha */
261   AM_RANGE(0xff20, 0xff23) AM_DEVREADWRITE(PIA6821, "pia_1", pia_r, coco_pia_1_w)
262   AM_RANGE(0xff24, 0xff27) AM_DEVREADWRITE(PIA6821, "pia_2", pia_r, pia_w)    /* Third PIA on Dragon Alpha */
263263   AM_RANGE(0Xff28, 0xff2b) AM_READWRITE(alpha_modem_r,   alpha_modem_w)   /* Modem, dummy to stop eror log ! */
264264   AM_RANGE(0xff2c, 0xff2f) AM_READWRITE(wd2797_r,         wd2797_w)   /* Alpha onboard disk interface */
265265   AM_RANGE(0xff40, 0xff7f) AM_DEVREADWRITE(DRAGON_CARTRIDGE, "coco_cartslot", coco_cartridge_r, coco_cartridge_w)
r4386r4387
698698
699699   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
700700   
701   MDRV_PIA6821_ADD( "pia_0", dragon32_pia_intf[0] )
702   MDRV_PIA6821_ADD( "pia_1", dragon32_pia_intf[1] )
703
701704   MDRV_SAM6883_ADD("sam", coco_sam_intf)
702705   
703706   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
738741   /* acia */
739742   MDRV_ACIA6551_ADD("acia")
740743   
744   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf[0] )
745   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf[1] )
746
741747   MDRV_SAM6883_ADD("sam", coco_sam_intf)
742748   
743749   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
778784   /* acia */
779785   MDRV_ACIA6551_ADD("acia")
780786   
787   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf[0] )
788   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf[1] )
789
781790   MDRV_SAM6883_ADD("sam", coco_sam_intf)
782791   
783792   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
824833   /* acia */
825834   MDRV_ACIA6551_ADD("acia")
826835   
836   MDRV_PIA6821_ADD( "pia_0", dgnalpha_pia_intf[0] )
837   MDRV_PIA6821_ADD( "pia_1", dgnalpha_pia_intf[1] )
838   MDRV_PIA6821_ADD( "pia_2", dgnalpha_pia_intf[2] )
839
827840   MDRV_SAM6883_ADD("sam", coco_sam_intf)
828841   
829842   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
864877   /* acia */
865878   MDRV_ACIA6551_ADD("acia")
866879   
880   MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf[0] )
881   MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf[1] )
882
867883   MDRV_SAM6883_ADD("sam", coco_sam_intf)
868884   
869885   MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
902918   /* cassette */
903919   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
904920   
921   MDRV_PIA6821_ADD( "pia_0", coco_pia_intf[0] )
922   MDRV_PIA6821_ADD( "pia_1", coco_pia_intf[1] )
923
905924   MDRV_SAM6883_ADD("sam", coco_sam_intf)
906925   
907926   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
940959   /* cassette */
941960   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
942961   
962   MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf[0] )
963   MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf[1] )
964
943965   MDRV_SAM6883_ADD("sam", coco_sam_intf)
944966   
945967   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
9781000   /* cassette */
9791001   MDRV_CASSETTE_ADD( "cassette", coco_cassette_config )
9801002   
1003   MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf[0] )
1004   MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf[1] )
1005
9811006   MDRV_SAM6883_ADD("sam", coco_sam_intf)
9821007   
9831008   MDRV_COCO_CARTRIDGE_ADD("coco_cartslot")
r4386r4387
10121037   MDRV_SCREEN_SIZE(640, 25+192+26)
10131038   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 239)
10141039
1040   MDRV_PIA6821_ADD( "pia_0", coco3_pia_intf[0] )
1041   MDRV_PIA6821_ADD( "pia_1", coco3_pia_intf[1] )
1042
10151043   /* sound hardware */
10161044   MDRV_IMPORT_FROM( coco_sound )
10171045

Previous 15994 Revisions Next


© 1998-2018 The MESS Team