summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2021-04-20 01:52:25 +0200
committer hap <happppp@users.noreply.github.com>2021-04-20 01:52:36 +0200
commitc624eb0102ce5db000811df84b5d1f9853770d96 (patch)
tree833d3d7c39a1de5d60d4383fe9e267be43a3f373
parent4b47c9f10218f306b11f2bea07623728574a625e (diff)
smartboard: changes to make tasc smartboard test program work
-rw-r--r--src/devices/bus/centronics/smartboard.h1
-rw-r--r--src/devices/machine/smartboard.cpp59
-rw-r--r--src/devices/machine/smartboard.h5
-rw-r--r--src/mame/drivers/tasc.cpp1
4 files changed, 22 insertions, 44 deletions
diff --git a/src/devices/bus/centronics/smartboard.h b/src/devices/bus/centronics/smartboard.h
index a5ab09b48b1..4988086b11f 100644
--- a/src/devices/bus/centronics/smartboard.h
+++ b/src/devices/bus/centronics/smartboard.h
@@ -27,7 +27,6 @@ protected:
virtual void device_start() override { }
virtual void device_add_mconfig(machine_config &config) override;
- virtual DECLARE_WRITE_LINE_MEMBER(input_data2) override { if (started()) m_smartboard->reset_w(state); }
virtual DECLARE_WRITE_LINE_MEMBER(input_data0) override { if (started()) m_smartboard->data0_w(state); }
virtual DECLARE_WRITE_LINE_MEMBER(input_data7) override { if (started()) m_smartboard->data1_w(state); }
diff --git a/src/devices/machine/smartboard.cpp b/src/devices/machine/smartboard.cpp
index 123434e0cb5..07190d7d4e2 100644
--- a/src/devices/machine/smartboard.cpp
+++ b/src/devices/machine/smartboard.cpp
@@ -94,12 +94,11 @@ void tasc_sb30_device::device_start()
std::fill(std::begin(m_squares), std::end(m_squares), 0);
// register for savestates
- save_item(NAME(m_reset));
save_item(NAME(m_data0));
save_item(NAME(m_data1));
save_item(NAME(m_output));
+ save_item(NAME(m_scan_pending));
save_item(NAME(m_pos));
- save_item(NAME(m_shift));
save_item(NAME(m_squares));
}
@@ -279,32 +278,33 @@ u8 tasc_sb30_device::spawn_cb(offs_t offset)
// I/O handlers
//-------------------------------------------------
-void tasc_sb30_device::reset_w(int state)
-{
- state = state ? 1 : 0;
-
- if (!state && m_reset)
- {
- m_pos = 0;
- update_output();
- }
-
- m_reset = state;
-}
-
void tasc_sb30_device::data0_w(int state)
{
state = state ? 1 : 0;
if (!state && m_data0)
{
- if (m_pos < 0x40)
+ if (m_scan_pending)
+ {
+ for (int i = 0; i < 64; i++)
+ {
+ // each piece is identified by a single bit in a 32-bit sequence
+ int piece_id = m_board->read_sensor(i >> 3 ^ 7, ~i & 7);
+ m_squares[i] = piece_id ? (1 << (piece_id - 1)) : 0;
+ }
+
+ m_pos = 0;
+ update_output();
+
+ m_scan_pending = false;
+ }
+ else
{
// output board led(s)
if (m_led_out.isnull())
- m_out_leds[m_pos & 7][m_pos >> 3] = m_data1;
+ m_out_leds[m_pos & 7][m_pos >> 3 & 7] = m_data1;
else
- m_led_out(m_pos, m_data1);
+ m_led_out(m_pos & 0x3f, m_pos >> 6 & 1);
}
}
@@ -315,20 +315,13 @@ void tasc_sb30_device::data1_w(int state)
{
state = state ? 1 : 0;
+ // clock position counter
if (!state && m_data1)
{
m_pos++;
- if ((m_pos & 0x3f) == 0)
- m_shift++;
-
if (m_data0)
- {
- m_shift = 0;
-
- // start scan
- scan_board();
- }
+ m_scan_pending = true;
update_output();
}
@@ -336,18 +329,8 @@ void tasc_sb30_device::data1_w(int state)
m_data1 = state;
}
-void tasc_sb30_device::scan_board()
-{
- for (int i = 0; i < 64; i++)
- {
- // each piece is identified by a single bit in a 32-bit sequence
- int piece_id = m_board->read_sensor(i >> 3 ^ 7, ~i & 7);
- m_squares[i] = piece_id ? (1 << (piece_id - 1)) : 0;
- }
-}
-
void tasc_sb30_device::update_output()
{
- m_output = BIT(m_squares[m_pos & 0x3f], m_shift & 0x1f);
+ m_output = BIT(m_squares[m_pos & 0x3f], m_pos >> 6 & 0x1f);
m_data_out(m_output);
}
diff --git a/src/devices/machine/smartboard.h b/src/devices/machine/smartboard.h
index 27ae5d4dcdb..27b48fe2820 100644
--- a/src/devices/machine/smartboard.h
+++ b/src/devices/machine/smartboard.h
@@ -23,7 +23,6 @@ public:
auto led_out() { return m_led_out.bind(); } // optional, outputs to sb30_ledy.x when not used
// external read/write lines
- void reset_w(int state);
void data0_w(int state);
void data1_w(int state);
int data_r() { return m_output; }
@@ -42,21 +41,19 @@ private:
devcb_write_line m_data_out;
devcb_write8 m_led_out;
- void scan_board();
void update_output();
bool piece_available(u8 id);
void init_cb(int state);
u8 spawn_cb(offs_t offset);
// i/o lines
- int m_reset = 0;
int m_data0 = 0;
int m_data1 = 0;
int m_output = 0;
// internal use
+ bool m_scan_pending = false;
u32 m_pos = 0;
- u8 m_shift = 0;
u32 m_squares[64]; // board state
};
diff --git a/src/mame/drivers/tasc.cpp b/src/mame/drivers/tasc.cpp
index ea3d37cca41..be31fbf38e2 100644
--- a/src/mame/drivers/tasc.cpp
+++ b/src/mame/drivers/tasc.cpp
@@ -170,7 +170,6 @@ void tasc_state::control_w(offs_t offset, u32 data, u32 mem_mask)
if (BIT(data, 27))
m_lcd->write(BIT(data, 26), data & 0xff);
- m_smartboard->reset_w(BIT(data, 27));
m_smartboard->data0_w(BIT(data, 30));
m_smartboard->data1_w(BIT(data, 31));
}