trunk/src/mame/machine/igs025.c
| r26059 | r26060 | |
| 196 | 196 | case 0x26: |
| 197 | 197 | case 0x27: |
| 198 | 198 | m_kb_ptr++; |
| 199 | | olds_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 199 | killbld_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 200 | 200 | break; |
| 201 | 201 | |
| 202 | 202 | // default: |
| r26059 | r26060 | |
| 229 | 229 | case 0x26: |
| 230 | 230 | case 0x27: |
| 231 | 231 | m_kb_ptr++; |
| 232 | | drgw2_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 232 | killbld_protection_calculate_hold(m_kb_cmd & 0x0f, data & 0xff); |
| 233 | 233 | break; |
| 234 | 234 | |
| 235 | 235 | // case 0x08: // Used only on init.. |
| r26059 | r26060 | |
| 265 | 265 | case 0x01: |
| 266 | 266 | return m_kb_reg & 0x7f; |
| 267 | 267 | |
| 268 | case 0x02: |
| 269 | return m_olds_bs | 0x80; |
| 270 | |
| 271 | case 0x03: |
| 272 | return m_kb_cmd3; |
| 273 | |
| 268 | 274 | case 0x05: |
| 269 | 275 | { |
| 270 | 276 | switch (m_kb_ptr) |
| r26059 | r26060 | |
| 285 | 291 | return 0x3f00 | BITSWAP8(m_kb_prot_hold, 5, 2, 9, 7, 10, 13, 12, 15); |
| 286 | 292 | } |
| 287 | 293 | |
| 288 | | return 0; |
| 294 | return 0x3f00; |
| 295 | //return 0; |
| 289 | 296 | } |
| 290 | 297 | |
| 291 | 298 | case 0x40: |
| r26059 | r26060 | |
| 294 | 301 | |
| 295 | 302 | // default: |
| 296 | 303 | // logerror("%06X: ASIC25 R CMD %X\n", space.device().safe_pc(), m_kb_cmd); |
| 297 | | } |
| 298 | | } |
| 299 | 304 | |
| 300 | | return 0; |
| 301 | | } |
| 305 | // drgw2 notes |
| 306 | // case 0x13: // Read to $80eeb8 |
| 307 | // case 0x1f: // Read to $80eeb8 |
| 308 | // case 0xf4: // Read to $80eeb8 |
| 309 | // case 0xf6: // Read to $80eeb8 |
| 310 | // case 0xf8: // Read to $80eeb8 |
| 311 | // return 0; |
| 302 | 312 | |
| 313 | // default: |
| 314 | // logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_kb_cmd); |
| 303 | 315 | |
| 304 | | READ16_MEMBER(igs025_device::olds_r) |
| 305 | | { |
| 306 | | if (offset) |
| 307 | | { |
| 308 | | switch (m_kb_cmd) |
| 309 | | { |
| 310 | | case 0x01: |
| 311 | | return m_kb_reg & 0x7f; |
| 312 | 316 | |
| 313 | | case 0x02: |
| 314 | | return m_olds_bs | 0x80; |
| 315 | | |
| 316 | | case 0x03: |
| 317 | | return m_kb_cmd3; |
| 318 | | |
| 319 | | case 0x05: |
| 320 | | { |
| 321 | | switch (m_kb_ptr) |
| 322 | | { |
| 323 | | case 1: |
| 324 | | return 0x3f00 | ((m_kb_game_id >> 0) & 0xff); |
| 325 | | |
| 326 | | case 2: |
| 327 | | return 0x3f00 | ((m_kb_game_id >> 8) & 0xff); |
| 328 | | |
| 329 | | case 3: |
| 330 | | return 0x3f00 | ((m_kb_game_id >> 16) & 0xff); |
| 331 | | |
| 332 | | case 4: |
| 333 | | return 0x3f00 | ((m_kb_game_id >> 24) & 0xff); |
| 334 | | |
| 335 | | |
| 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 | | } |
| 342 | 317 | } |
| 343 | | |
| 344 | | case 0x40: |
| 345 | | olds_protection_calculate_hilo(); |
| 346 | | return 0; // unused? |
| 347 | | } |
| 348 | 318 | } |
| 349 | 319 | |
| 350 | 320 | return 0; |
| 351 | 321 | } |
| 352 | 322 | |
| 353 | 323 | |
| 354 | | READ16_MEMBER(igs025_device::drgw2_d80000_protection_r) |
| 355 | | { |
| 356 | | switch (m_kb_cmd) |
| 357 | | { |
| 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; |
| 380 | | } |
| 381 | | |
| 382 | | case 0x40: |
| 383 | | drgw2_protection_calculate_hilo(); |
| 384 | | return 0; |
| 385 | | |
| 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; |
| 392 | | |
| 393 | | // default: |
| 394 | | // logerror("%06x: warning, reading with igs003_reg = %02x\n", space.device().safe_pc(), m_kb_cmd); |
| 395 | | } |
| 396 | | |
| 397 | | return 0; |
| 398 | | } |
| 399 | | |
| 400 | | |
| 401 | | |
| 402 | | |
| 403 | | void igs025_device::drgw2_protection_calculate_hold(int y, int z) |
| 404 | | { |
| 405 | | unsigned short old = m_kb_prot_hold; |
| 406 | | |
| 407 | | m_kb_prot_hold = ((old << 1) | (old >> 15)); |
| 408 | | |
| 409 | | m_kb_prot_hold ^= 0x2bad; |
| 410 | | m_kb_prot_hold ^= BIT(z, y); |
| 411 | | m_kb_prot_hold ^= BIT(old, 7) << 0; |
| 412 | | m_kb_prot_hold ^= BIT(~old, 13) << 4; |
| 413 | | m_kb_prot_hold ^= BIT(old, 3) << 11; |
| 414 | | |
| 415 | | m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1; |
| 416 | | } |
| 417 | | |
| 418 | | |
| 419 | | void igs025_device::olds_protection_calculate_hold(int y, int z) // calculated in routine $12dbc2 in olds |
| 420 | | { |
| 421 | | unsigned short old = m_kb_prot_hold; |
| 422 | | |
| 423 | | m_kb_prot_hold = ((old << 1) | (old >> 15)); |
| 424 | | |
| 425 | | m_kb_prot_hold ^= 0x2bad; |
| 426 | | m_kb_prot_hold ^= BIT(z, y); |
| 427 | | m_kb_prot_hold ^= BIT(old, 7) << 0; |
| 428 | | m_kb_prot_hold ^= BIT(~old, 13) << 4; |
| 429 | | m_kb_prot_hold ^= BIT(old, 3) << 11; |
| 430 | | |
| 431 | | m_kb_prot_hold ^= (m_kb_prot_hilo & ~0x0408) << 1; // $81790c |
| 432 | | } |
| 433 | | |
| 434 | 324 | void igs025_device::killbld_protection_calculate_hold(int y, int z) |
| 435 | 325 | { |
| 436 | 326 | unsigned short old = m_kb_prot_hold; |
| r26059 | r26060 | |
| 471 | 361 | } |
| 472 | 362 | |
| 473 | 363 | |
| 474 | | void igs025_device::drgw2_protection_calculate_hilo() |
| 475 | | { |
| 476 | | UINT8 source; |
| 477 | 364 | |
| 478 | | m_kb_prot_hilo_select++; |
| 479 | | if (m_kb_prot_hilo_select > 0xeb) { |
| 480 | | m_kb_prot_hilo_select = 0; |
| 481 | | } |
| 482 | 365 | |
| 483 | | source = m_kb_source_data[m_kb_region][m_kb_prot_hilo_select]; |
| 484 | 366 | |
| 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 | 367 | |
| 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 | | |
| 519 | 368 | const device_type IGS025 = &device_creator<igs025_device>; |
trunk/src/mame/machine/igs025.h
| r26059 | r26060 | |
| 13 | 13 | public: |
| 14 | 14 | igs025_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 15 | 15 | |
| 16 | | DECLARE_WRITE16_MEMBER( killbld_igs025_prot_w ); |
| 17 | 16 | DECLARE_READ16_MEMBER( killbld_igs025_prot_r ); |
| 18 | 17 | // use setters instead of making public? |
| 19 | 18 | const UINT8 (*m_kb_source_data)[0xec]; |
| r26059 | r26060 | |
| 24 | 23 | igs025_execute_external m_execute_external; |
| 25 | 24 | static void set_external_cb(device_t &device,igs025_execute_external newcb); |
| 26 | 25 | |
| 27 | | |
| 28 | | DECLARE_READ16_MEMBER( olds_r ); |
| 29 | 26 | DECLARE_WRITE16_MEMBER( olds_w ); |
| 30 | | //const UINT8 *m_kb_prot_hilo_source2; |
| 31 | | |
| 32 | | DECLARE_READ16_MEMBER( drgw2_d80000_protection_r ); |
| 33 | 27 | DECLARE_WRITE16_MEMBER( drgw2_d80000_protection_w ); |
| 34 | | |
| 28 | DECLARE_WRITE16_MEMBER( killbld_igs025_prot_w); |
| 35 | 29 | |
| 30 | |
| 36 | 31 | protected: |
| 37 | 32 | virtual void device_config_complete(); |
| 38 | 33 | virtual void device_validity_check(validity_checker &valid) const; |
| r26059 | r26060 | |
| 58 | 53 | UINT16 m_olds_bs; |
| 59 | 54 | UINT16 m_kb_cmd3; |
| 60 | 55 | |
| 61 | | |
| 62 | | void olds_protection_calculate_hilo(); |
| 63 | | void olds_protection_calculate_hold(int y, int z); |
| 64 | | |
| 65 | | |
| 66 | | |
| 67 | | |
| 68 | | |
| 69 | | |
| 70 | | |
| 71 | | void drgw2_protection_calculate_hilo(); |
| 72 | | void drgw2_protection_calculate_hold(int y, int z); |
| 73 | | |
| 74 | 56 | }; |
| 75 | 57 | |
| 76 | 58 | |