From fd98f4512bba0c7f92dbf45244c6720a8268e295 Mon Sep 17 00:00:00 2001 From: arcadez2003 <51386955+arcadez2003@users.noreply.github.com> Date: Tue, 6 Feb 2024 22:16:36 +0000 Subject: [PATCH] Alcon / Slap Fight MCU hookup --- src/machine/slapfght.c | 119 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 8 deletions(-) diff --git a/src/machine/slapfght.c b/src/machine/slapfght.c index d1c1b6264..4e7957b1e 100644 --- a/src/machine/slapfght.c +++ b/src/machine/slapfght.c @@ -21,6 +21,16 @@ static int slapfight_status_state; extern unsigned char *getstar_e803; static unsigned char mcu_val; +extern unsigned char *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly; + +static unsigned char from_main,from_mcu; +static int mcu_sent = 0,main_sent = 0; +static unsigned char portA_in,portA_out,ddrA; +static unsigned char portB_in,portB_out,ddrB; +static unsigned char portC_in,portC_out,ddrC; + + + /* Perform basic machine initialisation */ MACHINE_RESET( slapfight ) @@ -113,6 +123,107 @@ READ8_HANDLER( slapfight_port_00_r ) return slapfight_status; } +READ8_HANDLER( slapfight_68705_portA_r ) +{ + return (portA_out & ddrA) | (portA_in & ~ddrA); +} + +WRITE8_HANDLER( slapfight_68705_portA_w ) +{ + portA_out = data; +} + +WRITE8_HANDLER( slapfight_68705_ddrA_w ) +{ + ddrA = data; +} + +READ8_HANDLER( slapfight_68705_portB_r ) +{ + return (portB_out & ddrB) | (portB_in & ~ddrB); +} + +WRITE8_HANDLER( slapfight_68705_portB_w ) +{ + if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02)) + { + portA_in = from_main; + + if (main_sent) + //cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE); + cpunum_set_input_line(2,0,CLEAR_LINE); + + main_sent = 0; + } + if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04)) + { + from_mcu = portA_out; + mcu_sent = 1; + } + if ((ddrB & 0x08) && (~data & 0x08) && (portB_out & 0x08)) + { + *slapfight_scrollx_lo = portA_out; + } + if ((ddrB & 0x10) && (~data & 0x10) && (portB_out & 0x10)) + { + *slapfight_scrollx_hi = portA_out; + } + + portB_out = data; +} + +WRITE8_HANDLER( slapfight_68705_ddrB_w ) +{ + ddrB = data; +} + +READ8_HANDLER( slapfight_68705_portC_r ) +{ + portC_in = 0; + + if (main_sent) + portC_in |= 0x01; + if (!mcu_sent) + portC_in |= 0x02; + + return (portC_out & ddrC) | (portC_in & ~ddrC); +} + +WRITE8_HANDLER( slapfight_68705_portC_w ) +{ + portC_out = data; +} + +WRITE8_HANDLER( slapfight_68705_ddrC_w ) +{ + ddrC = data; +} + +WRITE8_HANDLER( slapfight_mcu_w ) +{ + from_main = data; + main_sent = 1; + //cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE); + cpunum_set_input_line(2,0,ASSERT_LINE); +} + +READ8_HANDLER( slapfight_mcu_r ) +{ + mcu_sent = 0; + return from_mcu; +} + +READ8_HANDLER( slapfight_mcu_status_r ) +{ + int res = 0; + + if (!main_sent) + res |= 0x02; + if (!mcu_sent) + res |= 0x04; + + return res; +} /* @@ -153,14 +264,6 @@ WRITE8_HANDLER( getstar_port_04_w ) } -/* Tiger Heli MCU */ - -static unsigned char from_main,from_mcu; -static int mcu_sent = 0,main_sent = 0; -static unsigned char portA_in,portA_out,ddrA; -static unsigned char portB_in,portB_out,ddrB; -static unsigned char portC_in,portC_out,ddrC; - READ8_HANDLER( tigerh_68705_portA_r ) { return (portA_out & ddrA) | (portA_in & ~ddrA);