a magic address xor means Nitro Ball can work with this code too.. and almost certainly Fighters History too (need to hook it up)

This commit is contained in:
David Haywood 2013-07-19 22:49:56 +00:00
parent 5b55cac1c2
commit 497d2efb73
7 changed files with 56 additions and 19 deletions

View File

@ -201,7 +201,7 @@ READ16_MEMBER( cninja_state::sshangha_protection_region_8_146_r )
int real_address = 0x1a0000 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
return data;
}
@ -220,7 +220,7 @@ READ16_MEMBER( cninja_state::sshangha_protection_region_6_146_r )
int real_address = 0x198000 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
// if ((realdat & mem_mask) != (data & mem_mask))
@ -309,7 +309,7 @@ READ16_MEMBER( cninja_state::mutantf_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
// if ((realdat & mem_mask) != (data & mem_mask))

View File

@ -106,7 +106,7 @@ READ16_MEMBER( funkyjet_state::funkyjet_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, /* note, same bitswap as fghthist */ 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
// if ((realdat & mem_mask) != (data & mem_mask))
// printf("returned %04x instead of %04x (real address %08x swapped addr %08x)\n", data, realdat, real_address, deco146_addr);

View File

@ -191,6 +191,34 @@ static ADDRESS_MAP_START( wizdfire_map, AS_PROGRAM, 16, rohga_state )
AM_RANGE(0xfdc000, 0xffffff) AM_RAM
ADDRESS_MAP_END
READ16_MEMBER( rohga_state::nb_protection_region_0_146_r )
{
UINT16 realdat = deco16_146_nitroball_prot_r(space,offset&0x3ff,mem_mask);
int real_address = 0 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 1,2,3, 4,5,6,7, 8,9,10,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 1 );
if ((realdat & mem_mask) != (data & mem_mask))
printf("returned %04x instead of %04x (real address %08x)\n", data, realdat, real_address);
return data;
}
WRITE16_MEMBER( rohga_state::nb_protection_region_0_146_w )
{
deco16_146_nitroball_prot_w(space,offset&0x3ff,data,mem_mask);
int real_address = 0 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 1,2,3, 4,5,6,7, 8,9,10,0) & 0x7fff;
UINT8 cs = 0;
m_deco146->write_data( space, deco146_addr, data, mem_mask, cs );
}
static ADDRESS_MAP_START( nitrobal_map, AS_PROGRAM, 16, rohga_state )
AM_RANGE(0x000000, 0x1fffff) AM_ROM
@ -220,8 +248,10 @@ static ADDRESS_MAP_START( nitrobal_map, AS_PROGRAM, 16, rohga_state )
AM_RANGE(0x390008, 0x390009) AM_DEVWRITE("deco_common", decocomn_device, palette_dma_w)
AM_RANGE(0xfec000, 0xff3fff) AM_RAM
AM_RANGE(0xff4000, 0xff47ff) AM_MIRROR(0x800) AM_READWRITE_LEGACY(deco16_146_nitroball_prot_r,deco16_146_nitroball_prot_w) AM_SHARE("prot16ram") /* Protection device */
AM_RANGE(0xff8000, 0xffffff) AM_RAM
// AM_RANGE(0xff4000, 0xff47ff) AM_MIRROR(0x800) AM_READWRITE_LEGACY(deco16_146_nitroball_prot_r,deco16_146_nitroball_prot_w) AM_SHARE("prot16ram") /* Protection device */
AM_RANGE(0xff4000, 0xff7fff) AM_READWRITE(nb_protection_region_0_146_r,nb_protection_region_0_146_w) AM_SHARE("prot16ram") /* Protection device */
AM_RANGE(0xff8000, 0xffffff) AM_RAM
ADDRESS_MAP_END
static ADDRESS_MAP_START( schmeisr_map, AS_PROGRAM, 16, rohga_state )
@ -443,7 +473,7 @@ static INPUT_PORTS_START( wizdfire )
INPUT_PORTS_END
static INPUT_PORTS_START( nitrobal )
PORT_START("IN0")
PORT_START("INPUTS")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
@ -461,13 +491,13 @@ static INPUT_PORTS_START( nitrobal )
PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNUSED )
PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
PORT_START("IN1")
PORT_START("SYSTEM")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_VBLANK("screen")
PORT_START("DSW1_2")
PORT_START("DSW")
PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
PORT_DIPSETTING( 0x0000, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x0001, DEF_STR( 2C_1C ) )
@ -922,6 +952,8 @@ static MACHINE_CONFIG_START( nitrobal, rohga_state )
MCFG_VIDEO_START_OVERRIDE(rohga_state,wizdfire)
MCFG_DECO146_ADD("ioprot")
/* sound hardware */
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")

View File

