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.
This commit is contained in:
Vas Crabb 2024-05-10 05:16:43 +10:00
parent de8d9d7886
commit b10b7366d7
7 changed files with 239 additions and 37 deletions

View File

@ -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()

View File

@ -0,0 +1,142 @@
<?xml version="1.0"?>
<!--
license:CC0-1.0
-->
<mamelayout version="2">
<element name="circle">
<disk />
</element>
<view name="Touch-Enabled" showpointers="yes">
<bounds x="0" y="0" width="4.5" height="4" />
<screen id="screen" index="0">
<bounds left="0" top="0" right="3" bottom="4" />
</screen>
<element ref="circle" inputtag="IN1" inputmask="0x02">
<color red="1" green="0.796" blue="0.573" />
<bounds x="3.1" y="0.15" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN1" inputmask="0x01">
<color red="0.780" green="0.396" blue="0" />
<bounds x="3.1" y="0.85" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x80">
<color red="0" green="1" blue="0" />
<bounds x="3.1" y="1.55" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x40">
<color red="0.635" green="0.765" blue="1" />
<bounds x="3.1" y="2.25" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x20">
<color red="1" green="0.427" blue="1" />
<bounds x="3.1" y="2.95" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x10">
<color red="1" green="0" blue="0" />
<bounds x="3.8" y="0.45" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x08">
<color red="0.188" green="0.349" blue="0.984" />
<bounds x="3.8" y="1.15" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x04">
<color red="0" green="0.588" blue="0" />
<bounds x="3.8" y="1.85" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x02">
<color red="1" green="1" blue="0" />
<bounds x="3.8" y="2.55" width="0.6" height="0.6" />
</element>
<element ref="circle" inputtag="IN2" inputmask="0x01">
<color red="1" green="1" blue="1" />
<bounds x="3.8" y="3.25" width="0.6" height="0.6" />
</element>
</view>
<script><![CDATA[
file:set_resolve_tags_callback(
function ()
-- get the touchscreen I/O port fields - X/Y reversed for rotated screen
local btn_field = file.device:ioport('IN0'):field(0x10)
local x_field = file.device:ioport('TOUCHY'):field(0x7f)
local y_field = file.device:ioport('TOUCHX'):field(0x7f)
-- for mapping coordinates
local view = file.views['Touch-Enabled']
local scr_item = view.items['screen']
local floor = math.floor
local l, r, t, b
local x_scale, y_scale
-- pointer state
local ptr_id = nil
local inside = false
local function release_touch()
btn_field:clear_value()
x_field:clear_value()
y_field:clear_value()
end
local function recomputed()
local bounds = scr_item.bounds
l = bounds.x0
r = bounds.x1
t = bounds.y0
b = bounds.y1
x_scale = 0x7f / bounds.width
y_scale = 0x7f / bounds.height
end
local function check_pointer(x, y)
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(0.5 + ((x - l) * x_scale)))
y_field:set_value(floor(0.5 + ((y - t) * y_scale)))
elseif inside then
inside = false
release_touch()
end
end
local function forget_pointer()
if inside then
release_touch()
end
ptr_id = nil
inside = false
end
local function pointer_updated(type, id, dev, x, y, btn, dn, up, cnt)
if ptr_id == id then
if (btn & 0x01) == 0 then
forget_pointer()
else
check_pointer(x, y)
end
elseif (not ptr_id) and ((dn & 0x01) ~= 0) and (x >= l) and (x < r) and (y >= t) and (y < b) then
ptr_id = id
check_pointer(x, y)
end
end
local function pointer_lost(type, id, dev, x, y, up, cnt)
if ptr_id == id then
forget_pointer()
end
end
-- attach callbacks to view
view:set_recomputed_callback(recomputed)
view:set_pointer_updated_callback(pointer_updated)
view:set_pointer_left_callback(pointer_lost)
view:set_pointer_aborted_callback(pointer_lost)
view:set_forget_pointers_callback(forget_pointer)
end)
]]></script>
</mamelayout>

View File

@ -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

View File

@ -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);
}

View File

@ -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<tvga9000_device> m_svga;
required_device<via6522_device> m_via;
required_device<screen_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 )

View File

@ -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"

View File

@ -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