src/mess/machine/nes_mmc.c
| r5997 | r5998 | |
| 10 | 10 | You can find the latest version of the doc at http://www.romhacking.net/docs/362/ |
| 11 | 11 | |
| 12 | 12 | |
| 13 | Missing components: |
| 14 | * Currently, we are not emulating 4-screen mirroring (only 3 games use it) |
| 15 | * We need a better way to implement CPU cycle based IRQ. Currently we update their counter once every scanline |
| 16 | but, with this approach, every time 114 clocks have passed and for certain games it is too much! |
| 17 | * We need to emulate additional sound hardware in mappers 019, 024, 026, 069, 085 (and possibly other ones) |
| 18 | * We need to emulate EEPROM in mapper 016 and 159 |
| 19 | * Barcode World (mapper 069) and Datach games (mapper 157) need Barcode Reader emulation |
| 20 | Notice that for mapper 157, the barcode reader enters in the irq, so glitches may be related to this! |
| 21 | * Karaoke Studio (mapper 188) misses input devices |
| 22 | |
| 13 | 23 | Known issues on specific mappers: |
| 14 | 24 | |
| 25 | * 000 F1 Race requires more precise PPU timing. It currently has plenty of 1-line glitches. |
| 15 | 26 | * 001 AD&D Hillsfar and Bill & Ted are broken. We need to ignore the case of writes happening on 2 |
| 16 | 27 | consecutive CPU cycles because these games use dirty tricks to reset counters (see note in mapper1_w) |
| 17 | 28 | * 001, 155 We don't handle (yet) WRAM enable/disable bit |
| 18 | | * 002, 003 Bus conflict? |
| 19 | | * 005 has some issues (e.g. Just Breed is not working), RAM banking needs hardware flags to determine size |
| 29 | * 002, 003, 094, 097, 152 Bus conflict? |
| 30 | * 005 has issues (see e.g. Just Breed or Metal Slader Glory), RAM banking needs hardware flags to determine size |
| 31 | * 014 in-game graphics is glitched |
| 20 | 32 | * 015 Shanghai Tycoon has corrupted graphics |
| 21 | | * 016 some graphics problem (e.g. Rokudenashi Blues misses some element of graphics) |
| 22 | | * 018 Pizza Pop and Plasma Ball shows graphics issues for this mapper |
| 23 | | * 024, 026, 085 Registers of the additional sound hardware are not emulated |
| 24 | | * 032 Major League is not properly working: check missing windows or field graphics in top view screens |
| 25 | | (it requires one hack to support both boards using this mapper) |
| 26 | 33 | * 033 has still some graphics problem (e.g. missing text in Akira) |
| 27 | | * 034 Impossible Mission 2 is not working |
| 34 | * 034 Impossible Mission II does not show graphics |
| 28 | 35 | * 038 seems to miss inputs. separate reads? |
| 29 | 36 | * 039 Study n Game 32 in 1 misses keyboard and starts differently than in NEStopia |
| 30 | | * 040 is not dealing correctly 0x6000-0x7fff (this got broken long ago) |
| 31 | 37 | * 042 Ai Senshi Nicol has broken graphics (our Mapper 42 implementation does not handle CHR banks) |
| 32 | 38 | * 051 only half of the games work |
| 33 | | * 064 has some IRQ problems - see Skull & Crossbones. Klax has broken graphics. |
| 34 | | * 065 Spartan X 2 has various glitches |
| 35 | | * 067 display issues, but vrom fixed |
| 39 | * 064 has many IRQ problems (due to the way we implement CPU based IRQ) - see Skull & Crossbones. |
| 40 | Klax has problems as well (even if it uses scanline based IRQ, according to Disch's docs). |
| 41 | * 067 some 1-line glitches that cannot be solved without a better implementation for cycle-based IRQs |
| 36 | 42 | * 071 Fire Hawk is not properly working (it requires one hack to support both boards using this mapper) |
| 37 | 43 | * 072, 086, 092 lack samples support (maybe others as well) |
| 44 | * 073 16 bit IRQ mode is not implemented |
| 38 | 45 | * 077 Requires 4-screen mirroring. Currently, it is very glitchy |
| 39 | | * 078 Cosmo Carrier is not working (it requires one hack to support both boards using this mapper). |
| 40 | | also, we lack NT mirroring |
| 41 | | * 082 has chr-rom banking problems. Also mapper is in the middle of sram, which is unemulated. |
| 42 | 46 | * 083 has serious glitches |
| 43 | | * 091 lacks IRQ needed by MK2 |
| 44 | | * 094 Bus conflict? |
| 45 | | * 096 is preliminary (no correct chr switch in connection to NT) |
| 46 | | * 097 Bus conflict? |
| 47 | * 096 is preliminary (no correct chr switch in connection to PPU) |
| 47 | 48 | * 104 Not all the games work |
| 48 | 49 | * 107 Are the scrolling glitches (check status bar) correct? NEStopia behaves similarly |
| 49 | 50 | * 112 Master Shooter is not working and misses some graphics |
| 50 | | * 113 is not following docs (missing NT mirroring and high CHR bit) |
| 51 | | * 115 (formerly 248) is preliminary |
| 52 | | * 118 mirroring is a guess, chr-rom banking is likely different |
| 53 | | * 143 are dancing block borders (in the intro) correct? |
| 54 | | * 146 Pyramid 2 does not work |
| 55 | | * 150 some problems (Magic Cubes, Mahjong Academy, others?), maybe mirroring related |
| 56 | | * 152 Bus conflict? |
| 51 | * 117 In-game glitches |
| 52 | * 119 Pin Bot has glitches when the ball is in the upper half of the screen |
| 53 | * 133 Qi Wang starts with corrupted graphics (ingame seems better) |
| 54 | * 143 are Dancing Block borders (in the intro) correct? |
| 55 | * 153 Famicom Jump II variant is not working, for some reason |
| 56 | * 158 In addition to IRQ problems (same as 64), mirroring was just a guess (wrong?). info needed! |
| 57 | 57 | * 164 preliminary - no sprites? |
| 58 | 58 | * 176 has some graphics problem |
| 59 | 59 | * 178 Fan Kong Jin Ying is not working (but not even in NEStopia) |
| 60 | 60 | * 180 Crazy Climber controller? |
| 61 | * 185 we emulate it like plain Mapper 3, but it's not: Mighty BombJack and Seicross don't work |
| 62 | * 187, 198, 208, 215 have some PRG banking issues - preliminary! |
| 61 | 63 | * 188 needs mic input (reads from 0x6000-0x7fff) |
| 64 | * 197 Super Fighter 3 has some glitch in-game (maybe mirroring?) |
| 65 | * 222 is only preliminar (wrong IRQ, mirroring or CHR banking?) |
| 62 | 66 | * 225 115-in-1 has glitches in the menu (games seem fine) |
| 63 | 67 | * 228 seems wrong. e.g. Action52 starts with a game rather than in the menu |
| 64 | 68 | * 229 is preliminary |
| 65 | 69 | * 230 not working yet (needs a value to flip at reset) |
| 66 | | * 231 not working yet |
| 67 | 70 | * 232 has graphics glitches |
| 68 | 71 | * 241 Commandos is not working (but not even in NEStopia) |
| 69 | | * 242 DQ7 is not working (it requires one hack to support both boards using this mapper) |
| 70 | | * 243 has glitches in Sachen logo |
| 72 | * 242 In Dragon Quest VIII graphics of the main character is not drawn (it seems similar to Shanghai Tycoon [map15] |
| 73 | because in place of the missing graphics we get glitches in the left border) |
| 74 | * 249 only half of the games work (and Du Bao Ying Hao seems to suffer the same problem as DQ8 and Shanghai Tycoon) |
| 75 | * 252 shows logo, but doesn't reach the game |
| 71 | 76 | * 255 does not really select game (same in NEStopia apparently) |
| 72 | 77 | |
| 78 | A few Mappers suffer of hardware conflict: original dumpers have used the same mapper number for more than |
| 79 | a kind of boards. In these cases (and only in these cases) we exploit nes.hsi to set up accordingly |
| 80 | emulation. Games which requires this hack are the following: |
| 81 | * 032 - Major League needs hardwired mirroring (missing windows and glitched field in top view, otherwise) |
| 82 | * 034 - Impossible Mission II is not like BxROM games (it writes to 0x7ffd-0x7fff, instead of 0x8000). It is still |
| 83 | unplayable though (see above) |
| 84 | * 078 - Cosmo Carrier needs a different mirroring than Holy Diver |
| 85 | * 113 - HES 6-in-1 requires mirroring (check Bookyman playfield), while other games break with this (check AV Soccer) |
| 86 | * 153 - Famicom Jump II uses a different board (or the same in a very different way) |
| 87 | * 242 - DQ8 has no mirroring (missing graphics is due to other reasons though) |
| 88 | |
| 73 | 89 | Details to investigate: |
| 74 | 90 | * 034 writes to 0x8000-0xffff should not be used for NINA-001 and BNROM, only unlicensed BxROM... |
| 75 | 91 | * 144 we ignore writes to 0x8000 while NEStopia does not. is it a problem? |
| 76 | 92 | * 240 we do not map writes to 0x4020-0x40ff. is this a problem? |
| 93 | * some other emus uses mapper 210 for mapper 019 games without additional sound hardware and mirroring capabilities |
| 94 | (in 210 mirroring is hardwired). However, simply initializing mirroring to Vertical in 019 seems to fix all glitches |
| 95 | in 210 games, so there seems to be no reason to have this duplicate mapper |
| 77 | 96 | |
| 97 | Some mappers copy PRG rom in SRAM region. Below is a list of those which does it (in MESS) to further |
| 98 | investigate if we are supporting them in the right way (e.g. do any of the following have conflicts with SRAM?): |
| 99 | * 065 (Gimmick! breaks badly without it) |
| 100 | * 040, 042, 050 |
| 101 | |
| 78 | 102 | Remember that the MMC # does not equal the mapper #. In particular, Mapper 4 is |
| 79 | 103 | in fact MMC3, Mapper 9 is MMC2 and Mapper 10 is MMC4. Makes perfect sense, right? |
| 80 | 104 | |
| r5997 | r5998 | |
| 134 | 158 | static name_table nt_page[4]; //quick banking structure for a maximum of 4K of RAM/ROM/ExRAM |
| 135 | 159 | |
| 136 | 160 | static int IRQ_enable, IRQ_enable_latch; |
| 137 | | static UINT16 IRQ_count, IRQ_count_latch, IRQ_reload; |
| 161 | static UINT16 IRQ_count, IRQ_count_latch; |
| 162 | static UINT8 IRQ_toggle; |
| 163 | static UINT8 IRQ_reset; |
| 138 | 164 | static UINT8 IRQ_status; |
| 139 | 165 | static UINT8 IRQ_mode; |
| 140 | 166 | |
| r5997 | r5998 | |
| 155 | 181 | static UINT8 mmc_cmd1, mmc_cmd2; // These represent registers where the mapper writes important values |
| 156 | 182 | static UINT8 mmc_count; // This is used as counter in mappers like 1 and 45 |
| 157 | 183 | |
| 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. |
| 184 | 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), |
| 185 | static int mmc_chr_base, mmc_chr_mask; // while MMC3 and clones (mapper 118 & 119) simply set them as 0 and 0xff resp. |
| 160 | 186 | |
| 187 | static UINT8 prg_bank[4]; // Many mappers writes only some bits of the selected bank (for both PRG and CHR), |
| 188 | static UINT8 vrom_bank[16]; // hence these are handy to latch bank values. |
| 161 | 189 | |
| 190 | |
| 162 | 191 | // FIXME: mapper specific variables should be unified as much as possible to make easier future implementation of save states |
| 163 | 192 | /* Local variables (a few more are defined just before handlers that use them...) */ |
| 164 | 193 | |
| r5997 | r5998 | |
| 166 | 195 | |
| 167 | 196 | static UINT8 MMC2_regs[4]; // these replace bank0/bank0_hi/bank1/bank1_hi |
| 168 | 197 | |
| 169 | | static int MMC3_cmd; |
| 170 | 198 | UINT8* extended_ntram; |
| 171 | 199 | |
| 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 | 200 | |
| 175 | 201 | static int MMC5_rom_bank_mode; |
| 176 | 202 | static int MMC5_vrom_bank_mode; |
| r5997 | r5998 | |
| 181 | 207 | UINT8 MMC5_vram[0x400]; |
| 182 | 208 | int MMC5_vram_control; |
| 183 | 209 | |
| 210 | // these might be unified in single mmc_reg[] array, together with mmc_cmd1 & mmc_cmd2 |
| 211 | // but be careful that MMC3 clones often use mmc_cmd1/mmc_cmd2 (from base MMC3) AND additional regs below! |
| 184 | 212 | static UINT8 mapper45_reg[4]; |
| 185 | 213 | static UINT8 mapper51_reg[3]; |
| 186 | | static UINT8 mapper64_reg[11]; |
| 187 | 214 | static UINT8 mapper83_reg[10]; |
| 188 | 215 | static UINT8 mapper83_low_reg[4]; |
| 189 | 216 | static UINT8 mapper95_reg[4]; |
| r5997 | r5998 | |
| 194 | 221 | static UINT8 mapper12_reg; |
| 195 | 222 | static UINT8 map52_reg_written; |
| 196 | 223 | static UINT8 map114_reg, map114_reg_enabled; |
| 224 | static UINT8 map215_reg[4]; |
| 225 | static UINT8 map217_reg[4]; |
| 226 | static UINT8 map249_reg; |
| 227 | static UINT8 map14_reg[2]; |
| 228 | static UINT8 mapper121_reg[3]; |
| 229 | static UINT8 mapper187_reg[4]; |
| 230 | static UINT8 map208_reg[5]; |
| 197 | 231 | |
| 232 | |
| 233 | static UINT8 extra_bank[16]; // some MMC3 clone have 2 series of PRG/CHR banks... |
| 234 | // we collect them all here: first 4 elements PRG banks, then 6/8 CHR banks |
| 235 | |
| 236 | // mapper 68 needs these for NT mirroring! |
| 237 | static int m68_mirror; |
| 238 | static int m0, m1; |
| 239 | |
| 240 | |
| 241 | // FDS / mapper 20 need these for disks (to be added to fds struct?) |
| 242 | static int fds_last_side; |
| 243 | static int fds_count; |
| 244 | |
| 245 | // Famicom Jump II is identified as Mapper 153, but it works in a completely different way. |
| 246 | // in particular, it requires these (not needed by other Mapper 153 games) |
| 247 | static UINT8 map153_reg[8]; |
| 248 | static UINT8 map153_bank_latch; |
| 249 | |
| 198 | 250 | static int mapper_warning; |
| 199 | 251 | |
| 200 | 252 | static emu_timer *nes_irq_timer; |
| r5997 | r5998 | |
| 217 | 269 | - nes_mid_mapper_r/w take care of accesses to 0x6000-0x7fff |
| 218 | 270 | - nes_mapper_w takes care of writes to 0x8000-0xffff |
| 219 | 271 | some mappers may access 0x4018-0x4100: this must be taken |
| 220 | | care separately in init_nes_core (see e.g. mapper 40) |
| 272 | care separately in init_nes_core |
| 221 | 273 | |
| 222 | 274 | *************************************************************/ |
| 223 | 275 | |
| r5997 | r5998 | |
| 326 | 378 | else |
| 327 | 379 | { |
| 328 | 380 | logerror("Unimplemented mapper write, offset: %04x, data: %02x\n", offset, data); |
| 329 | | #if 1 |
| 381 | #ifdef MAME_DEBUG |
| 330 | 382 | if (!mapper_warning) |
| 331 | 383 | { |
| 332 | 384 | logerror("This game is writing to the mapper area but no mapper is set. You may get better results by switching to a valid mapper.\n"); |
| 333 | 385 | mapper_warning = 1; |
| 334 | 386 | } |
| 335 | | |
| 336 | | switch (offset) |
| 337 | | { |
| 338 | | /* Hacked mapper for the 24-in-1 NES_ROM. */ |
| 339 | | /* It's really 35-in-1, and it's mostly different versions of Battle City. Unfortunately, the vrom dumps are bad */ |
| 340 | | case 0x7fde: |
| 341 | | data &= (nes.prg_chunks - 1); |
| 342 | | memory_set_bankptr(space->machine, 3, &nes.rom[data * 0x4000 + 0x10000]); |
| 343 | | memory_set_bankptr(space->machine, 4, &nes.rom[data * 0x4000 + 0x12000]); |
| 344 | | break; |
| 345 | | } |
| 346 | 387 | #endif |
| 347 | 388 | } |
| 348 | 389 | } |
| r5997 | r5998 | |
| 437 | 478 | memory_set_bankptr(machine, 4, &nes.rom[bank * 0x2000 + 0x10000]); |
| 438 | 479 | } |
| 439 | 480 | |
| 481 | /* We define an additional helper to map PRG-ROM to 0x6000-0x7000 */ |
| 482 | // TODO: are we implementing this correctly in the mappers which uses it? check! |
| 483 | |
| 484 | static void prg8_67( running_machine *machine, int bank ) |
| 485 | { |
| 486 | /* assumes that bank references an 8k chunk */ |
| 487 | bank &= ((nes.prg_chunks << 1) - 1); |
| 488 | memory_set_bankptr(machine, 5, &nes.rom[bank * 0x2000 + 0x10000]); |
| 489 | } |
| 490 | |
| 440 | 491 | /* CHR ROM in 1K, 2K, 4K or 8K blocks */ |
| 441 | 492 | |
| 442 | 493 | static void chr8( running_machine *machine, int bank, int source ) |
| r5997 | r5998 | |
| 866 | 917 | operate like a common MMC3 board on that specific block. To emulate this |
| 867 | 918 | we use the concept of bases and masks. Original MMC3 boards simply |
| 868 | 919 | set base = 0 and mask = 0xff at start and never change them */ |
| 920 | /* Notice that, atm, there is no way to directly handle MMC3 clone mappers |
| 921 | which use custom routines to set PRG/CHR. For these mappers we have to |
| 922 | re-define the 0x8000-0xffff handler at least for offsets 0 & 1 (i.e. the |
| 923 | offsets where are used set_prg/set_chr) by using the mapper-specific routines, |
| 924 | and then we can fall back to mapper4_w for the remaining offsets */ |
| 869 | 925 | |
| 870 | 926 | static void mapper4_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 871 | 927 | { |
| 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; |
| 928 | UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0; |
| 875 | 929 | |
| 876 | | if (MMC3_cmd & 0x40) |
| 877 | | { |
| 878 | | prg8_89(machine, last_bank - 1); |
| 879 | | prg8_cd(machine, prg0_bank); |
| 880 | | } |
| 881 | | else |
| 882 | | { |
| 883 | | prg8_89(machine, prg0_bank); |
| 884 | | prg8_cd(machine, last_bank - 1); |
| 885 | | } |
| 886 | | |
| 887 | | prg8_ab(machine, prg1_bank); |
| 888 | | prg8_ef(machine, last_bank); |
| 930 | prg8_89(machine, prg_base | (prg_bank[0 ^ prg_flip] & prg_mask)); |
| 931 | prg8_ab(machine, prg_base | (prg_bank[1] & prg_mask)); |
| 932 | prg8_cd(machine, prg_base | (prg_bank[2 ^ prg_flip] & prg_mask)); |
| 933 | prg8_ef(machine, prg_base | (prg_bank[3] & prg_mask)); |
| 889 | 934 | } |
| 890 | 935 | |
| 891 | 936 | static void mapper4_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 892 | 937 | { |
| 893 | | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 938 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 894 | 939 | |
| 895 | 940 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 896 | 941 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr); |
| r5997 | r5998 | |
| 902 | 947 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr); |
| 903 | 948 | } |
| 904 | 949 | |
| 950 | /* Here, IRQ counter decrements every scanline. */ |
| 905 | 951 | static void mapper4_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 906 | 952 | { |
| 907 | | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 953 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 908 | 954 | { |
| 909 | 955 | int priorCount = IRQ_count; |
| 910 | 956 | if ((IRQ_count == 0)) |
| r5997 | r5998 | |
| 932 | 978 | switch (offset & 0x6001) |
| 933 | 979 | { |
| 934 | 980 | case 0x0000: |
| 935 | | MMC3_helper = MMC3_cmd ^ data; |
| 936 | | MMC3_cmd = data; |
| 981 | MMC3_helper = mmc_cmd1 ^ data; |
| 982 | mmc_cmd1 = data; |
| 937 | 983 | |
| 938 | 984 | /* Has PRG Mode changed? */ |
| 939 | 985 | if (MMC3_helper & 0x40) |
| r5997 | r5998 | |
| 945 | 991 | break; |
| 946 | 992 | |
| 947 | 993 | case 0x0001: |
| 948 | | cmd = MMC3_cmd & 0x07; |
| 994 | cmd = mmc_cmd1 & 0x07; |
| 949 | 995 | switch (cmd) |
| 950 | 996 | { |
| 951 | | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 997 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 952 | 998 | case 2: case 3: case 4: case 5: |
| 953 | 999 | vrom_bank[cmd] = data; |
| 954 | 1000 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| r5997 | r5998 | |
| 971 | 1017 | nes.mid_ram_enable = data; |
| 972 | 1018 | break; |
| 973 | 1019 | |
| 974 | | case 0x4000: /* IRQ scanline counter */ |
| 1020 | case 0x4000: |
| 975 | 1021 | IRQ_count_latch = data; |
| 976 | 1022 | break; |
| 977 | 1023 | |
| 978 | | case 0x4001: /* IRQ scanline latch */ |
| 1024 | case 0x4001: /* some sources state that here we must have IRQ_count = IRQ_count_latch */ |
| 979 | 1025 | IRQ_count = 0; |
| 980 | 1026 | break; |
| 981 | 1027 | |
| 982 | | case 0x6000: /* Disable IRQs */ |
| 1028 | case 0x6000: |
| 983 | 1029 | IRQ_enable = 0; |
| 984 | 1030 | break; |
| 985 | 1031 | |
| 986 | | case 0x6001: /* Enable IRQs */ |
| 1032 | case 0x6001: |
| 987 | 1033 | IRQ_enable = 1; |
| 988 | 1034 | break; |
| 989 | 1035 | |
| r5997 | r5998 | |
| 1100 | 1146 | /* Send $5000-$5015 to the sound chip */ |
| 1101 | 1147 | if ((offset >= 0xf00) && (offset <= 0xf15)) |
| 1102 | 1148 | { |
| 1103 | | nes_psg_w (state->sound, offset & 0x1f, data); |
| 1149 | nes_psg_w(state->sound, offset & 0x1f, data); |
| 1104 | 1150 | return; |
| 1105 | 1151 | } |
| 1106 | 1152 | |
| r5997 | r5998 | |
| 1153 | 1199 | |
| 1154 | 1200 | /* tile data for MMC5 flood-fill NT mode */ |
| 1155 | 1201 | case 0x1006: |
| 1156 | | MMC5_floodtile=data; |
| 1202 | MMC5_floodtile = data; |
| 1157 | 1203 | break; |
| 1158 | 1204 | |
| 1159 | 1205 | /* attr data for MMC5 flood-fill NT mode */ |
| r5997 | r5998 | |
| 1288 | 1334 | vrom_bank[0] = data; |
| 1289 | 1335 | // mapper5_sync_vrom(0); |
| 1290 | 1336 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 1291 | | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 1292 | 1337 | // nes_vram_sprite[0] = vrom_bank[0] * 64; |
| 1293 | 1338 | // vrom_next[0] = 4; |
| 1294 | 1339 | // vrom_page_a = 1; |
| r5997 | r5998 | |
| 1309 | 1354 | vrom_bank[1] = data; |
| 1310 | 1355 | // mapper5_sync_vrom(0); |
| 1311 | 1356 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 1312 | | //ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 1313 | 1357 | // nes_vram_sprite[1] = vrom_bank[0] * 64; |
| 1314 | 1358 | // vrom_next[1] = 5; |
| 1315 | 1359 | // vrom_page_a = 1; |
| r5997 | r5998 | |
| 1326 | 1370 | vrom_bank[2] = data; |
| 1327 | 1371 | // mapper5_sync_vrom(0); |
| 1328 | 1372 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 1329 | | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 1330 | 1373 | // nes_vram_sprite[2] = vrom_bank[0] * 64; |
| 1331 | 1374 | // vrom_next[2] = 6; |
| 1332 | 1375 | // vrom_page_a = 1; |
| r5997 | r5998 | |
| 1350 | 1393 | vrom_bank[3] = data; |
| 1351 | 1394 | // mapper5_sync_vrom(0); |
| 1352 | 1395 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 1353 | | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 1354 | 1396 | // nes_vram_sprite[3] = vrom_bank[0] * 64; |
| 1355 | 1397 | // vrom_next[3] = 7; |
| 1356 | 1398 | // vrom_page_a = 1; |
| r5997 | r5998 | |
| 1367 | 1409 | vrom_bank[4] = data; |
| 1368 | 1410 | // mapper5_sync_vrom(0); |
| 1369 | 1411 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 1370 | | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 1371 | 1412 | // nes_vram_sprite[4] = vrom_bank[0] * 64; |
| 1372 | 1413 | // vrom_next[0] = 0; |
| 1373 | 1414 | // vrom_page_a = 0; |
| r5997 | r5998 | |
| 1388 | 1429 | vrom_bank[5] = data; |
| 1389 | 1430 | // mapper5_sync_vrom(0); |
| 1390 | 1431 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 1391 | | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 1392 | 1432 | // nes_vram_sprite[5] = vrom_bank[0] * 64; |
| 1393 | 1433 | // vrom_next[1] = 1; |
| 1394 | 1434 | // vrom_page_a = 0; |
| r5997 | r5998 | |
| 1405 | 1445 | vrom_bank[6] = data; |
| 1406 | 1446 | // mapper5_sync_vrom(0); |
| 1407 | 1447 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 1408 | | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 1409 | 1448 | // nes_vram_sprite[6] = vrom_bank[0] * 64; |
| 1410 | 1449 | // vrom_next[2] = 2; |
| 1411 | 1450 | // vrom_page_a = 0; |
| r5997 | r5998 | |
| 1434 | 1473 | vrom_bank[7] = data; |
| 1435 | 1474 | // mapper5_sync_vrom(0); |
| 1436 | 1475 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 1437 | | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 1438 | 1476 | // nes_vram_sprite[7] = vrom_bank[0] * 64; |
| 1439 | 1477 | // vrom_next[3] = 3; |
| 1440 | 1478 | // vrom_page_a = 0; |
| r5997 | r5998 | |
| 1453 | 1491 | // nes_vram[0 + (vrom_page_a*4)] = data * 64; |
| 1454 | 1492 | // nes_vram[0] = data * 64; |
| 1455 | 1493 | chr1_4(space->machine, data, CHRROM); |
| 1456 | | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 1457 | 1494 | // mapper5_sync_vrom(1); |
| 1458 | 1495 | if (!vrom_page_b) |
| 1459 | 1496 | { |
| r5997 | r5998 | |
| 1479 | 1516 | // nes_vram[1 + (vrom_page_a*4)] = data * 64; |
| 1480 | 1517 | // nes_vram[1] = data * 64; |
| 1481 | 1518 | chr1_5(space->machine, data, CHRROM); |
| 1482 | | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 1483 | 1519 | // mapper5_sync_vrom(1); |
| 1484 | 1520 | if (!vrom_page_b) |
| 1485 | 1521 | { |
| r5997 | r5998 | |
| 1500 | 1536 | // nes_vram[2 + (vrom_page_a*4)] = data * 64; |
| 1501 | 1537 | // nes_vram[2] = data * 64; |
| 1502 | 1538 | chr1_6(space->machine, data, CHRROM); |
| 1503 | | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 1504 | 1539 | // mapper5_sync_vrom(1); |
| 1505 | 1540 | if (!vrom_page_b) |
| 1506 | 1541 | { |
| r5997 | r5998 | |
| 1537 | 1572 | // nes_vram[3 + (vrom_page_a*4)] = data * 64; |
| 1538 | 1573 | // nes_vram[3] = data * 64; |
| 1539 | 1574 | chr1_7(space->machine, data, CHRROM); |
| 1540 | | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 1541 | 1575 | // mapper5_sync_vrom(1); |
| 1542 | 1576 | if (!vrom_page_b) |
| 1543 | 1577 | { |
| r5997 | r5998 | |
| 1582 | 1616 | Known Boards: FFE4 Copier Board |
| 1583 | 1617 | Games: Hacked versions of games |
| 1584 | 1618 | |
| 1585 | | In MESS: Unsupported, low priority |
| 1619 | In MESS: Supported? Not sure if we could also have ExRAM or not... |
| 1620 | However, priority is pretty low for this mapper. |
| 1586 | 1621 | |
| 1587 | 1622 | *************************************************************/ |
| 1588 | 1623 | |
| 1624 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 1625 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 1626 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 1627 | static void ffe_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 1628 | { |
| 1629 | /* 114 is the number of cycles per scanline */ |
| 1630 | /* TODO: change to reflect the actual number of cycles spent */ |
| 1631 | if (IRQ_enable) |
| 1632 | { |
| 1633 | if ((0xffff - IRQ_count) < 114) |
| 1634 | { |
| 1635 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 1636 | IRQ_count = 0xffff; |
| 1637 | IRQ_enable = 0; |
| 1638 | } |
| 1639 | IRQ_count -= 114; |
| 1640 | } |
| 1641 | } |
| 1642 | |
| 1643 | static WRITE8_HANDLER( mapper6_l_w ) |
| 1644 | { |
| 1645 | LOG_MMC(("mapper6_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 1646 | |
| 1647 | switch (offset) |
| 1648 | { |
| 1649 | case 0x1fe: |
| 1650 | mmc_cmd1 = data & 0x80; |
| 1651 | set_nt_mirroring((data & 0x10) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); |
| 1652 | break; |
| 1653 | case 0x1ff: |
| 1654 | set_nt_mirroring((data & 0x10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 1655 | break; |
| 1656 | |
| 1657 | case 0x401: |
| 1658 | IRQ_enable = data & 0x01; |
| 1659 | break; |
| 1660 | case 0x402: |
| 1661 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 1662 | break; |
| 1663 | case 0x403: |
| 1664 | IRQ_enable = 1; |
| 1665 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 1666 | break; |
| 1667 | } |
| 1668 | } |
| 1669 | |
| 1670 | static WRITE8_HANDLER( mapper6_w ) |
| 1671 | { |
| 1672 | LOG_MMC(("mapper6_w, offset: %04x, data: %02x\n", offset, data)); |
| 1673 | |
| 1674 | if (!mmc_cmd1) // when in "FFE mode" we are forced to use CHRRAM/EXRAM bank? |
| 1675 | { |
| 1676 | prg16_89ab(space->machine, data >> 2); |
| 1677 | // chr8(space->machine, data & 0x03, ???); |
| 1678 | // due to lack of info on the exact behavior, we simply act as if mmc_cmd=1 |
| 1679 | if (mmc_chr_source == CHRROM) |
| 1680 | chr8(space->machine, data & 0x03, CHRROM); |
| 1681 | } |
| 1682 | else if (mmc_chr_source == CHRROM) // otherwise, we can use CHRROM (when present) |
| 1683 | chr8(space->machine, data, CHRROM); |
| 1684 | } |
| 1685 | |
| 1589 | 1686 | /************************************************************* |
| 1590 | 1687 | |
| 1591 | 1688 | Mapper 7 |
| r5997 | r5998 | |
| 1613 | 1710 | Known Boards: FFE3 Copier Board |
| 1614 | 1711 | Games: Hacked versions of games |
| 1615 | 1712 | |
| 1616 | | In MESS: Supported |
| 1713 | In MESS: Supported? (I have no games to test this) |
| 1617 | 1714 | |
| 1618 | 1715 | *************************************************************/ |
| 1619 | 1716 | |
| r5997 | r5998 | |
| 1622 | 1719 | LOG_MMC(("mapper8_w, offset: %04x, data: %02x\n", offset, data)); |
| 1623 | 1720 | |
| 1624 | 1721 | chr8(space->machine, data & 0x07, CHRROM); |
| 1625 | | data = (data >> 3) & (nes.prg_chunks - 1); |
| 1626 | | memory_set_bankptr(space->machine, 1, &nes.rom[data * 0x4000 + 0x10000]); |
| 1627 | | memory_set_bankptr(space->machine, 2, &nes.rom[data * 0x4000 + 0x12000]); |
| 1722 | prg16_89ab(space->machine, data >> 3); |
| 1628 | 1723 | } |
| 1629 | 1724 | |
| 1630 | | |
| 1631 | 1725 | /************************************************************* |
| 1632 | 1726 | |
| 1633 | 1727 | Mapper 9 |
| r5997 | r5998 | |
| 1669 | 1763 | |
| 1670 | 1764 | static WRITE8_HANDLER( mapper9_w ) |
| 1671 | 1765 | { |
| 1766 | LOG_MMC(("mapper9_w, offset: %04x, data: %02x\n", offset, data)); |
| 1672 | 1767 | switch (offset & 0x7000) |
| 1673 | 1768 | { |
| 1674 | 1769 | case 0x2000: |
| r5997 | r5998 | |
| 1678 | 1773 | MMC2_regs[0] = data; |
| 1679 | 1774 | if (mmc_cmd1 == 0xfd) |
| 1680 | 1775 | chr4_0(space->machine, MMC2_regs[0], CHRROM); |
| 1681 | | LOG_MMC(("MMC2 VROM switch #1 (low): %02x\n", MMC2_regs[0])); |
| 1682 | 1776 | break; |
| 1683 | 1777 | case 0x4000: |
| 1684 | 1778 | MMC2_regs[1] = data; |
| 1685 | 1779 | if (mmc_cmd1 == 0xfe) |
| 1686 | 1780 | chr4_0(space->machine, MMC2_regs[1], CHRROM); |
| 1687 | | LOG_MMC(("MMC2 VROM switch #1 (high): %02x\n", MMC2_regs[1])); |
| 1688 | 1781 | break; |
| 1689 | 1782 | case 0x5000: |
| 1690 | 1783 | MMC2_regs[2] = data; |
| 1691 | 1784 | if (mmc_cmd2 == 0xfd) |
| 1692 | 1785 | chr4_4(space->machine, MMC2_regs[2], CHRROM); |
| 1693 | | LOG_MMC(("MMC2 VROM switch #2 (low): %02x\n", data)); |
| 1694 | 1786 | break; |
| 1695 | 1787 | case 0x6000: |
| 1696 | 1788 | MMC2_regs[3] = data; |
| 1697 | 1789 | if (mmc_cmd2 == 0xfe) |
| 1698 | 1790 | chr4_4(space->machine, MMC2_regs[3], CHRROM); |
| 1699 | | LOG_MMC(("MMC2 VROM switch #2 (high): %02x\n", data)); |
| 1700 | 1791 | break; |
| 1701 | 1792 | case 0x7000: |
| 1702 | 1793 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| r5997 | r5998 | |
| 1748 | 1839 | { |
| 1749 | 1840 | LOG_MMC(("mapper11_w, offset: %04x, data: %02x\n", offset, data)); |
| 1750 | 1841 | |
| 1751 | | chr8(space->machine, data >> 4, CHRROM); |
| 1842 | chr8(space->machine, data >> 4, mmc_chr_source); |
| 1752 | 1843 | prg32(space->machine, data & 0x0f); |
| 1753 | 1844 | } |
| 1754 | 1845 | |
| r5997 | r5998 | |
| 1781 | 1872 | |
| 1782 | 1873 | static void mapper12_set_chr( running_machine *machine ) |
| 1783 | 1874 | { |
| 1784 | | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 1875 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 1785 | 1876 | |
| 1786 | 1877 | chr1_x(machine, chr_page ^ 0, ((mapper12_reg & 0x01) << 8) | (vrom_bank[0] & ~0x01), CHRROM); |
| 1787 | 1878 | chr1_x(machine, chr_page ^ 1, ((mapper12_reg & 0x01) << 8) | (vrom_bank[0] | 0x01), CHRROM); |
| r5997 | r5998 | |
| 1801 | 1892 | switch (offset & 0x6001) |
| 1802 | 1893 | { |
| 1803 | 1894 | case 0x0000: |
| 1804 | | MMC3_helper = MMC3_cmd ^ data; |
| 1805 | | MMC3_cmd = data; |
| 1895 | MMC3_helper = mmc_cmd1 ^ data; |
| 1896 | mmc_cmd1 = data; |
| 1806 | 1897 | |
| 1807 | 1898 | /* Has PRG Mode changed? */ |
| 1808 | 1899 | if (MMC3_helper & 0x40) |
| r5997 | r5998 | |
| 1814 | 1905 | break; |
| 1815 | 1906 | |
| 1816 | 1907 | case 0x0001: |
| 1817 | | cmd = MMC3_cmd & 0x07; |
| 1908 | cmd = mmc_cmd1 & 0x07; |
| 1818 | 1909 | switch (cmd) |
| 1819 | 1910 | { |
| 1820 | | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 1911 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 1821 | 1912 | case 2: case 3: case 4: case 5: |
| 1822 | 1913 | vrom_bank[cmd] = data; |
| 1823 | 1914 | mapper12_set_chr(space->machine); |
| r5997 | r5998 | |
| 1858 | 1949 | Mapper 14 |
| 1859 | 1950 | |
| 1860 | 1951 | Known Boards: Bootleg Board by Rex Soft (SL1632) |
| 1861 | | Games: [no games in nes.hsi] |
| 1952 | Games: Samurai Spirits |
| 1862 | 1953 | |
| 1863 | 1954 | MMC3 clone |
| 1864 | 1955 | |
| 1865 | | In MESS: Unsupported |
| 1956 | In MESS: Supported |
| 1866 | 1957 | |
| 1867 | 1958 | *************************************************************/ |
| 1868 | 1959 | |
| 1960 | static void mapper14_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 1961 | { |
| 1962 | if (map14_reg[0] & 0x02) |
| 1963 | { |
| 1964 | mapper4_set_prg(machine, prg_base, prg_mask); |
| 1965 | } |
| 1966 | else |
| 1967 | { |
| 1968 | prg8_89(machine, extra_bank[0]); |
| 1969 | prg8_ab(machine, extra_bank[1]); |
| 1970 | prg8_cd(machine, extra_bank[2]); |
| 1971 | prg8_ef(machine, extra_bank[3]); |
| 1972 | } |
| 1973 | } |
| 1974 | |
| 1975 | static void mapper14_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 1976 | { |
| 1977 | static const UINT8 conv_table[8] = {5, 5, 5, 5, 3, 3, 1, 1}; |
| 1978 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 1979 | UINT8 bank[8]; |
| 1980 | UINT8 chr_base2[8]; |
| 1981 | int i; |
| 1982 | |
| 1983 | if (map14_reg[0] & 0x02) |
| 1984 | { |
| 1985 | for(i = 0; i < 8; i++) |
| 1986 | { |
| 1987 | bank[i] = vrom_bank[i]; |
| 1988 | chr_base2[i] = chr_base | ((map14_reg[0] << conv_table[i]) & 0x100); |
| 1989 | } |
| 1990 | } |
| 1991 | else |
| 1992 | { |
| 1993 | for(i = 0; i < 8; i++) |
| 1994 | { |
| 1995 | bank[i] = extra_bank[i + 4]; // first 4 extra_banks are PRG |
| 1996 | chr_base2[i] = chr_base; |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | chr1_x(machine, chr_page ^ 0, chr_base2[0] | (bank[0] & chr_mask), chr); |
| 2001 | chr1_x(machine, chr_page ^ 1, chr_base2[1] | (bank[1] & chr_mask), chr); |
| 2002 | chr1_x(machine, chr_page ^ 2, chr_base2[2] | (bank[2] & chr_mask), chr); |
| 2003 | chr1_x(machine, chr_page ^ 3, chr_base2[3] | (bank[3] & chr_mask), chr); |
| 2004 | chr1_x(machine, chr_page ^ 4, chr_base2[4] | (bank[4] & chr_mask), chr); |
| 2005 | chr1_x(machine, chr_page ^ 5, chr_base2[5] | (bank[5] & chr_mask), chr); |
| 2006 | chr1_x(machine, chr_page ^ 6, chr_base2[6] | (bank[6] & chr_mask), chr); |
| 2007 | chr1_x(machine, chr_page ^ 7, chr_base2[7] | (bank[7] & chr_mask), chr); |
| 2008 | } |
| 2009 | |
| 2010 | static WRITE8_HANDLER( mapper14_w ) |
| 2011 | { |
| 2012 | UINT8 map14_helper1, map14_helper2, MMC3_helper, cmd; |
| 2013 | LOG_MMC(("mapper14_w, offset: %04x, data: %02x\n", offset, data)); |
| 2014 | |
| 2015 | if (offset == 0x2131) |
| 2016 | { |
| 2017 | map14_reg[0] = data; |
| 2018 | mapper14_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 2019 | mapper14_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 2020 | |
| 2021 | if (!(map14_reg[0] & 0x02)) |
| 2022 | set_nt_mirroring(map14_reg[1] & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 2023 | } |
| 2024 | |
| 2025 | if (map14_reg[0] & 0x02) |
| 2026 | { |
| 2027 | switch (offset & 0x6001) |
| 2028 | { |
| 2029 | case 0x0000: |
| 2030 | MMC3_helper = mmc_cmd1 ^ data; |
| 2031 | mmc_cmd1 = data; |
| 2032 | |
| 2033 | /* Has PRG Mode changed? */ |
| 2034 | if (MMC3_helper & 0x40) |
| 2035 | mapper14_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 2036 | |
| 2037 | /* Has CHR Mode changed? */ |
| 2038 | if (MMC3_helper & 0x80) |
| 2039 | mapper14_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 2040 | break; |
| 2041 | |
| 2042 | case 0x0001: |
| 2043 | cmd = mmc_cmd1 & 0x07; |
| 2044 | switch (cmd) |
| 2045 | { |
| 2046 | case 0: case 1: // these have to be changed due to the different way mapper14_set_chr works (it handles 1k banks)! |
| 2047 | vrom_bank[2 * cmd] = data; |
| 2048 | vrom_bank[2 * cmd + 1] = data; |
| 2049 | mapper14_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 2050 | break; |
| 2051 | case 2: case 3: case 4: case 5: |
| 2052 | vrom_bank[cmd + 2] = data; |
| 2053 | mapper14_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 2054 | break; |
| 2055 | case 6: |
| 2056 | case 7: |
| 2057 | prg_bank[cmd - 6] = data; |
| 2058 | mapper14_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 2059 | break; |
| 2060 | } |
| 2061 | break; |
| 2062 | |
| 2063 | case 0x2000: |
| 2064 | set_nt_mirroring(map14_reg[1] & 0x01 ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 2065 | break; |
| 2066 | |
| 2067 | default: |
| 2068 | mapper4_w(space, offset, data); |
| 2069 | break; |
| 2070 | } |
| 2071 | } |
| 2072 | else if (offset >= 0x3000 && offset <= 0x6003 ) |
| 2073 | { |
| 2074 | map14_helper1 = (offset & 0x01) << 2; |
| 2075 | offset = ((offset & 0x02) | (offset >> 10)) >> 1; |
| 2076 | map14_helper2 = ((offset + 2) & 0x07) + 4; // '+4' because first 4 extra_banks are for PRG! |
| 2077 | extra_bank[map14_helper2] = (extra_bank[map14_helper2] & (0xf0 >> map14_helper1)) | ((data & 0x0f) << map14_helper1); |
| 2078 | mapper14_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 2079 | } |
| 2080 | else |
| 2081 | { |
| 2082 | switch (offset & 0x7003) |
| 2083 | { |
| 2084 | case 0x0000: |
| 2085 | case 0x2000: |
| 2086 | extra_bank[offset >> 13] = data; |
| 2087 | mapper14_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 2088 | break; |
| 2089 | |
| 2090 | case 0x1000: |
| 2091 | map14_reg[1] = data; |
| 2092 | set_nt_mirroring(map14_reg[1] & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 2093 | break; |
| 2094 | } |
| 2095 | } |
| 2096 | } |
| 2097 | |
| 1869 | 2098 | /************************************************************* |
| 1870 | 2099 | |
| 1871 | 2100 | Mapper 15 |
| r5997 | r5998 | |
| 1899 | 2128 | prg8_89(space->machine, map15_helper); |
| 1900 | 2129 | prg8_ab(space->machine, map15_helper + 1); |
| 1901 | 2130 | prg8_cd(space->machine, map15_helper + 1); |
| 1902 | | prg8_ef(space->machine, map15_helper); |
| 2131 | prg8_ef(space->machine, map15_helper + 1); |
| 1903 | 2132 | break; |
| 1904 | 2133 | case 0x002: |
| 1905 | 2134 | map15_helper |= map15_flip; |
| r5997 | r5998 | |
| 1913 | 2142 | prg8_89(space->machine, map15_helper); |
| 1914 | 2143 | prg8_ab(space->machine, map15_helper + 1); |
| 1915 | 2144 | prg8_cd(space->machine, map15_helper); |
| 1916 | | prg8_ef(space->machine, map15_helper); |
| 2145 | prg8_ef(space->machine, map15_helper + 1); |
| 1917 | 2146 | break; |
| 1918 | 2147 | } |
| 1919 | 2148 | } |
| r5997 | r5998 | |
| 1927 | 2156 | Dragon Ball Z II & III, Rokudenashi Blues, SD Gundam |
| 1928 | 2157 | Gaiden - KGM2 |
| 1929 | 2158 | |
| 2159 | At the moment, we don't support EEPROM I/O |
| 2160 | |
| 1930 | 2161 | In MESS: Supported |
| 1931 | 2162 | |
| 1932 | 2163 | *************************************************************/ |
| 1933 | 2164 | |
| 2165 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 2166 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 2167 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 1934 | 2168 | static void bandai_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 1935 | 2169 | { |
| 1936 | 2170 | /* 114 is the number of cycles per scanline */ |
| 1937 | 2171 | /* TODO: change to reflect the actual number of cycles spent */ |
| 1938 | | |
| 1939 | 2172 | if (IRQ_enable) |
| 1940 | 2173 | { |
| 1941 | 2174 | if (IRQ_count <= 114) |
| 1942 | 2175 | { |
| 1943 | 2176 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2177 | IRQ_count = (0xffff - 114 + IRQ_count); // wrap around the 16 bits counter |
| 1944 | 2178 | } |
| 1945 | 2179 | IRQ_count -= 114; |
| 1946 | 2180 | } |
| r5997 | r5998 | |
| 1956 | 2190 | case 2: case 3: |
| 1957 | 2191 | case 4: case 5: |
| 1958 | 2192 | case 6: case 7: |
| 1959 | | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 2193 | chr1_x(space->machine, offset & 0x07, data, mmc_chr_source); |
| 1960 | 2194 | break; |
| 1961 | 2195 | case 8: |
| 1962 | 2196 | prg16_89ab(space->machine, data); |
| r5997 | r5998 | |
| 1964 | 2198 | case 9: |
| 1965 | 2199 | switch (data & 0x03) |
| 1966 | 2200 | { |
| 1967 | | case 0: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 1968 | | case 1: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2201 | case 0: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2202 | case 1: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 1969 | 2203 | case 2: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 1970 | 2204 | case 3: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 1971 | 2205 | } |
| r5997 | r5998 | |
| 1974 | 2208 | IRQ_enable = data & 0x01; |
| 1975 | 2209 | break; |
| 1976 | 2210 | case 0x0b: |
| 1977 | | IRQ_count &= 0xff00; |
| 1978 | | IRQ_count |= data; |
| 2211 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 1979 | 2212 | break; |
| 1980 | 2213 | case 0x0c: |
| 1981 | | IRQ_count &= 0x00ff; |
| 1982 | | IRQ_count |= (data << 8); |
| 2214 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 1983 | 2215 | break; |
| 1984 | 2216 | default: |
| 1985 | 2217 | logerror("** uncaught mapper 16 write, offset: %04x, data: %02x\n", offset, data); |
| r5997 | r5998 | |
| 2001 | 2233 | Known Boards: FFE8 Copier Board |
| 2002 | 2234 | Games: Hacked versions of games |
| 2003 | 2235 | |
| 2004 | | In MESS: Supported. it also uses mapper4_irq. |
| 2236 | In MESS: Supported?. IRQ support is just a guess (used to |
| 2237 | use MMC3 IRQ but it was wrong and it never enabled it) |
| 2005 | 2238 | |
| 2006 | 2239 | *************************************************************/ |
| 2007 | 2240 | |
| r5997 | r5998 | |
| 2011 | 2244 | |
| 2012 | 2245 | switch (offset) |
| 2013 | 2246 | { |
| 2014 | | /* $42fe - mirroring */ |
| 2015 | 2247 | case 0x1fe: |
| 2016 | | if (data & 0x10) |
| 2017 | | set_nt_mirroring(PPU_MIRROR_LOW); |
| 2018 | | else |
| 2019 | | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 2248 | set_nt_mirroring((data & 0x10) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); |
| 2020 | 2249 | break; |
| 2021 | | /* $42ff - mirroring */ |
| 2022 | 2250 | case 0x1ff: |
| 2023 | | if (data & 0x10) |
| 2024 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2025 | | else |
| 2026 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2251 | set_nt_mirroring((data & 0x10) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 2027 | 2252 | break; |
| 2028 | | /* $4501 - $4503 */ |
| 2029 | | // case 0x401: |
| 2030 | | // case 0x402: |
| 2031 | | // case 0x403: |
| 2032 | | /* IRQ control */ |
| 2033 | | // break; |
| 2034 | | /* $4504 - $4507 : 8k PRG-Rom switch */ |
| 2253 | |
| 2254 | case 0x401: |
| 2255 | IRQ_enable = data & 0x01; |
| 2256 | break; |
| 2257 | case 0x402: |
| 2258 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 2259 | break; |
| 2260 | case 0x403: |
| 2261 | IRQ_enable = 1; |
| 2262 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 2263 | break; |
| 2264 | |
| 2035 | 2265 | case 0x404: |
| 2266 | prg8_89(space->machine, data); |
| 2267 | break; |
| 2036 | 2268 | case 0x405: |
| 2269 | prg8_ab(space->machine, data); |
| 2270 | break; |
| 2037 | 2271 | case 0x406: |
| 2272 | prg8_cd(space->machine, data); |
| 2273 | break; |
| 2038 | 2274 | case 0x407: |
| 2039 | | data &= ((nes.prg_chunks << 1) - 1); |
| 2040 | | // LOG_MMC(("Mapper 17 bank switch, bank: %02x, data: %02x\n", offset & 0x03, data)); |
| 2041 | | memory_set_bankptr(space->machine, (offset & 0x03) + 1, &nes.rom[0x2000 * (data) + 0x10000]); |
| 2275 | prg8_ef(space->machine, data); |
| 2042 | 2276 | break; |
| 2043 | | /* $4510 - $4517 : 1k CHR-Rom switch */ |
| 2277 | |
| 2044 | 2278 | case 0x410: |
| 2045 | 2279 | case 0x411: |
| 2046 | 2280 | case 0x412: |
| r5997 | r5998 | |
| 2049 | 2283 | case 0x415: |
| 2050 | 2284 | case 0x416: |
| 2051 | 2285 | case 0x417: |
| 2052 | | chr1_x(space->machine, offset&7, data&((nes.chr_chunks << 3) - 1), CHRROM); |
| 2053 | | // ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64); |
| 2286 | chr1_x(space->machine, offset & 7, data, CHRROM); |
| 2054 | 2287 | break; |
| 2055 | | default: |
| 2056 | | logerror("** uncaught mapper 17 write, offset: %04x, data: %02x\n", offset, data); |
| 2057 | | break; |
| 2058 | 2288 | } |
| 2059 | 2289 | } |
| 2060 | 2290 | |
| r5997 | r5998 | |
| 2070 | 2300 | In MESS: Supported |
| 2071 | 2301 | |
| 2072 | 2302 | *************************************************************/ |
| 2073 | | |
| 2303 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 2304 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 2305 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 2074 | 2306 | static void jaleco_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 2075 | 2307 | { |
| 2076 | | if (scanline <= PPU_BOTTOM_VISIBLE_SCANLINE) |
| 2308 | /* Increment & check the IRQ scanline counter */ |
| 2309 | if (IRQ_enable) |
| 2077 | 2310 | { |
| 2078 | | /* Increment & check the IRQ scanline counter */ |
| 2079 | | if (IRQ_enable) |
| 2311 | LOG_MMC(("scanline: %d, irq count: %04x\n", scanline, IRQ_count)); |
| 2312 | if (IRQ_mode & 0x08) |
| 2080 | 2313 | { |
| 2081 | | IRQ_count -= 0x100; |
| 2082 | | |
| 2083 | | LOG_MMC(("scanline: %d, irq count: %04x\n", scanline, IRQ_count)); |
| 2084 | | if (IRQ_mode & 0x08) |
| 2314 | if ((IRQ_count & 0x000f) < 114) // always true, but we only update the IRQ once per scanlines so we cannot be more precise :( |
| 2085 | 2315 | { |
| 2086 | | if ((IRQ_count & 0x0f) == 0x00) |
| 2087 | | /* rollover every 0x10 */ |
| 2088 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2316 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2317 | IRQ_count = (IRQ_count & ~0x000f) | (0x0f - (114 & 0x0f) + (IRQ_count & 0x000f)); // sort of wrap around the counter |
| 2089 | 2318 | } |
| 2090 | | else if (IRQ_mode & 0x04) |
| 2319 | // decrements should not affect upper bits, so we don't do anything here (114 > 0x0f) |
| 2320 | } |
| 2321 | else if (IRQ_mode & 0x04) |
| 2322 | { |
| 2323 | if ((IRQ_count & 0x00ff) < 114) |
| 2091 | 2324 | { |
| 2092 | | if ((IRQ_count & 0x0ff) == 0x00) |
| 2093 | | /* rollover every 0x100 */ |
| 2094 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2325 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2326 | IRQ_count = (IRQ_count & ~0x00ff) | (0xff - 114 + (IRQ_count & 0x00ff)); // wrap around the 8 bits counter |
| 2095 | 2327 | } |
| 2096 | | else if (IRQ_mode & 0x02) |
| 2328 | else |
| 2329 | IRQ_count -= 114; |
| 2330 | } |
| 2331 | else if (IRQ_mode & 0x02) |
| 2332 | { |
| 2333 | if ((IRQ_count & 0x0fff) < 114) |
| 2097 | 2334 | { |
| 2098 | | if ((IRQ_count & 0x0fff) == 0x000) |
| 2099 | | /* rollover every 0x1000 */ |
| 2100 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2335 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2336 | IRQ_count = (IRQ_count & ~0x0fff) | (0xfff - 114 + (IRQ_count & 0x0fff)); // wrap around the 12 bits counter |
| 2101 | 2337 | } |
| 2102 | | else if (IRQ_count == 0) |
| 2103 | | /* rollover at 0x10000 */ |
| 2104 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2338 | else |
| 2339 | IRQ_count -= 114; |
| 2105 | 2340 | } |
| 2341 | else if (IRQ_count < 114) |
| 2342 | { |
| 2343 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2344 | IRQ_count = (0xffff - 114 + IRQ_count); // wrap around the 16 bits counter |
| 2345 | } |
| 2346 | else |
| 2347 | IRQ_count -= 114; |
| 2106 | 2348 | } |
| 2107 | | else |
| 2108 | | { |
| 2109 | | IRQ_count = IRQ_count_latch; |
| 2110 | | } |
| 2111 | 2349 | } |
| 2112 | 2350 | |
| 2113 | | |
| 2114 | 2351 | static WRITE8_HANDLER( mapper18_w ) |
| 2115 | 2352 | { |
| 2116 | 2353 | UINT8 bank; |
| r5997 | r5998 | |
| 2119 | 2356 | switch (offset & 0x7003) |
| 2120 | 2357 | { |
| 2121 | 2358 | case 0x0000: |
| 2122 | | /* Switch 8k bank at $8000 - low 4 bits */ |
| 2123 | 2359 | prg_bank[0] = (prg_bank[0] & 0xf0) | (data & 0x0f); |
| 2124 | 2360 | prg8_89(space->machine, prg_bank[0]); |
| 2125 | 2361 | break; |
| 2126 | 2362 | case 0x0001: |
| 2127 | | /* Switch 8k bank at $8000 - high 4 bits */ |
| 2128 | 2363 | prg_bank[0] = (prg_bank[0] & 0x0f) | (data << 4); |
| 2129 | 2364 | prg8_89(space->machine, prg_bank[0]); |
| 2130 | 2365 | break; |
| 2131 | 2366 | case 0x0002: |
| 2132 | | /* Switch 8k bank at $a000 - low 4 bits */ |
| 2133 | 2367 | prg_bank[1] = (prg_bank[1] & 0xf0) | (data & 0x0f); |
| 2134 | 2368 | prg8_ab(space->machine, prg_bank[1]); |
| 2135 | 2369 | break; |
| 2136 | 2370 | case 0x0003: |
| 2137 | | /* Switch 8k bank at $a000 - high 4 bits */ |
| 2138 | 2371 | prg_bank[1] = (prg_bank[1] & 0x0f) | (data << 4); |
| 2139 | 2372 | prg8_ab(space->machine, prg_bank[1]); |
| 2140 | 2373 | break; |
| 2141 | 2374 | case 0x1000: |
| 2142 | | /* Switch 8k bank at $c000 - low 4 bits */ |
| 2143 | 2375 | prg_bank[2] = (prg_bank[2] & 0xf0) | (data & 0x0f); |
| 2144 | 2376 | prg8_cd(space->machine, prg_bank[2]); |
| 2145 | 2377 | break; |
| 2146 | 2378 | case 0x1001: |
| 2147 | | /* Switch 8k bank at $c000 - high 4 bits */ |
| 2148 | 2379 | prg_bank[2] = (prg_bank[2] & 0x0f) | (data << 4); |
| 2149 | 2380 | prg8_cd(space->machine, prg_bank[2]); |
| 2150 | 2381 | break; |
| r5997 | r5998 | |
| 2152 | 2383 | /* $9002, 3 (1002, 3) uncaught = Jaleco Baseball writes 0 */ |
| 2153 | 2384 | /* believe it's related to battery-backed ram enable/disable */ |
| 2154 | 2385 | |
| 2155 | | case 0x2000: |
| 2156 | | case 0x2001: |
| 2157 | | case 0x2002: |
| 2158 | | case 0x2003: |
| 2159 | | case 0x3000: |
| 2160 | | case 0x3001: |
| 2161 | | case 0x3002: |
| 2162 | | case 0x3003: |
| 2163 | | case 0x4000: |
| 2164 | | case 0x4001: |
| 2165 | | case 0x4002: |
| 2166 | | case 0x4003: |
| 2167 | | case 0x5000: |
| 2168 | | case 0x5001: |
| 2169 | | case 0x5002: |
| 2170 | | case 0x5003: |
| 2171 | | bank = ((offset & 0x7000) - 0x2000) / 0x0400 + ((offset & 0x0002) >> 1); |
| 2386 | case 0x2000: case 0x2001: case 0x2002: case 0x2003: |
| 2387 | case 0x3000: case 0x3001: case 0x3002: case 0x3003: |
| 2388 | case 0x4000: case 0x4001: case 0x4002: case 0x4003: |
| 2389 | case 0x5000: case 0x5001: case 0x5002: case 0x5003: |
| 2390 | bank = ((offset & 0x7000) - 0x2000) / 0x0800 + ((offset & 0x0002) >> 1); |
| 2172 | 2391 | if (offset & 0x0001) |
| 2173 | | vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | (data << 4); |
| 2392 | vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | ((data & 0x0f)<< 4); |
| 2174 | 2393 | else |
| 2175 | 2394 | vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f); |
| 2176 | 2395 | |
| 2177 | 2396 | chr1_x(space->machine, bank, vrom_bank[bank], CHRROM); |
| 2178 | 2397 | break; |
| 2179 | 2398 | |
| 2180 | | /* LBO - these are unverified */ |
| 2181 | | |
| 2182 | | case 0x6000: /* IRQ scanline counter - low byte, low nibble */ |
| 2399 | case 0x6000: |
| 2183 | 2400 | IRQ_count_latch = (IRQ_count_latch & 0xfff0) | (data & 0x0f); |
| 2184 | | LOG_MMC((" Mapper 18 copy/set irq latch (l-l): %02x\n", data)); |
| 2185 | 2401 | break; |
| 2186 | | case 0x6001: /* IRQ scanline counter - low byte, high nibble */ |
| 2402 | case 0x6001: |
| 2187 | 2403 | IRQ_count_latch = (IRQ_count_latch & 0xff0f) | ((data & 0x0f) << 4); |
| 2188 | | LOG_MMC((" Mapper 18 copy/set irq latch (l-h): %02x\n", data)); |
| 2189 | 2404 | break; |
| 2190 | 2405 | case 0x6002: |
| 2191 | | IRQ_count_latch = (IRQ_count_latch & 0xf0ff) | ((data & 0x0f) << 9); |
| 2192 | | LOG_MMC((" Mapper 18 copy/set irq latch (h-l): %02x\n", data)); |
| 2406 | IRQ_count_latch = (IRQ_count_latch & 0xf0ff) | ((data & 0x0f) << 8); |
| 2193 | 2407 | break; |
| 2194 | 2408 | case 0x6003: |
| 2195 | | IRQ_count_latch = (IRQ_count_latch & 0x0fff) | ((data & 0x0f) << 13); |
| 2196 | | LOG_MMC((" Mapper 18 copy/set irq latch (h-h): %02x\n", data)); |
| 2409 | IRQ_count_latch = (IRQ_count_latch & 0x0fff) | ((data & 0x0f) << 12); |
| 2197 | 2410 | break; |
| 2198 | 2411 | |
| 2199 | | /* LBO - these 2 are likely wrong */ |
| 2200 | | |
| 2201 | | case 0x7000: /* IRQ Control 0 */ |
| 2202 | | if (data & 0x01) |
| 2203 | | { |
| 2204 | | // IRQ_enable = 1; |
| 2205 | | IRQ_count = IRQ_count_latch; |
| 2206 | | } |
| 2207 | | LOG_MMC((" Mapper 18 IRQ Control 0: %02x\n", data)); |
| 2412 | case 0x7000: |
| 2413 | IRQ_count = IRQ_count_latch; |
| 2208 | 2414 | break; |
| 2209 | | case 0x7001: /* IRQ Control 1 */ |
| 2415 | case 0x7001: |
| 2210 | 2416 | IRQ_enable = data & 0x01; |
| 2211 | 2417 | IRQ_mode = data & 0x0e; |
| 2212 | | LOG_MMC((" Mapper 18 IRQ Control 1: %02x\n", data)); |
| 2213 | 2418 | break; |
| 2214 | 2419 | |
| 2215 | | case 0x7002: /* Misc */ |
| 2420 | case 0x7002: |
| 2216 | 2421 | switch (data & 0x03) |
| 2217 | 2422 | { |
| 2218 | | case 0: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2219 | | case 1: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2220 | | case 2: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2221 | | case 3: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2423 | case 0: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2424 | case 1: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2425 | case 2: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2426 | case 3: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2222 | 2427 | } |
| 2223 | 2428 | break; |
| 2224 | 2429 | |
| 2225 | | /* $f003 uncaught, writes 0(start) & various(ingame) */ |
| 2226 | | // case 0x7003: |
| 2227 | | // IRQ_count = data; |
| 2228 | | // break; |
| 2229 | | |
| 2230 | 2430 | default: |
| 2231 | 2431 | logerror("Mapper 18 uncaught addr: %04x value: %02x\n", offset + 0x8000, data); |
| 2232 | 2432 | break; |
| r5997 | r5998 | |
| 2245 | 2445 | |
| 2246 | 2446 | *************************************************************/ |
| 2247 | 2447 | |
| 2448 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 2449 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 2450 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 2248 | 2451 | static void namcot_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 2249 | 2452 | { |
| 2250 | 2453 | if (IRQ_enable) |
| 2251 | 2454 | { |
| 2252 | | if (IRQ_count == 0x7fff) |
| 2455 | if (IRQ_count >= (0x7fff - 114)) |
| 2456 | { |
| 2253 | 2457 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2458 | IRQ_count = 0; |
| 2459 | } |
| 2254 | 2460 | else |
| 2255 | | IRQ_count++; |
| 2461 | IRQ_count += 114; |
| 2256 | 2462 | } |
| 2257 | 2463 | } |
| 2258 | 2464 | |
| 2259 | 2465 | static WRITE8_HANDLER( mapper19_l_w ) |
| 2260 | 2466 | { |
| 2261 | 2467 | LOG_MMC(("mapper19_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 2468 | offset += 0x100; |
| 2262 | 2469 | |
| 2263 | 2470 | switch (offset & 0x1800) |
| 2264 | 2471 | { |
| r5997 | r5998 | |
| 2278 | 2485 | static READ8_HANDLER( mapper19_l_r ) |
| 2279 | 2486 | { |
| 2280 | 2487 | LOG_MMC(("mapper19_l_r, offset: %04x\n", offset)); |
| 2488 | offset += 0x100; |
| 2281 | 2489 | |
| 2282 | 2490 | switch (offset & 0x1800) |
| 2283 | 2491 | { |
| r5997 | r5998 | |
| 2290 | 2498 | } |
| 2291 | 2499 | } |
| 2292 | 2500 | |
| 2501 | static void mapper19_set_mirror( UINT8 page, UINT8 data ) |
| 2502 | { |
| 2503 | if (!(data < 0xe0)) |
| 2504 | set_nt_page(page, CIRAM, data & 0x01, 1); |
| 2505 | else |
| 2506 | set_nt_page(page, ROM, data, 0); |
| 2507 | } |
| 2508 | |
| 2293 | 2509 | static WRITE8_HANDLER( mapper19_w ) |
| 2294 | 2510 | { |
| 2295 | 2511 | LOG_MMC(("mapper19_w, offset: %04x, data: %02x\n", offset, data)); |
| r5997 | r5998 | |
| 2302 | 2518 | chr1_x(space->machine, offset / 0x800, data, CHRROM); |
| 2303 | 2519 | break; |
| 2304 | 2520 | case 0x4000: |
| 2305 | | set_nt_page(0, CIRAM, data & 0x01, 1); |
| 2521 | mapper19_set_mirror(0, data); |
| 2306 | 2522 | break; |
| 2307 | 2523 | case 0x4800: |
| 2308 | | set_nt_page(1, CIRAM, data & 0x01, 1); |
| 2524 | mapper19_set_mirror(1, data); |
| 2309 | 2525 | break; |
| 2310 | 2526 | case 0x5000: |
| 2311 | | set_nt_page(2, CIRAM, data & 0x01, 1); |
| 2527 | mapper19_set_mirror(2, data); |
| 2312 | 2528 | break; |
| 2313 | 2529 | case 0x5800: |
| 2314 | | set_nt_page(3, CIRAM, data & 0x01, 1); |
| 2530 | mapper19_set_mirror(3, data); |
| 2315 | 2531 | break; |
| 2316 | 2532 | case 0x6000: |
| 2317 | | prg8_89(space->machine, data); |
| 2533 | prg8_89(space->machine, data & 0x3f); |
| 2318 | 2534 | break; |
| 2319 | 2535 | case 0x6800: |
| 2320 | | prg8_ab(space->machine, data); |
| 2536 | mmc_cmd1 = data & 0xc0; // this should enable High CHRRAM, but we still have to properly implement it! |
| 2537 | prg8_ab(space->machine, data & 0x3f); |
| 2321 | 2538 | break; |
| 2322 | 2539 | case 0x7000: |
| 2323 | | prg8_cd(space->machine, data); |
| 2540 | prg8_cd(space->machine, data & 0x3f); |
| 2324 | 2541 | break; |
| 2542 | case 0x7800: |
| 2543 | LOG_MMC(("Mapper 19 sound address write, data: %02x\n", data)); |
| 2544 | break; |
| 2325 | 2545 | } |
| 2326 | 2546 | } |
| 2327 | 2547 | |
| r5997 | r5998 | |
| 2341 | 2561 | if (IRQ_enable_latch) |
| 2342 | 2562 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 2343 | 2563 | |
| 2344 | | /* Increment & check the IRQ scanline counter */ |
| 2345 | 2564 | if (IRQ_enable) |
| 2346 | 2565 | { |
| 2347 | 2566 | if (IRQ_count <= 114) |
| r5997 | r5998 | |
| 2357 | 2576 | |
| 2358 | 2577 | READ8_HANDLER( fds_r ) |
| 2359 | 2578 | { |
| 2360 | | int ret = 0x00; |
| 2361 | | static int last_side = 0; |
| 2362 | | static int count = 0; |
| 2363 | | |
| 2579 | UINT8 ret = 0x00; |
| 2364 | 2580 | LOG_MMC(("fds_r, offset: %04x\n", offset)); |
| 2365 | 2581 | |
| 2366 | 2582 | switch (offset) |
| r5997 | r5998 | |
| 2383 | 2599 | /* return "no disk" status if disk is unloaded */ |
| 2384 | 2600 | if (nes_fds.data == NULL) |
| 2385 | 2601 | ret = 1; |
| 2386 | | else if (last_side != nes_fds.current_side) |
| 2602 | else if (fds_last_side != nes_fds.current_side) |
| 2387 | 2603 | { |
| 2388 | 2604 | /* If we've switched disks, report "no disk" for a few reads */ |
| 2389 | 2605 | ret = 1; |
| 2390 | | count ++; |
| 2391 | | if (count == 50) |
| 2606 | fds_count ++; |
| 2607 | if (fds_count == 50) |
| 2392 | 2608 | { |
| 2393 | | last_side = nes_fds.current_side; |
| 2394 | | count = 0; |
| 2609 | fds_last_side = nes_fds.current_side; |
| 2610 | fds_count = 0; |
| 2395 | 2611 | } |
| 2396 | 2612 | } |
| 2397 | 2613 | else |
| r5997 | r5998 | |
| 2416 | 2632 | |
| 2417 | 2633 | switch (offset) |
| 2418 | 2634 | { |
| 2419 | | case 0x00: /* $4020 */ |
| 2420 | | IRQ_count_latch &= ~0xff; |
| 2421 | | IRQ_count_latch |= data; |
| 2635 | case 0x00: |
| 2636 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 2422 | 2637 | break; |
| 2423 | | case 0x01: /* $4021 */ |
| 2424 | | IRQ_count_latch &= ~0xff00; |
| 2425 | | IRQ_count_latch |= (data << 8); |
| 2638 | case 0x01: |
| 2639 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 2426 | 2640 | break; |
| 2427 | | case 0x02: /* $4022 */ |
| 2641 | case 0x02: |
| 2428 | 2642 | IRQ_count = IRQ_count_latch; |
| 2429 | 2643 | IRQ_enable = data; |
| 2430 | 2644 | break; |
| 2431 | | case 0x03: /* $4023 */ |
| 2645 | case 0x03: |
| 2432 | 2646 | // d0 = sound io (1 = enable) |
| 2433 | 2647 | // d1 = disk io (1 = enable) |
| 2434 | 2648 | break; |
| 2435 | | case 0x04: /* $4024 */ |
| 2649 | case 0x04: |
| 2436 | 2650 | /* write data out to disk */ |
| 2437 | 2651 | break; |
| 2438 | | case 0x05: /* $4025 */ |
| 2652 | case 0x05: |
| 2653 | nes_fds.write_reg = data; |
| 2654 | |
| 2439 | 2655 | nes_fds.motor_on = data & 0x01; |
| 2440 | | if (data & 0x02) nes_fds.head_position = 0; |
| 2656 | if (data & 0x02) |
| 2657 | nes_fds.head_position = 0; |
| 2441 | 2658 | nes_fds.read_mode = data & 0x04; |
| 2442 | | if (data & 0x08) |
| 2443 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2444 | | else |
| 2445 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2659 | set_nt_mirroring((data & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 2446 | 2660 | if ((!(data & 0x40)) && (nes_fds.write_reg & 0x40)) |
| 2447 | 2661 | nes_fds.head_position -= 2; // ??? |
| 2448 | 2662 | IRQ_enable_latch = data & 0x80; |
| 2449 | | |
| 2450 | | nes_fds.write_reg = data; |
| 2451 | 2663 | break; |
| 2452 | 2664 | } |
| 2453 | 2665 | |
| r5997 | r5998 | |
| 2502 | 2714 | prg8_ab(space->machine, data); |
| 2503 | 2715 | break; |
| 2504 | 2716 | case 0x3000: |
| 2505 | | /* Switch 1k vrom at $0000 - low 4 bits */ |
| 2506 | 2717 | vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f); |
| 2507 | 2718 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2508 | 2719 | break; |
| 2509 | 2720 | case 0x3002: |
| 2510 | | /* Switch 1k vrom at $0000 - high 4 bits */ |
| 2511 | 2721 | vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4); |
| 2512 | 2722 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2513 | 2723 | break; |
| 2514 | 2724 | case 0x3001: |
| 2515 | 2725 | case 0x3004: |
| 2516 | | /* Switch 1k vrom at $0400 - low 4 bits */ |
| 2517 | 2726 | vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f); |
| 2518 | 2727 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2519 | 2728 | break; |
| 2520 | 2729 | case 0x3003: |
| 2521 | 2730 | case 0x3006: |
| 2522 | | /* Switch 1k vrom at $0400 - high 4 bits */ |
| 2523 | 2731 | vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4); |
| 2524 | 2732 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2525 | 2733 | break; |
| 2526 | 2734 | case 0x4000: |
| 2527 | | /* Switch 1k vrom at $0800 - low 4 bits */ |
| 2528 | 2735 | vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f); |
| 2529 | 2736 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2530 | 2737 | break; |
| 2531 | 2738 | case 0x4002: |
| 2532 | | /* Switch 1k vrom at $0800 - high 4 bits */ |
| 2533 | 2739 | vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4); |
| 2534 | 2740 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2535 | 2741 | break; |
| 2536 | 2742 | case 0x4001: |
| 2537 | 2743 | case 0x4004: |
| 2538 | | /* Switch 1k vrom at $0c00 - low 4 bits */ |
| 2539 | 2744 | vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f); |
| 2540 | 2745 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2541 | 2746 | break; |
| 2542 | 2747 | case 0x4003: |
| 2543 | 2748 | case 0x4006: |
| 2544 | | /* Switch 1k vrom at $0c00 - high 4 bits */ |
| 2545 | 2749 | vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4); |
| 2546 | 2750 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2547 | 2751 | break; |
| 2548 | 2752 | case 0x5000: |
| 2549 | | /* Switch 1k vrom at $1000 - low 4 bits */ |
| 2550 | 2753 | vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f); |
| 2551 | 2754 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2552 | 2755 | break; |
| 2553 | 2756 | case 0x5002: |
| 2554 | | /* Switch 1k vrom at $1000 - high 4 bits */ |
| 2555 | 2757 | vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4); |
| 2556 | 2758 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2557 | 2759 | break; |
| 2558 | 2760 | case 0x5001: |
| 2559 | 2761 | case 0x5004: |
| 2560 | | /* Switch 1k vrom at $1400 - low 4 bits */ |
| 2561 | 2762 | vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f); |
| 2562 | 2763 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2563 | 2764 | break; |
| 2564 | 2765 | case 0x5003: |
| 2565 | 2766 | case 0x5006: |
| 2566 | | /* Switch 1k vrom at $1400 - high 4 bits */ |
| 2567 | 2767 | vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4); |
| 2568 | 2768 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2569 | 2769 | break; |
| 2570 | 2770 | case 0x6000: |
| 2571 | | /* Switch 1k vrom at $1800 - low 4 bits */ |
| 2572 | 2771 | vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f); |
| 2573 | 2772 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2574 | 2773 | break; |
| 2575 | 2774 | case 0x6002: |
| 2576 | | /* Switch 1k vrom at $1800 - high 4 bits */ |
| 2577 | 2775 | vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4); |
| 2578 | 2776 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2579 | 2777 | break; |
| 2580 | 2778 | case 0x6001: |
| 2581 | 2779 | case 0x6004: |
| 2582 | | /* Switch 1k vrom at $1c00 - low 4 bits */ |
| 2583 | 2780 | vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f); |
| 2584 | 2781 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2585 | 2782 | break; |
| 2586 | 2783 | case 0x6003: |
| 2587 | 2784 | case 0x6006: |
| 2588 | | /* Switch 1k vrom at $1c00 - high 4 bits */ |
| 2589 | 2785 | vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4); |
| 2590 | 2786 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2591 | 2787 | break; |
| 2788 | |
| 2592 | 2789 | case 0x7000: |
| 2593 | | /* Set low 4 bits of latch */ |
| 2594 | | IRQ_count_latch &= ~0x0f; |
| 2595 | | IRQ_count_latch |= data & 0x0f; |
| 2596 | | // LOG_MMC(("konami_vrc4 irq_latch low: %02x\n", IRQ_count_latch)); |
| 2790 | IRQ_count_latch = (IRQ_count_latch & 0xf0) | (data & 0x0f); |
| 2597 | 2791 | break; |
| 2598 | 2792 | case 0x7002: |
| 2599 | 2793 | case 0x7040: |
| 2600 | | /* Set high 4 bits of latch */ |
| 2601 | | IRQ_count_latch &= ~0xf0; |
| 2602 | | IRQ_count_latch |= (data << 4) & 0xf0; |
| 2603 | | // LOG_MMC(("konami_vrc4 irq_latch high: %02x\n", IRQ_count_latch)); |
| 2794 | IRQ_count_latch = (IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4 ); |
| 2604 | 2795 | break; |
| 2605 | 2796 | case 0x7004: |
| 2606 | 2797 | case 0x7001: |
| 2607 | 2798 | case 0x7080: |
| 2799 | IRQ_mode = data & 0x04; // currently not implemented: 0 = prescaler mode / 1 = CPU mode |
| 2608 | 2800 | IRQ_enable = data & 0x02; |
| 2609 | 2801 | IRQ_enable_latch = data & 0x01; |
| 2610 | 2802 | if (data & 0x02) |
| 2611 | 2803 | IRQ_count = IRQ_count_latch; |
| 2612 | | // LOG_MMC(("konami_vrc4 irq_count set: %02x\n", IRQ_count)); |
| 2613 | | // LOG_MMC(("konami_vrc4 enable: %02x\n", IRQ_enable)); |
| 2614 | | // LOG_MMC(("konami_vrc4 enable latch: %02x\n", IRQ_enable_latch)); |
| 2615 | 2804 | break; |
| 2616 | 2805 | case 0x7006: |
| 2617 | 2806 | case 0x7003: |
| 2618 | 2807 | case 0x70c0: |
| 2619 | 2808 | IRQ_enable = IRQ_enable_latch; |
| 2620 | | // LOG_MMC(("konami_vrc4 enable copy: %02x\n", IRQ_enable)); |
| 2621 | 2809 | break; |
| 2622 | 2810 | default: |
| 2623 | 2811 | LOG_MMC(("konami_vrc4_w uncaught offset: %04x value: %02x\n", offset, data)); |
| r5997 | r5998 | |
| 2656 | 2844 | } |
| 2657 | 2845 | break; |
| 2658 | 2846 | case 0x2000: |
| 2659 | | /* Switch 8k bank at $a000 */ |
| 2660 | 2847 | prg8_ab(space->machine, data); |
| 2661 | 2848 | break; |
| 2662 | 2849 | case 0x3000: |
| 2663 | 2850 | case 0x4000: |
| 2664 | 2851 | case 0x5000: |
| 2665 | 2852 | case 0x6000: |
| 2666 | | /* switch 1k vrom at $0000-$1c00 */ |
| 2667 | 2853 | bank = ((offset & 0x7000) - 0x3000) / 0x0800 + (offset & 0x0001); |
| 2668 | 2854 | /* Notice that we store the banks as in other VRC, but then we take vrom_bank>>1 because it's VRC2A!*/ |
| 2669 | 2855 | if (offset & 0x0002) |
| r5997 | r5998 | |
| 2751 | 2937 | else |
| 2752 | 2938 | vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f); |
| 2753 | 2939 | |
| 2754 | | chr1_x(space->machine, bank, vrom_bank[bank], CHRROM); |
| 2940 | chr1_x(space->machine, bank, vrom_bank[bank], mmc_chr_source); |
| 2755 | 2941 | break; |
| 2756 | 2942 | case 0x7000: |
| 2757 | | /* Set low 4 bits of latch */ |
| 2758 | 2943 | IRQ_count_latch &= ~0x0f; |
| 2759 | 2944 | IRQ_count_latch |= data & 0x0f; |
| 2760 | 2945 | break; |
| 2761 | 2946 | case 0x7001: |
| 2762 | | /* Set high 4 bits of latch */ |
| 2763 | 2947 | IRQ_count_latch &= ~0xf0; |
| 2764 | 2948 | IRQ_count_latch |= (data << 4) & 0xf0; |
| 2765 | 2949 | break; |
| 2766 | 2950 | case 0x7002: |
| 2951 | IRQ_mode = data & 0x04; // currently not implemented: 0 = prescaler mode / 1 = CPU mode |
| 2767 | 2952 | IRQ_enable = data & 0x02; |
| 2768 | 2953 | IRQ_enable_latch = data & 0x01; |
| 2769 | 2954 | if (data & 0x02) |
| r5997 | r5998 | |
| 2836 | 3021 | IRQ_count_latch = data; |
| 2837 | 3022 | break; |
| 2838 | 3023 | case 0x7001: |
| 3024 | IRQ_mode = data & 0x04; // currently not implemented: 0 = prescaler mode / 1 = CPU mode |
| 2839 | 3025 | IRQ_enable = data & 0x02; |
| 2840 | 3026 | IRQ_enable_latch = data & 0x01; |
| 2841 | 3027 | if (data & 0x02) |
| r5997 | r5998 | |
| 2908 | 3094 | IRQ_enable = IRQ_enable_latch; |
| 2909 | 3095 | break; |
| 2910 | 3096 | case 0x7002: |
| 3097 | IRQ_mode = data & 0x04; // currently not implemented: 0 = prescaler mode / 1 = CPU mode |
| 2911 | 3098 | IRQ_enable = data & 0x02; |
| 2912 | 3099 | IRQ_enable_latch = data & 0x01; |
| 2913 | 3100 | if (data & 0x02) |
| r5997 | r5998 | |
| 2983 | 3170 | Games: Ai Sensei no Oshiete, Image Fight, Kaiketsu |
| 2984 | 3171 | Yanchamaru 2, Maikyuu Shima, Paaman, Paaman 2 |
| 2985 | 3172 | |
| 3173 | A crc check is required to support Major League (which uses |
| 3174 | a slightly different board) |
| 3175 | |
| 2986 | 3176 | In MESS: Supported. |
| 2987 | 3177 | |
| 2988 | 3178 | *************************************************************/ |
| r5997 | r5998 | |
| 2998 | 3188 | break; |
| 2999 | 3189 | case 0x1000: |
| 3000 | 3190 | mmc_cmd1 = data & 0x02; |
| 3001 | | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3191 | if (!nes.crc_hack) // Major League has hardwired mirroring (it would have required a separate mapper) |
| 3192 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3002 | 3193 | break; |
| 3003 | 3194 | case 0x2000: |
| 3004 | 3195 | prg8_ab(space->machine, data); |
| r5997 | r5998 | |
| 3029 | 3220 | { |
| 3030 | 3221 | LOG_MMC(("mapper33_w, offset: %04x, data: %02x\n", offset, data)); |
| 3031 | 3222 | |
| 3032 | | switch (offset & 0x7003) |
| 3223 | switch (offset & 0x6003) |
| 3033 | 3224 | { |
| 3034 | 3225 | case 0x0000: |
| 3035 | 3226 | set_nt_mirroring((data & 0x40) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| r5997 | r5998 | |
| 3067 | 3258 | Games: Deadly Tower, Impossible Mission II, Titanic 1912, |
| 3068 | 3259 | Dance Xtreme |
| 3069 | 3260 | |
| 3261 | There actually exist TWO different kind of boards using |
| 3262 | this mapper. NINA-001 is not compatible with the other |
| 3263 | kind of board, so Impossible Mission II requires a crc check |
| 3264 | to be supported. |
| 3265 | |
| 3070 | 3266 | In MESS: Supported. |
| 3071 | 3267 | |
| 3072 | 3268 | *************************************************************/ |
| r5997 | r5998 | |
| 3075 | 3271 | { |
| 3076 | 3272 | LOG_MMC(("mapper34_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 3077 | 3273 | |
| 3078 | | switch (offset) |
| 3274 | if (nes.crc_hack) // is it AVE Nina-01? |
| 3079 | 3275 | { |
| 3276 | switch (offset) |
| 3277 | { |
| 3080 | 3278 | case 0x1ffd: |
| 3081 | 3279 | prg32(space->machine, data); |
| 3082 | 3280 | break; |
| r5997 | r5998 | |
| 3086 | 3284 | case 0x1fff: |
| 3087 | 3285 | chr4_4(space->machine, data, CHRROM); |
| 3088 | 3286 | break; |
| 3287 | } |
| 3089 | 3288 | } |
| 3090 | 3289 | } |
| 3091 | 3290 | |
| r5997 | r5998 | |
| 3095 | 3294 | /* Deadly Towers is really a Mapper 34 game - the demo screens look wrong using mapper 7. */ |
| 3096 | 3295 | LOG_MMC(("mapper34_w, offset: %04x, data: %02x\n", offset, data)); |
| 3097 | 3296 | |
| 3098 | | prg32(space->machine, data); |
| 3297 | if (!nes.crc_hack) // is it plain BxROM? |
| 3298 | prg32(space->machine, data); |
| 3099 | 3299 | } |
| 3100 | 3300 | |
| 3101 | 3301 | /************************************************************* |
| r5997 | r5998 | |
| 3201 | 3401 | Mapper 40 |
| 3202 | 3402 | |
| 3203 | 3403 | Known Boards: Unknown Bootleg Board |
| 3204 | | Games: Super Mario Bros. 2 Lost Levels Pirate |
| 3404 | Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2) |
| 3205 | 3405 | |
| 3206 | 3406 | In MESS: Supported. |
| 3207 | 3407 | |
| r5997 | r5998 | |
| 3209 | 3409 | |
| 3210 | 3410 | static void mapper40_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 3211 | 3411 | { |
| 3212 | | /* Decrement & check the IRQ scanline counter */ |
| 3213 | 3412 | if (IRQ_enable) |
| 3214 | 3413 | { |
| 3215 | | if (--IRQ_count == 0) |
| 3414 | if ((0xfff - IRQ_count) <= 114) |
| 3216 | 3415 | { |
| 3416 | IRQ_count = (IRQ_count + 1) & 0xfff; |
| 3417 | IRQ_enable = 0; |
| 3217 | 3418 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 3218 | 3419 | } |
| 3420 | else |
| 3421 | IRQ_count += 114; |
| 3219 | 3422 | } |
| 3220 | 3423 | } |
| 3221 | 3424 | |
| r5997 | r5998 | |
| 3227 | 3430 | { |
| 3228 | 3431 | case 0x0000: |
| 3229 | 3432 | IRQ_enable = 0; |
| 3230 | | IRQ_count = 37; /* Hardcoded scanline scroll */ |
| 3433 | IRQ_count = 0; |
| 3231 | 3434 | break; |
| 3232 | 3435 | case 0x2000: |
| 3233 | 3436 | IRQ_enable = 1; |
| 3234 | 3437 | break; |
| 3235 | 3438 | case 0x6000: |
| 3236 | | /* Game runs code between banks, use slow but sure method */ |
| 3237 | 3439 | prg8_cd(space->machine, data); |
| 3238 | 3440 | break; |
| 3239 | 3441 | } |
| r5997 | r5998 | |
| 3287 | 3489 | switch(offset & 0x03) |
| 3288 | 3490 | { |
| 3289 | 3491 | case 0x00: |
| 3290 | | memory_set_bankptr(space->machine, 5, &nes.rom[(data & ((nes.prg_chunks << 1) - 1)) * 0x2000 + 0x10000]); |
| 3492 | prg8_67(space->machine, data); |
| 3291 | 3493 | break; |
| 3292 | 3494 | case 0x01: |
| 3293 | 3495 | set_nt_mirroring((data & 0x08) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| r5997 | r5998 | |
| 3316 | 3518 | Known Boards: Unknown Bootleg Board |
| 3317 | 3519 | Games: Super Mario Bros. 2 Pirate (LF36) |
| 3318 | 3520 | |
| 3319 | | In MESS: Supported. |
| 3521 | In MESS: Supported? The only image I found is not working |
| 3522 | (not even in NEStopia). |
| 3320 | 3523 | |
| 3321 | 3524 | *************************************************************/ |
| 3322 | 3525 | |
| r5997 | r5998 | |
| 3457 | 3660 | Known Boards: Rumblestation Board |
| 3458 | 3661 | Games: Rumblestation 15 in 1 |
| 3459 | 3662 | |
| 3460 | | In MESS: Partially Supported. |
| 3663 | In MESS: Supported. |
| 3461 | 3664 | |
| 3462 | 3665 | *************************************************************/ |
| 3463 | 3666 | |
| r5997 | r5998 | |
| 3512 | 3715 | Games: Bakushou!! Jinsei Gekijou 3, Bubble Bobble 2, |
| 3513 | 3716 | Captain Saver, Don Doko Don 2, Flintstones, Jetsons |
| 3514 | 3717 | |
| 3515 | | In MESS: Unsupported. |
| 3718 | This is basically Mapper 33 + IRQ. Notably, IRQ works the |
| 3719 | same as MMC3 irq, BUT latch values are "inverted" (XOR'ed |
| 3720 | with 0xff) and there is a little delay (not implemented yet) |
| 3721 | We simply use MMC3 IRQ and XOR the value written in the |
| 3722 | register 0xc000 below |
| 3516 | 3723 | |
| 3724 | In MESS: Supported. |
| 3725 | |
| 3517 | 3726 | *************************************************************/ |
| 3518 | 3727 | |
| 3728 | static WRITE8_HANDLER( mapper48_w ) |
| 3729 | { |
| 3730 | LOG_MMC(("mapper48_w, offset: %04x, data: %02x\n", offset, data)); |
| 3731 | |
| 3732 | switch (offset & 0x6003) |
| 3733 | { |
| 3734 | case 0x0000: |
| 3735 | prg8_89(space->machine, data); |
| 3736 | break; |
| 3737 | case 0x0001: |
| 3738 | prg8_ab(space->machine, data); |
| 3739 | break; |
| 3740 | case 0x0002: |
| 3741 | chr2_0(space->machine, data, CHRROM); |
| 3742 | break; |
| 3743 | case 0x0003: |
| 3744 | chr2_2(space->machine, data, CHRROM); |
| 3745 | break; |
| 3746 | case 0x2000: |
| 3747 | chr1_4(space->machine, data, CHRROM); |
| 3748 | break; |
| 3749 | case 0x2001: |
| 3750 | chr1_5(space->machine, data, CHRROM); |
| 3751 | break; |
| 3752 | case 0x2002: |
| 3753 | chr1_6(space->machine, data, CHRROM); |
| 3754 | break; |
| 3755 | case 0x2003: |
| 3756 | chr1_7(space->machine, data, CHRROM); |
| 3757 | break; |
| 3758 | case 0x4000: |
| 3759 | IRQ_count_latch = (0x100 - data) & 0xff; |
| 3760 | break; |
| 3761 | case 0x4001: |
| 3762 | IRQ_count = IRQ_count_latch; |
| 3763 | break; |
| 3764 | case 0x4002: |
| 3765 | IRQ_enable = 1; |
| 3766 | break; |
| 3767 | case 0x4003: |
| 3768 | IRQ_enable = 0; |
| 3769 | break; |
| 3770 | case 0x6000: |
| 3771 | set_nt_mirroring((data & 0x40) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3772 | break; |
| 3773 | } |
| 3774 | } |
| 3775 | |
| 3519 | 3776 | /************************************************************* |
| 3520 | 3777 | |
| 3521 | 3778 | Mapper 49 |
| r5997 | r5998 | |
| 3556 | 3813 | Mapper 50 |
| 3557 | 3814 | |
| 3558 | 3815 | Known Boards: Unknown Bootleg Board |
| 3559 | | Games: Super Mario Bros. Pirate Alt. Levels |
| 3816 | Games: Super Mario Bros. 2 Pirate (Jpn version of SMB2) |
| 3560 | 3817 | |
| 3561 | | In MESS: Unsupported. |
| 3818 | This was marked as Alt. Levels. is it true? |
| 3562 | 3819 | |
| 3820 | In MESS: Supported. |
| 3821 | |
| 3563 | 3822 | *************************************************************/ |
| 3564 | 3823 | |
| 3824 | static void mapper50_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 3825 | { |
| 3826 | if (IRQ_enable) |
| 3827 | { |
| 3828 | if (IRQ_count < 0x1000) |
| 3829 | { |
| 3830 | if ((0x1000 - IRQ_count) <= 114) |
| 3831 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 3832 | else |
| 3833 | IRQ_count += 114; |
| 3834 | } |
| 3835 | else |
| 3836 | IRQ_count += 114; |
| 3837 | |
| 3838 | IRQ_count &= 0xffff; // according to docs is 16bit counter -> it wraps only after 0xffff |
| 3839 | } |
| 3840 | } |
| 3841 | |
| 3842 | static WRITE8_HANDLER( mapper50_l_w ) |
| 3843 | { |
| 3844 | UINT8 prg; |
| 3845 | LOG_MMC(("mapper50_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 3846 | offset += 0x100; |
| 3847 | |
| 3848 | switch (offset & 0x160) |
| 3849 | { |
| 3850 | case 0x020: |
| 3851 | prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2); |
| 3852 | prg8_cd(space->machine, prg); |
| 3853 | break; |
| 3854 | case 0x120: |
| 3855 | IRQ_enable = data & 0x01; |
| 3856 | break; |
| 3857 | } |
| 3858 | } |
| 3859 | |
| 3860 | /* This goes to 0x4020-0x403f */ |
| 3861 | WRITE8_HANDLER( mapper50_add_w ) |
| 3862 | { |
| 3863 | UINT8 prg; |
| 3864 | LOG_MMC(("mapper50_add_w, offset: %04x, data: %02x\n", offset, data)); |
| 3865 | |
| 3866 | prg = (data & 0x08) | ((data & 0x06) >> 1) | ((data & 0x01) << 2); |
| 3867 | prg8_cd(space->machine, prg); |
| 3868 | } |
| 3869 | |
| 3565 | 3870 | /************************************************************* |
| 3566 | 3871 | |
| 3567 | 3872 | Mapper 51 |
| r5997 | r5998 | |
| 3569 | 3874 | Known Boards: Unknown Multigame Bootleg Board |
| 3570 | 3875 | Games: 11 in 1 Ball Games |
| 3571 | 3876 | |
| 3572 | | In MESS: Supported. |
| 3877 | In MESS: Partially Supported. |
| 3573 | 3878 | |
| 3574 | 3879 | *************************************************************/ |
| 3575 | 3880 | |
| r5997 | r5998 | |
| 3583 | 3888 | } |
| 3584 | 3889 | else |
| 3585 | 3890 | { |
| 3586 | | prg16_cdef(machine, (mapper51_reg[1] * 2) + 1); |
| 3587 | | prg16_89ab(machine, mapper51_reg[2] * 2); |
| 3891 | prg16_89ab(machine, (mapper51_reg[1] << 1) | (mapper51_reg[0] >> 1)); |
| 3892 | prg16_cdef(machine, (mapper51_reg[1] << 1) | 0x07); |
| 3588 | 3893 | } |
| 3589 | 3894 | } |
| 3590 | 3895 | |
| r5997 | r5998 | |
| 3600 | 3905 | { |
| 3601 | 3906 | LOG_MMC(("mapper51_w, offset: %04x, data: %02x\n", offset, data)); |
| 3602 | 3907 | |
| 3603 | | if (offset & 0x4000) |
| 3604 | | mapper51_reg[2] = data; |
| 3605 | | else |
| 3606 | | mapper51_reg[1] = data; |
| 3607 | | |
| 3608 | | mapper51_set_banks(space->machine); |
| 3908 | switch (offset & 0x6000) |
| 3909 | { |
| 3910 | case 0x4000: // here we also update reg[0] upper bit |
| 3911 | mapper51_reg[0] = (mapper51_reg[0] & 0x01) | ((data >> 3) & 0x02); |
| 3912 | case 0x0000: |
| 3913 | case 0x2000: |
| 3914 | case 0x6000: |
| 3915 | mapper51_reg[1] = data & 0x0f; |
| 3916 | mapper51_set_banks(space->machine); |
| 3917 | break; |
| 3918 | } |
| 3609 | 3919 | } |
| 3610 | 3920 | |
| 3611 | 3921 | /************************************************************* |
| r5997 | r5998 | |
| 3634 | 3944 | map52_helper1 = (data & 0x08); |
| 3635 | 3945 | map52_helper2 = (data & 0x40); |
| 3636 | 3946 | |
| 3637 | | mmc_prg_base = map52_helper1 ? ((data & 0x06) << 4) : ((data & 0x07) << 4); |
| 3947 | mmc_prg_base = map52_helper1 ? ((data & 0x07) << 4) : ((data & 0x06) << 4); |
| 3638 | 3948 | mmc_prg_mask = map52_helper1 ? 0x0f : 0x1f; |
| 3639 | 3949 | mmc_chr_base = ((data & 0x20) << 4) | ((data & 0x04) << 6) | (map52_helper2 ? ((data & 0x10) << 3) : 0); |
| 3640 | 3950 | mmc_chr_mask = map52_helper2 ? 0x7f : 0xff; |
| r5997 | r5998 | |
| 3654 | 3964 | Known Boards: Unknown Multigame Bootleg Board |
| 3655 | 3965 | Games: Supervision 16 in 1 |
| 3656 | 3966 | |
| 3657 | | In MESS: Unsupported. |
| 3967 | In MESS: Unsupported (SRAM banks can go in mid-regions). |
| 3658 | 3968 | |
| 3659 | 3969 | *************************************************************/ |
| 3660 | 3970 | |
| r5997 | r5998 | |
| 3770 | 4080 | Known Boards: Unknown Multigame Bootleg Board |
| 3771 | 4081 | Games: 4 in 1, 35 in 1 |
| 3772 | 4082 | |
| 3773 | | In MESS: Unsupported. |
| 4083 | In MESS: Unsupported (these are reset-based and have dips). |
| 3774 | 4084 | |
| 3775 | 4085 | *************************************************************/ |
| 3776 | 4086 | |
| r5997 | r5998 | |
| 3859 | 4169 | Games: Klax, Road Runner, Rolling Thunder, Shinobi, Skulls |
| 3860 | 4170 | & Croosbones, Xybots |
| 3861 | 4171 | |
| 3862 | | In MESS: Supported. It also uses mapper4_irq. |
| 4172 | In MESS: Partially Supported. It also uses mapper4_irq. |
| 3863 | 4173 | |
| 3864 | 4174 | *************************************************************/ |
| 3865 | 4175 | |
| 3866 | | static void mapper64_set_banks( running_machine *machine ) |
| 4176 | static void mapper64_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 3867 | 4177 | { |
| 3868 | | if (mmc_cmd1 & 0x20) |
| 4178 | if (!IRQ_mode) // we are in scanline mode! |
| 3869 | 4179 | { |
| 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); |
| 4180 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 4181 | { |
| 4182 | if (!IRQ_reset) |
| 4183 | { |
| 4184 | if (!IRQ_count) |
| 4185 | IRQ_count = IRQ_count_latch; |
| 4186 | else |
| 4187 | { |
| 4188 | IRQ_count--; |
| 4189 | if (IRQ_enable && !blanked && !IRQ_count) |
| 4190 | { |
| 4191 | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 4192 | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 4193 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 4194 | } |
| 4195 | } |
| 4196 | } |
| 4197 | else |
| 4198 | { |
| 4199 | IRQ_reset = 0; |
| 4200 | IRQ_count = IRQ_count_latch + 1; |
| 4201 | } |
| 4202 | } |
| 3874 | 4203 | } |
| 4204 | /* otherwise, we are in CPU cycles mode --> decrement count of 114 every scanline |
| 4205 | --> in the meanwhile anything can have happened to IRQ_reset and we would not know |
| 4206 | --> Skulls and Crossbones does not show anything!! */ |
| 3875 | 4207 | else |
| 3876 | 4208 | { |
| 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); |
| 4209 | // if (!IRQ_reset) |
| 4210 | { |
| 4211 | if (IRQ_count <= 114) |
| 4212 | IRQ_count = IRQ_count_latch; |
| 4213 | else |
| 4214 | { |
| 4215 | IRQ_count -= 114; |
| 4216 | if (IRQ_enable && !blanked && (IRQ_count <= 114)) |
| 4217 | { |
| 4218 | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 4219 | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 4220 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 4221 | } |
| 4222 | } |
| 4223 | } |
| 4224 | // else |
| 4225 | // { |
| 4226 | // IRQ_reset = 0; |
| 4227 | // IRQ_count = IRQ_count_latch + 1; |
| 4228 | // } |
| 3881 | 4229 | } |
| 4230 | } |
| 3882 | 4231 | |
| 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); |
| 4232 | static void mapper64_set_prg( running_machine *machine ) |
| 4233 | { |
| 4234 | UINT8 prg_mode = mmc_cmd1 & 0x40; |
| 3887 | 4235 | |
| 3888 | | prg8_89(machine, mapper64_reg[6]); |
| 3889 | | prg8_ab(machine, mapper64_reg[7]); |
| 3890 | | prg8_cd(machine, mapper64_reg[10]); |
| 4236 | prg8_89(machine, prg_bank[prg_mode ? 2: 0]); |
| 4237 | prg8_ab(machine, prg_bank[prg_mode ? 0: 1]); |
| 4238 | prg8_cd(machine, prg_bank[prg_mode ? 1: 2]); |
| 3891 | 4239 | } |
| 3892 | 4240 | |
| 3893 | | static WRITE8_HANDLER( mapper64_m_w ) |
| 4241 | static void mapper64_set_chr( running_machine *machine ) |
| 3894 | 4242 | { |
| 3895 | | LOG_MMC(("mapper64_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4243 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 4244 | |
| 4245 | if (mmc_cmd1 & 0x20) |
| 4246 | { |
| 4247 | chr1_x(machine, 0 ^ chr_page, vrom_bank[0], CHRROM); |
| 4248 | chr1_x(machine, 1 ^ chr_page, vrom_bank[8], CHRROM); |
| 4249 | chr1_x(machine, 2 ^ chr_page, vrom_bank[1], CHRROM); |
| 4250 | chr1_x(machine, 3 ^ chr_page, vrom_bank[9], CHRROM); |
| 4251 | } |
| 4252 | else |
| 4253 | { |
| 4254 | chr1_x(machine, 0 ^ chr_page, vrom_bank[0] & ~0x01, CHRROM); |
| 4255 | chr1_x(machine, 1 ^ chr_page, vrom_bank[0] | 0x01, CHRROM); |
| 4256 | chr1_x(machine, 2 ^ chr_page, vrom_bank[1] & ~0x01, CHRROM); |
| 4257 | chr1_x(machine, 3 ^ chr_page, vrom_bank[1] | 0x01, CHRROM); |
| 4258 | } |
| 4259 | |
| 4260 | chr1_x(machine, 4 ^ chr_page, vrom_bank[2], CHRROM); |
| 4261 | chr1_x(machine, 5 ^ chr_page, vrom_bank[3], CHRROM); |
| 4262 | chr1_x(machine, 6 ^ chr_page, vrom_bank[4], CHRROM); |
| 4263 | chr1_x(machine, 7 ^ chr_page, vrom_bank[5], CHRROM); |
| 3896 | 4264 | } |
| 3897 | 4265 | |
| 3898 | 4266 | static WRITE8_HANDLER( mapper64_w ) |
| 3899 | 4267 | { |
| 3900 | | /* TODO: something in the IRQ handling hoses Skull & Crossbones */ |
| 4268 | UINT8 map64_helper, cmd; |
| 4269 | LOG_MMC(("mapper64_w offset: %04x, data: %02x\n", offset, data)); |
| 3901 | 4270 | |
| 3902 | | // LOG_MMC(("mapper64_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline)); |
| 3903 | | |
| 3904 | | switch (offset & 0x7001) |
| 4271 | switch (offset & 0x6001) |
| 3905 | 4272 | { |
| 3906 | 4273 | case 0x0000: |
| 4274 | map64_helper = mmc_cmd1 ^ data; |
| 3907 | 4275 | mmc_cmd1 = data; |
| 4276 | |
| 4277 | /* Has PRG Mode changed? */ |
| 4278 | if (map64_helper & 0x40) |
| 4279 | mapper64_set_prg(space->machine); |
| 4280 | |
| 4281 | /* Has CHR Mode changed? */ |
| 4282 | if (map64_helper & 0xa0) |
| 4283 | mapper64_set_chr(space->machine); |
| 3908 | 4284 | break; |
| 4285 | |
| 3909 | 4286 | case 0x0001: |
| 3910 | | if ((mmc_cmd1 & 0x0f) < 10) |
| 3911 | | mapper64_reg[mmc_cmd1 & 0x0f] = data; |
| 3912 | | if ((mmc_cmd1 & 0x0f) == 0x0f) |
| 3913 | | mapper64_reg[10] = data; |
| 4287 | cmd = mmc_cmd1 & 0x0f; |
| 4288 | switch (cmd) |
| 4289 | { |
| 4290 | case 0: case 1: |
| 4291 | case 2: case 3: |
| 4292 | case 4: case 5: |
| 4293 | vrom_bank[cmd] = data; |
| 4294 | mapper64_set_chr(space->machine); |
| 4295 | break; |
| 4296 | case 6: case 7: |
| 4297 | prg_bank[cmd - 6] = data; |
| 4298 | mapper64_set_prg(space->machine); |
| 4299 | break; |
| 4300 | case 8: case 9: |
| 4301 | vrom_bank[cmd - 2] = data; |
| 4302 | mapper64_set_chr(space->machine); |
| 4303 | break; |
| 4304 | case 0x0f: |
| 4305 | prg_bank[2] = data; |
| 4306 | mapper64_set_prg(space->machine); |
| 4307 | break; |
| 4308 | } |
| 4309 | break; |
| 3914 | 4310 | |
| 3915 | | mapper64_set_banks(space->machine); |
| 3916 | | break; |
| 3917 | 4311 | case 0x2000: |
| 3918 | | /* Not sure if the one-screen mirroring applies to this mapper */ |
| 3919 | | if (data & 0x40) |
| 3920 | | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 3921 | | else |
| 3922 | | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 4312 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3923 | 4313 | break; |
| 3924 | | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 4314 | |
| 4315 | case 0x4000: |
| 3925 | 4316 | IRQ_count_latch = data; |
| 3926 | | if (0) |
| 3927 | | IRQ_count = IRQ_count_latch; |
| 3928 | | |
| 3929 | | LOG_MMC((" MMC3 copy/set irq latch: %02x\n", data)); |
| 3930 | 4317 | break; |
| 3931 | 4318 | |
| 3932 | 4319 | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 3933 | | IRQ_count = IRQ_count_latch; |
| 3934 | 4320 | IRQ_mode = data & 0x01; |
| 3935 | | LOG_MMC((" MMC3 set latch: %02x\n", data)); |
| 4321 | IRQ_reset = 1; |
| 3936 | 4322 | break; |
| 3937 | 4323 | |
| 3938 | | case 0x6000: /* $e000 - Disable IRQs */ |
| 4324 | case 0x6000: |
| 3939 | 4325 | IRQ_enable = 0; |
| 3940 | | if (0) |
| 3941 | | IRQ_count = IRQ_count_latch; |
| 3942 | | |
| 3943 | | LOG_MMC((" MMC3 disable irqs: %02x\n", data)); |
| 3944 | 4326 | break; |
| 3945 | 4327 | |
| 3946 | | case 0x6001: /* $e001 - Enable IRQs */ |
| 4328 | case 0x6001: |
| 3947 | 4329 | IRQ_enable = 1; |
| 3948 | | if (0) |
| 3949 | | IRQ_count = IRQ_count_latch; |
| 3950 | | |
| 3951 | | LOG_MMC((" MMC3 enable irqs: %02x\n", data)); |
| 3952 | 4330 | break; |
| 3953 | 4331 | |
| 3954 | 4332 | default: |
| r5997 | r5998 | |
| 3969 | 4347 | |
| 3970 | 4348 | *************************************************************/ |
| 3971 | 4349 | |
| 4350 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 4351 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 4352 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 3972 | 4353 | static void irem_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 3973 | 4354 | { |
| 3974 | | /* Increment & check the IRQ scanline counter */ |
| 3975 | 4355 | if (IRQ_enable) |
| 3976 | 4356 | { |
| 3977 | | if (--IRQ_count == 0) |
| 4357 | IRQ_count -= 114; |
| 4358 | |
| 4359 | if (IRQ_count <= 114) |
| 4360 | { |
| 4361 | IRQ_enable = 0; |
| 3978 | 4362 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 4363 | } |
| 3979 | 4364 | } |
| 3980 | 4365 | } |
| 3981 | 4366 | |
| r5997 | r5998 | |
| 3983 | 4368 | { |
| 3984 | 4369 | LOG_MMC(("mapper65_w, offset %04x, data: %02x\n", offset, data)); |
| 3985 | 4370 | |
| 3986 | | switch (offset & 0x7007) |
| 4371 | switch (offset & 0x7fff) |
| 3987 | 4372 | { |
| 3988 | 4373 | case 0x0000: |
| 3989 | 4374 | prg8_89(space->machine, data); |
| 3990 | | LOG_MMC((" Mapper 65 switch ($8000) value: %02x\n", data)); |
| 3991 | 4375 | break; |
| 4376 | |
| 3992 | 4377 | case 0x1001: |
| 3993 | | if (data & 0x80) |
| 3994 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 3995 | | else |
| 3996 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4378 | set_nt_mirroring((data & 0x80) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 3997 | 4379 | break; |
| 4380 | |
| 4381 | case 0x1003: |
| 4382 | IRQ_enable = data & 0x80; |
| 4383 | break; |
| 4384 | |
| 4385 | case 0x1004: |
| 4386 | IRQ_count = IRQ_count_latch; |
| 4387 | break; |
| 4388 | |
| 3998 | 4389 | case 0x1005: |
| 3999 | | IRQ_count = data << 1; |
| 4390 | IRQ_count_latch = (IRQ_count_latch & 0x00ff) | (data << 8); |
| 4000 | 4391 | break; |
| 4392 | |
| 4001 | 4393 | case 0x1006: |
| 4002 | | IRQ_enable = IRQ_count; |
| 4394 | IRQ_count_latch = (IRQ_count_latch & 0xff00) | data; |
| 4003 | 4395 | break; |
| 4004 | 4396 | |
| 4005 | 4397 | case 0x2000: |
| 4006 | 4398 | prg8_ab(space->machine, data); |
| 4007 | | LOG_MMC((" Mapper 65 switch ($a000) value: %02x\n", data)); |
| 4008 | 4399 | break; |
| 4009 | 4400 | |
| 4010 | 4401 | case 0x3000: |
| r5997 | r5998 | |
| 4015 | 4406 | case 0x3005: |
| 4016 | 4407 | case 0x3006: |
| 4017 | 4408 | case 0x3007: |
| 4018 | | /* Switch 1k VROM at $0000-$1c00 */ |
| 4019 | 4409 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 4020 | 4410 | break; |
| 4021 | 4411 | |
| 4022 | 4412 | case 0x4000: |
| 4023 | 4413 | prg8_cd(space->machine, data); |
| 4024 | | LOG_MMC((" Mapper 65 switch ($c000) value: %02x\n", data)); |
| 4025 | 4414 | break; |
| 4026 | 4415 | |
| 4027 | 4416 | default: |
| 4028 | | LOG_MMC(("Mapper 65 addr: %04x value: %02x\n", offset + 0x8000, data)); |
| 4029 | 4417 | break; |
| 4030 | 4418 | } |
| 4031 | 4419 | } |
| r5997 | r5998 | |
| 4057 | 4445 | Known Boards: Sunsoft 3 |
| 4058 | 4446 | Games: Fantasy Zone 2, Mito Koumon |
| 4059 | 4447 | |
| 4060 | | In MESS: Supported. It also uses mapper4_irq. |
| 4448 | In MESS: Supported. |
| 4061 | 4449 | |
| 4062 | 4450 | *************************************************************/ |
| 4063 | 4451 | |
| 4452 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 4453 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 4454 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 4455 | static void mapper67_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 4456 | { |
| 4457 | /* TODO: change to reflect the actual number of cycles spent: both using 114 or cycling 114,114,113 |
| 4458 | produces a 1-line glitch in Fantasy Zone 2: it really requires the counter to be updated each CPU cycle! */ |
| 4459 | if (IRQ_enable) |
| 4460 | { |
| 4461 | if (IRQ_count <= 114) |
| 4462 | { |
| 4463 | IRQ_enable = 0; |
| 4464 | IRQ_count = 0xffff; |
| 4465 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 4466 | } |
| 4467 | else |
| 4468 | IRQ_count -= 114; |
| 4469 | } |
| 4470 | } |
| 4471 | |
| 4064 | 4472 | static WRITE8_HANDLER( mapper67_w ) |
| 4065 | 4473 | { |
| 4066 | 4474 | LOG_MMC(("mapper67_w, offset %04x, data: %02x\n", offset, data)); |
| 4067 | | switch (offset & 0x7801) |
| 4475 | switch (offset & 0x7800) |
| 4068 | 4476 | { |
| 4069 | | // case 0x0000: /* IRQ acknowledge */ |
| 4070 | | // IRQ_enable = 0; |
| 4071 | | // break; |
| 4072 | | case 0x0800: |
| 4073 | | chr2_0(space->machine, data, CHRROM); |
| 4074 | | break; |
| 4075 | | case 0x1800: |
| 4076 | | chr2_2(space->machine, data, CHRROM); |
| 4077 | | break; |
| 4078 | | case 0x2800: |
| 4079 | | chr2_4(space->machine, data, CHRROM); |
| 4080 | | break; |
| 4081 | | case 0x3800: |
| 4082 | | chr2_6(space->machine, data, CHRROM); |
| 4083 | | break; |
| 4084 | | case 0x4800: |
| 4085 | | // nes_vram[5] = data * 64; |
| 4086 | | // break; |
| 4087 | | case 0x4801: |
| 4088 | | /* IRQ count? */ |
| 4089 | | IRQ_count = IRQ_count_latch; |
| 4090 | | IRQ_count_latch = data; |
| 4091 | | break; |
| 4092 | | case 0x5800: |
| 4093 | | // chr4_0(space->machine, data); |
| 4094 | | // break; |
| 4095 | | case 0x5801: |
| 4096 | | IRQ_enable = data; |
| 4097 | | break; |
| 4098 | | case 0x6800: |
| 4099 | | case 0x6801: |
| 4100 | | switch (data & 3) |
| 4101 | | { |
| 4102 | | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 4103 | | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 4104 | | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 4105 | | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 4106 | | } |
| 4107 | | break; |
| 4108 | | case 0x7800: |
| 4109 | | case 0x7801: |
| 4110 | | prg16_89ab(space->machine, data); |
| 4111 | | break; |
| 4112 | | default: |
| 4113 | | LOG_MMC(("mapper67_w uncaught offset: %04x, data: %02x\n", offset, data)); |
| 4114 | | break; |
| 4115 | | |
| 4477 | case 0x0800: |
| 4478 | chr2_0(space->machine, data, CHRROM); |
| 4479 | break; |
| 4480 | case 0x1800: |
| 4481 | chr2_2(space->machine, data, CHRROM); |
| 4482 | break; |
| 4483 | case 0x2800: |
| 4484 | chr2_4(space->machine, data, CHRROM); |
| 4485 | break; |
| 4486 | case 0x3800: |
| 4487 | chr2_6(space->machine, data, CHRROM); |
| 4488 | break; |
| 4489 | case 0x4000: |
| 4490 | case 0x4800: |
| 4491 | IRQ_toggle ^= 1; |
| 4492 | if (IRQ_toggle) |
| 4493 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 4494 | else |
| 4495 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 4496 | break; |
| 4497 | case 0x5800: |
| 4498 | IRQ_enable = data & 0x10; |
| 4499 | IRQ_toggle = 0; |
| 4500 | break; |
| 4501 | case 0x6800: |
| 4502 | switch (data & 3) |
| 4503 | { |
| 4504 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 4505 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 4506 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 4507 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 4508 | } |
| 4509 | break; |
| 4510 | case 0x7800: |
| 4511 | prg16_89ab(space->machine, data); |
| 4512 | break; |
| 4513 | default: |
| 4514 | LOG_MMC(("mapper67_w uncaught offset: %04x, data: %02x\n", offset, data)); |
| 4515 | break; |
| 4116 | 4516 | } |
| 4117 | 4517 | } |
| 4118 | 4518 | |
| r5997 | r5998 | |
| 4129 | 4529 | |
| 4130 | 4530 | static void mapper68_mirror( running_machine *machine, int m68_mirror, int m0, int m1 ) |
| 4131 | 4531 | { |
| 4132 | | /* The 0x20000 (128k) offset is a magic number */ |
| 4133 | | #define M68_OFFSET 0x20000 |
| 4134 | | |
| 4135 | 4532 | switch (m68_mirror) |
| 4136 | 4533 | { |
| 4137 | 4534 | case 0x00: |
| r5997 | r5998 | |
| 4147 | 4544 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 4148 | 4545 | break; |
| 4149 | 4546 | case 0x10: |
| 4150 | | set_nt_page(0, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4151 | | set_nt_page(1, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4152 | | set_nt_page(2, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4153 | | set_nt_page(3, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4547 | set_nt_page(0, ROM, m0 | 0x80, 0); |
| 4548 | set_nt_page(1, ROM, m1 | 0x80, 0); |
| 4549 | set_nt_page(2, ROM, m0 | 0x80, 0); |
| 4550 | set_nt_page(3, ROM, m1 | 0x80, 0); |
| 4154 | 4551 | break; |
| 4155 | 4552 | case 0x11: |
| 4156 | | set_nt_page(0, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4157 | | set_nt_page(1, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4158 | | set_nt_page(2, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4159 | | set_nt_page(3, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4553 | set_nt_page(0, ROM, m0 | 0x80, 0); |
| 4554 | set_nt_page(1, ROM, m0 | 0x80, 0); |
| 4555 | set_nt_page(2, ROM, m1 | 0x80, 0); |
| 4556 | set_nt_page(3, ROM, m1 | 0x80, 0); |
| 4160 | 4557 | break; |
| 4161 | 4558 | case 0x12: |
| 4162 | | set_nt_page(0, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4163 | | set_nt_page(1, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4164 | | set_nt_page(2, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4165 | | set_nt_page(3, ROM, m0 | 0x80, 0); //(m0 << 10) + M68_OFFSET); |
| 4559 | set_nt_page(0, ROM, m0 | 0x80, 0); |
| 4560 | set_nt_page(1, ROM, m0 | 0x80, 0); |
| 4561 | set_nt_page(2, ROM, m0 | 0x80, 0); |
| 4562 | set_nt_page(3, ROM, m0 | 0x80, 0); |
| 4166 | 4563 | break; |
| 4167 | 4564 | case 0x13: |
| 4168 | | set_nt_page(0, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4169 | | set_nt_page(1, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4170 | | set_nt_page(2, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4171 | | set_nt_page(3, ROM, m1 | 0x80, 0); //(m1 << 10) + M68_OFFSET); |
| 4565 | set_nt_page(0, ROM, m1 | 0x80, 0); |
| 4566 | set_nt_page(1, ROM, m1 | 0x80, 0); |
| 4567 | set_nt_page(2, ROM, m1 | 0x80, 0); |
| 4568 | set_nt_page(3, ROM, m1 | 0x80, 0); |
| 4172 | 4569 | break; |
| 4173 | 4570 | } |
| 4174 | 4571 | } |
| 4175 | 4572 | |
| 4176 | 4573 | static WRITE8_HANDLER( mapper68_w ) |
| 4177 | 4574 | { |
| 4178 | | static int m68_mirror; |
| 4179 | | static int m0, m1; |
| 4180 | | |
| 4181 | 4575 | LOG_MMC(("mapper68_w, offset %04x, data: %02x\n", offset, data)); |
| 4182 | 4576 | |
| 4183 | 4577 | switch (offset & 0x7000) |
| 4184 | 4578 | { |
| 4185 | 4579 | case 0x0000: |
| 4186 | | /* Switch 2k VROM at $0000 */ |
| 4187 | 4580 | chr2_0(space->machine, data, CHRROM); |
| 4188 | 4581 | break; |
| 4189 | 4582 | case 0x1000: |
| 4190 | | /* Switch 2k VROM at $0800 */ |
| 4191 | 4583 | chr2_2(space->machine, data, CHRROM); |
| 4192 | 4584 | break; |
| 4193 | 4585 | case 0x2000: |
| 4194 | | /* Switch 2k VROM at $1000 */ |
| 4195 | 4586 | chr2_4(space->machine, data, CHRROM); |
| 4196 | 4587 | break; |
| 4197 | 4588 | case 0x3000: |
| 4198 | | /* Switch 2k VROM at $1800 */ |
| 4199 | 4589 | chr2_6(space->machine, data, CHRROM); |
| 4200 | 4590 | break; |
| 4201 | 4591 | case 0x4000: |
| r5997 | r5998 | |
| 4225 | 4615 | |
| 4226 | 4616 | Known Boards: JLROM, JSROM, Sunsoft 5B, Sunsoft FME7 and |
| 4227 | 4617 | Custom |
| 4228 | | Games: Barcode World, Batman - Return of the Joker, Gimmick!, |
| 4229 | | Splatter House - Wanpaku Graffiti |
| 4618 | Games: Barcode World, Batman - Return of the Joker, Gimmick! |
| 4230 | 4619 | |
| 4231 | 4620 | In MESS: Supported. |
| 4232 | 4621 | |
| 4233 | 4622 | *************************************************************/ |
| 4234 | 4623 | |
| 4235 | | /* should this be used for Mapper 67 as well?!? */ |
| 4236 | | static void sunsoft_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 4624 | /* Here, IRQ counter decrements every CPU cycle. Since we update it every scanline, |
| 4625 | we need to decrement it by 114 (Each scanline consists of 341 dots and, on NTSC, |
| 4626 | there are 3 dots to every 1 CPU cycle, hence 114 is the number of cycles per scanline ) */ |
| 4627 | static void mapper69_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 4237 | 4628 | { |
| 4238 | | /* 114 is the number of cycles per scanline */ |
| 4239 | 4629 | /* TODO: change to reflect the actual number of cycles spent */ |
| 4240 | | |
| 4241 | | if (IRQ_enable) |
| 4630 | if ((IRQ_enable & 0x80) && (IRQ_enable & 0x01)) |
| 4242 | 4631 | { |
| 4243 | 4632 | if (IRQ_count <= 114) |
| 4244 | 4633 | { |
| 4634 | IRQ_count = 0xffff; |
| 4245 | 4635 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 4246 | 4636 | } |
| 4247 | | IRQ_count -= 114; |
| 4637 | else |
| 4638 | IRQ_count -= 114; |
| 4248 | 4639 | } |
| 4640 | else if (IRQ_enable & 0x01) // if enable bit is not set, only decrement the counter! |
| 4641 | { |
| 4642 | if (IRQ_count <= 114) |
| 4643 | IRQ_count = 0xffff; |
| 4644 | else |
| 4645 | IRQ_count -= 114; |
| 4646 | } |
| 4249 | 4647 | } |
| 4250 | 4648 | |
| 4251 | 4649 | static WRITE8_HANDLER( mapper69_w ) |
| 4252 | 4650 | { |
| 4253 | | static int cmd = 0; |
| 4254 | 4651 | LOG_MMC(("mapper69_w, offset %04x, data: %02x\n", offset, data)); |
| 4255 | 4652 | |
| 4256 | | switch (offset & 0x7000) |
| 4653 | switch (offset & 0x6000) |
| 4257 | 4654 | { |
| 4258 | 4655 | case 0x0000: |
| 4259 | | cmd = data & 0x0f; |
| 4656 | mmc_cmd1 = data & 0x0f; |
| 4260 | 4657 | break; |
| 4261 | 4658 | |
| 4262 | 4659 | case 0x2000: |
| 4263 | | switch (cmd) |
| 4660 | switch (mmc_cmd1) |
| 4264 | 4661 | { |
| 4265 | 4662 | case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: |
| 4266 | | chr1_x(space->machine, cmd, data, CHRROM); |
| 4267 | | //ppu2c0x_set_videorom_bank(state->ppu, cmd, 1, data, 64); |
| 4663 | chr1_x(space->machine, mmc_cmd1, data, CHRROM); |
| 4268 | 4664 | break; |
| 4269 | 4665 | |
| 4270 | | /* TODO: deal with bankswitching/write-protecting the mid-mapper area */ |
| 4666 | /* TODO: deal properly with bankswitching/write-protecting the mid-mapper area */ |
| 4271 | 4667 | case 8: |
| 4272 | | #if 0 |
| 4273 | 4668 | if (!(data & 0x40)) |
| 4274 | | { |
| 4275 | | memory_set_bankptr(space->machine, 5, &nes.rom[(data & 0x3f) * 0x2000 + 0x10000]); |
| 4276 | | } |
| 4277 | | else |
| 4278 | | #endif |
| 4279 | | LOG_MMC(("mapper69_w, cmd 8, data: %02x\n", data)); |
| 4669 | prg8_67(space->machine, data & 0x3f); |
| 4670 | else if (data & 0x80) |
| 4671 | memory_set_bankptr(space->machine, 5, &nes.wram[(data & 0x3f) * 0x2000]); |
| 4280 | 4672 | break; |
| 4281 | 4673 | |
| 4282 | 4674 | case 9: |
| 4283 | 4675 | prg8_89(space->machine, data); |
| 4284 | 4676 | break; |
| 4285 | | case 10: |
| 4677 | case 0x0a: |
| 4286 | 4678 | prg8_ab(space->machine, data); |
| 4287 | 4679 | break; |
| 4288 | | case 11: |
| 4680 | case 0x0b: |
| 4289 | 4681 | prg8_cd(space->machine, data); |
| 4290 | 4682 | break; |
| 4291 | | case 12: |
| 4683 | case 0x0c: |
| 4292 | 4684 | switch (data & 0x03) |
| 4293 | 4685 | { |
| 4294 | 4686 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| r5997 | r5998 | |
| 4297 | 4689 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 4298 | 4690 | } |
| 4299 | 4691 | break; |
| 4300 | | case 13: |
| 4692 | case 0x0d: |
| 4301 | 4693 | IRQ_enable = data; |
| 4302 | 4694 | break; |
| 4303 | | case 14: |
| 4695 | case 0x0e: |
| 4304 | 4696 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 4305 | 4697 | break; |
| 4306 | | case 15: |
| 4698 | case 0x0f: |
| 4307 | 4699 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 4308 | 4700 | break; |
| 4309 | 4701 | } |
| 4310 | 4702 | break; |
| 4311 | 4703 | |
| 4704 | /* Here we would have sound command for Sunsoft 5b variant */ |
| 4705 | // case 0x4000: |
| 4706 | // case 0x6000: |
| 4707 | |
| 4312 | 4708 | default: |
| 4313 | 4709 | logerror("mapper69_w uncaught %04x value: %02x\n", offset + 0x8000, data); |
| 4314 | 4710 | break; |
| r5997 | r5998 | |
| 4473 | 4869 | |
| 4474 | 4870 | static void mapper74_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 4475 | 4871 | { |
| 4476 | | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 4872 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 4477 | 4873 | UINT8 chr_src[6]; |
| 4478 | 4874 | int i; |
| 4479 | 4875 | |
| r5997 | r5998 | |
| 4498 | 4894 | switch (offset & 0x6001) |
| 4499 | 4895 | { |
| 4500 | 4896 | case 0x0000: |
| 4501 | | MMC3_helper = MMC3_cmd ^ data; |
| 4502 | | MMC3_cmd = data; |
| 4897 | MMC3_helper = mmc_cmd1 ^ data; |
| 4898 | mmc_cmd1 = data; |
| 4503 | 4899 | |
| 4504 | 4900 | /* Has PRG Mode changed? */ |
| 4505 | 4901 | if (MMC3_helper & 0x40) |
| r5997 | r5998 | |
| 4511 | 4907 | break; |
| 4512 | 4908 | |
| 4513 | 4909 | case 0x0001: |
| 4514 | | cmd = MMC3_cmd & 0x07; |
| 4910 | cmd = mmc_cmd1 & 0x07; |
| 4515 | 4911 | switch (cmd) |
| 4516 | 4912 | { |
| 4517 | | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 4913 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 4518 | 4914 | case 2: case 3: case 4: case 5: |
| 4519 | 4915 | vrom_bank[cmd] = data; |
| 4520 | 4916 | mapper74_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| r5997 | r5998 | |
| 4635 | 5031 | Known Boards: Irem LROG017 |
| 4636 | 5032 | Games: Napoleon Senki |
| 4637 | 5033 | |
| 4638 | | In MESS: Supported. |
| 5034 | In MESS: Partially Supported (it needs 4-screen mirroring). |
| 4639 | 5035 | |
| 4640 | 5036 | *************************************************************/ |
| 4641 | 5037 | |
| r5997 | r5998 | |
| 4655 | 5051 | Games: Holy Diver, Portopia Renzoku Satsujin Jiken, |
| 4656 | 5052 | Uchuusen - Cosmo Carrier |
| 4657 | 5053 | |
| 4658 | | In MESS: Partially Supported. |
| 5054 | A crc check is required to support Cosmo Carrier (which uses |
| 5055 | a slightly different board) |
| 4659 | 5056 | |
| 5057 | In MESS: Supported. |
| 5058 | |
| 4660 | 5059 | *************************************************************/ |
| 4661 | 5060 | |
| 4662 | 5061 | static WRITE8_HANDLER( mapper78_w ) |
| 4663 | 5062 | { |
| 4664 | 5063 | LOG_MMC(("mapper78_w, offset: %04x, data: %02x\n", offset, data)); |
| 4665 | | /* Switch 8k VROM bank */ |
| 5064 | |
| 5065 | if (nes.crc_hack) // Jaleco JF16 board has different mirroring even if uses same mapper number :( |
| 5066 | set_nt_mirroring((data & 0x08) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); |
| 5067 | else |
| 5068 | set_nt_mirroring((data & 0x08) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 5069 | |
| 4666 | 5070 | chr8(space->machine, (data & 0xf0) >> 4, CHRROM); |
| 4667 | | |
| 4668 | | /* Switch 16k ROM bank */ |
| 4669 | | prg16_89ab(space->machine, data & 0x0f); |
| 5071 | prg16_89ab(space->machine, data & 0x07); |
| 4670 | 5072 | } |
| 4671 | 5073 | |
| 4672 | 5074 | /************************************************************* |
| r5997 | r5998 | |
| 4715 | 5117 | switch (offset) |
| 4716 | 5118 | { |
| 4717 | 5119 | case 0x1ef0: |
| 4718 | | /* Switch 2k VROM at $0000 */ |
| 4719 | 5120 | chr2_0(space->machine, (data & 0x7f) >> 1, CHRROM); |
| 4720 | 5121 | break; |
| 4721 | 5122 | case 0x1ef1: |
| 4722 | | /* Switch 2k VROM at $0000 */ |
| 4723 | 5123 | chr2_2(space->machine, (data & 0x7f) >> 1, CHRROM); |
| 4724 | 5124 | break; |
| 4725 | 5125 | case 0x1ef2: |
| 4726 | | /* Switch 1k VROM at $1000 */ |
| 4727 | 5126 | chr1_4(space->machine, data, CHRROM); |
| 4728 | 5127 | break; |
| 4729 | 5128 | case 0x1ef3: |
| 4730 | | /* Switch 1k VROM at $1400 */ |
| 4731 | 5129 | chr1_5(space->machine, data, CHRROM); |
| 4732 | 5130 | break; |
| 4733 | 5131 | case 0x1ef4: |
| 4734 | | /* Switch 1k VROM at $1800 */ |
| 4735 | 5132 | chr1_6(space->machine, data, CHRROM); |
| 4736 | 5133 | break; |
| 4737 | 5134 | case 0x1ef5: |
| 4738 | | /* Switch 1k VROM at $1c00 */ |
| 4739 | 5135 | chr1_7(space->machine, data, CHRROM); |
| 4740 | 5136 | break; |
| 4741 | 5137 | case 0x1ef6: |
| r5997 | r5998 | |
| 4743 | 5139 | break; |
| 4744 | 5140 | case 0x1efa: |
| 4745 | 5141 | case 0x1efb: |
| 4746 | | /* Switch 8k ROM at $8000 */ |
| 4747 | 5142 | prg8_89(space->machine, data); |
| 4748 | 5143 | break; |
| 4749 | 5144 | case 0x1efc: |
| 4750 | 5145 | case 0x1efd: |
| 4751 | | /* Switch 8k ROM at $a000 */ |
| 4752 | 5146 | prg8_ab(space->machine, data); |
| 4753 | 5147 | break; |
| 4754 | 5148 | case 0x1efe: |
| 4755 | 5149 | case 0x1eff: |
| 4756 | | /* Switch 8k ROM at $c000 */ |
| 4757 | 5150 | prg8_cd(space->machine, data); |
| 4758 | 5151 | break; |
| 4759 | 5152 | default: |
| r5997 | r5998 | |
| 4777 | 5170 | |
| 4778 | 5171 | Mapper 82 |
| 4779 | 5172 | |
| 4780 | | Known Boards: Taito X1017 |
| 5173 | Known Boards: Taito X1-017 |
| 4781 | 5174 | Games: Kyuukyoku Harikiri Koushien, Kyuukyoku Harikiri |
| 4782 | 5175 | Stadium, SD Keiji - Blader |
| 4783 | 5176 | |
| r5997 | r5998 | |
| 4787 | 5180 | |
| 4788 | 5181 | static WRITE8_HANDLER( mapper82_m_w ) |
| 4789 | 5182 | { |
| 4790 | | static int vrom_switch; |
| 4791 | | |
| 4792 | | /* This mapper has problems */ |
| 4793 | | |
| 4794 | 5183 | LOG_MMC(("mapper82_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 4795 | 5184 | |
| 4796 | 5185 | switch (offset) |
| 4797 | 5186 | { |
| 4798 | 5187 | case 0x1ef0: |
| 4799 | | if (vrom_switch) |
| 4800 | | chr2_4(space->machine, data, CHRROM); |
| 5188 | if (mmc_cmd1) |
| 5189 | chr2_4(space->machine, data >> 1, CHRROM); |
| 4801 | 5190 | else |
| 4802 | | chr2_0(space->machine, data, CHRROM); |
| 5191 | chr2_0(space->machine, data >> 1, CHRROM); |
| 4803 | 5192 | break; |
| 4804 | 5193 | case 0x1ef1: |
| 4805 | | if (vrom_switch) |
| 5194 | if (mmc_cmd1) |
| 4806 | 5195 | chr2_6(space->machine, data, CHRROM); |
| 4807 | 5196 | else |
| 4808 | 5197 | chr2_2(space->machine, data, CHRROM); |
| 4809 | 5198 | break; |
| 4810 | 5199 | case 0x1ef2: |
| 4811 | | chr1_x(space->machine, 4 ^ vrom_switch, data, CHRROM); |
| 5200 | chr1_x(space->machine, 4 ^ mmc_cmd1, data, CHRROM); |
| 4812 | 5201 | break; |
| 4813 | 5202 | case 0x1ef3: |
| 4814 | | chr1_x(space->machine, 5 ^ vrom_switch, data, CHRROM); |
| 5203 | chr1_x(space->machine, 5 ^ mmc_cmd1, data, CHRROM); |
| 4815 | 5204 | break; |
| 4816 | 5205 | case 0x1ef4: |
| 4817 | | chr1_x(space->machine, 6 ^ vrom_switch, data, CHRROM); |
| 5206 | chr1_x(space->machine, 6 ^ mmc_cmd1, data, CHRROM); |
| 4818 | 5207 | break; |
| 4819 | 5208 | case 0x1ef5: |
| 4820 | | chr1_x(space->machine, 7 ^ vrom_switch, data, CHRROM); |
| 5209 | chr1_x(space->machine, 7 ^ mmc_cmd1, data, CHRROM); |
| 4821 | 5210 | break; |
| 4822 | 5211 | case 0x1ef6: |
| 4823 | | set_nt_mirroring((data & 0x1) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 4824 | | //doc says 1= swapped. Causes in-game issues, but mostly fixes title screen |
| 4825 | | vrom_switch = ((data & 0x02) << 1); |
| 5212 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 5213 | mmc_cmd1 = ((data & 0x02) << 1); |
| 4826 | 5214 | break; |
| 4827 | 5215 | |
| 4828 | 5216 | case 0x1efa: |
| r5997 | r5998 | |
| 4975 | 5363 | switch (offset & 0x7018) |
| 4976 | 5364 | { |
| 4977 | 5365 | case 0x0000: |
| 4978 | | /* Switch 8k bank at $8000 */ |
| 4979 | 5366 | prg8_89(space->machine, data); |
| 4980 | 5367 | break; |
| 4981 | 5368 | case 0x0008: |
| 4982 | 5369 | case 0x0010: |
| 4983 | 5370 | case 0x0018: |
| 4984 | | /* Switch 8k bank at $a000 */ |
| 4985 | 5371 | prg8_ab(space->machine, data); |
| 4986 | 5372 | break; |
| 4987 | 5373 | |
| 4988 | 5374 | case 0x1000: |
| 4989 | | /* Switch 8k bank at $c000 */ |
| 4990 | 5375 | prg8_cd(space->machine, data); |
| 4991 | 5376 | break; |
| 4992 | 5377 | |
| r5997 | r5998 | |
| 5025 | 5410 | IRQ_count_latch = data; |
| 5026 | 5411 | break; |
| 5027 | 5412 | case 0x7000: |
| 5413 | IRQ_mode = data & 0x04; // currently not implemented: 0 = prescaler mode / 1 = CPU mode |
| 5028 | 5414 | IRQ_enable = data & 0x02; |
| 5029 | 5415 | IRQ_enable_latch = data & 0x01; |
| 5030 | 5416 | if (data & 0x02) |
| r5997 | r5998 | |
| 5160 | 5546 | Games: Mortal Kombat II, Street Fighter III, Super Mario |
| 5161 | 5547 | Kart Rider |
| 5162 | 5548 | |
| 5163 | | In MESS: Partially supported. |
| 5549 | This board uses an IRQ system very similar to MMC3. We indeed |
| 5550 | use mapper4_irq, but there is some small glitch! |
| 5164 | 5551 | |
| 5552 | In MESS: Supported. |
| 5553 | |
| 5165 | 5554 | *************************************************************/ |
| 5166 | 5555 | |
| 5167 | 5556 | static WRITE8_HANDLER( mapper91_m_w ) |
| 5168 | 5557 | { |
| 5169 | 5558 | LOG_MMC(("mapper91_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5170 | 5559 | |
| 5171 | | switch (offset & 0x7000) |
| 5560 | switch (offset & 0x1000) |
| 5172 | 5561 | { |
| 5173 | 5562 | case 0x0000: |
| 5174 | 5563 | switch (offset & 0x03) |
| r5997 | r5998 | |
| 5180 | 5569 | } |
| 5181 | 5570 | break; |
| 5182 | 5571 | case 0x1000: |
| 5183 | | switch (offset & 0x01) |
| 5572 | switch (offset & 0x03) |
| 5184 | 5573 | { |
| 5185 | 5574 | case 0x00: prg8_89(space->machine, data); break; |
| 5186 | 5575 | case 0x01: prg8_ab(space->machine, data); break; |
| 5576 | case 0x02: IRQ_enable = 0; IRQ_count = 0; break; |
| 5577 | case 0x03: IRQ_enable = 1; IRQ_count = 7; break; |
| 5187 | 5578 | } |
| 5188 | 5579 | break; |
| 5189 | 5580 | default: |
| r5997 | r5998 | |
| 5487 | 5878 | Known Boards: Unknown Bootleg Board |
| 5488 | 5879 | Games: Super Mario Bros. 3 Pirate |
| 5489 | 5880 | |
| 5490 | | In MESS: Unsupported. |
| 5881 | In MESS: Supported. |
| 5491 | 5882 | |
| 5492 | 5883 | *************************************************************/ |
| 5493 | 5884 | |
| 5885 | static void mapper106_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 5886 | { |
| 5887 | if (IRQ_enable) |
| 5888 | { |
| 5889 | if ((0xffff - IRQ_count) < 114) |
| 5890 | { |
| 5891 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 5892 | IRQ_enable = 0; |
| 5893 | } |
| 5894 | |
| 5895 | IRQ_count = (IRQ_count + 114) & 0xffff; |
| 5896 | } |
| 5897 | } |
| 5898 | |
| 5899 | static WRITE8_HANDLER( mapper106_w ) |
| 5900 | { |
| 5901 | LOG_MMC(("mapper106_w, offset: %04x, data: %02x\n", offset, data)); |
| 5902 | switch (offset & 0x0f) |
| 5903 | { |
| 5904 | case 0x00: |
| 5905 | case 0x02: |
| 5906 | chr1_x(space->machine, offset & 0x07, data & 0xfe, CHRROM); |
| 5907 | break; |
| 5908 | case 0x01: |
| 5909 | case 0x03: |
| 5910 | chr1_x(space->machine, offset & 0x07, data | 0x01, CHRROM); |
| 5911 | break; |
| 5912 | case 0x04: case 0x05: |
| 5913 | case 0x06: case 0x07: |
| 5914 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 5915 | break; |
| 5916 | case 0x08: |
| 5917 | prg8_89(space->machine, data | 0x10); |
| 5918 | break; |
| 5919 | case 0x09: |
| 5920 | prg8_ab(space->machine, data); |
| 5921 | break; |
| 5922 | case 0x0a: |
| 5923 | prg8_cd(space->machine, data); |
| 5924 | break; |
| 5925 | case 0x0b: |
| 5926 | prg8_ef(space->machine, data | 0x10); |
| 5927 | break; |
| 5928 | case 0x0c: |
| 5929 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 5930 | break; |
| 5931 | case 0x0d: |
| 5932 | IRQ_count = 0; |
| 5933 | IRQ_enable = 0; |
| 5934 | break; |
| 5935 | case 0x0e: |
| 5936 | IRQ_count = (IRQ_count & 0xff00) | data; |
| 5937 | break; |
| 5938 | case 0x0f: |
| 5939 | IRQ_count = (IRQ_count & 0x00ff) | (data << 8); |
| 5940 | IRQ_enable = 1; |
| 5941 | break; |
| 5942 | } |
| 5943 | } |
| 5944 | |
| 5494 | 5945 | /************************************************************* |
| 5495 | 5946 | |
| 5496 | 5947 | Mapper 107 |
| r5997 | r5998 | |
| 5640 | 6091 | |
| 5641 | 6092 | if (!(offset & 0x100)) |
| 5642 | 6093 | { |
| 5643 | | prg32(space->machine, data >> 3); |
| 5644 | | chr8(space->machine, data & 0x07, CHRROM); |
| 6094 | prg32(space->machine, (data & 0x38) >> 3); |
| 6095 | chr8(space->machine, (data & 0x07) | ((data & 0x40) >> 3), CHRROM); |
| 6096 | if (nes.crc_hack) // this breaks AV Soccer but it is needed by HES 6-in-1! |
| 6097 | set_nt_mirroring((data & 0x80) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ); |
| 5645 | 6098 | } |
| 5646 | 6099 | } |
| 5647 | 6100 | |
| r5997 | r5998 | |
| 5726 | 6179 | |
| 5727 | 6180 | MMC3 clone |
| 5728 | 6181 | |
| 5729 | | In MESS: Partally Supported |
| 6182 | In MESS: Supported |
| 5730 | 6183 | |
| 5731 | 6184 | *************************************************************/ |
| 5732 | 6185 | |
| 5733 | | static void mapper115_set_prg( running_machine *machine ) |
| 6186 | static void mapper115_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 5734 | 6187 | { |
| 5735 | | if (mapper115_reg[3] & 0x80) |
| 5736 | | { |
| 5737 | | prg16_89ab(machine, mapper115_reg[3] & 0x0f); |
| 5738 | | } |
| 6188 | if (mapper115_reg[0] & 0x80) |
| 6189 | prg32(machine, mapper115_reg[0] >> 1); |
| 5739 | 6190 | else |
| 5740 | | { |
| 5741 | | prg8_89(machine, mapper115_reg[1] & 0x1f); |
| 5742 | | prg8_ab(machine, mapper115_reg[2] & 0x1f); |
| 5743 | | } |
| 6191 | mapper4_set_prg(machine, prg_base, prg_mask); |
| 5744 | 6192 | } |
| 5745 | 6193 | |
| 5746 | 6194 | static WRITE8_HANDLER( mapper115_m_w ) |
| 5747 | 6195 | { |
| 5748 | 6196 | LOG_MMC(("mapper115_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 5749 | 6197 | |
| 5750 | | mapper115_reg[3] = data; |
| 5751 | | mapper115_set_prg(space->machine); |
| 6198 | switch (offset & 0x01) |
| 6199 | { |
| 6200 | case 0x00: |
| 6201 | mapper115_reg[0] = data; |
| 6202 | mapper115_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6203 | break; |
| 6204 | case 0x01: |
| 6205 | mmc_chr_base = (data & 0x01) ? 0x100 : 0x000; |
| 6206 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6207 | break; |
| 6208 | } |
| 5752 | 6209 | } |
| 5753 | 6210 | |
| 5754 | 6211 | static WRITE8_HANDLER( mapper115_w ) |
| 5755 | 6212 | { |
| 6213 | UINT8 map115_helper, cmd; |
| 5756 | 6214 | LOG_MMC(("mapper115_w, offset: %04x, data: %02x\n", offset, data)); |
| 5757 | 6215 | |
| 5758 | | switch (offset & 0x7001) |
| 6216 | switch (offset & 0x6001) |
| 5759 | 6217 | { |
| 5760 | | case 0x0000: |
| 5761 | | mapper115_reg[0] = data; |
| 5762 | | break; |
| 5763 | | case 0x0001: |
| 5764 | | switch (mapper115_reg[0] & 0x07) |
| 5765 | | { |
| 5766 | | case 0: |
| 5767 | | chr2_0(space->machine, data >> 1, CHRROM); |
| 6218 | case 0x0000: |
| 6219 | map115_helper = mmc_cmd1 ^ data; |
| 6220 | mmc_cmd1 = data; |
| 6221 | |
| 6222 | /* Has PRG Mode changed? */ |
| 6223 | if (map115_helper & 0x40) |
| 6224 | mapper115_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6225 | |
| 6226 | /* Has CHR Mode changed? */ |
| 6227 | if (map115_helper & 0x80) |
| 6228 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 5768 | 6229 | break; |
| 5769 | | case 1: |
| 5770 | | chr2_2(space->machine, data >> 1, CHRROM); |
| 6230 | |
| 6231 | case 0x0001: |
| 6232 | cmd = mmc_cmd1 & 0x07; |
| 6233 | switch (cmd) |
| 6234 | { |
| 6235 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 6236 | case 2: case 3: case 4: case 5: |
| 6237 | vrom_bank[cmd] = data; |
| 6238 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6239 | break; |
| 6240 | case 6: |
| 6241 | case 7: |
| 6242 | prg_bank[cmd - 6] = data; |
| 6243 | mapper115_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6244 | break; |
| 6245 | } |
| 5771 | 6246 | break; |
| 5772 | | case 2: |
| 5773 | | chr1_4(space->machine, data, CHRROM); |
| 6247 | |
| 6248 | default: |
| 6249 | mapper4_w(space, offset, data); |
| 5774 | 6250 | break; |
| 5775 | | case 3: |
| 5776 | | chr1_5(space->machine, data, CHRROM); |
| 5777 | | break; |
| 5778 | | case 4: |
| 5779 | | chr1_6(space->machine, data, CHRROM); |
| 5780 | | break; |
| 5781 | | case 5: |
| 5782 | | chr1_7(space->machine, data, CHRROM); |
| 5783 | | break; |
| 5784 | | case 6: |
| 5785 | | mapper115_reg[1] = data; |
| 5786 | | mapper115_set_prg(space->machine); |
| 5787 | | break; |
| 5788 | | case 7: |
| 5789 | | mapper115_reg[2] = data; |
| 5790 | | mapper115_set_prg(space->machine); |
| 5791 | | break; |
| 5792 | | } |
| 5793 | | break; |
| 5794 | | case 0x2000: |
| 5795 | | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 5796 | | break; |
| 5797 | | case 0x4000: |
| 5798 | | IRQ_count_latch = data; |
| 5799 | | break; |
| 5800 | | case 0x4001: |
| 5801 | | IRQ_count = IRQ_count_latch; |
| 5802 | | break; |
| 5803 | | case 0x6000: |
| 5804 | | IRQ_enable = 0; |
| 5805 | | break; |
| 5806 | | case 0x6001: |
| 5807 | | IRQ_enable = 1; |
| 5808 | | break; |
| 5809 | 6251 | } |
| 5810 | 6252 | } |
| 5811 | 6253 | |
| 5812 | | static void mapper115_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 5813 | | { |
| 5814 | | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 5815 | | { |
| 5816 | | int priorCount = IRQ_count; |
| 5817 | | if ((IRQ_count == 0) || IRQ_reload) |
| 5818 | | { |
| 5819 | | IRQ_count = IRQ_count_latch; |
| 5820 | | IRQ_reload = 0; |
| 5821 | | } |
| 5822 | | else |
| 5823 | | IRQ_count --; |
| 5824 | | |
| 5825 | | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 5826 | | { |
| 5827 | | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 5828 | | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 5829 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 5830 | | } |
| 5831 | | } |
| 5832 | | } |
| 5833 | | |
| 5834 | 6254 | /************************************************************* |
| 5835 | 6255 | |
| 5836 | 6256 | Mapper 116 |
| r5997 | r5998 | |
| 5853 | 6273 | |
| 5854 | 6274 | *************************************************************/ |
| 5855 | 6275 | |
| 6276 | static void mapper117_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 6277 | { |
| 6278 | // if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 6279 | { |
| 6280 | if (IRQ_enable && IRQ_count) |
| 6281 | { |
| 6282 | IRQ_count--; |
| 6283 | if (!IRQ_count) |
| 6284 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 6285 | } |
| 6286 | } |
| 6287 | } |
| 6288 | |
| 6289 | static WRITE8_HANDLER( mapper117_w ) |
| 6290 | { |
| 6291 | LOG_MMC(("mapper117_w, offset: %04x, data: %02x\n", offset, data)); |
| 6292 | |
| 6293 | switch (offset) |
| 6294 | { |
| 6295 | case 0x0000: |
| 6296 | prg8_89(space->machine, data); |
| 6297 | break; |
| 6298 | case 0x0001: |
| 6299 | prg8_ab(space->machine, data); |
| 6300 | break; |
| 6301 | case 0x0002: |
| 6302 | prg8_cd(space->machine, data); |
| 6303 | break; |
| 6304 | case 0x0003: |
| 6305 | prg8_ef(space->machine, data); |
| 6306 | break; |
| 6307 | case 0x2000: |
| 6308 | case 0x2001: |
| 6309 | case 0x2002: |
| 6310 | case 0x2003: |
| 6311 | case 0x2004: |
| 6312 | case 0x2005: |
| 6313 | case 0x2006: |
| 6314 | case 0x2007: |
| 6315 | chr1_x(space->machine, offset & 0x07, data, CHRROM); |
| 6316 | break; |
| 6317 | |
| 6318 | case 0x5000: |
| 6319 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 6320 | break; |
| 6321 | |
| 6322 | case 0x4001: |
| 6323 | IRQ_count_latch = data; |
| 6324 | break; |
| 6325 | case 0x4002: |
| 6326 | // IRQ cleared |
| 6327 | break; |
| 6328 | case 0x4003: |
| 6329 | IRQ_count = IRQ_count_latch; |
| 6330 | break; |
| 6331 | case 0x6000: |
| 6332 | IRQ_enable = data & 0x01; |
| 6333 | break; |
| 6334 | } |
| 6335 | } |
| 6336 | |
| 5856 | 6337 | /************************************************************* |
| 5857 | 6338 | |
| 5858 | 6339 | Mapper 118 |
| r5997 | r5998 | |
| 5865 | 6346 | |
| 5866 | 6347 | *************************************************************/ |
| 5867 | 6348 | |
| 6349 | static void mapper118_set_mirror( void ) |
| 6350 | { |
| 6351 | if (mmc_cmd1 & 0x80) |
| 6352 | { |
| 6353 | set_nt_page(0, CIRAM, (vrom_bank[2] & 0x80) >> 7, 1); |
| 6354 | set_nt_page(1, CIRAM, (vrom_bank[3] & 0x80) >> 7, 1); |
| 6355 | set_nt_page(2, CIRAM, (vrom_bank[4] & 0x80) >> 7, 1); |
| 6356 | set_nt_page(3, CIRAM, (vrom_bank[5] & 0x80) >> 7, 1); |
| 6357 | } |
| 6358 | else |
| 6359 | { |
| 6360 | set_nt_page(0, CIRAM, (vrom_bank[0] & 0x80) >> 7, 1); |
| 6361 | set_nt_page(1, CIRAM, (vrom_bank[0] & 0x80) >> 7, 1); |
| 6362 | set_nt_page(2, CIRAM, (vrom_bank[1] & 0x80) >> 7, 1); |
| 6363 | set_nt_page(3, CIRAM, (vrom_bank[1] & 0x80) >> 7, 1); |
| 6364 | } |
| 6365 | } |
| 6366 | |
| 5868 | 6367 | static WRITE8_HANDLER( mapper118_w ) |
| 5869 | 6368 | { |
| 6369 | UINT8 MMC3_helper, cmd; |
| 5870 | 6370 | LOG_MMC(("mapper118_w, offset: %04x, data: %02x\n", offset, data)); |
| 5871 | 6371 | |
| 5872 | 6372 | switch (offset & 0x6001) |
| 5873 | 6373 | { |
| 5874 | | case 0x2000: /* $a000 */ |
| 5875 | | LOG_MMC((" mapper 118 mirroring: %02x\n", data)); |
| 5876 | | switch (data & 0x02) |
| 6374 | case 0x0000: |
| 6375 | MMC3_helper = mmc_cmd1 ^ data; |
| 6376 | mmc_cmd1 = data; |
| 6377 | |
| 6378 | /* Has PRG Mode changed? */ |
| 6379 | if (MMC3_helper & 0x40) |
| 6380 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6381 | |
| 6382 | /* Has CHR Mode changed? */ |
| 6383 | if (MMC3_helper & 0x80) |
| 5877 | 6384 | { |
| 5878 | | case 0x00: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 5879 | | case 0x01: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 6385 | mapper118_set_mirror(); |
| 6386 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 5880 | 6387 | } |
| 5881 | 6388 | break; |
| 5882 | 6389 | |
| 5883 | | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 5884 | | IRQ_count = data; |
| 6390 | case 0x0001: |
| 6391 | cmd = mmc_cmd1 & 0x07; |
| 6392 | switch (cmd) |
| 6393 | { |
| 6394 | case 0: case 1: |
| 6395 | case 2: case 3: case 4: case 5: |
| 6396 | vrom_bank[cmd] = data; |
| 6397 | mapper118_set_mirror(); |
| 6398 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6399 | break; |
| 6400 | case 6: |
| 6401 | case 7: |
| 6402 | prg_bank[cmd - 6] = data; |
| 6403 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6404 | break; |
| 6405 | } |
| 5885 | 6406 | break; |
| 5886 | 6407 | |
| 5887 | | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 5888 | | IRQ_count_latch = data; |
| 6408 | case 0x2000: |
| 5889 | 6409 | break; |
| 5890 | 6410 | |
| 5891 | 6411 | default: |
| r5997 | r5998 | |
| 5907 | 6427 | |
| 5908 | 6428 | static void mapper119_set_chr( running_machine *machine ) |
| 5909 | 6429 | { |
| 5910 | | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 6430 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 6431 | UINT8 chr_src[6], chr_mask[6]; |
| 6432 | int i; |
| 5911 | 6433 | |
| 5912 | | if (vrom_bank[0] & 0x40) |
| 5913 | | chr2_x(machine, chr_page ^ 0, (vrom_bank[0] >> 1) & 0x03, CHRRAM); |
| 5914 | | else |
| 5915 | | chr2_x(machine, chr_page ^ 0, ((vrom_bank[0] & 0x3f) >> 1), CHRROM); |
| 6434 | for (i = 0; i < 6; i++) |
| 6435 | { |
| 6436 | chr_src[i] = (vrom_bank[i] & 0x40) ? CHRRAM : CHRROM; |
| 6437 | chr_mask[i] = (vrom_bank[i] & 0x40) ? 0x07 : 0x3f; |
| 6438 | } |
| 5916 | 6439 | |
| 5917 | | if (vrom_bank[1] & 0x40) |
| 5918 | | chr2_x(machine, chr_page ^ 2, (vrom_bank[1] >> 1) & 0x03, CHRRAM); |
| 5919 | | else |
| 5920 | | chr2_x(machine, chr_page ^ 2, ((vrom_bank[1] & 0x3f) >> 1), CHRROM); |
| 5921 | | |
| 5922 | | if (vrom_bank[2] & 0x40) |
| 5923 | | chr1_x(machine, chr_page ^ 4, vrom_bank[2] & 0x07, CHRRAM); |
| 5924 | | else |
| 5925 | | chr1_x(machine, chr_page ^ 4, vrom_bank[2] & 0x3f, CHRROM); |
| 5926 | | |
| 5927 | | if (vrom_bank[3] & 0x40) |
| 5928 | | chr1_x(machine, chr_page ^ 5, vrom_bank[3] & 0x07, CHRRAM); |
| 5929 | | else |
| 5930 | | chr1_x(machine, chr_page ^ 5, vrom_bank[3] & 0x3f, CHRROM); |
| 5931 | | |
| 5932 | | if (vrom_bank[4] & 0x40) |
| 5933 | | chr1_x(machine, chr_page ^ 6, vrom_bank[4] & 0x07, CHRRAM); |
| 5934 | | else |
| 5935 | | chr1_x(machine, chr_page ^ 6, vrom_bank[4] & 0x3f, CHRROM); |
| 5936 | | |
| 5937 | | if (vrom_bank[5] & 0x40) |
| 5938 | | chr1_x(machine, chr_page ^ 7, vrom_bank[5] & 0x07, CHRRAM); |
| 5939 | | else |
| 5940 | | chr1_x(machine, chr_page ^ 7, vrom_bank[5] & 0x3f, CHRROM); |
| 6440 | chr1_x(machine, chr_page ^ 0, ((vrom_bank[0] & ~0x01) & chr_mask[0]), chr_src[0]); |
| 6441 | chr1_x(machine, chr_page ^ 1, ((vrom_bank[0] | 0x01) & chr_mask[0]), chr_src[0]); |
| 6442 | chr1_x(machine, chr_page ^ 2, ((vrom_bank[1] & ~0x01) & chr_mask[1]), chr_src[1]); |
| 6443 | chr1_x(machine, chr_page ^ 3, ((vrom_bank[1] | 0x01) & chr_mask[1]), chr_src[1]); |
| 6444 | chr1_x(machine, chr_page ^ 4, (vrom_bank[2] & chr_mask[2]), chr_src[2]); |
| 6445 | chr1_x(machine, chr_page ^ 5, (vrom_bank[3] & chr_mask[3]), chr_src[3]); |
| 6446 | chr1_x(machine, chr_page ^ 6, (vrom_bank[4] & chr_mask[4]), chr_src[4]); |
| 6447 | chr1_x(machine, chr_page ^ 7, (vrom_bank[5] & chr_mask[5]), chr_src[5]); |
| 5941 | 6448 | } |
| 5942 | 6449 | |
| 5943 | 6450 | static WRITE8_HANDLER( mapper119_w ) |
| 5944 | 6451 | { |
| 5945 | | static UINT8 last_bank = 0xff; |
| 6452 | UINT8 MMC3_helper, cmd; |
| 5946 | 6453 | LOG_MMC(("mapper119_w, offset: %04x, data: %02x\n", offset, data)); |
| 5947 | 6454 | |
| 5948 | 6455 | switch (offset & 0x6001) |
| 5949 | 6456 | { |
| 5950 | | case 0x0000: /* $8000 */ |
| 5951 | | MMC3_cmd = data; |
| 6457 | case 0x0000: |
| 6458 | MMC3_helper = mmc_cmd1 ^ data; |
| 6459 | mmc_cmd1 = data; |
| 5952 | 6460 | |
| 5953 | | /* Toggle between switching $8000 and $c000 */ |
| 5954 | | if (last_bank != (data & 0xc0)) |
| 5955 | | { |
| 5956 | | /* Reset the banks */ |
| 6461 | /* Has PRG Mode changed? */ |
| 6462 | if (MMC3_helper & 0x40) |
| 5957 | 6463 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6464 | |
| 6465 | /* Has CHR Mode changed? */ |
| 6466 | if (MMC3_helper & 0x80) |
| 5958 | 6467 | mapper119_set_chr(space->machine); |
| 5959 | | LOG_MMC((" MMC3 reset banks\n")); |
| 5960 | | } |
| 5961 | | last_bank = data & 0xc0; |
| 5962 | 6468 | break; |
| 5963 | | |
| 5964 | 6469 | case 0x0001: /* $8001 */ |
| 5965 | | { |
| 5966 | | UINT8 cmd = MMC3_cmd & 0x07; |
| 6470 | cmd = mmc_cmd1 & 0x07; |
| 5967 | 6471 | switch (cmd) |
| 5968 | 6472 | { |
| 5969 | | case 0: case 1: // these do not need to be separated because we shift banks in set_chr! |
| 6473 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 5970 | 6474 | case 2: case 3: case 4: case 5: |
| 5971 | 6475 | vrom_bank[cmd] = data; |
| 5972 | 6476 | mapper119_set_chr(space->machine); |
| r5997 | r5998 | |
| 5978 | 6482 | break; |
| 5979 | 6483 | } |
| 5980 | 6484 | break; |
| 5981 | | } |
| 6485 | |
| 5982 | 6486 | default: |
| 5983 | 6487 | mapper4_w(space, offset, data); |
| 5984 | 6488 | break; |
| r5997 | r5998 | |
| 6005 | 6509 | |
| 6006 | 6510 | MMC3 clone |
| 6007 | 6511 | |
| 6008 | | In MESS: Unsupported. |
| 6512 | In MESS: Supported. |
| 6009 | 6513 | |
| 6010 | 6514 | *************************************************************/ |
| 6011 | 6515 | |
| 6516 | static WRITE8_HANDLER( mapper121_l_w ) |
| 6517 | { |
| 6518 | LOG_MMC(("mapper12_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6519 | offset += 0x100; |
| 6520 | |
| 6521 | if (!(offset < 0x1000)) |
| 6522 | { |
| 6523 | switch (data & 0x03) |
| 6524 | { |
| 6525 | case 0x00: |
| 6526 | case 0x03: |
| 6527 | mapper121_reg[2] = 0x00; |
| 6528 | break; |
| 6529 | case 0x01: |
| 6530 | mapper121_reg[2] = 0x83; |
| 6531 | break; |
| 6532 | case 0x02: |
| 6533 | mapper121_reg[2] = 0x42; |
| 6534 | break; |
| 6535 | } |
| 6536 | } |
| 6537 | } |
| 6538 | |
| 6539 | static READ8_HANDLER( mapper121_l_r ) |
| 6540 | { |
| 6541 | LOG_MMC(("mapper12_l_r, offset: %04x\n", offset)); |
| 6542 | offset += 0x100; |
| 6543 | |
| 6544 | if (!(offset < 0x1000)) |
| 6545 | return mapper121_reg[2]; |
| 6546 | else |
| 6547 | return 0; |
| 6548 | } |
| 6549 | |
| 6550 | static void mapper121_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 6551 | { |
| 6552 | UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0; |
| 6553 | UINT8 new_bank2, new_bank3; |
| 6554 | |
| 6555 | new_bank2 = mapper121_reg[0] ? mapper121_reg[0] : prg_bank[2 ^ prg_flip]; |
| 6556 | new_bank3 = mapper121_reg[1] ? mapper121_reg[1] : prg_bank[3]; |
| 6557 | |
| 6558 | prg8_89(machine, prg_base | (prg_bank[0 ^ prg_flip] & prg_mask)); |
| 6559 | prg8_ab(machine, prg_base | (prg_bank[1] & prg_mask)); |
| 6560 | prg8_cd(machine, prg_base | (new_bank2 & prg_mask)); |
| 6561 | prg8_ef(machine, prg_base | (new_bank3 & prg_mask)); |
| 6562 | } |
| 6563 | |
| 6564 | static WRITE8_HANDLER( mapper121_w ) |
| 6565 | { |
| 6566 | UINT8 MMC3_helper, cmd; |
| 6567 | LOG_MMC(("mapper121_w, offset: %04x, data: %02x\n", offset, data)); |
| 6568 | |
| 6569 | if ((offset < 0x2000) && (offset & 0x03) == 0x03) |
| 6570 | { |
| 6571 | switch (data) |
| 6572 | { |
| 6573 | case 0x20: |
| 6574 | mapper121_reg[1] = 0x13; |
| 6575 | break; |
| 6576 | case 0x26: |
| 6577 | mapper121_reg[1] = 0x08; |
| 6578 | break; |
| 6579 | case 0x28: |
| 6580 | mapper121_reg[0] = 0x0c; |
| 6581 | break; |
| 6582 | case 0x29: |
| 6583 | mapper121_reg[1] = 0x1b; |
| 6584 | break; |
| 6585 | case 0xab: |
| 6586 | mapper121_reg[1] = 0x07; |
| 6587 | break; |
| 6588 | case 0xec: |
| 6589 | case 0xef: |
| 6590 | mapper121_reg[1] = 0x0d; |
| 6591 | break; |
| 6592 | case 0xff: |
| 6593 | mapper121_reg[1] = 0x09; |
| 6594 | break; |
| 6595 | default: |
| 6596 | mapper121_reg[0] = 0x0; |
| 6597 | mapper121_reg[1] = 0x0; |
| 6598 | break; |
| 6599 | } |
| 6600 | } |
| 6601 | else |
| 6602 | { |
| 6603 | switch (offset & 0x6001) |
| 6604 | { |
| 6605 | case 0x0000: |
| 6606 | MMC3_helper = mmc_cmd1 ^ data; |
| 6607 | mmc_cmd1 = data; |
| 6608 | |
| 6609 | /* Has PRG Mode changed? */ |
| 6610 | if (MMC3_helper & 0x40) |
| 6611 | mapper121_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6612 | |
| 6613 | /* Has CHR Mode changed? */ |
| 6614 | if (MMC3_helper & 0x80) |
| 6615 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6616 | break; |
| 6617 | |
| 6618 | case 0x0001: |
| 6619 | cmd = mmc_cmd1 & 0x07; |
| 6620 | switch (cmd) |
| 6621 | { |
| 6622 | case 0: case 1: |
| 6623 | case 2: case 3: case 4: case 5: |
| 6624 | vrom_bank[cmd] = data; |
| 6625 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6626 | break; |
| 6627 | case 6: |
| 6628 | case 7: |
| 6629 | prg_bank[cmd - 6] = data; |
| 6630 | mapper121_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6631 | break; |
| 6632 | } |
| 6633 | break; |
| 6634 | |
| 6635 | default: |
| 6636 | mapper4_w(space, offset, data); |
| 6637 | break; |
| 6638 | } |
| 6639 | } |
| 6640 | mapper121_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6641 | } |
| 6642 | |
| 6012 | 6643 | /************************************************************* |
| 6013 | 6644 | |
| 6014 | 6645 | Mapper 122 |
| r5997 | r5998 | |
| 6183 | 6814 | { |
| 6184 | 6815 | LOG_MMC(("mapper133_l_w %04x:%02x\n", offset, data)); |
| 6185 | 6816 | |
| 6186 | | if (offset == 0) |
| 6187 | | { |
| 6188 | | prg32(space->machine, data >> 2); |
| 6189 | | chr8(space->machine, data, CHRROM);} |
| 6817 | mapper133_l_w(space, offset & 0xff, data); // offset does not really count for this mapper |
| 6190 | 6818 | } |
| 6191 | 6819 | |
| 6192 | 6820 | /************************************************************* |
| r5997 | r5998 | |
| 6194 | 6822 | Mapper 134 |
| 6195 | 6823 | |
| 6196 | 6824 | Known Boards: Unknown Multigame Bootleg Board (4646B) |
| 6197 | | Games: 2 in 1 - Family Camp & Aladdin 4 |
| 6825 | Games: 2 in 1 - Family Kid & Aladdin 4 |
| 6198 | 6826 | |
| 6199 | 6827 | MMC3 clone |
| 6200 | 6828 | |
| 6201 | | In MESS: Unsupported. |
| 6829 | In MESS: Supported. |
| 6202 | 6830 | |
| 6203 | 6831 | *************************************************************/ |
| 6204 | 6832 | |
| 6833 | static WRITE8_HANDLER( mapper134_m_w ) |
| 6834 | { |
| 6835 | LOG_MMC(("mapper134_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6836 | |
| 6837 | if (offset == 0x01) |
| 6838 | { |
| 6839 | mmc_prg_base = (data & 0x02) << 4; |
| 6840 | mmc_prg_mask = 0x1f; |
| 6841 | mmc_chr_base = (data & 0x20) << 3; |
| 6842 | mmc_chr_mask = 0xff; |
| 6843 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 6844 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 6845 | } |
| 6846 | } |
| 6847 | |
| 6205 | 6848 | /************************************************************* |
| 6206 | 6849 | |
| 6207 | 6850 | Mapper 135 |
| r5997 | r5998 | |
| 6283 | 6926 | { |
| 6284 | 6927 | LOG_MMC(("mapper137_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6285 | 6928 | |
| 6286 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 6287 | | but 0x4100 is offset = 0 */ |
| 6929 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6288 | 6930 | if (!(offset & 0x100)) |
| 6289 | 6931 | { |
| 6290 | 6932 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 6319 | 6961 | { |
| 6320 | 6962 | LOG_MMC(("mapper137_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6321 | 6963 | |
| 6322 | | mapper137_l_w(space, offset + 0x100, data); |
| 6964 | mapper137_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6323 | 6965 | } |
| 6324 | 6966 | |
| 6325 | 6967 | /************************************************************* |
| r5997 | r5998 | |
| 6338 | 6980 | UINT8 bank_helper1 = 0, bank_helper2 = 0; |
| 6339 | 6981 | LOG_MMC(("mapper138_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6340 | 6982 | |
| 6341 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 6342 | | but 0x4100 is offset = 0 */ |
| 6983 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6343 | 6984 | if (!(offset & 0x100)) |
| 6344 | 6985 | { |
| 6345 | 6986 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 6376 | 7017 | { |
| 6377 | 7018 | LOG_MMC(("mapper138_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6378 | 7019 | |
| 6379 | | mapper138_l_w(space, offset + 0x100, data); |
| 7020 | mapper138_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6380 | 7021 | } |
| 6381 | 7022 | |
| 6382 | 7023 | /************************************************************* |
| r5997 | r5998 | |
| 6395 | 7036 | UINT8 bank_helper1 = 0, bank_helper2 = 0; |
| 6396 | 7037 | LOG_MMC(("mapper139_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6397 | 7038 | |
| 6398 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 6399 | | but 0x4100 is offset = 0 */ |
| 7039 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6400 | 7040 | if (!(offset & 0x100)) |
| 6401 | 7041 | { |
| 6402 | 7042 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 6433 | 7073 | { |
| 6434 | 7074 | LOG_MMC(("mapper139_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6435 | 7075 | |
| 6436 | | mapper139_l_w(space, offset + 0x100, data); |
| 7076 | mapper139_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6437 | 7077 | } |
| 6438 | 7078 | |
| 6439 | 7079 | /************************************************************* |
| r5997 | r5998 | |
| 6472 | 7112 | UINT8 bank_helper1 = 0, bank_helper2 = 0; |
| 6473 | 7113 | LOG_MMC(("mapper141_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6474 | 7114 | |
| 6475 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 6476 | | but 0x4100 is offset = 0 */ |
| 7115 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6477 | 7116 | if (!(offset & 0x100)) |
| 6478 | 7117 | { |
| 6479 | 7118 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 6510 | 7149 | { |
| 6511 | 7150 | LOG_MMC(("mapper141_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6512 | 7151 | |
| 6513 | | mapper141_l_w(space, offset + 0x100, data); |
| 7152 | mapper141_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6514 | 7153 | } |
| 6515 | 7154 | |
| 6516 | 7155 | /************************************************************* |
| r5997 | r5998 | |
| 6539 | 7178 | { |
| 6540 | 7179 | LOG_MMC(("mapper143_l_r, offset: %04x\n", offset)); |
| 6541 | 7180 | |
| 6542 | | /* the address is read only if we are at 0x4100 + k * 0x200, |
| 6543 | | but 0x4100 is offset = 0 */ |
| 7181 | /* the address is read only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6544 | 7182 | if (!(offset & 0x100)) |
| 6545 | 7183 | return (~offset & 0x3f) | 0x40; |
| 6546 | 7184 | else |
| r5997 | r5998 | |
| 6568 | 7206 | if ((offset & 0x7fff) == 0) |
| 6569 | 7207 | return; |
| 6570 | 7208 | |
| 6571 | | data = data |(memory_read_byte(space, offset) & 1); |
| 7209 | data = data | (memory_read_byte(space, offset) & 1); |
| 6572 | 7210 | |
| 6573 | 7211 | chr8(space->machine, data >> 4, CHRROM); |
| 6574 | 7212 | prg32(space->machine, data & 0x07); |
| r5997 | r5998 | |
| 6638 | 7276 | { |
| 6639 | 7277 | LOG_MMC(("mapper147_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6640 | 7278 | |
| 6641 | | mapper147_l_w(space, offset + 0x100, data); |
| 7279 | mapper147_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6642 | 7280 | } |
| 6643 | 7281 | |
| 6644 | 7282 | static WRITE8_HANDLER( mapper147_w ) |
| 6645 | 7283 | { |
| 6646 | 7284 | LOG_MMC(("mapper147_w, offset: %04x, data: %02x\n", offset, data)); |
| 6647 | 7285 | |
| 6648 | | mapper147_l_w(space, offset + 0x100, data); |
| 7286 | mapper147_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6649 | 7287 | } |
| 6650 | 7288 | |
| 6651 | 7289 | /************************************************************* |
| r5997 | r5998 | |
| 6706 | 7344 | { |
| 6707 | 7345 | LOG_MMC(("mapper150_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 6708 | 7346 | |
| 6709 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 6710 | | but 0x4100 is offset = 0 */ |
| 7347 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 6711 | 7348 | if (!(offset & 0x100)) |
| 6712 | 7349 | { |
| 6713 | 7350 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 6757 | 7394 | { |
| 6758 | 7395 | LOG_MMC(("mapper150_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 6759 | 7396 | |
| 6760 | | mapper150_l_w(space, offset + 0x100, data); |
| 7397 | mapper150_l_w(space, (offset + 0x100) & 0xfff, data); |
| 6761 | 7398 | } |
| 6762 | 7399 | |
| 6763 | 7400 | /************************************************************* |
| r5997 | r5998 | |
| 6800 | 7437 | Games: Dragon Ball, Dragon Ball 3, Famicom Jump, Famicom |
| 6801 | 7438 | Jump II |
| 6802 | 7439 | |
| 6803 | | In MESS: Unsupported. |
| 7440 | This mapper should be exactly like Mapper 16, but with |
| 7441 | SRAM in place of EEPROM. Hence, writes to 0x6000-0x7fff |
| 7442 | go to SRAM (not sure if there exist boards with no SRAM |
| 7443 | and no EEPROM... investigate!) |
| 7444 | Famicom Jump II uses a different board (or uses the same |
| 7445 | board in a very different way) |
| 6804 | 7446 | |
| 7447 | In MESS: Supported. |
| 7448 | |
| 6805 | 7449 | *************************************************************/ |
| 6806 | 7450 | |
| 7451 | static void mapper153_set_prg( running_machine *machine ) |
| 7452 | { |
| 7453 | UINT8 mmc_helper = 0; |
| 7454 | int i; |
| 7455 | |
| 7456 | for (i = 0; i < 8; i++) |
| 7457 | mmc_helper |= ((map153_reg[i] & 0x01) << 4); |
| 7458 | |
| 7459 | map153_bank_latch = mmc_helper | (map153_bank_latch & 0x0f); |
| 7460 | |
| 7461 | prg16_89ab(machine, map153_bank_latch); |
| 7462 | prg16_cdef(machine, mmc_helper | 0x0f); |
| 7463 | } |
| 7464 | |
| 7465 | static WRITE8_HANDLER( mapper153_m_w ) |
| 7466 | { |
| 7467 | LOG_MMC(("mapper153_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 7468 | |
| 7469 | if (nes.crc_hack) // Famicom Jump II uses a different board |
| 7470 | { |
| 7471 | switch (offset & 0x0f) // there is no CHRROM and prg banking works differently |
| 7472 | { |
| 7473 | case 0: case 1: |
| 7474 | case 2: case 3: |
| 7475 | case 4: case 5: |
| 7476 | case 6: case 7: |
| 7477 | map153_reg[offset & 0x07] = data; |
| 7478 | mapper153_set_prg(space->machine); |
| 7479 | break; |
| 7480 | case 8: |
| 7481 | map153_bank_latch = (data & 0x0f) | (map153_bank_latch & 0x10); |
| 7482 | prg16_89ab(space->machine, map153_bank_latch); |
| 7483 | break; |
| 7484 | default: |
| 7485 | mapper16_m_w(space, offset & 0x0f, data); |
| 7486 | break; |
| 7487 | } |
| 7488 | } |
| 7489 | else |
| 7490 | mapper16_m_w(space, offset, data); |
| 7491 | } |
| 7492 | |
| 7493 | static WRITE8_HANDLER( mapper153_w ) |
| 7494 | { |
| 7495 | LOG_MMC(("mapper153_w, offset: %04x, data: %02x\n", offset, data)); |
| 7496 | |
| 7497 | mapper153_w(space, offset, data); |
| 7498 | } |
| 7499 | |
| 6807 | 7500 | /************************************************************* |
| 6808 | 7501 | |
| 6809 | 7502 | Mapper 154 |
| r5997 | r5998 | |
| 6823 | 7516 | switch (offset & 1) |
| 6824 | 7517 | { |
| 6825 | 7518 | case 0: |
| 6826 | | { |
| 6827 | | set_nt_mirroring((data & 0x40) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); |
| 6828 | | mmc_cmd1 = data & 7; |
| 6829 | | break; |
| 6830 | | } |
| 7519 | set_nt_mirroring((data & 0x40) ? PPU_MIRROR_HIGH : PPU_MIRROR_LOW); |
| 7520 | mmc_cmd1 = data & 7; |
| 7521 | break; |
| 6831 | 7522 | case 1: |
| 7523 | switch (mmc_cmd1) |
| 6832 | 7524 | { |
| 6833 | | switch (mmc_cmd1) |
| 6834 | | { |
| 6835 | | case 0: chr2_0(space->machine, data >> 1, CHRROM); break; |
| 6836 | | case 1: chr2_2(space->machine, data >> 1, CHRROM); break; |
| 6837 | | case 2: chr1_4(space->machine, data | 0x40, CHRROM); break; |
| 6838 | | case 3: chr1_5(space->machine, data | 0x40, CHRROM); break; |
| 6839 | | case 4: chr1_6(space->machine, data | 0x40, CHRROM); break; |
| 6840 | | case 5: chr1_7(space->machine, data | 0x40, CHRROM); break; |
| 6841 | | case 6: prg8_89(space->machine, data); break; |
| 6842 | | case 7: prg8_ab(space->machine, data); break; |
| 6843 | | } |
| 6844 | | break; |
| 7525 | case 0: chr2_0(space->machine, data >> 1, CHRROM); break; |
| 7526 | case 1: chr2_2(space->machine, data >> 1, CHRROM); break; |
| 7527 | case 2: chr1_4(space->machine, data | 0x40, CHRROM); break; |
| 7528 | case 3: chr1_5(space->machine, data | 0x40, CHRROM); break; |
| 7529 | case 4: chr1_6(space->machine, data | 0x40, CHRROM); break; |
| 7530 | case 5: chr1_7(space->machine, data | 0x40, CHRROM); break; |
| 7531 | case 6: prg8_89(space->machine, data); break; |
| 7532 | case 7: prg8_ab(space->machine, data); break; |
| 6845 | 7533 | } |
| 7534 | break; |
| 6846 | 7535 | } |
| 6847 | 7536 | } |
| 6848 | 7537 | |
| r5997 | r5998 | |
| 6915 | 7604 | Known Boards: Bandai Datach Board |
| 6916 | 7605 | Games: Datach Games |
| 6917 | 7606 | |
| 6918 | | In MESS: Unsupported. Needs reads from 0x6000-0x7fff for the |
| 6919 | | Datach barcode reader |
| 7607 | This mapper is basically Mapper 16 + Datach reader. We |
| 7608 | currently do not support the Barcode reader. |
| 6920 | 7609 | |
| 7610 | In MESS: Partially supported. Needs reads from 0x6000-0x7fff |
| 7611 | for the Datach barcode reader |
| 7612 | |
| 6921 | 7613 | *************************************************************/ |
| 6922 | 7614 | |
| 6923 | 7615 | /************************************************************* |
| r5997 | r5998 | |
| 6927 | 7619 | Known Boards: Tengen 800037 |
| 6928 | 7620 | Games: Alien Syndrome |
| 6929 | 7621 | |
| 6930 | | In MESS: Unsupported. |
| 7622 | In MESS: Very preliminary support. |
| 6931 | 7623 | |
| 6932 | 7624 | *************************************************************/ |
| 6933 | 7625 | |
| 7626 | // probably wrong... |
| 7627 | static void mapper158_set_mirror( running_machine *machine ) |
| 7628 | { |
| 7629 | UINT8 nt_mode = mmc_cmd1 & 0x80; |
| 7630 | |
| 7631 | set_nt_page(0, ROM, vrom_bank[nt_mode ? 2 : 0], 0); |
| 7632 | set_nt_page(1, ROM, vrom_bank[nt_mode ? 3 : 0], 0); |
| 7633 | set_nt_page(2, ROM, vrom_bank[nt_mode ? 4 : 1], 0); |
| 7634 | set_nt_page(3, ROM, vrom_bank[nt_mode ? 5 : 1], 0); |
| 7635 | } |
| 7636 | |
| 7637 | static WRITE8_HANDLER( mapper158_w ) |
| 7638 | { |
| 7639 | UINT8 map158_helper, cmd; |
| 7640 | LOG_MMC(("mapper158_w offset: %04x, data: %02x\n", offset, data)); |
| 7641 | |
| 7642 | switch (offset & 0x6001) |
| 7643 | { |
| 7644 | case 0x0000: |
| 7645 | map158_helper = mmc_cmd1 ^ data; |
| 7646 | mmc_cmd1 = data; |
| 7647 | |
| 7648 | /* Has PRG Mode changed? */ |
| 7649 | if (map158_helper & 0x40) |
| 7650 | mapper64_set_prg(space->machine); |
| 7651 | |
| 7652 | /* Has CHR Mode changed? */ |
| 7653 | if (map158_helper & 0xa0) |
| 7654 | { |
| 7655 | mapper64_set_chr(space->machine); |
| 7656 | mapper158_set_mirror(space->machine); |
| 7657 | } |
| 7658 | break; |
| 7659 | |
| 7660 | case 0x0001: |
| 7661 | cmd = mmc_cmd1 & 0x0f; |
| 7662 | switch (cmd) |
| 7663 | { |
| 7664 | case 0: case 1: |
| 7665 | case 2: case 3: |
| 7666 | case 4: case 5: |
| 7667 | vrom_bank[cmd] = data; |
| 7668 | mapper64_set_chr(space->machine); |
| 7669 | mapper158_set_mirror(space->machine); |
| 7670 | break; |
| 7671 | case 6: case 7: |
| 7672 | prg_bank[cmd - 6] = data; |
| 7673 | mapper64_set_prg(space->machine); |
| 7674 | break; |
| 7675 | case 8: case 9: |
| 7676 | vrom_bank[cmd - 2] = data; |
| 7677 | mapper64_set_chr(space->machine); |
| 7678 | mapper158_set_mirror(space->machine); |
| 7679 | break; |
| 7680 | case 0x0f: |
| 7681 | prg_bank[2] = data; |
| 7682 | mapper64_set_prg(space->machine); |
| 7683 | break; |
| 7684 | } |
| 7685 | break; |
| 7686 | |
| 7687 | case 0x2000: |
| 7688 | break; |
| 7689 | |
| 7690 | default: |
| 7691 | mapper64_w(space, offset, data); |
| 7692 | break; |
| 7693 | } |
| 7694 | } |
| 7695 | |
| 6934 | 7696 | /************************************************************* |
| 6935 | 7697 | |
| 6936 | 7698 | Mapper 159 |
| r5997 | r5998 | |
| 6938 | 7700 | Known Boards: Bandai Board |
| 6939 | 7701 | Games: Dragon Ball Z, Magical Taruruuto-kun, SD Gundam Gaiden |
| 6940 | 7702 | |
| 6941 | | In MESS: Unsupported. |
| 7703 | This is exactly like Mapper 16, but with different EEPROM I/O. |
| 7704 | At the moment we don't support EEPROM in either mapper. |
| 6942 | 7705 | |
| 7706 | In MESS: Supported. |
| 7707 | |
| 6943 | 7708 | *************************************************************/ |
| 6944 | 7709 | |
| 6945 | 7710 | /************************************************************* |
| r5997 | r5998 | |
| 7349 | 8114 | static WRITE8_HANDLER( mapper179_l_w ) |
| 7350 | 8115 | { |
| 7351 | 8116 | LOG_MMC(("mapper179_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8117 | offset += 0x4100; |
| 7352 | 8118 | |
| 7353 | | if ((offset - 0x100) & 0x1000) |
| 8119 | if (offset & 0x5000) |
| 7354 | 8120 | prg32(space->machine, data >> 1); |
| 7355 | 8121 | } |
| 7356 | 8122 | |
| r5997 | r5998 | |
| 7447 | 8213 | } |
| 7448 | 8214 | break; |
| 7449 | 8215 | case 0x6003: |
| 7450 | | IRQ_count = data; |
| 7451 | | IRQ_enable = 1; |
| 7452 | | break; |
| 7453 | | } |
| 7454 | | } |
| 7455 | | |
| 7456 | | static void mapper182_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 7457 | | { |
| 7458 | | if ((scanline < PPU_BOTTOM_VISIBLE_SCANLINE) /*|| (scanline == ppu_scanlines_per_frame-1)*/) |
| 7459 | | { |
| 7460 | | int priorCount = IRQ_count; |
| 7461 | | if ((IRQ_count == 0) || IRQ_reload) |
| 8216 | if (data) |
| 7462 | 8217 | { |
| 7463 | | IRQ_count = IRQ_count_latch; |
| 7464 | | IRQ_reload = 0; |
| 8218 | IRQ_count = data; |
| 8219 | IRQ_enable = 1; |
| 7465 | 8220 | } |
| 7466 | 8221 | else |
| 7467 | | IRQ_count --; |
| 7468 | | |
| 7469 | | if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount) |
| 7470 | | { |
| 7471 | | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 7472 | | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 7473 | | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 7474 | | } |
| 8222 | IRQ_enable = 0; |
| 8223 | break; |
| 7475 | 8224 | } |
| 7476 | 8225 | } |
| 7477 | 8226 | |
| r5997 | r5998 | |
| 7516 | 8265 | Known Boards: CNROM |
| 7517 | 8266 | Games: B-Wings, Mighty Bomb Jack, Seicross, Spy vs. Spy |
| 7518 | 8267 | |
| 7519 | | In MESS: Unsupported. |
| 8268 | In MESS: Very Preliminar Support. We act like it is mapper 3 |
| 8269 | but we need to emulate the read back from 0x8000-0xfff! |
| 7520 | 8270 | |
| 7521 | 8271 | *************************************************************/ |
| 7522 | 8272 | |
| 8273 | static WRITE8_HANDLER( mapper185_w ) |
| 8274 | { |
| 8275 | LOG_MMC(("mapper3_w offset: %04x, data: %02x\n", offset, data)); |
| 8276 | |
| 8277 | chr8(space->machine, data, CHRROM); |
| 8278 | } |
| 8279 | |
| 7523 | 8280 | /************************************************************* |
| 7524 | 8281 | |
| 7525 | 8282 | Mapper 186 |
| r5997 | r5998 | |
| 7541 | 8298 | |
| 7542 | 8299 | MMC3 clone |
| 7543 | 8300 | |
| 7544 | | In MESS: Unsupported. |
| 8301 | In MESS: Preliminary Support. |
| 7545 | 8302 | |
| 7546 | 8303 | *************************************************************/ |
| 7547 | 8304 | |
| 8305 | static void mapper187_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 8306 | { |
| 8307 | UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0; |
| 8308 | |
| 8309 | if (!(mapper187_reg[0] & 0x80)) |
| 8310 | { |
| 8311 | prg8_89(machine, prg_base | (prg_bank[0 ^ prg_flip] & prg_mask)); |
| 8312 | prg8_ab(machine, prg_base | (prg_bank[1] & prg_mask)); |
| 8313 | prg8_cd(machine, prg_base | (prg_bank[2 ^ prg_flip] & prg_mask)); |
| 8314 | prg8_ef(machine, prg_base | (prg_bank[3] & prg_mask)); |
| 8315 | } |
| 8316 | } |
| 8317 | |
| 8318 | static void mapper187_set_chr( running_machine *machine, UINT8 chr, int chr_base, int chr_mask ) |
| 8319 | { |
| 8320 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 8321 | UINT8 new_base[8]; |
| 8322 | int i; |
| 8323 | |
| 8324 | for (i = 0; i < 8; i++) |
| 8325 | new_base[i] = ((i & 0x04) == chr_page)? (chr_base | 0x100) : chr_base; |
| 8326 | |
| 8327 | chr1_x(machine, chr_page ^ 0, new_base[0] | ((vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 8328 | chr1_x(machine, chr_page ^ 1, new_base[1] | ((vrom_bank[0] | 0x01) & chr_mask), chr); |
| 8329 | chr1_x(machine, chr_page ^ 2, new_base[2] | ((vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 8330 | chr1_x(machine, chr_page ^ 3, new_base[3] | ((vrom_bank[1] | 0x01) & chr_mask), chr); |
| 8331 | chr1_x(machine, chr_page ^ 4, new_base[4] | (vrom_bank[2] & chr_mask), chr); |
| 8332 | chr1_x(machine, chr_page ^ 5, new_base[5] | (vrom_bank[3] & chr_mask), chr); |
| 8333 | chr1_x(machine, chr_page ^ 6, new_base[6] | (vrom_bank[4] & chr_mask), chr); |
| 8334 | chr1_x(machine, chr_page ^ 7, new_base[7] | (vrom_bank[5] & chr_mask), chr); |
| 8335 | } |
| 8336 | |
| 8337 | static WRITE8_HANDLER( mapper187_l_w ) |
| 8338 | { |
| 8339 | UINT8 new_bank; |
| 8340 | LOG_MMC(("mapper187_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8341 | offset += 0x100; |
| 8342 | |
| 8343 | if (offset == 0x1000) |
| 8344 | { |
| 8345 | switch (data & 0x03) |
| 8346 | { |
| 8347 | case 0x00: |
| 8348 | case 0x01: |
| 8349 | mapper187_reg[1] = 0x83; |
| 8350 | break; |
| 8351 | case 0x02: |
| 8352 | mapper187_reg[1] = 0x42; |
| 8353 | break; |
| 8354 | case 0x03: |
| 8355 | mapper187_reg[1] = 0x00; |
| 8356 | break; |
| 8357 | } |
| 8358 | } |
| 8359 | |
| 8360 | if (!(offset <= 0x1000)) |
| 8361 | { |
| 8362 | mapper187_reg[0] = data; |
| 8363 | |
| 8364 | if (mapper187_reg[0] & 0x80) |
| 8365 | { |
| 8366 | new_bank = (mapper187_reg[0] & 0x1f); |
| 8367 | |
| 8368 | if (mapper187_reg[0] & 0x20) |
| 8369 | prg32(space->machine, new_bank >> 2); |
| 8370 | else |
| 8371 | { |
| 8372 | prg16_89ab(space->machine, new_bank); |
| 8373 | prg16_cdef(space->machine, new_bank); |
| 8374 | } |
| 8375 | } |
| 8376 | else |
| 8377 | mapper187_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8378 | } |
| 8379 | } |
| 8380 | |
| 8381 | static READ8_HANDLER( mapper187_l_r ) |
| 8382 | { |
| 8383 | LOG_MMC(("mapper187_l_r, offset: %04x\n", offset)); |
| 8384 | offset += 0x100; |
| 8385 | |
| 8386 | if (!(offset < 0x1000)) |
| 8387 | return mapper187_reg[1]; |
| 8388 | else |
| 8389 | return 0; |
| 8390 | } |
| 8391 | |
| 8392 | static WRITE8_HANDLER( mapper187_w ) |
| 8393 | { |
| 8394 | UINT8 MMC3_helper, cmd; |
| 8395 | LOG_MMC(("mapper187_w, offset: %04x, data: %02x\n", offset, data)); |
| 8396 | |
| 8397 | switch (offset & 0x6003) |
| 8398 | { |
| 8399 | case 0x0000: |
| 8400 | mapper187_reg[2] = 1; |
| 8401 | MMC3_helper = mmc_cmd1 ^ data; |
| 8402 | mmc_cmd1 = data; |
| 8403 | |
| 8404 | /* Has PRG Mode changed? */ |
| 8405 | if (MMC3_helper & 0x40) |
| 8406 | mapper187_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8407 | |
| 8408 | /* Has CHR Mode changed? */ |
| 8409 | if (MMC3_helper & 0x80) |
| 8410 | mapper187_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8411 | break; |
| 8412 | |
| 8413 | case 0x0001: |
| 8414 | if (mapper187_reg[2]) |
| 8415 | { |
| 8416 | cmd = mmc_cmd1 & 0x07; |
| 8417 | switch (cmd) |
| 8418 | { |
| 8419 | case 0: case 1: |
| 8420 | case 2: case 3: case 4: case 5: |
| 8421 | vrom_bank[cmd] = data; |
| 8422 | mapper187_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8423 | break; |
| 8424 | case 6: |
| 8425 | case 7: |
| 8426 | prg_bank[cmd - 6] = data; |
| 8427 | mapper187_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8428 | break; |
| 8429 | } |
| 8430 | } |
| 8431 | break; |
| 8432 | |
| 8433 | case 0x0002: |
| 8434 | break; |
| 8435 | |
| 8436 | case 0x0003: |
| 8437 | mapper187_reg[2] = 0; |
| 8438 | |
| 8439 | if (data == 0x28) |
| 8440 | prg8_cd(space->machine, 0x17); |
| 8441 | else if (data == 0x2a) |
| 8442 | prg8_ab(space->machine, 0x0f); |
| 8443 | break; |
| 8444 | |
| 8445 | default: |
| 8446 | mapper4_w(space, offset, data); |
| 8447 | break; |
| 8448 | } |
| 8449 | } |
| 8450 | |
| 7548 | 8451 | /************************************************************* |
| 7549 | 8452 | |
| 7550 | 8453 | Mapper 188 |
| r5997 | r5998 | |
| 7572 | 8475 | |
| 7573 | 8476 | MMC3 clone |
| 7574 | 8477 | |
| 7575 | | In MESS: Unsupported. |
| 8478 | In MESS: Supported. |
| 7576 | 8479 | |
| 7577 | 8480 | *************************************************************/ |
| 7578 | 8481 | |
| 8482 | static WRITE8_HANDLER( mapper189_l_w ) |
| 8483 | { |
| 8484 | LOG_MMC(("mapper189_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8485 | |
| 8486 | prg32(space->machine, (data >> 4) | data); |
| 8487 | } |
| 8488 | |
| 8489 | static WRITE8_HANDLER( mapper189_m_w ) |
| 8490 | { |
| 8491 | LOG_MMC(("mapper189_m_w, offset: %04x, data: %04x\n", offset, data)); |
| 8492 | |
| 8493 | mapper189_l_w(space, offset & 0xff, data); // offset does not really count for this mapper |
| 8494 | } |
| 8495 | |
| 8496 | /* This is like mapper4 but with no PRG bankswitch (beacuse it is handled by low writes) */ |
| 8497 | static WRITE8_HANDLER( mapper189_w ) |
| 8498 | { |
| 8499 | UINT8 MMC3_helper, cmd; |
| 8500 | LOG_MMC(("mapper189_w, offset: %04x, data: %02x\n", offset, data)); |
| 8501 | |
| 8502 | switch (offset & 0x6001) |
| 8503 | { |
| 8504 | case 0x0000: |
| 8505 | MMC3_helper = mmc_cmd1 ^ data; |
| 8506 | mmc_cmd1 = data; |
| 8507 | |
| 8508 | /* Has CHR Mode changed? */ |
| 8509 | if (MMC3_helper & 0x80) |
| 8510 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8511 | break; |
| 8512 | |
| 8513 | case 0x0001: |
| 8514 | cmd = mmc_cmd1 & 0x07; |
| 8515 | switch (cmd) |
| 8516 | { |
| 8517 | case 0: case 1: |
| 8518 | case 2: case 3: case 4: case 5: |
| 8519 | vrom_bank[cmd] = data; |
| 8520 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8521 | break; |
| 8522 | } |
| 8523 | break; |
| 8524 | |
| 8525 | default: |
| 8526 | mapper4_w(space, offset, data); |
| 8527 | break; |
| 8528 | } |
| 8529 | } |
| 8530 | |
| 7579 | 8531 | /************************************************************* |
| 7580 | 8532 | |
| 7581 | 8533 | Mapper 190 |
| r5997 | r5998 | |
| 7594 | 8546 | Known Boards: Type B by Waixing |
| 7595 | 8547 | Games: Sugoro Quest (C) |
| 7596 | 8548 | |
| 7597 | | MMC3 clone |
| 8549 | MMC3 clone. This is a minor modification of Mapper 74, |
| 8550 | in the sense that it is the same board except for the |
| 8551 | CHRRAM pages. |
| 7598 | 8552 | |
| 7599 | | In MESS: Unsupported. |
| 8553 | In MESS: Supported. |
| 7600 | 8554 | |
| 7601 | 8555 | *************************************************************/ |
| 7602 | 8556 | |
| 8557 | static void mapper191_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8558 | { |
| 8559 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 8560 | UINT8 chr_src[6]; |
| 8561 | int i; |
| 8562 | |
| 8563 | for (i = 0; i < 6; i++) |
| 8564 | chr_src[i] = (vrom_bank[i] & 0x80) ? CHRRAM : CHRROM; |
| 8565 | |
| 8566 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 8567 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 8568 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 8569 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 8570 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 8571 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 8572 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 8573 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 8574 | } |
| 8575 | |
| 8576 | static WRITE8_HANDLER( mapper191_w ) |
| 8577 | { |
| 8578 | UINT8 MMC3_helper, cmd; |
| 8579 | LOG_MMC(("mapper191_w, offset: %04x, data: %02x\n", offset, data)); |
| 8580 | |
| 8581 | switch (offset & 0x6001) |
| 8582 | { |
| 8583 | case 0x0000: |
| 8584 | MMC3_helper = mmc_cmd1 ^ data; |
| 8585 | mmc_cmd1 = data; |
| 8586 | |
| 8587 | /* Has PRG Mode changed? */ |
| 8588 | if (MMC3_helper & 0x40) |
| 8589 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8590 | |
| 8591 | /* Has CHR Mode changed? */ |
| 8592 | if (MMC3_helper & 0x80) |
| 8593 | mapper191_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8594 | break; |
| 8595 | |
| 8596 | case 0x0001: |
| 8597 | cmd = mmc_cmd1 & 0x07; |
| 8598 | switch (cmd) |
| 8599 | { |
| 8600 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8601 | case 2: case 3: case 4: case 5: |
| 8602 | vrom_bank[cmd] = data; |
| 8603 | mapper191_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8604 | break; |
| 8605 | case 6: |
| 8606 | case 7: |
| 8607 | prg_bank[cmd - 6] = data; |
| 8608 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8609 | break; |
| 8610 | } |
| 8611 | break; |
| 8612 | |
| 8613 | default: |
| 8614 | mapper74_w(space, offset, data); |
| 8615 | break; |
| 8616 | } |
| 8617 | } |
| 8618 | |
| 7603 | 8619 | /************************************************************* |
| 7604 | 8620 | |
| 7605 | 8621 | Mapper 192 |
| r5997 | r5998 | |
| 7607 | 8623 | Known Boards: Type C by Waixing |
| 7608 | 8624 | Games: Ying Lie Qun Xia Zhuan, Young Chivalry |
| 7609 | 8625 | |
| 7610 | | MMC3 clone |
| 8626 | MMC3 clone. This is a minor modification of Mapper 74, |
| 8627 | in the sense that it is the same board except for the |
| 8628 | CHRRAM pages. |
| 7611 | 8629 | |
| 7612 | | In MESS: Unsupported. |
| 8630 | In MESS: Supported. |
| 7613 | 8631 | |
| 7614 | 8632 | *************************************************************/ |
| 7615 | 8633 | |
| 8634 | static void mapper192_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8635 | { |
| 8636 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 8637 | UINT8 chr_src[6]; |
| 8638 | int i; |
| 8639 | |
| 8640 | for (i = 0; i < 6; i++) |
| 8641 | chr_src[i] = ((vrom_bank[i] == 0x08) || (vrom_bank[i] == 0x09) || (vrom_bank[i] == 0x0a) || (vrom_bank[i] == 0x0b)) ? CHRRAM : CHRROM; |
| 8642 | |
| 8643 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 8644 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 8645 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 8646 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 8647 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 8648 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 8649 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 8650 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 8651 | } |
| 8652 | |
| 8653 | static WRITE8_HANDLER( mapper192_w ) |
| 8654 | { |
| 8655 | UINT8 MMC3_helper, cmd; |
| 8656 | LOG_MMC(("mapper192_w, offset: %04x, data: %02x\n", offset, data)); |
| 8657 | |
| 8658 | switch (offset & 0x6001) |
| 8659 | { |
| 8660 | case 0x0000: |
| 8661 | MMC3_helper = mmc_cmd1 ^ data; |
| 8662 | mmc_cmd1 = data; |
| 8663 | |
| 8664 | /* Has PRG Mode changed? */ |
| 8665 | if (MMC3_helper & 0x40) |
| 8666 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8667 | |
| 8668 | /* Has CHR Mode changed? */ |
| 8669 | if (MMC3_helper & 0x80) |
| 8670 | mapper192_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8671 | break; |
| 8672 | |
| 8673 | case 0x0001: |
| 8674 | cmd = mmc_cmd1 & 0x07; |
| 8675 | switch (cmd) |
| 8676 | { |
| 8677 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8678 | case 2: case 3: case 4: case 5: |
| 8679 | vrom_bank[cmd] = data; |
| 8680 | mapper192_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8681 | break; |
| 8682 | case 6: |
| 8683 | case 7: |
| 8684 | prg_bank[cmd - 6] = data; |
| 8685 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8686 | break; |
| 8687 | } |
| 8688 | break; |
| 8689 | |
| 8690 | default: |
| 8691 | mapper74_w(space, offset, data); |
| 8692 | break; |
| 8693 | } |
| 8694 | } |
| 8695 | |
| 7616 | 8696 | /************************************************************* |
| 7617 | 8697 | |
| 7618 | 8698 | Mapper 193 |
| r5997 | r5998 | |
| 7655 | 8735 | Known Boards: Type D by Waixing |
| 7656 | 8736 | Games: Super Robot Taisen (C) |
| 7657 | 8737 | |
| 7658 | | MMC3 clone |
| 8738 | MMC3 clone. This is a minor modification of Mapper 74, |
| 8739 | in the sense that it is the same board except for the |
| 8740 | CHRRAM pages. |
| 7659 | 8741 | |
| 7660 | | In MESS: Unsupported. |
| 8742 | In MESS: Supported. |
| 7661 | 8743 | |
| 7662 | 8744 | *************************************************************/ |
| 7663 | 8745 | |
| 8746 | static void mapper194_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8747 | { |
| 8748 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 8749 | UINT8 chr_src[6]; |
| 8750 | int i; |
| 8751 | |
| 8752 | for (i = 0; i < 6; i++) |
| 8753 | chr_src[i] = (vrom_bank[i] < 0x02) ? CHRRAM : CHRROM; |
| 8754 | |
| 8755 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 8756 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 8757 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 8758 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 8759 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 8760 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 8761 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 8762 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 8763 | } |
| 8764 | |
| 8765 | static WRITE8_HANDLER( mapper194_w ) |
| 8766 | { |
| 8767 | UINT8 MMC3_helper, cmd; |
| 8768 | LOG_MMC(("mapper194_w, offset: %04x, data: %02x\n", offset, data)); |
| 8769 | |
| 8770 | switch (offset & 0x6001) |
| 8771 | { |
| 8772 | case 0x0000: |
| 8773 | MMC3_helper = mmc_cmd1 ^ data; |
| 8774 | mmc_cmd1 = data; |
| 8775 | |
| 8776 | /* Has PRG Mode changed? */ |
| 8777 | if (MMC3_helper & 0x40) |
| 8778 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8779 | |
| 8780 | /* Has CHR Mode changed? */ |
| 8781 | if (MMC3_helper & 0x80) |
| 8782 | mapper194_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8783 | break; |
| 8784 | |
| 8785 | case 0x0001: |
| 8786 | cmd = mmc_cmd1 & 0x07; |
| 8787 | switch (cmd) |
| 8788 | { |
| 8789 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8790 | case 2: case 3: case 4: case 5: |
| 8791 | vrom_bank[cmd] = data; |
| 8792 | mapper194_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8793 | break; |
| 8794 | case 6: |
| 8795 | case 7: |
| 8796 | prg_bank[cmd - 6] = data; |
| 8797 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8798 | break; |
| 8799 | } |
| 8800 | break; |
| 8801 | |
| 8802 | default: |
| 8803 | mapper74_w(space, offset, data); |
| 8804 | break; |
| 8805 | } |
| 8806 | } |
| 8807 | |
| 7664 | 8808 | /************************************************************* |
| 7665 | 8809 | |
| 7666 | 8810 | Mapper 195 |
| r5997 | r5998 | |
| 7669 | 8813 | Games: Captain Tsubasa Vol. II (C), Chaos World, God |
| 7670 | 8814 | Slayer (C), Zu Qiu Xiao Jiang |
| 7671 | 8815 | |
| 7672 | | MMC3 clone |
| 8816 | MMC3 clone. This is a minor modification of Mapper 74, |
| 8817 | in the sense that it is the same board except for the |
| 8818 | CHRRAM pages. |
| 7673 | 8819 | |
| 7674 | | In MESS: Unsupported. |
| 8820 | In MESS: Supported. |
| 7675 | 8821 | |
| 7676 | 8822 | *************************************************************/ |
| 7677 | 8823 | |
| 8824 | static void mapper195_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8825 | { |
| 8826 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 8827 | UINT8 chr_src[6]; |
| 8828 | int i; |
| 8829 | |
| 8830 | for (i = 0; i < 6; i++) |
| 8831 | chr_src[i] = (vrom_bank[i] < 0x04) ? CHRRAM : CHRROM; |
| 8832 | |
| 8833 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 8834 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 8835 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 8836 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 8837 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 8838 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 8839 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 8840 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 8841 | } |
| 8842 | |
| 8843 | static WRITE8_HANDLER( mapper195_w ) |
| 8844 | { |
| 8845 | UINT8 MMC3_helper, cmd; |
| 8846 | LOG_MMC(("mapper195_w, offset: %04x, data: %02x\n", offset, data)); |
| 8847 | |
| 8848 | switch (offset & 0x6001) |
| 8849 | { |
| 8850 | case 0x0000: |
| 8851 | MMC3_helper = mmc_cmd1 ^ data; |
| 8852 | mmc_cmd1 = data; |
| 8853 | |
| 8854 | /* Has PRG Mode changed? */ |
| 8855 | if (MMC3_helper & 0x40) |
| 8856 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8857 | |
| 8858 | /* Has CHR Mode changed? */ |
| 8859 | if (MMC3_helper & 0x80) |
| 8860 | mapper195_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8861 | break; |
| 8862 | |
| 8863 | case 0x0001: |
| 8864 | cmd = mmc_cmd1 & 0x07; |
| 8865 | switch (cmd) |
| 8866 | { |
| 8867 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8868 | case 2: case 3: case 4: case 5: |
| 8869 | vrom_bank[cmd] = data; |
| 8870 | mapper195_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 8871 | break; |
| 8872 | case 6: |
| 8873 | case 7: |
| 8874 | prg_bank[cmd - 6] = data; |
| 8875 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8876 | break; |
| 8877 | } |
| 8878 | break; |
| 8879 | |
| 8880 | default: |
| 8881 | mapper74_w(space, offset, data); |
| 8882 | break; |
| 8883 | } |
| 8884 | } |
| 8885 | |
| 7678 | 8886 | /************************************************************* |
| 7679 | 8887 | |
| 7680 | 8888 | Mapper 196 |
| r5997 | r5998 | |
| 7693 | 8901 | { |
| 7694 | 8902 | LOG_MMC(("mapper196_w, offset: %04x, data: %02x\n", offset, data)); |
| 7695 | 8903 | |
| 7696 | | switch (offset & 0x6004) |
| 7697 | | { |
| 7698 | | case 0x0000: |
| 7699 | | mapper4_w(space, 0x0000, data); |
| 7700 | | break; |
| 7701 | | case 0x0004: |
| 7702 | | mapper4_w(space, 0x0001, data); |
| 7703 | | break; |
| 7704 | | case 0x2000: |
| 7705 | | set_nt_mirroring(data & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); // diff with MMC3: not check for data & 0x40 |
| 7706 | | break; |
| 7707 | | case 0x2004: |
| 7708 | | mapper4_w(space, 0x2001, data); |
| 7709 | | break; |
| 7710 | | case 0x4000: |
| 7711 | | mapper4_w(space, 0x4000, data); |
| 7712 | | break; |
| 7713 | | case 0x4004: |
| 7714 | | mapper4_w(space, 0x4001, data); |
| 7715 | | break; |
| 7716 | | case 0x6000: |
| 7717 | | mapper4_w(space, 0x6000, data); |
| 7718 | | break; |
| 7719 | | case 0x6004: |
| 7720 | | mapper4_w(space, 0x6001, data); |
| 7721 | | break; |
| 7722 | | default: |
| 7723 | | break; |
| 7724 | | } |
| 8904 | mapper4_w(space, (offset & 0x6000) | ((offset & 0x04) >> 2), data); |
| 7725 | 8905 | } |
| 7726 | 8906 | |
| 7727 | 8907 | /************************************************************* |
| r5997 | r5998 | |
| 7733 | 8913 | |
| 7734 | 8914 | MMC3 clone |
| 7735 | 8915 | |
| 7736 | | In MESS: Unsupported. |
| 8916 | In MESS: Supported. |
| 7737 | 8917 | |
| 7738 | 8918 | *************************************************************/ |
| 7739 | 8919 | |
| 8920 | static void mapper197_set_chr( running_machine *machine, UINT8 chr_source, int chr_base, int chr_mask ) |
| 8921 | { |
| 8922 | chr4_0(machine, chr_base | ((vrom_bank[0] >> 1) & chr_mask), chr_source); |
| 8923 | chr2_4(machine, chr_base | (vrom_bank[1] & chr_mask), chr_source); |
| 8924 | chr2_6(machine, chr_base | (vrom_bank[2] & chr_mask), chr_source); |
| 8925 | } |
| 8926 | |
| 8927 | static WRITE8_HANDLER( mapper197_w ) |
| 8928 | { |
| 8929 | UINT8 MMC3_helper, cmd; |
| 8930 | LOG_MMC(("mapper197_w, offset: %04x, data: %02x\n", offset, data)); |
| 8931 | |
| 8932 | switch (offset & 0x6001) |
| 8933 | { |
| 8934 | case 0x0000: |
| 8935 | MMC3_helper = mmc_cmd1 ^ data; |
| 8936 | mmc_cmd1 = data; |
| 8937 | |
| 8938 | /* Has PRG Mode changed? */ |
| 8939 | if (MMC3_helper & 0x40) |
| 8940 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8941 | |
| 8942 | /* Has CHR Mode changed? */ |
| 8943 | if (MMC3_helper & 0x80) |
| 8944 | mapper197_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8945 | break; |
| 8946 | |
| 8947 | case 0x0001: |
| 8948 | cmd = mmc_cmd1 & 0x0f; |
| 8949 | switch (cmd) |
| 8950 | { |
| 8951 | case 0: case 2: case 4: |
| 8952 | vrom_bank[cmd >> 1] = data; |
| 8953 | mapper197_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 8954 | break; |
| 8955 | case 6: |
| 8956 | case 7: |
| 8957 | prg_bank[cmd - 6] = data; |
| 8958 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 8959 | break; |
| 8960 | } |
| 8961 | break; |
| 8962 | |
| 8963 | default: |
| 8964 | mapper4_w(space, offset, data); |
| 8965 | break; |
| 8966 | } |
| 8967 | } |
| 8968 | |
| 7740 | 8969 | /************************************************************* |
| 7741 | 8970 | |
| 7742 | 8971 | Mapper 198 |
| r5997 | r5998 | |
| 7744 | 8973 | Known Boards: Type F by Waixing |
| 7745 | 8974 | Games: Tenchi wo Kurau II (C) |
| 7746 | 8975 | |
| 7747 | | MMC3 clone |
| 8976 | MMC3 clone. |
| 7748 | 8977 | |
| 7749 | | In MESS: Unsupported. |
| 8978 | In MESS: Preliminary support. |
| 7750 | 8979 | |
| 7751 | 8980 | *************************************************************/ |
| 7752 | 8981 | |
| 8982 | static void mapper198_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 8983 | { |
| 8984 | UINT8 prg_flip = (mmc_cmd1 & 0x40) ? 2 : 0; |
| 8985 | |
| 8986 | prg8_89(machine, prg_base | (prg_bank[0 ^ prg_flip] & prg_mask)); |
| 8987 | prg8_ab(machine, prg_base | (prg_bank[1] & prg_mask)); |
| 8988 | prg8_cd(machine, prg_base | (prg_bank[2 ^ prg_flip] & prg_mask)); |
| 8989 | prg8_ef(machine, prg_base | (prg_bank[3] & prg_mask)); |
| 8990 | } |
| 8991 | |
| 8992 | static WRITE8_HANDLER( mapper198_w ) |
| 8993 | { |
| 8994 | UINT8 MMC3_helper, cmd; |
| 8995 | LOG_MMC(("mapper198_w, offset: %04x, data: %02x\n", offset, data)); |
| 8996 | |
| 8997 | switch (offset & 0x6001) |
| 8998 | { |
| 8999 | case 0x0000: |
| 9000 | MMC3_helper = mmc_cmd1 ^ data; |
| 9001 | mmc_cmd1 = data; |
| 9002 | |
| 9003 | /* Has PRG Mode changed? */ |
| 9004 | if (MMC3_helper & 0x40) |
| 9005 | mapper198_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9006 | |
| 9007 | /* Has CHR Mode changed? */ |
| 9008 | if (MMC3_helper & 0x80) |
| 9009 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9010 | break; |
| 9011 | |
| 9012 | case 0x0001: |
| 9013 | cmd = mmc_cmd1 & 0x07; |
| 9014 | switch (cmd) |
| 9015 | { |
| 9016 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9017 | case 2: case 3: case 4: case 5: |
| 9018 | vrom_bank[cmd] = data; |
| 9019 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9020 | break; |
| 9021 | case 6: |
| 9022 | case 7: |
| 9023 | prg_bank[cmd - 6] = data & ((data > 0x3f) ? 0x4f : 0x3f); |
| 9024 | mapper198_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9025 | break; |
| 9026 | } |
| 9027 | break; |
| 9028 | |
| 9029 | default: |
| 9030 | mapper74_w(space, offset, data); |
| 9031 | break; |
| 9032 | } |
| 9033 | } |
| 9034 | |
| 7753 | 9035 | /************************************************************* |
| 7754 | 9036 | |
| 7755 | 9037 | Mapper 199 |
| r5997 | r5998 | |
| 7760 | 9042 | |
| 7761 | 9043 | MMC3 clone |
| 7762 | 9044 | |
| 7763 | | In MESS: Unsupported. |
| 9045 | In MESS: Supported. |
| 7764 | 9046 | |
| 7765 | 9047 | *************************************************************/ |
| 7766 | 9048 | |
| 9049 | static void mapper199_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 9050 | { |
| 9051 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 9052 | UINT8 chr_src[8]; |
| 9053 | int i; |
| 9054 | |
| 9055 | for (i = 0; i < 8; i++) |
| 9056 | chr_src[i] = (vrom_bank[i] < 0x08) ? CHRRAM : CHRROM; |
| 9057 | |
| 9058 | chr1_x(machine, chr_page ^ 0, chr_base | (vrom_bank[0] & chr_mask), chr_src[0]); |
| 9059 | chr1_x(machine, chr_page ^ 1, chr_base | (vrom_bank[6] & chr_mask), chr_src[6]); |
| 9060 | chr1_x(machine, chr_page ^ 2, chr_base | (vrom_bank[1] & chr_mask), chr_src[1]); |
| 9061 | chr1_x(machine, chr_page ^ 3, chr_base | (vrom_bank[7] & chr_mask), chr_src[7]); |
| 9062 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr_src[2]); |
| 9063 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr_src[3]); |
| 9064 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr_src[4]); |
| 9065 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr_src[5]); |
| 9066 | } |
| 9067 | |
| 9068 | static WRITE8_HANDLER( mapper199_w ) |
| 9069 | { |
| 9070 | UINT8 MMC3_helper, cmd; |
| 9071 | LOG_MMC(("mapper199_w, offset: %04x, data: %02x\n", offset, data)); |
| 9072 | |
| 9073 | switch (offset & 0x6001) |
| 9074 | { |
| 9075 | case 0x0000: |
| 9076 | MMC3_helper = mmc_cmd1 ^ data; |
| 9077 | mmc_cmd1 = data; |
| 9078 | |
| 9079 | /* Has PRG Mode changed? */ |
| 9080 | if (MMC3_helper & 0x40) |
| 9081 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9082 | |
| 9083 | /* Has CHR Mode changed? */ |
| 9084 | if (MMC3_helper & 0x80) |
| 9085 | mapper199_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 9086 | break; |
| 9087 | |
| 9088 | case 0x0001: |
| 9089 | cmd = mmc_cmd1 & 0x0f; |
| 9090 | switch (cmd) |
| 9091 | { |
| 9092 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9093 | case 2: case 3: case 4: case 5: |
| 9094 | vrom_bank[cmd] = data; |
| 9095 | mapper199_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 9096 | break; |
| 9097 | case 6: |
| 9098 | case 7: |
| 9099 | case 8: |
| 9100 | case 9: |
| 9101 | prg_bank[cmd - 6] = data; |
| 9102 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9103 | break; |
| 9104 | case 0x0a: case 0x0b: |
| 9105 | vrom_bank[cmd - 4] = data; |
| 9106 | mapper199_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 9107 | break; |
| 9108 | } |
| 9109 | break; |
| 9110 | |
| 9111 | default: |
| 9112 | mapper4_w(space, offset, data); |
| 9113 | break; |
| 9114 | } |
| 9115 | } |
| 9116 | |
| 7767 | 9117 | /************************************************************* |
| 7768 | 9118 | |
| 7769 | 9119 | Mapper 200 |
| r5997 | r5998 | |
| 7882 | 9232 | |
| 7883 | 9233 | MMC3 clone |
| 7884 | 9234 | |
| 7885 | | In MESS: Unsupported. |
| 9235 | In MESS: Supported. |
| 7886 | 9236 | |
| 7887 | 9237 | *************************************************************/ |
| 7888 | 9238 | |
| 9239 | static WRITE8_HANDLER( mapper205_m_w ) |
| 9240 | { |
| 9241 | LOG_MMC(("mapper205_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 9242 | |
| 9243 | if (offset & 0x0800) |
| 9244 | { |
| 9245 | mmc_prg_base = (data & 0x03) << 4; |
| 9246 | mmc_prg_mask = (data & 0x02) ? 0x0f : 0x1f; |
| 9247 | mmc_chr_base = (data & 0x03) << 7; |
| 9248 | mmc_chr_mask = (data & 0x02) ? 0x7f : 0xff; |
| 9249 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9250 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9251 | } |
| 9252 | } |
| 9253 | |
| 7889 | 9254 | /************************************************************* |
| 7890 | 9255 | |
| 7891 | 9256 | Mapper 206 |
| r5997 | r5998 | |
| 7986 | 9351 | |
| 7987 | 9352 | MMC3 clone. It also requires reads from 0x5000-0x7fff. |
| 7988 | 9353 | |
| 7989 | | In MESS: Unsupported. |
| 9354 | In MESS: Preliminary Support. |
| 7990 | 9355 | |
| 7991 | 9356 | *************************************************************/ |
| 7992 | 9357 | |
| 9358 | static WRITE8_HANDLER( mapper208_l_w ) |
| 9359 | { |
| 9360 | static const UINT8 conv_table[256] = |
| 9361 | { |
| 9362 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x49,0x19,0x09,0x59,0x49,0x19,0x09, |
| 9363 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x51,0x41,0x11,0x01,0x51,0x41,0x11,0x01, |
| 9364 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x49,0x19,0x09,0x59,0x49,0x19,0x09, |
| 9365 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x51,0x41,0x11,0x01,0x51,0x41,0x11,0x01, |
| 9366 | 0x00,0x10,0x40,0x50,0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9367 | 0x08,0x18,0x48,0x58,0x08,0x18,0x48,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9368 | 0x00,0x10,0x40,0x50,0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9369 | 0x08,0x18,0x48,0x58,0x08,0x18,0x48,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9370 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x58,0x48,0x18,0x08,0x58,0x48,0x18,0x08, |
| 9371 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x50,0x40,0x10,0x00,0x50,0x40,0x10,0x00, |
| 9372 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x58,0x48,0x18,0x08,0x58,0x48,0x18,0x08, |
| 9373 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x50,0x40,0x10,0x00,0x50,0x40,0x10,0x00, |
| 9374 | 0x01,0x11,0x41,0x51,0x01,0x11,0x41,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9375 | 0x09,0x19,0x49,0x59,0x09,0x19,0x49,0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9376 | 0x01,0x11,0x41,0x51,0x01,0x11,0x41,0x51,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 9377 | 0x09,0x19,0x49,0x59,0x09,0x19,0x49,0x59,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
| 9378 | }; |
| 9379 | |
| 9380 | LOG_MMC(("mapper208_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 9381 | |
| 9382 | if (!(offset < 0x1700)) |
| 9383 | map208_reg[offset & 0x03] = data ^ conv_table[map208_reg[4]]; |
| 9384 | else if (!(offset < 0xf00)) |
| 9385 | map208_reg[4] = data; |
| 9386 | else if (!(offset < 0x700)) |
| 9387 | prg32(space->machine, ((data >> 3) & 0x02) | (data & 0x01)); |
| 9388 | } |
| 9389 | |
| 9390 | static READ8_HANDLER( mapper208_l_r ) |
| 9391 | { |
| 9392 | LOG_MMC(("mapper208_l_r, offset: %04x\n", offset)); |
| 9393 | |
| 9394 | if (!(offset < 0x1700)) |
| 9395 | return map208_reg[offset & 0x03]; |
| 9396 | |
| 9397 | return 0x00; |
| 9398 | } |
| 9399 | |
| 9400 | /* This is like mapper4 but with no PRG bankswitch (beacuse it is handled by low writes) */ |
| 9401 | // replace with map189_w... they are the same!! |
| 9402 | static WRITE8_HANDLER( mapper208_w ) |
| 9403 | { |
| 9404 | UINT8 MMC3_helper, cmd; |
| 9405 | LOG_MMC(("mapper208_w, offset: %04x, data: %02x\n", offset, data)); |
| 9406 | |
| 9407 | switch (offset & 0x6001) |
| 9408 | { |
| 9409 | case 0x0000: |
| 9410 | MMC3_helper = mmc_cmd1 ^ data; |
| 9411 | mmc_cmd1 = data; |
| 9412 | |
| 9413 | /* Has CHR Mode changed? */ |
| 9414 | if (MMC3_helper & 0x80) |
| 9415 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9416 | break; |
| 9417 | |
| 9418 | case 0x0001: |
| 9419 | cmd = mmc_cmd1 & 0x07; |
| 9420 | switch (cmd) |
| 9421 | { |
| 9422 | case 0: case 1: |
| 9423 | case 2: case 3: case 4: case 5: |
| 9424 | vrom_bank[cmd] = data; |
| 9425 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9426 | break; |
| 9427 | } |
| 9428 | break; |
| 9429 | |
| 9430 | default: |
| 9431 | mapper4_w(space, offset, data); |
| 9432 | break; |
| 9433 | } |
| 9434 | } |
| 9435 | |
| 7993 | 9436 | /************************************************************* |
| 7994 | 9437 | |
| 7995 | 9438 | Mapper 209 |
| r5997 | r5998 | |
| 8009 | 9452 | Known Boards: Undocumented / Unused ?!? |
| 8010 | 9453 | Games: ---------- |
| 8011 | 9454 | |
| 9455 | For some emulators, this is the same as Mapper 19 but it |
| 9456 | has hardwired mirroring and no additional sound hardware. |
| 9457 | Initializing Mirroring to Vertical in Mapper 19 seems to |
| 9458 | fix all glitches in 'so-called' Mapper 210 games, so there |
| 9459 | seems to be no reason to have this duplicate mapper (at |
| 9460 | least until we emulate additional sound hardware... if sound |
| 9461 | writes would create conflicts, we might consider to split the |
| 9462 | mapper in two variants) |
| 9463 | |
| 8012 | 9464 | In MESS: ---------- |
| 8013 | 9465 | |
| 8014 | 9466 | *************************************************************/ |
| r5997 | r5998 | |
| 8100 | 9552 | MMC3 clone. Also, it probably needs a hack to support both |
| 8101 | 9553 | variants (Boogerman & MK3). |
| 8102 | 9554 | |
| 8103 | | In MESS: Unsupported. |
| 9555 | In MESS: Preliminary support. |
| 8104 | 9556 | |
| 8105 | 9557 | *************************************************************/ |
| 8106 | 9558 | |
| 9559 | // remove mask & base parameters! |
| 9560 | static void mapper215_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 9561 | { |
| 9562 | if (map215_reg[0] & 0x80) |
| 9563 | { |
| 9564 | prg16_89ab(machine, (map215_reg[0] & 0xf0) | (map215_reg[1] & 0x10)); |
| 9565 | prg16_cdef(machine, (map215_reg[0] & 0xf0) | (map215_reg[1] & 0x10)); |
| 9566 | } |
| 9567 | else |
| 9568 | { |
| 9569 | mmc_prg_base = (map215_reg[1] & 0x08) ? 0x20 : (map215_reg[1] & 0x10); |
| 9570 | mmc_prg_mask = (map215_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 9571 | |
| 9572 | mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask); |
| 9573 | } |
| 9574 | } |
| 9575 | |
| 9576 | static void mapper215_set_chr( running_machine *machine, UINT8 chr ) |
| 9577 | { |
| 9578 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 9579 | int chr_base = (map215_reg[1] & 0x04) ? 0x100 : ((map215_reg[1] & 0x10) << 3); |
| 9580 | int chr_mask = (map215_reg[1] & 0x04) ? 0xff : 0x7f; |
| 9581 | |
| 9582 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 9583 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr); |
| 9584 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 9585 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr); |
| 9586 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr); |
| 9587 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr); |
| 9588 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr); |
| 9589 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr); |
| 9590 | } |
| 9591 | |
| 9592 | static WRITE8_HANDLER( mapper215_l_w ) |
| 9593 | { |
| 9594 | LOG_MMC(("mapper215_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 9595 | offset += 0x100; |
| 9596 | |
| 9597 | if (offset == 0x1000) |
| 9598 | { |
| 9599 | map215_reg[0] = data; |
| 9600 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9601 | } |
| 9602 | else if (offset == 0x1001) |
| 9603 | { |
| 9604 | map215_reg[1] = data; |
| 9605 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9606 | } |
| 9607 | else if (offset == 0x1007) |
| 9608 | { |
| 9609 | mmc_cmd1 = 0; |
| 9610 | map215_reg[2] = data; |
| 9611 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9612 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9613 | } |
| 9614 | } |
| 9615 | |
| 9616 | static WRITE8_HANDLER( mapper215_w ) |
| 9617 | { |
| 9618 | UINT8 MMC3_helper, cmd; |
| 9619 | static const UINT8 conv_table[8] = {0,2,5,3,6,1,7,4}; |
| 9620 | LOG_MMC(("mapper215_w, offset: %04x, data: %02x\n", offset, data)); |
| 9621 | |
| 9622 | if (!map215_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers |
| 9623 | { |
| 9624 | switch (offset & 0x6001) |
| 9625 | { |
| 9626 | case 0x0000: |
| 9627 | MMC3_helper = mmc_cmd1 ^ data; |
| 9628 | mmc_cmd1 = data; |
| 9629 | |
| 9630 | /* Has PRG Mode changed? */ |
| 9631 | if (MMC3_helper & 0x40) |
| 9632 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9633 | |
| 9634 | /* Has CHR Mode changed? */ |
| 9635 | if (MMC3_helper & 0x80) |
| 9636 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9637 | break; |
| 9638 | |
| 9639 | case 0x0001: |
| 9640 | cmd = mmc_cmd1 & 0x07; |
| 9641 | switch (cmd) |
| 9642 | { |
| 9643 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9644 | case 2: case 3: case 4: case 5: |
| 9645 | vrom_bank[cmd] = data; |
| 9646 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9647 | break; |
| 9648 | case 6: |
| 9649 | case 7: |
| 9650 | prg_bank[cmd - 6] = data; |
| 9651 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9652 | break; |
| 9653 | } |
| 9654 | break; |
| 9655 | |
| 9656 | default: |
| 9657 | mapper4_w(space, offset, data); |
| 9658 | break; |
| 9659 | } |
| 9660 | } |
| 9661 | else |
| 9662 | { |
| 9663 | switch (offset & 0x6001) |
| 9664 | { |
| 9665 | case 0x0000: |
| 9666 | break; |
| 9667 | |
| 9668 | case 0x0001: |
| 9669 | cmd = mmc_cmd1 & 0x07; |
| 9670 | if (map215_reg[3] && ((map215_reg[0] & 0x80) == 0 || cmd < 6)) // if we use the prg16 banks and cmd=6,7 DON'T enter! |
| 9671 | { |
| 9672 | map215_reg[3] = 0; |
| 9673 | switch (cmd) |
| 9674 | { |
| 9675 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9676 | case 2: case 3: case 4: case 5: |
| 9677 | vrom_bank[cmd] = data; |
| 9678 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9679 | break; |
| 9680 | case 6: |
| 9681 | case 7: |
| 9682 | prg_bank[cmd - 6] = data; |
| 9683 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9684 | break; |
| 9685 | } |
| 9686 | } |
| 9687 | break; |
| 9688 | |
| 9689 | case 0x2000: |
| 9690 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 9691 | MMC3_helper = mmc_cmd1 ^ data; |
| 9692 | mmc_cmd1 = data; |
| 9693 | |
| 9694 | /* Has PRG Mode changed? */ |
| 9695 | if (MMC3_helper & 0x40) |
| 9696 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9697 | |
| 9698 | /* Has CHR Mode changed? */ |
| 9699 | if (MMC3_helper & 0x80) |
| 9700 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 9701 | |
| 9702 | map215_reg[3] = 1; |
| 9703 | break; |
| 9704 | |
| 9705 | // case 0x2001: |
| 9706 | // mapper4_w(space, 0x4001, data); |
| 9707 | // break; |
| 9708 | |
| 9709 | case 0x4000: |
| 9710 | set_nt_mirroring(((data >> 7) | data) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 9711 | break; |
| 9712 | |
| 9713 | case 0x4001: |
| 9714 | mapper4_w(space, 0x6001, data); |
| 9715 | break; |
| 9716 | |
| 9717 | // case 0x6000: |
| 9718 | // mapper4_w(space, 0x6000, data); |
| 9719 | // break; |
| 9720 | |
| 9721 | case 0x6001: |
| 9722 | mapper4_w(space, 0x4000, data); |
| 9723 | mapper4_w(space, 0x4001, data); |
| 9724 | break; |
| 9725 | |
| 9726 | default: |
| 9727 | mapper4_w(space, offset, data); |
| 9728 | break; |
| 9729 | } |
| 9730 | } |
| 9731 | } |
| 9732 | |
| 8107 | 9733 | /************************************************************* |
| 8108 | 9734 | |
| 8109 | 9735 | Mapper 216 |
| r5997 | r5998 | |
| 8135 | 9761 | |
| 8136 | 9762 | MMC3 clone |
| 8137 | 9763 | |
| 8138 | | In MESS: Unsupported. |
| 9764 | In MESS: Supported. |
| 8139 | 9765 | |
| 8140 | 9766 | *************************************************************/ |
| 8141 | 9767 | |
| 9768 | // remove mask & base parameters! |
| 9769 | static void mapper217_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 9770 | { |
| 9771 | mmc_prg_base = (map217_reg[1] & 0x08) ? 0 : (map217_reg[1] & 0x10); |
| 9772 | mmc_prg_mask = (map217_reg[1] & 0x08) ? 0x1f : 0x0f; |
| 9773 | |
| 9774 | mmc_prg_base |= ((map217_reg[1] & 0x03) << 5); |
| 9775 | |
| 9776 | mapper4_set_prg(machine, mmc_prg_base, mmc_prg_mask); |
| 9777 | } |
| 9778 | |
| 9779 | static void mapper217_set_chr( running_machine *machine, UINT8 chr ) |
| 9780 | { |
| 9781 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 9782 | int chr_base = (map217_reg[1] & 0x08) ? 0x00 : ((map217_reg[1] & 0x10) << 3); |
| 9783 | int chr_mask = (map217_reg[1] & 0x08) ? 0xff : 0x7f; |
| 9784 | |
| 9785 | chr_base |= ((map217_reg[1] & 0x03) << 8); |
| 9786 | |
| 9787 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), chr); |
| 9788 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), chr); |
| 9789 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), chr); |
| 9790 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), chr); |
| 9791 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), chr); |
| 9792 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), chr); |
| 9793 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), chr); |
| 9794 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), chr); |
| 9795 | } |
| 9796 | |
| 9797 | static WRITE8_HANDLER( mapper217_l_w ) |
| 9798 | { |
| 9799 | UINT8 bank; |
| 9800 | LOG_MMC(("mapper217_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 9801 | offset += 0x100; |
| 9802 | |
| 9803 | if (offset == 0x1000) |
| 9804 | { |
| 9805 | map217_reg[0] = data; |
| 9806 | if (data & 0x80) |
| 9807 | { |
| 9808 | bank = (data & 0x0f) | ((map217_reg[1] & 0x03) << 4); |
| 9809 | prg16_89ab(space->machine, bank); |
| 9810 | prg16_cdef(space->machine, bank); |
| 9811 | } |
| 9812 | else |
| 9813 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9814 | } |
| 9815 | else if (offset == 0x1001) |
| 9816 | { |
| 9817 | map217_reg[1] = data; |
| 9818 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9819 | } |
| 9820 | else if (offset == 0x1007) |
| 9821 | { |
| 9822 | map217_reg[2] = data; |
| 9823 | } |
| 9824 | } |
| 9825 | |
| 9826 | static WRITE8_HANDLER( mapper217_w ) |
| 9827 | { |
| 9828 | UINT8 MMC3_helper, cmd; |
| 9829 | static const UINT8 conv_table[8] = {0, 6, 3, 7, 5, 2, 4, 1}; |
| 9830 | LOG_MMC(("mapper217_w, offset: %04x, data: %02x\n", offset, data)); |
| 9831 | |
| 9832 | if (!map217_reg[2]) // in this case we act like MMC3, only with alt prg/chr handlers |
| 9833 | { |
| 9834 | switch (offset & 0x6001) |
| 9835 | { |
| 9836 | case 0x0000: |
| 9837 | MMC3_helper = mmc_cmd1 ^ data; |
| 9838 | mmc_cmd1 = data; |
| 9839 | |
| 9840 | /* Has PRG Mode changed? */ |
| 9841 | if (MMC3_helper & 0x40) |
| 9842 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9843 | |
| 9844 | /* Has CHR Mode changed? */ |
| 9845 | if (MMC3_helper & 0x80) |
| 9846 | mapper217_set_chr(space->machine, mmc_chr_source); |
| 9847 | break; |
| 9848 | |
| 9849 | case 0x0001: |
| 9850 | cmd = mmc_cmd1 & 0x07; |
| 9851 | switch (cmd) |
| 9852 | { |
| 9853 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9854 | case 2: case 3: case 4: case 5: |
| 9855 | vrom_bank[cmd] = data; |
| 9856 | mapper217_set_chr(space->machine, mmc_chr_source); |
| 9857 | break; |
| 9858 | case 6: |
| 9859 | case 7: |
| 9860 | prg_bank[cmd - 6] = data; |
| 9861 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9862 | break; |
| 9863 | } |
| 9864 | break; |
| 9865 | |
| 9866 | default: |
| 9867 | mapper4_w(space, offset, data); |
| 9868 | break; |
| 9869 | } |
| 9870 | } |
| 9871 | else |
| 9872 | { |
| 9873 | switch (offset & 0x6001) |
| 9874 | { |
| 9875 | case 0x0000: |
| 9876 | mapper4_w(space, 0xc000, data); |
| 9877 | break; |
| 9878 | |
| 9879 | case 0x0001: |
| 9880 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 9881 | MMC3_helper = mmc_cmd1 ^ data; |
| 9882 | mmc_cmd1 = data; |
| 9883 | |
| 9884 | /* Has PRG Mode changed? */ |
| 9885 | if (MMC3_helper & 0x40) |
| 9886 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9887 | |
| 9888 | /* Has CHR Mode changed? */ |
| 9889 | if (MMC3_helper & 0x80) |
| 9890 | mapper217_set_chr(space->machine, mmc_chr_source); |
| 9891 | |
| 9892 | map217_reg[3] = 1; |
| 9893 | break; |
| 9894 | |
| 9895 | case 0x2000: |
| 9896 | cmd = mmc_cmd1 & 0x07; |
| 9897 | if (map217_reg[3]) |
| 9898 | { |
| 9899 | map217_reg[3] = 0; |
| 9900 | switch (cmd) |
| 9901 | { |
| 9902 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 9903 | case 2: case 3: case 4: case 5: |
| 9904 | vrom_bank[cmd] = data; |
| 9905 | mapper217_set_chr(space->machine, mmc_chr_source); |
| 9906 | break; |
| 9907 | case 6: |
| 9908 | case 7: |
| 9909 | prg_bank[cmd - 6] = data; |
| 9910 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9911 | break; |
| 9912 | } |
| 9913 | } |
| 9914 | break; |
| 9915 | |
| 9916 | |
| 9917 | case 0x2001: |
| 9918 | set_nt_mirroring(data & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 9919 | break; |
| 9920 | |
| 9921 | default: |
| 9922 | mapper4_w(space, offset, data); |
| 9923 | break; |
| 9924 | } |
| 9925 | } |
| 9926 | } |
| 9927 | |
| 8142 | 9928 | /************************************************************* |
| 8143 | 9929 | |
| 8144 | 9930 | Mapper 218 |
| r5997 | r5998 | |
| 8236 | 10022 | |
| 8237 | 10023 | *************************************************************/ |
| 8238 | 10024 | |
| 10025 | /* Scanline based IRQ ? */ |
| 10026 | static void mapper222_irq( const device_config *device, int scanline, int vblank, int blanked ) |
| 10027 | { |
| 10028 | if (scanline < PPU_BOTTOM_VISIBLE_SCANLINE) |
| 10029 | { |
| 10030 | if (!IRQ_count || ++IRQ_count < 240) |
| 10031 | return; |
| 10032 | |
| 10033 | IRQ_count = 0; |
| 10034 | LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, |
| 10035 | video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen))); |
| 10036 | cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 10037 | } |
| 10038 | } |
| 10039 | |
| 10040 | static WRITE8_HANDLER( mapper222_w ) |
| 10041 | { |
| 10042 | UINT8 bank; |
| 10043 | LOG_MMC(("mapper222_w, offset: %04x, data: %02x\n", offset, data)); |
| 10044 | |
| 10045 | switch (offset & 0x7003) |
| 10046 | { |
| 10047 | case 0x0000: |
| 10048 | prg8_89(space->machine, data); |
| 10049 | break; |
| 10050 | case 0x1000: |
| 10051 | set_nt_mirroring((data & 0x01) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 10052 | break; |
| 10053 | case 0x2000: |
| 10054 | prg8_ab(space->machine, data); |
| 10055 | break; |
| 10056 | case 0x3000: |
| 10057 | case 0x3002: |
| 10058 | case 0x4000: |
| 10059 | case 0x4002: |
| 10060 | case 0x5000: |
| 10061 | case 0x5002: |
| 10062 | case 0x6000: |
| 10063 | case 0x6002: |
| 10064 | bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0002) >> 3); |
| 10065 | chr1_x(space->machine, bank, data, CHRROM); |
| 10066 | break; |
| 10067 | case 0x7000: |
| 10068 | IRQ_count = data; |
| 10069 | break; |
| 10070 | } |
| 10071 | } |
| 10072 | |
| 8239 | 10073 | /************************************************************* |
| 8240 | 10074 | |
| 8241 | 10075 | Mapper 223 |
| r5997 | r5998 | |
| 8399 | 10233 | Known Boards: Bootleg Board by Active Enterprise |
| 8400 | 10234 | Games: Action 52, Cheetah Men II |
| 8401 | 10235 | |
| 8402 | | In MESS: Only Partially Supported. |
| 10236 | In MESS: Partially Supported. |
| 8403 | 10237 | |
| 8404 | 10238 | *************************************************************/ |
| 8405 | 10239 | |
| 8406 | 10240 | static WRITE8_HANDLER( mapper228_w ) |
| 8407 | 10241 | { |
| 8408 | | /* The address lines double as data */ |
| 8409 | | /* --mPPppppPP-cccc */ |
| 8410 | | int bank; |
| 8411 | | int chr; |
| 8412 | | |
| 10242 | int prg_bank, prg_chip, chr_bank; |
| 10243 | UINT8 prg_mode; |
| 8413 | 10244 | LOG_MMC(("mapper228_w, offset: %04x, data: %02x\n", offset, data)); |
| 8414 | 10245 | |
| 8415 | | /* Determine low 4 bits of program bank */ |
| 8416 | | bank = (offset & 0x780) >> 7; |
| 10246 | set_nt_mirroring((offset & 0x2000) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8417 | 10247 | |
| 8418 | | #if 1 |
| 8419 | | /* Determine high 2 bits of program bank */ |
| 8420 | | switch (offset & 0x1800) |
| 10248 | chr_bank = (data & 0x03) | ((offset & 0x0f) << 2); |
| 10249 | chr8(space->machine, chr_bank, CHRROM); |
| 10250 | |
| 10251 | prg_bank = (offset & 0x7c0) >> 6; |
| 10252 | prg_chip = (offset & 0x1800) >> 11; |
| 10253 | prg_mode = offset & 0x20; |
| 10254 | |
| 10255 | switch (prg_chip) |
| 8421 | 10256 | { |
| 8422 | | case 0x0800: |
| 8423 | | bank |= 0x10; |
| 8424 | | break; |
| 8425 | | case 0x1800: |
| 8426 | | bank |= 0x20; |
| 8427 | | break; |
| 10257 | case 0: break; // we are already at the correct bank |
| 10258 | case 1: prg_bank |= 0x10; break; // chip 1 starts at block 16 |
| 10259 | case 2: break; // chip 2 was an empty socket |
| 10260 | case 3: prg_bank |= 0x20; break; // chip 3 starts at block 32 |
| 8428 | 10261 | } |
| 8429 | | #else |
| 8430 | | bank |= (offset & 0x1800) >> 7; |
| 8431 | | #endif |
| 8432 | 10262 | |
| 8433 | | /* see if the bank value is 16k or 32k */ |
| 8434 | | if (offset & 0x20) |
| 10263 | if (prg_mode) |
| 8435 | 10264 | { |
| 8436 | | /* 16k bank value, adjust */ |
| 8437 | | bank <<= 1; |
| 8438 | | if (offset & 0x40) |
| 8439 | | bank ++; |
| 8440 | | |
| 8441 | | prg16_89ab(space->machine, bank); |
| 8442 | | prg16_cdef(space->machine, bank); |
| 10265 | prg16_89ab(space->machine, prg_bank); |
| 10266 | prg16_cdef(space->machine, prg_bank); |
| 8443 | 10267 | } |
| 8444 | 10268 | else |
| 8445 | | { |
| 8446 | | prg32(space->machine, bank); |
| 8447 | | } |
| 8448 | | |
| 8449 | | if (offset & 0x2000) |
| 8450 | | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 8451 | | else |
| 8452 | | set_nt_mirroring(PPU_MIRROR_VERT); |
| 8453 | | |
| 8454 | | /* Now handle vrom banking */ |
| 8455 | | chr = (data & 0x03) + ((offset & 0x0f) << 2); |
| 8456 | | chr8(space->machine, chr, CHRROM); |
| 10269 | prg32(space->machine, prg_bank >> 1); |
| 8457 | 10270 | } |
| 8458 | 10271 | |
| 8459 | 10272 | /************************************************************* |
| r5997 | r5998 | |
| 8493 | 10306 | Known Boards: Unknown Bootleg Multigame Board |
| 8494 | 10307 | Games: 22 in 1 |
| 8495 | 10308 | |
| 8496 | | In MESS: Supported. Needs a reset to work (not possible yet) |
| 10309 | In MESS: Partially Supported. It would need a reset |
| 10310 | to work (not possible yet) |
| 8497 | 10311 | |
| 8498 | 10312 | *************************************************************/ |
| 8499 | 10313 | |
| r5997 | r5998 | |
| 8539 | 10353 | set_nt_mirroring((offset & 0x80) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8540 | 10354 | |
| 8541 | 10355 | prg16_89ab(space->machine, (offset & 0x1e)); |
| 8542 | | prg16_cdef(space->machine, (offset & 0x1e) + (data & 0x20) ? 1 : 0); |
| 10356 | prg16_cdef(space->machine, (offset & 0x1e) | ((offset & 0x20) ? 1 : 0)); |
| 8543 | 10357 | } |
| 8544 | 10358 | |
| 8545 | 10359 | /************************************************************* |
| r5997 | r5998 | |
| 8721 | 10535 | Simple mapper: writes to 0x8000-0xffff sets prg32 banks to |
| 8722 | 10536 | (offset>>3)&f. written data&3 sets the mirroring (with |
| 8723 | 10537 | switched high/low compared to the standard one). However, |
| 8724 | | a second variant DQ7 and requires no NT mirroring. |
| 8725 | | Currently, we do not support this variant. |
| 10538 | a second variant DQ8 and requires no NT mirroring. |
| 8726 | 10539 | |
| 8727 | | In MESS: Partial Support. |
| 10540 | A crc check is required to support Dragon Quest VIII (which |
| 10541 | uses a slightly different board) |
| 8728 | 10542 | |
| 10543 | In MESS: Supported. |
| 10544 | |
| 8729 | 10545 | *************************************************************/ |
| 8730 | 10546 | |
| 8731 | 10547 | static WRITE8_HANDLER( mapper242_w ) |
| 8732 | 10548 | { |
| 8733 | 10549 | LOG_MMC(("mapper242_w, offset: %04x, data: %02x\n", offset, data)); |
| 8734 | 10550 | |
| 8735 | | prg32(space->machine, (offset >> 3) & 0x0f); |
| 10551 | prg32(space->machine, offset >> 3); |
| 8736 | 10552 | |
| 8737 | | waixing_set_mirror(data & 0x03); |
| 10553 | if (!nes.crc_hack) // DQ8 board does not have this / Zan Shi does |
| 10554 | { |
| 10555 | switch (data & 0x03) |
| 10556 | { |
| 10557 | case 0: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 10558 | case 1: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 10559 | case 2: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 10560 | case 3: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 10561 | } |
| 10562 | } |
| 8738 | 10563 | } |
| 8739 | 10564 | |
| 8740 | 10565 | /************************************************************* |
| r5997 | r5998 | |
| 8754 | 10579 | { |
| 8755 | 10580 | LOG_MMC(("mapper243_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8756 | 10581 | |
| 8757 | | /* write happens only if we are at 0x4100 + k * 0x200, |
| 8758 | | but 0x4100 is offset = 0 */ |
| 10582 | /* write happens only if we are at 0x4100 + k * 0x200, but 0x4100 is offset = 0 */ |
| 8759 | 10583 | if (!(offset & 0x100)) |
| 8760 | 10584 | { |
| 8761 | 10585 | if (!(offset & 0x01)) |
| r5997 | r5998 | |
| 8829 | 10653 | Mapper 245 |
| 8830 | 10654 | |
| 8831 | 10655 | Known Boards: Type H by Waixing |
| 8832 | | Games: Ying Xiong Yuan Yi Jing Chuan Qi |
| 10656 | Games: Ying Xiong Yuan Yi Jing Chuan Qi, Yong Zhe Dou E |
| 10657 | Long - Dragon Quest VII |
| 8833 | 10658 | |
| 8834 | 10659 | MMC3 clone. More info to come. |
| 8835 | 10660 | |
| 8836 | | In MESS: Unsupported. |
| 10661 | In MESS: Supported. |
| 8837 | 10662 | |
| 8838 | 10663 | *************************************************************/ |
| 8839 | 10664 | |
| 10665 | static WRITE8_HANDLER( mapper245_w ) |
| 10666 | { |
| 10667 | UINT8 cmd, map245_helper; |
| 10668 | LOG_MMC(("mapper245_w, offset: %04x, data: %02x\n", offset, data)); |
| 10669 | |
| 10670 | switch (offset & 0x6001) |
| 10671 | { |
| 10672 | case 0x0001: |
| 10673 | cmd = mmc_cmd1 & 0x0f; |
| 10674 | switch (cmd) |
| 10675 | { |
| 10676 | case 0: // in this case we set prg_base in addition to vrom_bank! |
| 10677 | mmc_prg_base = (data << 5) & 0x40; |
| 10678 | mmc_prg_mask = 0x3f; |
| 10679 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10680 | case 1: case 2: case 3: case 4: case 5: |
| 10681 | vrom_bank[cmd] = data; |
| 10682 | if (nes.chr_chunks > 0) |
| 10683 | mapper4_set_chr(space->machine, CHRROM, mmc_chr_base, mmc_chr_mask); |
| 10684 | else // according to Disch's docs, mmc_cmd1&0x80 swaps 4k CHRRAM banks |
| 10685 | { |
| 10686 | map245_helper = /*(mmc_cmd1 & 0x80) ? 1 : */0; |
| 10687 | chr4_0(space->machine, 0 ^ map245_helper, CHRRAM); |
| 10688 | chr4_4(space->machine, 1 ^ map245_helper, CHRRAM); |
| 10689 | } |
| 10690 | break; |
| 10691 | case 6: |
| 10692 | case 7: |
| 10693 | prg_bank[cmd - 6] = data; |
| 10694 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10695 | break; |
| 10696 | } |
| 10697 | break; |
| 10698 | |
| 10699 | case 0x2001: |
| 10700 | break; |
| 10701 | |
| 10702 | default: |
| 10703 | mapper4_w(space, offset, data); |
| 10704 | break; |
| 10705 | } |
| 10706 | } |
| 10707 | |
| 8840 | 10708 | /************************************************************* |
| 8841 | 10709 | |
| 8842 | 10710 | Mapper 246 |
| r5997 | r5998 | |
| 8917 | 10785 | |
| 8918 | 10786 | Mapper 249 |
| 8919 | 10787 | |
| 8920 | | Known Boards: Waixing Security 0 & 1 |
| 10788 | Known Boards: Waixing with Security Chip |
| 8921 | 10789 | Games: Duo Bao Xiao Ying Hao - Guang Ming yu An Hei Chuan Shuo, |
| 8922 | 10790 | Myth Struggle, San Shi Liu Ji, Shui Hu Zhuan |
| 8923 | 10791 | |
| 8924 | 10792 | MMC3 clone |
| 8925 | 10793 | |
| 8926 | | In MESS: Unsupported. |
| 10794 | In MESS: Partially Supported. |
| 8927 | 10795 | |
| 8928 | 10796 | *************************************************************/ |
| 8929 | 10797 | |
| 10798 | static void mapper249_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 10799 | { |
| 10800 | int i; |
| 10801 | |
| 10802 | if (map249_reg) |
| 10803 | { |
| 10804 | for (i = 0; i < 4; i ++) // should this apply only to bank[0],bank[1]? |
| 10805 | { |
| 10806 | prg_bank[i] = ((prg_bank[i] & 0x01)) | ((prg_bank[i] >> 3) & 0x02) | |
| 10807 | ((prg_bank[i] >> 1) & 0x04) | ((prg_bank[i] << 2) & 0x18); |
| 10808 | } |
| 10809 | } |
| 10810 | |
| 10811 | mapper4_set_prg(machine, prg_base, prg_mask); |
| 10812 | } |
| 10813 | |
| 10814 | static void mapper249_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 10815 | { |
| 10816 | UINT8 chr_page = (mmc_cmd1 & 0x80) >> 5; |
| 10817 | int i; |
| 10818 | |
| 10819 | if (map249_reg) |
| 10820 | { |
| 10821 | for (i = 0; i < 6; i ++) |
| 10822 | { |
| 10823 | vrom_bank[i] = ((vrom_bank[i] & 0x03)) | ((vrom_bank[i] >> 1) & 0x04) | |
| 10824 | ((vrom_bank[i] >> 4) & 0x08) | ((vrom_bank[i] >> 2) & 0x10) | |
| 10825 | ((vrom_bank[i] << 3) & 0x20) | ((vrom_bank[i] << 2) & 0xc0); |
| 10826 | } |
| 10827 | } |
| 10828 | |
| 10829 | chr1_x(machine, chr_page ^ 0, chr_base | ((vrom_bank[0] & ~0x01) & chr_mask), mmc_chr_source); |
| 10830 | chr1_x(machine, chr_page ^ 1, chr_base | ((vrom_bank[0] | 0x01) & chr_mask), mmc_chr_source); |
| 10831 | chr1_x(machine, chr_page ^ 2, chr_base | ((vrom_bank[1] & ~0x01) & chr_mask), mmc_chr_source); |
| 10832 | chr1_x(machine, chr_page ^ 3, chr_base | ((vrom_bank[1] | 0x01) & chr_mask), mmc_chr_source); |
| 10833 | chr1_x(machine, chr_page ^ 4, chr_base | (vrom_bank[2] & chr_mask), mmc_chr_source); |
| 10834 | chr1_x(machine, chr_page ^ 5, chr_base | (vrom_bank[3] & chr_mask), mmc_chr_source); |
| 10835 | chr1_x(machine, chr_page ^ 6, chr_base | (vrom_bank[4] & chr_mask), mmc_chr_source); |
| 10836 | chr1_x(machine, chr_page ^ 7, chr_base | (vrom_bank[5] & chr_mask), mmc_chr_source); |
| 10837 | } |
| 10838 | |
| 10839 | static WRITE8_HANDLER( mapper249_l_w ) |
| 10840 | { |
| 10841 | LOG_MMC(("mapper249_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 10842 | |
| 10843 | offset += 0x100; |
| 10844 | |
| 10845 | if (offset == 0x1000) |
| 10846 | { |
| 10847 | map249_reg = data & 0x02; |
| 10848 | mapper249_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10849 | mapper249_set_chr(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10850 | } |
| 10851 | } |
| 10852 | |
| 10853 | static WRITE8_HANDLER( mapper249_w ) |
| 10854 | { |
| 10855 | UINT8 MMC3_helper, cmd; |
| 10856 | LOG_MMC(("mapper249_w, offset: %04x, data: %02x\n", offset, data)); |
| 10857 | |
| 10858 | switch (offset & 0x6001) |
| 10859 | { |
| 10860 | case 0x0000: |
| 10861 | MMC3_helper = mmc_cmd1 ^ data; |
| 10862 | mmc_cmd1 = data; |
| 10863 | |
| 10864 | /* Has PRG Mode changed? */ |
| 10865 | if (MMC3_helper & 0x40) |
| 10866 | mapper249_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10867 | |
| 10868 | /* Has CHR Mode changed? */ |
| 10869 | if (MMC3_helper & 0x80) |
| 10870 | mapper249_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 10871 | break; |
| 10872 | |
| 10873 | case 0x0001: |
| 10874 | cmd = mmc_cmd1 & 0x07; |
| 10875 | switch (cmd) |
| 10876 | { |
| 10877 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 10878 | case 2: case 3: case 4: case 5: |
| 10879 | vrom_bank[cmd] = data; |
| 10880 | mapper249_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 10881 | break; |
| 10882 | case 6: |
| 10883 | case 7: |
| 10884 | prg_bank[cmd - 6] = data; |
| 10885 | mapper249_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 10886 | break; |
| 10887 | } |
| 10888 | break; |
| 10889 | |
| 10890 | default: |
| 10891 | mapper4_w(space, offset, data); |
| 10892 | break; |
| 10893 | } |
| 10894 | } |
| 10895 | |
| 8930 | 10896 | /************************************************************* |
| 8931 | 10897 | |
| 8932 | 10898 | Mapper 250 |
| r5997 | r5998 | |
| 8935 | 10901 | Games: Time Diver Avenger |
| 8936 | 10902 | |
| 8937 | 10903 | This acts basically like a MMC3 with different use of write |
| 8938 | | address. According to NEStopia, there is also a slightly |
| 8939 | | different way to set NT mirroring (see below). |
| 10904 | address. |
| 8940 | 10905 | |
| 8941 | 10906 | In MESS: Supported. |
| 8942 | 10907 | |
| r5997 | r5998 | |
| 8946 | 10911 | { |
| 8947 | 10912 | LOG_MMC(("mapper250_w, offset: %04x, data: %02x\n", offset, data)); |
| 8948 | 10913 | |
| 8949 | | switch (offset & 0x6001) |
| 8950 | | { |
| 8951 | | case 0x2000: |
| 8952 | | set_nt_mirroring(data & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); // diff with MMC3: not check for data & 0x40 |
| 8953 | | break; |
| 8954 | | default: |
| 8955 | | mapper4_w(space, (offset & 0x6000) | ((offset & 0x400) >> 10), offset & 0xff); |
| 8956 | | break; |
| 8957 | | } |
| 10914 | mapper4_w(space, (offset & 0x6000) | ((offset & 0x400) >> 10), offset & 0xff); |
| 8958 | 10915 | } |
| 8959 | 10916 | |
| 8960 | 10917 | /************************************************************* |
| r5997 | r5998 | |
| 8975 | 10932 | Known Boards: Unknown Bootleg Board by Waixing |
| 8976 | 10933 | Games: San Guo Zhi |
| 8977 | 10934 | |
| 10935 | This board uses Konami IRQ |
| 10936 | |
| 8978 | 10937 | In MESS: Unsupported. |
| 8979 | 10938 | |
| 8980 | 10939 | *************************************************************/ |
| 8981 | 10940 | |
| 10941 | static WRITE8_HANDLER( mapper252_w ) |
| 10942 | { |
| 10943 | UINT8 mmc_helper, bank; |
| 10944 | LOG_MMC(("mapper252_w, offset: %04x, data: %02x\n", offset, data)); |
| 10945 | |
| 10946 | switch (offset & 0x7000) |
| 10947 | { |
| 10948 | case 0x0000: |
| 10949 | prg8_89(space->machine, data); |
| 10950 | break; |
| 10951 | case 0x2000: |
| 10952 | prg8_ab(space->machine, data); |
| 10953 | break; |
| 10954 | case 0x3000: |
| 10955 | case 0x4000: |
| 10956 | case 0x5000: |
| 10957 | case 0x6000: |
| 10958 | bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0008) >> 3); |
| 10959 | mmc_helper = offset & 0x04; |
| 10960 | if (mmc_helper) |
| 10961 | vrom_bank[bank] = (vrom_bank[bank] & 0x0f) | ((data & 0x0f) << 4); |
| 10962 | else |
| 10963 | vrom_bank[bank] = (vrom_bank[bank] & 0xf0) | (data & 0x0f); |
| 10964 | chr1_x(space->machine, bank, vrom_bank[bank], CHRROM); |
| 10965 | break; |
| 10966 | case 0xf000: |
| 10967 | switch (offset & 0x0c) |
| 10968 | { |
| 10969 | case 0x00: |
| 10970 | IRQ_count_latch = (IRQ_count_latch & 0xf0) | (data & 0x0f); |
| 10971 | break; |
| 10972 | case 0x04: |
| 10973 | IRQ_count_latch = (IRQ_count_latch & 0x0f) | ((data & 0x0f) << 4); |
| 10974 | break; |
| 10975 | case 0x08: |
| 10976 | IRQ_enable = data & 0x02; |
| 10977 | IRQ_enable_latch = data & 0x01; |
| 10978 | if (data & 0x02) |
| 10979 | IRQ_count = IRQ_count_latch; |
| 10980 | break; |
| 10981 | case 0x0c: |
| 10982 | IRQ_enable = IRQ_enable_latch; |
| 10983 | break; |
| 10984 | } |
| 10985 | break; |
| 10986 | } |
| 10987 | } |
| 10988 | |
| 8982 | 10989 | /************************************************************* |
| 8983 | 10990 | |
| 8984 | 10991 | Mapper 253 |
| r5997 | r5998 | |
| 9011 | 11018 | Known Boards: Unknown Bootleg Board |
| 9012 | 11019 | Games: 110 in 1 |
| 9013 | 11020 | |
| 9014 | | In MESS: Unsupported. |
| 11021 | In MESS: Preliminary support. |
| 9015 | 11022 | |
| 9016 | 11023 | *************************************************************/ |
| 9017 | 11024 | |
| r5997 | r5998 | |
| 9040 | 11047 | |
| 9041 | 11048 | static const mmc mmc_list[] = |
| 9042 | 11049 | { |
| 9043 | | /* INES DESC LOW_W, LOW_R, MED_W, HIGH_W, PPU_latch, scanline CB, hblank CB */ |
| 9044 | | { 0, "No Mapper", NULL, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9045 | | { 1, "MMC1", NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL }, |
| 9046 | | { 2, "74161/32 ROM sw", NULL, NULL, NULL, mapper2_w, NULL, NULL, NULL }, |
| 9047 | | { 3, "74161/32 VROM sw", NULL, NULL, NULL, mapper3_w, NULL, NULL, NULL }, |
| 9048 | | { 4, "MMC3", NULL, NULL, NULL, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9049 | | { 5, "MMC5", mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq }, |
| 9050 | | { 7, "ROM Switch", NULL, NULL, NULL, mapper7_w, NULL, NULL, NULL }, |
| 9051 | | { 8, "FFE F3xxxx", NULL, NULL, NULL, mapper8_w, NULL, NULL, NULL }, |
| 9052 | | { 9, "MMC2", NULL, NULL, NULL, mapper9_w, mapper9_latch, NULL, NULL}, |
| 9053 | | { 10, "MMC4", NULL, NULL, NULL, mapper10_w, mapper9_latch, NULL, NULL }, |
| 9054 | | { 11, "Color Dreams Mapper", NULL, NULL, NULL, mapper11_w, NULL, NULL, NULL }, |
| 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 }, |
| 9057 | | { 15, "100-in-1", NULL, NULL, NULL, mapper15_w, NULL, NULL, NULL }, |
| 9058 | | { 16, "Bandai", NULL, NULL, mapper16_m_w, mapper16_w, NULL,NULL, bandai_irq }, |
| 9059 | | { 17, "FFE F8xxx", mapper17_l_w, NULL, NULL, NULL, NULL, NULL, mapper4_irq }, |
| 9060 | | { 18, "Jaleco", NULL, NULL, NULL, mapper18_w, NULL, NULL, jaleco_irq }, |
| 9061 | | { 19, "Namco 106", mapper19_l_w, mapper19_l_r, NULL, mapper19_w, NULL, NULL, namcot_irq }, |
| 9062 | | { 20, "Famicom Disk System", NULL, NULL, NULL, NULL, NULL, NULL, fds_irq }, |
| 9063 | | { 21, "Konami VRC 4", NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq }, |
| 9064 | | { 22, "Konami VRC 2a", NULL, NULL, NULL, konami_vrc2a_w, NULL, NULL, NULL }, |
| 9065 | | { 23, "Konami VRC 2b", NULL, NULL, NULL, konami_vrc2b_w, NULL, NULL, konami_irq }, |
| 9066 | | { 24, "Konami VRC 6a", NULL, NULL, NULL, konami_vrc6a_w, NULL, NULL, konami_irq }, |
| 9067 | | { 25, "Konami VRC 4", NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq }, |
| 9068 | | { 26, "Konami VRC 6b", NULL, NULL, NULL, konami_vrc6b_w, NULL, NULL, konami_irq }, |
| 9069 | | { 32, "Irem G-101", NULL, NULL, NULL, mapper32_w, NULL, NULL, NULL }, |
| 9070 | | { 33, "Taito TC0190", NULL, NULL, NULL, mapper33_w, NULL, NULL, NULL }, |
| 9071 | | { 34, "Nina-1", NULL, NULL, mapper34_m_w, mapper34_w, NULL, NULL, NULL }, |
| 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 }, |
| 9074 | | { 38, "Crime Buster", NULL, NULL, mapper38_m_w, NULL, NULL, NULL, NULL }, |
| 9075 | | { 39, "Subor Study n Game", NULL, NULL, NULL, mapper39_w, NULL, NULL, NULL }, |
| 9076 | | { 40, "SMB2j (bootleg)", NULL, NULL, NULL, mapper40_w, NULL, NULL, mapper40_irq }, |
| 9077 | | { 41, "Caltron 6-in-1", NULL, NULL, mapper41_m_w, mapper41_w, NULL, NULL, NULL }, |
| 9078 | | { 42, "Mario Baby", NULL, NULL, NULL, mapper42_w, NULL, NULL, NULL }, |
| 9079 | | { 43, "150-in-1", NULL, NULL, NULL, mapper43_w, NULL, NULL, NULL }, |
| 9080 | | { 44, "7-in-1 MMC3", NULL, NULL, NULL, mapper44_w, NULL, NULL, mapper4_irq }, |
| 9081 | | { 45, "X-in-1 MMC3", NULL, NULL, mapper45_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9082 | | { 46, "15-in-1 Color Dreams", NULL, NULL, mapper46_m_w, mapper46_w, NULL, NULL, NULL }, |
| 9083 | | { 47, "2-in-1 MMC3", NULL, NULL, mapper47_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 9084 | | { 49, "4-in-1 MMC3", NULL, NULL, mapper49_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 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 }, |
| 9087 | | { 57, "6-in-1", NULL, NULL, NULL, mapper57_w, NULL, NULL, NULL }, |
| 9088 | | { 58, "X-in-1", NULL, NULL, NULL, mapper58_w, NULL, NULL, NULL }, |
| 9089 | | { 61, "20-in-1", NULL, NULL, NULL, mapper61_w, NULL, NULL, NULL }, |
| 9090 | | { 62, "X-in-1", NULL, NULL, NULL, mapper62_w, NULL, NULL, NULL }, |
| 9091 | | { 64, "Tengen", NULL, NULL, mapper64_m_w, mapper64_w, NULL, NULL, mapper4_irq }, |
| 9092 | | { 65, "Irem H3001", NULL, NULL, NULL, mapper65_w, NULL, NULL, irem_irq }, |
| 9093 | | { 66, "74161/32 Jaleco", NULL, NULL, NULL, mapper66_w, NULL, NULL, NULL }, |
| 9094 | | { 67, "SunSoft 3", NULL, NULL, NULL, mapper67_w, NULL, NULL, mapper4_irq }, |
| 9095 | | { 68, "SunSoft 4", NULL, NULL, NULL, mapper68_w, NULL, NULL, NULL }, |
| 9096 | | { 69, "SunSoft 5", NULL, NULL, NULL, mapper69_w, NULL, NULL, sunsoft_irq }, |
| 9097 | | { 70, "74161/32 Bandai", NULL, NULL, NULL, mapper70_w, NULL, NULL, NULL }, |
| 9098 | | { 71, "Camerica", NULL, NULL, mapper71_m_w, mapper71_w, NULL, NULL, NULL }, |
| 9099 | | { 72, "74161/32 Jaleco", NULL, NULL, NULL, mapper72_w, NULL, NULL, NULL }, |
| 9100 | | { 73, "Konami VRC 3", NULL, NULL, NULL, mapper73_w, NULL, NULL, konami_irq }, |
| 9101 | | { 74, "Waixing Type A", NULL, NULL, NULL, mapper74_w, NULL, NULL, mapper4_irq }, |
| 9102 | | { 75, "Konami VRC 1", NULL, NULL, NULL, mapper75_w, NULL, NULL, NULL }, |
| 9103 | | { 76, "Namco 109", NULL, NULL, NULL, mapper76_w, NULL, NULL, NULL }, |
| 9104 | | { 77, "74161/32 ?", NULL, NULL, NULL, mapper77_w, NULL, NULL, NULL }, |
| 9105 | | { 78, "74161/32 Irem", NULL, NULL, NULL, mapper78_w, NULL, NULL, NULL }, |
| 9106 | | { 79, "Nina-3 (AVE)", mapper79_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9107 | | { 80, "Taito X1-005 Ver. A", NULL, NULL, mapper80_m_w, NULL, NULL, NULL, NULL }, |
| 9108 | | { 82, "Taito C075", NULL, NULL, mapper82_m_w, NULL, NULL, NULL, NULL }, |
| 9109 | | { 83, "Cony", mapper83_l_w, mapper83_l_r, NULL, mapper83_w, NULL, NULL, NULL }, |
| 9110 | | { 84, "Pasofami", NULL, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9111 | | { 85, "Konami VRC 7", NULL, NULL, NULL, konami_vrc7_w, NULL, NULL, konami_irq }, |
| 9112 | | { 86, "Jaleco Early Mapper 2",NULL, NULL, mapper86_m_w, NULL, NULL, NULL, NULL }, |
| 9113 | | { 87, "74161/32 VROM sw-a", NULL, NULL, mapper87_m_w, NULL, NULL, NULL, NULL }, |
| 9114 | | { 88, "Namco 118", NULL, NULL, NULL, mapper88_w, NULL, NULL, NULL }, |
| 9115 | | { 89, "Sunsoft Early", NULL, NULL, NULL, mapper89_w, NULL, NULL, NULL }, |
| 9116 | | // 90 - pirate mapper |
| 9117 | | { 91, "HK-SF3 (bootleg)", NULL, NULL, mapper91_m_w, NULL, NULL, NULL, NULL }, |
| 9118 | | { 92, "Jaleco Early Mapper 1",NULL, NULL, NULL, mapper92_w, NULL, NULL, NULL }, |
| 9119 | | { 93, "Sunsoft LS161", NULL, NULL, NULL, mapper93_w, NULL, NULL, NULL }, |
| 9120 | | { 94, "Capcom LS161", NULL, NULL, NULL, mapper94_w, NULL, NULL, NULL }, |
| 9121 | | { 95, "Namco ??", NULL, NULL, NULL, mapper95_w, NULL, NULL, NULL }, |
| 9122 | | { 96, "74161/32", NULL, NULL, NULL, mapper96_w, NULL, NULL, NULL }, |
| 9123 | | { 97, "Irem - PRG HI", NULL, NULL, NULL, mapper97_w, NULL, NULL, NULL }, |
| 9124 | | // 99 - vs. system |
| 9125 | | // 100 - images hacked to work with nesticle |
| 9126 | | { 101, "?? LS161", NULL, NULL, mapper101_m_w, mapper101_w, NULL, NULL, NULL }, |
| 9127 | | { 104, "Golden Five", NULL, NULL, NULL, mapper104_w, NULL, NULL, NULL }, |
| 9128 | | { 107, "Magic Dragon", NULL, NULL, NULL, mapper107_w, NULL, NULL, NULL }, |
| 9129 | | { 112, "Asper", NULL, NULL, NULL, mapper112_w, NULL, NULL, NULL }, |
| 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 }, |
| 9132 | | { 115, "Bao Qing Tian", NULL, NULL, mapper115_m_w, mapper115_w, NULL, NULL, mapper115_irq }, |
| 9133 | | { 118, "MMC3?", NULL, NULL, NULL, mapper118_w, NULL, NULL, mapper4_irq }, |
| 9134 | | { 119, "MMC3 - Pinbot", NULL, NULL, NULL, mapper119_w, NULL, NULL, mapper4_irq }, |
| 9135 | | { 132, "TXC T22211A", mapper132_l_w, mapper132_l_r, NULL, mapper132_w, NULL, NULL, NULL }, |
| 9136 | | { 133, "Sachen SA72008", mapper133_l_w, NULL, mapper133_m_w, NULL, NULL, NULL, NULL }, |
| 9137 | | { 136, "Sachen TCU01", mapper136_l_w, mapper136_l_r, NULL, NULL, NULL, NULL, NULL }, |
| 9138 | | { 137, "Sachen 8259D", mapper137_l_w, NULL, mapper137_m_w, NULL, NULL, NULL, NULL }, |
| 9139 | | { 138, "Sachen 8259B", mapper138_l_w, NULL, mapper138_m_w, NULL, NULL, NULL, NULL }, |
| 9140 | | { 139, "Sachen 8259C", mapper139_l_w, NULL, mapper139_m_w, NULL, NULL, NULL, NULL }, |
| 9141 | | { 140, "Jaleco", NULL, NULL, mapper_140_m_w, NULL, NULL, NULL, NULL }, |
| 9142 | | { 141, "Sachen 8259A", mapper141_l_w, NULL, mapper141_m_w, NULL, NULL, NULL, NULL }, |
| 9143 | | { 143, "Sachen TCA01", NULL, mapper143_l_r, NULL, NULL, NULL, NULL, NULL }, |
| 9144 | | { 144, "AGCI 50282", NULL, NULL, NULL, mapper144_w, NULL, NULL, NULL }, //Death Race only |
| 9145 | | { 145, "Sachen SA72007", mapper145_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9146 | | { 146, "Sachen SA0161M", mapper79_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, // basically same as Mapper 79 (Nina006) |
| 9147 | | { 147, "Sachen TCU02", mapper147_l_w, NULL, mapper147_m_w, mapper147_w, NULL, NULL, NULL }, |
| 9148 | | { 148, "Sachen SA0037", NULL, NULL, NULL, mapper148_w, NULL, NULL, NULL }, |
| 9149 | | { 149, "Sachen SA0036", NULL, NULL, NULL, mapper149_w, NULL, NULL, NULL }, |
| 9150 | | { 150, "Sachen 74LS374B", mapper150_l_w, mapper150_l_r, mapper150_m_w, NULL, NULL, NULL, NULL }, |
| 9151 | | { 152, "Taito Discrete", NULL, NULL, NULL, mapper152_w, NULL, NULL, NULL }, |
| 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) |
| 9154 | | { 156, "Open Corp. DAOU36", NULL, NULL, NULL, mapper156_w, NULL, NULL, NULL }, |
| 9155 | | { 164, "Final Fantasy V", mapper164_l_w, NULL, NULL, mapper164_w, NULL, NULL, NULL }, |
| 9156 | | { 166, "Subor Board Type 1", NULL, NULL, NULL, mapper166_w, NULL, NULL, NULL }, |
| 9157 | | { 167, "Subor Board Type 2", NULL, NULL, NULL, mapper167_w, NULL, NULL, NULL }, |
| 9158 | | { 171, "Kaiser KS7058", NULL, NULL, NULL, mapper171_w, NULL, NULL, NULL }, |
| 9159 | | { 172, "TXC T22211B", mapper132_l_w, mapper132_l_r, NULL, mapper172_w, NULL, NULL, NULL }, |
| 9160 | | { 173, "TXC T22211C", mapper132_l_w, mapper173_l_r, NULL, mapper132_w, NULL, NULL, NULL }, |
| 9161 | | { 176, "Zhi Li Xiao Zhuan Yuan",mapper176_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9162 | | { 177, "Henggedianzi Board", NULL, NULL, NULL, mapper177_w, NULL, NULL, NULL }, |
| 9163 | | { 178, "San Guo Zhong Lie Zhuan",mapper178_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9164 | | { 179, "Xing He Zhan Shi", mapper179_l_w, NULL, NULL, mapper179_w, NULL, NULL, NULL }, |
| 9165 | | { 180, "Nihon Bussan - PRG HI",NULL, NULL, NULL, mapper180_w, NULL, NULL, NULL }, |
| 9166 | | { 182, "Super games", NULL, NULL, NULL, mapper182_w, NULL, NULL, mapper182_irq }, |
| 9167 | | { 184, "Sunsoft VROM/4K", NULL, NULL, mapper184_m_w, NULL, NULL, NULL, NULL }, |
| 9168 | | { 188, "UNROM reversed", NULL, NULL, NULL, mapper188_w, NULL, NULL, NULL }, |
| 9169 | | { 193, "Fighting Hero", NULL, NULL, mapper193_m_w, NULL, NULL, NULL, NULL }, |
| 9170 | | { 196, "Super Mario Bros. 11",NULL, NULL, NULL, mapper196_w, NULL, NULL, mapper4_irq }, |
| 9171 | | { 200, "X-in-1", NULL, NULL, NULL, mapper200_w, NULL, NULL, NULL }, |
| 9172 | | { 201, "X-in-1", NULL, NULL, NULL, mapper201_w, NULL, NULL, NULL }, |
| 9173 | | { 202, "150-in-1", NULL, NULL, NULL, mapper202_w, NULL, NULL, NULL }, |
| 9174 | | { 203, "35-in-1", NULL, NULL, NULL, mapper203_w, NULL, NULL, NULL }, |
| 9175 | | { 204, "64-in-1", NULL, NULL, NULL, mapper204_w, NULL, NULL, NULL }, |
| 9176 | | { 206, "MIMIC-1", NULL, NULL, NULL, mapper206_w, NULL, NULL, mapper4_irq }, |
| 9177 | | { 207, "Taito X1-005 Ver. B", NULL, NULL, mapper207_m_w, NULL, NULL, NULL, NULL }, |
| 9178 | | { 212, "Super HIK 300-in-1", NULL, NULL, NULL, mapper212_w, NULL, NULL, NULL }, |
| 9179 | | { 213, "9999999-in-1", NULL, NULL, NULL, mapper213_w, NULL, NULL, NULL }, |
| 9180 | | { 214, "Super Gun 20-in-1", NULL, NULL, NULL, mapper214_w, NULL, NULL, NULL }, |
| 9181 | | { 216, "RCM GS2015", NULL, NULL, NULL, mapper216_w, NULL, NULL, NULL }, |
| 9182 | | { 221, "X-in-1 (N625092)", NULL, NULL, NULL, mapper221_w, NULL, NULL, NULL }, |
| 9183 | | { 225, "72-in-1 bootleg", NULL, NULL, NULL, mapper225_w, NULL, NULL, NULL }, |
| 9184 | | { 226, "76-in-1 bootleg", NULL, NULL, NULL, mapper226_w, NULL, NULL, NULL }, |
| 9185 | | { 227, "1200-in-1 bootleg", NULL, NULL, NULL, mapper227_w, NULL, NULL, NULL }, |
| 9186 | | { 228, "Action 52", NULL, NULL, NULL, mapper228_w, NULL, NULL, NULL }, |
| 9187 | | { 229, "31-in-1", NULL, NULL, NULL, mapper229_w, NULL, NULL, NULL }, |
| 9188 | | { 230, "22-in-1", NULL, NULL, NULL, mapper230_w, NULL, NULL, NULL }, |
| 9189 | | { 231, "Nina-7 (AVE)", NULL, NULL, NULL, mapper231_w, NULL, NULL, NULL }, |
| 9190 | | { 232, "Quattro", NULL, NULL, mapper232_w, mapper232_w, NULL, NULL, NULL }, |
| 9191 | | // 234 - maxi-15 |
| 9192 | | { 240, "Jing Ke Xin Zhuan", mapper240_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9193 | | { 241, "Education 18-in-1", NULL, mapper241_l_r, NULL, mapper241_w, NULL, NULL, NULL }, |
| 9194 | | { 242, "Wai Xing Zhan Shi", NULL, NULL, NULL, mapper242_w, NULL, NULL, NULL }, |
| 9195 | | { 243, "Sachen 74LS374A", mapper243_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 9196 | | { 244, "Decathlon", NULL, NULL, NULL, mapper244_w, NULL, NULL, NULL }, |
| 9197 | | { 246, "Fong Shen Bang", NULL, NULL, mapper246_m_w, NULL, NULL, NULL, NULL }, |
| 9198 | | { 250, "Time Diver Avenger", NULL, NULL, NULL, mapper250_w, NULL, NULL, mapper4_irq }, |
| 9199 | | { 255, "X-in-1", NULL, NULL, NULL, mapper255_w, NULL, NULL, NULL }, |
| 11050 | /* INES DESC LOW_W, LOW_R, MED_W, HIGH_W, PPU_latch, scanline CB, hblank CB */ |
| 11051 | { 0, "No Mapper", NULL, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11052 | { 1, "MMC1", NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL }, |
| 11053 | { 2, "Ux-ROM", NULL, NULL, NULL, mapper2_w, NULL, NULL, NULL }, |
| 11054 | { 3, "Cx-ROM", NULL, NULL, NULL, mapper3_w, NULL, NULL, NULL }, |
| 11055 | { 4, "MMC3", NULL, NULL, NULL, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11056 | { 5, "MMC5", mapper5_l_w, mapper5_l_r, NULL, mapper5_w, NULL, NULL, mapper5_irq }, |
| 11057 | { 6, "FFE F4xxxx", mapper6_l_w, NULL, NULL, mapper6_w, NULL, NULL, ffe_irq }, |
| 11058 | { 7, "Ax-ROM", NULL, NULL, NULL, mapper7_w, NULL, NULL, NULL }, |
| 11059 | { 8, "FFE F3xxxx", NULL, NULL, NULL, mapper8_w, NULL, NULL, NULL }, |
| 11060 | { 9, "MMC2", NULL, NULL, NULL, mapper9_w, mapper9_latch, NULL, NULL}, |
| 11061 | { 10, "MMC4", NULL, NULL, NULL, mapper10_w, mapper9_latch, NULL, NULL }, |
| 11062 | { 11, "Color Dreams", NULL, NULL, NULL, mapper11_w, NULL, NULL, NULL }, |
| 11063 | { 12, "Rex Soft DBZ5", mapper12_l_w, mapper12_l_r, NULL, mapper12_w, NULL, NULL, mapper4_irq }, |
| 11064 | { 13, "CP-ROM", NULL, NULL, NULL, mapper13_w, NULL, NULL, NULL }, |
| 11065 | { 14, "Rex Soft SL1632", NULL, NULL, NULL, mapper14_w, NULL, NULL, mapper4_irq }, |
| 11066 | { 15, "100-in-1", NULL, NULL, NULL, mapper15_w, NULL, NULL, NULL }, |
| 11067 | { 16, "Bandai LZ93D50 - 24C02", NULL, NULL, mapper16_m_w, mapper16_w, NULL,NULL, bandai_irq }, |
| 11068 | { 17, "FFE F8xxx", mapper17_l_w, NULL, NULL, NULL, NULL, NULL, ffe_irq }, |
| 11069 | { 18, "Jaleco SS88006", NULL, NULL, NULL, mapper18_w, NULL, NULL, jaleco_irq }, |
| 11070 | { 19, "Namcot 106 + N106", mapper19_l_w, mapper19_l_r, NULL, mapper19_w, NULL, NULL, namcot_irq }, |
| 11071 | { 20, "Famicom Disk System", NULL, NULL, NULL, NULL, NULL, NULL, fds_irq }, |
| 11072 | { 21, "Konami VRC 4", NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq }, |
| 11073 | { 22, "Konami VRC 2a", NULL, NULL, NULL, konami_vrc2a_w, NULL, NULL, NULL }, |
| 11074 | { 23, "Konami VRC 2b", NULL, NULL, NULL, konami_vrc2b_w, NULL, NULL, konami_irq }, |
| 11075 | { 24, "Konami VRC 6a", NULL, NULL, NULL, konami_vrc6a_w, NULL, NULL, konami_irq }, |
| 11076 | { 25, "Konami VRC 4", NULL, NULL, NULL, konami_vrc4_w, NULL, NULL, konami_irq }, |
| 11077 | { 26, "Konami VRC 6b", NULL, NULL, NULL, konami_vrc6b_w, NULL, NULL, konami_irq }, |
| 11078 | // 27 World Hero |
| 11079 | // 28, 29, 30, 31 Unused |
| 11080 | { 32, "Irem G-101", NULL, NULL, NULL, mapper32_w, NULL, NULL, NULL }, |
| 11081 | { 33, "Taito TC0190FMC", NULL, NULL, NULL, mapper33_w, NULL, NULL, NULL }, |
| 11082 | { 34, "Nina-001", NULL, NULL, mapper34_m_w, mapper34_w, NULL, NULL, NULL }, |
| 11083 | // 35 Unused |
| 11084 | { 36, "TXC Policeman", NULL, NULL, NULL, mapper36_w, NULL, NULL, NULL }, |
| 11085 | { 37, "ZZ Board", NULL, NULL, mapper37_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11086 | { 38, "Crime Buster", NULL, NULL, mapper38_m_w, NULL, NULL, NULL, NULL }, |
| 11087 | { 39, "Subor Study n Game", NULL, NULL, NULL, mapper39_w, NULL, NULL, NULL }, |
| 11088 | { 40, "SMB2 JPN (bootleg)", NULL, NULL, NULL, mapper40_w, NULL, NULL, mapper40_irq }, |
| 11089 | { 41, "Caltron 6-in-1", NULL, NULL, mapper41_m_w, mapper41_w, NULL, NULL, NULL }, |
| 11090 | { 42, "Mario Baby", NULL, NULL, NULL, mapper42_w, NULL, NULL, NULL }, |
| 11091 | { 43, "150-in-1", NULL, NULL, NULL, mapper43_w, NULL, NULL, NULL }, |
| 11092 | { 44, "SuperBig 7-in-1", NULL, NULL, NULL, mapper44_w, NULL, NULL, mapper4_irq }, |
| 11093 | { 45, "X-in-1 MMC3", NULL, NULL, mapper45_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11094 | { 46, "Rumblestation", NULL, NULL, mapper46_m_w, mapper46_w, NULL, NULL, NULL }, |
| 11095 | { 47, "QJ Board", NULL, NULL, mapper47_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11096 | { 48, "Taito TC0190FMC PAL16R4", NULL, NULL, NULL, mapper48_w, NULL, NULL, mapper4_irq }, |
| 11097 | { 49, "Super HIK 4-in-1", NULL, NULL, mapper49_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11098 | { 50, "SMB2 JPN (bootleg 2)", mapper50_l_w, NULL, NULL, NULL, NULL, NULL, mapper50_irq }, |
| 11099 | { 51, "Ballgames 11-in-1", NULL, NULL, mapper51_m_w, mapper51_w, NULL, NULL, NULL }, |
| 11100 | { 52, "Mario 7-in-1", NULL, NULL, mapper52_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11101 | // 53 Supervision 16-in-1 |
| 11102 | // 54 Novel Diamond X-in-1 |
| 11103 | // 55 Genius SMB |
| 11104 | // 56 Kaiser KS202 |
| 11105 | { 57, "GKA 6-in-1", NULL, NULL, NULL, mapper57_w, NULL, NULL, NULL }, |
| 11106 | { 58, "GKB X-in-1", NULL, NULL, NULL, mapper58_w, NULL, NULL, NULL }, |
| 11107 | // 59 Unused |
| 11108 | // 60 4-in-1 Reset based |
| 11109 | { 61, "Tetris Family 20-in-1", NULL, NULL, NULL, mapper61_w, NULL, NULL, NULL }, |
| 11110 | { 62, "Super 700-in-1", NULL, NULL, NULL, mapper62_w, NULL, NULL, NULL }, |
| 11111 | // 63 CH001 X-in-1 |
| 11112 | { 64, "Tengen 800032", NULL, NULL, NULL, mapper64_w, NULL, NULL, mapper64_irq }, |
| 11113 | { 65, "Irem H3001", NULL, NULL, NULL, mapper65_w, NULL, NULL, irem_irq }, |
| 11114 | { 66, "Gx-ROM", NULL, NULL, NULL, mapper66_w, NULL, NULL, NULL }, |
| 11115 | { 67, "SunSoft 3", NULL, NULL, NULL, mapper67_w, NULL, NULL, mapper67_irq }, |
| 11116 | { 68, "SunSoft 4", NULL, NULL, NULL, mapper68_w, NULL, NULL, NULL }, |
| 11117 | { 69, "SunSoft FME", NULL, NULL, NULL, mapper69_w, NULL, NULL, mapper69_irq }, |
| 11118 | { 70, "74161/32 Bandai", NULL, NULL, NULL, mapper70_w, NULL, NULL, NULL }, |
| 11119 | { 71, "Camerica", NULL, NULL, mapper71_m_w, mapper71_w, NULL, NULL, NULL }, |
| 11120 | { 72, "74161/32 Jaleco", NULL, NULL, NULL, mapper72_w, NULL, NULL, NULL }, |
| 11121 | { 73, "Konami VRC 3", NULL, NULL, NULL, mapper73_w, NULL, NULL, konami_irq }, |
| 11122 | { 74, "Waixing Type A", NULL, NULL, NULL, mapper74_w, NULL, NULL, mapper4_irq }, |
| 11123 | { 75, "Konami VRC 1", NULL, NULL, NULL, mapper75_w, NULL, NULL, NULL }, |
| 11124 | { 76, "Namco 3446", NULL, NULL, NULL, mapper76_w, NULL, NULL, NULL }, |
| 11125 | { 77, "Irem LROG017", NULL, NULL, NULL, mapper77_w, NULL, NULL, NULL }, |
| 11126 | { 78, "Irem Holy Diver", NULL, NULL, NULL, mapper78_w, NULL, NULL, NULL }, |
| 11127 | { 79, "Nina-03", mapper79_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11128 | { 80, "Taito X1-005 Ver. A", NULL, NULL, mapper80_m_w, NULL, NULL, NULL, NULL }, |
| 11129 | // 81 Unused |
| 11130 | { 82, "Taito X1-017", NULL, NULL, mapper82_m_w, NULL, NULL, NULL, NULL }, |
| 11131 | { 83, "Cony", mapper83_l_w, mapper83_l_r, NULL, mapper83_w, NULL, NULL, NULL }, |
| 11132 | { 84, "Pasofami hacked images?", NULL, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11133 | { 85, "Konami VRC 7", NULL, NULL, NULL, konami_vrc7_w, NULL, NULL, konami_irq }, |
| 11134 | { 86, "Jaleco JF13", NULL, NULL, mapper86_m_w, NULL, NULL, NULL, NULL }, |
| 11135 | { 87, "74139/74", NULL, NULL, mapper87_m_w, NULL, NULL, NULL, NULL }, |
| 11136 | { 88, "Namcot 34x3", NULL, NULL, NULL, mapper88_w, NULL, NULL, NULL }, |
| 11137 | { 89, "Sunsoft 2b", NULL, NULL, NULL, mapper89_w, NULL, NULL, NULL }, |
| 11138 | // 90 JY Company Type A |
| 11139 | { 91, "HK-SF3 (bootleg)", NULL, NULL, mapper91_m_w, NULL, NULL, NULL, mapper4_irq }, |
| 11140 | { 92, "Jaleco JF19 / JF21", NULL, NULL, NULL, mapper92_w, NULL, NULL, NULL }, |
| 11141 | { 93, "Sunsoft 2A", NULL, NULL, NULL, mapper93_w, NULL, NULL, NULL }, |
| 11142 | { 94, "Capcom LS161", NULL, NULL, NULL, mapper94_w, NULL, NULL, NULL }, |
| 11143 | { 95, "Namcot 3425", NULL, NULL, NULL, mapper95_w, NULL, NULL, NULL }, |
| 11144 | { 96, "Bandai OekaKids", NULL, NULL, NULL, mapper96_w, NULL, NULL, NULL }, |
| 11145 | { 97, "Irem Kaiketsu", NULL, NULL, NULL, mapper97_w, NULL, NULL, NULL }, |
| 11146 | // 98 Unused |
| 11147 | // 99 VS. system |
| 11148 | // 100 images hacked to work with nesticle? |
| 11149 | { 101, "Jaleco?? LS161", NULL, NULL, mapper101_m_w, mapper101_w, NULL, NULL, NULL }, |
| 11150 | // 102 Unused |
| 11151 | // 103 Bootleg cart 2708 |
| 11152 | { 104, "Golden Five", NULL, NULL, NULL, mapper104_w, NULL, NULL, NULL }, |
| 11153 | // 105 Nintendo World Championship |
| 11154 | { 106, "SMB3 (bootleg)", NULL, NULL, NULL, mapper106_w, NULL, NULL, mapper106_irq }, |
| 11155 | { 107, "Magic Dragon", NULL, NULL, NULL, mapper107_w, NULL, NULL, NULL }, |
| 11156 | // 108 Whirlwind |
| 11157 | // 109, 110 Unused |
| 11158 | // 111 Ninja Ryuukenden Chinese? |
| 11159 | { 112, "Asder", NULL, NULL, NULL, mapper112_w, NULL, NULL, NULL }, |
| 11160 | { 113, "Sachen/Hacker/Nina", mapper113_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11161 | { 114, "The Lion King", NULL, NULL, mapper114_m_w, mapper114_w, NULL, NULL, mapper4_irq }, |
| 11162 | { 115, "Kasing", NULL, NULL, mapper115_m_w, mapper115_w, NULL, NULL, mapper4_irq }, |
| 11163 | // 116 Someri Team |
| 11164 | { 117, "Future Media", NULL, NULL, NULL, mapper117_w, NULL, NULL, mapper117_irq }, |
| 11165 | { 118, "TKS-ROM / TLS-ROM", NULL, NULL, NULL, mapper118_w, NULL, NULL, mapper4_irq }, |
| 11166 | { 119, "TQ-ROM", NULL, NULL, NULL, mapper119_w, NULL, NULL, mapper4_irq }, |
| 11167 | // 120 FDS bootleg |
| 11168 | { 121, "K - Panda Prince", mapper121_l_w, mapper121_l_r, NULL, mapper121_w, NULL, NULL, mapper4_irq }, |
| 11169 | // 122 Unused |
| 11170 | // 123 K H2288 |
| 11171 | // 124, 125 Unused |
| 11172 | // 126 Powerjoy 84-in-1 |
| 11173 | // 127, 128, 129, 130, 131 Unused |
| 11174 | { 132, "TXC T22211A", mapper132_l_w, mapper132_l_r, NULL, mapper132_w, NULL, NULL, NULL }, |
| 11175 | { 133, "Sachen SA72008", mapper133_l_w, NULL, mapper133_m_w, NULL, NULL, NULL, NULL }, |
| 11176 | { 134, "Family 4646B", NULL, NULL, mapper134_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11177 | // 135 Unused |
| 11178 | { 136, "Sachen TCU01", mapper136_l_w, mapper136_l_r, NULL, NULL, NULL, NULL, NULL }, |
| 11179 | { 137, "Sachen 8259D", mapper137_l_w, NULL, mapper137_m_w, NULL, NULL, NULL, NULL }, |
| 11180 | { 138, "Sachen 8259B", mapper138_l_w, NULL, mapper138_m_w, NULL, NULL, NULL, NULL }, |
| 11181 | { 139, "Sachen 8259C", mapper139_l_w, NULL, mapper139_m_w, NULL, NULL, NULL, NULL }, |
| 11182 | { 140, "Jaleco JF11", NULL, NULL, mapper_140_m_w, NULL, NULL, NULL, NULL }, |
| 11183 | { 141, "Sachen 8259A", mapper141_l_w, NULL, mapper141_m_w, NULL, NULL, NULL, NULL }, |
| 11184 | // 142 Kaiser KS7032 |
| 11185 | { 143, "Sachen TCA01", NULL, mapper143_l_r, NULL, NULL, NULL, NULL, NULL }, |
| 11186 | { 144, "AGCI 50282", NULL, NULL, NULL, mapper144_w, NULL, NULL, NULL }, //Death Race only |
| 11187 | { 145, "Sachen SA72007", mapper145_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11188 | { 146, "Sachen SA0161M", mapper79_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, // basically same as Mapper 79 (Nina006) |
| 11189 | { 147, "Sachen TCU02", mapper147_l_w, NULL, mapper147_m_w, mapper147_w, NULL, NULL, NULL }, |
| 11190 | { 148, "Sachen SA0037", NULL, NULL, NULL, mapper148_w, NULL, NULL, NULL }, |
| 11191 | { 149, "Sachen SA0036", NULL, NULL, NULL, mapper149_w, NULL, NULL, NULL }, |
| 11192 | { 150, "Sachen 74LS374B", mapper150_l_w, mapper150_l_r, mapper150_m_w, NULL, NULL, NULL, NULL }, |
| 11193 | // 151 Konami VS. system |
| 11194 | { 152, "Taito 74161/161", NULL, NULL, NULL, mapper152_w, NULL, NULL, NULL }, |
| 11195 | { 153, "Bandai LZ93D50", NULL, NULL, mapper153_m_w, mapper153_w, NULL,NULL, bandai_irq }, |
| 11196 | { 154, "Namcot 34xx", NULL, NULL, NULL, mapper154_w, NULL, NULL, NULL }, |
| 11197 | { 155, "SK-ROM", NULL, NULL, NULL, mapper1_w, NULL, NULL, NULL }, // diff compared to MMC1 concern WRAM (unsupported for MMC1 as well, atm) |
| 11198 | { 156, "Open Corp. DAOU36", NULL, NULL, NULL, mapper156_w, NULL, NULL, NULL }, |
| 11199 | { 157, "Bandai Datach Board", NULL, NULL, mapper16_m_w, mapper16_w, NULL,NULL, bandai_irq }, // no Datach Reader -> we fall back to mapper 16 |
| 11200 | { 158, "Tengen T800037", NULL, NULL, NULL, mapper158_w, NULL, NULL, mapper64_irq }, |
| 11201 | { 159, "Bandai LZ93D50 - 24C01", NULL, NULL, mapper16_m_w, mapper16_w, NULL,NULL, bandai_irq }, |
| 11202 | // 160, 161, 162 Unused |
| 11203 | // 163 Nanjing |
| 11204 | { 164, "Final Fantasy V", mapper164_l_w, NULL, NULL, mapper164_w, NULL, NULL, NULL }, |
| 11205 | // 165 Waixing SH2 |
| 11206 | { 166, "Subor Board Type 1", NULL, NULL, NULL, mapper166_w, NULL, NULL, NULL }, |
| 11207 | { 167, "Subor Board Type 2", NULL, NULL, NULL, mapper167_w, NULL, NULL, NULL }, |
| 11208 | // 168 Racermate Challenger II |
| 11209 | // 169 Unused |
| 11210 | // 170 Fujiya |
| 11211 | { 171, "Kaiser KS7058", NULL, NULL, NULL, mapper171_w, NULL, NULL, NULL }, |
| 11212 | { 172, "TXC T22211B", mapper132_l_w, mapper132_l_r, NULL, mapper172_w, NULL, NULL, NULL }, |
| 11213 | { 173, "TXC T22211C", mapper132_l_w, mapper173_l_r, NULL, mapper132_w, NULL, NULL, NULL }, |
| 11214 | // 174 Unused |
| 11215 | // 175 Kaiser KS7022 |
| 11216 | { 176, "Zhi Li Xiao Zhuan Yuan", mapper176_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11217 | { 177, "Henggedianzi Board", NULL, NULL, NULL, mapper177_w, NULL, NULL, NULL }, |
| 11218 | { 178, "San Guo Zhong Lie Zhuan", mapper178_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11219 | { 179, "Xing He Zhan Shi", mapper179_l_w, NULL, NULL, mapper179_w, NULL, NULL, NULL }, |
| 11220 | { 180, "Nihon Bussan UN-ROM", NULL, NULL, NULL, mapper180_w, NULL, NULL, NULL }, |
| 11221 | // 181 Unused |
| 11222 | { 182, "Hosenkan", NULL, NULL, NULL, mapper182_w, NULL, NULL, mapper4_irq }, |
| 11223 | // 183 FDS bootleg |
| 11224 | { 184, "Sunsoft 1", NULL, NULL, mapper184_m_w, NULL, NULL, NULL, NULL }, |
| 11225 | { 185, "CN-ROM", NULL, NULL, NULL, mapper185_w, NULL, NULL, NULL }, |
| 11226 | // 186 Fukutake |
| 11227 | { 187, "King of Fighters 96", mapper187_l_w, mapper187_l_r, NULL, mapper187_w, NULL, NULL, mapper4_irq }, |
| 11228 | { 188, "Bandai Karaoke", NULL, NULL, NULL, mapper188_w, NULL, NULL, NULL }, |
| 11229 | { 189, "TXC TW Board", mapper189_l_w, NULL, mapper189_m_w, mapper189_w, NULL, NULL, mapper4_irq }, |
| 11230 | // 190 Unused |
| 11231 | { 191, "Waixing Type B", NULL, NULL, NULL, mapper191_w, NULL, NULL, mapper4_irq }, |
| 11232 | { 192, "Waixing Type C", NULL, NULL, NULL, mapper192_w, NULL, NULL, mapper4_irq }, |
| 11233 | { 193, "Fighting Hero", NULL, NULL, mapper193_m_w, NULL, NULL, NULL, NULL }, |
| 11234 | { 194, "Waixing Type D", NULL, NULL, NULL, mapper194_w, NULL, NULL, mapper4_irq }, |
| 11235 | { 195, "Waixing Type E", NULL, NULL, NULL, mapper195_w, NULL, NULL, mapper4_irq }, |
| 11236 | { 196, "Super Mario Bros. 11", NULL, NULL, NULL, mapper196_w, NULL, NULL, mapper4_irq }, |
| 11237 | { 197, "Super Fighter 3", NULL, NULL, NULL, mapper197_w, NULL, NULL, mapper4_irq }, |
| 11238 | { 198, "Waixing Type F", NULL, NULL, NULL, mapper198_w, NULL, NULL, mapper4_irq }, |
| 11239 | { 199, "Waixing Type G", NULL, NULL, NULL, mapper199_w, NULL, NULL, mapper4_irq }, |
| 11240 | { 200, "36-in-1", NULL, NULL, NULL, mapper200_w, NULL, NULL, NULL }, |
| 11241 | { 201, "21-in-1", NULL, NULL, NULL, mapper201_w, NULL, NULL, NULL }, |
| 11242 | { 202, "150-in-1", NULL, NULL, NULL, mapper202_w, NULL, NULL, NULL }, |
| 11243 | { 203, "35-in-1", NULL, NULL, NULL, mapper203_w, NULL, NULL, NULL }, |
| 11244 | { 204, "64-in-1", NULL, NULL, NULL, mapper204_w, NULL, NULL, NULL }, |
| 11245 | { 205, "15-in-1", NULL, NULL, mapper205_m_w, mapper4_w, NULL, NULL, mapper4_irq }, |
| 11246 | { 206, "MIMIC-1", NULL, NULL, NULL, mapper206_w, NULL, NULL, mapper4_irq }, |
| 11247 | { 207, "Taito X1-005 Ver. B", NULL, NULL, mapper207_m_w, NULL, NULL, NULL, NULL }, |
| 11248 | { 208, "Gouder G3717", mapper208_l_w, mapper208_l_r, NULL, mapper208_w, NULL, NULL, mapper4_irq }, |
| 11249 | // 209 JY Company Type B |
| 11250 | // 210 Some emu uses this as Mapper 19 without some features |
| 11251 | // 211 JY Company Type C |
| 11252 | { 212, "Super HIK 300-in-1", NULL, NULL, NULL, mapper212_w, NULL, NULL, NULL }, |
| 11253 | { 213, "9999999-in-1", NULL, NULL, NULL, mapper213_w, NULL, NULL, NULL }, |
| 11254 | { 214, "Super Gun 20-in-1", NULL, NULL, NULL, mapper214_w, NULL, NULL, NULL }, |
| 11255 | { 215, "Super Game Boogerman", mapper215_l_w, NULL, NULL, mapper215_w, NULL, NULL, mapper4_irq }, |
| 11256 | { 216, "RCM GS2015", NULL, NULL, NULL, mapper216_w, NULL, NULL, NULL }, |
| 11257 | { 217, "Golden Card 6-in-1", mapper217_l_w, NULL, NULL, mapper217_w, NULL, NULL, mapper4_irq }, |
| 11258 | // 218 Unused |
| 11259 | // 219 Bootleg a9746 |
| 11260 | // 220 Summer Carnival '92?? |
| 11261 | { 221, "X-in-1 (N625092)", NULL, NULL, NULL, mapper221_w, NULL, NULL, NULL }, |
| 11262 | { 222, "Dragonninja Bootleg", NULL, NULL, NULL, mapper222_w, NULL, NULL, mapper222_irq }, |
| 11263 | // 223 Waixing Type I |
| 11264 | // 224 Waixing Type J |
| 11265 | { 225, "72-in-1 bootleg", NULL, NULL, NULL, mapper225_w, NULL, NULL, NULL }, |
| 11266 | { 226, "76-in-1 bootleg", NULL, NULL, NULL, mapper226_w, NULL, NULL, NULL }, |
| 11267 | { 227, "1200-in-1 bootleg", NULL, NULL, NULL, mapper227_w, NULL, NULL, NULL }, |
| 11268 | { 228, "Action 52", NULL, NULL, NULL, mapper228_w, NULL, NULL, NULL }, |
| 11269 | { 229, "31-in-1", NULL, NULL, NULL, mapper229_w, NULL, NULL, NULL }, |
| 11270 | { 230, "22-in-1", NULL, NULL, NULL, mapper230_w, NULL, NULL, NULL }, |
| 11271 | { 231, "20-in-1", NULL, NULL, NULL, mapper231_w, NULL, NULL, NULL }, |
| 11272 | { 232, "Quattro", NULL, NULL, mapper232_w, mapper232_w, NULL, NULL, NULL }, |
| 11273 | // 233 Super 22 Games |
| 11274 | // 234 AVE Maxi 15 |
| 11275 | // 235 Golden Game x-in-1 |
| 11276 | // 236 Game 800-in-1 |
| 11277 | // 237 Unused |
| 11278 | // 238 Bootleg 6035052 |
| 11279 | // 239 Unused |
| 11280 | { 240, "Jing Ke Xin Zhuan", mapper240_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11281 | { 241, "Education 18-in-1", NULL, mapper241_l_r, NULL, mapper241_w, NULL, NULL, NULL }, |
| 11282 | { 242, "Wai Xing Zhan Shi", NULL, NULL, NULL, mapper242_w, NULL, NULL, NULL }, |
| 11283 | { 243, "Sachen 74LS374A", mapper243_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 11284 | { 244, "Decathlon", NULL, NULL, NULL, mapper244_w, NULL, NULL, NULL }, |
| 11285 | { 245, "Waixing Type H", NULL, NULL, NULL, mapper245_w, NULL, NULL, mapper4_irq }, |
| 11286 | { 246, "Fong Shen Bang", NULL, NULL, mapper246_m_w, NULL, NULL, NULL, NULL }, |
| 11287 | // 247, 248 Unused |
| 11288 | { 249, "Waixing Security Board", mapper249_l_w, NULL, NULL, mapper249_w, NULL, NULL, mapper4_irq }, |
| 11289 | { 250, "Time Diver Avenger", NULL, NULL, NULL, mapper250_w, NULL, NULL, mapper4_irq }, |
| 11290 | // 251 Shen Hua Jian Yun III?? |
| 11291 | { 252, "Waixing San Guo Zhi", NULL, NULL, NULL, mapper252_w, NULL, NULL, konami_irq }, |
| 11292 | // 253 Super 8-in-1 99 King Fighter?? |
| 11293 | // 254 Pikachu Y2K |
| 11294 | { 255, "110-in-1", NULL, NULL, NULL, mapper255_w, NULL, NULL, NULL }, |
| 9200 | 11295 | }; |
| 9201 | 11296 | |
| 9202 | 11297 | |
| r5997 | r5998 | |
| 9255 | 11350 | |
| 9256 | 11351 | MMC5_vram_control = 0; |
| 9257 | 11352 | |
| 11353 | /* Point the WRAM/battery area to the first RAM bank */ |
| 11354 | if (mmc_num != 20) |
| 11355 | memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]); |
| 11356 | |
| 9258 | 11357 | /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */ |
| 9259 | 11358 | for (i = 0; i < 4; i++) |
| 9260 | | { |
| 9261 | 11359 | 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 | | } |
| 11360 | for (i = 0; i < 16; i++) |
| 11361 | vrom_bank[i] = 0; |
| 11362 | for (i = 0; i < 16; i++) |
| 11363 | extra_bank[i] = 0; |
| 9267 | 11364 | |
| 9268 | | /* Point the WRAM/battery area to the first RAM bank */ |
| 9269 | | if (mmc_num != 20 && mmc_num != 40) |
| 9270 | | memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]); |
| 11365 | /* Finally, we init IRQ-related quantities. */ |
| 11366 | IRQ_enable = IRQ_enable_latch = 0; |
| 11367 | IRQ_count = IRQ_count_latch = 0; |
| 11368 | IRQ_toggle = 0; |
| 9271 | 11369 | |
| 9272 | 11370 | switch (mmc_num) |
| 9273 | 11371 | { |
| r5997 | r5998 | |
| 9296 | 11394 | prg32(space->machine, 0); |
| 9297 | 11395 | break; |
| 9298 | 11396 | case 3: |
| 9299 | | /* Doesn't bank-switch */ |
| 11397 | case 185: |
| 9300 | 11398 | prg32(space->machine, 0); |
| 9301 | 11399 | break; |
| 9302 | 11400 | case 4: |
| 9303 | | case 74: |
| 9304 | 11401 | case 206: |
| 9305 | 11402 | /* Only MMC3 and clones seem to use 4-screen! */ |
| 9306 | | |
| 9307 | 11403 | /* hardware uses an 8K RAM chip, but can't address the high 4K! */ |
| 9308 | 11404 | /* that much is documented for Nintendo Gauntlet boards */ |
| 9309 | 11405 | if(nes.four_screen_vram) |
| r5997 | r5998 | |
| 9315 | 11411 | set_nt_page(3, CART_NTRAM, 3, 1); |
| 9316 | 11412 | } |
| 9317 | 11413 | case 12: |
| 11414 | case 74: |
| 9318 | 11415 | case 118: |
| 9319 | 11416 | case 119: |
| 11417 | case 191: |
| 11418 | case 192: |
| 11419 | case 194: |
| 11420 | case 195: |
| 9320 | 11421 | case 196: |
| 11422 | case 245: |
| 9321 | 11423 | case 250: |
| 9322 | | /* Can switch 8k prg banks */ |
| 9323 | | IRQ_enable = 0; |
| 9324 | | IRQ_count = IRQ_count_latch = 0; |
| 9325 | | IRQ_reload = 0; |
| 9326 | | prg_bank[0] = 0xfe; |
| 9327 | | prg_bank[1] = 0xff; |
| 9328 | | MMC3_cmd = 0; |
| 11424 | prg_bank[0] = prg_bank[2] = 0xfe; // prg_bank[2] & prg_bank[3] remain always the same in most MMC3 variants |
| 11425 | prg_bank[1] = prg_bank[3] = 0xff; // but some pirate clone mappers change them after writing certain registers |
| 11426 | mmc_cmd1 = 0; |
| 9329 | 11427 | mmc_cmd2 = 0x80; |
| 9330 | 11428 | mmc_prg_base = mmc_chr_base = 0; |
| 9331 | | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11429 | mmc_prg_mask = mmc_chr_mask = 0xff; // these could be init'ed as xxx_chunks-1 and they would work the same |
| 9332 | 11430 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9333 | 11431 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 9334 | 11432 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| r5997 | r5998 | |
| 9338 | 11436 | MMC5_rom_bank_mode = 3; |
| 9339 | 11437 | MMC5_vrom_bank_mode = 0; |
| 9340 | 11438 | MMC5_vram_protect = 0; |
| 9341 | | IRQ_enable = 0; |
| 9342 | | IRQ_count = 0; |
| 9343 | 11439 | nes.mid_ram_enable = 0; |
| 9344 | 11440 | prg16_89ab(space->machine, nes.prg_chunks - 2); |
| 9345 | 11441 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9346 | 11442 | break; |
| 11443 | case 6: |
| 11444 | mmc_cmd1 = 0; |
| 11445 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11446 | prg16_89ab(space->machine, 0); |
| 11447 | prg16_cdef(space->machine, 7); |
| 11448 | break; |
| 9347 | 11449 | case 7: |
| 9348 | 11450 | /* Bankswitches 32k at a time */ |
| 9349 | 11451 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 9350 | 11452 | prg16_89ab(space->machine, 0); |
| 9351 | 11453 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9352 | 11454 | break; |
| 11455 | case 8: |
| 9353 | 11456 | case 96: |
| 9354 | | case 8: |
| 9355 | | /* Switches 16k banks at $8000, 1st 2 16k banks loaded on reset */ |
| 9356 | 11457 | prg32(space->machine, 0); |
| 9357 | 11458 | break; |
| 9358 | 11459 | case 9: |
| 9359 | | /* Can switch 8k prg banks */ |
| 9360 | | /* Note that the iNES header defines the number of banks as 8k in size, rather than 16k */ |
| 9361 | | /* Reset VROM latches */ |
| 9362 | 11460 | MMC2_regs[0] = MMC2_regs[2] = 0; |
| 9363 | 11461 | MMC2_regs[1] = MMC2_regs[3] = 0; |
| 9364 | 11462 | mmc_cmd1 = mmc_cmd2 = 0xfe; |
| r5997 | r5998 | |
| 9376 | 11474 | prg16_89ab(space->machine, 0); |
| 9377 | 11475 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9378 | 11476 | break; |
| 9379 | | case 11: /* Switches 32k banks, 1st 32k bank loaded on reset (?) May be more like mapper 7... */ |
| 11477 | case 11: |
| 11478 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; // NINA-07 has no CHRROM |
| 9380 | 11479 | prg32(space->machine, 0); |
| 9381 | 11480 | break; |
| 9382 | | case 15: /* Can switch 8k prg banks */ |
| 11481 | case 14: |
| 11482 | extra_bank[2] = 0xfe; |
| 11483 | extra_bank[3] = 0xff; |
| 11484 | extra_bank[0] = extra_bank[1] = extra_bank[4] = extra_bank[5] = extra_bank[6] = 0; |
| 11485 | extra_bank[7] = extra_bank[8] = extra_bank[9] = extra_bank[0xa] = extra_bank[0xb] = 0; |
| 11486 | map14_reg[0] = map14_reg[1] = 0; |
| 11487 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11488 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11489 | mmc_cmd1 = 0; |
| 11490 | mmc_cmd2 = 0x80; |
| 11491 | mmc_prg_base = mmc_chr_base = 0; |
| 11492 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11493 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11494 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11495 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11496 | break; |
| 11497 | case 15: |
| 9383 | 11498 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 9384 | 11499 | prg32(space->machine, 0); |
| 9385 | 11500 | break; |
| 9386 | 11501 | case 16: |
| 9387 | 11502 | case 17: |
| 9388 | 11503 | case 18: |
| 11504 | case 157: |
| 11505 | case 159: |
| 11506 | mmc_cmd1 = 0; |
| 11507 | prg16_89ab(space->machine, 0); |
| 11508 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 11509 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11510 | break; |
| 9389 | 11511 | case 19: |
| 11512 | mmc_cmd1 = 0; |
| 9390 | 11513 | prg16_89ab(space->machine, 0); |
| 9391 | 11514 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 11515 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11516 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 9392 | 11517 | break; |
| 9393 | 11518 | case 20: |
| 9394 | | IRQ_enable = IRQ_enable_latch = 0; |
| 9395 | | IRQ_count = IRQ_count_latch = 0; |
| 11519 | fds_last_side = 0; |
| 11520 | fds_count = 0; |
| 9396 | 11521 | nes_fds.motor_on = 0; |
| 9397 | 11522 | nes_fds.door_closed = 0; |
| 9398 | 11523 | nes_fds.current_side = 1; |
| r5997 | r5998 | |
| 9401 | 11526 | nes_fds.read_mode = nes_fds.write_reg = 0; |
| 9402 | 11527 | break; |
| 9403 | 11528 | case 21: |
| 9404 | | case 25: |
| 9405 | | IRQ_enable = IRQ_enable_latch = 0; |
| 9406 | | IRQ_count = IRQ_count_latch = 0; |
| 9407 | | /* fall through */ |
| 9408 | 11529 | case 22: |
| 9409 | 11530 | case 23: |
| 11531 | case 24: |
| 11532 | case 25: |
| 11533 | case 26: |
| 9410 | 11534 | case 33: |
| 11535 | case 48: |
| 11536 | case 73: |
| 11537 | case 75: |
| 11538 | case 80: |
| 11539 | case 82: |
| 11540 | case 85: |
| 11541 | case 87: |
| 11542 | case 117: |
| 11543 | case 207: |
| 11544 | case 222: |
| 11545 | case 252: |
| 11546 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9411 | 11547 | prg16_89ab(space->machine, 0); |
| 9412 | 11548 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9413 | 11549 | break; |
| r5997 | r5998 | |
| 9415 | 11551 | mmc_cmd1 = 0; |
| 9416 | 11552 | prg16_89ab(space->machine, 0); |
| 9417 | 11553 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9418 | | // set_nt_mirroring(PPU_MIRROR_HIGH); // this would be needed for Major League |
| 11554 | if (nes.crc_hack) |
| 11555 | set_nt_mirroring(PPU_MIRROR_HIGH); // needed by Major League |
| 9419 | 11556 | break; |
| 9420 | | case 24: |
| 9421 | | case 26: |
| 9422 | | case 73: |
| 9423 | | case 75: |
| 9424 | | IRQ_enable = IRQ_enable_latch = 0; |
| 9425 | | IRQ_count = IRQ_count_latch = 0; |
| 9426 | | prg16_89ab(space->machine, 0); |
| 9427 | | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9428 | | break; |
| 9429 | 11557 | case 34: |
| 9430 | | /* Can switch 32k prg banks */ |
| 9431 | 11558 | prg32(space->machine, 0); |
| 9432 | 11559 | break; |
| 9433 | 11560 | 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; |
| 11561 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11562 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11563 | mmc_cmd1 = 0; |
| 9440 | 11564 | mmc_cmd2 = 0x80; |
| 9441 | 11565 | mmc_prg_base = mmc_chr_base = 0; |
| 9442 | 11566 | mmc_prg_mask = 0x07; |
| r5997 | r5998 | |
| 9446 | 11570 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9447 | 11571 | break; |
| 9448 | 11572 | case 40: |
| 9449 | | IRQ_enable = 0; |
| 9450 | | IRQ_count = 0; |
| 9451 | | /* Who's your daddy? */ |
| 9452 | | memcpy(&nes.rom[0x6000], &nes.rom[((nes.prg_chunks << 1) - 2) * 0x2000 + 0x10000], 0x2000); |
| 9453 | | //ugly hack to deal with iNES header usage of chunk count. |
| 9454 | | prg8_89(space->machine, (nes.prg_chunks << 1) - 4); |
| 9455 | | prg8_ab(space->machine, (nes.prg_chunks << 1) - 3); |
| 9456 | | prg8_cd(space->machine, 0); |
| 9457 | | prg8_ef(space->machine, (nes.prg_chunks << 1) - 1); |
| 11573 | prg8_67(space->machine, 0xfe); |
| 11574 | prg8_89(space->machine, 0xfc); |
| 11575 | prg8_ab(space->machine, 0xfd); |
| 11576 | prg8_cd(space->machine, 0xfe); |
| 11577 | prg8_ef(space->machine, 0xff); |
| 9458 | 11578 | break; |
| 9459 | 11579 | case 41: |
| 9460 | 11580 | mmc_cmd1 = 0; |
| r5997 | r5998 | |
| 9470 | 11590 | case 44: |
| 9471 | 11591 | case 47: |
| 9472 | 11592 | case 49: |
| 9473 | | IRQ_enable = 0; |
| 9474 | | IRQ_count = IRQ_count_latch = 0; |
| 9475 | | IRQ_reload = 0; |
| 9476 | | prg_bank[0] = 0xfe; |
| 9477 | | prg_bank[1] = 0xff; |
| 9478 | | MMC3_cmd = 0; |
| 11593 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11594 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11595 | mmc_cmd1 = 0; |
| 9479 | 11596 | mmc_cmd2 = 0x80; |
| 9480 | 11597 | mmc_prg_base = mmc_chr_base = 0; |
| 9481 | 11598 | mmc_prg_mask = 0x0f; |
| r5997 | r5998 | |
| 9485 | 11602 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9486 | 11603 | break; |
| 9487 | 11604 | case 45: |
| 9488 | | IRQ_enable = 0; |
| 9489 | | IRQ_count = IRQ_count_latch = 0; |
| 9490 | | IRQ_reload = 0; |
| 9491 | | prg_bank[0] = 0xfe; |
| 9492 | | prg_bank[1] = 0xff; |
| 11605 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11606 | prg_bank[1] = prg_bank[3] = 0xff; |
| 9493 | 11607 | mmc_cmd1 = 0; |
| 9494 | 11608 | mmc_cmd2 = 0x80; |
| 9495 | 11609 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| r5997 | r5998 | |
| 9506 | 11620 | prg32(space->machine, 0); |
| 9507 | 11621 | chr8(space->machine, 0, CHRROM); |
| 9508 | 11622 | break; |
| 11623 | case 50: |
| 11624 | prg8_67(space->machine, 0x0f); |
| 11625 | prg8_89(space->machine, 0x08); |
| 11626 | prg8_ab(space->machine, 0x09); |
| 11627 | prg8_cd(space->machine, 0); |
| 11628 | prg8_ef(space->machine, 0x0b); |
| 11629 | break; |
| 11630 | case 51: |
| 11631 | mapper51_reg[0] = 0x01; |
| 11632 | mapper51_reg[1] = 0x00; |
| 11633 | mapper51_set_banks(space->machine); |
| 11634 | break; |
| 9509 | 11635 | case 52: |
| 9510 | | IRQ_enable = 0; |
| 9511 | | IRQ_count = IRQ_count_latch = 0; |
| 9512 | | IRQ_reload = 0; |
| 9513 | 11636 | prg_bank[0] = 0xfe; |
| 11637 | prg_bank[2] = 0xfe; |
| 9514 | 11638 | prg_bank[1] = 0xff; |
| 11639 | prg_bank[3] = 0xff; |
| 9515 | 11640 | mmc_cmd1 = 0; |
| 9516 | 11641 | mmc_cmd2 = 0x80; |
| 9517 | 11642 | map52_reg_written = 0; |
| r5997 | r5998 | |
| 9524 | 11649 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9525 | 11650 | memory_set_bankptr(space->machine, 5, nes.wram); |
| 9526 | 11651 | break; |
| 9527 | | case 51: |
| 9528 | | mapper51_reg[0] = 0x01; |
| 9529 | | mapper51_reg[1] = 0x00; |
| 9530 | | mapper51_reg[2] = 0x00; |
| 9531 | | mapper51_set_banks(space->machine); |
| 9532 | | break; |
| 9533 | 11652 | case 57: |
| 9534 | 11653 | mmc_cmd1 = 0x00; |
| 9535 | 11654 | mmc_cmd2 = 0x00; |
| r5997 | r5998 | |
| 9547 | 11666 | prg32(space->machine, 0); |
| 9548 | 11667 | break; |
| 9549 | 11668 | case 64: |
| 9550 | | /* Can switch 3 8k prg banks */ |
| 11669 | case 158: |
| 11670 | mmc_cmd1 = 0; |
| 9551 | 11671 | prg16_89ab(space->machine, nes.prg_chunks - 1); |
| 9552 | 11672 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9553 | 11673 | break; |
| 9554 | 11674 | case 65: |
| 9555 | | IRQ_enable = 0; |
| 9556 | | IRQ_count = 0; |
| 9557 | | prg16_89ab(space->machine, 0); |
| 9558 | | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9559 | | break; |
| 9560 | 11675 | case 67: |
| 9561 | | case 68: |
| 9562 | 11676 | case 69: |
| 9563 | 11677 | case 71: |
| 9564 | 11678 | case 72: |
| 9565 | 11679 | case 78: |
| 9566 | 11680 | case 92: |
| 9567 | | IRQ_enable = IRQ_enable_latch = 0; |
| 9568 | | IRQ_count = IRQ_count_latch = 0; |
| 9569 | 11681 | prg16_89ab(space->machine, 0); |
| 9570 | 11682 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9571 | 11683 | break; |
| 11684 | case 68: |
| 11685 | m68_mirror = m0 = m1 = 0; |
| 11686 | prg16_89ab(space->machine, 0); |
| 11687 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 11688 | break; |
| 9572 | 11689 | case 70: |
| 9573 | 11690 | prg16_89ab(space->machine, nes.prg_chunks - 2); |
| 9574 | 11691 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| r5997 | r5998 | |
| 9598 | 11715 | chr8(space->machine, 0, CHRROM); |
| 9599 | 11716 | prg32(space->machine, 0); |
| 9600 | 11717 | break; |
| 9601 | | case 80: |
| 9602 | | case 207: |
| 9603 | | case 82: |
| 9604 | | case 85: |
| 9605 | | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9606 | | prg16_89ab(space->machine, 0); |
| 9607 | | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9608 | | break; |
| 9609 | | // case 70: |
| 9610 | | case 87: |
| 9611 | 11718 | case 228: |
| 9612 | | prg16_89ab(space->machine, 0); |
| 9613 | | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 11719 | chr8(space->machine, 0, CHRROM); |
| 11720 | prg32(space->machine, 0); |
| 9614 | 11721 | break; |
| 9615 | 11722 | case 83: |
| 9616 | 11723 | mapper83_reg[9] = 0x0f; |
| r5997 | r5998 | |
| 9670 | 11777 | prg16_89ab(space->machine, 0x00); |
| 9671 | 11778 | prg16_cdef(space->machine, 0x0f); |
| 9672 | 11779 | break; |
| 11780 | case 106: |
| 11781 | prg8_89(space->machine, (nes.prg_chunks << 1) - 1); |
| 11782 | prg8_ab(space->machine, 0); |
| 11783 | prg8_cd(space->machine, 0); |
| 11784 | prg8_ef(space->machine, (nes.prg_chunks << 1) - 1); |
| 11785 | break; |
| 9673 | 11786 | case 114: |
| 9674 | | IRQ_enable = 0; |
| 9675 | | IRQ_count = IRQ_count_latch = 0; |
| 9676 | | IRQ_reload = 0; |
| 9677 | 11787 | map114_reg = map114_reg_enabled = 0; |
| 9678 | | prg_bank[0] = 0xfe; |
| 9679 | | prg_bank[1] = 0xff; |
| 9680 | | MMC3_cmd = 0; |
| 11788 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11789 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11790 | mmc_cmd1 = 0; |
| 9681 | 11791 | mmc_cmd2 = 0x80; |
| 9682 | 11792 | mmc_prg_base = mmc_chr_base = 0; |
| 9683 | 11793 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| r5997 | r5998 | |
| 9686 | 11796 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9687 | 11797 | break; |
| 9688 | 11798 | case 115: |
| 9689 | | mapper115_reg[0] = mapper115_reg[1] = mapper115_reg[2] = mapper115_reg[3] = 0; |
| 9690 | | prg32(space->machine, 0xff); |
| 11799 | mapper115_reg[0] = 0; |
| 11800 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11801 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11802 | mmc_cmd1 = 0; |
| 11803 | mmc_cmd2 = 0x80; |
| 11804 | mmc_prg_base = mmc_chr_base = 0; |
| 11805 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11806 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11807 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11808 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 9691 | 11809 | break; |
| 11810 | case 121: |
| 11811 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11812 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11813 | mapper121_reg[0] = mapper121_reg[1] = mapper121_reg[2] = 0; |
| 11814 | mmc_cmd1 = 0; |
| 11815 | mmc_cmd2 = 0x80; |
| 11816 | mmc_prg_base = mmc_chr_base = 0; |
| 11817 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11818 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11819 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11820 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11821 | break; |
| 9692 | 11822 | case 132: |
| 9693 | 11823 | case 172: |
| 9694 | 11824 | case 173: |
| 9695 | 11825 | txc_reg[0] = txc_reg[1] = txc_reg[2] = txc_reg[3] = 0; |
| 9696 | 11826 | prg32(space->machine, 0); |
| 9697 | 11827 | break; |
| 11828 | case 134: |
| 11829 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11830 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11831 | mmc_cmd1 = 0; |
| 11832 | mmc_cmd2 = 0x80; |
| 11833 | mmc_prg_base = mmc_chr_base = 0; |
| 11834 | mmc_prg_mask = 0x1f; |
| 11835 | mmc_chr_mask = 0xff; |
| 11836 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11837 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11838 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11839 | break; |
| 9698 | 11840 | case 166: |
| 9699 | 11841 | subor_reg[0] = subor_reg[1] = subor_reg[2] = subor_reg[3] = 0; |
| 9700 | 11842 | prg16_89ab(space->machine, 0); |
| r5997 | r5998 | |
| 9718 | 11860 | case 138: |
| 9719 | 11861 | case 139: |
| 9720 | 11862 | case 141: |
| 11863 | mmc_cmd1 = 0; |
| 9721 | 11864 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9722 | | mmc_cmd1 = 0; |
| 9723 | 11865 | prg32(space->machine, 0); |
| 9724 | 11866 | chr8(space->machine, 0, mmc_chr_source); |
| 9725 | 11867 | set_nt_mirroring(PPU_MIRROR_VERT); |
| r5997 | r5998 | |
| 9749 | 11891 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9750 | 11892 | chr8(space->machine, 0, CHRROM); |
| 9751 | 11893 | break; |
| 11894 | case 153: |
| 11895 | mmc_cmd1 = 0; |
| 11896 | prg16_89ab(space->machine, 0); |
| 11897 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 11898 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11899 | // Famicom Jump II needs also the following! |
| 11900 | for (i = 0; i < 8; i++) |
| 11901 | map153_reg[i] = 0; |
| 11902 | |
| 11903 | map153_bank_latch = 0; |
| 11904 | if (nes.crc_hack) |
| 11905 | mapper153_set_prg(space->machine); |
| 11906 | break; |
| 9752 | 11907 | case 154: |
| 9753 | 11908 | prg16_89ab(space->machine, nes.prg_chunks - 2); |
| 9754 | 11909 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| r5997 | r5998 | |
| 9774 | 11929 | prg16_cdef(space->machine, 0); |
| 9775 | 11930 | break; |
| 9776 | 11931 | case 182: |
| 9777 | | IRQ_enable = 0; |
| 9778 | | IRQ_count = 0; |
| 9779 | 11932 | prg32(space->machine, (nes.prg_chunks - 1) >> 1); |
| 9780 | 11933 | break; |
| 9781 | 11934 | case 188: |
| 9782 | 11935 | prg16_89ab(space->machine, 0); |
| 9783 | 11936 | prg16_cdef(space->machine, (nes.prg_chunks - 1) ^ 0x08); |
| 9784 | 11937 | break; |
| 11938 | case 187: |
| 11939 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11940 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11941 | mapper187_reg[0] = mapper187_reg[1] = mapper187_reg[2] = mapper187_reg[3] = 0; |
| 11942 | mmc_cmd1 = 0; |
| 11943 | mmc_cmd2 = 0x80; |
| 11944 | mmc_prg_base = mmc_chr_base = 0; |
| 11945 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11946 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11947 | mapper187_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11948 | mapper187_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11949 | break; |
| 11950 | case 189: |
| 11951 | mmc_cmd1 = 0; |
| 11952 | mmc_cmd2 = 0x80; |
| 11953 | mmc_chr_base = 0; |
| 11954 | mmc_chr_mask = 0xff; |
| 11955 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11956 | prg32(space->machine, 0); |
| 11957 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11958 | break; |
| 9785 | 11959 | case 193: |
| 9786 | 11960 | prg32(space->machine, (nes.prg_chunks - 1) >> 1); |
| 9787 | 11961 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 9788 | 11962 | break; |
| 11963 | case 197: |
| 11964 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 11965 | prg_bank[1] = prg_bank[3] = 0xff; |
| 11966 | mmc_cmd1 = 0; |
| 11967 | mmc_cmd2 = 0x80; |
| 11968 | mmc_prg_base = mmc_chr_base = 0; |
| 11969 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11970 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11971 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11972 | mapper197_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11973 | break; |
| 11974 | case 198: |
| 11975 | prg_bank[0] = 0x00; |
| 11976 | prg_bank[1] = 0x01; |
| 11977 | prg_bank[2] = 0x4e; |
| 11978 | prg_bank[3] = 0x4f; |
| 11979 | mmc_cmd1 = 0; |
| 11980 | mmc_cmd2 = 0x80; |
| 11981 | mmc_prg_base = mmc_chr_base = 0; |
| 11982 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11983 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11984 | mapper198_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11985 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 11986 | break; |
| 11987 | case 199: |
| 11988 | prg_bank[0] = 0x00; |
| 11989 | prg_bank[1] = 0x01; |
| 11990 | prg_bank[2] = 0x3e; |
| 11991 | prg_bank[3] = 0x3f; |
| 11992 | mmc_cmd1 = 0; |
| 11993 | mmc_cmd2 = 0x80; |
| 11994 | mmc_prg_base = mmc_chr_base = 0; |
| 11995 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 11996 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 11997 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 11998 | mapper199_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 11999 | break; |
| 9789 | 12000 | case 200: |
| 9790 | 12001 | prg16_89ab(space->machine, nes.prg_chunks - 1); |
| 9791 | 12002 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| r5997 | r5998 | |
| 9803 | 12014 | prg16_cdef(space->machine, 0); |
| 9804 | 12015 | chr8(space->machine, 0, CHRROM); |
| 9805 | 12016 | break; |
| 12017 | case 205: |
| 12018 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 12019 | prg_bank[1] = prg_bank[3] = 0xff; |
| 12020 | mmc_cmd1 = 0; |
| 12021 | mmc_cmd2 = 0x80; |
| 12022 | mmc_prg_base = 0x10; |
| 12023 | mmc_prg_mask = 0x1f; |
| 12024 | mmc_chr_base = 0; |
| 12025 | mmc_chr_mask = 0xff; |
| 12026 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12027 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 12028 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 12029 | break; |
| 12030 | case 208: |
| 12031 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 12032 | prg_bank[1] = prg_bank[3] = 0xff; |
| 12033 | map208_reg[0] = map208_reg[1] = map208_reg[2] = map208_reg[3] = map208_reg[4] = 0; |
| 12034 | mmc_cmd1 = 0; |
| 12035 | mmc_cmd2 = 0x80; |
| 12036 | mmc_prg_base = mmc_chr_base = 0; |
| 12037 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 12038 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12039 | mapper4_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 12040 | mapper4_set_chr(space->machine, mmc_chr_source, mmc_chr_base, mmc_chr_mask); |
| 12041 | break; |
| 9806 | 12042 | case 212: |
| 9807 | 12043 | chr8(space->machine, 0xff, CHRROM); |
| 9808 | 12044 | prg32(space->machine, 0xff); |
| 9809 | 12045 | break; |
| 12046 | case 215: |
| 12047 | prg_bank[0] = 0x00; |
| 12048 | prg_bank[2] = 0xfe; |
| 12049 | prg_bank[1] = 0x01; |
| 12050 | prg_bank[3] = 0xff; |
| 12051 | mmc_cmd1 = 0; |
| 12052 | mmc_cmd2 = 0x80; |
| 12053 | map215_reg[0] = 0x00; |
| 12054 | map215_reg[1] = 0xff; |
| 12055 | map215_reg[2] = 0x04; |
| 12056 | map215_reg[3] = 0; |
| 12057 | mmc_prg_base = 0; |
| 12058 | mmc_prg_mask = 0x1f; |
| 12059 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12060 | mapper215_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 12061 | mapper215_set_chr(space->machine, mmc_chr_source); |
| 12062 | break; |
| 9810 | 12063 | case 216: |
| 9811 | 12064 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 9812 | 12065 | prg32(space->machine, 0); |
| 9813 | 12066 | chr8(space->machine, 0, mmc_chr_source); |
| 9814 | 12067 | break; |
| 12068 | case 217: |
| 12069 | map217_reg[0] = 0x00; |
| 12070 | map217_reg[1] = 0xff; |
| 12071 | map217_reg[2] = 0x03; |
| 12072 | map217_reg[3] = 0; |
| 12073 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 12074 | prg_bank[1] = prg_bank[3] = 0xff; |
| 12075 | mmc_cmd1 = 0; |
| 12076 | mmc_cmd2 = 0x80; |
| 12077 | mmc_prg_base = mmc_chr_base = 0; |
| 12078 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 12079 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12080 | mapper217_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 12081 | mapper217_set_chr(space->machine, mmc_chr_source); |
| 12082 | break; |
| 9815 | 12083 | case 221: |
| 9816 | 12084 | mmc_cmd1 = 0; |
| 9817 | 12085 | mmc_cmd2 = 0; |
| r5997 | r5998 | |
| 9843 | 12111 | break; |
| 9844 | 12112 | case 231: |
| 9845 | 12113 | prg16_89ab(space->machine, 0); |
| 9846 | | prg16_cdef(space->machine, 0); |
| 12114 | prg16_cdef(space->machine, nes.prg_chunks - 1); |
| 9847 | 12115 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 9848 | 12116 | break; |
| 9849 | 12117 | case 232: |
| r5997 | r5998 | |
| 9861 | 12129 | case 246: |
| 9862 | 12130 | prg32(space->machine, 0xff); |
| 9863 | 12131 | break; |
| 12132 | case 249: |
| 12133 | prg_bank[0] = prg_bank[2] = 0xfe; |
| 12134 | prg_bank[1] = prg_bank[3] = 0xff; |
| 12135 | mmc_cmd1 = 0; |
| 12136 | mmc_cmd2 = 0x80; |
| 12137 | map249_reg = 0; |
| 12138 | mmc_prg_base = mmc_chr_base = 0; |
| 12139 | mmc_prg_mask = mmc_chr_mask = 0xff; |
| 12140 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12141 | mapper249_set_prg(space->machine, mmc_prg_base, mmc_prg_mask); |
| 12142 | mapper249_set_chr(space->machine, mmc_chr_base, mmc_chr_mask); |
| 12143 | break; |
| 9864 | 12144 | default: |
| 9865 | 12145 | /* Mapper not supported */ |
| 9866 | 12146 | err = 2; |
| r5997 | r5998 | |
| 9879 | 12159 | |
| 9880 | 12160 | *************************************************************/ |
| 9881 | 12161 | |
| 12162 | enum |
| 12163 | { |
| 12164 | CHRRAM_0 = 0, |
| 12165 | CHRRAM_1, |
| 12166 | CHRRAM_2, |
| 12167 | CHRRAM_4, |
| 12168 | CHRRAM_6, |
| 12169 | CHRRAM_8, |
| 12170 | CHRRAM_16, |
| 12171 | CHRRAM_32 |
| 12172 | }; |
| 12173 | |
| 12174 | enum |
| 12175 | { |
| 12176 | NROM = 0, |
| 12177 | SACHEN_8259A |
| 12178 | }; |
| 12179 | |
| 9882 | 12180 | static const unif unif_list[] = |
| 9883 | 12181 | { |
| 9884 | | /* UNIF LOW_W, LOW_R, MED_W, HIGH_W, PPU_latch, scanline CB, hblank CB */ |
| 9885 | | { "UNL-Sachen-8259A", mapper141_l_w, NULL, mapper141_m_w, NULL, NULL, NULL, NULL }, |
| 12182 | /* UNIF LOW_W, LOW_R, MED_W, HIGH_W, PPU_latch, scanline CB, hblank CB PRG CHR NVW WRAM CRAM NMT IDX*/ |
| 12183 | { "UNL-SACHEN-8259A", mapper141_l_w, NULL, mapper141_m_w, NULL, NULL, NULL, NULL, 256, 256, 0, 0, CHRRAM_0, 0, SACHEN_8259A}, |
| 9886 | 12184 | }; |
| 9887 | 12185 | |
| 9888 | 12186 | const unif *nes_unif_lookup( const char *board ) |
| r5997 | r5998 | |
| 9890 | 12188 | int i; |
| 9891 | 12189 | for (i = 0; i < sizeof(unif_list) / sizeof(unif_list[0]); i++) |
| 9892 | 12190 | { |
| 9893 | | if (unif_list[i].board == board) |
| 12191 | if (!mame_stricmp(unif_list[i].board, board)) |
| 9894 | 12192 | return &unif_list[i]; |
| 9895 | 12193 | } |
| 9896 | 12194 | return NULL; |
| 9897 | 12195 | } |
| 12196 | |
| 12197 | |
| 12198 | // WIP code - not very satisfactory... we would end up with a lot of duplicate code... |
| 12199 | int unif_reset( running_machine *machine, const char *board ) |
| 12200 | { |
| 12201 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 12202 | nes_state *state = machine->driver_data; |
| 12203 | int err = 0; |
| 12204 | const unif *unif_board; |
| 12205 | |
| 12206 | if (nes.chr_chunks == 0) |
| 12207 | chr8(machine, 0,CHRRAM); |
| 12208 | else |
| 12209 | chr8(machine, 0,CHRROM); |
| 12210 | |
| 12211 | /* Set the mapper irq callback */ |
| 12212 | unif_board = nes_unif_lookup(board); |
| 12213 | |
| 12214 | if (unif_board == NULL) |
| 12215 | fatalerror("Unimplemented UNIF Board"); |
| 12216 | |
| 12217 | ppu2c0x_set_scanline_callback(state->ppu, unif_board ? unif_board->mmc_scanline : NULL); |
| 12218 | ppu2c0x_set_hblank_callback(state->ppu, unif_board ? unif_board->mmc_hblank : NULL); |
| 12219 | |
| 12220 | if (!nes_irq_timer) |
| 12221 | nes_irq_timer = timer_alloc(machine, nes_irq_callback, NULL); |
| 12222 | |
| 12223 | /* Point the WRAM/battery area to the first RAM bank */ |
| 12224 | memory_set_bankptr(space->machine, 5, &nes.wram[0x0000]); |
| 12225 | |
| 12226 | switch (unif_board->board_idx) |
| 12227 | { |
| 12228 | case SACHEN_8259A: |
| 12229 | mmc_cmd1 = 0; |
| 12230 | mmc_chr_source = nes.chr_chunks ? CHRROM : CHRRAM; |
| 12231 | prg32(space->machine, 0); |
| 12232 | chr8(space->machine, 0, mmc_chr_source); |
| 12233 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 12234 | break; |
| 12235 | default: |
| 12236 | /* Mapper not supported */ |
| 12237 | err = 2; |
| 12238 | break; |
| 12239 | } |
| 12240 | return err; |
| 12241 | } |
| 12242 | |