(nw) output finder for splus,cpp

This commit is contained in:
Robbbert 2018-04-06 11:54:14 +10:00
parent 707764f7d6
commit 5512e70061

View File

@ -38,17 +38,19 @@ class splus_state : public driver_device
{ {
public: public:
splus_state(const machine_config &mconfig, device_type type, const char *tag) splus_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag), : driver_device(mconfig, type, tag)
m_cmosl_ram(*this, "cmosl"), , m_cmosl_ram(*this, "cmosl")
m_cmosh_ram(*this, "cmosh"), , m_cmosh_ram(*this, "cmosh")
m_program_ram(*this, "program_ram"), , m_program_ram(*this, "program_ram")
m_reel_ram(*this, "reel_ram"), , m_reel_ram(*this, "reel_ram")
m_i10(*this, "I10"), , m_i10(*this, "I10")
m_i20(*this, "I20"), , m_i20(*this, "I20")
m_i30(*this, "I30"), , m_i30(*this, "I30")
m_sensor(*this, "SENSOR"), , m_sensor(*this, "SENSOR")
m_maincpu(*this, "maincpu"), , m_maincpu(*this, "maincpu")
m_i2cmem(*this, "i2cmem") , m_i2cmem(*this, "i2cmem")
, m_digits(*this, "digit%u", 0U)
, m_leds(*this, "s_bnk%u%u", 0U, 0U)
{ {
m_sda_dir = 0; m_sda_dir = 0;
m_coin_state = 0; m_coin_state = 0;
@ -69,20 +71,25 @@ public:
return 0; return 0;
} }
// Pointers to External RAM DECLARE_WRITE8_MEMBER(splus_p1_w);
required_shared_ptr<uint8_t> m_cmosl_ram; DECLARE_WRITE8_MEMBER(splus_load_pulse_w);
required_shared_ptr<uint8_t> m_cmosh_ram; DECLARE_WRITE8_MEMBER(splus_serial_w);
DECLARE_WRITE8_MEMBER(splus_7seg_w);
// Program and Reel Data DECLARE_WRITE8_MEMBER(splus_duart_w);
optional_shared_ptr<uint8_t> m_program_ram; DECLARE_READ8_MEMBER(splus_serial_r);
required_shared_ptr<uint8_t> m_reel_ram; DECLARE_READ8_MEMBER(splus_m_reel_ram_r);
DECLARE_READ8_MEMBER(splus_p3_r);
// IO Ports DECLARE_READ8_MEMBER(splus_duart_r);
required_ioport m_i10; DECLARE_READ8_MEMBER(splus_watchdog_r);
required_ioport m_i20; DECLARE_READ8_MEMBER(splus_registers_r);
required_ioport m_i30; DECLARE_WRITE8_MEMBER(i2c_nvram_w);
required_ioport m_sensor; DECLARE_READ8_MEMBER(splus_reel_optics_r);
DECLARE_DRIVER_INIT(splus);
void splus(machine_config &config);
void splus_iomap(address_map &map);
void splus_map(address_map &map);
private:
// EEPROM States // EEPROM States
int m_sda_dir; int m_sda_dir;
@ -104,25 +111,29 @@ public:
int16_t m_stepper_pos[5]; int16_t m_stepper_pos[5];
uint8_t m_stop_pos[5]; uint8_t m_stop_pos[5];
DECLARE_WRITE8_MEMBER(splus_p1_w); virtual void machine_start() override
DECLARE_WRITE8_MEMBER(splus_load_pulse_w); {
DECLARE_WRITE8_MEMBER(splus_serial_w); m_digits.resolve();
DECLARE_WRITE8_MEMBER(splus_7seg_w); m_leds.resolve();
DECLARE_WRITE8_MEMBER(splus_duart_w); }
DECLARE_READ8_MEMBER(splus_serial_r);
DECLARE_READ8_MEMBER(splus_m_reel_ram_r); // Pointers to External RAM
DECLARE_READ8_MEMBER(splus_p3_r); required_shared_ptr<uint8_t> m_cmosl_ram;
DECLARE_READ8_MEMBER(splus_duart_r); required_shared_ptr<uint8_t> m_cmosh_ram;
DECLARE_READ8_MEMBER(splus_watchdog_r);
DECLARE_READ8_MEMBER(splus_registers_r); // Program and Reel Data
DECLARE_WRITE8_MEMBER(i2c_nvram_w); optional_shared_ptr<uint8_t> m_program_ram;
DECLARE_READ8_MEMBER(splus_reel_optics_r); required_shared_ptr<uint8_t> m_reel_ram;
DECLARE_DRIVER_INIT(splus);
// IO Ports
required_ioport m_i10;
required_ioport m_i20;
required_ioport m_i30;
required_ioport m_sensor;
required_device<cpu_device> m_maincpu; required_device<cpu_device> m_maincpu;
required_device<i2cmem_device> m_i2cmem; required_device<i2cmem_device> m_i2cmem;
void splus(machine_config &config); output_finder<9> m_digits;
void splus_iomap(address_map &map); output_finder<5,8> m_leds;
void splus_map(address_map &map);
}; };
/* Static Variables */ /* Static Variables */
@ -170,20 +181,26 @@ WRITE8_MEMBER(splus_state::splus_p1_w)
m_p1_unknown = (~data & 0x80); m_p1_unknown = (~data & 0x80);
// Stepper Motor Engaged // Stepper Motor Engaged
if (((m_bank40 >> 0) & 1) == 0x01) { if (BIT(m_bank40, 0))
{
// Reel Controllers Only // Reel Controllers Only
m_p1_reels = (data & 0x1f); m_p1_reels = (data & 0x1f);
// Loop through Reel Controllers // Loop through Reel Controllers
for (int x = 0; x < 5; x++) { for (int x = 0; x < 5; x++)
{
// Test Reel Controller // Test Reel Controller
if (((m_p1_reels >> x) & 1) == 0x01) { if (BIT(m_p1_reels, x))
{
// Forward Direction // Forward Direction
if (((m_bank10 >> 5) & 1) == 0x01) { if (BIT(m_bank10, 5))
{
m_stepper_pos[x]++; m_stepper_pos[x]++;
if (m_stepper_pos[x] == MAX_STEPPER) if (m_stepper_pos[x] == MAX_STEPPER)
m_stepper_pos[x] = 0; m_stepper_pos[x] = 0;
} else { }
else
{
m_stepper_pos[x]--; m_stepper_pos[x]--;
if (m_stepper_pos[x] < 0) if (m_stepper_pos[x] < 0)
m_stepper_pos[x] = MAX_STEPPER - 1; m_stepper_pos[x] = MAX_STEPPER - 1;
@ -194,7 +211,7 @@ WRITE8_MEMBER(splus_state::splus_p1_w)
} }
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
if ((data & 0x1f) == 0x01) if ((data & 0x1f) == 0x01)
osd_printf_info("Steppers %02X-%02X-%02X-%02X-%02X Motor=%02X Dir=%02X reels=%02X unk=%02X\n", m_stop_pos[0],m_stop_pos[1],m_stop_pos[2],m_stop_pos[3],m_stop_pos[4],((m_bank40 >> 0) & 1),((m_bank10 >> 5) & 1),(data & 0x1f), m_p1_unknown); osd_printf_info("Steppers %02X-%02X-%02X-%02X-%02X Motor=%02X Dir=%02X reels=%02X unk=%02X\n", m_stop_pos[0],m_stop_pos[1],m_stop_pos[2],m_stop_pos[3],m_stop_pos[4],BIT(m_bank40, 0),BIT(m_bank10, 5),(data & 0x1f), m_p1_unknown);
#endif #endif
} }
} }
@ -213,135 +230,111 @@ WRITE8_MEMBER(splus_state::splus_serial_w)
switch (out) switch (out)
{ {
case 0x00: // Bank 10 case 0x00: // Bank 10
if (((m_bank10 >> 0) & 1) != ((data >> 0) & 1)) {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
osd_printf_info("Coin Drop Meter =%02X\n",(data >> 0) & 1); if (BIT(m_bank10, 0) != BIT(data, 0)) {
osd_printf_info("Coin Drop Meter =%02X\n",BIT(data, 0);
}
if (BIT(m_bank10, 1) != BIT(data, 1)) {
osd_printf_info("Coin Out Meter =%02X\n",BIT(data, 1);
}
if (BIT(m_bank10, 2) != BIT(data, 2)) {
osd_printf_info("Coin In Meter =%02X\n",BIT(data, 2);
}
if (BIT(m_bank10, 3) != BIT(data, 3)) {
//osd_printf_info("B Switch for SDS =%02X\n",BIT(data, 3);
}
if (BIT(m_bank10, 4) != BIT(data, 4)) {
osd_printf_info("Hopper Drive 2 =%02X\n",BIT(data, 4);
}
if (BIT(m_bank10, 5) != BIT(data, 5)) {
osd_printf_info("Stepper Motor Direction =%02X\n",BIT(data, 5);
}
if (BIT(m_bank10, 6) != BIT(data, 6)) {
osd_printf_info("Mechanical Bell =%02X\n",BIT(data, 6);
}
if (BIT(m_bank10, 7) != BIT(data, 7)) {
osd_printf_info("Cancelled Credits Meter =%02X\n",BIT(data, 7);
}
#endif #endif
}
if (((m_bank10 >> 1) & 1) != ((data >> 1) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Coin Out Meter =%02X\n",(data >> 1) & 1);
#endif
}
if (((m_bank10 >> 2) & 1) != ((data >> 2) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Coin In Meter =%02X\n",(data >> 2) & 1);
#endif
}
if (((m_bank10 >> 3) & 1) != ((data >> 3) & 1)) {
//osd_printf_info("B Switch for SDS =%02X\n",(data >> 3) & 1);
}
if (((m_bank10 >> 4) & 1) != ((data >> 4) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Hopper Drive 2 =%02X\n",(data >> 4) & 1);
#endif
}
if (((m_bank10 >> 5) & 1) != ((data >> 5) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Stepper Motor Direction =%02X\n",(data >> 5) & 1);
#endif
}
if (((m_bank10 >> 6) & 1) != ((data >> 6) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Mechanical Bell =%02X\n",(data >> 6) & 1);
#endif
}
if (((m_bank10 >> 7) & 1) != ((data >> 7) & 1)) {
#if DEBUG_OUTPUT
osd_printf_info("Cancelled Credits Meter =%02X\n",(data >> 7) & 1);
#endif
}
m_bank10 = data; m_bank10 = data;
output().set_value("s_bnk10",(data >> 0) & 1); // Coin Drop Meter m_leds[1][0] = BIT(data, 0); // Coin Drop Meter
output().set_value("s_bnk11",(data >> 1) & 1); // Coin Out Meter m_leds[1][1] = BIT(data, 1); // Coin Out Meter
output().set_value("s_bnk12",(data >> 2) & 1); // Coin In Meter m_leds[1][2] = BIT(data, 2); // Coin In Meter
output().set_value("s_bnk13",(data >> 3) & 1); // B Switch for SDS m_leds[1][3] = BIT(data, 3); // B Switch for SDS
output().set_value("s_bnk14",(data >> 4) & 1); // Hopper Drive 2 m_leds[1][4] = BIT(data, 4); // Hopper Drive 2
output().set_value("s_bnk15",(data >> 5) & 1); // Stepper Motor Direction m_leds[1][5] = BIT(data, 5); // Stepper Motor Direction
output().set_value("s_bnk16",(data >> 6) & 1); // Mechanical Bell m_leds[1][6] = BIT(data, 6); // Mechanical Bell
output().set_value("s_bnk17",(data >> 7) & 1); // Cancelled Credits Meter m_leds[1][7] = BIT(data, 7); // Cancelled Credits Meter
break; break;
case 0x01: // Bank 20 case 0x01: // Bank 20
if (((m_bank20 >> 5) & 1) != ((data >> 5) & 1)) {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
osd_printf_info("Games Played Meter =%02X\n",(data >> 5) & 1); if (BIT(m_bank20, 5) != BIT(data, 5)) {
#endif osd_printf_info("Games Played Meter =%02X\n",BIT(data, 5);
} }
if (((m_bank20 >> 6) & 1) != ((data >> 6) & 1)) { if (BIT(m_bank20, 6) != BIT(data, 6)) {
#if DEBUG_OUTPUT osd_printf_info("Bill Acceptor Enable =%02X\n",BIT(data, 6);
osd_printf_info("Bill Acceptor Enable =%02X\n",(data >> 6) & 1);
#endif
} }
if (((m_bank20 >> 7) & 1) != ((data >> 7) & 1)) { if (BIT(m_bank20, 7) != BIT(data, 7)) {
#if DEBUG_OUTPUT osd_printf_info("Jackpots Meter =%02X\n",BIT(data, 7);
osd_printf_info("Jackpots Meter =%02X\n",(data >> 7) & 1);
#endif
} }
#endif
m_bank20 = data; m_bank20 = data;
output().set_value("s_bnk20",(data >> 0) & 1); // Payline Lamp 3 m_leds[2][0] = BIT(data, 0); // Payline Lamp 3
output().set_value("s_bnk21",(data >> 1) & 1); // Payline Lamp 4 m_leds[2][1] = BIT(data, 1); // Payline Lamp 4
output().set_value("s_bnk22",(data >> 2) & 1); // Payline Lamp 5 m_leds[2][2] = BIT(data, 2); // Payline Lamp 5
output().set_value("s_bnk23",(data >> 3) & 1); // Payline Lamp 6 m_leds[2][3] = BIT(data, 3); // Payline Lamp 6
output().set_value("s_bnk24",(data >> 4) & 1); // Door Optics Transmitter m_leds[2][4] = BIT(data, 4); // Door Optics Transmitter
output().set_value("s_bnk25",(data >> 5) & 1); // Games Played Meter m_leds[2][5] = BIT(data, 5); // Games Played Meter
output().set_value("s_bnk26",(data >> 6) & 1); // Bill Acceptor Enable m_leds[2][6] = BIT(data, 6); // Bill Acceptor Enable
output().set_value("s_bnk27",(data >> 7) & 1); // Jackpots Meter m_leds[2][7] = BIT(data, 7); // Jackpots Meter
break; break;
case 0x02: // Bank 30 case 0x02: // Bank 30
if (((m_bank30 >> 2) & 1) != ((data >> 2) & 1)) {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
osd_printf_info("Handle Release =%02X\n",(data >> 2) & 1); if (BIT(m_bank30, 2) != BIT(data, 2)) {
#endif osd_printf_info("Handle Release =%02X\n",BIT(data, 2);
} }
if (((m_bank30 >> 3) & 1) != ((data >> 3) & 1)) { if (BIT(m_bank30, 3) != BIT(data, 3)) {
#if DEBUG_OUTPUT osd_printf_info("Diverter =%02X\n",BIT(data, 3);
osd_printf_info("Diverter =%02X\n",(data >> 3) & 1);
#endif
} }
if (((m_bank30 >> 4) & 1) != ((data >> 4) & 1)) { if (BIT(m_bank30, 4) != BIT(data, 4)) {
#if DEBUG_OUTPUT osd_printf_info("Coin Lockout =%02X\n",BIT(data, 4);
osd_printf_info("Coin Lockout =%02X\n",(data >> 4) & 1);
#endif
} }
if (((m_bank30 >> 5) & 1) != ((data >> 5) & 1)) { if (BIT(m_bank30, 5) != BIT(data, 5)) {
#if DEBUG_OUTPUT osd_printf_info("Hopper Drive 1 =%02X\n",BIT(data, 5);
osd_printf_info("Hopper Drive 1 =%02X\n",(data >> 5) & 1);
#endif
} }
#endif
m_bank30 = data; m_bank30 = data;
output().set_value("s_bnk30",(data >> 0) & 1); // Change Candle Lamp Bottom m_leds[3][0] = BIT(data, 0); // Change Candle Lamp Bottom
output().set_value("s_bnk31",(data >> 1) & 1); // Change Candle Lamp Top m_leds[3][1] = BIT(data, 1); // Change Candle Lamp Top
output().set_value("s_bnk32",(data >> 2) & 1); // Handle Release m_leds[3][2] = BIT(data, 2); // Handle Release
output().set_value("s_bnk33",(data >> 3) & 1); // Diverter m_leds[3][3] = BIT(data, 3); // Diverter
output().set_value("s_bnk34",(data >> 4) & 1); // Coin Lockout m_leds[3][4] = BIT(data, 4); // Coin Lockout
output().set_value("s_bnk35",(data >> 5) & 1); // Hopper Drive 1 m_leds[3][5] = BIT(data, 5); // Hopper Drive 1
output().set_value("s_bnk36",(data >> 6) & 1); // Payline Lamp 1 m_leds[3][6] = BIT(data, 6); // Payline Lamp 1
output().set_value("s_bnk37",(data >> 7) & 1); // Payline Lamp 2 m_leds[3][7] = BIT(data, 7); // Payline Lamp 2
break; break;
case 0x04: // Bank 40 case 0x04: // Bank 40
if (((m_bank40 >> 0) & 1) != ((data >> 0) & 1)) {
#if DEBUG_OUTPUT #if DEBUG_OUTPUT
osd_printf_info("Stepper Motor Power Supply =%02X\n",(data >> 0) & 1); if (BIT(m_bank40, 0) != BIT(data, 0)) {
#endif osd_printf_info("Stepper Motor Power Supply =%02X\n",BIT(data, 0);
} }
if (((m_bank40 >> 3) & 1) != ((data >> 3) & 1)) { if (BIT(m_bank40, 3) != BIT(data, 3)) {
#if DEBUG_OUTPUT osd_printf_info("Jackpot/Hand Pay Lamp =%02X\n",BIT(data, 3);
osd_printf_info("Jackpot/Hand Pay Lamp =%02X\n",(data >> 3) & 1);
#endif
} }
#endif
m_bank40 = data; m_bank40 = data;
output().set_value("s_bnk40",(data >> 0) & 1); // Stepper Motor Power Supply m_leds[4][0] = BIT(data, 0); // Stepper Motor Power Supply
output().set_value("s_bnk41",(data >> 1) & 1); // Insert Coin Lamp m_leds[4][1] = BIT(data, 1); // Insert Coin Lamp
output().set_value("s_bnk42",(data >> 2) & 1); // Coin Accepted Lamp m_leds[4][2] = BIT(data, 2); // Coin Accepted Lamp
output().set_value("s_bnk43",(data >> 3) & 1); // Jackpot/Hand Pay Lamp m_leds[4][3] = BIT(data, 3); // Jackpot/Hand Pay Lamp
output().set_value("s_bnk44",(data >> 4) & 1); // Play Max Credits Lamp m_leds[4][4] = BIT(data, 4); // Play Max Credits Lamp
output().set_value("s_bnk45",(data >> 5) & 1); // Bet One Credit Lamp m_leds[4][5] = BIT(data, 5); // Bet One Credit Lamp
output().set_value("s_bnk46",(data >> 6) & 1); // Cashout Credit Lamp m_leds[4][6] = BIT(data, 6); // Cashout Credit Lamp
output().set_value("s_bnk47",(data >> 7) & 1); // Spin Button Lamp m_leds[4][7] = BIT(data, 7); // Spin Button Lamp
break; break;
} }
} }
@ -357,8 +350,8 @@ WRITE8_MEMBER(splus_state::splus_7seg_w)
val = (~data & 0x0f); // Digit Value val = (~data & 0x0f); // Digit Value
// Need to add ~m_io_port1-1 to seg value // Need to add ~m_io_port1-1 to seg value
if (seg < 0x0a && (m_io_port1 & 0xe0) == 0xe0) if (seg < 9 && (m_io_port1 & 0xe0) == 0xe0)
output().set_digit_value(seg, ls48_map[val]); m_digits[seg] = ls48_map[val];
} }
WRITE8_MEMBER(splus_state::splus_duart_w) WRITE8_MEMBER(splus_state::splus_duart_w)
@ -449,10 +442,10 @@ READ8_MEMBER(splus_state::splus_serial_r)
if ((m_i10->read() & 0x08) == 0x08) if ((m_i10->read() & 0x08) == 0x08)
door_optics = 0x08; door_optics = 0x08;
else else
door_optics = (((m_bank20 >> 4) & 1) << 3); // Use Door Optics Transmitter door_optics = BIT(m_bank20, 4) << 3; // Use Door Optics Transmitter
// Test if Hopper 1 and Hopper 2 Motors On // Test if Hopper 1 and Hopper 2 Motors On
if (((m_bank10 >> 4) & 1) || ((m_bank30 >> 5) & 1)) { if (BIT(m_bank10, 4) || BIT(m_bank30, 5)) {
if (m_coin_out_state == 0) if (m_coin_out_state == 0)
m_coin_out_state = 3; m_coin_out_state = 3;
} else { } else {