trunk/src/mess/drivers/amaztron.c
| r0 | r242611 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:hap |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | Coleco Amaze-A-Tron |
| 6 | * TMS1100 MCU, labeled MP3405(die label too) |
| 7 | |
| 8 | This is an electronic board game with a selection of 8 maze games, |
| 9 | most of them for 2 players. A 5x5 playing grid and four markers are |
| 10 | required to play. Refer to the official manual for more information. |
| 11 | |
| 12 | ***************************************************************************/ |
| 13 | |
| 14 | #include "emu.h" |
| 15 | #include "cpu/tms0980/tms0980.h" |
| 16 | #include "sound/speaker.h" |
| 17 | |
| 18 | #include "amaztron.lh" |
| 19 | |
| 20 | // master clock is a single stage RC oscillator: R=33K?, C=100pf, |
| 21 | // according to the TMS 1000 series data manual this is around 350kHz |
| 22 | #define MASTER_CLOCK (350000) |
| 23 | |
| 24 | |
| 25 | class amaztron_state : public driver_device |
| 26 | { |
| 27 | public: |
| 28 | amaztron_state(const machine_config &mconfig, device_type type, const char *tag) |
| 29 | : driver_device(mconfig, type, tag), |
| 30 | m_maincpu(*this, "maincpu"), |
| 31 | m_button_matrix(*this, "IN"), |
| 32 | m_speaker(*this, "speaker") |
| 33 | { } |
| 34 | |
| 35 | required_device<cpu_device> m_maincpu; |
| 36 | required_ioport_array<6> m_button_matrix; |
| 37 | required_device<speaker_sound_device> m_speaker; |
| 38 | |
| 39 | UINT16 m_r; |
| 40 | UINT16 m_o; |
| 41 | |
| 42 | DECLARE_READ8_MEMBER(read_k); |
| 43 | DECLARE_WRITE16_MEMBER(write_o); |
| 44 | DECLARE_WRITE16_MEMBER(write_r); |
| 45 | |
| 46 | void leds_update(); |
| 47 | |
| 48 | virtual void machine_start(); |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | |
| 53 | /*************************************************************************** |
| 54 | |
| 55 | I/O |
| 56 | |
| 57 | ***************************************************************************/ |
| 58 | |
| 59 | void amaztron_state::leds_update() |
| 60 | { |
| 61 | for (int i = 0; i < 2; i++) |
| 62 | if (m_r >> (i + 8) & 1) |
| 63 | output_set_digit_value(i, m_o); |
| 64 | } |
| 65 | |
| 66 | READ8_MEMBER(amaztron_state::read_k) |
| 67 | { |
| 68 | UINT8 k = 0; |
| 69 | |
| 70 | // read selected button rows |
| 71 | for (int i = 0; i < 6; i++) |
| 72 | { |
| 73 | if (m_r >> i & 1) |
| 74 | k |= m_button_matrix[i]->read(); |
| 75 | } |
| 76 | |
| 77 | // the 5th row is tied to K4+K8 |
| 78 | if (k & 0x10) k |= 0xc; |
| 79 | return k & 0xf; |
| 80 | } |
| 81 | |
| 82 | WRITE16_MEMBER(amaztron_state::write_r) |
| 83 | { |
| 84 | // R0-R5: input mux |
| 85 | // R6,R7: lamps |
| 86 | output_set_lamp_value(0, data >> 6 & 1); |
| 87 | output_set_lamp_value(1, data >> 7 & 1); |
| 88 | |
| 89 | // R8,R9: select digit |
| 90 | m_r = data; |
| 91 | leds_update(); |
| 92 | |
| 93 | // R10: speaker out |
| 94 | m_speaker->level_w(data >> 10 & 1); |
| 95 | } |
| 96 | |
| 97 | WRITE16_MEMBER(amaztron_state::write_o) |
| 98 | { |
| 99 | // O0-O6: digit segments |
| 100 | // O7: N/C |
| 101 | m_o = data & 0x7f; |
| 102 | leds_update(); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | |
| 107 | /*************************************************************************** |
| 108 | |
| 109 | Inputs |
| 110 | |
| 111 | ***************************************************************************/ |
| 112 | |
| 113 | static INPUT_PORTS_START( amaztron ) |
| 114 | PORT_START("IN.0") // R0 |
| 115 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_NAME("Button 1") |
| 116 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_NAME("Button 6") |
| 117 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_NAME("Button 11") |
| 118 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_NAME("Button 16") |
| 119 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_NAME("Button 21") |
| 120 | |
| 121 | PORT_START("IN.1") // R1 |
| 122 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_NAME("Button 2") |
| 123 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_NAME("Button 7") |
| 124 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_NAME("Button 12") |
| 125 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_NAME("Button 17") |
| 126 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_NAME("Button 22") |
| 127 | |
| 128 | PORT_START("IN.2") // R2 |
| 129 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3) PORT_NAME("Button 3") |
| 130 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_NAME("Button 8") |
| 131 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_NAME("Button 13") |
| 132 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_NAME("Button 18") |
| 133 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_NAME("Button 23") |
| 134 | |
| 135 | PORT_START("IN.3") // R3 |
| 136 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_NAME("Button 4") |
| 137 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_NAME("Button 9") |
| 138 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_NAME("Button 14") |
| 139 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_NAME("Button 19") |
| 140 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_NAME("Button 24") |
| 141 | |
| 142 | PORT_START("IN.4") // R4 |
| 143 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_NAME("Button 5") |
| 144 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_NAME("Button 10") |
| 145 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_NAME("Button 15") |
| 146 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_NAME("Button 20") |
| 147 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_NAME("Button 25") |
| 148 | |
| 149 | PORT_START("IN.5") // R5 |
| 150 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_NAME("Game Select") |
| 151 | PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_NAME("Game Start") |
| 152 | PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_UNUSED) |
| 153 | PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_UNUSED) |
| 154 | PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_UNUSED) |
| 155 | INPUT_PORTS_END |
| 156 | |
| 157 | |
| 158 | |
| 159 | /*************************************************************************** |
| 160 | |
| 161 | Machine Config |
| 162 | |
| 163 | ***************************************************************************/ |
| 164 | |
| 165 | void amaztron_state::machine_start() |
| 166 | { |
| 167 | m_r = 0; |
| 168 | m_o = 0; |
| 169 | |
| 170 | save_item(NAME(m_r)); |
| 171 | save_item(NAME(m_o)); |
| 172 | } |
| 173 | |
| 174 | |
| 175 | static MACHINE_CONFIG_START( amaztron, amaztron_state ) |
| 176 | |
| 177 | /* basic machine hardware */ |
| 178 | MCFG_CPU_ADD("maincpu", TMS1100, MASTER_CLOCK) |
| 179 | MCFG_TMS1XXX_READ_K_CB(READ8(amaztron_state, read_k)) |
| 180 | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(amaztron_state, write_o)) |
| 181 | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(amaztron_state, write_r)) |
| 182 | |
| 183 | MCFG_DEFAULT_LAYOUT(layout_amaztron) |
| 184 | |
| 185 | /* no video! */ |
| 186 | |
| 187 | /* sound hardware */ |
| 188 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 189 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 190 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 191 | MACHINE_CONFIG_END |
| 192 | |
| 193 | |
| 194 | |
| 195 | /*************************************************************************** |
| 196 | |
| 197 | Game driver(s) |
| 198 | |
| 199 | ***************************************************************************/ |
| 200 | |
| 201 | ROM_START( amaztron ) |
| 202 | ROM_REGION( 0x0800, "maincpu", 0 ) |
| 203 | ROM_LOAD( "tms1100nll_mp3405", 0x0000, 0x0800, CRC(9cbc0009) SHA1(17772681271b59280687492f37fa0859998f041d) ) |
| 204 | |
| 205 | ROM_REGION( 867, "maincpu:mpla", 0 ) |
| 206 | ROM_LOAD( "tms1100_amaztron_mpla.pla", 0, 867, CRC(03574895) SHA1(04407cabfb3adee2ee5e4218612cb06c12c540f4) ) |
| 207 | ROM_REGION( 365, "maincpu:opla", 0 ) |
| 208 | ROM_LOAD( "tms1100_amaztron_opla.pla", 0, 365, CRC(f3875384) SHA1(3c256a3db4f0aa9d93cf78124db39f4cbdc57e4a) ) |
| 209 | ROM_END |
| 210 | |
| 211 | |
| 212 | CONS( 1979, amaztron, 0, 0, amaztron, amaztron, driver_device, 0, "Coleco", "Amaze-A-Tron", GAME_SUPPORTS_SAVE ) |