trunk/src/mess/drivers/stopthie.c
| r242211 | r242212 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:hap |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | Parker Brothers Stop Thief |
| 6 | * MP0905BNL TMS0980NLL MP6101B (die labeled 0980B-01A) |
| 7 | |
| 8 | bla |
| 9 | |
| 10 | |
| 11 | TODO: |
| 12 | - ON/OFF button callbacks |
| 13 | - MCU clock is unknown |
| 14 | |
| 15 | ***************************************************************************/ |
| 16 | |
| 1 | 17 | #include "emu.h" |
| 2 | 18 | #include "cpu/tms0980/tms0980.h" |
| 19 | #include "sound/speaker.h" |
| 3 | 20 | |
| 4 | | /* Layout */ |
| 5 | 21 | #include "stopthie.lh" |
| 6 | 22 | |
| 23 | // master clock is unknown, the value below is an approximation |
| 24 | #define MASTER_CLOCK (350000) |
| 7 | 25 | |
| 8 | | class stopthie_state : public driver_device |
| 26 | |
| 27 | class stopthief_state : public driver_device |
| 9 | 28 | { |
| 10 | 29 | public: |
| 11 | | stopthie_state(const machine_config &mconfig, device_type type, const char *tag) |
| 12 | | : driver_device(mconfig, type, tag) , |
| 13 | | m_maincpu(*this, "maincpu") { } |
| 30 | stopthief_state(const machine_config &mconfig, device_type type, const char *tag) |
| 31 | : driver_device(mconfig, type, tag), |
| 32 | m_maincpu(*this, "maincpu"), |
| 33 | m_button_matrix(*this, "IN"), |
| 34 | m_speaker(*this, "speaker") |
| 35 | { } |
| 14 | 36 | |
| 15 | | DECLARE_READ8_MEMBER(stopthie_read_k); |
| 16 | | DECLARE_WRITE16_MEMBER(stopthie_write_o); |
| 17 | | DECLARE_WRITE16_MEMBER(stopthie_write_r); |
| 18 | 37 | required_device<cpu_device> m_maincpu; |
| 38 | required_ioport_array<3> m_button_matrix; |
| 39 | required_device<speaker_sound_device> m_speaker; |
| 40 | |
| 41 | UINT16 m_r; |
| 42 | UINT16 m_o; |
| 43 | |
| 44 | UINT16 m_leds_state[0x10]; |
| 45 | UINT16 m_leds_cache[0x10]; |
| 46 | UINT8 m_leds_decay[0x100]; |
| 47 | |
| 48 | DECLARE_READ8_MEMBER(read_k); |
| 49 | DECLARE_WRITE16_MEMBER(write_o); |
| 50 | DECLARE_WRITE16_MEMBER(write_r); |
| 51 | |
| 52 | TIMER_DEVICE_CALLBACK_MEMBER(leds_decay_tick); |
| 53 | void leds_update(); |
| 54 | |
| 55 | virtual void machine_start(); |
| 19 | 56 | }; |
| 20 | 57 | |
| 21 | 58 | |
| 22 | 59 | |
| 23 | | #define LOG 1 |
| 60 | /*************************************************************************** |
| 24 | 61 | |
| 25 | | static INPUT_PORTS_START( stopthie ) |
| 26 | | INPUT_PORTS_END |
| 62 | LEDs |
| 27 | 63 | |
| 64 | ***************************************************************************/ |
| 28 | 65 | |
| 29 | | READ8_MEMBER(stopthie_state::stopthie_read_k) |
| 30 | | { |
| 31 | | UINT8 data = 0; |
| 66 | // The device strobes the outputs very fast, it is unnoticeable to the user. |
| 67 | // To prevent flickering here, we need to simulate a decay. |
| 32 | 68 | |
| 33 | | if (LOG) |
| 34 | | logerror( "stopthie_read_k\n" ); |
| 69 | // decay time, in steps of 10ms |
| 70 | #define LEDS_DECAY_TIME 4 |
| 35 | 71 | |
| 36 | | return data; |
| 72 | void stopthief_state::leds_update() |
| 73 | { |
| 74 | UINT16 active_state[0x10]; |
| 75 | |
| 76 | for (int i = 0; i < 0x10; i++) |
| 77 | { |
| 78 | active_state[i] = 0; |
| 79 | |
| 80 | for (int j = 0; j < 0x10; j++) |
| 81 | { |
| 82 | int di = j << 4 | i; |
| 83 | |
| 84 | // turn on powered leds |
| 85 | if (m_leds_state[i] >> j & 1) |
| 86 | m_leds_decay[di] = LEDS_DECAY_TIME; |
| 87 | |
| 88 | // determine active state |
| 89 | int ds = (m_leds_decay[di] != 0) ? 1 : 0; |
| 90 | active_state[i] |= (ds << j); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | // on difference, send to output |
| 95 | for (int i = 0; i < 0x10; i++) |
| 96 | if (m_leds_cache[i] != active_state[i]) |
| 97 | output_set_digit_value(i, active_state[i]); |
| 98 | |
| 99 | memcpy(m_leds_cache, active_state, sizeof(m_leds_cache)); |
| 37 | 100 | } |
| 38 | 101 | |
| 102 | TIMER_DEVICE_CALLBACK_MEMBER(stopthief_state::leds_decay_tick) |
| 103 | { |
| 104 | // slowly turn off unpowered leds |
| 105 | for (int i = 0; i < 0x100; i++) |
| 106 | if (!(m_leds_state[i & 0xf] >> (i>>4) & 1) && m_leds_decay[i]) |
| 107 | m_leds_decay[i]--; |
| 108 | |
| 109 | leds_update(); |
| 110 | } |
| 39 | 111 | |
| 40 | | WRITE16_MEMBER(stopthie_state::stopthie_write_o) |
| 112 | |
| 113 | |
| 114 | /*************************************************************************** |
| 115 | |
| 116 | I/O |
| 117 | |
| 118 | ***************************************************************************/ |
| 119 | |
| 120 | READ8_MEMBER(stopthief_state::read_k) |
| 41 | 121 | { |
| 42 | | if (LOG) |
| 43 | | logerror( "stopthie_write_o: write %02x\n", data ); |
| 122 | // the Vss row is always on |
| 123 | UINT8 k = m_button_matrix[2]->read(); |
| 124 | |
| 125 | // read selected button rows |
| 126 | for (int i = 0; i < 2; i++) |
| 127 | { |
| 128 | const int ki[2] = { 0, 6 }; |
| 129 | if (m_o >> ki[i] & 1) |
| 130 | k |= m_button_matrix[i]->read(); |
| 131 | } |
| 132 | |
| 133 | return k; |
| 44 | 134 | } |
| 45 | 135 | |
| 136 | WRITE16_MEMBER(stopthief_state::write_r) |
| 137 | { |
| 138 | // R0-R2: select digit |
| 139 | UINT8 o = BITSWAP8(m_o,3,5,0,6,7,2,1,4) & 0x7f; |
| 140 | for (int i = 0; i < 10; i++) |
| 141 | m_leds_state[i] = (data >> i & 1) ? o : 0; |
| 142 | |
| 143 | leds_update(); |
| 144 | |
| 145 | // R3-..: sound |
| 46 | 146 | |
| 47 | | WRITE16_MEMBER(stopthie_state::stopthie_write_r) |
| 147 | |
| 148 | m_r = data; |
| 149 | } |
| 150 | |
| 151 | WRITE16_MEMBER(stopthief_state::write_o) |
| 48 | 152 | { |
| 49 | | if (LOG) |
| 50 | | logerror( "stopthie_write_r: write %04x\n", data ); |
| 153 | // O0,O6: input mux |
| 154 | // O3: sound on |
| 155 | // O0-O2,O4-O7: led segments A-G |
| 156 | m_o = data; |
| 51 | 157 | } |
| 52 | 158 | |
| 53 | 159 | |
| 54 | 160 | |
| 161 | /*************************************************************************** |
| 55 | 162 | |
| 163 | Inputs |
| 56 | 164 | |
| 57 | | static MACHINE_CONFIG_START( stopthie, stopthie_state ) |
| 165 | ***************************************************************************/ |
| 58 | 166 | |
| 167 | /* physical button layout and labels is like this: |
| 168 | |
| 169 | [1] [2] [OFF] |
| 170 | [3] [4] [ON] |
| 171 | [5] [6] [T, TIP] |
| 172 | [7] [8] [A, ARREST] |
| 173 | [9] [0] [C, CLUE] |
| 174 | */ |
| 175 | |
| 176 | static INPUT_PORTS_START( stopthief ) |
| 177 | PORT_START("IN.0") // O0 |
| 178 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("4") |
| 179 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("6") |
| 180 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("8") |
| 181 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("0") |
| 182 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("2") |
| 183 | |
| 184 | PORT_START("IN.1") // O6 |
| 185 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("3") |
| 186 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("5") |
| 187 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("7") |
| 188 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_NAME("9") |
| 189 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("1") |
| 190 | |
| 191 | // note: even though power buttons are on the matrix, they are not CPU-controlled |
| 192 | PORT_START("IN.2") // Vss! |
| 193 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGUP) PORT_NAME("On") |
| 194 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_NAME("Tip") |
| 195 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_NAME("Arrest") |
| 196 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_NAME("Clue") |
| 197 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_PGDN) PORT_NAME("Off") |
| 198 | INPUT_PORTS_END |
| 199 | |
| 200 | |
| 201 | |
| 202 | /*************************************************************************** |
| 203 | |
| 204 | Machine Config |
| 205 | |
| 206 | ***************************************************************************/ |
| 207 | |
| 208 | void stopthief_state::machine_start() |
| 209 | { |
| 210 | memset(m_leds_state, 0, sizeof(m_leds_state)); |
| 211 | memset(m_leds_cache, 0, sizeof(m_leds_cache)); |
| 212 | memset(m_leds_decay, 0, sizeof(m_leds_decay)); |
| 213 | m_r = 0; |
| 214 | m_o = 0; |
| 215 | |
| 216 | save_item(NAME(m_leds_state)); |
| 217 | save_item(NAME(m_leds_cache)); |
| 218 | save_item(NAME(m_leds_decay)); |
| 219 | save_item(NAME(m_r)); |
| 220 | save_item(NAME(m_o)); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | static MACHINE_CONFIG_START( stopthief, stopthief_state ) |
| 225 | |
| 59 | 226 | /* basic machine hardware */ |
| 60 | | MCFG_CPU_ADD( "maincpu", TMS0980, 500000 ) /* Clock is wrong */ |
| 61 | | MCFG_TMS1XXX_READ_K_CB( READ8( stopthie_state, stopthie_read_k ) ) |
| 62 | | MCFG_TMS1XXX_WRITE_O_CB( WRITE16( stopthie_state, stopthie_write_o ) ) |
| 63 | | MCFG_TMS1XXX_WRITE_R_CB( WRITE16( stopthie_state, stopthie_write_r ) ) |
| 227 | MCFG_CPU_ADD("maincpu", TMS0980, MASTER_CLOCK) |
| 228 | MCFG_TMS1XXX_READ_K_CB(READ8(stopthief_state, read_k)) |
| 229 | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(stopthief_state, write_o)) |
| 230 | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(stopthief_state, write_r)) |
| 64 | 231 | |
| 232 | MCFG_TIMER_DRIVER_ADD_PERIODIC("leds_decay", stopthief_state, leds_decay_tick, attotime::from_msec(10)) |
| 233 | |
| 65 | 234 | MCFG_DEFAULT_LAYOUT(layout_stopthie) |
| 235 | |
| 236 | /* no video! */ |
| 237 | |
| 238 | /* sound hardware */ |
| 239 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 240 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 241 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 66 | 242 | MACHINE_CONFIG_END |
| 67 | 243 | |
| 68 | | ROM_START( stopthie ) |
| 69 | | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 70 | | ROM_LOAD16_WORD( "stopthie.bin", 0x0000, 0x1000, CRC(03691115) SHA1(bdcd212aa50bb1c26cb2d0ee97e5cfc04841c108) ) |
| 71 | 244 | |
| 72 | | ROM_REGION( 1246, "maincpu:ipla", ROMREGION_ERASE00 ) |
| 73 | | ROM_REGION( 1982, "maincpu:mpla", ROMREGION_ERASE00 ) |
| 74 | | ROM_REGION( 352, "maincpu:opla", ROMREGION_ERASE00 ) |
| 75 | | ROM_REGION( 157, "maincpu:spla", ROMREGION_ERASE00 ) |
| 76 | | ROM_END |
| 77 | 245 | |
| 78 | 246 | /*************************************************************************** |
| 79 | 247 | |
| r242211 | r242212 | |
| 81 | 249 | |
| 82 | 250 | ***************************************************************************/ |
| 83 | 251 | |
| 84 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 85 | | CONS( 1979, stopthie, 0, 0, stopthie, stopthie, driver_device, 0, "Parker Brothers", "Stop Thief", GAME_NOT_WORKING | GAME_NO_SOUND) |
| 252 | ROM_START( stopthie ) |
| 253 | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 254 | ROM_LOAD( "tms0980nll_mp6101b", 0x0000, 0x1000, CRC(5b4114af) SHA1(30a9b20dd5f0d57ed34c53e46f5adbf959d47828) ) |
| 255 | |
| 256 | ROM_REGION( 1246, "maincpu:ipla", 0 ) |
| 257 | ROM_LOAD( "tms0980_default_ipla.pla", 0, 1246, CRC(42db9a38) SHA1(2d127d98028ec8ec6ea10c179c25e447b14ba4d0) ) |
| 258 | ROM_REGION( 1982, "maincpu:mpla", 0 ) |
| 259 | ROM_LOAD( "tms0980_default_mpla.pla", 0, 1982, CRC(3709014f) SHA1(d28ee59ded7f3b9dc3f0594a32a98391b6e9c961) ) |
| 260 | ROM_REGION( 352, "maincpu:opla", 0 ) |
| 261 | ROM_LOAD( "tms0980_stopthie_opla.pla", 0, 352, CRC(50337a48) SHA1(4a9ea62ed797a9ac5190eec3bb6ebebb7814628c) ) |
| 262 | ROM_REGION( 157, "maincpu:spla", 0 ) |
| 263 | ROM_LOAD( "tms0980_stopthie_spla.pla", 0, 157, CRC(399aa481) SHA1(72c56c58fde3fbb657d69647a9543b5f8fc74279) ) |
| 264 | ROM_END |
| 265 | |
| 266 | ROM_START( stopthiep ) |
| 267 | ROM_REGION( 0x1000, "maincpu", 0 ) |
| 268 | ROM_LOAD16_WORD( "us4341385", 0x0000, 0x1000, CRC(03691115) SHA1(bdcd212aa50bb1c26cb2d0ee97e5cfc04841c108) ) // from patent US4341385, data should be correct (it included checksums) |
| 269 | // TODO: put in 0980 proper order |
| 270 | |
| 271 | ROM_REGION( 1246, "maincpu:ipla", 0 ) |
| 272 | ROM_LOAD( "tms0980_default_ipla.pla", 0, 1246, CRC(42db9a38) SHA1(2d127d98028ec8ec6ea10c179c25e447b14ba4d0) ) |
| 273 | ROM_REGION( 1982, "maincpu:mpla", 0 ) |
| 274 | ROM_LOAD( "tms0980_default_mpla.pla", 0, 1982, CRC(3709014f) SHA1(d28ee59ded7f3b9dc3f0594a32a98391b6e9c961) ) |
| 275 | ROM_REGION( 352, "maincpu:opla", 0 ) |
| 276 | ROM_LOAD( "tms0980_stopthie_opla.pla", 0, 352, CRC(50337a48) SHA1(4a9ea62ed797a9ac5190eec3bb6ebebb7814628c) ) |
| 277 | ROM_REGION( 157, "maincpu:spla", 0 ) |
| 278 | ROM_LOAD( "tms0980_stopthie_spla.pla", 0, 157, CRC(399aa481) SHA1(72c56c58fde3fbb657d69647a9543b5f8fc74279) ) |
| 279 | ROM_END |
| 280 | |
| 281 | |
| 282 | CONS( 1979, stopthie, 0, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) |
| 283 | CONS( 1979, stopthiep, stopthie, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner) (prototype)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) |