Previous 15994 Revisions Next

r4479 Saturday 11th April, 2009 at 02:39:00 UTC by Robbbert
[TEC1] Improved keyboard and added documentation.
[src/mess/drivers]tec1.c

src/mess/drivers/tec1.c
r4478r4479
11/***************************************************************************
22 
3   TEC-1 driver, written by Robbbert in April, 2009 for MESS.
4 
5The TEC-1 was a single-board "computer" described in Talking Electronics
6magazine, issues number 10 and 11. Talking Electronics do not have dates on
7their issues, so the date is uncertain, although 1984 seems a reasonable
8guess. Talking Electronics operated from Cheltenham, a suburb of Melbourne.
9 
10The hardware is quite simple, consisting of a Z80 cpu, 2x 8212 8-bit latch,
1174C923 keyboard scanner, 20 push-button keys, 6-digit LED display, a speaker,
12a 2k EPROM and sundry parts.
13 
14The cpu speed could be adjusted by using a potentiometer, the range being
15250 kHz to 2MHz. This is a simple method of adjusting a game's difficulty.
16 
17We emulate the original version. Later enhancements included more RAM, speech
18synthesis and various attachments, however I have no information on these.
19 
20Keys:
210 to 9, A to F are on the key of the same name.
22AD (input an address) is the J key.
23+ and - (increment / decrement address) are the - and = keys.
24GO (execute program at current address) is the Enter key.
25Whenever a program listing mentions RESET, do a Soft Reset.
26 
27Each key causes a beep to be heard. You may need to press more than once
28to get it to register.
29 
30Inbuilt games - press the following sequence of keys:
31- Welcome: RESET D 1 + 0 2 AD 0 2 7 0 GO GO
32- Nim: RESET AD 3 E 0 GO GO
33- Invaders: RESET AD 3 2 0 GO GO
34- Luna Lander: RESET AD 4 9 0 GO GO
35 
36Not emulated / need to be checked:
37- The 74C923 code may need to be revisited to improve keyboard response.
38- The 10ms debounce is not emulated.
39- Artwork needs to be produced.
40 
41Thanks to Chris Schwartz who dumped his ROM for me way back in the old days.
42It's only taken 25 years to get around to emulating it...
43 
344***************************************************************************/
445 
5/* Core includes */
646#include "driver.h"
747#include "cpu/z80/z80.h"
848#include "sound/speaker.h"
r4478r4479
1050 
1151static emu_timer *tec1_kbd_timer;
1252static UINT8 tec1_kbd=0;
13static UINT8 tec1_nmi=0;
1453static UINT8 tec1_segment=0;
1554static UINT8 tec1_digit=0;
1655static const device_config *tec1_speaker;
1756 
1857 
58/***************************************************************************
59 
60   Display
61 
62***************************************************************************/
63 
1964static void tec1_display(void)
2065{
2166   UINT8 i;
r4478r4479
2671 
2772static WRITE8_HANDLER( tec1_segment_w )
2873{
74/*   d7 segment d
75   d6 segment e
76   d5 segment c
77   d4 segment dot
78   d3 segment b
79   d2 segment g
80   d1 segment f
81   d0 segment a */
82 
2983   tec1_segment = BITSWAP8(data, 4, 2, 1, 6, 7, 5, 3, 0);
30   tec1_display();
84   if (tec1_digit) tec1_display();
3185}
3286 
3387static WRITE8_HANDLER( tec1_digit_w )
3488{
89/*    d7 speaker
90   d6 not used
91   d5 data digit 1
92   d4 data digit 2
93   d3 address digit 1
94   d2 address digit 2
95   d1 address digit 3
96   d0 address digit 4 */
97 
98   speaker_level_w(tec1_speaker, (data & 0x80) ? 1 : 0);
99 
35100   tec1_digit = data & 0x3f;
36   speaker_level_w(tec1_speaker, (data & 0x80) ? 1 : 0);
37   tec1_display();
101   if (tec1_digit) tec1_display();
38102}
39103 
104 
105/***************************************************************************
106 
107   Keyboard
108 
109***************************************************************************/
110 
40111static READ8_HANDLER( tec1_kbd_r )
41112{
42   UINT8 data = tec1_kbd;
43113   cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE);
44   tec1_nmi = 0;
114   return tec1_kbd;
115}
116   
117static UINT8 tec1_convert_col_to_bin( UINT8 col, UINT8 row )
118{
119   UINT8 data = row;
120 
121   if (col & 2)
122      data |= 4;
123   else
124   if (col & 4)
125      data |= 8;
126   else
127   if (col & 8)
128      data |= 12;
129   else
130   if (col & 16)
131      data |= 16;
132 
45133   return data;
46134}
47   
135 
136 
137static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3" };
138 
48139static TIMER_CALLBACK( tec1_kbd_callback )
49140{
50/* 74C923 4 by 5 key encoder. If a key is pressed, scanning stops. */
141/* 74C923 4 by 5 key encoder. */
51142 
143 
52144   static UINT8 row=0;
53   if (tec1_nmi) return;
145 
146   /* if previous key is still held, bail out */
147   if (input_port_read(machine, keynames[row]))
148      if (tec1_convert_col_to_bin(input_port_read(machine, keynames[row]), row) == tec1_kbd)
149         return; 
150       
54151   row++;
55152   row &= 3;
56153 
57154   /* see if a key pressed */
58   if (row == 0)
59      tec1_kbd = input_port_read(machine, "LINE0");
60   else
61   if (row == 1)
62      tec1_kbd = input_port_read(machine, "LINE1");
63   else
64   if (row == 2)
65      tec1_kbd = input_port_read(machine, "LINE2");
66   else
67   if (row == 3)
68      tec1_kbd = input_port_read(machine, "LINE3");
69 
70   /* convert to the code that the chip uses */
71   if (tec1_kbd)
155   if (input_port_read(machine, keynames[row]))
72156   {
73      if (tec1_kbd & 1)
74         tec1_kbd = 0;
75      else
76      if (tec1_kbd & 2)
77         tec1_kbd = 4;
78      else
79      if (tec1_kbd & 4)
80         tec1_kbd = 8;
81      else
82      if (tec1_kbd & 8)
83         tec1_kbd = 12;
84      else
85      if (tec1_kbd & 16)
86         tec1_kbd = 16;
87 
88      tec1_kbd |= row;
89      tec1_nmi = 1;
157      tec1_kbd = tec1_convert_col_to_bin(input_port_read(machine, keynames[row]), row);
90158      cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, HOLD_LINE);
91159   }
92160}
93161 
162 
163/***************************************************************************
164 
165   Machine
166 
167***************************************************************************/
168 
94169static MACHINE_RESET( tec1 )
95170{
96171   tec1_kbd_timer = timer_alloc(machine,  tec1_kbd_callback, NULL );
97   timer_adjust_periodic( tec1_kbd_timer, attotime_zero, 0, ATTOTIME_IN_HZ(30) );
172   timer_adjust_periodic( tec1_kbd_timer, attotime_zero, 0, ATTOTIME_IN_HZ(500) );
98173   tec1_speaker = devtag_get_device(machine, "speaker");
99174}
100175 
101176 
177/***************************************************************************
178 
179   Address Map
180 
181***************************************************************************/
182 
102183static ADDRESS_MAP_START( tec1_map, ADDRESS_SPACE_PROGRAM, 8 )
103184   ADDRESS_MAP_GLOBAL_MASK(0x3fff)
104185   AM_RANGE(0x0000, 0x07ff) AM_ROM
r4478r4479
115196 
116197/**************************************************************************
117198 
118   Keyboard
199   Keyboard Layout
119200 
120201***************************************************************************/
121202 
r4478r4479
150231INPUT_PORTS_END
151232 
152233 
234/***************************************************************************
235 
236   Machine driver
237 
238***************************************************************************/
239 
153240static MACHINE_DRIVER_START( tec1 )
154241   /* basic machine hardware */
155242   MDRV_CPU_ADD("maincpu", Z80, 500000)   /* speed can be varied between 250kHz and 2MHz */
r4478r4479
170257 
171258/***************************************************************************
172259 
173  Game driver(s)
260   Game driver
174261 
175262***************************************************************************/
176263 
r4478r4479
184271ROM_END
185272 
186273/*    YEAR  NAME      PARENT  COMPAT  MACHINE     INPUT    INIT      CONFIG       COMPANY  FULLNAME */
187COMP( 1984, tec1,     0,      0,      tec1,       tec1,    0,        0,      "Talking Electronics Magazine",  "TEC-1" , 0 )
274COMP( 1984, tec1,     0,      0,      tec1,       tec1,    0,        0,      "Talking Electronics magazine",  "TEC-1" , 0 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team