src/mess/drivers/tec1.c
| r4478 | r4479 | |
| 1 | 1 | /***************************************************************************
|
| 2 | 2 | |
| 3 | TEC-1 driver, written by Robbbert in April, 2009 for MESS.
|
| 4 | |
| 5 | The TEC-1 was a single-board "computer" described in Talking Electronics
|
| 6 | magazine, issues number 10 and 11. Talking Electronics do not have dates on
|
| 7 | their issues, so the date is uncertain, although 1984 seems a reasonable
|
| 8 | guess. Talking Electronics operated from Cheltenham, a suburb of Melbourne.
|
| 9 | |
| 10 | The hardware is quite simple, consisting of a Z80 cpu, 2x 8212 8-bit latch,
|
| 11 | 74C923 keyboard scanner, 20 push-button keys, 6-digit LED display, a speaker,
|
| 12 | a 2k EPROM and sundry parts.
|
| 13 | |
| 14 | The cpu speed could be adjusted by using a potentiometer, the range being
|
| 15 | 250 kHz to 2MHz. This is a simple method of adjusting a game's difficulty.
|
| 16 | |
| 17 | We emulate the original version. Later enhancements included more RAM, speech
|
| 18 | synthesis and various attachments, however I have no information on these.
|
| 19 | |
| 20 | Keys:
|
| 21 | 0 to 9, A to F are on the key of the same name.
|
| 22 | AD (input an address) is the J key.
|
| 23 | + and - (increment / decrement address) are the - and = keys.
|
| 24 | GO (execute program at current address) is the Enter key.
|
| 25 | Whenever a program listing mentions RESET, do a Soft Reset.
|
| 26 | |
| 27 | Each key causes a beep to be heard. You may need to press more than once
|
| 28 | to get it to register.
|
| 29 | |
| 30 | Inbuilt 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 | |
| 36 | Not 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 | |
| 41 | Thanks to Chris Schwartz who dumped his ROM for me way back in the old days.
|
| 42 | It's only taken 25 years to get around to emulating it...
|
| 43 | |
| 3 | 44 | ***************************************************************************/
|
| 4 | 45 | |
| 5 | | /* Core includes */
|
| 6 | 46 | #include "driver.h"
|
| 7 | 47 | #include "cpu/z80/z80.h"
|
| 8 | 48 | #include "sound/speaker.h"
|
| r4478 | r4479 | |
| 10 | 50 | |
| 11 | 51 | static emu_timer *tec1_kbd_timer;
|
| 12 | 52 | static UINT8 tec1_kbd=0;
|
| 13 | | static UINT8 tec1_nmi=0;
|
| 14 | 53 | static UINT8 tec1_segment=0;
|
| 15 | 54 | static UINT8 tec1_digit=0;
|
| 16 | 55 | static const device_config *tec1_speaker;
|
| 17 | 56 | |
| 18 | 57 | |
| 58 | /***************************************************************************
|
| 59 | |
| 60 | Display
|
| 61 | |
| 62 | ***************************************************************************/
|
| 63 | |
| 19 | 64 | static void tec1_display(void)
|
| 20 | 65 | {
|
| 21 | 66 | UINT8 i;
|
| r4478 | r4479 | |
| 26 | 71 | |
| 27 | 72 | static WRITE8_HANDLER( tec1_segment_w )
|
| 28 | 73 | {
|
| 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 | |
| 29 | 83 | tec1_segment = BITSWAP8(data, 4, 2, 1, 6, 7, 5, 3, 0);
|
| 30 | | tec1_display();
|
| 84 | if (tec1_digit) tec1_display();
|
| 31 | 85 | }
|
| 32 | 86 | |
| 33 | 87 | static WRITE8_HANDLER( tec1_digit_w )
|
| 34 | 88 | {
|
| 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 | |
| 35 | 100 | tec1_digit = data & 0x3f;
|
| 36 | | speaker_level_w(tec1_speaker, (data & 0x80) ? 1 : 0);
|
| 37 | | tec1_display();
|
| 101 | if (tec1_digit) tec1_display();
|
| 38 | 102 | }
|
| 39 | 103 | |
| 104 | |
| 105 | /***************************************************************************
|
| 106 | |
| 107 | Keyboard
|
| 108 | |
| 109 | ***************************************************************************/
|
| 110 | |
| 40 | 111 | static READ8_HANDLER( tec1_kbd_r )
|
| 41 | 112 | {
|
| 42 | | UINT8 data = tec1_kbd;
|
| 43 | 113 | cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE);
|
| 44 | | tec1_nmi = 0;
|
| 114 | return tec1_kbd;
|
| 115 | }
|
| 116 |
|
| 117 | static 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 | |
| 45 | 133 | return data;
|
| 46 | 134 | }
|
| 47 | |
|
| 135 | |
| 136 | |
| 137 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3" };
|
| 138 | |
| 48 | 139 | static TIMER_CALLBACK( tec1_kbd_callback )
|
| 49 | 140 | {
|
| 50 | | /* 74C923 4 by 5 key encoder. If a key is pressed, scanning stops. */
|
| 141 | /* 74C923 4 by 5 key encoder. */
|
| 51 | 142 | |
| 143 | |
| 52 | 144 | 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 | |
| 54 | 151 | row++;
|
| 55 | 152 | row &= 3;
|
| 56 | 153 | |
| 57 | 154 | /* 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]))
|
| 72 | 156 | {
|
| 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);
|
| 90 | 158 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, HOLD_LINE);
|
| 91 | 159 | }
|
| 92 | 160 | }
|
| 93 | 161 | |
| 162 | |
| 163 | /***************************************************************************
|
| 164 | |
| 165 | Machine
|
| 166 | |
| 167 | ***************************************************************************/
|
| 168 | |
| 94 | 169 | static MACHINE_RESET( tec1 )
|
| 95 | 170 | {
|
| 96 | 171 | 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) );
|
| 98 | 173 | tec1_speaker = devtag_get_device(machine, "speaker");
|
| 99 | 174 | }
|
| 100 | 175 | |
| 101 | 176 | |
| 177 | /***************************************************************************
|
| 178 | |
| 179 | Address Map
|
| 180 | |
| 181 | ***************************************************************************/
|
| 182 | |
| 102 | 183 | static ADDRESS_MAP_START( tec1_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 103 | 184 | ADDRESS_MAP_GLOBAL_MASK(0x3fff)
|
| 104 | 185 | AM_RANGE(0x0000, 0x07ff) AM_ROM
|
| r4478 | r4479 | |
| 115 | 196 | |
| 116 | 197 | /**************************************************************************
|
| 117 | 198 | |
| 118 | | Keyboard
|
| 199 | Keyboard Layout
|
| 119 | 200 | |
| 120 | 201 | ***************************************************************************/
|
| 121 | 202 | |
| r4478 | r4479 | |
| 150 | 231 | INPUT_PORTS_END
|
| 151 | 232 | |
| 152 | 233 | |
| 234 | /***************************************************************************
|
| 235 | |
| 236 | Machine driver
|
| 237 | |
| 238 | ***************************************************************************/
|
| 239 | |
| 153 | 240 | static MACHINE_DRIVER_START( tec1 )
|
| 154 | 241 | /* basic machine hardware */
|
| 155 | 242 | MDRV_CPU_ADD("maincpu", Z80, 500000) /* speed can be varied between 250kHz and 2MHz */
|
| r4478 | r4479 | |
| 170 | 257 | |
| 171 | 258 | /***************************************************************************
|
| 172 | 259 | |
| 173 | | Game driver(s)
|
| 260 | Game driver
|
| 174 | 261 | |
| 175 | 262 | ***************************************************************************/
|
| 176 | 263 | |
| r4478 | r4479 | |
| 184 | 271 | ROM_END
|
| 185 | 272 | |
| 186 | 273 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */
|
| 187 | | COMP( 1984, tec1, 0, 0, tec1, tec1, 0, 0, "Talking Electronics Magazine", "TEC-1" , 0 )
|
| 274 | COMP( 1984, tec1, 0, 0, tec1, tec1, 0, 0, "Talking Electronics magazine", "TEC-1" , 0 )
|