modernize a little (nw)

This commit is contained in:
David Haywood 2014-04-20 01:20:44 +00:00
parent aa69cf772a
commit ce6e031021

View File

@ -87,6 +87,7 @@
#define LOG_PALETTE 0
#define LOG_IOCHIP 0
typedef device_delegate<int (int in)> segac2_prot_delegate;
class segac2_state : public md_base_state
{
@ -109,7 +110,7 @@ public:
UINT8 m_misc_io_data[0x10]; /* holds values written to the I/O chip */
/* protection-related tracking */
int (*m_prot_func)(int in); /* emulation of protection chip */
segac2_prot_delegate m_prot_func; /* emulation of protection chip */
UINT8 m_prot_write_buf; /* remembers what was written */
UINT8 m_prot_read_buf; /* remembers what was returned */
@ -147,7 +148,7 @@ public:
DECLARE_DRIVER_INIT(pclubjv2);
DECLARE_DRIVER_INIT(pclubjv4);
DECLARE_DRIVER_INIT(pclubjv5);
void segac2_common_init(int (*func)(int in));
void segac2_common_init(segac2_prot_delegate prot_func);
DECLARE_VIDEO_START(segac2_new);
DECLARE_MACHINE_START(segac2);
DECLARE_MACHINE_RESET(segac2);
@ -178,6 +179,29 @@ public:
optional_device<screen_device> m_screen;
required_device<palette_device> m_palette;
int prot_func_dummy(int in);
int prot_func_columns(int in);
int prot_func_columns2(int in);
int prot_func_tfrceac(int in);
int prot_func_borench(int in);
int prot_func_ribbit(int in);
int prot_func_twinsqua(int in);
int prot_func_puyo(int in);
int prot_func_tantr(int in);
int prot_func_tantrkor(int in);
int prot_func_potopoto(int in);
int prot_func_stkclmnj(int in);
int prot_func_stkclmns(int in);
int prot_func_ichirj(int in);
int prot_func_ichir(int in);
int prot_func_ichirk(int in);
int prot_func_puyopuy2(int in);
int prot_func_zunkyou(int in);
int prot_func_pclub(int in);
int prot_func_pclubjv2(int in);
int prot_func_pclubjv4(int in);
int prot_func_pclubjv5(int in);
};
@ -567,7 +591,7 @@ WRITE16_MEMBER(segac2_state::control_w )
/* protection chip reads */
READ16_MEMBER(segac2_state::prot_r )
{
if (LOG_PROTECTION) logerror("%06X:protection r=%02X\n", space.device().safe_pcbase(), m_prot_func ? m_prot_read_buf : 0xff);
if (LOG_PROTECTION) logerror("%06X:protection r=%02X\n", space.device().safe_pcbase(), m_prot_read_buf);
return m_prot_read_buf | 0xf0;
}
@ -590,8 +614,7 @@ WRITE16_MEMBER(segac2_state::prot_w )
m_prot_write_buf = data & 0x0f;
/* determine the value to return, should a read occur */
if (m_prot_func)
m_prot_read_buf = m_prot_func(table_index);
m_prot_read_buf = m_prot_func(table_index);
if (LOG_PROTECTION) logerror("%06X:protection w=%02X, new result=%02X\n", space.device().safe_pcbase(), data & 0x0f, m_prot_read_buf);
/* if the palette changed, force an update */
@ -1921,19 +1944,22 @@ it should be, otherwise I don't see how the formula could be computed.
******************************************************************************/
void segac2_state::segac2_common_init(int (*func)(int in))
void segac2_state::segac2_common_init(segac2_prot_delegate prot_func)
{
DRIVER_INIT_CALL(megadriv_c2);
m_prot_func = func;
m_prot_func = prot_func;
if (m_upd7759 != NULL)
m_maincpu->space(AS_PROGRAM).install_write_handler(0x880000, 0x880001, 0, 0x13fefe, write16_delegate(FUNC(segac2_state::segac2_upd7759_w),this));
}
int segac2_state::prot_func_dummy(int in)
{
return 0x0;
}
/* 317-0149 */
static int prot_func_columns(int in)
int segac2_state::prot_func_columns(int in)
{
int const b0 = BIT( in,2) ^ ((BIT(~in,0) && BIT( in,7)) || (BIT( in,4) && BIT( in,6)));
int const b1 = BIT(~in,0) ^ (BIT( in,2) || (BIT( in,5) && BIT(~in,6) && BIT( in,7)));
@ -1944,7 +1970,7 @@ static int prot_func_columns(int in)
}
/* 317-0160 */
static int prot_func_columns2(int in)
int segac2_state::prot_func_columns2(int in)
{
int const b0 = BIT( in,2) ^ (BIT( in,1) || (BIT( in,4) && BIT( in,5)));
int const b1 = (BIT( in,0) && BIT( in,3) && BIT( in,4)) ^ (BIT( in,6) || (BIT( in,5) && BIT( in,7)));
@ -1955,7 +1981,7 @@ static int prot_func_columns2(int in)
}
/* 317-0172 */
static int prot_func_tfrceac(int in)
int segac2_state::prot_func_tfrceac(int in)
{
int const b0 = BIT(~in,2) ^ ((BIT( in,0) && BIT(~in,7)) || (BIT( in,3) && BIT( in,4)));
int const b1 = (BIT( in,4) && BIT(~in,5) && BIT( in,7)) ^ ((BIT(~in,0) || BIT(~in,3)) && (BIT(~in,6) || BIT(~in,7))); // not in the form x1 XOR (x2 OR x3 OR x4)
@ -1966,7 +1992,7 @@ static int prot_func_tfrceac(int in)
}
/* 317-0173 */
static int prot_func_borench(int in)
int segac2_state::prot_func_borench(int in)
{
int const b0 = (BIT( in,1) && BIT( in,2) && BIT( in,3) && BIT( in,7)) ^ (BIT( in,5) || (BIT(~in,0) && BIT(~in,4)));
int const b1 = (BIT(~in,2) && BIT( in,3) && BIT( in,5)) ^ (BIT( in,1) || (BIT( in,0) && BIT(~in,4)));
@ -1977,7 +2003,7 @@ static int prot_func_borench(int in)
}
/* 317-0178 */
static int prot_func_ribbit(int in)
int segac2_state::prot_func_ribbit(int in)
{
int const b0 = (BIT( in,0) && BIT( in,4)) ^ ((BIT( in,1) && BIT( in,2)) || BIT( in,3) || BIT(~in,5));
int const b1 = (BIT( in,1) && BIT( in,5)) ^ ((BIT( in,2) && BIT( in,3)) || BIT( in,0) || BIT(~in,6));
@ -1988,7 +2014,7 @@ static int prot_func_ribbit(int in)
}
/* 317-0193 */
static int prot_func_twinsqua(int in)
int segac2_state::prot_func_twinsqua(int in)
{
int const b0 = (BIT( in,2) && BIT(~in,5)) ^ (BIT( in,3) || BIT(~in,4));
int const b1 = (BIT( in,0) && BIT(~in,2) && BIT( in,4)) ^ (BIT(~in,0) || BIT(~in,4) || BIT(~in,6)); // 0,4 repeated
@ -1999,7 +2025,7 @@ static int prot_func_twinsqua(int in)
}
/* 317-0203 */
static int prot_func_puyo(int in)
int segac2_state::prot_func_puyo(int in)
{
int const b0 = (BIT(~in,3) && BIT( in,7)) ^ ((BIT(~in,0) && BIT(~in,1)) || (BIT(~in,1) && BIT(~in,4))); // 1 repeated
int const b1 = (BIT( in,3) && BIT( in,5)) ^ (BIT(~in,2) || BIT( in,4) || BIT( in,6));
@ -2010,7 +2036,7 @@ static int prot_func_puyo(int in)
}
/* 317-0211 */
static int prot_func_tantr(int in)
int segac2_state::prot_func_tantr(int in)
{
int const b0 = (BIT( in,0) && BIT( in,4)) ^ ( BIT( in,5) || BIT(~in,6) || (BIT(~in,3) && BIT( in,7)));
int const b1 = (BIT( in,2) && BIT( in,6)) ^ ((BIT( in,1) && BIT( in,5)) || (BIT( in,3) && BIT( in,4)));
@ -2021,7 +2047,7 @@ static int prot_func_tantr(int in)
}
/* 317-???? */
static int prot_func_tantrkor(int in)
int segac2_state::prot_func_tantrkor(int in)
{
int const b0 = (BIT(~in,1) && BIT(~in,7)) ^ (BIT(~in,2) && BIT(~in,4));
int const b1 = (BIT( in,2) && BIT( in,6)) ^ (BIT( in,0) && BIT( in,1));
@ -2032,7 +2058,7 @@ static int prot_func_tantrkor(int in)
}
/* 317-0218 */
static int prot_func_potopoto(int in)
int segac2_state::prot_func_potopoto(int in)
{
int const b0 = (BIT(~in,2) && BIT(~in,4)) ^ (BIT(~in,1) && BIT( in,3));
int const b1 = (BIT( in,0) && BIT( in,5)) ^ (BIT( in,2) || BIT(~in,7));
@ -2043,7 +2069,7 @@ static int prot_func_potopoto(int in)
}
/* 317-0219 */
static int prot_func_stkclmnj(int in)
int segac2_state::prot_func_stkclmnj(int in)
{
int const b0 = (BIT( in,1) && BIT( in,4)) ^ (BIT( in,5) && BIT( in,2));
int const b1 = (BIT(~in,2) && BIT( in,6)) ^ (BIT(~in,5) && BIT( in,7));
@ -2054,7 +2080,7 @@ static int prot_func_stkclmnj(int in)
}
/* 317-0223 */
static int prot_func_stkclmns(int in)
int segac2_state::prot_func_stkclmns(int in)
{
int const b0 = (BIT( in,2) && BIT( in,4)) ^ (BIT( in,1) || BIT(~in,3));
int const b1 = (BIT( in,0) && BIT( in,5)) ^ (BIT( in,2) && BIT( in,7));
@ -2065,7 +2091,7 @@ static int prot_func_stkclmns(int in)
}
/* 317-0224 */
static int prot_func_ichirj(int in)
int segac2_state::prot_func_ichirj(int in)
{
int const b0 = (BIT( in,2) && BIT( in,4)) ^ (BIT(~in,5) && BIT(~in,2));
int const b1 = (BIT( in,2) && BIT(~in,6)) ^ (BIT( in,5) && BIT( in,7));
@ -2076,7 +2102,7 @@ static int prot_func_ichirj(int in)
}
/* 317-???? */
static int prot_func_ichir(int in)
int segac2_state::prot_func_ichir(int in)
{
int const b0 = (BIT(~in,2) && BIT( in,4)) ^ (BIT( in,5) && BIT(~in,2));
int const b1 = (BIT( in,1) && BIT( in,6)) ^ (BIT( in,5) || BIT( in,7));
@ -2087,7 +2113,7 @@ static int prot_func_ichir(int in)
}
/* 317-???? */
static int prot_func_ichirk(int in)
int segac2_state::prot_func_ichirk(int in)
{
int const b0 = (BIT(~in,2) && BIT( in,4)) ^ (BIT( in,5) && BIT(~in,1));
int const b1 = (BIT( in,0) && BIT( in,6)) ^ (BIT( in,5) && BIT( in,4));
@ -2098,7 +2124,7 @@ static int prot_func_ichirk(int in)
}
/* 317-0228 */
static int prot_func_puyopuy2(int in)
int segac2_state::prot_func_puyopuy2(int in)
{
int const b0 = (BIT(~in,0) && BIT(~in,7)) ^ (BIT( in,1) || BIT(~in,4) || BIT(~in,6));
int const b1 = (BIT( in,0) && BIT(~in,6)) ^ (BIT( in,3) && BIT( in,5));
@ -2108,7 +2134,7 @@ static int prot_func_puyopuy2(int in)
return (b3 << 3) | (b2 << 2) | (b1 << 1) | b0;
}
static int prot_func_zunkyou(int in)
int segac2_state::prot_func_zunkyou(int in)
{
int const b0 = (BIT(~in,1) && BIT( in,6)) ^ (BIT(~in,5) && BIT( in,7));
int const b1 = (BIT( in,0) && BIT(~in,5)) ^ (BIT(~in,3) || BIT( in,4));
@ -2118,12 +2144,12 @@ static int prot_func_zunkyou(int in)
return (b3 << 3) | (b2 << 2) | (b1 << 1) | b0;
}
static int prot_func_pclub(int in)
int segac2_state::prot_func_pclub(int in)
{
return 0xf;
}
static int prot_func_pclubjv2(int in)
int segac2_state::prot_func_pclubjv2(int in)
{
int const b0 = (BIT( in,3) && BIT(~in,4)) ^ ((BIT(~in,1) && BIT(~in,7)) || BIT( in,6));
int const b1 = (BIT( in,0) && BIT( in,5)) ^ (BIT( in,2) && BIT(~in,6));
@ -2133,7 +2159,7 @@ static int prot_func_pclubjv2(int in)
return (b3 << 3) | (b2 << 2) | (b1 << 1) | b0;
}
static int prot_func_pclubjv4(int in)
int segac2_state::prot_func_pclubjv4(int in)
{
int const b0 = (BIT(~in,2) && BIT( in,4)) ^ (BIT( in,1) && BIT(~in,6) && BIT(~in,3));
int const b1 = (BIT(~in,3) && BIT(~in,4)) ^ (BIT( in,0) && BIT( in,5) && BIT(~in,6));
@ -2143,7 +2169,7 @@ static int prot_func_pclubjv4(int in)
return (b3 << 3) | (b2 << 2) | (b1 << 1) | b0;
}
static int prot_func_pclubjv5(int in)
int segac2_state::prot_func_pclubjv5(int in)
{
int const b0 = (BIT(~in,1) && BIT( in,5)) ^ (BIT(~in,2) && BIT(~in,6));
int const b1 = (BIT(~in,0) && BIT( in,4)) ^ (BIT(~in,3) && BIT(~in,7));
@ -2157,94 +2183,94 @@ static int prot_func_pclubjv5(int in)
DRIVER_INIT_MEMBER(segac2_state,c2boot)
{
segac2_common_init(NULL);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_dummy),this));
}
DRIVER_INIT_MEMBER(segac2_state,bloxeedc)
{
segac2_common_init(NULL);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_dummy),this));
}
DRIVER_INIT_MEMBER(segac2_state,columns)
{
segac2_common_init(prot_func_columns);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_columns),this));
}
DRIVER_INIT_MEMBER(segac2_state,columns2)
{
segac2_common_init(prot_func_columns2);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_columns2),this));
}
DRIVER_INIT_MEMBER(segac2_state,tfrceac)
{
segac2_common_init(prot_func_tfrceac);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_tfrceac),this));
}
DRIVER_INIT_MEMBER(segac2_state,tfrceacb)
{
/* disable the palette bank switching from the protection chip */
segac2_common_init(NULL);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_dummy),this));
m_maincpu->space(AS_PROGRAM).nop_write(0x800000, 0x800001);
}
DRIVER_INIT_MEMBER(segac2_state,borench)
{
segac2_common_init(prot_func_borench);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_borench),this));
}
DRIVER_INIT_MEMBER(segac2_state,twinsqua)
{
segac2_common_init(prot_func_twinsqua);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_twinsqua),this));
}
DRIVER_INIT_MEMBER(segac2_state,ribbit)
{
segac2_common_init(prot_func_ribbit);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_ribbit),this));
}
DRIVER_INIT_MEMBER(segac2_state,puyo)
{
segac2_common_init(prot_func_puyo);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_puyo),this));
}
DRIVER_INIT_MEMBER(segac2_state,tantr)
{
segac2_common_init(prot_func_tantr);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_tantr),this));
}
DRIVER_INIT_MEMBER(segac2_state,tantrkor)
{
segac2_common_init(prot_func_tantrkor);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_tantrkor),this));
}
DRIVER_INIT_MEMBER(segac2_state,potopoto)
{
segac2_common_init(prot_func_potopoto);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_potopoto),this));
}
DRIVER_INIT_MEMBER(segac2_state,stkclmns)
{
segac2_common_init(prot_func_stkclmns);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_stkclmns),this));
}
DRIVER_INIT_MEMBER(segac2_state,stkclmnj)
{
segac2_common_init(prot_func_stkclmnj);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_stkclmnj),this));
}
DRIVER_INIT_MEMBER(segac2_state,ichir)
{
segac2_common_init(prot_func_ichir);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_ichir),this));
}
DRIVER_INIT_MEMBER(segac2_state,ichirk)
{
segac2_common_init(prot_func_ichirk);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_ichirk),this));
}
DRIVER_INIT_MEMBER(segac2_state,ichirj)
{
segac2_common_init(prot_func_ichirj);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_ichirj),this));
}
READ16_MEMBER(segac2_state::ichirjbl_prot_r )
@ -2254,25 +2280,25 @@ READ16_MEMBER(segac2_state::ichirjbl_prot_r )
DRIVER_INIT_MEMBER(segac2_state,ichirjbl)
{
segac2_common_init(NULL);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_dummy),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x840108, 0x840109, read16_delegate(FUNC(segac2_state::ichirjbl_prot_r),this) );
}
DRIVER_INIT_MEMBER(segac2_state,puyopuy2)
{
segac2_common_init(prot_func_puyopuy2);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_puyopuy2),this));
}
DRIVER_INIT_MEMBER(segac2_state,zunkyou)
{
segac2_common_init(prot_func_zunkyou);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_zunkyou),this));
}
DRIVER_INIT_MEMBER(segac2_state,pclub)
{
segac2_common_init(prot_func_pclub);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_pclub),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880120, 0x880121, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.1*/
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880124, 0x880125, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.2*/
@ -2281,7 +2307,7 @@ DRIVER_INIT_MEMBER(segac2_state,pclub)
DRIVER_INIT_MEMBER(segac2_state,pclubjv2)
{
segac2_common_init(prot_func_pclubjv2);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_pclubjv2),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880120, 0x880121, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.1*/
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880124, 0x880125, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.2*/
@ -2290,7 +2316,7 @@ DRIVER_INIT_MEMBER(segac2_state,pclubjv2)
DRIVER_INIT_MEMBER(segac2_state,pclubjv4)
{
segac2_common_init(prot_func_pclubjv4);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_pclubjv4),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880120, 0x880121, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.1*/
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880124, 0x880125, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.2*/
@ -2299,7 +2325,7 @@ DRIVER_INIT_MEMBER(segac2_state,pclubjv4)
DRIVER_INIT_MEMBER(segac2_state,pclubjv5)
{
segac2_common_init(prot_func_pclubjv5);
segac2_common_init(segac2_prot_delegate(FUNC(segac2_state::prot_func_pclubjv5),this));
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880120, 0x880121, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.1*/
m_maincpu->space(AS_PROGRAM).install_read_handler(0x880124, 0x880125, read16_delegate(FUNC(segac2_state::printer_r),this) );/*Print Club Vol.2*/
@ -2321,7 +2347,6 @@ DRIVER_INIT_MEMBER(segac2_state,pclubjv5)
bloxeedc is set as as clone of bloxeed as it is the same game but running
on a different piece of hardware. The parent 'bloxeed' is a system18 game
and does not currently work due to it being encrypted.
******************************************************************************/
@ -2343,7 +2368,7 @@ GAME( 1990, tfrceacj, tfrceac, segac2, tfrceac, segac2_state, tfrceac, ROT0,
GAME( 1990, tfrceacb, tfrceac, segac2, tfrceac, segac2_state, tfrceacb, ROT0, "bootleg", "Thunder Force AC (bootleg)", 0 )
GAME( 1990, borench, 0, segac2, borench, segac2_state, borench, ROT0, "Sega", "Borench (set 1)", 0 )
GAME( 1990, borencha, borench, segac2, borench, segac2_state, borench, ROT0, "Sega", "Borench (set 2)", 0 )
GAME( 1990, borencha, borench, segac2, borench, segac2_state, borench, ROT0, "Sega", "Borench (set 2)", GAME_NO_SOUND ) // why doesn't the sound play on this set?
GAME( 1991, twinsqua, 0, segac2, twinsqua, segac2_state, twinsqua, ROT0, "Sega", "Twin Squash", 0 )