summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/barcrest/mpu4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/barcrest/mpu4.cpp')
-rw-r--r--src/mame/barcrest/mpu4.cpp619
1 files changed, 288 insertions, 331 deletions
diff --git a/src/mame/barcrest/mpu4.cpp b/src/mame/barcrest/mpu4.cpp
index c20a3e1563b..3292ac4f685 100644
--- a/src/mame/barcrest/mpu4.cpp
+++ b/src/mame/barcrest/mpu4.cpp
@@ -24,7 +24,7 @@ previously added through expansion ports. However, there is no backwards compati
reworked.
Like MPU3, a 6840PTM is used for internal timing, and other miscellaneous control functions, including as a crude analogue sound device
-(a square wave from the PTM being used as the alarm sound generator). However, the main sound functionality is provided by
+(a square wave from the PTM being fed into a 1-bit DAC circuit as the alarm sound generator). However, the main sound functionality is provided by
dedicated hardware (an AY8913).
A MPU4 GAME CARD (cartridge) plugs into the MPU4 board containing the game, and a protection PAL (the 'characteriser').
@@ -81,7 +81,7 @@ In addition there are two auxiliary ports that can be accessed separately to the
|
Output2 --+-> Clock3 |
| |
- | Output3 ---> 'to audio amp' ??
+ | Output3 ---> 'to audio amp' (square wave)
|
+--------> CA1 IC3 (
@@ -225,6 +225,18 @@ To change between them, follow these instructions:
#include "mpu4.lh"
#include "mpu4ext.lh"
+#define LOG_IC3 (1U << 1)
+#define LOG_IC8 (1U << 2)
+
+#ifdef MAME_DEBUG
+#define VERBOSE (LOG_GENERAL | LOG_IC3 | LOG_IC8)
+#else
+#define VERBOSE (0)
+#endif
+#include "logmacro.h"
+
+#include <cmath>
+
/*
LED Segments related to pins (5 is not connected):
@@ -245,9 +257,9 @@ with settings like this in the majority of cases.
8 display enables (pins 10 - 17)
*/
-void mpu4_state::lamp_extend_small(int data)
+void mpu4_state::lamp_extend_small(uint8_t data)
{
- int lamp_ext_data,column,i;
+ uint8_t lamp_ext_data, column;
column = data & 0x07;
lamp_ext_data = 0x1f - ((data & 0xf8) >> 3);//remove the mux lines from the data
@@ -256,12 +268,12 @@ void mpu4_state::lamp_extend_small(int data)
{
//One write to reset the drive lines, one with the data, one to clear the lines, so only the 2nd write does anything
//TODO: PWM
- for (i = 0; i < 5; i++)
+ for (int i = 0; i < 5; i++)
{
- m_lamps[(8*column)+i+128] = BIT(lamp_ext_data, i);
+ m_lamps[(8*column) + i + 128] = BIT(lamp_ext_data, i);
}
}
- m_lamp_strobe_ext_persistence ++;
+ m_lamp_strobe_ext_persistence++;
if ((m_lamp_strobe_ext_persistence == 3)||(m_lamp_strobe_ext[0] != column))
{
m_lamp_strobe_ext_persistence = 0;
@@ -269,27 +281,27 @@ void mpu4_state::lamp_extend_small(int data)
}
}
-void mpu4_state::lamp_extend_large(int data,int column,int active)
+void mpu4_state::lamp_extend_large(uint8_t data, uint8_t column, bool active)
{
- m_lamp_sense = 0;
- int bit7 = BIT(data, 7);
- if ( bit7 != m_last_b7 )
+ m_lamp_sense = false;
+ uint8_t bit7 = BIT(data, 7);
+ if (bit7 != m_last_b7)
{
- m_card_live = 1;
+ m_card_live = true;
//depending on bit 7, we can access one of two 'blocks' of 64 lamps
- int lampbase = bit7 ? 0 : 64;
- if ( data & 0x3f )
+ uint8_t lampbase = bit7 ? 0 : 64;
+ if (data & 0x3f)
{
- m_lamp_sense = 1;
+ m_lamp_sense = true;
}
- if ( active )
+ if (active)
{
if (m_lamp_strobe_ext[bit7] != column)
{
for (int i = 0; i < 8; i++)
{
// this includes bit 7, so you don't get a true 128 extra lamps as the last row is always 0 or 1 depending on which set of 64 we're dealing with
- m_lamps[(8*column)+i+128+lampbase] = BIT(data, i);
+ m_lamps[(8*column) + i + 128 + lampbase] = BIT(data, i);
}
m_lamp_strobe_ext[bit7] = column;
}
@@ -298,23 +310,21 @@ void mpu4_state::lamp_extend_large(int data,int column,int active)
}
else
{
- m_card_live = 0;
+ m_card_live = false;
}
}
-void mpu4_state::led_write_extender(int latch, int data, int starting_column)
+void mpu4_state::led_write_extender(uint8_t latch, uint8_t data, uint8_t column)
{
- int diff,i,j, ext_strobe;
-
- diff = (latch ^ m_last_latch) & latch;
- ext_strobe = (7 - starting_column) * 8;
+ const uint8_t diff = (latch ^ m_last_latch) & latch;
+ const uint8_t ext_strobe = (7 - column) * 8;
data = ~data;//invert drive lines
- for (i=0; i<5; i++)
+ for (int i = 0; i < 5; i++)
{
- if (diff & (1<<i))
+ if (BIT(diff, i))
{
- for (j=0; j<8; j++)
+ for (int j = 0; j < 8; j++)
{
m_mpu4leds[(ext_strobe + i) | j], BIT(data, j);
}
@@ -328,20 +338,19 @@ void mpu4_state::led_write_extender(int latch, int data, int starting_column)
void mpu4_state::update_meters()
{
- int meter;
- int data = ((m_mmtr_data & 0x7f) | m_remote_meter);
+ uint8_t data = ((m_mmtr_data & 0x7f) | m_remote_meter);
switch (m_reel_mux)
{
case STANDARD_REEL:
if (m_hopper_type != TUBES)
{
- data = (data & 0x0F); //Strip reel data from meter drives, leaving active elements
+ data = (data & 0x0f); //Strip reel data from meter drives, leaving active elements
}
break;
case FIVE_REEL_5TO8:
m_reel[4]->update(((data >> 4) & 0x0f));
- data = (data & 0x0F); //Strip reel data from meter drives, leaving active elements
+ data = (data & 0x0f); //Strip reel data from meter drives, leaving active elements
awp_draw_reel(machine(),"reel5", *m_reel[4]);
break;
@@ -369,7 +378,7 @@ void mpu4_state::update_meters()
case SIX_REEL_5TO8: // m_reel[4] for this case is already handled in pia_ic5_porta_w
m_reel[4]->update(((data >> 4) & 0x0f));
//data = 0x00; //Strip all reel data from meter drives
- data = (data & 0x0F);
+ data = (data & 0x0f);
awp_draw_reel(machine(),"reel5", *m_reel[4]);
break;
#endif
@@ -381,21 +390,21 @@ void mpu4_state::update_meters()
break;
case FLUTTERBOX: //The backbox fan assembly fits in a reel unit sized box, wired to the remote meter pin, so we can handle it here
- output().set_value("flutterbox", data & 0x80);
+ m_flutterbox = BIT(data, 7);
data &= ~0x80; //Strip flutterbox data from meter drives
break;
}
- m_meters->update(7, (data & 0x80));
+ m_meters->update(7, data & 0x80);
- for (meter = 0; meter < 4; meter ++)
+ for (int meter = 0; meter < 4; meter++)
{
m_meters->update(meter, (data & (1 << meter)));
}
if (m_reel_mux == STANDARD_REEL)
{
- for (meter = 4; meter < 7; meter ++)
+ for (int meter = 4; meter < 7; meter++)
{
m_meters->update(meter, (data & (1 << meter)));
}
@@ -403,7 +412,7 @@ void mpu4_state::update_meters()
}
/* called if board is reset */
-MACHINE_RESET_MEMBER(mpu4_state,mpu4)
+MACHINE_RESET_MEMBER(mpu4_state, mpu4)
{
m_vfd->reset();
@@ -431,10 +440,10 @@ MACHINE_RESET_MEMBER(mpu4_state,mpu4)
/* 6809 IRQ handler */
-WRITE_LINE_MEMBER(mpu4_state::cpu0_irq)
+void mpu4_state::cpu0_irq(int state)
{
/* The PIA and PTM IRQ lines are all connected to a common PCB track, leading directly to the 6809 IRQ line. */
- int combined_state = m_pia3->irq_a_state() | m_pia3->irq_b_state() |
+ uint8_t combined_state = m_pia3->irq_a_state() | m_pia3->irq_b_state() |
m_pia4->irq_a_state() | m_pia4->irq_b_state() |
m_pia5->irq_a_state() | m_pia5->irq_b_state() |
m_pia6->irq_a_state() | m_pia6->irq_b_state() |
@@ -442,15 +451,23 @@ WRITE_LINE_MEMBER(mpu4_state::cpu0_irq)
m_pia8->irq_a_state() | m_pia8->irq_b_state() |
m_6840ptm->irq_state();
- if (!m_link7a_connected) //7B = IRQ, 7A = FIRQ, both = NMI
+ if (m_link7b_connected) //7B = IRQ, 7A = FIRQ, both = NMI
{
- m_maincpu->set_input_line(M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
- LOG(("6809 int%d \n", combined_state));
+ if (!m_link7a_connected)
+ {
+ m_maincpu->set_input_line(M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
+ LOG("6809 IRQ %d \n", combined_state);
+ }
+ else
+ {
+ m_maincpu->set_input_line(INPUT_LINE_NMI, combined_state ? ASSERT_LINE : CLEAR_LINE);
+ LOG("6809 NMI %d \n", combined_state);
+ }
}
else
{
m_maincpu->set_input_line(M6809_FIRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
- LOG(("6809 fint%d \n", combined_state));
+ LOG("6809 FIRQ %d \n", combined_state);
}
}
@@ -479,15 +496,13 @@ uint8_t mpu4_state::bankswitch_r()
void mpu4_state::bankset_w(uint8_t data)
{
- //logerror("bankset_w %02x\n", data);
-
m_pageval = (data - 2);//writes 2 and 3, to represent 0 and 1 - a hangover from the half page design?
m_bank1->set_entry((m_pageval + (m_pageset ? 4 : 0)) & m_numbanks);
}
/* IC2 6840 PTM handler */
-WRITE_LINE_MEMBER(mpu4_state::ic2_o1_callback)
+void mpu4_state::ic2_o1_callback(int state)
{
m_6840ptm->set_c2(state); /* copy output value to IC2 c2
this output is the clock for timer2 */
@@ -495,7 +510,7 @@ WRITE_LINE_MEMBER(mpu4_state::ic2_o1_callback)
}
-WRITE_LINE_MEMBER(mpu4_state::ic2_o2_callback)
+void mpu4_state::ic2_o2_callback(int state)
{
m_pia3->ca1_w(state); /* copy output value to IC3 ca1 */
/* the output from timer2 is the input clock for timer3 */
@@ -504,11 +519,12 @@ WRITE_LINE_MEMBER(mpu4_state::ic2_o2_callback)
}
-WRITE_LINE_MEMBER(mpu4_state::ic2_o3_callback)
+void mpu4_state::ic2_o3_callback(int state)
{
/* the output from timer3 is used as a square wave for the alarm output
and as an external clock source for timer 1! */
/* also runs lamp fade */
+ m_alarmdac->write(state);
m_6840ptm->set_c1(state);
}
@@ -516,8 +532,7 @@ WRITE_LINE_MEMBER(mpu4_state::ic2_o3_callback)
/* IC3, lamp data lines + alpha numeric display */
void mpu4_state::pia_ic3_porta_w(uint8_t data)
{
- int i;
- LOG_IC3(("%s: IC3 PIA Port A Set to %2x (lamp strobes 1 - 9)\n", machine().describe_context(),data));
+ LOGMASKED(LOG_IC3, "%s: IC3 PIA Port A Set to %2x (lamp strobes 1 - 9)\n", machine().describe_context(), data);
if(m_ic23_active)
{
@@ -527,19 +542,13 @@ void mpu4_state::pia_ic3_porta_w(uint8_t data)
// As a consequence, the lamp column data can change before the input strobe without
// causing the relevant lamps to black out.
- if (m_overcurrent_detect)
- {
- m_overcurrent = true;
- }
+ if (m_overcurrent_detect) m_overcurrent = true;
- if (m_undercurrent_detect)
- {
- m_undercurrent = true;
- }
+ if (m_undercurrent_detect) m_undercurrent = true;
- for (i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
{
- m_lamps[(8*m_input_strobe)+i] = BIT(data, i);
+ m_lamps[(8*m_input_strobe) + i] = BIT(data, i);
}
m_lamp_strobe = m_input_strobe;
}
@@ -548,26 +557,19 @@ void mpu4_state::pia_ic3_porta_w(uint8_t data)
void mpu4_state::pia_ic3_portb_w(uint8_t data)
{
- int i;
- LOG_IC3(("%s: IC3 PIA Port B Set to %2x (lamp strobes 10 - 17)\n", machine().describe_context(),data));
+ LOGMASKED(LOG_IC3, "%s: IC3 PIA Port B Set to %2x (lamp strobes 10 - 17)\n", machine().describe_context(), data);
- if(m_ic23_active)
+ if (m_ic23_active)
{
if (m_lamp_strobe2 != m_input_strobe)
{
- if (m_overcurrent_detect)
- {
- m_overcurrent = true;
- }
+ if (m_overcurrent_detect) m_overcurrent = true;
- if (m_undercurrent_detect)
- {
- m_undercurrent = true;
- }
+ if (m_undercurrent_detect) m_undercurrent = true;
- for (i = 0; i < 8; i++)
+ for (int i = 0; i < 8; i++)
{
- m_lamps[(8*m_input_strobe)+i+64] = BIT(data, i);
+ m_lamps[(8*m_input_strobe) + i + 64] = BIT(data, i);
}
m_lamp_strobe2 = m_input_strobe;
}
@@ -575,16 +577,16 @@ void mpu4_state::pia_ic3_portb_w(uint8_t data)
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic3_ca2_w)
+void mpu4_state::pia_ic3_ca2_w(int state)
{
- LOG_IC3(("%s: IC3 PIA Write CA2 (alpha data), %02X\n", machine().describe_context(),state));
+ LOGMASKED(LOG_IC3, "%s: IC3 PIA Write CA2 (alpha data), %02X\n", machine().describe_context(), state);
m_vfd->data(state);
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic3_cb2_w)
+void mpu4_state::pia_ic3_cb2_w(int state)
{
- LOG_IC3(("%s: IC3 PIA Write CB (alpha reset), %02X\n",machine().describe_context(),state));
+ LOGMASKED(LOG_IC3, "%s: IC3 PIA Write CB (alpha reset), %02X\n", machine().describe_context(), state);
// DM Data pin A
m_vfd->por(state);
}
@@ -605,19 +607,18 @@ void mpu4_state::ic23_update()
{
if (m_IC23G1)
{
- if ( m_IC23GA ) m_input_strobe |= 0x01;
- else m_input_strobe &= ~0x01;
+ if (m_IC23GA) m_input_strobe |= 0x01;
+ else m_input_strobe &= ~0x01;
- if ( m_IC23GB ) m_input_strobe |= 0x02;
- else m_input_strobe &= ~0x02;
+ if (m_IC23GB) m_input_strobe |= 0x02;
+ else m_input_strobe &= ~0x02;
- if ( m_IC23GC ) m_input_strobe |= 0x04;
- else m_input_strobe &= ~0x04;
+ if (m_IC23GC) m_input_strobe |= 0x04;
+ else m_input_strobe &= ~0x04;
}
}
}
- else
- if ((m_IC23G2A)||(m_IC23G2B))
+ else if (m_IC23G2A || m_IC23G2B)
{
m_input_strobe = 0x00;
}
@@ -632,7 +633,7 @@ IC24 is a 74LS122 pulse generator
CLEAR and B2 are tied high and A1 and A2 tied low, meaning any pulse
on B1 will give a low pulse on the output pin.
*/
-void mpu4_state::ic24_output(int data)
+void mpu4_state::ic24_output(uint8_t data)
{
m_IC23G2A = data;
ic23_update();
@@ -644,11 +645,9 @@ void mpu4_state::ic24_setup()
if (m_IC23GA)
{
double duration = TIME_OF_74LS123((220*1000),(0.1*0.000001));
- {
- m_ic23_active=true;
- ic24_output(0);
- m_ic24_timer->adjust(attotime::from_double(duration));
- }
+ m_ic23_active = true;
+ ic24_output(0);
+ m_ic24_timer->adjust(attotime::from_double(duration));
}
}
@@ -660,10 +659,11 @@ TIMER_CALLBACK_MEMBER(mpu4_state::update_ic24)
}
-WRITE_LINE_MEMBER(mpu4_state::dataport_rxd)
+void mpu4_state::dataport_rxd(int state)
{
m_pia4->cb1_w(state);
- LOG_IC3(("Dataport RX %x\n",state));
+ m_serial_output = state;
+ LOGMASKED(LOG_IC3, "Dataport RX %x\n", state);
}
/* IC4, 7 seg leds, 50Hz timer reel sensors, current sensors */
@@ -673,9 +673,9 @@ void mpu4_state::pia_ic4_porta_w(uint8_t data)
{
if (m_use_pia4_porta_leds)
{
- if(m_pia4_porta_leds_strobe != m_input_strobe)
+ if (m_pia4_porta_leds_strobe != m_input_strobe)
{
- for(int i=0; i<8; i++)
+ for (int i=0; i<8; i++)
{
m_mpu4leds[(((7 - m_input_strobe) | m_pia4_porta_leds_base) << 3) | i] = BIT(data, i);
}
@@ -708,52 +708,48 @@ uint8_t mpu4_state::pia_ic4_portb_r()
{
m_ic4_input_b = 0x00;
- if (m_pia5->ca2_output())
- {
- m_ic4_input_b |= 0x80;
- }
+ if (m_serial_output) m_ic4_input_b |= 0x80;
if (!m_reel_mux)
{
- if ( m_optic_pattern & 0x01 ) m_ic4_input_b |= 0x40; /* reel A tab */
+ if (m_optic_pattern & 0x01) m_ic4_input_b |= 0x40; /* reel A tab */
- if ( m_optic_pattern & 0x02 ) m_ic4_input_b |= 0x20; /* reel B tab */
+ if (m_optic_pattern & 0x02) m_ic4_input_b |= 0x20; /* reel B tab */
- if ( m_optic_pattern & 0x04 ) m_ic4_input_b |= 0x10; /* reel C tab */
+ if (m_optic_pattern & 0x04) m_ic4_input_b |= 0x10; /* reel C tab */
- if ( m_optic_pattern & 0x08 ) m_ic4_input_b |= 0x08; /* reel D tab */
+ if (m_optic_pattern & 0x08) m_ic4_input_b |= 0x08; /* reel D tab */
}
else
{
if (m_optic_pattern & (1<<m_active_reel)) m_ic4_input_b |= 0x08;
}
- if ( m_overcurrent )
+ if (m_low_volt_detect)
{
- m_ic4_input_b |= 0x02;
+ if (m_signal_50hz) m_ic4_input_b |= 0x04;
}
- if ( m_undercurrent )
- {
- m_ic4_input_b |= 0x01;
- }
+ if (m_overcurrent) m_ic4_input_b |= 0x02;
- LOG_IC3(("%s: IC4 PIA Read of Port B %x\n",machine().describe_context(),m_ic4_input_b));
+ if (m_undercurrent) m_ic4_input_b |= 0x01;
+
+ LOGMASKED(LOG_IC3, "%s: IC4 PIA Read of Port B %x\n", machine().describe_context(), m_ic4_input_b);
return m_ic4_input_b;
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic4_ca2_w)
+void mpu4_state::pia_ic4_ca2_w(int state)
{
- LOG_IC3(("%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", machine().describe_context(),state));
+ LOGMASKED(LOG_IC3, "%s: IC4 PIA Write CA (input MUX strobe /LED B), %02X\n", machine().describe_context(), state);
m_IC23GB = state;
ic23_update();
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic4_cb2_w)
+void mpu4_state::pia_ic4_cb2_w(int state)
{
- LOG_IC3(("%s: IC4 PIA Write CB (Reel optic flag), %02X\n", machine().describe_context(),state));
+ LOGMASKED(LOG_IC3, "%s: IC4 PIA Write CB (Reel optic flag), %02X\n", machine().describe_context(), state);
m_reel_flag=state;
}
@@ -806,7 +802,7 @@ uint8_t mpu4_state::pia_ic5_porta_r()
}
}
- LOG(("%s: IC5 PIA Read of Port A (AUX1)\n",machine().describe_context()));
+ LOG("%s: IC5 PIA Read of Port A (AUX1)\n", machine().describe_context());
uint8_t tempinput = m_aux1_port->read() | m_aux1_input;
@@ -816,7 +812,6 @@ uint8_t mpu4_state::pia_ic5_porta_r()
void mpu4_state::pia_ic5_porta_w(uint8_t data)
{
- int i;
if (m_hopper_type == HOPPER_NONDUART_A)
{
m_hopper1_opto = (data & 0x10);
@@ -827,15 +822,14 @@ void mpu4_state::pia_ic5_porta_w(uint8_t data)
case NO_EXTENDER:
if (m_led_extender == CARD_B)
{
- led_write_extender(data & 0x1f, m_pia4->a_output(),m_input_strobe);
+ led_write_extender(data & 0x1f, m_pia4->a_output(), m_input_strobe);
}
else if ((m_led_extender != CARD_A) && (m_led_extender != NO_EXTENDER))
{
- for(i=0; i<8; i++)
+ for (int i = 0; i < 8; i++)
{
m_mpu4leds[((m_input_strobe | 8) << 3) | i] = BIT(data, i);
}
- // m_digits[m_input_strobe | 8] = data;
}
break;
@@ -847,15 +841,15 @@ void mpu4_state::pia_ic5_porta_w(uint8_t data)
break;
case LARGE_CARD_A:
- lamp_extend_large(data,m_input_strobe,m_ic23_active);
+ lamp_extend_large(data, m_input_strobe, m_ic23_active);
break;
case LARGE_CARD_B:
- lamp_extend_large(data,m_input_strobe,m_ic23_active);
+ lamp_extend_large(data, m_input_strobe, m_ic23_active);
#if 0
if ((m_ic23_active) && m_card_live)
{
- for(i=0; i<8; i++)
+ for (int i = 0; i < 8; i++)
{
m_mpu4leds[(m_last_b7 << 6) | (m_input_strobe << 3) | i] = BIT(~data, i);
}
@@ -865,22 +859,22 @@ void mpu4_state::pia_ic5_porta_w(uint8_t data)
break;
case LARGE_CARD_C:
- lamp_extend_large(data,m_input_strobe,m_ic23_active);
+ lamp_extend_large(data, m_input_strobe, m_ic23_active);
break;
}
if (m_reel_mux == SIX_REEL_5TO8)
{
- m_reel[4]->update( data &0x0F);
- m_reel[5]->update((data >> 4)&0x0F);
+ m_reel[4]->update( data &0x0f);
+ m_reel[5]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel5", *m_reel[4]);
awp_draw_reel(machine(),"reel6", *m_reel[5]);
}
else if (m_reel_mux == SEVEN_REEL)
{
- m_reel[1]->update( data &0x0F);
- m_reel[2]->update((data >> 4)&0x0F);
+ m_reel[1]->update( data &0x0f);
+ m_reel[2]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel2", *m_reel[1]);
awp_draw_reel(machine(),"reel3", *m_reel[2]);
}
@@ -896,7 +890,7 @@ void mpu4_state::pia_ic5_portb_w(uint8_t data)
}
if (m_led_extender == CARD_A)
{
- led_write_extender(data & 0x07, m_pia4->a_output(),m_input_strobe);
+ led_write_extender(data & 0x07, m_pia4->a_output(), m_input_strobe);
}
if (m_use_simplecard_leds)
@@ -927,7 +921,7 @@ uint8_t mpu4_state::pia_ic5_portb_r()
}
}
- LOG(("%s: IC5 PIA Read of Port B (coin input AUX2)\n",machine().describe_context()));
+ LOG("%s: IC5 PIA Read of Port B (coin input AUX2)\n", machine().describe_context());
if (m_use_coinlocks)
{
// why are these being set in a read, not when the outputs are written?
@@ -953,8 +947,11 @@ If this sounds familiar, Amstrad did something very similar with their home comp
The PSG function, defined by the BC1,BC2 and BDIR signals, is controlled by CA2 and CB2 of IC6.
+The chipselect for the AY chip itself, however, is CB2 on IC5, so unless this goes live, things are likely to fail
+
PSG function selection:
-----------------------
+CSEL = IC5 CB2
BDIR = IC6 CB2 and BC1 = IC6 CA2
Pin | PSG Function
@@ -966,12 +963,11 @@ BDIR BC1 |
*/
/* PSG function selected */
-void mpu4_state::update_ay(device_t *device)
+void mpu4_state::update_ay()
{
if (!m_ay8913) return;
- pia6821_device *pia = downcast<pia6821_device *>(device);
- if (!pia->cb2_output())
+ if (!m_pia5->cb2_output())
{
switch (m_ay8913_address)
{
@@ -981,52 +977,52 @@ void mpu4_state::update_ay(device_t *device)
case 0x01:
/* CA2 = 1 CB2 = 0? : Read from selected PSG register and make the register data available to Port A */
- LOG(("AY8913 address = %d \n",m_pia6->a_output()&0x0f));
+ LOG("AY8913 address = %d \n", m_pia6->a_output()&0x0f);
break;
case 0x02:
/* CA2 = 0 CB2 = 1? : Write to selected PSG register and write data to Port A */
m_ay8913->data_w(m_pia6->a_output());
- LOG(("AY Chip Write \n"));
+ LOG("AY Chip Write \n");
break;
case 0x03:
/* CA2 = 1 CB2 = 1? : The register will now be selected and the user can read from or write to it.
The register will remain selected until another is chosen.*/
m_ay8913->address_w(m_pia6->a_output());
- LOG(("AY Chip Select \n"));
+ LOG("AY Chip Select \n");
break;
default:
- LOG(("AY Chip error \n"));
+ LOG("AY Chip error \n");
break;
}
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic5_cb2_w)
+void mpu4_state::pia_ic5_cb2_w(int state)
{
- update_ay(m_pia5);
+ update_ay();
}
/* IC6, Reel A and B and AY registers (MODs below 4 only) */
void mpu4_state::pia_ic6_portb_w(uint8_t data)
{
- LOG(("%s: IC6 PIA Port B Set to %2x (Reel A and B)\n", machine().describe_context(),data));
+ LOG("%s: IC6 PIA Port B Set to %2x (Reel A and B)\n", machine().describe_context(), data);
if (m_reel_mux == SEVEN_REEL)
{
- m_reel[3]->update( data &0x0F);
- m_reel[4]->update((data >> 4)&0x0F);
+ m_reel[3]->update( data &0x0f);
+ m_reel[4]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel4", *m_reel[3]);
awp_draw_reel(machine(),"reel5", *m_reel[4]);
}
else if (m_reels)
{
- m_reel[0]->update( data &0x0F);
- m_reel[1]->update((data >> 4)&0x0F);
+ m_reel[0]->update( data &0x0f);
+ m_reel[1]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel1", *m_reel[0]);
awp_draw_reel(machine(),"reel2", *m_reel[1]);
}
@@ -1035,35 +1031,35 @@ void mpu4_state::pia_ic6_portb_w(uint8_t data)
void mpu4_state::pia_ic6_porta_w(uint8_t data)
{
- LOG(("%s: IC6 PIA Write A %2x\n", machine().describe_context(),data));
+ LOG("%s: IC6 PIA Write A %2x\n", machine().describe_context(), data);
if (m_ay8913.found())
{
m_ay_data = data;
- update_ay(m_pia6);
+ update_ay();
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic6_ca2_w)
+void mpu4_state::pia_ic6_ca2_w(int state)
{
- LOG(("%s: IC6 PIA write CA2 %2x (AY8913 BC1)\n", machine().describe_context(),state));
+ LOG("%s: IC6 PIA write CA2 %2x (AY8913 BC1)\n", machine().describe_context(), state);
if (m_ay8913.found())
{
if ( state ) m_ay8913_address |= 0x01;
else m_ay8913_address &= ~0x01;
- update_ay(m_pia6);
+ update_ay();
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic6_cb2_w)
+void mpu4_state::pia_ic6_cb2_w(int state)
{
- LOG(("%s: IC6 PIA write CB2 %2x (AY8913 BCDIR)\n", machine().describe_context(),state));
+ LOG("%s: IC6 PIA write CB2 %2x (AY8913 BCDIR)\n", machine().describe_context(), state);
if (m_ay8913.found())
{
if ( state ) m_ay8913_address |= 0x02;
else m_ay8913_address &= ~0x02;
- update_ay(m_pia5); // using m_pia5 here allows m4fourmr to have sound
+ update_ay(); // using m_pia5 here allows m4fourmr to have sound
}
}
@@ -1071,18 +1067,18 @@ WRITE_LINE_MEMBER(mpu4_state::pia_ic6_cb2_w)
/* IC7 Reel C and D, mechanical meters/Reel E and F, input strobe bit A */
void mpu4_state::pia_ic7_porta_w(uint8_t data)
{
- LOG(("%s: IC7 PIA Port A Set to %2x (Reel C and D)\n", machine().describe_context(),data));
+ LOG("%s: IC7 PIA Port A Set to %2x (Reel C and D)\n", machine().describe_context(), data);
if (m_reel_mux == SEVEN_REEL)
{
- m_reel[5]->update( data &0x0F);
- m_reel[6]->update((data >> 4)&0x0F);
+ m_reel[5]->update( data &0x0f);
+ m_reel[6]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel6", *m_reel[5]);
awp_draw_reel(machine(),"reel7", *m_reel[6]);
}
else if (m_reels)
{
- m_reel[2]->update( data &0x0F);
- m_reel[3]->update((data >> 4)&0x0F);
+ m_reel[2]->update( data &0x0f);
+ m_reel[3]->update((data >> 4)&0x0f);
awp_draw_reel(machine(),"reel3", *m_reel[2]);
awp_draw_reel(machine(),"reel4", *m_reel[3]);
}
@@ -1110,19 +1106,19 @@ void mpu4_state::pia_ic7_portb_w(uint8_t data)
uint8_t mpu4_state::pia_ic7_portb_r()
{
-/* The meters are connected to a voltage drop sensor, where current
-flowing through them also passes through pin B7, meaning that when
-any meter is activated, pin B7 goes high.
-As for why they connected this to an output port rather than using
-CB1, no idea, although it proved of benefit when the reel multiplexer was designed
-as it allows a separate meter to be used when the rest of the port is blocked.
-This appears to have confounded the schematic drawer, who has assumed that
-all eight meters are driven from this port, giving the 8 line driver chip
-9 connections in total. */
+ /* The meters are connected to a voltage drop sensor, where current
+ flowing through them also passes through pin B7, meaning that when
+ any meter is activated, pin B7 goes high.
+ As for why they connected this to an output port rather than using
+ CB1, no idea, although it proved of benefit when the reel multiplexer was designed
+ as it allows a separate meter to be used when the rest of the port is blocked.
+ This appears to have confounded the schematic drawer, who has assumed that
+ all eight meters are driven from this port, giving the 8 line driver chip
+ 9 connections in total. */
- //This may be overkill, but the meter sensing is VERY picky
+ //This may be overkill, but the meter sensing is VERY picky.
- int combined_meter = m_meters->get_activity(0) | m_meters->get_activity(1) |
+ uint8_t combined_meter = m_meters->get_activity(0) | m_meters->get_activity(1) |
m_meters->get_activity(2) | m_meters->get_activity(3) |
m_meters->get_activity(4) | m_meters->get_activity(5) |
m_meters->get_activity(6) | m_meters->get_activity(7);
@@ -1137,16 +1133,16 @@ all eight meters are driven from this port, giving the 8 line driver chip
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic7_ca2_w)
+void mpu4_state::pia_ic7_ca2_w(int state)
{
- LOG(("%s: IC7 PIA write CA2 %2x (input strobe bit 0 / LED A)\n", machine().describe_context(),state));
+ LOG("%s: IC7 PIA write CA2 %2x (input strobe bit 0 / LED A)\n", machine().describe_context(), state);
m_IC23GA = state;
ic24_setup();
ic23_update();
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic7_cb2_w)
+void mpu4_state::pia_ic7_cb2_w(int state)
{
m_remote_meter = state?0x80:0x00;
}
@@ -1155,7 +1151,7 @@ WRITE_LINE_MEMBER(mpu4_state::pia_ic7_cb2_w)
/* IC8, Inputs, TRIACS, alpha clock */
uint8_t mpu4_state::pia_ic8_porta_r()
{
- LOG_IC8(("%s: IC8 PIA Read of Port A (MUX input data)\n", machine().describe_context()));
+ LOGMASKED(LOG_IC8, "%s: IC8 PIA Read of Port A (MUX input data)\n", machine().describe_context());
/* The orange inputs are polled twice as often as the black ones, for reasons of efficiency.
This is achieved via connecting every input line to an AND gate, thus allowing two strobes
to represent each orange input bank (strobes are active low). */
@@ -1182,95 +1178,32 @@ void mpu4_state::pia_ic8_portb_w(uint8_t data)
m_hopper2_opto = (data & 0x04);
data &= ~0x07; //remove Triacs from use
}
- LOG_IC8(("%s: IC8 PIA Port B Set to %2x (OUTPUT PORT, TRIACS)\n", machine().describe_context(),data));
- for (int i = 0; i < 8; i++)
+ LOGMASKED(LOG_IC8, "%s: IC8 PIA Port B Set to %2x (OUTPUT PORT, TRIACS)\n", machine().describe_context(), data);
+ for (uint8_t i = 0; i < 8; i++)
{
m_triacs[i] = BIT(data, i);
}
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic8_ca2_w)
+void mpu4_state::pia_ic8_ca2_w(int state)
{
- LOG_IC8(("%s: IC8 PIA write CA2 (input_strobe bit 2 / LED C) %02X\n", machine().describe_context(), state & 0xFF));
+ LOGMASKED(LOG_IC8, "%s: IC8 PIA write CA2 (input_strobe bit 2 / LED C) %02X\n", machine().describe_context(), state & 0xff);
m_IC23GC = state;
ic23_update();
}
-WRITE_LINE_MEMBER(mpu4_state::pia_ic8_cb2_w)
+void mpu4_state::pia_ic8_cb2_w(int state)
{
- LOG_IC8(("%s: IC8 PIA write CB2 (alpha clock) %02X\n", machine().describe_context(), state & 0xFF));
+ LOGMASKED(LOG_IC8, "%s: IC8 PIA write CB2 (alpha clock) %02X\n", machine().describe_context(), state & 0xff);
// DM Data pin B
m_vfd->sclk(!state);
}
-// universal sampled sound program card PCB 683077
-// Sampled sound card, using a PIA and PTM for timing and data handling
-void mpu4_state::pia_gb_porta_w(uint8_t data)
-{
- LOG_SS(("%s: GAMEBOARD: PIA Port A Set to %2x\n", machine().describe_context(),data));
- m_msm6376->write(data);
-}
-
-void mpu4_state::pia_gb_portb_w(uint8_t data)
-{
- int changed = m_expansion_latch^data;
-
- LOG_SS(("%s: GAMEBOARD: PIA Port B Set to %2x\n", machine().describe_context(),data));
-
- if ( changed & 0x20)
- { // digital volume clock line changed
- if ( !(data & 0x20) )
- { // changed from high to low,
- if ( !(data & 0x10) )//down
- {
- if ( m_global_volume < 32 ) m_global_volume++; //steps unknown
- }
- else
- {//up
- if ( m_global_volume > 0 ) m_global_volume--;
- }
-
- {
- LOG_SS(("%s: GAMEBOARD: Volume Set to %2x\n", machine().describe_context(),data));
- float percent = (32-m_global_volume)/32.0;
- m_msm6376->set_output_gain(0, percent);
- m_msm6376->set_output_gain(1, percent);
- }
- }
- }
- m_msm6376->ch2_w(data&0x02);
- m_msm6376->st_w(data&0x01);
-}
-uint8_t mpu4_state::pia_gb_portb_r()
-{
- LOG_SS(("%s: GAMEBOARD: PIA Read of Port B\n",machine().describe_context()));
- int data=0;
- // b7 NAR - we can load another address into Channel 1
- // b6, 1 = OKI ready, 0 = OKI busy
- // b5, vol clock
- // b4, 1 = Vol down, 0 = Vol up
- //
-
- if ( m_msm6376->nar_r() ) data |= 0x80;
- else data &= ~0x80;
-
- if ( m_msm6376->busy_r() ) data |= 0x40;
- else data &= ~0x40;
-
- return ( data | m_expansion_latch );
-}
-
-WRITE_LINE_MEMBER(mpu4_state::pia_gb_ca2_w)
-{
- LOG_SS(("%s: GAMEBOARD: OKI RESET data = %02X\n", machine().describe_context(), state));
-// reset line
-}
-
-WRITE_LINE_MEMBER(mpu4_state::pia_gb_cb2_w)
+void mpu4_state::pia_gb_cb2_w(int state)
{
// Some BWB games use this to drive the bankswitching
// should the regular bankswitch still work in these cases?
@@ -1281,53 +1214,6 @@ WRITE_LINE_MEMBER(mpu4_state::pia_gb_cb2_w)
}
}
-//Sampled sound timer
-/*
-The MSM6376 sound chip is configured in a slightly strange way, to enable dynamic
-sample rate changes (8Khz, 10.6 Khz, 16 KHz) by varying the clock.
-According to the BwB programmer's guide, the formula is:
-MSM6376 clock frequency:-
-freq = (1720000/((t3L+1)(t3H+1)))*[(t3H(T3L+1)+1)/(2(t1+1))]
-where [] means rounded up integer,
-t3L is the LSB of Clock 3,
-t3H is the MSB of Clock 3,
-and t1 is the initial value in clock 1.
-*/
-
-//O3 -> G1 O1 -> c2 o2 -> c1
-
-/* This is a bit of a cheat - since we don't clock into the OKI chip directly, we need to
-calculate the oscillation frequency in advance. We're running the timer for interrupt
-purposes, but the frequency calculation is done by plucking the values out as they are written.*/
-void mpu4_state::ic3ss_w(offs_t offset, uint8_t data)
-{
- m_ptm_ic3ss->write(offset,data);
-
- if (offset == 3)
- {
- m_t1 = data;
- }
- if (offset == 6)
- {
- m_t3h = data;
- }
- if (offset == 7)
- {
- m_t3l = data;
- }
-
- float num = (1720000/((m_t3l + 1)*(m_t3h + 1)));
- float denom1 = ((m_t3h *(m_t3l + 1)+ 1)/(2*(m_t1 + 1)));
-
- int denom2 = denom1 + 0.5f;//need to round up, this gives same precision as chip
- int freq=num*denom2;
-
- if (freq)
- {
- m_msm6376->set_unscaled_clock(freq);
- }
-}
-
/* input ports for MPU4 board */
INPUT_PORTS_START( mpu4 )
PORT_START("ORANGE1")
@@ -1975,16 +1861,15 @@ INPUT_PORTS_START( grtecp )
INPUT_PORTS_END
-
/* Common configurations */
void mpu4_state::mpu4_install_mod4oki_space(address_space &space)
{
- pia6821_device *const pia_ic4ss = subdevice<pia6821_device>("pia_ic4ss");
+ space.install_readwrite_handler(0x0880, 0x0883, read8sm_delegate(*m_okicard, FUNC(mpu4_oki_sampled_sound::ic4_read)), write8sm_delegate(*m_okicard, FUNC(mpu4_oki_sampled_sound::ic4_write)));
+
+ space.install_read_handler(0x08c0, 0x08c7, read8sm_delegate(*m_okicard, FUNC(mpu4_oki_sampled_sound::ic3_read)));
+ space.install_write_handler(0x08c0, 0x08c7, write8sm_delegate(*m_okicard, FUNC(mpu4_oki_sampled_sound::ic3_write)));
- space.install_readwrite_handler(0x0880, 0x0883, read8sm_delegate(*pia_ic4ss, FUNC(pia6821_device::read)), write8sm_delegate(*pia_ic4ss, FUNC(pia6821_device::write)));
- space.install_read_handler(0x08c0, 0x08c7, read8sm_delegate(*m_ptm_ic3ss, FUNC(ptm6840_device::read)));
- space.install_write_handler(0x08c0, 0x08c7, write8sm_delegate(*this, FUNC(mpu4_state::ic3ss_w)));
}
@@ -1995,30 +1880,106 @@ void mpu4_state::mpu4_config_common()
m_mpu4leds.resolve();
m_digits.resolve();
m_triacs.resolve();
+ m_flutterbox.resolve();
m_ic24_timer = timer_alloc(FUNC(mpu4_state::update_ic24), this);
+
+
+ save_item(NAME( m_mmtr_data ));
+ save_item(NAME( m_ay8913_address ));
+ save_item(NAME( m_signal_50hz ));
+ save_item(NAME( m_ic4_input_b ));
+ save_item(NAME( m_aux1_input ));
+ save_item(NAME( m_aux2_input ));
+ save_item(NAME( m_IC23G1 ));
+ save_item(NAME( m_IC23G2A ));
+ save_item(NAME( m_IC23G2B ));
+ save_item(NAME( m_IC23GC ));
+ save_item(NAME( m_IC23GB ));
+ save_item(NAME( m_IC23GA ));
+
+ save_item(NAME( m_reel_flag ));
+ save_item(NAME( m_ic23_active ));
+ save_item(NAME( m_input_strobe ));
+ save_item(NAME( m_lamp_strobe ));
+ save_item(NAME( m_lamp_strobe2 ));
+ save_item(NAME( m_lamp_strobe_ext_persistence ));
+ save_item(NAME( m_led_strobe ));
+ save_item(NAME( m_ay_data ));
+ save_item(NAME( m_optic_pattern ));
+
+ save_item(NAME( m_active_reel ));
+ save_item(NAME( m_remote_meter ));
+ save_item(NAME( m_reel_mux ));
+ save_item(NAME( m_lamp_extender ));
+ save_item(NAME( m_last_b7 ));
+ save_item(NAME( m_last_latch ));
+ save_item(NAME( m_lamp_sense ));
+ save_item(NAME( m_card_live ));
+ save_item(NAME( m_led_extender ));
+ save_item(NAME( m_bwb_bank ));
+ save_item(NAME( m_default_to_low_bank ));
+
+ save_item(NAME( m_use_pia4_porta_leds ));
+ save_item(NAME( m_pia4_porta_leds_base ));
+ save_item(NAME( m_pia4_porta_leds_strobe ));
+
+ save_item(NAME( m_use_simplecard_leds ));
+ save_item(NAME( m_simplecard_leds_base ));
+ save_item(NAME( m_simplecard_leds_strobe ));
+
+ save_item(NAME( m_pageval ));
+ save_item(NAME( m_pageset ));
+ save_item(NAME( m_hopper_type ));
+ save_item(NAME( m_reels ));
+ save_item(NAME( m_chrdata ));
+ save_item(NAME( m_serial_output ));
+
+ save_item(NAME( m_numbanks ));
+
+ save_item(NAME( m_link7a_connected ));
+ save_item(NAME( m_link7b_connected ));
+
+ save_item(NAME( m_overcurrent ));
+ save_item(NAME( m_undercurrent ));
+
+ save_item(NAME( m_overcurrent_detect ));
+ save_item(NAME( m_undercurrent_detect ));
+
+ save_item(NAME( m_low_volt_detect ));
+
+ save_item(NAME( m_use_coinlocks ));
+
+ save_item(NAME( m_hack_duart_fixed_low ));
+
+ save_item(NAME( m_hopper1_opto ));
+ save_item(NAME( m_hopper2_opto ));
+
m_lamp_strobe_ext_persistence = 0;
+
}
-MACHINE_START_MEMBER(mpu4_state,mod2)
+MACHINE_START_MEMBER(mpu4_state, mod2)
{
mpu4_config_common();
m_link7a_connected=false;
+ m_link7b_connected=true;
}
-MACHINE_START_MEMBER(mpu4_state,mpu4oki)
+MACHINE_START_MEMBER(mpu4_state, mpu4oki)
{
address_space &space = m_maincpu->space(AS_PROGRAM);
mpu4_config_common();
m_link7a_connected=false;
+ m_link7b_connected=true;
mpu4_install_mod4oki_space(space);
}
void mpu4_state::init_m4()
{
- m_bwb_bank = 0;
+ m_bwb_bank = false;
setup_rom_banks();
}
@@ -2032,7 +1993,7 @@ void mpu4_state::init_m4big()
address_space &space = m_maincpu->space(AS_PROGRAM);
- m_bwb_bank = 1;
+ m_bwb_bank = true;
space.install_write_handler(0x0858, 0x0858, write8smo_delegate(*this, FUNC(mpu4_state::bankswitch_w)));
space.install_write_handler(0x0878, 0x0878, write8smo_delegate(*this, FUNC(mpu4_state::bankset_w)));
uint8_t *rom = memregion("maincpu")->base();
@@ -2083,7 +2044,6 @@ void mpu4_state::mpu4_memmap(address_map &map)
// map(0x0800, 0x081f) // optional protection device lives here, see other maps
map(0x0850, 0x0850).rw(FUNC(mpu4_state::bankswitch_r), FUNC(mpu4_state::bankswitch_w)); /* write bank (rom page select) */
map(0x08e0, 0x08ef).rw(m_duart68681, FUNC(mc68681_device::read), FUNC(mc68681_device::write)); //Runs hoppers
- map(0x08ed, 0x08ed).r(FUNC(mpu4_state::hack_duart_r)); // hack until the hopper is hooked up to the duart in games wanting that setup (eg m4ready)
map(0x0900, 0x0907).rw(m_6840ptm, FUNC(ptm6840_device::read), FUNC(ptm6840_device::write));/* PTM6840 IC2 */
map(0x0a00, 0x0a03).rw(m_pia3, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* PIA6821 IC3 */
map(0x0b00, 0x0b03).rw(m_pia4, FUNC(pia6821_device::read), FUNC(pia6821_device::write)); /* PIA6821 IC4 */
@@ -2238,16 +2198,20 @@ void mpu4_state::tr_ht(machine_config &config)
void mpu4_state::tr_hda(machine_config &config)
{
m_hopper_type = HOPPER_DUART_A;
+ m_hopper1->dispense_handler().set("duart68681", FUNC(mc68681_device::ip5_w));
}
void mpu4_state::tr_hdb(machine_config &config)
{
m_hopper_type = HOPPER_DUART_B;
+ m_hopper1->dispense_handler().set("duart68681", FUNC(mc68681_device::ip5_w));
}
void mpu4_state::tr_hdc(machine_config &config)
{
m_hopper_type = HOPPER_DUART_C;
+ m_hopper1->dispense_handler().set("duart68681", FUNC(mc68681_device::ip5_w));
+ m_hopper2->dispense_handler().set("duart68681", FUNC(mc68681_device::ip6_w));
}
void mpu4_state::tr_hna(machine_config &config)
@@ -2270,6 +2234,11 @@ void mpu4_state::tr_over(machine_config &config)
m_overcurrent_detect = true;
}
+void mpu4_state::tr_lvdoff(machine_config &config)
+{
+ m_low_volt_detect = false;
+}
+
void mpu4_state::tr_p4l(machine_config &config)
{
m_use_pia4_porta_leds = true;
@@ -2294,7 +2263,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_6840ptm->o3_callback().set(FUNC(mpu4_state::ic2_o3_callback));
m_6840ptm->irq_callback().set(FUNC(mpu4_state::cpu0_irq));
- PIA6821(config, m_pia3, 0);
+ PIA6821(config, m_pia3);
m_pia3->writepa_handler().set(FUNC(mpu4_state::pia_ic3_porta_w));
m_pia3->writepb_handler().set(FUNC(mpu4_state::pia_ic3_portb_w));
m_pia3->ca2_handler().set(FUNC(mpu4_state::pia_ic3_ca2_w));
@@ -2302,7 +2271,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia3->irqa_handler().set(FUNC(mpu4_state::cpu0_irq));
m_pia3->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
- PIA6821(config, m_pia4, 0);
+ PIA6821(config, m_pia4);
m_pia4->readpb_handler().set(FUNC(mpu4_state::pia_ic4_portb_r));
m_pia4->writepa_handler().set(FUNC(mpu4_state::pia_ic4_porta_w));
m_pia4->writepb_handler().set(FUNC(mpu4_state::pia_ic4_portb_w));
@@ -2311,7 +2280,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia4->irqa_handler().set(FUNC(mpu4_state::cpu0_irq));
m_pia4->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
- PIA6821(config, m_pia5, 0);
+ PIA6821(config, m_pia5);
m_pia5->readpa_handler().set(FUNC(mpu4_state::pia_ic5_porta_r));
m_pia5->readpb_handler().set(FUNC(mpu4_state::pia_ic5_portb_r));
m_pia5->writepa_handler().set(FUNC(mpu4_state::pia_ic5_porta_w));
@@ -2322,7 +2291,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia5->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
m_pia5->set_port_a_input_overrides_output_mask(0x40); // needed for m4madhse
- PIA6821(config, m_pia6, 0);
+ PIA6821(config, m_pia6);
m_pia6->writepa_handler().set(FUNC(mpu4_state::pia_ic6_porta_w));
m_pia6->writepb_handler().set(FUNC(mpu4_state::pia_ic6_portb_w));
m_pia6->ca2_handler().set(FUNC(mpu4_state::pia_ic6_ca2_w));
@@ -2330,7 +2299,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia6->irqa_handler().set(FUNC(mpu4_state::cpu0_irq));
m_pia6->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
- PIA6821(config, m_pia7, 0);
+ PIA6821(config, m_pia7);
m_pia7->readpb_handler().set(FUNC(mpu4_state::pia_ic7_portb_r));
m_pia7->writepa_handler().set(FUNC(mpu4_state::pia_ic7_porta_w));
m_pia7->writepb_handler().set(FUNC(mpu4_state::pia_ic7_portb_w));
@@ -2339,7 +2308,7 @@ void mpu4_state::mpu4_common(machine_config &config)
m_pia7->irqa_handler().set(FUNC(mpu4_state::cpu0_irq));
m_pia7->irqb_handler().set(FUNC(mpu4_state::cpu0_irq));
- PIA6821(config, m_pia8, 0);
+ PIA6821(config, m_pia8);
m_pia8->readpa_handler().set(FUNC(mpu4_state::pia_ic8_porta_r));
m_pia8->writepb_handler().set(FUNC(mpu4_state::pia_ic8_portb_w));
m_pia8->ca2_handler().set(FUNC(mpu4_state::pia_ic8_ca2_w));
@@ -2353,22 +2322,12 @@ void mpu4_state::mpu4_common(machine_config &config)
m_dataport->rxd_handler().set(FUNC(mpu4_state::dataport_rxd));
HOPPER(config, m_hopper1, attotime::from_msec(100), TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
-}
-void mpu4_state::mpu4_common2(machine_config &config)
-{
- PTM6840(config, m_ptm_ic3ss, MPU4_MASTER_CLOCK / 4);
- m_ptm_ic3ss->set_external_clocks(0, 0, 0);
- m_ptm_ic3ss->o1_callback().set("ptm_ic3ss", FUNC(ptm6840_device::set_c2));
- m_ptm_ic3ss->o2_callback().set("ptm_ic3ss", FUNC(ptm6840_device::set_c1));
- m_ptm_ic3ss->o3_callback().set("ptm_ic3ss", FUNC(ptm6840_device::set_g1));
- PIA6821(config, m_pia_ic4ss, 0);
- m_pia_ic4ss->readpb_handler().set(FUNC(mpu4_state::pia_gb_portb_r));
- m_pia_ic4ss->writepa_handler().set(FUNC(mpu4_state::pia_gb_porta_w));
- m_pia_ic4ss->writepb_handler().set(FUNC(mpu4_state::pia_gb_portb_w));
- m_pia_ic4ss->ca2_handler().set(FUNC(mpu4_state::pia_gb_ca2_w));
- m_pia_ic4ss->cb2_handler().set(FUNC(mpu4_state::pia_gb_cb2_w));
+ SPEAKER(config, "mono").front_center();
+
+ DAC_1BIT(config, m_alarmdac, 0);
+ m_alarmdac->add_route(ALL_OUTPUTS, "mono", 0.50);
}
/***********************************************************************************************
@@ -2379,15 +2338,13 @@ void mpu4_state::mpu4_common2(machine_config &config)
void mpu4_state::mpu4base(machine_config &config)
{
- MCFG_MACHINE_START_OVERRIDE(mpu4_state,mod2)
- MCFG_MACHINE_RESET_OVERRIDE(mpu4_state,mpu4)
+ MCFG_MACHINE_START_OVERRIDE(mpu4_state, mod2)
+ MCFG_MACHINE_RESET_OVERRIDE(mpu4_state, mpu4)
MC6809(config, m_maincpu, MPU4_MASTER_CLOCK); // MC68B09P
m_maincpu->set_addrmap(AS_PROGRAM, &mpu4_state::mpu4_memmap);
mpu4_common(config);
- SPEAKER(config, "lspeaker").front_left();
- SPEAKER(config, "rspeaker").front_right();
NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0);
@@ -2408,17 +2365,17 @@ void mpu4_state::mod2_f(machine_config &config)
{
mpu4base(config);
AY8913(config, m_ay8913, MPU4_MASTER_CLOCK/4);
+
m_ay8913->set_flags(AY8910_SINGLE_OUTPUT);
m_ay8913->set_resistors_load(820, 0, 0);
- m_ay8913->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
- m_ay8913->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
+ m_ay8913->add_route(ALL_OUTPUTS, "mono", 1.0);
}
void mpu4_state::mod2_no_bacta_f(machine_config &config)
{
mod2_f(config);
config.device_remove("dataport");
- m_pia5->ca2_handler().set(m_pia4, FUNC(pia6821_device::cb1_w));
+ m_pia5->ca2_handler().set(FUNC(mpu4_state::dataport_rxd));
}
void mpu4_state::mod2_cheatchr_f(machine_config &config)
@@ -2437,7 +2394,7 @@ void mpu4_state::mod2_cheatchr_f(machine_config &config)
Configs for Mod4 with OKI
- TODO: mod4oki should eventually become a subclass
+ TODO: OKI is its own device, should mod4oki eventually become a subclass
***********************************************************************************************/
@@ -2446,20 +2403,20 @@ void mpu4_state::mod2_cheatchr_f(machine_config &config)
void mpu4_state::mod4oki_f(machine_config &config)
{
mpu4base(config);
- MCFG_MACHINE_START_OVERRIDE(mpu4_state,mpu4oki)
+ MCFG_MACHINE_START_OVERRIDE(mpu4_state, mpu4oki)
+
+ MPU4_OKI_SAMPLED_SOUND(config, m_okicard, MPU4_MASTER_CLOCK/4);
+ m_okicard->add_route(ALL_OUTPUTS, "mono", 1.0);
- mpu4_common2(config);
+ m_okicard->cb2_handler().set(FUNC(mpu4_state::pia_gb_cb2_w));
- OKIM6376(config, m_msm6376, 128000); //Adjusted by IC3, default to 16KHz sample. Can also be 85430 at 10.5KHz and 64000 at 8KHz
- m_msm6376->add_route(ALL_OUTPUTS, "lspeaker", 1.0);
- m_msm6376->add_route(ALL_OUTPUTS, "rspeaker", 1.0);
}
void mpu4_state::mod4oki_no_bacta_f(machine_config &config)
{
mod4oki_f(config);
config.device_remove("dataport");
- m_pia5->ca2_handler().set(m_pia4, FUNC(pia6821_device::cb1_w));
+ m_pia5->ca2_handler().set(FUNC(mpu4_state::dataport_rxd));
}
void mpu4_state::mod4oki_cheatchr_f(machine_config &config)