From b10b7366d7828a82231294ad02c00038879702ad Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 10 May 2024 05:16:43 +1000 Subject: [PATCH] Added touch-enamed layouts for Touchmaster and Paint'N Puzzle. midway/tmaster.cpp: Recycled touch-enabled Megatouch XL layout. misc/pntnpuzl.cpp: Added touch-enabled layout with touchscreen and buttons. All gameplay controls work with mouse/touch. misc/pntnpuzl.cpp: Added checks for debugger accesses on reads with side effects and added object finders for inputs. --- .../layout/{mtouchxl.lay => microtouch.lay} | 4 +- src/mame/layout/pntnpuzl.lay | 142 ++++++++++++++++++ src/mame/merit/mtouchxl.cpp | 8 +- src/mame/midway/tmaster.cpp | 7 + src/mame/misc/pntnpuzl.cpp | 81 ++++++---- src/mame/shared/microtouchlayout.cpp | 15 ++ src/mame/shared/microtouchlayout.h | 19 +++ 7 files changed, 239 insertions(+), 37 deletions(-) rename src/mame/layout/{mtouchxl.lay => microtouch.lay} (95%) create mode 100644 src/mame/layout/pntnpuzl.lay create mode 100644 src/mame/shared/microtouchlayout.cpp create mode 100644 src/mame/shared/microtouchlayout.h diff --git a/src/mame/layout/mtouchxl.lay b/src/mame/layout/microtouch.lay similarity index 95% rename from src/mame/layout/mtouchxl.lay rename to src/mame/layout/microtouch.lay index 32b8d1235f6..6f9f36c8894 100644 --- a/src/mame/layout/mtouchxl.lay +++ b/src/mame/layout/microtouch.lay @@ -49,8 +49,8 @@ license:CC0-1.0 if (x >= l) and (x < r) and (y >= t) and (y < b) then inside = true btn_field:set_value(1) - x_field:set_value(floor((x - l) * x_scale)) - y_field:set_value(floor((y - t) * y_scale)) + x_field:set_value(floor(0.5 + ((x - l) * x_scale))) + y_field:set_value(floor(0.5 + ((y - t) * y_scale))) elseif inside then inside = false release_touch() diff --git a/src/mame/layout/pntnpuzl.lay b/src/mame/layout/pntnpuzl.lay new file mode 100644 index 00000000000..b3b0e2c7880 --- /dev/null +++ b/src/mame/layout/pntnpuzl.lay @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mame/merit/mtouchxl.cpp b/src/mame/merit/mtouchxl.cpp index 95537dae9e0..af5c150abe2 100644 --- a/src/mame/merit/mtouchxl.cpp +++ b/src/mame/merit/mtouchxl.cpp @@ -31,6 +31,8 @@ #include "emu.h" +#include "microtouchlayout.h" + #include "bus/ata/atapicdr.h" #include "bus/ata/hdd.h" #include "bus/isa/isa_cards.h" @@ -52,8 +54,6 @@ #include "speaker.h" -#include "mtouchxl.lh" - namespace { @@ -292,7 +292,7 @@ void mtxl_state::at486(machine_config &config) //MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024) #endif - config.set_default_layout(layout_mtouchxl); + config.set_default_layout(layout_microtouch); } void mtxl_state::at486hd(machine_config &config) @@ -353,7 +353,7 @@ void mtxl_state::at486hd(machine_config &config) //MCFG_SIS85C496_ADD(":pci:05.0", ":maincpu", 32*1024*1024) #endif - config.set_default_layout(layout_mtouchxl); + config.set_default_layout(layout_microtouch); } #ifdef REAL_PCI_CHIPSET diff --git a/src/mame/midway/tmaster.cpp b/src/mame/midway/tmaster.cpp index 95714e735e3..9ea1556ba2c 100644 --- a/src/mame/midway/tmaster.cpp +++ b/src/mame/midway/tmaster.cpp @@ -90,6 +90,9 @@ Chips: ***************************************************************************/ #include "emu.h" + +#include "microtouchlayout.h" + #include "cpu/m68000/m68000.h" #include "machine/ds1204.h" #include "machine/mc68681.h" @@ -99,6 +102,7 @@ Chips: #include "machine/watchdog.h" #include "sound/okim6295.h" #include "video/cesblit.h" + #include "emupal.h" #include "screen.h" #include "speaker.h" @@ -410,11 +414,14 @@ void tmaster_state::tm(machine_config &config) SPEAKER(config, "mono").front_center(); OKIM6295(config, m_oki, XTAL(24'000'000) / 16, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "mono", 1.0); /* 1.5Mhz? clock frequency & pin 7 not verified */ + + config.set_default_layout(layout_microtouch); } void tmaster_state::tmds1204(machine_config &config) { tm(config); + DS1204(config, "ds1204", 0); } diff --git a/src/mame/misc/pntnpuzl.cpp b/src/mame/misc/pntnpuzl.cpp index 911881c3d90..03cd9aa04c4 100644 --- a/src/mame/misc/pntnpuzl.cpp +++ b/src/mame/misc/pntnpuzl.cpp @@ -1,9 +1,9 @@ // license:BSD-3-Clause // copyright-holders:David Haywood -/* paint & puzzle */ -/* video is standard VGA */ /* -OK, here's a somewhat complete rundown of the PCB. +paint & puzzle + +video is standard VGA Main PCB Reb B @@ -138,6 +138,7 @@ CN1 standard DB15 VGA connector (15KHz) */ #include "emu.h" + #include "cpu/m68000/m68000.h" #include "cpu/mcs96/i8x9x.h" #include "machine/6522via.h" @@ -146,6 +147,11 @@ CN1 standard DB15 VGA connector (15KHz) #include "screen.h" +//#define VERBOSE 1 +#include "logmacro.h" + +#include "pntnpuzl.lh" + namespace { @@ -158,6 +164,8 @@ public: , m_svga(*this, "svga") , m_via(*this, "via") , m_screen(*this, "screen") + , m_in0(*this, "IN0") + , m_touch(*this, { "TOUCHX", "TOUCHY" }) { } void pntnpuzl(machine_config &config); @@ -171,6 +179,8 @@ private: required_device m_svga; required_device m_via; required_device m_screen; + required_ioport m_in0; + required_ioport_array<2> m_touch; uint16_t m_pntpzl_200000 = 0; uint16_t m_serial = 0; @@ -178,8 +188,6 @@ private: uint16_t m_read_count = 0; int m_touchscr[5]{}; - - void pntnpuzl_200000_w(uint16_t data); void pntnpuzl_280018_w(uint16_t data); uint16_t pntnpuzl_280014_r(); @@ -217,7 +225,7 @@ write read void pntnpuzl_state::pntnpuzl_200000_w(uint16_t data) { -// logerror("200000: %04x\n",data); + LOG("200000: %04x\n", data); // bit 12: set to 1 when going to serial output to 280018 if ((m_pntpzl_200000 & 0x1000) && !(data & 0x1000)) { @@ -231,7 +239,7 @@ void pntnpuzl_state::pntnpuzl_200000_w(uint16_t data) void pntnpuzl_state::pntnpuzl_280018_w(uint16_t data) { -// logerror("%04x: 280018: %04x\n",m_maincpu->pc(),data); + LOG("%04x: 280018: %04x\n", m_maincpu->pc(), data); m_serial >>= 1; if (data & 0x2000) m_serial |= 0x400; @@ -241,56 +249,67 @@ void pntnpuzl_state::pntnpuzl_280018_w(uint16_t data) uint16_t pntnpuzl_state::pntnpuzl_280014_r() { - static const int startup[3] = { 0x80, 0x0c, 0x00 }; + constexpr int startup[3] = { 0x80, 0x0c, 0x00 }; int res; (void)m_via->read(0x14/2); - if (m_serial_out == 0x11) + if (!machine().side_effects_disabled()) { - if (ioport("IN0")->read() & 0x10) + if (m_serial_out == 0x11) { - m_touchscr[0] = 0x1b; - m_touchscr[2] = bitswap<8>(ioport("TOUCHX")->read(),0,1,2,3,4,5,6,7); - m_touchscr[4] = bitswap<8>(ioport("TOUCHY")->read(),0,1,2,3,4,5,6,7); + if (m_in0->read() & 0x10) + { + m_touchscr[0] = 0x1b; + m_touchscr[2] = bitswap<8>(m_touch[0]->read(), 0, 1, 2, 3, 4, 5, 6, 7); + m_touchscr[4] = bitswap<8>(m_touch[1]->read(), 0, 1, 2, 3, 4, 5, 6, 7); + } + else + { + m_touchscr[0] = 0; + } + + if (m_read_count >= 10) + m_read_count = 0; + res = m_touchscr[m_read_count / 2]; + m_read_count++; } else - m_touchscr[0] = 0; - - if (m_read_count >= 10) m_read_count = 0; - res = m_touchscr[m_read_count/2]; - m_read_count++; + { + if (m_read_count >= 6) + m_read_count = 0; + res = startup[m_read_count / 2]; + m_read_count++; + } + logerror("read 280014: %02x\n",res); } else { - if (m_read_count >= 6) m_read_count = 0; - res = startup[m_read_count/2]; - m_read_count++; + res = (m_serial_out == 0x11) ? m_touchscr[m_read_count / 2] : startup[m_read_count / 2]; } - logerror("read 280014: %02x\n",res); return res << 8; } uint16_t pntnpuzl_state::pntnpuzl_28001a_r() { - return 0x0c00 | (m_via->read(0x1a/2) << 8); + return 0x0c00 | (m_via->read(0x1a / 2) << 8); } uint16_t pntnpuzl_state::irq1_ack_r() { -// m_maincpu->set_input_line(1, CLEAR_LINE); + //if (!machine().side_effects_disabled()) m_maincpu->set_input_line(1, CLEAR_LINE); return 0; } uint16_t pntnpuzl_state::irq2_ack_r() { -// m_maincpu->set_input_line(2, CLEAR_LINE); + //if (!machine().side_effects_disabled()) m_maincpu->set_input_line(2, CLEAR_LINE); return 0; } uint16_t pntnpuzl_state::irq4_ack_r() { -// m_maincpu->set_input_line(4, CLEAR_LINE); + //if (!machine().side_effects_disabled()) m_maincpu->set_input_line(4, CLEAR_LINE); return 0; } @@ -324,13 +343,13 @@ void pntnpuzl_state::mcu_map(address_map &map) INPUT_CHANGED_MEMBER(pntnpuzl_state::coin_inserted) { - /* TODO: change this! */ - if(newval) - m_maincpu->pulse_input_line((uint8_t)param, m_maincpu->minimum_quantum_time()); + // TODO: change this! + if (newval) + m_maincpu->pulse_input_line(uint8_t(param), m_maincpu->minimum_quantum_time()); } static INPUT_PORTS_START( pntnpuzl ) - PORT_START("IN0") /* fake inputs */ + PORT_START("IN0") // fake inputs PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen") PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, pntnpuzl_state,coin_inserted, 1) PORT_IMPULSE(1) PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_HIGH )PORT_CHANGED_MEMBER(DEVICE_SELF, pntnpuzl_state,coin_inserted, 2) PORT_IMPULSE(1) @@ -427,4 +446,4 @@ void pntnpuzl_state::init_pip() } // anonymous namespace -GAME( 1993, pntnpuzl, 0, pntnpuzl, pntnpuzl, pntnpuzl_state, init_pip, ROT90, "Century Vending", "Paint 'N Puzzle", MACHINE_NO_SOUND | MACHINE_NOT_WORKING ) +GAMEL( 1993, pntnpuzl, 0, pntnpuzl, pntnpuzl, pntnpuzl_state, init_pip, ROT90, "Century Vending", "Paint 'N Puzzle", MACHINE_NO_SOUND | MACHINE_NOT_WORKING, layout_pntnpuzl ) diff --git a/src/mame/shared/microtouchlayout.cpp b/src/mame/shared/microtouchlayout.cpp new file mode 100644 index 00000000000..9abf8923654 --- /dev/null +++ b/src/mame/shared/microtouchlayout.cpp @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/********************************************************************* + + microtouchlayout.cpp + + Touch-enabled layout for systems with a single screen and a + Microtouch panel at :microtouch. + +*********************************************************************/ + +#include "emu.h" +#include "microtouchlayout.h" + +#include "microtouch.lh" diff --git a/src/mame/shared/microtouchlayout.h b/src/mame/shared/microtouchlayout.h new file mode 100644 index 00000000000..ccec23b389c --- /dev/null +++ b/src/mame/shared/microtouchlayout.h @@ -0,0 +1,19 @@ +// license:BSD-3-Clause +// copyright-holders:Vas Crabb +/********************************************************************* + + microtouchlayout.h + + Touch-enabled layout for systems with a single screen and a + Microtouch panel at :microtouch. + +*********************************************************************/ + +#ifndef MAME_SHARED_MICROTOUCHLAYOUT_H +#define MAME_SHARED_MICROTOUCHLAYOUT_H + +#pragma once + +extern const internal_layout layout_microtouch; + +#endif // MAME_SHARED_MICROTOUCHLAYOUT_H