Previous 15994 Revisions Next

r4009 Monday 29th December, 2008 at 13:10:22 UTC by Dirk Best
Converted the 6525 TPI to a device and added save state support
[docs]messnew.txt
[src/mess]mess.mak
[src/mess/audio]t6721.c
[src/mess/drivers]amiga.c c16.c cbmb.c
[src/mess/includes]cbmb.h cbmdrive.h vc1541.h
[src/mess/machine]6525tpi.c* 6525tpi.h* amigacd.c amigacd.h c16.c cbmb.c cbmdrive.c tpi6525.c tpi6525.h vc1541.c

src/mess/audio/t6721.c
r4008r4009
1717#include "driver.h"
1818#include "cpu/m6502/m6502.h"
1919
20#include "machine/tpi6525.h"
2120#include "includes/c16.h"
2221
2322
src/mess/includes/cbmb.h
r4008r4009
2828
2929WRITE8_HANDLER ( cbmb_colorram_w );
3030
31READ8_DEVICE_HANDLER( cbmb_tpi0_port_a_r );
32WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_a_w );
33
34WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_a );
35WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_b );
36WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_c );
37READ8_DEVICE_HANDLER( cbmb_keyboard_line_a );
38READ8_DEVICE_HANDLER( cbmb_keyboard_line_b );
39READ8_DEVICE_HANDLER( cbmb_keyboard_line_c );
40void cbmb_irq(const device_config *device, int level);
41
42WRITE8_DEVICE_HANDLER( cbmb_change_font );
43
3144DRIVER_INIT( p500 );
3245DRIVER_INIT( cbm600 );
3346DRIVER_INIT( cbm600pal );
src/mess/includes/vc1541.h
r4008r4009
176176/* IEC interface for c16 with c1551 */
177177
178178/* To be passed directly to the drivers */
179void c1551x_0_write_data(running_machine *machine, int data);
180int c1551x_0_read_data(running_machine *machine);
181void c1551x_0_write_handshake(running_machine *machine, int data);
182int c1551x_0_read_handshake(running_machine *machine);
183int c1551x_0_read_status(running_machine *machine);
179WRITE8_DEVICE_HANDLER( c1551x_write_data );
180READ8_DEVICE_HANDLER( c1551x_read_data );
181WRITE8_DEVICE_HANDLER( c1551x_write_handshake );
182READ8_DEVICE_HANDLER( c1551x_read_handshake );
183READ8_DEVICE_HANDLER( c1551x_read_status );
184184
185185
186186/* serial bus for vic20, c64 & c16 with vc1541 and some printer */
src/mess/includes/cbmdrive.h
r4008r4009
9797/* IEC interface for c16 with c1551 */
9898
9999/* To be passed directly to the drivers */
100void c1551_0_write_data(running_machine *machine, int data);
101int c1551_0_read_data(running_machine *machine);
102void c1551_0_write_handshake(running_machine *machine, int data);
103int c1551_0_read_handshake(running_machine *machine);
104int c1551_0_read_status(running_machine *machine);
100WRITE8_DEVICE_HANDLER( c1551_0_write_data );
101READ8_DEVICE_HANDLER( c1551_0_read_data );
102WRITE8_DEVICE_HANDLER( c1551_0_write_handshake );
103READ8_DEVICE_HANDLER( c1551_0_read_handshake );
104READ8_DEVICE_HANDLER( c1551_0_read_status );
105105
106void c1551_1_write_data(running_machine *machine, int data);
107int c1551_1_read_data(running_machine *machine);
108void c1551_1_write_handshake(running_machine *machine, int data);
109int c1551_1_read_handshake(running_machine *machine);
110int c1551_1_read_status(running_machine *machine);
106WRITE8_DEVICE_HANDLER( c1551_1_write_data );
107READ8_DEVICE_HANDLER( c1551_1_read_data );
108WRITE8_DEVICE_HANDLER( c1551_1_write_handshake );
109READ8_DEVICE_HANDLER( c1551_1_read_handshake );
110READ8_DEVICE_HANDLER( c1551_1_read_status );
111111
112112
113113/* Serial bus for vic20, c64 & c16 with vc1541 and some printer */
src/mess/machine/tpi6525.c
r4008r4009
1/***************************************************************************
2    mos tri port interface 6525
3   mos triple interface adapter 6523
4
5    peter.trauner@jk.uni-linz.ac.at
6
7   used in commodore b series
8   used in commodore c1551 floppy disk drive
9***************************************************************************/
10
11/*
12 mos tpi 6525
13 40 pin package
14 3 8 bit ports (pa, pb, pc)
15 8 registers to pc
16 0 port a 0 in low
17 1 port a data direction register 1 output
18 2 port b
19 3 port b ddr
20 4 port c
21  handshaking, interrupt mode
22  0 interrupt 0 input, 1 interrupt enabled
23   interrupt set on falling edge
24  1 interrupt 1 input
25  2 interrupt 2 input
26  3 interrupt 3 input
27  4 interrupt 4 input
28  5 irq output
29  6 ca handshake line (read handshake answer on I3 preferred)
30  7 cb handshake line (write handshake clear on I4 preferred)
31 5 port c ddr
32
33 6 cr configuration register
34  0 mc
35    0 port c normal input output mode like port a and b
36    1 port c used for handshaking and interrupt input
37  1 1 interrupt prioritized
38  2 i3 configure edge
39    1 interrupt set on positive edge
40  3 i4 configure edge
41  5,4 ca handshake
42   00 on read
43      rising edge of i3 sets ca high
44      read a data from computers sets ca low
45   01 pulse output
46      1 microsecond low after read a operation
47   10 manual output low
48   11 manual output high
49  7,6 cb handshake
50   00 handshake on write
51      write b data from computer sets cb 0
52      rising edge of i4 sets cb high
53   01 pulse output
54      1 microsecond low after write b operation
55   10 manual output low
56   11 manual output high
57 7 air active interrupt register
58   0 I0 occurred
59   1 I1 occurred
60   2 I2 occurred
61   3 I3 occurred
62   4 I4 occurred
63   read clears interrupt
64
65 non prioritized interrupts
66  interrupt is set when occurred
67  read clears all interrupts
68
69 prioritized interrupts
70  I4>I3>I2>I1>I0
71  highest interrupt can be found in air register
72  read clears highest interrupt
73*/
74
75#include "driver.h"
76#include "tpi6525.h"
77
78
79#define VERBOSE_LEVEL 0
80#define DBG_LOG(N,M,A) \
81   do { \
82      if(VERBOSE_LEVEL >= N) \
83      { \
84         if( M ) \
85            logerror("%11.6f: %-24s", attotime_to_double(timer_get_time(machine)), (char*) M ); \
86         logerror A; \
87      } \
88   } while (0)
89
90
91TPI6525 tpi6525[4]={
92   { 0 },
93   { 1 },
94   { 2 },
95   { 3 }
96};
97
98#define INTERRUPT_MODE (This->cr&1)
99#define PRIORIZED_INTERRUPTS (This->cr&2)
100#define INTERRUPT3_RISING_EDGE (This->cr&4)
101#define INTERRUPT4_RISING_EDGE (This->cr&8)
102#define CA_MANUAL_OUT (This->cr&0x20)
103#define CA_MANUAL_LEVEL ((This->cr&0x10)?1:0)
104#define CB_MANUAL_OUT (This->cr&0x80)
105#define CB_MANUAL_LEVEL ((This->cr&0x40)?1:0)
106
107static void tpi6525_reset(TPI6525 *This)
108{
109   This->cr=0;This->air=0;
110   This->a.ddr=0;This->a.port=0;
111   This->b.ddr=0;This->b.port=0;
112   This->c.ddr=0;This->c.port=0;
113   This->a.in=0xff;
114   This->b.in=0xff;
115   This->c.in=0xff;
116   This->interrupt.level=
117      This->irq_level[0]=
118      This->irq_level[1]=
119      This->irq_level[2]=
120      This->irq_level[3]=
121      This->irq_level[4]=0;
122}
123
124static void tpi6525_set_interrupt(running_machine *machine, TPI6525 *This)
125{
126   if (!This->interrupt.level && (This->air!=0)) {
127      This->interrupt.level=1;
128      DBG_LOG (3, "tpi6525",("%d set interrupt\n",This->number));
129      if (This->interrupt.output!=NULL)
130         This->interrupt.output(machine, This->interrupt.level);
131   }
132}
133
134static void tpi6525_clear_interrupt(running_machine *machine, TPI6525 *This)
135{
136   if (This->interrupt.level && (This->air==0)) {
137      This->interrupt.level=0;
138      DBG_LOG (3, "tpi6525",("%d clear interrupt\n",This->number));
139      if (This->interrupt.output!=NULL)
140         This->interrupt.output(machine, This->interrupt.level);
141   }
142}
143
144static void tpi6525_irq0_level(running_machine *machine, TPI6525 *This, int level)
145{
146   if (INTERRUPT_MODE && (level!=This->irq_level[0]) ) {
147      This->irq_level[0]=level;
148      if ((level==0)&&!(This->air&1)&&(This->c.ddr&1)) {
149         This->air|=1;
150         tpi6525_set_interrupt(machine, This);
151      }
152   }
153}
154
155static void tpi6525_irq1_level(running_machine *machine, TPI6525 *This, int level)
156{
157   if (INTERRUPT_MODE && (level!=This->irq_level[1]) ) {
158      This->irq_level[1]=level;
159      if ((level==0)&&!(This->air&2)&&(This->c.ddr&2)) {
160         This->air|=2;
161         tpi6525_set_interrupt(machine, This);
162      }
163   }
164}
165
166static void tpi6525_irq2_level(running_machine *machine, TPI6525 *This, int level)
167{
168   if (INTERRUPT_MODE && (level!=This->irq_level[2]) ) {
169      This->irq_level[2]=level;
170      if ((level==0)&&!(This->air&4)&&(This->c.ddr&4)) {
171         This->air|=4;
172         tpi6525_set_interrupt(machine, This);
173      }
174   }
175}
176
177static void tpi6525_irq3_level(running_machine *machine, TPI6525 *This, int level)
178{
179   if (INTERRUPT_MODE && (level!=This->irq_level[3]) ) {
180      This->irq_level[3]=level;
181      if ( ((INTERRUPT3_RISING_EDGE&&(level==1))
182           ||(!INTERRUPT3_RISING_EDGE&&(level==0)))
183          &&!(This->air&8)&&(This->c.ddr&8)) {
184         This->air|=8;
185         tpi6525_set_interrupt(machine, This);
186      }
187   }
188}
189
190static void tpi6525_irq4_level(running_machine *machine, TPI6525 *This, int level)
191{
192   if (INTERRUPT_MODE &&(level!=This->irq_level[4]) ) {
193      This->irq_level[4]=level;
194      if ( ((INTERRUPT4_RISING_EDGE&&(level==1))
195           ||(!INTERRUPT4_RISING_EDGE&&(level==0)))
196           &&!(This->air&0x10)&&(This->c.ddr&0x10)) {
197         This->air|=0x10;
198         tpi6525_set_interrupt(machine, This);
199      }
200   }
201}
202
203static int tpi6525_port_a_r(running_machine *machine, TPI6525 *This, int offset)
204{
205   int data=This->a.in;
206
207   if (This->a.read) data=This->a.read(machine);
208   data=(data&~This->a.ddr)|(This->a.ddr&This->a.port);
209
210   return data;
211}
212
213static void tpi6525_port_a_w(running_machine *machine, TPI6525 *This, int offset, int data)
214{
215   This->a.in=data;
216}
217
218static int tpi6525_port_b_r(running_machine *machine, TPI6525 *This, int offset)
219{
220   int data=This->b.in;
221
222   if (This->b.read) data=This->b.read(machine);
223   data=(data&~This->b.ddr)|(This->b.ddr&This->b.port);
224
225   return data;
226}
227
228static void tpi6525_port_b_w(running_machine *machine, TPI6525 *This, int offset, int data)
229{
230   This->b.in=data;
231}
232
233static int tpi6525_port_c_r(running_machine *machine, TPI6525 *This, int offset)
234{
235   int data=This->c.in;
236
237   if (This->c.read) data&=This->c.read(machine);
238   data=(data&~This->c.ddr)|(This->c.ddr&This->c.port);
239
240   return data;
241}
242
243static void tpi6525_port_c_w(running_machine *machine, TPI6525 *This, int offset, int data)
244{
245   This->c.in=data;
246}
247
248static int tpi6525_port_r(running_machine *machine, TPI6525 *This, int offset)
249{
250   int data=0xff;
251   switch (offset&7) {
252   case 0:
253      data=This->a.in;
254      if (This->a.read) data&=This->a.read(machine);
255      data=(data&~This->a.ddr)|(This->a.ddr&This->a.port);
256      break;
257   case 1:
258      data=This->b.in;
259      if (This->b.read) data&=This->b.read(machine);
260      data=(data&~This->b.ddr)|(This->b.ddr&This->b.port);
261      break;
262   case 2:
263      if (INTERRUPT_MODE) {
264         data=0;
265         if (This->irq_level[0]) data|=1;
266         if (This->irq_level[1]) data|=2;
267         if (This->irq_level[2]) data|=4;
268         if (This->irq_level[3]) data|=8;
269         if (This->irq_level[4]) data|=0x10;
270         if (!This->interrupt.level) data|=0x20;
271         if (This->ca.level) data|=0x40;
272         if (This->cb.level) data|=0x80;
273      } else {
274         data=This->c.in;
275         if (This->c.read) data&=This->c.read(machine);
276         data=(data&~This->c.ddr)|(This->c.ddr&This->c.port);
277      }
278      DBG_LOG (2, "tpi6525",
279             ("%d read %.2x %.2x\n",This->number, offset,data));
280      break;
281   case 3:
282      data=This->a.ddr;
283      break;
284   case 4:
285      data=This->b.ddr;
286      break;
287   case 5:
288      data=This->c.ddr;
289      break;
290   case 6: /* cr */
291      data=This->cr;
292      break;
293   case 7: /* air */
294      if (PRIORIZED_INTERRUPTS) {
295         if (This->air&0x10) {
296            data=0x10;
297            This->air&=~0x10;
298         } else if (This->air&8) {
299            data=8;
300            This->air&=~8;
301         } else if (This->air&4) {
302            data=4;
303            This->air&=~4;
304         } else if (This->air&2) {
305            data=2;
306            This->air&=~2;
307         } else if (This->air&1) {
308            data=1;
309            This->air&=~1;
310         }
311      } else {
312         data=This->air;
313         This->air=0;
314      }
315      tpi6525_clear_interrupt(machine, This);
316      break;
317   }
318   DBG_LOG (3, "tpi6525",
319          ("%d read %.2x %.2x\n",This->number, offset,data));
320   return data;
321}
322
323static void tpi6525_port_w(running_machine *machine, TPI6525 *This, int offset, int data)
324{
325   DBG_LOG (2, "tpi6525",
326          ("%d write %.2x %.2x\n",This->number, offset,data));
327
328   switch (offset&7) {
329   case 0:
330      This->a.port=data;
331      if (This->a.output) {
332         This->a.output(machine, This->a.port&This->a.ddr);
333      }
334      break;
335   case 1:
336      This->b.port=data;
337      if (This->b.output) {
338         This->b.output(machine, This->b.port&This->b.ddr);
339      }
340      break;
341   case 2:
342      This->c.port=data;
343      if (!INTERRUPT_MODE&&This->c.output) {
344         This->c.output(machine, This->c.port&This->c.ddr);
345      }
346      break;
347   case 3:
348      This->a.ddr=data;
349      if (This->a.output) {
350         This->a.output(machine, This->a.port&This->a.ddr);
351      }
352      break;
353   case 4:
354      This->b.ddr=data;
355      if (This->b.output) {
356         This->b.output(machine, This->b.port&This->b.ddr);
357      }
358      break;
359   case 5:
360      This->c.ddr=data;
361      if (!INTERRUPT_MODE&&This->c.output) {
362         This->c.output(machine, This->c.port&This->c.ddr);
363      }
364      break;
365   case 6:
366      This->cr=data;
367      if (INTERRUPT_MODE) {
368         if (CA_MANUAL_OUT) {
369            if (This->ca.level!=CA_MANUAL_LEVEL) {
370               This->ca.level=CA_MANUAL_LEVEL;
371               if (This->ca.output) This->ca.output(machine, This->ca.level);
372            }
373         }
374         if (CB_MANUAL_OUT) {
375            if (This->cb.level!=CB_MANUAL_LEVEL) {
376               This->cb.level=CB_MANUAL_LEVEL;
377               if (This->cb.output) This->cb.output(machine, This->cb.level);
378            }
379         }
380      }
381      break;
382   case 7:
383      /*This->air=data; */
384      break;
385   }
386}
387
388
389void tpi6525_0_reset(void)
390{
391   tpi6525_reset(tpi6525);
392}
393
394void tpi6525_1_reset(void)
395{
396   tpi6525_reset(tpi6525+1);
397}
398
399void tpi6525_2_reset(void)
400{
401   tpi6525_reset(tpi6525+2);
402}
403
404void tpi6525_3_reset(void)
405{
406   tpi6525_reset(tpi6525+3);
407}
408
409void tpi6525_0_irq0_level(running_machine *machine, int level)
410{
411   tpi6525_irq0_level(machine, tpi6525, level);
412}
413
414void tpi6525_0_irq1_level(running_machine *machine, int level)
415{
416   tpi6525_irq1_level(machine, tpi6525, level);
417}
418
419void tpi6525_0_irq2_level(running_machine *machine, int level)
420{
421   tpi6525_irq2_level(machine, tpi6525, level);
422}
423
424void tpi6525_0_irq3_level(running_machine *machine, int level)
425{
426   tpi6525_irq3_level(machine, tpi6525, level);
427}
428
429void tpi6525_0_irq4_level(running_machine *machine, int level)
430{
431   tpi6525_irq4_level(machine, tpi6525, level);
432}
433
434void tpi6525_1_irq0_level(running_machine *machine, int level)
435{
436   tpi6525_irq0_level(machine, tpi6525+1, level);
437}
438
439void tpi6525_1_irq1_level(running_machine *machine, int level)
440{
441   tpi6525_irq1_level(machine, tpi6525+1, level);
442}
443
444void tpi6525_1_irq2_level(running_machine *machine, int level)
445{
446   tpi6525_irq2_level(machine, tpi6525+1, level);
447}
448
449void tpi6525_1_irq3_level(running_machine *machine, int level)
450{
451   tpi6525_irq3_level(machine, tpi6525+1, level);
452}
453
454void tpi6525_1_irq4_level(running_machine *machine, int level)
455{
456   tpi6525_irq4_level(machine, tpi6525+1, level);
457}
458
459READ8_HANDLER ( tpi6525_0_port_r )
460{
461   return tpi6525_port_r(space->machine, tpi6525, offset);
462}
463
464READ8_HANDLER ( tpi6525_1_port_r )
465{
466   return tpi6525_port_r(space->machine, tpi6525+1, offset);
467}
468
469READ8_HANDLER ( tpi6525_2_port_r )
470{
471   return tpi6525_port_r(space->machine, tpi6525+2, offset);
472}
473
474READ8_HANDLER ( tpi6525_3_port_r )
475{
476   return tpi6525_port_r(space->machine, tpi6525+3, offset);
477}
478
479WRITE8_HANDLER ( tpi6525_0_port_w )
480{
481   tpi6525_port_w(space->machine, tpi6525, offset, data);
482}
483
484WRITE8_HANDLER ( tpi6525_1_port_w )
485{
486   tpi6525_port_w(space->machine, tpi6525+1, offset, data);
487}
488
489WRITE8_HANDLER ( tpi6525_2_port_w )
490{
491   tpi6525_port_w(space->machine, tpi6525+2, offset, data);
492}
493
494WRITE8_HANDLER ( tpi6525_3_port_w )
495{
496   tpi6525_port_w(space->machine, tpi6525+3, offset, data);
497}
498
499READ8_HANDLER ( tpi6525_0_port_a_r )
500{
501   return tpi6525_port_a_r(space->machine, tpi6525, offset);
502}
503
504READ8_HANDLER ( tpi6525_1_port_a_r )
505{
506   return tpi6525_port_a_r(space->machine, tpi6525+1, offset);
507}
508
509READ8_HANDLER ( tpi6525_2_port_a_r )
510{
511   return tpi6525_port_a_r(space->machine, tpi6525+2, offset);
512}
513
514READ8_HANDLER ( tpi6525_3_port_a_r )
515{
516   return tpi6525_port_a_r(space->machine, tpi6525+3, offset);
517}
518
519WRITE8_HANDLER ( tpi6525_0_port_a_w )
520{
521   tpi6525_port_a_w(space->machine, tpi6525, offset, data);
522}
523
524WRITE8_HANDLER ( tpi6525_1_port_a_w )
525{
526   tpi6525_port_a_w(space->machine, tpi6525+1, offset, data);
527}
528
529WRITE8_HANDLER ( tpi6525_2_port_a_w )
530{
531   tpi6525_port_a_w(space->machine, tpi6525+2, offset, data);
532}
533
534WRITE8_HANDLER ( tpi6525_3_port_a_w )
535{
536   tpi6525_port_a_w(space->machine, tpi6525+3, offset, data);
537}
538
539READ8_HANDLER ( tpi6525_0_port_b_r )
540{
541   return tpi6525_port_b_r(space->machine, tpi6525, offset);
542}
543
544READ8_HANDLER ( tpi6525_1_port_b_r )
545{
546   return tpi6525_port_b_r(space->machine, tpi6525+1, offset);
547}
548
549READ8_HANDLER ( tpi6525_2_port_b_r )
550{
551   return tpi6525_port_b_r(space->machine, tpi6525+2, offset);
552}
553
554READ8_HANDLER ( tpi6525_3_port_b_r )
555{
556   return tpi6525_port_b_r(space->machine, tpi6525+3, offset);
557}
558
559WRITE8_HANDLER ( tpi6525_0_port_b_w )
560{
561   tpi6525_port_b_w(space->machine, tpi6525, offset, data);
562}
563
564WRITE8_HANDLER ( tpi6525_1_port_b_w )
565{
566   tpi6525_port_b_w(space->machine, tpi6525+1, offset, data);
567}
568
569WRITE8_HANDLER ( tpi6525_2_port_b_w )
570{
571   tpi6525_port_b_w(space->machine, tpi6525+2, offset, data);
572}
573
574WRITE8_HANDLER ( tpi6525_3_port_b_w )
575{
576   tpi6525_port_b_w(space->machine, tpi6525+3, offset, data);
577}
578
579READ8_HANDLER ( tpi6525_0_port_c_r )
580{
581   return tpi6525_port_c_r(space->machine, tpi6525, offset);
582}
583
584READ8_HANDLER ( tpi6525_1_port_c_r )
585{
586   return tpi6525_port_c_r(space->machine, tpi6525+1, offset);
587}
588
589READ8_HANDLER ( tpi6525_2_port_c_r )
590{
591   return tpi6525_port_c_r(space->machine, tpi6525+2, offset);
592}
593
594READ8_HANDLER ( tpi6525_3_port_c_r )
595{
596   return tpi6525_port_c_r(space->machine, tpi6525+3, offset);
597}
598
599WRITE8_HANDLER ( tpi6525_0_port_c_w )
600{
601   tpi6525_port_c_w(space->machine, tpi6525, offset, data);
602}
603
604WRITE8_HANDLER ( tpi6525_1_port_c_w )
605{
606   tpi6525_port_c_w(space->machine, tpi6525+1, offset, data);
607}
608
609WRITE8_HANDLER ( tpi6525_2_port_c_w )
610{
611   tpi6525_port_c_w(space->machine, tpi6525+2, offset, data);
612}
613
614WRITE8_HANDLER ( tpi6525_3_port_c_w )
615{
616   tpi6525_port_c_w(space->machine, tpi6525+3, offset, data);
617}
src/mess/machine/tpi6525.h
r4008r4009
1/*****************************************************************************
2 *
3 * machine/tpi6525.h
4 *
5 * mos tri port interface 6525
6 * mos triple interface adapter 6523
7 *
8 * peter.trauner@jk.uni-linz.ac.at
9 *
10 * used in commodore b series
11 * used in commodore c1551 floppy disk drive
12 *
13 * tia6523 is a tpi6525 without control register!?
14 *
15 * tia6523
16 *   only some lines of port b and c are in the pinout!
17 *
18 * connector to floppy c1551 (delivered with c1551 as c16 expansion)
19 *   port a for data read/write
20 *   port b
21 *   0 status 0
22 *   1 status 1
23 *   port c
24 *   6 dav output edge data on port a available
25 *   7 ack input edge ready for next datum
26 *
27 ****************************************************************************/
28
29#ifndef TPI6525_H_
30#define TPI6525_H_
31
32
33/* fill in the callback functions */
34typedef struct {
35   int number;
36   struct {
37      int (*read)(running_machine *machine);
38      void (*output)(running_machine *machine, int data);
39      int port, ddr, in;
40   } a,b,c;
41
42   struct {
43      void (*output)(running_machine *machine, int level);
44      int level;
45   } ca, cb, interrupt;
46
47   int cr;
48   int air;
49
50   int irq_level[5];
51} TPI6525;
52
53
54/*----------- defined in machine/tpi6525.c -----------*/
55
56extern TPI6525 tpi6525[4];
57
58void tpi6525_0_reset(void);
59void tpi6525_1_reset(void);
60void tpi6525_2_reset(void);
61void tpi6525_3_reset(void);
62
63void tpi6525_0_irq0_level(running_machine *machine, int level);
64void tpi6525_0_irq1_level(running_machine *machine, int level);
65void tpi6525_0_irq2_level(running_machine *machine, int level);
66void tpi6525_0_irq3_level(running_machine *machine, int level);
67void tpi6525_0_irq4_level(running_machine *machine, int level);
68
69void tpi6525_1_irq0_level(running_machine *machine, int level);
70void tpi6525_1_irq1_level(running_machine *machine, int level);
71void tpi6525_1_irq2_level(running_machine *machine, int level);
72void tpi6525_1_irq3_level(running_machine *machine, int level);
73void tpi6525_1_irq4_level(running_machine *machine, int level);
74
75 READ8_HANDLER  ( tpi6525_0_port_r );
76 READ8_HANDLER  ( tpi6525_1_port_r );
77 READ8_HANDLER  ( tpi6525_2_port_r );
78 READ8_HANDLER  ( tpi6525_3_port_r );
79
80WRITE8_HANDLER ( tpi6525_0_port_w );
81WRITE8_HANDLER ( tpi6525_1_port_w );
82WRITE8_HANDLER ( tpi6525_2_port_w );
83WRITE8_HANDLER ( tpi6525_3_port_w );
84
85 READ8_HANDLER  ( tpi6525_0_port_a_r );
86 READ8_HANDLER  ( tpi6525_1_port_a_r );
87 READ8_HANDLER  ( tpi6525_2_port_a_r );
88 READ8_HANDLER  ( tpi6525_3_port_a_r );
89
90WRITE8_HANDLER ( tpi6525_0_port_a_w );
91WRITE8_HANDLER ( tpi6525_1_port_a_w );
92WRITE8_HANDLER ( tpi6525_2_port_a_w );
93WRITE8_HANDLER ( tpi6525_3_port_a_w );
94
95 READ8_HANDLER  ( tpi6525_0_port_b_r );
96 READ8_HANDLER  ( tpi6525_1_port_b_r );
97 READ8_HANDLER  ( tpi6525_2_port_b_r );
98 READ8_HANDLER  ( tpi6525_3_port_b_r );
99
100WRITE8_HANDLER ( tpi6525_0_port_b_w );
101WRITE8_HANDLER ( tpi6525_1_port_b_w );
102WRITE8_HANDLER ( tpi6525_2_port_b_w );
103WRITE8_HANDLER ( tpi6525_3_port_b_w );
104
105 READ8_HANDLER  ( tpi6525_0_port_c_r );
106 READ8_HANDLER  ( tpi6525_1_port_c_r );
107 READ8_HANDLER  ( tpi6525_2_port_c_r );
108 READ8_HANDLER  ( tpi6525_3_port_c_r );
109
110WRITE8_HANDLER ( tpi6525_0_port_c_w );
111WRITE8_HANDLER ( tpi6525_1_port_c_w );
112WRITE8_HANDLER ( tpi6525_2_port_c_w );
113WRITE8_HANDLER ( tpi6525_3_port_c_w );
114
115
116#endif /* TPI6525_H_ */
src/mess/machine/cbmb.c
r4008r4009
77#include "driver.h"
88#include "cpu/m6502/m6509.h"
99#include "sound/sid6581.h"
10#include "machine/6525tpi.h"
1011#include "machine/6526cia.h"
1112
1213#include "includes/cbm.h"
13#include "machine/tpi6525.h"
1414#include "video/vic6567.h"
1515#include "includes/cbmserb.h"
1616#include "includes/cbmieeeb.h"
r4008r4009
7272 i1 self pb0
7373 i0 tod (50 or 60 hertz frequency)
7474 */
75static int cbmb_tpi0_port_a_r(running_machine *machine)
75READ8_DEVICE_HANDLER( cbmb_tpi0_port_a_r )
7676{
7777   int data = 0;
7878
79   if (cbm_ieee_nrfd_r(machine)) data |= 0x80;
80   if (cbm_ieee_ndac_r(machine)) data |= 0x40;
81   if (cbm_ieee_eoi_r(machine)) data |= 0x20;
82   if (cbm_ieee_dav_r(machine)) data |= 0x10;
83   if (cbm_ieee_atn_r(machine)) data |= 0x08;
84/*   if (cbm_ieee_ren_r(machine)) data |= 0x04; */
79   if (cbm_ieee_nrfd_r(device->machine)) data |= 0x80;
80   if (cbm_ieee_ndac_r(device->machine)) data |= 0x40;
81   if (cbm_ieee_eoi_r(device->machine)) data |= 0x20;
82   if (cbm_ieee_dav_r(device->machine)) data |= 0x10;
83   if (cbm_ieee_atn_r(device->machine)) data |= 0x08;
84/*   if (cbm_ieee_ren_r(device->machine)) data |= 0x04; */
8585
8686   return data;
8787}
8888
89static void cbmb_tpi0_port_a_w(running_machine *machine, int data)
89WRITE8_DEVICE_HANDLER( cbmb_tpi0_port_a_w )
9090{
91   cbm_ieee_nrfd_w(machine, 0, data & 0x80);
92   cbm_ieee_ndac_w(machine, 0, data & 0x40);
93   cbm_ieee_eoi_w(machine, 0, data & 0x20);
94   cbm_ieee_dav_w(machine, 0, data & 0x10);
95   cbm_ieee_atn_w(machine, 0, data & 0x08);
96/*   cbm_ieee_ren_w(machine, 0, data & 0x04); */
91   cbm_ieee_nrfd_w(device->machine, 0, data & 0x80);
92   cbm_ieee_ndac_w(device->machine, 0, data & 0x40);
93   cbm_ieee_eoi_w(device->machine, 0, data & 0x20);
94   cbm_ieee_dav_w(device->machine, 0, data & 0x10);
95   cbm_ieee_atn_w(device->machine, 0, data & 0x08);
96/*   cbm_ieee_ren_w(device->machine, 0, data & 0x04); */
9797   logerror("cbm ieee %d %d\n", data & 0x02, data & 0x01);
9898}
9999
r4008r4009
109109   port c6 ?
110110  port c5 .. c0 keyboard line select
111111  port a7..a0 b7..b0 keyboard input */
112static void cbmb_keyboard_line_select_a(running_machine *machine, int line)
112WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_a )
113113{
114   cbmb_keyline_a=line;
114   cbmb_keyline_a = data;
115115}
116116
117static void cbmb_keyboard_line_select_b(running_machine *machine, int line)
117WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_b )
118118{
119   cbmb_keyline_b=line;
119   cbmb_keyline_b = data;
120120}
121121
122static void cbmb_keyboard_line_select_c(running_machine *machine, int line)
122WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_c )
123123{
124   cbmb_keyline_c=line;
124   cbmb_keyline_c = data;
125125}
126126
127static int cbmb_keyboard_line_a(running_machine *machine)
127READ8_DEVICE_HANDLER( cbmb_keyboard_line_a )
128128{
129129   int data = 0;
130130   
131131   if (!(cbmb_keyline_c & 0x01))
132      data |= input_port_read(machine, "ROW0");
132      data |= input_port_read(device->machine, "ROW0");
133133
134134   if (!(cbmb_keyline_c & 0x02))
135      data |= input_port_read(machine, "ROW2");
135      data |= input_port_read(device->machine, "ROW2");
136136
137137   if (!(cbmb_keyline_c & 0x04))
138      data |= input_port_read(machine, "ROW4");
138      data |= input_port_read(device->machine, "ROW4");
139139
140140   if (!(cbmb_keyline_c & 0x08))
141      data |= input_port_read(machine, "ROW6");
141      data |= input_port_read(device->machine, "ROW6");
142142
143143   if (!(cbmb_keyline_c & 0x10))
144      data |= input_port_read(machine, "ROW8");
144      data |= input_port_read(device->machine, "ROW8");
145145
146146   if (!(cbmb_keyline_c & 0x20))
147      data |= input_port_read(machine, "ROW10");
147      data |= input_port_read(device->machine, "ROW10");
148148
149149   return data ^0xff;
150150}
151151
152static int cbmb_keyboard_line_b(running_machine *machine)
152READ8_DEVICE_HANDLER( cbmb_keyboard_line_b )
153153{
154154   int data = 0;
155155   
156156   if (!(cbmb_keyline_c & 0x01))
157      data |= input_port_read(machine, "ROW1");
157      data |= input_port_read(device->machine, "ROW1");
158158
159159   if (!(cbmb_keyline_c & 0x02))
160      data |= input_port_read(machine, "ROW3");
160      data |= input_port_read(device->machine, "ROW3");
161161
162162   if (!(cbmb_keyline_c & 0x04))
163      data |= input_port_read(machine, "ROW5");
163      data |= input_port_read(device->machine, "ROW5");
164164
165165   if (!(cbmb_keyline_c & 0x08))
166      data |= input_port_read(machine, "ROW7");
166      data |= input_port_read(device->machine, "ROW7");
167167
168168   if (!(cbmb_keyline_c & 0x10))
169      data |= input_port_read(machine, "ROW9") | ((input_port_read(machine, "SPECIAL") & 0x04) ? 1 : 0 );
169      data |= input_port_read(device->machine, "ROW9") | ((input_port_read(device->machine, "SPECIAL") & 0x04) ? 1 : 0 );
170170
171171   if (!(cbmb_keyline_c & 0x20))
172      data |= input_port_read(machine, "ROW11");
172      data |= input_port_read(device->machine, "ROW11");
173173
174174   return data ^0xff;
175175}
176176
177static int cbmb_keyboard_line_c(running_machine *machine)
177READ8_DEVICE_HANDLER( cbmb_keyboard_line_c )
178178{
179179   int data = 0;
180180
181   if ((input_port_read(machine, "ROW0") & ~cbmb_keyline_a) ||
182            (input_port_read(machine, "ROW1") & ~cbmb_keyline_b))
181   if ((input_port_read(device->machine, "ROW0") & ~cbmb_keyline_a) ||
182            (input_port_read(device->machine, "ROW1") & ~cbmb_keyline_b))
183183       data |= 0x01;
184184
185   if ((input_port_read(machine, "ROW2") & ~cbmb_keyline_a) ||
186            (input_port_read(machine, "ROW3") & ~cbmb_keyline_b))
185   if ((input_port_read(device->machine, "ROW2") & ~cbmb_keyline_a) ||
186            (input_port_read(device->machine, "ROW3") & ~cbmb_keyline_b))
187187       data |= 0x02;
188188
189   if ((input_port_read(machine, "ROW4") & ~cbmb_keyline_a) ||
190            (input_port_read(machine, "ROW5") & ~cbmb_keyline_b))
189   if ((input_port_read(device->machine, "ROW4") & ~cbmb_keyline_a) ||
190            (input_port_read(device->machine, "ROW5") & ~cbmb_keyline_b))
191191       data |= 0x04;
192192
193   if ((input_port_read(machine, "ROW6") & ~cbmb_keyline_a) ||
194            (input_port_read(machine, "ROW7") & ~cbmb_keyline_b))
193   if ((input_port_read(device->machine, "ROW6") & ~cbmb_keyline_a) ||
194            (input_port_read(device->machine, "ROW7") & ~cbmb_keyline_b))
195195       data |= 0x08;
196196
197   if ((input_port_read(machine, "ROW8") & ~cbmb_keyline_a) ||
198            ((input_port_read(machine, "ROW9") | ((input_port_read(machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~cbmb_keyline_b))
197   if ((input_port_read(device->machine, "ROW8") & ~cbmb_keyline_a) ||
198            ((input_port_read(device->machine, "ROW9") | ((input_port_read(device->machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~cbmb_keyline_b))
199199       data |= 0x10;
200200
201   if ((input_port_read(machine, "ROW10") & ~cbmb_keyline_a) ||
202            (input_port_read(machine, "ROW11") & ~cbmb_keyline_b))
201   if ((input_port_read(device->machine, "ROW10") & ~cbmb_keyline_a) ||
202            (input_port_read(device->machine, "ROW11") & ~cbmb_keyline_b))
203203       data |= 0x20;
204204
205205   if (!p500)
r4008r4009
213213   return data ^0xff;
214214}
215215
216static void cbmb_irq(running_machine *machine, int level)
216void cbmb_irq(const device_config *device, int level)
217217{
218218   static int old_level = 0;
219   running_machine *machine = device->machine;
219220
220221   if (level != old_level)
221222   {
222223      DBG_LOG (3, "mos6509", ("irq %s\n", level ? "start" : "end"));
223      cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, level);
224      cpu_set_input_line(device->machine->cpu[0], M6502_IRQ_LINE, level);
224225      old_level = level;
225226   }
226227}
r4008r4009
246247
247248static void cbmb_tpi6525_0_irq2_level( const device_config *device, int level )
248249{
249   tpi6525_0_irq2_level(device->machine, level);
250   const device_config *tpi_0 = devtag_get_device(device->machine, TPI6525, "tpi6525_0");
251   tpi6525_irq2_level(tpi_0, level);
250252}
251253
252254const cia6526_interface cbmb_cia =
r4008r4009
278280   return cbmb_colorram[offset & 0x3ff];
279281}
280282
281static void cbmb_change_font(running_machine *machine, int level)
283WRITE8_DEVICE_HANDLER( cbmb_change_font )
282284{
283   cbmb_vh_set_font(level);
285   cbmb_vh_set_font(data);
284286}
285287
286288static void cbmb_common_driver_init(running_machine *machine)
r4008r4009
288290   cbmb_chargen=memory_region(machine, "main") + 0x100000;
289291   /*    memset(c64_memory, 0, 0xfd00); */
290292
291   tpi6525[0].a.read = cbmb_tpi0_port_a_r;
292   tpi6525[0].a.output = cbmb_tpi0_port_a_w;
293   tpi6525[0].ca.output = cbmb_change_font;
294   tpi6525[0].interrupt.output = cbmb_irq;
295   tpi6525[1].a.read = cbmb_keyboard_line_a;
296   tpi6525[1].b.read = cbmb_keyboard_line_b;
297   tpi6525[1].c.read = cbmb_keyboard_line_c;
298   tpi6525[1].a.output = cbmb_keyboard_line_select_a;
299   tpi6525[1].b.output = cbmb_keyboard_line_select_b;
300   tpi6525[1].c.output = cbmb_keyboard_line_select_c;
301
302293   timer_pulse(machine, ATTOTIME_IN_MSEC(10), NULL, 0, cbmb_frame_interrupt);
303294
304295   p500 = 0;
r4008r4009
345336MACHINE_RESET( cbmb )
346337{
347338   sndti_reset(SOUND_SID6581, 0);
348   tpi6525_0_reset();
349   tpi6525_1_reset();
350339
351340   cbm_drive_0_config (IEEE8ON ? IEEE : 0, 8);
352341   cbm_drive_1_config (IEEE9ON ? IEEE : 0, 9);
r4008r4009
356345static TIMER_CALLBACK(cbmb_frame_interrupt)
357346{
358347   static int level = 0;
348   const device_config *tpi_0 = devtag_get_device(machine, TPI6525, "tpi6525_0");
349   
359350#if 0
360351   int controller1 = input_port_read(machine, "CTRLSEL") & 0x07;
361352   int controller2 = input_port_read(machine, "CTRLSEL") & 0x70;
362353#endif
363354
364   tpi6525_0_irq0_level(machine, level);
355   tpi6525_irq0_level(tpi_0, level);
365356   level = !level;
366357   if (level) return ;
367358
src/mess/machine/vc1541.c
r4008r4009
139139#include "driver.h"
140140#include "image.h"
141141#include "cpu/m6502/m6502.h"
142#include "machine/6525tpi.h"
142143#include "machine/6522via.h"
143144
144#include "machine/tpi6525.h"
145
146145#include "includes/vc1541.h"
147146
148147
r4008r4009
12421241   6 input sync 0 active
12431242   7 input handshake in
12441243 */
1245static int c1551_port_c_r(running_machine *machine)
1244READ8_DEVICE_HANDLER( c1551_port_c_r )
12461245{
12471246   int data = 0xff;
12481247   
r4008r4009
12541253   return data;
12551254}
12561255
1257static int c1551_port_b_r(running_machine *machine)
1256READ8_DEVICE_HANDLER( c1551_port_b_r )
12581257{
1258   running_machine *machine = device->machine;
12591259   int data = drive->gcr.data[drive->pos];
12601260   DBG_LOG(2, "c1551 drive",("port a read %.2x\n", data));
12611261   return data;
r4008r4009
12651265static ADDRESS_MAP_START( _1551_map, ADDRESS_SPACE_PROGRAM, 8 )
12661266    AM_RANGE(0x0000, 0x0001) AM_READWRITE(c1551_port_r, c1551_port_w)
12671267   AM_RANGE(0x0002, 0x07ff) AM_RAM
1268    AM_RANGE(0x4000, 0x4007) AM_READWRITE(tpi6525_0_port_r, tpi6525_0_port_w)
1268    AM_RANGE(0x4000, 0x4007) AM_DEVREADWRITE(TPI6525, "c1551_tpi", tpi6525_r, tpi6525_w)
12691269   AM_RANGE(0xc000, 0xffff) AM_ROM
12701270ADDRESS_MAP_END
12711271
12721272
1273static void c1551x_write_data (running_machine *machine, TPI6525 *This, int data)
1273WRITE8_DEVICE_HANDLER( c1551x_write_data )
12741274{
12751275//   DBG_LOG(1, "c1551 cpu", ("%d write data %.2x\n", cpu_getactivecpu (), data));
12761276#ifdef CPU_SYNC
12771277   cpu_sync();
12781278#endif
1279   tpi6525_0_port_a_w(cpu_get_address_space(machine->cpu[drive->cpunumber], ADDRESS_SPACE_PROGRAM), 0,data);
1279   tpi6525_porta_w(device, 0, data);
12801280}
12811281
1282static int c1551x_read_data (running_machine *machine, TPI6525 *This)
1282READ8_DEVICE_HANDLER( c1551x_read_data )
12831283{
12841284   int data = 0xff;
12851285#ifdef CPU_SYNC
12861286   cpu_sync ();
12871287#endif
12881288
1289   data = tpi6525_0_port_a_r(cpu_get_address_space(machine->cpu[drive->cpunumber], ADDRESS_SPACE_PROGRAM), 0);
1289   data = tpi6525_porta_r(device, 0);
12901290//   DBG_LOG(2, "c1551 cpu",("%d read data %.2x\n", cpu_getactivecpu (), data));
12911291   return data;
12921292}
12931293
1294static void c1551x_write_handshake (running_machine *machine, TPI6525 *This, int data)
1294WRITE8_DEVICE_HANDLER( c1551x_write_handshake )
12951295{
12961296//   DBG_LOG(1, "c1551 cpu",("%d write handshake %.2x\n", cpu_getactivecpu (), data));
12971297#ifdef CPU_SYNC
12981298   cpu_sync();
12991299#endif
13001300
1301   tpi6525_0_port_c_w(cpu_get_address_space(machine->cpu[drive->cpunumber], ADDRESS_SPACE_PROGRAM), 0,data&0x40?0xff:0x7f);
1301   tpi6525_portc_w(device, 0, data & 0x40 ? 0xff : 0x7f);
13021302}
13031303
1304static int c1551x_read_handshake (running_machine *machine, TPI6525 *This)
1304READ8_DEVICE_HANDLER( c1551x_read_handshake )
13051305{
13061306   int data = 0xff;
13071307#ifdef CPU_SYNC
13081308   cpu_sync();
13091309#endif
13101310
1311   data = tpi6525_0_port_c_r(cpu_get_address_space(machine->cpu[drive->cpunumber], ADDRESS_SPACE_PROGRAM), 0) & 0x08 ? 0x80 : 0x00;
1311   data = tpi6525_portc_r(device, 0) & 0x08 ? 0x80 : 0x00;
13121312//   DBG_LOG(2, "c1551 cpu",("%d read handshake %.2x\n", cpu_getactivecpu (), data));
13131313   return data;
13141314}
13151315
1316static int c1551x_read_status (running_machine *machine, TPI6525 *This)
1316READ8_DEVICE_HANDLER( c1551x_read_status )
13171317{
13181318   int data = 0xff;
13191319#ifdef CPU_SYNC
13201320   cpu_sync();
13211321#endif
13221322
1323   data = tpi6525_0_port_c_r(cpu_get_address_space(machine->cpu[drive->cpunumber], ADDRESS_SPACE_PROGRAM), 0) & 0x03;
1323   data = tpi6525_portc_r(device, 0) & 0x03;
13241324//   DBG_LOG(1, "c1551 cpu",("%d read status %.2x\n", cpu_getactivecpu (), data));
13251325
13261326   return data;
13271327}
13281328
1329void c1551x_0_write_data(running_machine *machine, int data)
1330{
1331   c1551x_write_data(machine, tpi6525, data);
1332}
13331329
1334int c1551x_0_read_data(running_machine *machine)
1335{
1336   return c1551x_read_data(machine, tpi6525);
1337}
1338
1339void c1551x_0_write_handshake(running_machine *machine, int data)
1340{
1341   c1551x_write_handshake(machine, tpi6525, data);
1342}
1343
1344int c1551x_0_read_handshake(running_machine *machine)
1345{
1346   return c1551x_read_handshake(machine, tpi6525);
1347}
1348
1349int c1551x_0_read_status(running_machine *machine)
1350{
1351   return c1551x_read_status(machine, tpi6525);
1352}
1353
13541330/**************************************
13551331
13561332   Drive init & reset
r4008r4009
13661342
13671343   if (type == type_1551)
13681344   {
1369      tpi6525[0].c.read = c1551_port_c_r;
1370      tpi6525[0].b.read = c1551_port_b_r;
1371
13721345      /* time should be small enough to allow quitting of the irq
13731346      line before the next interrupt is triggered */
13741347      drive->drive.c1551.irq_timer = timer_alloc(machine, c1551_irq_timer, NULL);
r4008r4009
13911364   }
13921365
13931366   drive->track = 1.0;
1394
1395   if ((drive->type == type_1551))
1396   {
1397      tpi6525_0_reset();
1398   }
13991367}
14001368
1369
14011370/**************************************
14021371
14031372   Machine drivers
14041373
14051374**************************************/
14061375
1376const tpi6525_interface c1551_tpi_intf =
1377{
1378   NULL,
1379   c1551_port_b_r,
1380   c1551_port_c_r,
1381   NULL,
1382   NULL,
1383   NULL,
1384   NULL,
1385   NULL,
1386   NULL
1387};
1388
1389
14071390MACHINE_DRIVER_START( cpu_vc1540 )
14081391   MDRV_CPU_ADD("cpu_vc1540", M6502, XTAL_16_MHz / 16)
14091392   MDRV_CPU_PROGRAM_MAP(_1541_map, 0)
r4008r4009
14251408MACHINE_DRIVER_START( cpu_c1551 )
14261409   MDRV_CPU_ADD("cpu_c1551", M6510T, 2000000)
14271410   MDRV_CPU_PROGRAM_MAP(_1551_map, 0)
1411
1412   /* tpi */
1413   MDRV_TPI6525_ADD("c1551_tpi", c1551_tpi_intf)
14281414MACHINE_DRIVER_END
14291415
14301416MACHINE_DRIVER_START( cpu_c1571 )
src/mess/machine/c16.c
r4008r4009
1313#include "cpu/m6502/m6502.h"
1414#include "sound/sid6581.h"
1515
16#include "machine/tpi6525.h"
16#include "machine/6525tpi.h"
1717#include "video/ted7360.h"
1818#include "includes/cbmserb.h"
1919#include "includes/vc1541.h"
r4008r4009
438438   c16_select_roms (cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, 0);
439439   c16_switch_to_rom (cputag_get_address_space(machine,"main",ADDRESS_SPACE_PROGRAM), 0, 0);
440440
441   if (has_c1551)      /* C1551 */
442    {
443      tpi6525[2].a.read   = c1551x_0_read_data;
444      tpi6525[2].a.output = c1551x_0_write_data;
445      tpi6525[2].b.read   = c1551x_0_read_status;
446      tpi6525[2].c.read   = c1551x_0_read_handshake;
447      tpi6525[2].c.output = c1551x_0_write_handshake;
448   }
449   else
450   {
451      tpi6525[2].a.read   = c1551_0_read_data;
452      tpi6525[2].a.output = c1551_0_write_data;
453      tpi6525[2].b.read   = c1551_0_read_status;
454      tpi6525[2].c.read   = c1551_0_read_handshake;
455      tpi6525[2].c.output = c1551_0_write_handshake;
456   }
457
458   tpi6525[3].a.read   = c1551_1_read_data;
459   tpi6525[3].a.output = c1551_1_write_data;
460   tpi6525[3].b.read   = c1551_1_read_status;
461   tpi6525[3].c.read   = c1551_1_read_handshake;
462   tpi6525[3].c.output = c1551_1_write_handshake;
463
464441   rom = memory_region(machine, "main");
465442
466443   c16_memory_10000 = rom + 0x10000;
r4008r4009
478455   memset(mess_ram + (0xfd40 % mess_ram_size), 0xff, 0x20);
479456   
480457   if (has_c1551)      /* C1551 */
481      drive_config (machine, type_1551, 0, 0, 1, 8);
458      drive_config(machine, type_1551, 0, 0, 1, 8);
482459
483460   if (has_vc1541)      /* VC1541 */
484      drive_config (machine, type_1541, 0, 0, 1, 8);
461      drive_config(machine, type_1541, 0, 0, 1, 8);
485462}
486463
487464static void c16_driver_init(running_machine *machine)
r4008r4009
512489
513490MACHINE_RESET( c16 )
514491{
515   tpi6525_2_reset();
516   tpi6525_3_reset();
492   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
493   
517494   c364_speech_init(machine);
518495
519496   sndti_reset(SOUND_SID8580, 0);
520497
521498   if (read_cfg1(machine) & 0x80)  /* SID card present */
522499   {
523      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfd40, 0xfd5f, 0, 0, sid6581_0_port_r);
524      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfd40, 0xfd5f, 0, 0, sid6581_0_port_w);
525      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfe80, 0xfe9f, 0, 0, sid6581_0_port_r);
526      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfe80, 0xfe9f, 0, 0, sid6581_0_port_w);
500      memory_install_read8_handler(space, 0xfd40, 0xfd5f, 0, 0, sid6581_0_port_r);
501      memory_install_write8_handler(space,  0xfd40, 0xfd5f, 0, 0, sid6581_0_port_w);
502      memory_install_read8_handler(space, 0xfe80, 0xfe9f, 0, 0, sid6581_0_port_r);
503      memory_install_write8_handler(space,  0xfe80, 0xfe9f, 0, 0, sid6581_0_port_w);
527504   }
528505   else
529506   {
530      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfd40, 0xfd5f, 0, 0, SMH_NOP);
531      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfd40, 0xfd5f, 0, 0, SMH_NOP);
532      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfe80, 0xfe9f, 0, 0, SMH_NOP);
533      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfe80, 0xfe9f, 0, 0, SMH_NOP);
507      memory_install_read8_handler(space, 0xfd40, 0xfd5f, 0, 0, SMH_NOP);
508      memory_install_write8_handler(space,  0xfd40, 0xfd5f, 0, 0, SMH_NOP);
509      memory_install_read8_handler(space, 0xfe80, 0xfe9f, 0, 0, SMH_NOP);
510      memory_install_write8_handler(space,  0xfe80, 0xfe9f, 0, 0, SMH_NOP);
534511   }
535512
536513#if 0
r4008r4009
545522      memory_set_bankptr (machine, 6, mess_ram + (0x8000 % mess_ram_size));
546523      memory_set_bankptr (machine, 7, mess_ram + (0xc000 % mess_ram_size));
547524
548      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xff20, 0xff3d, 0, 0, SMH_BANK10);
549      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xff40, 0xffff, 0, 0, SMH_BANK11);
525      memory_install_write8_handler(space, 0xff20, 0xff3d, 0, 0, SMH_BANK10);
526      memory_install_write8_handler(space, 0xff40, 0xffff, 0, 0, SMH_BANK11);
550527      memory_set_bankptr (machine, 10, mess_ram + (0xff20 % mess_ram_size));
551528      memory_set_bankptr (machine, 11, mess_ram + (0xff40 % mess_ram_size));
552529
r4008r4009
554531   }
555532   else
556533   {
557      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x4000, 0xfcff, 0, 0, SMH_BANK10);
534      memory_install_write8_handler(space, 0x4000, 0xfcff, 0, 0, SMH_BANK10);
558535      memory_set_bankptr (machine, 10, mess_ram + (0x4000 % mess_ram_size));
559536
560537      ted7360_set_dma (ted7360_dma_read, ted7360_dma_read_rom);
r4008r4009
562539
563540   if (has_c1551 || has_iec8)      /* IEC8 on || C1551 */
564541   {
565      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfee0, 0xfeff, 0, 0, tpi6525_2_port_w);
566      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfee0, 0xfeff, 0, 0, tpi6525_2_port_r);
542      const device_config *tpi = devtag_get_device(machine, TPI6525, "tpi6535_tpi_2");
543      memory_install_write8_device_handler(space, tpi, 0xfee0, 0xfeff, 0, 0, tpi6525_w);
544      memory_install_read8_device_handler(space, tpi, 0xfee0, 0xfeff, 0, 0, tpi6525_r);
567545   }
568546   else
569547   {
570      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfee0, 0xfeff, 0, 0, SMH_NOP);
571      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfee0, 0xfeff, 0, 0, SMH_NOP);
548      memory_install_write8_handler(space, 0xfee0, 0xfeff, 0, 0, SMH_NOP);
549      memory_install_read8_handler(space, 0xfee0, 0xfeff, 0, 0, SMH_NOP);
572550   }
573551   if (has_iec9)               /* IEC9 on */
574552   {
575      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfec0, 0xfedf, 0, 0, tpi6525_3_port_w);
576      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfec0, 0xfedf, 0, 0, tpi6525_3_port_r);
553      const device_config *tpi = devtag_get_device(machine, TPI6525, "tpi6535_tpi_3");
554      memory_install_write8_device_handler(space, tpi, 0xfec0, 0xfedf, 0, 0, tpi6525_w);
555      memory_install_read8_device_handler(space, tpi, 0xfec0, 0xfedf, 0, 0, tpi6525_r);
577556   }
578557   else
579558   {
580      memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM),  0xfec0, 0xfedf, 0, 0, SMH_NOP);
581      memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xfec0, 0xfedf, 0, 0, SMH_NOP);
559      memory_install_write8_handler(space, 0xfec0, 0xfedf, 0, 0, SMH_NOP);
560      memory_install_read8_handler(space, 0xfec0, 0xfedf, 0, 0, SMH_NOP);
582561   }
583562
584563   if (has_c1551 || has_vc1541)      /* c1551 or vc1541 */
585564   {
586565      serial_config(machine, &fake_drive_interface);
587      drive_reset ();
566      drive_reset();
588567   }
589568   else                        /* simulated drives */
590569   {
591570      serial_config(machine, &sim_drive_interface);
592      cbm_serial_reset_write (machine, 0);
593      cbm_drive_0_config (SERIAL, 8);
594      cbm_drive_1_config (SERIAL, 9);
571      cbm_serial_reset_write(machine, 0);
572      cbm_drive_0_config(SERIAL, 8);
573      cbm_drive_1_config(SERIAL, 9);
595574   }
596575}
597576
src/mess/machine/cbmdrive.c
r4008r4009
16171617   return drive->i.iec.status;
16181618}
16191619
1620void c1551_0_write_data(running_machine *machine, int data)
1620
1621WRITE8_DEVICE_HANDLER( c1551_0_write_data )
16211622{
1622   c1551_write_data(machine, cbm_drive, data);
1623   c1551_write_data(device->machine, cbm_drive, data);
16231624}
1624int c1551_0_read_data(running_machine *machine)
1625
1626READ8_DEVICE_HANDLER( c1551_0_read_data )
16251627{
1626   return c1551_read_data(machine, cbm_drive);
1628   return c1551_read_data(device->machine, cbm_drive);
16271629}
1628void c1551_0_write_handshake(running_machine *machine, int data)
1630
1631WRITE8_DEVICE_HANDLER( c1551_0_write_handshake )
16291632{
1630   c1551_write_handshake(machine, cbm_drive, data);
1633   c1551_write_handshake(device->machine, cbm_drive, data);
16311634}
1632int c1551_0_read_handshake(running_machine *machine)
1635
1636READ8_DEVICE_HANDLER( c1551_0_read_handshake )
16331637{
1634   return c1551_read_handshake(machine, cbm_drive);
1638   return c1551_read_handshake(device->machine, cbm_drive);
16351639}
1636int c1551_0_read_status(running_machine *machine)
1640
1641READ8_DEVICE_HANDLER( c1551_0_read_status )
16371642{
1638   return c1551_read_status(machine, cbm_drive);
1643   return c1551_read_status(device->machine, cbm_drive);
16391644}
16401645
1641void c1551_1_write_data(running_machine *machine, int data)
1646WRITE8_DEVICE_HANDLER( c1551_1_write_data )
16421647{
1643   c1551_write_data(machine, cbm_drive + 1, data);
1648   c1551_write_data(device->machine, cbm_drive + 1, data);
16441649}
1645int c1551_1_read_data(running_machine *machine)
1650
1651READ8_DEVICE_HANDLER( c1551_1_read_data )
16461652{
1647   return c1551_read_data(machine, cbm_drive + 1);
1653   return c1551_read_data(device->machine, cbm_drive + 1);
16481654}
1649void c1551_1_write_handshake(running_machine *machine, int data)
1655
1656WRITE8_DEVICE_HANDLER( c1551_1_write_handshake )
16501657{
1651   c1551_write_handshake (machine, cbm_drive + 1, data);
1658   c1551_write_handshake(device->machine, cbm_drive + 1, data);
16521659}
1653int c1551_1_read_handshake(running_machine *machine)
1660
1661READ8_DEVICE_HANDLER( c1551_1_read_handshake )
16541662{
1655   return c1551_read_handshake(machine, cbm_drive + 1);
1663   return c1551_read_handshake(device->machine, cbm_drive + 1);
16561664}
1657int c1551_1_read_status(running_machine *machine)
1665
1666READ8_DEVICE_HANDLER( c1551_1_read_status )
16581667{
1659   return c1551_read_status(machine, cbm_drive + 1);
1668   return c1551_read_status(device->machine, cbm_drive + 1);
16601669}
16611670
1671
16621672/**************************************
16631673
16641674   VC1541
src/mess/machine/amigacd.c
r4008r4009
1212#include "driver.h"
1313#include "amiga.h"
1414#include "amigacd.h"
15#include "machine/6525tpi.h"
1516#include "machine/6526cia.h"
1617#include "machine/wd33c93.h"
17#include "machine/tpi6525.h"
1818#include "devices/chd_cd.h"
1919#include "matsucd.h"
2020
r4008r4009
213213      case 0x66:
214214      case 0x67:
215215      {
216         const device_config *tpi = devtag_get_device(space->machine, TPI6525, "tpi6525");
216217         LOG(( "DMAC: PC=%08x - TPI6525 Read(%d)\n", cpu_get_pc(space->cpu), (offset - 0x58) ));
217         return tpi6525_0_port_r(space, offset - 0x58);
218         return tpi6525_r(tpi, offset - 0x58);
218219      }
219220      break;
220221
r4008r4009
339340      case 0x66:
340341      case 0x67:
341342      {
343         const device_config *tpi = devtag_get_device(space->machine, TPI6525, "tpi6525");
342344         LOG(( "DMAC: PC=%08x - TPI6525 Write(%d) - data = %04x\n", cpu_get_pc(space->cpu), (offset - 0x58), data ));
343         tpi6525_0_port_w(space, offset - 0x58, data);
345         tpi6525_w(tpi, offset - 0x58, data);
344346      }
345347      break;
346348
r4008r4009
422424
423425***************************************************************************/
424426
425static int tp6525_portc_r(running_machine *machine)
427READ8_DEVICE_HANDLER( amigacd_tpi6525_portc_r )
426428{
427429   int   ret = 0;
428430
429   if ( (tpi6525[0].c.ddr & 0x04) == 0 ) /* if pin 2 is set to input */
431   if ( (tpi6525_get_ddr_c(device) & 0x04) == 0 ) /* if pin 2 is set to input */
430432   {
431433      ret |= matsucd_stch_r() ? 0x00 : 0x04;   /* read status change signal */
432434   }
433435
434   if ( (tpi6525[0].c.ddr & 0x08) == 0 ) /* if pin 3 is set to input */
436   if ( (tpi6525_get_ddr_c(device) & 0x08) == 0 ) /* if pin 3 is set to input */
435437      ret |= matsucd_sten_r() ? 0x08 : 0x00;   /* read enable signal */
436438
437439   return ret;
438440}
439441
440static void tp6525_portb_w(running_machine *machine, int data)
442WRITE8_DEVICE_HANDLER( amigacd_tpi6525_portb_w )
441443{
442   if ( tpi6525[0].b.ddr & 0x01 ) /* if pin 0 is set to output */
444   if ( tpi6525_get_ddr_b(device) & 0x01 ) /* if pin 0 is set to output */
443445      matsucd_cmd_w( data & 1 ); /* write to the /CMD signal */
444446
445   if ( tpi6525[0].b.ddr & 0x02 ) /* if pin 1 is set to output */
447   if ( tpi6525_get_ddr_b(device) & 0x02 ) /* if pin 1 is set to output */
446448      matsucd_enable_w( data & 2 ); /* write to the /ENABLE signal */
447449}
448450
r4008r4009
462464   }
463465}
464466
465static void tp6525_irq( running_machine *machine, int level )
467void amigacd_tpi6525_irq(const device_config *device, int level)
466468{
467469   LOG(( "TPI6525 Interrupt: level = %d\n", level ));
468470
r4008r4009
470472   {
471473      if ( (CUSTOM_REG(REG_INTREQ) & INTENA_PORTS) == 0 )
472474      {
473         amiga_custom_w(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff);
475         amiga_custom_w(cpu_get_address_space(device->machine->cpu[0], ADDRESS_SPACE_PROGRAM), REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff);
474476      }
475477      else
476478      {
r4008r4009
482484
483485static void cdrom_status_enabled( running_machine *machine, int level )
484486{
487   const device_config *tpi = devtag_get_device(machine, TPI6525, "tpi6525");
488
485489   /* PC3 on the 6525 */
486   tpi6525_0_irq3_level( machine, level );
490   tpi6525_irq3_level(tpi, level);
487491}
488492
489493static void cdrom_status_change( running_machine *machine, int level )
490494{
495   const device_config *tpi = devtag_get_device(machine, TPI6525, "tpi6525");
496
491497   /* invert */
492498   level = level ? 0 : 1;
493499
494500   /* PC2 on the 6525 */
495   tpi6525_0_irq2_level( machine, level );
501   tpi6525_irq2_level(tpi, level);
496502}
497503
498504static void cdrom_subcode_ready( running_machine *machine, int level )
499505{
506   const device_config *tpi = devtag_get_device(machine, TPI6525, "tpi6525");
507
500508   /* PC1 on the 6525 */
501   tpi6525_0_irq1_level( machine, level );
509   tpi6525_irq1_level(tpi, level);
502510}
503511
504512MACHINE_START( amigacd )
r4008r4009
509517   dmac_data.dma_timer = timer_alloc(machine, dmac_dma_proc, NULL);
510518   tp6525_delayed_timer = timer_alloc(machine, tp6525_delayed_irq, NULL);
511519
512   /* initialize the 6525 TPI */
513   tpi6525_0_reset();
514
515   tpi6525[0].a.read = NULL;
516   tpi6525[0].b.read = NULL;
517   tpi6525[0].c.read = tp6525_portc_r;
518
519   tpi6525[0].a.output = NULL;
520   tpi6525[0].b.output = tp6525_portb_w;
521   tpi6525[0].c.output = NULL;
522
523   tpi6525[0].interrupt.output = tp6525_irq;
524   tpi6525[0].ca.output = NULL;
525   tpi6525[0].cb.output = NULL;
526
527520   /* set up DMAC with autoconfig */
528521   amiga_add_autoconfig( machine, &dmac_device );
529522}
r4008r4009
536529   matsucd_set_status_changed_callback( cdrom_status_change );
537530   matsucd_set_subcode_ready_callback( cdrom_subcode_ready );
538531}
539
src/mess/machine/amigacd.h
r4008r4009
1#ifndef AMIGACD_H
2#define AMIGACD_H
1#ifndef __AMIGACD_H__
2#define __AMIGACD_H__
33
4
45MACHINE_START( amigacd );
56MACHINE_RESET( amigacd );
67
7#endif /* AMIGACD_H */
8/* 6525tpi */
9READ8_DEVICE_HANDLER( amigacd_tpi6525_portc_r );
10WRITE8_DEVICE_HANDLER( amigacd_tpi6525_portb_w );
11void amigacd_tpi6525_irq(const device_config *device, int level);
12
13
14#endif /* __AMIGACD_H__ */
src/mess/machine/6525tpi.c
r0r4009
1/***************************************************************************
2    mos tri port interface 6525
3   mos triple interface adapter 6523
4
5    peter.trauner@jk.uni-linz.ac.at
6
7   used in commodore b series
8   used in commodore c1551 floppy disk drive
9***************************************************************************/
10
11/*
12 mos tpi 6525
13 40 pin package
14 3 8 bit ports (pa, pb, pc)
15 8 registers to pc
16 0 port a 0 in low
17 1 port a data direction register 1 output
18 2 port b
19 3 port b ddr
20 4 port c
21  handshaking, interrupt mode
22  0 interrupt 0 input, 1 interrupt enabled
23   interrupt set on falling edge
24  1 interrupt 1 input
25  2 interrupt 2 input
26  3 interrupt 3 input
27  4 interrupt 4 input
28  5 irq output
29  6 ca handshake line (read handshake answer on I3 preferred)
30  7 cb handshake line (write handshake clear on I4 preferred)
31 5 port c ddr
32
33 6 cr configuration register
34  0 mc
35    0 port c normal input output mode like port a and b
36    1 port c used for handshaking and interrupt input
37  1 1 interrupt prioritized
38  2 i3 configure edge
39    1 interrupt set on positive edge
40  3 i4 configure edge
41  5,4 ca handshake
42   00 on read
43      rising edge of i3 sets ca high
44      read a data from computers sets ca low
45   01 pulse output
46      1 microsecond low after read a operation
47   10 manual output low
48   11 manual output high
49  7,6 cb handshake
50   00 handshake on write
51      write b data from computer sets cb 0
52      rising edge of i4 sets cb high
53   01 pulse output
54      1 microsecond low after write b operation
55   10 manual output low
56   11 manual output high
57 7 air active interrupt register
58   0 I0 occurred
59   1 I1 occurred
60   2 I2 occurred
61   3 I3 occurred
62   4 I4 occurred
63   read clears interrupt
64
65 non prioritized interrupts
66  interrupt is set when occurred
67  read clears all interrupts
68
69 prioritized interrupts
70  I4>I3>I2>I1>I0
71  highest interrupt can be found in air register
72  read clears highest interrupt
73*/
74
75#include "driver.h"
76#include "6525tpi.h"
77
78
79/***************************************************************************
80    CONSTANTS
81***************************************************************************/
82
83#define VERBOSE_LEVEL 0
84#define DBG_LOG(N,M,A) \
85   do { \
86      if(VERBOSE_LEVEL >= N) \
87      { \
88         if( M ) \
89            logerror("%11.6f: %-24s", attotime_to_double(timer_get_time(device->machine)), (char*) M ); \
90         logerror A; \
91      } \
92   } while (0)
93
94
95#define INTERRUPT_MODE (tpi6525->cr & 1)
96#define PRIORIZED_INTERRUPTS (tpi6525->cr & 2)
97#define INTERRUPT3_RISING_EDGE (tpi6525->cr & 4)
98#define INTERRUPT4_RISING_EDGE (tpi6525->cr & 8)
99#define CA_MANUAL_OUT (tpi6525->cr & 0x20)
100#define CA_MANUAL_LEVEL ((tpi6525->cr & 0x10) ? 1 : 0)
101#define CB_MANUAL_OUT (tpi6525->cr & 0x80)
102#define CB_MANUAL_LEVEL ((tpi6525->cr & 0x40) ? 1 : 0)
103
104
105/***************************************************************************
106    TYPE DEFINITIONS
107***************************************************************************/
108
109typedef struct _tpi6525_state tpi6525_state;
110struct _tpi6525_state
111{
112   const tpi6525_interface *intf;
113
114   UINT8 port_a, ddr_a, in_a;
115   UINT8 port_b, ddr_b, in_b;
116   UINT8 port_c, ddr_c, in_c;
117   
118   UINT8 ca_level, cb_level, interrupt_level;
119   
120   UINT8 cr;
121   UINT8 air;
122
123   UINT8 irq_level[5];
124};
125
126
127/*****************************************************************************
128    INLINE FUNCTIONS
129*****************************************************************************/
130
131INLINE tpi6525_state *get_safe_token(const device_config *device)
132{
133   assert(device != NULL);
134   assert(device->token != NULL);
135   assert(device->type == TPI6525);
136
137   return (tpi6525_state *)device->token;
138}
139
140
141/*****************************************************************************
142    DEVICE INTERFACE
143*****************************************************************************/
144
145static DEVICE_START( tpi6525 )
146{
147   tpi6525_state *tpi6525 = get_safe_token(device);
148
149   /* verify that we have an interface assigned */
150   assert(device->static_config != NULL);
151
152   /* register for state saving */
153   state_save_register_device_item(device, 0, tpi6525->port_a);
154   state_save_register_device_item(device, 0, tpi6525->ddr_a);
155   state_save_register_device_item(device, 0, tpi6525->in_a);
156   state_save_register_device_item(device, 0, tpi6525->port_b);
157   state_save_register_device_item(device, 0, tpi6525->ddr_b);
158   state_save_register_device_item(device, 0, tpi6525->in_b);
159   state_save_register_device_item(device, 0, tpi6525->port_c);
160   state_save_register_device_item(device, 0, tpi6525->ddr_c);
161   state_save_register_device_item(device, 0, tpi6525->in_c);
162   state_save_register_device_item(device, 0, tpi6525->ca_level);
163   state_save_register_device_item(device, 0, tpi6525->cb_level);
164   state_save_register_device_item(device, 0, tpi6525->interrupt_level);
165   state_save_register_device_item(device, 0, tpi6525->cr);
166   state_save_register_device_item(device, 0, tpi6525->air);
167   state_save_register_device_item_array(device, 0, tpi6525->irq_level);
168
169   return DEVICE_START_OK;
170}
171
172
173static DEVICE_RESET( tpi6525 )
174{
175   tpi6525_state *tpi6525 = get_safe_token(device);
176
177   /* clear old values */
178   memset(tpi6525, 0, sizeof(*tpi6525));
179
180   /* copy interface pointer */
181   tpi6525->intf = device->static_config;
182
183   /* setup some initial values */
184   tpi6525->in_a = 0xff;
185   tpi6525->in_b = 0xff;
186   tpi6525->in_c = 0xff;
187}
188
189
190static DEVICE_SET_INFO( tpi6525 )
191{
192   switch (state)
193   {
194      /* no parameters to set */
195   }
196}
197
198
199DEVICE_GET_INFO( tpi6525 )
200{
201   switch (state)
202   {
203      /* --- the following bits of info are returned as 64-bit signed integers --- */
204      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(tpi6525_state);      break;
205      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;      break;
206
207      /* --- the following bits of info are returned as pointers to data or functions --- */
208      case DEVINFO_FCT_SET_INFO:            info->set_info = DEVICE_SET_INFO_NAME( tpi6525 );   break;
209      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME( tpi6525 );         break;
210      case DEVINFO_FCT_STOP:               /* Nothing */                              break;
211      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME( tpi6525 );         break;
212
213      /* --- the following bits of info are returned as NULL-terminated strings --- */
214      case DEVINFO_STR_NAME:               strcpy(info->s, "6525 TPI");         break;
215      case DEVINFO_STR_FAMILY:            strcpy(info->s, "6525 TPI");         break;
216      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");               break;
217      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);            break;
218      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");   break;
219   }
220}
221
222
223/***************************************************************************
224    IMPLEMENTATION
225***************************************************************************/
226
227static void tpi6525_set_interrupt(const device_config *device)
228{
229   tpi6525_state *tpi6525 = get_safe_token(device);
230
231   if (!tpi6525->interrupt_level && (tpi6525->air != 0))
232   {
233      tpi6525->interrupt_level = 1;
234
235      DBG_LOG(3, "tpi6525", ("%s set interrupt\n", device->tag));
236
237      if (tpi6525->intf->irq_func != NULL)
238         tpi6525->intf->irq_func(device, tpi6525->interrupt_level);
239   }
240}
241
242
243static void tpi6525_clear_interrupt(const device_config *device)
244{
245   tpi6525_state *tpi6525 = get_safe_token(device);
246
247   if (tpi6525->interrupt_level && (tpi6525->air == 0))
248   {
249      tpi6525->interrupt_level = 0;
250
251      DBG_LOG (3, "tpi6525", ("%s clear interrupt\n", device->tag));
252
253      if (tpi6525->intf->irq_func != NULL)
254         tpi6525->intf->irq_func(device, tpi6525->interrupt_level);
255   }
256}
257
258
259void tpi6525_irq0_level(const device_config *device, int level)
260{
261   tpi6525_state *tpi6525 = get_safe_token(device);
262
263   if (INTERRUPT_MODE && (level != tpi6525->irq_level[0]))
264   {
265      tpi6525->irq_level[0] = level;
266
267      if ((level == 0) && !(tpi6525->air & 1) && (tpi6525->ddr_c & 1))
268      {
269         tpi6525->air |= 1;
270         tpi6525_set_interrupt(device);
271      }
272   }
273}
274
275
276void tpi6525_irq1_level(const device_config *device, int level)
277{
278   tpi6525_state *tpi6525 = get_safe_token(device);
279
280   if (INTERRUPT_MODE && (level != tpi6525->irq_level[1]))
281   {
282      tpi6525->irq_level[1] = level;
283
284      if ((level == 0) && !(tpi6525->air & 2) && (tpi6525->ddr_c & 2))
285      {
286         tpi6525->air |= 2;
287         tpi6525_set_interrupt(device);
288      }
289   }
290}
291
292
293void tpi6525_irq2_level(const device_config *device, int level)
294{
295   tpi6525_state *tpi6525 = get_safe_token(device);
296
297   if (INTERRUPT_MODE && (level != tpi6525->irq_level[2]))
298   {
299      tpi6525->irq_level[2] = level;
300
301      if ((level == 0) && !(tpi6525->air & 4) && (tpi6525->ddr_c & 4))
302      {
303         tpi6525->air |= 4;
304         tpi6525_set_interrupt(device);
305      }
306   }
307}
308
309
310void tpi6525_irq3_level(const device_config *device, int level)
311{
312   tpi6525_state *tpi6525 = get_safe_token(device);
313
314   if (INTERRUPT_MODE && (level != tpi6525->irq_level[3]))
315   {
316      tpi6525->irq_level[3] = level;
317
318      if (((INTERRUPT3_RISING_EDGE && (level == 1))
319         || (!INTERRUPT3_RISING_EDGE && (level == 0)))
320         && !(tpi6525->air & 8) && (tpi6525->ddr_c & 8))
321      {
322         tpi6525->air |= 8;
323         tpi6525_set_interrupt(device);
324      }
325   }
326}
327
328
329void tpi6525_irq4_level(const device_config *device, int level)
330{
331   tpi6525_state *tpi6525 = get_safe_token(device);
332
333   if (INTERRUPT_MODE && (level != tpi6525->irq_level[4]) )
334   {
335      tpi6525->irq_level[4] = level;
336
337      if (((INTERRUPT4_RISING_EDGE && (level == 1))
338         ||(!INTERRUPT4_RISING_EDGE&&(level == 0)))
339         && !(tpi6525->air & 0x10) && (tpi6525->ddr_c & 0x10))
340      {
341         tpi6525->air |= 0x10;
342         tpi6525_set_interrupt(device);
343      }
344   }
345}
346
347
348READ8_DEVICE_HANDLER( tpi6525_porta_r )
349{
350   tpi6525_state *tpi6525 = get_safe_token(device);
351   UINT8 data = tpi6525->in_a;
352
353   if (tpi6525->intf->in_a_func)
354      data = tpi6525->intf->in_a_func(device, offset);
355
356   data = (data & ~tpi6525->ddr_a) | (tpi6525->ddr_a & tpi6525->port_a);
357
358   return data;   
359}
360
361
362WRITE8_DEVICE_HANDLER( tpi6525_porta_w )
363{
364   tpi6525_state *tpi6525 = get_safe_token(device);
365
366   tpi6525->in_a = data;
367}
368
369
370READ8_DEVICE_HANDLER( tpi6525_portb_r )
371{
372   tpi6525_state *tpi6525 = get_safe_token(device);
373   UINT8 data = tpi6525->in_b;
374
375   if (tpi6525->intf->in_b_func)
376      data = tpi6525->intf->in_b_func(device, offset);
377
378   data = (data & ~tpi6525->ddr_b) | (tpi6525->ddr_b & tpi6525->port_b);
379
380   return data;
381}
382
383
384WRITE8_DEVICE_HANDLER( tpi6525_portb_w )
385{
386   tpi6525_state *tpi6525 = get_safe_token(device);
387
388   tpi6525->in_b = data;
389}
390
391
392READ8_DEVICE_HANDLER( tpi6525_portc_r )
393{
394   tpi6525_state *tpi6525 = get_safe_token(device);
395   UINT8 data = tpi6525->in_c;
396
397   if (tpi6525->intf->in_c_func)
398      data &= tpi6525->intf->in_c_func(device, offset);
399
400   data = (data & ~tpi6525->ddr_c) | (tpi6525->ddr_c & tpi6525->port_c);
401
402   return data;
403}
404
405
406WRITE8_DEVICE_HANDLER( tpi6525_portc_w )
407{
408   tpi6525_state *tpi6525 = get_safe_token(device);
409
410   tpi6525->in_c = data;
411}
412
413
414READ8_DEVICE_HANDLER( tpi6525_r )
415{
416   tpi6525_state *tpi6525 = get_safe_token(device);
417   UINT8 data = 0xff;
418
419   switch (offset & 7)
420   {
421   case 0:
422      data = tpi6525->in_a;
423
424      if (tpi6525->intf->in_a_func)
425         data &= tpi6525->intf->in_a_func(device, 0);
426
427      data = (data & ~tpi6525->ddr_a) | (tpi6525->ddr_a & tpi6525->port_a);
428
429      break;
430
431   case 1:
432      data = tpi6525->in_b;
433     
434      if (tpi6525->intf->in_b_func)
435         data &= tpi6525->intf->in_b_func(device, 0);
436
437      data = (data & ~tpi6525->ddr_b) | (tpi6525->ddr_b & tpi6525->port_b);
438
439      break;
440
441   case 2:
442      if (INTERRUPT_MODE)
443      {
444         data = 0;
445
446         if (tpi6525->irq_level[0]) data |= 0x01;
447         if (tpi6525->irq_level[1]) data |= 0x02;
448         if (tpi6525->irq_level[2]) data |= 0x04;
449         if (tpi6525->irq_level[3]) data |= 0x08;
450         if (tpi6525->irq_level[4]) data |= 0x10;
451         if (!tpi6525->interrupt_level) data |= 0x20;
452         if (tpi6525->ca_level) data |= 0x40;
453         if (tpi6525->cb_level) data |= 0x80;
454      }
455      else
456      {
457         data = tpi6525->in_c;
458         
459         if (tpi6525->intf->in_c_func)
460            data &= tpi6525->intf->in_c_func(device, 0);
461         
462         data = (data & ~tpi6525->ddr_c) | (tpi6525->ddr_c & tpi6525->port_c);
463      }
464
465      DBG_LOG(2, "tpi6525", ("%s read %.2x %.2x\n", device->tag, offset, data));
466      break;
467
468   case 3:
469      data = tpi6525->ddr_a;
470      break;
471
472   case 4:
473      data = tpi6525->ddr_b;
474      break;
475
476   case 5:
477      data = tpi6525->ddr_c;
478      break;
479
480   case 6:
481      data = tpi6525->cr;
482      break;
483
484   case 7: /* air */
485      if (PRIORIZED_INTERRUPTS)
486      {
487         if (tpi6525->air & 0x10)
488         {
489            data = 0x10;
490            tpi6525->air &= ~0x10;
491         }
492         else if (tpi6525->air & 8)
493         {
494            data = 8;
495            tpi6525->air &= ~8;
496         }
497         else if (tpi6525->air & 4)
498         {
499            data = 4;
500            tpi6525->air &= ~4;
501         }
502         else if (tpi6525->air & 2)
503         {
504            data = 2;
505            tpi6525->air &= ~2;
506         }
507         else if (tpi6525->air & 1)
508         {
509            data = 1;
510            tpi6525->air &= ~1;
511         }
512      }
513      else
514      {
515         data = tpi6525->air;
516         tpi6525->air = 0;
517      }
518     
519      tpi6525_clear_interrupt(device);
520      break;
521
522   }
523
524   DBG_LOG(3, "tpi6525", ("%s read %.2x %.2x\n", device->tag, offset, data));
525
526   return data;
527}
528
529
530WRITE8_DEVICE_HANDLER( tpi6525_w )
531{
532   tpi6525_state *tpi6525 = get_safe_token(device);
533
534   DBG_LOG(2, "tpi6525", ("%s write %.2x %.2x\n", device->tag, offset, data));
535
536   switch (offset & 7)
537   {
538   case 0:
539      tpi6525->port_a = data;
540
541      if (tpi6525->intf->out_a_func)
542         tpi6525->intf->out_a_func(device, 0, tpi6525->port_a & tpi6525->ddr_a);
543
544      break;
545     
546   case 1:
547      tpi6525->port_b = data;
548
549      if (tpi6525->intf->out_b_func)
550         tpi6525->intf->out_b_func(device, 0, tpi6525->port_b & tpi6525->ddr_b);
551
552      break;
553
554   case 2:
555      tpi6525->port_c = data;
556
557      if (!INTERRUPT_MODE && tpi6525->intf->out_c_func)
558         tpi6525->intf->out_c_func(device, 0, tpi6525->port_c & tpi6525->ddr_c);
559
560      break;
561
562   case 3:
563      tpi6525->ddr_a = data;
564
565      if (tpi6525->intf->out_a_func)
566         tpi6525->intf->out_a_func(device, 0, tpi6525->port_a & tpi6525->ddr_a);
567
568      break;
569
570   case 4:
571      tpi6525->ddr_b = data;
572
573      if (tpi6525->intf->out_b_func)
574         tpi6525->intf->out_b_func(device, 0, tpi6525->port_b & tpi6525->ddr_b);
575
576      break;
577
578   case 5:
579      tpi6525->ddr_c = data;
580
581      if (!INTERRUPT_MODE && tpi6525->intf->out_c_func)
582         tpi6525->intf->out_c_func(device, 0, tpi6525->port_c & tpi6525->ddr_c);
583
584      break;
585
586   case 6:
587      tpi6525->cr = data;
588     
589      if (INTERRUPT_MODE)
590      {
591         if (CA_MANUAL_OUT)
592         {
593            if (tpi6525->ca_level != CA_MANUAL_LEVEL)
594            {
595               tpi6525->ca_level = CA_MANUAL_LEVEL;
596
597               if (tpi6525->intf->out_ca_func)
598                  tpi6525->intf->out_ca_func(device, 0, tpi6525->ca_level);
599            }
600         }
601         if (CB_MANUAL_OUT)
602         {
603            if (tpi6525->cb_level != CB_MANUAL_LEVEL)
604            {
605               tpi6525->cb_level = CB_MANUAL_LEVEL;
606               
607               if (tpi6525->intf->out_cb_func)
608                  tpi6525->intf->out_cb_func(device, 0, tpi6525->cb_level);
609            }
610         }
611      }
612
613      break;
614
615   case 7:
616      /* tpi6525->air = data; */
617      break;
618   }
619}
620
621
622/* this should probably be done better, needed for amigacd.c */
623
624UINT8 tpi6525_get_ddr_a(const device_config *device)
625{
626   tpi6525_state *tpi6525 = get_safe_token(device);
627   return tpi6525->ddr_a;
628}
629
630UINT8 tpi6525_get_ddr_b(const device_config *device)
631{
632   tpi6525_state *tpi6525 = get_safe_token(device);
633   return tpi6525->ddr_b;
634}
635
636UINT8 tpi6525_get_ddr_c(const device_config *device)
637{
638   tpi6525_state *tpi6525 = get_safe_token(device);
639   return tpi6525->ddr_c;
640}
src/mess/machine/6525tpi.h
r0r4009
1/*****************************************************************************
2 *
3 * machine/tpi6525.h
4 *
5 * mos tri port interface 6525
6 * mos triple interface adapter 6523
7 *
8 * peter.trauner@jk.uni-linz.ac.at
9 *
10 * used in commodore b series
11 * used in commodore c1551 floppy disk drive
12 *
13 * tia6523 is a tpi6525 without control register!?
14 *
15 * tia6523
16 *   only some lines of port b and c are in the pinout!
17 *
18 * connector to floppy c1551 (delivered with c1551 as c16 expansion)
19 *   port a for data read/write
20 *   port b
21 *   0 status 0
22 *   1 status 1
23 *   port c
24 *   6 dav output edge data on port a available
25 *   7 ack input edge ready for next datum
26 *
27 ****************************************************************************/
28
29#ifndef __TPI6525_H__
30#define __TPI6525_H__
31
32
33/***************************************************************************
34    TYPE DEFINITIONS
35***************************************************************************/
36
37typedef struct _tpi6525_interface tpi6525_interface;
38struct _tpi6525_interface
39{
40   read8_device_func in_a_func;
41   read8_device_func in_b_func;
42   read8_device_func in_c_func;
43   write8_device_func out_a_func;
44   write8_device_func out_b_func;
45   write8_device_func out_c_func;
46   write8_device_func out_ca_func;
47   write8_device_func out_cb_func;
48   void (*irq_func)(const device_config *device, int level);
49};
50
51
52/***************************************************************************
53    DEVICE CONFIGURATION MACROS
54***************************************************************************/
55
56#define TPI6525 DEVICE_GET_INFO_NAME(tpi6525)
57
58#define MDRV_TPI6525_ADD(_tag, _intrf) \
59   MDRV_DEVICE_ADD(_tag, TPI6525, 0) \
60   MDRV_DEVICE_CONFIG(_intrf)
61
62#define MDRV_TPI6525_REMOVE(_tag) \
63   MDRV_DEVICE_REMOVE(_tag, TPI6525)
64
65
66/***************************************************************************
67    FUNCTION PROTOTYPES
68***************************************************************************/
69
70DEVICE_GET_INFO( tpi6525 );
71
72READ8_DEVICE_HANDLER( tpi6525_r );
73WRITE8_DEVICE_HANDLER( tpi6525_w );
74
75READ8_DEVICE_HANDLER( tpi6525_porta_r );
76WRITE8_DEVICE_HANDLER( tpi6525_porta_w );
77
78READ8_DEVICE_HANDLER( tpi6525_portb_r );
79WRITE8_DEVICE_HANDLER( tpi6525_portb_w );
80
81READ8_DEVICE_HANDLER( tpi6525_portc_r );
82WRITE8_DEVICE_HANDLER( tpi6525_portc_w );
83
84void tpi6525_irq0_level(const device_config *device, int level);
85void tpi6525_irq1_level(const device_config *device, int level);
86void tpi6525_irq2_level(const device_config *device, int level);
87void tpi6525_irq3_level(const device_config *device, int level);
88void tpi6525_irq4_level(const device_config *device, int level);
89
90UINT8 tpi6525_get_ddr_a(const device_config *device);
91UINT8 tpi6525_get_ddr_b(const device_config *device);
92UINT8 tpi6525_get_ddr_c(const device_config *device);
93
94
95#endif /* __TPI6525_H__ */
src/mess/mess.mak
r4008r4009
645645
646646$(MESSOBJ)/cbmshare.a: \
647647   $(MESS_FORMATS)/cbm_tap.o    \
648   $(MESS_MACHINE)/tpi6525.o   \
648   $(MESS_MACHINE)/6525tpi.o   \
649649   $(MESS_MACHINE)/cbm.o      \
650650   $(MESS_MACHINE)/cbmdrive.o   \
651651   $(MESS_MACHINE)/vc1541.o   \
src/mess/drivers/cbmb.c
r4008r4009
9999//#include "cpu/i86/i86.h"
100100#include "cpu/m6502/m6509.h"
101101#include "sound/sid6581.h"
102#include "machine/6525tpi.h"
102103#include "machine/6526cia.h"
103104
104105#include "includes/cbm.h"
105#include "machine/tpi6525.h"
106106#include "machine/cbmipt.h"
107107#include "video/vic6567.h"
108108#include "video/mc6845.h"
r4008r4009
136136   /* db00 coprocessor */
137137   AM_RANGE(0xfdc00, 0xfdcff) AM_DEVREAD( CIA6526R1, "cia", cia_r )
138138   /* dd00 acia */
139   AM_RANGE(0xfde00, 0xfdeff) AM_READ( tpi6525_0_port_r)
140   AM_RANGE(0xfdf00, 0xfdfff) AM_READ( tpi6525_1_port_r)
139   AM_RANGE(0xfde00, 0xfdeff) AM_DEVREAD(TPI6525, "tpi6525_0", tpi6525_r)
140   AM_RANGE(0xfdf00, 0xfdfff) AM_DEVREAD(TPI6525, "tpi6525_1", tpi6525_r)
141141   AM_RANGE(0xfe000, 0xfffff) AM_READ( SMH_ROM )
142142ADDRESS_MAP_END
143143
r4008r4009
159159   /* db00 coprocessor */
160160   AM_RANGE(0xfdc00, 0xfdcff) AM_DEVWRITE( CIA6526R1, "cia", cia_w)
161161   /* dd00 acia */
162   AM_RANGE(0xfde00, 0xfdeff) AM_WRITE( tpi6525_0_port_w)
163   AM_RANGE(0xfdf00, 0xfdfff) AM_WRITE( tpi6525_1_port_w)
162   AM_RANGE(0xfde00, 0xfdeff) AM_DEVWRITE(TPI6525, "tpi6525_0", tpi6525_w)
163   AM_RANGE(0xfdf00, 0xfdfff) AM_DEVWRITE(TPI6525, "tpi6525_1", tpi6525_w)
164164   AM_RANGE(0xfe000, 0xfffff) AM_WRITE( SMH_ROM) AM_BASE( &cbmb_kernal )
165165ADDRESS_MAP_END
166166
r4008r4009
183183   /* db00 coprocessor */
184184   AM_RANGE(0xfdc00, 0xfdcff) AM_DEVREAD( CIA6526R1, "cia", cia_r )
185185   /* dd00 acia */
186   AM_RANGE(0xfde00, 0xfdeff) AM_READ( tpi6525_0_port_r)
187   AM_RANGE(0xfdf00, 0xfdfff) AM_READ( tpi6525_1_port_r)
186   AM_RANGE(0xfde00, 0xfdeff) AM_DEVREAD(TPI6525, "tpi6525_0", tpi6525_r)
187   AM_RANGE(0xfdf00, 0xfdfff) AM_DEVREAD(TPI6525, "tpi6525_1", tpi6525_r)
188188   AM_RANGE(0xfe000, 0xfffff) AM_READ( SMH_ROM )
189189ADDRESS_MAP_END
190190
r4008r4009
207207   /* db00 coprocessor */
208208   AM_RANGE(0xfdc00, 0xfdcff) AM_DEVWRITE( CIA6526R1, "cia", cia_w)
209209   /* dd00 acia */
210   AM_RANGE(0xfde00, 0xfdeff) AM_WRITE( tpi6525_0_port_w)
211   AM_RANGE(0xfdf00, 0xfdfff) AM_WRITE( tpi6525_1_port_w)
210   AM_RANGE(0xfde00, 0xfdeff) AM_DEVWRITE(TPI6525, "tpi6525_0", tpi6525_w)
211   AM_RANGE(0xfdf00, 0xfdfff) AM_DEVWRITE(TPI6525, "tpi6525_1", tpi6525_w)
212212   AM_RANGE(0xfe000, 0xfffff) AM_WRITE( SMH_ROM) AM_BASE( &cbmb_kernal )
213213ADDRESS_MAP_END
214214
r4008r4009
353353 *
354354 *************************************/
355355
356const tpi6525_interface cbmb_tpi_0_intf =
357{
358   cbmb_tpi0_port_a_r,
359   NULL,
360   NULL,
361   cbmb_tpi0_port_a_w,
362   NULL,
363   NULL,
364   cbmb_change_font,
365   NULL,
366   cbmb_irq
367};
356368
369const tpi6525_interface cbmb_tpi_1_intf =
370{
371   cbmb_keyboard_line_a,
372   cbmb_keyboard_line_b,
373   cbmb_keyboard_line_c,
374   cbmb_keyboard_line_select_a,
375   cbmb_keyboard_line_select_b,
376   cbmb_keyboard_line_select_c,
377   NULL,
378   NULL,
379   NULL
380};
381
382
357383static MACHINE_DRIVER_START( cbm600 )
358384   /* basic machine hardware */
359385   MDRV_CPU_ADD("main", M6509, 7833600)        /* 7.8336 MHz */
r4008r4009
388414   /* cia */
389415   MDRV_CIA6526_ADD("cia", CIA6526R1, 0, cbmb_cia)
390416   
417   /* tpi */
418   MDRV_TPI6525_ADD("tpi6525_0", cbmb_tpi_0_intf)
419   MDRV_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
420
391421   MDRV_IMPORT_FROM(cbmb_cartslot)
392422MACHINE_DRIVER_END
393423
r4008r4009
452482   /* cia */
453483   MDRV_CIA6526_ADD("cia", CIA6526R1, 0, cbmb_cia)
454484
485   /* tpi */
486   MDRV_TPI6525_ADD("tpi6525_0", cbmb_tpi_0_intf)
487   MDRV_TPI6525_ADD("tpi6525_1", cbmb_tpi_1_intf)
488
455489   MDRV_IMPORT_FROM(cbmb_cartslot)
456490MACHINE_DRIVER_END
457491
r4008r4009
506540ROM_END
507541
508542
509#define rom_cbm610      rom_b128
510#define rom_cbm620      rom_b256
543#define rom_cbm610   rom_b128
544#define rom_cbm620   rom_b256
511545
512546
513547ROM_START( cbm620hu )
r4008r4009
551585   ROM_LOAD( "901232-01.u25", 0x0000, 0x1000, CRC(3a350bc3) SHA1(e7f3cbc8e282f79a00c3e95d75c8d725ee3c6287) )
552586ROM_END
553587
554#define rom_cbm710      rom_b128hp
555#define rom_cbm720      rom_b256hp
588#define rom_cbm710   rom_b128hp
589#define rom_cbm720   rom_b256hp
556590
557591
558592/* BX-256HP - only ROM loading added */
r4008r4009
596630   ROM_LOAD( "901225-01.bin", 0x100000, 0x1000, CRC(ec4272ee) SHA1(adc7c31e18c7c7413d54802ef2f4193da14711aa) )
597631ROM_END
598632
633
599634/***************************************************************************
600635
601636  Game driver(s)
602637
603638***************************************************************************/
604639
605/*    YEAR  NAME      PARENT COMPAT MACHINE     INPUT       INIT        CONFIG  COMPANY                             FULLNAME */
640/*    YEAR  NAME      PARENT  COMPAT  MACHINE    INPUT      INIT       CONFIG  COMPANY                             FULLNAME                                  FLAGS */
641COMP( 1983,   b500,     cbm610, 0,      cbm600,    cbm600,    cbm600,    0,      "Commodore Business Machines Co.",  "B500 (proto, 60Hz)",                     GAME_NOT_WORKING )
642COMP( 1983,   b128,     cbm610, 0,      cbm600pal, cbm600pal, cbm600pal, 0,      "Commodore Business Machines Co.",  "B128 (60Hz)",                            GAME_NOT_WORKING )
643COMP( 1983,   b256,     cbm610, 0,      cbm600pal, cbm600pal, cbm600hu,  0,      "Commodore Business Machines Co.",  "B256 (60Hz)",                            GAME_NOT_WORKING )
644COMP( 1983,   cbm610,   0,      0,      cbm600,    cbm600,    cbm600,    0,      "Commodore Business Machines Co.",  "CBM 610 (50Hz)",                         GAME_NOT_WORKING )
645COMP( 1983,   cbm620,   cbm610, 0,      cbm600pal, cbm600pal, cbm600pal, 0,      "Commodore Business Machines Co.",  "CBM 620 (50Hz)",                         GAME_NOT_WORKING )
646COMP( 1983,   cbm620hu, cbm610, 0,      cbm600pal, cbm600pal, cbm600hu,  0,      "Commodore Business Machines Co.",  "CBM 620 (Hungary, 50Hz)",                GAME_NOT_WORKING )
606647
607COMP( 1983,   b500,     cbm610,   0,  cbm600,     cbm600,     cbm600,     0,   "Commodore Business Machines Co.",  "B500 (proto, 60Hz)", GAME_NOT_WORKING)
608COMP( 1983,   b128,     cbm610,   0,  cbm600pal,  cbm600pal,  cbm600pal,  0,   "Commodore Business Machines Co.",   "B128 (60Hz)", GAME_NOT_WORKING)
609COMP( 1983,   b256,     cbm610,   0,  cbm600pal,  cbm600pal,  cbm600hu,   0,   "Commodore Business Machines Co.",   "B256 (60Hz)", GAME_NOT_WORKING)
610COMP( 1983,   cbm610,   0,        0,  cbm600,     cbm600,     cbm600,     0,   "Commodore Business Machines Co.",  "CBM 610 (50Hz)", GAME_NOT_WORKING)
611COMP( 1983,   cbm620,   cbm610,   0,  cbm600pal,  cbm600pal,  cbm600pal,  0,   "Commodore Business Machines Co.",   "CBM 620 (50Hz)", GAME_NOT_WORKING)
612COMP( 1983,   cbm620hu, cbm610,   0,  cbm600pal,  cbm600pal,  cbm600hu,   0,   "Commodore Business Machines Co.",   "CBM 620 (Hungary, 50Hz)", GAME_NOT_WORKING)
648COMP( 1983, b128hp,   cbm610, 0,      cbm700,    cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "B128-80HP (60Hz)",                       GAME_NOT_WORKING )
649COMP( 1983, b256hp,   cbm610, 0,      cbm700,    cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "B256-80HP (60Hz)",                       GAME_NOT_WORKING )
650COMP( 1983, cbm710,   cbm610, 0,      cbm700pal, cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "CBM 710 (50Hz)",                         GAME_NOT_WORKING )
651COMP( 1983, cbm720,   cbm610, 0,      cbm700pal, cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "CBM 720 (50Hz)",                         GAME_NOT_WORKING )
652COMP( 1983, cbm720se, cbm610, 0,      cbm700pal, cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "CBM 720 (Sweden/Finland, 50Hz)",         GAME_NOT_WORKING )
613653
614COMP( 1983, b128hp,   cbm610,   0,  cbm700,     cbm700,     cbm700,     0,   "Commodore Business Machines Co.",  "B128-80HP (60Hz)", GAME_NOT_WORKING)
615COMP( 1983, b256hp,   cbm610,   0,  cbm700,     cbm700,     cbm700,     0,   "Commodore Business Machines Co.",   "B256-80HP (60Hz)", GAME_NOT_WORKING)
616COMP( 1983, cbm710,   cbm610,   0,  cbm700pal,  cbm700,     cbm700,     0,   "Commodore Business Machines Co.",  "CBM 710 (50Hz)", GAME_NOT_WORKING)
617COMP( 1983, cbm720,   cbm610,   0,  cbm700pal,  cbm700,     cbm700,     0,   "Commodore Business Machines Co.",   "CBM 720 (50Hz)", GAME_NOT_WORKING)
618COMP( 1983, cbm720se, cbm610,   0,  cbm700pal,  cbm700,     cbm700,     0,   "Commodore Business Machines Co.",   "CBM 720 (Sweden/Finland, 50Hz)", GAME_NOT_WORKING)
654COMP( 1983,   bx256hp,  cbm610, 0,      bx256hp,   cbm700,    cbm700,    0,      "Commodore Business Machines Co.",  "BX256-80HP (60Hz)",                      GAME_NOT_WORKING )
619655
620COMP( 1983,   bx256hp,  cbm610,   0,  bx256hp,    cbm700,     cbm700,     0,   "Commodore Business Machines Co.",   "BX256-80HP (60Hz)", GAME_NOT_WORKING)
621
622COMP( 1983,   p500,     0,        0,  p500,       p500,       p500,       0,   "Commodore Business Machines Co.",   "P500 (proto, a.k.a. B128-40 or Pet-II)", GAME_NOT_WORKING)
656COMP( 1983,   p500,     0,      0,      p500,      p500,      p500,      0,      "Commodore Business Machines Co.",  "P500 (proto, a.k.a. B128-40 or Pet-II)", GAME_NOT_WORKING )
src/mess/drivers/c16.c
r4008r4009
121121#include "cpu/m6502/m6502.h"
122122#include "sound/sid6581.h"
123123
124#include "machine/6525tpi.h"
124125#include "includes/vc1541.h"
125126#include "machine/cbmipt.h"
126127#include "video/ted7360.h"
r4008r4009
362363 *
363364 *************************************/
364365
366const tpi6525_interface c16_tpi6525_tpi_2_intf =
367{
368   c1551_0_read_data,
369   c1551_0_read_status,
370   c1551_0_read_handshake,
371   c1551_0_write_data,
372   NULL,
373   c1551_0_write_handshake,
374   NULL,
375   NULL,
376   NULL   
377};
365378
379const tpi6525_interface c16_tpi6525_tpi_2_c1551_intf =
380{
381   c1551x_read_data,
382   c1551x_read_status,
383   c1551x_read_handshake,
384   c1551x_write_data,
385   NULL,
386   c1551x_write_handshake,
387   NULL,
388   NULL,
389   NULL
390};
391
392const tpi6525_interface c16_tpi6525_tpi_3_intf =
393{
394   c1551_1_read_data,
395   c1551_1_read_status,
396   c1551_1_read_handshake,
397   c1551_1_write_data,
398   NULL,
399   c1551_1_write_handshake,
400   NULL,
401   NULL,
402   NULL   
403};
404
405
366406static MACHINE_DRIVER_START( c16 )
367407   /* basic machine hardware */
368408   MDRV_CPU_ADD("main", M7501, 1400000)        /* 7.8336 MHz */
r4008r4009
403443   /* via */
404444   MDRV_VIA6522_ADD("via6522_2", 0, vc1541_via2)
405445   MDRV_VIA6522_ADD("via6522_3", 0, vc1541_via3)
406   
446
447   /* tpi */
448   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_intf)
449   MDRV_TPI6525_ADD("tpi6535_tpi_3", c16_tpi6525_tpi_3_intf)
450
407451   MDRV_IMPORT_FROM(c16_cartslot)
408452MACHINE_DRIVER_END
409453
410454
411455static MACHINE_DRIVER_START( c16c )
412456   MDRV_IMPORT_FROM( c16 )
457
458   MDRV_TPI6525_REMOVE("tpi6535_tpi_2")
459   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_c1551_intf)
460
413461   MDRV_IMPORT_FROM( cpu_c1551 )
414462#ifdef CPU_SYNC
415463   MDRV_QUANTUM_TIME(HZ(60))
src/mess/drivers/amiga.c
r4008r4009
2323
2424/* Components */
2525#include "sound/custom.h"
26#include "machine/6525tpi.h"
2627#include "machine/6526cia.h"
2728#include "machine/amigafdc.h"
2829#include "machine/amigakbd.h"
r4008r4009
270271   }
271272};
272273
274static const tpi6525_interface cdtv_tpi_intf =
275{
276   NULL,
277   NULL,
278   amigacd_tpi6525_portc_r,
279   NULL,
280   amigacd_tpi6525_portb_w,
281   NULL,
282   NULL,
283   NULL,
284   amigacd_tpi6525_irq
285};
286
287
273288static MACHINE_DRIVER_START( amiga_cartslot )
274289   MDRV_CARTSLOT_ADD("cart")
275290   MDRV_CARTSLOT_EXTENSION_LIST("rom,bin")
r4008r4009
316331   MDRV_CIA8520_ADD("cia_1", 0, cia_1_intf)
317332MACHINE_DRIVER_END
318333
334static MACHINE_DRIVER_START( a1000n )
335   MDRV_IMPORT_FROM(ntsc)
336   MDRV_CPU_MODIFY("main")
337   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)
338MACHINE_DRIVER_END
339
340static MACHINE_DRIVER_START( a500n )
341   MDRV_IMPORT_FROM(ntsc)
342   MDRV_IMPORT_FROM(amiga_cartslot)
343MACHINE_DRIVER_END
344
345
319346static MACHINE_DRIVER_START( cdtv )
320347   MDRV_IMPORT_FROM(ntsc)
321348   MDRV_CPU_REPLACE("main", M68000, CDTV_CLOCK_X1 / 4)
r4008r4009
332359
333360   /* cdrom */
334361   MDRV_CDROM_ADD( "cdrom" )
362   MDRV_TPI6525_ADD("tpi6525", cdtv_tpi_intf)
335363
336364   /* cia */
337365   MDRV_CIA8520_REMOVE("cia_0")
r4008r4009
340368   MDRV_CIA8520_ADD("cia_1", 0, cia_1_cdtv_intf)
341369MACHINE_DRIVER_END
342370
343static MACHINE_DRIVER_START( a1000n )
344   MDRV_IMPORT_FROM(ntsc)
345   MDRV_CPU_MODIFY("main")
346   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)   
347MACHINE_DRIVER_END
348371
349
350static MACHINE_DRIVER_START( a500n )
351   MDRV_IMPORT_FROM(ntsc)
352   MDRV_IMPORT_FROM(amiga_cartslot)
353MACHINE_DRIVER_END
354
355372static MACHINE_DRIVER_START( pal )
356373   MDRV_IMPORT_FROM(ntsc)
357374
r4008r4009
376393static MACHINE_DRIVER_START( a1000p )
377394   MDRV_IMPORT_FROM(pal)
378395   MDRV_CPU_MODIFY("main")
379   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)   
396   MDRV_CPU_PROGRAM_MAP(a1000_mem, 0)
380397MACHINE_DRIVER_END
381398
382399/***************************************************************************
r4008r4009
618635   CONFIG_DEVICE(amiga_floppy_getinfo)
619636SYSTEM_CONFIG_END
620637
638
621639/***************************************************************************
622640  Game drivers
623641***************************************************************************/
docs/messnew.txt
r4008r4009
9797
9898- Changed the SAM6883 implementation to be a device.  [Miodrag Milanovic]
9999
100- Changed the 6525 TPI implementation to be a device and added save state
101  support.  [Dirk Best]
102
100103- Various code cleanups.  [Atari Ace]
101104
102105- Fixed regression that could cause hanging when creating an image from the

Previous 15994 Revisions Next


© 1998-2018 The MESS Team