Previous 15994 Revisions Next

r14516 Saturday 18th February, 2012 at 19:07:36 UTC by Michael Zapf
ti99: obsolete files (no whatsnew)
[src/mess/drivers]ti99_8.c
[src/mess/machine/ti99]crubus.c crubus.h

src/mess/machine/ti99/crubus.c
r14515r14516
1/*
2    TI-99 CRU Bus
3*/
4
5#include "emu.h"
6#include "crubus.h"
7
8#define MAXCRU 20
9
10typedef struct _crubus_dev
11{
12   /* The device. */
13   device_t      *device;
14
15   /* Read access. */
16   cru_read_function   cru_read;
17
18   /* Write access. */
19   cru_write_function   cru_write;
20
21   /* Address bits involved. The CRU makes use of the address bus. */
22   UINT16         address_mask;
23
24   /* Value of the address bits which are involved for selecting for read. */
25   UINT16         select;
26
27} crubus_dev;
28
29typedef struct _crubus_state
30{
31   crubus_dev         component[MAXCRU];
32   /* Management function */
33   int devindex;
34
35} crubus_state;
36
37INLINE crubus_state *get_safe_token(device_t *device)
38{
39   assert(device != NULL);
40   assert(device->type() == CRUBUS);
41
42   return (crubus_state *)downcast<legacy_device_base *>(device)->token();
43}
44
45static void cru_mount_device(device_t *device, device_t *crudev, UINT16 address_mask, UINT16 address_bits, cru_read_function cruread, cru_write_function cruwrite)
46{
47   crubus_state *crubus = get_safe_token(device);
48   int index = crubus->devindex++;
49//  logerror("register cru device %lx\n", (long unsigned int)crudev);
50   if (index < MAXCRU)
51   {
52      if (crubus->component[index].device == NULL)
53      {
54         crubus->component[index].device = crudev;
55         crubus->component[index].cru_read = cruread;
56         crubus->component[index].cru_write = cruwrite;
57         crubus->component[index].address_mask = address_mask;
58         crubus->component[index].select = address_bits;
59      }
60   }
61}
62
63/***************************************************************************
64    ACCESSOR FUNCTIONS
65***************************************************************************/
66
67READ8_DEVICE_HANDLER( ti99_crubus_r )
68{
69   crubus_state *crubus = get_safe_token(device);
70   UINT8 reply = 0;
71
72   for (int i=0; i < MAXCRU; i++)
73   {
74      crubus_dev *crudev = &crubus->component[i];
75      if (crubus->component[i].device != NULL)
76      {
77         if (crudev->cru_read != NULL)
78         {
79            if (((offset<<4) & crudev->address_mask)==crudev->select)
80            {
81               // CRU read is implemented as an 8-bit read access.
82               // We shift the address for the sake of readability
83               // Each read access returns 8 consecutive CRU bits
84               // Shift 4 = addr*8*2
85               crudev->cru_read(crudev->device, offset<<4, &reply);
86            }
87         }
88      }
89   }
90//  printf("cru read %04x = %02x\n", offset<<4, reply);
91
92   return reply;
93}
94
95WRITE8_DEVICE_HANDLER( ti99_crubus_w )
96{
97   crubus_state *crubus = get_safe_token(device);
98
99//  printf("cru write %04x = %02x\n", offset<<1, data);
100   for (int i=0; i < MAXCRU; i++)
101   {
102      crubus_dev *crudev = &crubus->component[i];
103      if (crubus->component[i].device != NULL)
104      {
105         if (crudev->cru_write != NULL)
106         {
107            if (((offset<<1) & crudev->address_mask)==crudev->select)
108            {
109               // CRU write is implemented as a 1-bit access
110               crudev->cru_write(crudev->device, offset<<1, data);
111            }
112         }
113      }
114   }
115}
116
117/***************************************************************************
118    DEVICE FUNCTIONS
119***************************************************************************/
120
121static DEVICE_START( crubus )
122{
123   int i = 0;
124   int done=FALSE;
125   cruconf_device *cons = (cruconf_device*)device->static_config();
126   crubus_state *crubus = get_safe_token(device);
127
128   logerror("start CRU bus\n");
129
130   crubus->devindex = 0;
131
132   while (!done)
133   {
134      if (cons[i].name != NULL)
135      {
136         device_t *dev = device->machine().device(cons[i].name);
137         if (dev!=NULL)
138            cru_mount_device(device, dev, cons[i].address_mask, cons[i].select_pattern, cons[i].read, cons[i].write);
139         else
140            logerror("ti99_crubus: Device %s not found.\n", cons[i].name);
141      }
142      else done=TRUE;
143      i++;
144   }
145}
146
147static DEVICE_STOP( crubus )
148{
149   logerror("stop CRU bus\n");
150}
151
152static DEVICE_RESET( crubus )
153{
154   logerror("reset CRU bus\n");
155}
156
157static const char DEVTEMPLATE_SOURCE[] = __FILE__;
158
159#define DEVTEMPLATE_ID(p,s)             p##crubus##s
160#define DEVTEMPLATE_FEATURES            DT_HAS_START | DT_HAS_STOP | DT_HAS_RESET
161#define DEVTEMPLATE_NAME                "TI99 CRU bus system"
162#define DEVTEMPLATE_FAMILY              "Internal devices"
163#include "devtempl.h"
164
165DEFINE_LEGACY_DEVICE( CRUBUS, crubus );
src/mess/machine/ti99/crubus.h
r14515r14516
1#ifndef __CRUBUS__
2#define __CRUBUS__
3/*
4    TI-99 CRU Bus
5    header file for crubus
6*/
7
8typedef void (*cru_read_function)(device_t *device, offs_t offset, UINT8 *value);
9typedef void (*cru_write_function)(device_t *device, offs_t offset, UINT8 value);
10
11typedef struct _cruconf_device
12{
13   const char            *name;
14   UINT16               address_mask;
15   UINT16               select_pattern;
16   cru_read_function      read;
17   cru_write_function      write;
18} cruconf_device;
19
20READ8_DEVICE_HANDLER( ti99_crubus_r );
21WRITE8_DEVICE_HANDLER( ti99_crubus_w );
22
23/* device interface */
24DECLARE_LEGACY_DEVICE( CRUBUS, crubus );
25
26#define MCFG_CRUBUS_ADD(_tag, _devices)         \
27   MCFG_DEVICE_ADD(_tag, CRUBUS, 0) \
28   MCFG_DEVICE_CONFIG( _devices )
29
30#endif
src/mess/drivers/ti99_8.c
r14515r14516
211211#include "machine/ti99/speech8.h"
212212
213213#include "machine/ti99/peribox.h"
214#include "machine/ti99/crubus.h"
215214#include "machine/ti99/mapper8.h"
216215#include "machine/ti99/grom.h"
217216#include "machine/ti99/gromport.h"

Previous 15994 Revisions Next


© 1998-2018 The MESS Team