@ -132,7 +132,7 @@ READ16_MEMBER( sshangha_state::sshangha_protection_region_d_146_r )
int real_address = 0x3f4000 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
return data;
}
@ -149,7 +149,7 @@ READ16_MEMBER( sshangha_state::sshangha_protection_region_8_146_r )
int real_address = 0x3e0000 + (offset *2);
int deco146_addr = BITSWAP32(real_address, /* NC */31,30,29,28,27,26,25,24,23,22,21,20,19,18, 13,12,11,/**/ 17,16,15,14, 10,9,8, 7,6,5,4, 3,2,1,0) & 0x7fff;
UINT8 cs = 0;
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs );
UINT16 data = m_deco146->read_data( deco146_addr, mem_mask, cs, 0 );
return data;
}

View File

@ -71,6 +71,9 @@ public:
UINT32 screen_update_wizdfire(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
UINT32 screen_update_nitrobal(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
void mixwizdfirelayer(bitmap_rgb32 &bitmap, const rectangle &cliprect, int gfxregion, UINT16 pri, UINT16 primask);
READ16_MEMBER( nb_protection_region_0_146_r );
WRITE16_MEMBER( nb_protection_region_0_146_w );
};
/*----------- defined in video/rohga.c -----------*/
UINT16 rohga_pri_callback(UINT16 x);

View File

@ -1225,7 +1225,7 @@ void deco146_device::soundlatch_write_callback(address_space &space, UINT16 data
UINT16 deco146_device::read_protport(UINT16 address, UINT16 mem_mask)
UINT16 deco146_device::read_protport(UINT16 address, UINT16 mem_mask, int extra_read_address_xor)
{
UINT16 retdata = 0;
@ -1239,6 +1239,8 @@ UINT16 deco146_device::read_protport(UINT16 address, UINT16 mem_mask)
m_latchflag = 0;
if (extra_read_address_xor) address ^= 0x44a;
// otherwise process the data..
int location = port_table[address>>1].write_offset;
@ -1347,7 +1349,7 @@ void deco146_device::write_protport(address_space &space, UINT16 address, UINT16
}
UINT16 deco146_device::read_data(UINT16 address, UINT16 mem_mask, UINT8 &csflags)
UINT16 deco146_device::read_data(UINT16 address, UINT16 mem_mask, UINT8 &csflags, int extra_read_address_xor)
{
UINT16 retdata = 0;
csflags = 0;
@ -1373,7 +1375,7 @@ UINT16 deco146_device::read_data(UINT16 address, UINT16 mem_mask, UINT8 &csflags
if (i==0) // the first cs is our internal protection area
{
//logerror("read matches cs table (protection) %01x %04x %04x\n", i, real_address, mem_mask);
return read_protport( real_address, mem_mask);
return read_protport( real_address, mem_mask, extra_read_address_xor);
}
else
{
@ -1617,9 +1619,9 @@ static READ16_HANDLER( deco16_146_core_prot_r )
switch (offset)
{
case 0x41a: /* was 0x582 */ /* Player 1 & Player 2 */ return space.machine().root_device().ioport("IN0")->read();
case 0x320: /* was 0x4c */ /* Coins/VBL */ return space.machine().root_device().ioport("IN1")->read();
case 0x4e6: /* was 0x672 */ /* Dip switches */ return space.machine().root_device().ioport("DSW1_2")->read();
case 0x41a: /* was 0x582 */ /* Player 1 & Player 2 */ return space.machine().root_device().ioport("INPUTS")->read();
case 0x320: /* was 0x4c */ /* Coins/VBL */ return space.machine().root_device().ioport("SYSTEM")->read();
case 0x4e6: /* was 0x672 */ /* Dip switches */ return space.machine().root_device().ioport("DSW")->read();
case 0x5c8: /* was 0x13a */ return ((DECO_PORT(0x98)&0x00f0)<<8) | ((DECO_PORT(0x98)&0x0003)<<10) | ((DECO_PORT(0x98)&0x000c)<<6);
case 0x3ca: /* was 0x53c */ return ((DECO_PORT(0xc0)&0x0ff0)<<4) | ((DECO_PORT(0xc0)&0xf000)>>8);
case 0x360: /* was 0x6c */ return ((DECO_PORT(0xec)&0x00ff)<<8);

View File

@ -11,7 +11,7 @@ public:
deco146_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
void write_data(address_space &space, UINT16 address, UINT16 data, UINT16 mem_mask, UINT8 &csflags);
UINT16 read_data(UINT16 address, UINT16 mem_mask, UINT8 &csflags);
UINT16 read_data(UINT16 address, UINT16 mem_mask, UINT8 &csflags, int extra_read_address_xor);
// legacy stuff
@ -26,7 +26,7 @@ protected:
virtual void device_start();
virtual void device_reset();
UINT16 read_protport(UINT16 address, UINT16 mem_mask);
UINT16 read_protport(UINT16 address, UINT16 mem_mask, int extra_read_address_xor);
void write_protport(address_space &space, UINT16 address, UINT16 data, UINT16 mem_mask);
UINT16 m_rambank0[0x80];