mirror of
https://github.com/holub/mame
synced 2025-06-07 21:33:45 +03:00
jaleco/ms1_gatearray.cpp: Cleaned up code. (#11663)
This commit is contained in:
parent
de955af966
commit
7e572705cc
@ -21,7 +21,6 @@ megasys1_gatearray_device::megasys1_gatearray_device(
|
|||||||
, m_cpu(*this, finder_base::DUMMY_TAG)
|
, m_cpu(*this, finder_base::DUMMY_TAG)
|
||||||
, m_cpuregion(*this, finder_base::DUMMY_TAG)
|
, m_cpuregion(*this, finder_base::DUMMY_TAG)
|
||||||
{
|
{
|
||||||
m_has_decoded = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ void megasys1_gatearray_device::device_start()
|
|||||||
save_item(NAME(m_gatearray_hs));
|
save_item(NAME(m_gatearray_hs));
|
||||||
save_item(NAME(m_gatearray_hs_ram));
|
save_item(NAME(m_gatearray_hs_ram));
|
||||||
rom_decode();
|
rom_decode();
|
||||||
install_gatearray_overlay();
|
install_overlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void megasys1_gatearray_device::device_reset()
|
void megasys1_gatearray_device::device_reset()
|
||||||
@ -47,18 +46,18 @@ void megasys1_gatearray_d65006_device::rom_decode()
|
|||||||
|
|
||||||
for (int i = 0 ; i < size/2 ; i++)
|
for (int i = 0 ; i < size/2 ; i++)
|
||||||
{
|
{
|
||||||
|
const u16 x = RAM[i];
|
||||||
|
|
||||||
|
auto const BITSWAP_0 = [x] () { return bitswap<16>(x,0xd,0xe,0xf,0x0,0x1,0x8,0x9,0xa,0xb,0xc,0x5,0x6,0x7,0x2,0x3,0x4); };
|
||||||
|
auto const BITSWAP_1 = [x] () { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0xe,0xc,0xa,0x8,0x6,0x4,0x2,0x0); };
|
||||||
|
auto const BITSWAP_2 = [x] () { return bitswap<16>(x,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
||||||
|
|
||||||
u16 y;
|
u16 y;
|
||||||
u16 x = RAM[i];
|
if (i < 0x08000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
|
else if (i < 0x10000/2) { y = BITSWAP_2(); }
|
||||||
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0xe,0xf,0x0,0x1,0x8,0x9,0xa,0xb,0xc,0x5,0x6,0x7,0x2,0x3,0x4); };
|
else if (i < 0x18000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0xe,0xc,0xa,0x8,0x6,0x4,0x2,0x0); };
|
else if (i < 0x20000/2) { y = BITSWAP_1(); }
|
||||||
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
else { y = BITSWAP_2(); }
|
||||||
|
|
||||||
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x10000/2) { y = BITSWAP_2(x); }
|
|
||||||
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
|
|
||||||
else { y = BITSWAP_2(x); }
|
|
||||||
|
|
||||||
RAM[i] = y;
|
RAM[i] = y;
|
||||||
}
|
}
|
||||||
@ -73,18 +72,18 @@ void megasys1_gatearray_gs88000_device::rom_decode()
|
|||||||
|
|
||||||
for (int i = 0 ; i < size/2 ; i++)
|
for (int i = 0 ; i < size/2 ; i++)
|
||||||
{
|
{
|
||||||
|
const u16 x = RAM[i];
|
||||||
|
|
||||||
|
auto const BITSWAP_0 = [x] () { return bitswap<16>(x,0xd,0xe,0xf,0x0,0xa,0x9,0x8,0x1,0x6,0x5,0xc,0xb,0x7,0x2,0x3,0x4); };
|
||||||
|
auto const BITSWAP_1 = [x] () { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0x8,0xa,0xc,0xe,0x0,0x2,0x4,0x6); };
|
||||||
|
auto const BITSWAP_2 = [x] () { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
||||||
|
|
||||||
u16 y;
|
u16 y;
|
||||||
u16 x = RAM[i];
|
if (i < 0x08000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
|
else if (i < 0x10000/2) { y = BITSWAP_2(); }
|
||||||
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0xe,0xf,0x0,0xa,0x9,0x8,0x1,0x6,0x5,0xc,0xb,0x7,0x2,0x3,0x4); };
|
else if (i < 0x18000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0x7,0x5,0x3,0x1,0x8,0xa,0xc,0xe,0x0,0x2,0x4,0x6); };
|
else if (i < 0x20000/2) { y = BITSWAP_1(); }
|
||||||
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
else { y = BITSWAP_2(); }
|
||||||
|
|
||||||
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x10000/2) { y = BITSWAP_2(x); }
|
|
||||||
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
|
|
||||||
else { y = BITSWAP_2(x); }
|
|
||||||
|
|
||||||
RAM[i] = y;
|
RAM[i] = y;
|
||||||
}
|
}
|
||||||
@ -98,19 +97,19 @@ void megasys1_gatearray_unkarray_device::rom_decode()
|
|||||||
|
|
||||||
for (int i = 0 ; i < size/2 ; i++)
|
for (int i = 0 ; i < size/2 ; i++)
|
||||||
{
|
{
|
||||||
|
const u16 x = RAM[i];
|
||||||
|
|
||||||
|
auto const BITSWAP_0 = [x] () { return bitswap<16>(x,0xd,0x0,0xa,0x9,0x6,0xe,0xb,0xf,0x5,0xc,0x7,0x2,0x3,0x8,0x1,0x4); };
|
||||||
|
auto const BITSWAP_1 = [x] () { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
||||||
|
auto const BITSWAP_2 = [x] () { return bitswap<16>(x,0xf,0xd,0xb,0x9,0xc,0xe,0x0,0x7,0x5,0x3,0x1,0x8,0xa,0x2,0x4,0x6); };
|
||||||
|
auto const BITSWAP_3 = [x] () { return bitswap<16>(x,0x4,0x5,0x1,0x2,0xe,0xd,0x3,0xb,0xa,0x9,0x6,0x7,0x0,0x8,0xf,0xc); };
|
||||||
|
|
||||||
u16 y;
|
u16 y;
|
||||||
u16 x = RAM[i];
|
if (i < 0x08000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
|
else if (i < 0x10000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_2() : BITSWAP_3(); }
|
||||||
auto const BITSWAP_0 = [] (u16 x) { return bitswap<16>(x,0xd,0x0,0xa,0x9,0x6,0xe,0xb,0xf,0x5,0xc,0x7,0x2,0x3,0x8,0x1,0x4); };
|
else if (i < 0x18000/2) { y = ( (i | (0x248/2)) != i ) ? BITSWAP_0() : BITSWAP_1(); }
|
||||||
auto const BITSWAP_1 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x6,0x7,0x0,0x1,0x2,0x3,0xb,0xa,0x9,0x8,0xf,0xe,0xd,0xc); };
|
else if (i < 0x20000/2) { y = BITSWAP_1(); }
|
||||||
auto const BITSWAP_2 = [] (u16 x) { return bitswap<16>(x,0xf,0xd,0xb,0x9,0xc,0xe,0x0,0x7,0x5,0x3,0x1,0x8,0xa,0x2,0x4,0x6); };
|
else { y = BITSWAP_3(); }
|
||||||
auto const BITSWAP_3 = [] (u16 x) { return bitswap<16>(x,0x4,0x5,0x1,0x2,0xe,0xd,0x3,0xb,0xa,0x9,0x6,0x7,0x0,0x8,0xf,0xc); };
|
|
||||||
|
|
||||||
if (i < 0x08000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x10000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_2(x);} else {y = BITSWAP_3(x);} }
|
|
||||||
else if (i < 0x18000/2) { if ( (i | (0x248/2)) != i ) {y = BITSWAP_0(x);} else {y = BITSWAP_1(x);} }
|
|
||||||
else if (i < 0x20000/2) { y = BITSWAP_1(x); }
|
|
||||||
else { y = BITSWAP_3(x); }
|
|
||||||
|
|
||||||
RAM[i] = y;
|
RAM[i] = y;
|
||||||
}
|
}
|
||||||
@ -127,9 +126,14 @@ void megasys1_gatearray_unkarray_device::rom_decode()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool megasys1_gatearray_device::gatearray_hs_seq(u16 g1,u16 g2,u16 g3,u16 g4)
|
inline bool megasys1_gatearray_device::hs_seq() const
|
||||||
{
|
{
|
||||||
return (m_gatearray_hs_ram[0/2] == g1 && m_gatearray_hs_ram[2/2] == g2 && m_gatearray_hs_ram[4/2] == g3 && m_gatearray_hs_ram[6/2] == g4);
|
|
||||||
|
return
|
||||||
|
m_gatearray_hs_ram[0/2] == m_gatearray_seq[0] &&
|
||||||
|
m_gatearray_hs_ram[2/2] == m_gatearray_seq[1] &&
|
||||||
|
m_gatearray_hs_ram[4/2] == m_gatearray_seq[2] &&
|
||||||
|
m_gatearray_hs_ram[6/2] == m_gatearray_seq[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,7 +170,7 @@ void megasys1_gatearray_device::gatearray_w(offs_t offset, u16 data, u16 mem_mas
|
|||||||
|
|
||||||
COMBINE_DATA(&m_gatearray_hs_ram[offset]);
|
COMBINE_DATA(&m_gatearray_hs_ram[offset]);
|
||||||
|
|
||||||
if (gatearray_hs_seq(m_gatearray_seq[0],m_gatearray_seq[1],m_gatearray_seq[2],m_gatearray_seq[3]) && offset == 0x8/2)
|
if (hs_seq() && offset == 0x8/2)
|
||||||
m_gatearray_hs = 1;
|
m_gatearray_hs = 1;
|
||||||
else
|
else
|
||||||
m_gatearray_hs = 0;
|
m_gatearray_hs = 0;
|
||||||
@ -174,7 +178,7 @@ void megasys1_gatearray_device::gatearray_w(offs_t offset, u16 data, u16 mem_mas
|
|||||||
LOG("GATEARRAY HS W %04x (%04x) -> [%02x]\n",data,mem_mask,offset*2);
|
LOG("GATEARRAY HS W %04x (%04x) -> [%02x]\n",data,mem_mask,offset*2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void megasys1_gatearray_device::install_gatearray_overlay()
|
void megasys1_gatearray_device::install_overlay()
|
||||||
{
|
{
|
||||||
m_cpu->space(AS_PROGRAM).install_read_handler(0x00000, 0x3ffff, read16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_r)));
|
m_cpu->space(AS_PROGRAM).install_read_handler(0x00000, 0x3ffff, read16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_r)));
|
||||||
m_cpu->space(AS_PROGRAM).install_write_handler(0x20000, 0x2ffff, write16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_w)));
|
m_cpu->space(AS_PROGRAM).install_write_handler(0x20000, 0x2ffff, write16s_delegate(*this, FUNC(megasys1_gatearray_device::gatearray_w)));
|
||||||
|
@ -23,21 +23,20 @@ protected:
|
|||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
virtual void device_reset() override;
|
virtual void device_reset() override;
|
||||||
|
|
||||||
void install_gatearray_overlay();
|
void install_overlay();
|
||||||
u16 gatearray_r(offs_t offset, u16 mem_mask = ~0);
|
u16 gatearray_r(offs_t offset, u16 mem_mask = ~0);
|
||||||
void gatearray_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
void gatearray_w(offs_t offset, u16 data, u16 mem_mask = ~0);
|
||||||
bool gatearray_hs_seq(u16 g1,u16 g2,u16 g3,u16 g4);
|
bool hs_seq() const;
|
||||||
|
|
||||||
|
virtual void rom_decode() = 0;
|
||||||
|
|
||||||
int m_gatearray_hs = 0;
|
int m_gatearray_hs = 0;
|
||||||
u16 m_gatearray_hs_ram[0x8]{};
|
u16 m_gatearray_hs_ram[0x8]{};
|
||||||
|
|
||||||
const u16* m_gatearray_seq = nullptr;
|
const u16 *m_gatearray_seq = nullptr;
|
||||||
|
|
||||||
required_device<cpu_device> m_cpu;
|
required_device<cpu_device> m_cpu;
|
||||||
required_memory_region m_cpuregion;
|
required_memory_region m_cpuregion;
|
||||||
bool m_has_decoded;
|
|
||||||
|
|
||||||
virtual void rom_decode() = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +53,6 @@ protected:
|
|||||||
private:
|
private:
|
||||||
// write sequence return value
|
// write sequence return value
|
||||||
static constexpr u16 jaleco_d65006_unlock_sequence[5] = { 0x0000,0x0055,0x00aa,0x00ff, 0x835d };
|
static constexpr u16 jaleco_d65006_unlock_sequence[5] = { 0x0000,0x0055,0x00aa,0x00ff, 0x835d };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class megasys1_gatearray_gs88000_device : public megasys1_gatearray_device
|
class megasys1_gatearray_gs88000_device : public megasys1_gatearray_device
|
||||||
@ -69,9 +67,6 @@ protected:
|
|||||||
|
|
||||||
// write sequence return value
|
// write sequence return value
|
||||||
static constexpr u16 jaleco_gs88000_unlock_sequence[5] = { 0x00ff,0x0055,0x00aa,0x0000, 0x889e };
|
static constexpr u16 jaleco_gs88000_unlock_sequence[5] = { 0x00ff,0x0055,0x00aa,0x0000, 0x889e };
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class megasys1_gatearray_unkarray_device : public megasys1_gatearray_device
|
class megasys1_gatearray_unkarray_device : public megasys1_gatearray_device
|
||||||
@ -83,9 +78,6 @@ protected:
|
|||||||
megasys1_gatearray_unkarray_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
|
megasys1_gatearray_unkarray_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock);
|
||||||
|
|
||||||
virtual void rom_decode() override;
|
virtual void rom_decode() override;
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// device type definition
|
// device type definition
|
||||||
|
Loading…
Reference in New Issue
Block a user