Previous 15994 Revisions Next

r3298 Friday 19th September, 2008 at 20:59:00 UTC by Wilbert Pol
Removed now unused rriot implementation
[src/mess]mess.mak
[src/mess/machine]rriot.c rriot.h

src/mess/machine/rriot.c
r3297r3298
1/**********************************************************************
2 * RIOT emulation
3 *
4 * MOS ROM RAM IO Timer 6530
5 *
6 * TODO:
7 * - test if it works ;)
8 * - change kim1 driver to use it
9 *
10 * used in chess champion mk2
11 * rockwell aim65 ?
12 **********************************************************************/
13
14#include "driver.h"
15#include "rriot.h"
16
17
18#define VERBOSE 0
19
20#define LOG(a) do { if (VERBOSE) logerror a; } while (0)
21
22/*
23  riot 6530
24
25  a0,a1 divide select (1,8,64,1024)
26  a3 set means irq on
27
28 io, timer selected
29 xx000 Port A data
30 xx001 Port A direction
31 xx010 Port B data
32 xx010 Port B direction
33
34 xx1xx timer selected, irq disable
35 x11xx t
36
37    6530
38    offset  R/W short   purpose
39    0       X   DRA     Data register A
40    1       X   DDRA    Data direction register A
41    2       X   DRB     Data register B
42    3       X   DDRB    Data direction register B
43    4       W   CNT1T   Count down from value, divide by 1, disable IRQ
44    5       W   CNT8T   Count down from value, divide by 8, disable IRQ
45    6       W   CNT64T  Count down from value, divide by 64, disable IRQ
46            R   LATCH   Read current counter value, disable IRQ
47    7       W   CNT1KT  Count down from value, divide by 1024, disable IRQ
48            R   STATUS  Read counter statzs, bit 7 = 1 means counter overflow
49    8       X   DRA     Data register A
50    9       X   DDRA    Data direction register A
51    A       X   DRB     Data register B
52    B       X   DDRB    Data direction register B
53    C       W   CNT1I   Count down from value, divide by 1, enable IRQ
54    D       W   CNT8I   Count down from value, divide by 8, enable IRQ
55    E       W   CNT64I  Count down from value, divide by 64, enable IRQ
56            R   LATCH   Read current counter value, enable IRQ
57    F       W   CNT1KI  Count down from value, divide by 1024, enable IRQ
58            R   STATUS  Read counter statzs, bit 7 = 1 means counter overflow
59*/
60
61typedef struct {
62   const RRIOT_CONFIG *config;
63   struct {
64      UINT8 in, out, ddr;
65   } port_a, port_b;
66
67   UINT8   irqen;      /* IRQ enabled ? */
68   enum { Delay1, Delay8, Delay64, Delay1024, TimerShot } state;
69   attotime shottime;
70   int   irq;
71   emu_timer *timer;    /* timer callback */
72} RRIOT;
73
74static RRIOT rriot[MAX_RRIOTS]= { {0} };
75
76static TIMER_CALLBACK(rriot_timer_cb);
77
78void rriot_init(int nr, const RRIOT_CONFIG *config)
79{
80   memset(&rriot[nr], 0, sizeof(rriot[nr]));
81   rriot[nr].config = config;
82   rriot[nr].timer = timer_alloc(rriot_timer_cb, NULL);
83
84    LOG(("RRIOT - successfully initialised\n"));
85}
86
87void rriot_reset(int nr)
88{
89   rriot[nr].port_a.ddr=0;
90   if (rriot[nr].config->port_a.output)
91      rriot[nr].config->port_a.output(nr,0xff);
92   rriot[nr].port_b.ddr=0;
93   if (rriot[nr].config->port_b.output)
94      rriot[nr].config->port_b.output(nr,0xff);
95
96   rriot[nr].irq=0;rriot[nr].irqen=0;
97   if (rriot[nr].config->irq_callback)
98      rriot[nr].config->irq_callback(nr, 0);
99}
100
101int rriot_r(int chip, int offset)
102{
103   int data = 0xff;
104
105   offset&=0xf;
106   if (!(offset&4)) { // io part of chip
107      switch( offset&3 )
108      {
109      case 0: /* Data register A */
110         if( rriot[chip].config->port_a.input )
111            data = (*rriot[chip].config->port_a.input)(chip);
112         /* mask input bits and combine with output bits */
113         data = (data & ~rriot[chip].port_a.ddr) | (rriot[chip].port_a.out & rriot[chip].port_a.ddr);
114         LOG(("rriot(%d) DRA   read : $%02x\n", chip, data));
115         break;
116      case 1: /* Data direction register A */
117         data = rriot[chip].port_a.ddr;
118         LOG(("rriot(%d) DDRA  read : $%02x\n", chip, data));
119         break;
120      case 2: /* Data register B */
121         if( rriot[chip].config->port_b.input )
122            data = (*rriot[chip].config->port_b.input)(chip);
123         /* mask input bits and combine with output bits */
124         data = (data & ~rriot[chip].port_b.ddr) | (rriot[chip].port_b.out & rriot[chip].port_b.ddr);
125//         LOG(("rriot(%d) DRB   read : $%02x\n", chip, data));
126         break;
127      case 3: /* Data direction register B */
128         data = rriot[chip].port_b.ddr;
129         LOG(("rriot(%d) DDRB  read : $%02x\n", chip, data));
130         break;
131      }
132   } else { // timer part of chip
133      switch (offset&1) {
134      case 0: /* Timer count read */
135         switch (rriot[chip].state) {
136         case Delay1:
137            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds;
138            break;
139         case Delay8:
140            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>3;
141            break;
142         case Delay64:
143            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>6;
144            break;
145         case Delay1024:
146            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>10;
147            break;
148         case TimerShot:
149            data=255- attotime_mul(attotime_sub(timer_get_time(), rriot[chip].shottime), rriot[chip].config->baseclock).seconds;
150            if (data <0 ) data=0;
151            break;
152         }
153         if( rriot[chip].irqen&&rriot[chip].irq ) /* with IRQ? */
154         {
155            if( rriot[chip].config->irq_callback )
156               (*rriot[chip].config->irq_callback)(chip, 0);
157         }
158         rriot[chip].irq=0;
159         break;
160      case 1: /* Timer status read */
161         data = rriot[chip].irq?0x80:0;
162         LOG(("riot(%d) STAT  read : $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":"    ")));
163         break;
164      }
165      // problem when restarting with read the timer!?
166      rriot[chip].irqen = (offset & 8) ? 1 : 0;
167    }
168   return data;
169}
170
171static TIMER_CALLBACK(rriot_timer_cb)
172{
173   int chip = param;
174   LOG(("rriot(%d) timer expired\n", chip));
175   rriot[chip].irq=1;
176   rriot[chip].state=TimerShot;
177   rriot[chip].shottime=timer_get_time();
178   if( rriot[chip].irqen ) /* with IRQ? */
179   {
180      if( rriot[chip].config->irq_callback )
181         (*rriot[chip].config->irq_callback)(chip, 1);
182   }
183}
184
185void rriot_w(int chip, int offset, int data)
186{
187   offset&=0xf;
188   if (!(offset&4)) {
189      switch( offset&3 )
190      {
191      case 0: /* Data register A */
192         LOG(("rriot(%d) DRA  write: $%02x\n", chip, data));
193         rriot[chip].port_a.out = data;
194         if( rriot[chip].config->port_a.output )
195            (*rriot[chip].config->port_a.output)(chip,data);
196         break;
197      case 1: /* Data direction register A */
198         LOG(("rriot(%d) DDRA  write: $%02x\n", chip, data));
199         rriot[chip].port_a.ddr = data;
200         break;
201      case 2: /* Data register B */
202//         LOG(("rriot(%d) DRB   write: $%02x\n", chip, data));
203         rriot[chip].port_b.out = data;
204         if( rriot[chip].config->port_b.output )
205            (*rriot[chip].config->port_b.output)(chip,data);
206         break;
207      case 3: /* Data direction register B */
208         LOG(("rriot(%d) DDRB  write: $%02x\n", chip, data));
209         rriot[chip].port_b.ddr = data;
210         break;
211      }
212   } else {
213      if( rriot[chip].irqen&&rriot[chip].irq ) /* with IRQ? */
214      {
215         if( rriot[chip].config->irq_callback )
216            (*rriot[chip].config->irq_callback)(chip, 0);
217      }
218      rriot[chip].irqen = (offset & 8) ? 1 : 0;
219      rriot[chip].irq =0;
220
221      switch (offset&3) {
222      case 0: /* Timer 1 start */
223         LOG(("rriot(%d) TMR1  write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
224         timer_adjust_oneshot(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) ), chip);
225         rriot[chip].state=Delay1;
226         break;
227      case 1: /* Timer 8 start */
228         LOG(("rriot(%d) TMR8  write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
229         timer_adjust_oneshot(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 8 ), chip);
230         rriot[chip].state=Delay8;
231         break;
232      case 2: /* Timer 64 start */
233         LOG(("rriot(%d) TMR64 write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
234//         LOG(("rriot(%d) TMR64 write: time is $%f\n", chip, (double)(64.0 * (data + 1) / rriot[chip].clock)));
235         timer_adjust_oneshot(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 64 ), chip);
236         rriot[chip].state=Delay64;
237         break;
238      case 3: /* Timer 1024 start */
239         LOG(("rriot(%d) TMR1K write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
240         timer_adjust_oneshot(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 1024 ), chip);
241         rriot[chip].state=Delay1024;
242         break;
243      }
244    }
245}
246
247static int rriot_a_r(int chip)
248{
249   int data;
250   if (rriot[chip].config->port_a.input)
251      data = rriot[chip].config->port_a.input(chip);
252   else
253      data = 0xff;
254   data &= ~rriot[chip].port_a.ddr;
255   data |= (rriot[chip].port_a.ddr&rriot[chip].port_a.out);
256   return data;
257}
258
259static int rriot_b_r(int chip)
260{
261   int data;
262   if (rriot[chip].config->port_b.input)
263      data = rriot[chip].config->port_b.input(chip);
264   else
265      data = 0xff;
266   data &= ~rriot[chip].port_b.ddr;
267   data |= (rriot[chip].port_b.ddr&rriot[chip].port_b.out);
268   return data;
269}
270
271static void rriot_a_w(int chip, int data)
272{
273#if 0
274   rriot[chip].port_a.in = data;
275#endif
276}
277
278static void rriot_b_w(int chip, int data)
279{
280
281}
282
283 READ8_HANDLER ( rriot_0_r ) { return rriot_r(0,offset); }
284WRITE8_HANDLER ( rriot_0_w ) { rriot_w(0,offset,data); }
285 READ8_HANDLER ( rriot_1_r ) { return rriot_r(1,offset); }
286WRITE8_HANDLER ( rriot_1_w ) { rriot_w(1,offset,data); }
287 READ8_HANDLER ( rriot_2_r ) { return rriot_r(2,offset); }
288WRITE8_HANDLER ( rriot_2_w ) { rriot_w(2,offset,data); }
289 READ8_HANDLER ( rriot_3_r ) { return rriot_r(3,offset); }
290WRITE8_HANDLER ( rriot_3_w ) { rriot_w(3,offset,data); }
291
292 READ8_HANDLER( rriot_0_a_r ) { return rriot_a_r(0); }
293 READ8_HANDLER( rriot_1_a_r ) { return rriot_a_r(1); }
294 READ8_HANDLER( rriot_2_a_r ) { return rriot_a_r(2); }
295 READ8_HANDLER( rriot_3_a_r ) { return rriot_a_r(3); }
296
297 READ8_HANDLER( rriot_0_b_r ) { return rriot_b_r(0); }
298 READ8_HANDLER( rriot_1_b_r ) { return rriot_b_r(1); }
299 READ8_HANDLER( rriot_2_b_r ) { return rriot_b_r(2); }
300 READ8_HANDLER( rriot_3_b_r ) { return rriot_b_r(3); }
301
302WRITE8_HANDLER( rriot_0_a_w ) { rriot_a_w(0,data); }
303WRITE8_HANDLER( rriot_1_a_w ) { rriot_a_w(1,data); }
304WRITE8_HANDLER( rriot_2_a_w ) { rriot_a_w(2,data); }
305WRITE8_HANDLER( rriot_3_a_w ) { rriot_a_w(3,data); }
306
307WRITE8_HANDLER( rriot_0_b_w ) { rriot_b_w(0,data); }
308WRITE8_HANDLER( rriot_1_b_w ) { rriot_b_w(1,data); }
309WRITE8_HANDLER( rriot_2_b_w ) { rriot_b_w(2,data); }
310WRITE8_HANDLER( rriot_3_b_w ) { rriot_b_w(3,data); }
311
312
src/mess/machine/rriot.h
r3297r3298
1#ifndef RIOT_H
2#define RIOT_H
3
4/* mos rom ram io timer 6530 */
5
6/* ram and rom areas are not handled in this rriot compoment */
7
8/*
9internal 64 byte ram
10internal 1024 byte rom
11inputs and output
12timer
13interrupt logic
14logic to connect up to 7 6530 without additional address decoding logic
15
161kb rom selection
17a0..a9,
18rs0, cs1, cs2 mask programmed!
19
2064byte ram selection
21a0..a5
22rs0, cs1, cs2, a6, a7, a8, a9 mask programmed!
23
24io, timer selection
25a0..a3 (a4,a5 don't care)
26rs0, cs1, cs2, a6, a7, a8, a9 mask programmed!
27(a2=0 io, a3 don't care)
28 a2=1 timer, a3 interrupt enable)
29
30standard configurations! CS2(a12) CS1(a11) rs0(a10)
31chip subtype 1: rom 0x0400, ram 0x000, io 0x200
32chip subtype 2: rom 0x0800, ram 0x040, io 0x240
33chip subtype 3: rom 0x0c00, ram 0x080, io 0x280
34chip subtype 4: rom 0x1000, ram 0x0c0, io 0x2c0
35chip subtype 5: rom 0x1400, ram 0x100, io 0x300
36chip subtype 6: rom 0x1800, ram 0x140, io 0x340
37chip subtype 7: rom 0x1c00, ram 0x180, io 0x380
38
395V    1 40 PA1
40PA0   2 39 PA2
41CLK   3 38 PA3
42RS0   4 37 PA4
43A9    5 36 PA5
44A8    6 35 PA6
45A7    7 34 PA7
46A6    8 33 D0
47R /W  9 32 D1
48A5   10 31 D2
49A4   11 30 D3
50A3   12 29 D4
51A2   13 28 D5
52A1   14 27 D6
53A0   15 26 D7
54/RES 16 25 PB0
55PB7  17 24 PB1
56PB6  18 23 PB2
57PB5  19 22 PB3
58GND  20 21 PB4
59
60D0..7 data bus
61A0..9 address bus
62R /W  read or /write
63RS0 rom select
64
65
66/RES reset
67CLK (phi2) clock for timer
68PA0..7, PB0..8 input or output (software selectable)
69
70PB7 could be configured as /IRQ line
71PB6,PB5 could be configured as CS1,CS2 (mask programmed with the rom!)
72
73dumping suggestions
74wire an adapter for an 2764 eprom, so it is readable with many eprom burners
75read the complete 8kbyte data
76extract the positions from the dump
77
78*/
79
80
81/*
82mos 6532
83chip also contains 128 bytes ram (own chip select line)
84no rom
85separate irq output
86some significant differences, so unique component
87*/
88
89#ifdef __cplusplus
90extern "C" {
91#endif
92
93#define MAX_RRIOTS   4
94
95typedef struct {
96   int baseclock;
97   struct {
98      int (*input)(int chip);
99      void (*output)(int chip, int value);
100   } port_a, port_b;
101   void (*irq_callback)(int chip, int level);
102} RRIOT_CONFIG;
103
104/* This has to be called from a driver at startup */
105void rriot_init(int nr, const RRIOT_CONFIG *riot);
106
107int rriot_r(int chip, int offs);
108void rriot_w(int chip, int offs, int data);
109
110void rriot_reset(int nr);
111
112 READ8_HANDLER  ( rriot_0_r );
113WRITE8_HANDLER ( rriot_0_w );
114 READ8_HANDLER  ( rriot_1_r );
115WRITE8_HANDLER ( rriot_1_w );
116 READ8_HANDLER  ( rriot_2_r );
117WRITE8_HANDLER ( rriot_2_w );
118 READ8_HANDLER  ( rriot_3_r );
119WRITE8_HANDLER ( rriot_3_w );
120
121 READ8_HANDLER( rriot_0_a_r );
122 READ8_HANDLER( rriot_1_a_r );
123 READ8_HANDLER( rriot_2_a_r );
124 READ8_HANDLER( rriot_3_a_r );
125
126WRITE8_HANDLER( rriot_0_a_w );
127WRITE8_HANDLER( rriot_1_a_w );
128WRITE8_HANDLER( rriot_2_a_w );
129WRITE8_HANDLER( rriot_3_a_w );
130
131 READ8_HANDLER( rriot_0_b_r );
132 READ8_HANDLER( rriot_1_b_r );
133 READ8_HANDLER( rriot_2_b_r );
134 READ8_HANDLER( rriot_3_b_r );
135
136WRITE8_HANDLER( rriot_0_b_w );
137WRITE8_HANDLER( rriot_1_b_w );
138WRITE8_HANDLER( rriot_2_b_w );
139WRITE8_HANDLER( rriot_3_b_w );
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif
src/mess/mess.mak
r3297r3298
492492   $(MESS_MACHINE)/msm8251.o  \
493493   $(MESS_MACHINE)/tc8521.o   \
494494   $(MESS_VIDEO)/crtc6845.o   \
495   $(MESS_MACHINE)/rriot.o    \
496495   $(MESS_MACHINE)/74145.o    \
497496   $(MESS_MACHINE)/ins8250.o \
498497   $(MESS_MACHINE)/pc_mouse.o \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team