Previous 199869 Revisions Next

r36119 Friday 27th February, 2015 at 09:44:03 UTC by hap
forgot to remove one
[src/mess/drivers]stopthie.c

trunk/src/mess/drivers/stopthie.c
r244630r244631
1// license:BSD-3-Clause
2// copyright-holders:hap
3/***************************************************************************
4
5  Parker Brothers Stop Thief, by Bob Doyle
6  * TMS0980NLL MP6101B (die labeled 0980B-01A)
7
8  Stop Thief is actually a board game, the electronic device emulated here
9  (called Electronic Crime Scanner) is an accessory. To start a game, press
10  the ON button. Otherwise, it is in test-mode where you can hear all sounds.
11
12
13  TODO:
14  - MCU clock is unknown
15  - stopthiep: unable to start a game (may be intentional?)
16
17***************************************************************************/
18
19#include "emu.h"
20#include "cpu/tms0980/tms0980.h"
21#include "sound/speaker.h"
22
23#include "stopthie.lh"
24
25// master clock is unknown, the value below is an approximation
26#define MASTER_CLOCK (425000)
27
28
29class stopthief_state : public driver_device
30{
31public:
32   stopthief_state(const machine_config &mconfig, device_type type, const char *tag)
33      : driver_device(mconfig, type, tag),
34      m_maincpu(*this, "maincpu"),
35      m_button_matrix(*this, "IN"),
36      m_speaker(*this, "speaker")
37   { }
38
39   required_device<cpu_device> m_maincpu;
40   required_ioport_array<3> m_button_matrix;
41   required_device<speaker_sound_device> m_speaker;
42
43   UINT16 m_o;
44   bool m_power_on;
45
46   UINT16 m_display_state[0x10];
47   UINT16 m_display_cache[0x10];
48   UINT8 m_display_decay[0x100];
49
50   DECLARE_READ8_MEMBER(read_k);
51   DECLARE_WRITE16_MEMBER(write_o);
52   DECLARE_WRITE16_MEMBER(write_r);
53
54   DECLARE_INPUT_CHANGED_MEMBER(power_button);
55   DECLARE_WRITE_LINE_MEMBER(auto_power_off);
56
57   TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick);
58   void display_update();
59
60   virtual void machine_reset();
61   virtual void machine_start();
62};
63
64
65
66/***************************************************************************
67
68  LED Display
69
70***************************************************************************/
71
72// The device strobes the outputs very fast, it is unnoticeable to the user.
73// To prevent flickering here, we need to simulate a decay.
74
75// decay time, in steps of 1ms
76#define DISPLAY_DECAY_TIME 40
77
78void stopthief_state::display_update()
79{
80   UINT16 active_state[0x10];
81
82   for (int i = 0; i < 0x10; i++)
83   {
84      active_state[i] = 0;
85
86      for (int j = 0; j < 0x10; j++)
87      {
88         int di = j << 4 | i;
89
90         // turn on powered segments
91         if (m_power_on && m_display_state[i] >> j & 1)
92            m_display_decay[di] = DISPLAY_DECAY_TIME;
93
94         // determine active state
95         int ds = (m_display_decay[di] != 0) ? 1 : 0;
96         active_state[i] |= (ds << j);
97      }
98   }
99
100   // on difference, send to output
101   for (int i = 0; i < 0x10; i++)
102      if (m_display_cache[i] != active_state[i])
103         output_set_digit_value(i, active_state[i]);
104
105   memcpy(m_display_cache, active_state, sizeof(m_display_cache));
106}
107
108TIMER_DEVICE_CALLBACK_MEMBER(stopthief_state::display_decay_tick)
109{
110   // slowly turn off unpowered segments
111   for (int i = 0; i < 0x100; i++)
112      if (!(m_display_state[i & 0xf] >> (i>>4) & 1) && m_display_decay[i])
113         m_display_decay[i]--;
114
115   display_update();
116}
117
118
119
120/***************************************************************************
121
122  I/O
123
124***************************************************************************/
125
126READ8_MEMBER(stopthief_state::read_k)
127{
128   // the Vss row is always on
129   UINT8 k = m_button_matrix[2]->read();
130
131   // read selected button rows
132   for (int i = 0; i < 2; i++)
133   {
134      const int ki[2] = { 0, 6 };
135      if (m_o >> ki[i] & 1)
136         k |= m_button_matrix[i]->read();
137   }
138
139   return k;
140}
141
142WRITE16_MEMBER(stopthief_state::write_r)
143{
144   // R0-R2: select digit
145   UINT8 o = BITSWAP8(m_o,3,5,2,1,4,0,6,7) & 0x7f;
146   for (int i = 0; i < 3; i++)
147      m_display_state[i] = (data >> i & 1) ? o : 0;
148
149   display_update();
150
151   // R3-R8: speaker on
152   m_speaker->level_w((data & 0x1f8 && m_o & 8) ? 1 : 0);
153}
154
155WRITE16_MEMBER(stopthief_state::write_o)
156{
157   // O0,O6: input mux
158   // O3: speaker out
159   // O0-O2,O4-O7: led segments A-G
160   m_o = data;
161}
162
163
164
165/***************************************************************************
166
167  Inputs
168
169***************************************************************************/
170
171INPUT_CHANGED_MEMBER(stopthief_state::power_button)
172{
173   m_power_on = (bool)(FPTR)param;
174   m_maincpu->set_input_line(INPUT_LINE_RESET, m_power_on ? CLEAR_LINE : ASSERT_LINE);
175}
176
177/* physical button layout and labels is like this:
178
179    [1] [2] [OFF]
180    [3] [4] [ON]
181    [5] [6] [T, TIP]
182    [7] [8] [A, ARREST]
183    [9] [0] [C, CLUE]
184*/
185
186static INPUT_PORTS_START( stopthief )
187   PORT_START("IN.0") // O0
188   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("4")
189   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("6")
190   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("8")
191   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("0")
192   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("2")
193
194   PORT_START("IN.1") // O6
195   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("3")
196   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("5")
197   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("7")
198   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_NAME("9")
199   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("1")
200
201   // note: even though power buttons are on the matrix, they are not CPU-controlled
202   PORT_START("IN.2") // Vss!
203   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_PGUP) PORT_NAME("On") PORT_CHANGED_MEMBER(DEVICE_SELF, stopthief_state, power_button, (void *)true)
204   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_T) PORT_NAME("Tip")
205   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_A) PORT_NAME("Arrest")
206   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_C) PORT_NAME("Clue")
207   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_CODE(KEYCODE_PGDN) PORT_NAME("Off") PORT_CHANGED_MEMBER(DEVICE_SELF, stopthief_state, power_button, (void *)false)
208INPUT_PORTS_END
209
210
211
212/***************************************************************************
213
214  Machine Config
215
216***************************************************************************/
217
218WRITE_LINE_MEMBER(stopthief_state::auto_power_off)
219{
220   // TMS0980 auto power-off opcode
221   if (state)
222   {
223      m_power_on = false;
224      m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
225   }
226}
227
228
229void stopthief_state::machine_reset()
230{
231   m_power_on = true;
232}
233
234void stopthief_state::machine_start()
235{
236   // zerofill
237   memset(m_display_state, 0, sizeof(m_display_state));
238   memset(m_display_cache, 0, sizeof(m_display_cache));
239   memset(m_display_decay, 0, sizeof(m_display_decay));
240
241   m_o = 0;
242   m_power_on = false;
243
244   // register for savestates
245   save_item(NAME(m_display_state));
246   save_item(NAME(m_display_cache));
247   save_item(NAME(m_display_decay));
248
249   save_item(NAME(m_o));
250   save_item(NAME(m_power_on));
251}
252
253
254static MACHINE_CONFIG_START( stopthief, stopthief_state )
255
256   /* basic machine hardware */
257   MCFG_CPU_ADD("maincpu", TMS0980, MASTER_CLOCK)
258   MCFG_TMS1XXX_READ_K_CB(READ8(stopthief_state, read_k))
259   MCFG_TMS1XXX_WRITE_O_CB(WRITE16(stopthief_state, write_o))
260   MCFG_TMS1XXX_WRITE_R_CB(WRITE16(stopthief_state, write_r))
261   MCFG_TMS1XXX_POWER_OFF_CB(WRITELINE(stopthief_state, auto_power_off))
262
263   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", stopthief_state, display_decay_tick, attotime::from_msec(1))
264
265   MCFG_DEFAULT_LAYOUT(layout_stopthie)
266
267   /* no video! */
268
269   /* sound hardware */
270   MCFG_SPEAKER_STANDARD_MONO("mono")
271   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
272   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
273MACHINE_CONFIG_END
274
275
276
277/***************************************************************************
278
279  Game driver(s)
280
281***************************************************************************/
282
283ROM_START( stopthie )
284   ROM_REGION( 0x1000, "maincpu", 0 )
285   ROM_LOAD( "tms0980nll_mp6101b", 0x0000, 0x1000, CRC(8bde5bb4) SHA1(8c318fcce67acc24c7ae361f575f28ec6f94665a) )
286
287   ROM_REGION( 1246, "maincpu:ipla", 0 )
288   ROM_LOAD( "tms0980_default_ipla.pla", 0, 1246, CRC(42db9a38) SHA1(2d127d98028ec8ec6ea10c179c25e447b14ba4d0) )
289   ROM_REGION( 1982, "maincpu:mpla", 0 )
290   ROM_LOAD( "tms0980_default_mpla.pla", 0, 1982, CRC(3709014f) SHA1(d28ee59ded7f3b9dc3f0594a32a98391b6e9c961) )
291   ROM_REGION( 352, "maincpu:opla", 0 )
292   ROM_LOAD( "tms0980_stopthie_opla.pla", 0, 352, CRC(50337a48) SHA1(4a9ea62ed797a9ac5190eec3bb6ebebb7814628c) )
293   ROM_REGION( 157, "maincpu:spla", 0 )
294   ROM_LOAD( "tms0980_stopthie_spla.pla", 0, 157, CRC(399aa481) SHA1(72c56c58fde3fbb657d69647a9543b5f8fc74279) )
295ROM_END
296
297ROM_START( stopthiep )
298   ROM_REGION( 0x1000, "maincpu", 0 )
299   ROM_LOAD16_WORD( "us4341385", 0x0000, 0x1000, CRC(07aec38a) SHA1(0a3d0956495c0d6d9ea771feae6c14a473a800dc) ) // from patent US4341385, data should be correct (it included checksums)
300
301   ROM_REGION( 1246, "maincpu:ipla", 0 )
302   ROM_LOAD( "tms0980_default_ipla.pla", 0, 1246, CRC(42db9a38) SHA1(2d127d98028ec8ec6ea10c179c25e447b14ba4d0) )
303   ROM_REGION( 1982, "maincpu:mpla", 0 )
304   ROM_LOAD( "tms0980_default_mpla.pla", 0, 1982, CRC(3709014f) SHA1(d28ee59ded7f3b9dc3f0594a32a98391b6e9c961) )
305   ROM_REGION( 352, "maincpu:opla", 0 )
306   ROM_LOAD( "tms0980_stopthie_opla.pla", 0, 352, CRC(50337a48) SHA1(4a9ea62ed797a9ac5190eec3bb6ebebb7814628c) )
307   ROM_REGION( 157, "maincpu:spla", 0 )
308   ROM_LOAD( "tms0980_stopthie_spla.pla", 0, 157, CRC(399aa481) SHA1(72c56c58fde3fbb657d69647a9543b5f8fc74279) )
309ROM_END
310
311
312CONS( 1979, stopthie,  0,        0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner)", GAME_SUPPORTS_SAVE )
313CONS( 1979, stopthiep, stopthie, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner) (prototype)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team