diff --git a/src/mame/drivers/saitek_stratos.cpp b/src/mame/drivers/saitek_stratos.cpp index d77f9859ce5..5b260413d1c 100644 --- a/src/mame/drivers/saitek_stratos.cpp +++ b/src/mame/drivers/saitek_stratos.cpp @@ -1,27 +1,46 @@ // license:BSD-3-Clause -// copyright-holders:Olivier Galibert +// copyright-holders:Olivier Galibert, hap /*************************************************************************** - Saitek/Scisys Kasparov Stratos Chess Computer +Scisys Kasparov Stratos Chess Computer + +TODO: +- add LCD (7x7 screen + 6 7segs) +- add Turbo King/Corona (same hardware family) +- add endgame rom (softwarelist?) +- clean up driver +- does nvram work? maybe both ram chips battery-backed +- add soft power off with STOP button(writes 0 to control_w), power-on with GO button ***************************************************************************/ #include "emu.h" #include "cpu/m6502/m65c02.h" #include "machine/nvram.h" -#include "machine/timer.h" +#include "machine/sensorboard.h" +#include "sound/dac.h" +#include "sound/volt_reg.h" +#include "speaker.h" +#include "video/pwm.h" #include "screen.h" +// internal artwork +#include "saitek_stratos.lh" // clickable + class stratos_state : public driver_device { public: - stratos_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag) - , maincpu(*this, "maincpu") - , nvram(*this, "nvram") - , bank_8000(*this, "bank_8000") - , bank_4000(*this, "bank_4000") - , nvram_bank(*this, "nvram_bank") + stratos_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + maincpu(*this, "maincpu"), + nvram(*this, "nvram"), + bank_8000(*this, "bank_8000"), + bank_4000(*this, "bank_4000"), + nvram_bank(*this, "nvram_bank"), + m_board(*this, "board"), + m_display(*this, "display"), + m_dac(*this, "dac"), + m_inputs(*this, "IN.%u", 0) { } void stratos(machine_config &config); @@ -38,14 +57,13 @@ private: DECLARE_READ8_MEMBER(lcd_r); DECLARE_WRITE8_MEMBER(lcd_w); - TIMER_DEVICE_CALLBACK_MEMBER(irq_timer); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); void stratos_mem(address_map &map); std::unique_ptr nvram_data; uint8_t control, led_latch_control; - uint32_t individual_leds; + uint32_t individual_leds, ind_leds; uint8_t latch_AH_red, latch_AH_green, latch_18_red, latch_18_green; void show_leds(); virtual void machine_reset() override; @@ -55,6 +73,12 @@ private: required_memory_bank bank_8000; required_memory_bank bank_4000; required_memory_bank nvram_bank; + required_device m_board; + required_device m_display; + required_device m_dac; + required_ioport_array<8> m_inputs; + + bool m_lcd_busy; }; void stratos_state::init_stratos() @@ -62,8 +86,8 @@ void stratos_state::init_stratos() nvram_data = std::make_unique(0x2000); nvram->set_base(nvram_data.get(), 0x2000); - bank_8000 ->configure_entries(0, 4, memregion("roms_8000")->base(), 0x8000); - bank_4000 ->configure_entries(0, 4, memregion("roms_4000")->base(), 0x4000); + bank_8000 ->configure_entries(0, 2, memregion("roms_8000")->base(), 0x8000); + bank_4000 ->configure_entries(0, 2, memregion("roms_4000")->base(), 0x4000); nvram_bank->configure_entries(0, 2, nvram_data.get(), 0x1000); } @@ -112,18 +136,17 @@ void stratos_state::show_leds() } logerror("leds R:%s -- G:%s (%s)\n", str_red, str_green, machine().describe_context()); -} -TIMER_DEVICE_CALLBACK_MEMBER(stratos_state::irq_timer) -{ - maincpu->set_input_line(M65C02_IRQ_LINE, HOLD_LINE); + + m_display->matrix_partial(0, 4, ~led_latch_control >> 4 & 0xf, 1 << (led_latch_control & 0xf), false); + m_display->matrix_partial(4, 2, 1 << (control >> 5 & 1), (~ind_leds & 0xff) | (~control << 6 & 0x100)); } uint32_t stratos_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { static bool nmi=false; - if(machine().input().code_pressed(KEYCODE_W)) { + if(machine().input().code_pressed(KEYCODE_F1)) { if(!nmi) { maincpu->pulse_input_line(M65C02_NMI_LINE, attotime::zero); nmi = true; @@ -137,6 +160,7 @@ uint32_t stratos_state::screen_update(screen_device &screen, bitmap_rgb32 &bitma WRITE8_MEMBER(stratos_state::p2000_w) { + m_dac->write(0); led_latch_control = data; if(!(data & 0x10)) @@ -154,16 +178,24 @@ WRITE8_MEMBER(stratos_state::p2000_w) READ8_MEMBER(stratos_state::p2200_r) { logerror("p2200_r (%s)\n", machine().describe_context()); + + //printf("%X ",led_latch_control&0xf); + + return ~m_board->read_file(led_latch_control & 0xf); return machine().rand(); + return 0; } WRITE8_MEMBER(stratos_state::p2200_w) { + m_dac->write(1); logerror("p2200_w %02x -> %02x (%s)\n", data, data^0xff, machine().describe_context()); } WRITE8_MEMBER(stratos_state::p2400_w) { + ind_leds = data; + if(control & 0x20) { individual_leds = individual_leds & 0x100ff; individual_leds |= (data ^ 0xff) << 8; @@ -175,6 +207,8 @@ WRITE8_MEMBER(stratos_state::p2400_w) if(!(control & 0x04)) individual_leds |= 0x10000; } + + show_leds(); } READ8_MEMBER(stratos_state::control_r) @@ -287,7 +321,29 @@ READ8_MEMBER(stratos_state::control_r) // (20) = difficulty level logerror("control_r (%s)\n", machine().describe_context()); - return xx ? 0x20 : 0x00; + + u8 data = 0; + + //printf("%X ",led_latch_control&0xf); + +//printf("%X ",ind_leds); + + u8 sel = led_latch_control & 0xf; + + if (sel == 8) + { + // lcd busy flag? + data = m_lcd_busy ? 0x20: 0; + m_lcd_busy = false; + } + + if (sel < 8) + data |= m_inputs[sel]->read() << 5; + + return data; + //return xx ? 0x20 : 0x00; + //return 0; + //return 0xe0; } WRITE8_MEMBER(stratos_state::control_w) @@ -295,19 +351,22 @@ WRITE8_MEMBER(stratos_state::control_w) logerror("control_w %02x bank %d (%s)\n", data, data & 3, machine().describe_context()); control = data; - bank_8000->set_entry(data & 3); - bank_4000->set_entry(data & 3); + bank_8000->set_entry(data & 1); + bank_4000->set_entry(data >> 1 & 1); // ? nvram_bank->set_entry((data >> 1) & 1); + + show_leds(); } READ8_MEMBER(stratos_state::lcd_r) { - return 0x00; + return 0; } WRITE8_MEMBER(stratos_state::lcd_w) { + m_lcd_busy = true; // 08 0b - 00? // 04 06 - 05 // 02 0d - 07 @@ -347,33 +406,87 @@ void stratos_state::stratos_mem(address_map &map) } static INPUT_PORTS_START( stratos ) + PORT_START("IN.0") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_1) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_2) // level + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_3) + + PORT_START("IN.1") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_4) // sound + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_5) // stop? + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_6) // new game? + + PORT_START("IN.2") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_7) // rook + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_8) // pawn + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_9) // bishop + + PORT_START("IN.3") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_Q) // queen + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_W) // knight + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_E) // king + + PORT_START("IN.4") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_R) // play + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_T) // tab/color + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_Y) // - + + PORT_START("IN.5") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_U) // + + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_I) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_O) + + PORT_START("IN.6") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_A) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_S) // info + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_D) + + PORT_START("IN.7") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_F) + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_G) + PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_KEYPAD) PORT_CODE(KEYCODE_H) // normal INPUT_PORTS_END void stratos_state::stratos(machine_config &config) { - M65C02(config, maincpu, 5670000); + /* basic machine hardware */ + M65C02(config, maincpu, 5.67_MHz_XTAL); maincpu->set_addrmap(AS_PROGRAM, &stratos_state::stratos_mem); - - screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); - screen.set_refresh_hz(50); - screen.set_size(240, 64); - screen.set_visarea(0, 239, 0, 63); - screen.set_screen_update(FUNC(stratos_state::screen_update)); - - TIMER(config, "irq").configure_periodic(FUNC(stratos_state::irq_timer), attotime::from_hz(1000)); + maincpu->set_periodic_int(FUNC(stratos_state::irq0_line_hold), attotime::from_hz(1024)); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); + + SENSORBOARD(config, m_board).set_type(sensorboard_device::BUTTONS); + m_board->init_cb().set(m_board, FUNC(sensorboard_device::preset_chess)); + m_board->set_delay(attotime::from_msec(100)); + + /* video hardware */ + screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); + screen.set_refresh_hz(50); + screen.set_size(7, 7); + screen.set_visarea_full(); + screen.set_screen_update(FUNC(stratos_state::screen_update)); + + PWM_DISPLAY(config, m_display).set_size(4+2, 8+1); + m_display->set_bri_levels(0.05); + m_display->set_bri_maximum(0.5); + + config.set_default_layout(layout_saitek_stratos); + + /* sound hardware */ + SPEAKER(config, "speaker").front_center(); + DAC_1BIT(config, m_dac).add_route(ALL_OUTPUTS, "speaker", 0.25); + VOLTAGE_REGULATOR(config, "vref").add_route(0, "dac", 1.0, DAC_VREF_POS_INPUT); } ROM_START( stratos ) - ROM_REGION(0x20000, "roms_8000", 0) + ROM_REGION(0x10000, "roms_8000", 0) ROM_LOAD("w1_728m_u3.u3", 0x0000, 0x8000, CRC(b58a7256) SHA1(75b3a3a65f4ca8d52aa5b17a06319bff59d9014f)) ROM_LOAD("bw1_918n_u4.u4", 0x8000, 0x8000, CRC(cb0de631) SHA1(f78d40213be21775966cbc832d64acd9b73de632)) - ROM_FILL(0x10000, 0x10000, 0xff) ROM_REGION(0x10000, "roms_4000", 0) ROM_FILL(0x00000, 0x10000, 0xff) ROM_END /* YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS */ -CONS( 1986, stratos, 0, 0, stratos, stratos, stratos_state, init_stratos, "SciSys", "Kasparov Stratos", MACHINE_NOT_WORKING | MACHINE_NO_SOUND) +CONS( 1986, stratos, 0, 0, stratos, stratos, stratos_state, init_stratos, "SciSys", "Kasparov Stratos", MACHINE_NOT_WORKING | MACHINE_CLICKABLE_ARTWORK ) diff --git a/src/mame/layout/saitek_stratos.lay b/src/mame/layout/saitek_stratos.lay new file mode 100644 index 00000000000..cc9e4f07874 --- /dev/null +++ b/src/mame/layout/saitek_stratos.lay @@ -0,0 +1,395 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +