Previous 199869 Revisions Next

r34804 Sunday 1st February, 2015 at 22:30:13 UTC by hap
wildfire 7segleds and buttons work
[src/emu/cpu/amis2000]amis2000.c
[src/mess/drivers]splitsec.c tispeak.c wildfire.c
[src/mess/layout]wildfire.lay

trunk/src/emu/cpu/amis2000/amis2000.c
r243315r243316
3333
3434static ADDRESS_MAP_START(program_1_5k, AS_PROGRAM, 8, amis2000_device)
3535   AM_RANGE(0x0000, 0x03ff) AM_ROM
36   AM_RANGE(0x0400, 0x05ff) AM_NOP
36   AM_RANGE(0x0400, 0x05ff) AM_NOP // 0x00
3737   AM_RANGE(0x0600, 0x07ff) AM_ROM
3838ADDRESS_MAP_END
3939
r243315r243316
128128   m_program = &space(AS_PROGRAM);
129129   m_data = &space(AS_DATA);
130130
131   m_read_k.resolve_safe(0);
132   m_read_i.resolve_safe(0);
131   m_read_k.resolve_safe(0xf);
132   m_read_i.resolve_safe(0xf);
133133   m_read_d.resolve_safe(0);
134134   m_write_d.resolve_safe();
135135   m_write_a.resolve_safe();
r243315r243316
209209   m_d_polarity = 0;
210210   m_d = 0; d_latch_out(false);
211211   m_a = 0; m_write_a(0, 0, 0xffff);
212   m_i = 0;
213   m_k = 0;
212   m_i = 0xf;
213   m_k = 0xf;
214214}
215215
216216
trunk/src/mess/drivers/splitsec.c
r243315r243316
103103   for (int i = 0; i < 0x10; i++)
104104   {
105105      // update current state
106      if (m_r >> i & 1)
107         m_leds_state[i] = m_o;
106      m_leds_state[i] = (m_r >> i & 1) ? m_o : 0;
108107
109108      active_state[i] = 0;
110109
trunk/src/mess/drivers/tispeak.c
r243315r243316
138138   for (int i = 0; i < 0x10; i++)
139139   {
140140      // update current state
141      if (m_r >> i & 1)
142         m_leds_state[i] = m_o;
141      m_leds_state[i] = (m_r >> i & 1) ? m_o : 0;
143142
144143      active_state[i] = 0;
145144
trunk/src/mess/drivers/wildfire.c
r243315r243316
3131   required_device<cpu_device> m_maincpu;
3232   required_device<speaker_sound_device> m_speaker;
3333
34   UINT8 m_d;
35   UINT16 m_a;
36
37   UINT16 m_leds_state[0x10];
38   UINT16 m_leds_cache[0x10];
39   UINT8 m_leds_decay[0x100];
40
3441   DECLARE_WRITE8_MEMBER(write_d);
3542   DECLARE_WRITE16_MEMBER(write_a);
3643
44   TIMER_DEVICE_CALLBACK_MEMBER(leds_decay_tick);
45   void leds_update();
46   bool index_is_7segled(int i);
47
3748   virtual void machine_start();
3849};
3950
4051
52
4153/***************************************************************************
4254
55  LEDs
56
57***************************************************************************/
58
59// The device strobes the outputs very fast, it is unnoticeable to the user.
60// To prevent flickering here, we need to simulate a decay.
61
62// decay time, in steps of 10ms
63#define LEDS_DECAY_TIME 4
64
65bool wildfire_state::index_is_7segled(int i)
66{
67   // first 3 A are 7segleds
68   return (i < 3);
69}
70
71void wildfire_state::leds_update()
72{
73   UINT16 active_state[0x10];
74
75   for (int i = 0; i < 0x10; i++)
76   {
77      // update current state
78      m_leds_state[i] = (~m_a >> i & 1) ? m_d : 0;
79      if (index_is_7segled(i))
80         m_leds_state[i] = BITSWAP8(m_leds_state[i],7,0,1,2,3,4,5,6);
81
82      active_state[i] = 0;
83
84      for (int j = 0; j < 0x10; j++)
85      {
86         int di = j << 4 | i;
87
88         // turn on powered leds
89         if (m_leds_state[i] >> j & 1)
90            m_leds_decay[di] = LEDS_DECAY_TIME;
91
92         // determine active state
93         int ds = (m_leds_decay[di] != 0) ? 1 : 0;
94         active_state[i] |= (ds << j);
95      }
96   }
97
98   // on difference, send to output
99   for (int i = 0; i < 0x10; i++)
100      if (m_leds_cache[i] != active_state[i])
101      {
102         if (index_is_7segled(i))
103            output_set_digit_value(i, active_state[i] & 0x7f);
104
105         for (int j = 0; j < 8; j++)
106            output_set_lamp_value(i*10 + j, active_state[i] >> j & 1);
107      }
108
109   memcpy(m_leds_cache, active_state, sizeof(m_leds_cache));
110}
111
112TIMER_DEVICE_CALLBACK_MEMBER(wildfire_state::leds_decay_tick)
113{
114   // slowly turn off unpowered leds
115   for (int i = 0; i < 0x100; i++)
116      if (!(m_leds_state[i & 0xf] >> (i>>4) & 1) && m_leds_decay[i])
117         m_leds_decay[i]--;
118
119   leds_update();
120}
121
122
123
124/***************************************************************************
125
43126  I/O
44127
45128***************************************************************************/
46129
47130WRITE8_MEMBER(wildfire_state::write_d)
48131{
132   m_d = data;
133   leds_update();
49134}
50135
51136WRITE16_MEMBER(wildfire_state::write_a)
52137{
138   m_a = data;
139   leds_update();
53140}
54141
55142
r243315r243316
62149
63150static INPUT_PORTS_START( wildfire )
64151   PORT_START("IN1") // I
65   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Shooter Button")
66   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Left Flipper")
67   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Right Flipper")
68   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED )
152   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Shooter Button")
153   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Left Flipper")
154   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Right Flipper")
155   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
69156INPUT_PORTS_END
70157
71158
r243315r243316
78165
79166void wildfire_state::machine_start()
80167{
168   // zerofill
169   memset(m_leds_state, 0, sizeof(m_leds_state));
170   memset(m_leds_cache, 0, sizeof(m_leds_cache));
171   memset(m_leds_decay, 0, sizeof(m_leds_decay));
172
173   m_d = 0;
174   m_a = 0;
175
176   // register for savestates
177   save_item(NAME(m_leds_state));
178   save_item(NAME(m_leds_cache));
179   save_item(NAME(m_leds_decay));
180
181   save_item(NAME(m_d));
182   save_item(NAME(m_a));
81183}
82184
83185
r243315r243316
89191   MCFG_AMI_S2000_WRITE_D_CB(WRITE8(wildfire_state, write_d))
90192   MCFG_AMI_S2000_WRITE_A_CB(WRITE16(wildfire_state, write_a))
91193
194   MCFG_TIMER_DRIVER_ADD_PERIODIC("leds_decay", wildfire_state, leds_decay_tick, attotime::from_msec(10))
195
92196   MCFG_DEFAULT_LAYOUT(layout_wildfire)
93197
94198   /* no video! */
trunk/src/mess/layout/wildfire.lay
r243315r243316
55
66   <element name="static_black"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element>
77
8   <element name="digit" defstate="0">
9      <led7seg><color red="1.0" green="0.20" blue="0.22" /></led7seg>
10   </element>
811
12
913<!-- build screen -->
1014
1115   <view name="Internal Layout">
r243315r243316
1418         <bounds left="0" right="100" top="0" bottom="100" />
1519      </bezel>
1620
21      <bezel name="digit0" element="digit"><bounds x="0" y="0" width="10" height="15" /></bezel>
22      <bezel name="digit1" element="digit"><bounds x="10" y="0" width="10" height="15" /></bezel>
23      <bezel name="digit2" element="digit"><bounds x="20" y="0" width="10" height="15" /></bezel>
24
1725   </view>
1826</mamelayout>


Previous 199869 Revisions Next


© 1997-2024 The MAME Team