src/mess/drivers/genesis.c
| r2310 | r2311 | |
| 53 | 53 | #include "includes/genesis.h" |
| 54 | 54 | #include "devices/cartslot.h" |
| 55 | 55 | #include "../../mame/drivers/megadriv.h" |
| 56 | #include "cpu/m68000/m68000.h" |
| 56 | 57 | |
| 57 | 58 | static int is_ssf2 = 0; |
| 58 | 59 | static int is_redcliff = 0; |
| r2310 | r2311 | |
| 73 | 74 | static int is_smb2 = 0; |
| 74 | 75 | static int is_kof98 = 0; |
| 75 | 76 | static int is_kaiju = 0; |
| 77 | static int is_chifi3 = 0; |
| 76 | 78 | |
| 77 | 79 | static UINT8 *genesis_sram; |
| 78 | 80 | static int genesis_sram_start; |
| r2310 | r2311 | |
| 200 | 202 | |
| 201 | 203 | genesis_sram = NULL; |
| 202 | 204 | genesis_sram_start = genesis_sram_len = genesis_sram_active = genesis_sram_readonly = 0; |
| 203 | | is_ssf2 = is_redcliff = is_radica = is_kof99 = is_soulb = is_mjlovr = is_squir = is_smous = is_elfwor = is_lionk2 = is_rx3 = is_bugsl = is_sbub = is_smb2 = is_kof98 = is_kaiju = 0; |
| 205 | is_ssf2 = is_redcliff = is_radica = is_kof99 = is_soulb = is_mjlovr = is_squir = is_smous = is_elfwor = is_lionk2 = is_rx3 = is_bugsl = is_sbub = is_smb2 = is_kof98 = is_kaiju = is_chifi3 = 0; |
| 204 | 206 | |
| 205 | 207 | rawROM = memory_region(REGION_CPU1); |
| 206 | 208 | ROM = rawROM /*+ 512 */; |
| r2310 | r2311 | |
| 368 | 370 | |
| 369 | 371 | if (length == 0x200000) |
| 370 | 372 | { |
| 373 | static unsigned char chifi3sig[] = { 0xb6, 0x16, 0x66, 0x00, 0x00, 0x4a}; |
| 374 | |
| 375 | if (!memcmp(&ROM[0x1780 + relocate],&chifi3sig[0],sizeof(chifi3sig))) |
| 376 | { |
| 377 | is_chifi3 = 1; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | |
| 382 | if (length == 0x200000) |
| 383 | { |
| 371 | 384 | static unsigned char lionk2sig[] = { 0x26, 0x79, 0x00, 0xff, 0x00, 0xf4}; |
| 372 | 385 | |
| 373 | 386 | if (!memcmp(&ROM[0x03c2+relocate],&lionk2sig[0],sizeof(lionk2sig))) |
| r2310 | r2311 | |
| 442 | 455 | memcpy(&ROM[0x400000],&ROM[0x000000],0x200000); |
| 443 | 456 | memcpy(&ROM[0x600000],&ROM[0x000000],0x200000); |
| 444 | 457 | } |
| 458 | |
| 445 | 459 | if (is_radica) |
| 446 | 460 | { |
| 447 | 461 | memcpy(&ROM[0x400000], &ROM[0], 0x400000); // keep a copy for later banking.. making use of huge ROM_REGION allocated to genesis driver |
| 448 | 462 | memcpy(&ROM[0x800000], &ROM[0], 0x400000); // wraparound banking (from hazemd code) |
| 449 | 463 | } |
| 464 | if (is_chifi3) |
| 465 | { |
| 466 | memcpy(ROM + 0x400000, ROM + 0x000000, 0x200000); |
| 467 | memcpy(ROM + 0x600000, ROM + 0x000000, 0x200000); |
| 468 | } |
| 450 | 469 | |
| 451 | 470 | |
| 452 | 471 | /* check if cart has battery save */ |
| r2310 | r2311 | |
| 585 | 604 | } |
| 586 | 605 | } |
| 587 | 606 | |
| 607 | |
| 608 | WRITE16_HANDLER( g_chifi3_bank_w ) |
| 609 | { |
| 610 | UINT8 *ROM = memory_region(REGION_CPU1); |
| 611 | |
| 612 | if (data==0xf100) // *hit player |
| 613 | { |
| 614 | int x; |
| 615 | for (x=0;x<0x100000;x+=0x10000) |
| 616 | { |
| 617 | memcpy(ROM + x, ROM + 0x410000, 0x10000); |
| 618 | } |
| 619 | } |
| 620 | else if (data==0xd700) // title screen.. |
| 621 | { |
| 622 | int x; |
| 623 | for (x=0;x<0x100000;x+=0x10000) |
| 624 | { |
| 625 | memcpy(ROM + x, ROM + 0x470000, 0x10000); |
| 626 | } |
| 627 | } |
| 628 | else if (data==0xd300) // character hits floor |
| 629 | { |
| 630 | int x; |
| 631 | for (x=0;x<0x100000;x+=0x10000) |
| 632 | { |
| 633 | memcpy(ROM + x, ROM + 0x430000, 0x10000); |
| 634 | } |
| 635 | } |
| 636 | else if (data==0x0000) |
| 637 | { |
| 638 | int x; |
| 639 | for (x=0;x<0x100000;x+=0x10000) |
| 640 | { |
| 641 | memcpy(ROM + x, ROM + 0x400000+x, 0x10000); |
| 642 | } |
| 643 | } |
| 644 | else |
| 645 | { |
| 646 | logerror("%06x chifi3, bankw? %04x %04x\n",activecpu_get_pc(), offset,data); |
| 647 | } |
| 648 | |
| 649 | } |
| 650 | |
| 651 | READ16_HANDLER( g_chifi3_prot_r ) |
| 652 | { |
| 653 | UINT32 retdat; |
| 654 | |
| 655 | /* not 100% correct, there may be some relationship between the reads here |
| 656 | and the writes made at the start of the game.. */ |
| 657 | |
| 658 | /* |
| 659 | 04dc10 chifi3, prot_r? 2800 |
| 660 | 04cefa chifi3, prot_r? 65262 |
| 661 | */ |
| 662 | |
| 663 | if (activecpu_get_pc()==0x01782) // makes 'VS' screen appear |
| 664 | { |
| 665 | retdat = activecpu_get_reg(M68K_D3)&0xff; |
| 666 | retdat<<=8; |
| 667 | return retdat; |
| 668 | } |
| 669 | else if (activecpu_get_pc()==0x1c24) // background gfx etc. |
| 670 | { |
| 671 | retdat = activecpu_get_reg(M68K_D3)&0xff; |
| 672 | retdat<<=8; |
| 673 | return retdat; |
| 674 | } |
| 675 | else if (activecpu_get_pc()==0x10c4a) // unknown |
| 676 | { |
| 677 | return mame_rand(machine); |
| 678 | } |
| 679 | else if (activecpu_get_pc()==0x10c50) // unknown |
| 680 | { |
| 681 | return mame_rand(machine); |
| 682 | } |
| 683 | else if (activecpu_get_pc()==0x10c52) // relates to the game speed.. |
| 684 | { |
| 685 | retdat = activecpu_get_reg(M68K_D4)&0xff; |
| 686 | retdat<<=8; |
| 687 | return retdat; |
| 688 | } |
| 689 | else if (activecpu_get_pc()==0x061ae) |
| 690 | { |
| 691 | retdat = activecpu_get_reg(M68K_D3)&0xff; |
| 692 | retdat<<=8; |
| 693 | return retdat; |
| 694 | } |
| 695 | else if (activecpu_get_pc()==0x061b0) |
| 696 | { |
| 697 | retdat = activecpu_get_reg(M68K_D3)&0xff; |
| 698 | retdat<<=8; |
| 699 | return retdat; |
| 700 | } |
| 701 | else |
| 702 | { |
| 703 | logerror("%06x chifi3, prot_r? %04x\n",activecpu_get_pc(), offset); |
| 704 | } |
| 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | |
| 710 | // Kaiju? (Pokemon Stadium) handler from HazeMD |
| 588 | 711 | static WRITE16_HANDLER( g_kaiju_bank_w ) |
| 589 | 712 | { |
| 590 | 713 | UINT8 *ROM = memory_region(REGION_CPU1); |
| r2310 | r2311 | |
| 802 | 925 | { |
| 803 | 926 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x700000, 0x7fffff, 0, 0, g_kaiju_bank_w ); |
| 804 | 927 | } |
| 928 | if (is_chifi3) |
| 929 | { |
| 930 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0x400000, 0x4fffff, 0, 0, g_chifi3_prot_r ); |
| 931 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x600000, 0x6fffff, 0, 0, g_chifi3_bank_w ); |
| 805 | 932 | |
| 933 | } |
| 934 | |
| 806 | 935 | if (is_radica) |
| 807 | 936 | { |
| 808 | 937 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xa13000, 0xa1307f, 0, 0, radica_bank_select ); |