part 2 (nw)

This commit is contained in:
David Haywood 2013-11-08 15:56:09 +00:00
parent 666532e476
commit ec40506c6a
2 changed files with 91 additions and 123 deletions

View File

@ -64,34 +64,17 @@ void igs025_device::device_start()
save_item(NAME(m_kb_ptr));
m_olds_prot_hold = 0;
m_olds_prot_hilo = 0;
m_olds_prot_hilo_select = 0;
m_olds_cmd = 0;
m_olds_reg = 0;
m_olds_ptr = 0;
m_olds_bs = 0;
m_olds_cmd3 = 0;
m_kb_cmd3 = 0;
save_item(NAME(m_olds_cmd));
save_item(NAME(m_olds_reg));
save_item(NAME(m_olds_ptr));
save_item(NAME(m_olds_bs));
save_item(NAME(m_olds_cmd3));
save_item(NAME(m_kb_cmd3));
m_drgw2_cmd = 0;
m_drgw2_ptr = 0;
m_drgw2_prot_hilo = 0;
m_drgw2_prot_hilo_select = 0;
m_drgw2_prot_hold = 0;
save_item(NAME(m_drgw2_cmd));
save_item(NAME(m_drgw2_ptr));
save_item(NAME(m_drgw2_prot_hilo));
save_item(NAME(m_drgw2_prot_hilo_select));
save_item(NAME(m_drgw2_prot_hold));
}
void igs025_device::device_reset()
@ -105,38 +88,12 @@ void igs025_device::device_reset()
m_kb_ptr = 0;
m_kb_swap = 0;
m_olds_prot_hold = 0;
m_olds_prot_hilo = 0;
m_olds_prot_hilo_select = 0;
m_olds_cmd = 0;
m_olds_reg = 0;
m_olds_ptr = 0;
m_olds_bs = 0;
m_olds_cmd3 = 0;
m_drgw2_cmd = 0;
m_drgw2_ptr = 0;
m_drgw2_prot_hilo = 0;
m_drgw2_prot_hilo_select = 0;
m_drgw2_prot_hold = 0;
m_kb_cmd3 = 0;
}
void igs025_device::killbld_protection_calculate_hold(int y, int z)
{
unsigned short old = m_kb_prot_hold;
m_kb_prot_hold = ((old << 1) | (old >> 15));
m_kb_prot_hold ^= 0x2bad;
m_kb_prot_hold ^= BIT(z, y);
m_kb_prot_hold ^= BIT( old, 7) << 0;
m_kb_prot_hold ^= BIT(~old, 13) << 4;
m_kb_prot_hold ^= BIT( old, 3) << 11;
m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1;
}
void igs025_device::killbld_protection_calculate_hilo()
{
@ -269,39 +226,25 @@ READ16_MEMBER(igs025_device::killbld_igs025_prot_r )
/* todo, collapse this all into above */
void igs025_device::olds_protection_calculate_hold(int y, int z) // calculated in routine $12dbc2 in olds
{
unsigned short old = m_olds_prot_hold;
m_olds_prot_hold = ((old << 1) | (old >> 15));
m_olds_prot_hold ^= 0x2bad;
m_olds_prot_hold ^= BIT(z, y);
m_olds_prot_hold ^= BIT( old, 7) << 0;
m_olds_prot_hold ^= BIT(~old, 13) << 4;
m_olds_prot_hold ^= BIT( old, 3) << 11;
m_olds_prot_hold ^= (m_olds_prot_hilo & ~0x0408) << 1; // $81790c
}
void igs025_device::olds_protection_calculate_hilo() // calculated in routine $12dbc2 in olds
{
UINT8 source;
m_olds_prot_hilo_select++;
if (m_olds_prot_hilo_select > 0xeb) {
m_olds_prot_hilo_select = 0;
m_kb_prot_hilo_select++;
if (m_kb_prot_hilo_select > 0xeb) {
m_kb_prot_hilo_select = 0;
}
source = olds_source_data[m_drgw2_protection_region][m_olds_prot_hilo_select];
source = olds_source_data[m_drgw2_protection_region][m_kb_prot_hilo_select];
if (m_olds_prot_hilo_select & 1) // $8178fa
if (m_kb_prot_hilo_select & 1) // $8178fa
{
m_olds_prot_hilo = (m_olds_prot_hilo & 0x00ff) | (source << 8); // $8178d8
m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); // $8178d8
}
else
{
m_olds_prot_hilo = (m_olds_prot_hilo & 0xff00) | (source << 0); // $8178d8
m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); // $8178d8
}
}
@ -309,14 +252,14 @@ WRITE16_MEMBER(igs025_device::olds_w )
{
if (offset == 0)
{
m_olds_cmd = data;
m_kb_cmd = data;
}
else
{
switch (m_olds_cmd)
switch (m_kb_cmd)
{
case 0x00:
m_olds_reg = data;
m_kb_reg = data;
break;
case 0x02:
@ -327,12 +270,12 @@ WRITE16_MEMBER(igs025_device::olds_w )
{
m_execute_external();
m_olds_cmd3 = ((data >> 4) + 1) & 0x3;
m_kb_cmd3 = ((data >> 4) + 1) & 0x3;
}
break;
case 0x04:
m_olds_ptr = data;
m_kb_ptr = data;
break;
case 0x20:
@ -343,8 +286,8 @@ WRITE16_MEMBER(igs025_device::olds_w )
case 0x25:
case 0x26:
case 0x27:
m_olds_ptr++;
olds_protection_calculate_hold(m_olds_cmd & 0x0f, data & 0xff);
m_kb_ptr++;
olds_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff);
break;
// default:
@ -357,20 +300,20 @@ READ16_MEMBER(igs025_device::olds_r )
{
if (offset)
{
switch (m_olds_cmd)
switch (m_kb_cmd)
{
case 0x01:
return m_olds_reg & 0x7f;
return m_kb_reg & 0x7f;
case 0x02:
return m_olds_bs | 0x80;
case 0x03:
return m_olds_cmd3;
return m_kb_cmd3;
case 0x05:
{
switch (m_olds_ptr)
switch (m_kb_ptr)
{
case 1:
return 0x3f00 | ((m_kb_game_id >> 0) & 0xff);
@ -389,7 +332,7 @@ READ16_MEMBER(igs025_device::olds_r )
case 5:
default: // >= 5
return 0x3f00 | BITSWAP8(m_olds_prot_hold, 5,2,9,7,10,13,12,15); // $817906
return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15); // $817906
}
}
@ -403,49 +346,36 @@ READ16_MEMBER(igs025_device::olds_r )
}
void igs025_device::drgw2_protection_calculate_hold(int y, int z)
{
unsigned short old = m_drgw2_prot_hold;
m_drgw2_prot_hold = ((old << 1) | (old >> 15));
m_drgw2_prot_hold ^= 0x2bad;
m_drgw2_prot_hold ^= BIT(z, y);
m_drgw2_prot_hold ^= BIT( old, 7) << 0;
m_drgw2_prot_hold ^= BIT(~old, 13) << 4;
m_drgw2_prot_hold ^= BIT( old, 3) << 11;
m_drgw2_prot_hold ^= (m_drgw2_prot_hilo & ~0x0408) << 1;
}
void igs025_device::drgw2_protection_calculate_hilo()
{
UINT8 source;
m_drgw2_prot_hilo_select++;
if (m_drgw2_prot_hilo_select > 0xeb) {
m_drgw2_prot_hilo_select = 0;
m_kb_prot_hilo_select++;
if (m_kb_prot_hilo_select > 0xeb) {
m_kb_prot_hilo_select = 0;
}
source = m_drgw2_source_data[m_drgw2_protection_region][m_drgw2_prot_hilo_select];
source = m_drgw2_source_data[m_drgw2_protection_region][m_kb_prot_hilo_select];
if (m_drgw2_prot_hilo_select & 1)
if (m_kb_prot_hilo_select & 1)
{
m_drgw2_prot_hilo = (m_drgw2_prot_hilo & 0x00ff) | (source << 8);
m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8);
}
else
{
m_drgw2_prot_hilo = (m_drgw2_prot_hilo & 0xff00) | (source << 0);
m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0);
}
}
READ16_MEMBER(igs025_device::drgw2_d80000_protection_r )
{
switch (m_drgw2_cmd)
switch (m_kb_cmd)
{
case 0x05:
{
switch (m_drgw2_ptr)
switch (m_kb_ptr)
{
case 1:
return 0x3f00 | ((m_kb_game_id >> 0) & 0xff);
@ -461,7 +391,7 @@ READ16_MEMBER(igs025_device::drgw2_d80000_protection_r )
case 5:
default:
return 0x3f00 | BITSWAP8(m_drgw2_prot_hold, 5,2,9,7,10,13,12,15);
return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15);
}
return 0x3f00;
@ -479,7 +409,7 @@ READ16_MEMBER(igs025_device::drgw2_d80000_protection_r )
// return 0;
// default:
// logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_drgw2_cmd);
// logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_kb_cmd);
}
return 0;
@ -489,11 +419,11 @@ WRITE16_MEMBER(igs025_device::drgw2_d80000_protection_w )
{
if (offset == 0)
{
m_drgw2_cmd = data;
m_kb_cmd = data;
return;
}
switch (m_drgw2_cmd)
switch (m_kb_cmd)
{
case 0x20:
case 0x21:
@ -503,8 +433,8 @@ WRITE16_MEMBER(igs025_device::drgw2_d80000_protection_w )
case 0x25:
case 0x26:
case 0x27:
m_drgw2_ptr++;
drgw2_protection_calculate_hold(m_drgw2_cmd & 0x0f, data & 0xff);
m_kb_ptr++;
drgw2_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff);
break;
// case 0x08: // Used only on init..
@ -520,11 +450,59 @@ WRITE16_MEMBER(igs025_device::drgw2_d80000_protection_w )
// break;
// default:
// logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_drgw2_cmd, data);
// logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_kb_cmd, data);
}
}
void igs025_device::drgw2_protection_calculate_hold(int y, int z)
{
unsigned short old = m_kb_prot_hold;
m_kb_prot_hold = ((old << 1) | (old >> 15));
m_kb_prot_hold ^= 0x2bad;
m_kb_prot_hold ^= BIT(z, y);
m_kb_prot_hold ^= BIT(old, 7) << 0;
m_kb_prot_hold ^= BIT(~old, 13) << 4;
m_kb_prot_hold ^= BIT(old, 3) << 11;
m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1;
}
void igs025_device::olds_protection_calculate_hold(int y, int z) // calculated in routine $12dbc2 in olds
{
unsigned short old = m_kb_prot_hold;
m_kb_prot_hold = ((old << 1) | (old >> 15));
m_kb_prot_hold ^= 0x2bad;
m_kb_prot_hold ^= BIT(z, y);
m_kb_prot_hold ^= BIT(old, 7) << 0;
m_kb_prot_hold ^= BIT(~old, 13) << 4;
m_kb_prot_hold ^= BIT(old, 3) << 11;
m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1; // $81790c
}
void igs025_device::killbld_protection_calculate_hold(int y, int z)
{
unsigned short old = m_kb_prot_hold;
m_kb_prot_hold = ((old << 1) | (old >> 15));
m_kb_prot_hold ^= 0x2bad;
m_kb_prot_hold ^= BIT(z, y);
m_kb_prot_hold ^= BIT(old, 7) << 0;
m_kb_prot_hold ^= BIT(~old, 13) << 4;
m_kb_prot_hold ^= BIT(old, 3) << 11;
m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1;
}
const device_type IGS025 = &device_creator<igs025_device>;

View File

@ -26,7 +26,7 @@ public:
DECLARE_READ16_MEMBER( olds_r );
DECLARE_WRITE16_MEMBER( olds_w );
//const UINT8 *m_olds_prot_hilo_source2;
//const UINT8 *m_kb_prot_hilo_source2;
const UINT8 (*olds_source_data)[0xec];
DECLARE_READ16_MEMBER( drgw2_d80000_protection_r );
@ -55,14 +55,9 @@ protected:
void no_callback_setup(void);
int m_olds_cmd;
int m_olds_reg;
int m_olds_ptr;
UINT16 m_olds_bs;
UINT16 m_olds_cmd3;
UINT16 m_olds_prot_hold;
UINT16 m_olds_prot_hilo;
UINT16 m_olds_prot_hilo_select;
UINT16 m_kb_cmd3;
void olds_protection_calculate_hilo();
@ -72,11 +67,6 @@ protected:
UINT16 m_drgw2_prot_hold;
UINT16 m_drgw2_prot_hilo;
UINT16 m_drgw2_prot_hilo_select;
int m_drgw2_cmd;
int m_drgw2_ptr;
void drgw2_protection_calculate_hilo();