Previous 15994 Revisions Next

r11027 Friday 1st April, 2011 at 05:35:14 UTC by Curt Coder
[TMC2000E] Modernized driver.
[src/mess/drivers]tmc2000e.c
[src/mess/includes]tmc2000e.h

src/mess/includes/tmc2000e.h
r11026r11027
1#pragma once
2
13#ifndef __TMC2000E__
24#define __TMC2000E__
35
6#define ADDRESS_MAP_MODERN
7
8#include "emu.h"
9#include "cpu/cosmac/cosmac.h"
10#include "formats/basicdsk.h"
11#include "imagedev/cassette.h"
12#include "imagedev/flopdrv.h"
13#include "imagedev/printer.h"
14#include "machine/rescap.h"
15#include "machine/ram.h"
16#include "sound/cdp1864.h"
17
418#define SCREEN_TAG      "screen"
519#define CDP1802_TAG      "cdp1802"
620#define CDP1864_TAG      "cdp1864"
r11026r11027
1226{
1327public:
1428   tmc2000e_state(running_machine &machine, const driver_device_config_base &config)
15      : driver_device(machine, config) { }
29      : driver_device(machine, config),
30        m_maincpu(*this, CDP1802_TAG),
31        m_cti(*this, CDP1864_TAG),
32        m_cassette(*this, CASSETTE_TAG)
33   { }
1634
35   required_device<cpu_device> m_maincpu;
36   required_device<device_t> m_cti;
37   required_device<device_t> m_cassette;
38
39   virtual void machine_start();
40   virtual void machine_reset();
41
42   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
43   
44   DECLARE_READ8_MEMBER( vismac_r );
45   DECLARE_WRITE8_MEMBER( vismac_w );
46   DECLARE_READ8_MEMBER( floppy_r );
47   DECLARE_WRITE8_MEMBER( floppy_w );
48   DECLARE_READ8_MEMBER( ascii_keyboard_r );
49   DECLARE_READ8_MEMBER( io_r );
50   DECLARE_WRITE8_MEMBER( io_w );
51   DECLARE_WRITE8_MEMBER( io_select_w );
52   DECLARE_WRITE8_MEMBER( keyboard_latch_w );
53   DECLARE_READ_LINE_MEMBER( rdata_r );
54   DECLARE_READ_LINE_MEMBER( bdata_r );
55   DECLARE_READ_LINE_MEMBER( gdata_r );
56   DECLARE_READ_LINE_MEMBER( clear_r );
57   DECLARE_READ_LINE_MEMBER( ef2_r );
58   DECLARE_READ_LINE_MEMBER( ef3_r );
59   DECLARE_WRITE_LINE_MEMBER( q_w );
60   DECLARE_WRITE8_MEMBER( dma_w );
61
1762   /* video state */
18   int cdp1864_efx;      /* EFx */
19   UINT8 *colorram;      /* color memory */
20   UINT8 color;
63   int m_cdp1864_efx;      /* EFx */
64   UINT8 *m_colorram;      /* color memory */
65   UINT8 m_color;
2166
2267   /* keyboard state */
23   int keylatch;         /* key latch */
24   int reset;            /* reset activated */
25
26   /* devices */
27   device_t *cdp1864;
28   device_t *cassette;
68   int m_keylatch;         /* key latch */
69   int m_reset;         /* reset activated */
2970};
3071
3172#endif
src/mess/drivers/tmc2000e.c
r11026r11027
2929
3030*/
3131
32#include "emu.h"
3332#include "includes/tmc2000e.h"
34#include "cpu/cosmac/cosmac.h"
35#include "imagedev/printer.h"
36#include "imagedev/flopdrv.h"
37#include "formats/basicdsk.h"
38#include "imagedev/cassette.h"
39#include "sound/cdp1864.h"
40#include "machine/rescap.h"
41#include "machine/ram.h"
4233
4334/* Read/Write Handlers */
4435
45static READ8_HANDLER( vismac_r )
36READ8_MEMBER( tmc2000e_state::vismac_r )
4637{
4738   return 0;
4839}
4940
50static WRITE8_HANDLER( vismac_w )
41WRITE8_MEMBER( tmc2000e_state::vismac_w )
5142{
5243}
5344
54static READ8_HANDLER( floppy_r )
45READ8_MEMBER( tmc2000e_state::floppy_r )
5546{
5647   return 0;
5748}
5849
59static WRITE8_HANDLER( floppy_w )
50WRITE8_MEMBER( tmc2000e_state::floppy_w )
6051{
6152}
6253
63static READ8_HANDLER( ascii_keyboard_r )
54READ8_MEMBER( tmc2000e_state::ascii_keyboard_r )
6455{
6556   return 0;
6657}
6758
68static READ8_HANDLER( io_r )
59READ8_MEMBER( tmc2000e_state::io_r )
6960{
7061   return 0;
7162}
7263
73static WRITE8_HANDLER( io_w )
64WRITE8_MEMBER( tmc2000e_state::io_w )
7465{
7566}
7667
77static WRITE8_HANDLER( io_select_w )
68WRITE8_MEMBER( tmc2000e_state::io_select_w )
7869{
7970}
8071
81static WRITE8_HANDLER( keyboard_latch_w )
72WRITE8_MEMBER( tmc2000e_state::keyboard_latch_w )
8273{
83   tmc2000e_state *state = space->machine().driver_data<tmc2000e_state>();
84
85   state->keylatch = data;
74   m_keylatch = data;
8675}
8776
8877/* Memory Maps */
8978
90static ADDRESS_MAP_START( tmc2000e_map, AS_PROGRAM, 8 )
79static ADDRESS_MAP_START( tmc2000e_map, AS_PROGRAM, 8, tmc2000e_state )
9180   AM_RANGE(0x0000, 0x1fff) AM_RAM
9281   AM_RANGE(0xc000, 0xdfff) AM_ROM
93   AM_RANGE(0xfc00, 0xffff) AM_WRITEONLY AM_BASE_MEMBER(tmc2000e_state, colorram)
82   AM_RANGE(0xfc00, 0xffff) AM_WRITEONLY AM_BASE(m_colorram)
9483ADDRESS_MAP_END
9584
96static ADDRESS_MAP_START( tmc2000e_io_map, AS_IO, 8 )
97   AM_RANGE(0x01, 0x01) AM_DEVWRITE(CDP1864_TAG, cdp1864_tone_latch_w)
98   AM_RANGE(0x02, 0x02) AM_DEVWRITE(CDP1864_TAG, cdp1864_step_bgcolor_w)
85static ADDRESS_MAP_START( tmc2000e_io_map, AS_IO, 8, tmc2000e_state )
86   AM_RANGE(0x01, 0x01) AM_DEVWRITE_LEGACY(CDP1864_TAG, cdp1864_tone_latch_w)
87   AM_RANGE(0x02, 0x02) AM_DEVWRITE_LEGACY(CDP1864_TAG, cdp1864_step_bgcolor_w)
9988   AM_RANGE(0x03, 0x03) AM_READWRITE(ascii_keyboard_r, keyboard_latch_w)
10089   AM_RANGE(0x04, 0x04) AM_READWRITE(io_r, io_w)
10190   AM_RANGE(0x05, 0x05) AM_READWRITE(vismac_r, vismac_w)
r11026r11027
126115
127116/* Video */
128117
129static READ_LINE_DEVICE_HANDLER( rdata_r )
118READ_LINE_MEMBER( tmc2000e_state::rdata_r )
130119{
131   tmc2000e_state *state = device->machine().driver_data<tmc2000e_state>();
132
133   return BIT(state->color, 2);
120   return BIT(m_color, 2);
134121}
135122
136static READ_LINE_DEVICE_HANDLER( bdata_r )
123READ_LINE_MEMBER( tmc2000e_state::bdata_r )
137124{
138   tmc2000e_state *state = device->machine().driver_data<tmc2000e_state>();
139
140   return BIT(state->color, 1);
125   return BIT(m_color, 1);
141126}
142127
143static READ_LINE_DEVICE_HANDLER( gdata_r )
128READ_LINE_MEMBER( tmc2000e_state::gdata_r )
144129{
145   tmc2000e_state *state = device->machine().driver_data<tmc2000e_state>();
146
147   return BIT(state->color, 0);
130   return BIT(m_color, 0);
148131}
149132
150133static CDP1864_INTERFACE( tmc2000e_cdp1864_intf )
r11026r11027
152135   CDP1802_TAG,
153136   SCREEN_TAG,
154137   CDP1864_INTERLACED,
155   DEVCB_LINE(rdata_r),
156   DEVCB_LINE(bdata_r),
157   DEVCB_LINE(gdata_r),
138   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, rdata_r),
139   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, bdata_r),
140   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, gdata_r),
158141   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
159142   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
160143   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1),
r11026r11027
164147   RES_K(4.7)   // unverified
165148};
166149
167static SCREEN_UPDATE( tmc2000e )
150bool tmc2000e_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
168151{
169   tmc2000e_state *state = screen->machine().driver_data<tmc2000e_state>();
152   cdp1864_update(m_cti, &bitmap, &cliprect);
170153
171   cdp1864_update(state->cdp1864, bitmap, cliprect);
172
173154   return 0;
174155}
175156
176157/* CDP1802 Interface */
177158
178static READ_LINE_DEVICE_HANDLER( clear_r )
159READ_LINE_MEMBER( tmc2000e_state::clear_r )
179160{
180   return BIT(input_port_read(device->machine(), "RUN"), 0);
161   return BIT(input_port_read(m_machine, "RUN"), 0);
181162}
182163
183static READ_LINE_DEVICE_HANDLER( ef2_r )
164READ_LINE_MEMBER( tmc2000e_state::ef2_r )
184165{
185   return cassette_input(device) < 0;
166   return cassette_input(m_cassette) < 0;
186167}
187168
188static READ_LINE_DEVICE_HANDLER( ef3_r )
169READ_LINE_MEMBER( tmc2000e_state::ef3_r )
189170{
190   tmc2000e_state *state = device->machine().driver_data<tmc2000e_state>();
191171   static const char *const keynames[] = { "IN0", "IN1", "IN2", "IN3", "IN4", "IN5", "IN6", "IN7" };
192   UINT8 data = ~input_port_read(device->machine(), keynames[state->keylatch / 8]);
172   UINT8 data = ~input_port_read(m_machine, keynames[m_keylatch / 8]);
193173
194   return BIT(data, state->keylatch % 8);
174   return BIT(data, m_keylatch % 8);
195175}
196176
197static WRITE_LINE_DEVICE_HANDLER( tmc2000e_q_w )
177WRITE_LINE_MEMBER( tmc2000e_state::q_w )
198178{
199   tmc2000e_state *driver_state = device->machine().driver_data<tmc2000e_state>();
200
201179   // turn CDP1864 sound generator on/off
202180
203   cdp1864_aoe_w(driver_state->cdp1864, state);
181   cdp1864_aoe_w(m_cti, state);
204182
205183   // set Q led status
206184
207   set_led_status(device->machine(), 1, state);
185   set_led_status(m_machine, 1, state);
208186
209187   // tape out
210188
211   cassette_output(driver_state->cassette, state ? -1.0 : +1.0);
189   cassette_output(m_cassette, state ? -1.0 : +1.0);
212190
213191   // floppy control (FDC-6)
214192}
215193
216static WRITE8_DEVICE_HANDLER( tmc2000e_dma_w )
194WRITE8_MEMBER( tmc2000e_state::dma_w )
217195{
218   tmc2000e_state *state = device->machine().driver_data<tmc2000e_state>();
196   m_color = (m_colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
219197
220   state->color = (state->colorram[offset & 0x3ff]) & 0x07; // 0x04 = R, 0x02 = B, 0x01 = G
221
222   cdp1864_con_w(state->cdp1864, 0); // HACK
223   cdp1864_dma_w(state->cdp1864, offset, data);
198   cdp1864_con_w(m_cti, 0); // HACK
199   cdp1864_dma_w(m_cti, offset, data);
224200}
225201
226202static COSMAC_INTERFACE( tmc2000e_config )
227203{
228204   DEVCB_LINE_VCC,
229   DEVCB_LINE(clear_r),
205   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, clear_r),
230206   DEVCB_NULL,
231   DEVCB_DEVICE_LINE(CASSETTE_TAG, ef2_r),
232   DEVCB_LINE(ef3_r),
207   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, ef2_r),
208   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, ef3_r),
233209   DEVCB_NULL,
234   DEVCB_LINE(tmc2000e_q_w),
210   DEVCB_DRIVER_LINE_MEMBER(tmc2000e_state, q_w),
235211   DEVCB_NULL,
236   DEVCB_HANDLER(tmc2000e_dma_w),
212   DEVCB_DRIVER_MEMBER(tmc2000e_state, dma_w),
237213   NULL,
238214   DEVCB_NULL,
239215   DEVCB_NULL
r11026r11027
241217
242218/* Machine Initialization */
243219
244static MACHINE_START( tmc2000e )
220void tmc2000e_state::machine_start()
245221{
246   tmc2000e_state *state = machine.driver_data<tmc2000e_state>();
247
248222   /* allocate color RAM */
249   state->colorram = auto_alloc_array(machine, UINT8, TMC2000E_COLORRAM_SIZE);
223   m_colorram = auto_alloc_array(m_machine, UINT8, TMC2000E_COLORRAM_SIZE);
250224
251   /* find devices */
252   state->cdp1864 = machine.device(CDP1864_TAG);
253   state->cassette = machine.device(CASSETTE_TAG);
254
255225   /* register for state saving */
256   state->save_pointer(NAME(state->colorram), TMC2000E_COLORRAM_SIZE);
257   state->save_item(NAME(state->cdp1864_efx));
258   state->save_item(NAME(state->keylatch));
226   save_pointer(NAME(m_colorram), TMC2000E_COLORRAM_SIZE);
227   save_item(NAME(m_cdp1864_efx));
228   save_item(NAME(m_keylatch));
259229}
260230
261static MACHINE_RESET( tmc2000e )
231void tmc2000e_state::machine_reset()
262232{
263   tmc2000e_state *state = machine.driver_data<tmc2000e_state>();
233   m_cti->reset();
264234
265   state->cdp1864->reset();
266
267235   // reset program counter to 0xc000
268236}
269237
r11026r11027
296264   MCFG_CPU_IO_MAP(tmc2000e_io_map)
297265   MCFG_CPU_CONFIG(tmc2000e_config)
298266
299   MCFG_MACHINE_START(tmc2000e)
300   MCFG_MACHINE_RESET(tmc2000e)
301
302267   // video hardware
303268   MCFG_CDP1864_SCREEN_ADD(SCREEN_TAG, XTAL_1_75MHz)
304   MCFG_SCREEN_UPDATE(tmc2000e)
305269
306270   MCFG_PALETTE_LENGTH(8)
307271

Previous 15994 Revisions Next


© 1998-2018 The MESS Team