trunk/src/mess/drivers/hh_tms1k.c
| r243823 | r243824 | |
| 14 | 14 | #include "sound/speaker.h" |
| 15 | 15 | |
| 16 | 16 | #include "ebball.lh" |
| 17 | #include "tc4.lh" |
| 17 | 18 | |
| 18 | 19 | |
| 19 | 20 | class hh_tms1k_state : public driver_device |
| r243823 | r243824 | |
| 22 | 23 | hh_tms1k_state(const machine_config &mconfig, device_type type, const char *tag) |
| 23 | 24 | : driver_device(mconfig, type, tag), |
| 24 | 25 | m_maincpu(*this, "maincpu"), |
| 25 | | // m_button_matrix(*this, "IN"), |
| 26 | | m_speaker(*this, "speaker") |
| 26 | m_inp_matrix(*this, "IN"), |
| 27 | m_speaker(*this, "speaker"), |
| 28 | m_display_maxy(0), |
| 29 | m_display_maxx(0), |
| 30 | m_display_wait(50) |
| 27 | 31 | { } |
| 28 | 32 | |
| 29 | 33 | required_device<cpu_device> m_maincpu; |
| 30 | | // required_ioport_array<3> m_button_matrix; |
| 31 | | required_device<speaker_sound_device> m_speaker; |
| 34 | optional_ioport_array<7> m_inp_matrix; // max 7 |
| 35 | optional_device<speaker_sound_device> m_speaker; |
| 36 | |
| 37 | UINT16 m_r; |
| 38 | UINT16 m_o; |
| 39 | UINT16 m_inp_mux; |
| 32 | 40 | |
| 41 | int m_display_maxy; |
| 42 | int m_display_maxx; |
| 43 | int m_display_wait; |
| 44 | |
| 45 | UINT32 m_display_state[0x20]; |
| 46 | UINT32 m_display_cache[0x20]; |
| 47 | UINT8 m_display_decay[0x20][0x20]; |
| 48 | UINT16 m_7seg_mask[0x20]; |
| 49 | |
| 50 | UINT8 read_inputs(int columns); |
| 51 | |
| 52 | // game-specific handlers |
| 53 | void tc4_display(); |
| 54 | DECLARE_READ8_MEMBER(tc4_read_k); |
| 55 | DECLARE_WRITE16_MEMBER(tc4_write_o); |
| 56 | DECLARE_WRITE16_MEMBER(tc4_write_r); |
| 57 | |
| 58 | TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); |
| 59 | bool index_is_7segled(int index); |
| 60 | void display_update(); |
| 61 | |
| 62 | |
| 33 | 63 | virtual void machine_start(); |
| 34 | 64 | }; |
| 35 | 65 | |
| 36 | 66 | |
| 37 | | static INPUT_PORTS_START( ebball ) |
| 38 | | INPUT_PORTS_END |
| 67 | void hh_tms1k_state::machine_start() |
| 68 | { |
| 69 | // zerofill |
| 70 | memset(m_display_state, 0, sizeof(m_display_state)); |
| 71 | memset(m_display_cache, 0, sizeof(m_display_cache)); |
| 72 | memset(m_display_decay, 0, sizeof(m_display_decay)); |
| 73 | memset(m_7seg_mask, 0, sizeof(m_7seg_mask)); |
| 39 | 74 | |
| 75 | m_o = 0; |
| 76 | m_r = 0; |
| 77 | m_inp_mux = 0; |
| 40 | 78 | |
| 79 | // register for savestates |
| 80 | save_item(NAME(m_display_maxy)); |
| 81 | save_item(NAME(m_display_maxx)); |
| 82 | save_item(NAME(m_display_wait)); |
| 41 | 83 | |
| 84 | save_item(NAME(m_display_state)); |
| 85 | save_item(NAME(m_display_cache)); |
| 86 | save_item(NAME(m_display_decay)); |
| 87 | save_item(NAME(m_7seg_mask)); |
| 88 | |
| 89 | save_item(NAME(m_o)); |
| 90 | save_item(NAME(m_r)); |
| 91 | save_item(NAME(m_inp_mux)); |
| 92 | } |
| 93 | |
| 94 | |
| 42 | 95 | /*************************************************************************** |
| 43 | 96 | |
| 44 | | Machine Config |
| 97 | Helper Functions |
| 45 | 98 | |
| 46 | 99 | ***************************************************************************/ |
| 47 | 100 | |
| 48 | | void hh_tms1k_state::machine_start() |
| 101 | |
| 102 | // The device strobes the outputs very fast, it is unnoticeable to the user. |
| 103 | // To prevent flickering here, we need to simulate a decay. |
| 104 | |
| 105 | |
| 106 | void hh_tms1k_state::display_update() |
| 49 | 107 | { |
| 108 | UINT32 active_state[0x20]; |
| 109 | |
| 110 | for (int y = 0; y < m_display_maxy; y++) |
| 111 | { |
| 112 | active_state[y] = 0; |
| 113 | |
| 114 | for (int x = 0; x < m_display_maxx; x++) |
| 115 | { |
| 116 | // turn on powered segments |
| 117 | if (m_display_state[y] >> x & 1) |
| 118 | m_display_decay[y][x] = m_display_wait; |
| 119 | |
| 120 | // determine active state |
| 121 | int ds = (m_display_decay[y][x] != 0) ? 1 : 0; |
| 122 | active_state[y] |= (ds << x); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // on difference, send to output |
| 127 | for (int y = 0; y < m_display_maxy; y++) |
| 128 | if (m_display_cache[y] != active_state[y]) |
| 129 | { |
| 130 | if (m_7seg_mask[y] != 0) |
| 131 | output_set_digit_value(y, active_state[y] & m_7seg_mask[y]); |
| 132 | |
| 133 | const int mul = (m_display_maxx <= 10) ? 10 : 100; |
| 134 | for (int x = 0; x < m_display_maxx; x++) |
| 135 | output_set_lamp_value(y * mul + x, active_state[y] >> x & 1); |
| 136 | } |
| 137 | |
| 138 | memcpy(m_display_cache, active_state, sizeof(m_display_cache)); |
| 50 | 139 | } |
| 51 | 140 | |
| 141 | TIMER_DEVICE_CALLBACK_MEMBER(hh_tms1k_state::display_decay_tick) |
| 142 | { |
| 143 | // slowly turn off unpowered segments |
| 144 | for (int y = 0; y < m_display_maxy; y++) |
| 145 | for (int x = 0; x < m_display_maxx; x++) |
| 146 | if (!(m_display_state[y] >> x & 1) && m_display_decay[y][x] != 0) |
| 147 | m_display_decay[y][x]--; |
| 148 | |
| 149 | display_update(); |
| 150 | } |
| 52 | 151 | |
| 152 | |
| 153 | UINT8 hh_tms1k_state::read_inputs(int columns) |
| 154 | { |
| 155 | UINT8 k = 0; |
| 156 | |
| 157 | // read selected input rows |
| 158 | for (int i = 0; i < columns; i++) |
| 159 | if (m_inp_mux >> i & 1) |
| 160 | k |= m_inp_matrix[i]->read(); |
| 161 | |
| 162 | return k; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | |
| 167 | /*************************************************************************** |
| 168 | |
| 169 | Minidrivers (I/O, Inputs, Machine Config) |
| 170 | |
| 171 | ***************************************************************************/ |
| 172 | |
| 173 | /*************************************************************************** |
| 174 | |
| 175 | Coleco Total Control 4 |
| 176 | * TMS1400NLL MP7334-N2 (die labeled MP7334) |
| 177 | |
| 178 | This is a head to head electronic tabletop LED-display sports console. |
| 179 | One cartridge(Football) was included with the console, the other three were |
| 180 | sold separately. Gameplay has emphasis on strategy, read the official manual |
| 181 | on how to play. Remember that you can rotate the view in MESS: rotate left |
| 182 | for Home(P1) orientation, rotate right for Visitor(P2) orientation. |
| 183 | |
| 184 | Cartridge socket: |
| 185 | 1 N/C |
| 186 | 2 9V+ |
| 187 | 3 power switch |
| 188 | 4 K8 |
| 189 | 5 K4 |
| 190 | 6 K2 |
| 191 | 7 K1 |
| 192 | 8 R9 |
| 193 | |
| 194 | The cartridge connects pin 8 with one of the K-pins. |
| 195 | |
| 196 | Available cartridges: |
| 197 | - Football (K8, confirmed) |
| 198 | - Hockey (K4?) |
| 199 | - Soccer (K2?) |
| 200 | - Basketball (K1?) |
| 201 | |
| 202 | |
| 203 | TODO: |
| 204 | - pin configuration of other carts is guessed |
| 205 | - softlist for the cartridges? |
| 206 | - offsensive players leds are supposed to look brighter |
| 207 | - MCU clock is unknown |
| 208 | |
| 209 | ***************************************************************************/ |
| 210 | |
| 211 | void hh_tms1k_state::tc4_display() |
| 212 | { |
| 213 | m_display_maxy = 10; |
| 214 | m_display_maxx = 9; |
| 215 | |
| 216 | // R5,7,8,9 are 7segs |
| 217 | for (int y = 0; y < m_display_maxy; y++) |
| 218 | if (y >= 5 && y <= 9 && y != 6) |
| 219 | m_7seg_mask[y] = 0x7f; |
| 220 | |
| 221 | // update current state (note: R6 as extra column!) |
| 222 | for (int y = 0; y < m_display_maxy; y++) |
| 223 | m_display_state[y] = (m_r >> y & 1) ? (m_o | (m_r << 2 & 0x100)) : 0; |
| 224 | |
| 225 | display_update(); |
| 226 | } |
| 227 | |
| 228 | READ8_MEMBER(hh_tms1k_state::tc4_read_k) |
| 229 | { |
| 230 | UINT8 k = read_inputs(6); |
| 231 | |
| 232 | // read from cartridge |
| 233 | if (m_inp_mux & 0x200) |
| 234 | k |= m_inp_matrix[6]->read(); |
| 235 | |
| 236 | return k; |
| 237 | } |
| 238 | |
| 239 | WRITE16_MEMBER(hh_tms1k_state::tc4_write_o) |
| 240 | { |
| 241 | // O0-O7: leds/7segment |
| 242 | m_o = data; |
| 243 | tc4_display(); |
| 244 | } |
| 245 | |
| 246 | WRITE16_MEMBER(hh_tms1k_state::tc4_write_r) |
| 247 | { |
| 248 | // R10: speaker out |
| 249 | m_speaker->level_w(data >> 10 & 1); |
| 250 | |
| 251 | // R0-R5: input mux |
| 252 | // R9: to cartridge slot |
| 253 | m_inp_mux = data & 0x23f; |
| 254 | |
| 255 | // R6: led column 8 |
| 256 | // +other: select leds |
| 257 | m_r = data; |
| 258 | tc4_display(); |
| 259 | } |
| 260 | |
| 261 | |
| 262 | static INPUT_PORTS_START( tc4 ) |
| 263 | PORT_START("IN.0") // R0 |
| 264 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Pass/Shoot Button 3") // right |
| 265 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Pass/Shoot Button 1") // left |
| 266 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Pass/Shoot Button 2") // middle |
| 267 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 D/K Button") |
| 268 | |
| 269 | PORT_START("IN.1") // R1 |
| 270 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) |
| 271 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) |
| 272 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) |
| 273 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) |
| 274 | |
| 275 | PORT_START("IN.2") // R2 |
| 276 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) |
| 277 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) |
| 278 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) |
| 279 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) |
| 280 | |
| 281 | PORT_START("IN.3") // R3 |
| 282 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_PLAYER(2) |
| 283 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_PLAYER(2) |
| 284 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_PLAYER(2) |
| 285 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_PLAYER(2) |
| 286 | |
| 287 | PORT_START("IN.4") // R4 |
| 288 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(2) |
| 289 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(2) |
| 290 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_PLAYER(2) |
| 291 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_PLAYER(2) |
| 292 | |
| 293 | PORT_START("IN.5") // R5 |
| 294 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 3") // right |
| 295 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 1") // left |
| 296 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 2") // middle |
| 297 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_NAME("P2 D/K Button") |
| 298 | |
| 299 | PORT_START("IN.6") // R9 |
| 300 | PORT_CONFNAME( 0x0f, 0x08, "Cartridge") |
| 301 | PORT_CONFSETTING( 0x01, "Basketball" ) |
| 302 | PORT_CONFSETTING( 0x02, "Soccer" ) |
| 303 | PORT_CONFSETTING( 0x04, "Hockey" ) |
| 304 | PORT_CONFSETTING( 0x08, "Football" ) |
| 305 | INPUT_PORTS_END |
| 306 | |
| 307 | static MACHINE_CONFIG_START( tc4, hh_tms1k_state ) |
| 308 | |
| 309 | /* basic machine hardware */ |
| 310 | MCFG_CPU_ADD("maincpu", TMS1400, 450000) // approximation - RC osc. R=27.3K, C=100pf, but unknown RC curve |
| 311 | MCFG_TMS1XXX_READ_K_CB(READ8(hh_tms1k_state, tc4_read_k)) |
| 312 | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(hh_tms1k_state, tc4_write_o)) |
| 313 | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(hh_tms1k_state, tc4_write_r)) |
| 314 | |
| 315 | MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_tms1k_state, display_decay_tick, attotime::from_msec(1)) |
| 316 | |
| 317 | MCFG_DEFAULT_LAYOUT(layout_tc4) |
| 318 | |
| 319 | /* no video! */ |
| 320 | |
| 321 | /* sound hardware */ |
| 322 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 323 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 324 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 325 | MACHINE_CONFIG_END |
| 326 | |
| 327 | |
| 328 | |
| 329 | /*************************************************************************** |
| 330 | |
| 331 | Entex Baseball |
| 332 | * TMS1000NLP MP0914 (die labeled MP0914A) |
| 333 | |
| 334 | ***************************************************************************/ |
| 335 | |
| 336 | // inputs |
| 337 | static INPUT_PORTS_START( ebball ) |
| 338 | INPUT_PORTS_END |
| 339 | |
| 340 | // machine config |
| 53 | 341 | static MACHINE_CONFIG_START( ebball, hh_tms1k_state ) |
| 54 | 342 | |
| 55 | 343 | /* basic machine hardware */ |
| r243823 | r243824 | |
| 73 | 361 | |
| 74 | 362 | ***************************************************************************/ |
| 75 | 363 | |
| 364 | ROM_START( tc4 ) |
| 365 | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 366 | ROM_LOAD( "tms1400nll_mp7334", 0x0000, 0x1000, CRC(923f3821) SHA1(a9ae342d7ff8dae1dedcd1e4984bcfae68586581) ) |
| 367 | |
| 368 | ROM_REGION( 867, "maincpu:mpla", 0 ) |
| 369 | ROM_LOAD( "tms1100_default_mpla.pla", 0, 867, CRC(62445fc9) SHA1(d6297f2a4bc7a870b76cc498d19dbb0ce7d69fec) ) |
| 370 | ROM_REGION( 557, "maincpu:opla", 0 ) |
| 371 | ROM_LOAD( "tms1400_tc4_opla.pla", 0, 557, CRC(3b908725) SHA1(f83bf5faa5b3cb51f87adc1639b00d6f9a71ad19) ) |
| 372 | ROM_END |
| 373 | |
| 374 | |
| 76 | 375 | ROM_START( ebball ) |
| 77 | 376 | ROM_REGION( 0x0400, "maincpu", 0 ) |
| 78 | 377 | ROM_LOAD( "mp0914", 0x0000, 0x0400, CRC(3c6fb05b) SHA1(b2fe4b3ca72d6b4c9bfa84d67f64afdc215e7178) ) |
| r243823 | r243824 | |
| 85 | 384 | |
| 86 | 385 | |
| 87 | 386 | CONS( 1979, ebball, 0, 0, ebball, ebball, driver_device, 0, "Entex", "Baseball (Entex)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) |
| 387 | |
| 388 | CONS( 1981, tc4, 0, 0, tc4, tc4, driver_device, 0, "Coleco", "Total Control 4", GAME_SUPPORTS_SAVE ) |
trunk/src/mess/drivers/tc4.c
| r243823 | r243824 | |
| 1 | | // license:BSD-3-Clause |
| 2 | | // copyright-holders:hap |
| 3 | | /*************************************************************************** |
| 4 | | |
| 5 | | Coleco Total Control 4 |
| 6 | | * TMS1400NLL MP7334-N2 (die labeled MP7334) |
| 7 | | |
| 8 | | This is a head to head electronic tabletop LED-display sports console. |
| 9 | | One cartridge(Football) was included with the console, the other three were |
| 10 | | sold separately. Gameplay has emphasis on strategy, read the official manual |
| 11 | | on how to play. Remember that you can rotate the view in MESS: rotate left |
| 12 | | for Home(P1) orientation, rotate right for Visitor(P2) orientation. |
| 13 | | |
| 14 | | Cartridge socket: |
| 15 | | 1 N/C |
| 16 | | 2 9V+ |
| 17 | | 3 power switch |
| 18 | | 4 K8 |
| 19 | | 5 K4 |
| 20 | | 6 K2 |
| 21 | | 7 K1 |
| 22 | | 8 R9 |
| 23 | | |
| 24 | | The cartridge connects pin 8 with one of the K-pins. |
| 25 | | |
| 26 | | Available cartridges: |
| 27 | | - Football (K8, confirmed) |
| 28 | | - Hockey (K4?) |
| 29 | | - Soccer (K2?) |
| 30 | | - Basketball (K1?) |
| 31 | | |
| 32 | | |
| 33 | | TODO: |
| 34 | | - pin configuration of other carts is guessed |
| 35 | | - softlist for the cartridges? |
| 36 | | - offsensive players leds are supposed to look brighter |
| 37 | | - MCU clock is unknown |
| 38 | | |
| 39 | | ***************************************************************************/ |
| 40 | | |
| 41 | | #include "emu.h" |
| 42 | | #include "cpu/tms0980/tms0980.h" |
| 43 | | #include "sound/speaker.h" |
| 44 | | |
| 45 | | #include "tc4.lh" |
| 46 | | |
| 47 | | // The master clock is a single stage RC oscillator: R=27.3K, C=100pf. |
| 48 | | // TMS1400 RC curve is unknown, so let's do an approximation until it is. |
| 49 | | #define MASTER_CLOCK (450000) |
| 50 | | |
| 51 | | |
| 52 | | class tc4_state : public driver_device |
| 53 | | { |
| 54 | | public: |
| 55 | | tc4_state(const machine_config &mconfig, device_type type, const char *tag) |
| 56 | | : driver_device(mconfig, type, tag), |
| 57 | | m_maincpu(*this, "maincpu"), |
| 58 | | m_button_matrix(*this, "IN"), |
| 59 | | m_speaker(*this, "speaker") |
| 60 | | { } |
| 61 | | |
| 62 | | required_device<cpu_device> m_maincpu; |
| 63 | | required_ioport_array<7> m_button_matrix; |
| 64 | | required_device<speaker_sound_device> m_speaker; |
| 65 | | |
| 66 | | UINT16 m_r; |
| 67 | | UINT16 m_o; |
| 68 | | |
| 69 | | UINT16 m_display_state[0x10]; |
| 70 | | UINT16 m_display_cache[0x10]; |
| 71 | | UINT8 m_display_decay[0x100]; |
| 72 | | |
| 73 | | DECLARE_READ8_MEMBER(read_k); |
| 74 | | DECLARE_WRITE16_MEMBER(write_o); |
| 75 | | DECLARE_WRITE16_MEMBER(write_r); |
| 76 | | |
| 77 | | TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); |
| 78 | | bool index_is_7segled(int index); |
| 79 | | void display_update(); |
| 80 | | |
| 81 | | virtual void machine_start(); |
| 82 | | }; |
| 83 | | |
| 84 | | |
| 85 | | |
| 86 | | /*************************************************************************** |
| 87 | | |
| 88 | | LED Display |
| 89 | | |
| 90 | | ***************************************************************************/ |
| 91 | | |
| 92 | | // The device strobes the outputs very fast, it is unnoticeable to the user. |
| 93 | | // To prevent flickering here, we need to simulate a decay. |
| 94 | | |
| 95 | | // decay time, in steps of 1ms |
| 96 | | #define DISPLAY_DECAY_TIME 50 |
| 97 | | |
| 98 | | inline bool tc4_state::index_is_7segled(int index) |
| 99 | | { |
| 100 | | // R5,7,8,9 are 7segs |
| 101 | | return (index >= 5 && index <= 9 && index != 6); |
| 102 | | } |
| 103 | | |
| 104 | | void tc4_state::display_update() |
| 105 | | { |
| 106 | | UINT16 active_state[0x10]; |
| 107 | | |
| 108 | | for (int i = 0; i < 0x10; i++) |
| 109 | | { |
| 110 | | // update current state (note: R6 as extra column!) |
| 111 | | m_display_state[i] = (m_r >> i & 1) ? (m_o | (m_r << 2 & 0x100)) : 0; |
| 112 | | |
| 113 | | active_state[i] = 0; |
| 114 | | |
| 115 | | for (int j = 0; j < 0x10; j++) |
| 116 | | { |
| 117 | | int di = j << 4 | i; |
| 118 | | |
| 119 | | // turn on powered segments |
| 120 | | if (m_display_state[i] >> j & 1) |
| 121 | | m_display_decay[di] = DISPLAY_DECAY_TIME; |
| 122 | | |
| 123 | | // determine active state |
| 124 | | int ds = (m_display_decay[di] != 0) ? 1 : 0; |
| 125 | | active_state[i] |= (ds << j); |
| 126 | | } |
| 127 | | } |
| 128 | | |
| 129 | | // on difference, send to output |
| 130 | | for (int i = 0; i < 0x10; i++) |
| 131 | | if (m_display_cache[i] != active_state[i]) |
| 132 | | { |
| 133 | | if (index_is_7segled(i)) |
| 134 | | output_set_digit_value(i, active_state[i] & 0x7f); |
| 135 | | |
| 136 | | for (int j = 0; j < 9; j++) |
| 137 | | output_set_lamp_value(i*10 + j, active_state[i] >> j & 1); |
| 138 | | } |
| 139 | | |
| 140 | | memcpy(m_display_cache, active_state, sizeof(m_display_cache)); |
| 141 | | } |
| 142 | | |
| 143 | | TIMER_DEVICE_CALLBACK_MEMBER(tc4_state::display_decay_tick) |
| 144 | | { |
| 145 | | // slowly turn off unpowered segments |
| 146 | | for (int i = 0; i < 0x100; i++) |
| 147 | | if (!(m_display_state[i & 0xf] >> (i>>4) & 1) && m_display_decay[i]) |
| 148 | | m_display_decay[i]--; |
| 149 | | |
| 150 | | display_update(); |
| 151 | | } |
| 152 | | |
| 153 | | |
| 154 | | |
| 155 | | /*************************************************************************** |
| 156 | | |
| 157 | | I/O |
| 158 | | |
| 159 | | ***************************************************************************/ |
| 160 | | |
| 161 | | READ8_MEMBER(tc4_state::read_k) |
| 162 | | { |
| 163 | | UINT8 k = 0; |
| 164 | | |
| 165 | | // read selected button rows |
| 166 | | for (int i = 0; i < 6; i++) |
| 167 | | if (m_r >> i & 1) |
| 168 | | k |= m_button_matrix[i]->read(); |
| 169 | | |
| 170 | | // read from cartridge |
| 171 | | if (m_r & 0x200) |
| 172 | | k |= m_button_matrix[6]->read(); |
| 173 | | |
| 174 | | return k; |
| 175 | | } |
| 176 | | |
| 177 | | WRITE16_MEMBER(tc4_state::write_o) |
| 178 | | { |
| 179 | | // O0-O7: leds/7segment |
| 180 | | m_o = data; |
| 181 | | display_update(); |
| 182 | | } |
| 183 | | |
| 184 | | WRITE16_MEMBER(tc4_state::write_r) |
| 185 | | { |
| 186 | | // R10: speaker out |
| 187 | | m_speaker->level_w(data >> 10 & 1); |
| 188 | | |
| 189 | | // R0-R5: input mux |
| 190 | | // R6: led column 8 |
| 191 | | // R9: to cartridge slot |
| 192 | | // +other: select leds |
| 193 | | m_r = data & 0x3ff; |
| 194 | | display_update(); |
| 195 | | } |
| 196 | | |
| 197 | | |
| 198 | | |
| 199 | | /*************************************************************************** |
| 200 | | |
| 201 | | Inputs |
| 202 | | |
| 203 | | ***************************************************************************/ |
| 204 | | |
| 205 | | static INPUT_PORTS_START( tc4 ) |
| 206 | | PORT_START("IN.0") // R0 |
| 207 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Pass/Shoot Button 3") // right |
| 208 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Pass/Shoot Button 1") // left |
| 209 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Pass/Shoot Button 2") // middle |
| 210 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 D/K Button") |
| 211 | | |
| 212 | | PORT_START("IN.1") // R1 |
| 213 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) |
| 214 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) |
| 215 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) |
| 216 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) |
| 217 | | |
| 218 | | PORT_START("IN.2") // R2 |
| 219 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) |
| 220 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) |
| 221 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) |
| 222 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) |
| 223 | | |
| 224 | | PORT_START("IN.3") // R3 |
| 225 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_PLAYER(2) |
| 226 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_PLAYER(2) |
| 227 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_PLAYER(2) |
| 228 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_PLAYER(2) |
| 229 | | |
| 230 | | PORT_START("IN.4") // R4 |
| 231 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(2) |
| 232 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(2) |
| 233 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_PLAYER(2) |
| 234 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_PLAYER(2) |
| 235 | | |
| 236 | | PORT_START("IN.5") // R5 |
| 237 | | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 3") // right |
| 238 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 1") // left |
| 239 | | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Pass/Shoot Button 2") // middle |
| 240 | | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_NAME("P2 D/K Button") |
| 241 | | |
| 242 | | PORT_START("IN.6") // R9 |
| 243 | | PORT_CONFNAME( 0x0f, 0x08, "Cartridge") |
| 244 | | PORT_CONFSETTING( 0x01, "Basketball" ) |
| 245 | | PORT_CONFSETTING( 0x02, "Soccer" ) |
| 246 | | PORT_CONFSETTING( 0x04, "Hockey" ) |
| 247 | | PORT_CONFSETTING( 0x08, "Football" ) |
| 248 | | INPUT_PORTS_END |
| 249 | | |
| 250 | | |
| 251 | | |
| 252 | | /*************************************************************************** |
| 253 | | |
| 254 | | Machine Config |
| 255 | | |
| 256 | | ***************************************************************************/ |
| 257 | | |
| 258 | | void tc4_state::machine_start() |
| 259 | | { |
| 260 | | // zerofill |
| 261 | | memset(m_display_state, 0, sizeof(m_display_state)); |
| 262 | | memset(m_display_cache, 0, sizeof(m_display_cache)); |
| 263 | | memset(m_display_decay, 0, sizeof(m_display_decay)); |
| 264 | | |
| 265 | | m_r = 0; |
| 266 | | m_o = 0; |
| 267 | | |
| 268 | | // register for savestates |
| 269 | | save_item(NAME(m_display_state)); |
| 270 | | save_item(NAME(m_display_cache)); |
| 271 | | save_item(NAME(m_display_decay)); |
| 272 | | |
| 273 | | save_item(NAME(m_r)); |
| 274 | | save_item(NAME(m_o)); |
| 275 | | } |
| 276 | | |
| 277 | | |
| 278 | | static MACHINE_CONFIG_START( tc4, tc4_state ) |
| 279 | | |
| 280 | | /* basic machine hardware */ |
| 281 | | MCFG_CPU_ADD("maincpu", TMS1400, MASTER_CLOCK) |
| 282 | | MCFG_TMS1XXX_READ_K_CB(READ8(tc4_state, read_k)) |
| 283 | | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(tc4_state, write_o)) |
| 284 | | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(tc4_state, write_r)) |
| 285 | | |
| 286 | | MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", tc4_state, display_decay_tick, attotime::from_msec(1)) |
| 287 | | |
| 288 | | MCFG_DEFAULT_LAYOUT(layout_tc4) |
| 289 | | |
| 290 | | /* no video! */ |
| 291 | | |
| 292 | | /* sound hardware */ |
| 293 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 294 | | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 295 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 296 | | MACHINE_CONFIG_END |
| 297 | | |
| 298 | | |
| 299 | | |
| 300 | | /*************************************************************************** |
| 301 | | |
| 302 | | Game driver(s) |
| 303 | | |
| 304 | | ***************************************************************************/ |
| 305 | | |
| 306 | | ROM_START( tc4 ) |
| 307 | | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 308 | | ROM_LOAD( "tms1400nll_mp7334", 0x0000, 0x1000, CRC(923f3821) SHA1(a9ae342d7ff8dae1dedcd1e4984bcfae68586581) ) |
| 309 | | |
| 310 | | ROM_REGION( 867, "maincpu:mpla", 0 ) |
| 311 | | ROM_LOAD( "tms1100_default_mpla.pla", 0, 867, CRC(62445fc9) SHA1(d6297f2a4bc7a870b76cc498d19dbb0ce7d69fec) ) |
| 312 | | ROM_REGION( 557, "maincpu:opla", 0 ) |
| 313 | | ROM_LOAD( "tms1400_tc4_opla.pla", 0, 557, CRC(3b908725) SHA1(f83bf5faa5b3cb51f87adc1639b00d6f9a71ad19) ) |
| 314 | | ROM_END |
| 315 | | |
| 316 | | |
| 317 | | CONS( 1981, tc4, 0, 0, tc4, tc4, driver_device, 0, "Coleco", "Total Control 4", GAME_SUPPORTS_SAVE ) |