fphantom,robotadv: small refactor to picking up piece

This commit is contained in:
hap 2023-09-03 10:37:25 +02:00
parent df6b878ca2
commit 7a9a815a83
3 changed files with 20 additions and 14 deletions

View file

@ -265,15 +265,16 @@ void phantom_state::update_pieces_position(int state)
x += 12;
// check if the magnet is in the center of a square
bool valid_pos = ((m_hmotor_pos & 0x0f) > 0 && (m_hmotor_pos & 0x0f) <= 7) && ((m_vmotor_pos & 0x0f) > 8 && (m_vmotor_pos & 0x0f) <= 0xf);
const bool valid_pos = ((m_hmotor_pos & 0x0f) > 0 && (m_hmotor_pos & 0x0f) <= 7) && ((m_vmotor_pos & 0x0f) > 8 && (m_vmotor_pos & 0x0f) <= 0xf);
if (state)
{
if (valid_pos)
{
// pick up piece, unless it was picked up by the user
int pos = (y << 4 & 0xf0) | (x & 0x0f);
const int pos = (y << 4 & 0xf0) | (x & 0x0f);
if (pos != m_board->get_handpos())
{
m_piece_hand = m_board->read_piece(x, y);
if (m_piece_hand != 0)
@ -282,6 +283,7 @@ void phantom_state::update_pieces_position(int state)
m_board->refresh();
}
}
}
else
{
int count = 0;

View file

@ -20,6 +20,8 @@ noticeable on the 2nd level.
--------------------------------------------------------------------------------
PCB notes:
Bottom board:
What appeared to be a cpu socket was a passthru to the top board.
4 other smaller chip sockets also passed thru to the top.

View file

@ -6,7 +6,7 @@ Novag Chess Robot Adversary, chess computer with robotic arm. The chess engine
is MyChess by David Kittinger, just like the one in Novag Savant.
Hardware notes:
- PCB label: PACIFIC MICROELECTRONICS GROUP, 743-279A/280A/281A
- PCB label: GOODNIGHT DESIGN, PACIFIC MICROELECTRONICS GROUP, 743-279A/280A/281A
- Zilog Z8400B PS, 6 MHz XTAL
- 40KB ROM (4*2764 or equivalent, 4*MSM2716AS) + 1 socket for expansion
- 5KB RAM (8*TMM314APL-1, 2*TC5514AP-8 battery-backed)
@ -278,8 +278,9 @@ void robotadv_state::update_piece(double x, double y)
return;
// pick up piece, unless it was picked up by the user
int pos = (by << 4 & 0xf0) | (bx & 0x0f);
const int pos = (by << 4 & 0xf0) | (bx & 0x0f);
if (pos != m_board->get_handpos())
{
m_piece_hand = m_board->read_piece(bx, by);
if (m_piece_hand != 0)
@ -289,6 +290,7 @@ void robotadv_state::update_piece(double x, double y)
}
}
}
}
void robotadv_state::refresh()
{
@ -309,8 +311,8 @@ void robotadv_state::refresh()
// output claw position
const int open = (m_limits & 1) ? 0x800 : 0; // put open state on x bit 11
m_out_pos[0] = int((x + 15.0) * 50.0) | open;
m_out_pos[1] = int((y + 15.0) * 50.0);
m_out_pos[0] = int((x + 15.0) * 50.0 + 0.5) | open;
m_out_pos[1] = int((y + 15.0) * 50.0 + 0.5);
}