trunk/src/mame/machine/315-5838_317-0229_comp.c
| r243184 | r243185 | |
| 10 | 10 | dumb security check, decompressing a single string. |
| 11 | 11 | |
| 12 | 12 | Each channel appears to be connected to a different set of ROMs, however there is |
| 13 | | defintiely only 315-5838 single chip. |
| 13 | defintiely only a single 315-5838 chip. (could the different channels actually just |
| 14 | be mirror addresses, with part of the address determining the ROMs to use?) |
| 14 | 15 | |
| 15 | 16 | Dead of Alive only uses a single channel, and has the source data in RAM, not ROM. |
| 16 | 17 | This is similar to how some 5881 games were set up, with the ST-V versions decrypting |
| r243184 | r243185 | |
| 18 | 19 | |
| 19 | 20 | Looking at the values read I don't think there is any address based encryption, for |
| 20 | 21 | example many blocks where you'd expect a zero fill start with repeating patterns |
| 21 | | of 8f708f70 (different lengths) which would appear to relate to compressed 0x00 data |
| 22 | of 8f708f70 (different lengths) channel would appear to relate to compressed 0x00 data |
| 22 | 23 | |
| 23 | 24 | read addr 0071253c, blah_r 8f708f70 - read count count 00000004 |
| 24 | 25 | read addr 00712540, blah_r 8f708f70 - read count count 00000008 |
| r243184 | r243185 | |
| 46 | 47 | |
| 47 | 48 | void sega_315_5838_comp_device::device_start() |
| 48 | 49 | { |
| 49 | | m_decathlt_lastcount = 0; |
| 50 | | m_decathlt_prot_uploadmode = 0; |
| 51 | | m_decathlt_prot_uploadoffset = 0; |
| 50 | for (int i = 0; i < 2; i++) |
| 51 | { |
| 52 | m_channel[i].m_decathlt_lastcount = 0; |
| 53 | m_channel[i].m_decathlt_prot_uploadmode = 0; |
| 54 | m_channel[i].m_decathlt_prot_uploadoffset = 0; |
| 55 | m_channel[i].m_read_ch.bind_relative_to(*owner()); |
| 52 | 56 | |
| 53 | | m_read_ch1.bind_relative_to(*owner()); |
| 54 | | m_read_ch2.bind_relative_to(*owner()); |
| 57 | } |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | 60 | void sega_315_5838_comp_device::device_reset() |
| 58 | 61 | { |
| 59 | | memset(m_decathlt_protregs, 0, sizeof(m_decathlt_protregs)); |
| 60 | | m_decathlt_lastcount = 0; |
| 61 | | m_decathlt_prot_uploadmode = 0; |
| 62 | | m_decathlt_prot_uploadoffset = 0; |
| 63 | | m_decathlt_part = 1; |
| 62 | for (int i = 0; i < 2; i++) |
| 63 | { |
| 64 | m_channel[i].m_srcoffset = 0; |
| 65 | m_channel[i].m_decathlt_lastcount = 0; |
| 66 | m_channel[i].m_decathlt_prot_uploadmode = 0; |
| 67 | m_channel[i].m_decathlt_prot_uploadoffset = 0; |
| 68 | } |
| 64 | 69 | |
| 65 | 70 | m_protstate = 0; |
| 66 | 71 | } |
| r243184 | r243185 | |
| 77 | 82 | #endif |
| 78 | 83 | |
| 79 | 84 | |
| 80 | | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_r) |
| 85 | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot1_r) |
| 81 | 86 | { |
| 82 | | return genericdecathlt_prot_r(offset, mem_mask, 0); |
| 87 | return genericdecathlt_prot_r(mem_mask, 0); |
| 83 | 88 | } |
| 84 | 89 | |
| 85 | | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot_ch2_r) |
| 90 | READ32_MEMBER(sega_315_5838_comp_device::decathlt_prot2_r) |
| 86 | 91 | { |
| 87 | | return genericdecathlt_prot_r(offset, mem_mask, 1); |
| 92 | return genericdecathlt_prot_r(mem_mask, 1); |
| 88 | 93 | } |
| 89 | 94 | |
| 90 | 95 | |
| 91 | | UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 offset, UINT32 mem_mask, int which) |
| 96 | UINT32 sega_315_5838_comp_device::genericdecathlt_prot_r(UINT32 mem_mask, int channel) |
| 92 | 97 | { |
| 93 | | |
| 94 | 98 | // UINT32 *fake0 = (UINT32*)memregion( ":fake0" )->base(); |
| 99 | // UINT32 retvalue = 0xffff; |
| 95 | 100 | |
| 96 | | if (offset==2) |
| 101 | switch (m_channel[channel].m_srcoffset) |
| 97 | 102 | { |
| 98 | | // UINT32 retvalue = 0xffff; |
| 103 | default: |
| 99 | 104 | |
| 100 | | switch (m_decathlt_protregs[0]) |
| 101 | | { |
| 102 | | default: |
| 105 | m_channel[channel].m_decathlt_lastcount++; |
| 103 | 106 | |
| 104 | | m_decathlt_lastcount++; |
| 107 | UINT32 tempdata = 0; |
| 108 | tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 0; |
| 109 | m_channel[channel].m_srcoffset++; |
| 110 | tempdata |= m_channel[channel].m_read_ch(m_channel[channel].m_srcoffset) << 16; |
| 111 | m_channel[channel].m_srcoffset++; |
| 105 | 112 | |
| 106 | | UINT32 tempdata = 0; |
| 107 | 113 | |
| 108 | | if (which == 0) |
| 109 | | { |
| 110 | | tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 16; |
| 111 | | m_decathlt_protregs[0]++; |
| 112 | | tempdata |= m_read_ch1(m_decathlt_protregs[0]) << 0; |
| 113 | | m_decathlt_protregs[0]++; |
| 114 | | } |
| 115 | | else |
| 116 | | { |
| 117 | | tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 16; |
| 118 | | m_decathlt_protregs[0]++; |
| 119 | | tempdata |= m_read_ch2(m_decathlt_protregs[0]) << 0; |
| 120 | | m_decathlt_protregs[0]++; |
| 121 | | } |
| 114 | #ifdef DEBUG_DATA_DUMP |
| 115 | //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata, m_channel[channel].m_decathlt_lastcount*4); |
| 116 | fwrite(&tempdata, 1, 4, tempfile); |
| 117 | #else |
| 118 | logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_channel[channel].m_srcoffset*2, tempdata, m_channel[channel].m_decathlt_lastcount*4); |
| 119 | #endif |
| 122 | 120 | |
| 123 | | #ifdef DEBUG_DATA_DUMP |
| 124 | | //printf("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata, m_decathlt_lastcount*4); |
| 125 | | fwrite(&tempdata, 1, 4, tempfile); |
| 126 | | #else |
| 127 | | logerror("read addr %08x, blah_r %08x - read count count %08x\n", m_decathlt_protregs[0]*2, tempdata, m_decathlt_lastcount*4); |
| 128 | | #endif |
| 129 | | |
| 130 | | return tempdata; |
| 121 | return tempdata; |
| 131 | 122 | #if 0 |
| 132 | | case 0x03228e4: |
| 133 | | if (fake0) retvalue = fake0[(((0x20080/4)+m_decathlt_lastcount))]; |
| 134 | | m_decathlt_lastcount++; |
| 135 | | return retvalue; |
| 123 | case 0x03228e4: |
| 124 | if (fake0) retvalue = fake0[(((0x20080/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 125 | m_channel[channel].m_decathlt_lastcount++; |
| 126 | return retvalue; |
| 136 | 127 | |
| 137 | | case 0x00a9f3a: |
| 138 | | if (fake0) retvalue = fake0[(((0x00000/4)+m_decathlt_lastcount))]; |
| 139 | | m_decathlt_lastcount++; |
| 140 | | return retvalue; |
| 128 | case 0x00a9f3a: |
| 129 | if (fake0) retvalue = fake0[(((0x00000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 130 | m_channel[channel].m_decathlt_lastcount++; |
| 131 | return retvalue; |
| 141 | 132 | |
| 142 | | case 0x0213ab4: |
| 143 | | if (fake0) retvalue = fake0[(((0x40000/4)+m_decathlt_lastcount))]; |
| 144 | | m_decathlt_lastcount++; |
| 145 | | return retvalue; |
| 133 | case 0x0213ab4: |
| 134 | if (fake0) retvalue = fake0[(((0x40000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 135 | m_channel[channel].m_decathlt_lastcount++; |
| 136 | return retvalue; |
| 146 | 137 | |
| 147 | | case 0x01efaf0: |
| 148 | | if (fake0) retvalue = fake0[(((0x60000/4)+m_decathlt_lastcount))]; |
| 149 | | m_decathlt_lastcount++; |
| 150 | | return retvalue; |
| 138 | case 0x01efaf0: |
| 139 | if (fake0) retvalue = fake0[(((0x60000/4)+m_channel[channel].m_decathlt_lastcount))]; |
| 140 | m_channel[channel].m_decathlt_lastcount++; |
| 141 | return retvalue; |
| 151 | 142 | |
| 152 | | case 0x033f16c: |
| 153 | | case 0x038929c: |
| 143 | case 0x033f16c: |
| 144 | case 0x038929c: |
| 154 | 145 | |
| 155 | 146 | |
| 156 | 147 | |
| 157 | | case 0x00de05a: |
| 158 | | case 0x0334258: |
| 159 | | case 0x019fb82: |
| 160 | | case 0x033dbf6: |
| 161 | | case 0x0011ac6: |
| 162 | | case 0x00060dc: |
| 163 | | case 0x0000002: |
| 164 | | case 0x0008c90: |
| 165 | | case 0x035cdc8: |
| 166 | | case 0x0327960: |
| 167 | | case 0x0329b8c: |
| 168 | | case 0x00d6e92: |
| 169 | | case 0x000081e: |
| 170 | | case 0x00035d6: |
| 171 | | case 0x00089a6: |
| 172 | | case 0x03315f4: |
| 173 | | case 0x0023fe0: |
| 174 | | case 0x001e290: |
| 175 | | case 0x0026e86: |
| 176 | | case 0x0012494: |
| 177 | | case 0x001b35a: |
| 178 | | case 0x0018424: |
| 148 | case 0x00de05a: |
| 149 | case 0x0334258: |
| 150 | case 0x019fb82: |
| 151 | case 0x033dbf6: |
| 152 | case 0x0011ac6: |
| 153 | case 0x00060dc: |
| 154 | case 0x0000002: |
| 155 | case 0x0008c90: |
| 156 | case 0x035cdc8: |
| 157 | case 0x0327960: |
| 158 | case 0x0329b8c: |
| 159 | case 0x00d6e92: |
| 160 | case 0x000081e: |
| 161 | case 0x00035d6: |
| 162 | case 0x00089a6: |
| 163 | case 0x03315f4: |
| 164 | case 0x0023fe0: |
| 165 | case 0x001e290: |
| 166 | case 0x0026e86: |
| 167 | case 0x0012494: |
| 168 | case 0x001b35a: |
| 169 | case 0x0018424: |
| 179 | 170 | |
| 180 | | return retvalue; |
| 171 | return retvalue; |
| 181 | 172 | #endif |
| 182 | | } |
| 183 | | |
| 184 | | |
| 185 | 173 | } |
| 186 | | else |
| 187 | | { |
| 188 | | logerror("%06x Decathlete prot R offset %04x mask %08x regs %08x, %08x, %08x, %08x\n", safe_pc(), offset, mem_mask, m_decathlt_protregs[0], m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]); |
| 189 | | } |
| 190 | 174 | |
| 191 | | return m_decathlt_protregs[offset]; |
| 175 | return 0xffffffff; |
| 192 | 176 | } |
| 193 | 177 | |
| 194 | | |
| 195 | | void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int offset, int which) |
| 178 | void sega_315_5838_comp_device::set_prot_addr(UINT32 data, UINT32 mem_mask, int channel) |
| 196 | 179 | { |
| 180 | // printf("set_prot_addr\n"); |
| 181 | COMBINE_DATA(&m_channel[channel].m_srcoffset); |
| 197 | 182 | |
| 198 | | printf("write_prot_data %08x %08x %08x\n", offset, data, mem_mask); |
| 183 | //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",channel, m_channel[channel].m_decathlt_lastcount*4); |
| 184 | m_channel[channel].m_decathlt_lastcount = 0; |
| 199 | 185 | |
| 200 | | m_decathlt_protregs[offset] = (data&mem_mask)|(m_decathlt_protregs[offset]&~mem_mask); |
| 201 | | // m_decathlt_protregs[0] = 0x0c00000/4; |
| 202 | | |
| 203 | | if (offset==0) // seems to set a source address |
| 186 | if (mem_mask == 0x0000ffff) |
| 204 | 187 | { |
| 205 | | m_decathlt_part ^=1; |
| 188 | printf("set source address to %08x (channel %d)\n", m_channel[channel].m_srcoffset, channel); |
| 189 | } |
| 206 | 190 | |
| 207 | | //if (m_decathlt_part==0) logerror("%d, last read count was %06x\n",which, m_decathlt_lastcount*4); |
| 208 | | m_decathlt_lastcount = 0; |
| 209 | | if (m_decathlt_part==1) logerror("%d Decathlete prot W offset %04x data %08x, %08x, >>> regs %08x <<<<, %08x, %08x, %08x\n",which, offset, data, m_decathlt_protregs[0], m_decathlt_protregs[0]*4, m_decathlt_protregs[1], m_decathlt_protregs[2], m_decathlt_protregs[3]); |
| 210 | 191 | |
| 211 | 192 | #ifdef DEBUG_DATA_DUMP |
| 212 | | if (mem_mask == 0x0000ffff) |
| 193 | if (mem_mask == 0x0000ffff) |
| 194 | { |
| 195 | if (tempfile) |
| 196 | fclose(tempfile); |
| 197 | |
| 198 | char filename[256]; |
| 199 | sprintf(filename, "%d_compressed_%08x", channel, m_channel[channel].m_srcoffset * 2); |
| 200 | tempfile = fopen(filename, "w+b"); |
| 201 | |
| 202 | // the table and dictionary are uploaded repeatedly, usually before groups of data transfers but |
| 203 | // it's always the same tables (one pair for each channel) |
| 213 | 204 | { |
| 214 | | if (tempfile) |
| 215 | | fclose(tempfile); |
| 205 | FILE* fp; |
| 206 | sprintf(filename, "%d_compressed_table1", channel); |
| 207 | fp = fopen(filename, "w+b"); |
| 208 | fwrite(&m_channel[channel].m_decathlt_prottable1, 24, 2, fp); |
| 209 | fclose(fp); |
| 210 | } |
| 216 | 211 | |
| 217 | | char filename[256]; |
| 218 | | sprintf(filename, "%d_compressed_%08x", which, m_decathlt_protregs[0] ); |
| 219 | | tempfile = fopen(filename, "w+b"); |
| 212 | { |
| 213 | FILE* fp; |
| 214 | sprintf(filename, "%d_compressed_dictionary", channel); |
| 215 | fp = fopen(filename, "w+b"); |
| 216 | fwrite(&m_channel[channel].m_decathlt_dictionary, 128, 2, fp); |
| 217 | fclose(fp); |
| 220 | 218 | } |
| 219 | } |
| 221 | 220 | #endif |
| 222 | 221 | |
| 222 | } |
| 223 | |
| 224 | void sega_315_5838_comp_device::set_upload_mode(UINT16 data, int channel) |
| 225 | { |
| 226 | if ((data == 0x8000) || (data == 0x0000)) |
| 227 | { |
| 228 | // logerror("changed to upload mode 1\n"); |
| 229 | m_channel[channel].m_decathlt_prot_uploadmode = 1; |
| 230 | m_channel[channel].m_decathlt_prot_uploadoffset = 0; |
| 223 | 231 | } |
| 232 | else if ((data == 0x8080) || (data == 0x0080)) |
| 233 | { |
| 234 | m_channel[channel].m_decathlt_prot_uploadmode = 2; |
| 235 | m_channel[channel].m_decathlt_prot_uploadoffset = 0; |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | fatalerror("unknown upload mode\n"); |
| 240 | } |
| 241 | } |
| 224 | 242 | |
| 225 | | if (offset==1) // uploads 2 tables... |
| 243 | void sega_315_5838_comp_device::upload_table_data(UINT16 data, int channel) |
| 244 | { |
| 245 | if (m_channel[channel].m_decathlt_prot_uploadmode == 1) |
| 226 | 246 | { |
| 227 | | if (mem_mask==0xffff0000) |
| 247 | if (m_channel[channel].m_decathlt_prot_uploadoffset >= 24) |
| 228 | 248 | { |
| 229 | | if (data == 0x80000000) |
| 230 | | { |
| 231 | | // logerror("changed to upload mode 1\n"); |
| 232 | | m_decathlt_prot_uploadmode = 1; |
| 233 | | m_decathlt_prot_uploadoffset = 0; |
| 234 | | } |
| 235 | | else if (data == 0x80800000) |
| 236 | | { |
| 237 | | // logerror("changed to upload mode 2\n"); |
| 238 | | m_decathlt_prot_uploadmode = 2; |
| 239 | | m_decathlt_prot_uploadoffset = 0; |
| 240 | | } |
| 241 | | else |
| 242 | | { |
| 243 | | // logerror("unknown upload mode\n"); |
| 244 | | m_decathlt_prot_uploadmode = 2; |
| 245 | | m_decathlt_prot_uploadoffset = 0; |
| 246 | | } |
| 247 | | |
| 248 | | // logerror("ARGH! %08x %08x\n",mem_mask,data); |
| 249 | fatalerror("upload mode 1 error, too big\n"); |
| 250 | return; |
| 249 | 251 | } |
| 250 | | else if (mem_mask==0x0000ffff) |
| 251 | | { |
| 252 | | if (m_decathlt_prot_uploadmode==1) |
| 253 | | { |
| 254 | | if (m_decathlt_prot_uploadoffset>=24) |
| 255 | | { |
| 256 | | // logerror("upload mode 1 error, too big\n"); |
| 257 | | return; |
| 258 | | } |
| 259 | 252 | |
| 260 | | //logerror("uploading table 1 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff); |
| 261 | | m_decathlt_prottable1[m_decathlt_prot_uploadoffset]=data&0xffff; |
| 262 | | m_decathlt_prot_uploadoffset++; |
| 263 | | |
| 264 | | printf("table 1 %04x\n", data & 0xffff); |
| 265 | | |
| 266 | | { |
| 267 | | /* 0x18 (24) values in this table, rom data is 0x1800000 long, maybe it has |
| 268 | | something to do with that? or 24-address b its? |
| 269 | | |
| 270 | | uploaded values appear to be 12-bit, some are repeated |
| 271 | | */ |
| 272 | | |
| 273 | | { |
| 274 | | FILE* fp; |
| 275 | | if (which==1) fp = fopen("table1x","wb"); |
| 276 | | else fp = fopen("table1","wb"); |
| 277 | | |
| 278 | | { |
| 279 | | fwrite(&m_decathlt_prottable1,24,2,fp); |
| 280 | | } |
| 281 | | fclose(fp); |
| 282 | | } |
| 283 | | } |
| 284 | | |
| 285 | | } |
| 286 | | else if (m_decathlt_prot_uploadmode==2) |
| 287 | | { |
| 288 | | if (m_decathlt_prot_uploadoffset>=128) |
| 289 | | { |
| 290 | | //logerror("upload mode 2 error, too big\n"); |
| 291 | | return; |
| 292 | | } |
| 293 | | |
| 294 | | //logerror("uploading table 2 %04x %04x\n",m_decathlt_prot_uploadoffset, data&0xffff); |
| 295 | | m_decathlt_prottable2[m_decathlt_prot_uploadoffset]=data&0xffff; |
| 296 | | m_decathlt_prot_uploadoffset++; |
| 297 | | |
| 298 | | printf("dictionary %04x\n", data & 0xffff); |
| 299 | | |
| 300 | | |
| 301 | | { |
| 302 | | /* the table uploaded here is a 256 byte table with 256 unique values, remaps something? */ |
| 303 | | |
| 304 | | { |
| 305 | | FILE* fp; |
| 306 | | if (which==1) fp = fopen("table2x","wb"); |
| 307 | | else fp = fopen("table2","wb"); |
| 308 | | |
| 309 | | { |
| 310 | | fwrite(&m_decathlt_prottable2,128,2,fp); |
| 311 | | } |
| 312 | | fclose(fp); |
| 313 | | } |
| 314 | | } |
| 315 | | } |
| 316 | | else |
| 317 | | { |
| 318 | | // logerror("unknown upload mode!\n"); |
| 319 | | } |
| 253 | //logerror("uploading table 1 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff); |
| 254 | m_channel[channel].m_decathlt_prottable1[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff; |
| 255 | m_channel[channel].m_decathlt_prot_uploadoffset++; |
| 256 | printf("unk table 1 %04x (channel %d)\n", data & 0xffff, channel); |
| 257 | } |
| 258 | else if (m_channel[channel].m_decathlt_prot_uploadmode == 2) |
| 259 | { |
| 260 | if (m_channel[channel].m_decathlt_prot_uploadoffset >= 128) |
| 261 | { |
| 262 | fatalerror("upload mode 2 error, too big\n"); |
| 263 | return; |
| 320 | 264 | } |
| 265 | |
| 266 | //logerror("uploading table 2 %04x %04x\n",m_channel[channel].m_decathlt_prot_uploadoffset, data&0xffff); |
| 267 | m_channel[channel].m_decathlt_dictionary[m_channel[channel].m_decathlt_prot_uploadoffset] = data & 0xffff; |
| 268 | m_channel[channel].m_decathlt_prot_uploadoffset++; |
| 269 | printf("dictionary %04x (channel %d)\n", data & 0xffff, channel); |
| 321 | 270 | } |
| 271 | } |
| 322 | 272 | |
| 323 | | if (offset>1) |
| 273 | void sega_315_5838_comp_device::write_prot_data(UINT32 data, UINT32 mem_mask, int channel, int rev_words) |
| 274 | { |
| 275 | if (mem_mask==0xffff0000) |
| 324 | 276 | { |
| 325 | | // logerror("higher offset write\n"); |
| 277 | if (rev_words==0) set_upload_mode(data >> 16, channel); |
| 278 | else upload_table_data(data >>16, channel); |
| 326 | 279 | } |
| 327 | | |
| 280 | else if (mem_mask == 0x0000ffff) |
| 281 | { |
| 282 | if (rev_words==0) upload_table_data(data & 0xffff, channel); |
| 283 | else set_upload_mode(data & 0xffff, channel); |
| 284 | } |
| 285 | else |
| 286 | { |
| 287 | fatalerror("write_prot_data invalid mem_mask\b"); |
| 288 | } |
| 328 | 289 | } |
| 329 | 290 | |
| 330 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w ) |
| 331 | | { |
| 332 | | write_prot_data(data,mem_mask, offset, 0); |
| 333 | 291 | |
| 334 | | } |
| 335 | 292 | |
| 336 | | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w ) |
| 337 | | { |
| 338 | | write_prot_data(data,mem_mask, offset, 1); |
| 293 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w_doa ) { write_prot_data(data, mem_mask, 0, 1); } |
| 294 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_w) { write_prot_data(data, mem_mask, 0, 0); } |
| 295 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_w) { write_prot_data(data, mem_mask, 1, 0); } |
| 339 | 296 | |
| 297 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot1_srcaddr_w ) { set_prot_addr(data, mem_mask, 0); } |
| 298 | WRITE32_MEMBER( sega_315_5838_comp_device::decathlt_prot2_srcaddr_w) { set_prot_addr(data, mem_mask, 1); } |
| 340 | 299 | |
| 341 | | } |
| 342 | 300 | |
| 343 | 301 | void sega_315_5838_comp_device::install_decathlt_protection() |
| 344 | 302 | { |
| 345 | | /* It uploads 2 tables here, then performs what looks like a number of transfers, setting |
| 346 | | a source address of some kind (scrambled?) and then making many reads from a single address */ |
| 347 | | |
| 348 | 303 | //todo, install these in the driver, they differ between games |
| 349 | 304 | cpu_device* cpu = (cpu_device*)machine().device(":maincpu"); |
| 350 | 305 | |
| 306 | cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF0, 0x37FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address |
| 307 | cpu->space(AS_PROGRAM).install_write_handler(0x37FFFF4, 0x37FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this)); // upload tables |
| 308 | cpu->space(AS_PROGRAM).install_read_handler(0x37FFFF8, 0x37FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data |
| 351 | 309 | |
| 352 | | cpu->space(AS_PROGRAM).install_readwrite_handler(0x37FFFF0, 0x37FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w), this)); |
| 353 | | /* 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? */ |
| 354 | | cpu->space(AS_PROGRAM).install_readwrite_handler(0x27FFFF0, 0x27FFFFF, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot_ch2_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this)); |
| 310 | // the device is addressed here too, uploading a different set of tables and accessing a different part of ROM |
| 311 | cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF0, 0x27FFFF3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_srcaddr_w), this)); // set compressed data source address |
| 312 | cpu->space(AS_PROGRAM).install_write_handler(0x27FFFF4, 0x27FFFF7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_w), this)); // upload tables |
| 313 | cpu->space(AS_PROGRAM).install_read_handler(0x27FFFF8, 0x27FFFFb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot2_r), this)); // read decompressed data |
| 355 | 314 | } |
| 356 | 315 | |
| 357 | 316 | |
| r243184 | r243185 | |
| 387 | 346 | { |
| 388 | 347 | printf("doa_prot_w %08x %08x %08x\n", offset*4, data, mem_mask); |
| 389 | 348 | |
| 390 | | if (offset == 0x7ff2 / 4) |
| 391 | | { |
| 392 | | if (data == 0) |
| 393 | | { |
| 394 | | m_protstate = 0; |
| 395 | | strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00"); // this is the single decompressed string DOA needs |
| 396 | | } |
| 397 | | } |
| 398 | | else logerror("Unhandled Protection WRITE %x @ %x mask %x (PC=%x)\n", data, offset, mem_mask, space.device().safe_pc()); |
| 349 | m_protstate = 0; |
| 399 | 350 | } |
| 400 | 351 | |
| 401 | 352 | |
| r243184 | r243185 | |
| 403 | 354 | { |
| 404 | 355 | //todo, install these in the driver, they differ between games |
| 405 | 356 | cpu_device* cpu = (cpu_device*)machine().device(":maincpu"); |
| 357 | |
| 358 | m_protstate = 0; |
| 359 | strcpy((char *)m_protram, " TECMO LTD. DEAD OR ALIVE 1996.10.22 VER. 1.00"); // this is the single decompressed string DOA needs, note, 2 spaces at start, might indicate a dummy read like with 5881 on Model 2 |
| 360 | |
| 406 | 361 | cpu->space(AS_PROGRAM).install_readwrite_handler(0x01d80000, 0x01dfffff, read32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_r), this), write32_delegate(FUNC(sega_315_5838_comp_device::doa_prot_w), this)); |
| 362 | cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff0, 0x01d87ff3, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_srcaddr_w), this)); // set compressed data source address (always set 0, data is in RAM) |
| 363 | cpu->space(AS_PROGRAM).install_write_handler(0x01d87ff4, 0x01d87ff7, write32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_w_doa), this)); // upload tab |
| 364 | // cpu->space(AS_PROGRAM).install_read_handler(0x01d87ff8, 0x01d87ffb, read32_delegate(FUNC(sega_315_5838_comp_device::decathlt_prot1_r), this)); // read decompressed data |
| 365 | |
| 407 | 366 | } |
| | No newline at end of file |