diff options
| author | 2026-04-17 00:09:44 +0200 | |
|---|---|---|
| committer | 2026-04-17 00:46:41 +0200 | |
| commit | e6d532490dc06b17641499db6cefc620f7b0e868 (patch) | |
| tree | ab806110375079b0db9f576f41a94339bff60dbd /src/devices/machine/gmboard.cpp | |
| parent | 9ba4599fedac458be8700a73d1b4090caf244d10 (diff) | |
gmboard: fix regression with fphantom hint button
Diffstat (limited to 'src/devices/machine/gmboard.cpp')
| -rw-r--r-- | src/devices/machine/gmboard.cpp | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/src/devices/machine/gmboard.cpp b/src/devices/machine/gmboard.cpp index b0af97d6795..7a95344d703 100644 --- a/src/devices/machine/gmboard.cpp +++ b/src/devices/machine/gmboard.cpp @@ -31,7 +31,8 @@ TODO: #include "emu.h" #include "gmboard.h" -#define LOG_DRIFT (1 << 1U) +#define LOG_MAGNET (1 << 1U) +#define LOG_DRIFT (2 << 1U) //#define VERBOSE (LOG_DRIFT) //#define LOG_OUTPUT_FUNC osd_printf_info @@ -215,6 +216,7 @@ void gmboard_device::magnet_w(int state) int mx = dx + 0.5; int my = dy + 0.5; + int gx = mx, gy = my; // convert motors position into board coordinates int x = mx / 4 - 2; @@ -227,6 +229,8 @@ void gmboard_device::magnet_w(int state) if (state) { + bool found = false; + if (valid_pos) { // pick up piece, unless it was picked up by the user @@ -237,41 +241,62 @@ void gmboard_device::magnet_w(int state) if (m_piece_hand != 0) { + found = true; m_board->write_piece(x, y, 0); m_board->refresh(); } } } - else + + if (!found) { - // pick up piece from internal pieces map - m_piece_hand = m_pieces_map[my][mx]; - m_pieces_map[my][mx] = 0; + int count = 0; + + // check surrounding area for piece + for (int sy = my - 1; sy <= my + 1; sy++) + for (int sx = mx - 1; sx <= mx + 1; sx++) + if (sy >= 0 && sx >= 0 && m_pieces_map[sy][sx] != 0) + { + gx = sx; gy = sy; + m_piece_hand = m_pieces_map[sy][sx]; + m_pieces_map[sy][sx] = 0; + count++; + } + + // more than one piece found (shouldn't happen) + if (count > 1) + popmessage("Internal collision!"); } } - else if (m_piece_hand != 0) + + if (m_piece_hand) { - if (valid_pos) + LOGMASKED(LOG_MAGNET, "%s piece %2d @ %2d,%2d (%2d,%2d)\n", state ? "grab" : "drop", m_piece_hand, x, y, gx, gy); + + if (!state) { - // collision with piece on board (user interference) - if (m_board->read_piece(x, y) != 0) - popmessage("Collision at %c%d!", x + 'A', y + 1); - else + if (valid_pos) { - m_board->write_piece(x, y, m_piece_hand); - m_board->refresh(); + // collision with piece on board (user interference) + if (m_board->read_piece(x, y) != 0) + popmessage("Collision at %c%d!", x + 'A', y + 1); + else + { + m_board->write_piece(x, y, m_piece_hand); + m_board->refresh(); + } } - } - else - { - // collision with internal pieces map (shouldn't happen) - if (m_pieces_map[my][mx] != 0) - popmessage("Internal collision!"); else - m_pieces_map[my][mx] = m_piece_hand; - } + { + // collision with internal pieces map (shouldn't happen) + if (m_pieces_map[my][mx] != 0) + popmessage("Internal collision!"); + else + m_pieces_map[my][mx] = m_piece_hand; + } - m_piece_hand = 0; + m_piece_hand = 0; + } } } |
