Merge pull request #5099 from cam900/igs022_tags

igs022.cpp : Updates
This commit is contained in:
R. Belmont 2019-05-23 12:59:20 -04:00 committed by GitHub
commit 24f105286a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 81 deletions

View File

@ -1252,7 +1252,6 @@ void igs017_state::init_lhzb2()
// install and configure protection device(s)
// m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xda5610, 0xda5613, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025));
// m_igs022->m_sharedprotram = m_sharedprotram;
// m_igs025->m_kb_source_data = dw3_source_data;
// m_igs025->m_kb_source_data_offset = 0;
// m_igs025->m_kb_game_id = 0x00060000;
@ -1426,7 +1425,6 @@ void igs017_state::init_slqz2()
// install and configure protection device(s)
// m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xda5610, 0xda5613, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025));
// m_igs022->m_sharedprotram = m_sharedprotram;
// m_igs025->m_kb_source_data = dw3_source_data;
// m_igs025->m_kb_source_data_offset = 0;
// m_igs025->m_kb_game_id = 0x00060000;
@ -4262,7 +4260,7 @@ ROM_START( lhzb2 )
ROM_REGION( 0x80000, "maincpu", 0 )
ROM_LOAD16_WORD_SWAP( "p1100.u30", 0x00000, 0x80000, CRC(68102b25) SHA1(6c1e8d204be0efda0e9b6c2f49b5c6760712475f) )
ROM_REGION( 0x10000, "igs022data", 0 ) // INTERNATIONAL GAMES SYSTEM CO.,LTD
ROM_REGION( 0x10000, "igs022", 0 ) // INTERNATIONAL GAMES SYSTEM CO.,LTD
ROM_LOAD( "m1104.u11",0x0000, 0x10000, CRC(794d0276) SHA1(ac903d2faa3fb315438dc8da22c5337611a8790d) )
ROM_REGION( 0x400000, "igs017_igs031:sprites", 0 ) // address scrambling
@ -4338,7 +4336,7 @@ ROM_START( slqz2 )
ROM_REGION( 0x80000, "maincpu", 0 )
ROM_LOAD16_WORD_SWAP( "p1100.u28", 0x00000, 0x80000, CRC(0b8e5c9e) SHA1(16572bd1163bba4da8a76b10649d2f71e50ad369) )
ROM_REGION( 0x10000, "igs022data", 0 ) // INTERNATIONAL GAMES SYSTEM CO.,LTD
ROM_REGION( 0x10000, "igs022", 0 ) // INTERNATIONAL GAMES SYSTEM CO.,LTD
ROM_LOAD( "m1103.u12", 0x00000, 0x10000, CRC(9f3b8d65) SHA1(5ee1ad025474399c2826f21d970e76f25d0fa1fd) )
ROM_REGION( 0x400000, "igs017_igs031:sprites", 0 ) // address scrambling

View File

