summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2021-04-16 16:48:22 +0200
committer hap <happppp@users.noreply.github.com>2021-04-16 16:48:33 +0200
commit50c0632bfbf35cf49d39931cf8376f1259255aa8 (patch)
tree91e289adc946b0f5694f4db897d3185a04666761
parent2bf61d807885e2e57e42a711cf3e2549c10301b5 (diff)
smartboard: add safeguards for invalid read
-rw-r--r--src/mame/drivers/tasc.cpp1
-rw-r--r--src/mame/machine/smartboard.cpp32
-rw-r--r--src/mame/machine/smartboard.h2
3 files changed, 22 insertions, 13 deletions
diff --git a/src/mame/drivers/tasc.cpp b/src/mame/drivers/tasc.cpp
index 2b5053122ce..e20f06c7729 100644
--- a/src/mame/drivers/tasc.cpp
+++ b/src/mame/drivers/tasc.cpp
@@ -36,6 +36,7 @@ notes:
TODO:
- bootrom disable timer shouldn't be needed, real ARM has already fetched the next opcode
- sound is too high pitched, same problem as in risc2500
+- "disable leds" setting breaks smartboard controls
******************************************************************************/
diff --git a/src/mame/machine/smartboard.cpp b/src/mame/machine/smartboard.cpp
index 72a0978da94..4288f28044e 100644
--- a/src/mame/machine/smartboard.cpp
+++ b/src/mame/machine/smartboard.cpp
@@ -225,16 +225,21 @@ uint8_t tasc_sb30_device::spawn_cb(offs_t offset)
uint8_t tasc_sb30_device::read()
{
- int x = (m_position & 0x3f) / 8;
- int y = (m_position & 0x3f) % 8;
- int piece_id = m_board->read_sensor(7 - x, 7 - y);
+ if (m_position < 0x40)
+ {
+ int x = 7 - m_position / 8;
+ int y = 7 - m_position % 8;
+ int piece_id = m_board->read_sensor(x, y);
+
+ // each piece is identified by a single bit in a 32-bit sequence, if multiple bits are active the MSB is used
+ uint32_t sb30_id = 0;
+ if (piece_id > 0)
+ sb30_id = 1UL << (piece_id - 1);
- // each piece is identified by a single bit in a 32-bit sequence, if multiple bits are active the MSB is used
- uint32_t sb30_id = 0;
- if (piece_id > 0)
- sb30_id = 1UL << (piece_id - 1);
+ return BIT(sb30_id, m_shift & 0x1f);
+ }
- return BIT(sb30_id, m_shift & 0x1f);
+ return 0;
}
void tasc_sb30_device::write(uint8_t data)
@@ -244,15 +249,18 @@ void tasc_sb30_device::write(uint8_t data)
if (BIT(data, 6) && !BIT(m_data, 6))
{
- int x = (m_position & 0x3f) / 8;
- int y = (m_position & 0x3f) % 8;
- m_out_leds[y][x] = BIT(data, 7);
+ if (m_position < 0x40)
+ {
+ int x = m_position / 8;
+ int y = m_position % 8;
+ m_out_leds[y][x] = BIT(data, 7);
+ }
}
if (!BIT(data, 7) && BIT(m_data, 7))
{
m_position++;
- if (m_position & 0x40)
+ if (m_position >= 0x40)
{
m_shift++;
if (m_position & 1)
diff --git a/src/mame/machine/smartboard.h b/src/mame/machine/smartboard.h
index 4eefb86e5bf..c56adda84e7 100644
--- a/src/mame/machine/smartboard.h
+++ b/src/mame/machine/smartboard.h
@@ -47,7 +47,7 @@ private:
output_finder<8,8> m_out_leds;
emu_timer * m_leds_off_timer;
uint8_t m_data;
- uint8_t m_position;
+ uint32_t m_position;
uint8_t m_shift;
};