Previous 199869 Revisions Next

r33677 Thursday 4th December, 2014 at 20:46:31 UTC by hap
starwbc: hooked up inputs/outputs
[src/mess/drivers]cnsector.c comp4.c merlin.c simon.c starwbc.c ticalc1x.c
[src/mess/layout]starwbc.lay

trunk/src/mess/drivers/cnsector.c
r242188r242189
5858
5959***************************************************************************/
6060
61// Devices with TMS09x0 strobe the outputs very fast, it is unnoticeable to the user.
61// The device strobes the outputs very fast, it is unnoticeable to the user.
6262// To prevent flickering here, we need to simulate a decay.
6363
6464// decay time, in steps of 10ms
r242188r242189
118118
119119   // read selected button rows
120120   for (int i = 0; i < 5; i++)
121      if (m_o & (1 << i))
121      if (m_o >> i & 1)
122122         k |= m_button_matrix[i]->read();
123123   
124124   return k;
trunk/src/mess/drivers/comp4.c
r242188r242189
102102
103103   // read selected button rows
104104   for (int i = 0; i < 3; i++)
105      if (m_o & (1 << (i + 1)))
105      if (m_o >> (i+1) & 1)
106106         k |= m_button_matrix[i]->read();
107107   
108108   return k;
trunk/src/mess/drivers/merlin.c
r242188r242189
7878   
7979   // read selected button rows
8080   for (int i = 0; i < 4; i++)
81      if (m_o & (1 << i))
81      if (m_o >> i & 1)
8282         k |= m_button_matrix[i]->read();
8383
8484   return k;
trunk/src/mess/drivers/simon.c
r242188r242189
6666   for (int i = 0; i < 4; i++)
6767   {
6868      const int r[4] = { 0, 1, 2, 9 };
69      if (m_r & (1 << r[i]))
69      if (m_r >> r[i] & 1)
7070         k |= m_button_matrix[i]->read();
7171   }
7272
trunk/src/mess/drivers/starwbc.c
r242188r242189
22// copyright-holders:hap
33/***************************************************************************
44
5  Kenner Star Wars: Electronic Battle Command Game
6  * TMS1100 MCU, marked MP3438A
5  Kenner Star Wars - Electronic Battle Command
6  * TMS1100 MCU, labeled MP3438A
7 
8  This is a small tabletop space-dogfighting game.
79
810
911***************************************************************************/
1012
1113#include "emu.h"
1214#include "cpu/tms0980/tms0980.h"
15#include "sound/speaker.h"
1316
1417#include "starwbc.lh"
1518
1619
20// master clock is unknown, the value below is an approximation
21#define MASTER_CLOCK (350000)
22
23
1724class starwbc_state : public driver_device
1825{
1926public:
2027   starwbc_state(const machine_config &mconfig, device_type type, const char *tag)
2128      : driver_device(mconfig, type, tag),
22      m_maincpu(*this, "maincpu")
29      m_maincpu(*this, "maincpu"),
30      m_button_matrix(*this, "IN"),
31      m_speaker(*this, "speaker")
2332   { }
2433
2534   required_device<cpu_device> m_maincpu;
35   required_ioport_array<11> m_button_matrix;
36   required_device<speaker_sound_device> m_speaker;
2637
2738   UINT16 m_r;
2839   UINT16 m_o;
2940
41   UINT16 m_leds_state[0x10];
42   UINT16 m_leds_cache[0x10];
43   UINT8 m_leds_decay[0x100];
44
3045   DECLARE_READ8_MEMBER(read_k);
3146   DECLARE_WRITE16_MEMBER(write_o);
3247   DECLARE_WRITE16_MEMBER(write_r);
48   
49   TIMER_DEVICE_CALLBACK_MEMBER(leds_decay_tick);
50   void leds_update();
51   void prepare_and_update();
3352
3453   virtual void machine_start();
3554};
r242188r242189
3857
3958/***************************************************************************
4059
60  LEDs
61
62***************************************************************************/
63
64// The device strobes the outputs very fast, it is unnoticeable to the user.
65// To prevent flickering here, we need to simulate a decay.
66
67// decay time, in steps of 10ms
68#define LEDS_DECAY_TIME 4
69
70void starwbc_state::leds_update()
71{
72   UINT16 active_state[0x10];
73   
74   for (int i = 0; i < 0x10; i++)
75   {
76      active_state[i] = 0;
77     
78      for (int j = 0; j < 0x10; j++)
79      {
80         int di = j << 4 | i;
81         
82         // turn on powered leds
83         if (m_leds_state[i] >> j & 1)
84            m_leds_decay[di] = LEDS_DECAY_TIME;
85         
86         // determine active state
87         int ds = (m_leds_decay[di] != 0) ? 1 : 0;
88         active_state[i] |= (ds << j);
89      }
90   }
91   
92   // on difference, send to output
93   for (int i = 0; i < 0x10; i++)
94      if (m_leds_cache[i] != active_state[i])
95      {
96         output_set_digit_value(i, active_state[i]);
97         
98         for (int j = 0; j < 8; j++)
99            output_set_lamp_value(i*10 + j, active_state[i] >> j & 1);
100      }
101   
102   memcpy(m_leds_cache, active_state, sizeof(m_leds_cache));
103}
104
105TIMER_DEVICE_CALLBACK_MEMBER(starwbc_state::leds_decay_tick)
106{
107   // slowly turn off unpowered leds
108   for (int i = 0; i < 0x100; i++)
109      if (!(m_leds_state[i & 0xf] >> (i>>4) & 1) && m_leds_decay[i])
110         m_leds_decay[i]--;
111   
112   leds_update();
113}
114
115void starwbc_state::prepare_and_update()
116{
117   UINT8 o = (m_o << 4 & 0xf0) | (m_o >> 4 & 0x0f);
118   const UINT8 mask[5] = { 0x30, 0xff, 0xff, 0x7f, 0x7f };
119   
120   // R0,R2,R4,R6,R8
121   for (int i = 0; i < 5; i++)
122      m_leds_state[i*2] = (m_r >> (i*2) & 1) ? (o & mask[i]) : 0;
123
124   leds_update();
125}
126
127
128
129/***************************************************************************
130
41131  I/O
42132
43133***************************************************************************/
44134
45135READ8_MEMBER(starwbc_state::read_k)
46136{
47   return 0;
137   UINT8 k = 0;
138
139   // read selected button rows
140   for (int i = 0; i < 11; i++)
141      if (m_r >> i & 1)
142         k |= m_button_matrix[i]->read();
143
144   // const int r[5] = { 3, 5, 6, 7, 9 }; //nope
145   //printf("%04X ",m_r);
146   
147   return k;
48148}
49149
50150WRITE16_MEMBER(starwbc_state::write_r)
51151{
152   // R0,R2,R4: select lamp row
153   // R6,R8: select digit
154   // R3,R5-R7,R9: input mux
155   // R9: piezo speaker
156   m_speaker->level_w(data >> 9 & 1);
157   
52158   m_r = data;
159   prepare_and_update();
53160}
54161
55162WRITE16_MEMBER(starwbc_state::write_o)
56163{
164   // O0-O7: leds state
57165   m_o = data;
166   prepare_and_update();
58167}
59168
60169
r242188r242189
66175***************************************************************************/
67176
68177static INPUT_PORTS_START( starwbc )
178   PORT_START("IN.0")
179   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1)
180   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2)
181   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3)
182   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4)
183
184   PORT_START("IN.1")
185   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_5)
186   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_6)
187   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_7)
188   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_8)
189
190   PORT_START("IN.2")
191   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_9)
192   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_0)
193   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS)
194   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS)
195
196   PORT_START("IN.3")
197   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q)
198   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_W)
199   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_E)
200   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_R)
201
202   PORT_START("IN.4")
203   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_T)
204   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y)
205   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_U)
206   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_I)
207
208   PORT_START("IN.5")
209   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_O)
210   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_A)
211   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_S)
212   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_D)
213
214   PORT_START("IN.6")
215   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_F)
216   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_G)
217   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_H)
218   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_J)
219
220   PORT_START("IN.7")
221   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_K)
222   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_L)
223   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z)
224   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_X)
225
226   PORT_START("IN.8")
227   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_C)
228   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_V)
229   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_B)
230   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_N)
231
232   PORT_START("IN.9")
233   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_M)
234   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA)
235   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP)
236   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH)
237
238   PORT_START("IN.10")
239   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_1_PAD)
240   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_2_PAD)
241   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_3_PAD)
242   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CODE(KEYCODE_4_PAD)
69243INPUT_PORTS_END
70244
71245
r242188r242189
78252
79253void starwbc_state::machine_start()
80254{
255   memset(m_leds_state, 0, sizeof(m_leds_state));
256   memset(m_leds_cache, 0, sizeof(m_leds_cache));
257   memset(m_leds_decay, 0, sizeof(m_leds_decay));
81258   m_r = 0;
82259   m_o = 0;
83260   
261   save_item(NAME(m_leds_state));
262   save_item(NAME(m_leds_cache));
263   save_item(NAME(m_leds_decay));
84264   save_item(NAME(m_r));
85265   save_item(NAME(m_o));
86266}
r242188r242189
89269static MACHINE_CONFIG_START( starwbc, starwbc_state )
90270
91271   /* basic machine hardware */
92   MCFG_CPU_ADD("maincpu", TMS1100, 400000)
272   MCFG_CPU_ADD("maincpu", TMS1100, MASTER_CLOCK)
93273   MCFG_TMS1XXX_READ_K_CB(READ8(starwbc_state, read_k))
94274   MCFG_TMS1XXX_WRITE_O_CB(WRITE16(starwbc_state, write_o))
95275   MCFG_TMS1XXX_WRITE_R_CB(WRITE16(starwbc_state, write_r))
276
277   MCFG_TIMER_DRIVER_ADD_PERIODIC("leds_decay", starwbc_state, leds_decay_tick, attotime::from_msec(10))
96278   
97279   MCFG_DEFAULT_LAYOUT(layout_starwbc)
98280
99281   /* no video! */
100282
101283   /* sound hardware */
102//   MCFG_SPEAKER_STANDARD_MONO("mono")
284   MCFG_SPEAKER_STANDARD_MONO("mono")
285   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
286   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
103287MACHINE_CONFIG_END
104288
105289
r242188r242189
121305ROM_END
122306
123307
124CONS( 1979, starwbc, 0, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars: Electronic Battle Command Game", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE | GAME_NO_SOUND )
308CONS( 1979, starwbc, 0, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars - Electronic Battle Command", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
trunk/src/mess/drivers/ticalc1x.c
r242188r242189
150150
151151   // read selected button rows
152152   for (int i = 0; i < 11; i++)
153      if (m_r & (1 << i))
153      if (m_r >> i & 1)
154154         k |= m_button_matrix[i]->read();
155155
156156   return k;
r242188r242189
182182
183183   // read selected button rows
184184   for (int i = 0; i < 7; i++)
185      if (m_o & (1 << (i + 1)))
185      if (m_o >> (i+1) & 1)
186186         k |= m_button_matrix[i]->read();
187187
188188   return k;
r242188r242189
213213
214214   // read selected button rows
215215   for (int i = 0; i < 4; i++)
216      if (m_o & (1 << (i + 1)))
216      if (m_o >> (i+1) & 1)
217217         k |= m_button_matrix[i]->read();
218218
219219   return k;
r242188r242189
255255
256256   // read selected button rows
257257   for (int i = 0; i < 8; i++)
258      if (m_o & (1 << i))
258      if (m_o >> i & 1)
259259         k |= m_button_matrix[i]->read();
260260
261261   return k;
trunk/src/mess/layout/starwbc.lay
r242188r242189
11<?xml version="1.0"?>
22<mamelayout version="2">
33
4<!-- define elements -->
5
6   <element name="digit" defstate="0">
7      <led7seg><color red="1.0" green="0.25" blue="0.23" /></led7seg>
8   </element>
9
10   <element name="lamp" defstate="0">
11      <disk state="1"><color red="1.0" green="0.25" blue="0.23" /></disk>
12      <disk state="0"><color red="0.2" green="0.05" blue="0.04" /></disk>
13   </element>
14
15
16<!-- build screen -->
17
418   <view name="Internal Layout">
519      <bounds left="0" right="200" top="0" bottom="200" />
620
21      <bezel name="lamp20" element="lamp"><bounds x="0" y="0" width="5" height="5" /></bezel>
22      <bezel name="lamp21" element="lamp"><bounds x="10" y="0" width="5" height="5" /></bezel>
23      <bezel name="lamp22" element="lamp"><bounds x="20" y="0" width="5" height="5" /></bezel>
24      <bezel name="lamp23" element="lamp"><bounds x="30" y="0" width="5" height="5" /></bezel>
25
26      <bezel name="lamp24" element="lamp"><bounds x="0" y="10" width="5" height="5" /></bezel>
27      <bezel name="lamp25" element="lamp"><bounds x="10" y="10" width="5" height="5" /></bezel>
28      <bezel name="lamp26" element="lamp"><bounds x="20" y="10" width="5" height="5" /></bezel>
29      <bezel name="lamp27" element="lamp"><bounds x="30" y="10" width="5" height="5" /></bezel>
30
31      <bezel name="lamp40" element="lamp"><bounds x="0" y="20" width="5" height="5" /></bezel>
32      <bezel name="lamp41" element="lamp"><bounds x="10" y="20" width="5" height="5" /></bezel>
33      <bezel name="lamp42" element="lamp"><bounds x="20" y="20" width="5" height="5" /></bezel>
34      <bezel name="lamp43" element="lamp"><bounds x="30" y="20" width="5" height="5" /></bezel>
35
36      <bezel name="lamp44" element="lamp"><bounds x="0" y="30" width="5" height="5" /></bezel>
37      <bezel name="lamp45" element="lamp"><bounds x="10" y="30" width="5" height="5" /></bezel>
38      <bezel name="lamp46" element="lamp"><bounds x="20" y="30" width="5" height="5" /></bezel>
39      <bezel name="lamp47" element="lamp"><bounds x="30" y="30" width="5" height="5" /></bezel>
40
41      <bezel name="lamp5" element="lamp"><bounds x="50" y="10" width="5" height="5" /></bezel>
42      <bezel name="lamp4" element="lamp"><bounds x="50" y="30" width="5" height="5" /></bezel>
43
44      <bezel name="digit6" element="digit"><bounds x="50" y="50" width="10" height="15" /></bezel>
45      <bezel name="digit8" element="digit"><bounds x="60" y="50" width="10" height="15" /></bezel>
46
47
748   </view>
849</mamelayout>


Previous 199869 Revisions Next


© 1997-2024 The MAME Team