@ -1042,7 +1042,7 @@ ROM_START( drgw3 )
ROM_LOAD16_BYTE( "dw3_v106.u12", 0x100001, 0x080000, CRC(c3f6838b) SHA1(c135b1d4dd62af308139d40d03c29be7508fb1e7) )
ROM_LOAD16_BYTE( "dw3_v106.u13", 0x100000, 0x080000, CRC(28284e22) SHA1(4643a69881ddb7383ca10f3eb2aa2cf41be39e9f) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data - is it correct for this set? */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data - is it correct for this set? */
ROM_LOAD( "dw3_v100.u15", 0x000000, 0x010000, CRC(03dc4fdf) SHA1(b329b04325d4f725231b1bb7862eedef2319b652) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -1068,7 +1068,7 @@ ROM_START( drgw3105 )
ROM_LOAD16_BYTE( "dw3_v105.u12", 0x100001, 0x080000, CRC(c5e24318) SHA1(c6954495bbc72c3985df75aecf6afd6826c8e30e) )
ROM_LOAD16_BYTE( "dw3_v105.u13", 0x100000, 0x080000, CRC(8d6c9d39) SHA1(cb79303ab551e91f07e11414db4254d5b161d415) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data - is it correct for this set? */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data - is it correct for this set? */
ROM_LOAD( "dw3_v100.u15", 0x000000, 0x010000, CRC(03dc4fdf) SHA1(b329b04325d4f725231b1bb7862eedef2319b652) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -1093,7 +1093,7 @@ ROM_START( drgw3103 )
ROM_LOAD16_BYTE( "dw3_v103j.u12", 0x100001, 0x080000, CRC(275b39a2) SHA1(8ba4d2601734c2dda3d4269fbe8f543dc3f0b212) )
ROM_LOAD16_BYTE( "dw3_v103j.u13", 0x100000, 0x080000, CRC(9aa56e8f) SHA1(c3f27d8b59adf72040a2e2c11e34f9b07efd7e9e) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "dw3_v100.u15", 0x000000, 0x010000, CRC(03dc4fdf) SHA1(b329b04325d4f725231b1bb7862eedef2319b652) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -1141,7 +1141,7 @@ ROM_START( drgw3100 )
ROM_LOAD16_BYTE( "dw3_v100.u12", 0x100001, 0x080000, CRC(47243906) SHA1(9cd46e3cba97f049bcb238ceb6edf27a760ef831) )
ROM_LOAD16_BYTE( "dw3_v100.u13", 0x100000, 0x080000, CRC(b7cded21) SHA1(c1ae2af2e42227503c81bbcd2bd6862aa416bd78) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "dw3_v100.u15", 0x000000, 0x010000, CRC(03dc4fdf) SHA1(b329b04325d4f725231b1bb7862eedef2319b652) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -1193,7 +1193,7 @@ ROM_START( dwex )
ROM_LOAD16_BYTE( "ex_v100.u12", 0x100001, 0x080000, CRC(bc171799) SHA1(142329dffbca199f3e748a52146a03e27b36db6a) )
ROM_LOAD16_BYTE( "ex_v100.u13", 0x100000, 0x080000, CRC(7afe6322) SHA1(a52d71af1d6de16c5a3df23eacdab3466693ba8d) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "ex_data.u15", 0x000000, 0x010000, CRC(03dc4fdf) SHA1(b329b04325d4f725231b1bb7862eedef2319b652) )
ROM_REGION( 0x500000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -2015,7 +2015,7 @@ ROM_START( killbld )
PGM_68K_BIOS
ROM_LOAD16_WORD_SWAP( "p0300_v109.u9", 0x100000, 0x200000, CRC(2fcee215) SHA1(855281a9090bfdf3da9f4d50c121765131a13400) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "kb_u2.rom", 0x000000, 0x010000, CRC(de3eae63) SHA1(03af767ef764055bda528b5cc6a24b9e1218cca8) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -2051,7 +2051,7 @@ ROM_START( killbld104 )
ROM_LOAD16_BYTE( "kb_u4_v104.u4", 0x200001, 0x080000, CRC(1ed8b2e7) SHA1(331c037640cfc1fe743cd0e65a1156c470b3303e) )
ROM_LOAD16_BYTE( "kb_u5_v104.u5", 0x200000, 0x080000, CRC(a0bafc29) SHA1(b20db7c16353c6f87ed3c08c9d037b07336711f1) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "kb_u2_v104.u2", 0x000000, 0x010000, CRC(c970f6d5) SHA1(399fc6f80262784c566363c847dc3fdc4fb37494) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
@ -2087,7 +2087,7 @@ ROM_START( killbld106 )
ROM_LOAD16_BYTE( "kb_u4_v106.u4", 0x200001, 0x080000, CRC(169bbaaf) SHA1(a1833d3fd024c43ba7642f13e83a5b7b66631136) )
ROM_LOAD16_BYTE( "kb_u5_v106.u5", 0x200000, 0x080000, CRC(df85abd4) SHA1(f9e37f76c7af8a8492bd1fd22d8b3fbda194ed03) )
ROM_REGION( 0x010000, "igs022data", 0 ) /* Protection Data */
ROM_REGION( 0x010000, "igs022", 0 ) /* Protection Data */
ROM_LOAD( "kb_u2_v106.u2", 0x000000, 0x010000, CRC(5df8cf51) SHA1(d82e281a43015da653fc37e97f52943e03a07112) )
ROM_REGION( 0xa00000, "tiles", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */

View File

@ -11,17 +11,19 @@
#include "emu.h"
#include "igs022.h"
#include <algorithm>
igs022_device::igs022_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
igs022_device::igs022_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock)
: device_t(mconfig, IGS022, tag, owner, clock)
, m_sharedprotram(*this, "sharedprotram")
, m_rom(*this, DEVICE_SELF)
{
}
void igs022_device::device_start()
{
// Reset stuff
memset(m_kb_regs, 0, 0x100 * sizeof(uint32_t));
m_sharedprotram = nullptr;
std::fill(std::begin(m_kb_regs), std::end(m_kb_regs), 0);
save_item(NAME(m_kb_regs));
}
@ -30,25 +32,21 @@ void igs022_device::device_reset()
{
//printf("igs022_device::device_reset()");
if (!m_sharedprotram)
{
logerror("m_sharedprotram was not set\n");
return;
}
IGS022_reset();
memset(m_kb_regs, 0, 0x100 * sizeof(uint32_t));
std::fill(std::begin(m_kb_regs), std::end(m_kb_regs), 0);
}
void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uint16_t mode)
void igs022_device::IGS022_do_dma(u16 src, u16 dst, u16 size, u16 mode)
{
//printf("igs022_device::IGS022_do_dma\n");
uint16_t param;
/*
P_SRC =0x300290 (offset from prot rom base)
P_DST =0x300292 (words from 0x300000)
@ -61,13 +59,12 @@ void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uin
1,2,3 table based ops
*/
param = mode >> 8;
const u16 param = mode >> 8;
// the initial DMA on kilbld has 0x10 set, drgw3 has 0x18 set, not sure how they affect the operation.
if (mode & 0x00f8) printf("IGS022_do_dma mode bits %04x set\n", mode & 0x00f8);
mode &=0x7; // what are the other bits?
mode &= 0x7; // what are the other bits?
if ((mode == 0) || (mode == 1) || (mode == 2) || (mode == 3) || (mode == 4))
{
@ -81,19 +78,18 @@ void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uin
odd offsets cause an overflow
*/
int x;
uint16_t *PROTROM = (uint16_t*)memregion(":igs022data")->base();
const u16 *PROTROM = (u16*)m_rom->base();
for (x = 0; x < size; x++)
for (int x = 0; x < size; x++)
{
uint16_t dat2 = PROTROM[src + x];
u16 dat2 = PROTROM[src + x];
uint8_t extraoffset = param&0xff;
uint8_t* dectable = (uint8_t*)memregion(":igs022data")->base(); // the basic decryption table is at the start of the mcu data rom!
uint8_t taboff = ((x*2)+extraoffset) & 0xff; // must allow for overflow in instances of odd offsets
uint16_t extraxor = ((dectable[taboff+1]) << 8) | (dectable[taboff+0] << 0);
const u8 extraoffset = param & 0xff;
const u8* dectable = (u8*)m_rom->base(); // the basic decryption table is at the start of the mcu data rom!
const u8 taboff = ((x * 2) + extraoffset) & 0xff; // must allow for overflow in instances of odd offsets
u16 extraxor = ((dectable[taboff + 1]) << 8) | (dectable[taboff + 0] << 0);
if (mode==4)
if (mode == 4)
{
extraxor = 0;
if ((x & 0x003) == 0x000) extraxor |= 0x0049; // 'I'
@ -101,37 +97,34 @@ void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uin
if ((x & 0x003) == 0x002) extraxor |= 0x0053; // 'S'
if ((x & 0x003) == 0x003) extraxor |= 0x0020; // ' '
if ((x & 0x300) == 0x000) extraxor |= 0x4900; // 'I'
if ((x & 0x300) == 0x100) extraxor |= 0x4700; // 'G'
if ((x & 0x300) == 0x200) extraxor |= 0x5300; // 'S'
if ((x & 0x300) == 0x300) extraxor |= 0x2000; // ' '
}
// mode==0 plain
if (mode==3) dat2 ^= extraxor;
if (mode==2) dat2 += extraxor;
if (mode==1) dat2 -= extraxor;
// mode == 0 plain
if (mode == 3) dat2 ^= extraxor;
if (mode == 2) dat2 += extraxor;
if (mode == 1) dat2 -= extraxor;
if (mode==4)
if (mode == 4)
{
//printf("%06x | %04x (%04x)\n", (dst+x)*2, dat2, (uint16_t)(dat2-extraxor));
//printf("%06x | %04x (%04x)\n", (dst+x)*2, dat2, (u16)(dat2-extraxor));
dat2 -= extraxor;
}
m_sharedprotram[dst + x] = dat2;
}
}
else if (mode == 5)
{
/* mode 5 seems to be a byteswapped copy */
int x;
uint16_t *PROTROM = (uint16_t*)memregion(":igs022data")->base();
for (x = 0; x < size; x++)
const u16 *PROTROM = (u16*)m_rom->base();
for (int x = 0; x < size; x++)
{
uint16_t dat = PROTROM[src + x];
u16 dat = PROTROM[src + x];
dat = ((dat &0x00ff) << 8) | ((dat &0xff00) >> 8);
m_sharedprotram[dst + x] = dat;
@ -140,11 +133,10 @@ void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uin
else if (mode == 6)
{
/* mode 6 seems to be a nibble swapped copy */
int x;
uint16_t *PROTROM = (uint16_t*)memregion(":igs022data")->base();
for (x = 0; x < size; x++)
const u16 *PROTROM = (u16*)m_rom->base();
for (int x = 0; x < size; x++)
{
uint16_t dat = PROTROM[src + x];
u16 dat = PROTROM[src + x];
dat = ((dat & 0xf0f0) >> 4)|
((dat & 0x0f0f) << 4);
@ -171,18 +163,17 @@ void igs022_device::IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uin
// and puts the version # of the data rom in ram
void igs022_device::IGS022_reset()
{
int i;
uint16_t *PROTROM = (uint16_t*)memregion(":igs022data")->base();
const u16 *PROTROM = (u16*)m_rom->base();
// fill ram with A5 patern
for (i = 0; i < 0x4000/2; i++)
for (int i = 0; i < 0x4000/2; i++)
m_sharedprotram[i] = 0xa55a;
// the auto-dma
uint16_t src = PROTROM[0x100 / 2];
uint32_t dst = PROTROM[0x102 / 2];
uint16_t size = PROTROM[0x104 / 2];
uint16_t mode = PROTROM[0x106 / 2];
u16 src = PROTROM[0x100 / 2];
const u32 dst = PROTROM[0x102 / 2];
const u16 size = PROTROM[0x104 / 2];
u16 mode = PROTROM[0x106 / 2];
mode &= 0xff;
@ -200,17 +191,16 @@ void igs022_device::IGS022_handle_command()
{
//printf("igs022_device::IGS022_handle_command\n");
uint16_t cmd = m_sharedprotram[0x200/2];
const u16 cmd = m_sharedprotram[0x200/2];
if (cmd == 0x6d) // Store values to asic ram
{
uint32_t p1 = (m_sharedprotram[0x298/2] << 16) | m_sharedprotram[0x29a/2];
uint32_t p2 = (m_sharedprotram[0x29c/2] << 16) | m_sharedprotram[0x29e/2];
const u32 p1 = (m_sharedprotram[0x298/2] << 16) | m_sharedprotram[0x29a/2];
const u32 p2 = (m_sharedprotram[0x29c/2] << 16) | m_sharedprotram[0x29e/2];
if ((p2 & 0xffff) == 0x9) // Set value
{
int reg = (p2 >> 16) & 0xffff;
const int reg = (p2 >> 16) & 0xffff;
if (reg & 0x300) { // 300?? killbld expects 0x200, drgw3 expects 0x100?
m_kb_regs[reg & 0xff] = p1;
@ -219,24 +209,24 @@ void igs022_device::IGS022_handle_command()
if ((p2 & 0xffff) == 0x6) // Add value
{
int src1 = (p1 >> 16) & 0xff;
int src2 = (p1 >> 0) & 0xff;
int dst = (p2 >> 16) & 0xff;
const int src1 = (p1 >> 16) & 0xff;
const int src2 = (p1 >> 0) & 0xff;
const int dst = (p2 >> 16) & 0xff;
m_kb_regs[dst] = m_kb_regs[src2] - m_kb_regs[src1];
}
if ((p2 & 0xffff) == 0x1) // Add Imm?
{
int reg = (p2 >> 16) & 0xff;
int imm = (p1 >> 0) & 0xffff;
const int reg = (p2 >> 16) & 0xff;
const int imm = (p1 >> 0) & 0xffff;
m_kb_regs[reg] += imm;
}
if ((p2 & 0xffff) == 0xa) // Get value
{
int reg = (p1 >> 16) & 0xFF;
const int reg = (p1 >> 16) & 0xFF;
m_sharedprotram[0x29c/2] = (m_kb_regs[reg] >> 16) & 0xffff;
m_sharedprotram[0x29e/2] = m_kb_regs[reg] & 0xffff;
@ -261,10 +251,10 @@ void igs022_device::IGS022_handle_command()
if (cmd == 0x4f) // memcpy with encryption / scrambling
{
uint16_t src = m_sharedprotram[0x290 / 2] >> 1; // External mcu data is 8 bit and addressed as such
uint32_t dst = m_sharedprotram[0x292 / 2];
uint16_t size = m_sharedprotram[0x294 / 2];
uint16_t mode = m_sharedprotram[0x296 / 2];
const u16 src = m_sharedprotram[0x290 / 2] >> 1; // External mcu data is 8 bit and addressed as such
const u32 dst = m_sharedprotram[0x292 / 2];
const u16 size = m_sharedprotram[0x294 / 2];
const u16 mode = m_sharedprotram[0x296 / 2];
IGS022_do_dma(src,dst,size,mode);

View File

@ -10,20 +10,22 @@
class igs022_device : public device_t
{
public:
igs022_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
igs022_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
uint16_t* m_sharedprotram;
void IGS022_handle_command();
protected:
virtual void device_start() override;
virtual void device_reset() override;
uint32_t m_kb_regs[0x100];
u32 m_kb_regs[0x100];
void IGS022_do_dma(uint16_t src, uint16_t dst, uint16_t size, uint16_t mode);
void IGS022_do_dma(u16 src, u16 dst, u16 size, u16 mode);
void IGS022_reset();
private:
optional_shared_ptr<u16> m_sharedprotram;
required_memory_region m_rom;
};

View File

@ -348,7 +348,6 @@ void pgm_022_025_state::init_killbld()
// install and configure protection device(s)
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xd40000, 0xd40003, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025));
m_igs022->m_sharedprotram = m_sharedprotram;
m_igs025->m_kb_source_data = killbld_source_data;
}
@ -359,7 +358,6 @@ void pgm_022_025_state::init_drgw3()
// install and configure protection device(s)
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xda5610, 0xda5613, read16_delegate(FUNC(igs025_device::killbld_igs025_prot_r), (igs025_device*)m_igs025), write16_delegate(FUNC(igs025_device::killbld_igs025_prot_w), (igs025_device*)m_igs025));
m_igs022->m_sharedprotram = m_sharedprotram;
m_igs025->m_kb_source_data = dw3_source_data;
}
@ -368,7 +366,7 @@ void pgm_022_025_state::killbld_mem(address_map &map)
{
pgm_mem(map);
map(0x100000, 0x2fffff).bankr("bank1"); /* Game ROM */
map(0x300000, 0x303fff).ram().share("sharedprotram"); // Shared with protection device
map(0x300000, 0x303fff).ram().share("igs022:sharedprotram"); // Shared with protection device
}

View File

@ -6,7 +6,6 @@ class pgm_022_025_state : public pgm_state
public:
pgm_022_025_state(const machine_config &mconfig, device_type type, const char *tag)
: pgm_state(mconfig, type, tag),
m_sharedprotram(*this, "sharedprotram"),
m_igs025(*this,"igs025"),
m_igs022(*this,"igs022")
@ -15,8 +14,6 @@ public:
void pgm_dw3_decrypt();
void pgm_killbld_decrypt();
required_shared_ptr<u16> m_sharedprotram;
void init_killbld();
void init_drgw3();
DECLARE_MACHINE_RESET(killbld);