src/mess/drivers/tec1.c
| r0 | r4472 | |
| 1 | /***************************************************************************
|
| 2 | |
| 3 | ***************************************************************************/
|
| 4 | |
| 5 | /* Core includes */
|
| 6 | #include "driver.h"
|
| 7 | #include "cpu/z80/z80.h"
|
| 8 | #include "sound/speaker.h"
|
| 9 | #include "tec1.lh"
|
| 10 | |
| 11 | static emu_timer *tec1_kbd_timer;
|
| 12 | static UINT8 tec1_kbd=0;
|
| 13 | static UINT8 tec1_nmi=0;
|
| 14 | static UINT8 tec1_segment=0;
|
| 15 | static UINT8 tec1_digit=0;
|
| 16 | static const device_config *tec1_speaker;
|
| 17 | |
| 18 | |
| 19 | static void tec1_display(void)
|
| 20 | {
|
| 21 | UINT8 i;
|
| 22 | for (i = 0; i < 6; i++)
|
| 23 | if (tec1_digit & (1 << i))
|
| 24 | output_set_digit_value(5-i, tec1_segment);
|
| 25 | }
|
| 26 | |
| 27 | static WRITE8_HANDLER( tec1_segment_w )
|
| 28 | {
|
| 29 | tec1_segment = BITSWAP8(data, 4, 2, 1, 6, 7, 5, 3, 0);
|
| 30 | tec1_display();
|
| 31 | }
|
| 32 | |
| 33 | static WRITE8_HANDLER( tec1_digit_w )
|
| 34 | {
|
| 35 | tec1_digit = data & 0x3f;
|
| 36 | speaker_level_w(tec1_speaker, (data & 0x80) ? 1 : 0);
|
| 37 | tec1_display();
|
| 38 | }
|
| 39 | |
| 40 | static READ8_HANDLER( tec1_kbd_r )
|
| 41 | {
|
| 42 | UINT8 data = tec1_kbd;
|
| 43 | cpu_set_input_line(space->machine->cpu[0], INPUT_LINE_NMI, CLEAR_LINE);
|
| 44 | tec1_nmi = 0;
|
| 45 | return data;
|
| 46 | }
|
| 47 |
|
| 48 | static TIMER_CALLBACK( tec1_kbd_callback )
|
| 49 | {
|
| 50 | /* 74C923 4 by 5 key encoder. If a key is pressed, scanning stops. */
|
| 51 | |
| 52 | static UINT8 row=0;
|
| 53 | if (tec1_nmi) return;
|
| 54 | row++;
|
| 55 | row &= 3;
|
| 56 | |
| 57 | /* 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)
|
| 72 | {
|
| 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;
|
| 90 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, HOLD_LINE);
|
| 91 | }
|
| 92 | }
|
| 93 | |
| 94 | static MACHINE_RESET( tec1 )
|
| 95 | {
|
| 96 | tec1_kbd_timer = timer_alloc(machine, tec1_kbd_callback, NULL );
|
| 97 | timer_adjust_periodic( tec1_kbd_timer, attotime_zero, 0, ATTOTIME_IN_HZ(30) );
|
| 98 | tec1_speaker = devtag_get_device(machine, "speaker");
|
| 99 | }
|
| 100 | |
| 101 | |
| 102 | static ADDRESS_MAP_START( tec1_map, ADDRESS_SPACE_PROGRAM, 8 )
|
| 103 | ADDRESS_MAP_GLOBAL_MASK(0x3fff)
|
| 104 | AM_RANGE(0x0000, 0x07ff) AM_ROM
|
| 105 | AM_RANGE(0x0800, 0x17ff) AM_RAM
|
| 106 | ADDRESS_MAP_END
|
| 107 | |
| 108 | static ADDRESS_MAP_START( tec1_io, ADDRESS_SPACE_IO, 8 )
|
| 109 | ADDRESS_MAP_GLOBAL_MASK(0x07)
|
| 110 | AM_RANGE(0x00, 0x00) AM_READ(tec1_kbd_r)
|
| 111 | AM_RANGE(0x01, 0x01) AM_WRITE(tec1_digit_w)
|
| 112 | AM_RANGE(0x02, 0x02) AM_WRITE(tec1_segment_w)
|
| 113 | ADDRESS_MAP_END
|
| 114 | |
| 115 | |
| 116 | /**************************************************************************
|
| 117 | |
| 118 | Keyboard
|
| 119 | |
| 120 | ***************************************************************************/
|
| 121 | |
| 122 | static INPUT_PORTS_START( tec1 )
|
| 123 | PORT_START("LINE0") /* KEY ROW 0 */
|
| 124 | PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
|
| 125 | PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) PORT_CHAR('4')
|
| 126 | PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) PORT_CHAR('8')
|
| 127 | PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) PORT_CHAR('C')
|
| 128 | PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('=')
|
| 129 | |
| 130 | PORT_START("LINE1") /* KEY ROW 1 */
|
| 131 | PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) PORT_CHAR('1')
|
| 132 | PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) PORT_CHAR('5')
|
| 133 | PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) PORT_CHAR('9')
|
| 134 | PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) PORT_CHAR('D')
|
| 135 | PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-')
|
| 136 | |
| 137 | PORT_START("LINE2") /* KEY ROW 2 */
|
| 138 | PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) PORT_CHAR('2')
|
| 139 | PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) PORT_CHAR('6')
|
| 140 | PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) PORT_CHAR('A')
|
| 141 | PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) PORT_CHAR('E')
|
| 142 | PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_NAME("GO") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
|
| 143 | |
| 144 | PORT_START("LINE3") /* KEY ROW 3 */
|
| 145 | PORT_BIT(0x01, 0x00, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) PORT_CHAR('3')
|
| 146 | PORT_BIT(0x02, 0x00, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) PORT_CHAR('7')
|
| 147 | PORT_BIT(0x04, 0x00, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) PORT_CHAR('B')
|
| 148 | PORT_BIT(0x08, 0x00, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
|
| 149 | PORT_BIT(0x10, 0x00, IPT_KEYBOARD) PORT_NAME("AD") PORT_CODE(KEYCODE_J) PORT_CHAR('J')
|
| 150 | INPUT_PORTS_END
|
| 151 | |
| 152 | |
| 153 | static MACHINE_DRIVER_START( tec1 )
|
| 154 | /* basic machine hardware */
|
| 155 | MDRV_CPU_ADD("maincpu", Z80, 500000) /* speed can be varied between 250kHz and 2MHz */
|
| 156 | MDRV_CPU_PROGRAM_MAP(tec1_map, 0)
|
| 157 | MDRV_CPU_IO_MAP(tec1_io, 0)
|
| 158 | |
| 159 | MDRV_MACHINE_RESET(tec1)
|
| 160 | |
| 161 | /* video hardware */
|
| 162 | MDRV_DEFAULT_LAYOUT(layout_tec1)
|
| 163 | |
| 164 | /* sound hardware */
|
| 165 | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 166 | MDRV_SOUND_ADD("speaker", SPEAKER, 0)
|
| 167 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
|
| 168 | MACHINE_DRIVER_END
|
| 169 | |
| 170 | |
| 171 | /***************************************************************************
|
| 172 | |
| 173 | Game driver(s)
|
| 174 | |
| 175 | ***************************************************************************/
|
| 176 | |
| 177 | ROM_START(tec1)
|
| 178 | ROM_REGION(0x10000, "maincpu", 0)
|
| 179 | ROM_LOAD("tec1.rom", 0x0000, 0x0800, CRC(b3390c36) SHA1(18aabc68d473206b7fc4e365c6b57a4e218482c3) )
|
| 180 | // ROM_SYSTEM_BIOS(0, "tec1", "TEC-1")
|
| 181 | // ROMX_LOAD("tec1.rom", 0x0000, 0x0800, CRC(b3390c36) SHA1(18aabc68d473206b7fc4e365c6b57a4e218482c3), ROM_BIOS(1))
|
| 182 | // ROM_SYSTEM_BIOS(1, "tec1a", "TEC-1A")
|
| 183 | // ROMX_LOAD("tec1a.rom", 0x0000, 0x0800, CRC(60daea3c) SHA1(383b7e7f02e91fb18c87eb03c5949e31156771d4), ROM_BIOS(2))
|
| 184 | ROM_END
|
| 185 | |
| 186 | /* 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 )
|