mirror of
https://github.com/holub/mame
synced 2025-07-05 01:48:29 +03:00
smartboard: add safeguards for invalid read
This commit is contained in:
parent
2bf61d8078
commit
50c0632bfb
@ -36,6 +36,7 @@ notes:
|
|||||||
TODO:
|
TODO:
|
||||||
- bootrom disable timer shouldn't be needed, real ARM has already fetched the next opcode
|
- 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
|
- sound is too high pitched, same problem as in risc2500
|
||||||
|
- "disable leds" setting breaks smartboard controls
|
||||||
|
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
@ -225,9 +225,11 @@ uint8_t tasc_sb30_device::spawn_cb(offs_t offset)
|
|||||||
|
|
||||||
uint8_t tasc_sb30_device::read()
|
uint8_t tasc_sb30_device::read()
|
||||||
{
|
{
|
||||||
int x = (m_position & 0x3f) / 8;
|
if (m_position < 0x40)
|
||||||
int y = (m_position & 0x3f) % 8;
|
{
|
||||||
int piece_id = m_board->read_sensor(7 - x, 7 - y);
|
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
|
// 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;
|
uint32_t sb30_id = 0;
|
||||||
@ -237,6 +239,9 @@ uint8_t tasc_sb30_device::read()
|
|||||||
return BIT(sb30_id, m_shift & 0x1f);
|
return BIT(sb30_id, m_shift & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void tasc_sb30_device::write(uint8_t data)
|
void tasc_sb30_device::write(uint8_t data)
|
||||||
{
|
{
|
||||||
if (BIT(data, 3) && !BIT(m_data, 3))
|
if (BIT(data, 3) && !BIT(m_data, 3))
|
||||||
@ -244,15 +249,18 @@ void tasc_sb30_device::write(uint8_t data)
|
|||||||
|
|
||||||
if (BIT(data, 6) && !BIT(m_data, 6))
|
if (BIT(data, 6) && !BIT(m_data, 6))
|
||||||
{
|
{
|
||||||
int x = (m_position & 0x3f) / 8;
|
if (m_position < 0x40)
|
||||||
int y = (m_position & 0x3f) % 8;
|
{
|
||||||
|
int x = m_position / 8;
|
||||||
|
int y = m_position % 8;
|
||||||
m_out_leds[y][x] = BIT(data, 7);
|
m_out_leds[y][x] = BIT(data, 7);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!BIT(data, 7) && BIT(m_data, 7))
|
if (!BIT(data, 7) && BIT(m_data, 7))
|
||||||
{
|
{
|
||||||
m_position++;
|
m_position++;
|
||||||
if (m_position & 0x40)
|
if (m_position >= 0x40)
|
||||||
{
|
{
|
||||||
m_shift++;
|
m_shift++;
|
||||||
if (m_position & 1)
|
if (m_position & 1)
|
||||||
|
@ -47,7 +47,7 @@ private:
|
|||||||
output_finder<8,8> m_out_leds;
|
output_finder<8,8> m_out_leds;
|
||||||
emu_timer * m_leds_off_timer;
|
emu_timer * m_leds_off_timer;
|
||||||
uint8_t m_data;
|
uint8_t m_data;
|
||||||
uint8_t m_position;
|
uint32_t m_position;
|
||||||
uint8_t m_shift;
|
uint8_t m_shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user