summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2015-03-24 20:17:31 +0100
committer hap <happppp@users.noreply.github.com>2015-03-24 20:17:31 +0100
commita09a8fcbc8cc5500112521e5a569ce9f472a5d88 (patch)
tree3ce9b43cbb736230a0d7ae71195ca1d8615ad82f
parent7237f125a9fa86899d22067fae9e7f8b2ce95a06 (diff)
darktower motor simulation
-rw-r--r--src/mess/drivers/hh_tms1k.c11
-rw-r--r--src/mess/drivers/mbdtower.c124
-rw-r--r--src/mess/layout/mbdtower.lay7
3 files changed, 117 insertions, 25 deletions
diff --git a/src/mess/drivers/hh_tms1k.c b/src/mess/drivers/hh_tms1k.c
index c58cd7a1def..83d83023ef0 100644
--- a/src/mess/drivers/hh_tms1k.c
+++ b/src/mess/drivers/hh_tms1k.c
@@ -24,6 +24,7 @@
*MP2139 ? 1982, Gakken Galaxy Invader 1000
*MP2788 ? 1980, Bandai Flight Time
@MP3226 TMS1000 1978, Milton Bradley Simon
+ *MP3301 TMS1000 1979, Milton Bradley Bigtrak
*MP3320A TMS1000 1979, Coleco Head to Head Basketball
MP3403 TMS1100 1978, Marx Electronic Bowling -> elecbowl.c
@MP3404 TMS1100 1978, Parker Brothers Merlin
@@ -730,7 +731,7 @@ void hh_tms1k_state::ebball_display()
// R8 is a 7seg
m_display_segmask[8] = 0x7f;
- display_matrix(7, 9, m_o, m_r);
+ display_matrix(7, 9, ~m_o, m_r);
}
WRITE16_MEMBER(hh_tms1k_state::ebball_write_r)
@@ -750,7 +751,7 @@ WRITE16_MEMBER(hh_tms1k_state::ebball_write_o)
{
// O0-O6: led row
// O7: N/C
- m_o = ~data;
+ m_o = data;
ebball_display();
}
@@ -848,7 +849,7 @@ void hh_tms1k_state::ebball2_display()
for (int y = 0; y < 3; y++)
m_display_segmask[y] = 0x7f;
- display_matrix(8, 10, m_o, m_r);
+ display_matrix(8, 10, ~m_o, m_r ^ 0x7f);
}
WRITE16_MEMBER(hh_tms1k_state::ebball2_write_r)
@@ -860,14 +861,14 @@ WRITE16_MEMBER(hh_tms1k_state::ebball2_write_r)
m_speaker->level_w(data >> 10 & 1);
// R0-R9: led columns
- m_r = data ^ 0x7f;
+ m_r = data;
ebball2_display();
}
WRITE16_MEMBER(hh_tms1k_state::ebball2_write_o)
{
// O0-O7: led row/segment
- m_o = ~data;
+ m_o = data;
ebball2_display();
}
diff --git a/src/mess/drivers/mbdtower.c b/src/mess/drivers/mbdtower.c
index c7c35a4ab75..b591dc81ec4 100644
--- a/src/mess/drivers/mbdtower.c
+++ b/src/mess/drivers/mbdtower.c
@@ -4,7 +4,9 @@
Milton Bradley Dark Tower
* TMS1400NLL MP7332-N1.U1(Rev. B) or MP7332-N2LL(Rev. C), die labeled MP7332
+ (assume same ROM contents between revisions)
* SN75494N MOS-to-LED digit driver
+ * rotating reel + lightsensor
x
@@ -22,13 +24,20 @@ public:
{ }
void mbdtower_display();
+ bool sensor_led_on() { return m_display_decay[0][0] != 0; }
+
+ int m_motor_pos;
+ int m_motor_pos_prev;
+ int m_motor_decay;
+ bool m_motor_on;
+ bool m_sensor_blind;
+
+ TIMER_DEVICE_CALLBACK_MEMBER(motor_sim_tick);
+
DECLARE_WRITE16_MEMBER(write_r);
DECLARE_WRITE16_MEMBER(write_o);
DECLARE_READ8_MEMBER(read_k);
- bool m_motor_on;
- bool m_sensor;
-
protected:
virtual void machine_start();
};
@@ -36,27 +45,104 @@ protected:
/***************************************************************************
- I/O
+ Display, Motor
***************************************************************************/
void mbdtower_state::mbdtower_display()
{
+ // declare display matrix size and the 2 7segs
+ m_display_maxx = 7;
+ m_display_maxy = 3;
+ m_display_segmask[1] = m_display_segmask[2] = 0x7f;
+
+ // update current state
+ if (~m_r & 0x10)
+ {
+ UINT8 o = BITSWAP8(m_o,7,0,4,3,2,1,6,5) & 0x7f;
+ m_display_state[2] = (m_o & 0x80) ? o : 0;
+ m_display_state[1] = (m_o & 0x80) ? 0 : o;
+ m_display_state[0] = (m_r >> 8 & 1) | (m_r >> 4 & 0xe);
+
+ display_update();
+ }
+ else
+ {
+ // display items turned off
+ display_matrix(7, 3, 0, 0);
+ }
+}
+
+TIMER_DEVICE_CALLBACK_MEMBER(mbdtower_state::motor_sim_tick)
+{
+ // it rotates counter-clockwise (when viewed from above)
+ if (m_motor_on)
+ {
+ m_motor_pos = (m_motor_pos - 1) & 0x7f;
+
+ // give it some time to spin out when it's turned off
+ if (m_r & 0x200)
+ m_motor_decay += (m_motor_decay < 6);
+ else if (m_motor_decay > 0)
+ m_motor_decay--;
+ else
+ m_motor_on = false;
+ }
+
+ // 8 evenly spaced holes in the rotation disc for the sensor to 'see' through.
+ // The first hole is much bigger, enabling the game to determine the position.
+ if ((m_motor_pos & 0xf) < 4 || m_motor_pos < 0xc)
+ m_sensor_blind = false;
+ else
+ m_sensor_blind = true;
+
+ // on change, output info
+ if (m_motor_pos != m_motor_pos_prev)
+ output_set_value("motor_pos", 100 * (m_motor_pos / (float)0x80));
+
+ /* 3 display cards per hole, like this:
+
+ (0) <---- display increments this way <---- (7)
+
+ VICTORY WIZARD DRAGON GOLD KEY SCOUT WARRIOR (void) CURSED
+ WARRIORS BAZAAR CLOSED SWORD SILVER KEY HEALER FOOD (void) LOST
+ BRIGANDS KEY MISSING PEGASUS BRASS KEY GOLD BEAST (void) PLAGUE
+ */
+ int card_pos = m_motor_pos >> 4 & 7;
+ if (card_pos != (m_motor_pos_prev >> 4 & 7))
+ output_set_value("card_pos", card_pos);
+
+ m_motor_pos_prev = m_motor_pos;
}
+
+
+/***************************************************************************
+
+ I/O
+
+***************************************************************************/
+
WRITE16_MEMBER(mbdtower_state::write_r)
{
// R0-R2: input mux
m_inp_mux = data & 7;
+ // R9: motor on
+ if ((m_r ^ data) & 0x200)
+ output_set_value("motor_on", data >> 9 & 1);
+ if (data & 0x200)
+ m_motor_on = true;
+
// R3: N/C
- // R4: 75494 enable (speaker, lamps, digit select go through that IC)
+ // R4: 75494 /EN (speaker, lamps, digit select go through that IC)
// R5-R7: tower lamps
// R8: rotation sensor led
- // R9: motor on
+ m_r = data;
+ mbdtower_display();
// R10: speaker out
- m_speaker->level_w(data >> 10 & 1);
+ m_speaker->level_w(~data >> 4 & data >> 10 & 1);
}
WRITE16_MEMBER(mbdtower_state::write_o)
@@ -64,22 +150,16 @@ WRITE16_MEMBER(mbdtower_state::write_o)
// O0-O6: led segments A-G
// O7: digit select
m_o = data;
+ mbdtower_display();
}
-
READ8_MEMBER(mbdtower_state::read_k)
{
// rotation sensor is on K8
-
- return read_inputs(3);
+ return read_inputs(3) | ((!m_sensor_blind && sensor_led_on()) ? 8 : 0);
}
-/* tower motor simulation:
-
-*/
-
-
/***************************************************************************
@@ -138,15 +218,20 @@ void mbdtower_state::machine_start()
hh_tms1k_state::machine_start();
// zerofill/register for savestates
+ m_motor_pos = 0;
+ m_motor_pos_prev = -1;
+ m_motor_decay = 0;
m_motor_on = false;
- m_sensor = false;
+ m_sensor_blind = false;
+ save_item(NAME(m_motor_pos));
+ /* save_item(NAME(m_motor_pos_prev)); */ // don't save!
+ save_item(NAME(m_motor_decay));
save_item(NAME(m_motor_on));
- save_item(NAME(m_sensor));
+ save_item(NAME(m_sensor_blind));
}
-
static MACHINE_CONFIG_START( mbdtower, mbdtower_state )
/* basic machine hardware */
@@ -155,6 +240,7 @@ static MACHINE_CONFIG_START( mbdtower, mbdtower_state )
MCFG_TMS1XXX_WRITE_R_CB(WRITE16(mbdtower_state, write_r))
MCFG_TMS1XXX_WRITE_O_CB(WRITE16(mbdtower_state, write_o))
+ MCFG_TIMER_DRIVER_ADD_PERIODIC("tower_motor", mbdtower_state, motor_sim_tick, attotime::from_msec(3500/0x80)) // ~3.5sec for a full rotation
MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_tms1k_state, display_decay_tick, attotime::from_msec(1))
MCFG_DEFAULT_LAYOUT(layout_mbdtower)
@@ -168,7 +254,6 @@ MACHINE_CONFIG_END
-
/***************************************************************************
Game driver(s)
@@ -187,4 +272,3 @@ ROM_END
CONS( 1981, mbdtower, 0, 0, mbdtower, mbdtower, driver_device, 0, "Milton Bradley", "Dark Tower (Milton Bradley)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING )
-
diff --git a/src/mess/layout/mbdtower.lay b/src/mess/layout/mbdtower.lay
index 940ef1a955e..aff46ef4eff 100644
--- a/src/mess/layout/mbdtower.lay
+++ b/src/mess/layout/mbdtower.lay
@@ -5,6 +5,10 @@
<element name="static_black"><rect><color red="0.0" green="0.0" blue="0.0" /></rect></element>
+ <element name="digit" defstate="0">
+ <led7seg><color red="1.0" green="0.20" blue="0.22" /></led7seg>
+ </element>
+
<!-- build screen -->
@@ -14,6 +18,9 @@
<bounds left="0" right="64" top="0" bottom="64" />
</bezel>
+ <bezel name="digit1" element="digit"><bounds x="0" y="0" width="10" height="15" /></bezel>
+ <bezel name="digit2" element="digit"><bounds x="10" y="0" width="10" height="15" /></bezel>
+
</view>
</mamelayout>