diff options
| author | 2011-06-14 00:54:19 +0000 | |
|---|---|---|
| committer | 2011-06-14 00:54:19 +0000 | |
| commit | 488e13d2780af621ddd1f597aa8a7f69df0af2a2 (patch) | |
| tree | 71a9a28494b6c7db6bfeb6b4e6d090b289a49638 /src | |
| parent | c422a1a72e9f77121b4a1d932ceaf711c433f17a (diff) | |
Some improvements to the protection address / logging simulation for Decathlete (saturn.c). [David Haywood]
Diffstat (limited to 'src')
| -rw-r--r-- | src/mame/machine/stvprot.c | 107 |
1 files changed, 71 insertions, 36 deletions
diff --git a/src/mame/machine/stvprot.c b/src/mame/machine/stvprot.c index 2e9578152a7..cba36c9037e 100644 --- a/src/mame/machine/stvprot.c +++ b/src/mame/machine/stvprot.c @@ -144,7 +144,7 @@ static WRITE32_HANDLER ( twcup98_prot_w ) logerror("A-Bus control protection write at %06x: [%02x] <- %08x\n",cpu_get_pc(&space->device()),offset,data); if(offset == 3) { - printf("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); + logerror("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); //MAIN : 12120000 DATA : 0ad20069 Tecmo logo if(a_bus[3] == 0x12120000 && a_bus[2] == 0x0ad20069) @@ -211,7 +211,7 @@ static WRITE32_HANDLER ( sss_prot_w ) logerror("A-Bus control protection write at %06x: [%02x] <- %08x\n",cpu_get_pc(&space->device()),offset,data); if(offset == 3) { - //printf("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); + //logerror("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); switch(a_bus[3]) { case 0x2c5b0000: ctrl_index = (0x145ffac/4)-1; break; @@ -281,7 +281,7 @@ static WRITE32_HANDLER ( rsgun_prot_w ) logerror("A-Bus control protection write at %06x: [%02x] <- %08x\n",cpu_get_pc(&space->device()),offset,data); if(offset == 3) { - //printf("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); + //logerror("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); switch(a_bus[3]) { case 0x77770000: ctrl_index = 0; break; @@ -353,7 +353,7 @@ static WRITE32_HANDLER ( elandore_prot_w ) if(offset == 3) { /* a bus value 2 seed is used too here. */ - //printf("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); + //logerror("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); switch(a_bus[3]) { case ELANDORE_CTRL_1_HUMAN: // (human polygons) @@ -458,7 +458,7 @@ static WRITE32_HANDLER ( ffreveng_prot_w ) logerror("A-Bus control protection write at %06x: [%02x] <- %08x\n",cpu_get_pc(&space->device()),offset,data); if(offset == 3) { - //printf("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); + //logerror("MAIN : %08x DATA : %08x\n",a_bus[3],a_bus[2]); switch(a_bus[3]) { /*ffreveng*/ @@ -531,26 +531,37 @@ static UINT16 decathlt_prottable2[128]; static READ32_HANDLER( decathlt_prot_r ) { - UINT32 *ROM = (UINT32 *)space->machine().region("abus")->base(); + // the offsets written to the protection device definitely only refer to 2 of the roms + // it's a fair assumption to say that only those 2 are connected to the protection device + UINT8 *ROM = (UINT8 *)space->machine().region("abus")->base()+0x1000000; if (offset==2) { - //UINT32 retval; - /* I think the address and data are scrambled.. */ - UINT32 retvalue = /*rand() | (rand()<<16);*/ ROM[(decathlt_protregs[0])]; - decathlt_protregs[0]++; + UINT32 retvalue; + + retvalue = ROM[(decathlt_protregs[0]*2)-2]; decathlt_protregs[0]++; + retvalue <<= 8; + retvalue |= ROM[(decathlt_protregs[0]*2)+1-2]; + retvalue <<= 8; + retvalue |= ROM[(decathlt_protregs[0]*2)-2]; decathlt_protregs[0]++; + retvalue <<= 8; + retvalue |= ROM[(decathlt_protregs[0]*2)+1-2]; + + decathlt_lastcount++; - return retvalue; // reads this, then the game writes it to vram... + logerror("blah_r %08x\n", retvalue); + return retvalue; } else { - mame_printf_info("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n",cpu_get_pc(&space->device()), offset, mem_mask, decathlt_protregs[0], decathlt_protregs[1], decathlt_protregs[2], decathlt_protregs[3]); + logerror("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n",cpu_get_pc(&space->device()), offset, mem_mask, decathlt_protregs[0], decathlt_protregs[1], decathlt_protregs[2], decathlt_protregs[3]); } return decathlt_protregs[offset]; } -static WRITE32_HANDLER( decathlt_prot_w ) + +void write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which) { decathlt_protregs[offset] = (data&mem_mask)|(decathlt_protregs[offset]&~mem_mask); // decathlt_protregs[0] = 0x0c00000/4; @@ -559,9 +570,9 @@ static WRITE32_HANDLER( decathlt_prot_w ) { decathlt_part ^=1; - if (decathlt_part==0) mame_printf_info("last count was %06x\n",decathlt_lastcount); + //if (decathlt_part==0) logerror("%d, last read count was %06x\n",which, decathlt_lastcount*4); decathlt_lastcount = 0; - mame_printf_info("%06x Decathlete prot W offset %04x data %08x, regs %08x, %08x, %08x, %08x\n",cpu_get_pc(&space->device()), offset, data, decathlt_protregs[0], decathlt_protregs[1], decathlt_protregs[2], decathlt_protregs[3]); + if (decathlt_part==1) logerror("%d Decathlete prot W offset %04x data %08x, %08x, >>> regs %08x <<<<, %08x, %08x, %08x\n",which, offset, data, decathlt_protregs[0], decathlt_protregs[0]*4, decathlt_protregs[1], decathlt_protregs[2], decathlt_protregs[3]); } if (offset==1) // uploads 2 tables... @@ -570,24 +581,24 @@ static WRITE32_HANDLER( decathlt_prot_w ) { if (data == 0x80000000) { - mame_printf_info("changed to upload mode 1\n"); + // logerror("changed to upload mode 1\n"); decathlt_prot_uploadmode = 1; decathlt_prot_uploadoffset = 0; } else if (data == 0x80800000) { - mame_printf_info("changed to upload mode 2\n"); + // logerror("changed to upload mode 2\n"); decathlt_prot_uploadmode = 2; decathlt_prot_uploadoffset = 0; } else { - mame_printf_info("unknown upload mode\n"); + // logerror("unknown upload mode\n"); decathlt_prot_uploadmode = 2; decathlt_prot_uploadoffset = 0; } -// mame_printf_info("ARGH! %08x %08x\n",mem_mask,data); +// logerror("ARGH! %08x %08x\n",mem_mask,data); } else if (mem_mask==0x0000ffff) { @@ -595,11 +606,11 @@ static WRITE32_HANDLER( decathlt_prot_w ) { if (decathlt_prot_uploadoffset>=24) { - mame_printf_info("upload mode 1 error, too big\n"); + // logerror("upload mode 1 error, too big\n"); return; } - mame_printf_info("uploading table 1 %04x %04x\n",decathlt_prot_uploadoffset, data&0xffff); + //logerror("uploading table 1 %04x %04x\n",decathlt_prot_uploadoffset, data&0xffff); decathlt_prottable1[decathlt_prot_uploadoffset]=data&0xffff; decathlt_prot_uploadoffset++; @@ -609,12 +620,18 @@ static WRITE32_HANDLER( decathlt_prot_w ) uploaded values appear to be 12-bit, some are repeated */ - FILE* fp; - fp = fopen("table1","wb"); + { - fwrite(&decathlt_prottable2,24,2,fp); + + FILE* fp; + if (which==1) fp = fopen("table1x","wb"); + else fp = fopen("table1","wb"); + + { + fwrite(&decathlt_prottable1,24,2,fp); + } + fclose(fp); } - fclose(fp); } } @@ -622,38 +639,56 @@ static WRITE32_HANDLER( decathlt_prot_w ) { if (decathlt_prot_uploadoffset>=128) { - mame_printf_info("upload mode 2 error, too big\n"); + //logerror("upload mode 2 error, too big\n"); return; } - mame_printf_info("uploading table 2 %04x %04x\n",decathlt_prot_uploadoffset, data&0xffff); + //logerror("uploading table 2 %04x %04x\n",decathlt_prot_uploadoffset, data&0xffff); decathlt_prottable2[decathlt_prot_uploadoffset]=data&0xffff; decathlt_prot_uploadoffset++; { /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */ - FILE* fp; - fp = fopen("table2","wb"); + { - fwrite(&decathlt_prottable2,128,2,fp); + FILE* fp; + if (which==1) fp = fopen("table2x","wb"); + else fp = fopen("table2","wb"); + + { + fwrite(&decathlt_prottable2,128,2,fp); + } + fclose(fp); } - fclose(fp); } } else { - mame_printf_info("unknown upload mode!\n"); + // logerror("unknown upload mode!\n"); } } } if (offset>1) { - mame_printf_info("higher offset write\n"); + // logerror("higher offset write\n"); } } +static WRITE32_HANDLER( decathlt_prot1_w ) +{ + write_prot_data(data,mem_mask, offset, 0); + +} + +static WRITE32_HANDLER( decathlt_prot2_w ) +{ + write_prot_data(data,mem_mask, offset, 1); + + +} + void install_decathlt_protection(running_machine &machine) { /* It uploads 2 tables here, then performs what looks like a number of transfers, setting @@ -663,9 +698,9 @@ void install_decathlt_protection(running_machine &machine) decathlt_prot_uploadmode = 0; decathlt_prot_uploadoffset = 0; decathlt_part = 1; - machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x37FFFF0, 0x37FFFFF, FUNC(decathlt_prot_r), FUNC(decathlt_prot_w)); - /* It uploads 2 tables here too, but nothing else, mirror? unused? */ -// machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x27FFFF0, 0x27FFFFF, FUNC(decathlt_prot_r), FUNC(decathlt_prot_w)); + machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x37FFFF0, 0x37FFFFF, FUNC(decathlt_prot_r), FUNC(decathlt_prot1_w)); + /* It accesses the device at this address too, with different tables, for the game textures, should it just act like a mirror, or a secondary device? */ + machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_readwrite_handler(0x27FFFF0, 0x27FFFFF, FUNC(decathlt_prot_r), FUNC(decathlt_prot2_w)); } void stv_register_protection_savestates(running_machine &machine) |
