Previous 199869 Revisions Next

r36611 Tuesday 24th March, 2015 at 19:17:31 UTC by hap
darktower motor simulation
[src/mess/drivers]hh_tms1k.c mbdtower.c
[src/mess/layout]mbdtower.lay

trunk/src/mess/drivers/hh_tms1k.c
r245122r245123
2424 *MP2139   ?        1982, Gakken Galaxy Invader 1000
2525 *MP2788   ?        1980, Bandai Flight Time
2626 @MP3226   TMS1000  1978, Milton Bradley Simon
27 *MP3301   TMS1000  1979, Milton Bradley Bigtrak
2728 *MP3320A  TMS1000  1979, Coleco Head to Head Basketball
2829  MP3403   TMS1100  1978, Marx Electronic Bowling -> elecbowl.c
2930 @MP3404   TMS1100  1978, Parker Brothers Merlin
r245122r245123
730731   // R8 is a 7seg
731732   m_display_segmask[8] = 0x7f;
732733   
733   display_matrix(7, 9, m_o, m_r);
734   display_matrix(7, 9, ~m_o, m_r);
734735}
735736
736737WRITE16_MEMBER(hh_tms1k_state::ebball_write_r)
r245122r245123
750751{
751752   // O0-O6: led row
752753   // O7: N/C
753   m_o = ~data;
754   m_o = data;
754755   ebball_display();
755756}
756757
r245122r245123
848849   for (int y = 0; y < 3; y++)
849850      m_display_segmask[y] = 0x7f;
850851   
851   display_matrix(8, 10, m_o, m_r);
852   display_matrix(8, 10, ~m_o, m_r ^ 0x7f);
852853}
853854
854855WRITE16_MEMBER(hh_tms1k_state::ebball2_write_r)
r245122r245123
860861   m_speaker->level_w(data >> 10 & 1);
861862   
862863   // R0-R9: led columns
863   m_r = data ^ 0x7f;
864   m_r = data;
864865   ebball2_display();
865866}
866867
867868WRITE16_MEMBER(hh_tms1k_state::ebball2_write_o)
868869{
869870   // O0-O7: led row/segment
870   m_o = ~data;
871   m_o = data;
871872   ebball2_display();
872873}
873874
trunk/src/mess/drivers/mbdtower.c
r245122r245123
44
55  Milton Bradley Dark Tower
66  * TMS1400NLL MP7332-N1.U1(Rev. B) or MP7332-N2LL(Rev. C), die labeled MP7332
7    (assume same ROM contents between revisions)
78  * SN75494N MOS-to-LED digit driver
9  * rotating reel + lightsensor
810
911  x
1012
r245122r245123
2224   { }
2325
2426   void mbdtower_display();
27   bool sensor_led_on() { return m_display_decay[0][0] != 0; }
28
29   int m_motor_pos;
30   int m_motor_pos_prev;
31   int m_motor_decay;
32   bool m_motor_on;
33   bool m_sensor_blind;
34
35   TIMER_DEVICE_CALLBACK_MEMBER(motor_sim_tick);
36
2537   DECLARE_WRITE16_MEMBER(write_r);
2638   DECLARE_WRITE16_MEMBER(write_o);
2739   DECLARE_READ8_MEMBER(read_k);
2840
29   bool m_motor_on;
30   bool m_sensor;
31
3241protected:
3342   virtual void machine_start();
3443};
r245122r245123
3645
3746/***************************************************************************
3847
39  I/O
48  Display, Motor
4049
4150***************************************************************************/
4251
4352void mbdtower_state::mbdtower_display()
4453{
54   // declare display matrix size and the 2 7segs
55   m_display_maxx = 7;
56   m_display_maxy = 3;
57   m_display_segmask[1] = m_display_segmask[2] = 0x7f;
58   
59   // update current state
60   if (~m_r & 0x10)
61   {
62      UINT8 o = BITSWAP8(m_o,7,0,4,3,2,1,6,5) & 0x7f;
63      m_display_state[2] = (m_o & 0x80) ? o : 0;
64      m_display_state[1] = (m_o & 0x80) ? 0 : o;
65      m_display_state[0] = (m_r >> 8 & 1) | (m_r >> 4 & 0xe);
66
67      display_update();
68   }
69   else
70   {
71      // display items turned off
72      display_matrix(7, 3, 0, 0);
73   }
4574}
4675
76TIMER_DEVICE_CALLBACK_MEMBER(mbdtower_state::motor_sim_tick)
77{
78   // it rotates counter-clockwise (when viewed from above)
79   if (m_motor_on)
80   {
81      m_motor_pos = (m_motor_pos - 1) & 0x7f;
82     
83      // give it some time to spin out when it's turned off
84      if (m_r & 0x200)
85         m_motor_decay += (m_motor_decay < 6);
86      else if (m_motor_decay > 0)
87         m_motor_decay--;
88      else
89         m_motor_on = false;
90   }
91
92   // 8 evenly spaced holes in the rotation disc for the sensor to 'see' through.
93   // The first hole is much bigger, enabling the game to determine the position.
94   if ((m_motor_pos & 0xf) < 4 || m_motor_pos < 0xc)
95      m_sensor_blind = false;
96   else
97      m_sensor_blind = true;
98   
99   // on change, output info
100   if (m_motor_pos != m_motor_pos_prev)
101      output_set_value("motor_pos", 100 * (m_motor_pos / (float)0x80));
102   
103   /* 3 display cards per hole, like this:
104   
105       (0)                <---- display increments this way <----                    (7)
106
107       VICTORY    WIZARD         DRAGON    GOLD KEY     SCOUT    WARRIOR   (void)    CURSED
108       WARRIORS   BAZAAR CLOSED  SWORD     SILVER KEY   HEALER   FOOD      (void)    LOST
109       BRIGANDS   KEY MISSING    PEGASUS   BRASS KEY    GOLD     BEAST     (void)    PLAGUE
110   */
111   int card_pos = m_motor_pos >> 4 & 7;
112   if (card_pos != (m_motor_pos_prev >> 4 & 7))
113      output_set_value("card_pos", card_pos);
114   
115   m_motor_pos_prev = m_motor_pos;
116}
117
118
119
120/***************************************************************************
121
122  I/O
123
124***************************************************************************/
125
47126WRITE16_MEMBER(mbdtower_state::write_r)
48127{
49128   // R0-R2: input mux
50129   m_inp_mux = data & 7;
51130   
131   // R9: motor on
132   if ((m_r ^ data) & 0x200)
133      output_set_value("motor_on", data >> 9 & 1);
134   if (data & 0x200)
135      m_motor_on = true;
136
52137   // R3: N/C
53   // R4: 75494 enable (speaker, lamps, digit select go through that IC)
138   // R4: 75494 /EN (speaker, lamps, digit select go through that IC)
54139   // R5-R7: tower lamps
55140   // R8: rotation sensor led
56   // R9: motor on
141   m_r = data;
142   mbdtower_display();
57143   
58144   // R10: speaker out
59   m_speaker->level_w(data >> 10 & 1);
145   m_speaker->level_w(~data >> 4 & data >> 10 & 1);
60146}
61147
62148WRITE16_MEMBER(mbdtower_state::write_o)
r245122r245123
64150   // O0-O6: led segments A-G
65151   // O7: digit select
66152   m_o = data;
153   mbdtower_display();
67154}
68155
69
70156READ8_MEMBER(mbdtower_state::read_k)
71157{
72158   // rotation sensor is on K8
73   
74   return read_inputs(3);
159   return read_inputs(3) | ((!m_sensor_blind && sensor_led_on()) ? 8 : 0);
75160}
76161
77162
78/* tower motor simulation:
79163
80*/
81
82
83
84164/***************************************************************************
85165
86166  Inputs
r245122r245123
138218   hh_tms1k_state::machine_start();
139219
140220   // zerofill/register for savestates
221   m_motor_pos = 0;
222   m_motor_pos_prev = -1;
223   m_motor_decay = 0;
141224   m_motor_on = false;
142   m_sensor = false;
225   m_sensor_blind = false;
143226   
227   save_item(NAME(m_motor_pos));
228   /* save_item(NAME(m_motor_pos_prev)); */ // don't save!
229   save_item(NAME(m_motor_decay));
144230   save_item(NAME(m_motor_on));
145   save_item(NAME(m_sensor));
231   save_item(NAME(m_sensor_blind));
146232}
147233
148234
149
150235static MACHINE_CONFIG_START( mbdtower, mbdtower_state )
151236
152237   /* basic machine hardware */
r245122r245123
155240   MCFG_TMS1XXX_WRITE_R_CB(WRITE16(mbdtower_state, write_r))
156241   MCFG_TMS1XXX_WRITE_O_CB(WRITE16(mbdtower_state, write_o))
157242
243   MCFG_TIMER_DRIVER_ADD_PERIODIC("tower_motor", mbdtower_state, motor_sim_tick, attotime::from_msec(3500/0x80)) // ~3.5sec for a full rotation
158244   MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_tms1k_state, display_decay_tick, attotime::from_msec(1))
159245   MCFG_DEFAULT_LAYOUT(layout_mbdtower)
160246
r245122r245123
168254
169255
170256
171
172257/***************************************************************************
173258
174259  Game driver(s)
r245122r245123
187272
188273
189274CONS( 1981, mbdtower, 0, 0, mbdtower, mbdtower, driver_device, 0, "Milton Bradley", "Dark Tower (Milton Bradley)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )
190
trunk/src/mess/layout/mbdtower.lay
r245122r245123
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">
r245122r245123
1418         <bounds left="0" right="64" top="0" bottom="64" />
1519      </bezel>
1620
21      <bezel name="digit1" element="digit"><bounds x="0" y="0" width="10" height="15" /></bezel>
22      <bezel name="digit2" element="digit"><bounds x="10" y="0" width="10" height="15" /></bezel>
1723
24
1825   </view>
1926</mamelayout>


Previous 199869 Revisions Next


© 1997-2024 The MAME Team