Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alcon / Slap Fight MCU hookup #116

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 111 additions & 8 deletions src/machine/slapfght.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
}


/*
Expand Down Expand Up @@ -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);
Expand Down
Loading