trunk/src/mame/machine/igs025.c
| r26058 | r26059 | |
| 94 | 94 | |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | /****************************************/ |
| 98 | /* WRITE */ |
| 99 | /****************************************/ |
| 97 | 100 | |
| 98 | | void igs025_device::killbld_protection_calculate_hilo() |
| 99 | | { |
| 100 | | UINT8 source; |
| 101 | | |
| 102 | | m_kb_prot_hilo_select++; |
| 103 | | |
| 104 | | if (m_kb_prot_hilo_select > 0xeb) { |
| 105 | | m_kb_prot_hilo_select = 0; |
| 106 | | } |
| 107 | | |
| 108 | | source = m_kb_source_data[m_drgw2_protection_region][m_kb_prot_hilo_select]; |
| 109 | | |
| 110 | | if (m_kb_prot_hilo_select & 1) |
| 111 | | { |
| 112 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); |
| 113 | | } |
| 114 | | else |
| 115 | | { |
| 116 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); |
| 117 | | } |
| 118 | | } |
| 119 | | |
| 120 | 101 | WRITE16_MEMBER(igs025_device::killbld_igs025_prot_w ) |
| 121 | 102 | { |
| 122 | 103 | if (offset == 0) |
| r26058 | r26059 | |
| 176 | 157 | } |
| 177 | 158 | } |
| 178 | 159 | |
| 179 | | READ16_MEMBER(igs025_device::killbld_igs025_prot_r ) |
| 180 | | { |
| 181 | | if (offset) |
| 182 | | { |
| 183 | | switch (m_kb_cmd) |
| 184 | | { |
| 185 | | case 0x00: |
| 186 | | return BITSWAP8((m_kb_swap+1) & 0x7f, 0,1,2,3,4,5,6,7); // drgw3 |
| 187 | | |
| 188 | | case 0x01: |
| 189 | | return m_kb_reg & 0x7f; |
| 190 | | |
| 191 | | case 0x05: |
| 192 | | { |
| 193 | | switch (m_kb_ptr) |
| 194 | | { |
| 195 | | case 1: |
| 196 | | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 197 | | |
| 198 | | case 2: |
| 199 | | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 200 | | |
| 201 | | case 3: |
| 202 | | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 203 | | |
| 204 | | case 4: |
| 205 | | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 206 | | |
| 207 | | default: // >= 5 |
| 208 | | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15); |
| 209 | | } |
| 210 | | |
| 211 | | return 0; |
| 212 | | } |
| 213 | | |
| 214 | | case 0x40: |
| 215 | | killbld_protection_calculate_hilo(); |
| 216 | | return 0; // Read and then discarded |
| 217 | | |
| 218 | | // default: |
| 219 | | // logerror("%06X: ASIC25 R CMD %X\n", space.device().safe_pc(), m_kb_cmd); |
| 220 | | } |
| 221 | | } |
| 222 | | |
| 223 | | return 0; |
| 224 | | } |
| 225 | | |
| 226 | | |
| 227 | | /* todo, collapse this all into above */ |
| 228 | | |
| 229 | | |
| 230 | | void igs025_device::olds_protection_calculate_hilo() // calculated in routine $12dbc2 in olds |
| 231 | | { |
| 232 | | UINT8 source; |
| 233 | | |
| 234 | | m_kb_prot_hilo_select++; |
| 235 | | if (m_kb_prot_hilo_select > 0xeb) { |
| 236 | | m_kb_prot_hilo_select = 0; |
| 237 | | } |
| 238 | | |
| 239 | | source = olds_source_data[m_drgw2_protection_region][m_kb_prot_hilo_select]; |
| 240 | | |
| 241 | | if (m_kb_prot_hilo_select & 1) // $8178fa |
| 242 | | { |
| 243 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); // $8178d8 |
| 244 | | } |
| 245 | | else |
| 246 | | { |
| 247 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); // $8178d8 |
| 248 | | } |
| 249 | | } |
| 250 | | |
| 251 | 160 | WRITE16_MEMBER(igs025_device::olds_w ) |
| 252 | 161 | { |
| 253 | 162 | if (offset == 0) |
| r26058 | r26059 | |
| 296 | 205 | } |
| 297 | 206 | } |
| 298 | 207 | |
| 299 | | READ16_MEMBER(igs025_device::olds_r ) |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | WRITE16_MEMBER(igs025_device::drgw2_d80000_protection_w ) |
| 300 | 214 | { |
| 215 | if (offset == 0) |
| 216 | { |
| 217 | m_kb_cmd = data; |
| 218 | return; |
| 219 | } |
| 220 | |
| 221 | switch (m_kb_cmd) |
| 222 | { |
| 223 | case 0x20: |
| 224 | case 0x21: |
| 225 | case 0x22: |
| 226 | case 0x23: |
| 227 | case 0x24: |
| 228 | case 0x25: |
| 229 | case 0x26: |
| 230 | case 0x27: |
| 231 | m_kb_ptr++; |
| 232 | drgw2_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 233 | break; |
| 234 | |
| 235 | // case 0x08: // Used only on init.. |
| 236 | // case 0x09: |
| 237 | // case 0x0a: |
| 238 | // case 0x0b: |
| 239 | // case 0x0c: |
| 240 | // break; |
| 241 | |
| 242 | // case 0x15: // ???? |
| 243 | // case 0x17: |
| 244 | // case 0xf2: |
| 245 | // break; |
| 246 | |
| 247 | // default: |
| 248 | // logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_kb_cmd, data); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /****************************************/ |
| 253 | /* READ */ |
| 254 | /****************************************/ |
| 255 | |
| 256 | READ16_MEMBER(igs025_device::killbld_igs025_prot_r) |
| 257 | { |
| 301 | 258 | if (offset) |
| 302 | 259 | { |
| 303 | 260 | switch (m_kb_cmd) |
| 304 | 261 | { |
| 305 | | case 0x01: |
| 306 | | return m_kb_reg & 0x7f; |
| 262 | case 0x00: |
| 263 | return BITSWAP8((m_kb_swap + 1) & 0x7f, 0, 1, 2, 3, 4, 5, 6, 7); // drgw3 |
| 307 | 264 | |
| 308 | | case 0x02: |
| 309 | | return m_olds_bs | 0x80; |
| 265 | case 0x01: |
| 266 | return m_kb_reg & 0x7f; |
| 310 | 267 | |
| 311 | | case 0x03: |
| 312 | | return m_kb_cmd3; |
| 268 | case 0x05: |
| 269 | { |
| 270 | switch (m_kb_ptr) |
| 271 | { |
| 272 | case 1: |
| 273 | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 313 | 274 | |
| 314 | | case 0x05: |
| 315 | | { |
| 316 | | switch (m_kb_ptr) |
| 317 | | { |
| 318 | | case 1: |
| 319 | | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 275 | case 2: |
| 276 | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 320 | 277 | |
| 321 | | case 2: |
| 322 | | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 278 | case 3: |
| 279 | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 323 | 280 | |
| 324 | | case 3: |
| 325 | | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 281 | case 4: |
| 282 | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 326 | 283 | |
| 327 | | case 4: |
| 328 | | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 284 | default: // >= 5 |
| 285 | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5, 2, 9, 7, 10, 13, 12, 15); |
| 286 | } |
| 329 | 287 | |
| 288 | return 0; |
| 289 | } |
| 330 | 290 | |
| 291 | case 0x40: |
| 292 | killbld_protection_calculate_hilo(); |
| 293 | return 0; // Read and then discarded |
| 331 | 294 | |
| 332 | | |
| 333 | | case 5: |
| 334 | | default: // >= 5 |
| 335 | | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15); // $817906 |
| 336 | | } |
| 337 | | } |
| 338 | | |
| 339 | | case 0x40: |
| 340 | | olds_protection_calculate_hilo(); |
| 341 | | return 0; // unused? |
| 295 | // default: |
| 296 | // logerror("%06X: ASIC25 R CMD %X\n", space.device().safe_pc(), m_kb_cmd); |
| 342 | 297 | } |
| 343 | 298 | } |
| 344 | 299 | |
| r26058 | r26059 | |
| 346 | 301 | } |
| 347 | 302 | |
| 348 | 303 | |
| 349 | | |
| 350 | | |
| 351 | | void igs025_device::drgw2_protection_calculate_hilo() |
| 304 | READ16_MEMBER(igs025_device::olds_r) |
| 352 | 305 | { |
| 353 | | UINT8 source; |
| 306 | if (offset) |
| 307 | { |
| 308 | switch (m_kb_cmd) |
| 309 | { |
| 310 | case 0x01: |
| 311 | return m_kb_reg & 0x7f; |
| 354 | 312 | |
| 355 | | m_kb_prot_hilo_select++; |
| 356 | | if (m_kb_prot_hilo_select > 0xeb) { |
| 357 | | m_kb_prot_hilo_select = 0; |
| 358 | | } |
| 313 | case 0x02: |
| 314 | return m_olds_bs | 0x80; |
| 359 | 315 | |
| 360 | | source = m_drgw2_source_data[m_drgw2_protection_region][m_kb_prot_hilo_select]; |
| 316 | case 0x03: |
| 317 | return m_kb_cmd3; |
| 361 | 318 | |
| 362 | | if (m_kb_prot_hilo_select & 1) |
| 363 | | { |
| 364 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); |
| 365 | | } |
| 366 | | else |
| 367 | | { |
| 368 | | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); |
| 369 | | } |
| 370 | | } |
| 371 | | |
| 372 | | READ16_MEMBER(igs025_device::drgw2_d80000_protection_r ) |
| 373 | | { |
| 374 | | switch (m_kb_cmd) |
| 375 | | { |
| 376 | 319 | case 0x05: |
| 377 | 320 | { |
| 378 | | switch (m_kb_ptr) |
| 379 | | { |
| 380 | | case 1: |
| 381 | | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 321 | switch (m_kb_ptr) |
| 322 | { |
| 323 | case 1: |
| 324 | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 382 | 325 | |
| 383 | | case 2: |
| 384 | | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 326 | case 2: |
| 327 | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 385 | 328 | |
| 386 | | case 3: |
| 387 | | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 329 | case 3: |
| 330 | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 388 | 331 | |
| 389 | | case 4: |
| 390 | | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 332 | case 4: |
| 333 | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 391 | 334 | |
| 392 | | case 5: |
| 393 | | default: |
| 394 | | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5,2,9,7,10,13,12,15); |
| 395 | | } |
| 396 | 335 | |
| 397 | | return 0x3f00; |
| 336 | |
| 337 | |
| 338 | case 5: |
| 339 | default: // >= 5 |
| 340 | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5, 2, 9, 7, 10, 13, 12, 15); // $817906 |
| 341 | } |
| 398 | 342 | } |
| 399 | 343 | |
| 400 | 344 | case 0x40: |
| 401 | | drgw2_protection_calculate_hilo(); |
| 402 | | return 0; |
| 403 | | |
| 404 | | // case 0x13: // Read to $80eeb8 |
| 405 | | // case 0x1f: // Read to $80eeb8 |
| 406 | | // case 0xf4: // Read to $80eeb8 |
| 407 | | // case 0xf6: // Read to $80eeb8 |
| 408 | | // case 0xf8: // Read to $80eeb8 |
| 409 | | // return 0; |
| 410 | | |
| 411 | | // default: |
| 412 | | // logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_kb_cmd); |
| 345 | olds_protection_calculate_hilo(); |
| 346 | return 0; // unused? |
| 347 | } |
| 413 | 348 | } |
| 414 | 349 | |
| 415 | 350 | return 0; |
| 416 | 351 | } |
| 417 | 352 | |
| 418 | | WRITE16_MEMBER(igs025_device::drgw2_d80000_protection_w ) |
| 353 | |
| 354 | READ16_MEMBER(igs025_device::drgw2_d80000_protection_r) |
| 419 | 355 | { |
| 420 | | if (offset == 0) |
| 356 | switch (m_kb_cmd) |
| 421 | 357 | { |
| 422 | | m_kb_cmd = data; |
| 423 | | return; |
| 358 | case 0x05: |
| 359 | { |
| 360 | switch (m_kb_ptr) |
| 361 | { |
| 362 | case 1: |
| 363 | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 364 | |
| 365 | case 2: |
| 366 | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 367 | |
| 368 | case 3: |
| 369 | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 370 | |
| 371 | case 4: |
| 372 | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 373 | |
| 374 | case 5: |
| 375 | default: |
| 376 | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5, 2, 9, 7, 10, 13, 12, 15); |
| 377 | } |
| 378 | |
| 379 | return 0x3f00; |
| 424 | 380 | } |
| 425 | 381 | |
| 426 | | switch (m_kb_cmd) |
| 427 | | { |
| 428 | | case 0x20: |
| 429 | | case 0x21: |
| 430 | | case 0x22: |
| 431 | | case 0x23: |
| 432 | | case 0x24: |
| 433 | | case 0x25: |
| 434 | | case 0x26: |
| 435 | | case 0x27: |
| 436 | | m_kb_ptr++; |
| 437 | | drgw2_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 438 | | break; |
| 382 | case 0x40: |
| 383 | drgw2_protection_calculate_hilo(); |
| 384 | return 0; |
| 439 | 385 | |
| 440 | | // case 0x08: // Used only on init.. |
| 441 | | // case 0x09: |
| 442 | | // case 0x0a: |
| 443 | | // case 0x0b: |
| 444 | | // case 0x0c: |
| 445 | | // break; |
| 386 | // case 0x13: // Read to $80eeb8 |
| 387 | // case 0x1f: // Read to $80eeb8 |
| 388 | // case 0xf4: // Read to $80eeb8 |
| 389 | // case 0xf6: // Read to $80eeb8 |
| 390 | // case 0xf8: // Read to $80eeb8 |
| 391 | // return 0; |
| 446 | 392 | |
| 447 | | // case 0x15: // ???? |
| 448 | | // case 0x17: |
| 449 | | // case 0xf2: |
| 450 | | // break; |
| 393 | // default: |
| 394 | // logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_kb_cmd); |
| 395 | } |
| 451 | 396 | |
| 452 | | // default: |
| 453 | | // logerror("%06x: warning, writing to igs003_reg %02x = %02x\n", space.device().safe_pc(), m_kb_cmd, data); |
| 454 | | } |
| 397 | return 0; |
| 455 | 398 | } |
| 456 | 399 | |
| 457 | 400 | |
| 458 | 401 | |
| 402 | |
| 459 | 403 | void igs025_device::drgw2_protection_calculate_hold(int y, int z) |
| 460 | 404 | { |
| 461 | 405 | unsigned short old = m_kb_prot_hold; |
| r26058 | r26059 | |
| 504 | 448 | |
| 505 | 449 | |
| 506 | 450 | |
| 451 | void igs025_device::killbld_protection_calculate_hilo() |
| 452 | { |
| 453 | UINT8 source; |
| 507 | 454 | |
| 455 | m_kb_prot_hilo_select++; |
| 456 | |
| 457 | if (m_kb_prot_hilo_select > 0xeb) { |
| 458 | m_kb_prot_hilo_select = 0; |
| 459 | } |
| 460 | |
| 461 | source = m_kb_source_data[m_kb_region][m_kb_prot_hilo_select]; |
| 462 | |
| 463 | if (m_kb_prot_hilo_select & 1) |
| 464 | { |
| 465 | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | |
| 474 | void igs025_device::drgw2_protection_calculate_hilo() |
| 475 | { |
| 476 | UINT8 source; |
| 477 | |
| 478 | m_kb_prot_hilo_select++; |
| 479 | if (m_kb_prot_hilo_select > 0xeb) { |
| 480 | m_kb_prot_hilo_select = 0; |
| 481 | } |
| 482 | |
| 483 | source = m_kb_source_data[m_kb_region][m_kb_prot_hilo_select]; |
| 484 | |
| 485 | if (m_kb_prot_hilo_select & 1) |
| 486 | { |
| 487 | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | void igs025_device::olds_protection_calculate_hilo() // calculated in routine $12dbc2 in olds |
| 496 | { |
| 497 | UINT8 source; |
| 498 | |
| 499 | m_kb_prot_hilo_select++; |
| 500 | if (m_kb_prot_hilo_select > 0xeb) { |
| 501 | m_kb_prot_hilo_select = 0; |
| 502 | } |
| 503 | |
| 504 | source = m_kb_source_data[m_kb_region][m_kb_prot_hilo_select]; |
| 505 | |
| 506 | if (m_kb_prot_hilo_select & 1) // $8178fa |
| 507 | { |
| 508 | m_kb_prot_hilo = (m_kb_prot_hilo & 0x00ff) | (source << 8); // $8178d8 |
| 509 | } |
| 510 | else |
| 511 | { |
| 512 | m_kb_prot_hilo = (m_kb_prot_hilo & 0xff00) | (source << 0); // $8178d8 |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 508 | 519 | const device_type IGS025 = &device_creator<igs025_device>; |