mirror of
https://github.com/holub/mame
synced 2025-05-28 16:43:04 +03:00
Hooked up touch screen to Odeon Twister 2 [Mariusz Wojcieszek]
This commit is contained in:
parent
56f7f75901
commit
5fc1b023b4
@ -14,6 +14,24 @@
|
||||
|
||||
#define LOG 0
|
||||
|
||||
enum MICROTOUCH_FORMAT
|
||||
{
|
||||
FORMAT_UNKNOWN,
|
||||
FORMAT_TABLET,
|
||||
FORMAT_DECIMAL
|
||||
};
|
||||
|
||||
ALLOW_SAVE_TYPE(MICROTOUCH_FORMAT);
|
||||
|
||||
enum MICROTOUCH_MODE
|
||||
{
|
||||
MODE_INACTIVE,
|
||||
MODE_STREAM,
|
||||
MODE_POINT
|
||||
};
|
||||
|
||||
ALLOW_SAVE_TYPE(MICROTOUCH_MODE);
|
||||
|
||||
static struct
|
||||
{
|
||||
UINT8 rx_buffer[16];
|
||||
@ -23,10 +41,8 @@ static struct
|
||||
UINT8 tx_buffer_num;
|
||||
UINT8 tx_buffer_ptr;
|
||||
int reset_done;
|
||||
int format_tablet;
|
||||
int format_decimal;
|
||||
int mode_inactive;
|
||||
int mode_stream;
|
||||
MICROTOUCH_FORMAT format;
|
||||
MICROTOUCH_MODE mode;
|
||||
int last_touch_state;
|
||||
int last_x;
|
||||
int last_y;
|
||||
@ -90,6 +106,33 @@ static void microtouch_send_format_decimal_packet(int x, int y)
|
||||
microtouch.tx_buffer[microtouch.tx_buffer_num++] = 0x0d;
|
||||
}
|
||||
|
||||
static void microtouch_send_touch_packet(running_machine &machine)
|
||||
{
|
||||
int tx = input_port_read(machine, "TOUCH_X");
|
||||
int ty = input_port_read(machine, "TOUCH_Y");
|
||||
|
||||
if ( microtouch.touch_callback == NULL ||
|
||||
microtouch.touch_callback( machine, &tx, &ty ) != 0 )
|
||||
{
|
||||
ty = 0x4000 - ty;
|
||||
|
||||
switch( microtouch.format )
|
||||
{
|
||||
case FORMAT_TABLET:
|
||||
microtouch_send_format_table_packet(0xc8, tx, ty);
|
||||
break;
|
||||
case FORMAT_DECIMAL:
|
||||
microtouch_send_format_decimal_packet(tx, ty);
|
||||
break;
|
||||
case FORMAT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
microtouch.last_touch_state = 1;
|
||||
microtouch.last_x = tx;
|
||||
microtouch.last_y = ty;
|
||||
}
|
||||
}
|
||||
|
||||
static TIMER_CALLBACK(microtouch_timer_callback)
|
||||
{
|
||||
if ( microtouch.tx_buffer_ptr < microtouch.tx_buffer_num )
|
||||
@ -103,9 +146,8 @@ static TIMER_CALLBACK(microtouch_timer_callback)
|
||||
}
|
||||
|
||||
if ( (microtouch.reset_done == 0) ||
|
||||
((microtouch.format_tablet == 0) && (microtouch.format_decimal == 0)) ||
|
||||
(microtouch.mode_inactive == 1) ||
|
||||
(microtouch.mode_stream == 0) )
|
||||
(microtouch.format == FORMAT_UNKNOWN) ||
|
||||
(microtouch.mode != MODE_STREAM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -113,39 +155,23 @@ static TIMER_CALLBACK(microtouch_timer_callback)
|
||||
// send format tablet packet
|
||||
if ( input_port_read(machine, "TOUCH") & 0x01 )
|
||||
{
|
||||
int tx = input_port_read(machine, "TOUCH_X");
|
||||
int ty = input_port_read(machine, "TOUCH_Y");
|
||||
|
||||
if ( microtouch.touch_callback == NULL ||
|
||||
microtouch.touch_callback( machine, &tx, &ty ) != 0 )
|
||||
{
|
||||
ty = 0x4000 - ty;
|
||||
|
||||
if ( microtouch.format_tablet )
|
||||
{
|
||||
microtouch_send_format_table_packet(0xc8, tx, ty);
|
||||
}
|
||||
else if ( microtouch.format_decimal )
|
||||
{
|
||||
microtouch_send_format_decimal_packet(tx, ty);
|
||||
}
|
||||
microtouch.last_touch_state = 1;
|
||||
microtouch.last_x = tx;
|
||||
microtouch.last_y = ty;
|
||||
}
|
||||
microtouch_send_touch_packet(machine);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( microtouch.last_touch_state == 1 )
|
||||
{
|
||||
microtouch.last_touch_state = 0;
|
||||
if ( microtouch.format_tablet )
|
||||
switch( microtouch.format )
|
||||
{
|
||||
microtouch_send_format_table_packet(0x88, microtouch.last_x, microtouch.last_y);
|
||||
}
|
||||
else if ( microtouch.format_decimal )
|
||||
{
|
||||
microtouch_send_format_decimal_packet(microtouch.last_x, microtouch.last_y);
|
||||
case FORMAT_TABLET:
|
||||
microtouch_send_format_table_packet(0x88, microtouch.last_x, microtouch.last_y);
|
||||
break;
|
||||
case FORMAT_DECIMAL:
|
||||
microtouch_send_format_decimal_packet(microtouch.last_x, microtouch.last_y);
|
||||
break;
|
||||
case FORMAT_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,10 +188,10 @@ void microtouch_init(running_machine &machine, microtouch_tx_func tx_cb, microto
|
||||
microtouch.timer = machine.scheduler().timer_alloc(FUNC(microtouch_timer_callback));
|
||||
microtouch.timer->adjust(attotime::from_hz(167*5), 0, attotime::from_hz(167*5));
|
||||
|
||||
microtouch.format = FORMAT_UNKNOWN;
|
||||
microtouch.mode = MODE_INACTIVE;
|
||||
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.reset_done);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.format_tablet);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.mode_inactive);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.mode_stream);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_touch_state);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_x);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.last_y);
|
||||
@ -174,8 +200,8 @@ void microtouch_init(running_machine &machine, microtouch_tx_func tx_cb, microto
|
||||
state_save_register_item_array(machine, "microtouch", NULL, 0, microtouch.tx_buffer);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.tx_buffer_num);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.tx_buffer_ptr);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.format_decimal);
|
||||
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.format);
|
||||
state_save_register_item(machine, "microtouch", NULL, 0, microtouch.mode);
|
||||
};
|
||||
|
||||
|
||||
@ -201,12 +227,15 @@ void microtouch_rx(int count, UINT8* data)
|
||||
// check command
|
||||
if ( microtouch_check_command( "MS", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
microtouch.mode_stream = 1;
|
||||
microtouch.mode_inactive = 0;
|
||||
microtouch.mode = MODE_STREAM;
|
||||
}
|
||||
else if ( microtouch_check_command( "MI", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
microtouch.mode_inactive = 1;
|
||||
microtouch.mode = MODE_INACTIVE;
|
||||
}
|
||||
else if ( microtouch_check_command( "MP", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
microtouch.mode = MODE_POINT;
|
||||
}
|
||||
else if ( microtouch_check_command( "R", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
@ -215,11 +244,11 @@ void microtouch_rx(int count, UINT8* data)
|
||||
}
|
||||
else if ( microtouch_check_command( "FT", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
microtouch.format_tablet = 1;
|
||||
microtouch.format = FORMAT_TABLET;
|
||||
}
|
||||
else if ( microtouch_check_command( "FD", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
microtouch.format_decimal = 1;
|
||||
microtouch.format = FORMAT_DECIMAL;
|
||||
}
|
||||
else if ( microtouch_check_command("OI", microtouch.rx_buffer_ptr, microtouch.rx_buffer ) )
|
||||
{
|
||||
@ -243,9 +272,17 @@ void microtouch_rx(int count, UINT8* data)
|
||||
}
|
||||
};
|
||||
|
||||
static INPUT_CHANGED( microtouch_touch )
|
||||
{
|
||||
if ( newval && ( microtouch.mode == MODE_POINT ) )
|
||||
{
|
||||
microtouch_send_touch_packet( field.machine() );
|
||||
}
|
||||
}
|
||||
|
||||
INPUT_PORTS_START(microtouch)
|
||||
PORT_START("TOUCH")
|
||||
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME( "Touch screen" )
|
||||
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME( "Touch screen" ) PORT_CHANGED( microtouch_touch, 0 )
|
||||
PORT_START("TOUCH_X")
|
||||
PORT_BIT( 0x3fff, 0x2000, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(45) PORT_KEYDELTA(15)
|
||||
PORT_START("TOUCH_Y")
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "includes/cd32.h"
|
||||
#include "sound/cdda.h"
|
||||
#include "imagedev/chd_cd.h"
|
||||
#include "machine/microtch.h"
|
||||
|
||||
#define CD32PAL_XTAL_X1 XTAL_28_37516MHz
|
||||
#define CD32PAL_XTAL_X2 XTAL_4_433619MHz
|
||||
@ -1369,6 +1370,110 @@ static DRIVER_INIT(mgprem11)
|
||||
state->m_input_hack = mgprem11_input_hack;
|
||||
}
|
||||
|
||||
static INPUT_PORTS_START( odeontw2 )
|
||||
// PORT_INCLUDE( cd32 )
|
||||
PORT_INCLUDE( microtouch )
|
||||
|
||||
PORT_START("CIA0PORTA")
|
||||
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
PORT_START("CIA0PORTB")
|
||||
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNKNOWN )
|
||||
|
||||
|
||||
PORT_START("DIPSW1")
|
||||
PORT_DIPNAME( 0x01, 0x01, "DSW1 1" )
|
||||
PORT_DIPSETTING( 0x01, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x02, 0x02, "DSW1 2" )
|
||||
PORT_DIPSETTING( 0x02, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x04, 0x04, "DSW1 3" )
|
||||
PORT_DIPSETTING( 0x04, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x08, 0x08, "DSW1 4" )
|
||||
PORT_DIPSETTING( 0x08, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x10, 0x10, "DSW1 5" )
|
||||
PORT_DIPSETTING( 0x10, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x20, 0x20, "DSW1 6" )
|
||||
PORT_DIPSETTING( 0x20, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x40, 0x40, "DSW1 7" )
|
||||
PORT_DIPSETTING( 0x40, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x80, 0x80, "DSW1 8" )
|
||||
PORT_DIPSETTING( 0x80, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
|
||||
PORT_START("DIPSW2")
|
||||
PORT_DIPNAME( 0x01, 0x01, "DSW2 1" )
|
||||
PORT_DIPSETTING( 0x01, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x02, 0x02, "DSW2 2" )
|
||||
PORT_DIPSETTING( 0x02, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x04, 0x04, "DSW2 3" )
|
||||
PORT_DIPSETTING( 0x04, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x08, 0x08, "DSW2 4" )
|
||||
PORT_DIPSETTING( 0x08, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x10, 0x10, "DSW2 5" )
|
||||
PORT_DIPSETTING( 0x10, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x20, 0x20, "DSW2 6" )
|
||||
PORT_DIPSETTING( 0x20, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x40, 0x40, "DSW2 7" )
|
||||
PORT_DIPSETTING( 0x40, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
PORT_DIPNAME( 0x80, 0x80, "DSW2 8" )
|
||||
PORT_DIPSETTING( 0x80, "Reset" )
|
||||
PORT_DIPSETTING( 0x00, "Set" )
|
||||
|
||||
INPUT_PORTS_END
|
||||
|
||||
static void serial_w(running_machine &machine, UINT16 data)
|
||||
{
|
||||
UINT8 data8 = data & 0xff;
|
||||
if ( data8 != 0x00 )
|
||||
microtouch_rx(1, &data8);
|
||||
}
|
||||
|
||||
static void microtouch_tx(running_machine &machine, UINT8 data)
|
||||
{
|
||||
amiga_serial_in_w(machine, data);
|
||||
}
|
||||
|
||||
static DRIVER_INIT( odeontw2 )
|
||||
{
|
||||
cd32_state *state = machine.driver_data<cd32_state>();
|
||||
static const amiga_machine_interface cd32_intf =
|
||||
{
|
||||
AGA_CHIP_RAM_MASK,
|
||||
NULL, NULL, cd32_potgo_w,
|
||||
NULL, NULL, serial_w,
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
FLAGS_AGA_CHIPSET
|
||||
};
|
||||
|
||||
/* configure our Amiga setup */
|
||||
amiga_machine_config(machine, &cd32_intf);
|
||||
|
||||
/* set up memory */
|
||||
memory_configure_bank(machine, "bank1", 0, 1, state->m_chip_ram, 0);
|
||||
memory_configure_bank(machine, "bank1", 1, 1, machine.region("user1")->base(), 0);
|
||||
|
||||
/* input hack */
|
||||
state->m_input_hack = NULL;
|
||||
|
||||
/* touch screen */
|
||||
microtouch_init(machine, microtouch_tx, NULL);
|
||||
}
|
||||
|
||||
/***************************************************************************************************/
|
||||
|
||||
// these are clones of the cd32 SYSTEM because they run on a stock retail unit, with additional HW
|
||||
@ -1379,4 +1484,4 @@ GAME( 1995, lsrquiz2, cd32, cd32base, lsrquiz2, lsrquiz2, ROT0, "CD Express", "L
|
||||
GAME( 1995, lasstixx, cd32, cd32base, lasstixx, lasstixx, ROT0, "CD Express", "Laser Strixx 2", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND )
|
||||
GAME( 1995, mgnumber, cd32, cd32base, mgnumber, mgnumber, ROT0, "CD Express", "Magic Number", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND )
|
||||
GAME( 1996, mgprem11, cd32, cd32base, mgprem11, mgprem11, ROT0, "CD Express", "Magic Premium (v1.1)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND )
|
||||
GAME( 1999, odeontw2, cd32, cd32base, cd32, cd32, ROT0, "CD Express", "Odeon Twister 2 (v202.19)", GAME_NOT_WORKING )
|
||||
GAME( 1999, odeontw2, cd32, cd32base, odeontw2, odeontw2, ROT0, "CD Express", "Odeon Twister 2 (v202.19)", GAME_NOT_WORKING )
|
||||
|
Loading…
Reference in New Issue
Block a user