From 598e17aee1e85f3d59c945a2d8951b1379e8bd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Mon, 2 Dec 2024 05:44:15 +0200 Subject: [PATCH 1/9] Add initial mouse support (misses pixels, wrong density) --- src/mame/ussr/juku.cpp | 99 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index 40737fd3e34ee..569140c4aa6bf 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -91,11 +91,16 @@ class juku_state : public driver_device m_keys(*this, "COL.%u", 0U), m_key_special(*this, "SPECIAL"), m_screen(*this, "screen"), - m_speaker(*this, "speaker") + m_speaker(*this, "speaker"), + m_mouse_x(*this, "MOUSE_X"), + m_mouse_y(*this, "MOUSE_Y"), + m_mouse_b(*this, "BUTTONS") { } void juku(machine_config &config); + DECLARE_INPUT_CHANGED_MEMBER(mouse_update); + protected: virtual void machine_start() override ATTR_COLD; virtual void machine_reset() override ATTR_COLD; @@ -114,6 +119,7 @@ class juku_state : public driver_device required_ioport m_key_special; required_device m_screen; required_device m_speaker; + optional_ioport m_mouse_x, m_mouse_y, m_mouse_b; int32_t m_width, m_height, m_hbporch, m_vbporch; @@ -136,6 +142,10 @@ class juku_state : public driver_device uint8_t pio0_portb_r(); void pio0_portc_w(uint8_t data); + uint8_t mouse_port_r(); + uint8_t m_prev_mouse_x, m_prev_mouse_y; + uint8_t m_prev_mouse_byte; + void screen_width(uint8_t data); void screen_hblank_period(uint8_t data); void screen_hfporch(uint8_t data); @@ -206,6 +216,7 @@ void juku_state::io_map(address_map &map) map(0x1f, 0x1f).rw(FUNC(juku_state::fdc_data_r), FUNC(juku_state::fdc_data_w)); // mapping for cassette version (E5101?) // map(0x1c, 0x1d).rw(m_sio[1], FUNC(i8251_device::read), FUNC(i8251_device::write)); + map(0x80, 0x80).r(FUNC(juku_state::mouse_port_r)); } @@ -397,6 +408,17 @@ static INPUT_PORTS_START( juku ) PORT_START("SPECIAL") PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) + + // Optional mouse at system port X1 + PORT_START("MOUSE_X") + PORT_BIT( 0xff, 0x00, IPT_MOUSE_X ) PORT_CODE(MOUSECODE_X) PORT_SENSITIVITY(50) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) + + PORT_START("MOUSE_Y") + PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y ) PORT_CODE(MOUSECODE_Y) PORT_SENSITIVITY(50) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) + + PORT_START("BUTTONS") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Left Button") PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Right Button") PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) INPUT_PORTS_END @@ -583,6 +605,75 @@ void juku_state::speaker_w(int state) } +//************************************************************************** +// MOUSE +//************************************************************************** + +/* + * Calculate positive/negative delta from old and new relative value + */ +inline int delta(int o, int n) +{ + if(o>n) { + if(o-n<128) return n-o; + else return n+255-o; + } + if(oread(), y = m_mouse_y->read(); + int dx = delta(m_prev_mouse_x, x); + int dy = delta(m_prev_mouse_y, y); + + data |= m_mouse_b->read(); + + if (dx!=0) { + data |= dx > 0 ? 0b00001000 : 0b00001100; + m_prev_mouse_x = x; + } + + if (dy!=0) { + data |= dy > 0 ? 0b00110000 : 0b00100000; + m_prev_mouse_y = y; + } + + if (m_prev_mouse_byte != data) { + m_prev_mouse_byte = data; + + LOG("m: "); + for (int i = 7; i >= 0; i--) + LOG("%d", BIT(data, i)); + LOG(" \n"); + } + + return data; +} + +INPUT_CHANGED_MEMBER(juku_state::mouse_update) +{ + + m_pic->ir6_w(CLEAR_LINE); + m_pic->ir6_w(HOLD_LINE); +} + + //************************************************************************** // MACHINE EMULATION //************************************************************************** @@ -671,6 +762,9 @@ void juku_state::machine_start() save_item(NAME(m_beep_state)); save_item(NAME(m_beep_level)); save_item(NAME(m_fdc_cur_cmd)); + save_item(NAME(m_prev_mouse_byte)); + save_item(NAME(m_prev_mouse_y)); + save_item(NAME(m_prev_mouse_x)); save_pointer(NAME(m_ram), 0x10000); } @@ -688,6 +782,9 @@ void juku_state::machine_reset() m_vblank_period_lsb = -1; m_monitor_bits = 0U; m_empty_screen_on_update = 0; + m_prev_mouse_byte = 0; + m_prev_mouse_y = 0; + m_prev_mouse_x = 0; } From c64a230674f8466d60c58be5d4f46635b555b5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Fri, 27 Dec 2024 00:29:25 +0200 Subject: [PATCH 2/9] Move mouse to optional device, add timer to fix density --- src/mame/ussr/juku.cpp | 119 ++++++------------------------------ src/mame/ussr/jukumouse.cpp | 115 ++++++++++++++++++++++++++++++++++ src/mame/ussr/jukumouse.h | 30 +++++++++ 3 files changed, 162 insertions(+), 102 deletions(-) create mode 100644 src/mame/ussr/jukumouse.cpp create mode 100644 src/mame/ussr/jukumouse.h diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index 569140c4aa6bf..a68c6cc0284a9 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -33,6 +33,8 @@ #include "emu.h" +#include "jukumouse.h" + #include "cpu/i8085/i8085.h" #include "imagedev/floppy.h" #include "machine/74148.h" @@ -44,6 +46,7 @@ #include "machine/wd_fdc.h" #include "sound/spkrdev.h" +#include "emuopts.h" #include "screen.h" #include "softlist_dev.h" #include "speaker.h" @@ -92,15 +95,11 @@ class juku_state : public driver_device m_key_special(*this, "SPECIAL"), m_screen(*this, "screen"), m_speaker(*this, "speaker"), - m_mouse_x(*this, "MOUSE_X"), - m_mouse_y(*this, "MOUSE_Y"), - m_mouse_b(*this, "BUTTONS") + m_mouse(*this, "mouse") { } void juku(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(mouse_update); - protected: virtual void machine_start() override ATTR_COLD; virtual void machine_reset() override ATTR_COLD; @@ -119,7 +118,7 @@ class juku_state : public driver_device required_ioport m_key_special; required_device m_screen; required_device m_speaker; - optional_ioport m_mouse_x, m_mouse_y, m_mouse_b; + optional_device m_mouse; int32_t m_width, m_height, m_hbporch, m_vbporch; @@ -142,10 +141,6 @@ class juku_state : public driver_device uint8_t pio0_portb_r(); void pio0_portc_w(uint8_t data); - uint8_t mouse_port_r(); - uint8_t m_prev_mouse_x, m_prev_mouse_y; - uint8_t m_prev_mouse_byte; - void screen_width(uint8_t data); void screen_hblank_period(uint8_t data); void screen_hfporch(uint8_t data); @@ -216,7 +211,6 @@ void juku_state::io_map(address_map &map) map(0x1f, 0x1f).rw(FUNC(juku_state::fdc_data_r), FUNC(juku_state::fdc_data_w)); // mapping for cassette version (E5101?) // map(0x1c, 0x1d).rw(m_sio[1], FUNC(i8251_device::read), FUNC(i8251_device::write)); - map(0x80, 0x80).r(FUNC(juku_state::mouse_port_r)); } @@ -408,17 +402,6 @@ static INPUT_PORTS_START( juku ) PORT_START("SPECIAL") PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_SHIFT_2) - - // Optional mouse at system port X1 - PORT_START("MOUSE_X") - PORT_BIT( 0xff, 0x00, IPT_MOUSE_X ) PORT_CODE(MOUSECODE_X) PORT_SENSITIVITY(50) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) - - PORT_START("MOUSE_Y") - PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y ) PORT_CODE(MOUSECODE_Y) PORT_SENSITIVITY(50) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) - - PORT_START("BUTTONS") - PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Left Button") PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Right Button") PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(juku_state::mouse_update), 1) INPUT_PORTS_END @@ -605,75 +588,6 @@ void juku_state::speaker_w(int state) } -//************************************************************************** -// MOUSE -//************************************************************************** - -/* - * Calculate positive/negative delta from old and new relative value - */ -inline int delta(int o, int n) -{ - if(o>n) { - if(o-n<128) return n-o; - else return n+255-o; - } - if(oread(), y = m_mouse_y->read(); - int dx = delta(m_prev_mouse_x, x); - int dy = delta(m_prev_mouse_y, y); - - data |= m_mouse_b->read(); - - if (dx!=0) { - data |= dx > 0 ? 0b00001000 : 0b00001100; - m_prev_mouse_x = x; - } - - if (dy!=0) { - data |= dy > 0 ? 0b00110000 : 0b00100000; - m_prev_mouse_y = y; - } - - if (m_prev_mouse_byte != data) { - m_prev_mouse_byte = data; - - LOG("m: "); - for (int i = 7; i >= 0; i--) - LOG("%d", BIT(data, i)); - LOG(" \n"); - } - - return data; -} - -INPUT_CHANGED_MEMBER(juku_state::mouse_update) -{ - - m_pic->ir6_w(CLEAR_LINE); - m_pic->ir6_w(HOLD_LINE); -} - - //************************************************************************** // MACHINE EMULATION //************************************************************************** @@ -749,6 +663,9 @@ void juku_state::machine_start() membank("ram_4000")->set_base(&m_ram[0x4000]); membank("ram_c000")->set_base(&m_ram[0xc000]); + if (m_mouse.found() && strcmp(mconfig().options().mouse_device(), "none") != 0) + m_maincpu->space(AS_IO).install_read_handler(0x80, 0x80, read8smo_delegate(*m_mouse, FUNC(juku_mouse_device::mouse_port_r))); + // register for save states save_item(NAME(m_width)); save_item(NAME(m_height)); @@ -762,9 +679,6 @@ void juku_state::machine_start() save_item(NAME(m_beep_state)); save_item(NAME(m_beep_level)); save_item(NAME(m_fdc_cur_cmd)); - save_item(NAME(m_prev_mouse_byte)); - save_item(NAME(m_prev_mouse_y)); - save_item(NAME(m_prev_mouse_x)); save_pointer(NAME(m_ram), 0x10000); } @@ -782,9 +696,6 @@ void juku_state::machine_reset() m_vblank_period_lsb = -1; m_monitor_bits = 0U; m_empty_screen_on_update = 0; - m_prev_mouse_byte = 0; - m_prev_mouse_y = 0; - m_prev_mouse_x = 0; } @@ -798,7 +709,7 @@ void juku_state::juku(machine_config &config) I8080A(config, m_maincpu, 20_MHz_XTAL/10); m_maincpu->set_addrmap(AS_PROGRAM, &juku_state::mem_map); m_maincpu->set_addrmap(AS_IO, &juku_state::io_map); - m_maincpu->in_inta_func().set("pic", FUNC(pic8259_device::acknowledge)); + m_maincpu->in_inta_func().set(m_pic, FUNC(pic8259_device::acknowledge)); ADDRESS_MAP_BANK(config, m_bank); m_bank->set_map(&juku_state::bank_map); @@ -854,13 +765,13 @@ void juku_state::juku(machine_config &config) // КР580ВВ51A I8251(config, m_sio[0], 0); - m_sio[0]->rxrdy_handler().set("pic", FUNC(pic8259_device::ir2_w)); - m_sio[0]->txrdy_handler().set("pic", FUNC(pic8259_device::ir3_w)); + m_sio[0]->rxrdy_handler().set(m_pic, FUNC(pic8259_device::ir2_w)); + m_sio[0]->txrdy_handler().set(m_pic, FUNC(pic8259_device::ir3_w)); // КР580ВВ51A (instead of FDC?) I8251(config, m_sio[1], 0); - m_sio[1]->rxrdy_handler().set("pic", FUNC(pic8259_device::ir0_w)); - m_sio[1]->txrdy_handler().set("pic", FUNC(pic8259_device::ir1_w)); + m_sio[1]->rxrdy_handler().set(m_pic, FUNC(pic8259_device::ir0_w)); + m_sio[1]->txrdy_handler().set(m_pic, FUNC(pic8259_device::ir1_w)); // Электроника МС 6105.1 "Колокольчик" (DEC VR201 analog) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -875,6 +786,10 @@ void juku_state::juku(machine_config &config) // К155ИВ1 TTL74148(config, m_key_encoder, 0); + // E4701 + JUKU_MOUSE(config, m_mouse); + m_mouse->int_handler().set(m_pic, FUNC(pic8259_device::ir6_w)); + // КР1818ВГ93 (for E6502 disk drive) KR1818VG93(config, m_fdc, 16_MHz_XTAL/16); m_fdc->drq_wr_callback().set(FUNC(juku_state::fdc_drq_w)); diff --git a/src/mame/ussr/jukumouse.cpp b/src/mame/ussr/jukumouse.cpp new file mode 100644 index 0000000000000..f1b44a5a585b4 --- /dev/null +++ b/src/mame/ussr/jukumouse.cpp @@ -0,0 +1,115 @@ +// license:BSD-3-Clause +// copyright-holders:Märt Põder + +#include "emu.h" +#include "jukumouse.h" + +#define VERBOSE 1 +#define LOG_OUTPUT_FUNC osd_printf_info + +#include "logmacro.h" + +DEFINE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device, "juku_mouse", "Juku E510x mouse") + +juku_mouse_device::juku_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, JUKU_MOUSE, tag, owner, clock), + m_mouse_x(*this, "MOUSE_X"), + m_mouse_y(*this, "MOUSE_Y"), + m_mouse_b(*this, "BUTTONS"), + m_int_handler(*this) +{ +} + +void juku_mouse_device::device_start() +{ + save_item(NAME(m_prev_mouse_y)); + save_item(NAME(m_prev_mouse_x)); + save_item(NAME(m_prev_byte)); + m_mouse_timer = timer_alloc(FUNC(juku_mouse_device::poll_delta), this); +} + +void juku_mouse_device::device_reset() +{ + m_prev_mouse_y = 0; + m_prev_mouse_x = 0; + m_prev_byte = 0; + m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1400)); +} + +/* + * Calculate positive/negative delta from old and new relative value + */ +inline int delta(int o, int n) +{ + if(o>n) { + if(o-n<128) return n-o; + else return n+255-o; + } + if(oread(); + int x = m_mouse_x->read(), y = m_mouse_y->read(); + int dx = delta(m_prev_mouse_x, x); + int dy = delta(m_prev_mouse_y, y); + + if (dx != 0 || dy != 0 || (m_prev_byte & 0b11) != buttons) { + m_int_handler(CLEAR_LINE); + m_int_handler(ASSERT_LINE); + } +} + +INPUT_PORTS_START( juku_mouse ) + PORT_START("MOUSE_X") + PORT_BIT(0xff, 0x00, IPT_MOUSE_X) PORT_CODE(MOUSECODE_X) PORT_SENSITIVITY(23) + + PORT_START("MOUSE_Y") + PORT_BIT(0xff, 0x00, IPT_MOUSE_Y) PORT_CODE(MOUSECODE_Y) PORT_SENSITIVITY(23) + + PORT_START("BUTTONS") + PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_CODE(MOUSECODE_BUTTON1) PORT_NAME("Left Button") + PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_CODE(MOUSECODE_BUTTON2) PORT_NAME("Right Button") +INPUT_PORTS_END + +uint8_t juku_mouse_device::mouse_port_r() +{ + // 7------- always 1 + // -6------ always 0 + // --5----- vertical active + // ---4---- vertical direction + // ----3--- horizontal active + // -----2-- horizontal direction + // ------1- left button + // -------0 right button + + uint8_t data = 0b10000000 | m_mouse_b->read(); + int x = m_mouse_x->read(), y = m_mouse_y->read(); + int dx = delta(m_prev_mouse_x, x); + int dy = delta(m_prev_mouse_y, y); + + if (dx != 0) { + data |= dx > 0 ? 0b00001000 : 0b00001100; + m_prev_mouse_x = x; + } + + if (dy != 0) { + data |= dy > 0 ? 0b00110000 : 0b00100000; + m_prev_mouse_y = y; + } + + m_prev_byte = data; + + return data; +} + +ioport_constructor juku_mouse_device::device_input_ports() const +{ + return INPUT_PORTS_NAME( juku_mouse ); +} diff --git a/src/mame/ussr/jukumouse.h b/src/mame/ussr/jukumouse.h new file mode 100644 index 0000000000000..44c086e6b9c6f --- /dev/null +++ b/src/mame/ussr/jukumouse.h @@ -0,0 +1,30 @@ +// license: BSD-3-Clause +// copyright-holders:Märt Põder + +#ifndef MAME_USSR_JUKU_H +#define MAME_USSR_JUKU_H + +#pragma once + +class juku_mouse_device : public device_t +{ +public: + juku_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + uint8_t mouse_port_r(); + auto int_handler() { return m_int_handler.bind(); } + TIMER_CALLBACK_MEMBER( poll_delta ); +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + virtual ioport_constructor device_input_ports() const override ATTR_COLD; +private: + required_ioport m_mouse_x, m_mouse_y, m_mouse_b; + uint8_t m_prev_mouse_x, m_prev_mouse_y; + uint8_t m_prev_byte; + devcb_write_line m_int_handler; + emu_timer *m_mouse_timer; +}; + +DECLARE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device) + +#endif // MAME_USSR_JUKU_H \ No newline at end of file From ee7c650787422d35924f2090b7229e71405cff84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Fri, 27 Dec 2024 00:41:34 +0200 Subject: [PATCH 3/9] Format tabs, remove mouse from TODO --- src/mame/ussr/juku.cpp | 9 ++++----- src/mame/ussr/jukumouse.cpp | 18 +++++++++--------- src/mame/ussr/jukumouse.h | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index a68c6cc0284a9..af9f5634eb5b8 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -27,7 +27,6 @@ - Network? - Ramdisk? - Memory extensions? - - Mouse! ***************************************************************************/ @@ -663,8 +662,8 @@ void juku_state::machine_start() membank("ram_4000")->set_base(&m_ram[0x4000]); membank("ram_c000")->set_base(&m_ram[0xc000]); - if (m_mouse.found() && strcmp(mconfig().options().mouse_device(), "none") != 0) - m_maincpu->space(AS_IO).install_read_handler(0x80, 0x80, read8smo_delegate(*m_mouse, FUNC(juku_mouse_device::mouse_port_r))); + if (m_mouse.found() && strcmp(mconfig().options().mouse_device(), "none") != 0) + m_maincpu->space(AS_IO).install_read_handler(0x80, 0x80, read8smo_delegate(*m_mouse, FUNC(juku_mouse_device::mouse_port_r))); // register for save states save_item(NAME(m_width)); @@ -787,8 +786,8 @@ void juku_state::juku(machine_config &config) TTL74148(config, m_key_encoder, 0); // E4701 - JUKU_MOUSE(config, m_mouse); - m_mouse->int_handler().set(m_pic, FUNC(pic8259_device::ir6_w)); + JUKU_MOUSE(config, m_mouse); + m_mouse->int_handler().set(m_pic, FUNC(pic8259_device::ir6_w)); // КР1818ВГ93 (for E6502 disk drive) KR1818VG93(config, m_fdc, 16_MHz_XTAL/16); diff --git a/src/mame/ussr/jukumouse.cpp b/src/mame/ussr/jukumouse.cpp index f1b44a5a585b4..d141775a608e0 100644 --- a/src/mame/ussr/jukumouse.cpp +++ b/src/mame/ussr/jukumouse.cpp @@ -4,8 +4,8 @@ #include "emu.h" #include "jukumouse.h" -#define VERBOSE 1 -#define LOG_OUTPUT_FUNC osd_printf_info +//#define VERBOSE 1 +//#define LOG_OUTPUT_FUNC osd_printf_info #include "logmacro.h" @@ -32,7 +32,7 @@ void juku_mouse_device::device_reset() { m_prev_mouse_y = 0; m_prev_mouse_x = 0; - m_prev_byte = 0; + m_prev_byte = 0; m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1400)); } @@ -61,9 +61,9 @@ TIMER_CALLBACK_MEMBER( juku_mouse_device::poll_delta ) int dy = delta(m_prev_mouse_y, y); if (dx != 0 || dy != 0 || (m_prev_byte & 0b11) != buttons) { - m_int_handler(CLEAR_LINE); - m_int_handler(ASSERT_LINE); - } + m_int_handler(CLEAR_LINE); + m_int_handler(ASSERT_LINE); + } } INPUT_PORTS_START( juku_mouse ) @@ -98,13 +98,13 @@ uint8_t juku_mouse_device::mouse_port_r() data |= dx > 0 ? 0b00001000 : 0b00001100; m_prev_mouse_x = x; } - - if (dy != 0) { + + if (dy != 0) { data |= dy > 0 ? 0b00110000 : 0b00100000; m_prev_mouse_y = y; } - m_prev_byte = data; + m_prev_byte = data; return data; } diff --git a/src/mame/ussr/jukumouse.h b/src/mame/ussr/jukumouse.h index 44c086e6b9c6f..4a13a9cc0f19b 100644 --- a/src/mame/ussr/jukumouse.h +++ b/src/mame/ussr/jukumouse.h @@ -20,7 +20,7 @@ class juku_mouse_device : public device_t private: required_ioport m_mouse_x, m_mouse_y, m_mouse_b; uint8_t m_prev_mouse_x, m_prev_mouse_y; - uint8_t m_prev_byte; + uint8_t m_prev_byte; devcb_write_line m_int_handler; emu_timer *m_mouse_timer; }; From 0089c9fa0f8971371862afd2d3b4db58295a028e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Fri, 27 Dec 2024 00:46:54 +0200 Subject: [PATCH 4/9] Add newline to end of file --- src/mame/ussr/jukumouse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mame/ussr/jukumouse.h b/src/mame/ussr/jukumouse.h index 4a13a9cc0f19b..01b68eea0984d 100644 --- a/src/mame/ussr/jukumouse.h +++ b/src/mame/ussr/jukumouse.h @@ -27,4 +27,4 @@ class juku_mouse_device : public device_t DECLARE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device) -#endif // MAME_USSR_JUKU_H \ No newline at end of file +#endif // MAME_USSR_JUKU_H From 10ad3d6f82a57a03657309a7f52622ad29e6612f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Fri, 3 Jan 2025 17:04:40 +0200 Subject: [PATCH 5/9] Convert to memory view (instead of bank device) --- src/mame/ussr/juku.cpp | 85 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index af9f5634eb5b8..8ab849db66e0a 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -37,7 +37,6 @@ #include "cpu/i8085/i8085.h" #include "imagedev/floppy.h" #include "machine/74148.h" -#include "machine/bankdev.h" #include "machine/i8251.h" #include "machine/i8255.h" #include "machine/pic8259.h" @@ -82,7 +81,11 @@ class juku_state : public driver_device juku_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), - m_bank(*this, "bank"), + m_rom(*this, "maincpu"), + m_exp(*this, "expcart"), + m_ram(*this, "ram"), + m_ext(*this, "ext%u", 0U), + m_mode(*this, "mode"), m_pic(*this, "pic"), m_pit(*this, "pit%u", 0U), m_pio(*this, "pio%u", 0U), @@ -105,7 +108,11 @@ class juku_state : public driver_device private: required_device m_maincpu; - required_device m_bank; + required_region_ptr m_rom; + optional_region_ptr m_exp; + required_shared_ptr m_ram; + optional_shared_ptr_array m_ext; + memory_view m_mode; required_device m_pic; required_device_array m_pit; required_device_array m_pio; @@ -130,10 +137,7 @@ class juku_state : public driver_device uint8_t m_fdc_cur_cmd; - std::unique_ptr m_ram; - void mem_map(address_map &map) ATTR_COLD; - void bank_map(address_map &map) ATTR_COLD; void io_map(address_map &map) ATTR_COLD; void pio0_porta_w(uint8_t data); @@ -167,25 +171,9 @@ class juku_state : public driver_device void juku_state::mem_map(address_map &map) { - map(0x0000, 0xffff).m(m_bank, FUNC(address_map_bank_device::amap8)); -} - -void juku_state::bank_map(address_map &map) -{ - // memory mode 0 - map(0x00000, 0x03fff).rom().region("maincpu", 0); - map(0x00000, 0x03fff).bankw("ram_0000"); - map(0x04000, 0x0ffff).bankrw("ram_4000"); - // memory mode 1 - map(0x10000, 0x1ffff).bankrw("ram_0000"); - map(0x1d800, 0x1ffff).bankr("rom_d800"); - // memory mode 2 - map(0x20000, 0x23fff).bankrw("ram_0000"); - map(0x24000, 0x2bfff).rom().region("extension", 0); - map(0x2c000, 0x2ffff).bankrw("ram_c000"); - map(0x2d800, 0x2ffff).bankr("rom_d800"); - // memory mode 3 - map(0x30000, 0x3ffff).bankrw("ram_0000"); + map(0x0000, 0xffff).ram().share(m_ram); + map(0x0000, 0x7fff).ram().share(m_ext[0]); + map(0x0000, 0xffff).view(m_mode); } void juku_state::io_map(address_map &map) @@ -649,19 +637,33 @@ void juku_state::pio0_portc_w(uint8_t data) floppy->ss_w(BIT(data, 6)); } - m_bank->set_bank(data & 0x03); + m_mode.select(data & 0b11); } void juku_state::machine_start() { - m_ram = std::make_unique(0x10000); - - membank("rom_d800")->set_base(memregion("maincpu")->base() + 0x1800); - - membank("ram_0000")->set_base(&m_ram[0x0000]); - membank("ram_4000")->set_base(&m_ram[0x4000]); - membank("ram_c000")->set_base(&m_ram[0xc000]); - + // map memory modes + m_mode[0].install_rom(0x0000, 0x3fff, &m_rom[0x0000]); + m_mode[0].install_writeonly(0x0000, 0x3fff, &m_ram[0x0000]); + m_mode[0].install_ram(0x4000, 0xffff, &m_ram[0x4000]); + m_mode[1].install_ram(0x0000, 0xd7ff, &m_ram[0x0000]); + m_mode[1].install_rom(0xd800, 0xffff, &m_rom[0x1800]); + m_mode[1].install_writeonly(0xd800, 0xffff, &m_ram[0xd800]); + m_mode[2].install_ram(0x0000, 0x3fff, &m_ram[0x0000]); + // optional BASIC expansion cartridge + m_mode[2].install_rom(0x4000, 0xbfff, &m_exp[0x0000]); + //m_mode[2].install_ram(0x4000, 0xbfff, &m_ext[0][0x0000]); + // no info on programs actually using extra 32kb "memory window" + m_mode[2].install_writeonly(0x4000, 0xbfff, &m_ext[0][0x0000]); + // could also refer to usual ram (specs not clear) + //m_mode[2].install_writeonly(0x4000, 0xbfff, &m_ram[0x4000]); + m_mode[2].install_ram(0xc000, 0xd7ff, &m_ram[0xc000]); + m_mode[2].install_rom(0xd800, 0xffff, &m_rom[0x1800]); + m_mode[2].install_writeonly(0xd800, 0xffff, &m_ram[0xd800]); + // could as well disable the view, but for coherence + m_mode[3].install_ram(0x0000, 0xffff, &m_ram[0x0000]); + + // check if mouse is plugged if (m_mouse.found() && strcmp(mconfig().options().mouse_device(), "none") != 0) m_maincpu->space(AS_IO).install_read_handler(0x80, 0x80, read8smo_delegate(*m_mouse, FUNC(juku_mouse_device::mouse_port_r))); @@ -678,12 +680,11 @@ void juku_state::machine_start() save_item(NAME(m_beep_state)); save_item(NAME(m_beep_level)); save_item(NAME(m_fdc_cur_cmd)); - save_pointer(NAME(m_ram), 0x10000); } void juku_state::machine_reset() { - m_bank->set_bank(0); + m_mode.select(0); m_key_encoder->enable_input_w(0); m_beep_state = 0; m_beep_level = 0; @@ -710,12 +711,6 @@ void juku_state::juku(machine_config &config) m_maincpu->set_addrmap(AS_IO, &juku_state::io_map); m_maincpu->in_inta_func().set(m_pic, FUNC(pic8259_device::acknowledge)); - ADDRESS_MAP_BANK(config, m_bank); - m_bank->set_map(&juku_state::bank_map); - m_bank->set_data_width(8); - m_bank->set_addr_width(18); - m_bank->set_stride(0x10000); - // КР580ВН59 PIC8259(config, m_pic, 0); m_pic->out_int_callback().set_inputline(m_maincpu, 0); @@ -785,7 +780,7 @@ void juku_state::juku(machine_config &config) // К155ИВ1 TTL74148(config, m_key_encoder, 0); - // E4701 + // E4701 (joystick like mouse device) JUKU_MOUSE(config, m_mouse); m_mouse->int_handler().set(m_pic, FUNC(pic8259_device::ir6_w)); @@ -808,7 +803,7 @@ ROM_START( juku ) ROM_REGION(0x4000, "maincpu", 0) // Monitor 3.3 with Bootstrap 3.3, FDC 1791 from early 1985 prototype - // Does not seem to be compatible with JBASIC extension cartridge + // Does not seem to be compatible with JBASIC expansion cartridge ROM_SYSTEM_BIOS(0, "jmon3.3", "Monitor/Bootstrap 3.3 \\w JBASIC") ROMX_LOAD("jmon33.bin", 0x0000, 0x4000, CRC(ed22c287) SHA1(76407d99bf83035ef526d980c9468cb04972608c), ROM_BIOS(0)) @@ -837,7 +832,7 @@ ROM_START( juku ) ROM_SYSTEM_BIOS(5, "2.43m_43", "Tape/Disk \\w AT keyb (2.43m #0043)") ROMX_LOAD("ekta43.bin", 0x0000, 0x4000, CRC(05678f9f) SHA1(a7419bfd8249871cc7dbf5c6ea85022d6963fc9a), ROM_BIOS(5)) - ROM_REGION(0x8000, "extension", 0) + ROM_REGION(0x8000, "expcart", 0) // EKTA JBASIC cartridge (buggy) seems similar to v1.1 from 14.09.1987. // There is also a version with additional HEX$ directive for EKDOS. From 77689b91e839ea0ef851d757a085ba75440b8032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Sat, 4 Jan 2025 20:04:18 +0200 Subject: [PATCH 6/9] Update TODO list and remove year from JMON description --- src/mame/ussr/juku.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index 8ab849db66e0a..748580f626825 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -21,8 +21,10 @@ and T to boot from tape/disk/network TODO: + - E5103 (Juss) and IBM AT keyboard layouts? - Work out how the floppy interface really works? - Tape? (split up to E5101 batch as tape only?) + - Separate FDC 1791, 1792 and 1793 versions - И41 (=Multibus-1) compatibility? - Network? - Ramdisk? @@ -802,7 +804,7 @@ ROM_START( juku ) ROM_DEFAULT_BIOS("3.43m_37") ROM_REGION(0x4000, "maincpu", 0) - // Monitor 3.3 with Bootstrap 3.3, FDC 1791 from early 1985 prototype + // Monitor 3.3 with Bootstrap 3.3, FDC 1791 from early prototypes // Does not seem to be compatible with JBASIC expansion cartridge ROM_SYSTEM_BIOS(0, "jmon3.3", "Monitor/Bootstrap 3.3 \\w JBASIC") ROMX_LOAD("jmon33.bin", 0x0000, 0x4000, CRC(ed22c287) SHA1(76407d99bf83035ef526d980c9468cb04972608c), ROM_BIOS(0)) From 5e295f7f37a93cc615621e159f4c13fce86c6bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Tue, 7 Jan 2025 08:10:28 +0200 Subject: [PATCH 7/9] Reduce mouse rate to 600 Hz to better mimic GTR behaviour --- src/mame/ussr/jukumouse.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mame/ussr/jukumouse.cpp b/src/mame/ussr/jukumouse.cpp index d141775a608e0..c8a4d6cc49dcf 100644 --- a/src/mame/ussr/jukumouse.cpp +++ b/src/mame/ussr/jukumouse.cpp @@ -9,6 +9,8 @@ #include "logmacro.h" +static constexpr int MOUSE_RATE_HZ = 600; + DEFINE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device, "juku_mouse", "Juku E510x mouse") juku_mouse_device::juku_mouse_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) @@ -33,7 +35,7 @@ void juku_mouse_device::device_reset() m_prev_mouse_y = 0; m_prev_mouse_x = 0; m_prev_byte = 0; - m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(1400)); + m_mouse_timer->adjust(attotime::zero, 0, attotime::from_hz(MOUSE_RATE_HZ)); } /* From fddf8ea9f58af7fcb7c7da49f2513b6c8794ac9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Fri, 10 Jan 2025 02:11:08 +0200 Subject: [PATCH 8/9] Make timer #3 clock 2 copy real E5104 (~49.920128 Hz) --- src/mame/ussr/juku.cpp | 16 ++++++---------- src/mame/ussr/jukumouse.cpp | 1 + 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/mame/ussr/juku.cpp b/src/mame/ussr/juku.cpp index 748580f626825..ec4c7fa77131c 100644 --- a/src/mame/ussr/juku.cpp +++ b/src/mame/ussr/juku.cpp @@ -725,30 +725,26 @@ void juku_state::juku(machine_config &config) m_pit[0]->out_handler<0>().set(m_pit[1], FUNC(pit8253_device::write_clk0)); m_pit[0]->out_handler<0>().append(m_pit[0], FUNC(pit8253_device::write_gate1)); m_pit[0]->out_handler<0>().append(m_pit[0], FUNC(pit8253_device::write_gate2)); - //m_pit[0]->out_handler<1>().set(, ); // HOR RTR - //m_pit[0]->out_handler<1>().append(, ); // HOR RTR + //m_pit[0]->out_handler<1>().set(?, ?); // HOR RTR // КР580ВИ53 #2 PIT8253(config, m_pit[1], 0); - m_pit[0]->out_handler<2>().set(m_pit[1], FUNC(pit8253_device::write_clk1)); // H SYNC DSL + m_pit[0]->out_handler<2>().set(m_pit[1], FUNC(pit8253_device::write_clk1)); // HOR SYNC DSL m_pit[0]->out_handler<2>().append(m_pit[1], FUNC(pit8253_device::write_clk2)); m_pit[1]->out_handler<0>().append(m_pit[1], FUNC(pit8253_device::write_gate1)); m_pit[1]->out_handler<0>().append(m_pit[1], FUNC(pit8253_device::write_gate2)); m_pit[1]->out_handler<1>().set(m_pic, FUNC(pic8259_device::ir5_w)); // VER RTR / FRAME INT - - //m_pit[1]->out_handler<2>().append(m_pit[1], FUNC(pit8253_device::write_clk1)); // VERT SYNC DSL + //m_pit[1]->out_handler<2>().set(m_pit[1], FUNC(pit8253_device::write_clk1)); // VERT SYNC DSL //m_pit[1]->out_handler<2>().append(m_pit[1], FUNC(pit8253_device::write_clk2)); // КР580ВИ53 #3 PIT8253(config, m_pit[2], 0); - m_pit[2]->set_clk<0>(16_MHz_XTAL/13); // 1.23 MHz m_pit[2]->set_clk<1>(16_MHz_XTAL/8); // 2 MHz - m_pit[2]->set_clk<2>(16_MHz_XTAL/13); // 1.23 MHz - - //m_pit[1]->out_handler<0>().append(...); // BAUD RATE + m_pit[1]->out_handler<1>().append(m_pit[2], FUNC(pit8253_device::write_clk2)); // ~49.92 Hz + //m_pit[2]->out_handler<0>().set(?, ?); // BAUD RATE m_pit[2]->out_handler<1>().append(FUNC(juku_state::speaker_w)); // SOUND - //m_pit[1]->out_handler<2>().append(...); // SYNC BAUD RATE + //m_pit[2]->out_handler<2>().set(?, ?); // SYNC BAUD RATE // КР580ВВ55A #1 (=КР580ИК55) I8255A(config, m_pio[0]); diff --git a/src/mame/ussr/jukumouse.cpp b/src/mame/ussr/jukumouse.cpp index c8a4d6cc49dcf..91616e2d6f20f 100644 --- a/src/mame/ussr/jukumouse.cpp +++ b/src/mame/ussr/jukumouse.cpp @@ -9,6 +9,7 @@ #include "logmacro.h" +// measured avg in heavy use 442-520, max ~1400Hz static constexpr int MOUSE_RATE_HZ = 600; DEFINE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device, "juku_mouse", "Juku E510x mouse") From e7fffcccb6b946629f980cc71d3cc51afcf40075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4rt=20P=C3=B5der?= Date: Sat, 11 Jan 2025 13:54:22 +0200 Subject: [PATCH 9/9] Rename preprocessor variable to full MAME_USSR_JUKUMOUSE_H --- src/mame/ussr/jukumouse.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mame/ussr/jukumouse.h b/src/mame/ussr/jukumouse.h index 01b68eea0984d..a91f7da5432f0 100644 --- a/src/mame/ussr/jukumouse.h +++ b/src/mame/ussr/jukumouse.h @@ -1,8 +1,8 @@ // license: BSD-3-Clause // copyright-holders:Märt Põder -#ifndef MAME_USSR_JUKU_H -#define MAME_USSR_JUKU_H +#ifndef MAME_USSR_JUKUMOUSE_H +#define MAME_USSR_JUKUMOUSE_H #pragma once @@ -27,4 +27,4 @@ class juku_mouse_device : public device_t DECLARE_DEVICE_TYPE(JUKU_MOUSE, juku_mouse_device) -#endif // MAME_USSR_JUKU_H +#endif // MAME_USSR_JUKUMOUSE_H