Previous 15994 Revisions Next

r5073 Wednesday 24th June, 2009 at 07:28:04 UTC by Dirk Best
[EINSTEIN] Fixed line endings
[src/mess/drivers]einstein.c

src/mess/drivers/einstein.c
r5072r5073
1/******************************************************************************
2 
3    Tatung Einstein
4    system driver
5 
6 
7    TMS9129 VDP Graphics
8        16k ram
9 
10    Z80 CPU (4 MHz)
11 
12    Z80 CTC (4 MHz)
13        channel 0 is serial transmit clock
14        channel 1 is serial receive clock
15        trigger for channel 0,1 and 2 is a 2 MHz clock
16        trigger for channel 3 is the terminal count of channel 2
17 
18    Intel 8251 Serial (2 MHz clock?)
19 
20    WD1770 Floppy Disc controller
21        density is fixed, 4 drives and double sided supported
22 
23    AY-3-8910 PSG (2 MHz)
24        port A and port B are connected to the keyboard. Port A is keyboard
25        line select, Port B is data.
26 
27    printer connected to port A of PIO. /ACK from printer is connected to /ASTB.
28    D7-D0 of PIO port A is printer data lines.
29    ARDY of PIO is connected to /STROBE on printer.
30 
31    user port is port B of PIO
32    keyboard connected to port A and port B of PSG
33 
34    TODO:
35    - The ADC is not emulated!
36    - printer emulation needs checking!
37 
38    Many thanks to Chris Coxall for the schematics of the TC-01, the dump of the
39    system rom and a dump of a Xtal boot disc.
40 
41    Many thanks to Andrew Dunipace for his help with the 80-column card
42    and Speculator hardware (Spectrum emulator).
43 
44    Kevin Thacker [MESS driver]
45 
46 
47 
48 ******************************************************************************/
49 
50#include "driver.h"
51#include "machine/z80ctc.h"
52#include "machine/z80pio.h"
53#include "machine/z80sio.h"
54#include "video/tms9928a.h"
55#include "cpu/z80/z80.h"
56#include "cpu/z80/z80daisy.h"
57#include "machine/wd17xx.h"
58#include "machine/ctronics.h"
59#include "machine/msm8251.h"
60#include "devices/dsk.h"
61#include "devices/basicdsk.h"
62#include "sound/ay8910.h"
63#include "video/mc6845.h"
64#include "einstei2.lh"
65 
66 
67/***************************************************************************
68    CONSTANTS
69***************************************************************************/
70 
71/* xtals */
72#define XTAL_X001  XTAL_10_738635MHz
73#define XTAL_X002  XTAL_8MHz
74 
75/* integrated circuits */
76#define IC_I001  "i001"  /* Z8400A */
77#define IC_I030  "i030"  /* AY-3-8910 */
78#define IC_I038  "i038"  /* TMM9129 */
79#define IC_I042  "i042"  /* WD1770-PH */
80#define IC_I050  "i050"  /* ADC0844CCN */
81#define IC_I058  "i058"  /* Z8430A */
82#define IC_I060  "i060"  /* uPD8251A */
83#define IC_I063  "i063"  /* Z8420A */
84 
85/* interrupt sources */
86#define EINSTEIN_KEY_INT   (1<<0)
87#define EINSTEIN_ADC_INT   (1<<1)
88#define EINSTEIN_FIRE_INT  (1<<2)
89 
90 
91/***************************************************************************
92    TYPE DEFINITIONS
93***************************************************************************/
94 
95typedef struct _einstein_state einstein_state;
96struct _einstein_state
97{
98   const device_config *color_screen;
99   const device_config *ctc;
100 
101   int rom_enabled;
102   int interrupt;
103   int interrupt_mask;
104   int ctc_trigger;
105 
106   /* keyboard */
107   UINT8 keyboard_line;
108   UINT8 keyboard_data;
109 
110   /* 80 column device */
111   const device_config *mc6845;
112   const device_config *crtc_screen;
113   UINT8 *crtc_ram;
114};
115 
116 
117/***************************************************************************
118    80 COLUMN DEVICE
119***************************************************************************/
120 
121/* lower 3 bits of address define a 256-byte "row".
122 * upper 8 bits define the offset in the row,
123 * data bits define data to write
124 */
125static WRITE8_HANDLER( einstein_80col_ram_w )
126{
127   einstein_state *einstein = space->machine->driver_data;
128   einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)] = data;
129}
130 
131static READ8_HANDLER( einstein_80col_ram_r )
132{
133   einstein_state *einstein = space->machine->driver_data;
134   return einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)];
135}
136 
137/* TODO: Verify implementation */
138static MC6845_UPDATE_ROW( einstein_6845_update_row )
139{
140   einstein_state *einstein = device->machine->driver_data;
141   UINT8 *data = memory_region(device->machine, "gfx1");
142   UINT8 char_code, data_byte;
143   int i, x;
144 
145   for (i = 0, x = 0; i < x_count; i++, x += 8)
146   {
147      char_code = einstein->crtc_ram[(ma + i) & 0x07ff];
148      data_byte = data[(char_code << 3) + ra];
149 
150      *BITMAP_ADDR16(bitmap, y, x + 0) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 7);
151      *BITMAP_ADDR16(bitmap, y, x + 1) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 6);
152      *BITMAP_ADDR16(bitmap, y, x + 2) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 5);
153      *BITMAP_ADDR16(bitmap, y, x + 3) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 4);
154      *BITMAP_ADDR16(bitmap, y, x + 4) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 3);
155      *BITMAP_ADDR16(bitmap, y, x + 5) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 2);
156      *BITMAP_ADDR16(bitmap, y, x + 6) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 1);
157      *BITMAP_ADDR16(bitmap, y, x + 7) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 0);
158   }
159}
160 
161/* bit 0 - vsync state?
162 * bit 1 - 0 = 40 column mode (color monitor), 1 = 80 column mode (b/w monitor)
1/******************************************************************************
2
3    Tatung Einstein
4    system driver
5
6
7    TMS9129 VDP Graphics
8        16k ram
9
10    Z80 CPU (4 MHz)
11
12    Z80 CTC (4 MHz)
13        channel 0 is serial transmit clock
14        channel 1 is serial receive clock
15        trigger for channel 0,1 and 2 is a 2 MHz clock
16        trigger for channel 3 is the terminal count of channel 2
17
18    Intel 8251 Serial (2 MHz clock?)
19
20    WD1770 Floppy Disc controller
21        density is fixed, 4 drives and double sided supported
22
23    AY-3-8910 PSG (2 MHz)
24        port A and port B are connected to the keyboard. Port A is keyboard
25        line select, Port B is data.
26
27    printer connected to port A of PIO. /ACK from printer is connected to /ASTB.
28    D7-D0 of PIO port A is printer data lines.
29    ARDY of PIO is connected to /STROBE on printer.
30
31    user port is port B of PIO
32    keyboard connected to port A and port B of PSG
33
34    TODO:
35    - The ADC is not emulated!
36    - printer emulation needs checking!
37
38    Many thanks to Chris Coxall for the schematics of the TC-01, the dump of the
39    system rom and a dump of a Xtal boot disc.
40
41    Many thanks to Andrew Dunipace for his help with the 80-column card
42    and Speculator hardware (Spectrum emulator).
43
44    Kevin Thacker [MESS driver]
45
46
47
48 ******************************************************************************/
49
50#include "driver.h"
51#include "machine/z80ctc.h"
52#include "machine/z80pio.h"
53#include "machine/z80sio.h"
54#include "video/tms9928a.h"
55#include "cpu/z80/z80.h"
56#include "cpu/z80/z80daisy.h"
57#include "machine/wd17xx.h"
58#include "machine/ctronics.h"
59#include "machine/msm8251.h"
60#include "devices/dsk.h"
61#include "devices/basicdsk.h"
62#include "sound/ay8910.h"
63#include "video/mc6845.h"
64#include "einstei2.lh"
65
66
67/***************************************************************************
68    CONSTANTS
69***************************************************************************/
70
71/* xtals */
72#define XTAL_X001  XTAL_10_738635MHz
73#define XTAL_X002  XTAL_8MHz
74
75/* integrated circuits */
76#define IC_I001  "i001"  /* Z8400A */
77#define IC_I030  "i030"  /* AY-3-8910 */
78#define IC_I038  "i038"  /* TMM9129 */
79#define IC_I042  "i042"  /* WD1770-PH */
80#define IC_I050  "i050"  /* ADC0844CCN */
81#define IC_I058  "i058"  /* Z8430A */
82#define IC_I060  "i060"  /* uPD8251A */
83#define IC_I063  "i063"  /* Z8420A */
84
85/* interrupt sources */
86#define EINSTEIN_KEY_INT   (1<<0)
87#define EINSTEIN_ADC_INT   (1<<1)
88#define EINSTEIN_FIRE_INT  (1<<2)
89
90
91/***************************************************************************
92    TYPE DEFINITIONS
93***************************************************************************/
94
95typedef struct _einstein_state einstein_state;
96struct _einstein_state
97{
98   const device_config *color_screen;
99   const device_config *ctc;
100
101   int rom_enabled;
102   int interrupt;
103   int interrupt_mask;
104   int ctc_trigger;
105
106   /* keyboard */
107   UINT8 keyboard_line;
108   UINT8 keyboard_data;
109
110   /* 80 column device */
111   const device_config *mc6845;
112   const device_config *crtc_screen;
113   UINT8 *crtc_ram;
114};
115
116
117/***************************************************************************
118    80 COLUMN DEVICE
119***************************************************************************/
120
121/* lower 3 bits of address define a 256-byte "row".
122 * upper 8 bits define the offset in the row,
123 * data bits define data to write
124 */
125static WRITE8_HANDLER( einstein_80col_ram_w )
126{
127   einstein_state *einstein = space->machine->driver_data;
128   einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)] = data;
129}
130
131static READ8_HANDLER( einstein_80col_ram_r )
132{
133   einstein_state *einstein = space->machine->driver_data;
134   return einstein->crtc_ram[((offset & 0x07) << 8) | ((offset >> 8) & 0xff)];
135}
136
137/* TODO: Verify implementation */
138static MC6845_UPDATE_ROW( einstein_6845_update_row )
139{
140   einstein_state *einstein = device->machine->driver_data;
141   UINT8 *data = memory_region(device->machine, "gfx1");
142   UINT8 char_code, data_byte;
143   int i, x;
144
145   for (i = 0, x = 0; i < x_count; i++, x += 8)
146   {
147      char_code = einstein->crtc_ram[(ma + i) & 0x07ff];
148      data_byte = data[(char_code << 3) + ra];
149
150      *BITMAP_ADDR16(bitmap, y, x + 0) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 7);
151      *BITMAP_ADDR16(bitmap, y, x + 1) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 6);
152      *BITMAP_ADDR16(bitmap, y, x + 2) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 5);
153      *BITMAP_ADDR16(bitmap, y, x + 3) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 4);
154      *BITMAP_ADDR16(bitmap, y, x + 4) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 3);
155      *BITMAP_ADDR16(bitmap, y, x + 5) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 2);
156      *BITMAP_ADDR16(bitmap, y, x + 6) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 1);
157      *BITMAP_ADDR16(bitmap, y, x + 7) = TMS9928A_PALETTE_SIZE + BIT(data_byte, 0);
158   }
159}
160
161/* bit 0 - vsync state?
162 * bit 1 - 0 = 40 column mode (color monitor), 1 = 80 column mode (b/w monitor)
163163 * bit 2 - 0 = 50Hz, 1 = 60Hz
164 */
165static READ8_HANDLER( einstein_80col_state_r )
166{
167   einstein_state *einstein = space->machine->driver_data;
168   UINT8 result = 0;
169 
170   result |= video_screen_get_vblank(einstein->crtc_screen);
171   result |= input_port_read(space->machine, "80column_dips") & 0x06;
172 
173   logerror("%s: einstein_80col_state_r %02x\n", cpuexec_describe_context(space->machine), result);
174 
175   return result;
176}
177 
178 
179/****************************************************************
180   EINSTEIN NON-Z80 DEVICES DAISY CHAIN SUPPORT
181****************************************************************/
182 
183static DEVICE_START( einstein_daisy ) { }
184 
185static int einstein_keyboard_daisy_irq_state(const device_config *device)
186{
187   einstein_state *einstein = device->machine->driver_data;
188 
189   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_KEY_INT)
190      return Z80_DAISY_INT;
191 
192   return 0;
193}
194 
195static int einstein_keyboard_daisy_irq_ack(const device_config *device)
196{
197   return 0xf7;
198}
199 
200static DEVICE_GET_INFO( einstein_keyboard_daisy )
201{
202   switch (state)
203   {
204      /* --- the following bits of info are returned as 64-bit signed integers --- */
205      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
206      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
207      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
208 
209      /* --- the following bits of info are returned as pointers to data or functions --- */
210      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
211      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_keyboard_daisy_irq_state;   break;
212      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_keyboard_daisy_irq_ack;      break;
213 
214      /* --- the following bits of info are returned as NULL-terminated strings --- */
215      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein keyboard daisy chain");      break;
216      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
217      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
218      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
219      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
220   }
221}
222 
223static int einstein_adc_daisy_irq_state(const device_config *device)
224{
225   einstein_state *einstein = device->machine->driver_data;
226 
227   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_ADC_INT)
228      return Z80_DAISY_INT;
229 
230   return 0;
231}
232 
233static int einstein_adc_daisy_irq_ack(const device_config *device)
234{
235   return 0xfb;
236}
237 
238static DEVICE_GET_INFO( einstein_adc_daisy )
239{
240   switch (state)
241   {
242      /* --- the following bits of info are returned as 64-bit signed integers --- */
243      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
244      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
245      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
246 
247      /* --- the following bits of info are returned as pointers to data or functions --- */
248      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
249      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_adc_daisy_irq_state;   break;
250      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_adc_daisy_irq_ack;      break;
251 
252      /* --- the following bits of info are returned as NULL-terminated strings --- */
253      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein ADC daisy chain");         break;
254      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
255      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
256      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
257      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
258   }
259}
260 
261static int einstein_fire_daisy_irq_state(const device_config *device)
262{
263   einstein_state *einstein = device->machine->driver_data;
264 
265   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_FIRE_INT)
266      return Z80_DAISY_INT;
267 
268   return 0;
269}
270 
271static int einstein_fire_daisy_irq_ack(const device_config *device)
272{
273   return 0xfd;
274}
275 
276static DEVICE_GET_INFO( einstein_fire_daisy )
277{
278   switch (state)
279   {
280      /* --- the following bits of info are returned as 64-bit signed integers --- */
281      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
282      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
283      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
284 
285      /* --- the following bits of info are returned as pointers to data or functions --- */
286      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
287      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_fire_daisy_irq_state;      break;
288      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_fire_daisy_irq_ack;         break;
289 
290      /* --- the following bits of info are returned as NULL-terminated strings --- */
291      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein fire button daisy chain");      break;
292      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
293      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
294      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
295      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
296   }
297}
298 
299/* int priority */
300/* keyboard int->ctc/adc->pio */
301static const z80_daisy_chain einstein_daisy_chain[] =
302{
303   { "keyboard_daisy" },
304   { IC_I058 },
305   { "adc_daisy" },
306   { IC_I063 },
307   { "fire_daisy" },
308   { NULL }
309};
310 
311 
312/***************************************************************************
313    KEYBOARD
314***************************************************************************/
315 
316/* refresh keyboard data. It is refreshed when the keyboard line is written */
317static void einstein_scan_keyboard(running_machine *machine)
318{
319   einstein_state *einstein = machine->driver_data;
320   UINT8 data = 0xff;
321 
322   if (!BIT(einstein->keyboard_line, 0)) data &= input_port_read(machine, "LINE0");
323   if (!BIT(einstein->keyboard_line, 1)) data &= input_port_read(machine, "LINE1");
324   if (!BIT(einstein->keyboard_line, 2)) data &= input_port_read(machine, "LINE2");
325   if (!BIT(einstein->keyboard_line, 3)) data &= input_port_read(machine, "LINE3");
326   if (!BIT(einstein->keyboard_line, 4)) data &= input_port_read(machine, "LINE4");
327   if (!BIT(einstein->keyboard_line, 5)) data &= input_port_read(machine, "LINE5");
328   if (!BIT(einstein->keyboard_line, 6)) data &= input_port_read(machine, "LINE6");
329   if (!BIT(einstein->keyboard_line, 7)) data &= input_port_read(machine, "LINE7");
330 
331   einstein->keyboard_data = data;
332}
333 
334static TIMER_DEVICE_CALLBACK( einstein_keyboard_timer_callback )
335{
336   einstein_state *einstein = timer->machine->driver_data;
337 
338   /* re-scan keyboard */
339   einstein_scan_keyboard(timer->machine);
340 
341   /* if /fire1 or /fire2 is 0, signal a fire interrupt */
342   if ((input_port_read(timer->machine, "BUTTONS") & 0x03) != 0)
343   {
344      einstein->interrupt |= EINSTEIN_FIRE_INT;
345   }
346 
347   /* keyboard data changed? */
348   if (einstein->keyboard_data != 0xff)
349   {
350      /* generate interrupt */
351      einstein->interrupt |= EINSTEIN_KEY_INT;
352   }
353}
354 
355static WRITE8_HANDLER( einstein_keyboard_line_write )
356{
357   einstein_state *einstein = space->machine->driver_data;
358 
359   logerror("einstein_keyboard_line_write: %02x\n", data);
360 
361   einstein->keyboard_line = data;
362 
363   /* re-scan the keyboard */
364   einstein_scan_keyboard(space->machine);
365}
366 
367static READ8_HANDLER( einstein_keyboard_data_read )
368{
369   einstein_state *einstein = space->machine->driver_data;
370 
371   /* re-scan the keyboard */
372   einstein_scan_keyboard(space->machine);
373 
374   logerror("einstein_keyboard_data_read: %02x\n", einstein->keyboard_data);
375 
376   return einstein->keyboard_data;
377}
378 
379 
380/***************************************************************************
381    FLOPPY DRIVES
382***************************************************************************/
383 
384static WRITE8_DEVICE_HANDLER( einstein_drsel_w )
385{
386   logerror("%s: einstein_drsel_w %02x\n", cpuexec_describe_context(device->machine), data);
387 
388   /* bit 0 to 3 select the drive */
389   if (BIT(data, 0)) wd17xx_set_drive(device, 0);
390   if (BIT(data, 1)) wd17xx_set_drive(device, 1);
391   if (BIT(data, 2)) wd17xx_set_drive(device, 2);
392   if (BIT(data, 3)) wd17xx_set_drive(device, 3);
393 
394   /* bit 4 selects the side */
395   wd17xx_set_side(device, BIT(data, 4));
396}
397 
398 
399/***************************************************************************
400    CTC
401***************************************************************************/
402 
403/* channel 0 and 1 have a 2 MHz input clock for triggering */
404static TIMER_DEVICE_CALLBACK( einstein_ctc_trigger_callback )
405{
406   einstein_state *einstein = timer->machine->driver_data;
407 
408   /* toggle line status */
409   einstein->ctc_trigger ^= 1;
410 
411   z80ctc_trg0_w(einstein->ctc, 0, einstein->ctc_trigger);
412   z80ctc_trg1_w(einstein->ctc, 0, einstein->ctc_trigger);
413}
414 
415 
416/***************************************************************************
417    UART
418***************************************************************************/
419 
420static WRITE8_DEVICE_HANDLER( einstein_serial_transmit_clock )
421{
422   const device_config *uart = devtag_get_device(device->machine, IC_I060);
423   msm8251_transmit_clock(uart);
424}
425 
426static WRITE8_DEVICE_HANDLER( einstein_serial_receive_clock )
427{
428   const device_config *uart = devtag_get_device(device->machine, IC_I060);
429   msm8251_receive_clock(uart);
430}
431 
432 
433/***************************************************************************
434    MEMORY BANKING
435***************************************************************************/
436 
437static void einstein_page_rom(running_machine *machine)
438{
439   einstein_state *einstein = machine->driver_data;
440   memory_set_bankptr(machine, 1, einstein->rom_enabled ? memory_region(machine, "bios") : mess_ram);
441}
442 
443/* writing to this port is a simple trigger, and switches between RAM and ROM */
444static WRITE8_HANDLER( einstein_rom_w )
445{
446   einstein_state *einstein = space->machine->driver_data;
447   einstein->rom_enabled ^= 1;
448   einstein_page_rom(space->machine);
449}
450 
451 
452/***************************************************************************
453    INTERRUPTS
454***************************************************************************/
455 
456static READ8_HANDLER( einstein_kybintmsk_r )
457{
458   const device_config *printer = devtag_get_device(space->machine, "centronics");
459   einstein_state *einstein = space->machine->driver_data;
460   UINT8 data = 0;
461 
462   /* clear key int. a read of this I/O port will do this or a reset */
463   einstein->interrupt &= ~EINSTEIN_KEY_INT;
464 
465   /* bit 0 and 1: fire buttons on the joysticks */
466   data |= input_port_read(space->machine, "BUTTONS");
467 
468   /* bit 2 to 4: printer status */
469   data |= centronics_busy_r(printer) << 2;
470   data |= centronics_pe_r(printer) << 3;
471   data |= centronics_fault_r(printer) << 4;
472 
473   /* bit 5 to 7: graph, control and shift key */
474   data |= input_port_read(space->machine, "EXTRA");
475 
476   logerror("%s: einstein_kybintmsk_r %02x\n", cpuexec_describe_context(space->machine), data);
477 
478   return data;
479}
480 
481static WRITE8_HANDLER( einstein_kybintmsk_w )
482{
483   einstein_state *einstein = space->machine->driver_data;
484 
485   logerror("%s: einstein_kybintmsk_w %02x\n", cpuexec_describe_context(space->machine), data);
486 
487   /* set mask from bit 0 */
488   if (data & 0x01)
489   {
490      logerror("key int is disabled\n");
491      einstein->interrupt_mask &= ~EINSTEIN_KEY_INT;
492   }
493   else
494   {
495      logerror("key int is enabled\n");
496      einstein->interrupt_mask |= EINSTEIN_KEY_INT;
497   }
498}
499 
500/* writing to this I/O port sets the state of the mask; D0 is used */
501/* writing 0 enables the /ADC interrupt */
502static WRITE8_HANDLER( einstein_adcintmsk_w )
503{
504   einstein_state *einstein = space->machine->driver_data;
505 
506   logerror("%s: einstein_adcintmsk_w %02x\n", cpuexec_describe_context(space->machine), data);
507 
508   if (data & 0x01)
509   {
510      logerror("adc int is disabled\n");
511      einstein->interrupt_mask &= ~EINSTEIN_ADC_INT;
512   }
513   else
514   {
515      logerror("adc int is enabled\n");
516      einstein->interrupt_mask |= EINSTEIN_ADC_INT;
517   }
518}
519 
520/* writing to this I/O port sets the state of the mask; D0 is used */
521/* writing 0 enables the /FIRE interrupt */
522static WRITE8_HANDLER( einstein_fire_int_w )
523{
524   einstein_state *einstein = space->machine->driver_data;
525 
526   logerror("%s: einstein_fire_int_w %02x\n", cpuexec_describe_context(space->machine), data);
527 
528   if (data & 0x01)
529   {
530      logerror("fire int is disabled\n");
531      einstein->interrupt_mask &= ~EINSTEIN_FIRE_INT;
532   }
533   else
534   {
535      logerror("fire int is enabled\n");
536      einstein->interrupt_mask |= EINSTEIN_FIRE_INT;
537   }
538}
539 
540 
541/***************************************************************************
542    MACHINE EMULATION
543***************************************************************************/
544 
545static const TMS9928a_interface tms9928a_interface =
546{
547   TMS9929A,
548   0x4000, /* 16k RAM, provided by IC i040 and i041 */
549   0, 0,
550   NULL
551};
552 
553static MACHINE_START( einstein )
554{
555   TMS9928A_configure(&tms9928a_interface);
556}
557 
558static MACHINE_RESET( einstein )
559{
560   einstein_state *einstein = machine->driver_data;
561 
562   /* save pointers to our devices */
563   einstein->color_screen = devtag_get_device(machine, "screen");
564   einstein->ctc = devtag_get_device(machine, IC_I058);
565 
566   /* initialize memory mapping */
567   memory_set_bankptr(machine, 2, mess_ram);
568   memory_set_bankptr(machine, 3, mess_ram + 0x8000);
569   einstein->rom_enabled = 1;
570   einstein_page_rom(machine);
571 
572   TMS9928A_reset();
573 
574   /* a reset causes the fire int, adc int, keyboard int mask
575    to be set to 1, which causes all these to be DISABLED */
576   einstein->interrupt = 0;
577   einstein->interrupt_mask = 0;
578 
579   floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40);
580 
581   einstein->ctc_trigger = 0;
582}
583 
584static MACHINE_RESET( einstein2 )
585{
586   einstein_state *einstein = machine->driver_data;
587 
588   /* call standard initialization first */
589   MACHINE_RESET_CALL(einstein);
590 
591   /* get 80 column specific devices */
592   einstein->mc6845 = devtag_get_device(machine, "crtc");
593   einstein->crtc_screen = devtag_get_device(machine, "80column");
594 
595   /* 80 column card palette */
596   palette_set_color(machine, TMS9928A_PALETTE_SIZE, RGB_BLACK);
597   palette_set_color(machine, TMS9928A_PALETTE_SIZE + 1, MAKE_RGB(0, 224, 0));
598 
599   einstein->crtc_ram = auto_alloc_array(machine, UINT8, 2048);
600}
601 
602 
603/***************************************************************************
604    VIDEO EMULATION
605***************************************************************************/
606 
607static VIDEO_UPDATE( einstein2 )
608{
609   einstein_state *einstein = screen->machine->driver_data;
610 
611   if (screen == einstein->color_screen)
612      VIDEO_UPDATE_CALL(tms9928a);
613   else if (screen == einstein->crtc_screen)
614      mc6845_update(einstein->mc6845, bitmap, cliprect);
615   else
616      fatalerror("Unknown screen '%s'\n", screen->tag);
617 
618   return 0;
619}
620 
621 
622/***************************************************************************
623    ADDRESS MAPS
624***************************************************************************/
625 
626static ADDRESS_MAP_START( einstein_mem, ADDRESS_SPACE_PROGRAM, 8 )
627   AM_RANGE(0x0000, 0x07fff) AM_READWRITE(SMH_BANK(1), SMH_BANK(2))
628   AM_RANGE(0x8000, 0x0ffff) AM_RAMBANK(3)
629ADDRESS_MAP_END
630 
631/* The I/O ports are decoded into 8 blocks using address lines A3 to A7 */
632static ADDRESS_MAP_START( einstein_io, ADDRESS_SPACE_IO, 8 )
633   /* block 0, ay8910 psg */
634   AM_RANGE(0x02, 0x02) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I030, ay8910_r, ay8910_address_w)
635   AM_RANGE(0x03, 0x03) AM_MIRROR(0xff04) AM_DEVWRITE(IC_I030, ay8910_data_w)
636   /* block 1, tms9928a vdp */
637   AM_RANGE(0x08, 0x08) AM_MIRROR(0xff06) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w)
638   AM_RANGE(0x09, 0x09) AM_MIRROR(0xff06) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w)
639   /* block 2, msm8251 uart */
640   AM_RANGE(0x10, 0x10) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, msm8251_data_r, msm8251_data_w)
641   AM_RANGE(0x11, 0x11) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, msm8251_status_r, msm8251_control_w)
642   /* block 3, wd1770 floppy controller */
643   AM_RANGE(0x18, 0x1b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I042, wd17xx_r, wd17xx_w)
644   /* block 4, internal controls */
645   AM_RANGE(0x20, 0x20) AM_MIRROR(0xff00) AM_READWRITE(einstein_kybintmsk_r, einstein_kybintmsk_w)
646   AM_RANGE(0x21, 0x21) AM_MIRROR(0xff00) AM_WRITE(einstein_adcintmsk_w)
647   AM_RANGE(0x23, 0x23) AM_MIRROR(0xff00) AM_DEVWRITE(IC_I042, einstein_drsel_w)
648   AM_RANGE(0x24, 0x24) AM_MIRROR(0xff00) AM_WRITE(einstein_rom_w)
649   AM_RANGE(0x25, 0x25) AM_MIRROR(0xff00) AM_WRITE(einstein_fire_int_w)
650   /* block 5, z80ctc */
651   AM_RANGE(0x28, 0x2b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I058, z80ctc_r, z80ctc_w)
652   /* block 6, z80pio */
653   AM_RANGE(0x30, 0x33) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I063, z80pio_r, z80pio_w)
654#if 0
655   /* block 7, adc */
656   AM_RANGE(0x38, 0x38) AM_MIRROR(0xff07) AM_DEVREADWRITE(IC_I050, adc0844_r, adc0844_w)
657#endif
658ADDRESS_MAP_END
659 
660static ADDRESS_MAP_START( einstein2_io, ADDRESS_SPACE_IO, 8 )
661   AM_IMPORT_FROM(einstein_io)
662   AM_RANGE(0x40, 0x47) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(einstein_80col_ram_r, einstein_80col_ram_w)
663   AM_RANGE(0x48, 0x48) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_address_w)
664   AM_RANGE(0x49, 0x49) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_register_w)
665   AM_RANGE(0x4c, 0x4c) AM_MIRROR(0xff00) AM_READ(einstein_80col_state_r)
666ADDRESS_MAP_END
667 
668 
669/***************************************************************************
670    INPUT PORTS
671***************************************************************************/
672 
673static INPUT_PORTS_START( einstein )
674   PORT_START("LINE0")
675   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BREAK") PORT_CODE(KEYCODE_LALT)
676   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_1_PAD)
677   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F0") PORT_CODE(KEYCODE_F1)
678   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_3_PAD)
679   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK)
680   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
681   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
682   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
683 
684   PORT_START("LINE1")
685   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
686   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
687   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
688   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEFT") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
689   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('\xA3')
690   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DOWN") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
691   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\xBA') PORT_CHAR('\xBD')   // is \xBA correct for double vertical bar || ?
692   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('@')
693 
694   PORT_START("LINE2")
695   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
696   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
697   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
698   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
699   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RIGHT") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
700   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
701   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
702   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F5))
703 
704   PORT_START("LINE3")
705   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
706   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
707   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
708   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
709   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DELETE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
710   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('-')
711   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("UP") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
712   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F4))
713 
714   PORT_START("LINE4")
715   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
716   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
717   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
718   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
719   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
720   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('\"')
721   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
722   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F3))
723 
724   PORT_START("LINE5")
725   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
726   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
727   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
728   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
729   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
730   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
731   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
732   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F2))
733 
734   PORT_START("LINE6")
735   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
736   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
737   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
738   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
739   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
740   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
741   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
742   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F1))
743 
744   PORT_START("LINE7")
745   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
746   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
747   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
748   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
749   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
750   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
751   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
752   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F6))
753 
754   PORT_START("EXTRA")
755   PORT_BIT(0x1f, IP_ACTIVE_HIGH, IPT_UNUSED)
756   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("GRPH")    PORT_CODE(KEYCODE_F8)
757   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CONTROL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
758   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT")   PORT_CODE(KEYCODE_LSHIFT)   PORT_CODE(KEYCODE_RSHIFT)   PORT_CHAR(UCHAR_SHIFT_1)
759 
760   /* fire buttons for analogue joysticks */
761   PORT_START("BUTTONS")
762   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 1 Button 1") PORT_PLAYER(1)
763   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 2 Button 1") PORT_PLAYER(2)
764   PORT_BIT(0xfc, IP_ACTIVE_HIGH, IPT_UNUSED)
765 
766   /* analog joystick 1 x axis */
767   PORT_START("JOY1_X")
768   PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE
769 
770   /* analog joystick 1 y axis */
771   PORT_START("JOY1_Y")
772   PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(1) PORT_REVERSE
773 
774   /* analog joystick 2 x axis */
775   PORT_START("JOY2_X")
776   PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) PORT_REVERSE
777 
778   /* analog joystick 2 Y axis */
779   PORT_START("JOY2_Y")
780   PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE
781INPUT_PORTS_END
782 
783INPUT_PORTS_START( einstein_80col )
784   PORT_INCLUDE(einstein)
785 
786   /* dip switches on the 80 column card */
787   PORT_START("80column_dips")
788   PORT_DIPNAME(0x02, 0x00, "Startup mode")
789   PORT_DIPSETTING(0x00, "40 column")
790   PORT_DIPSETTING(0x02, "80 column")
791   PORT_DIPNAME(0x04, 0x00, "50/60Hz")
792   PORT_DIPSETTING(0x00, "50Hz")
793   PORT_DIPSETTING(0x04, "60Hz")
794INPUT_PORTS_END
795 
796 
797/***************************************************************************
798    MACHINE DRIVERS
799***************************************************************************/
800 
801static const z80ctc_interface einstein_ctc_intf =
802{
803   0,
804   0,
805   einstein_serial_transmit_clock,
806   einstein_serial_receive_clock,
807   z80ctc_trg3_w
808};
809 
810 
811static const z80pio_interface einstein_pio_intf =
812{
813   DEVCB_NULL,
814   DEVCB_NULL,
815   DEVCB_NULL,
816   DEVCB_DEVICE_HANDLER("centronics", centronics_data_w),
817   DEVCB_NULL,
818   DEVCB_DEVICE_LINE("centronics", centronics_strobe_w),
819   DEVCB_NULL
820};
821 
822static const ay8910_interface einstein_ay_interface =
823{
824   AY8910_LEGACY_OUTPUT,
825   AY8910_DEFAULT_LOADS,
826   DEVCB_NULL,
827   DEVCB_MEMORY_HANDLER(IC_I001, PROGRAM, einstein_keyboard_data_read),
828   DEVCB_MEMORY_HANDLER(IC_I001, PROGRAM, einstein_keyboard_line_write),
829   DEVCB_NULL
830};
831 
832static const centronics_interface einstein_centronics_config =
833{
834   FALSE,
835   DEVCB_DEVICE_LINE(IC_I063, z80pio_astb_w),
836   DEVCB_NULL,
837   DEVCB_NULL
838};
839 
840static const mc6845_interface einstein_crtc6845_interface =
841{
842   "80column",
843   8,
844   NULL,
845   einstein_6845_update_row,
846   NULL,
847   DEVCB_NULL,
848   DEVCB_NULL,
849   DEVCB_NULL,
850   DEVCB_NULL,
851   NULL
852};
853 
854 
855static MACHINE_DRIVER_START( einstein )
856   /* basic machine hardware */
857   MDRV_CPU_ADD(IC_I001, Z80, XTAL_X002 / 2)
858   MDRV_CPU_PROGRAM_MAP(einstein_mem)
859   MDRV_CPU_IO_MAP(einstein_io)
860   MDRV_CPU_CONFIG(einstein_daisy_chain)
861 
862   MDRV_DRIVER_DATA(einstein_state)
863 
864   MDRV_MACHINE_START(einstein)
865   MDRV_MACHINE_RESET(einstein)
866 
867   /* this is actually clocked at the system clock 4 MHz, but this would be too fast for our
868   driver. So we update at 50Hz and hope this is good enough. */
869   MDRV_TIMER_ADD_PERIODIC("keyboard", einstein_keyboard_timer_callback, HZ(50))
870 
871   MDRV_Z80PIO_ADD(IC_I063, einstein_pio_intf)
872 
873   MDRV_Z80CTC_ADD(IC_I058, XTAL_X002 / 2, einstein_ctc_intf)
874   /* the input to channel 0 and 1 of the ctc is a 2 MHz clock */
875   MDRV_TIMER_ADD_PERIODIC("ctc", einstein_ctc_trigger_callback, HZ(XTAL_X002 /4))
876 
877   /* Einstein daisy chain support for non-Z80 devices */
878   MDRV_DEVICE_ADD("keyboard_daisy", DEVICE_GET_INFO_NAME(einstein_keyboard_daisy), 0)
879   MDRV_DEVICE_ADD("adc_daisy", DEVICE_GET_INFO_NAME(einstein_adc_daisy), 0)
880   MDRV_DEVICE_ADD("fire_daisy", DEVICE_GET_INFO_NAME(einstein_fire_daisy), 0)
881 
882    /* video hardware */
883   MDRV_IMPORT_FROM(tms9928a)
884   MDRV_SCREEN_MODIFY("screen")
885   MDRV_SCREEN_REFRESH_RATE(50)
886   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
887 
888   /* sound hardware */
889   MDRV_SPEAKER_STANDARD_MONO("mono")
890   MDRV_SOUND_ADD(IC_I030, AY8910, XTAL_X002 / 4)
891   MDRV_SOUND_CONFIG(einstein_ay_interface)
892   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
893 
894   /* printer */
895   MDRV_CENTRONICS_ADD("centronics", einstein_centronics_config)
896 
897   /* uart */
898   MDRV_MSM8251_ADD(IC_I060, default_msm8251_interface)
899 
900   MDRV_WD1770_ADD(IC_I042, default_wd17xx_interface)
901MACHINE_DRIVER_END
902 
903 
904static MACHINE_DRIVER_START( einstei2 )
905   MDRV_IMPORT_FROM( einstein )
906 
907   MDRV_CPU_MODIFY(IC_I001)
908   MDRV_CPU_IO_MAP(einstein2_io)
909   MDRV_MACHINE_RESET(einstein2)
910 
911    /* video hardware */
912   MDRV_DEFAULT_LAYOUT(layout_einstei2)
913 
914   MDRV_SCREEN_ADD("80column", RASTER)
915   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
916   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
917   MDRV_SCREEN_SIZE(640, 400)
918   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1)
919   MDRV_SCREEN_REFRESH_RATE(50)
920 
921   /* 2 additional colors for the 80 column screen */
922   MDRV_PALETTE_LENGTH(TMS9928A_PALETTE_SIZE + 2)
923 
924   MDRV_MC6845_ADD("crtc", MC6845, XTAL_X002 / 4, einstein_crtc6845_interface)
925 
926   MDRV_VIDEO_UPDATE(einstein2)
927MACHINE_DRIVER_END
928 
929 
930/***************************************************************************
931    ROM DEFINITIONS
932***************************************************************************/
933 
934/* There are two sockets, i023 and i024, each either a 2764 or 27128
935 * only i023 is used by default and fitted with the 8k bios (called MOS).
936 *
937 * We are missing dumps of version MOS 1.1, possibly of 1.0 if it exists.
938 */
939ROM_START( einstein )
940   ROM_REGION(0x8000, "bios", 0)
941   /* i023 */
942   ROM_SYSTEM_BIOS(0,  "mos12",  "MOS 1.2")
943   ROMX_LOAD("mos12.i023", 0, 0x2000, CRC(ec134953) SHA1(a02125d8ebcda48aa784adbb42a8b2d7ef3a4b77), ROM_BIOS(1))
944   ROM_SYSTEM_BIOS(1,  "mos121",  "MOS 1.21")
945   ROMX_LOAD("mos121.i023", 0, 0x2000, CRC(a746eeb6) SHA1(f75aaaa777d0fd92225acba291f6bf428b341d3e), ROM_BIOS(2))
946   ROM_RELOAD(0x2000, 0x2000)
947   /* i024 */
948   ROM_FILL(0x4000, 0x4000, 0xff)
949ROM_END
950 
951ROM_START( einstei2 )
952   ROM_REGION(0x8000, "bios", 0)
953   /* i023 */
954   ROM_SYSTEM_BIOS(0,  "mos12",  "MOS 1.2")
955   ROMX_LOAD("mos12.i023", 0, 0x2000, CRC(ec134953) SHA1(a02125d8ebcda48aa784adbb42a8b2d7ef3a4b77), ROM_BIOS(1))
956   ROM_SYSTEM_BIOS(1,  "mos121",  "MOS 1.21")
957   ROMX_LOAD("mos121.i023", 0, 0x2000, CRC(a746eeb6) SHA1(f75aaaa777d0fd92225acba291f6bf428b341d3e), ROM_BIOS(2))
958   ROM_RELOAD(0x2000, 0x2000)
959   /* i024 */
960   ROM_FILL(0x4000, 0x4000, 0xff)
961 
962   /* character rom from 80 column card */
963   ROM_REGION(0x800, "gfx1", 0)
964   ROM_LOAD("charrom.rom", 0, 0x800, NO_DUMP)
965ROM_END
966 
967 
968/***************************************************************************
969    SYSTEM CONFIG
970***************************************************************************/
971 
972static void einstein_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
973{
974   /* floppy */
975   switch(state)
976   {
977      /* --- the following bits of info are returned as 64-bit signed integers --- */
978      case MESS_DEVINFO_INT_COUNT:   info->i = 4; break;
979 
980      default:                  legacydsk_device_getinfo(devclass, state, info); break;
981   }
982}
983 
984static SYSTEM_CONFIG_START( einstein )
985   /* RAM is provided by 8k DRAM ICs i009, i010, i011, i012, i013, i014, i015 and i016 */
986   CONFIG_RAM_DEFAULT(8 * 8 * 1024)
987   CONFIG_DEVICE(einstein_floppy_getinfo)
988SYSTEM_CONFIG_END
989 
990 
991/***************************************************************************
992    GAME DRIVERS
993***************************************************************************/
994 
995/*    YEAR  NAME      PARENT    COMPAT  MACHINE   INPUT           INIT  CONFIG,   COMPANY   FULLNAME                             FLAGS */
996COMP( 1984, einstein, 0,        0,      einstein, einstein,       0,    einstein, "Tatung", "Einstein TC-01",                    0 )
997COMP( 1984, einstei2, einstein, 0,      einstei2, einstein_80col, 0,    einstein, "Tatung", "Einstein TC-01 + 80 column device", 0 )
164 */
165static READ8_HANDLER( einstein_80col_state_r )
166{
167   einstein_state *einstein = space->machine->driver_data;
168   UINT8 result = 0;
169
170   result |= video_screen_get_vblank(einstein->crtc_screen);
171   result |= input_port_read(space->machine, "80column_dips") & 0x06;
172
173   logerror("%s: einstein_80col_state_r %02x\n", cpuexec_describe_context(space->machine), result);
174
175   return result;
176}
177
178
179/****************************************************************
180   EINSTEIN NON-Z80 DEVICES DAISY CHAIN SUPPORT
181****************************************************************/
182
183static DEVICE_START( einstein_daisy ) { }
184
185static int einstein_keyboard_daisy_irq_state(const device_config *device)
186{
187   einstein_state *einstein = device->machine->driver_data;
188
189   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_KEY_INT)
190      return Z80_DAISY_INT;
191
192   return 0;
193}
194
195static int einstein_keyboard_daisy_irq_ack(const device_config *device)
196{
197   return 0xf7;
198}
199
200static DEVICE_GET_INFO( einstein_keyboard_daisy )
201{
202   switch (state)
203   {
204      /* --- the following bits of info are returned as 64-bit signed integers --- */
205      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
206      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
207      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
208
209      /* --- the following bits of info are returned as pointers to data or functions --- */
210      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
211      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_keyboard_daisy_irq_state;   break;
212      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_keyboard_daisy_irq_ack;      break;
213
214      /* --- the following bits of info are returned as NULL-terminated strings --- */
215      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein keyboard daisy chain");      break;
216      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
217      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
218      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
219      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
220   }
221}
222
223static int einstein_adc_daisy_irq_state(const device_config *device)
224{
225   einstein_state *einstein = device->machine->driver_data;
226
227   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_ADC_INT)
228      return Z80_DAISY_INT;
229
230   return 0;
231}
232
233static int einstein_adc_daisy_irq_ack(const device_config *device)
234{
235   return 0xfb;
236}
237
238static DEVICE_GET_INFO( einstein_adc_daisy )
239{
240   switch (state)
241   {
242      /* --- the following bits of info are returned as 64-bit signed integers --- */
243      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
244      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
245      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
246
247      /* --- the following bits of info are returned as pointers to data or functions --- */
248      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
249      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_adc_daisy_irq_state;   break;
250      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_adc_daisy_irq_ack;      break;
251
252      /* --- the following bits of info are returned as NULL-terminated strings --- */
253      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein ADC daisy chain");         break;
254      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
255      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
256      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
257      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
258   }
259}
260
261static int einstein_fire_daisy_irq_state(const device_config *device)
262{
263   einstein_state *einstein = device->machine->driver_data;
264
265   if (einstein->interrupt & einstein->interrupt_mask & EINSTEIN_FIRE_INT)
266      return Z80_DAISY_INT;
267
268   return 0;
269}
270
271static int einstein_fire_daisy_irq_ack(const device_config *device)
272{
273   return 0xfd;
274}
275
276static DEVICE_GET_INFO( einstein_fire_daisy )
277{
278   switch (state)
279   {
280      /* --- the following bits of info are returned as 64-bit signed integers --- */
281      case DEVINFO_INT_TOKEN_BYTES:               info->i = 4;                                 break;
282      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                 break;
283      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                  break;
284
285      /* --- the following bits of info are returned as pointers to data or functions --- */
286      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(einstein_daisy);      break;
287      case DEVINFO_FCT_IRQ_STATE:                  info->f = (genf *)einstein_fire_daisy_irq_state;      break;
288      case DEVINFO_FCT_IRQ_ACK:                  info->f = (genf *)einstein_fire_daisy_irq_ack;         break;
289
290      /* --- the following bits of info are returned as NULL-terminated strings --- */
291      case DEVINFO_STR_NAME:                     strcpy(info->s, "Einstein fire button daisy chain");      break;
292      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Einstein daisy chain");            break;
293      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                           break;
294      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                        break;
295      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");            break;
296   }
297}
298
299/* int priority */
300/* keyboard int->ctc/adc->pio */
301static const z80_daisy_chain einstein_daisy_chain[] =
302{
303   { "keyboard_daisy" },
304   { IC_I058 },
305   { "adc_daisy" },
306   { IC_I063 },
307   { "fire_daisy" },
308   { NULL }
309};
310
311
312/***************************************************************************
313    KEYBOARD
314***************************************************************************/
315
316/* refresh keyboard data. It is refreshed when the keyboard line is written */
317static void einstein_scan_keyboard(running_machine *machine)
318{
319   einstein_state *einstein = machine->driver_data;
320   UINT8 data = 0xff;
321
322   if (!BIT(einstein->keyboard_line, 0)) data &= input_port_read(machine, "LINE0");
323   if (!BIT(einstein->keyboard_line, 1)) data &= input_port_read(machine, "LINE1");
324   if (!BIT(einstein->keyboard_line, 2)) data &= input_port_read(machine, "LINE2");
325   if (!BIT(einstein->keyboard_line, 3)) data &= input_port_read(machine, "LINE3");
326   if (!BIT(einstein->keyboard_line, 4)) data &= input_port_read(machine, "LINE4");
327   if (!BIT(einstein->keyboard_line, 5)) data &= input_port_read(machine, "LINE5");
328   if (!BIT(einstein->keyboard_line, 6)) data &= input_port_read(machine, "LINE6");
329   if (!BIT(einstein->keyboard_line, 7)) data &= input_port_read(machine, "LINE7");
330
331   einstein->keyboard_data = data;
332}
333
334static TIMER_DEVICE_CALLBACK( einstein_keyboard_timer_callback )
335{
336   einstein_state *einstein = timer->machine->driver_data;
337
338   /* re-scan keyboard */
339   einstein_scan_keyboard(timer->machine);
340
341   /* if /fire1 or /fire2 is 0, signal a fire interrupt */
342   if ((input_port_read(timer->machine, "BUTTONS") & 0x03) != 0)
343   {
344      einstein->interrupt |= EINSTEIN_FIRE_INT;
345   }
346
347   /* keyboard data changed? */
348   if (einstein->keyboard_data != 0xff)
349   {
350      /* generate interrupt */
351      einstein->interrupt |= EINSTEIN_KEY_INT;
352   }
353}
354
355static WRITE8_HANDLER( einstein_keyboard_line_write )
356{
357   einstein_state *einstein = space->machine->driver_data;
358
359   logerror("einstein_keyboard_line_write: %02x\n", data);
360
361   einstein->keyboard_line = data;
362
363   /* re-scan the keyboard */
364   einstein_scan_keyboard(space->machine);
365}
366
367static READ8_HANDLER( einstein_keyboard_data_read )
368{
369   einstein_state *einstein = space->machine->driver_data;
370
371   /* re-scan the keyboard */
372   einstein_scan_keyboard(space->machine);
373
374   logerror("einstein_keyboard_data_read: %02x\n", einstein->keyboard_data);
375
376   return einstein->keyboard_data;
377}
378
379
380/***************************************************************************
381    FLOPPY DRIVES
382***************************************************************************/
383
384static WRITE8_DEVICE_HANDLER( einstein_drsel_w )
385{
386   logerror("%s: einstein_drsel_w %02x\n", cpuexec_describe_context(device->machine), data);
387
388   /* bit 0 to 3 select the drive */
389   if (BIT(data, 0)) wd17xx_set_drive(device, 0);
390   if (BIT(data, 1)) wd17xx_set_drive(device, 1);
391   if (BIT(data, 2)) wd17xx_set_drive(device, 2);
392   if (BIT(data, 3)) wd17xx_set_drive(device, 3);
393
394   /* bit 4 selects the side */
395   wd17xx_set_side(device, BIT(data, 4));
396}
397
398
399/***************************************************************************
400    CTC
401***************************************************************************/
402
403/* channel 0 and 1 have a 2 MHz input clock for triggering */
404static TIMER_DEVICE_CALLBACK( einstein_ctc_trigger_callback )
405{
406   einstein_state *einstein = timer->machine->driver_data;
407
408   /* toggle line status */
409   einstein->ctc_trigger ^= 1;
410
411   z80ctc_trg0_w(einstein->ctc, 0, einstein->ctc_trigger);
412   z80ctc_trg1_w(einstein->ctc, 0, einstein->ctc_trigger);
413}
414
415
416/***************************************************************************
417    UART
418***************************************************************************/
419
420static WRITE8_DEVICE_HANDLER( einstein_serial_transmit_clock )
421{
422   const device_config *uart = devtag_get_device(device->machine, IC_I060);
423   msm8251_transmit_clock(uart);
424}
425
426static WRITE8_DEVICE_HANDLER( einstein_serial_receive_clock )
427{
428   const device_config *uart = devtag_get_device(device->machine, IC_I060);
429   msm8251_receive_clock(uart);
430}
431
432
433/***************************************************************************
434    MEMORY BANKING
435***************************************************************************/
436
437static void einstein_page_rom(running_machine *machine)
438{
439   einstein_state *einstein = machine->driver_data;
440   memory_set_bankptr(machine, 1, einstein->rom_enabled ? memory_region(machine, "bios") : mess_ram);
441}
442
443/* writing to this port is a simple trigger, and switches between RAM and ROM */
444static WRITE8_HANDLER( einstein_rom_w )
445{
446   einstein_state *einstein = space->machine->driver_data;
447   einstein->rom_enabled ^= 1;
448   einstein_page_rom(space->machine);
449}
450
451
452/***************************************************************************
453    INTERRUPTS
454***************************************************************************/
455
456static READ8_HANDLER( einstein_kybintmsk_r )
457{
458   const device_config *printer = devtag_get_device(space->machine, "centronics");
459   einstein_state *einstein = space->machine->driver_data;
460   UINT8 data = 0;
461
462   /* clear key int. a read of this I/O port will do this or a reset */
463   einstein->interrupt &= ~EINSTEIN_KEY_INT;
464
465   /* bit 0 and 1: fire buttons on the joysticks */
466   data |= input_port_read(space->machine, "BUTTONS");
467
468   /* bit 2 to 4: printer status */
469   data |= centronics_busy_r(printer) << 2;
470   data |= centronics_pe_r(printer) << 3;
471   data |= centronics_fault_r(printer) << 4;
472
473   /* bit 5 to 7: graph, control and shift key */
474   data |= input_port_read(space->machine, "EXTRA");
475
476   logerror("%s: einstein_kybintmsk_r %02x\n", cpuexec_describe_context(space->machine), data);
477
478   return data;
479}
480
481static WRITE8_HANDLER( einstein_kybintmsk_w )
482{
483   einstein_state *einstein = space->machine->driver_data;
484
485   logerror("%s: einstein_kybintmsk_w %02x\n", cpuexec_describe_context(space->machine), data);
486
487   /* set mask from bit 0 */
488   if (data & 0x01)
489   {
490      logerror("key int is disabled\n");
491      einstein->interrupt_mask &= ~EINSTEIN_KEY_INT;
492   }
493   else
494   {
495      logerror("key int is enabled\n");
496      einstein->interrupt_mask |= EINSTEIN_KEY_INT;
497   }
498}
499
500/* writing to this I/O port sets the state of the mask; D0 is used */
501/* writing 0 enables the /ADC interrupt */
502static WRITE8_HANDLER( einstein_adcintmsk_w )
503{
504   einstein_state *einstein = space->machine->driver_data;
505
506   logerror("%s: einstein_adcintmsk_w %02x\n", cpuexec_describe_context(space->machine), data);
507
508   if (data & 0x01)
509   {
510      logerror("adc int is disabled\n");
511      einstein->interrupt_mask &= ~EINSTEIN_ADC_INT;
512   }
513   else
514   {
515      logerror("adc int is enabled\n");
516      einstein->interrupt_mask |= EINSTEIN_ADC_INT;
517   }
518}
519
520/* writing to this I/O port sets the state of the mask; D0 is used */
521/* writing 0 enables the /FIRE interrupt */
522static WRITE8_HANDLER( einstein_fire_int_w )
523{
524   einstein_state *einstein = space->machine->driver_data;
525
526   logerror("%s: einstein_fire_int_w %02x\n", cpuexec_describe_context(space->machine), data);
527
528   if (data & 0x01)
529   {
530      logerror("fire int is disabled\n");
531      einstein->interrupt_mask &= ~EINSTEIN_FIRE_INT;
532   }
533   else
534   {
535      logerror("fire int is enabled\n");
536      einstein->interrupt_mask |= EINSTEIN_FIRE_INT;
537   }
538}
539
540
541/***************************************************************************
542    MACHINE EMULATION
543***************************************************************************/
544
545static const TMS9928a_interface tms9928a_interface =
546{
547   TMS9929A,
548   0x4000, /* 16k RAM, provided by IC i040 and i041 */
549   0, 0,
550   NULL
551};
552
553static MACHINE_START( einstein )
554{
555   TMS9928A_configure(&tms9928a_interface);
556}
557
558static MACHINE_RESET( einstein )
559{
560   einstein_state *einstein = machine->driver_data;
561
562   /* save pointers to our devices */
563   einstein->color_screen = devtag_get_device(machine, "screen");
564   einstein->ctc = devtag_get_device(machine, IC_I058);
565
566   /* initialize memory mapping */
567   memory_set_bankptr(machine, 2, mess_ram);
568   memory_set_bankptr(machine, 3, mess_ram + 0x8000);
569   einstein->rom_enabled = 1;
570   einstein_page_rom(machine);
571
572   TMS9928A_reset();
573
574   /* a reset causes the fire int, adc int, keyboard int mask
575    to be set to 1, which causes all these to be DISABLED */
576   einstein->interrupt = 0;
577   einstein->interrupt_mask = 0;
578
579   floppy_drive_set_geometry(image_from_devtype_and_index(machine, IO_FLOPPY, 0), FLOPPY_DRIVE_SS_40);
580
581   einstein->ctc_trigger = 0;
582}
583
584static MACHINE_RESET( einstein2 )
585{
586   einstein_state *einstein = machine->driver_data;
587
588   /* call standard initialization first */
589   MACHINE_RESET_CALL(einstein);
590
591   /* get 80 column specific devices */
592   einstein->mc6845 = devtag_get_device(machine, "crtc");
593   einstein->crtc_screen = devtag_get_device(machine, "80column");
594
595   /* 80 column card palette */
596   palette_set_color(machine, TMS9928A_PALETTE_SIZE, RGB_BLACK);
597   palette_set_color(machine, TMS9928A_PALETTE_SIZE + 1, MAKE_RGB(0, 224, 0));
598
599   einstein->crtc_ram = auto_alloc_array(machine, UINT8, 2048);
600}
601
602
603/***************************************************************************
604    VIDEO EMULATION
605***************************************************************************/
606
607static VIDEO_UPDATE( einstein2 )
608{
609   einstein_state *einstein = screen->machine->driver_data;
610
611   if (screen == einstein->color_screen)
612      VIDEO_UPDATE_CALL(tms9928a);
613   else if (screen == einstein->crtc_screen)
614      mc6845_update(einstein->mc6845, bitmap, cliprect);
615   else
616      fatalerror("Unknown screen '%s'\n", screen->tag);
617
618   return 0;
619}
620
621
622/***************************************************************************
623    ADDRESS MAPS
624***************************************************************************/
625
626static ADDRESS_MAP_START( einstein_mem, ADDRESS_SPACE_PROGRAM, 8 )
627   AM_RANGE(0x0000, 0x07fff) AM_READWRITE(SMH_BANK(1), SMH_BANK(2))
628   AM_RANGE(0x8000, 0x0ffff) AM_RAMBANK(3)
629ADDRESS_MAP_END
630
631/* The I/O ports are decoded into 8 blocks using address lines A3 to A7 */
632static ADDRESS_MAP_START( einstein_io, ADDRESS_SPACE_IO, 8 )
633   /* block 0, ay8910 psg */
634   AM_RANGE(0x02, 0x02) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I030, ay8910_r, ay8910_address_w)
635   AM_RANGE(0x03, 0x03) AM_MIRROR(0xff04) AM_DEVWRITE(IC_I030, ay8910_data_w)
636   /* block 1, tms9928a vdp */
637   AM_RANGE(0x08, 0x08) AM_MIRROR(0xff06) AM_READWRITE(TMS9928A_vram_r, TMS9928A_vram_w)
638   AM_RANGE(0x09, 0x09) AM_MIRROR(0xff06) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w)
639   /* block 2, msm8251 uart */
640   AM_RANGE(0x10, 0x10) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, msm8251_data_r, msm8251_data_w)
641   AM_RANGE(0x11, 0x11) AM_MIRROR(0xff06) AM_DEVREADWRITE(IC_I060, msm8251_status_r, msm8251_control_w)
642   /* block 3, wd1770 floppy controller */
643   AM_RANGE(0x18, 0x1b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I042, wd17xx_r, wd17xx_w)
644   /* block 4, internal controls */
645   AM_RANGE(0x20, 0x20) AM_MIRROR(0xff00) AM_READWRITE(einstein_kybintmsk_r, einstein_kybintmsk_w)
646   AM_RANGE(0x21, 0x21) AM_MIRROR(0xff00) AM_WRITE(einstein_adcintmsk_w)
647   AM_RANGE(0x23, 0x23) AM_MIRROR(0xff00) AM_DEVWRITE(IC_I042, einstein_drsel_w)
648   AM_RANGE(0x24, 0x24) AM_MIRROR(0xff00) AM_WRITE(einstein_rom_w)
649   AM_RANGE(0x25, 0x25) AM_MIRROR(0xff00) AM_WRITE(einstein_fire_int_w)
650   /* block 5, z80ctc */
651   AM_RANGE(0x28, 0x2b) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I058, z80ctc_r, z80ctc_w)
652   /* block 6, z80pio */
653   AM_RANGE(0x30, 0x33) AM_MIRROR(0xff04) AM_DEVREADWRITE(IC_I063, z80pio_r, z80pio_w)
654#if 0
655   /* block 7, adc */
656   AM_RANGE(0x38, 0x38) AM_MIRROR(0xff07) AM_DEVREADWRITE(IC_I050, adc0844_r, adc0844_w)
657#endif
658ADDRESS_MAP_END
659
660static ADDRESS_MAP_START( einstein2_io, ADDRESS_SPACE_IO, 8 )
661   AM_IMPORT_FROM(einstein_io)
662   AM_RANGE(0x40, 0x47) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_READWRITE(einstein_80col_ram_r, einstein_80col_ram_w)
663   AM_RANGE(0x48, 0x48) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_address_w)
664   AM_RANGE(0x49, 0x49) AM_MIRROR(0xff00) AM_DEVWRITE("crtc", mc6845_register_w)
665   AM_RANGE(0x4c, 0x4c) AM_MIRROR(0xff00) AM_READ(einstein_80col_state_r)
666ADDRESS_MAP_END
667
668
669/***************************************************************************
670    INPUT PORTS
671***************************************************************************/
672
673static INPUT_PORTS_START( einstein )
674   PORT_START("LINE0")
675   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("BREAK") PORT_CODE(KEYCODE_LALT)
676   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_1_PAD)
677   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F0") PORT_CODE(KEYCODE_F1)
678   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_3_PAD)
679   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CAPS LOCK") PORT_CODE(KEYCODE_CAPSLOCK)
680   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
681   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SPACE") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
682   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC))
683
684   PORT_START("LINE1")
685   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('I')
686   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('O')
687   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('P')
688   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LEFT") PORT_CODE(KEYCODE_LEFT) PORT_CHAR(UCHAR_MAMEKEY(LEFT))
689   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('\xA3')
690   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DOWN") PORT_CODE(KEYCODE_DOWN) PORT_CHAR(UCHAR_MAMEKEY(DOWN))
691   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('\xBA') PORT_CHAR('\xBD')   // is \xBA correct for double vertical bar || ?
692   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('@')
693
694   PORT_START("LINE2")
695   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('K')
696   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('L')
697   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+')
698   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*')
699   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RIGHT") PORT_CODE(KEYCODE_RIGHT) PORT_CHAR(UCHAR_MAMEKEY(RIGHT))
700   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
701   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')')
702   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F5))
703
704   PORT_START("LINE3")
705   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<')
706   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>')
707   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?')
708   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(')
709   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("DELETE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8)
710   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=') PORT_CHAR('-')
711   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("UP") PORT_CODE(KEYCODE_UP) PORT_CHAR(UCHAR_MAMEKEY(UP))
712   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F4))
713
714   PORT_START("LINE4")
715   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'')
716   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&')
717   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%')
718   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$')
719   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#')
720   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('\"')
721   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!')
722   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F3))
723
724   PORT_START("LINE5")
725   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('U')
726   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y')
727   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('T')
728   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('R')
729   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
730   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('W')
731   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q')
732   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F2))
733
734   PORT_START("LINE6")
735   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('J')
736   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('H')
737   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('G')
738   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
739   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
740   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('S')
741   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
742   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F1))
743
744   PORT_START("LINE7")
745   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('M')
746   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('N')
747   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
748   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('V')
749   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
750   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('X')
751   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z')
752   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F6))
753
754   PORT_START("EXTRA")
755   PORT_BIT(0x1f, IP_ACTIVE_HIGH, IPT_UNUSED)
756   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("GRPH")    PORT_CODE(KEYCODE_F8)
757   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CONTROL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
758   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT")   PORT_CODE(KEYCODE_LSHIFT)   PORT_CODE(KEYCODE_RSHIFT)   PORT_CHAR(UCHAR_SHIFT_1)
759
760   /* fire buttons for analogue joysticks */
761   PORT_START("BUTTONS")
762   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 1 Button 1") PORT_PLAYER(1)
763   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("Joystick 2 Button 1") PORT_PLAYER(2)
764   PORT_BIT(0xfc, IP_ACTIVE_HIGH, IPT_UNUSED)
765
766   /* analog joystick 1 x axis */
767   PORT_START("JOY1_X")
768   PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_REVERSE
769
770   /* analog joystick 1 y axis */
771   PORT_START("JOY1_Y")
772   PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(1) PORT_REVERSE
773
774   /* analog joystick 2 x axis */
775   PORT_START("JOY2_X")
776   PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) PORT_REVERSE
777
778   /* analog joystick 2 Y axis */
779   PORT_START("JOY2_Y")
780   PORT_BIT(0xff, 0x80, IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE
781INPUT_PORTS_END
782
783INPUT_PORTS_START( einstein_80col )
784   PORT_INCLUDE(einstein)
785
786   /* dip switches on the 80 column card */
787   PORT_START("80column_dips")
788   PORT_DIPNAME(0x02, 0x00, "Startup mode")
789   PORT_DIPSETTING(0x00, "40 column")
790   PORT_DIPSETTING(0x02, "80 column")
791   PORT_DIPNAME(0x04, 0x00, "50/60Hz")
792   PORT_DIPSETTING(0x00, "50Hz")
793   PORT_DIPSETTING(0x04, "60Hz")
794INPUT_PORTS_END
795
796
797/***************************************************************************
798    MACHINE DRIVERS
799***************************************************************************/
800
801static const z80ctc_interface einstein_ctc_intf =
802{
803   0,
804   0,
805   einstein_serial_transmit_clock,
806   einstein_serial_receive_clock,
807   z80ctc_trg3_w
808};
809
810
811static const z80pio_interface einstein_pio_intf =
812{
813   DEVCB_NULL,
814   DEVCB_NULL,
815   DEVCB_NULL,
816   DEVCB_DEVICE_HANDLER("centronics", centronics_data_w),
817   DEVCB_NULL,
818   DEVCB_DEVICE_LINE("centronics", centronics_strobe_w),
819   DEVCB_NULL
820};
821
822static const ay8910_interface einstein_ay_interface =
823{
824   AY8910_LEGACY_OUTPUT,
825   AY8910_DEFAULT_LOADS,
826   DEVCB_NULL,
827   DEVCB_MEMORY_HANDLER(IC_I001, PROGRAM, einstein_keyboard_data_read),
828   DEVCB_MEMORY_HANDLER(IC_I001, PROGRAM, einstein_keyboard_line_write),
829   DEVCB_NULL
830};
831
832static const centronics_interface einstein_centronics_config =
833{
834   FALSE,
835   DEVCB_DEVICE_LINE(IC_I063, z80pio_astb_w),
836   DEVCB_NULL,
837   DEVCB_NULL
838};
839
840static const mc6845_interface einstein_crtc6845_interface =
841{
842   "80column",
843   8,
844   NULL,
845   einstein_6845_update_row,
846   NULL,
847   DEVCB_NULL,
848   DEVCB_NULL,
849   DEVCB_NULL,
850   DEVCB_NULL,
851   NULL
852};
853
854
855static MACHINE_DRIVER_START( einstein )
856   /* basic machine hardware */
857   MDRV_CPU_ADD(IC_I001, Z80, XTAL_X002 / 2)
858   MDRV_CPU_PROGRAM_MAP(einstein_mem)
859   MDRV_CPU_IO_MAP(einstein_io)
860   MDRV_CPU_CONFIG(einstein_daisy_chain)
861
862   MDRV_DRIVER_DATA(einstein_state)
863
864   MDRV_MACHINE_START(einstein)
865   MDRV_MACHINE_RESET(einstein)
866
867   /* this is actually clocked at the system clock 4 MHz, but this would be too fast for our
868   driver. So we update at 50Hz and hope this is good enough. */
869   MDRV_TIMER_ADD_PERIODIC("keyboard", einstein_keyboard_timer_callback, HZ(50))
870
871   MDRV_Z80PIO_ADD(IC_I063, einstein_pio_intf)
872
873   MDRV_Z80CTC_ADD(IC_I058, XTAL_X002 / 2, einstein_ctc_intf)
874   /* the input to channel 0 and 1 of the ctc is a 2 MHz clock */
875   MDRV_TIMER_ADD_PERIODIC("ctc", einstein_ctc_trigger_callback, HZ(XTAL_X002 /4))
876
877   /* Einstein daisy chain support for non-Z80 devices */
878   MDRV_DEVICE_ADD("keyboard_daisy", DEVICE_GET_INFO_NAME(einstein_keyboard_daisy), 0)
879   MDRV_DEVICE_ADD("adc_daisy", DEVICE_GET_INFO_NAME(einstein_adc_daisy), 0)
880   MDRV_DEVICE_ADD("fire_daisy", DEVICE_GET_INFO_NAME(einstein_fire_daisy), 0)
881
882    /* video hardware */
883   MDRV_IMPORT_FROM(tms9928a)
884   MDRV_SCREEN_MODIFY("screen")
885   MDRV_SCREEN_REFRESH_RATE(50)
886   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
887
888   /* sound hardware */
889   MDRV_SPEAKER_STANDARD_MONO("mono")
890   MDRV_SOUND_ADD(IC_I030, AY8910, XTAL_X002 / 4)
891   MDRV_SOUND_CONFIG(einstein_ay_interface)
892   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
893
894   /* printer */
895   MDRV_CENTRONICS_ADD("centronics", einstein_centronics_config)
896
897   /* uart */
898   MDRV_MSM8251_ADD(IC_I060, default_msm8251_interface)
899
900   MDRV_WD1770_ADD(IC_I042, default_wd17xx_interface)
901MACHINE_DRIVER_END
902
903
904static MACHINE_DRIVER_START( einstei2 )
905   MDRV_IMPORT_FROM( einstein )
906
907   MDRV_CPU_MODIFY(IC_I001)
908   MDRV_CPU_IO_MAP(einstein2_io)
909   MDRV_MACHINE_RESET(einstein2)
910
911    /* video hardware */
912   MDRV_DEFAULT_LAYOUT(layout_einstei2)
913
914   MDRV_SCREEN_ADD("80column", RASTER)
915   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
916   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
917   MDRV_SCREEN_SIZE(640, 400)
918   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 400-1)
919   MDRV_SCREEN_REFRESH_RATE(50)
920
921   /* 2 additional colors for the 80 column screen */
922   MDRV_PALETTE_LENGTH(TMS9928A_PALETTE_SIZE + 2)
923
924   MDRV_MC6845_ADD("crtc", MC6845, XTAL_X002 / 4, einstein_crtc6845_interface)
925
926   MDRV_VIDEO_UPDATE(einstein2)
927MACHINE_DRIVER_END
928
929
930/***************************************************************************
931    ROM DEFINITIONS
932***************************************************************************/
933
934/* There are two sockets, i023 and i024, each either a 2764 or 27128
935 * only i023 is used by default and fitted with the 8k bios (called MOS).
936 *
937 * We are missing dumps of version MOS 1.1, possibly of 1.0 if it exists.
938 */
939ROM_START( einstein )
940   ROM_REGION(0x8000, "bios", 0)
941   /* i023 */
942   ROM_SYSTEM_BIOS(0,  "mos12",  "MOS 1.2")
943   ROMX_LOAD("mos12.i023", 0, 0x2000, CRC(ec134953) SHA1(a02125d8ebcda48aa784adbb42a8b2d7ef3a4b77), ROM_BIOS(1))
944   ROM_SYSTEM_BIOS(1,  "mos121",  "MOS 1.21")
945   ROMX_LOAD("mos121.i023", 0, 0x2000, CRC(a746eeb6) SHA1(f75aaaa777d0fd92225acba291f6bf428b341d3e), ROM_BIOS(2))
946   ROM_RELOAD(0x2000, 0x2000)
947   /* i024 */
948   ROM_FILL(0x4000, 0x4000, 0xff)
949ROM_END
950
951ROM_START( einstei2 )
952   ROM_REGION(0x8000, "bios", 0)
953   /* i023 */
954   ROM_SYSTEM_BIOS(0,  "mos12",  "MOS 1.2")
955   ROMX_LOAD("mos12.i023", 0, 0x2000, CRC(ec134953) SHA1(a02125d8ebcda48aa784adbb42a8b2d7ef3a4b77), ROM_BIOS(1))
956   ROM_SYSTEM_BIOS(1,  "mos121",  "MOS 1.21")
957   ROMX_LOAD("mos121.i023", 0, 0x2000, CRC(a746eeb6) SHA1(f75aaaa777d0fd92225acba291f6bf428b341d3e), ROM_BIOS(2))
958   ROM_RELOAD(0x2000, 0x2000)
959   /* i024 */
960   ROM_FILL(0x4000, 0x4000, 0xff)
961
962   /* character rom from 80 column card */
963   ROM_REGION(0x800, "gfx1", 0)
964   ROM_LOAD("charrom.rom", 0, 0x800, NO_DUMP)
965ROM_END
966
967
968/***************************************************************************
969    SYSTEM CONFIG
970***************************************************************************/
971
972static void einstein_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
973{
974   /* floppy */
975   switch(state)
976   {
977      /* --- the following bits of info are returned as 64-bit signed integers --- */
978      case MESS_DEVINFO_INT_COUNT:   info->i = 4; break;
979
980      default:                  legacydsk_device_getinfo(devclass, state, info); break;
981   }
982}
983
984static SYSTEM_CONFIG_START( einstein )
985   /* RAM is provided by 8k DRAM ICs i009, i010, i011, i012, i013, i014, i015 and i016 */
986   CONFIG_RAM_DEFAULT(8 * 8 * 1024)
987   CONFIG_DEVICE(einstein_floppy_getinfo)
988SYSTEM_CONFIG_END
989
990
991/***************************************************************************
992    GAME DRIVERS
993***************************************************************************/
994
995/*    YEAR  NAME      PARENT    COMPAT  MACHINE   INPUT           INIT  CONFIG,   COMPANY   FULLNAME                             FLAGS */
996COMP( 1984, einstein, 0,        0,      einstein, einstein,       0,    einstein, "Tatung", "Einstein TC-01",                    0 )
997COMP( 1984, einstei2, einstein, 0,      einstei2, einstein_80col, 0,    einstein, "Tatung", "Einstein TC-01 + 80 column device", 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team