src/mess/machine/nes_mmc.c
| r5944 | r5945 | |
| 12 | 12 | |
| 13 | 13 | Known issues on specific mappers: |
| 14 | 14 | |
| 15 | | * 001 AD&D Hillsfar seems to be broken. |
| 15 | * 001 AD&D Hillsfar and Bill & Ted are broken. We need to ignore the case of writes happening on 2 |
| 16 | consecutive CPU cycles because these games use dirty tricks to reset counters (see note in mapper1_w) |
| 17 | * 001, 155 We don't handle (yet) WRAM enable/disable bit |
| 16 | 18 | * 002, 003 Bus conflict? |
| 17 | 19 | * 005 has some issues (e.g. Just Breed is not working), RAM banking needs hardware flags to determine size |
| 18 | 20 | * 015 Shanghai Tycoon has corrupted graphics |
| r5944 | r5945 | |
| 27 | 29 | * 039 Study n Game 32 in 1 misses keyboard and starts differently than in NEStopia |
| 28 | 30 | * 040 is not dealing correctly 0x6000-0x7fff (this got broken long ago) |
| 29 | 31 | * 042 Ai Senshi Nicol has broken graphics (our Mapper 42 implementation does not handle CHR banks) |
| 30 | | * 045 is not fully working |
| 31 | | * 047 selection menu is totally glitched (unique regression left from 0.130u2 changes) |
| 32 | 32 | * 051 only half of the games work |
| 33 | 33 | * 064 has some IRQ problems - see Skull & Crossbones. Klax has broken graphics. |
| 34 | 34 | * 065 Spartan X 2 has various glitches |
| 35 | 35 | * 067 display issues, but vrom fixed |
| 36 | 36 | * 071 Fire Hawk is not properly working (it requires one hack to support both boards using this mapper) |
| 37 | 37 | * 072, 086, 092 lack samples support (maybe others as well) |
| 38 | | * 074 is only preliminar (no correct CHR swap) |
| 39 | 38 | * 077 Requires 4-screen mirroring. Currently, it is very glitchy |
| 40 | 39 | * 078 Cosmo Carrier is not working (it requires one hack to support both boards using this mapper). |
| 41 | 40 | also, we lack NT mirroring |
| r5944 | r5945 | |
| 131 | 130 | } name_table; |
| 132 | 131 | |
| 133 | 132 | /* Global variables */ |
| 134 | | static int prg_mask; |
| 135 | | |
| 136 | 133 | static chr_bank chr_map[8]; //quick banking structure, because some of this changes multiple times per scanline! |
| 137 | 134 | static name_table nt_page[4]; //quick banking structure for a maximum of 4K of RAM/ROM/ExRAM |
| 138 | 135 | |
| r5944 | r5945 | |
| 149 | 146 | read8_space_func mmc_read_mid; |
| 150 | 147 | write8_space_func mmc_write; |
| 151 | 148 | |
| 152 | | static int vrom_bank[16]; |
| 153 | 149 | static int mult1, mult2; |
| 154 | 150 | |
| 155 | 151 | /* common local variables */ |
| 156 | | static UINT8 mmc_chr_source; // this is set at init to CHRROM or CHRRAM. a few mappers can swap between |
| 157 | | // the two (this is done in the specific handlers) |
| 158 | | static UINT8 mmc_cmd1, mmc_cmd2; // these represent registers where the mapper writes important values |
| 159 | | static UINT8 mmc_bank_latch1, mmc_bank_latch2; // some mappers change banks by writing subsets of these bits |
| 152 | static UINT8 mmc_chr_source; // This is set at init to CHRROM or CHRRAM. a few mappers can swap between |
| 153 | // the two (this is done in the specific handlers). |
| 160 | 154 | |
| 155 | static UINT8 mmc_cmd1, mmc_cmd2; // These represent registers where the mapper writes important values |
| 156 | static UINT8 mmc_count; // This is used as counter in mappers like 1 and 45 |
| 157 | |
| 158 | static int prg_bank[4]; // Many mappers writes only some bits of the selected bank (for both PRG and CHR), |
| 159 | static int vrom_bank[16]; // hence these are handy to latch bank values. |
| 160 | |
| 161 | |
| 161 | 162 | // FIXME: mapper specific variables should be unified as much as possible to make easier future implementation of save states |
| 162 | 163 | /* Local variables (a few more are defined just before handlers that use them...) */ |
| 163 | | static int MMC1_Size_16k; |
| 164 | | static int MMC1_High; |
| 165 | | static int MMC1_reg; |
| 166 | | static int MMC1_reg_count; |
| 167 | | static int MMC1_Switch_Low, MMC1_SizeVrom_4k; |
| 168 | | static int MMC1_bank1, MMC1_bank2, MMC1_bank3, MMC1_bank4; |
| 169 | | static int MMC1_extended_bank; |
| 170 | | static int MMC1_extended_base; |
| 171 | | static int MMC1_extended_swap; |
| 172 | 164 | |
| 173 | | static int MMC2_bank0, MMC2_bank0_hi, MMC2_bank0_latch, MMC2_bank1, MMC2_bank1_hi, MMC2_bank1_latch; |
| 165 | static UINT8 MMC1_regs[4]; |
| 174 | 166 | |
| 167 | static UINT8 MMC2_regs[4]; // these replace bank0/bank0_hi/bank1/bank1_hi |
| 168 | |
| 175 | 169 | static int MMC3_cmd; |
| 176 | | static int MMC3_prg0, MMC3_prg1; |
| 177 | | static int MMC3_chr[6]; |
| 178 | | static int MMC3_prg_base, MMC3_prg_mask; |
| 179 | | static int MMC3_chr_base, MMC3_chr_mask; |
| 180 | 170 | UINT8* extended_ntram; |
| 181 | 171 | |
| 172 | static int mmc_prg_base, mmc_prg_mask; // MMC3 based multigame carts select a block of banks by using these (and then act like normal MMC3), |
| 173 | static int mmc_chr_base, mmc_chr_mask; // while MMC3 and clones (mapper 118 & 119) simply set them as 0 and 0xff resp. |
| 174 | |
| 182 | 175 | static int MMC5_rom_bank_mode; |
| 183 | 176 | static int MMC5_vrom_bank_mode; |
| 184 | 177 | static int MMC5_vram_protect; |
| r5944 | r5945 | |
| 188 | 181 | UINT8 MMC5_vram[0x400]; |
| 189 | 182 | int MMC5_vram_control; |
| 190 | 183 | |
| 191 | | static int mapper45_data[4], mapper45_cmd; |
| 184 | static UINT8 mapper45_reg[4]; |
| 185 | static UINT8 mapper51_reg[3]; |
| 186 | static UINT8 mapper64_reg[11]; |
| 187 | static UINT8 mapper83_reg[10]; |
| 188 | static UINT8 mapper83_low_reg[4]; |
| 189 | static UINT8 mapper95_reg[4]; |
| 190 | static UINT8 mapper115_reg[4]; |
| 191 | static UINT8 txc_reg[4]; // used by mappers 132, 172 & 173 |
| 192 | static UINT8 subor_reg[4]; // used by mappers 166 & 167 |
| 193 | static UINT8 sachen_reg[8]; // used by mappers 137, 138, 139 & 141 |
| 194 | static UINT8 mapper12_reg; |
| 195 | static UINT8 map52_reg_written; |
| 196 | static UINT8 map114_reg, map114_reg_enabled; |
| 192 | 197 | |
| 193 | | static int mapper64_data[0x10], mapper64_cmd; |
| 194 | | |
| 195 | | static int mapper83_data[10]; |
| 196 | | static int mapper83_low_data[4]; |
| 197 | | |
| 198 | 198 | static int mapper_warning; |
| 199 | 199 | |
| 200 | 200 | static emu_timer *nes_irq_timer; |
| r5944 | r5945 | |
| 693 | 693 | |
| 694 | 694 | *************************************************************/ |
| 695 | 695 | |
| 696 | | static WRITE8_HANDLER( mapper1_w ) |
| 696 | static void MMC1_set_prg( running_machine *machine ) |
| 697 | 697 | { |
| 698 | | int reg; |
| 698 | UINT8 prg_mode, prg_offset; |
| 699 | 699 | |
| 700 | | /* Find which register we are dealing with */ |
| 700 | prg_mode = MMC1_regs[0] & 0x0c; |
| 701 | /* prg_mode&0x8 determines bank size: 32k (if 0) or 16k (if 1)? when in 16k mode, |
| 702 | prg_mode&0x4 determines which half of the PRG space we can swap: if it is 4, |
| 703 | MMC1_regs[3] sets banks at 0x8000; if it is 0, MMC1_regs[3] sets banks at 0xc000. */ |
| 704 | |
| 705 | prg_offset = MMC1_regs[1] & 0x10; |
| 706 | /* In principle, MMC1_regs[2]&0x10 might affect "extended" banks as well, when chr_mode=1. |
| 707 | However, quoting Disch's docs: When in 4k CHR mode, 0x10 in both $A000 and $C000 *must* be |
| 708 | set to the same value, or else pages will constantly be swapped as graphics render! |
| 709 | Hence, we use only MMC1_regs[1]&0x10 for prg_offset */ |
| 710 | |
| 711 | switch (prg_mode) |
| 712 | { |
| 713 | case 0x00: |
| 714 | case 0x04: |
| 715 | prg32(machine, prg_offset + MMC1_regs[3]); |
| 716 | break; |
| 717 | case 0x08: |
| 718 | prg16_89ab(machine, prg_offset + 0); |
| 719 | prg16_cdef(machine, prg_offset + MMC1_regs[3]); |
| 720 | break; |
| 721 | case 0x0c: |
| 722 | prg16_89ab(machine, prg_offset + MMC1_regs[3]); |
| 723 | prg16_cdef(machine, prg_offset + 0x0f); |
| 724 | break; |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | static void MMC1_set_chr( running_machine *machine ) |
| 729 | { |
| 730 | UINT8 chr_mode = MMC1_regs[0] & 0x10; |
| 731 | |
| 732 | if (nes.chr_chunks) |
| 733 | { |
| 734 | if (chr_mode) |
| 735 | { |
| 736 | chr4_0(machine, MMC1_regs[1] & 0x1f, CHRROM); |
| 737 | chr4_4(machine, MMC1_regs[2] & 0x1f, CHRROM); |
| 738 | } |
| 739 | else |
| 740 | chr8(machine, (MMC1_regs[1] & 0x1f) >> 1, CHRROM); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | static WRITE8_HANDLER( mapper1_w ) |
| 745 | { |
| 701 | 746 | /* Note that there is only one latch and shift counter, shared amongst the 4 regs */ |
| 702 | 747 | /* Space Shuttle will not work if they have independent variables. */ |
| 703 | | reg = (offset >> 13); |
| 748 | LOG_MMC(("mapper1_w offset: %04x, data: %02x\n", offset, data)); |
| 704 | 749 | |
| 750 | |
| 751 | /* here we would need to add an if(cpu_cycles_passed>1) test, and |
| 752 | if requirement is not met simply return without writing anything. |
| 753 | AD&D Hillsfar and Bill & Ted rely on this behavior!! */ |
| 705 | 754 | if (data & 0x80) |
| 706 | 755 | { |
| 707 | | MMC1_reg_count = 0; |
| 708 | | MMC1_reg = 0; |
| 756 | mmc_count = 0; |
| 757 | mmc_cmd1 = 0; |
| 709 | 758 | |
| 710 | | /* Set these to their defaults - needed for Robocop 3, Dynowars */ |
| 711 | | MMC1_Size_16k = 1; |
| 712 | | MMC1_Switch_Low = 1; |
| 713 | | /* TODO: should we switch banks at this time also? */ |
| 759 | /* Set reg at 0x8000 to size 16k and lower half swap - needed for Robocop 3, Dynowars */ |
| 760 | MMC1_regs[0] |= 0x0c; |
| 761 | MMC1_set_prg(space->machine); |
| 762 | |
| 714 | 763 | LOG_MMC(("=== MMC1 regs reset to default\n")); |
| 715 | 764 | return; |
| 716 | 765 | } |
| 717 | 766 | |
| 718 | | if (MMC1_reg_count < 5) |
| 767 | if (mmc_count < 5) |
| 719 | 768 | { |
| 720 | | if (MMC1_reg_count == 0) MMC1_reg = 0; |
| 721 | | MMC1_reg >>= 1; |
| 722 | | MMC1_reg |= (data & 0x01) ? 0x10 : 0x00; |
| 723 | | MMC1_reg_count ++; |
| 769 | if (mmc_count == 0) mmc_cmd1 = 0; |
| 770 | mmc_cmd1 >>= 1; |
| 771 | mmc_cmd1 |= (data & 0x01) ? 0x10 : 0x00; |
| 772 | mmc_count++; |
| 724 | 773 | } |
| 725 | 774 | |
| 726 | | if (MMC1_reg_count == 5) |
| 775 | if (mmc_count == 5) |
| 727 | 776 | { |
| 728 | | // LOG_MMC((" MMC1 reg#%02x val:%02x\n", offset, MMC1_reg)); |
| 729 | | switch (reg) |
| 777 | switch (offset & 0x6000) /* Which reg shall we write to? */ |
| 730 | 778 | { |
| 731 | | case 0: |
| 732 | | MMC1_Switch_Low = MMC1_reg & 0x04; |
| 733 | | MMC1_Size_16k = MMC1_reg & 0x08; |
| 779 | case 0x0000: |
| 780 | MMC1_regs[0] = mmc_cmd1; |
| 734 | 781 | |
| 735 | | switch (MMC1_reg & 0x03) |
| 736 | | { |
| 737 | | case 0: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 738 | | case 1: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 739 | | case 2: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 740 | | case 3: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 741 | | } |
| 742 | | |
| 743 | | MMC1_SizeVrom_4k = (MMC1_reg & 0x10); |
| 744 | | LOG_MMC((" MMC1 reg #1 val:%02x\n", MMC1_reg)); |
| 745 | | LOG_MMC(("\t\tBank Size: ")); |
| 746 | | if (MMC1_Size_16k) |
| 747 | | LOG_MMC(("16k\n")); |
| 748 | | else LOG_MMC(("32k\n")); |
| 749 | | |
| 750 | | LOG_MMC(("\t\tBank Select: ")); |
| 751 | | if (MMC1_Switch_Low) |
| 752 | | LOG_MMC(("$8000\n")); |
| 753 | | else LOG_MMC(("$C000\n")); |
| 754 | | |
| 755 | | LOG_MMC(("\t\tVROM Bankswitch Size Select: ")); |
| 756 | | if (MMC1_SizeVrom_4k) |
| 757 | | LOG_MMC(("4k\n")); |
| 758 | | else LOG_MMC(("8k\n")); |
| 759 | | |
| 760 | | LOG_MMC(("\t\tMirroring: %d\n", MMC1_reg & 0x03)); |
| 761 | | break; |
| 762 | | |
| 763 | | case 1: |
| 764 | | MMC1_extended_bank = (MMC1_extended_bank & ~0x01) | ((MMC1_reg & 0x10) >> 4); |
| 765 | | if (MMC1_extended == 2) |
| 766 | | { |
| 767 | | /* MMC1_SizeVrom_4k determines if we use the special 256k bank register */ |
| 768 | | if (!MMC1_SizeVrom_4k) |
| 769 | | { |
| 770 | | /* Pick 1st or 4th 256k bank */ |
| 771 | | MMC1_extended_base = 0xc0000 * (MMC1_extended_bank & 0x01) + 0x10000; |
| 772 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 773 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 774 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 775 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 776 | | LOG_MMC(("MMC1_extended 1024k bank (no reg) select: %02x\n", MMC1_extended_bank)); |
| 777 | | } |
| 778 | | else |
| 779 | | { |
| 780 | | /* Set 256k bank based on the 256k bank select register */ |
| 781 | | if (MMC1_extended_swap) |
| 782 | | { |
| 783 | | MMC1_extended_base = 0x40000 * MMC1_extended_bank + 0x10000; |
| 784 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 785 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 786 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 787 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 788 | | LOG_MMC(("MMC1_extended 1024k bank (reg 1) select: %02x\n", MMC1_extended_bank)); |
| 789 | | MMC1_extended_swap = 0; |
| 790 | | } |
| 791 | | else MMC1_extended_swap = 1; |
| 792 | | } |
| 793 | | } |
| 794 | | else if (MMC1_extended == 1 && nes.chr_chunks == 0) |
| 795 | | { |
| 796 | | /* Pick 1st or 2nd 256k bank */ |
| 797 | | MMC1_extended_base = 0x40000 * (MMC1_extended_bank & 0x01) + 0x10000; |
| 798 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 799 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 800 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 801 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 802 | | LOG_MMC(("MMC1_extended 512k bank select: %02x\n", MMC1_extended_bank & 0x01)); |
| 803 | | } |
| 804 | | else if (nes.chr_chunks > 0) |
| 805 | | { |
| 806 | | // LOG_MMC(("MMC1_SizeVrom_4k: %02x bank:%02x\n", MMC1_SizeVrom_4k, MMC1_reg)); |
| 807 | | |
| 808 | | if (!MMC1_SizeVrom_4k) |
| 809 | | { |
| 810 | | /* we take care of the actual bank size when we divide bank by 2 in the chr8 call */ |
| 811 | | //int bank = MMC1_reg & (nes.chr_chunks - 1); // this breaks Pinball Quest |
| 812 | | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 813 | | chr8(space->machine, bank >> 1, CHRROM); |
| 814 | | LOG_MMC(("MMC1 8k VROM switch: %02x\n", MMC1_reg)); |
| 815 | | } |
| 816 | | else |
| 817 | | { |
| 818 | | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 819 | | chr4_0(space->machine, bank, CHRROM); |
| 820 | | LOG_MMC(("MMC1 4k VROM switch (low): %02x\n", MMC1_reg)); |
| 821 | | } |
| 822 | | } |
| 823 | | break; |
| 824 | | case 2: |
| 825 | | // LOG_MMC(("MMC1_Reg_2: %02x\n",MMC1_Reg_2)); |
| 826 | | MMC1_extended_bank = (MMC1_extended_bank & ~0x02) | ((MMC1_reg & 0x10) >> 3); |
| 827 | | if (MMC1_extended == 2 && MMC1_SizeVrom_4k) |
| 828 | | { |
| 829 | | if (MMC1_extended_swap) |
| 830 | | { |
| 831 | | /* Set 256k bank based on the 256k bank select register */ |
| 832 | | MMC1_extended_base = 0x40000 * MMC1_extended_bank + 0x10000; |
| 833 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 834 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 835 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 836 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 837 | | LOG_MMC(("MMC1_extended 1024k bank (reg 2) select: %02x\n", MMC1_extended_bank)); |
| 838 | | MMC1_extended_swap = 0; |
| 839 | | } |
| 840 | | else |
| 841 | | MMC1_extended_swap = 1; |
| 842 | | } |
| 843 | | if (MMC1_SizeVrom_4k) |
| 844 | | { |
| 845 | | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 846 | | chr4_4(space->machine, bank, CHRROM); |
| 847 | | LOG_MMC(("MMC1 4k VROM switch (high): %02x\n", MMC1_reg)); |
| 848 | | } |
| 849 | | break; |
| 850 | | case 3: |
| 851 | | /* Switching 1 32k bank of PRG ROM */ |
| 852 | | MMC1_reg &= 0x0f; |
| 853 | | if (!MMC1_Size_16k) |
| 854 | | { |
| 855 | | int bank = MMC1_reg & (nes.prg_chunks - 1); |
| 856 | | |
| 857 | | MMC1_bank1 = bank * 0x4000; |
| 858 | | MMC1_bank2 = bank * 0x4000 + 0x2000; |
| 859 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 860 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 861 | | if (!MMC1_extended) |
| 862 | | { |
| 863 | | MMC1_bank3 = bank * 0x4000 + 0x4000; |
| 864 | | MMC1_bank4 = bank * 0x4000 + 0x6000; |
| 865 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 866 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 867 | | } |
| 868 | | LOG_MMC(("MMC1 32k bank select: %02x\n", MMC1_reg)); |
| 869 | | } |
| 870 | | else |
| 871 | | /* Switching one 16k bank */ |
| 872 | | { |
| 873 | | if (MMC1_Switch_Low) |
| 874 | | { |
| 875 | | int bank = MMC1_reg & (nes.prg_chunks - 1); |
| 876 | | |
| 877 | | MMC1_bank1 = bank * 0x4000; |
| 878 | | MMC1_bank2 = bank * 0x4000 + 0x2000; |
| 879 | | |
| 880 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 881 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 882 | | if (!MMC1_extended) |
| 883 | | { |
| 884 | | MMC1_bank3 = MMC1_High; |
| 885 | | MMC1_bank4 = MMC1_High + 0x2000; |
| 886 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 887 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 888 | | } |
| 889 | | LOG_MMC(("MMC1 16k-low bank select: %02x\n", MMC1_reg)); |
| 890 | | } |
| 891 | | else |
| 892 | | { |
| 893 | | int bank = MMC1_reg & (nes.prg_chunks - 1); |
| 894 | | |
| 895 | | if (!MMC1_extended) |
| 896 | | { |
| 897 | | |
| 898 | | MMC1_bank1 = 0; |
| 899 | | MMC1_bank2 = 0x2000; |
| 900 | | MMC1_bank3 = bank * 0x4000; |
| 901 | | MMC1_bank4 = bank * 0x4000 + 0x2000; |
| 902 | | |
| 903 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 904 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 905 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 906 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 907 | | } |
| 908 | | LOG_MMC(("MMC1 16k-high bank select: %02x\n", MMC1_reg)); |
| 909 | | } |
| 910 | | } |
| 911 | | |
| 912 | | LOG_MMC(("-- page1: %06x\n", MMC1_bank1)); |
| 913 | | LOG_MMC(("-- page2: %06x\n", MMC1_bank2)); |
| 914 | | LOG_MMC(("-- page3: %06x\n", MMC1_bank3)); |
| 915 | | LOG_MMC(("-- page4: %06x\n", MMC1_bank4)); |
| 916 | | break; |
| 782 | switch (MMC1_regs[0] & 0x03) |
| 783 | { |
| 784 | case 0: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 785 | case 1: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 786 | case 2: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 787 | case 3: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 788 | } |
| 789 | MMC1_set_chr(space->machine); |
| 790 | MMC1_set_prg(space->machine); |
| 791 | break; |
| 792 | case 0x2000: |
| 793 | MMC1_regs[1] = mmc_cmd1; |
| 794 | MMC1_set_chr(space->machine); |
| 795 | MMC1_set_prg(space->machine); |
| 796 | break; |
| 797 | case 0x4000: |
| 798 | MMC1_regs[2] = mmc_cmd1; |
| 799 | MMC1_set_chr(space->machine); |
| 800 | break; |
| 801 | case 0x6000: |
| 802 | MMC1_regs[3] = mmc_cmd1; |
| 803 | MMC1_set_prg(space->machine); |
| 804 | break; |
| 917 | 805 | } |
| 918 | | MMC1_reg_count = 0; |
| 806 | |
| 807 | mmc_count = 0; |
| 919 | 808 | } |
| 920 | 809 | } |
| 921 | 810 | |
| r5944 | r5945 | |
| 932 | 821 | |
| 933 | 822 | static WRITE8_HANDLER( mapper2_w ) |
| 934 | 823 | { |
| 824 | LOG_MMC(("mapper2_w offset: %04x, data: %02x\n", offset, data)); |
| 825 | |
| 935 | 826 | prg16_89ab(space->machine, data); |
| 936 | 827 | } |
| 937 | 828 | |
| r5944 | r5945 | |
| 951 | 842 | |
| 952 | 843 | static WRITE8_HANDLER( mapper3_w ) |
| 953 | 844 | { |
| 845 | LOG_MMC(("mapper3_w offset: %04x, data: %02x\n", offset, data)); |
| 846 | |
| 954 | 847 | chr8(space->machine, data, CHRROM); |
| 955 | 848 | } |
| 956 | 849 | |
| r5944 | r5945 | |
| 968 | 861 | |
| 969 | 862 | *************************************************************/ |
| 970 | 863 | |
| 971 | | static void mapper4_set_prg( running_machine *machine ) |
| 864 | /* Many multigame carts based on MMC3 works as follows: they select a |
| 865 | block of banks by writing in the 0x6000-0x7fff range and then they |
| 866 | operate like a common MMC3 board on that specific block. To emulate this |
| 867 | we use the concept of bases and masks. Original MMC3 boards simply |
| 868 | set base = 0 and mask = 0xff at start and never change them */ |
| 869 | |
| 870 | static void mapper4_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 972 | 871 | { |
| 973 | | int prg0_bank = MMC3_prg_base | (MMC3_prg0 & MMC3_prg_mask); |
| 974 | | int prg1_bank = MMC3_prg_base | (MMC3_prg1 & MMC3_prg_mask); |
| 975 | | int last_bank = MMC3_prg_base | MMC3_prg_mask; |
| 872 | int prg0_bank = prg_base | (prg_bank[0] & prg_mask); |
| 873 | int prg1_bank = prg_base | (prg_bank[1] & prg_mask); |
| 874 | int last_bank = prg_base | prg_mask; |
| 976 | 875 | |
| 977 | 876 | if (MMC3_cmd & 0x40) |
| 978 | 877 | { |
| 979 | | memory_set_bankptr(machine, 1, &nes.rom[(last_bank - 1) * 0x2000 + 0x10000]); |
| 980 | | memory_set_bankptr(machine, 3, &nes.rom[0x2000 * (prg0_bank) + 0x10000]); |
| 878 | prg8_89(machine, last_bank - 1); |
| 879 | prg8_cd(machine, prg0_bank); |
| 981 | 880 | } |
| 982 | 881 | else |
| 983 | 882 | { |
| 984 | | memory_set_bankptr(machine, 1, &nes.rom[0x2000 * (prg0_bank) + 0x10000]); |
| 985 | | memory_set_bankptr(machine, 3, &nes.rom[(last_bank - 1) * 0x2000 + 0x10000]); |
| 883 | prg8_89(machine, prg0_bank); |
| 884 | prg8_cd(machine, last_bank - 1); |
| 986 | 885 | } |
| 987 | | memory_set_bankptr(machine, 2, &nes.rom[0x2000 * (prg1_bank) + 0x10000]); |
| 988 | | memory_set_bankptr(machine, 4, &nes.rom[(last_bank) * 0x2000 + 0x10000]); |
| 886 | |
| 887 | prg8_ab(machine, prg1_bank); |
| 888 | prg8_ef(machine, last_bank); |
| 989 | 889 | } |
| 990 | 890 | |
| 991 | | static void mapper4_set_chr( running_machine *machine, UINT8 chr ) |
| 891 | static void mapper4_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 992 | 892 | { |
| 993 | 893 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 994 | 894 | |
| 995 | | chr2_x(machine, chr_page ^ 0, MMC3_chr_base | ((MMC3_chr[0] >> 1) & MMC3_chr_mask), chr); |
| 996 | | chr2_x(machine, chr_page ^ 2, MMC3_chr_base | ((MMC3_chr[1] >> 1) & MMC3_chr_mask), chr); |
| 997 | | chr1_x(machine, chr_page ^ 4, MMC3_chr_base | (MMC3_chr[2]& MMC3_chr_mask), chr); |
| 998 | | chr1_x(machine, chr_page ^ 5, MMC3_chr_base | (MMC3_chr[3]& MMC3_chr_mask), chr); |
| 999 | | chr1_x(machine, chr_page ^ 6, MMC3_chr_base | (MMC3_chr[4]& MMC3_chr_mask), chr); |
| 1000 | | chr1_x(machine, chr_page ^ 7, MMC3_chr_base | (MMC3_chr[5]& MMC3_chr_mask), chr); |
| 895 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 896 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr); |
| 897 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 898 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr); |
| 899 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr); |
| 900 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr); |
| 901 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr); |
| 902 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr); |
| 1001 | 903 | } |
| 1002 | 904 | |
| 1003 | 905 | static void mapper4_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| r5944 | r5945 | |
| 1005 | 907 | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 1006 | 908 | { |
| 1007 | 909 | int priorCount = IRQ_count; |
| 1008 | | if ((IRQ_count == 0) || IRQ_reload) |
| 910 | if ((IRQ_count == 0)) |
| 1009 | 911 | { |
| 1010 | 912 | IRQ_count = IRQ_count_latch; |
| 1011 | | IRQ_reload = 0; |
| 1012 | 913 | } |
| 1013 | 914 | else |
| 1014 | | IRQ_count --; |
| 915 | IRQ_count--; |
| 1015 | 916 | |
| 1016 | 917 | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 1017 | 918 | { |
| 1018 | 919 | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 1019 | 920 | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 1020 | 921 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 1021 | | // timer_adjust_oneshot(nes_irq_timer, cputag_clocks_to_attotime(device->machine, "maincpu", 4), 0); |
| 1022 | 922 | } |
| 1023 | 923 | } |
| 1024 | 924 | } |
| 1025 | 925 | |
| 1026 | 926 | static WRITE8_HANDLER( mapper4_w ) |
| 1027 | 927 | { |
| 1028 | | static UINT8 last_bank = 0xff; |
| 928 | UINT8 MMC3_helper, cmd; |
| 1029 | 929 | |
| 1030 | | // LOG_MMC(("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline)); |
| 930 | LOG_MMC(("mapper4_w offset: %04x, data: %02x\n", offset, data)); |
| 1031 | 931 | |
| 1032 | | //only bits 14,13, and 0 matter for offset! |
| 1033 | 932 | switch (offset & 0x6001) |
| 1034 | 933 | { |
| 1035 | | case 0x0000: /* $8000 */ |
| 934 | case 0x0000: |
| 935 | MMC3_helper = MMC3_cmd ^ data; |
| 1036 | 936 | MMC3_cmd = data; |
| 1037 | 937 | |
| 1038 | | /* Toggle between switching $8000 and $c000 */ |
| 1039 | | if (last_bank != (data & 0xc0)) |
| 1040 | | { |
| 1041 | | /* Reset the banks */ |
| 1042 | | mapper4_set_prg(space->machine); |
| 1043 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 1044 | | LOG_MMC((" MMC3 reset banks\n")); |
| 1045 | | } |
| 1046 | | last_bank = data & 0xc0; |
| 938 | /* Has PRG Mode changed? */ |
| 939 | if (MMC3_helper & 0x40) |
| 940 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 941 | |
| 942 | /* Has CHR Mode changed? */ |
| 943 | if (MMC3_helper & 0x80) |
| 944 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 1047 | 945 | break; |
| 1048 | 946 | |
| 1049 | | case 0x0001: /* $8001 */ |
| 1050 | | { |
| 1051 | | UINT8 cmd = MMC3_cmd & 0x07; |
| 947 | case 0x0001: |
| 948 | cmd = MMC3_cmd & 0x07; |
| 1052 | 949 | switch (cmd) |
| 1053 | 950 | { |
| 1054 | | case 0: case 1: |
| 1055 | | data &= 0xfe; |
| 1056 | | MMC3_chr[cmd] = data; |
| 1057 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 1058 | | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 1059 | | break; |
| 1060 | | |
| 951 | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 1061 | 952 | case 2: case 3: case 4: case 5: |
| 1062 | | MMC3_chr[cmd] = data; |
| 1063 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 1064 | | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 953 | vrom_bank[cmd] = data; |
| 954 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 1065 | 955 | break; |
| 1066 | | |
| 1067 | 956 | case 6: |
| 1068 | | MMC3_prg0 = data; |
| 1069 | | mapper4_set_prg(space->machine); |
| 1070 | | break; |
| 1071 | | |
| 1072 | 957 | case 7: |
| 1073 | | MMC3_prg1 = data; |
| 1074 | | mapper4_set_prg(space->machine); |
| 958 | prg_bank[cmd - 6] = data; |
| 959 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 1075 | 960 | break; |
| 1076 | 961 | } |
| 1077 | 962 | break; |
| 1078 | | } |
| 1079 | | case 0x2000: /* $a000 */ |
| 1080 | | if (data & 0x40) |
| 1081 | | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 1082 | | else |
| 1083 | | { |
| 1084 | | if (data & 0x01) |
| 1085 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1086 | | else |
| 1087 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1088 | | } |
| 963 | |
| 964 | case 0x2000: |
| 965 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 1089 | 966 | break; |
| 1090 | 967 | |
| 1091 | | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 968 | case 0x2001: /* extra RAM enable/disable */ |
| 969 | mmc_cmd2 = data; /* This actually is made of two parts: data&0x80 = WRAM enabled and data&0x40 = WRAM readonly! */ |
| 970 | /* We save this twice because we will need mmc_cmd2 in some clone mapper */ |
| 1092 | 971 | nes.mid_ram_enable = data; |
| 1093 | | LOG_MMC((" MMC3 mid_ram enable: %02x\n", 0)); |
| 1094 | 972 | break; |
| 1095 | 973 | |
| 1096 | | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 974 | case 0x4000: /* IRQ scanline counter */ |
| 1097 | 975 | IRQ_count_latch = data; |
| 1098 | | // LOG_MMC((" MMC3 set irq count latch: %02x (scanline %d)\n", data, ppu2c0x_get_current_scanline(0))); |
| 1099 | 976 | break; |
| 1100 | 977 | |
| 1101 | | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 1102 | | IRQ_reload = 1; |
| 1103 | | // LOG_MMC((" MMC3 set irq reload (scanline %d)\n", ppu2c0x_get_current_scanline(0))); |
| 978 | case 0x4001: /* IRQ scanline latch */ |
| 979 | IRQ_count = 0; |
| 1104 | 980 | break; |
| 1105 | 981 | |
| 1106 | | case 0x6000: /* $e000 - Disable IRQs */ |
| 982 | case 0x6000: /* Disable IRQs */ |
| 1107 | 983 | IRQ_enable = 0; |
| 1108 | | LOG_MMC((" MMC3 disable irqs\n")); |
| 1109 | 984 | break; |
| 1110 | 985 | |
| 1111 | | case 0x6001: /* $e001 - Enable IRQs */ |
| 986 | case 0x6001: /* Enable IRQs */ |
| 1112 | 987 | IRQ_enable = 1; |
| 1113 | | LOG_MMC((" MMC3 enable irqs\n")); |
| 1114 | 988 | break; |
| 1115 | 989 | |
| 1116 | 990 | default: |
| r5944 | r5945 | |
| 1747 | 1621 | { |
| 1748 | 1622 | LOG_MMC(("mapper8_w, offset: %04x, data: %02x\n", offset, data)); |
| 1749 | 1623 | |
| 1750 | | /* Switch 8k VROM bank */ |
| 1751 | 1624 | chr8(space->machine, data & 0x07, CHRROM); |
| 1752 | | |
| 1753 | | /* Switch 16k PRG bank */ |
| 1754 | 1625 | data = (data >> 3) & (nes.prg_chunks - 1); |
| 1755 | 1626 | memory_set_bankptr(space->machine, 1, &nes.rom[data * 0x4000 + 0x10000]); |
| 1756 | 1627 | memory_set_bankptr(space->machine, 2, &nes.rom[data * 0x4000 + 0x12000]); |
| r5944 | r5945 | |
| 1772 | 1643 | { |
| 1773 | 1644 | if ((offset & 0x3ff0) == 0x0fd0) |
| 1774 | 1645 | { |
| 1775 | | LOG_MMC(("mapper9 vrom latch switch (bank 0 low): %02x\n", MMC2_bank0)); |
| 1776 | | MMC2_bank0_latch = 0xfd; |
| 1777 | | chr4_0(device->machine, MMC2_bank0, CHRROM); |
| 1646 | LOG_MMC(("mapper9 vrom latch switch (bank 0 low): %02x\n", MMC2_regs[0])); |
| 1647 | mmc_cmd1 = 0xfd; |
| 1648 | chr4_0(device->machine, MMC2_regs[0], CHRROM); |
| 1778 | 1649 | } |
| 1779 | 1650 | else if ((offset & 0x3ff0) == 0x0fe0) |
| 1780 | 1651 | { |
| 1781 | | LOG_MMC(("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank0_hi)); |
| 1782 | | MMC2_bank0_latch = 0xfe; |
| 1783 | | chr4_0(device->machine, MMC2_bank0_hi, CHRROM); |
| 1652 | LOG_MMC(("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_regs[1])); |
| 1653 | mmc_cmd1 = 0xfe; |
| 1654 | chr4_0(device->machine, MMC2_regs[1], CHRROM); |
| 1784 | 1655 | } |
| 1785 | 1656 | else if ((offset & 0x3ff0) == 0x1fd0) |
| 1786 | 1657 | { |
| 1787 | | LOG_MMC(("mapper9 vrom latch switch (bank 1 low): %02x\n", MMC2_bank1)); |
| 1788 | | MMC2_bank1_latch = 0xfd; |
| 1789 | | chr4_4(device->machine, MMC2_bank1, CHRROM); |
| 1658 | LOG_MMC(("mapper9 vrom latch switch (bank 1 low): %02x\n", MMC2_regs[2])); |
| 1659 | mmc_cmd2 = 0xfd; |
| 1660 | chr4_4(device->machine, MMC2_regs[2], CHRROM); |
| 1790 | 1661 | } |
| 1791 | 1662 | else if ((offset & 0x3ff0) == 0x1fe0) |
| 1792 | 1663 | { |
| 1793 | | LOG_MMC(("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank1_hi)); |
| 1794 | | MMC2_bank1_latch = 0xfe; |
| 1795 | | chr4_4(device->machine, MMC2_bank1_hi, CHRROM); |
| 1664 | LOG_MMC(("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_regs[3])); |
| 1665 | mmc_cmd2 = 0xfe; |
| 1666 | chr4_4(device->machine, MMC2_regs[3], CHRROM); |
| 1796 | 1667 | } |
| 1797 | 1668 | } |
| 1798 | 1669 | |
| r5944 | r5945 | |
| 1801 | 1672 | switch (offset & 0x7000) |
| 1802 | 1673 | { |
| 1803 | 1674 | case 0x2000: |
| 1804 | | /* Switch the first 8k prg bank */ |
| 1805 | 1675 | prg8_89(space->machine, data); |
| 1806 | 1676 | break; |
| 1807 | 1677 | case 0x3000: |
| 1808 | | MMC2_bank0 = data; |
| 1809 | | if (MMC2_bank0_latch == 0xfd) |
| 1810 | | chr4_0(space->machine, MMC2_bank0, CHRROM); |
| 1811 | | LOG_MMC(("MMC2 VROM switch #1 (low): %02x\n", MMC2_bank0)); |
| 1678 | MMC2_regs[0] = data; |
| 1679 | if (mmc_cmd1 == 0xfd) |
| 1680 | chr4_0(space->machine, MMC2_regs[0], CHRROM); |
| 1681 | LOG_MMC(("MMC2 VROM switch #1 (low): %02x\n", MMC2_regs[0])); |
| 1812 | 1682 | break; |
| 1813 | 1683 | case 0x4000: |
| 1814 | | MMC2_bank0_hi = data; |
| 1815 | | if (MMC2_bank0_latch == 0xfe) |
| 1816 | | chr4_0(space->machine, MMC2_bank0_hi, CHRROM); |
| 1817 | | LOG_MMC(("MMC2 VROM switch #1 (high): %02x\n", MMC2_bank0_hi)); |
| 1684 | MMC2_regs[1] = data; |
| 1685 | if (mmc_cmd1 == 0xfe) |
| 1686 | chr4_0(space->machine, MMC2_regs[1], CHRROM); |
| 1687 | LOG_MMC(("MMC2 VROM switch #1 (high): %02x\n", MMC2_regs[1])); |
| 1818 | 1688 | break; |
| 1819 | 1689 | case 0x5000: |
| 1820 | | MMC2_bank1 = data; |
| 1821 | | if (MMC2_bank1_latch == 0xfd) |
| 1822 | | chr4_4(space->machine, MMC2_bank1, CHRROM); |
| 1690 | MMC2_regs[2] = data; |
| 1691 | if (mmc_cmd2 == 0xfd) |
| 1692 | chr4_4(space->machine, MMC2_regs[2], CHRROM); |
| 1823 | 1693 | LOG_MMC(("MMC2 VROM switch #2 (low): %02x\n", data)); |
| 1824 | 1694 | break; |
| 1825 | 1695 | case 0x6000: |
| 1826 | | MMC2_bank1_hi = data; |
| 1827 | | if (MMC2_bank1_latch == 0xfe) |
| 1828 | | chr4_4(space->machine, MMC2_bank1_hi, CHRROM); |
| 1696 | MMC2_regs[3] = data; |
| 1697 | if (mmc_cmd2 == 0xfe) |
| 1698 | chr4_4(space->machine, MMC2_regs[3], CHRROM); |
| 1829 | 1699 | LOG_MMC(("MMC2 VROM switch #2 (high): %02x\n", data)); |
| 1830 | 1700 | break; |
| 1831 | 1701 | case 0x7000: |
| r5944 | r5945 | |
| 1855 | 1725 | switch (offset & 0x7000) |
| 1856 | 1726 | { |
| 1857 | 1727 | case 0x2000: |
| 1858 | | /* Switch the first 16k prg bank */ |
| 1859 | 1728 | prg16_89ab(space->machine, data); |
| 1860 | 1729 | break; |
| 1861 | 1730 | default: |
| r5944 | r5945 | |
| 1879 | 1748 | { |
| 1880 | 1749 | LOG_MMC(("mapper11_w, offset: %04x, data: %02x\n", offset, data)); |
| 1881 | 1750 | |
| 1882 | | /* Switch 8k VROM bank */ |
| 1883 | 1751 | chr8(space->machine, data >> 4, CHRROM); |
| 1884 | | |
| 1885 | | /* Switch 32k prg bank */ |
| 1886 | 1752 | prg32(space->machine, data & 0x0f); |
| 1887 | 1753 | } |
| 1888 | 1754 | |
| r5944 | r5945 | |
| 1895 | 1761 | |
| 1896 | 1762 | MMC3 clone |
| 1897 | 1763 | |
| 1898 | | In MESS: Unsupported |
| 1764 | In MESS: Partially Supported |
| 1899 | 1765 | |
| 1900 | 1766 | *************************************************************/ |
| 1901 | 1767 | |
| 1768 | static WRITE8_HANDLER( mapper12_l_w ) |
| 1769 | { |
| 1770 | LOG_MMC(("mapper12_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 1771 | |
| 1772 | mapper12_reg = data; |
| 1773 | } |
| 1774 | |
| 1775 | /* we would need to use this read handler in 0x6000-0x7fff as well */ |
| 1776 | static READ8_HANDLER( mapper12_l_r ) |
| 1777 | { |
| 1778 | LOG_MMC(("mapper12_l_r, offset: %04x\n", offset)); |
| 1779 | return 0x01; |
| 1780 | } |
| 1781 | |
| 1782 | static void mapper12_set_chr( running_machine *machine ) |
| 1783 | { |
| 1784 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 1785 | |
| 1786 | chr1_x(machine, chr_page ^ 0, ((mapper12_reg & 0x01) << 8) | (vrom_bank[0] & ~0x01), CHRROM); |
| 1787 | chr1_x(machine, chr_page ^ 1, ((mapper12_reg & 0x01) << 8) | (vrom_bank[0] | 0x01), CHRROM); |
| 1788 | chr1_x(machine, chr_page ^ 2, ((mapper12_reg & 0x01) << 8) | (vrom_bank[1] & ~0x01), CHRROM); |
| 1789 | chr1_x(machine, chr_page ^ 3, ((mapper12_reg & 0x01) << 8) | (vrom_bank[1] | 0x01), CHRROM); |
| 1790 | chr1_x(machine, chr_page ^ 4, ((mapper12_reg & 0x10) << 4) | vrom_bank[2], CHRROM); |
| 1791 | chr1_x(machine, chr_page ^ 5, ((mapper12_reg & 0x10) << 4) | vrom_bank[3], CHRROM); |
| 1792 | chr1_x(machine, chr_page ^ 6, ((mapper12_reg & 0x10) << 4) | vrom_bank[4], CHRROM); |
| 1793 | chr1_x(machine, chr_page ^ 7, ((mapper12_reg & 0x10) << 4) | vrom_bank[5], CHRROM); |
| 1794 | } |
| 1795 | |
| 1796 | static WRITE8_HANDLER( mapper12_w ) |
| 1797 | { |
| 1798 | UINT8 MMC3_helper, cmd; |
| 1799 | LOG_MMC(("mapper12_w, offset: %04x, data: %02x\n", offset, data)); |
| 1800 | |
| 1801 | switch (offset & 0x6001) |
| 1802 | { |
| 1803 | case 0x0000: |
| 1804 | MMC3_helper = MMC3_cmd ^ data; |
| 1805 | MMC3_cmd = data; |
| 1806 | |
| 1807 | /* Has PRG Mode changed? */ |
| 1808 | if (MMC3_helper & 0x40) |
| 1809 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 1810 | |
| 1811 | /* Has CHR Mode changed? */ |
| 1812 | if (MMC3_helper & 0x80) |
| 1813 | mapper12_set_chr(space->machine); |
| 1814 | break; |
| 1815 | |
| 1816 | case 0x0001: |
| 1817 | cmd = MMC3_cmd & 0x07; |
| 1818 | switch (cmd) |
| 1819 | { |
| 1820 | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 1821 | case 2: case 3: case 4: case 5: |
| 1822 | vrom_bank[cmd] = data; |
| 1823 | mapper12_set_chr(space->machine); |
| 1824 | break; |
| 1825 | case 6: |
| 1826 | case 7: |
| 1827 | prg_bank[cmd - 6] = data; |
| 1828 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 1829 | break; |
| 1830 | } |
| 1831 | break; |
| 1832 | |
| 1833 | default: |
| 1834 | mapper4_w(space, offset, data); |
| 1835 | break; |
| 1836 | } |
| 1837 | } |
| 1838 | |
| 1902 | 1839 | /************************************************************* |
| 1903 | 1840 | |
| 1904 | 1841 | Mapper 13 |
| r5944 | r5945 | |
| 2015 | 1952 | |
| 2016 | 1953 | switch (offset & 0x000f) |
| 2017 | 1954 | { |
| 2018 | | case 0: |
| 2019 | | case 1: |
| 2020 | | case 2: |
| 2021 | | case 3: |
| 2022 | | case 4: |
| 2023 | | case 5: |
| 2024 | | case 6: |
| 2025 | | case 7: |
| 1955 | case 0: case 1: |
| 1956 | case 2: case 3: |
| 1957 | case 4: case 5: |
| 1958 | case 6: case 7: |
| 2026 | 1959 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 2027 | 1960 | break; |
| 2028 | 1961 | case 8: |
| 2029 | | /* Switch 16k bank at $8000 */ |
| 2030 | 1962 | prg16_89ab(space->machine, data); |
| 2031 | 1963 | break; |
| 2032 | 1964 | case 9: |
| 2033 | 1965 | switch (data & 0x03) |
| 2034 | 1966 | { |
| 2035 | | case 0: |
| 2036 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2037 | | break; |
| 2038 | | case 1: |
| 2039 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2040 | | break; |
| 2041 | | case 2: |
| 2042 | | set_nt_mirroring(PPU_MIRROR_LOW); |
| 2043 | | break; |
| 2044 | | case 3: |
| 2045 | | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 2046 | | break; |
| 1967 | case 0: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 1968 | case 1: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 1969 | case 2: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 1970 | case 3: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2047 | 1971 | } |
| 2048 | 1972 | break; |
| 2049 | 1973 | case 0x0a: |
| r5944 | r5945 | |
| 2189 | 2113 | |
| 2190 | 2114 | static WRITE8_HANDLER( mapper18_w ) |
| 2191 | 2115 | { |
| 2192 | | // static int irq; |
| 2193 | | static int bank_8000 = 0; |
| 2194 | | static int bank_a000 = 0; |
| 2195 | | static int bank_c000 = 0; |
| 2196 | | |
| 2116 | UINT8 bank; |
| 2197 | 2117 | LOG_MMC(("mapper18_w, offset: %04x, data: %02x\n", offset, data)); |
| 2198 | 2118 | |
| 2199 | 2119 | switch (offset & 0x7003) |
| 2200 | 2120 | { |
| 2201 | 2121 | case 0x0000: |
| 2202 | 2122 | /* Switch 8k bank at $8000 - low 4 bits */ |
| 2203 | | bank_8000 = (bank_8000 & 0xf0) | (data & 0x0f); |
| 2204 | | bank_8000 &= prg_mask; |
| 2205 | | memory_set_bankptr(space->machine, 1, &nes.rom[0x2000 * (bank_8000) + 0x10000]); |
| 2123 | prg_bank[0] = (prg_bank[0] & 0xf0) | (data & 0x0f); |
| 2124 | prg8_89(space->machine, prg_bank[0]); |
| 2206 | 2125 | break; |
| 2207 | 2126 | case 0x0001: |
| 2208 | 2127 | /* Switch 8k bank at $8000 - high 4 bits */ |
| 2209 | | bank_8000 = (bank_8000 & 0x0f) | (data << 4); |
| 2210 | | bank_8000 &= prg_mask; |
| 2211 | | memory_set_bankptr(space->machine, 1, &nes.rom[0x2000 * (bank_8000) + 0x10000]); |
| 2128 | prg_bank[0] = (prg_bank[0] & 0x0f) | (data << 4); |
| 2129 | prg8_89(space->machine, prg_bank[0]); |
| 2212 | 2130 | break; |
| 2213 | 2131 | case 0x0002: |
| 2214 | 2132 | /* Switch 8k bank at $a000 - low 4 bits */ |
| 2215 | | bank_a000 = (bank_a000 & 0xf0) | (data & 0x0f); |
| 2216 | | bank_a000 &= prg_mask; |
| 2217 | | memory_set_bankptr(space->machine, 2, &nes.rom[0x2000 * (bank_a000) + 0x10000]); |
| 2133 | prg_bank[1] = (prg_bank[1] & 0xf0) | (data & 0x0f); |
| 2134 | prg8_ab(space->machine, prg_bank[1]); |
| 2218 | 2135 | break; |
| 2219 | 2136 | case 0x0003: |
| 2220 | 2137 | /* Switch 8k bank at $a000 - high 4 bits */ |
| 2221 | | bank_a000 = (bank_a000 & 0x0f) | (data << 4); |
| 2222 | | bank_a000 &= prg_mask; |
| 2223 | | memory_set_bankptr(space->machine, 2, &nes.rom[0x2000 * (bank_a000) + 0x10000]); |
| 2138 | prg_bank[1] = (prg_bank[1] & 0x0f) | (data << 4); |
| 2139 | prg8_ab(space->machine, prg_bank[1]); |
| 2224 | 2140 | break; |
| 2225 | 2141 | case 0x1000: |
| 2226 | 2142 | /* Switch 8k bank at $c000 - low 4 bits */ |
| 2227 | | bank_c000 = (bank_c000 & 0xf0) | (data & 0x0f); |
| 2228 | | bank_c000 &= prg_mask; |
| 2229 | | memory_set_bankptr(space->machine, 3, &nes.rom[0x2000 * (bank_c000) + 0x10000]); |
| 2143 | prg_bank[2] = (prg_bank[2] & 0xf0) | (data & 0x0f); |
| 2144 | prg8_cd(space->machine, prg_bank[2]); |
| 2230 | 2145 | break; |
| 2231 | 2146 | case 0x1001: |
| 2232 | 2147 | /* Switch 8k bank at $c000 - high 4 bits */ |
| 2233 | | bank_c000 = (bank_c000 & 0x0f) | (data << 4); |
| 2234 | | bank_c000 &= prg_mask; |
| 2235 | | memory_set_bankptr(space->machine, 3, &nes.rom[0x2000 * (bank_c000) + 0x10000]); |
| 2148 | prg_bank[2] = (prg_bank[2] & 0x0f) | (data << 4); |
| 2149 | prg8_cd(space->machine, prg_bank[2]); |
| 2236 | 2150 | break; |
| 2237 | 2151 | |
| 2238 | 2152 | /* $9002, 3 (1002, 3) uncaught = Jaleco Baseball writes 0 */ |
| 2239 | 2153 | /* believe it's related to battery-backed ram enable/disable */ |
| 2240 | 2154 | |
| 2241 | 2155 | case 0x2000: |
| 2242 | | /* Switch 1k vrom at $0000 - low 4 bits */ |
| 2243 | | vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f); |
| 2244 | | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2245 | | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2246 | | break; |
| 2247 | 2156 | case 0x2001: |
| 2248 | | /* Switch 1k vrom at $0000 - high 4 bits */ |
| 2249 | | vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4); |
| 2250 | | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2251 | | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2252 | | break; |
| 2253 | 2157 | case 0x2002: |
| 2254 | | /* Switch 1k vrom at $0400 - low 4 bits */ |
| 2255 | | vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f); |
| 2256 | | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2257 | | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2258 | | break; |
| 2259 | 2158 | case 0x2003: |
| 2260 | | /* Switch 1k vrom at $0400 - high 4 bits */ |
| 2261 | | vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4); |
| 2262 | | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2263 | | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2264 | | break; |
| 2265 | 2159 | case 0x3000: |
| 2266 | | /* Switch 1k vrom at $0800 - low 4 bits */ |
| 2267 | | vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f); |
| 2268 | | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2269 | | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2270 | | break; |
| 2271 | 2160 | case 0x3001: |
| 2272 | | /* Switch 1k vrom at $0800 - high 4 bits */ |
| 2273 | | vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4); |
| 2274 | | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2275 | | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2276 | | break; |
| 2277 | 2161 | case 0x3002: |
| 2278 | | /* Switch 1k vrom at $0c00 - low 4 bits */ |
| 2279 | | vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f); |
| 2280 | | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2281 | | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2282 | | break; |
| 2283 | 2162 | case 0x3003: |
| 2284 | | /* Switch 1k vrom at $0c00 - high 4 bits */ |
| 2285 | | vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4); |
| 2286 | | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2287 | | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2288 | | break; |
| 2289 | 2163 | case 0x4000: |
| 2290 | | /* Switch 1k vrom at $1000 - low 4 bits */ |
| 2291 | | vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f); |
| 2292 | | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2293 | | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2294 | | break; |
| 2295 | 2164 | case 0x4001: |
| 2296 | | /* Switch 1k vrom at $1000 - high 4 bits */ |
| 2297 | | vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4); |
| 2298 | | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2299 | | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2300 | | break; |
| 2301 | 2165 | case 0x4002: |
| 2302 | | /* Switch 1k vrom at $1400 - low 4 bits */ |
| 2303 | | vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f); |
| 2304 | | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2305 | | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2306 | | break; |
| 2307 | 2166 | case 0x4003: |
| 2308 | | /* Switch 1k vrom at $1400 - high 4 bits */ |
| 2309 | | vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4); |
| 2310 | | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2311 | | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2312 | | break; |
| 2313 | 2167 | case 0x5000: |
| 2314 | | /* Switch 1k vrom at $1800 - low 4 bits */ |
| 2315 | | vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f); |
| 2316 | | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2317 | | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2318 | | break; |
| 2319 | 2168 | case 0x5001: |
| 2320 | | /* Switch 1k vrom at $1800 - high 4 bits */ |
| 2321 | | vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4); |
| 2322 | | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2323 | | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2324 | | break; |
| 2325 | 2169 | case 0x5002: |
| 2326 | | /* Switch 1k vrom at $1c00 - low 4 bits */ |
| 2327 | | vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f); |
| 2328 | | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2329 | | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2330 | | break; |
| 2331 | 2170 | case 0x5003: |
| 2332 | | /* Switch 1k vrom at $1c00 - high 4 bits */ |
| 2333 | | vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4); |
| 2334 | | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2335 | | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2171 | bank = ((offset & 0x7000) - 0x2000) / 0x0400 + ((offset & 0x0002) >> 1); |
| 2172 | if (offset & 0x0001) |
| 2173 | vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | (data << 4); |
| 2174 | else |
| 2175 | vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f); |
| 2176 | |
| 2177 | chr1_x(space->machine, bank, vrom_bank[bank], CHRROM); |
| 2336 | 2178 | break; |
| 2337 | 2179 | |
| 2338 | 2180 | /* LBO - these are unverified */ |
| r5944 | r5945 | |
| 2405 | 2247 | |
| 2406 | 2248 | static void namcot_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 2407 | 2249 | { |
| 2408 | | IRQ_count ++; |
| 2409 | | /* Increment & check the IRQ scanline counter */ |
| 2410 | | if (IRQ_enable && (IRQ_count == 0x7fff)) |
| 2250 | if (IRQ_enable) |
| 2411 | 2251 | { |
| 2412 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2252 | if (IRQ_count == 0x7fff) |
| 2253 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2254 | else |
| 2255 | IRQ_count++; |
| 2413 | 2256 | } |
| 2414 | 2257 | } |
| 2415 | 2258 | |
| r5944 | r5945 | |
| 2419 | 2262 | |
| 2420 | 2263 | switch (offset & 0x1800) |
| 2421 | 2264 | { |
| 2422 | | case 0x1000: |
| 2423 | | /* low byte of IRQ */ |
| 2265 | case 0x0800: |
| 2266 | LOG_MMC(("Mapper 19 sound port write, data: %02x\n", data)); |
| 2267 | break; |
| 2268 | case 0x1000: /* low byte of IRQ */ |
| 2424 | 2269 | IRQ_count = (IRQ_count & 0x7f00) | data; |
| 2425 | 2270 | break; |
| 2426 | | case 0x1800: |
| 2427 | | /* high byte of IRQ, IRQ enable in high bit */ |
| 2271 | case 0x1800: /* high byte of IRQ, IRQ enable in high bit */ |
| 2428 | 2272 | IRQ_count = (IRQ_count & 0xff) | ((data & 0x7f) << 8); |
| 2429 | 2273 | IRQ_enable = data & 0x80; |
| 2430 | 2274 | break; |
| 2431 | 2275 | } |
| 2432 | 2276 | } |
| 2433 | 2277 | |
| 2278 | static READ8_HANDLER( mapper19_l_r ) |
| 2279 | { |
| 2280 | LOG_MMC(("mapper19_l_r, offset: %04x\n", offset)); |
| 2281 | |
| 2282 | switch (offset & 0x1800) |
| 2283 | { |
| 2284 | case 0x1000: |
| 2285 | return IRQ_count & 0xff; |
| 2286 | case 0x1800: |
| 2287 | return (IRQ_count >> 8) & 0xff; |
| 2288 | default: |
| 2289 | return 0x00; |
| 2290 | } |
| 2291 | } |
| 2292 | |
| 2434 | 2293 | static WRITE8_HANDLER( mapper19_w ) |
| 2435 | 2294 | { |
| 2436 | 2295 | LOG_MMC(("mapper19_w, offset: %04x, data: %02x\n", offset, data)); |
| 2437 | 2296 | switch (offset & 0x7800) |
| 2438 | 2297 | { |
| 2439 | | case 0x0000: |
| 2440 | | case 0x0800: |
| 2441 | | case 0x1000: |
| 2442 | | case 0x1800: |
| 2443 | | case 0x2000: |
| 2444 | | case 0x2800: |
| 2445 | | case 0x3000: |
| 2446 | | case 0x3800: |
| 2298 | case 0x0000: case 0x0800: |
| 2299 | case 0x1000: case 0x1800: |
| 2300 | case 0x2000: case 0x2800: |
| 2301 | case 0x3000: case 0x3800: |
| 2447 | 2302 | chr1_x(space->machine, offset / 0x800, data, CHRROM); |
| 2448 | 2303 | break; |
| 2449 | 2304 | case 0x4000: |
| r5944 | r5945 | |
| 2629 | 2484 | switch (offset & 0x7007) |
| 2630 | 2485 | { |
| 2631 | 2486 | case 0x0000: |
| 2632 | | /* Switch 8k bank at $8000 */ |
| 2633 | 2487 | prg8_89(space->machine, data); |
| 2634 | 2488 | break; |
| 2635 | 2489 | case 0x1000: |
| r5944 | r5945 | |
| 2645 | 2499 | /* $1001 is uncaught */ |
| 2646 | 2500 | |
| 2647 | 2501 | case 0x2000: |
| 2648 | | /* Switch 8k bank at $a000 */ |
| 2649 | 2502 | prg8_ab(space->machine, data); |
| 2650 | 2503 | break; |
| 2651 | 2504 | case 0x3000: |
| r5944 | r5945 | |
| 2752 | 2605 | case 0x7004: |
| 2753 | 2606 | case 0x7001: |
| 2754 | 2607 | case 0x7080: |
| 2755 | | IRQ_count = IRQ_count_latch; |
| 2756 | 2608 | IRQ_enable = data & 0x02; |
| 2757 | 2609 | IRQ_enable_latch = data & 0x01; |
| 2610 | if (data & 0x02) |
| 2611 | IRQ_count = IRQ_count_latch; |
| 2758 | 2612 | // LOG_MMC(("konami_vrc4 irq_count set: %02x\n", IRQ_count)); |
| 2759 | 2613 | // LOG_MMC(("konami_vrc4 enable: %02x\n", IRQ_enable)); |
| 2760 | 2614 | // LOG_MMC(("konami_vrc4 enable latch: %02x\n", IRQ_enable_latch)); |
| r5944 | r5945 | |
| 2849 | 2703 | switch (offset & 0x3000) |
| 2850 | 2704 | { |
| 2851 | 2705 | case 0: |
| 2852 | | /* Switch 8k bank at $8000 */ |
| 2853 | 2706 | prg8_89(space->machine, data); |
| 2854 | 2707 | break; |
| 2855 | 2708 | case 0x1000: |
| r5944 | r5945 | |
| 2861 | 2714 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2862 | 2715 | } |
| 2863 | 2716 | break; |
| 2864 | | |
| 2865 | 2717 | case 0x2000: |
| 2866 | | /* Switch 8k bank at $a000 */ |
| 2867 | 2718 | prg8_ab(space->machine, data); |
| 2868 | 2719 | break; |
| 2869 | 2720 | default: |
| r5944 | r5945 | |
| 2894 | 2745 | case 0x6001: |
| 2895 | 2746 | case 0x6002: |
| 2896 | 2747 | case 0x6003: |
| 2897 | | /* switch 1k vrom at $0000-$1c00 */ |
| 2898 | 2748 | bank = ((select & 0x7000) - 0x3000) / 0x0800 + ((select & 0x0002) >> 1); |
| 2899 | 2749 | if (select & 0x0001) |
| 2900 | 2750 | vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | (data << 4); |
| r5944 | r5945 | |
| 2914 | 2764 | IRQ_count_latch |= (data << 4) & 0xf0; |
| 2915 | 2765 | break; |
| 2916 | 2766 | case 0x7002: |
| 2917 | | IRQ_count = IRQ_count_latch; |
| 2918 | 2767 | IRQ_enable = data & 0x02; |
| 2919 | 2768 | IRQ_enable_latch = data & 0x01; |
| 2769 | if (data & 0x02) |
| 2770 | IRQ_count = IRQ_count_latch; |
| 2920 | 2771 | break; |
| 2921 | 2772 | |
| 2922 | 2773 | default: |
| r5944 | r5945 | |
| 2947 | 2798 | case 0x0001: |
| 2948 | 2799 | case 0x0002: |
| 2949 | 2800 | case 0x0003: |
| 2950 | | /* Switch 16k bank at $8000 */ |
| 2951 | 2801 | prg16_89ab(space->machine, data); |
| 2952 | 2802 | break; |
| 2953 | 2803 | |
| r5944 | r5945 | |
| 2968 | 2818 | case 0x4001: |
| 2969 | 2819 | case 0x4002: |
| 2970 | 2820 | case 0x4003: |
| 2971 | | /* Switch 8k bank at $c000 */ |
| 2972 | 2821 | prg8_cd(space->machine, data); |
| 2973 | 2822 | break; |
| 2974 | 2823 | case 0x5000: |
| r5944 | r5945 | |
| 2979 | 2828 | case 0x6001: |
| 2980 | 2829 | case 0x6002: |
| 2981 | 2830 | case 0x6003: |
| 2982 | | /* switch 1k vrom at $0000-$1c00 */ |
| 2983 | 2831 | bank = ((offset & 0x7000) - 0x5000) / 0x0400 + (offset & 0x0003); |
| 2984 | 2832 | chr1_x(space->machine, bank, data, CHRROM); |
| 2985 | 2833 | break; |
| r5944 | r5945 | |
| 2988 | 2836 | IRQ_count_latch = data; |
| 2989 | 2837 | break; |
| 2990 | 2838 | case 0x7001: |
| 2991 | | IRQ_count = IRQ_count_latch; |
| 2992 | 2839 | IRQ_enable = data & 0x02; |
| 2993 | 2840 | IRQ_enable_latch = data & 0x01; |
| 2841 | if (data & 0x02) |
| 2842 | IRQ_count = IRQ_count_latch; |
| 2994 | 2843 | break; |
| 2995 | 2844 | case 0x7002: |
| 2996 | 2845 | IRQ_enable = IRQ_enable_latch; |
| r5944 | r5945 | |
| 3022 | 2871 | switch (offset & 0x7003) |
| 3023 | 2872 | { |
| 3024 | 2873 | case 0: case 1: case 2: case 3: |
| 3025 | | /* Switch 16k bank at $8000 */ |
| 3026 | 2874 | prg16_89ab(space->machine, data); |
| 3027 | 2875 | break; |
| 3028 | 2876 | |
| r5944 | r5945 | |
| 3040 | 2888 | } |
| 3041 | 2889 | break; |
| 3042 | 2890 | case 0x4000: case 0x4001: case 0x4002: case 0x4003: |
| 3043 | | /* Switch 8k bank at $c000 */ |
| 3044 | 2891 | prg8_cd(space->machine, data); |
| 3045 | 2892 | break; |
| 3046 | 2893 | case 0x5000: |
| r5944 | r5945 | |
| 3051 | 2898 | case 0x6001: |
| 3052 | 2899 | case 0x6002: |
| 3053 | 2900 | case 0x6003: |
| 3054 | | /* switch 1k vrom at $0000-$1c00 */ |
| 3055 | 2901 | bank = ((offset & 0x7000) - 0x5000) / 0x0400 + ((offset & 0x0001) << 1) + ((offset & 0x0002) >> 1); |
| 3056 | 2902 | chr1_x(space->machine, bank, data, CHRROM); |
| 3057 | 2903 | break; |
| r5944 | r5945 | |
| 3062 | 2908 | IRQ_enable = IRQ_enable_latch; |
| 3063 | 2909 | break; |
| 3064 | 2910 | case 0x7002: |
| 3065 | | IRQ_count = IRQ_count_latch; |
| 3066 | 2911 | IRQ_enable = data & 0x02; |
| 3067 | 2912 | IRQ_enable_latch = data & 0x01; |
| 2913 | if (data & 0x02) |
| 2914 | IRQ_count = IRQ_count_latch; |
| 3068 | 2915 | break; |
| 3069 | 2916 | |
| 3070 | 2917 | default: |
| r5944 | r5945 | |
| 3154 | 3001 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3155 | 3002 | break; |
| 3156 | 3003 | case 0x2000: |
| 3157 | | /* Switch 8k bank at $A000 */ |
| 3158 | 3004 | prg8_ab(space->machine, data); |
| 3159 | 3005 | break; |
| 3160 | 3006 | case 0x3000: |
| 3161 | | /* Switch 1k VROM at $1000 */ |
| 3162 | 3007 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 3163 | 3008 | break; |
| 3164 | 3009 | default: |
| r5944 | r5945 | |
| 3233 | 3078 | switch (offset) |
| 3234 | 3079 | { |
| 3235 | 3080 | case 0x1ffd: |
| 3236 | | /* Switch 32k prg banks */ |
| 3237 | 3081 | prg32(space->machine, data); |
| 3238 | 3082 | break; |
| 3239 | 3083 | case 0x1ffe: |
| 3240 | | /* Switch 4k VNES_ROM at 0x0000 */ |
| 3241 | 3084 | chr4_0(space->machine, data, CHRROM); |
| 3242 | 3085 | break; |
| 3243 | 3086 | case 0x1fff: |
| 3244 | | /* Switch 4k VNES_ROM at 0x1000 */ |
| 3245 | 3087 | chr4_4(space->machine, data, CHRROM); |
| 3246 | 3088 | break; |
| 3247 | 3089 | } |
| r5944 | r5945 | |
| 3298 | 3140 | |
| 3299 | 3141 | MMC3 clone |
| 3300 | 3142 | |
| 3301 | | In MESS: Unsupported. |
| 3143 | In MESS: Supported. |
| 3302 | 3144 | |
| 3303 | 3145 | *************************************************************/ |
| 3304 | 3146 | |
| 3147 | static WRITE8_HANDLER( mapper37_m_w ) |
| 3148 | { |
| 3149 | UINT8 map37_helper; |
| 3150 | LOG_MMC(("mapper37_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3151 | |
| 3152 | map37_helper = (data & 0x06) >> 1; |
| 3153 | |
| 3154 | mmc_prg_base = map37_helper << 3; |
| 3155 | mmc_prg_mask = (map37_helper == 2) ? 0x0f : 0x07; |
| 3156 | mmc_chr_base = map37_helper << 6; |
| 3157 | mmc_chr_mask = 0x7f; |
| 3158 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3159 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3160 | } |
| 3161 | |
| 3305 | 3162 | /************************************************************* |
| 3306 | 3163 | |
| 3307 | 3164 | Mapper 38 |
| r5944 | r5945 | |
| 3530 | 3387 | |
| 3531 | 3388 | static WRITE8_HANDLER( mapper44_w ) |
| 3532 | 3389 | { |
| 3533 | | // LOG_MMC(("mapper44_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline)); |
| 3390 | UINT8 page; |
| 3391 | LOG_MMC(("mapper44_w offset: %04x, data: %02x\n", offset, data)); |
| 3534 | 3392 | |
| 3535 | | //only bits 14,13, and 0 matter for offset! |
| 3536 | 3393 | switch (offset & 0x6001) |
| 3537 | 3394 | { |
| 3538 | 3395 | case 0x2001: /* $a001 - Select 128K ROM/VROM base (0..5) or last 256K ROM/VRAM base (6) */ |
| 3539 | | { |
| 3540 | | UINT8 page = (data & 0x07); |
| 3541 | | if (page > 6) |
| 3542 | | page = 6; |
| 3543 | | MMC3_prg_base = page * 16; |
| 3544 | | MMC3_prg_mask = (page > 5) ? 0x1f : 0x0f; |
| 3545 | | MMC3_chr_base = page * 128; |
| 3546 | | MMC3_chr_mask = (page > 5) ? 0xff : 0x7f; |
| 3547 | | } |
| 3548 | | mapper4_set_prg(space->machine); |
| 3549 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 3396 | page = (data & 0x07); |
| 3397 | if (page > 6) |
| 3398 | page = 6; |
| 3399 | |
| 3400 | mmc_prg_base = page << 4; |
| 3401 | mmc_prg_mask = (page > 5) ? 0x1f : 0x0f; |
| 3402 | mmc_chr_base = page << 7; |
| 3403 | mmc_chr_mask = (page > 5) ? 0xff : 0x7f; |
| 3404 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3405 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3550 | 3406 | break; |
| 3551 | 3407 | |
| 3552 | 3408 | default: |
| r5944 | r5945 | |
| 3570 | 3426 | { |
| 3571 | 3427 | LOG_MMC(("mapper45_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3572 | 3428 | |
| 3573 | | if (offset == 0) |
| 3429 | /* This bit is the "register lock". Once register are locked, writes go to WRAM |
| 3430 | and there is no way to unlock them (except by resetting the machine) */ |
| 3431 | if (mapper45_reg[3] & 0x40) |
| 3432 | nes.wram[offset] = data; |
| 3433 | else |
| 3574 | 3434 | { |
| 3575 | | mapper45_data[mapper45_cmd] = data; |
| 3576 | | mapper45_cmd = (mapper45_cmd + 1) & 0x03; |
| 3435 | mapper45_reg[mmc_count] = data; |
| 3436 | mmc_count = (mmc_count + 1) & 0x03; |
| 3577 | 3437 | |
| 3578 | | if (!mapper45_cmd) |
| 3438 | if (!mmc_count) |
| 3579 | 3439 | { |
| 3580 | | LOG_MMC(("mapper45_m_w, command completed %02x %02x %02x %02x\n", mapper45_data[3], |
| 3581 | | mapper45_data[2], mapper45_data[1], mapper45_data[0])); |
| 3440 | LOG_MMC(("mapper45_m_w, command completed %02x %02x %02x %02x\n", mapper45_reg[3], |
| 3441 | mapper45_reg[2], mapper45_reg[1], mapper45_reg[0])); |
| 3582 | 3442 | |
| 3583 | | MMC3_prg_base = mapper45_data[1]; |
| 3584 | | MMC3_prg_mask = 0x3f ^ (mapper45_data[3] & 0x3f); |
| 3585 | | MMC3_chr_base = ((mapper45_data[2] & 0xf0) << 4) + mapper45_data[0]; |
| 3586 | | |
| 3587 | | if (mapper45_data[2] & 0x08) |
| 3588 | | MMC3_chr_mask = (1 << ((mapper45_data[2] & 0x07) + 1)) - 1; |
| 3589 | | else |
| 3590 | | MMC3_chr_mask = 0; |
| 3591 | | |
| 3592 | | mapper4_set_prg(space->machine); |
| 3593 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 3443 | mmc_prg_base = mapper45_reg[1]; |
| 3444 | mmc_prg_mask = 0x3f ^ (mapper45_reg[3] & 0x3f); |
| 3445 | mmc_chr_base = ((mapper45_reg[2] & 0xf0) << 4) + mapper45_reg[0]; |
| 3446 | mmc_chr_mask = 0xff >> (~mapper45_reg[2] & 0x0f); |
| 3447 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3448 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3594 | 3449 | } |
| 3595 | 3450 | } |
| 3596 | | if (mapper45_data[3] & 0x40) |
| 3597 | | nes.wram[offset] = data; |
| 3598 | 3451 | } |
| 3599 | 3452 | |
| 3600 | 3453 | /************************************************************* |
| r5944 | r5945 | |
| 3612 | 3465 | { |
| 3613 | 3466 | LOG_MMC(("mapper46_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3614 | 3467 | |
| 3615 | | mmc_bank_latch1 = (mmc_bank_latch1 & 0x01) | ((data & 0x0f) << 1); |
| 3616 | | mmc_bank_latch2 = (mmc_bank_latch2 & 0x07) | ((data & 0xf0) >> 1); |
| 3617 | | prg32(space->machine, mmc_bank_latch1); |
| 3618 | | chr8(space->machine, mmc_bank_latch2, CHRROM); |
| 3468 | prg_bank[0] = (prg_bank[0] & 0x01) | ((data & 0x0f) << 1); |
| 3469 | vrom_bank[0] = (vrom_bank[0] & 0x07) | ((data & 0xf0) >> 1); |
| 3470 | prg32(space->machine, prg_bank[0]); |
| 3471 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 3619 | 3472 | } |
| 3620 | 3473 | |
| 3621 | 3474 | static WRITE8_HANDLER( mapper46_w ) |
| 3622 | 3475 | { |
| 3623 | 3476 | LOG_MMC(("mapper46_w, offset: %04x, data: %02x\n", offset, data)); |
| 3624 | 3477 | |
| 3625 | | mmc_bank_latch1 = (mmc_bank_latch1 & ~0x01) | (data & 0x01); |
| 3626 | | mmc_bank_latch2 = (mmc_bank_latch2 & ~0x07) | ((data & 0x70) >> 4); |
| 3627 | | prg32(space->machine, mmc_bank_latch1); |
| 3628 | | chr8(space->machine, mmc_bank_latch2, CHRROM); |
| 3478 | prg_bank[0] = (prg_bank[0] & ~0x01) | (data & 0x01); |
| 3479 | vrom_bank[0] = (vrom_bank[0] & ~0x07) | ((data & 0x70) >> 4); |
| 3480 | prg32(space->machine, prg_bank[0]); |
| 3481 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 3629 | 3482 | } |
| 3630 | 3483 | |
| 3631 | 3484 | /************************************************************* |
| r5944 | r5945 | |
| 3643 | 3496 | { |
| 3644 | 3497 | LOG_MMC(("mapper47_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3645 | 3498 | |
| 3646 | | if (offset == 0) |
| 3647 | | { |
| 3648 | | MMC3_prg_base = (data & 0x01) << 4; |
| 3649 | | MMC3_prg_mask = 0x0f; |
| 3650 | | MMC3_chr_base = (data & 0x01) << 7; |
| 3651 | | MMC3_chr_mask = 0x7f; |
| 3652 | | mapper4_set_prg(space->machine); |
| 3653 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 3654 | | } |
| 3499 | mmc_prg_base = (data & 0x01) << 4; |
| 3500 | mmc_prg_mask = 0x0f; |
| 3501 | mmc_chr_base = (data & 0x01) << 7; |
| 3502 | mmc_chr_mask = 0x7f; |
| 3503 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3504 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3655 | 3505 | } |
| 3656 | 3506 | |
| 3657 | 3507 | /************************************************************* |
| r5944 | r5945 | |
| 3681 | 3531 | { |
| 3682 | 3532 | LOG_MMC(("mapper49_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3683 | 3533 | |
| 3684 | | if ((offset & 0x1800) == 0x0800 && (offset & 0xff) == data) |
| 3534 | /* mid writes only work when WRAM is enabled. not sure if I should |
| 3535 | change the condition to mmc_cmd2==0x80 (i.e. what is the effect of |
| 3536 | the read-only bit?) */ |
| 3537 | if (mmc_cmd2 & 0x80) |
| 3685 | 3538 | { |
| 3686 | | MMC3_prg_base = (data & 0xc0) >> 2; |
| 3687 | | MMC3_prg_mask = 0x0f; |
| 3688 | | MMC3_chr_base = (data & 0xc0) << 1; |
| 3689 | | MMC3_chr_mask = 0x7f; |
| 3690 | | mapper4_set_prg(space->machine); |
| 3691 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 3539 | if (data & 0x01) /* if this is 0, then we have 32k PRG blocks */ |
| 3540 | { |
| 3541 | mmc_prg_base = (data & 0xc0) >> 2; |
| 3542 | mmc_prg_mask = 0x0f; |
| 3543 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3544 | } |
| 3545 | else |
| 3546 | prg32(space->machine, (data & 0x30) >> 4); |
| 3547 | |
| 3548 | mmc_chr_base = (data & 0xc0) << 1; |
| 3549 | mmc_chr_mask = 0x7f; |
| 3550 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3692 | 3551 | } |
| 3693 | 3552 | } |
| 3694 | 3553 | |
| r5944 | r5945 | |
| 3716 | 3575 | |
| 3717 | 3576 | static void mapper51_set_banks( running_machine *machine ) |
| 3718 | 3577 | { |
| 3719 | | set_nt_mirroring((MMC1_bank1 == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3578 | set_nt_mirroring((mapper51_reg[0] == 3) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3720 | 3579 | |
| 3721 | | if (MMC1_bank1 & 0x01) |
| 3580 | if (mapper51_reg[0] & 0x01) |
| 3722 | 3581 | { |
| 3723 | | prg32(machine, MMC1_bank2); |
| 3582 | prg32(machine, mapper51_reg[1]); |
| 3724 | 3583 | } |
| 3725 | 3584 | else |
| 3726 | 3585 | { |
| 3727 | | prg16_cdef(machine, (MMC1_bank2 * 2) + 1); |
| 3728 | | prg16_89ab(machine, MMC1_bank3 * 2); |
| 3586 | prg16_cdef(machine, (mapper51_reg[1] * 2) + 1); |
| 3587 | prg16_89ab(machine, mapper51_reg[2] * 2); |
| 3729 | 3588 | } |
| 3730 | 3589 | } |
| 3731 | 3590 | |
| r5944 | r5945 | |
| 3733 | 3592 | { |
| 3734 | 3593 | LOG_MMC(("mapper51_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3735 | 3594 | |
| 3736 | | MMC1_bank1 = ((data >> 1) & 0x01) | ((data >> 3) & 0x02); |
| 3595 | mapper51_reg[0] = ((data >> 1) & 0x01) | ((data >> 3) & 0x02); |
| 3737 | 3596 | mapper51_set_banks(space->machine); |
| 3738 | 3597 | } |
| 3739 | 3598 | |
| r5944 | r5945 | |
| 3742 | 3601 | LOG_MMC(("mapper51_w, offset: %04x, data: %02x\n", offset, data)); |
| 3743 | 3602 | |
| 3744 | 3603 | if (offset & 0x4000) |
| 3745 | | { |
| 3746 | | MMC1_bank3 = data; |
| 3747 | | } |
| 3604 | mapper51_reg[2] = data; |
| 3748 | 3605 | else |
| 3749 | | { |
| 3750 | | MMC1_bank2 = data; |
| 3751 | | } |
| 3606 | mapper51_reg[1] = data; |
| 3607 | |
| 3752 | 3608 | mapper51_set_banks(space->machine); |
| 3753 | 3609 | } |
| 3754 | 3610 | |
| r5944 | r5945 | |
| 3761 | 3617 | |
| 3762 | 3618 | MMC3 clone |
| 3763 | 3619 | |
| 3764 | | In MESS: Unsupported. |
| 3620 | In MESS: Supported. |
| 3765 | 3621 | |
| 3766 | 3622 | *************************************************************/ |
| 3767 | 3623 | |
| 3624 | static WRITE8_HANDLER( mapper52_m_w ) |
| 3625 | { |
| 3626 | UINT8 map52_helper1, map52_helper2; |
| 3627 | LOG_MMC(("mapper52_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3628 | |
| 3629 | /* mid writes only work when WRAM is enabled. not sure if I should |
| 3630 | change the condition to mmc_cmd2==0x80 (i.e. what is the effect of |
| 3631 | the read-only bit?) and it only can happen once! */ |
| 3632 | if ((mmc_cmd2 & 0x80) && !map52_reg_written) |
| 3633 | { |
| 3634 | map52_helper1 = (data & 0x08); |
| 3635 | map52_helper2 = (data & 0x40); |
| 3636 | |
| 3637 | mmc_prg_base = map52_helper1 ? ((data & 0x06) << 4) : ((data & 0x07) << 4); |
| 3638 | mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f; |
| 3639 | mmc_chr_base = ((data & 0x20) << 4) | ((data & 0x04) << 6) | (map52_helper2 ? ((data & 0x10) << 3) : 0); |
| 3640 | mmc_chr_mask = map52_helper2 ? 0x7f : 0xff; |
| 3641 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 3642 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 3643 | |
| 3644 | map52_reg_written = 1; |
| 3645 | } |
| 3646 | else |
| 3647 | nes.wram[offset] = data; |
| 3648 | } |
| 3649 | |
| 3768 | 3650 | /************************************************************* |
| 3769 | 3651 | |
| 3770 | 3652 | Mapper 53 |
| r5944 | r5945 | |
| 3983 | 3865 | |
| 3984 | 3866 | static void mapper64_set_banks( running_machine *machine ) |
| 3985 | 3867 | { |
| 3986 | | if (mapper64_cmd & 0x20) |
| 3868 | if (mmc_cmd1 & 0x20) |
| 3987 | 3869 | { |
| 3988 | | chr1_0(machine, mapper64_data[0], CHRROM); |
| 3989 | | chr1_2(machine, mapper64_data[1], CHRROM); |
| 3990 | | chr1_1(machine, mapper64_data[8], CHRROM); |
| 3991 | | chr1_3(machine, mapper64_data[9], CHRROM); |
| 3870 | chr1_0(machine, mapper64_reg[0], CHRROM); |
| 3871 | chr1_2(machine, mapper64_reg[1], CHRROM); |
| 3872 | chr1_1(machine, mapper64_reg[8], CHRROM); |
| 3873 | chr1_3(machine, mapper64_reg[9], CHRROM); |
| 3992 | 3874 | } |
| 3993 | 3875 | else |
| 3994 | 3876 | { |
| 3995 | | chr1_0(machine, mapper64_data[0] & 0xfe, CHRROM); |
| 3996 | | chr1_1(machine, (mapper64_data[0] & 0xfe) | 1, CHRROM); |
| 3997 | | chr1_2(machine, mapper64_data[1] & 0xfe, CHRROM); |
| 3998 | | chr1_3(machine, (mapper64_data[1] & 0xfe) | 1, CHRROM); |
| 3877 | chr1_0(machine, mapper64_reg[0] & 0xfe, CHRROM); |
| 3878 | chr1_1(machine, (mapper64_reg[0] & 0xfe) | 1, CHRROM); |
| 3879 | chr1_2(machine, mapper64_reg[1] & 0xfe, CHRROM); |
| 3880 | chr1_3(machine, (mapper64_reg[1] & 0xfe) | 1, CHRROM); |
| 3999 | 3881 | } |
| 4000 | 3882 | |
| 4001 | | chr1_4(machine, mapper64_data[2], CHRROM); |
| 4002 | | chr1_5(machine, mapper64_data[3], CHRROM); |
| 4003 | | chr1_6(machine, mapper64_data[4], CHRROM); |
| 4004 | | chr1_7(machine, mapper64_data[5], CHRROM); |
| 3883 | chr1_4(machine, mapper64_reg[2], CHRROM); |
| 3884 | chr1_5(machine, mapper64_reg[3], CHRROM); |
| 3885 | chr1_6(machine, mapper64_reg[4], CHRROM); |
| 3886 | chr1_7(machine, mapper64_reg[5], CHRROM); |
| 4005 | 3887 | |
| 4006 | | prg8_89(machine, mapper64_data[6]); |
| 4007 | | prg8_ab(machine, mapper64_data[7]); |
| 4008 | | prg8_cd(machine, mapper64_data[10]); |
| 3888 | prg8_89(machine, mapper64_reg[6]); |
| 3889 | prg8_ab(machine, mapper64_reg[7]); |
| 3890 | prg8_cd(machine, mapper64_reg[10]); |
| 4009 | 3891 | } |
| 4010 | 3892 | |
| 4011 | 3893 | static WRITE8_HANDLER( mapper64_m_w ) |
| r5944 | r5945 | |
| 4022 | 3904 | switch (offset & 0x7001) |
| 4023 | 3905 | { |
| 4024 | 3906 | case 0x0000: |
| 4025 | | mapper64_cmd = data; |
| 3907 | mmc_cmd1 = data; |
| 4026 | 3908 | break; |
| 4027 | 3909 | case 0x0001: |
| 4028 | | if ((mapper64_cmd & 0x0f) < 10) |
| 4029 | | mapper64_data[mapper64_cmd & 0x0f] = data; |
| 4030 | | if ((mapper64_cmd & 0x0f) == 0x0f) |
| 4031 | | mapper64_data[10] = data; |
| 3910 | if ((mmc_cmd1 & 0x0f) < 10) |
| 3911 | mapper64_reg[mmc_cmd1 & 0x0f] = data; |
| 3912 | if ((mmc_cmd1 & 0x0f) == 0x0f) |
| 3913 | mapper64_reg[10] = data; |
| 4032 | 3914 | |
| 4033 | 3915 | mapper64_set_banks(space->machine); |
| 4034 | 3916 | break; |
| r5944 | r5945 | |
| 4037 | 3919 | if (data & 0x40) |
| 4038 | 3920 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 4039 | 3921 | else |
| 4040 | | { |
| 4041 | | if (data & 0x01) |
| 4042 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4043 | | else |
| 4044 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4045 | | } |
| 3922 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 4046 | 3923 | break; |
| 4047 | 3924 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 4048 | 3925 | IRQ_count_latch = data; |
| r5944 | r5945 | |
| 4109 | 3986 | switch (offset & 0x7007) |
| 4110 | 3987 | { |
| 4111 | 3988 | case 0x0000: |
| 4112 | | /* Switch 8k bank at $8000 */ |
| 4113 | | data &= prg_mask; |
| 4114 | | memory_set_bankptr(space->machine, 1, &nes.rom[0x2000 * (data) + 0x10000]); |
| 3989 | prg8_89(space->machine, data); |
| 4115 | 3990 | LOG_MMC((" Mapper 65 switch ($8000) value: %02x\n", data)); |
| 4116 | 3991 | break; |
| 4117 | 3992 | case 0x1001: |
| r5944 | r5945 | |
| 4128 | 4003 | break; |
| 4129 | 4004 | |
| 4130 | 4005 | case 0x2000: |
| 4131 | | /* Switch 8k bank at $a000 */ |
| 4132 | | data &= prg_mask; |
| 4133 | | memory_set_bankptr(space->machine, 2, &nes.rom[0x2000 * (data) + 0x10000]); |
| 4006 | prg8_ab(space->machine, data); |
| 4134 | 4007 | LOG_MMC((" Mapper 65 switch ($a000) value: %02x\n", data)); |
| 4135 | 4008 | break; |
| 4136 | 4009 | |
| r5944 | r5945 | |
| 4143 | 4016 | case 0x3006: |
| 4144 | 4017 | case 0x3007: |
| 4145 | 4018 | /* Switch 1k VROM at $0000-$1c00 */ |
| 4146 | | chr1_x(space->machine, offset &7, data, CHRROM); |
| 4147 | | //ppu2c0x_set_videorom_bank(state->ppu, offset & 7, 1, data, 64); |
| 4019 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 4148 | 4020 | break; |
| 4149 | 4021 | |
| 4150 | 4022 | case 0x4000: |
| 4151 | | /* Switch 8k bank at $c000 */ |
| 4152 | | data &= prg_mask; |
| 4153 | | memory_set_bankptr(space->machine, 3, &nes.rom[0x2000 * (data) + 0x10000]); |
| 4023 | prg8_cd(space->machine, data); |
| 4154 | 4024 | LOG_MMC((" Mapper 65 switch ($c000) value: %02x\n", data)); |
| 4155 | 4025 | break; |
| 4156 | 4026 | |
| r5944 | r5945 | |
| 4572 | 4442 | Games: Columbus - Ougon no Yoake (C), Ji Jia Zhan Shi, |
| 4573 | 4443 | Jia A Fung Yun, Wei Luo Chuan Qi |
| 4574 | 4444 | |
| 4575 | | In MESS: Partially Supported, but we ignore accesses to 0x5000 / 0x6000 atm |
| 4576 | | (is this the reason for missing graphics?) |
| 4445 | This mapper is quite similar to MMC3, but with two differences: |
| 4446 | mirroring is not the same, and when VROM banks 8,9 are accessed |
| 4447 | they point to CHRRAM and not CHRROM. |
| 4577 | 4448 | |
| 4449 | In MESS: Supported |
| 4450 | |
| 4578 | 4451 | *************************************************************/ |
| 4579 | 4452 | |
| 4580 | 4453 | /* MIRROR_LOW and MIRROR_HIGH are swapped! */ |
| r5944 | r5945 | |
| 4598 | 4471 | } |
| 4599 | 4472 | } |
| 4600 | 4473 | |
| 4474 | static void mapper74_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 4475 | { |
| 4476 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 4477 | UINT8 chr_src[6]; |
| 4478 | int i; |
| 4479 | |
| 4480 | for (i = 0; i < 6; i++) |
| 4481 | chr_src[i] = ((vrom_bank[i] == 8) || (vrom_bank[i] == 9)) ? CHRRAM : CHRROM; |
| 4482 | |
| 4483 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 4484 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 4485 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 4486 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 4487 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 4488 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 4489 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 4490 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 4491 | } |
| 4492 | |
| 4601 | 4493 | static WRITE8_HANDLER( mapper74_w ) |
| 4602 | 4494 | { |
| 4495 | UINT8 MMC3_helper, cmd; |
| 4603 | 4496 | LOG_MMC(("mapper74_w, offset: %04x, data: %02x\n", offset, data)); |
| 4604 | 4497 | |
| 4605 | 4498 | switch (offset & 0x6001) |
| 4606 | 4499 | { |
| 4500 | case 0x0000: |
| 4501 | MMC3_helper = MMC3_cmd ^ data; |
| 4502 | MMC3_cmd = data; |
| 4503 | |
| 4504 | /* Has PRG Mode changed? */ |
| 4505 | if (MMC3_helper & 0x40) |
| 4506 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 4507 | |
| 4508 | /* Has CHR Mode changed? */ |
| 4509 | if (MMC3_helper & 0x80) |
| 4510 | mapper74_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 4511 | break; |
| 4512 | |
| 4513 | case 0x0001: |
| 4514 | cmd = MMC3_cmd & 0x07; |
| 4515 | switch (cmd) |
| 4516 | { |
| 4517 | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 4518 | case 2: case 3: case 4: case 5: |
| 4519 | vrom_bank[cmd] = data; |
| 4520 | mapper74_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 4521 | break; |
| 4522 | case 6: |
| 4523 | case 7: |
| 4524 | prg_bank[cmd - 6] = data; |
| 4525 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 4526 | break; |
| 4527 | } |
| 4528 | break; |
| 4529 | |
| 4607 | 4530 | case 0x2000: |
| 4608 | 4531 | waixing_set_mirror(data); //maybe data & 0x03? |
| 4609 | 4532 | break; |
| 4533 | |
| 4610 | 4534 | case 0x2001: |
| 4611 | 4535 | break; |
| 4536 | |
| 4612 | 4537 | default: |
| 4613 | 4538 | mapper4_w(space, offset, data); |
| 4614 | 4539 | break; |
| r5944 | r5945 | |
| 4637 | 4562 | break; |
| 4638 | 4563 | case 0x1000: |
| 4639 | 4564 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 4640 | | mmc_bank_latch1 = (mmc_bank_latch1 & 0x0f) | ((data & 0x02) << 3); |
| 4641 | | mmc_bank_latch2 = (mmc_bank_latch2 & 0x0f) | ((data & 0x04) << 2); |
| 4642 | | chr4_0(space->machine, mmc_bank_latch1, CHRROM); |
| 4643 | | chr4_4(space->machine, mmc_bank_latch2, CHRROM); |
| 4565 | vrom_bank[0] = (vrom_bank[0] & 0x0f) | ((data & 0x02) << 3); |
| 4566 | vrom_bank[1] = (vrom_bank[1] & 0x0f) | ((data & 0x04) << 2); |
| 4567 | chr4_0(space->machine, vrom_bank[0], CHRROM); |
| 4568 | chr4_4(space->machine, vrom_bank[1], CHRROM); |
| 4644 | 4569 | break; |
| 4645 | 4570 | case 0x2000: |
| 4646 | 4571 | prg8_ab(space->machine, data); |
| r5944 | r5945 | |
| 4649 | 4574 | prg8_cd(space->machine, data); |
| 4650 | 4575 | break; |
| 4651 | 4576 | case 0x6000: |
| 4652 | | mmc_bank_latch1 = (mmc_bank_latch1 & 0x10) | (data & 0x0f); |
| 4653 | | chr4_0(space->machine, mmc_bank_latch1, CHRROM); |
| 4577 | vrom_bank[0] = (vrom_bank[0] & 0x10) | (data & 0x0f); |
| 4578 | chr4_0(space->machine, vrom_bank[0], CHRROM); |
| 4654 | 4579 | break; |
| 4655 | 4580 | case 0x7000: |
| 4656 | | mmc_bank_latch2 = (mmc_bank_latch2 & 0x10) | (data & 0x0f); |
| 4657 | | chr4_4(space->machine, mmc_bank_latch2, CHRROM); |
| 4581 | vrom_bank[1] = (vrom_bank[1] & 0x10) | (data & 0x0f); |
| 4582 | chr4_4(space->machine, vrom_bank[1], CHRROM); |
| 4658 | 4583 | break; |
| 4659 | 4584 | } |
| 4660 | 4585 | } |
| r5944 | r5945 | |
| 4871 | 4796 | switch (offset) |
| 4872 | 4797 | { |
| 4873 | 4798 | case 0x1ef0: |
| 4874 | | /* Switch 2k VROM at $0000 or $1000 */ |
| 4875 | 4799 | if (vrom_switch) |
| 4876 | | chr2_4 (space->machine, data, CHRROM); |
| 4800 | chr2_4(space->machine, data, CHRROM); |
| 4877 | 4801 | else |
| 4878 | | chr2_0 (space->machine, data, CHRROM); |
| 4802 | chr2_0(space->machine, data, CHRROM); |
| 4879 | 4803 | break; |
| 4880 | 4804 | case 0x1ef1: |
| 4881 | | /* Switch 2k VROM at $0800 or $1800 */ |
| 4882 | 4805 | if (vrom_switch) |
| 4883 | | chr2_6 (space->machine, data, CHRROM); |
| 4806 | chr2_6(space->machine, data, CHRROM); |
| 4884 | 4807 | else |
| 4885 | | chr2_2 (space->machine, data, CHRROM); |
| 4808 | chr2_2(space->machine, data, CHRROM); |
| 4886 | 4809 | break; |
| 4887 | 4810 | case 0x1ef2: |
| 4888 | | /* Switch 1k VROM at $1000 */ |
| 4889 | 4811 | chr1_x(space->machine, 4 ^ vrom_switch, data, CHRROM); |
| 4890 | | //ppu2c0x_set_videorom_bank(state->ppu, 4 ^ vrom_switch, 1, data, 64); |
| 4891 | 4812 | break; |
| 4892 | 4813 | case 0x1ef3: |
| 4893 | | /* Switch 1k VROM at $1400 */ |
| 4894 | 4814 | chr1_x(space->machine, 5 ^ vrom_switch, data, CHRROM); |
| 4895 | | // ppu2c0x_set_videorom_bank(state->ppu, 5 ^ vrom_switch, 1, data, 64); |
| 4896 | 4815 | break; |
| 4897 | 4816 | case 0x1ef4: |
| 4898 | | /* Switch 1k VROM at $1800 */ |
| 4899 | 4817 | chr1_x(space->machine, 6 ^ vrom_switch, data, CHRROM); |
| 4900 | | // ppu2c0x_set_videorom_bank(state->ppu, 6 ^ vrom_switch, 1, data, 64); |
| 4901 | 4818 | break; |
| 4902 | 4819 | case 0x1ef5: |
| 4903 | | /* Switch 1k VROM at $1c00 */ |
| 4904 | 4820 | chr1_x(space->machine, 7 ^ vrom_switch, data, CHRROM); |
| 4905 | | // ppu2c0x_set_videorom_bank(state->ppu, 7 ^ vrom_switch, 1, data, 64); |
| 4906 | 4821 | break; |
| 4907 | 4822 | case 0x1ef6: |
| 4908 | | (data&0x1)?set_nt_mirroring(PPU_MIRROR_VERT):set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4823 | set_nt_mirroring((data & 0x1) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 4909 | 4824 | //doc says 1= swapped. Causes in-game issues, but mostly fixes title screen |
| 4910 | 4825 | vrom_switch = ((data & 0x02) << 1); |
| 4911 | 4826 | break; |
| 4912 | 4827 | |
| 4913 | 4828 | case 0x1efa: |
| 4914 | | /* Switch 8k ROM at $8000 */ |
| 4915 | 4829 | prg8_89(space->machine, data >> 2); |
| 4916 | 4830 | break; |
| 4917 | 4831 | case 0x1efb: |
| 4918 | | /* Switch 8k ROM at $a000 */ |
| 4919 | 4832 | prg8_ab(space->machine, data >> 2); |
| 4920 | 4833 | break; |
| 4921 | 4834 | case 0x1efc: |
| 4922 | | /* Switch 8k ROM at $c000 */ |
| 4923 | 4835 | prg8_cd(space->machine, data >> 2); |
| 4924 | 4836 | break; |
| 4925 | 4837 | default: |
| r5944 | r5945 | |
| 4942 | 4854 | |
| 4943 | 4855 | static WRITE8_HANDLER( mapper83_l_w ) |
| 4944 | 4856 | { |
| 4945 | | mapper83_low_data[offset & 0x03] = data; |
| 4857 | mapper83_low_reg[offset & 0x03] = data; |
| 4946 | 4858 | } |
| 4947 | 4859 | |
| 4948 | 4860 | static READ8_HANDLER( mapper83_l_r ) |
| 4949 | 4861 | { |
| 4950 | | return mapper83_low_data[offset & 0x03]; |
| 4862 | return mapper83_low_reg[offset & 0x03]; |
| 4951 | 4863 | } |
| 4952 | 4864 | |
| 4953 | 4865 | static void mapper83_set_prg( running_machine *machine ) |
| 4954 | 4866 | { |
| 4955 | | prg16_89ab(machine, mapper83_data[8] & 0x3f); |
| 4956 | | prg16_cdef(machine, (mapper83_data[8] & 0x30) | 0x0f); |
| 4867 | prg16_89ab(machine, mapper83_reg[8] & 0x3f); |
| 4868 | prg16_cdef(machine, (mapper83_reg[8] & 0x30) | 0x0f); |
| 4957 | 4869 | } |
| 4958 | 4870 | |
| 4959 | 4871 | static void mapper83_set_chr( running_machine *machine ) |
| 4960 | 4872 | { |
| 4961 | | chr1_0(machine, mapper83_data[0] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4962 | | chr1_1(machine, mapper83_data[1] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4963 | | chr1_2(machine, mapper83_data[2] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4964 | | chr1_3(machine, mapper83_data[3] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4965 | | chr1_4(machine, mapper83_data[4] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4966 | | chr1_5(machine, mapper83_data[5] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4967 | | chr1_6(machine, mapper83_data[6] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4968 | | chr1_7(machine, mapper83_data[7] | ((mapper83_data[8] & 0x30) << 4), CHRROM); |
| 4873 | chr1_0(machine, mapper83_reg[0] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4874 | chr1_1(machine, mapper83_reg[1] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4875 | chr1_2(machine, mapper83_reg[2] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4876 | chr1_3(machine, mapper83_reg[3] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4877 | chr1_4(machine, mapper83_reg[4] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4878 | chr1_5(machine, mapper83_reg[5] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4879 | chr1_6(machine, mapper83_reg[6] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4880 | chr1_7(machine, mapper83_reg[7] | ((mapper83_reg[8] & 0x30) << 4), CHRROM); |
| 4969 | 4881 | } |
| 4970 | 4882 | |
| 4971 | 4883 | static WRITE8_HANDLER( mapper83_w ) |
| r5944 | r5945 | |
| 4978 | 4890 | case 0x3000: |
| 4979 | 4891 | case 0x30ff: |
| 4980 | 4892 | case 0x31ff: |
| 4981 | | mapper83_data[8] = data; |
| 4893 | mapper83_reg[8] = data; |
| 4982 | 4894 | mapper83_set_prg(space->machine); |
| 4983 | 4895 | mapper83_set_chr(space->machine); |
| 4984 | 4896 | break; |
| r5944 | r5945 | |
| 5023 | 4935 | case 0x0315: |
| 5024 | 4936 | case 0x0316: |
| 5025 | 4937 | case 0x0317: |
| 5026 | | mapper83_data[offset - 0x0310] = data; |
| 4938 | mapper83_reg[offset - 0x0310] = data; |
| 5027 | 4939 | mapper83_set_chr(space->machine); |
| 5028 | 4940 | break; |
| 5029 | 4941 | case 0x0318: |
| 5030 | | mapper83_data[9] = data; |
| 4942 | mapper83_reg[9] = data; |
| 5031 | 4943 | mapper83_set_prg(space->machine); |
| 5032 | 4944 | break; |
| 5033 | 4945 | } |
| r5944 | r5945 | |
| 5057 | 4969 | |
| 5058 | 4970 | static WRITE8_HANDLER( konami_vrc7_w ) |
| 5059 | 4971 | { |
| 4972 | UINT8 bank; |
| 5060 | 4973 | LOG_MMC(("konami_vrc7_w, offset: %04x, data: %02x\n", offset, data)); |
| 5061 | 4974 | |
| 5062 | 4975 | switch (offset & 0x7018) |
| r5944 | r5945 | |
| 5080 | 4993 | /* TODO: there are sound regs in here */ |
| 5081 | 4994 | |
| 5082 | 4995 | case 0x2000: |
| 5083 | | /* Switch 1k VROM at $0000 */ |
| 5084 | | chr1_0(space->machine, data, mmc_chr_source); |
| 5085 | | break; |
| 5086 | | case 0x2008: case 0x2010: case 0x2018: |
| 5087 | | /* Switch 1k VROM at $0400 */ |
| 5088 | | chr1_1(space->machine, data, mmc_chr_source); |
| 5089 | | break; |
| 4996 | case 0x2008: |
| 4997 | case 0x2010: |
| 4998 | case 0x2018: |
| 5090 | 4999 | case 0x3000: |
| 5091 | | /* Switch 1k VROM at $0800 */ |
| 5092 | | chr1_2(space->machine, data, mmc_chr_source); |
| 5093 | | break; |
| 5094 | | case 0x3008: case 0x3010: case 0x3018: |
| 5095 | | /* Switch 1k VROM at $0c00 */ |
| 5096 | | chr1_3(space->machine, data, mmc_chr_source); |
| 5097 | | break; |
| 5000 | case 0x3008: |
| 5001 | case 0x3010: |
| 5002 | case 0x3018: |
| 5098 | 5003 | case 0x4000: |
| 5099 | | /* Switch 1k VROM at $1000 */ |
| 5100 | | chr1_4(space->machine, data, mmc_chr_source); |
| 5101 | | break; |
| 5102 | | case 0x4008: case 0x4010: case 0x4018: |
| 5103 | | /* Switch 1k VROM at $1400 */ |
| 5104 | | chr1_5(space->machine, data, mmc_chr_source); |
| 5105 | | break; |
| 5004 | case 0x4008: |
| 5005 | case 0x4010: |
| 5006 | case 0x4018: |
| 5106 | 5007 | case 0x5000: |
| 5107 | | /* Switch 1k VROM at $1800 */ |
| 5108 | | chr1_6(space->machine, data, mmc_chr_source); |
| 5008 | case 0x5008: |
| 5009 | case 0x5010: |
| 5010 | case 0x5018: |
| 5011 | bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0018) ? 1 : 0); |
| 5012 | chr1_x(space->machine, bank, data, mmc_chr_source); |
| 5109 | 5013 | break; |
| 5110 | | case 0x5008: case 0x5010: case 0x5018: |
| 5111 | | /* Switch 1k VROM at $1c00 */ |
| 5112 | | chr1_7(space->machine, data, mmc_chr_source); |
| 5113 | | break; |
| 5114 | 5014 | |
| 5115 | 5015 | case 0x6000: |
| 5116 | 5016 | switch (data & 0x03) |
| r5944 | r5945 | |
| 5125 | 5025 | IRQ_count_latch = data; |
| 5126 | 5026 | break; |
| 5127 | 5027 | case 0x7000: |
| 5128 | | IRQ_count = IRQ_count_latch; |
| 5129 | 5028 | IRQ_enable = data & 0x02; |
| 5130 | 5029 | IRQ_enable_latch = data & 0x01; |
| 5030 | if (data & 0x02) |
| 5031 | IRQ_count = IRQ_count_latch; |
| 5131 | 5032 | break; |
| 5132 | 5033 | case 0x7008: case 0x7010: case 0x7018: |
| 5133 | 5034 | IRQ_enable = IRQ_enable_latch; |
| r5944 | r5945 | |
| 5199 | 5100 | switch (offset & 1) |
| 5200 | 5101 | { |
| 5201 | 5102 | case 0: |
| 5202 | | { |
| 5203 | | mmc_cmd1 = data & 7; |
| 5204 | | break; |
| 5205 | | } |
| 5103 | mmc_cmd1 = data & 7; |
| 5104 | break; |
| 5206 | 5105 | case 1: |
| 5106 | switch (mmc_cmd1) |
| 5207 | 5107 | { |
| 5208 | | switch (mmc_cmd1) |
| 5209 | | { |
| 5210 | | case 0: chr2_0(space->machine, data >> 1, CHRROM); break; |
| 5211 | | case 1: chr2_2(space->machine, data >> 1, CHRROM); break; |
| 5212 | | case 2: chr1_4(space->machine, data | 0x40, CHRROM); break; |
| 5213 | | case 3: chr1_5(space->machine, data | 0x40, CHRROM); break; |
| 5214 | | case 4: chr1_6(space->machine, data | 0x40, CHRROM); break; |
| 5215 | | case 5: chr1_7(space->machine, data | 0x40, CHRROM); break; |
| 5216 | | case 6: prg8_89(space->machine,data); break; |
| 5217 | | case 7: prg8_ab(space->machine,data); break; |
| 5218 | | } |
| 5219 | | break; |
| 5108 | case 0: chr2_0(space->machine, data >> 1, CHRROM); break; |
| 5109 | case 1: chr2_2(space->machine, data >> 1, CHRROM); break; |
| 5110 | case 2: chr1_4(space->machine, data | 0x40, CHRROM); break; |
| 5111 | case 3: chr1_5(space->machine, data | 0x40, CHRROM); break; |
| 5112 | case 4: chr1_6(space->machine, data | 0x40, CHRROM); break; |
| 5113 | case 5: chr1_7(space->machine, data | 0x40, CHRROM); break; |
| 5114 | case 6: prg8_89(space->machine,data); break; |
| 5115 | case 7: prg8_ab(space->machine,data); break; |
| 5220 | 5116 | } |
| 5117 | break; |
| 5221 | 5118 | } |
| 5222 | 5119 | } |
| 5223 | 5120 | |
| r5944 | r5945 | |
| 5372 | 5269 | |
| 5373 | 5270 | *************************************************************/ |
| 5374 | 5271 | |
| 5375 | | UINT8 map95_reg[4]; |
| 5376 | | |
| 5377 | 5272 | static WRITE8_HANDLER( mapper95_w ) |
| 5378 | 5273 | { |
| 5379 | 5274 | LOG_MMC(("mapper95_w, offset: %04x, data: %02x\n", offset, data)); |
| r5944 | r5945 | |
| 5398 | 5293 | case 4: |
| 5399 | 5294 | case 5: |
| 5400 | 5295 | chr1_x(space->machine, 2 + mmc_cmd1, data & 0x1f, CHRROM); |
| 5401 | | map95_reg[mmc_cmd1 - 2] = data & 0x20; |
| 5296 | mapper95_reg[mmc_cmd1 - 2] = data & 0x20; |
| 5402 | 5297 | if (!(mmc_cmd1 & 0x80)) |
| 5403 | 5298 | { |
| 5404 | | set_nt_page(0, CIRAM, map95_reg[0] ? 1 : 0, 1); |
| 5405 | | set_nt_page(1, CIRAM, map95_reg[1] ? 1 : 0, 1); |
| 5406 | | set_nt_page(2, CIRAM, map95_reg[2] ? 1 : 0, 1); |
| 5407 | | set_nt_page(3, CIRAM, map95_reg[3] ? 1 : 0, 1); |
| 5299 | set_nt_page(0, CIRAM, mapper95_reg[0] ? 1 : 0, 1); |
| 5300 | set_nt_page(1, CIRAM, mapper95_reg[1] ? 1 : 0, 1); |
| 5301 | set_nt_page(2, CIRAM, mapper95_reg[2] ? 1 : 0, 1); |
| 5302 | set_nt_page(3, CIRAM, mapper95_reg[3] ? 1 : 0, 1); |
| 5408 | 5303 | } |
| 5409 | 5304 | else |
| 5410 | 5305 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| r5944 | r5945 | |
| 5561 | 5456 | { |
| 5562 | 5457 | if (data & 0x08) |
| 5563 | 5458 | { |
| 5564 | | mmc_bank_latch1 = ((data & 0x07) << 4) | (mmc_bank_latch1 & 0x0f); |
| 5565 | | prg16_89ab(space->machine, mmc_bank_latch1); |
| 5459 | prg_bank[0] = ((data & 0x07) << 4) | (prg_bank[0] & 0x0f); |
| 5460 | prg16_89ab(space->machine, prg_bank[0]); |
| 5566 | 5461 | prg16_cdef(space->machine, ((data & 0x07) << 4) | 0x0f); |
| 5567 | 5462 | } |
| 5568 | 5463 | |
| 5569 | 5464 | } |
| 5570 | 5465 | else |
| 5571 | 5466 | { |
| 5572 | | mmc_bank_latch1 = (mmc_bank_latch1 & 0x70) | (data & 0x0f); |
| 5573 | | prg16_89ab(space->machine, mmc_bank_latch1); |
| 5467 | prg_bank[0] = (prg_bank[0] & 0x70) | (data & 0x0f); |
| 5468 | prg16_89ab(space->machine, prg_bank[0]); |
| 5574 | 5469 | } |
| 5575 | 5470 | } |
| 5576 | 5471 | |
| r5944 | r5945 | |
| 5757 | 5652 | Known Boards: Unknown Bootleg Board |
| 5758 | 5653 | Games: The Lion King |
| 5759 | 5654 | |
| 5760 | | MMC3 clone |
| 5655 | MMC3 clone. |
| 5761 | 5656 | |
| 5762 | | In MESS: Unsupported. |
| 5657 | In MESS: Supported. |
| 5763 | 5658 | |
| 5764 | 5659 | *************************************************************/ |
| 5765 | 5660 | |
| 5661 | static WRITE8_HANDLER( mapper114_m_w ) |
| 5662 | { |
| 5663 | LOG_MMC(("mapper114_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5664 | |
| 5665 | map114_reg = data; |
| 5666 | |
| 5667 | if (map114_reg & 0x80) |
| 5668 | { |
| 5669 | prg16_89ab(space->machine, data & 0x1f); |
| 5670 | prg16_cdef(space->machine, data & 0x1f); |
| 5671 | } |
| 5672 | else |
| 5673 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 5674 | |
| 5675 | } |
| 5676 | |
| 5677 | static WRITE8_HANDLER( mapper114_w ) |
| 5678 | { |
| 5679 | static const UINT8 conv_table[8] = {0, 3, 1, 5, 6, 7, 2, 4}; |
| 5680 | LOG_MMC(("mapper114_w, offset: %04x, data: %02x\n", offset, data)); |
| 5681 | |
| 5682 | if (offset < 0x6000) |
| 5683 | { |
| 5684 | switch (offset & 0x6000) |
| 5685 | { |
| 5686 | case 0x0000: |
| 5687 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 5688 | break; |
| 5689 | case 0x2000: |
| 5690 | map114_reg_enabled = 1; |
| 5691 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 5692 | mapper4_w(space, 0x8000, data); |
| 5693 | break; |
| 5694 | case 0x4000: |
| 5695 | if (map114_reg_enabled && (map114_reg & 0x80) == 0) |
| 5696 | { |
| 5697 | map114_reg_enabled = 0; |
| 5698 | mapper4_w(space, 0x8001, data); |
| 5699 | } |
| 5700 | break; |
| 5701 | } |
| 5702 | } |
| 5703 | else |
| 5704 | { |
| 5705 | switch (offset & 0x03) |
| 5706 | { |
| 5707 | case 0x02: |
| 5708 | mapper4_w(space, 0xe000, data); |
| 5709 | break; |
| 5710 | case 0x03: |
| 5711 | mapper4_w(space, 0xe001, data); |
| 5712 | mapper4_w(space, 0xc000, data); |
| 5713 | mapper4_w(space, 0xc001, data); |
| 5714 | break; |
| 5715 | } |
| 5716 | } |
| 5717 | } |
| 5718 | |
| 5766 | 5719 | /************************************************************* |
| 5767 | 5720 | |
| 5768 | 5721 | Mapper 115 (formerly 248) |
| r5944 | r5945 | |
| 5779 | 5732 | |
| 5780 | 5733 | static void mapper115_set_prg( running_machine *machine ) |
| 5781 | 5734 | { |
| 5782 | | if (MMC1_bank4 & 0x80) |
| 5735 | if (mapper115_reg[3] & 0x80) |
| 5783 | 5736 | { |
| 5784 | | prg16_89ab(machine, MMC1_bank4 & 0x0f); |
| 5737 | prg16_89ab(machine, mapper115_reg[3] & 0x0f); |
| 5785 | 5738 | } |
| 5786 | 5739 | else |
| 5787 | 5740 | { |
| 5788 | | prg8_89(machine, MMC1_bank2 & 0x1f); |
| 5789 | | prg8_ab(machine, MMC1_bank3 & 0x1f); |
| 5741 | prg8_89(machine, mapper115_reg[1] & 0x1f); |
| 5742 | prg8_ab(machine, mapper115_reg[2] & 0x1f); |
| 5790 | 5743 | } |
| 5791 | 5744 | } |
| 5792 | 5745 | |
| r5944 | r5945 | |
| 5794 | 5747 | { |
| 5795 | 5748 | LOG_MMC(("mapper115_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5796 | 5749 | |
| 5797 | | MMC1_bank4 = data; |
| 5750 | mapper115_reg[3] = data; |
| 5798 | 5751 | mapper115_set_prg(space->machine); |
| 5799 | 5752 | } |
| 5800 | 5753 | |
| r5944 | r5945 | |
| 5805 | 5758 | switch (offset & 0x7001) |
| 5806 | 5759 | { |
| 5807 | 5760 | case 0x0000: |
| 5808 | | MMC1_bank1 = data; |
| 5761 | mapper115_reg[0] = data; |
| 5809 | 5762 | break; |
| 5810 | 5763 | case 0x0001: |
| 5811 | | switch (MMC1_bank1 & 0x07) |
| 5764 | switch (mapper115_reg[0] & 0x07) |
| 5812 | 5765 | { |
| 5813 | 5766 | case 0: |
| 5814 | 5767 | chr2_0(space->machine, data >> 1, CHRROM); |
| r5944 | r5945 | |
| 5829 | 5782 | chr1_7(space->machine, data, CHRROM); |
| 5830 | 5783 | break; |
| 5831 | 5784 | case 6: |
| 5832 | | MMC1_bank2 = data; |
| 5785 | mapper115_reg[1] = data; |
| 5833 | 5786 | mapper115_set_prg(space->machine); |
| 5834 | 5787 | break; |
| 5835 | 5788 | case 7: |
| 5836 | | MMC1_bank3 = data; |
| 5789 | mapper115_reg[2] = data; |
| 5837 | 5790 | mapper115_set_prg(space->machine); |
| 5838 | 5791 | break; |
| 5839 | 5792 | } |
| r5944 | r5945 | |
| 5914 | 5867 | |
| 5915 | 5868 | static WRITE8_HANDLER( mapper118_w ) |
| 5916 | 5869 | { |
| 5917 | | static UINT8 last_bank = 0xff; |
| 5918 | 5870 | LOG_MMC(("mapper118_w, offset: %04x, data: %02x\n", offset, data)); |
| 5919 | 5871 | |
| 5920 | | //uses just bits 14, 13, and 0 |
| 5921 | 5872 | switch (offset & 0x6001) |
| 5922 | 5873 | { |
| 5923 | | case 0x0000: /* $8000 */ |
| 5924 | | MMC3_cmd = data; |
| 5925 | | |
| 5926 | | /* Toggle between switching $8000 and $c000 */ |
| 5927 | | if (last_bank != (data & 0xc0)) |
| 5928 | | { |
| 5929 | | /* Reset the banks */ |
| 5930 | | mapper4_set_prg(space->machine); |
| 5931 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 5932 | | } |
| 5933 | | last_bank = data & 0xc0; |
| 5934 | | break; |
| 5935 | | |
| 5936 | | case 0x0001: /* $8001 */ |
| 5937 | | { |
| 5938 | | UINT8 cmd = MMC3_cmd & 0x07; |
| 5939 | | switch (cmd) |
| 5940 | | { |
| 5941 | | case 0: case 1: |
| 5942 | | data &= 0xfe; |
| 5943 | | MMC3_chr[cmd] = data; |
| 5944 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 5945 | | break; |
| 5946 | | |
| 5947 | | case 2: case 3: case 4: case 5: |
| 5948 | | MMC3_chr[cmd] = data; |
| 5949 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 5950 | | break; |
| 5951 | | |
| 5952 | | case 6: |
| 5953 | | MMC3_prg0 = data; |
| 5954 | | mapper4_set_prg(space->machine); |
| 5955 | | break; |
| 5956 | | |
| 5957 | | case 7: |
| 5958 | | MMC3_prg1 = data; |
| 5959 | | mapper4_set_prg(space->machine); |
| 5960 | | break; |
| 5961 | | } |
| 5962 | | break; |
| 5963 | | } |
| 5964 | 5874 | case 0x2000: /* $a000 */ |
| 5965 | 5875 | LOG_MMC((" mapper 118 mirroring: %02x\n", data)); |
| 5966 | 5876 | switch (data & 0x02) |
| r5944 | r5945 | |
| 5970 | 5880 | } |
| 5971 | 5881 | break; |
| 5972 | 5882 | |
| 5973 | | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 5974 | | nes.mid_ram_enable = data; |
| 5975 | | LOG_MMC((" MMC3 mid_ram enable: %02x\n", data)); |
| 5976 | | break; |
| 5977 | | |
| 5978 | 5883 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 5979 | 5884 | IRQ_count = data; |
| 5980 | | LOG_MMC((" MMC3 set irq count: %02x\n", data)); |
| 5981 | 5885 | break; |
| 5982 | 5886 | |
| 5983 | 5887 | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 5984 | 5888 | IRQ_count_latch = data; |
| 5985 | | LOG_MMC((" MMC3 set irq count latch: %02x\n", data)); |
| 5986 | 5889 | break; |
| 5987 | 5890 | |
| 5988 | | case 0x6000: /* $e000 - Disable IRQs */ |
| 5989 | | IRQ_enable = 0; |
| 5990 | | IRQ_count = IRQ_count_latch; /* TODO: verify this */ |
| 5991 | | LOG_MMC((" MMC3 disable irqs: %02x\n", data)); |
| 5992 | | break; |
| 5993 | | |
| 5994 | | case 0x6001: /* $e001 - Enable IRQs */ |
| 5995 | | IRQ_enable = 1; |
| 5996 | | LOG_MMC((" MMC3 enable irqs: %02x\n", data)); |
| 5997 | | break; |
| 5998 | | |
| 5999 | 5891 | default: |
| 6000 | | logerror("mapper4_w uncaught: %04x value: %02x\n", offset + 0x8000, data); |
| 5892 | mapper4_w(space, offset, data); |
| 6001 | 5893 | break; |
| 6002 | 5894 | } |
| 6003 | 5895 | } |
| r5944 | r5945 | |
| 6017 | 5909 | { |
| 6018 | 5910 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 6019 | 5911 | |
| 6020 | | if (MMC3_chr[0] & 0x40) |
| 6021 | | chr2_x(machine, chr_page ^ 0, (MMC3_chr[0] >> 1) & 0x03, CHRRAM); |
| 5912 | if (vrom_bank[0] & 0x40) |
| 5913 | chr2_x(machine, chr_page ^ 0, (vrom_bank[0] >> 1) & 0x03, CHRRAM); |
| 6022 | 5914 | else |
| 6023 | | chr2_x(machine, chr_page ^ 0, ((MMC3_chr[0] & 0x3f) >> 1), CHRROM); |
| 5915 | chr2_x(machine, chr_page ^ 0, ((vrom_bank[0] & 0x3f) >> 1), CHRROM); |
| 6024 | 5916 | |
| 6025 | | if (MMC3_chr[1] & 0x40) |
| 6026 | | chr2_x(machine, chr_page ^ 2, (MMC3_chr[1] >> 1) & 0x03, CHRRAM); |
| 5917 | if (vrom_bank[1] & 0x40) |
| 5918 | chr2_x(machine, chr_page ^ 2, (vrom_bank[1] >> 1) & 0x03, CHRRAM); |
| 6027 | 5919 | else |
| 6028 | | chr2_x(machine, chr_page ^ 2, ((MMC3_chr[1] & 0x3f) >> 1), CHRROM); |
| 5920 | chr2_x(machine, chr_page ^ 2, ((vrom_bank[1] & 0x3f) >> 1), CHRROM); |
| 6029 | 5921 | |
| 6030 | | if (MMC3_chr[2] & 0x40) |
| 6031 | | chr1_x(machine, chr_page ^ 4, MMC3_chr[2] & 0x07, CHRRAM); |
| 5922 | if (vrom_bank[2] & 0x40) |
| 5923 | chr1_x(machine, chr_page ^ 4, vrom_bank[2] & 0x07, CHRRAM); |
| 6032 | 5924 | else |
| 6033 | | chr1_x(machine, chr_page ^ 4, MMC3_chr[2] & 0x3f, CHRROM); |
| 5925 | chr1_x(machine, chr_page ^ 4, vrom_bank[2] & 0x3f, CHRROM); |
| 6034 | 5926 | |
| 6035 | | if (MMC3_chr[3] & 0x40) |
| 6036 | | chr1_x(machine, chr_page ^ 5, MMC3_chr[3] & 0x07, CHRRAM); |
| 5927 | if (vrom_bank[3] & 0x40) |
| 5928 | chr1_x(machine, chr_page ^ 5, vrom_bank[3] & 0x07, CHRRAM); |
| 6037 | 5929 | else |
| 6038 | | chr1_x(machine, chr_page ^ 5, MMC3_chr[3] & 0x3f, CHRROM); |
| 5930 | chr1_x(machine, chr_page ^ 5, vrom_bank[3] & 0x3f, CHRROM); |
| 6039 | 5931 | |
| 6040 | | if (MMC3_chr[4] & 0x40) |
| 6041 | | chr1_x(machine, chr_page ^ 6, MMC3_chr[4] & 0x07, CHRRAM); |
| 5932 | if (vrom_bank[4] & 0x40) |
| 5933 | chr1_x(machine, chr_page ^ 6, vrom_bank[4] & 0x07, CHRRAM); |
| 6042 | 5934 | else |
| 6043 | | chr1_x(machine, chr_page ^ 6, MMC3_chr[4] & 0x3f, CHRROM); |
| 5935 | chr1_x(machine, chr_page ^ 6, vrom_bank[4] & 0x3f, CHRROM); |
| 6044 | 5936 | |
| 6045 | | if (MMC3_chr[5] & 0x40) |
| 6046 | | chr1_x(machine, chr_page ^ 7, MMC3_chr[5] & 0x07, CHRRAM); |
| 5937 | if (vrom_bank[5] & 0x40) |
| 5938 | chr1_x(machine, chr_page ^ 7, vrom_bank[5] & 0x07, CHRRAM); |
| 6047 | 5939 | else |
| 6048 | | chr1_x(machine, chr_page ^ 7, MMC3_chr[5] & 0x3f, CHRROM); |
| 5940 | chr1_x(machine, chr_page ^ 7, vrom_bank[5] & 0x3f, CHRROM); |
| 6049 | 5941 | } |
| 6050 | 5942 | |
| 6051 | 5943 | static WRITE8_HANDLER( mapper119_w ) |
| r5944 | r5945 | |
| 6053 | 5945 | static UINT8 last_bank = 0xff; |
| 6054 | 5946 | LOG_MMC(("mapper119_w, offset: %04x, data: %02x\n", offset, data)); |
| 6055 | 5947 | |
| 6056 | | //only bits 14,13, and 0 matter for offset! |
| 6057 | 5948 | switch (offset & 0x6001) |
| 6058 | 5949 | { |
| 6059 | 5950 | case 0x0000: /* $8000 */ |
| r5944 | r5945 | |
| 6063 | 5954 | if (last_bank != (data & 0xc0)) |
| 6064 | 5955 | { |
| 6065 | 5956 | /* Reset the banks */ |
| 6066 | | mapper4_set_prg(space->machine); |
| 5957 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6067 | 5958 | mapper119_set_chr(space->machine); |
| 6068 | 5959 | LOG_MMC((" MMC3 reset banks\n")); |
| 6069 | 5960 | } |
| r5944 | r5945 | |
| 6075 | 5966 | UINT8 cmd = MMC3_cmd & 0x07; |
| 6076 | 5967 | switch (cmd) |
| 6077 | 5968 | { |
| 6078 | | case 0: case 1: |
| 6079 | | MMC3_chr[cmd] = data; |
| 6080 | | mapper119_set_chr(space->machine); |
| 6081 | | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 6082 | | break; |
| 6083 | | |
| 5969 | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 6084 | 5970 | case 2: case 3: case 4: case 5: |
| 6085 | | MMC3_chr[cmd] = data; |
| 5971 | vrom_bank[cmd] = data; |
| 6086 | 5972 | mapper119_set_chr(space->machine); |
| 6087 | | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 6088 | 5973 | break; |
| 6089 | | |
| 6090 | 5974 | case 6: |
| 6091 | | MMC3_prg0 = data; |
| 6092 | | mapper4_set_prg(space->machine); |
| 6093 | | break; |
| 6094 | | |
| 6095 | 5975 | case 7: |
| 6096 | | MMC3_prg1 = data; |
| 6097 | | mapper4_set_prg(space->machine); |
| 5976 | prg_bank[cmd - 6] = data; |
| 5977 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6098 | 5978 | break; |
| 6099 | 5979 | } |
| 6100 | 5980 | break; |
| 6101 | 5981 | } |
| 6102 | | case 0x2000: /* $a000 */ |
| 6103 | | if (data & 0x40) |
| 6104 | | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 6105 | | else |
| 6106 | | { |
| 6107 | | if (data & 0x01) |
| 6108 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 6109 | | else |
| 6110 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 6111 | | } |
| 6112 | | break; |
| 6113 | | |
| 6114 | | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 6115 | | nes.mid_ram_enable = data; |
| 6116 | | LOG_MMC((" MMC3 mid_ram enable: %02x\n", 0)); |
| 6117 | | break; |
| 6118 | | |
| 6119 | | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 6120 | | IRQ_count_latch = data; |
| 6121 | | // LOG_MMC((" MMC3 set irq count latch: %02x (scanline %d)\n", data, ppu2c0x_get_current_scanline(0))); |
| 6122 | | break; |
| 6123 | | |
| 6124 | | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 6125 | | IRQ_reload = 1; |
| 6126 | | // LOG_MMC((" MMC3 set irq reload (scanline %d)\n", ppu2c0x_get_current_scanline(0))); |
| 6127 | | break; |
| 6128 | | |
| 6129 | | case 0x6000: /* $e000 - Disable IRQs */ |
| 6130 | | IRQ_enable = 0; |
| 6131 | | LOG_MMC((" MMC3 disable irqs\n")); |
| 6132 | | break; |
| 6133 | | |
| 6134 | | case 0x6001: /* $e001 - Enable IRQs */ |
| 6135 | | IRQ_enable = 1; |
| 6136 | | LOG_MMC((" MMC3 enable irqs\n")); |
| 6137 | | break; |
| 6138 | | |
| 6139 | 5982 | default: |
| 6140 | | logerror("mapper119_w uncaught: %04x value: %02x\n", offset + 0x8000, data); |
| 5983 | mapper4_w(space, offset, data); |
| 6141 | 5984 | break; |
| 6142 | 5985 | } |
| 6143 | 5986 | } |
| r5944 | r5945 | |
| 6291 | 6134 | |
| 6292 | 6135 | *************************************************************/ |
| 6293 | 6136 | |
| 6294 | | UINT8 txc_reg[4]; // also used by mappers 172 & 173 |
| 6295 | | |
| 6296 | 6137 | static WRITE8_HANDLER( mapper132_l_w ) |
| 6297 | 6138 | { |
| 6298 | 6139 | LOG_MMC(("mapper132_l_w, offset: %04x, data: %02x\n", offset, data)); |
| r5944 | r5945 | |
| 6307 | 6148 | |
| 6308 | 6149 | if (offset == 0x0000) |
| 6309 | 6150 | return (txc_reg[1] ^ txc_reg[2]) | 0x40; |
| 6310 | | |
| 6311 | 6151 | else |
| 6312 | 6152 | return 0x00; |
| 6313 | 6153 | } |
| r5944 | r5945 | |
| 6339 | 6179 | chr8(space->machine, data, CHRROM); |
| 6340 | 6180 | } |
| 6341 | 6181 | |
| 6182 | static WRITE8_HANDLER( mapper133_m_w ) |
| 6183 | { |
| 6184 | LOG_MMC(("mapper133_l_w %04x:%02x\n", offset, data)); |
| 6185 | |
| 6186 | if (offset == 0) |
| 6187 | { |
| 6188 | prg32(space->machine, data >> 2); |
| 6189 | chr8(space->machine, data, CHRROM);} |
| 6190 | } |
| 6191 | |
| 6342 | 6192 | /************************************************************* |
| 6343 | 6193 | |
| 6344 | 6194 | Mapper 134 |
| r5944 | r5945 | |
| 6406 | 6256 | |
| 6407 | 6257 | *************************************************************/ |
| 6408 | 6258 | |
| 6409 | | UINT8 sachen_regs[8]; // used by mappers 137, 138, 139, 141 |
| 6410 | | |
| 6411 | 6259 | static void sachen_set_mirror( UINT8 nt ) // used by mappers 137, 138, 139, 141 |
| 6412 | 6260 | { |
| 6413 | 6261 | switch (nt) |
| r5944 | r5945 | |
| 6443 | 6291 | mmc_cmd1 = data & 0x07; |
| 6444 | 6292 | else |
| 6445 | 6293 | { |
| 6446 | | sachen_regs[mmc_cmd1] = data; |
| 6294 | sachen_reg[mmc_cmd1] = data; |
| 6447 | 6295 | |
| 6448 | 6296 | switch (mmc_cmd1) |
| 6449 | 6297 | { |
| r5944 | r5945 | |
| 6456 | 6304 | default: |
| 6457 | 6305 | if (mmc_chr_source == CHRROM) |
| 6458 | 6306 | { |
| 6459 | | chr1_0(space->machine, (sachen_regs[0] & 0x07), CHRROM); |
| 6460 | | chr1_1(space->machine, (sachen_regs[1] & 0x07) | (sachen_regs[4] << 4 & 0x10), CHRROM); |
| 6461 | | chr1_2(space->machine, (sachen_regs[2] & 0x07) | (sachen_regs[4] << 3 & 0x10), CHRROM); |
| 6462 | | chr1_3(space->machine, (sachen_regs[3] & 0x07) | (sachen_regs[4] << 2 & 0x10) | (sachen_regs[6] << 3 & 0x08), CHRROM); |
| 6307 | chr1_0(space->machine, (sachen_reg[0] & 0x07), CHRROM); |
| 6308 | chr1_1(space->machine, (sachen_reg[1] & 0x07) | (sachen_reg[4] << 4 & 0x10), CHRROM); |
| 6309 | chr1_2(space->machine, (sachen_reg[2] & 0x07) | (sachen_reg[4] << 3 & 0x10), CHRROM); |
| 6310 | chr1_3(space->machine, (sachen_reg[3] & 0x07) | (sachen_reg[4] << 2 & 0x10) | (sachen_reg[6] << 3 & 0x08), CHRROM); |
| 6463 | 6311 | } |
| 6464 | 6312 | break; |
| 6465 | 6313 | } |
| r5944 | r5945 | |
| 6471 | 6319 | { |
| 6472 | 6320 | LOG_MMC(("mapper137_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6473 | 6321 | |
| 6474 | | mapper137_l_w(space, (offset + 0x100) & 0x01, data); |
| 6322 | mapper137_l_w(space, offset + 0x100, data); |
| 6475 | 6323 | } |
| 6476 | 6324 | |
| 6477 | 6325 | /************************************************************* |
| r5944 | r5945 | |
| 6498 | 6346 | mmc_cmd1 = data & 0x07; |
| 6499 | 6347 | else |
| 6500 | 6348 | { |
| 6501 | | sachen_regs[mmc_cmd1] = data; |
| 6349 | sachen_reg[mmc_cmd1] = data; |
| 6502 | 6350 | |
| 6503 | 6351 | switch (mmc_cmd1) |
| 6504 | 6352 | { |
| r5944 | r5945 | |
| 6511 | 6359 | default: |
| 6512 | 6360 | if (mmc_chr_source == CHRROM) |
| 6513 | 6361 | { |
| 6514 | | bank_helper1 = sachen_regs[7] & 0x01; |
| 6515 | | bank_helper2 = (sachen_regs[4] & 0x07) << 3; |
| 6516 | | chr2_0(space->machine, ((sachen_regs[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2), CHRROM); |
| 6517 | | chr2_2(space->machine, ((sachen_regs[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2), CHRROM); |
| 6518 | | chr2_4(space->machine, ((sachen_regs[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2), CHRROM); |
| 6519 | | chr2_6(space->machine, ((sachen_regs[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2), CHRROM); |
| 6362 | bank_helper1 = sachen_reg[7] & 0x01; |
| 6363 | bank_helper2 = (sachen_reg[4] & 0x07) << 3; |
| 6364 | chr2_0(space->machine, ((sachen_reg[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2), CHRROM); |
| 6365 | chr2_2(space->machine, ((sachen_reg[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2), CHRROM); |
| 6366 | chr2_4(space->machine, ((sachen_reg[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2), CHRROM); |
| 6367 | chr2_6(space->machine, ((sachen_reg[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2), CHRROM); |
| 6520 | 6368 | } |
| 6521 | 6369 | break; |
| 6522 | 6370 | } |
| r5944 | r5945 | |
| 6528 | 6376 | { |
| 6529 | 6377 | LOG_MMC(("mapper138_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6530 | 6378 | |
| 6531 | | mapper138_l_w(space, offset & 0x01, data); |
| 6379 | mapper138_l_w(space, offset + 0x100, data); |
| 6532 | 6380 | } |
| 6533 | 6381 | |
| 6534 | 6382 | /************************************************************* |
| r5944 | r5945 | |
| 6555 | 6403 | mmc_cmd1 = data & 0x07; |
| 6556 | 6404 | else |
| 6557 | 6405 | { |
| 6558 | | sachen_regs[mmc_cmd1] = data; |
| 6406 | sachen_reg[mmc_cmd1] = data; |
| 6559 | 6407 | |
| 6560 | 6408 | switch (mmc_cmd1) |
| 6561 | 6409 | { |
| r5944 | r5945 | |
| 6568 | 6416 | default: |
| 6569 | 6417 | if (mmc_chr_source == CHRROM) |
| 6570 | 6418 | { |
| 6571 | | bank_helper1 = sachen_regs[7] & 0x01; |
| 6572 | | bank_helper2 = (sachen_regs[4] & 0x07) << 3; |
| 6573 | | chr2_0(space->machine, ((sachen_regs[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 2, CHRROM); |
| 6574 | | chr2_2(space->machine, ((sachen_regs[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2) << 2 | 0x01, CHRROM); |
| 6575 | | chr2_4(space->machine, ((sachen_regs[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2) << 2 | 0x02, CHRROM) ; |
| 6576 | | chr2_6(space->machine, ((sachen_regs[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2) << 2 | 0x03, CHRROM); |
| 6419 | bank_helper1 = sachen_reg[7] & 0x01; |
| 6420 | bank_helper2 = (sachen_reg[4] & 0x07) << 3; |
| 6421 | chr2_0(space->machine, ((sachen_reg[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 2, CHRROM); |
| 6422 | chr2_2(space->machine, ((sachen_reg[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2) << 2 | 0x01, CHRROM); |
| 6423 | chr2_4(space->machine, ((sachen_reg[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2) << 2 | 0x02, CHRROM) ; |
| 6424 | chr2_6(space->machine, ((sachen_reg[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2) << 2 | 0x03, CHRROM); |
| 6577 | 6425 | } |
| 6578 | 6426 | break; |
| 6579 | 6427 | } |
| r5944 | r5945 | |
| 6585 | 6433 | { |
| 6586 | 6434 | LOG_MMC(("mapper139_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6587 | 6435 | |
| 6588 | | mapper139_l_w(space, (offset + 0x100) & 0x01, data); |
| 6436 | mapper139_l_w(space, offset + 0x100, data); |
| 6589 | 6437 | } |
| 6590 | 6438 | |
| 6591 | 6439 | /************************************************************* |
| r5944 | r5945 | |
| 6632 | 6480 | mmc_cmd1 = data & 0x07; |
| 6633 | 6481 | else |
| 6634 | 6482 | { |
| 6635 | | sachen_regs[mmc_cmd1] = data; |
| 6483 | sachen_reg[mmc_cmd1] = data; |
| 6636 | 6484 | |
| 6637 | 6485 | switch (mmc_cmd1) |
| 6638 | 6486 | { |
| r5944 | r5945 | |
| 6645 | 6493 | default: |
| 6646 | 6494 | if (mmc_chr_source == CHRROM) |
| 6647 | 6495 | { |
| 6648 | | bank_helper1 = sachen_regs[7] & 0x01; |
| 6649 | | bank_helper2 = (sachen_regs[4] & 0x07) << 3; |
| 6650 | | chr2_0(space->machine, ((sachen_regs[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 1, mmc_chr_source); |
| 6651 | | chr2_2(space->machine, ((sachen_regs[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2) << 1 | 0x01, mmc_chr_source); |
| 6652 | | chr2_4(space->machine, ((sachen_regs[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2) << 1, mmc_chr_source); |
| 6653 | | chr2_6(space->machine, ((sachen_regs[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2) << 1 | 0x01, mmc_chr_source); |
| 6496 | bank_helper1 = sachen_reg[7] & 0x01; |
| 6497 | bank_helper2 = (sachen_reg[4] & 0x07) << 3; |
| 6498 | chr2_0(space->machine, ((sachen_reg[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 1, mmc_chr_source); |
| 6499 | chr2_2(space->machine, ((sachen_reg[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2) << 1 | 0x01, mmc_chr_source); |
| 6500 | chr2_4(space->machine, ((sachen_reg[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2) << 1, mmc_chr_source); |
| 6501 | chr2_6(space->machine, ((sachen_reg[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2) << 1 | 0x01, mmc_chr_source); |
| 6654 | 6502 | } |
| 6655 | 6503 | break; |
| 6656 | 6504 | } |
| r5944 | r5945 | |
| 6662 | 6510 | { |
| 6663 | 6511 | LOG_MMC(("mapper141_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6664 | 6512 | |
| 6665 | | mapper141_l_w(space, (offset + 0x100) & 0x01, data); |
| 6513 | mapper141_l_w(space, offset + 0x100, data); |
| 6666 | 6514 | } |
| 6667 | 6515 | |
| 6668 | 6516 | /************************************************************* |
| r5944 | r5945 | |
| 6722 | 6570 | |
| 6723 | 6571 | data = data |(memory_read_byte(space, offset) & 1); |
| 6724 | 6572 | |
| 6725 | | /* Switch 8k VROM bank */ |
| 6726 | 6573 | chr8(space->machine, data >> 4, CHRROM); |
| 6727 | | |
| 6728 | | /* Switch 32k prg bank */ |
| 6729 | 6574 | prg32(space->machine, data & 0x07); |
| 6730 | 6575 | } |
| 6731 | 6576 | |
| r5944 | r5945 | |
| 6793 | 6638 | { |
| 6794 | 6639 | LOG_MMC(("mapper147_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6795 | 6640 | |
| 6796 | | mapper147_l_w(space, offset & 0x01, data); |
| 6641 | mapper147_l_w(space, offset + 0x100, data); |
| 6797 | 6642 | } |
| 6798 | 6643 | |
| 6799 | 6644 | static WRITE8_HANDLER( mapper147_w ) |
| 6800 | 6645 | { |
| 6801 | 6646 | LOG_MMC(("mapper147_w, offset: %04x, data: %02x\n", offset, data)); |
| 6802 | 6647 | |
| 6803 | | mapper147_l_w(space, (offset + 0x100) & 0x01, data); |
| 6648 | mapper147_l_w(space, offset + 0x100, data); |
| 6804 | 6649 | } |
| 6805 | 6650 | |
| 6806 | 6651 | /************************************************************* |
| r5944 | r5945 | |
| 6853 | 6698 | Games: Chess Academy, Chinese Checkers Jpn, Mahjong Academy, |
| 6854 | 6699 | Olympic IQ, Poker II, Tasac |
| 6855 | 6700 | |
| 6856 | | Still investigating this mapper... |
| 6701 | In MESS: Supported. |
| 6857 | 6702 | |
| 6858 | | In MESS: Preliminary Support. |
| 6859 | | |
| 6860 | 6703 | *************************************************************/ |
| 6861 | 6704 | |
| 6862 | 6705 | static WRITE8_HANDLER( mapper150_l_w ) |
| r5944 | r5945 | |
| 6874 | 6717 | switch (mmc_cmd1) |
| 6875 | 6718 | { |
| 6876 | 6719 | case 0x02: |
| 6720 | vrom_bank[0] = (vrom_bank[0] & ~0x08) | ((data << 3) & 0x08); |
| 6721 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 6877 | 6722 | prg32(space->machine, data & 0x01); |
| 6878 | | chr8(space->machine, (mmc_bank_latch1 & ~0x08) | ((data << 3) & 0x08), CHRROM); |
| 6879 | 6723 | break; |
| 6880 | 6724 | case 0x04: |
| 6881 | | chr8(space->machine, (mmc_bank_latch1 & ~0x04) | ((data << 2) & 0x04), CHRROM); |
| 6725 | vrom_bank[0] = (vrom_bank[0] & ~0x04) | ((data << 2) & 0x04); |
| 6726 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 6882 | 6727 | break; |
| 6883 | 6728 | case 0x05: |
| 6884 | 6729 | prg32(space->machine, data & 0x07); |
| 6885 | 6730 | break; |
| 6886 | 6731 | case 0x06: |
| 6887 | | chr8(space->machine, (mmc_bank_latch1 & ~0x03) | (data << 0 & 0x03), CHRROM); |
| 6732 | vrom_bank[0] = (vrom_bank[0] & ~0x03) | (data << 0 & 0x03); |
| 6733 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 6888 | 6734 | break; |
| 6889 | 6735 | case 0x07: |
| 6890 | 6736 | sachen_set_mirror((data >> 1) & 0x03); |
| r5944 | r5945 | |
| 6900 | 6746 | { |
| 6901 | 6747 | LOG_MMC(("mapper150_l_r, offset: %04x", offset)); |
| 6902 | 6748 | |
| 6903 | | /* read happens only if we are at 0x4100 + k * 0x200, |
| 6904 | | but 0x4100 is offset = 0 */ |
| 6749 | /* read happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6905 | 6750 | if (!(offset & 0x100)) |
| 6906 | 6751 | return (~mmc_cmd1 & 0x3f) /* ^ dips*/; // we would need to check the Dips here |
| 6907 | 6752 | else |
| r5944 | r5945 | |
| 6912 | 6757 | { |
| 6913 | 6758 | LOG_MMC(("mapper150_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6914 | 6759 | |
| 6915 | | mapper150_l_w(space, (offset + 0x100) & 0x01, data); |
| 6760 | mapper150_l_w(space, offset + 0x100, data); |
| 6916 | 6761 | } |
| 6917 | 6762 | |
| 6918 | 6763 | /************************************************************* |
| r5944 | r5945 | |
| 7005 | 6850 | |
| 7006 | 6851 | Mapper 155 |
| 7007 | 6852 | |
| 7008 | | Known Boards: ??? |
| 6853 | Known Boards: SKROM |
| 7009 | 6854 | Games: Tatakae!! Rahmen Man - Sakuretsu Choujin 102 Gei |
| 7010 | 6855 | |
| 7011 | | In MESS: Unsupported. |
| 6856 | This is basically MMC1 with a different way to handle WRAM |
| 6857 | (this difference is not emulated yet, since we don't fully |
| 6858 | emulate WRAM in MMC1 either) |
| 7012 | 6859 | |
| 6860 | In MESS: Supported (as complete as MMC1). |
| 6861 | |
| 7013 | 6862 | *************************************************************/ |
| 7014 | 6863 | |
| 7015 | 6864 | /************************************************************* |
| r5944 | r5945 | |
| 7190 | 7039 | |
| 7191 | 7040 | *************************************************************/ |
| 7192 | 7041 | |
| 7193 | | UINT8 subor_reg[4]; // used also by 167 below |
| 7194 | | |
| 7195 | 7042 | static WRITE8_HANDLER( mapper166_w ) |
| 7196 | 7043 | { |
| 7197 | 7044 | UINT8 map166_helper1, map166_helper2; |
| r5944 | r5945 | |
| 7568 | 7415 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 7569 | 7416 | break; |
| 7570 | 7417 | case 0x2000: |
| 7571 | | mmc_bank_latch1 = data; |
| 7418 | mmc_cmd1 = data; |
| 7572 | 7419 | break; |
| 7573 | 7420 | case 0x4000: |
| 7574 | | switch (mmc_bank_latch1) |
| 7421 | switch (mmc_cmd1) |
| 7575 | 7422 | { |
| 7576 | 7423 | case 0: |
| 7577 | 7424 | chr2_0(space->machine, data >> 1, CHRROM); |
| r5944 | r5945 | |
| 8897 | 8744 | Known Boards: Bootleg Board by Sachen (74SL374A) |
| 8898 | 8745 | Games: Poker III |
| 8899 | 8746 | |
| 8900 | | Conflicting info about this. Still investigating. The board is similar |
| 8901 | | to the one of mapper 150. |
| 8747 | The board is similar to the one of mapper 150. |
| 8902 | 8748 | |
| 8903 | 8749 | In MESS: Supported. |
| 8904 | 8750 | |
| r5944 | r5945 | |
| 8923 | 8769 | chr8(space->machine, 3, CHRROM); |
| 8924 | 8770 | break; |
| 8925 | 8771 | case 0x02: |
| 8926 | | chr8(space->machine, (mmc_bank_latch1 & ~0x08) | (data << 3 & 0x08), CHRROM); // Nestopia |
| 8772 | vrom_bank[0] = (vrom_bank[0] & ~0x08) | (data << 3 & 0x08); |
| 8773 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 8927 | 8774 | break; |
| 8928 | 8775 | case 0x04: |
| 8929 | | chr8(space->machine, (mmc_bank_latch1 & ~0x01) | (data << 0 & 0x01), CHRROM); // Nestopia |
| 8776 | vrom_bank[0] = (vrom_bank[0] & ~0x01) | (data << 0 & 0x01); |
| 8777 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 8930 | 8778 | break; |
| 8931 | 8779 | case 0x05: |
| 8932 | 8780 | prg32(space->machine, data & 0x01); |
| 8933 | 8781 | break; |
| 8934 | 8782 | case 0x06: |
| 8935 | | chr8(space->machine, (mmc_bank_latch1 & ~0x06) | (data << 1 & 0x06), CHRROM); // Nestopia |
| 8783 | vrom_bank[0] = (vrom_bank[0] & ~0x06) | (data << 1 & 0x06); |
| 8784 | chr8(space->machine, vrom_bank[0], CHRROM); |
| 8936 | 8785 | break; |
| 8937 | 8786 | case 0x07: |
| 8938 | 8787 | set_nt_mirroring(data & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| r5944 | r5945 | |
| 9203 | 9052 | { 9, "MMC2", NULL, NULL, NULL, mapper9_w, mapper9_latch, NULL, NULL}, |
| 9204 | 9053 | { 10, "MMC4", NULL, NULL, NULL, mapper10_w, mapper9_latch, NULL, NULL }, |
| 9205 | 9054 | { 11, "Color Dreams Mapper", NULL, NULL, NULL, mapper11_w, NULL, NULL, NULL }, |
| 9206 | | { 13, "CP-ROM", NULL, NULL, NULL, mapper13_w, NULL, NULL, NULL }, //needs CHR-RAM hooked up |
| 9055 | { 12, "Rex Soft DBZ5", mapper12_l_w, mapper12_l_r, NULL, mapper12_w, NULL, NULL, mapper4_irq }, |
| 9056 | { 13, "CP-ROM", NULL, NULL, NULL, mapper13_w, NULL, NULL, NULL }, |
| 9207 | 9057 | { 15, "100-in-1", NULL, NULL, NULL, mapper15_w, NULL, NULL, NULL }, |
| 9208 | 9058 | { 16, "Bandai", NULL, NULL, mapper16_m_w, mapper16_w, NULL,NULL, bandai_irq }, |
| 9209 | 9059 | { 17, "FFE F8xxx", mapper17_l_w, NULL, NULL, NULL, NULL, NULL, mapper4_irq }, |
| 9210 | 9060 | { 18, "Jaleco", NULL, NULL, NULL, mapper18_w, NULL, NULL, jaleco_irq }, |
| 9211 | | { 19, "Namco 106", mapper19_l_w, NULL, NULL, mapper19_w, NULL, NULL, namcot_irq }, |
| 9061 | { 19, "Namco 106", mapper19_l_w, mapper19_l_r, NULL, mapper19_w, NULL, NULL, namcot_irq }, |
| 9212 | 9062 | { 20, "Famicom Disk System", NULL, NULL, NULL, NULL, NULL, NULL, fds_irq }, |
| 9213 | 9063 | { 21, "Konami VRC 4", NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq }, |
| 9214 | 9064 | { 22, "Konami VRC 2a", NULL, NULL, NULL, konami_vrc2a_w, NULL, NULL, NULL }, |
| r5944 | r5945 | |
| 9220 | 9070 | { 33, "Taito TC0190", NULL, NULL, NULL, mapper33_w, NULL, NULL, NULL }, |
| 9221 | 9071 | { 34, "Nina-1", NULL, NULL, mapper34_m_w, mapper34_w, NULL, NULL, NULL }, |
| 9222 | 9072 | { 36, "TXC Policeman", NULL, NULL, NULL, mapper36_w, NULL, NULL, NULL }, |
| 9073 | { 37, "ZZ Board", NULL, NULL, mapper37_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9223 | 9074 | { 38, "Crime Buster", NULL, NULL, mapper38_m_w, NULL, NULL, NULL, NULL }, |
| 9224 | 9075 | { 39, "Subor Study n Game", NULL, NULL, NULL, mapper39_w, NULL, NULL, NULL }, |
| 9225 | 9076 | { 40, "SMB2j (bootleg)", NULL, NULL, NULL, mapper40_w, NULL, NULL, mapper40_irq }, |
| r5944 | r5945 | |
| 9232 | 9083 | { 47, "2-in-1 MMC3", NULL, NULL, mapper47_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9233 | 9084 | { 49, "4-in-1 MMC3", NULL, NULL, mapper49_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9234 | 9085 | { 51, "11-in-1", NULL, NULL, mapper51_m_w, mapper51_w, NULL, NULL, NULL }, |
| 9086 | { 52, "Mario 7-in-1", NULL, NULL, mapper52_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9235 | 9087 | { 57, "6-in-1", NULL, NULL, NULL, mapper57_w, NULL, NULL, NULL }, |
| 9236 | 9088 | { 58, "X-in-1", NULL, NULL, NULL, mapper58_w, NULL, NULL, NULL }, |
| 9237 | 9089 | { 61, "20-in-1", NULL, NULL, NULL, mapper61_w, NULL, NULL, NULL }, |
| r5944 | r5945 | |
| 9276 | 9128 | { 107, "Magic Dragon", NULL, NULL, NULL, mapper107_w, NULL, NULL, NULL }, |
| 9277 | 9129 | { 112, "Asper", NULL, NULL, NULL, mapper112_w, NULL, NULL, NULL }, |
| 9278 | 9130 | { 113, "Sachen/Hacker/Nina", mapper113_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9131 | { 114, "The Lion King", NULL, NULL, mapper114_m_w, mapper114_w, NULL, NULL, mapper4_irq }, |
| 9279 | 9132 | { 115, "Bao Qing Tian", NULL, NULL, mapper115_m_w, mapper115_w, NULL, NULL, mapper115_irq }, |
| 9280 | 9133 | { 118, "MMC3?", NULL, NULL, NULL, mapper118_w, NULL, NULL, mapper4_irq }, |
| 9281 | 9134 | { 119, "MMC3 - Pinbot", NULL, NULL, NULL, mapper119_w, NULL, NULL, mapper4_irq }, |
| 9282 | 9135 | { 132, "TXC T22211A", mapper132_l_w, mapper132_l_r, NULL, mapper132_w, NULL, NULL, NULL }, |
| 9283 | | { 133, "Sachen SA72008", mapper133_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9136 | { 133, "Sachen SA72008", mapper133_l_w, NULL, mapper133_m_w, NULL, NULL, NULL, NULL }, |
| 9284 | 9137 | { 136, "Sachen TCU01", mapper136_l_w, mapper136_l_r, NULL, NULL, NULL, NULL, NULL }, |
| 9285 | 9138 | { 137, "Sachen 8259D", mapper137_l_w, NULL, mapper137_m_w, NULL, NULL, NULL, NULL }, |
| 9286 | 9139 | { 138, "Sachen 8259B", mapper138_l_w, NULL, mapper138_m_w, NULL, NULL, NULL, NULL }, |
| r5944 | r5945 | |
| 9297 | 9150 | { 150, "Sachen 74LS374B", mapper150_l_w, mapper150_l_r, mapper150_m_w, NULL, NULL, NULL, NULL }, |
| 9298 | 9151 | { 152, "Taito Discrete", NULL, NULL, NULL, mapper152_w, NULL, NULL, NULL }, |
| 9299 | 9152 | { 154, "Devil Man", NULL, NULL, NULL, mapper154_w, NULL, NULL, NULL }, |
| 9153 | { 155, "Devil Man", NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL }, // diff compared to MMC1 concern WRAM (unsupported for MMC1 as well, atm) |
| 9300 | 9154 | { 156, "Open Corp. DAOU36", NULL, NULL, NULL, mapper156_w, NULL, NULL, NULL }, |
| 9301 | 9155 | { 164, "Final Fantasy V", mapper164_l_w, NULL, NULL, mapper164_w, NULL, NULL, NULL }, |
| 9302 | 9156 | { 166, "Subor Board Type 1", NULL, NULL, NULL, mapper166_w, NULL, NULL, NULL }, |
| r5944 | r5945 | |
| 9375 | 9229 | { |
| 9376 | 9230 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 9377 | 9231 | nes_state *state = machine->driver_data; |
| 9378 | | int err = 0; |
| 9232 | int err = 0, i; |
| 9379 | 9233 | const mmc *mapper; |
| 9380 | 9234 | |
| 9381 | 9235 | if (nes.chr_chunks == 0) |
| r5944 | r5945 | |
| 9387 | 9241 | mapper = nes_mapper_lookup(mmc_num); |
| 9388 | 9242 | |
| 9389 | 9243 | if (mapper == NULL) |
| 9390 | | fatalerror("Unimplemented Mapper"); |
| 9244 | fatalerror("Unimplemented Mapper %d", mmc_num); |
| 9245 | // logerror("Mapper %d is not yet supported, defaulting to no mapper.\n", mmc_num); // this one would be a better output |
| 9391 | 9246 | |
| 9247 | |
| 9392 | 9248 | ppu2c0x_set_scanline_callback(state->ppu, mapper ? mapper->mmc_scanline : NULL); |
| 9393 | 9249 | ppu2c0x_set_hblank_callback(state->ppu, mapper ? mapper->mmc_hblank : NULL); |
| 9394 | 9250 | |
| r5944 | r5945 | |
| 9396 | 9252 | nes_irq_timer = timer_alloc(machine, nes_irq_callback, NULL); |
| 9397 | 9253 | |
| 9398 | 9254 | mapper_warning = 0; |
| 9399 | | /* 8k mask */ |
| 9400 | | prg_mask = ((nes.prg_chunks << 1) - 1); |
| 9401 | 9255 | |
| 9402 | 9256 | MMC5_vram_control = 0; |
| 9403 | 9257 | |
| 9258 | /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */ |
| 9259 | for (i = 0; i < 4; i++) |
| 9260 | { |
| 9261 | prg_bank[i] = 0; |
| 9262 | vrom_bank[4 * i + 0] = 0; |
| 9263 | vrom_bank[4 * i + 1] = 0; |
| 9264 | vrom_bank[4 * i + 2] = 0; |
| 9265 | vrom_bank[4 * i + 3] = 0; |
| 9266 | } |
| 9267 | |
| 9404 | 9268 | /* Point the WRAM/battery area to the first RAM bank */ |
| 9405 | 9269 | if (mmc_num != 20 && mmc_num != 40) |
| 9406 | 9270 | memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]); |
| r5944 | r5945 | |
| 9412 | 9276 | prg32(space->machine, 0); |
| 9413 | 9277 | break; |
| 9414 | 9278 | case 1: |
| 9415 | | /* Reset the latch */ |
| 9416 | | MMC1_reg = 0; |
| 9417 | | MMC1_reg_count = 0; |
| 9418 | | |
| 9419 | | MMC1_Size_16k = 1; |
| 9420 | | MMC1_Switch_Low = 1; |
| 9421 | | MMC1_SizeVrom_4k = 0; |
| 9422 | | MMC1_extended_bank = 0; |
| 9423 | | MMC1_extended_swap = 0; |
| 9424 | | MMC1_extended_base = 0x10000; |
| 9425 | | MMC1_extended = ((nes.prg_chunks << 4) + nes.chr_chunks * 8) >> 9; |
| 9426 | | |
| 9427 | | if (!MMC1_extended) |
| 9428 | | /* Set it to the end of the prg rom */ |
| 9429 | | MMC1_High = (nes.prg_chunks - 1) * 0x4000; |
| 9430 | | else |
| 9431 | | /* Set it to the end of the first 256k bank */ |
| 9432 | | MMC1_High = 15 * 0x4000; |
| 9433 | | |
| 9434 | | MMC1_bank1 = 0; |
| 9435 | | MMC1_bank2 = 0x2000; |
| 9436 | | MMC1_bank3 = MMC1_High; |
| 9437 | | MMC1_bank4 = MMC1_High + 0x2000; |
| 9438 | | |
| 9439 | | memory_set_bankptr(space->machine, 1, &nes.rom[MMC1_extended_base + MMC1_bank1]); |
| 9440 | | memory_set_bankptr(space->machine, 2, &nes.rom[MMC1_extended_base + MMC1_bank2]); |
| 9441 | | memory_set_bankptr(space->machine, 3, &nes.rom[MMC1_extended_base + MMC1_bank3]); |
| 9442 | | memory_set_bankptr(space->machine, 4, &nes.rom[MMC1_extended_base + MMC1_bank4]); |
| 9443 | | logerror("-- page1: %06x\n", MMC1_bank1); |
| 9444 | | logerror("-- page2: %06x\n", MMC1_bank2); |
| 9445 | | logerror("-- page3: %06x\n", MMC1_bank3); |
| 9446 | | logerror("-- page4: %06x\n", MMC1_bank4); |
| 9279 | case 155: |
| 9280 | mmc_cmd1 = 0; |
| 9281 | mmc_count = 0; |
| 9282 | MMC1_regs[0] = 0x0f; |
| 9283 | MMC1_regs[1] = MMC1_regs[2] = MMC1_regs[3] = 0; |
| 9284 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 9285 | MMC1_set_chr(space->machine); |
| 9286 | MMC1_set_prg(space->machine); |
| 9447 | 9287 | break; |
| 9448 | 9288 | case 2: |
| 9449 | 9289 | /* These games don't switch VROM, but some ROMs incorrectly have CHR chunks */ |
| r5944 | r5945 | |
| 9474 | 9314 | set_nt_page(2, CART_NTRAM, 2, 1); |
| 9475 | 9315 | set_nt_page(3, CART_NTRAM, 3, 1); |
| 9476 | 9316 | } |
| 9317 | case 12: |
| 9477 | 9318 | case 118: |
| 9478 | 9319 | case 119: |
| 9479 | 9320 | case 196: |
| r5944 | r5945 | |
| 9482 | 9323 | IRQ_enable = 0; |
| 9483 | 9324 | IRQ_count = IRQ_count_latch = 0; |
| 9484 | 9325 | IRQ_reload = 0; |
| 9485 | | MMC3_prg0 = 0xfe; |
| 9486 | | MMC3_prg1 = 0xff; |
| 9326 | prg_bank[0] = 0xfe; |
| 9327 | prg_bank[1] = 0xff; |
| 9487 | 9328 | MMC3_cmd = 0; |
| 9488 | | MMC3_prg_base = 0; |
| 9489 | | MMC3_prg_mask = (nes.prg_chunks << 1) - 1; |
| 9490 | | MMC3_chr_base = 0; |
| 9491 | | MMC3_chr_mask = (nes.chr_chunks << 3) - 1; |
| 9329 | mmc_cmd2 = 0x80; |
| 9330 | mmc_prg_base = mmc_chr_base = 0; |
| 9331 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 9492 | 9332 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9493 | | mapper4_set_prg(space->machine); |
| 9494 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 9333 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9334 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9495 | 9335 | break; |
| 9496 | 9336 | case 5: |
| 9497 | 9337 | /* Can switch 8k prg banks, but they are saved as 16k in size */ |
| r5944 | r5945 | |
| 9519 | 9359 | /* Can switch 8k prg banks */ |
| 9520 | 9360 | /* Note that the iNES header defines the number of banks as 8k in size, rather than 16k */ |
| 9521 | 9361 | /* Reset VROM latches */ |
| 9522 | | MMC2_bank0 = MMC2_bank1 = 0; |
| 9523 | | MMC2_bank0_hi = MMC2_bank1_hi = 0; |
| 9524 | | MMC2_bank0_latch = MMC2_bank1_latch = 0xfe; |
| 9362 | MMC2_regs[0] = MMC2_regs[2] = 0; |
| 9363 | MMC2_regs[1] = MMC2_regs[3] = 0; |
| 9364 | mmc_cmd1 = mmc_cmd2 = 0xfe; |
| 9525 | 9365 | prg8_89(space->machine, 0); |
| 9526 | 9366 | //ugly hack to deal with iNES header usage of chunk count. |
| 9527 | 9367 | prg8_ab(space->machine, (nes.prg_chunks << 1) - 3); |
| r5944 | r5945 | |
| 9530 | 9370 | break; |
| 9531 | 9371 | case 10: |
| 9532 | 9372 | /* Reset VROM latches */ |
| 9533 | | MMC2_bank0 = MMC2_bank1 = 0; |
| 9534 | | MMC2_bank0_hi = MMC2_bank1_hi = 0; |
| 9535 | | MMC2_bank0_latch = MMC2_bank1_latch = 0xfe; |
| 9373 | MMC2_regs[0] = MMC2_regs[2] = 0; |
| 9374 | MMC2_regs[1] = MMC2_regs[3] = 0; |
| 9375 | mmc_cmd1 = mmc_cmd2 = 0xfe; |
| 9536 | 9376 | prg16_89ab(space->machine, 0); |
| 9537 | 9377 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9538 | 9378 | break; |
| r5944 | r5945 | |
| 9590 | 9430 | /* Can switch 32k prg banks */ |
| 9591 | 9431 | prg32(space->machine, 0); |
| 9592 | 9432 | break; |
| 9433 | case 37: |
| 9434 | IRQ_enable = 0; |
| 9435 | IRQ_count = IRQ_count_latch = 0; |
| 9436 | IRQ_reload = 0; |
| 9437 | prg_bank[0] = 0xfe; |
| 9438 | prg_bank[1] = 0xff; |
| 9439 | MMC3_cmd = 0; |
| 9440 | mmc_cmd2 = 0x80; |
| 9441 | mmc_prg_base = mmc_chr_base = 0; |
| 9442 | mmc_prg_mask = 0x07; |
| 9443 | mmc_chr_mask = 0x7f; |
| 9444 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9445 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9446 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9447 | break; |
| 9593 | 9448 | case 40: |
| 9594 | 9449 | IRQ_enable = 0; |
| 9595 | 9450 | IRQ_count = 0; |
| r5944 | r5945 | |
| 9618 | 9473 | IRQ_enable = 0; |
| 9619 | 9474 | IRQ_count = IRQ_count_latch = 0; |
| 9620 | 9475 | IRQ_reload = 0; |
| 9621 | | MMC3_prg0 = 0xfe; |
| 9622 | | MMC3_prg1 = 0xff; |
| 9476 | prg_bank[0] = 0xfe; |
| 9477 | prg_bank[1] = 0xff; |
| 9623 | 9478 | MMC3_cmd = 0; |
| 9624 | | MMC3_prg_base = 0; |
| 9625 | | MMC3_prg_mask = 0x0f; |
| 9626 | | MMC3_chr_base = 0; |
| 9627 | | MMC3_chr_mask = 0x7f; |
| 9479 | mmc_cmd2 = 0x80; |
| 9480 | mmc_prg_base = mmc_chr_base = 0; |
| 9481 | mmc_prg_mask = 0x0f; |
| 9482 | mmc_chr_mask = 0x7f; |
| 9628 | 9483 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9629 | | mapper4_set_prg(space->machine); |
| 9630 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 9484 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9485 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9631 | 9486 | break; |
| 9632 | 9487 | case 45: |
| 9633 | 9488 | IRQ_enable = 0; |
| 9634 | 9489 | IRQ_count = IRQ_count_latch = 0; |
| 9635 | 9490 | IRQ_reload = 0; |
| 9636 | | MMC3_prg0 = 0xfe; |
| 9637 | | MMC3_prg1 = 0xff; |
| 9638 | | MMC3_cmd = 0; |
| 9639 | | MMC3_prg_base = 0x30; |
| 9640 | | MMC3_prg_mask = 0x0f; |
| 9641 | | MMC3_chr_base = 0; |
| 9642 | | MMC3_chr_mask = 0x7f; |
| 9491 | prg_bank[0] = 0xfe; |
| 9492 | prg_bank[1] = 0xff; |
| 9493 | mmc_cmd1 = 0; |
| 9494 | mmc_cmd2 = 0x80; |
| 9643 | 9495 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9644 | | mapper45_cmd = 0; |
| 9645 | | mapper45_data[0] = mapper45_data[1] = mapper45_data[2] = mapper45_data[3] = 0; |
| 9646 | | mapper4_set_prg(space->machine); |
| 9647 | | mapper4_set_chr(space->machine, mmc_chr_source); |
| 9496 | mapper45_reg[0] = mapper45_reg[1] = mapper45_reg[2] = mapper45_reg[3] = 0; |
| 9497 | mmc_prg_base = 0x30; |
| 9498 | mmc_prg_mask = 0x3f; |
| 9499 | mmc_chr_base = 0; |
| 9500 | mmc_chr_mask = 0x7f; |
| 9501 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9502 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9648 | 9503 | memory_set_bankptr(space->machine, 5, nes.wram); |
| 9649 | 9504 | break; |
| 9650 | 9505 | case 46: |
| 9651 | | mmc_bank_latch1 = 0; |
| 9652 | | mmc_bank_latch2 = 0; |
| 9653 | 9506 | prg32(space->machine, 0); |
| 9654 | 9507 | chr8(space->machine, 0, CHRROM); |
| 9655 | 9508 | break; |
| 9509 | case 52: |
| 9510 | IRQ_enable = 0; |
| 9511 | IRQ_count = IRQ_count_latch = 0; |
| 9512 | IRQ_reload = 0; |
| 9513 | prg_bank[0] = 0xfe; |
| 9514 | prg_bank[1] = 0xff; |
| 9515 | mmc_cmd1 = 0; |
| 9516 | mmc_cmd2 = 0x80; |
| 9517 | map52_reg_written = 0; |
| 9518 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9519 | mmc_prg_base = 0; |
| 9520 | mmc_prg_mask = 0x1f; |
| 9521 | mmc_chr_base = 0; |
| 9522 | mmc_chr_mask = 0xff; |
| 9523 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9524 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9525 | memory_set_bankptr(space->machine, 5, nes.wram); |
| 9526 | break; |
| 9656 | 9527 | case 51: |
| 9657 | | MMC1_bank1 = 0x01; |
| 9658 | | MMC1_bank2 = 0x00; |
| 9659 | | MMC1_bank3 = 0x00; |
| 9528 | mapper51_reg[0] = 0x01; |
| 9529 | mapper51_reg[1] = 0x00; |
| 9530 | mapper51_reg[2] = 0x00; |
| 9660 | 9531 | mapper51_set_banks(space->machine); |
| 9661 | 9532 | break; |
| 9662 | 9533 | case 57: |
| 9663 | | MMC1_bank1 = 0x00; |
| 9664 | | MMC1_bank2 = 0x00; |
| 9534 | mmc_cmd1 = 0x00; |
| 9535 | mmc_cmd2 = 0x00; |
| 9665 | 9536 | prg16_89ab(space->machine, 0); |
| 9666 | 9537 | prg16_cdef(space->machine, 0); |
| 9667 | 9538 | chr8(space->machine, 0, CHRROM); |
| r5944 | r5945 | |
| 9742 | 9613 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9743 | 9614 | break; |
| 9744 | 9615 | case 83: |
| 9745 | | mapper83_data[9] = 0x0f; |
| 9616 | mapper83_reg[9] = 0x0f; |
| 9746 | 9617 | prg8_cd(space->machine, 0x1e); |
| 9747 | 9618 | prg8_ef(space->machine, 0x1f); |
| 9748 | 9619 | break; |
| r5944 | r5945 | |
| 9796 | 9667 | prg32(space->machine, 0); |
| 9797 | 9668 | break; |
| 9798 | 9669 | case 104: |
| 9799 | | mmc_bank_latch1 = 0; |
| 9800 | 9670 | prg16_89ab(space->machine, 0x00); |
| 9801 | 9671 | prg16_cdef(space->machine, 0x0f); |
| 9802 | 9672 | break; |
| 9673 | case 114: |
| 9674 | IRQ_enable = 0; |
| 9675 | IRQ_count = IRQ_count_latch = 0; |
| 9676 | IRQ_reload = 0; |
| 9677 | map114_reg = map114_reg_enabled = 0; |
| 9678 | prg_bank[0] = 0xfe; |
| 9679 | prg_bank[1] = 0xff; |
| 9680 | MMC3_cmd = 0; |
| 9681 | mmc_cmd2 = 0x80; |
| 9682 | mmc_prg_base = mmc_chr_base = 0; |
| 9683 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 9684 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9685 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9686 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9687 | break; |
| 9688 | case 115: |
| 9689 | mapper115_reg[0] = mapper115_reg[1] = mapper115_reg[2] = mapper115_reg[3] = 0; |
| 9690 | prg32(space->machine, 0xff); |
| 9691 | break; |
| 9803 | 9692 | case 132: |
| 9804 | 9693 | case 172: |
| 9805 | 9694 | case 173: |
| r5944 | r5945 | |
| 9850 | 9739 | chr8(space->machine, 0, CHRROM); |
| 9851 | 9740 | break; |
| 9852 | 9741 | case 150: |
| 9853 | | mmc_bank_latch1 = 0; |
| 9854 | 9742 | mmc_cmd1 = 0; |
| 9855 | 9743 | prg32(space->machine, 0); |
| 9856 | 9744 | chr8(space->machine, 0, CHRROM); |
| r5944 | r5945 | |
| 9964 | 9852 | mapper232_set_prg(space->machine); |
| 9965 | 9853 | break; |
| 9966 | 9854 | case 243: |
| 9967 | | mmc_bank_latch1 = 3; |
| 9855 | vrom_bank[0] = 3; |
| 9968 | 9856 | mmc_cmd1 = 0; |
| 9969 | 9857 | chr8(space->machine, 3, CHRROM); |
| 9970 | 9858 | prg32(space->machine, 0); |
| r5944 | r5945 | |
| 9973 | 9861 | case 246: |
| 9974 | 9862 | prg32(space->machine, 0xff); |
| 9975 | 9863 | break; |
| 9976 | | case 248: |
| 9977 | | MMC1_bank1 = MMC1_bank2 = MMC1_bank3 = MMC1_bank4 = 0; |
| 9978 | | prg32(space->machine, 0xff); |
| 9979 | | break; |
| 9980 | 9864 | default: |
| 9981 | 9865 | /* Mapper not supported */ |
| 9982 | 9866 | err = 2; |