summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar cam900 <dbtlrchl@naver.com>2019-04-14 01:44:05 +0900
committerGravatarGravatar cam900 <dbtlrchl@naver.com>2019-04-14 01:44:05 +0900
commit44a653c01ab09bae8164df050a7d44062058a4cc (patch) (github)
tree62eb748de3a59acd11ba72954d0ed2824bc33319
parent808ec55f338ee8ddac08df45938e6f6bcd368d57 (diff)
downloadmame-44a653c01ab09bae8164df050a7d44062058a4cc.tar.bz2
mame-44a653c01ab09bae8164df050a7d44062058a4cc.zip
deco146.cpp : Updates
Reduce unnecessary arguments, Duplicates, Unnecessary lines, Fix spacings, Debugger issues, Use shorter type values deco104.cpp : Reduce unnecessary line, Use shorter type values
-rw-r--r--src/mame/drivers/boogwing.cpp2
-rw-r--r--src/mame/drivers/cninja.cpp8
-rw-r--r--src/mame/drivers/dblewing.cpp2
-rw-r--r--src/mame/drivers/deco32.cpp2
-rw-r--r--src/mame/drivers/deco_mlc.cpp2
-rw-r--r--src/mame/drivers/dietgo.cpp2
-rw-r--r--src/mame/drivers/dreambal.cpp2
-rw-r--r--src/mame/drivers/funkyjet.cpp2
-rw-r--r--src/mame/drivers/lemmings.cpp2
-rw-r--r--src/mame/drivers/pktgaldx.cpp2
-rw-r--r--src/mame/drivers/rohga.cpp2
-rw-r--r--src/mame/drivers/sshangha.cpp4
-rw-r--r--src/mame/machine/deco104.cpp8
-rw-r--r--src/mame/machine/deco104.h2
-rw-r--r--src/mame/machine/deco146.cpp112
-rw-r--r--src/mame/machine/deco146.h48
16 files changed, 93 insertions, 109 deletions
diff --git a/src/mame/drivers/boogwing.cpp b/src/mame/drivers/boogwing.cpp
index 9e6b2a8f006..4b2de301bab 100644
--- a/src/mame/drivers/boogwing.cpp
+++ b/src/mame/drivers/boogwing.cpp
@@ -103,7 +103,7 @@ READ16_MEMBER( boogwing_state::boogwing_protection_region_0_104_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco104->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco104->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/cninja.cpp b/src/mame/drivers/cninja.cpp
index dc44e2c2415..0e1fb38a8fd 100644
--- a/src/mame/drivers/cninja.cpp
+++ b/src/mame/drivers/cninja.cpp
@@ -68,7 +68,7 @@ READ16_MEMBER( cninja_state::cninja_protection_region_0_104_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_ioprot->read_data( deco146_addr, cs );
return data;
}
@@ -150,7 +150,7 @@ READ16_MEMBER( cninja_state::edrandy_protection_region_8_146_r )
int real_address = 0x1a0000 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_ioprot->read_data( deco146_addr, cs );
return data;
}
@@ -169,7 +169,7 @@ READ16_MEMBER( cninja_state::edrandy_protection_region_6_146_r )
int real_address = 0x198000 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_ioprot->read_data( deco146_addr, cs );
// if ((realdat & mem_mask) != (data & mem_mask))
@@ -259,7 +259,7 @@ READ16_MEMBER( cninja_state::mutantf_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_ioprot->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/dblewing.cpp b/src/mame/drivers/dblewing.cpp
index 9dca38e1d10..377bad7496a 100644
--- a/src/mame/drivers/dblewing.cpp
+++ b/src/mame/drivers/dblewing.cpp
@@ -158,7 +158,7 @@ READ16_MEMBER( dblewing_state::wf_protection_region_0_104_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco104->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco104->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/deco32.cpp b/src/mame/drivers/deco32.cpp
index 22147ec5fbf..43e862d83ac 100644
--- a/src/mame/drivers/deco32.cpp
+++ b/src/mame/drivers/deco32.cpp
@@ -700,7 +700,7 @@ READ16_MEMBER( deco32_state::ioprot_r )
offs_t deco146_addr = bitswap<32>(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_t cs = 0;
- return m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ return m_ioprot->read_data( deco146_addr, cs );
}
WRITE16_MEMBER( deco32_state::ioprot_w )
diff --git a/src/mame/drivers/deco_mlc.cpp b/src/mame/drivers/deco_mlc.cpp
index d8801dc5e11..687d233f865 100644
--- a/src/mame/drivers/deco_mlc.cpp
+++ b/src/mame/drivers/deco_mlc.cpp
@@ -279,7 +279,7 @@ READ16_MEMBER( deco_mlc_state::sh96_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco146->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco146->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/dietgo.cpp b/src/mame/drivers/dietgo.cpp
index 5b2d2167a51..ba7b6eaabd3 100644
--- a/src/mame/drivers/dietgo.cpp
+++ b/src/mame/drivers/dietgo.cpp
@@ -39,7 +39,7 @@ READ16_MEMBER( dietgo_state::dietgo_protection_region_0_104_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco104->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco104->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/dreambal.cpp b/src/mame/drivers/dreambal.cpp
index ebb65adf9f4..8e248ffce42 100644
--- a/src/mame/drivers/dreambal.cpp
+++ b/src/mame/drivers/dreambal.cpp
@@ -102,7 +102,7 @@ READ16_MEMBER( dreambal_state::dreambal_protection_region_0_104_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco104->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco104->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/funkyjet.cpp b/src/mame/drivers/funkyjet.cpp
index 3a538d9c7d9..95ce63c39fb 100644
--- a/src/mame/drivers/funkyjet.cpp
+++ b/src/mame/drivers/funkyjet.cpp
@@ -110,7 +110,7 @@ READ16_MEMBER( funkyjet_state::funkyjet_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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 */ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) & 0x7fff;
uint8_t cs = 0;
- uint16_t data = m_deco146->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco146->read_data( deco146_addr, cs );
// 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);
diff --git a/src/mame/drivers/lemmings.cpp b/src/mame/drivers/lemmings.cpp
index 27bfeec5d5f..40ae0d3fcae 100644
--- a/src/mame/drivers/lemmings.cpp
+++ b/src/mame/drivers/lemmings.cpp
@@ -48,7 +48,7 @@ READ16_MEMBER( lemmings_state::lem_protection_region_0_146_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco146->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco146->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/pktgaldx.cpp b/src/mame/drivers/pktgaldx.cpp
index 00e244d5ee2..81873d4577f 100644
--- a/src/mame/drivers/pktgaldx.cpp
+++ b/src/mame/drivers/pktgaldx.cpp
@@ -80,7 +80,7 @@ READ16_MEMBER( pktgaldx_state::pktgaldx_protection_region_f_104_r )
{
int real_address = 0 + (offset *2);
uint8_t cs = 0;
- uint16_t data = m_deco104->read_data( real_address&0x7fff, mem_mask, cs );
+ uint16_t data = m_deco104->read_data( real_address&0x7fff, cs );
return data;
}
diff --git a/src/mame/drivers/rohga.cpp b/src/mame/drivers/rohga.cpp
index 4667d3e6e50..c6d7bc47dcd 100644
--- a/src/mame/drivers/rohga.cpp
+++ b/src/mame/drivers/rohga.cpp
@@ -146,7 +146,7 @@ READ16_MEMBER( rohga_state::ioprot_r )
int real_address = 0 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_ioprot->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_ioprot->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/drivers/sshangha.cpp b/src/mame/drivers/sshangha.cpp
index 3550995dc79..b8b2d485cad 100644
--- a/src/mame/drivers/sshangha.cpp
+++ b/src/mame/drivers/sshangha.cpp
@@ -125,7 +125,7 @@ READ16_MEMBER( sshangha_state::sshangha_protection_region_d_146_r )
int real_address = 0x3f4000 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco146->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco146->read_data( deco146_addr, cs );
return data;
}
@@ -142,7 +142,7 @@ READ16_MEMBER( sshangha_state::sshangha_protection_region_8_146_r )
int real_address = 0x3e0000 + (offset *2);
int deco146_addr = bitswap<32>(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_t cs = 0;
- uint16_t data = m_deco146->read_data( deco146_addr, mem_mask, cs );
+ uint16_t data = m_deco146->read_data( deco146_addr, cs );
return data;
}
diff --git a/src/mame/machine/deco104.cpp b/src/mame/machine/deco104.cpp
index 36fffd62e70..673e3cef383 100644
--- a/src/mame/machine/deco104.cpp
+++ b/src/mame/machine/deco104.cpp
@@ -3,7 +3,7 @@
/****************************************************************************
Data East 104 based protection/IO chips
- (a variation on the Deco 146 protection, see deco146.c for notes)
+ (a variation on the Deco 146 protection, see deco146.cpp for notes)
Emulation by David Haywood
based on findings by Charles MacDonald
@@ -1048,12 +1048,10 @@ static deco146port_xx const port104_table[] = {
};
-
DEFINE_DEVICE_TYPE(DECO104PROT, deco104_device, "deco104", "DECO 104 Protection")
-
-deco104_device::deco104_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+deco104_device::deco104_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: deco_146_base_device(mconfig, DECO104PROT, tag, owner, clock)
{
m_bankswitch_swap_read_address = 0x66;
@@ -1067,8 +1065,6 @@ deco104_device::deco104_device(const machine_config &mconfig, const char *tag, d
}
-
-
void deco104_device::device_start()
{
deco_146_base_device::device_start();
diff --git a/src/mame/machine/deco104.h b/src/mame/machine/deco104.h
index aa2957437b9..f2649f71601 100644
--- a/src/mame/machine/deco104.h
+++ b/src/mame/machine/deco104.h
@@ -13,7 +13,7 @@
class deco104_device : public deco_146_base_device
{
public:
- deco104_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ deco104_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
protected:
virtual void device_start() override;
diff --git a/src/mame/machine/deco146.cpp b/src/mame/machine/deco146.cpp
index 5a8afab01c9..6d4368171be 100644
--- a/src/mame/machine/deco146.cpp
+++ b/src/mame/machine/deco146.cpp
@@ -1119,14 +1119,14 @@ static deco146port_xx const port_table[] = {
/* 0x7fe */ { 0x04c, { NIB1__, NIB2__, NIB0__, NIB3__ }, 0, 1 }
};
-inline uint16_t reorder(uint16_t input, uint8_t const *weights)
+inline u16 reorder(u16 input, u8 const *weights)
{
- uint16_t temp = 0;
- for(int i = 0; i < 16; i++)
+ u16 temp = 0;
+ for (int i = 0; i < 16; i++)
{
- if(input & (1 << i)) // if input bit is set
+ if (input & (1 << i)) // if input bit is set
{
- if(weights[i] != 0xFF) // and weight exists for output bit
+ if (weights[i] != 0xFF) // and weight exists for output bit
{
temp |= 1 << weights[i]; // set that bit
}
@@ -1139,9 +1139,9 @@ inline uint16_t reorder(uint16_t input, uint8_t const *weights)
/* there are probably less dumb ways of doing the CS logic, it could be hooked up
more like the system16 mapper chips */
-void deco_146_base_device::write_data(uint16_t address, uint16_t data, uint16_t mem_mask, uint8_t &csflags)
+void deco_146_base_device::write_data(u16 address, u16 data, u16 mem_mask, u8 &csflags)
{
- address = bitswap<16>(address>>1, 15,14,13,12,11,10, m_external_addrswap[9],m_external_addrswap[8] ,m_external_addrswap[7],m_external_addrswap[6],m_external_addrswap[5],m_external_addrswap[4],m_external_addrswap[3],m_external_addrswap[2],m_external_addrswap[1],m_external_addrswap[0]) << 1;
+ address = bitswap<16>(address >> 1, 15,14,13,12,11,10, m_external_addrswap[9],m_external_addrswap[8] ,m_external_addrswap[7],m_external_addrswap[6],m_external_addrswap[5],m_external_addrswap[4],m_external_addrswap[3],m_external_addrswap[2],m_external_addrswap[1],m_external_addrswap[0]) << 1;
csflags = 0;
int upper_addr_bits = (address & 0x7800) >> 11;
@@ -1151,9 +1151,9 @@ void deco_146_base_device::write_data(uint16_t address, uint16_t data, uint16_t
int real_address = address & 0xf;
logerror("write to config regs %04x %04x %04x\n", real_address, data, mem_mask);
- if ((real_address>=0x2) && (real_address<=0x0c))
+ if ((real_address >= 0x2) && (real_address <= 0x0c))
{
- region_selects[(real_address-2)/2] = data &0xf;
+ region_selects[(real_address - 2) / 2] = data & 0xf;
return;
}
else
@@ -1164,16 +1164,16 @@ void deco_146_base_device::write_data(uint16_t address, uint16_t data, uint16_t
return; // or fall through?
}
- for (int i=0;i<6;i++)
+ for (int i = 0; i < 6; i++)
{
int cs = region_selects[i];
- if (cs==upper_addr_bits)
+ if (cs == upper_addr_bits)
{
int real_address = address & 0x7ff;
csflags |= (1 << i);
- if (i==0) // the first cs is our internal protection area
+ if (i == 0) // the first cs is our internal protection area
{
// logerror("write matches cs table (protection) %01x %04x %04x %04x\n", i, real_address, data, mem_mask);
write_protport(real_address, data, mem_mask);
@@ -1185,17 +1185,17 @@ void deco_146_base_device::write_data(uint16_t address, uint16_t data, uint16_t
}
}
- if (csflags==0)
+ if (csflags == 0)
{
logerror("write not in cs table\n");
}
}
-uint16_t deco_146_base_device::read_protport(uint16_t address, uint16_t mem_mask)
+u16 deco_146_base_device::read_protport(u16 address)
{
// if we read the last written address immediately after then ignore all other logic and just return what was written unmodified
- if ((address==m_latchaddr) && (m_latchflag==1))
+ if (((address == m_latchaddr) && (m_latchflag == 1)) && (!machine().side_effects_disabled()))
{
logerror("returning latched data %04x\n", m_latchdata);
m_latchflag = 0;
@@ -1207,19 +1207,15 @@ uint16_t deco_146_base_device::read_protport(uint16_t address, uint16_t mem_mask
if (m_magic_read_address_xor_enabled) address ^= m_magic_read_address_xor;
int location = 0;
- uint16_t realret = read_data_getloc(address, location);
+ u16 realret = read_data_getloc(address, location);
- if (location == m_bankswitch_swap_read_address) // this has a special meaning
+ if ((location == m_bankswitch_swap_read_address) && (!machine().side_effects_disabled())) // this has a special meaning
{
- // logerror("(bankswitch) %04x %04x\n", address, mem_mask);
+ // logerror("(bankswitch) %04x %04x\n", address);
- if (m_current_rambank==0)
- m_current_rambank = 1;
- else
- m_current_rambank = 0;
+ m_current_rambank ^= 1;
}
-
return realret;
}
@@ -1229,75 +1225,73 @@ TIMER_CALLBACK_MEMBER(deco_146_base_device::write_soundlatch)
m_soundlatch_irq_cb(ASSERT_LINE);
}
-void deco_146_base_device::write_protport(uint16_t address, uint16_t data, uint16_t mem_mask)
+void deco_146_base_device::write_protport(u16 address, u16 data, u16 mem_mask)
{
m_latchaddr = address;
m_latchdata = data;
m_latchflag = 1;
- if ((address&0xff) == m_xor_port)
+ if ((address & 0xff) == m_xor_port)
{
logerror("LOAD XOR REGISTER %04x %04x\n", data, mem_mask);
COMBINE_DATA(&m_xor);
}
- else if ((address&0xff) == m_mask_port)
+ else if ((address & 0xff) == m_mask_port)
{
// logerror("LOAD NAND REGISTER %04x %04x\n", data, mem_mask);
COMBINE_DATA(&m_nand);
}
- else if ((address&0xff) == m_soundlatch_port)
+ else if ((address & 0xff) == m_soundlatch_port)
{
logerror("LOAD SOUND LATCH: %04x\n", data);
machine().scheduler().synchronize(timer_expired_delegate(FUNC(deco_146_base_device::write_soundlatch), this), data & 0xff);
}
// always store
- if (m_current_rambank==0)
- COMBINE_DATA(&m_rambank0[(address&0xff)>>1]);
- else
- COMBINE_DATA(&m_rambank1[(address&0xff)>>1]);
-
+ COMBINE_DATA(&m_rambank[m_current_rambank][(address & 0xff) >> 1]);
}
-uint16_t deco_146_base_device::read_data(uint16_t address, uint16_t mem_mask, uint8_t &csflags)
+u16 deco_146_base_device::read_data(u16 address, u8 &csflags)
{
- address = bitswap<16>(address>>1, 15,14,13,12,11,10, m_external_addrswap[9],m_external_addrswap[8] ,m_external_addrswap[7],m_external_addrswap[6],m_external_addrswap[5],m_external_addrswap[4],m_external_addrswap[3],m_external_addrswap[2],m_external_addrswap[1],m_external_addrswap[0]) << 1;
+ address = bitswap<16>(address >> 1, 15,14,13,12,11,10, m_external_addrswap[9],m_external_addrswap[8] ,m_external_addrswap[7],m_external_addrswap[6],m_external_addrswap[5],m_external_addrswap[4],m_external_addrswap[3],m_external_addrswap[2],m_external_addrswap[1],m_external_addrswap[0]) << 1;
- uint16_t retdata = 0;
+ u16 retdata = 0;
csflags = 0;
int upper_addr_bits = (address & 0x7800) >> 11;
if (upper_addr_bits == 0x8) // configuration registers are hardcoded to this area
{
int real_address = address & 0xf;
- logerror("read config regs? %04x %04x\n", real_address, mem_mask);
+ if (!machine().side_effects_disabled())
+ logerror("read config regs? %04x\n", real_address);
+
return 0x0000;
}
// what gets priority?
- for (int i=0;i<6;i++)
+ for (int i = 0; i < 6; i++)
{
int cs = region_selects[i];
- if (cs==upper_addr_bits)
+ if (cs == upper_addr_bits)
{
int real_address = address & 0x7ff;
csflags |= (1 << i);
- if (i==0) // the first cs is our internal protection area
+ 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);
+ //logerror("read matches cs table (protection) %01x %04x\n", i, real_address);
+ return read_protport(real_address);
}
- else
+ else if (!machine().side_effects_disabled())
{
- logerror("read matches cs table (external connection) %01x %04x %04x\n", i, real_address, mem_mask);
+ logerror("read matches cs table (external connection) %01x %04x\n", i, real_address);
}
}
}
- if (csflags==0)
+ if ((csflags == 0) && (!machine().side_effects_disabled()))
{
logerror("read not in cs table\n");
}
@@ -1311,7 +1305,7 @@ u8 deco_146_base_device::soundlatch_r()
return m_soundlatch;
}
-deco_146_base_device::deco_146_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
+deco_146_base_device::deco_146_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, type, tag, owner, clock),
m_port_a_r(*this),
m_port_b_r(*this),
@@ -1332,11 +1326,12 @@ deco_146_base_device::deco_146_base_device(const machine_config &mconfig, device
void deco_146_base_device::device_start()
{
- for (int i=0;i<0x80;i++)
+ for (int bank = 0; bank < 2; bank++)
{
+ m_rambank[bank] = std::make_unique<u16[]>(0x80);
// the mutant fighter old sim assumes 0x0000
- m_rambank0[i] = 0xffff;
- m_rambank1[i] = 0xffff;
+ std::fill_n(&m_rambank[bank][0], 0x80, 0xffff);
+ save_pointer(NAME(m_rambank[bank]), 0x80, bank);
}
// bind our handler
@@ -1348,8 +1343,6 @@ void deco_146_base_device::device_start()
save_item(NAME(m_xor));
save_item(NAME(m_nand));
- save_item(NAME(m_rambank0));
- save_item(NAME(m_rambank1));
save_item(NAME(m_current_rambank));
save_item(NAME(region_selects));
@@ -1384,11 +1377,11 @@ void deco_146_base_device::device_reset()
}
-uint16_t deco_146_base_device::read_data_getloc(uint16_t address, int& location)
+u16 deco_146_base_device::read_data_getloc(u16 address, int& location)
{
- uint16_t retdata = 0;
+ u16 retdata = 0;
- location = m_lookup_table[address>>1].write_offset;
+ location = m_lookup_table[address >> 1].write_offset;
if (location==INPUT_PORT_A)
{
@@ -1404,16 +1397,13 @@ uint16_t deco_146_base_device::read_data_getloc(uint16_t address, int& location)
}
else
{
- if (m_current_rambank==0)
- retdata = m_rambank0[location>>1];
- else
- retdata = m_rambank1[location>>1];
+ retdata = m_rambank[m_current_rambank][location >> 1];
}
- uint16_t realret = reorder(retdata, &m_lookup_table[address>>1].mapping[0] );
+ u16 realret = reorder(retdata, &m_lookup_table[address >> 1].mapping[0] );
- if (m_lookup_table[address>>1].use_xor) realret ^= m_xor;
- if (m_lookup_table[address>>1].use_nand) realret = (realret & ~m_nand);
+ if (m_lookup_table[address >> 1].use_xor) realret ^= m_xor;
+ if (m_lookup_table[address >> 1].use_nand) realret = (realret & ~m_nand);
return realret;
}
@@ -1422,7 +1412,7 @@ uint16_t deco_146_base_device::read_data_getloc(uint16_t address, int& location)
DEFINE_DEVICE_TYPE(DECO146PROT, deco146_device, "deco146", "DECO 146 Protection")
-deco146_device::deco146_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+deco146_device::deco146_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: deco_146_base_device(mconfig, DECO146PROT, tag, owner, clock)
{
m_bankswitch_swap_read_address = 0x78;
diff --git a/src/mame/machine/deco146.h b/src/mame/machine/deco146.h
index 64bdaf9c2f5..31a4b5a4af5 100644
--- a/src/mame/machine/deco146.h
+++ b/src/mame/machine/deco146.h
@@ -38,27 +38,26 @@
struct deco146port_xx
{
int write_offset;
- uint8_t mapping[16];
+ u8 mapping[16];
int use_xor;
int use_nand;
};
-
/* Data East 146 protection chip */
class deco_146_base_device : public device_t
{
public:
- void write_data(uint16_t address, uint16_t data, uint16_t mem_mask, uint8_t &csflags);
- uint16_t read_data(uint16_t address, uint16_t mem_mask, uint8_t &csflags);
+ void write_data(u16 address, u16 data, u16 mem_mask, u8 &csflags);
+ u16 read_data(u16 address, u8 &csflags);
auto port_a_cb() { return m_port_a_r.bind(); }
auto port_b_cb() { return m_port_b_r.bind(); }
auto port_c_cb() { return m_port_c_r.bind(); }
// there are some standard ways the chip gets hooked up, so have them here ready to use
- void set_interface_scramble(uint8_t a9, uint8_t a8, uint8_t a7, uint8_t a6, uint8_t a5, uint8_t a4, uint8_t a3,uint8_t a2,uint8_t a1,uint8_t a0)
+ void set_interface_scramble(u8 a9, u8 a8, u8 a7, u8 a6, u8 a5, u8 a4, u8 a3,u8 a2,u8 a1,u8 a0)
{
m_external_addrswap[9] = a9;
m_external_addrswap[8] = a8;
@@ -83,54 +82,53 @@ public:
devcb_read16 m_port_b_r;
devcb_read16 m_port_c_r;
- uint8_t m_bankswitch_swap_read_address;
- uint16_t m_magic_read_address_xor;
+ u8 m_bankswitch_swap_read_address;
+ u16 m_magic_read_address_xor;
bool m_magic_read_address_xor_enabled;
- uint8_t m_xor_port;
- uint8_t m_mask_port;
- uint8_t m_soundlatch_port;
+ u8 m_xor_port;
+ u8 m_mask_port;
+ u8 m_soundlatch_port;
- uint8_t m_external_addrswap[10];
+ u8 m_external_addrswap[10];
deco146port_xx const *m_lookup_table;
protected:
- deco_146_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
+ deco_146_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
virtual void device_start() override;
virtual void device_reset() override;
- uint16_t read_protport(uint16_t address, uint16_t mem_mask);
- virtual void write_protport(uint16_t address, uint16_t data, uint16_t mem_mask);
- virtual uint16_t read_data_getloc(uint16_t address, int& location);
+ u16 read_protport(u16 address);
+ virtual void write_protport(u16 address, u16 data, u16 mem_mask);
+ virtual u16 read_data_getloc(u16 address, int& location);
- uint16_t m_rambank0[0x80];
- uint16_t m_rambank1[0x80];
+ std::unique_ptr<u16[]> m_rambank[2];
int m_current_rambank;
- uint16_t m_nand;
- uint16_t m_xor;
+ u16 m_nand;
+ u16 m_xor;
- uint16_t m_latchaddr;
- uint16_t m_latchdata;
+ u16 m_latchaddr;
+ u16 m_latchdata;
- uint8_t m_configregion; // which value of upper 4 address lines accesses the config region
+ u8 m_configregion; // which value of upper 4 address lines accesses the config region
int m_latchflag;
private:
TIMER_CALLBACK_MEMBER(write_soundlatch);
- uint8_t region_selects[6];
+ u8 region_selects[6];
- uint8_t m_soundlatch;
+ u8 m_soundlatch;
devcb_write_line m_soundlatch_irq_cb;
};
class deco146_device : public deco_146_base_device
{
public:
- deco146_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
+ deco146_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};
DECLARE_DEVICE_TYPE(DECO146PROT, deco146_device)