summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author David Haywood <mamehaze@users.noreply.github.com>2013-05-20 00:09:58 +0000
committer David Haywood <mamehaze@users.noreply.github.com>2013-05-20 00:09:58 +0000
commita4030229e25c5d71eab7755019a7cfc3ff26001e (patch)
treec1d424210365792ae84426601360fbd0db359658
parent9030e832e2ec12a5a7f299dbbdec4e5a1ac712af (diff)
PGM improvements [iq132]
- Implemented the bitswap protection for Killing Blade allowing all regions to work. - Implemented additional protection required by Dragon World 3, the game is not any Further along, but it is much cleaner code. - Implemented bitswap protection and several DMA modes for olds. The ram_dump hack is no longer required. The protection simulation is still somewhat incomplete.
-rw-r--r--src/mame/includes/pgm.h38
-rw-r--r--src/mame/machine/pgmprot4.c673
-rw-r--r--src/mame/machine/pgmprot6.c474
3 files changed, 815 insertions, 370 deletions
diff --git a/src/mame/includes/pgm.h b/src/mame/includes/pgm.h
index f1d74db156d..6e10c8d82cb 100644
--- a/src/mame/includes/pgm.h
+++ b/src/mame/includes/pgm.h
@@ -365,14 +365,24 @@ public:
: pgm_state(mconfig, type, tag),
m_sharedprotram(*this, "sharedprotram") {
}
+
+ const UINT8 (*m_kb_source_data)[0xec];
+ INT32 m_kb_source_data_offset;
+
+ DECLARE_WRITE16_MEMBER( killbld_mainram_w ); // debug
+
+ UINT32 m_kb_game_id;
+
+ UINT16 m_kb_prot_hold;
+ UINT16 m_kb_prot_hilo;
+ UINT16 m_kb_prot_hilo_select;
+
int m_kb_cmd;
int m_kb_reg;
int m_kb_ptr;
- int m_kb_region_sequence_position;
+ UINT8 m_kb_swap;
UINT32 m_kb_regs[0x10];
- int reg;
- int ptr;
- UINT8 dw3_swap;
+
required_shared_ptr<UINT16> m_sharedprotram;
DECLARE_DRIVER_INIT(killbld);
@@ -381,13 +391,14 @@ public:
DECLARE_MACHINE_RESET(dw3);
void pgm_dw3_decrypt();
void pgm_killbld_decrypt();
+ void killbld_protection_calculate_hilo();
+ void killbld_protection_calculate_hold(int y, int z);
void IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode);
void IGS022_reset();
void IGS022_handle_command();
+
DECLARE_WRITE16_MEMBER( killbld_igs025_prot_w );
DECLARE_READ16_MEMBER( killbld_igs025_prot_r );
- DECLARE_WRITE16_MEMBER( drgw3_igs025_prot_w );
- DECLARE_READ16_MEMBER( drgw3_igs025_prot_r );
};
/* for machine/pgmprot6.c type games */
@@ -398,12 +409,16 @@ public:
: pgm_state(mconfig, type, tag),
m_sharedprotram(*this, "sharedprotram") {
}
- // olds
- int m_kb_cmd;
- int m_kb_reg;
- int m_kb_ptr;
+
+ 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;
+ const UINT8 *m_olds_prot_hilo_source2;
required_shared_ptr<UINT16> m_sharedprotram;
DECLARE_DRIVER_INIT(olds);
@@ -415,6 +430,9 @@ public:
DECLARE_READ16_MEMBER( olds_r );
DECLARE_WRITE16_MEMBER( olds_w );
DECLARE_READ16_MEMBER( olds_prot_swap_r );
+ void IGS028_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode);
+ void olds_protection_calculate_hilo();
+ void olds_protection_calculate_hold(int y, int z);
};
diff --git a/src/mame/machine/pgmprot4.c b/src/mame/machine/pgmprot4.c
index 14e23d0e527..fef29a20347 100644
--- a/src/mame/machine/pgmprot4.c
+++ b/src/mame/machine/pgmprot4.c
@@ -32,12 +32,8 @@
*/
-
void pgm_022_025_state::pgm_dw3_decrypt()
{
-// int i;
-// UINT16 *src=(UINT16 *) (OP_ROM+0x100000);
-
int i;
UINT16 *src = (UINT16 *) (memregion("maincpu")->base()+0x100000);
@@ -46,19 +42,11 @@ void pgm_022_025_state::pgm_dw3_decrypt()
for(i=0; i<rom_size/2; i++) {
UINT16 x = src[i];
- if((i & 0x005460) == 0x001400)
- x ^= 0x0100;
-
- if((i & 0x005450) == 0x001040)
+ if((i & 0x005460) == 0x001400 || (i & 0x005450) == 0x001040)
x ^= 0x0100;
- if((i & 0x005e00) == 0x001c00)
- x ^= 0x40;
-
- if((i & 0x005580) == 0x001100)
- x ^= 0x40;
-
-
+ if((i & 0x005e00) == 0x001c00 || (i & 0x005580) == 0x001100)
+ x ^= 0x0040;
src[i] = x;
}
@@ -66,9 +54,6 @@ void pgm_022_025_state::pgm_dw3_decrypt()
void pgm_022_025_state::pgm_killbld_decrypt()
{
-// int i;
-// UINT16 *src=(UINT16 *) (OP_ROM+0x100000);
-
int i;
UINT16 *src = (UINT16 *) (memregion("maincpu")->base()+0x100000);
@@ -77,16 +62,252 @@ void pgm_022_025_state::pgm_killbld_decrypt()
for(i=0; i<rom_size/2; i++) {
UINT16 x = src[i];
- if((i & 0x6d00) == 0x0400 || (i & 0x6c80) == 0x0880)
+ if((i & 0x006d00) == 0x000400 || (i & 0x006c80) == 0x000880)
x ^= 0x0008;
- if((i & 0x7500) == 0x2400 || (i & 0x7600) == 0x3200)
+
+ if((i & 0x007500) == 0x002400 || (i & 0x007600) == 0x003200)
x ^= 0x1000;
src[i] = x;
}
}
+// these were all xored by a table at $178B2A
+static const UINT8 killbld_source_data[0x0c][0xec] = // offsets to these tables stored at $155ed0
+{
+ { // region 16, $178772
+ 0x5e, 0x09, 0xb3, 0x39, 0x60, 0x71, 0x71, 0x53, 0x11, 0xe5, 0x26, 0x34, 0x4c, 0x8c, 0x90, 0xee,
+ 0xed, 0xb5, 0x05, 0x95, 0x9e, 0x6b, 0xdd, 0x87, 0x0e, 0x7b, 0xed, 0x33, 0xaf, 0xc2, 0x62, 0x98,
+ 0xec, 0xc8, 0x2c, 0x2b, 0x57, 0x3d, 0x00, 0xbd, 0x12, 0xac, 0xba, 0x64, 0x81, 0x99, 0x16, 0x29,
+ 0xb4, 0x63, 0xa8, 0xd9, 0xc9, 0x5f, 0xfe, 0x21, 0xbb, 0xbf, 0x9b, 0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x4e, 0x16, 0x83
+ },
+ { 0, }, // unused region 1a
+ { 0, }, // unused region 1b
+ { 0, }, // unused region 1c
+ { 0, }, // unused region 1d
+ { 0, }, // unused region 1e
+ { 0, }, // unused region 1f
+ { // region 20, $17a322
+ 0xb3, 0x10, 0xf3, 0x0b, 0xe0, 0x71, 0x60, 0x53, 0x11, 0x9a, 0x12, 0x70, 0x1f, 0x1e, 0x81, 0xda,
+ 0x9d, 0x1f, 0x4b, 0xd6, 0x71, 0x48, 0x83, 0xe1, 0x04, 0x6c, 0x1b, 0xf1, 0xcd, 0x09, 0xdf, 0x3e,
+ 0x0b, 0xaa, 0x95, 0xc1, 0x07, 0xec, 0x0f, 0x54, 0xd0, 0x16, 0xb0, 0xdc, 0x86, 0x7b, 0x52, 0x38,
+ 0x3c, 0x68, 0x2b, 0xed, 0xe2, 0xeb, 0xb3, 0xc6, 0x48, 0x24, 0x41, 0x36, 0x17, 0x25, 0x1f, 0xa5,
+ 0x22, 0xc6, 0x5c, 0xa6, 0x19, 0xef, 0x17, 0x5c, 0x56, 0x4b, 0x4a, 0x2b, 0x75, 0xab, 0xe6, 0x22,
+ 0xd5, 0xc0, 0xd3, 0x46, 0xcc, 0xe4, 0xd4, 0xc4, 0x8c, 0x9a, 0x8a, 0x75, 0x24, 0x73, 0xa4, 0x26,
+ 0xca, 0x79, 0xaf, 0xb3, 0x94, 0x2a, 0x15, 0xbe, 0x40, 0x7b, 0x4d, 0xf6, 0xb4, 0xa4, 0x7b, 0xcf,
+ 0xce, 0xa0, 0x1d, 0xcb, 0x2f, 0x60, 0x28, 0x63, 0x85, 0x98, 0xd3, 0xd2, 0x45, 0x3f, 0x02, 0x65,
+ 0xd7, 0xf4, 0xbc, 0x2a, 0xe7, 0x50, 0xd1, 0x3f, 0x7f, 0xf6, 0x05, 0xb8, 0xe9, 0x39, 0x10, 0x6e,
+ 0x68, 0xa8, 0x89, 0x60, 0x00, 0x68, 0xfd, 0x20, 0xc4, 0xdc, 0xef, 0x67, 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ef,
+ 0x08, 0x84, 0x97, 0x23, 0xd1, 0x17, 0x2f, 0x38, 0xb4, 0x6d, 0x8f, 0x2a, 0x15, 0xf0, 0x40, 0xe9,
+ 0x02, 0x33, 0xd7, 0x5e, 0x99, 0x57, 0x15, 0x32, 0xbd, 0x8f, 0x48, 0x38, 0x91, 0x36, 0xe9, 0x07,
+ 0xc9, 0x37, 0x1d, 0x12, 0x2a, 0xbf, 0x5f, 0xdb, 0x85, 0x75, 0xbf, 0xdc, 0x59, 0x8a, 0x43, 0x51,
+ 0x4b, 0x77, 0xfd, 0x84, 0xc4, 0x28, 0xc7, 0x85, 0x25, 0x1a, 0x87, 0x8b, 0xc1, 0xd9, 0x1a, 0x78,
+ 0xe5, 0x03, 0x20, 0x56, 0xa0, 0xc2, 0x17, 0xf2, 0x29, 0xa0, 0xbd, 0xf8, 0x61, 0x9c, 0x7d, 0x54,
+ 0x3a, 0x11, 0xb5, 0x69, 0x9a, 0x1c, 0xbb, 0xf6, 0x2d, 0x86, 0xa8, 0x4d, 0xdd, 0x5a, 0xd6, 0xe4,
+ 0x11, 0x7e, 0x4b, 0x13, 0x6c, 0xb6, 0x01, 0x0a, 0x72, 0xbc, 0xe8, 0xf1, 0x82, 0x0e, 0xd0, 0xcf,
+ 0xbf, 0x50, 0x95, 0xb7, 0xa7, 0xec, 0xd7, 0xb3, 0x49, 0x5c, 0x47, 0x5f, 0xa9, 0xda, 0x70, 0xb0,
+ 0xdc, 0x9a, 0xa3, 0x48, 0xd3, 0xf5, 0x72, 0xd5, 0x43, 0xd8, 0x19, 0xcc
+ }
+};
+// all tables xored with data from $149c4c
+static const UINT8 dw3_source_data[0x07][0xec] =
+{
+ { // region 1, $14c21a
+ 0x67, 0x51, 0xf3, 0x19, 0xa0, 0x09, 0xb1, 0x21, 0xb0, 0xee, 0xe3, 0xf6, 0xbe, 0x81, 0x35, 0xe3,
+ 0xfb, 0xe6, 0xef, 0xdf, 0x61, 0x01, 0xfa, 0x22, 0x5d, 0x43,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0xc4, 0x32, 0x7c, 0x35, 0x02, 0x06,
+ 0x46, 0x77, 0x30, 0xb6, 0x33, 0x4b, 0xb8, 0xfd, 0x02, 0xd8, 0x14, 0x40, 0x99, 0x25, 0x7e, 0x55,
+ 0xd6, 0x44, 0x43, 0x8d, 0x73, 0x0e, 0x71, 0x48, 0xd3, 0x82, 0x40, 0xda
+ }
+};
void pgm_022_025_state::IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode)
{
@@ -105,12 +326,9 @@ void pgm_022_025_state::IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT1
//mame_printf_debug("src %04x dst %04x size %04x mode %04x\n", src, dst, size, mode);
- //if (src&1) mame_printf_debug("odd offset\n");
-
param = mode >> 8;
mode &=0xf; // what are the other bits?
-
if ((mode == 0) || (mode == 1) || (mode == 2) || (mode == 3))
{
/* mode3 applies a xor from a 0x100 byte table to the data being
@@ -120,59 +338,20 @@ void pgm_022_025_state::IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT1
the param used with the mode gives a start offset into the table
- odd offsets seem to change the table slightly (see rawDataOdd)
-
+ odd offsets cause an overflow
*/
- /*
- unsigned char rawDataOdd[256] = {
- 0xB6, 0xA8, 0xB1, 0x5D, 0x2C, 0x5D, 0x4F, 0xC1,
- 0xCF, 0x39, 0x3A, 0xB7, 0x65, 0x85, 0xD9, 0xEE,
- 0xDB, 0x7B, 0x5F, 0x81, 0x03, 0x6D, 0xEB, 0x07,
- 0x0F, 0xB5, 0x61, 0x59, 0xCD, 0x60, 0x06, 0x21,
- 0xA0, 0x99, 0xDD, 0x27, 0x42, 0xD7, 0xC5, 0x5B,
- 0x3B, 0xC6, 0x4F, 0xA2, 0x20, 0xF6, 0x61, 0x61,
- 0x8C, 0x46, 0x8C, 0xCA, 0xE0, 0x0E, 0x2C, 0xE9,
- 0xBA, 0x0F, 0x45, 0x6D, 0x36, 0x1C, 0x18, 0x37,
- 0xE7, 0x85, 0x89, 0xA4, 0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, 0x2B, 0x85, 0x2D, 0xE5,
- 0x13, 0x22, 0x48, 0xB6, 0xF3, 0x2D, 0x00, 0x9A
- };
- */
int x;
UINT16 *PROTROM = (UINT16*)memregion("igs022data")->base();
for (x = 0; x < size; x++)
{
- //UINT16 *RAMDUMP = (UINT16*)memregion("user2")->base();
- //UINT16 dat = RAMDUMP[dst + x];
-
UINT16 dat2 = PROTROM[src + x];
- UINT8 extraoffset = param&0xfe; // the lowest bit changed the table addressing in tests, see 'rawDataOdd' table instead.. it's still related to the main one, not identical
- UINT8* dectable = (UINT8*)memregion("igs022data")->base();//rawDataEven; // the basic decryption table is at the start of the mcu data rom! at least in killbld
- UINT16 extraxor = ((dectable[((x*2)+0+extraoffset)&0xff]) << 8) | (dectable[((x*2)+1+extraoffset)&0xff] << 0);
+ UINT8 extraoffset = param&0xff;
+ UINT8* dectable = (UINT8*)memregion("igs022data")->base(); // the basic decryption table is at the start of the mcu data rom! at least in killbld
+ UINT8 taboff = ((x*2)+extraoffset) & 0xff; // must allow for overflow in instances of odd offsets
+ UINT16 extraxor = ((dectable[taboff+0]) << 8) | (dectable[taboff+1] << 0);
dat2 = ((dat2 & 0x00ff)<<8) | ((dat2 & 0xff00)>>8);
@@ -207,7 +386,6 @@ void pgm_022_025_state::IGS022_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT1
{
UINT16 dat = PROTROM[src + x];
-
m_sharedprotram[dst + x] = dat;
}
}
@@ -268,7 +446,7 @@ void pgm_022_025_state::IGS022_reset()
src >>= 1;
- printf("Auto-DMA %04x %04x %04x %04x\n",src,dst,size,mode);
+// printf("Auto-DMA %04x %04x %04x %04x\n",src,dst,size,mode);
IGS022_do_dma(src,dst,size,mode);
@@ -282,38 +460,48 @@ void pgm_022_025_state::IGS022_reset()
void pgm_022_025_state::IGS022_handle_command()
{
UINT16 cmd = m_sharedprotram[0x200/2];
+
//mame_printf_debug("command %04x\n", cmd);
- if (cmd == 0x6d) //Store values to asic ram
+
+ if (cmd == 0x6d) // Store values to asic ram
{
UINT32 p1 = (m_sharedprotram[0x298/2] << 16) | m_sharedprotram[0x29a/2];
UINT32 p2 = (m_sharedprotram[0x29c/2] << 16) | m_sharedprotram[0x29e/2];
- if ((p2 & 0xffff) == 0x9) //Set value
+ if ((p2 & 0xffff) == 0x9) // Set value
{
int reg = (p2 >> 16) & 0xffff;
+
if (reg & 0x200)
m_kb_regs[reg & 0xff] = p1;
}
- if ((p2 & 0xffff) == 0x6) //Add value
+
+ if ((p2 & 0xffff) == 0x6) // Add value
{
int src1 = (p1 >> 16) & 0xff;
int src2 = (p1 >> 0) & 0xff;
int dst = (p2 >> 16) & 0xff;
+
m_kb_regs[dst] = m_kb_regs[src2] - m_kb_regs[src1];
}
- if ((p2 & 0xffff) == 0x1) //Add Imm?
+
+ if ((p2 & 0xffff) == 0x1) // Add Imm?
{
int reg = (p2 >> 16) & 0xff;
int imm = (p1 >> 0) & 0xffff;
+
m_kb_regs[reg] += imm;
}
- if ((p2 & 0xffff) == 0xa) //Get value
+
+ if ((p2 & 0xffff) == 0xa) // Get value
{
int reg = (p1 >> 16) & 0xFF;
+
m_sharedprotram[0x29c/2] = (m_kb_regs[reg] >> 16) & 0xffff;
m_sharedprotram[0x29e/2] = m_kb_regs[reg] & 0xffff;
}
}
+
if(cmd == 0x4f) //memcpy with encryption / scrambling
{
UINT16 src = m_sharedprotram[0x290 / 2] >> 1; // ?
@@ -323,80 +511,149 @@ void pgm_022_025_state::IGS022_handle_command()
IGS022_do_dma(src,dst,size,mode);
}
+}
+
+void pgm_022_025_state::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 pgm_022_025_state::killbld_protection_calculate_hilo()
+{
+ UINT8 source;
+
+ m_kb_prot_hilo_select++;
+
+ if (m_kb_prot_hilo_select > 0xeb) {
+ m_kb_prot_hilo_select = 0;
+ }
+
+ source = m_kb_source_data[(ioport("Region")->read() - m_kb_source_data_offset)][m_kb_prot_hilo_select];
+
+ if (m_kb_prot_hilo_select & 1)
+ {
+ m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8);
+ }
+ else
+ {
+ m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0);
+ }
+}
WRITE16_MEMBER(pgm_022_025_state::killbld_igs025_prot_w )
{
-// mame_printf_debug("killbrd prot r\n");
-// return 0;
offset &= 0xf;
if (offset == 0)
+ {
m_kb_cmd = data;
- else //offset==2
+ }
+ else
{
- logerror("%06X: ASIC25 W CMD %X VAL %X\n", space.device().safe_pc(), m_kb_cmd, data);
- if (m_kb_cmd == 0)
- m_kb_reg = data;
- else if (m_kb_cmd == 2)
+ switch (m_kb_cmd)
{
- if (data == 1) //Execute cmd
+ case 0x00:
+ m_kb_reg = data;
+ break;
+
+ //case 0x01: // ??
+ //break;
+
+ case 0x02:
{
- IGS022_handle_command();
- m_kb_reg++;
+ if (data == 0x0001) { // Execute cmd
+ IGS022_handle_command();
+ m_kb_reg++;
+ }
}
+ break;
+
+ case 0x03:
+ m_kb_swap = data;
+ break;
+
+ case 0x04:
+ m_kb_ptr = data;
+ break;
+
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ m_kb_ptr++;
+ killbld_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff);
+ break;
+
+ // default:
+ // logerror("%06X: ASIC25 W CMD %X VAL %X\n", space.device().safe_pc(), m_kb_cmd, data);
}
- else if (m_kb_cmd == 4)
- m_kb_ptr = data;
- else if (m_kb_cmd == 0x20)
- m_kb_ptr++;
}
}
READ16_MEMBER(pgm_022_025_state::killbld_igs025_prot_r )
{
-// mame_printf_debug("killbld prot w\n");
- UINT16 res ;
-
- offset &= 0xf;
- res = 0;
-
- if (offset == 1)
+ if (offset)
{
- if (m_kb_cmd == 1)
- {
- res = m_kb_reg & 0x7f;
- }
- else if (m_kb_cmd == 5)
+ switch (m_kb_cmd)
{
- UINT8 kb_region_sequence[11] = {0x17, 0x14, 0x91, 0x89, 0x21, 0xD5, 0x7C, 0x65, 0x8F, 0x8E, 0xE1};
- UINT8 ret;
+ case 0x00:
+ return BITSWAP8((m_kb_swap+1)&0xff, 0,1,2,3,4,5,6,7); // dw3
- // this isn't properly understood.. should be some kind of bitswap / xor / shift..based on values written to 0x22/0x23 etc.?
- // return hardcoded china sequence results for now, avoids rom patch
- if (m_kb_region_sequence_position < 11)
- {
- ret = kb_region_sequence[m_kb_region_sequence_position];
- m_kb_region_sequence_position++;
- }
- else
+ case 0x01:
+ return m_kb_reg & 0x7f;
+
+ case 0x05:
{
- UINT32 protvalue = 0x89911400 | ioport("Region")->read();
- ret = (protvalue >> (8 * (m_kb_ptr - 1))) & 0xff;
+
+ logerror ("ptr: %d\n", m_kb_ptr);
+
+ switch (m_kb_ptr)
+ {
+ case 1:
+ return 0x3f00 | ioport("Region")->read();
+
+ case 2:
+ return 0x3f00 | ((m_kb_game_id >> 8) & 0xff);
+
+ case 3:
+ return 0x3f00 | ((m_kb_game_id >> 16) & 0xff);
+
+ case 4:
+ return 0x3f00 | ((m_kb_game_id >> 24) & 0xff);
+
+ case 5:
+ default: // >= 5
+ return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15);
+ }
+
+ return 0;
}
- res = 0x3f00 | ret; // always 0x3fxx in logged behavior...
+ case 0x40:
+ killbld_protection_calculate_hilo();
+ return 0; // is this used?
+ //default:
+ // logerror("%06X: ASIC25 R CMD %X\n", space.device().safe_pc(), m_kb_cmd);
}
}
- logerror("%06X: ASIC25 R CMD %X VAL %X\n", space.device().safe_pc(), m_kb_cmd, res);
- return res;
-}
-
-
+ return 0;
+}
MACHINE_RESET_MEMBER(pgm_022_025_state,killbld)
{
@@ -405,17 +662,17 @@ MACHINE_RESET_MEMBER(pgm_022_025_state,killbld)
IGS022_reset();
// Reset IGS025 stuff
+ m_kb_prot_hold = 0;
+ m_kb_prot_hilo = 0;
+ m_kb_prot_hilo_select = 0;
m_kb_cmd = 0;
m_kb_reg = 0;
m_kb_ptr = 0;
- m_kb_region_sequence_position = 0;
- memset(m_kb_regs, 0, 0x10 * sizeof(UINT32));
+ m_kb_swap = 0;
+ memset(m_kb_regs, 0, 0x10 * sizeof(UINT32));
}
-
-
-
DRIVER_INIT_MEMBER(pgm_022_025_state,killbld)
{
pgm_basic_init();
@@ -423,13 +680,22 @@ DRIVER_INIT_MEMBER(pgm_022_025_state,killbld)
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xd40000, 0xd40003, read16_delegate(FUNC(pgm_022_025_state::killbld_igs025_prot_r),this), write16_delegate(FUNC(pgm_022_025_state::killbld_igs025_prot_w),this));
+ m_kb_source_data = killbld_source_data;
+ m_kb_source_data_offset = 0x16;
+ m_kb_game_id = 0x89911400;
+
+ m_kb_prot_hold = 0;
+ m_kb_prot_hilo = 0;
+ m_kb_prot_hilo_select = 0;
m_kb_cmd = 0;
m_kb_reg = 0;
m_kb_ptr = 0;
- m_kb_region_sequence_position = 0;
+ m_kb_swap = 0;
memset(m_kb_regs, 0, 0x10 * sizeof(UINT32));
- save_item(NAME(m_kb_region_sequence_position));
+ save_item(NAME(m_kb_prot_hold));
+ save_item(NAME(m_kb_prot_hilo));
+ save_item(NAME(m_kb_prot_hilo_select));
save_item(NAME(m_kb_cmd));
save_item(NAME(m_kb_reg));
save_item(NAME(m_kb_ptr));
@@ -446,136 +712,69 @@ MACHINE_RESET_MEMBER(pgm_022_025_state,dw3)
- these should almost certainly end up there as the result of executing the protection
commands are startup, but which, and how? */
-// m_sharedprotram[0x200/2] = 0x006d;
+ m_sharedprotram[0x200/2] = 0x006d;
m_sharedprotram[0x202/2] = 0x007c; // it cares about this, operation status flag?
-// m_sharedprotram[0x20c/2] = 0x0000;
-// m_sharedprotram[0x20e/2] = 0x0007;
-// m_sharedprotram[0x210/2] = 0x0000;
-// m_sharedprotram[0x212/2] = 0x0004;
-// m_sharedprotram[0x214/2] = 0x0000;
-// m_sharedprotram[0x216/2] = 0x0007;
-// m_sharedprotram[0x218/2] = 0x0000;
-// m_sharedprotram[0x21a/2] = 0x0004;
+ m_sharedprotram[0x20c/2] = 0x0000;
+ m_sharedprotram[0x20e/2] = 0x0007;
+ m_sharedprotram[0x210/2] = 0x0000;
+ m_sharedprotram[0x212/2] = 0x0004;
+ m_sharedprotram[0x214/2] = 0x0000;
+ m_sharedprotram[0x216/2] = 0x0007;
+ m_sharedprotram[0x218/2] = 0x0000;
+ m_sharedprotram[0x21a/2] = 0x0004;
-// m_sharedprotram[0x288/2] = 0x0000;
-// m_sharedprotram[0x28a/2] = 0x00c2;
-// m_sharedprotram[0x28c/2] = 0x0000;
-// m_sharedprotram[0x28e/2] = 0x00c2;
-// m_sharedprotram[0x290/2] = 0x0500;
-// m_sharedprotram[0x292/2] = 0x1000;
-// m_sharedprotram[0x294/2] = 0x00c3;
-// m_sharedprotram[0x296/2] = 0x7104;
-// m_sharedprotram[0x298/2] = 0x0000;
-// m_sharedprotram[0x29a/2] = 0x0003;
-// m_sharedprotram[0x29c/2] = 0x0108;
-// m_sharedprotram[0x29e/2] = 0x0009;
+ m_sharedprotram[0x288/2] = 0x0000;
+ m_sharedprotram[0x28a/2] = 0x00c2;
+ m_sharedprotram[0x28c/2] = 0x0000;
+ m_sharedprotram[0x28e/2] = 0x00c2;
+ m_sharedprotram[0x290/2] = 0x0500;
+ m_sharedprotram[0x292/2] = 0x1000;
+ m_sharedprotram[0x294/2] = 0x00c3;
+ m_sharedprotram[0x296/2] = 0x7104;
+ m_sharedprotram[0x298/2] = 0x0000;
+ m_sharedprotram[0x29a/2] = 0x0003;
+ m_sharedprotram[0x29c/2] = 0x0108;
+ m_sharedprotram[0x29e/2] = 0x0009;
-// m_sharedprotram[0x2a2/2] = 0x84f6; // it cares about this, it's the version number of the data rom, copied automatically!
+ m_sharedprotram[0x2a2/2] = 0x84f6; // it cares about this, it's the version number of the data rom, copied automatically!
-// m_sharedprotram[0x2ac/2] = 0x006d;
-// m_sharedprotram[0x2ae/2] = 0x0000;
+ m_sharedprotram[0x2ac/2] = 0x006d;
+ m_sharedprotram[0x2ae/2] = 0x0000;
-// m_sharedprotram[0x2b0/2] = 0xaf56;
+ m_sharedprotram[0x2b0/2] = 0xaf56;
// Reset IGS025 stuff
+ m_kb_prot_hold = 0;
+ m_kb_prot_hilo = 0;
+ m_kb_prot_hilo_select = 0;
m_kb_cmd = 0;
m_kb_reg = 0;
m_kb_ptr = 0;
- m_kb_region_sequence_position = 0;
+ m_kb_swap = 0;
memset(m_kb_regs, 0, 0x10 * sizeof(UINT32));
}
-
-
-#define DW3BITSWAP(s,d,bs,bd) d=((d&(~(1<<bd)))|(((s>>bs)&1)<<bd))
-
-WRITE16_MEMBER(pgm_022_025_state::drgw3_igs025_prot_w )
-{
- offset&=0xf;
-
- if(offset==0)
- m_kb_cmd=data;
- else //offset==2
- {
- printf("%06X: ASIC25 W CMD %X VAL %X\n",space.device().safe_pc(),m_kb_cmd,data);
- if(m_kb_cmd==0)
- reg=data;
- else if(m_kb_cmd==3) //??????????
- {
- dw3_swap = data;
-
- printf("SWAP %02x\n",dw3_swap);
- }
- //else if(kb_cmd==4)
- // ptr=data;
- else if(m_kb_cmd==0x20)
- ptr++;
- }
-}
-
-READ16_MEMBER(pgm_022_025_state::drgw3_igs025_prot_r )
+DRIVER_INIT_MEMBER(pgm_022_025_state,drgw3)
{
-// mame_printf_debug("killbld prot w\n");
- UINT16 res ;
-
- offset&=0xf;
- res=0;
-
- if(offset==1)
- {
- if(m_kb_cmd==0) //swap
- {
- UINT8 v1=(dw3_swap+1)&0x7F;
- UINT8 v2=0;
- DW3BITSWAP(v1,v2,7,0);
- DW3BITSWAP(v1,v2,6,1);
- DW3BITSWAP(v1,v2,5,2);
- DW3BITSWAP(v1,v2,4,3);
- DW3BITSWAP(v1,v2,3,4);
- DW3BITSWAP(v1,v2,2,5);
- DW3BITSWAP(v1,v2,1,6);
- DW3BITSWAP(v1,v2,0,7);
-
- res=v2;
-
- }
- else if(m_kb_cmd==1)
- {
- res=reg&0x7f;
- }
- else if(m_kb_cmd==5)
- {
- UINT32 protvalue;
- protvalue = 0x60000|ioport("Region")->read();
- res=(protvalue>>(8*(ptr-1)))&0xff;
+ pgm_basic_init();
+ m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xDA5610, 0xDA5613, read16_delegate(FUNC(pgm_022_025_state::killbld_igs025_prot_r),this), write16_delegate(FUNC(pgm_022_025_state::killbld_igs025_prot_w),this));
- }
- }
- logerror("%06X: ASIC25 R CMD %X VAL %X\n",space.device().safe_pc(),m_kb_cmd,res);
- return res;
-}
+ m_kb_source_data = dw3_source_data;
+ m_kb_source_data_offset = 1;
+ m_kb_game_id = 0x00060000;
-
-DRIVER_INIT_MEMBER(pgm_022_025_state,drgw3)
-{
- pgm_basic_init();
- ptr = 0;
-/*
- {
- int x;
- UINT16 *RAMDUMP = (UINT16*)memregion("user2")->base();
- for (x=0;x<(0x4000/2);x++)
- {
- m_sharedprotram[x] = RAMDUMP[x];
- if((x>=0x100)&&(x<0x110)) printf("data 0x%4x, offset:%x\n",m_sharedprotram[x],x);
- }
- }
-*/
- m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xDA5610, 0xDA5613, read16_delegate(FUNC(pgm_022_025_state::drgw3_igs025_prot_r),this), write16_delegate(FUNC(pgm_022_025_state::drgw3_igs025_prot_w),this));
+ m_kb_prot_hold = 0;
+ m_kb_prot_hilo = 0;
+ m_kb_prot_hilo_select = 0;
+ m_kb_cmd = 0;
+ m_kb_reg = 0;
+ m_kb_ptr = 0;
+ m_kb_swap = 0;
+ memset(m_kb_regs, 0, 0x10 * sizeof(UINT32));
pgm_dw3_decrypt();
}
@@ -613,7 +812,7 @@ INPUT_PORTS_START( killbld )
PORT_INCLUDE ( pgm )
PORT_MODIFY("Region") /* Region - supplied by protection device */
- PORT_DIPNAME( 0x00ff, 0x0021, "Region (not currently working)" ) // different regions supply different protection code sequences, we only have the China one ATM
+ PORT_DIPNAME( 0x00ff, 0x0021, "Region" )
PORT_DIPSETTING( 0x0016, DEF_STR( Taiwan ) )
PORT_DIPSETTING( 0x0017, DEF_STR( China ) )
PORT_DIPSETTING( 0x0018, DEF_STR( Hong_Kong ) )
@@ -633,7 +832,7 @@ INPUT_PORTS_START( dw3 )
PORT_MODIFY("Region") /* Region - supplied by protection device */
PORT_CONFNAME( 0x000f, 0x0006, DEF_STR( Region ) )
- PORT_CONFSETTING( 0x0000, "0" )
+// PORT_CONFSETTING( 0x0000, "0" )
PORT_CONFSETTING( 0x0001, "1" )
PORT_CONFSETTING( 0x0002, "2" )
PORT_CONFSETTING( 0x0003, "3" )
diff --git a/src/mame/machine/pgmprot6.c b/src/mame/machine/pgmprot6.c
index 627999129ec..a45eb4e894b 100644
--- a/src/mame/machine/pgmprot6.c
+++ b/src/mame/machine/pgmprot6.c
@@ -14,177 +14,402 @@
IGS025 is some kind of state machine, bitswaps etc.
Simulation is incomplete
+ - Register simulation incomplete
+ - DMA Mode 0 decryption unknown
***********************************************************************/
#include "emu.h"
#include "includes/pgm.h"
-UINT32 pgm_028_025_state::olds_prot_addr( UINT16 addr )
+// tables are xored by table at $1998dc
+static const UINT8 olds_source_data[7][0xec] = // table addresses $2951CA
{
- UINT32 mode = addr & 0xff;
- UINT32 offset = addr >> 8;
- UINT32 realaddr;
+ { // region 1, $1A669A
+ 0x67, 0x51, 0xf3, 0x19, 0xa0, 0x11, 0xe1, 0x11, 0x10, 0xee, 0xe3, 0xf6, 0xbe, 0x81, 0x35, 0xe3,
+ 0xfb, 0xe6, 0xef, 0xdf, 0x61, 0x01,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b, 0x5e, 0xa8, 0x52, 0xc4, 0x32, 0x7c, 0x35, 0x02, 0x06,
+ 0x46, 0x77, 0x30, 0xb6, 0x33, 0x4b, 0xb8, 0xfd, 0x02, 0xd8, 0x14, 0x40, 0x99, 0x25, 0x7e, 0x55,
+ 0xd6, 0x44, 0x43, 0x8d, 0x73, 0x0e, 0x71, 0x48, 0xd3, 0x82, 0x40, 0xda
+ }
+};
- switch(mode)
+UINT32 pgm_028_025_state::olds_prot_addr(UINT16 addr)
+{
+ switch (addr & 0xff)
{
case 0x0:
case 0x5:
- case 0xa:
- realaddr = 0x402a00 + (offset << 2);
- break;
-
+ case 0xa: return 0x402a00 + ((addr >> 8) << 2);
case 0x2:
- case 0x8:
- realaddr = 0x402e00 + (offset << 2);
- break;
+ case 0x8: return 0x402e00 + ((addr >> 8) << 2);
+ case 0x1: return 0x40307e;
+ case 0x3: return 0x403090;
+ case 0x4: return 0x40309a;
+ case 0x6: return 0x4030a4;
+ case 0x7: return 0x403000;
+ case 0x9: return 0x40306e;
+ }
- case 0x1:
- realaddr = 0x40307e;
- break;
+ return 0;
+}
- case 0x3:
- realaddr = 0x403090;
- break;
+UINT32 pgm_028_025_state::olds_read_reg(UINT16 addr)
+{
+ UINT32 protaddr = (olds_prot_addr(addr) - 0x400000) / 2;
+ return m_sharedprotram[protaddr] << 16 | m_sharedprotram[protaddr + 1];
+}
- case 0x4:
- realaddr = 0x40309a;
- break;
+void pgm_028_025_state::olds_write_reg( UINT16 addr, UINT32 val )
+{
+ m_sharedprotram[((olds_prot_addr(addr) - 0x400000) / 2) + 0] = val >> 16;
+ m_sharedprotram[((olds_prot_addr(addr) - 0x400000) / 2) + 1] = val & 0xffff;
+}
- case 0x6:
- realaddr = 0x4030a4;
- break;
+void pgm_028_025_state::IGS028_do_dma(UINT16 src, UINT16 dst, UINT16 size, UINT16 mode)
+{
+ UINT16 param = mode >> 8;
+ UINT16 *PROTROM = (UINT16*)memregion("user1")->base();
- case 0x7:
- realaddr = 0x403000;
- break;
+// logerror ("mode: %2.2x, src: %4.4x, dst: %4.4x, size: %4.4x, data: %4.4x\n", (mode &0xf), src, dst, size, mode);
- case 0x9:
- realaddr = 0x40306e;
- break;
+ mode &= 0x0f;
+
+ switch (mode)
+ {
+ case 0x00: // This mode copies code later on in the game! Encrypted somehow?
+ // src:2fc8, dst: 045a, size: 025e, mode: 0000
+ // jumps from 12beb4 in unprotected set
+ // jumps from 1313e0 in protected set
+ case 0x01: // swap bytes and nibbles
+ case 0x02: // ^= encryption
+ case 0x05: // copy
+ case 0x06: // += encryption (correct?)
+ {
+ UINT8 extraoffset = param & 0xff;
+ UINT8 *dectable = (UINT8 *)(PROTROM + (0x100 / 2));
+
+ for (INT32 x = 0; x < size; x++)
+ {
+ UINT16 dat2 = PROTROM[src + x];
+
+ int taboff = ((x*2)+extraoffset) & 0xff; // must allow for overflow in instances of odd offsets
+ unsigned short extraxor = ((dectable[taboff + 0]) << 0) | (dectable[taboff + 1] << 8);
+
+ if (mode==0) dat2 = 0x4e75; // hack
+ if (mode==1) dat2 = ((dat2 & 0xf000) >> 12) | ((dat2 & 0x0f00) >> 4) | ((dat2 & 0x00f0) << 4) | ((dat2 & 0x000f) << 12);
+ if (mode==2) dat2 ^= extraxor;
+ if (mode==5) dat2 = dat2;
+ if (mode==6) dat2 += extraxor;
+
+ if (mode==2 || mode==6) dat2 = (dat2<<8)|(dat2>>8);
- default:
- realaddr = 0;
+ m_sharedprotram[dst + x] = (dat2 << 8) | (dat2 >> 8);
+ }
+ }
+ break;
+
+ //default:
+ // logerror ("DMA mode unknown!!!\nsrc:%4.4x, dst: %4.4x, size: %4.4x, mode: %4.4x\n", src, dst, size, mode);
}
- return realaddr;
}
-UINT32 pgm_028_025_state::olds_read_reg(UINT16 addr )
+void pgm_028_025_state::olds_protection_calculate_hold(int y, int z) // calculated in routine $12dbc2 in olds
{
- UINT32 protaddr = (olds_prot_addr(addr) - 0x400000) / 2;
- return m_sharedprotram[protaddr] << 16 | m_sharedprotram[protaddr + 1];
-}
+ unsigned short old = m_olds_prot_hold;
-void pgm_028_025_state::olds_write_reg( UINT16 addr, UINT32 val )
-{
- m_sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2] = val >> 16;
- m_sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2 + 1] = val & 0xffff;
+ 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
}
-MACHINE_RESET_MEMBER(pgm_028_025_state,olds)
+void pgm_028_025_state::olds_protection_calculate_hilo() // calculated in routine $12dbc2 in olds
{
- UINT16 *mem16 = (UINT16 *)memregion("user2")->base();
- int i;
+ UINT8 source;
- MACHINE_RESET_CALL_MEMBER(pgm);
+ m_olds_prot_hilo_select++;
+ if (m_olds_prot_hilo_select > 0xeb) {
+ m_olds_prot_hilo_select = 0;
+ }
+
+ source = olds_source_data[ioport("Region")->read() - 1][m_olds_prot_hilo_select];
- /* populate shared protection ram with data read from pcb .. */
- for (i = 0; i < 0x4000 / 2; i++)
+ if (m_olds_prot_hilo_select & 1) // $8178fa
{
- m_sharedprotram[i] = mem16[i];
+ m_olds_prot_hilo = (m_olds_prot_hilo & 0x00ff) | (source << 8); // $8178d8
}
-
- //ROM:004008B4 .word 0xFBA5
- for(i = 0; i < 0x4000 / 2; i++)
+ else
{
- if (m_sharedprotram[i] == (0xffff - i))
- m_sharedprotram[i] = 0x4e75;
+ m_olds_prot_hilo = (m_olds_prot_hilo & 0xff00) | (source << 0); // $8178d8
}
}
-READ16_MEMBER(pgm_028_025_state::olds_r )
+WRITE16_MEMBER(pgm_028_025_state::olds_w )
{
- UINT16 res = 0;
-
- if (offset == 1)
+ if (offset == 0)
+ {
+ m_olds_cmd = data;
+ }
+ else
{
- if (m_kb_cmd == 1)
- res = m_kb_reg & 0x7f;
- if (m_kb_cmd == 2)
- res = m_olds_bs | 0x80;
- if (m_kb_cmd == 3)
- res = m_olds_cmd3;
- else if (m_kb_cmd == 5)
+ switch (m_olds_cmd)
{
- UINT32 protvalue = 0x900000 | ioport("Region")->read(); // region from protection device.
- res = (protvalue >> (8 * (m_kb_ptr - 1))) & 0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world
+ case 0x00:
+ m_olds_reg = data;
+ break;
+
+ case 0x02:
+ m_olds_bs = ((data & 0x03) << 6) | ((data & 0x04) << 3) | ((data & 0x08) << 1);
+ break;
+
+ case 0x03:
+ {
+ UINT16 cmd = m_sharedprotram[0x3026 / 2];
+
+ // logerror ("command: %x\n", cmd);
+
+ switch (cmd)
+ {
+ case 0x12:
+ {
+ UINT16 mode = m_sharedprotram[0x303e / 2]; // ?
+ UINT16 src = m_sharedprotram[0x306a / 2] >> 1; // ?
+ UINT16 dst = m_sharedprotram[0x3084 / 2] & 0x1fff;
+ UINT16 size = m_sharedprotram[0x30a2 / 2] & 0x1fff;
+
+ IGS028_do_dma(src, dst, size, mode);
+ }
+ break;
+
+ case 0x64: // incomplete...
+ {
+ UINT16 p1 = m_sharedprotram[0x3050 / 2];
+ UINT16 p2 = m_sharedprotram[0x3082 / 2];
+
+ // logerror ("p1: %4.4x, p2: %4.4x\n", p1, p2);
+
+ if (p2 == 0x02)
+ olds_write_reg(p1, olds_read_reg(p1) + 0x10000);
+ }
+ break;
+
+ // default:
+ // logerror ("unemulated command!\n");
+ }
+
+ m_olds_cmd3 = ((data >> 4) + 1) & 0x3;
+ }
+ break;
+ case 0x04:
+ m_olds_ptr = data;
+ break;
+
+ case 0x20:
+ case 0x21:
+ case 0x22:
+ case 0x23:
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ m_olds_ptr++;
+ olds_protection_calculate_hold(m_olds_cmd & 0x0f, data & 0xff);
+ break;
+
+ // default:
+ // logerror ("unemulated write mode!\n");
}
}
- logerror("%06X: ASIC25 R CMD %X VAL %X\n", space.device().safe_pc(), m_kb_cmd, res);
- return res;
}
-WRITE16_MEMBER(pgm_028_025_state::olds_w )
+READ16_MEMBER(pgm_028_025_state::olds_r )
{
- if (offset == 0)
- m_kb_cmd = data;
- else //offset==2
+ if (offset)
{
- logerror("%06X: ASIC25 W CMD %X VAL %X\n",space.device().safe_pc(), m_kb_cmd, data);
- if (m_kb_cmd == 0)
- m_kb_reg = data;
- else if(m_kb_cmd == 2) //a bitswap=
- {
- int reg = 0;
- if (data & 0x01)
- reg |= 0x40;
- if (data & 0x02)
- reg |= 0x80;
- if (data & 0x04)
- reg |= 0x20;
- if (data & 0x08)
- reg |= 0x10;
- m_olds_bs = reg;
- }
- else if (m_kb_cmd == 3)
+ switch (m_olds_cmd)
{
- UINT16 cmd = m_sharedprotram[0x3026 / 2];
- switch (cmd)
+ case 0x01:
+ return m_olds_reg & 0x7f;
+
+ case 0x02:
+ return m_olds_bs | 0x80;
+
+ case 0x03:
+ return m_olds_cmd3;
+
+ case 0x05:
{
- case 0x11:
- case 0x12:
- break;
- case 0x64:
- {
- UINT16 cmd0 = m_sharedprotram[0x3082 / 2];
- UINT16 val0 = m_sharedprotram[0x3050 / 2]; //CMD_FORMAT
- {
- if ((cmd0 & 0xff) == 0x2)
- olds_write_reg(val0, olds_read_reg(val0) + 0x10000);
- }
- break;
- }
+ switch (m_olds_ptr)
+ {
+ case 1: return 0x3f00 | ioport("Region")->read();
+
+ case 2:
+ return 0x3f00 | 0x00;
+
+ case 3:
+ return 0x3f00 | 0x90;
+
+ case 4:
+ return 0x3f00 | 0x00;
- default:
- break;
+ case 5:
+ default: // >= 5
+ return 0x3f00 | BITSWAP8(m_olds_prot_hold, 5,2,9,7,10,13,12,15); // $817906
+ }
}
- m_olds_cmd3 = ((data >> 4) + 1) & 0x3;
+
+ case 0x40:
+ olds_protection_calculate_hilo();
+ return 0; // unused?
}
- else if (m_kb_cmd == 4)
- m_kb_ptr = data;
- else if(m_kb_cmd == 0x20)
- m_kb_ptr++;
}
+
+ return 0;
}
-READ16_MEMBER(pgm_028_025_state::olds_prot_swap_r )
+MACHINE_RESET_MEMBER(pgm_028_025_state,olds)
{
- if (space.device().safe_pc() < 0x100000) //bios
- return m_mainram[0x178f4 / 2];
- else //game
- return m_mainram[0x178d8 / 2];
+ MACHINE_RESET_CALL_MEMBER(pgm);
+// written by protection device
+// there seems to be an auto-dma that writes from $401000-402573?
+ m_sharedprotram[0x1000/2] = 0x4749; // 'IGS.28'
+ m_sharedprotram[0x1002/2] = 0x2E53;
+ m_sharedprotram[0x1004/2] = 0x3832;
+ m_sharedprotram[0x3064/2] = 0xB315; // crc or status check?
+
+// Should these be written by command 64??
+// m_sharedprotram[0x2a00/2] = 0x0000; // ?
+// m_sharedprotram[0x2a02/2] = 0x0000; // ?
+ m_sharedprotram[0x2a04/2] = 0x0002; // ?
+// m_sharedprotram[0x2a06/2] = 0x0000; // ?
+// m_sharedprotram[0x2ac0/2] = 0x0000; // ?
+ m_sharedprotram[0x2ac2/2] = 0x0001; // ?
+// m_sharedprotram[0x2e00/2] = 0x0000; // ?
+// m_sharedprotram[0x2e02/2] = 0x0000; // ?
+// m_sharedprotram[0x2e04/2] = 0x0000; // ?
+ m_sharedprotram[0x2e06/2] = 0x0009; // seconds on char. select timer
+// m_sharedprotram[0x2e08/2] = 0x0000; // ?
+ m_sharedprotram[0x2e0a/2] = 0x0006; // ?
}
DRIVER_INIT_MEMBER(pgm_028_025_state,olds)
@@ -192,17 +417,20 @@ DRIVER_INIT_MEMBER(pgm_028_025_state,olds)
pgm_basic_init();
m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xdcb400, 0xdcb403, read16_delegate(FUNC(pgm_028_025_state::olds_r),this), write16_delegate(FUNC(pgm_028_025_state::olds_w),this));
- m_maincpu->space(AS_PROGRAM).install_read_handler(0x8178f4, 0x8178f5, read16_delegate(FUNC(pgm_028_025_state::olds_prot_swap_r),this));
- m_kb_cmd = 0;
- m_kb_reg = 0;
- m_kb_ptr = 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;
- save_item(NAME(m_kb_cmd));
- save_item(NAME(m_kb_reg));
- save_item(NAME(m_kb_ptr));
+ 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));
}