poundfor: Add uPD4701A devices

This commit is contained in:
AJR 2017-05-21 15:03:24 -04:00
parent a662d26e29
commit 17bd0ab306
3 changed files with 68 additions and 92 deletions

View File

@ -898,37 +898,6 @@ WRITE16_MEMBER(m72_state::soundram_w)
}
READ16_MEMBER(m72_state::poundfor_trackball_r)
{
static const char *const axisnames[] = { "TRACK0_X", "TRACK0_Y", "TRACK1_X", "TRACK1_Y" };
if (offset == 0)
{
int i,curr;
for (i = 0;i < 4;i++)
{
curr = ioport(axisnames[i])->read();
m_diff[i] = (curr - m_prev[i]);
m_prev[i] = curr;
}
}
switch (offset)
{
default:
case 0:
return (m_diff[0] & 0xff) | ((m_diff[2] & 0xff) << 8);
case 1:
return ((m_diff[0] >> 8) & 0x1f) | (m_diff[2] & 0x1f00) | (ioport("IN0")->read() & 0xe0e0);
case 2:
return (m_diff[1] & 0xff) | ((m_diff[3] & 0xff) << 8);
case 3:
return ((m_diff[1] >> 8) & 0x1f) | (m_diff[3] & 0x1f00);
}
}
#define M72_CPU1_MEMORY(NAME,ROMSIZE,WORKRAM) \
static ADDRESS_MAP_START( NAME##_map, AS_PROGRAM, 16 , m72_state ) \
AM_RANGE(0x00000, ROMSIZE-1) AM_ROM \
@ -1013,7 +982,7 @@ static ADDRESS_MAP_START( m72_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(port02_w) /* coin counters, reset sound cpu, other stuff? */
AM_RANGE(0x02, 0x03) AM_WRITE8(port02_w, 0x00ff) /* coin counters, reset sound cpu, other stuff? */
AM_RANGE(0x04, 0x05) AM_WRITE(dmaon_w)
AM_RANGE(0x06, 0x07) AM_WRITE(irq_line_w)
AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("upd71059c", pic8259_device, read, write, 0x00ff)
@ -1029,7 +998,7 @@ static ADDRESS_MAP_START( m84_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
AM_RANGE(0x02, 0x03) AM_WRITE8(rtype2_port02_w, 0x00ff)
AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("upd71059c", pic8259_device, read, write, 0x00ff)
AM_RANGE(0x80, 0x81) AM_WRITE(scrolly1_w)
AM_RANGE(0x82, 0x83) AM_WRITE(scrollx1_w)
@ -1042,7 +1011,7 @@ static ADDRESS_MAP_START( m84_v33_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
AM_RANGE(0x02, 0x03) AM_WRITE8(rtype2_port02_w, 0x00ff)
AM_RANGE(0x80, 0x81) AM_WRITE(scrolly1_w)
AM_RANGE(0x82, 0x83) AM_WRITE(scrollx1_w)
AM_RANGE(0x84, 0x85) AM_WRITE(scrolly2_w)
@ -1054,9 +1023,10 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( poundfor_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x08, 0x0f) AM_READ(poundfor_trackball_r)
AM_RANGE(0x08, 0x0f) AM_DEVREAD8("upd4701l", upd4701_device, read_xy, 0x00ff)
AM_RANGE(0x08, 0x0f) AM_DEVREAD8("upd4701h", upd4701_device, read_xy, 0xff00)
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
AM_RANGE(0x02, 0x03) AM_WRITE8(poundfor_port02_w, 0x00ff)
AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("upd71059c", pic8259_device, read, write, 0x00ff)
AM_RANGE(0x80, 0x81) AM_WRITE(scrolly1_w)
AM_RANGE(0x82, 0x83) AM_WRITE(scrollx1_w)
@ -1069,7 +1039,7 @@ static ADDRESS_MAP_START( m82_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w)
AM_RANGE(0x02, 0x03) AM_WRITE8(rtype2_port02_w, 0x00ff)
AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("upd71059c", pic8259_device, read, write, 0x00ff)
AM_RANGE(0x80, 0x81) AM_WRITE(scrolly1_w)
AM_RANGE(0x82, 0x83) AM_WRITE(scrollx1_w)
@ -1086,7 +1056,7 @@ static ADDRESS_MAP_START( m81_portmap, AS_IO, 16, m72_state )
AM_RANGE(0x02, 0x03) AM_READ_PORT("IN1")
AM_RANGE(0x04, 0x05) AM_READ_PORT("DSW")
AM_RANGE(0x00, 0x01) AM_DEVWRITE("m72", m72_audio_device, sound_command_w)
AM_RANGE(0x02, 0x03) AM_WRITE(rtype2_port02_w) /* coin counters, reset sound cpu, other stuff? */
AM_RANGE(0x02, 0x03) AM_WRITE8(rtype2_port02_w, 0x00ff) /* coin counters, reset sound cpu, other stuff? */
AM_RANGE(0x04, 0x05) AM_WRITE(dmaon_w)
AM_RANGE(0x06, 0x07) AM_WRITE(irq_line_w)
AM_RANGE(0x40, 0x43) AM_DEVREADWRITE8("upd71059c", pic8259_device, read, write, 0x00ff)
@ -1616,15 +1586,12 @@ static INPUT_PORTS_START( m81_hharry )
INPUT_PORTS_END
static INPUT_PORTS_START( poundfor )
PORT_START("IN0")
PORT_BIT( 0x001f, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* high bits of trackball X */
PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1)
PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1)
PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x1f00, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* high bits of trackball X */
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2)
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("IN0") // not read directly
PORT_BIT( 0x9f9f, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER("upd4701l", upd4701_device, right_w)
PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_WRITE_LINE_DEVICE_MEMBER("upd4701l", upd4701_device, left_w)
PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER("upd4701h", upd4701_device, right_w)
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_WRITE_LINE_DEVICE_MEMBER("upd4701h", upd4701_device, left_w)
PORT_START("IN1")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
@ -1691,16 +1658,16 @@ static INPUT_PORTS_START( poundfor )
IREM_COIN_MODE_2_HIGH
PORT_START("TRACK0_X")
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(1)
PORT_BIT( 0x0fff, 0x0000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_RESET PORT_PLAYER(1)
PORT_START("TRACK0_Y")
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(1)
PORT_BIT( 0x0fff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_RESET PORT_PLAYER(1)
PORT_START("TRACK1_X")
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_PLAYER(2)
PORT_BIT( 0x0fff, 0x0000, IPT_TRACKBALL_X ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_REVERSE PORT_RESET PORT_PLAYER(2)
PORT_START("TRACK1_Y")
PORT_BIT( 0xffff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_PLAYER(2)
PORT_BIT( 0x0fff, 0x0000, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(50) PORT_KEYDELTA(30) PORT_RESET PORT_PLAYER(2)
INPUT_PORTS_END
static INPUT_PORTS_START( airduel )
@ -2147,6 +2114,14 @@ static MACHINE_CONFIG_START( poundfor )
MCFG_PIC8259_ADD( "upd71059c", INPUTLINE("maincpu", 0), VCC, NOOP)
MCFG_DEVICE_ADD("upd4701l", UPD4701A, 0)
MCFG_UPD4701_PORTX("TRACK0_X")
MCFG_UPD4701_PORTY("TRACK0_Y")
MCFG_DEVICE_ADD("upd4701h", UPD4701A, 0)
MCFG_UPD4701_PORTX("TRACK1_X")
MCFG_UPD4701_PORTY("TRACK1_Y")
/* video hardware */
MCFG_GFXDECODE_ADD("gfxdecode", "palette", rtype2)
MCFG_PALETTE_ADD("palette", 512)

View File

@ -8,6 +8,7 @@
#include "audio/m72.h"
#include "sound/dac.h"
#include "machine/pic8259.h"
#include "machine/upd4701.h"
#include "screen.h"
#define M81_B_B_JUMPER_J3_S \
@ -44,6 +45,7 @@ public:
m_generic_paletteram_16(*this, "paletteram"),
m_generic_paletteram2_16(*this, "paletteram2"),
m_upd71059c(*this, "upd71059c"),
m_upd4701(*this, {"upd4701l", "upd4701h"}),
m_fg_source(0),
m_bg_source(0),
m_m81_b_b_j3(*this, "JumperJ3"),
@ -69,6 +71,7 @@ public:
required_shared_ptr<uint16_t> m_generic_paletteram_16;
required_shared_ptr<uint16_t> m_generic_paletteram2_16;
optional_device<pic8259_device> m_upd71059c;
optional_device_array<upd4701_device, 2> m_upd4701;
std::unique_ptr<uint16_t[]> m_protection_ram;
emu_timer *m_scanline_timer;
@ -89,10 +92,6 @@ public:
int m_bg_source;
optional_ioport m_m81_b_b_j3;
//poundfor specific
int m_prev[4];
int m_diff[4];
// majtitle specific
int m_m82_rowscroll;
uint16_t m_m82_tmcontrol;
@ -131,7 +130,7 @@ public:
DECLARE_WRITE16_MEMBER(scrolly1_w);
DECLARE_WRITE16_MEMBER(scrolly2_w);
DECLARE_WRITE16_MEMBER(dmaon_w);
DECLARE_WRITE16_MEMBER(port02_w);
DECLARE_WRITE8_MEMBER(port02_w);
DECLARE_READ16_MEMBER(protection_r);
DECLARE_WRITE16_MEMBER(protection_w);
@ -144,8 +143,8 @@ public:
DECLARE_WRITE16_MEMBER(airduelm72_sample_trigger_w);
DECLARE_WRITE16_MEMBER(dkgenm72_sample_trigger_w);
DECLARE_WRITE16_MEMBER(gallop_sample_trigger_w);
DECLARE_READ16_MEMBER(poundfor_trackball_r);
DECLARE_WRITE16_MEMBER(rtype2_port02_w);
DECLARE_WRITE8_MEMBER(rtype2_port02_w);
DECLARE_WRITE8_MEMBER(poundfor_port02_w);
DECLARE_WRITE16_MEMBER(m82_gfx_ctrl_w);
DECLARE_WRITE16_MEMBER(m82_tm_ctrl_w);

View File

@ -265,9 +265,6 @@ VIDEO_START_MEMBER(m72_state,poundfor)
m_bg_tilemap->set_scrolldx(6,0);
m_fg_tilemap->set_scrolldy(-128,-128);
m_bg_tilemap->set_scrolldy(-128,-128);
save_item(NAME(m_prev));
save_item(NAME(m_diff));
}
@ -379,50 +376,55 @@ WRITE16_MEMBER(m72_state::dmaon_w)
}
WRITE16_MEMBER(m72_state::port02_w)
WRITE8_MEMBER(m72_state::port02_w)
{
if (ACCESSING_BITS_0_7)
{
if (data & 0xe0) logerror("write %02x to port 02\n",data);
if (data & 0xe0) logerror("write %02x to port 02\n",data);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~ioport("DSW")->read() >> 8) & 1));
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~ioport("DSW")->read() >> 8) & 1));
/* bit 3 is display disable */
m_video_off = data & 0x08;
/* bit 3 is display disable */
m_video_off = data & 0x08;
/* bit 4 resets sound CPU (active low) */
if (data & 0x10)
m_soundcpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
else
m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
/* bit 4 resets sound CPU (active low) */
if (data & 0x10)
m_soundcpu->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
else
m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
/* bit 5 = "bank"? */
}
/* bit 5 = "bank"? */
}
WRITE16_MEMBER(m72_state::rtype2_port02_w)
WRITE8_MEMBER(m72_state::rtype2_port02_w)
{
if (ACCESSING_BITS_0_7)
{
if (data & 0xe0) logerror("write %02x to port 02\n",data);
if (data & 0xe0) logerror("write %02x to port 02\n",data);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
/* bits 0/1 are coin counters */
machine().bookkeeping().coin_counter_w(0,data & 0x01);
machine().bookkeeping().coin_counter_w(1,data & 0x02);
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~ioport("DSW")->read() >> 8) & 1));
/* bit 2 is flip screen (handled both by software and hardware) */
flip_screen_set(((data & 0x04) >> 2) ^ ((~ioport("DSW")->read() >> 8) & 1));
/* bit 3 is display disable */
m_video_off = data & 0x08;
/* bit 3 is display disable */
m_video_off = data & 0x08;
/* other bits unknown */
}
/* other bits unknown */
}
WRITE8_MEMBER(m72_state::poundfor_port02_w)
{
// bit 5 resets both uPD4701A?
m_upd4701[0]->resetx_w(BIT(data, 5));
m_upd4701[0]->resety_w(BIT(data, 5));
m_upd4701[1]->resetx_w(BIT(data, 5));
m_upd4701[1]->resety_w(BIT(data, 5));
rtype2_port02_w(space, 0, data & 0xbf);
}