Removed code from Ralf Schaefer and demoted drivers to skeleton and not working (nw)

This commit is contained in:
Miodrag Milanovic 2016-03-03 21:15:37 +01:00
parent afb2d8e0ef
commit 9a8c689960
5 changed files with 17 additions and 1510 deletions

View File

@ -1777,8 +1777,6 @@ files {
MAME_DIR .. "src/mame/drivers/mephisto.cpp",
MAME_DIR .. "src/mame/drivers/mmodular.cpp",
MAME_DIR .. "src/mame/drivers/stratos.cpp",
MAME_DIR .. "src/mame/machine/mboard.cpp",
MAME_DIR .. "src/mame/includes/mboard.h",
}
createMESSProjects(_target, _subtarget, "hitachi")

View File

@ -1,5 +1,5 @@
// license:???
// copyright-holders:Dirk Verwiebe, Robbbert, Cowering, Ralf Schaefer
// license:BSD-3-Clause
// copyright-holders:Dirk Verwiebe, Robbbert, Cowering
/***************************************************************************
Mephisto Glasgow 3 S chess computer
Dirk V.
@ -39,27 +39,19 @@ How to play (quick guide)
Note about clickable artwork: You need to be running in windowed mode;
and you need to use newui.
R.Schaefer Oct 2010
1. everything concerning chessboard moved to machine mboard
2. Border pieces added. This allow setting up and repair chess positons
3. chessboard added for Amsterdam, Dallas 16 Bit, Dallas 32 Bit, Roma 32 Bit
4. Save states added.
***************************************************************************/
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "glasgow.lh"
#include "sound/beep.h"
#include "includes/mboard.h"
class glasgow_state : public mboard_state
class glasgow_state : public driver_device
{
public:
glasgow_state(const machine_config &mconfig, device_type type, const char *tag)
: mboard_state(mconfig, type, tag),
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_beep(*this, "beeper"),
m_line0(*this, "LINE0"),
@ -121,7 +113,6 @@ WRITE16_MEMBER( glasgow_state::glasgow_lcd_flag_w )
else
{
m_led7 = 0;
mboard_key_selector = 1;
}
}
@ -129,28 +120,17 @@ READ16_MEMBER( glasgow_state::glasgow_keys_r )
{
UINT8 data = 0xff;
/* See if any keys pressed */
data = 3;
if (mboard_key_select == m_line0->read())
data &= 1;
if (mboard_key_select == m_line1->read())
data &= 2;
return data << 8;
}
WRITE16_MEMBER( glasgow_state::glasgow_keys_w )
{
mboard_key_select = data >> 8;
}
WRITE16_MEMBER( glasgow_state::write_lcd )
{
UINT8 lcd_data = data >> 8;
output().set_digit_value(m_lcd_shift_counter, mboard_lcd_invert & 1 ? lcd_data^0xff : lcd_data);
m_lcd_shift_counter--;
m_lcd_shift_counter &= 3;
logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
@ -159,12 +139,10 @@ WRITE16_MEMBER( glasgow_state::write_lcd )
WRITE16_MEMBER( glasgow_state::write_lcd_flag )
{
// UINT8 lcd_flag;
mboard_lcd_invert = 0;
// lcd_flag=data >> 8;
//m_beep->set_state((data >> 8) & 1 ? 1 : 0);
if ((data >> 8) == 0)
{
mboard_key_selector = 1;
m_led7 = 0;
}
else
@ -191,16 +169,7 @@ WRITE16_MEMBER( glasgow_state::write_irq_flag )
READ16_MEMBER( glasgow_state::read_newkeys16 ) //Amsterdam, Roma
{
UINT16 data;
if (mboard_key_selector == 0)
data = m_line0->read();
else
data = m_line1->read();
logerror("read Keyboard Offset = %x Data = %x Select = %x \n", offset, data, mboard_key_selector);
data <<= 8;
return data ;
return 0;
}
@ -220,9 +189,6 @@ READ16_MEMBER(glasgow_state::read_test)
WRITE32_MEMBER( glasgow_state::write_lcd32 )
{
UINT8 lcd_data = data >> 8;
output().set_digit_value(m_lcd_shift_counter, mboard_lcd_invert & 1 ? lcd_data^0xff : lcd_data);
m_lcd_shift_counter--;
m_lcd_shift_counter &= 3;
//logerror("LCD Offset = %d Data = %x \n ", offset, lcd_data);
@ -232,11 +198,8 @@ WRITE32_MEMBER( glasgow_state::write_lcd_flag32 )
{
// UINT8 lcd_flag = data >> 24;
mboard_lcd_invert = 0;
if ((data >> 24) == 0)
{
mboard_key_selector = 1;
m_led7 = 0;
}
else
@ -254,17 +217,7 @@ WRITE32_MEMBER( glasgow_state::write_lcd_flag32 )
READ32_MEMBER( glasgow_state::read_newkeys32 ) // Dallas 32, Roma 32
{
UINT32 data;
if (mboard_key_selector == 0)
data = m_line0->read();
else
data = m_line1->read();
//if (mboard_key_selector == 1) data = m_line0->read(); else data = 0;
if(data)
logerror("read Keyboard Offset = %x Data = %x\n", offset, data);
data <<= 24;
return data ;
return 0;
}
#ifdef UNUSED_FUNCTION
@ -295,28 +248,20 @@ TIMER_DEVICE_CALLBACK_MEMBER(glasgow_state::update_nmi32)
void glasgow_state::machine_start()
{
mboard_key_selector = 0;
m_irq_flag = 0;
m_lcd_shift_counter = 3;
mboard_savestate_register();
}
MACHINE_START_MEMBER(glasgow_state,dallas32)
{
m_lcd_shift_counter = 3;
mboard_savestate_register();
}
void glasgow_state::machine_reset()
{
m_lcd_shift_counter = 3;
mboard_set_border_pieces();
mboard_set_board();
}
static ADDRESS_MAP_START(glasgow_mem, AS_PROGRAM, 16, glasgow_state)
@ -325,8 +270,6 @@ static ADDRESS_MAP_START(glasgow_mem, AS_PROGRAM, 16, glasgow_state)
AM_RANGE(0x00010000, 0x00010001) AM_WRITE(glasgow_lcd_w)
AM_RANGE(0x00010002, 0x00010003) AM_READWRITE(glasgow_keys_r,glasgow_keys_w)
AM_RANGE(0x00010004, 0x00010005) AM_WRITE(glasgow_lcd_flag_w)
AM_RANGE(0x00010006, 0x00010007) AM_READWRITE(mboard_read_board_16,mboard_write_LED_16)
AM_RANGE(0x00010008, 0x00010009) AM_WRITE(mboard_write_board_16)
AM_RANGE(0x0001c000, 0x0001ffff) AM_RAM // 16KB
ADDRESS_MAP_END
@ -337,10 +280,7 @@ static ADDRESS_MAP_START(amsterd_mem, AS_PROGRAM, 16, glasgow_state)
AM_RANGE(0x00800002, 0x00800003) AM_WRITE(write_lcd)
AM_RANGE(0x00800008, 0x00800009) AM_WRITE(write_lcd_flag)
AM_RANGE(0x00800004, 0x00800005) AM_WRITE(write_irq_flag)
AM_RANGE(0x00800010, 0x00800011) AM_WRITE(mboard_write_board_16)
AM_RANGE(0x00800020, 0x00800021) AM_READ(mboard_read_board_16)
AM_RANGE(0x00800040, 0x00800041) AM_READ(read_newkeys16)
AM_RANGE(0x00800088, 0x00800089) AM_WRITE(mboard_write_LED_16)
AM_RANGE(0x00ffc000, 0x00ffffff) AM_RAM // 16KB
ADDRESS_MAP_END
@ -352,10 +292,7 @@ static ADDRESS_MAP_START(dallas32_mem, AS_PROGRAM, 32, glasgow_state)
AM_RANGE(0x00800000, 0x00800003) AM_WRITE(write_lcd32)
AM_RANGE(0x00800004, 0x00800007) AM_WRITE(write_beeper32)
AM_RANGE(0x00800008, 0x0080000B) AM_WRITE(write_lcd_flag32)
AM_RANGE(0x00800010, 0x00800013) AM_WRITE(mboard_write_board_32)
AM_RANGE(0x00800020, 0x00800023) AM_READ(mboard_read_board_32)
AM_RANGE(0x00800040, 0x00800043) AM_READ(read_newkeys32)
AM_RANGE(0x00800088, 0x0080008b) AM_WRITE(mboard_write_LED_32)
ADDRESS_MAP_END
static INPUT_PORTS_START( new_keyboard ) //Amsterdam, Dallas 32, Roma, Roma 32
@ -407,12 +344,10 @@ INPUT_PORTS_EXTERN( chessboard);
static INPUT_PORTS_START( oldkeys )
PORT_INCLUDE( old_keyboard )
PORT_INCLUDE( chessboard )
INPUT_PORTS_END
static INPUT_PORTS_START( newkeys )
PORT_INCLUDE( new_keyboard )
PORT_INCLUDE( chessboard )
INPUT_PORTS_END
static MACHINE_CONFIG_START( glasgow, glasgow_state )
@ -424,7 +359,6 @@ static MACHINE_CONFIG_START( glasgow, glasgow_state )
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_TIMER_DRIVER_ADD_PERIODIC("nmi_timer", glasgow_state, update_nmi, attotime::from_hz(50))
MCFG_TIMER_DRIVER_ADD_PERIODIC("artwork_timer", glasgow_state, mboard_update_artwork, attotime::from_hz(100))
MACHINE_CONFIG_END
static MACHINE_CONFIG_DERIVED( amsterd, glasgow )
@ -500,10 +434,10 @@ ROM_END
***************************************************************************/
/* YEAR, NAME, PARENT, COMPAT, MACHINE, INPUT, INIT, COMPANY, FULLNAME, FLAGS */
CONS( 1984, glasgow, 0, 0, glasgow, oldkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto III S Glasgow", MACHINE_SUPPORTS_SAVE)
CONS( 1984, amsterd, 0, 0, amsterd, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Amsterdam", MACHINE_SUPPORTS_SAVE)
CONS( 1984, dallas, glasgow, 0, glasgow, oldkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas", MACHINE_SUPPORTS_SAVE)
CONS( 1984, glasgow, 0, 0, glasgow, oldkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto III S Glasgow", MACHINE_NOT_WORKING)
CONS( 1984, amsterd, 0, 0, amsterd, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Amsterdam", MACHINE_NOT_WORKING)
CONS( 1984, dallas, glasgow, 0, glasgow, oldkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas", MACHINE_NOT_WORKING)
CONS( 1984, roma, amsterd, 0, glasgow, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Roma", MACHINE_NOT_WORKING)
CONS( 1984, dallas32, amsterd, 0, dallas32, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas 32 Bit", MACHINE_SUPPORTS_SAVE)
CONS( 1984, roma32, amsterd, 0, dallas32, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Roma 32 Bit", MACHINE_SUPPORTS_SAVE)
CONS( 1984, dallas16, amsterd, 0, amsterd, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas 16 Bit", MACHINE_SUPPORTS_SAVE)
CONS( 1984, dallas32, amsterd, 0, dallas32, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas 32 Bit", MACHINE_NOT_WORKING)
CONS( 1984, roma32, amsterd, 0, dallas32, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Roma 32 Bit", MACHINE_NOT_WORKING)
CONS( 1984, dallas16, amsterd, 0, amsterd, newkeys, driver_device, 0, "Hegener & Glaser Muenchen", "Mephisto Dallas 16 Bit", MACHINE_NOT_WORKING)

View File

@ -1,9 +1,7 @@
// license:???
// copyright-holders:Ralf Schaefer, Robbbert
// license:BSD-3-Clause
// copyright-holders:Robbbert
/******************************************************************************
Novag SuperConstellation Chess Computer
2010 R. Schaefer
CPU 6502
Clock 4 MHz
@ -30,756 +28,25 @@ public:
supercon_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_beep(*this, "beeper"),
m_b_white(*this, "B_WHITE"),
m_b_black(*this, "B_BLACK"),
m_b_clr(*this, "B_CLR"),
m_status_1(*this, "STATUS_1"),
m_status_2(*this, "STATUS_2"),
m_status_3(*this, "STATUS_3"),
m_status_4(*this, "STATUS_4"),
m_status_5(*this, "STATUS_5"),
m_status_6(*this, "STATUS_6"),
m_status_7(*this, "STATUS_7"),
m_status_8(*this, "STATUS_8"),
m_board_1(*this, "BOARD_1"),
m_board_2(*this, "BOARD_2"),
m_board_3(*this, "BOARD_3"),
m_board_4(*this, "BOARD_4"),
m_board_5(*this, "BOARD_5"),
m_board_6(*this, "BOARD_6"),
m_board_7(*this, "BOARD_7"),
m_board_8(*this, "BOARD_8") { }
m_beep(*this, "beeper")
{ }
required_device<cpu_device> m_maincpu;
required_device<beep_device> m_beep;
DECLARE_READ8_MEMBER(supercon_port1_r);
DECLARE_READ8_MEMBER(supercon_port2_r);
DECLARE_READ8_MEMBER(supercon_port3_r);
DECLARE_READ8_MEMBER(supercon_port4_r);
DECLARE_WRITE8_MEMBER(supercon_port1_w);
DECLARE_WRITE8_MEMBER(supercon_port2_w);
DECLARE_WRITE8_MEMBER(supercon_port3_w);
DECLARE_WRITE8_MEMBER(supercon_port4_w);
static const UINT8 m_border_pieces[12];
emu_timer* m_timer_update_irq;
emu_timer* m_timer_mouse_click;
int m_emu_started;
int m_moving_piece;
UINT8 m_data_1E00;
UINT8 m_data_1F00;
UINT8 m_LED_18;
UINT8 m_LED_AH;
UINT8 m_LED_ST;
UINT8 *m_last_LED;
UINT8 m_last_LED_value;
int m_led_update;
int m_remove_led_flag;
int m_selecting;
int m_save_key_data;
attotime m_wait_time;
int *m_current_field;
int m_confirm_board_click;
int m_board[64];
int m_save_board[64];
void set_board();
void set_pieces();
void set_border_pieces();
void clear_pieces();
void update_leds();
virtual void machine_reset() override;
DECLARE_DRIVER_INIT(supercon);
virtual void machine_start() override;
TIMER_CALLBACK_MEMBER(mouse_click);
TIMER_CALLBACK_MEMBER(update_irq);
TIMER_DEVICE_CALLBACK_MEMBER(update_artwork);
void board_presave();
void board_postload();
protected:
required_ioport m_b_white;
required_ioport m_b_black;
required_ioport m_b_clr;
required_ioport m_status_1;
required_ioport m_status_2;
required_ioport m_status_3;
required_ioport m_status_4;
required_ioport m_status_5;
required_ioport m_status_6;
required_ioport m_status_7;
required_ioport m_status_8;
required_ioport m_board_1;
required_ioport m_board_2;
required_ioport m_board_3;
required_ioport m_board_4;
required_ioport m_board_5;
required_ioport m_board_6;
required_ioport m_board_7;
required_ioport m_board_8;
void mouse_update();
int get_first_cleared_bit(UINT8 data);
int get_first_bit(UINT8 data);
};
#define VERBOSE 0
#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
enum
{
EM, /*No piece*/
BP,
BN,
BB,
BR,
BQ,
BK,
WP,
WN,
WB,
WR,
WQ,
WK
};
#define LED_LINE_AH 0x10
#define LED_LINE_ST 0x20
#define LED_LINE_18 0x40
#define MAIN_CLOCK 4000000 /* 4 MHz */
#define NOT_VALID 99
#define NO_ACTION 0
#define TAKE 1
#define SET 2
/* artwork board */
const UINT8 supercon_state::m_border_pieces[12] = {WK,WQ,WR,WB,WN,WP,BK,BQ,BR,BB,BN,BP};
void supercon_state::set_board()
{
static const int start_board[64] = {
BR, BN, BB, BQ, BK, BB, BN, BR,
BP, BP, BP, BP, BP, BP, BP, BP,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
WP, WP, WP, WP, WP, WP, WP, WP,
WR, WN, WB, WQ, WK, WB, WN, WR };
for (UINT8 i=0; i<64; i++)
m_board[i]=start_board[i];
}
void supercon_state::set_pieces()
{
int i;
for (i=0;i<64;i++)
output().set_indexed_value("P", i, m_board[i]);
}
void supercon_state::set_border_pieces()
{
UINT8 i;
for (i=0;i<12;i++)
output().set_indexed_value("Q", i, m_border_pieces[i]);
}
void supercon_state::clear_pieces()
{
int i;
for (i=0;i<64;i++)
{
output().set_indexed_value("P", i, EM);
m_board[i]=EM;
}
}
int supercon_state::get_first_cleared_bit(UINT8 data)
{
int i;
for (i = 0; i < 8; i++)
if (!BIT(data, i))
return i;
return NOT_VALID;
}
int supercon_state::get_first_bit(UINT8 data)
{
int i;
for (i = 0; i < 8; i++)
if (BIT(data, i))
return i;
return NOT_VALID;
}
void supercon_state::update_leds()
{
int i;
for (i = 0; i < 8; i++)
{
if (BIT(m_LED_18, i))
output().set_led_value(i + 1, 1);
else
output().set_led_value(i + 1, 0);
if (BIT(m_LED_AH, i))
output().set_led_value(i + 9, 1);
else
output().set_led_value(i + 9, 0);
if (BIT(m_LED_ST, i))
output().set_led_value(i + 17, 1);
else
output().set_led_value(i + 17, 0);
}
}
void supercon_state::mouse_update()
{
UINT8 port_input; // m_left;
int i;
/* border pieces and moving piece */
port_input = m_b_white->read();
if (port_input)
{
i = get_first_bit(port_input);
m_moving_piece = m_border_pieces[i];
output().set_value("MOVING", m_moving_piece);
return;
}
port_input = m_b_black->read();
if (port_input)
{
i = get_first_bit(port_input);
m_moving_piece = m_border_pieces[6+i];
output().set_value("MOVING", m_moving_piece);
return;
}
port_input = m_b_clr->read();
if (port_input)
{
if (m_moving_piece)
{
m_moving_piece=0;
output().set_value("MOVING", m_moving_piece);
return;
}
}
}
/* Driver initialization */
DRIVER_INIT_MEMBER(supercon_state,supercon)
{
m_LED_18=0;
m_LED_AH=0;
m_LED_ST=0;
m_wait_time = attotime::from_hz(4);
m_save_key_data = 0xff;
m_moving_piece=0;
}
/* Read 1C000 */
READ8_MEMBER( supercon_state::supercon_port1_r )
{
LOG(("Read from %04x \n",0x1C00));
return 0xff;
}
/* Read 1D000 */
READ8_MEMBER( supercon_state::supercon_port2_r )
{
LOG(("Read from %04x \n",0x1D00));
return 0xff;
}
/* Read 1E00 */
READ8_MEMBER( supercon_state::supercon_port3_r )
{
int i;
UINT8 key_data=0;
static const char *const status_lines[8] =
{ "STATUS_1", "STATUS_2", "STATUS_3", "STATUS_4", "STATUS_5", "STATUS_6", "STATUS_7", "STATUS_8" };
LOG(("Read from %04x \n",0x1E00));
/* remove last bit (only if it was not already set) */
if ( m_data_1F00 & LED_LINE_AH )
{
if (m_last_LED_value != m_LED_AH)
m_LED_AH=m_LED_AH & ~m_data_1E00;
}
else if ( m_data_1F00 & LED_LINE_ST)
{
if (m_last_LED_value != m_LED_ST)
m_LED_ST=m_LED_ST & ~m_data_1E00;
}
else if ( m_data_1F00 & LED_LINE_18 )
{
if (m_last_LED_value != m_LED_18)
m_LED_18=m_LED_18 & ~m_data_1E00;
}
LOG(("LED_18 from %02x \n",m_LED_18));
LOG(("LED_AH from %02x \n",m_LED_AH));
LOG(("LED_ST from %02x \n",m_LED_ST));
if (m_led_update) /*No LED Update if Port 1C00,1D00 was read */
update_leds();
m_remove_led_flag=TRUE;
m_led_update=TRUE;
m_LED_18=0;
m_LED_AH=0;
m_LED_ST=0;
/* Start */
if (!m_emu_started)
return 0xbf;
else
m_timer_update_irq->adjust( attotime::zero, 0, attotime::from_hz(598) ); //HACK adjust timer after start ???
/* Buttons */
i=get_first_bit(m_data_1E00);
if (i==NOT_VALID)
return 0xff;
switch ( i )
{
case 0: key_data=m_status_1->read(); break;
case 1: key_data=m_status_2->read(); break;
case 2: key_data=m_status_3->read(); break;
case 3: key_data=m_status_4->read(); break;
case 4: key_data=m_status_5->read(); break;
case 5: key_data=m_status_6->read(); break;
case 6: key_data=m_status_7->read(); break;
case 7: key_data=m_status_8->read(); break;
}
if (key_data != 0xc0)
{
LOG(("%s, key_data: %02x \n",status_lines[i],key_data));
/* Button: New Game -> initialize board */
if (i==0 && key_data==0x80)
{
set_board();
set_pieces();
m_emu_started=FALSE;
}
/* Button: Clear Board -> remove all pieces */
if (i==3 && key_data==0x80)
clear_pieces();
if (key_data != 0xff )
return key_data;
}
return 0xc0;
}
/* Read Port $1F00 */
READ8_MEMBER( supercon_state::supercon_port4_r )
{
int i_18, i_AH;
UINT8 key_data = 0x00;
static const char *const board_lines[8] =
{ "BOARD_1", "BOARD_2", "BOARD_3", "BOARD_4", "BOARD_5", "BOARD_6", "BOARD_7", "BOARD_8" };
LOG(("Read from %04x \n",0x1F00));
/* Board buttons */
i_18=get_first_bit(m_data_1E00);
if (i_18==NOT_VALID)
return 0xff;
/* if a button was pressed wait til timer -timer_mouse_click- is fired */
if (m_selecting)
return m_save_key_data;
else
{
set_pieces();
output().set_value("MOVING",m_moving_piece);
}
switch ( i_18 )
{
case 0: key_data=m_board_1->read(); break;
case 1: key_data=m_board_2->read(); break;
case 2: key_data=m_board_3->read(); break;
case 3: key_data=m_board_4->read(); break;
case 4: key_data=m_board_5->read(); break;
case 5: key_data=m_board_6->read(); break;
case 6: key_data=m_board_7->read(); break;
case 7: key_data=m_board_8->read(); break;
}
if (key_data != 0xff)
{
LOG(("%s key_data: %02x \n",board_lines[i_18],key_data));
/* Only if valid data */
if (key_data)
{
/* Set or remove pieces */
i_AH=7-get_first_cleared_bit(key_data);
LOG(("Press -> AH: %d 18: %d Piece: %d\n",i_AH,i_18,m_board[i_18*8 + i_AH]););
m_current_field=&m_board[i_18*8 + i_AH];
if (m_moving_piece)
{
*m_current_field = m_moving_piece;
m_moving_piece = EM;
}
else
{
m_moving_piece = *m_current_field;
*m_current_field = EM;
}
m_selecting=TRUE; /* Flag is removed in timer -timer_mouse_click- */
m_save_key_data=key_data; /* return same key_data til flag selecting is removed */
m_timer_mouse_click->adjust(m_wait_time, 0);
return key_data;
}
}
return 0xff;
}
/* Write Port $1C00 */
WRITE8_MEMBER( supercon_state::supercon_port1_w )
{
LOG(("Write from %04x data: %02x\n",0x1C00,data));
m_led_update=FALSE;
}
/* Write Port $1D00 */
WRITE8_MEMBER( supercon_state::supercon_port2_w )
{
LOG(("Write from %04x data: %02x\n",0x1D00,data));
m_led_update=FALSE;
}
/* Write Port $1E00 */
WRITE8_MEMBER( supercon_state::supercon_port3_w )
{
if (data)
LOG(("Write from %04x data: %02x\n",0x1E00,data));
if (data)
{
m_data_1E00=data;
/* Set bits for LED's */
if ( m_data_1F00)
{
if (m_data_1F00 & LED_LINE_AH )
{
m_last_LED = &m_LED_AH; /* save last value */
m_last_LED_value = *m_last_LED;
m_LED_AH=m_LED_AH | m_data_1E00;
}
else if (m_data_1F00 & LED_LINE_ST )
{
m_last_LED = &m_LED_ST;
m_last_LED_value = *m_last_LED;
m_LED_ST=m_LED_ST | m_data_1E00;
}
else if (m_data_1F00 & LED_LINE_18)
{
m_last_LED = &m_LED_18;
m_last_LED_value = *m_last_LED;
m_LED_18=m_LED_18 | m_data_1E00;
}
}
}
// The IRQ handler writes to both 0x1E00 (1x) and 0x1F00 (2x) ports.
// Not 100% sure if this is the correct place for clearing the IRQ
// line.
m_maincpu->set_input_line(M6502_IRQ_LINE, CLEAR_LINE);
}
/* Write Port $1F00 */
WRITE8_MEMBER( supercon_state::supercon_port4_w )
{
if (data)
LOG(("Write from %04x data: %02x\n",0x1F00,data));
if (data)
m_data_1F00=data;
/* Bit 7 is set -> Buzzer on */
if ( m_data_1F00 & 0x80 )
{
m_beep->set_state(1);
m_emu_started=TRUE;
}
else
m_beep->set_state(0);
}
TIMER_CALLBACK_MEMBER(supercon_state::mouse_click)
{
m_selecting=FALSE;
}
TIMER_DEVICE_CALLBACK_MEMBER(supercon_state::update_artwork)
{
mouse_update();
}
TIMER_CALLBACK_MEMBER(supercon_state::update_irq)
{
m_maincpu->set_input_line(M6502_IRQ_LINE, ASSERT_LINE);
}
/* Save state call backs */
void supercon_state::board_presave()
{
for (int i=0;i<64;i++)
{
m_save_board[i] = m_board[i];
}
}
void supercon_state::board_postload()
{
for (int i=0;i<64;i++)
{
m_board[i] = m_save_board[i];
}
set_pieces();
}
void supercon_state::machine_start()
{
m_timer_update_irq = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supercon_state::update_irq),this));
m_timer_update_irq->adjust( attotime::zero, 0, attotime::from_hz(1000) );
m_timer_mouse_click = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(supercon_state::mouse_click),this),nullptr);
save_item(NAME(m_save_board));
machine().save().register_postload(save_prepost_delegate(FUNC(supercon_state::board_postload),this));
machine().save().register_presave(save_prepost_delegate(FUNC(supercon_state::board_presave),this));
}
void supercon_state::machine_reset()
{
set_board();
set_pieces();
set_border_pieces();
m_emu_started=FALSE;
}
/* Address maps */
static ADDRESS_MAP_START(supercon_mem, AS_PROGRAM, 8, supercon_state)
AM_RANGE( 0x0000, 0x0fff) AM_RAM
AM_RANGE( 0x2000, 0x7fff) AM_ROM
AM_RANGE( 0x8000, 0xffff) AM_ROM
AM_RANGE( 0x1C00, 0x1C00) AM_WRITE ( supercon_port1_w )
AM_RANGE( 0x1D00, 0x1D00) AM_WRITE ( supercon_port2_w )
AM_RANGE( 0x1E00, 0x1E00) AM_WRITE ( supercon_port3_w )
AM_RANGE( 0x1F00, 0x1F00) AM_WRITE ( supercon_port4_w )
AM_RANGE( 0x1C00, 0x1C00) AM_READ ( supercon_port1_r )
AM_RANGE( 0x1D00, 0x1D00) AM_READ ( supercon_port2_r )
AM_RANGE( 0x1E00, 0x1E00) AM_READ ( supercon_port3_r )
AM_RANGE( 0x1F00, 0x1F00) AM_READ ( supercon_port4_r )
ADDRESS_MAP_END
/* Input ports */
static INPUT_PORTS_START( supercon )
PORT_START("BOARD_1")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_2")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_3")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_4")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_5")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_6")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_7")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("BOARD_8")
PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_1")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_2")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_3")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_4")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_5")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_6")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_7")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("STATUS_8")
PORT_BIT(0x040, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("B_WHITE")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("B_BLACK")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("B_CLR")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
INPUT_PORTS_END
/* Machine driver */
@ -793,8 +60,6 @@ static MACHINE_CONFIG_START( supercon, supercon_state )
MCFG_SPEAKER_STANDARD_MONO("mono")
MCFG_SOUND_ADD("beeper", BEEP, 3250)
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
MCFG_TIMER_DRIVER_ADD_PERIODIC("artwork_timer", supercon_state, update_artwork, attotime::from_hz(20))
MACHINE_CONFIG_END
/* ROM definition */
@ -808,4 +73,4 @@ ROM_END
/* Driver */
/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
CONS( 1983, supercon, 0, 0, supercon, supercon, supercon_state, supercon, "Novag", "SuperConstellation", MACHINE_SUPPORTS_SAVE | MACHINE_REQUIRES_ARTWORK )
CONS( 1983, supercon, 0, 0, supercon, supercon, driver_device, 0, "Novag", "SuperConstellation", MACHINE_IS_SKELETON )

View File

@ -1,122 +0,0 @@
// license:???
// copyright-holders:Ralf Schaefer, Cowering
/**********************************************************************
Mephisto Chess Computers
**********************************************************************/
#ifndef __MBOARD_H__
#define __MBOARD_H__
/***************************************************************************
MACROS
***************************************************************************/
enum
{
EM, /*No piece*/
BP,
BN,
BB,
BR,
BQ,
BK,
WP,
WN,
WB,
WR,
WQ,
WK
};
#define NOT_VALID 99
#define BORDER_PIECE 64
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
class mboard_state : public driver_device
{
public:
mboard_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_line(*this, "LINE"),
m_line10(*this, "LINE10"),
m_b_white(*this, "B_WHITE"),
m_b_black(*this, "B_BLACK"),
m_b_buttons(*this, "B_BUTTONS"),
m_mouse_x(*this, "MOUSE_X"),
m_mouse_y(*this, "MOUSE_Y"),
m_button_l(*this, "BUTTON_L"),
m_button_r(*this, "BUTTON_R")
{ }
DECLARE_READ8_MEMBER(mboard_read_board_8);
DECLARE_WRITE8_MEMBER(mboard_write_board_8);
DECLARE_WRITE8_MEMBER(mboard_write_LED_8);
DECLARE_READ16_MEMBER(mboard_read_board_16);
DECLARE_WRITE16_MEMBER(mboard_write_board_16);
DECLARE_WRITE16_MEMBER(mboard_write_LED_16);
DECLARE_READ32_MEMBER(mboard_read_board_32);
DECLARE_WRITE32_MEMBER(mboard_write_board_32);
DECLARE_WRITE32_MEMBER(mboard_write_LED_32);
TIMER_DEVICE_CALLBACK_MEMBER( mboard_update_artwork);
void mboard_savestate_register();
void mboard_set_board();
void mboard_set_border_pieces();
inline UINT8 pos_to_num(UINT8 val);
UINT8 mboard_lcd_invert;
UINT8 mboard_key_select;
UINT8 mboard_key_selector;
int get_first_cleared_bit(UINT8 data);
private:
static const int start_board[64];
static UINT8 border_pieces[12];
int m_board[64];
int save_board[64];
UINT16 Line18_LED;
UINT16 Line18_REED;
int mouse_hold_border_piece;
UINT8 mouse_hold_from;
UINT8 mouse_hold_piece;
int read_board_flag;
int get_first_bit(UINT8 data);
UINT8 read_board();
void write_board(UINT8 data);
void write_LED(UINT8 data);
void board_presave();
void board_postload();
void clear_board();
void set_artwork();
void check_board_buttons();
public:
required_device<cpu_device> m_maincpu;
required_ioport_array<8> m_line;
required_ioport m_line10;
required_ioport m_b_white;
required_ioport m_b_black;
required_ioport m_b_buttons;
required_ioport m_mouse_x;
required_ioport m_mouse_y;
required_ioport m_button_l;
required_ioport m_button_r;
};
#endif /* __MBOARD_H__ */

View File

@ -1,568 +0,0 @@
// license:???
// copyright-holders:Ralf Schaefer, Cowering
/**********************************************************************
Mephisto Chess Computers
**********************************************************************/
#include "emu.h"
#include "includes/mboard.h"
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
#define IsPiece(x) ((m_board[x] >=1) && (m_board[x] <=12))
const int mboard_state::start_board[64] =
{
BR, BN, BB, BQ, BK, BB, BN, BR,
BP, BP, BP, BP, BP, BP, BP, BP,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
EM, EM, EM, EM, EM, EM, EM, EM,
WP, WP, WP, WP, WP, WP, WP, WP,
WR, WN, WB, WQ, WK, WB, WN, WR
};
UINT8 mboard_state::border_pieces[12] = {WK,WQ,WR,WB,WN,WP,BK,BQ,BR,BB,BN,BP,};
int mboard_state::get_first_bit(UINT8 data)
{
int i;
for (i = 0; i < 8; i++)
if (BIT(data, i))
return i;
return NOT_VALID;
}
inline UINT8 mboard_state::pos_to_num(UINT8 val)
{
switch (val)
{
case 0xfe: return 7;
case 0xfd: return 6;
case 0xfb: return 5;
case 0xf7: return 4;
case 0xef: return 3;
case 0xdf: return 2;
case 0xbf: return 1;
case 0x7f: return 0;
default: return 0xff;
}
}
int mboard_state::get_first_cleared_bit(UINT8 data)
{
int i;
for (i=0;i<8;i++)
if (!BIT(data, i))
return i;
return NOT_VALID;
}
UINT8 mboard_state::read_board()
{
UINT8 i_18, i_AH;
UINT8 data;
data = 0xff;
/*
Example board scan:
Starting postion and pawn on E2 is lifted
mask: 7f 0111 1111 Line 8
data: 0 0000 0000 all fields occupied
mask: bf 1011 1111 Line 7
data: 0 0000 0000 all fields occupied
mask: df 1101 1111 Line 6
data: ff 1111 1111 all fields empty
mask: ef 1110 1111 Line 5
data: ff 1111 1111 all fields empty
mask: f7 1111 0111 Line 4
data: ff 1111 1111 all fields empty
mask: fb 1111 1011 Line 3
data: ff 1111 1111 all fields empty
mask: fd 1111 1101 Line 2
data: 10 0001 0000 E2 is empty rest is occupied
mask: fe 1111 1110 Line 1
data: 0 0000 0000 all fields occupied
*/
/* looking for cleared bit in mask Line18_REED => current line */
if (data && Line18_REED)
{
i_18 = get_first_cleared_bit(Line18_REED);
if (i_18 == NOT_VALID)
printf("No cleared bit in mask Line18_REED!\n");
else
{
/* looking for a piece in this line and clear bit in data if found */
for (i_AH = 0; i_AH < 8; i_AH = i_AH + 1)
if (IsPiece(64 - (i_18 * 8 + 8 - i_AH)))
data &= ~(1 << i_AH); // clear bit
read_board_flag = TRUE;
}
}
return data;
}
void mboard_state::write_board(UINT8 data)
{
Line18_REED=data;
if (read_board_flag && !strcmp(machine().system().name,"glasgow") ) //HACK
Line18_LED = 0;
else
Line18_LED = data;
read_board_flag = FALSE;
if (data == 0xff)
mboard_key_selector = 0;
}
void mboard_state::write_LED(UINT8 data)
{
int i;
UINT8 i_AH, i_18;
UINT8 LED;
mboard_lcd_invert = 1;
/*
Example: turn led E2 on
mask: fd 1111 1101 Line 2
data: 10 0001 0000 Line E
*/
for (i=0; i < 64; i++) /* all LED's off */
output().set_led_value(i, 0);
if (Line18_LED)
{
for (i_AH = 0; i_AH < 8; i_AH++) /* turn LED on depending on bit masks */
{
if (BIT(data,i_AH))
{
for (i_18 = 0; i_18 < 8; i_18++)
{
LED = (i_18*8 + 8-i_AH-1);
if (!(Line18_LED & (1 << i_18))) /* cleared bit */
output().set_led_value(LED, 1);
//else
// output().set_led_value(LED, 0);
}
}
}
}
}
READ8_MEMBER(mboard_state::mboard_read_board_8)
{
UINT8 data;
data=read_board();
logerror("Read Board Port Data = %d\n ",data);
return data;
}
READ16_MEMBER(mboard_state::mboard_read_board_16)
{
UINT8 data;
data=read_board();
return data << 8;
}
READ32_MEMBER(mboard_state::mboard_read_board_32)
{
UINT8 data;
data=read_board();
return data<<24;
}
WRITE8_MEMBER(mboard_state::mboard_write_board_8)
{
write_board(data);
logerror("Write Board Port Data = %02x\n",data);
}
WRITE16_MEMBER(mboard_state::mboard_write_board_16)
{
if (data & 0xff) write_board(data);
logerror("write board 16 %08x\n",data);
write_board(data>>8);
}
WRITE32_MEMBER(mboard_state::mboard_write_board_32)
{
// data |= data << 24;
//printf("write board %08x %08x\n",offset,data);
logerror("write board 32 o: %08x d: %08x\n",offset,data);
if (offset) write_board(data);
else write_board(data>>24);
}
WRITE8_MEMBER(mboard_state::mboard_write_LED_8)
{
write_LED(data);
space.device().execute().spin_until_time(attotime::from_usec(7));
}
WRITE16_MEMBER(mboard_state::mboard_write_LED_16)
{
write_LED(data >> 8);
space.device().execute().spin_until_time(attotime::from_usec(9));
}
WRITE32_MEMBER(mboard_state::mboard_write_LED_32)
{
// data = data | data << 24;
//printf("write LED %08x %08x\n",offset,data);
if (offset) write_LED(data);
else write_LED(data >> 24);
logerror("write LED 32 o: %08x d: %08x\n",offset,data);
// space.device().execute().spin_until_time(ATTOTIME_IN_USEC(20));
}
/* save states callback */
void mboard_state::board_presave()
{
int i;
for (i=0;i<64;i++)
save_board[i]=m_board[i];
}
void mboard_state::board_postload()
{
int i;
for (i=0;i<64;i++)
m_board[i]=save_board[i];
}
void mboard_state::mboard_savestate_register()
{
save_item(NAME(save_board));
machine().save().register_postload(save_prepost_delegate(FUNC(mboard_state::board_postload),this));
machine().save().register_presave(save_prepost_delegate(FUNC(mboard_state::board_presave),this));
}
void mboard_state::mboard_set_board()
{
read_board_flag = TRUE;
int i;
for (i=0;i<64;i++)
m_board[i]=start_board[i];
}
void mboard_state::clear_board()
{
int i;
for (i=0;i<64;i++)
m_board[i]=EM;
}
void mboard_state::set_artwork()
{
int i;
for (i=0;i<64;i++)
output().set_indexed_value("P", i, m_board[i]);
}
void mboard_state::mboard_set_border_pieces()
{
int i;
for (i=0;i<12;i++)
output().set_indexed_value("Q", i, border_pieces[i]);
}
TIMER_DEVICE_CALLBACK_MEMBER(mboard_state::mboard_update_artwork )
{
check_board_buttons();
set_artwork();
mboard_set_border_pieces();
}
void mboard_state::check_board_buttons()
{
int field;
int i;
UINT8 port_input=0;
UINT8 data = 0xff;
static UINT8 board_row = 0;
static UINT16 mouse_down = 0;
UINT8 pos2num_res = 0;
board_row++;
board_row &= 7;
int click_on_border_piece=FALSE;
/* check click on border pieces */
i=0;
port_input = m_b_black->read();
if (port_input)
{
i=get_first_bit(port_input)+6;
click_on_border_piece=TRUE;
}
port_input = m_b_white->read();
if (port_input)
{
i=get_first_bit(port_input);
click_on_border_piece=TRUE;
}
if (click_on_border_piece)
{
if (!mouse_down)
{
if (border_pieces[i] > 12 ) /* second click on selected border piece */
{
mouse_hold_border_piece=FALSE;
border_pieces[i]=border_pieces[i]-12;
mouse_hold_from=0;
mouse_hold_piece=0;
}
else if (!mouse_hold_piece) /*select border piece */
{
if (mouse_hold_border_piece)
border_pieces[mouse_hold_from]=border_pieces[mouse_hold_from]-12;
mouse_hold_from=i;
mouse_hold_piece=border_pieces[i];
border_pieces[i]=border_pieces[i]+12;
mouse_hold_border_piece=TRUE;
}
mouse_down = board_row + 1;
}
return;
}
/* check click on board */
data = m_line[board_row]->read();
if ((data != 0xff) && (!mouse_down) )
{
pos2num_res = pos_to_num(data);
field=64-(board_row*8+8-pos2num_res);
if (!(pos2num_res < 8))
logerror("Position out of bound!");
else if ((mouse_hold_piece) && (!IsPiece(field)))
{
/* Moving a piece onto a blank */
m_board[field] = mouse_hold_piece;
if (mouse_hold_border_piece)
{
border_pieces[mouse_hold_from]=border_pieces[mouse_hold_from]-12;
}else if ( field != mouse_hold_from ) /* Put a selected piece back to the source field */
m_board[mouse_hold_from] = 0;
mouse_hold_from = 0;
mouse_hold_piece = 0;
mouse_hold_border_piece=FALSE;
}
else if ((!mouse_hold_piece) )
{
/* Picking up a piece */
if (IsPiece(field))
{
mouse_hold_from = field;
mouse_hold_piece = m_board[field];
m_board[field] = m_board[field]+12;
}
}
mouse_down = board_row + 1;
}
else if ((data == 0xff) && (mouse_down == (board_row + 1))) /* Wait for mouse to be released */
mouse_down = 0;
/* check click on border - remove selected piece*/
if (m_line10->read())
{
if (mouse_hold_piece)
{
if (mouse_hold_border_piece)
border_pieces[mouse_hold_from]=border_pieces[mouse_hold_from]-12;
else
m_board[mouse_hold_from] = 0;
mouse_hold_from = 0;
mouse_hold_piece = 0;
mouse_hold_border_piece = FALSE;
}
return;
}
/* check additional buttons */
if (data == 0xff)
{
port_input = m_b_buttons->read();
if (port_input==0x01)
{
clear_board();
return;
}else if (port_input==0x02)
{
mboard_set_board();
return;
}
}
}
extern INPUT_PORTS_START( chessboard )
PORT_START("LINE.0")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.2")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.3")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.4")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.5")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.6")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE.7")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD)
PORT_START("LINE10")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("B_WHITE")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("B_BLACK")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x010, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x020, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("B_BUTTONS")
PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD)
PORT_START("MOUSE_X")
PORT_BIT( 0xffff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100)
PORT_START("MOUSE_Y")
PORT_BIT( 0xffff, 0x00, IPT_MOUSE_Y ) PORT_SENSITIVITY(100)
PORT_START("BUTTON_L")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("left button")
PORT_START("BUTTON_R")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("right button")
INPUT_PORTS_END