mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
phantom/emirage/robotadv: fix piece positions when board is rotated
This commit is contained in:
parent
0c166ae47e
commit
64a60aa0fb
11 changed files with 79 additions and 27 deletions
|
@ -154,7 +154,7 @@ void sensorboard_device::device_start()
|
|||
save_item(NAME(m_sensordelay));
|
||||
}
|
||||
|
||||
void sensorboard_device::preset_chess(int state)
|
||||
void sensorboard_device::preset_chess(u8 data)
|
||||
{
|
||||
// set chessboard start position
|
||||
|
||||
|
@ -611,12 +611,13 @@ INPUT_CHANGED_MEMBER(sensorboard_device::ui_init)
|
|||
cancel_hand();
|
||||
|
||||
m_clear_cb(init ? 0 : 1);
|
||||
u8 rotate = m_inp_ui->read() & 2;
|
||||
|
||||
if (init)
|
||||
m_init_cb(1);
|
||||
m_init_cb(1 | rotate);
|
||||
|
||||
// rotate pieces
|
||||
if (m_inp_ui->read() & 2)
|
||||
if (rotate)
|
||||
{
|
||||
u8 tempstate[0x100];
|
||||
for (int y = 0; y < m_height; y++)
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
auto spawn_cb() { return m_spawn_cb.bind(); } // spawnpoint/piece = offset, retval = new piece id
|
||||
auto output_cb() { return m_output_cb.bind(); } // pos = offset(A8 for ui/board, A9 for count), id = data
|
||||
|
||||
void preset_chess(int state = 0); // init_cb() preset for chessboards
|
||||
void preset_chess(u8 data = 0); // init_cb() preset for chessboards
|
||||
|
||||
// read sensors
|
||||
u8 read_sensor(u8 x, u8 y);
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
// handle board state
|
||||
u8 read_piece(u8 x, u8 y) { return m_curstate[y * m_width + x]; }
|
||||
void write_piece(u8 x, u8 y, u8 id) { m_curstate[y * m_width + x] = id; }
|
||||
void clear_board(int state = 0) { memset(m_curstate, 0, sizeof(m_curstate)); } // default clear_cb()
|
||||
void clear_board(u8 data = 0) { memset(m_curstate, 0, sizeof(m_curstate)); } // default clear_cb()
|
||||
|
||||
void refresh();
|
||||
void cancel_sensor();
|
||||
|
@ -104,8 +104,8 @@ private:
|
|||
required_ioport m_inp_ui;
|
||||
required_ioport m_inp_conf;
|
||||
|
||||
devcb_write_line m_clear_cb;
|
||||
devcb_write_line m_init_cb;
|
||||
devcb_write8 m_clear_cb;
|
||||
devcb_write8 m_init_cb;
|
||||
devcb_read8 m_remove_cb;
|
||||
devcb_read8 m_sensor_cb;
|
||||
devcb_read8 m_spawn_cb;
|
||||
|
|
|
@ -140,7 +140,7 @@ void tasc_sb30_device::device_add_mconfig(machine_config &config)
|
|||
// sensorboard_device interface
|
||||
//-------------------------------------------------
|
||||
|
||||
void tasc_sb30_device::init_cb(int state)
|
||||
void tasc_sb30_device::init_cb(u8 data)
|
||||
{
|
||||
m_board->clear_board();
|
||||
m_board->write_piece(0, 0, SB30_WHITE_ROOK1);
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
void update_output();
|
||||
bool piece_available(u8 id);
|
||||
void init_cb(int state);
|
||||
void init_cb(u8 data);
|
||||
u8 spawn_cb(offs_t offset);
|
||||
|
||||
// i/o lines
|
||||
|
|
|
@ -110,7 +110,7 @@ private:
|
|||
void main_map(address_map &map);
|
||||
void v2_map(address_map &map);
|
||||
|
||||
void init_board(int state);
|
||||
void init_board(u8 data);
|
||||
DECLARE_DEVICE_IMAGE_LOAD_MEMBER(cart_load);
|
||||
|
||||
void update_display();
|
||||
|
@ -147,7 +147,7 @@ void arb_state::update_reset()
|
|||
|
||||
// sensorboard
|
||||
|
||||
void arb_state::init_board(int state)
|
||||
void arb_state::init_board(u8 data)
|
||||
{
|
||||
// different board setup for checkers
|
||||
if (m_altboard)
|
||||
|
|
|
@ -107,7 +107,8 @@ private:
|
|||
attotime m_motor_remain[2];
|
||||
emu_timer *m_motor_timer[2];
|
||||
|
||||
void clear_board(int state);
|
||||
void init_board(u8 data);
|
||||
void clear_board(u8 data);
|
||||
void init_motors();
|
||||
|
||||
void get_scaled_pos(double *x, double *y);
|
||||
|
@ -168,7 +169,23 @@ void mirage_state::machine_reset()
|
|||
output_magnet_pos();
|
||||
}
|
||||
|
||||
void mirage_state::clear_board(int state)
|
||||
void mirage_state::init_board(u8 data)
|
||||
{
|
||||
m_board->preset_chess(data);
|
||||
|
||||
// reposition pieces if board will be rotated
|
||||
if (data & 2)
|
||||
{
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = 7; x >= 0; x--)
|
||||
{
|
||||
m_board->write_piece(x + 4, y, m_board->read_piece(x, y));
|
||||
m_board->write_piece(x, y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mirage_state::clear_board(u8 data)
|
||||
{
|
||||
memset(m_pieces_map, 0, sizeof(m_pieces_map));
|
||||
m_piece_hand = 0;
|
||||
|
@ -563,7 +580,7 @@ void mirage_state::mirage(machine_config &config)
|
|||
SENSORBOARD(config, m_board).set_type(sensorboard_device::BUTTONS);
|
||||
m_board->set_size(8+4, 8);
|
||||
m_board->clear_cb().set(FUNC(mirage_state::clear_board));
|
||||
m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess));
|
||||
m_board->init_cb().set(FUNC(mirage_state::init_board));
|
||||
m_board->set_delay(attotime::from_msec(150));
|
||||
//m_board->set_nvram_enable(true);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
|
||||
void main_map(address_map &map);
|
||||
|
||||
void init_board(int state);
|
||||
void init_board(u8 data);
|
||||
u8 read_board_row(u8 row);
|
||||
|
||||
// I/O handlers
|
||||
|
@ -91,7 +91,7 @@ void dsc_state::machine_start()
|
|||
Sensorboard
|
||||
*******************************************************************************/
|
||||
|
||||
void dsc_state::init_board(int state)
|
||||
void dsc_state::init_board(u8 data)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
|
|
|
@ -124,7 +124,8 @@ protected:
|
|||
u8 hmotor_ff_clear_r();
|
||||
u8 vmotor_ff_clear_r();
|
||||
|
||||
void clear_board(int state);
|
||||
void init_board(u8 data);
|
||||
void clear_board(u8 data);
|
||||
void check_rotation();
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(motors_timer);
|
||||
void update_pieces_position(int state);
|
||||
|
@ -161,7 +162,23 @@ void phantom_state::machine_reset()
|
|||
output_magnet_pos();
|
||||
}
|
||||
|
||||
void phantom_state::clear_board(int state)
|
||||
void phantom_state::init_board(u8 data)
|
||||
{
|
||||
m_board->preset_chess(data);
|
||||
|
||||
// reposition pieces if board will be rotated
|
||||
if (data & 2)
|
||||
{
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = 7; x >= 0; x--)
|
||||
{
|
||||
m_board->write_piece(x + 4, y, m_board->read_piece(x, y));
|
||||
m_board->write_piece(x, y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void phantom_state::clear_board(u8 data)
|
||||
{
|
||||
memset(m_pieces_map, 0, sizeof(m_pieces_map));
|
||||
m_piece_hand = 0;
|
||||
|
@ -606,7 +623,7 @@ void phantom_state::phantom(machine_config &config)
|
|||
SENSORBOARD(config, m_board).set_type(sensorboard_device::BUTTONS);
|
||||
m_board->set_size(8+4, 8);
|
||||
m_board->clear_cb().set(FUNC(phantom_state::clear_board));
|
||||
m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess));
|
||||
m_board->init_cb().set(FUNC(phantom_state::init_board));
|
||||
m_board->set_delay(attotime::from_msec(100));
|
||||
|
||||
// video hardware
|
||||
|
|
|
@ -104,7 +104,8 @@ private:
|
|||
u8 counters_r();
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(refresh_timer) { refresh(); }
|
||||
void clear_board(int state);
|
||||
void init_board(u8 data);
|
||||
void clear_board(u8 data);
|
||||
void refresh();
|
||||
void update_counters();
|
||||
void update_limits();
|
||||
|
@ -142,7 +143,23 @@ void robotadv_state::machine_reset()
|
|||
refresh();
|
||||
}
|
||||
|
||||
void robotadv_state::clear_board(int state)
|
||||
void robotadv_state::init_board(u8 data)
|
||||
{
|
||||
m_board->preset_chess(data);
|
||||
|
||||
// reposition pieces if board will be rotated
|
||||
if (data & 2)
|
||||
{
|
||||
for (int y = 0; y < 8; y++)
|
||||
for (int x = 7; x >= 0; x--)
|
||||
{
|
||||
m_board->write_piece(x + 4, y, m_board->read_piece(x, y));
|
||||
m_board->write_piece(x, y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void robotadv_state::clear_board(u8 data)
|
||||
{
|
||||
m_piece_hand = 0;
|
||||
m_board->clear_board();
|
||||
|
@ -514,7 +531,7 @@ void robotadv_state::robotadv(machine_config &config)
|
|||
SENSORBOARD(config, m_board).set_type(sensorboard_device::MAGNETS);
|
||||
m_board->set_size(8+4, 8);
|
||||
m_board->clear_cb().set(FUNC(robotadv_state::clear_board));
|
||||
m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess));
|
||||
m_board->init_cb().set(FUNC(robotadv_state::init_board));
|
||||
m_board->set_delay(attotime::from_msec(150));
|
||||
m_board->set_nvram_enable(true);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ private:
|
|||
void init_backgammon();
|
||||
void init_jacquet();
|
||||
void init_plakoto();
|
||||
void board_init_cb(int state);
|
||||
void board_init_cb(u8 data);
|
||||
u8 board_spawn_cb(offs_t offset);
|
||||
u8 board_remove_cb();
|
||||
u8 board_sensor_cb(offs_t offset);
|
||||
|
@ -197,9 +197,9 @@ INPUT_CHANGED_MEMBER(ecbackg_state::init_board)
|
|||
m_board->refresh();
|
||||
}
|
||||
|
||||
void ecbackg_state::board_init_cb(int state)
|
||||
void ecbackg_state::board_init_cb(u8 data)
|
||||
{
|
||||
if (!state)
|
||||
if (~data & 1)
|
||||
init_backgammon();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ private:
|
|||
u16 m_led_data[2] = { };
|
||||
bool m_enable_reset = false;
|
||||
|
||||
void init_board(int state);
|
||||
void init_board(u8 data);
|
||||
|
||||
// I/O handlers
|
||||
void update_display();
|
||||
|
@ -107,7 +107,7 @@ void edames_state::machine_start()
|
|||
save_item(NAME(m_enable_reset));
|
||||
}
|
||||
|
||||
void edames_state::init_board(int state)
|
||||
void edames_state::init_board(u8 data)
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue