src/mess/machine/nes_mmc.c
| r5302 | r5303 | |
| 1 | 1 | /* |
| 2 | 2 | TODO: |
| 3 | 3 | . 5 has some issues, RAM banking needs hardware flags to determine size |
| 4 | | . 13 needs banked VRAM. -see Videomation |
| 5 | 4 | . 45 mapper is not fully working |
| 6 | 5 | . 51 only half of the games work |
| 7 | 6 | . 64 has some IRQ problems - see Skull & Crossbones |
| r5302 | r5303 | |
| 10 | 9 | . 82 has chr-rom banking problems. Also mapper is in the middle of sram, which is unemulated. |
| 11 | 10 | . 96 is preliminary. |
| 12 | 11 | . 118 mirroring is a guess, chr-rom banking is likely different |
| 13 | | . 193 Missing PPU feature? |
| 14 | 12 | . 228 seems wrong |
| 15 | 13 | . 229 is preliminary |
| 16 | 14 | . 230 not working yet |
| r5302 | r5303 | |
| 35 | 33 | #define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0) |
| 36 | 34 | #define LOG_FDS(x) do { if (VERBOSE) logerror x; } while (0) |
| 37 | 35 | |
| 36 | /*PPU fast banking constants and structures */ |
| 37 | |
| 38 | #define CHRROM 0 |
| 39 | #define CHRRAM 1 |
| 40 | |
| 41 | typedef struct |
| 42 | { |
| 43 | int source; //defines source of base pointer |
| 44 | int origin; //defines offset of 0x400 byte segment at base pointer |
| 45 | UINT8* access; //source translated + origin -> valid pointer! |
| 46 | } chr_bank; |
| 47 | |
| 48 | /*PPU nametable fast banking constants and structures */ |
| 49 | |
| 50 | #define CIRAM 0 |
| 51 | #define ROM 1 |
| 52 | #define EXRAM 2 |
| 53 | |
| 54 | typedef struct |
| 55 | { |
| 56 | int source; //defines source of base pointer |
| 57 | int origin; //defines offset of 0x400 byte segment at base pointer |
| 58 | int writable; //ExRAM, at least, can be write-protected AND used as nametable |
| 59 | UINT8* access; //source translated + origin -> valid pointer! |
| 60 | } name_table; |
| 61 | |
| 38 | 62 | /* Global variables */ |
| 39 | 63 | static int prg_mask; |
| 40 | 64 | |
| 65 | static chr_bank chr_map[8]; //quick banking structure, because some of this changes multiple times per scanline! |
| 66 | static name_table nt_page[4]; //quick banking structure for a maximum of 4K of RAM/ROM/ExRAM |
| 67 | |
| 41 | 68 | static int IRQ_enable, IRQ_enable_latch; |
| 42 | 69 | static UINT16 IRQ_count, IRQ_count_latch, IRQ_reload; |
| 43 | 70 | static UINT8 IRQ_status; |
| r5302 | r5303 | |
| 95 | 122 | |
| 96 | 123 | static emu_timer *nes_irq_timer; |
| 97 | 124 | |
| 125 | void set_nt_page(int page, int source, int bank, int writable); |
| 126 | |
| 98 | 127 | static TIMER_CALLBACK(nes_irq_callback) |
| 99 | 128 | { |
| 100 | 129 | cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE); |
| 101 | 130 | timer_adjust_oneshot(nes_irq_timer, attotime_never, 0); |
| 102 | 131 | } |
| 103 | 132 | |
| 133 | WRITE8_HANDLER( nes_chr_w) |
| 134 | { |
| 135 | int bank =offset>>10; |
| 136 | if(chr_map[bank].source == CHRRAM) |
| 137 | { |
| 138 | chr_map[bank].access[offset&0x3FF]=data; |
| 139 | } |
| 140 | } |
| 141 | READ8_HANDLER( nes_chr_r) |
| 142 | { |
| 143 | int bank =offset>>10; |
| 144 | return chr_map[bank].access[offset&0x3FF]; |
| 145 | } |
| 146 | |
| 147 | WRITE8_HANDLER(nes_nt_w) |
| 148 | { |
| 149 | int page=((offset&0xC00)>>10); |
| 150 | if(nt_page[page].writable ==0) |
| 151 | return; |
| 152 | nt_page[page].access[offset&0x3FF]=data; |
| 153 | } |
| 154 | READ8_HANDLER(nes_nt_r) |
| 155 | { |
| 156 | int page=((offset&0xC00)>>10); |
| 157 | return nt_page[page].access[offset&0x3FF]; |
| 158 | } |
| 159 | |
| 104 | 160 | WRITE8_HANDLER( nes_low_mapper_w ) |
| 105 | 161 | { |
| 106 | 162 | if (mmc_write_low) (*mmc_write_low)(space, offset, data); |
| r5302 | r5303 | |
| 133 | 189 | if (mmc_write_mid) (*mmc_write_mid)(space, offset, data); |
| 134 | 190 | else if (nes.mid_ram_enable) |
| 135 | 191 | nes_battery_ram[offset] = data; |
| 136 | | // else |
| 192 | else |
| 137 | 193 | { |
| 138 | 194 | logerror("Unimplemented MID mapper write, offset: %04x, data: %02x\n", offset, data); |
| 139 | 195 | #ifdef MAME_DEBUG |
| r5302 | r5303 | |
| 185 | 241 | * Some helpful routines used by the mappers |
| 186 | 242 | */ |
| 187 | 243 | |
| 244 | void ppu_mirror_custom (int page, int address) |
| 245 | { |
| 246 | fatalerror("Unimplemented: custom NT mirroring"); |
| 247 | } |
| 248 | |
| 249 | void ppu_mirror_MMC5 (int page, int src) |
| 250 | { |
| 251 | switch(src) |
| 252 | { |
| 253 | case 0://CIRAM0 |
| 254 | set_nt_page(page, CIRAM, 0,1); |
| 255 | break; |
| 256 | case 1://CIRAM1 |
| 257 | set_nt_page(page, CIRAM, 1,1); |
| 258 | break; |
| 259 | case 2://ExRAM |
| 260 | set_nt_page(page, EXRAM,0,1);//actually only works during rendering. |
| 261 | break; |
| 262 | case 3://FillRegisters -useless without dot-based PPU, in general |
| 263 | //break; |
| 264 | default: fatalerror("Unimplemented: Fill support"); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | void ppu_mirror_custom_vrom (int page, int address) |
| 269 | { |
| 270 | set_nt_page(page, ROM, address,0); |
| 271 | } |
| 272 | |
| 188 | 273 | static void prg8_89 (const address_space *space, int bank) |
| 189 | 274 | { |
| 190 | 275 | /* assumes that bank references an 8k chunk */ |
| r5302 | r5303 | |
| 266 | 351 | } |
| 267 | 352 | } |
| 268 | 353 | |
| 269 | | static void chr8 (running_machine *machine, int bank) |
| 354 | void set_nt_page(int page, int source, int bank, int writable) |
| 270 | 355 | { |
| 271 | | nes_state *state = machine->driver_data; |
| 272 | | bank &= (nes.chr_chunks - 1); |
| 273 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 8, bank, 512); |
| 356 | UINT8* base_ptr; |
| 357 | |
| 358 | switch(source) |
| 359 | { |
| 360 | case ROM:base_ptr=nes.vrom; |
| 361 | case EXRAM:base_ptr=nes.exram; |
| 362 | case CIRAM: |
| 363 | default: base_ptr=nes.ciram; |
| 364 | } |
| 365 | |
| 366 | page&=3; //mask down to the 4 logical pages |
| 367 | nt_page[page].source=source; |
| 368 | nt_page[page].origin=bank*0x400; |
| 369 | nt_page[page].access=base_ptr+nt_page[page].origin; |
| 370 | nt_page[page].writable=writable; |
| 274 | 371 | } |
| 275 | 372 | |
| 276 | | static void chr4_0 (running_machine *machine, int bank) |
| 373 | void set_nt_mirroring(int mirroring ) |
| 277 | 374 | { |
| 278 | | nes_state *state = machine->driver_data; |
| 279 | | bank &= ((nes.chr_chunks << 1) - 1); |
| 280 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 4, bank, 256); |
| 375 | /* setup our videomem handlers based on mirroring */ |
| 376 | switch( mirroring ) |
| 377 | { |
| 378 | case PPU_MIRROR_VERT: |
| 379 | set_nt_page(0, CIRAM, 0, 1); |
| 380 | set_nt_page(1, CIRAM, 1, 1); |
| 381 | set_nt_page(2, CIRAM, 0, 1); |
| 382 | set_nt_page(3, CIRAM, 1, 1); |
| 383 | break; |
| 384 | |
| 385 | case PPU_MIRROR_HORZ: |
| 386 | set_nt_page(0, CIRAM, 0, 1); |
| 387 | set_nt_page(1, CIRAM, 0, 1); |
| 388 | set_nt_page(2, CIRAM, 1, 1); |
| 389 | set_nt_page(3, CIRAM, 1, 1); |
| 390 | break; |
| 391 | |
| 392 | case PPU_MIRROR_HIGH: |
| 393 | set_nt_page(0, CIRAM, 1, 1); |
| 394 | set_nt_page(1, CIRAM, 1, 1); |
| 395 | set_nt_page(2, CIRAM, 1, 1); |
| 396 | set_nt_page(3, CIRAM, 1, 1); |
| 397 | break; |
| 398 | |
| 399 | case PPU_MIRROR_LOW: |
| 400 | set_nt_page(0, CIRAM, 0, 1); |
| 401 | set_nt_page(1, CIRAM, 0, 1); |
| 402 | set_nt_page(2, CIRAM, 0, 1); |
| 403 | set_nt_page(3, CIRAM, 0, 1); |
| 404 | break; |
| 405 | |
| 406 | case PPU_MIRROR_NONE: |
| 407 | case PPU_MIRROR_4SCREEN: |
| 408 | default: |
| 409 | /* external RAM needs to be used somehow. */ |
| 410 | /* but as a default, we'll arbitrarily set vertical so as not to crash*/ |
| 411 | |
| 412 | logerror("Mapper set 4-screen mirroring without supplying external nametable memory!\n"); |
| 413 | |
| 414 | set_nt_page(0, CIRAM, 0, 1); |
| 415 | set_nt_page(1, CIRAM, 0, 1); |
| 416 | set_nt_page(2, CIRAM, 1, 1); |
| 417 | set_nt_page(3, CIRAM, 1, 1); |
| 418 | break; |
| 419 | } |
| 281 | 420 | } |
| 282 | 421 | |
| 283 | | static void chr4_4 (running_machine *machine, int bank) |
| 422 | static void chr8 (running_machine *machine, int bank, int source) |
| 284 | 423 | { |
| 285 | | nes_state *state = machine->driver_data; |
| 424 | int i; |
| 425 | //nes_state *state = machine->driver_data; |
| 426 | bank &= (nes.chr_chunks - 1); |
| 427 | |
| 428 | for(i=0;i<8;i++) |
| 429 | { |
| 430 | chr_map[i].source=source; |
| 431 | chr_map[i].origin=(bank*0x2000)+(i*0x400); //for save state uses! |
| 432 | if(source==CHRRAM) |
| 433 | chr_map[i].access=&nes.vram[chr_map[i].origin]; |
| 434 | else chr_map[i].access=&nes.vrom[chr_map[i].origin]; |
| 435 | } |
| 436 | //ppu2c0x_set_videorom_bank(state->ppu, 0, 8, bank, 512); |
| 437 | } |
| 438 | static void chr4_x (running_machine *machine, int start, int bank, int source) |
| 439 | { |
| 440 | int i; |
| 286 | 441 | bank &= ((nes.chr_chunks << 1) - 1); |
| 287 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 4, bank, 256); |
| 442 | for(i=0;i<4;i++) |
| 443 | { |
| 444 | chr_map[i+start].source=source; |
| 445 | chr_map[i+start].origin=(bank*0x1000)+(i*0x400); //for save state uses! |
| 446 | if(source==CHRRAM) |
| 447 | chr_map[i+start].access=&nes.vram[chr_map[i+start].origin]; |
| 448 | else chr_map[i+start].access=&nes.vrom[chr_map[i+start].origin]; |
| 449 | } |
| 450 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 4, bank, 256); |
| 288 | 451 | } |
| 289 | 452 | |
| 290 | | static void chr2_0 (running_machine *machine, int bank) |
| 453 | static void chr4_0 (running_machine *machine, int bank, int source) |
| 291 | 454 | { |
| 292 | | nes_state *state = machine->driver_data; |
| 293 | | bank &= ((nes.chr_chunks << 2) - 1); |
| 294 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 2, bank, 128); |
| 455 | chr4_x(machine, 0, bank, source); |
| 295 | 456 | } |
| 296 | 457 | |
| 297 | | static void chr2_2 (running_machine *machine, int bank) |
| 458 | static void chr4_4 (running_machine *machine, int bank, int source) |
| 298 | 459 | { |
| 299 | | nes_state *state = machine->driver_data; |
| 460 | chr4_x(machine, 4, bank, source); |
| 461 | } |
| 462 | static void chr2_x (running_machine *machine, int start, int bank, int source) |
| 463 | { |
| 464 | int i; |
| 300 | 465 | bank &= ((nes.chr_chunks << 2) - 1); |
| 301 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 2, bank, 128); |
| 466 | for(i=0;i<2;i++) |
| 467 | { |
| 468 | chr_map[i+start].source=source; |
| 469 | chr_map[i+start].origin=(bank*0x800)+(i*0x400); |
| 470 | if(source==CHRRAM) |
| 471 | chr_map[i+start].access=&nes.vram[chr_map[i+start].origin]; |
| 472 | else chr_map[i+start].access=&nes.vrom[chr_map[i+start].origin]; |
| 473 | } |
| 302 | 474 | } |
| 303 | 475 | |
| 304 | | static void chr2_4 (running_machine *machine, int bank) |
| 476 | static void chr2_0 (running_machine *machine, int bank, int source) |
| 305 | 477 | { |
| 306 | | nes_state *state = machine->driver_data; |
| 307 | | bank &= ((nes.chr_chunks << 2) - 1); |
| 308 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 2, bank, 128); |
| 478 | chr2_x(machine, 0, bank, source); |
| 309 | 479 | } |
| 310 | 480 | |
| 311 | | static void chr2_6 (running_machine *machine, int bank) |
| 481 | static void chr2_2 (running_machine *machine, int bank, int source) |
| 312 | 482 | { |
| 313 | | nes_state *state = machine->driver_data; |
| 314 | | bank &= ((nes.chr_chunks << 2) - 1); |
| 315 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 2, bank, 128); |
| 483 | chr2_x(machine, 2, bank, source); |
| 316 | 484 | } |
| 317 | | static void chr1_0 (running_machine *machine, int bank) |
| 485 | |
| 486 | static void chr2_4 (running_machine *machine, int bank, int source) |
| 318 | 487 | { |
| 319 | | nes_state *state = machine->driver_data; |
| 320 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 321 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, bank, 64); |
| 488 | chr2_x(machine, 4, bank, source); |
| 322 | 489 | } |
| 323 | | static void chr1_1 (running_machine *machine, int bank) |
| 490 | |
| 491 | static void chr2_6 (running_machine *machine, int bank, int source) |
| 324 | 492 | { |
| 325 | | nes_state *state = machine->driver_data; |
| 326 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 327 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, bank, 64); |
| 493 | chr2_x(machine, 6, bank, source); |
| 328 | 494 | } |
| 329 | | static void chr1_2 (running_machine *machine, int bank) |
| 495 | static void chr1_x (running_machine *machine, int start, int bank, int source) |
| 330 | 496 | { |
| 331 | | nes_state *state = machine->driver_data; |
| 497 | chr_map[start].source=source; |
| 332 | 498 | bank &= ((nes.chr_chunks << 3) - 1); |
| 333 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, bank, 64); |
| 499 | chr_map[start].origin=bank*0x400; |
| 500 | if(source==CHRRAM) |
| 501 | chr_map[start].access=&nes.vram[chr_map[start].origin]; |
| 502 | else chr_map[start].access=&nes.vrom[chr_map[start].origin]; |
| 334 | 503 | } |
| 335 | | static void chr1_3 (running_machine *machine, int bank) |
| 504 | static void chr1_0 (running_machine *machine, int bank, int source) |
| 336 | 505 | { |
| 337 | | nes_state *state = machine->driver_data; |
| 338 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 339 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, bank, 64); |
| 506 | chr1_x(machine, 0, bank, source); |
| 340 | 507 | } |
| 341 | | static void chr1_4 (running_machine *machine, int bank) |
| 508 | static void chr1_1 (running_machine *machine, int bank, int source) |
| 342 | 509 | { |
| 343 | | nes_state *state = machine->driver_data; |
| 344 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 345 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, bank, 64); |
| 510 | chr1_x(machine, 1, bank, source); |
| 346 | 511 | } |
| 347 | | static void chr1_5 (running_machine *machine, int bank) |
| 512 | static void chr1_2 (running_machine *machine, int bank, int source) |
| 348 | 513 | { |
| 349 | | nes_state *state = machine->driver_data; |
| 350 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 351 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, bank, 64); |
| 514 | chr1_x(machine, 2, bank, source); |
| 352 | 515 | } |
| 353 | | static void chr1_6 (running_machine *machine, int bank) |
| 516 | static void chr1_3 (running_machine *machine, int bank, int source) |
| 354 | 517 | { |
| 355 | | nes_state *state = machine->driver_data; |
| 356 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 357 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, bank, 64); |
| 518 | chr1_x(machine, 3, bank, source); |
| 358 | 519 | } |
| 359 | | static void chr1_7 (running_machine *machine, int bank) |
| 520 | static void chr1_4 (running_machine *machine, int bank, int source) |
| 360 | 521 | { |
| 361 | | nes_state *state = machine->driver_data; |
| 362 | | bank &= ((nes.chr_chunks << 3) - 1); |
| 363 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, bank, 64); |
| 522 | chr1_x(machine, 4, bank, source); |
| 364 | 523 | } |
| 524 | static void chr1_5 (running_machine *machine, int bank, int source) |
| 525 | { |
| 526 | chr1_x(machine, 5, bank, source); |
| 527 | } |
| 528 | static void chr1_6 (running_machine *machine, int bank, int source) |
| 529 | { |
| 530 | chr1_x(machine, 6, bank, source); |
| 531 | } |
| 532 | static void chr1_7 (running_machine *machine, int bank, int source) |
| 533 | { |
| 534 | chr1_x(machine, 7, bank, source); |
| 535 | } |
| 365 | 536 | |
| 366 | 537 | |
| 367 | 538 | static WRITE8_HANDLER( mapper1_w ) |
| 368 | 539 | { |
| 369 | | nes_state *state = space->machine->driver_data; |
| 370 | 540 | int reg; |
| 371 | 541 | |
| 372 | 542 | /* Find which register we are dealing with */ |
| r5302 | r5303 | |
| 406 | 576 | |
| 407 | 577 | switch (MMC1_reg & 0x03) |
| 408 | 578 | { |
| 409 | | case 0: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 410 | | case 1: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 411 | | case 2: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 412 | | case 3: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 579 | case 0: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 580 | case 1: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 581 | case 2: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 582 | case 3: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 413 | 583 | } |
| 414 | 584 | |
| 415 | 585 | MMC1_SizeVrom_4k = (MMC1_reg & 0x10); |
| r5302 | r5303 | |
| 479 | 649 | |
| 480 | 650 | if (!MMC1_SizeVrom_4k) |
| 481 | 651 | { |
| 482 | | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 483 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 8, bank, 256); |
| 652 | int bank = MMC1_reg & (nes.chr_chunks - 1); |
| 653 | //int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 654 | chr8(space->machine, bank>>1, CHRROM); |
| 655 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 8, bank, 256); |
| 484 | 656 | LOG_MMC(("MMC1 8k VROM switch: %02x\n", MMC1_reg)); |
| 485 | 657 | } |
| 486 | 658 | else |
| 487 | 659 | { |
| 488 | 660 | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 489 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 4, bank, 256); |
| 661 | chr4_0(space->machine,bank, CHRROM); |
| 662 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 4, bank, 256); |
| 490 | 663 | LOG_MMC(("MMC1 4k VROM switch (low): %02x\n", MMC1_reg)); |
| 491 | 664 | } |
| 492 | 665 | } |
| r5302 | r5303 | |
| 513 | 686 | if (MMC1_SizeVrom_4k) |
| 514 | 687 | { |
| 515 | 688 | int bank = MMC1_reg & ((nes.chr_chunks << 1) - 1); |
| 516 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 4, bank, 256); |
| 689 | chr4_4(space->machine, bank, CHRROM); |
| 690 | //ppu2c0x_set_videorom_bank(state->ppu, 4, 4, bank, 256); |
| 517 | 691 | LOG_MMC(("MMC1 4k VROM switch (high): %02x\n", MMC1_reg)); |
| 518 | 692 | } |
| 519 | 693 | break; |
| r5302 | r5303 | |
| 596 | 770 | |
| 597 | 771 | static WRITE8_HANDLER( mapper3_w ) |
| 598 | 772 | { |
| 599 | | chr8 (space->machine, data); |
| 773 | chr8 (space->machine, data, CHRROM); |
| 600 | 774 | } |
| 601 | 775 | |
| 602 | 776 | static void mapper4_set_prg ( const address_space *space) |
| r5302 | r5303 | |
| 621 | 795 | |
| 622 | 796 | static void mapper4_set_chr (running_machine *machine) |
| 623 | 797 | { |
| 624 | | nes_state *state = machine->driver_data; |
| 798 | //nes_state *state = machine->driver_data; |
| 625 | 799 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 626 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 0, 2, MMC3_chr_base * 64 | ( MMC3_chr[0] & ( MMC3_chr_mask * 64 ) ), 1); |
| 627 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 2, 2, MMC3_chr_base * 64 | ( MMC3_chr[1] & ( MMC3_chr_mask * 64 ) ), 1); |
| 628 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 4, 1, MMC3_chr_base * 64 | ( MMC3_chr[2] & ( MMC3_chr_mask * 64 ) ), 1); |
| 629 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 5, 1, MMC3_chr_base * 64 | ( MMC3_chr[3] & ( MMC3_chr_mask * 64 ) ), 1); |
| 630 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 6, 1, MMC3_chr_base * 64 | ( MMC3_chr[4] & ( MMC3_chr_mask * 64 ) ), 1); |
| 631 | | ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 7, 1, MMC3_chr_base * 64 | ( MMC3_chr[5] & ( MMC3_chr_mask * 64 ) ), 1); |
| 800 | |
| 801 | chr2_x(machine, chr_page ^ 0, MMC3_chr_base | ( (MMC3_chr[0]>>1) & ( MMC3_chr_mask ) ), CHRROM); |
| 802 | chr2_x(machine, chr_page ^ 2, MMC3_chr_base | ( (MMC3_chr[1]>>1) & ( MMC3_chr_mask ) ), CHRROM); |
| 803 | chr1_x(machine, chr_page ^4, MMC3_chr_base | (MMC3_chr[2]& ( MMC3_chr_mask ) ), CHRROM); |
| 804 | chr1_x(machine, chr_page ^5, MMC3_chr_base | (MMC3_chr[3]& ( MMC3_chr_mask ) ), CHRROM); |
| 805 | chr1_x(machine, chr_page ^6, MMC3_chr_base | (MMC3_chr[4]& ( MMC3_chr_mask ) ), CHRROM); |
| 806 | chr1_x(machine, chr_page ^7, MMC3_chr_base | (MMC3_chr[5]& ( MMC3_chr_mask ) ), CHRROM); |
| 807 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 0, 2, MMC3_chr_base * 64 | ( MMC3_chr[0] & ( MMC3_chr_mask * 64 ) ), 1); |
| 808 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 2, 2, MMC3_chr_base * 64 | ( MMC3_chr[1] & ( MMC3_chr_mask * 64 ) ), 1); |
| 809 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 4, 1, MMC3_chr_base * 64 | ( MMC3_chr[2] & ( MMC3_chr_mask * 64 ) ), 1); |
| 810 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 5, 1, MMC3_chr_base * 64 | ( MMC3_chr[3] & ( MMC3_chr_mask * 64 ) ), 1); |
| 811 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 6, 1, MMC3_chr_base * 64 | ( MMC3_chr[4] & ( MMC3_chr_mask * 64 ) ), 1); |
| 812 | //ppu2c0x_set_videorom_bank(state->ppu, chr_page ^ 7, 1, MMC3_chr_base * 64 | ( MMC3_chr[5] & ( MMC3_chr_mask * 64 ) ), 1); |
| 632 | 813 | } |
| 633 | 814 | |
| 634 | 815 | static void mapper4_irq ( const device_config *device, int scanline, int vblank, int blanked ) |
| r5302 | r5303 | |
| 655 | 836 | |
| 656 | 837 | static WRITE8_HANDLER( mapper4_w ) |
| 657 | 838 | { |
| 658 | | nes_state *state = space->machine->driver_data; |
| 659 | 839 | static UINT8 last_bank = 0xff; |
| 660 | 840 | |
| 661 | 841 | // logerror("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| r5302 | r5303 | |
| 684 | 864 | { |
| 685 | 865 | case 0: case 1: |
| 686 | 866 | data &= 0xfe; |
| 687 | | MMC3_chr[cmd] = data * 64; |
| 867 | MMC3_chr[cmd] = data; |
| 688 | 868 | mapper4_set_chr (space->machine); |
| 689 | 869 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 690 | 870 | break; |
| 691 | 871 | |
| 692 | 872 | case 2: case 3: case 4: case 5: |
| 693 | | MMC3_chr[cmd] = data * 64; |
| 873 | MMC3_chr[cmd] = data; |
| 694 | 874 | mapper4_set_chr (space->machine); |
| 695 | 875 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 696 | 876 | break; |
| r5302 | r5303 | |
| 709 | 889 | } |
| 710 | 890 | case 0x2000: /* $a000 */ |
| 711 | 891 | if (data & 0x40) |
| 712 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 892 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 713 | 893 | else |
| 714 | 894 | { |
| 715 | 895 | if (data & 0x01) |
| 716 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 896 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 717 | 897 | else |
| 718 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 898 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 719 | 899 | } |
| 720 | 900 | break; |
| 721 | 901 | |
| r5302 | r5303 | |
| 752 | 932 | |
| 753 | 933 | static WRITE8_HANDLER( mapper118_w ) |
| 754 | 934 | { |
| 755 | | nes_state *state = space->machine->driver_data; |
| 935 | //nes_state *state = space->machine->driver_data; |
| 756 | 936 | static UINT8 last_bank = 0xff; |
| 757 | 937 | |
| 758 | 938 | // logerror("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| r5302 | r5303 | |
| 780 | 960 | { |
| 781 | 961 | case 0: case 1: |
| 782 | 962 | data &= 0xfe; |
| 783 | | MMC3_chr[cmd] = data * 64; |
| 963 | MMC3_chr[cmd] = data; |
| 784 | 964 | mapper4_set_chr (space->machine); |
| 785 | 965 | break; |
| 786 | 966 | |
| 787 | 967 | case 2: case 3: case 4: case 5: |
| 788 | | MMC3_chr[cmd] = data * 64; |
| 968 | MMC3_chr[cmd] = data; |
| 789 | 969 | mapper4_set_chr (space->machine); |
| 790 | 970 | break; |
| 791 | 971 | |
| r5302 | r5303 | |
| 805 | 985 | LOG_MMC((" mapper 118 mirroring: %02x\n", data)); |
| 806 | 986 | switch (data & 0x02) |
| 807 | 987 | { |
| 808 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 809 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 988 | case 0x00: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 989 | case 0x01: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 810 | 990 | } |
| 811 | 991 | break; |
| 812 | 992 | |
| r5302 | r5303 | |
| 842 | 1022 | } |
| 843 | 1023 | } |
| 844 | 1024 | |
| 1025 | |
| 1026 | static void mapper119_set_chr (running_machine *machine) |
| 1027 | { |
| 1028 | //nes_state *state = machine->driver_data; |
| 1029 | UINT8 chr_page = (MMC3_cmd & 0x80) >> 5; |
| 1030 | if(MMC3_chr[0]&0x40) |
| 1031 | chr2_x(machine, chr_page ^ 0, (MMC3_chr[0]>>1)&3, CHRRAM); |
| 1032 | else chr2_x(machine, chr_page ^ 0, ((MMC3_chr[0])>>1), CHRROM); |
| 1033 | if(MMC3_chr[1]&0x40) |
| 1034 | chr2_x(machine, chr_page ^ 2, (MMC3_chr[1]>>1)&3, CHRRAM); |
| 1035 | else chr2_x(machine, chr_page ^ 2, (MMC3_chr[1]>>1), CHRROM); |
| 1036 | if(MMC3_chr[2]&0x40) |
| 1037 | chr1_x(machine, chr_page ^ 4, MMC3_chr[2]&7, CHRRAM); |
| 1038 | else chr1_x(machine, chr_page ^ 4, MMC3_chr[2], CHRROM); |
| 1039 | |
| 1040 | if(MMC3_chr[3]&0x40) |
| 1041 | chr1_x(machine, chr_page ^ 5, MMC3_chr[3]&7, CHRRAM); |
| 1042 | else chr1_x(machine, chr_page ^ 5, MMC3_chr[3], CHRROM); |
| 1043 | if(MMC3_chr[4]&0x40) |
| 1044 | chr1_x(machine, chr_page ^ 6, MMC3_chr[4]&7, CHRRAM); |
| 1045 | else chr1_x(machine, chr_page ^ 6, MMC3_chr[4], CHRROM); |
| 1046 | if(MMC3_chr[5]&0x40) |
| 1047 | chr1_x(machine, chr_page ^ 7, MMC3_chr[5]&7, CHRRAM); |
| 1048 | else chr1_x(machine, chr_page ^ 7, MMC3_chr[5], CHRROM); |
| 1049 | } |
| 1050 | |
| 1051 | static WRITE8_HANDLER( mapper119_w ) |
| 1052 | { |
| 1053 | //nes_state *state = space->machine->driver_data; |
| 1054 | static UINT8 last_bank = 0xff; |
| 1055 | |
| 1056 | // logerror("mapper4_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 1057 | |
| 1058 | //only bits 14,13, and 0 matter for offset! |
| 1059 | switch (offset & 0x6001) |
| 1060 | { |
| 1061 | case 0x0000: /* $8000 */ |
| 1062 | MMC3_cmd = data; |
| 1063 | |
| 1064 | /* Toggle between switching $8000 and $c000 */ |
| 1065 | if (last_bank != (data & 0xc0)) |
| 1066 | { |
| 1067 | /* Reset the banks */ |
| 1068 | mapper4_set_prg (space); |
| 1069 | mapper4_set_chr (space->machine); |
| 1070 | LOG_MMC((" MMC3 reset banks\n")); |
| 1071 | } |
| 1072 | last_bank = data & 0xc0; |
| 1073 | break; |
| 1074 | |
| 1075 | case 0x0001: /* $8001 */ |
| 1076 | { |
| 1077 | UINT8 cmd = MMC3_cmd & 0x07; |
| 1078 | switch (cmd) |
| 1079 | { |
| 1080 | case 0: case 1: |
| 1081 | //data &= 0xfe; |
| 1082 | MMC3_chr[cmd] = data; |
| 1083 | mapper119_set_chr (space->machine); |
| 1084 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 1085 | break; |
| 1086 | |
| 1087 | case 2: case 3: case 4: case 5: |
| 1088 | MMC3_chr[cmd] = data;// * 64; |
| 1089 | mapper119_set_chr (space->machine); |
| 1090 | LOG_MMC((" MMC3 set vram %d: %d\n", cmd, data)); |
| 1091 | break; |
| 1092 | |
| 1093 | case 6: |
| 1094 | MMC3_prg0 = data; |
| 1095 | mapper4_set_prg (space); |
| 1096 | break; |
| 1097 | |
| 1098 | case 7: |
| 1099 | MMC3_prg1 = data; |
| 1100 | mapper4_set_prg (space); |
| 1101 | break; |
| 1102 | } |
| 1103 | break; |
| 1104 | } |
| 1105 | case 0x2000: /* $a000 */ |
| 1106 | if (data & 0x40) |
| 1107 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 1108 | else |
| 1109 | { |
| 1110 | if (data & 0x01) |
| 1111 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1112 | else |
| 1113 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1114 | } |
| 1115 | break; |
| 1116 | |
| 1117 | case 0x2001: /* $a001 - extra RAM enable/disable */ |
| 1118 | nes.mid_ram_enable = data; |
| 1119 | LOG_MMC((" MMC3 mid_ram enable: %02x\n", 0)); |
| 1120 | break; |
| 1121 | |
| 1122 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| 1123 | IRQ_count_latch = data; |
| 1124 | // LOG_MMC((" MMC3 set irq count latch: %02x (scanline %d)\n", data, ppu2c0x_get_current_scanline(0))); |
| 1125 | break; |
| 1126 | |
| 1127 | case 0x4001: /* $c001 - IRQ scanline latch */ |
| 1128 | IRQ_reload = 1; |
| 1129 | // LOG_MMC((" MMC3 set irq reload (scanline %d)\n", ppu2c0x_get_current_scanline(0))); |
| 1130 | break; |
| 1131 | |
| 1132 | case 0x6000: /* $e000 - Disable IRQs */ |
| 1133 | IRQ_enable = 0; |
| 1134 | LOG_MMC((" MMC3 disable irqs\n")); |
| 1135 | break; |
| 1136 | |
| 1137 | case 0x6001: /* $e001 - Enable IRQs */ |
| 1138 | IRQ_enable = 1; |
| 1139 | LOG_MMC((" MMC3 enable irqs\n")); |
| 1140 | break; |
| 1141 | |
| 1142 | default: |
| 1143 | logerror("mapper119_w uncaught: %04x value: %02x\n", offset + 0x8000, data); |
| 1144 | break; |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | |
| 845 | 1149 | static void mapper5_irq ( const device_config *device, int scanline, int vblank, int blanked ) |
| 846 | 1150 | { |
| 847 | 1151 | #if 1 |
| r5302 | r5303 | |
| 964 | 1268 | break; |
| 965 | 1269 | |
| 966 | 1270 | case 0x1005: /* $5105 */ |
| 967 | | ppu_mirror_custom (0, data & 0x03); |
| 968 | | ppu_mirror_custom (1, (data & 0x0c) >> 2); |
| 969 | | ppu_mirror_custom (2, (data & 0x30) >> 4); |
| 970 | | ppu_mirror_custom (3, (data & 0xc0) >> 6); |
| 1271 | ppu_mirror_MMC5 (0, data & 0x03); |
| 1272 | ppu_mirror_MMC5 (1, (data & 0x0c) >> 2); |
| 1273 | ppu_mirror_MMC5 (2, (data & 0x30) >> 4); |
| 1274 | ppu_mirror_MMC5 (3, (data & 0xc0) >> 6); |
| 971 | 1275 | break; |
| 972 | 1276 | |
| 973 | | /* $5106 - ?? cv3 sets to 0 */ |
| 974 | | /* $5107 - ?? cv3 sets to 0 */ |
| 1277 | /* $5106 - Fill mode: Tile bits ?? cv3 sets to 0 */ |
| 1278 | /* $5107 - Fill mode: Attr bits?? cv3 sets to 0 */ |
| 975 | 1279 | |
| 976 | 1280 | case 0x1013: /* $5113 */ |
| 977 | 1281 | logerror ("MMC5 mid RAM bank select: %02x\n", data & 0x07); |
| r5302 | r5303 | |
| 1092 | 1396 | /* 1k switch */ |
| 1093 | 1397 | vrom_bank[0] = data; |
| 1094 | 1398 | // mapper5_sync_vrom(0); |
| 1095 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 1399 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 1400 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 1096 | 1401 | // nes_vram_sprite[0] = vrom_bank[0] * 64; |
| 1097 | 1402 | // vrom_next[0] = 4; |
| 1098 | 1403 | // vrom_page_a = 1; |
| r5302 | r5303 | |
| 1106 | 1411 | { |
| 1107 | 1412 | case 0x02: |
| 1108 | 1413 | /* 2k switch */ |
| 1109 | | chr2_0 (space->machine, data); |
| 1414 | chr2_0 (space->machine, data, CHRROM); |
| 1110 | 1415 | break; |
| 1111 | 1416 | case 0x03: |
| 1112 | 1417 | /* 1k switch */ |
| 1113 | 1418 | vrom_bank[1] = data; |
| 1114 | 1419 | // mapper5_sync_vrom(0); |
| 1115 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 1420 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 1421 | //ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 1116 | 1422 | // nes_vram_sprite[1] = vrom_bank[0] * 64; |
| 1117 | 1423 | // vrom_next[1] = 5; |
| 1118 | 1424 | // vrom_page_a = 1; |
| r5302 | r5303 | |
| 1128 | 1434 | /* 1k switch */ |
| 1129 | 1435 | vrom_bank[2] = data; |
| 1130 | 1436 | // mapper5_sync_vrom(0); |
| 1131 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 1437 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 1438 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 1132 | 1439 | // nes_vram_sprite[2] = vrom_bank[0] * 64; |
| 1133 | 1440 | // vrom_next[2] = 6; |
| 1134 | 1441 | // vrom_page_a = 1; |
| r5302 | r5303 | |
| 1141 | 1448 | switch (MMC5_vrom_bank_mode) |
| 1142 | 1449 | { |
| 1143 | 1450 | case 0x01: |
| 1144 | | chr4_0 (space->machine, data); |
| 1451 | chr4_0 (space->machine, data, CHRROM); |
| 1145 | 1452 | break; |
| 1146 | 1453 | case 0x02: |
| 1147 | 1454 | /* 2k switch */ |
| 1148 | | chr2_2 (space->machine, data); |
| 1455 | chr2_2 (space->machine, data, CHRROM); |
| 1149 | 1456 | break; |
| 1150 | 1457 | case 0x03: |
| 1151 | 1458 | /* 1k switch */ |
| 1152 | 1459 | vrom_bank[3] = data; |
| 1153 | 1460 | // mapper5_sync_vrom(0); |
| 1154 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 1461 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 1462 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 1155 | 1463 | // nes_vram_sprite[3] = vrom_bank[0] * 64; |
| 1156 | 1464 | // vrom_next[3] = 7; |
| 1157 | 1465 | // vrom_page_a = 1; |
| r5302 | r5303 | |
| 1167 | 1475 | /* 1k switch */ |
| 1168 | 1476 | vrom_bank[4] = data; |
| 1169 | 1477 | // mapper5_sync_vrom(0); |
| 1170 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 1478 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 1479 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 1171 | 1480 | // nes_vram_sprite[4] = vrom_bank[0] * 64; |
| 1172 | 1481 | // vrom_next[0] = 0; |
| 1173 | 1482 | // vrom_page_a = 0; |
| r5302 | r5303 | |
| 1181 | 1490 | { |
| 1182 | 1491 | case 0x02: |
| 1183 | 1492 | /* 2k switch */ |
| 1184 | | chr2_4 (space->machine, data); |
| 1493 | chr2_4 (space->machine, data, CHRROM); |
| 1185 | 1494 | break; |
| 1186 | 1495 | case 0x03: |
| 1187 | 1496 | /* 1k switch */ |
| 1188 | 1497 | vrom_bank[5] = data; |
| 1189 | 1498 | // mapper5_sync_vrom(0); |
| 1190 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 1499 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 1500 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 1191 | 1501 | // nes_vram_sprite[5] = vrom_bank[0] * 64; |
| 1192 | 1502 | // vrom_next[1] = 1; |
| 1193 | 1503 | // vrom_page_a = 0; |
| r5302 | r5303 | |
| 1203 | 1513 | /* 1k switch */ |
| 1204 | 1514 | vrom_bank[6] = data; |
| 1205 | 1515 | // mapper5_sync_vrom(0); |
| 1206 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 1516 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 1517 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 1207 | 1518 | // nes_vram_sprite[6] = vrom_bank[0] * 64; |
| 1208 | 1519 | // vrom_next[2] = 2; |
| 1209 | 1520 | // vrom_page_a = 0; |
| r5302 | r5303 | |
| 1217 | 1528 | { |
| 1218 | 1529 | case 0x00: |
| 1219 | 1530 | /* 8k switch */ |
| 1220 | | chr8 (space->machine, data); |
| 1531 | chr8 (space->machine, data, CHRROM); |
| 1221 | 1532 | break; |
| 1222 | 1533 | case 0x01: |
| 1223 | 1534 | /* 4k switch */ |
| 1224 | | chr4_4 (space->machine, data); |
| 1535 | chr4_4 (space->machine, data, CHRROM); |
| 1225 | 1536 | break; |
| 1226 | 1537 | case 0x02: |
| 1227 | 1538 | /* 2k switch */ |
| 1228 | | chr2_6 (space->machine, data); |
| 1539 | chr2_6 (space->machine, data, CHRROM); |
| 1229 | 1540 | break; |
| 1230 | 1541 | case 0x03: |
| 1231 | 1542 | /* 1k switch */ |
| 1232 | 1543 | vrom_bank[7] = data; |
| 1233 | 1544 | // mapper5_sync_vrom(0); |
| 1234 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 1545 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 1546 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 1235 | 1547 | // nes_vram_sprite[7] = vrom_bank[0] * 64; |
| 1236 | 1548 | // vrom_next[3] = 3; |
| 1237 | 1549 | // vrom_page_a = 0; |
| r5302 | r5303 | |
| 1249 | 1561 | // nes_vram[vrom_next[0]] = data * 64; |
| 1250 | 1562 | // nes_vram[0 + (vrom_page_a*4)] = data * 64; |
| 1251 | 1563 | // nes_vram[0] = data * 64; |
| 1252 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 1564 | chr1_4(space->machine, data, CHRROM); |
| 1565 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 1253 | 1566 | // mapper5_sync_vrom(1); |
| 1254 | 1567 | if (!vrom_page_b) |
| 1255 | 1568 | { |
| r5302 | r5303 | |
| 1265 | 1578 | { |
| 1266 | 1579 | case 0x02: |
| 1267 | 1580 | /* 2k switch */ |
| 1268 | | chr2_0 (space->machine, data); |
| 1269 | | chr2_4 (space->machine, data); |
| 1581 | chr2_0 (space->machine, data, CHRROM); |
| 1582 | chr2_4 (space->machine, data, CHRROM); |
| 1270 | 1583 | break; |
| 1271 | 1584 | case 0x03: |
| 1272 | 1585 | /* 1k switch */ |
| r5302 | r5303 | |
| 1274 | 1587 | // nes_vram[vrom_next[1]] = data * 64; |
| 1275 | 1588 | // nes_vram[1 + (vrom_page_a*4)] = data * 64; |
| 1276 | 1589 | // nes_vram[1] = data * 64; |
| 1277 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 1590 | chr1_5(space->machine, data, CHRROM); |
| 1591 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 1278 | 1592 | // mapper5_sync_vrom(1); |
| 1279 | 1593 | if (!vrom_page_b) |
| 1280 | 1594 | { |
| r5302 | r5303 | |
| 1294 | 1608 | // nes_vram[vrom_next[2]] = data * 64; |
| 1295 | 1609 | // nes_vram[2 + (vrom_page_a*4)] = data * 64; |
| 1296 | 1610 | // nes_vram[2] = data * 64; |
| 1297 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 1611 | chr1_6(space->machine, data, CHRROM); |
| 1612 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 1298 | 1613 | // mapper5_sync_vrom(1); |
| 1299 | 1614 | if (!vrom_page_b) |
| 1300 | 1615 | { |
| r5302 | r5303 | |
| 1310 | 1625 | { |
| 1311 | 1626 | case 0x00: |
| 1312 | 1627 | /* 8k switch */ |
| 1313 | | chr8 (space->machine, data); |
| 1628 | chr8 (space->machine, data, CHRROM); |
| 1314 | 1629 | break; |
| 1315 | 1630 | case 0x01: |
| 1316 | 1631 | /* 4k switch */ |
| 1317 | | chr4_0 (space->machine, data); |
| 1318 | | chr4_4 (space->machine, data); |
| 1632 | chr4_0 (space->machine, data, CHRROM); |
| 1633 | chr4_4 (space->machine, data, CHRROM); |
| 1319 | 1634 | break; |
| 1320 | 1635 | case 0x02: |
| 1321 | 1636 | /* 2k switch */ |
| 1322 | | chr2_2 (space->machine, data); |
| 1323 | | chr2_6 (space->machine, data); |
| 1637 | chr2_2 (space->machine, data, CHRROM); |
| 1638 | chr2_6 (space->machine, data, CHRROM); |
| 1324 | 1639 | break; |
| 1325 | 1640 | case 0x03: |
| 1326 | 1641 | /* 1k switch */ |
| r5302 | r5303 | |
| 1328 | 1643 | // nes_vram[vrom_next[3]] = data * 64; |
| 1329 | 1644 | // nes_vram[3 + (vrom_page_a*4)] = data * 64; |
| 1330 | 1645 | // nes_vram[3] = data * 64; |
| 1331 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 1646 | chr1_7(space->machine, data, CHRROM); |
| 1647 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 1332 | 1648 | // mapper5_sync_vrom(1); |
| 1333 | 1649 | if (!vrom_page_b) |
| 1334 | 1650 | { |
| r5302 | r5303 | |
| 1368 | 1684 | |
| 1369 | 1685 | static WRITE8_HANDLER( mapper7_w ) |
| 1370 | 1686 | { |
| 1371 | | nes_state *state = space->machine->driver_data; |
| 1372 | | |
| 1373 | 1687 | if (data & 0x10) |
| 1374 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 1688 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 1375 | 1689 | else |
| 1376 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 1690 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 1377 | 1691 | |
| 1378 | 1692 | prg32 (space, data); |
| 1379 | 1693 | } |
| r5302 | r5303 | |
| 1382 | 1696 | { |
| 1383 | 1697 | LOG_MMC(("* Mapper 8 switch, vrom: %02x, rom: %02x\n", data & 0x07, (data >> 3))); |
| 1384 | 1698 | /* Switch 8k VROM bank */ |
| 1385 | | chr8 (space->machine, data & 0x07); |
| 1699 | chr8 (space->machine, data & 0x07, CHRROM); |
| 1386 | 1700 | |
| 1387 | 1701 | /* Switch 16k PRG bank */ |
| 1388 | 1702 | data = (data >> 3) & (nes.prg_chunks - 1); |
| r5302 | r5303 | |
| 1397 | 1711 | { |
| 1398 | 1712 | logerror ("mapper9 vrom latch switch (bank 0 low): %02x\n", MMC2_bank0); |
| 1399 | 1713 | MMC2_bank0_latch = 0xfd; |
| 1400 | | chr4_0 (device->machine, MMC2_bank0); |
| 1714 | chr4_0 (device->machine, MMC2_bank0, CHRROM); |
| 1401 | 1715 | } |
| 1402 | 1716 | else if ((offset & 0x3ff0) == 0x0fe0) |
| 1403 | 1717 | { |
| 1404 | 1718 | logerror ("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank0_hi); |
| 1405 | 1719 | MMC2_bank0_latch = 0xfe; |
| 1406 | | chr4_0 (device->machine, MMC2_bank0_hi); |
| 1720 | chr4_0 (device->machine, MMC2_bank0_hi, CHRROM); |
| 1407 | 1721 | } |
| 1408 | 1722 | else if ((offset & 0x3ff0) == 0x1fd0) |
| 1409 | 1723 | { |
| 1410 | 1724 | logerror ("mapper9 vrom latch switch (bank 1 low): %02x\n", MMC2_bank1); |
| 1411 | 1725 | MMC2_bank1_latch = 0xfd; |
| 1412 | | chr4_4 (device->machine, MMC2_bank1); |
| 1726 | chr4_4 (device->machine, MMC2_bank1, CHRROM); |
| 1413 | 1727 | } |
| 1414 | 1728 | else if ((offset & 0x3ff0) == 0x1fe0) |
| 1415 | 1729 | { |
| 1416 | 1730 | logerror ("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank1_hi); |
| 1417 | 1731 | MMC2_bank1_latch = 0xfe; |
| 1418 | | chr4_4 (device->machine, MMC2_bank1_hi); |
| 1732 | chr4_4 (device->machine, MMC2_bank1_hi, CHRROM); |
| 1419 | 1733 | } |
| 1420 | 1734 | } |
| 1421 | 1735 | |
| 1422 | 1736 | static WRITE8_HANDLER( mapper9_w ) |
| 1423 | 1737 | { |
| 1424 | | nes_state *state = space->machine->driver_data; |
| 1738 | //nes_state *state = space->machine->driver_data; |
| 1425 | 1739 | |
| 1426 | 1740 | switch (offset & 0x7000) |
| 1427 | 1741 | { |
| r5302 | r5303 | |
| 1432 | 1746 | case 0x3000: |
| 1433 | 1747 | MMC2_bank0 = data; |
| 1434 | 1748 | if (MMC2_bank0_latch == 0xfd) |
| 1435 | | chr4_0 (space->machine, MMC2_bank0); |
| 1749 | chr4_0 (space->machine, MMC2_bank0, CHRROM); |
| 1436 | 1750 | logerror("MMC2 VROM switch #1 (low): %02x\n", MMC2_bank0); |
| 1437 | 1751 | break; |
| 1438 | 1752 | case 0x4000: |
| 1439 | 1753 | MMC2_bank0_hi = data; |
| 1440 | 1754 | if (MMC2_bank0_latch == 0xfe) |
| 1441 | | chr4_0 (space->machine, MMC2_bank0_hi); |
| 1755 | chr4_0 (space->machine, MMC2_bank0_hi, CHRROM); |
| 1442 | 1756 | logerror("MMC2 VROM switch #1 (high): %02x\n", MMC2_bank0_hi); |
| 1443 | 1757 | break; |
| 1444 | 1758 | case 0x5000: |
| 1445 | 1759 | MMC2_bank1 = data; |
| 1446 | 1760 | if (MMC2_bank1_latch == 0xfd) |
| 1447 | | chr4_4 (space->machine, MMC2_bank1); |
| 1761 | chr4_4 (space->machine, MMC2_bank1, CHRROM); |
| 1448 | 1762 | logerror("MMC2 VROM switch #2 (low): %02x\n", data); |
| 1449 | 1763 | break; |
| 1450 | 1764 | case 0x6000: |
| 1451 | 1765 | MMC2_bank1_hi = data; |
| 1452 | 1766 | if (MMC2_bank1_latch == 0xfe) |
| 1453 | | chr4_4 (space->machine, MMC2_bank1_hi); |
| 1767 | chr4_4 (space->machine, MMC2_bank1_hi, CHRROM); |
| 1454 | 1768 | logerror("MMC2 VROM switch #2 (high): %02x\n", data); |
| 1455 | 1769 | break; |
| 1456 | 1770 | case 0x7000: |
| 1457 | 1771 | if (data&1) |
| 1458 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1772 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1459 | 1773 | else |
| 1460 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1774 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1461 | 1775 | break; |
| 1462 | 1776 | default: |
| 1463 | 1777 | logerror("MMC2 uncaught w: %04x:%02x\n", offset, data); |
| r5302 | r5303 | |
| 1472 | 1786 | { |
| 1473 | 1787 | logerror ("mapper10 vrom latch switch (bank 0 low): %02x\n", MMC2_bank0); |
| 1474 | 1788 | MMC2_bank0_latch = 0xfd; |
| 1475 | | chr4_0 (device->machine, MMC2_bank0); |
| 1789 | chr4_0 (device->machine, MMC2_bank0, CHRROM); |
| 1476 | 1790 | } |
| 1477 | 1791 | else if ((offset & 0x3ff0) == 0x0fe0) |
| 1478 | 1792 | { |
| 1479 | 1793 | logerror ("mapper10 vrom latch switch (bank 0 high): %02x\n", MMC2_bank0_hi); |
| 1480 | 1794 | MMC2_bank0_latch = 0xfe; |
| 1481 | | chr4_0 (device->machine, MMC2_bank0_hi); |
| 1795 | chr4_0 (device->machine, MMC2_bank0_hi, CHRROM); |
| 1482 | 1796 | } |
| 1483 | 1797 | else if ((offset & 0x3ff0) == 0x1fd0) |
| 1484 | 1798 | { |
| 1485 | 1799 | logerror ("mapper10 vrom latch switch (bank 1 low): %02x\n", MMC2_bank1); |
| 1486 | 1800 | MMC2_bank1_latch = 0xfd; |
| 1487 | | chr4_4 (device->machine, MMC2_bank1); |
| 1801 | chr4_4 (device->machine, MMC2_bank1, CHRROM); |
| 1488 | 1802 | } |
| 1489 | 1803 | else if ((offset & 0x3ff0) == 0x1fe0) |
| 1490 | 1804 | { |
| 1491 | 1805 | logerror ("mapper10 vrom latch switch (bank 0 high): %02x\n", MMC2_bank1_hi); |
| 1492 | 1806 | MMC2_bank1_latch = 0xfe; |
| 1493 | | chr4_4 (device->machine, MMC2_bank1_hi); |
| 1807 | chr4_4 (device->machine, MMC2_bank1_hi, CHRROM); |
| 1494 | 1808 | } |
| 1495 | 1809 | } |
| 1496 | 1810 | |
| 1497 | 1811 | static WRITE8_HANDLER( mapper10_w ) |
| 1498 | 1812 | { |
| 1499 | | nes_state *state = space->machine->driver_data; |
| 1500 | | |
| 1501 | 1813 | switch (offset & 0x7000) |
| 1502 | 1814 | { |
| 1503 | 1815 | case 0x2000: |
| r5302 | r5303 | |
| 1507 | 1819 | case 0x3000: |
| 1508 | 1820 | MMC2_bank0 = data; |
| 1509 | 1821 | if (MMC2_bank0_latch == 0xfd) |
| 1510 | | chr4_0 (space->machine, MMC2_bank0); |
| 1822 | chr4_0 (space->machine, MMC2_bank0, CHRROM); |
| 1511 | 1823 | logerror("MMC4 VROM switch #1 (low): %02x\n", MMC2_bank0); |
| 1512 | 1824 | break; |
| 1513 | 1825 | case 0x4000: |
| 1514 | 1826 | MMC2_bank0_hi = data; |
| 1515 | 1827 | if (MMC2_bank0_latch == 0xfe) |
| 1516 | | chr4_0 (space->machine, MMC2_bank0_hi); |
| 1828 | chr4_0 (space->machine, MMC2_bank0_hi, CHRROM); |
| 1517 | 1829 | logerror("MMC4 VROM switch #1 (high): %02x\n", MMC2_bank0_hi); |
| 1518 | 1830 | break; |
| 1519 | 1831 | case 0x5000: |
| 1520 | 1832 | MMC2_bank1 = data; |
| 1521 | 1833 | if (MMC2_bank1_latch == 0xfd) |
| 1522 | | chr4_4 (space->machine, MMC2_bank1); |
| 1834 | chr4_4 (space->machine, MMC2_bank1, CHRROM); |
| 1523 | 1835 | logerror("MMC4 VROM switch #2 (low): %02x\n", data); |
| 1524 | 1836 | break; |
| 1525 | 1837 | case 0x6000: |
| 1526 | 1838 | MMC2_bank1_hi = data; |
| 1527 | 1839 | if (MMC2_bank1_latch == 0xfe) |
| 1528 | | chr4_4 (space->machine, MMC2_bank1_hi); |
| 1840 | chr4_4 (space->machine, MMC2_bank1_hi, CHRROM); |
| 1529 | 1841 | logerror("MMC4 VROM switch #2 (high): %02x\n", data); |
| 1530 | 1842 | break; |
| 1531 | 1843 | case 0x7000: |
| 1532 | 1844 | if (data&1) |
| 1533 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1845 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1534 | 1846 | else |
| 1535 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1847 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1536 | 1848 | break; |
| 1537 | 1849 | default: |
| 1538 | 1850 | logerror("MMC4 uncaught w: %04x:%02x\n", offset, data); |
| r5302 | r5303 | |
| 1545 | 1857 | LOG_MMC(("* Mapper 11 switch, data: %02x\n", data)); |
| 1546 | 1858 | |
| 1547 | 1859 | /* Switch 8k VROM bank */ |
| 1548 | | chr8 (space->machine, data >> 4); |
| 1860 | chr8 (space->machine, data >> 4, CHRROM); |
| 1549 | 1861 | |
| 1550 | 1862 | /* Switch 32k prg bank */ |
| 1551 | 1863 | prg32 (space, data & 0x0f); |
| 1552 | 1864 | } |
| 1553 | 1865 | static WRITE8_HANDLER( mapper13_w ) |
| 1554 | 1866 | { |
| 1555 | | LOG_MMC(("* Mapper 13 switch, data: %02x\n", data )); |
| 1556 | | |
| 1557 | | //this is a place-holder call. |
| 1558 | | //mapper doesn't work because CHR-RAM is not mapped. |
| 1559 | | chr4_4 (space->machine, data); |
| 1867 | chr4_4(space->machine, data, CHRRAM); |
| 1560 | 1868 | } |
| 1561 | 1869 | |
| 1562 | 1870 | static WRITE8_HANDLER( mapper15_w ) |
| 1563 | 1871 | { |
| 1564 | | nes_state *state = space->machine->driver_data; |
| 1565 | 1872 | int bank = (data & (nes.prg_chunks - 1)) * 0x4000; |
| 1566 | 1873 | int base = data & 0x80 ? 0x12000 : 0x10000; |
| 1567 | 1874 | |
| r5302 | r5303 | |
| 1569 | 1876 | { |
| 1570 | 1877 | case 0x0000: |
| 1571 | 1878 | if (data & 0x40) |
| 1572 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1879 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1573 | 1880 | else |
| 1574 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1881 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1575 | 1882 | memory_set_bankptr (space->machine, 1, &nes.rom[bank + base]); |
| 1576 | 1883 | memory_set_bankptr (space->machine, 2, &nes.rom[bank + (base ^ 0x2000)]); |
| 1577 | 1884 | memory_set_bankptr (space->machine, 3, &nes.rom[bank + (base ^ 0x4000)]); |
| r5302 | r5303 | |
| 1592 | 1899 | |
| 1593 | 1900 | case 0x0003: |
| 1594 | 1901 | if (data & 0x40) |
| 1595 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1902 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1596 | 1903 | else |
| 1597 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1904 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1598 | 1905 | memory_set_bankptr (space->machine, 3, &nes.rom[bank + base]); |
| 1599 | 1906 | memory_set_bankptr (space->machine, 4, &nes.rom[bank + (base ^ 0x2000)]); |
| 1600 | 1907 | break; |
| r5302 | r5303 | |
| 1618 | 1925 | |
| 1619 | 1926 | static WRITE8_HANDLER( mapper16_w ) |
| 1620 | 1927 | { |
| 1621 | | nes_state *state = space->machine->driver_data; |
| 1622 | | |
| 1623 | 1928 | logerror ("mapper16 (mid and high) w, offset: %04x, data: %02x\n", offset, data); |
| 1624 | 1929 | |
| 1625 | 1930 | switch (offset & 0x000f) |
| 1626 | 1931 | { |
| 1627 | 1932 | //use new utility functions for bounds checks! |
| 1628 | 1933 | case 0: |
| 1629 | | chr1_0(space->machine, data); |
| 1630 | | break; |
| 1631 | 1934 | case 1: |
| 1632 | | chr1_1(space->machine, data); |
| 1633 | | break; |
| 1634 | 1935 | case 2: |
| 1635 | | chr1_2(space->machine, data); |
| 1636 | | break; |
| 1637 | 1936 | case 3: |
| 1638 | | chr1_3(space->machine, data); |
| 1639 | | break; |
| 1640 | 1937 | case 4: |
| 1641 | | chr1_4(space->machine, data); |
| 1642 | | break; |
| 1643 | 1938 | case 5: |
| 1644 | | chr1_5(space->machine, data); |
| 1645 | | break; |
| 1646 | 1939 | case 6: |
| 1647 | | chr1_6(space->machine, data); |
| 1648 | | break; |
| 1649 | 1940 | case 7: |
| 1650 | | chr1_7(space->machine, data); |
| 1941 | chr1_x(space->machine, offset&0x07, data, CHRROM); |
| 1651 | 1942 | break; |
| 1652 | 1943 | case 8: |
| 1653 | 1944 | /* Switch 16k bank at $8000 */ |
| r5302 | r5303 | |
| 1657 | 1948 | switch (data & 0x03) |
| 1658 | 1949 | { |
| 1659 | 1950 | case 0: |
| 1660 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1951 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1661 | 1952 | break; |
| 1662 | 1953 | case 1: |
| 1663 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1954 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1664 | 1955 | break; |
| 1665 | 1956 | case 2: |
| 1666 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 1957 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 1667 | 1958 | break; |
| 1668 | 1959 | case 3: |
| 1669 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 1960 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 1670 | 1961 | break; |
| 1671 | 1962 | } |
| 1672 | 1963 | break; |
| r5302 | r5303 | |
| 1689 | 1980 | |
| 1690 | 1981 | static WRITE8_HANDLER( mapper17_l_w ) |
| 1691 | 1982 | { |
| 1692 | | nes_state *state = space->machine->driver_data; |
| 1693 | | |
| 1694 | 1983 | switch (offset) |
| 1695 | 1984 | { |
| 1696 | 1985 | /* $42fe - mirroring */ |
| 1697 | 1986 | case 0x1fe: |
| 1698 | 1987 | if (data & 0x10) |
| 1699 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 1988 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 1700 | 1989 | else |
| 1701 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 1990 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 1702 | 1991 | break; |
| 1703 | 1992 | /* $42ff - mirroring */ |
| 1704 | 1993 | case 0x1ff: |
| 1705 | 1994 | if (data & 0x10) |
| 1706 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 1995 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 1707 | 1996 | else |
| 1708 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 1997 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 1709 | 1998 | break; |
| 1710 | 1999 | /* $4501 - $4503 */ |
| 1711 | 2000 | // case 0x401: |
| r5302 | r5303 | |
| 1731 | 2020 | case 0x415: |
| 1732 | 2021 | case 0x416: |
| 1733 | 2022 | case 0x417: |
| 1734 | | data &= ((nes.chr_chunks << 3) - 1); |
| 1735 | | ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64); |
| 2023 | chr1_x(space->machine, offset&7, data&((nes.chr_chunks << 3) - 1), CHRROM); |
| 2024 | // ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64); |
| 1736 | 2025 | break; |
| 1737 | 2026 | default: |
| 1738 | 2027 | logerror("** uncaught mapper 17 write, offset: %04x, data: %02x\n", offset, data); |
| r5302 | r5303 | |
| 1782 | 2071 | |
| 1783 | 2072 | static WRITE8_HANDLER( mapper18_w ) |
| 1784 | 2073 | { |
| 1785 | | nes_state *state = space->machine->driver_data; |
| 1786 | 2074 | // static int irq; |
| 1787 | 2075 | static int bank_8000 = 0; |
| 1788 | 2076 | static int bank_a000 = 0; |
| r5302 | r5303 | |
| 1834 | 2122 | /* Switch 1k vrom at $0000 - low 4 bits */ |
| 1835 | 2123 | vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f); |
| 1836 | 2124 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 1837 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2125 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2126 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 1838 | 2127 | break; |
| 1839 | 2128 | case 0x2001: |
| 1840 | 2129 | /* Switch 1k vrom at $0000 - high 4 bits */ |
| 1841 | 2130 | vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4); |
| 1842 | 2131 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 1843 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2132 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2133 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 1844 | 2134 | break; |
| 1845 | 2135 | case 0x2002: |
| 1846 | 2136 | /* Switch 1k vrom at $0400 - low 4 bits */ |
| 1847 | 2137 | vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f); |
| 1848 | 2138 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 1849 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2139 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2140 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 1850 | 2141 | break; |
| 1851 | 2142 | case 0x2003: |
| 1852 | 2143 | /* Switch 1k vrom at $0400 - high 4 bits */ |
| 1853 | 2144 | vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4); |
| 1854 | 2145 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 1855 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2146 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2147 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 1856 | 2148 | break; |
| 1857 | 2149 | case 0x3000: |
| 1858 | 2150 | /* Switch 1k vrom at $0800 - low 4 bits */ |
| 1859 | 2151 | vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f); |
| 1860 | 2152 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 1861 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2153 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2154 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 1862 | 2155 | break; |
| 1863 | 2156 | case 0x3001: |
| 1864 | 2157 | /* Switch 1k vrom at $0800 - high 4 bits */ |
| 1865 | 2158 | vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4); |
| 1866 | 2159 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 1867 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2160 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2161 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 1868 | 2162 | break; |
| 1869 | 2163 | case 0x3002: |
| 1870 | 2164 | /* Switch 1k vrom at $0c00 - low 4 bits */ |
| 1871 | 2165 | vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f); |
| 1872 | 2166 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 1873 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2167 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2168 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 1874 | 2169 | break; |
| 1875 | 2170 | case 0x3003: |
| 1876 | 2171 | /* Switch 1k vrom at $0c00 - high 4 bits */ |
| 1877 | 2172 | vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4); |
| 1878 | 2173 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 1879 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2174 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2175 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 1880 | 2176 | break; |
| 1881 | 2177 | case 0x4000: |
| 1882 | 2178 | /* Switch 1k vrom at $1000 - low 4 bits */ |
| 1883 | 2179 | vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f); |
| 1884 | 2180 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 1885 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2181 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2182 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 1886 | 2183 | break; |
| 1887 | 2184 | case 0x4001: |
| 1888 | 2185 | /* Switch 1k vrom at $1000 - high 4 bits */ |
| 1889 | 2186 | vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4); |
| 1890 | 2187 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 1891 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2188 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2189 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 1892 | 2190 | break; |
| 1893 | 2191 | case 0x4002: |
| 1894 | 2192 | /* Switch 1k vrom at $1400 - low 4 bits */ |
| 1895 | 2193 | vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f); |
| 1896 | 2194 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 1897 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2195 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2196 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 1898 | 2197 | break; |
| 1899 | 2198 | case 0x4003: |
| 1900 | 2199 | /* Switch 1k vrom at $1400 - high 4 bits */ |
| 1901 | 2200 | vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4); |
| 1902 | 2201 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 1903 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2202 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2203 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 1904 | 2204 | break; |
| 1905 | 2205 | case 0x5000: |
| 1906 | 2206 | /* Switch 1k vrom at $1800 - low 4 bits */ |
| 1907 | 2207 | vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f); |
| 1908 | 2208 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 1909 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2209 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2210 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 1910 | 2211 | break; |
| 1911 | 2212 | case 0x5001: |
| 1912 | 2213 | /* Switch 1k vrom at $1800 - high 4 bits */ |
| 1913 | 2214 | vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4); |
| 1914 | 2215 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 1915 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2216 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2217 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 1916 | 2218 | break; |
| 1917 | 2219 | case 0x5002: |
| 1918 | 2220 | /* Switch 1k vrom at $1c00 - low 4 bits */ |
| 1919 | 2221 | vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f); |
| 1920 | 2222 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 1921 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2223 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2224 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 1922 | 2225 | break; |
| 1923 | 2226 | case 0x5003: |
| 1924 | 2227 | /* Switch 1k vrom at $1c00 - high 4 bits */ |
| 1925 | 2228 | vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4); |
| 1926 | 2229 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 1927 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2230 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2231 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 1928 | 2232 | break; |
| 1929 | 2233 | |
| 1930 | 2234 | /* LBO - these are unverified */ |
| r5302 | r5303 | |
| 1965 | 2269 | case 0x7002: /* Misc */ |
| 1966 | 2270 | switch (data & 0x03) |
| 1967 | 2271 | { |
| 1968 | | case 0: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 1969 | | case 1: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 1970 | | case 2: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 1971 | | case 3: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2272 | case 0: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2273 | case 1: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2274 | case 2: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2275 | case 3: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 1972 | 2276 | } |
| 1973 | 2277 | break; |
| 1974 | 2278 | |
| r5302 | r5303 | |
| 2011 | 2315 | |
| 2012 | 2316 | static WRITE8_HANDLER( mapper19_w ) |
| 2013 | 2317 | { |
| 2014 | | nes_state *state = space->machine->driver_data; |
| 2015 | | |
| 2016 | 2318 | switch (offset & 0x7800) |
| 2017 | 2319 | { |
| 2018 | 2320 | case 0x0000: |
| r5302 | r5303 | |
| 2024 | 2326 | case 0x3000: |
| 2025 | 2327 | case 0x3800: |
| 2026 | 2328 | /* Switch 1k VROM at $0000-$1c00 */ |
| 2027 | | ppu2c0x_set_videorom_bank(state->ppu, offset / 0x800, 1, data, 64); |
| 2329 | chr1_x(space->machine, offset /0x800, data, CHRROM); |
| 2330 | // ppu2c0x_set_videorom_bank(state->ppu, offset / 0x800, 1, data, 64); |
| 2028 | 2331 | break; |
| 2029 | 2332 | |
| 2030 | 2333 | case 0x6000: |
| r5302 | r5303 | |
| 2119 | 2422 | |
| 2120 | 2423 | WRITE8_HANDLER ( fds_w ) |
| 2121 | 2424 | { |
| 2122 | | nes_state *state = space->machine->driver_data; |
| 2123 | | |
| 2124 | 2425 | switch (offset) |
| 2125 | 2426 | { |
| 2126 | 2427 | case 0x00: /* $4020 */ |
| r5302 | r5303 | |
| 2147 | 2448 | if (data & 0x02) nes_fds.head_position = 0; |
| 2148 | 2449 | nes_fds.read_mode = data & 0x04; |
| 2149 | 2450 | if (data & 0x08) |
| 2150 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 2451 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2151 | 2452 | else |
| 2152 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 2453 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2153 | 2454 | if ((!(data & 0x40)) && (nes_fds.write_reg & 0x40)) |
| 2154 | 2455 | nes_fds.head_position -= 2; // ??? |
| 2155 | 2456 | IRQ_enable_latch = data & 0x80; |
| r5302 | r5303 | |
| 2174 | 2475 | |
| 2175 | 2476 | static WRITE8_HANDLER( konami_vrc2a_w ) |
| 2176 | 2477 | { |
| 2177 | | nes_state *state = space->machine->driver_data; |
| 2178 | | |
| 2179 | 2478 | if (offset < 0x3000) |
| 2180 | 2479 | { |
| 2181 | 2480 | switch (offset & 0x3000) |
| r5302 | r5303 | |
| 2188 | 2487 | case 0x1000: |
| 2189 | 2488 | switch (data & 0x03) |
| 2190 | 2489 | { |
| 2191 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 2192 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2193 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 2194 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 2490 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2491 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2492 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2493 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2195 | 2494 | } |
| 2196 | 2495 | break; |
| 2197 | 2496 | |
| r5302 | r5303 | |
| 2222 | 2521 | int bank = (offset & 0x7000) / 0x0800 + (offset & 0x0001); |
| 2223 | 2522 | vrom_bank[bank] = data >> 1; |
| 2224 | 2523 | vrom_bank[bank] &= ((nes.chr_chunks << 3) - 1); |
| 2225 | | ppu2c0x_set_videorom_bank(state->ppu, bank, 1, vrom_bank[bank], 64); |
| 2524 | chr1_x(space->machine, bank, vrom_bank[bank], CHRROM); |
| 2525 | //ppu2c0x_set_videorom_bank(state->ppu, bank, 1, vrom_bank[bank], 64); |
| 2226 | 2526 | } |
| 2227 | 2527 | break; |
| 2228 | 2528 | |
| r5302 | r5303 | |
| 2250 | 2550 | |
| 2251 | 2551 | static WRITE8_HANDLER( konami_vrc2b_w ) |
| 2252 | 2552 | { |
| 2253 | | nes_state *state = space->machine->driver_data; |
| 2254 | 2553 | UINT16 select; |
| 2255 | 2554 | |
| 2256 | 2555 | // logerror("konami_vrc2b_w offset: %04x value: %02x\n", offset, data); |
| r5302 | r5303 | |
| 2267 | 2566 | case 0x1000: |
| 2268 | 2567 | switch (data & 0x03) |
| 2269 | 2568 | { |
| 2270 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 2271 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2272 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 2273 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 2569 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2570 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2571 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2572 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2274 | 2573 | } |
| 2275 | 2574 | break; |
| 2276 | 2575 | |
| r5302 | r5303 | |
| 2297 | 2596 | /* Switch 1k vrom at $0000 - low 4 bits */ |
| 2298 | 2597 | vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f); |
| 2299 | 2598 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2300 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2599 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2600 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2301 | 2601 | break; |
| 2302 | 2602 | case 0x3001: |
| 2303 | 2603 | /* Switch 1k vrom at $0000 - high 4 bits */ |
| 2304 | 2604 | vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4); |
| 2305 | 2605 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2306 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2606 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2607 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2307 | 2608 | break; |
| 2308 | 2609 | case 0x3002: |
| 2309 | 2610 | /* Switch 1k vrom at $0400 - low 4 bits */ |
| 2310 | 2611 | vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f); |
| 2311 | 2612 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2312 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2613 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2614 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2313 | 2615 | break; |
| 2314 | 2616 | case 0x3003: |
| 2315 | 2617 | /* Switch 1k vrom at $0400 - high 4 bits */ |
| 2316 | 2618 | vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4); |
| 2317 | 2619 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2318 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2620 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2621 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2319 | 2622 | break; |
| 2320 | 2623 | case 0x4000: |
| 2321 | 2624 | /* Switch 1k vrom at $0800 - low 4 bits */ |
| 2322 | 2625 | vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f); |
| 2323 | 2626 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2324 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2627 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2628 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2325 | 2629 | break; |
| 2326 | 2630 | case 0x4001: |
| 2327 | 2631 | /* Switch 1k vrom at $0800 - high 4 bits */ |
| 2328 | 2632 | vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4); |
| 2329 | 2633 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2330 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2634 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2635 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2331 | 2636 | break; |
| 2332 | 2637 | case 0x4002: |
| 2333 | 2638 | /* Switch 1k vrom at $0c00 - low 4 bits */ |
| 2334 | 2639 | vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f); |
| 2335 | 2640 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2336 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2641 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2642 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2337 | 2643 | break; |
| 2338 | 2644 | case 0x4003: |
| 2339 | 2645 | /* Switch 1k vrom at $0c00 - high 4 bits */ |
| 2340 | 2646 | vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4); |
| 2341 | 2647 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2342 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2648 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2649 | //ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2343 | 2650 | break; |
| 2344 | 2651 | case 0x5000: |
| 2345 | 2652 | /* Switch 1k vrom at $1000 - low 4 bits */ |
| 2346 | 2653 | vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f); |
| 2347 | 2654 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2348 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2655 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2656 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2349 | 2657 | break; |
| 2350 | 2658 | case 0x5001: |
| 2351 | 2659 | /* Switch 1k vrom at $1000 - high 4 bits */ |
| 2352 | 2660 | vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4); |
| 2353 | 2661 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2354 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2662 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2663 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2355 | 2664 | break; |
| 2356 | 2665 | case 0x5002: |
| 2357 | 2666 | /* Switch 1k vrom at $1400 - low 4 bits */ |
| 2358 | 2667 | vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f); |
| 2359 | 2668 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2360 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2669 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2670 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2361 | 2671 | break; |
| 2362 | 2672 | case 0x5003: |
| 2363 | 2673 | /* Switch 1k vrom at $1400 - high 4 bits */ |
| 2364 | 2674 | vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4); |
| 2365 | 2675 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2366 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2676 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2677 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2367 | 2678 | break; |
| 2368 | 2679 | case 0x6000: |
| 2369 | 2680 | /* Switch 1k vrom at $1800 - low 4 bits */ |
| 2370 | 2681 | vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f); |
| 2371 | 2682 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2372 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2683 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2684 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2373 | 2685 | break; |
| 2374 | 2686 | case 0x6001: |
| 2375 | 2687 | /* Switch 1k vrom at $1800 - high 4 bits */ |
| 2376 | 2688 | vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4); |
| 2377 | 2689 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2378 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2690 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2691 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2379 | 2692 | break; |
| 2380 | 2693 | case 0x6002: |
| 2381 | 2694 | /* Switch 1k vrom at $1c00 - low 4 bits */ |
| 2382 | 2695 | vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f); |
| 2383 | 2696 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2384 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2697 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2698 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2385 | 2699 | break; |
| 2386 | 2700 | case 0x6003: |
| 2387 | 2701 | /* Switch 1k vrom at $1c00 - high 4 bits */ |
| 2388 | 2702 | vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4); |
| 2389 | 2703 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2390 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2704 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2705 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2391 | 2706 | break; |
| 2392 | 2707 | case 0x7000: |
| 2393 | 2708 | /* Set low 4 bits of latch */ |
| r5302 | r5303 | |
| 2413 | 2728 | |
| 2414 | 2729 | static WRITE8_HANDLER( konami_vrc4_w ) |
| 2415 | 2730 | { |
| 2416 | | nes_state *state = space->machine->driver_data; |
| 2417 | | |
| 2418 | 2731 | switch (offset & 0x7007) |
| 2419 | 2732 | { |
| 2420 | 2733 | case 0x0000: |
| r5302 | r5303 | |
| 2425 | 2738 | case 0x1000: |
| 2426 | 2739 | switch (data & 0x03) |
| 2427 | 2740 | { |
| 2428 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 2429 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2430 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 2431 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 2741 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2742 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2743 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2744 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2432 | 2745 | } |
| 2433 | 2746 | break; |
| 2434 | 2747 | |
| r5302 | r5303 | |
| 2443 | 2756 | /* Switch 1k vrom at $0000 - low 4 bits */ |
| 2444 | 2757 | vrom_bank[0] = (vrom_bank[0] & 0xf0) | (data & 0x0f); |
| 2445 | 2758 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2446 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2759 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2760 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2447 | 2761 | break; |
| 2448 | 2762 | case 0x3002: |
| 2449 | 2763 | /* Switch 1k vrom at $0000 - high 4 bits */ |
| 2450 | 2764 | vrom_bank[0] = (vrom_bank[0] & 0x0f) | (data << 4); |
| 2451 | 2765 | vrom_bank[0] &= ((nes.chr_chunks << 3) - 1); |
| 2452 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2766 | chr1_0(space->machine, vrom_bank[0], CHRROM); |
| 2767 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, vrom_bank[0], 64); |
| 2453 | 2768 | break; |
| 2454 | 2769 | case 0x3001: |
| 2455 | 2770 | case 0x3004: |
| 2456 | 2771 | /* Switch 1k vrom at $0400 - low 4 bits */ |
| 2457 | 2772 | vrom_bank[1] = (vrom_bank[1] & 0xf0) | (data & 0x0f); |
| 2458 | 2773 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2459 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2774 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2775 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2460 | 2776 | break; |
| 2461 | 2777 | case 0x3003: |
| 2462 | 2778 | case 0x3006: |
| 2463 | 2779 | /* Switch 1k vrom at $0400 - high 4 bits */ |
| 2464 | 2780 | vrom_bank[1] = (vrom_bank[1] & 0x0f) | (data << 4); |
| 2465 | 2781 | vrom_bank[1] &= ((nes.chr_chunks << 3) - 1); |
| 2466 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2782 | chr1_1(space->machine, vrom_bank[1], CHRROM); |
| 2783 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, vrom_bank[1], 64); |
| 2467 | 2784 | break; |
| 2468 | 2785 | case 0x4000: |
| 2469 | 2786 | /* Switch 1k vrom at $0800 - low 4 bits */ |
| 2470 | 2787 | vrom_bank[2] = (vrom_bank[2] & 0xf0) | (data & 0x0f); |
| 2471 | 2788 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2472 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2789 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2790 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2473 | 2791 | break; |
| 2474 | 2792 | case 0x4002: |
| 2475 | 2793 | /* Switch 1k vrom at $0800 - high 4 bits */ |
| 2476 | 2794 | vrom_bank[2] = (vrom_bank[2] & 0x0f) | (data << 4); |
| 2477 | 2795 | vrom_bank[2] &= ((nes.chr_chunks << 3) - 1); |
| 2478 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2796 | chr1_2(space->machine, vrom_bank[2], CHRROM); |
| 2797 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, vrom_bank[2], 64); |
| 2479 | 2798 | break; |
| 2480 | 2799 | case 0x4001: |
| 2481 | 2800 | case 0x4004: |
| 2482 | 2801 | /* Switch 1k vrom at $0c00 - low 4 bits */ |
| 2483 | 2802 | vrom_bank[3] = (vrom_bank[3] & 0xf0) | (data & 0x0f); |
| 2484 | 2803 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2485 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2804 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2805 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2486 | 2806 | break; |
| 2487 | 2807 | case 0x4003: |
| 2488 | 2808 | case 0x4006: |
| 2489 | 2809 | /* Switch 1k vrom at $0c00 - high 4 bits */ |
| 2490 | 2810 | vrom_bank[3] = (vrom_bank[3] & 0x0f) | (data << 4); |
| 2491 | 2811 | vrom_bank[3] &= ((nes.chr_chunks << 3) - 1); |
| 2492 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2812 | chr1_3(space->machine, vrom_bank[3], CHRROM); |
| 2813 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, vrom_bank[3], 64); |
| 2493 | 2814 | break; |
| 2494 | 2815 | case 0x5000: |
| 2495 | 2816 | /* Switch 1k vrom at $1000 - low 4 bits */ |
| 2496 | 2817 | vrom_bank[4] = (vrom_bank[4] & 0xf0) | (data & 0x0f); |
| 2497 | 2818 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2498 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2819 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2820 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2499 | 2821 | break; |
| 2500 | 2822 | case 0x5002: |
| 2501 | 2823 | /* Switch 1k vrom at $1000 - high 4 bits */ |
| 2502 | 2824 | vrom_bank[4] = (vrom_bank[4] & 0x0f) | (data << 4); |
| 2503 | 2825 | vrom_bank[4] &= ((nes.chr_chunks << 3) - 1); |
| 2504 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2826 | chr1_4(space->machine, vrom_bank[4], CHRROM); |
| 2827 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, vrom_bank[4], 64); |
| 2505 | 2828 | break; |
| 2506 | 2829 | case 0x5001: |
| 2507 | 2830 | case 0x5004: |
| 2508 | 2831 | /* Switch 1k vrom at $1400 - low 4 bits */ |
| 2509 | 2832 | vrom_bank[5] = (vrom_bank[5] & 0xf0) | (data & 0x0f); |
| 2510 | 2833 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2511 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2834 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2835 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2512 | 2836 | break; |
| 2513 | 2837 | case 0x5003: |
| 2514 | 2838 | case 0x5006: |
| 2515 | 2839 | /* Switch 1k vrom at $1400 - high 4 bits */ |
| 2516 | 2840 | vrom_bank[5] = (vrom_bank[5] & 0x0f) | (data << 4); |
| 2517 | 2841 | vrom_bank[5] &= ((nes.chr_chunks << 3) - 1); |
| 2518 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2842 | chr1_5(space->machine, vrom_bank[5], CHRROM); |
| 2843 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, vrom_bank[5], 64); |
| 2519 | 2844 | break; |
| 2520 | 2845 | case 0x6000: |
| 2521 | 2846 | /* Switch 1k vrom at $1800 - low 4 bits */ |
| 2522 | 2847 | vrom_bank[6] = (vrom_bank[6] & 0xf0) | (data & 0x0f); |
| 2523 | 2848 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2524 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2849 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2850 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2525 | 2851 | break; |
| 2526 | 2852 | case 0x6002: |
| 2527 | 2853 | /* Switch 1k vrom at $1800 - high 4 bits */ |
| 2528 | 2854 | vrom_bank[6] = (vrom_bank[6] & 0x0f) | (data << 4); |
| 2529 | 2855 | vrom_bank[6] &= ((nes.chr_chunks << 3) - 1); |
| 2530 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2856 | chr1_6(space->machine, vrom_bank[6], CHRROM); |
| 2857 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, vrom_bank[6], 64); |
| 2531 | 2858 | break; |
| 2532 | 2859 | case 0x6001: |
| 2533 | 2860 | case 0x6004: |
| 2534 | 2861 | /* Switch 1k vrom at $1c00 - low 4 bits */ |
| 2535 | 2862 | vrom_bank[7] = (vrom_bank[7] & 0xf0) | (data & 0x0f); |
| 2536 | 2863 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2537 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2864 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2865 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2538 | 2866 | break; |
| 2539 | 2867 | case 0x6003: |
| 2540 | 2868 | case 0x6006: |
| 2541 | 2869 | /* Switch 1k vrom at $1c00 - high 4 bits */ |
| 2542 | 2870 | vrom_bank[7] = (vrom_bank[7] & 0x0f) | (data << 4); |
| 2543 | 2871 | vrom_bank[7] &= ((nes.chr_chunks << 3) - 1); |
| 2544 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2872 | chr1_7(space->machine, vrom_bank[7], CHRROM); |
| 2873 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, vrom_bank[7], 64); |
| 2545 | 2874 | break; |
| 2546 | 2875 | case 0x7000: |
| 2547 | 2876 | /* Set low 4 bits of latch */ |
| r5302 | r5303 | |
| 2580 | 2909 | |
| 2581 | 2910 | static WRITE8_HANDLER( konami_vrc6a_w ) |
| 2582 | 2911 | { |
| 2583 | | nes_state *state = space->machine->driver_data; |
| 2584 | | |
| 2585 | 2912 | // logerror("konami_vrc6_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 2586 | 2913 | |
| 2587 | 2914 | switch (offset & 0x7003) |
| r5302 | r5303 | |
| 2598 | 2925 | case 0x3003: |
| 2599 | 2926 | switch (data & 0x0c) |
| 2600 | 2927 | { |
| 2601 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 2602 | | case 0x04: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2603 | | case 0x08: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 2604 | | case 0x0c: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 2928 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2929 | case 0x04: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2930 | case 0x08: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2931 | case 0x0c: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2605 | 2932 | } |
| 2606 | 2933 | break; |
| 2607 | 2934 | case 0x4000: case 0x4001: case 0x4002: case 0x4003: |
| r5302 | r5303 | |
| 2613 | 2940 | case 0x5002: |
| 2614 | 2941 | case 0x5003: |
| 2615 | 2942 | /* switch 1k VROM at $0000-$0c00 */ |
| 2616 | | ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 0, 1, data, 64); |
| 2943 | chr1_x(space->machine, offset&3, data, CHRROM); |
| 2944 | // ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 0, 1, data, 64); |
| 2617 | 2945 | break; |
| 2618 | 2946 | |
| 2619 | 2947 | case 0x6000: |
| r5302 | r5303 | |
| 2621 | 2949 | case 0x6002: |
| 2622 | 2950 | case 0x6003: |
| 2623 | 2951 | /* switch 1k VROM at $1000-$1c00 */ |
| 2624 | | ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 4, 1, data, 64); |
| 2952 | chr1_x(space->machine, (offset&3)+4, data, CHRROM); |
| 2953 | // ppu2c0x_set_videorom_bank(state->ppu, (offset & 3) + 4, 1, data, 64); |
| 2625 | 2954 | break; |
| 2626 | 2955 | |
| 2627 | 2956 | case 0x7000: |
| r5302 | r5303 | |
| 2645 | 2974 | |
| 2646 | 2975 | static WRITE8_HANDLER( konami_vrc6b_w ) |
| 2647 | 2976 | { |
| 2648 | | nes_state *state = space->machine->driver_data; |
| 2649 | | |
| 2650 | 2977 | // logerror("konami_vrc6_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 2651 | 2978 | |
| 2652 | 2979 | switch (offset & 0x7003) |
| r5302 | r5303 | |
| 2663 | 2990 | case 0x3003: |
| 2664 | 2991 | switch (data & 0x0c) |
| 2665 | 2992 | { |
| 2666 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 2667 | | case 0x04: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 2668 | | case 0x08: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 2669 | | case 0x0c: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 2993 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 2994 | case 0x04: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 2995 | case 0x08: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 2996 | case 0x0c: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 2670 | 2997 | } |
| 2671 | 2998 | break; |
| 2672 | 2999 | case 0x4000: case 0x4001: case 0x4002: case 0x4003: |
| r5302 | r5303 | |
| 2675 | 3002 | break; |
| 2676 | 3003 | case 0x5000: |
| 2677 | 3004 | /* Switch 1k VROM at $0000 */ |
| 2678 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, data, 64); |
| 3005 | chr1_0(space->machine,data, CHRROM); |
| 3006 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, data, 64); |
| 2679 | 3007 | break; |
| 2680 | 3008 | case 0x5002: |
| 2681 | 3009 | /* Switch 1k VROM at $0400 */ |
| 2682 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64); |
| 3010 | chr1_1(space->machine,data, CHRROM); |
| 3011 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64); |
| 2683 | 3012 | break; |
| 2684 | 3013 | case 0x5001: |
| 2685 | 3014 | /* Switch 1k VROM at $0800 */ |
| 2686 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64); |
| 3015 | chr1_2(space->machine,data, CHRROM); |
| 3016 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64); |
| 2687 | 3017 | break; |
| 2688 | 3018 | case 0x5003: |
| 2689 | 3019 | /* Switch 1k VROM at $0c00 */ |
| 2690 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64); |
| 3020 | chr1_3(space->machine,data, CHRROM); |
| 3021 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64); |
| 2691 | 3022 | break; |
| 2692 | 3023 | case 0x6000: |
| 2693 | 3024 | /* Switch 1k VROM at $1000 */ |
| 2694 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 3025 | chr1_4(space->machine,data, CHRROM); |
| 3026 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 2695 | 3027 | break; |
| 2696 | 3028 | case 0x6002: |
| 2697 | 3029 | /* Switch 1k VROM at $1400 */ |
| 2698 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 3030 | chr1_5(space->machine,data, CHRROM); |
| 3031 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 2699 | 3032 | break; |
| 2700 | 3033 | case 0x6001: |
| 2701 | 3034 | /* Switch 1k VROM at $1800 */ |
| 2702 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 3035 | chr1_6(space->machine,data, CHRROM); |
| 3036 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 2703 | 3037 | break; |
| 2704 | 3038 | case 0x6003: |
| 2705 | 3039 | /* Switch 1k VROM at $1c00 */ |
| 2706 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 3040 | chr1_7(space->machine,data, CHRROM); |
| 3041 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 2707 | 3042 | break; |
| 2708 | 3043 | case 0x7000: |
| 2709 | 3044 | IRQ_count_latch = data; |
| r5302 | r5303 | |
| 2725 | 3060 | |
| 2726 | 3061 | static WRITE8_HANDLER( mapper32_w ) |
| 2727 | 3062 | { |
| 2728 | | nes_state *state = space->machine->driver_data; |
| 2729 | 3063 | static int bankSel; |
| 2730 | 3064 | |
| 2731 | 3065 | // logerror("mapper32_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| r5302 | r5303 | |
| 2742 | 3076 | case 0x1000: |
| 2743 | 3077 | bankSel = data & 0x02; |
| 2744 | 3078 | if (data & 0x01) |
| 2745 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3079 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2746 | 3080 | else |
| 2747 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3081 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2748 | 3082 | break; |
| 2749 | 3083 | case 0x2000: |
| 2750 | 3084 | /* Switch 8k bank at $A000 */ |
| r5302 | r5303 | |
| 2752 | 3086 | break; |
| 2753 | 3087 | case 0x3000: |
| 2754 | 3088 | /* Switch 1k VROM at $1000 */ |
| 2755 | | ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64); |
| 3089 | chr1_x(space->machine, offset&7, data, CHRROM); |
| 3090 | //ppu2c0x_set_videorom_bank(state->ppu, offset & 0x07, 1, data, 64); |
| 2756 | 3091 | break; |
| 2757 | 3092 | default: |
| 2758 | 3093 | logerror("Uncaught mapper 32 write, addr: %04x value: %02x\n", offset + 0x8000, data); |
| r5302 | r5303 | |
| 2762 | 3097 | |
| 2763 | 3098 | static WRITE8_HANDLER( mapper33_w ) |
| 2764 | 3099 | { |
| 2765 | | nes_state *state = space->machine->driver_data; |
| 2766 | | |
| 2767 | 3100 | // logerror("mapper33_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 2768 | 3101 | |
| 2769 | 3102 | switch (offset & 0x7003) |
| r5302 | r5303 | |
| 2780 | 3113 | break; |
| 2781 | 3114 | case 0x0002: |
| 2782 | 3115 | /* Switch 2k VROM at $0000 */ |
| 2783 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 2, data, 128); |
| 3116 | chr2_0(space->machine, data, CHRROM); |
| 3117 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 2, data, 128); |
| 2784 | 3118 | break; |
| 2785 | 3119 | case 0x0003: |
| 2786 | 3120 | /* Switch 2k VROM at $0800 */ |
| 2787 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 2, data, 128); |
| 3121 | chr2_2(space->machine, data, CHRROM); |
| 3122 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 2, data, 128); |
| 2788 | 3123 | break; |
| 2789 | 3124 | case 0x2000: |
| 2790 | 3125 | /* Switch 1k VROM at $1000 */ |
| 2791 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 3126 | chr1_4(space->machine, data, CHRROM); |
| 3127 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 2792 | 3128 | break; |
| 2793 | 3129 | case 0x2001: |
| 2794 | 3130 | /* Switch 1k VROM at $1400 */ |
| 2795 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 3131 | chr1_5(space->machine, data, CHRROM); |
| 3132 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 2796 | 3133 | break; |
| 2797 | 3134 | case 0x2002: |
| 2798 | 3135 | /* Switch 1k VROM at $1800 */ |
| 2799 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 3136 | chr1_6(space->machine, data, CHRROM); |
| 3137 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 2800 | 3138 | break; |
| 2801 | 3139 | case 0x2003: |
| 2802 | 3140 | /* Switch 1k VROM at $1c00 */ |
| 2803 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 3141 | chr1_7(space->machine, data, CHRROM); |
| 3142 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 2804 | 3143 | break; |
| 2805 | 3144 | default: |
| 2806 | 3145 | logerror("Uncaught mapper 33 write, addr: %04x value: %02x\n", offset + 0x8000, data); |
| r5302 | r5303 | |
| 2820 | 3159 | break; |
| 2821 | 3160 | case 0x1ffe: |
| 2822 | 3161 | /* Switch 4k VNES_ROM at 0x0000 */ |
| 2823 | | chr4_0 (space->machine, data); |
| 3162 | chr4_0 (space->machine, data, CHRROM); |
| 2824 | 3163 | break; |
| 2825 | 3164 | case 0x1fff: |
| 2826 | 3165 | /* Switch 4k VNES_ROM at 0x1000 */ |
| 2827 | | chr4_4 (space->machine, data); |
| 3166 | chr4_4 (space->machine, data, CHRROM); |
| 2828 | 3167 | break; |
| 2829 | 3168 | } |
| 2830 | 3169 | } |
| r5302 | r5303 | |
| 2873 | 3212 | |
| 2874 | 3213 | static WRITE8_HANDLER( mapper41_m_w ) |
| 2875 | 3214 | { |
| 2876 | | nes_state *state = space->machine->driver_data; |
| 2877 | | |
| 2878 | 3215 | LOG_MMC(("mapper41_m_w, offset: %04x, data: %02x\n", offset, data)); |
| 2879 | 3216 | |
| 2880 | 3217 | if (offset & 0x20) |
| 2881 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3218 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 2882 | 3219 | else |
| 2883 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3220 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 2884 | 3221 | |
| 2885 | 3222 | mapper41_reg2 = offset & 0x04; |
| 2886 | 3223 | mapper41_chr &= ~0x0c; |
| r5302 | r5303 | |
| 2896 | 3233 | { |
| 2897 | 3234 | mapper41_chr &= ~0x03; |
| 2898 | 3235 | mapper41_chr |= data & 0x03; |
| 2899 | | chr8(space->machine, mapper41_chr); |
| 3236 | chr8(space->machine, mapper41_chr, CHRROM); |
| 2900 | 3237 | } |
| 2901 | 3238 | } |
| 2902 | 3239 | |
| 2903 | 3240 | static WRITE8_HANDLER( mapper42_w ) |
| 2904 | 3241 | { |
| 2905 | | nes_state *state = space->machine->driver_data; |
| 2906 | | |
| 2907 | 3242 | LOG_MMC(("mapper42_w, offset: %04x, data: %02x\n", offset, data)); |
| 2908 | 3243 | |
| 2909 | 3244 | if ( offset >= 0x7000 ) |
| r5302 | r5303 | |
| 2914 | 3249 | memory_set_bankptr (space->machine, 5, &nes.rom[( data & ( ( nes.prg_chunks << 1 ) -1 ) ) * 0x2000 + 0x10000]); |
| 2915 | 3250 | break; |
| 2916 | 3251 | case 0x01: |
| 2917 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3252 | set_nt_mirroring(( data & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 2918 | 3253 | break; |
| 2919 | 3254 | case 0x02: |
| 2920 | 3255 | /* Check if IRQ is being enabled */ |
| r5302 | r5303 | |
| 2933 | 3268 | |
| 2934 | 3269 | static WRITE8_HANDLER( mapper43_w ) |
| 2935 | 3270 | { |
| 2936 | | nes_state *state = space->machine->driver_data; |
| 2937 | 3271 | int bank = ( ( ( offset >> 8 ) & 0x03 ) * 0x20 ) + ( offset & 0x1F ); |
| 2938 | 3272 | |
| 2939 | 3273 | LOG_MMC(("mapper43_w, offset: %04x, data: %02x\n", offset, data)); |
| 2940 | 3274 | |
| 2941 | | ppu2c0x_set_mirroring( state->ppu, ( offset & 0x2000 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3275 | set_nt_mirroring(( offset & 0x2000 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 2942 | 3276 | |
| 2943 | 3277 | if ( offset & 0x0800 ) |
| 2944 | 3278 | { |
| r5302 | r5303 | |
| 3048 | 3382 | MMC1_bank1 = ( MMC1_bank1 & 0x01 ) | ( ( data & 0x0F ) << 1 ); |
| 3049 | 3383 | MMC1_bank2 = ( MMC1_bank2 & 0x07 ) | ( ( data & 0xF0 ) >> 1 ); |
| 3050 | 3384 | prg32(space, MMC1_bank1); |
| 3051 | | chr8(space->machine, MMC1_bank2); |
| 3385 | chr8(space->machine, MMC1_bank2, CHRROM); |
| 3052 | 3386 | } |
| 3053 | 3387 | |
| 3054 | 3388 | static WRITE8_HANDLER( mapper46_w ) |
| r5302 | r5303 | |
| 3058 | 3392 | MMC1_bank1 = ( MMC1_bank1 & ~0x01 ) | ( ( data & 0x02 ) >> 1 ); |
| 3059 | 3393 | MMC1_bank2 = ( MMC1_bank2 & ~0x07 ) | ( ( data & 0x70 ) >> 4 ); |
| 3060 | 3394 | prg32(space, MMC1_bank1); |
| 3061 | | chr8(space->machine, MMC1_bank2); |
| 3395 | chr8(space->machine, MMC1_bank2, CHRROM); |
| 3062 | 3396 | } |
| 3063 | 3397 | |
| 3064 | 3398 | static WRITE8_HANDLER( mapper47_m_w ) |
| r5302 | r5303 | |
| 3090 | 3424 | } |
| 3091 | 3425 | |
| 3092 | 3426 | static void mapper51_set_banks( const address_space *space ) { |
| 3093 | | nes_state *state = space->machine->driver_data; |
| 3427 | set_nt_mirroring(( MMC1_bank1 == 3 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3094 | 3428 | |
| 3095 | | ppu2c0x_set_mirroring( state->ppu, ( MMC1_bank1 == 3 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3096 | | |
| 3097 | 3429 | if ( MMC1_bank1 & 0x01 ) { |
| 3098 | 3430 | prg32( space, MMC1_bank2 ); |
| 3099 | 3431 | } else { |
| r5302 | r5303 | |
| 3124 | 3456 | |
| 3125 | 3457 | static WRITE8_HANDLER( mapper57_w ) |
| 3126 | 3458 | { |
| 3127 | | nes_state *state = space->machine->driver_data; |
| 3128 | | |
| 3129 | 3459 | LOG_MMC(("mapper57_w, offset: %04x, data: %02x\n", offset, data)); |
| 3130 | 3460 | |
| 3131 | 3461 | if ( offset & 0x0800 ) { |
| r5302 | r5303 | |
| 3141 | 3471 | prg16_cdef( space, ( MMC1_bank2 >> 5 ) & 0x03 ); |
| 3142 | 3472 | } |
| 3143 | 3473 | |
| 3144 | | ppu2c0x_set_mirroring( state->ppu, ( MMC1_bank2 & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3474 | set_nt_mirroring(( MMC1_bank2 & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3145 | 3475 | |
| 3146 | | chr8( space->machine, ( MMC1_bank1 & 0x03 ) | ( MMC1_bank2 & 0x07 ) | ( ( MMC1_bank2 & 0x10 ) >> 1 ) ); |
| 3476 | chr8( space->machine, ( MMC1_bank1 & 0x03 ) | ( MMC1_bank2 & 0x07 ) | ( ( MMC1_bank2 & 0x10 ) >> 1 ), CHRROM ); |
| 3147 | 3477 | } |
| 3148 | 3478 | |
| 3149 | 3479 | static WRITE8_HANDLER( mapper58_w ) |
| 3150 | 3480 | { |
| 3151 | | nes_state *state = space->machine->driver_data; |
| 3152 | | |
| 3153 | 3481 | LOG_MMC(("mapper58_w, offset: %04x, data: %02x\n", offset, data)); |
| 3154 | 3482 | |
| 3155 | 3483 | if ( offset & 0x4000 ) { |
| r5302 | r5303 | |
| 3160 | 3488 | prg32( space, ( offset & 0x06 ) >> 1 ); |
| 3161 | 3489 | } |
| 3162 | 3490 | |
| 3163 | | chr8( space->machine, ( offset & 0x38 ) >> 3 ); |
| 3491 | chr8( space->machine, ( offset & 0x38 ) >> 3, CHRROM ); |
| 3164 | 3492 | |
| 3165 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x02 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3493 | set_nt_mirroring(( data & 0x02 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3166 | 3494 | } |
| 3167 | 3495 | } |
| 3168 | 3496 | |
| 3169 | 3497 | static WRITE8_HANDLER( mapper61_w ) |
| 3170 | 3498 | { |
| 3171 | | nes_state *state = space->machine->driver_data; |
| 3499 | //nes_state *state = space->machine->driver_data; |
| 3172 | 3500 | |
| 3173 | 3501 | LOG_MMC(("mapper61_w, offset: %04x, data: %02x\n", offset, data)); |
| 3174 | 3502 | |
| r5302 | r5303 | |
| 3183 | 3511 | prg16_cdef( space, ( ( offset & 0x0F ) << 1 ) | ( ( offset & 0x20 ) >> 4 ) ); |
| 3184 | 3512 | break; |
| 3185 | 3513 | } |
| 3186 | | ppu2c0x_set_mirroring( state->ppu, ( offset & 0x80 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3514 | set_nt_mirroring(( offset & 0x80 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3187 | 3515 | } |
| 3188 | 3516 | |
| 3189 | 3517 | static WRITE8_HANDLER( mapper62_w ) |
| 3190 | 3518 | { |
| 3191 | | nes_state *state = space->machine->driver_data; |
| 3192 | | |
| 3193 | 3519 | LOG_MMC(("mapper62_w, offset :%04x, data: %02x\n", offset, data)); |
| 3194 | 3520 | |
| 3195 | | chr8( space->machine, ( ( offset & 0x1F ) << 2 ) | ( data & 0x03 ) ); |
| 3521 | chr8( space->machine, ( ( offset & 0x1F ) << 2 ) | ( data & 0x03 ) , CHRROM); |
| 3196 | 3522 | |
| 3197 | 3523 | if ( offset & 0x20 ) { |
| 3198 | 3524 | prg16_89ab( space, ( offset & 0x40 ) | ( ( offset >> 8 ) & 0x3F ) ); |
| r5302 | r5303 | |
| 3201 | 3527 | prg32( space, ( ( offset & 0x40 ) | ( ( offset >> 8 ) & 0x3F ) ) >> 1 ); |
| 3202 | 3528 | } |
| 3203 | 3529 | |
| 3204 | | ppu2c0x_set_mirroring( state->ppu, ( offset & 0x80 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3530 | set_nt_mirroring(( offset & 0x80 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 3205 | 3531 | } |
| 3206 | 3532 | |
| 3207 | 3533 | static void mapper64_set_banks( const address_space *space ) { |
| 3208 | 3534 | if ( mapper64_cmd & 0x20 ) { |
| 3209 | | chr1_0( space->machine, mapper64_data[0] ); |
| 3210 | | chr1_2( space->machine, mapper64_data[1] ); |
| 3211 | | chr1_1( space->machine, mapper64_data[8] ); |
| 3212 | | chr1_3( space->machine, mapper64_data[9] ); |
| 3535 | chr1_0( space->machine, mapper64_data[0], CHRROM ); |
| 3536 | chr1_2( space->machine, mapper64_data[1], CHRROM ); |
| 3537 | chr1_1( space->machine, mapper64_data[8] , CHRROM); |
| 3538 | chr1_3( space->machine, mapper64_data[9], CHRROM ); |
| 3213 | 3539 | } else { |
| 3214 | | chr1_0( space->machine, mapper64_data[0] & 0xFE ); |
| 3215 | | chr1_1( space->machine, ( mapper64_data[0] & 0xFE ) | 1 ); |
| 3216 | | chr1_2( space->machine, mapper64_data[1] & 0xFE ); |
| 3217 | | chr1_3( space->machine, ( mapper64_data[1] & 0xFE ) | 1 ); |
| 3540 | chr1_0( space->machine, mapper64_data[0] & 0xFE, CHRROM ); |
| 3541 | chr1_1( space->machine, ( mapper64_data[0] & 0xFE ) | 1, CHRROM ); |
| 3542 | chr1_2( space->machine, mapper64_data[1] & 0xFE, CHRROM ); |
| 3543 | chr1_3( space->machine, ( mapper64_data[1] & 0xFE ) | 1, CHRROM ); |
| 3218 | 3544 | } |
| 3219 | | chr1_4( space->machine, mapper64_data[2] ); |
| 3220 | | chr1_5( space->machine, mapper64_data[3] ); |
| 3221 | | chr1_6( space->machine, mapper64_data[4] ); |
| 3222 | | chr1_7( space->machine, mapper64_data[5] ); |
| 3545 | chr1_4( space->machine, mapper64_data[2], CHRROM ); |
| 3546 | chr1_5( space->machine, mapper64_data[3], CHRROM ); |
| 3547 | chr1_6( space->machine, mapper64_data[4], CHRROM ); |
| 3548 | chr1_7( space->machine, mapper64_data[5], CHRROM ); |
| 3223 | 3549 | |
| 3224 | 3550 | prg8_89( space, mapper64_data[6] ); |
| 3225 | 3551 | prg8_ab( space, mapper64_data[7] ); |
| r5302 | r5303 | |
| 3234 | 3560 | static WRITE8_HANDLER( mapper64_w ) |
| 3235 | 3561 | { |
| 3236 | 3562 | /* TODO: something in the IRQ handling hoses Skull & Crossbones */ |
| 3237 | | nes_state *state = space->machine->driver_data; |
| 3563 | //nes_state *state = space->machine->driver_data; |
| 3238 | 3564 | |
| 3239 | 3565 | // logerror("mapper64_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 3240 | 3566 | |
| r5302 | r5303 | |
| 3255 | 3581 | case 0x2000: |
| 3256 | 3582 | /* Not sure if the one-screen mirroring applies to this mapper */ |
| 3257 | 3583 | if (data & 0x40) |
| 3258 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 3584 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 3259 | 3585 | else |
| 3260 | 3586 | { |
| 3261 | 3587 | if (data & 0x01) |
| 3262 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3588 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 3263 | 3589 | else |
| 3264 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3590 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 3265 | 3591 | } |
| 3266 | 3592 | break; |
| 3267 | 3593 | case 0x4000: /* $c000 - IRQ scanline counter */ |
| r5302 | r5303 | |
| 3314 | 3640 | |
| 3315 | 3641 | static WRITE8_HANDLER( mapper65_w ) |
| 3316 | 3642 | { |
| 3317 | | nes_state *state = space->machine->driver_data; |
| 3318 | | |
| 3319 | 3643 | switch (offset & 0x7007) |
| 3320 | 3644 | { |
| 3321 | 3645 | case 0x0000: |
| r5302 | r5303 | |
| 3326 | 3650 | break; |
| 3327 | 3651 | case 0x1001: |
| 3328 | 3652 | if (data & 0x80) |
| 3329 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3653 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 3330 | 3654 | else |
| 3331 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3655 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 3332 | 3656 | break; |
| 3333 | 3657 | case 0x1005: |
| 3334 | 3658 | IRQ_count = data << 1; |
| r5302 | r5303 | |
| 3353 | 3677 | case 0x3006: |
| 3354 | 3678 | case 0x3007: |
| 3355 | 3679 | /* Switch 1k VROM at $0000-$1c00 */ |
| 3356 | | ppu2c0x_set_videorom_bank(state->ppu, offset & 7, 1, data, 64); |
| 3680 | chr1_x(space->machine, offset &7, data, CHRROM); |
| 3681 | //ppu2c0x_set_videorom_bank(state->ppu, offset & 7, 1, data, 64); |
| 3357 | 3682 | break; |
| 3358 | 3683 | |
| 3359 | 3684 | case 0x4000: |
| r5302 | r5303 | |
| 3374 | 3699 | LOG_MMC(("* Mapper 66 switch, offset %04x, data: %02x\n", offset, data)); |
| 3375 | 3700 | |
| 3376 | 3701 | prg32 (space, (data & 0x30) >> 4); |
| 3377 | | chr8 (space->machine, data & 0x03); |
| 3702 | chr8 (space->machine, data & 0x03, CHRROM); |
| 3378 | 3703 | } |
| 3379 | 3704 | |
| 3380 | 3705 | static void sunsoft_irq ( const device_config *device, int scanline, int vblank, int blanked ) |
| r5302 | r5303 | |
| 3395 | 3720 | |
| 3396 | 3721 | static WRITE8_HANDLER( mapper67_w ) |
| 3397 | 3722 | { |
| 3398 | | nes_state *state = space->machine->driver_data; |
| 3399 | | |
| 3400 | 3723 | // logerror("mapper67_w, offset %04x, data: %02x\n", offset, data); |
| 3401 | 3724 | switch (offset & 0x7801) |
| 3402 | 3725 | { |
| r5302 | r5303 | |
| 3404 | 3727 | // IRQ_enable = 0; |
| 3405 | 3728 | // break; |
| 3406 | 3729 | case 0x0800: |
| 3407 | | chr2_0 (space->machine, data); |
| 3730 | chr2_0 (space->machine, data, CHRROM); |
| 3408 | 3731 | break; |
| 3409 | 3732 | case 0x1800: |
| 3410 | | chr2_2 (space->machine, data); |
| 3733 | chr2_2 (space->machine, data, CHRROM); |
| 3411 | 3734 | break; |
| 3412 | 3735 | case 0x2800: |
| 3413 | | chr2_4 (space->machine, data); |
| 3736 | chr2_4 (space->machine, data, CHRROM); |
| 3414 | 3737 | break; |
| 3415 | 3738 | case 0x3800: |
| 3416 | | chr2_6 (space->machine, data); |
| 3739 | chr2_6 (space->machine, data, CHRROM); |
| 3417 | 3740 | break; |
| 3418 | 3741 | case 0x4800: |
| 3419 | 3742 | // nes_vram[5] = data * 64; |
| r5302 | r5303 | |
| 3433 | 3756 | case 0x6801: |
| 3434 | 3757 | switch(data&3) |
| 3435 | 3758 | { |
| 3436 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 3437 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 3438 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 3439 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 3759 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 3760 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 3761 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 3762 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 3440 | 3763 | } |
| 3441 | 3764 | break; |
| 3442 | 3765 | case 0x7800: |
| r5302 | r5303 | |
| 3452 | 3775 | |
| 3453 | 3776 | static void mapper68_mirror (running_machine *machine, int m68_mirror, int m0, int m1) |
| 3454 | 3777 | { |
| 3455 | | nes_state *state = machine->driver_data; |
| 3456 | | |
| 3457 | 3778 | /* The 0x20000 (128k) offset is a magic number */ |
| 3458 | 3779 | #define M68_OFFSET 0x20000 |
| 3459 | 3780 | |
| 3460 | 3781 | switch (m68_mirror) |
| 3461 | 3782 | { |
| 3462 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 3463 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 3464 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 3465 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 3783 | case 0x00: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 3784 | case 0x01: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 3785 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 3786 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 3466 | 3787 | case 0x10: |
| 3467 | | ppu_mirror_custom_vrom (0, (m0 << 10) + M68_OFFSET); |
| 3468 | | ppu_mirror_custom_vrom (1, (m1 << 10) + M68_OFFSET); |
| 3469 | | ppu_mirror_custom_vrom (2, (m0 << 10) + M68_OFFSET); |
| 3470 | | ppu_mirror_custom_vrom (3, (m1 << 10) + M68_OFFSET); |
| 3788 | ppu_mirror_custom_vrom (0, m0|0x80); //(m0 << 10) + M68_OFFSET); |
| 3789 | ppu_mirror_custom_vrom (1, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3790 | ppu_mirror_custom_vrom (2, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3791 | ppu_mirror_custom_vrom (3, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3471 | 3792 | break; |
| 3472 | 3793 | case 0x11: |
| 3473 | | ppu_mirror_custom_vrom (0, (m0 << 10) + M68_OFFSET); |
| 3474 | | ppu_mirror_custom_vrom (1, (m0 << 10) + M68_OFFSET); |
| 3475 | | ppu_mirror_custom_vrom (2, (m1 << 10) + M68_OFFSET); |
| 3476 | | ppu_mirror_custom_vrom (3, (m1 << 10) + M68_OFFSET); |
| 3794 | ppu_mirror_custom_vrom (0, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3795 | ppu_mirror_custom_vrom (1, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3796 | ppu_mirror_custom_vrom (2, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3797 | ppu_mirror_custom_vrom (3, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3477 | 3798 | break; |
| 3478 | 3799 | case 0x12: |
| 3479 | | ppu_mirror_custom_vrom (0, (m0 << 10) + M68_OFFSET); |
| 3480 | | ppu_mirror_custom_vrom (1, (m0 << 10) + M68_OFFSET); |
| 3481 | | ppu_mirror_custom_vrom (2, (m0 << 10) + M68_OFFSET); |
| 3482 | | ppu_mirror_custom_vrom (3, (m0 << 10) + M68_OFFSET); |
| 3800 | ppu_mirror_custom_vrom (0, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3801 | ppu_mirror_custom_vrom (1, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3802 | ppu_mirror_custom_vrom (2, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3803 | ppu_mirror_custom_vrom (3, m0|0x80);//(m0 << 10) + M68_OFFSET); |
| 3483 | 3804 | break; |
| 3484 | 3805 | case 0x13: |
| 3485 | | ppu_mirror_custom_vrom (0, (m1 << 10) + M68_OFFSET); |
| 3486 | | ppu_mirror_custom_vrom (1, (m1 << 10) + M68_OFFSET); |
| 3487 | | ppu_mirror_custom_vrom (2, (m1 << 10) + M68_OFFSET); |
| 3488 | | ppu_mirror_custom_vrom (3, (m1 << 10) + M68_OFFSET); |
| 3806 | ppu_mirror_custom_vrom (0, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3807 | ppu_mirror_custom_vrom (1, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3808 | ppu_mirror_custom_vrom (2, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3809 | ppu_mirror_custom_vrom (3, m1|0x80);//(m1 << 10) + M68_OFFSET); |
| 3489 | 3810 | break; |
| 3490 | 3811 | } |
| 3491 | 3812 | } |
| r5302 | r5303 | |
| 3499 | 3820 | { |
| 3500 | 3821 | case 0x0000: |
| 3501 | 3822 | /* Switch 2k VROM at $0000 */ |
| 3502 | | chr2_0 (space->machine, data); |
| 3823 | chr2_0 (space->machine, data, CHRROM); |
| 3503 | 3824 | break; |
| 3504 | 3825 | case 0x1000: |
| 3505 | 3826 | /* Switch 2k VROM at $0800 */ |
| 3506 | | chr2_2 (space->machine, data); |
| 3827 | chr2_2 (space->machine, data, CHRROM); |
| 3507 | 3828 | break; |
| 3508 | 3829 | case 0x2000: |
| 3509 | 3830 | /* Switch 2k VROM at $1000 */ |
| 3510 | | chr2_4 (space->machine, data); |
| 3831 | chr2_4 (space->machine, data, CHRROM); |
| 3511 | 3832 | break; |
| 3512 | 3833 | case 0x3000: |
| 3513 | 3834 | /* Switch 2k VROM at $1800 */ |
| 3514 | | chr2_6 (space->machine, data); |
| 3835 | chr2_6 (space->machine, data, CHRROM); |
| 3515 | 3836 | break; |
| 3516 | 3837 | case 0x4000: |
| 3517 | | m0 = data; |
| 3838 | m0 = data&0x7F; |
| 3518 | 3839 | mapper68_mirror (space->machine, m68_mirror, m0, m1); |
| 3519 | 3840 | break; |
| 3520 | 3841 | case 0x5000: |
| 3521 | | m1 = data; |
| 3842 | m1 = data&0x7F; |
| 3522 | 3843 | mapper68_mirror (space->machine, m68_mirror, m0, m1); |
| 3523 | 3844 | break; |
| 3524 | 3845 | case 0x6000: |
| r5302 | r5303 | |
| 3537 | 3858 | |
| 3538 | 3859 | static WRITE8_HANDLER( mapper69_w ) |
| 3539 | 3860 | { |
| 3540 | | nes_state *state = space->machine->driver_data; |
| 3541 | 3861 | static int cmd = 0; |
| 3542 | 3862 | |
| 3543 | 3863 | // logerror("mapper69_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| r5302 | r5303 | |
| 3552 | 3872 | switch (cmd) |
| 3553 | 3873 | { |
| 3554 | 3874 | case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: |
| 3555 | | ppu2c0x_set_videorom_bank(state->ppu, cmd, 1, data, 64); |
| 3875 | chr1_x(space->machine, cmd, data, CHRROM); |
| 3876 | //ppu2c0x_set_videorom_bank(state->ppu, cmd, 1, data, 64); |
| 3556 | 3877 | break; |
| 3557 | 3878 | |
| 3558 | 3879 | /* TODO: deal with bankswitching/write-protecting the mid-mapper area */ |
| r5302 | r5303 | |
| 3579 | 3900 | case 12: |
| 3580 | 3901 | switch (data & 0x03) |
| 3581 | 3902 | { |
| 3582 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 3583 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 3584 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 3585 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 3903 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 3904 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 3905 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 3906 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 3586 | 3907 | } |
| 3587 | 3908 | break; |
| 3588 | 3909 | case 13: |
| r5302 | r5303 | |
| 3605 | 3926 | |
| 3606 | 3927 | static WRITE8_HANDLER( mapper70_w ) |
| 3607 | 3928 | { |
| 3608 | | nes_state *state = space->machine->driver_data; |
| 3609 | | |
| 3610 | 3929 | logerror("mapper70_w offset %04x, data: %02x\n", offset, data); |
| 3611 | 3930 | |
| 3612 | 3931 | /* TODO: is the data being written irrelevant? */ |
| 3613 | 3932 | |
| 3614 | 3933 | prg16_89ab (space, (data & 0xf0) >> 4); |
| 3615 | 3934 | |
| 3616 | | chr8 (space->machine, data & 0x0f); |
| 3935 | chr8 (space->machine, data & 0x0f, CHRROM); |
| 3617 | 3936 | |
| 3618 | 3937 | #if 1 |
| 3619 | 3938 | if (data & 0x80) |
| 3620 | | // ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3621 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 3939 | // set_nt_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 3940 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 3622 | 3941 | else |
| 3623 | | // ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3624 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 3942 | // set_nt_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 3943 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 3625 | 3944 | #endif |
| 3626 | 3945 | } |
| 3627 | 3946 | |
| r5302 | r5303 | |
| 3647 | 3966 | if(data&0x80) |
| 3648 | 3967 | prg16_89ab (space, data & 0x0f); |
| 3649 | 3968 | if(data&0x40) |
| 3650 | | chr8 (space->machine, data & 0x0f); |
| 3969 | chr8 (space->machine, data & 0x0f, CHRROM); |
| 3651 | 3970 | |
| 3652 | 3971 | } |
| 3653 | 3972 | |
| r5302 | r5303 | |
| 3684 | 4003 | |
| 3685 | 4004 | static WRITE8_HANDLER( mapper75_w ) |
| 3686 | 4005 | { |
| 3687 | | nes_state *state = space->machine->driver_data; |
| 3688 | | |
| 3689 | 4006 | logerror("mapper75_w, offset: %04x, data: %02x\n", offset, data); |
| 3690 | 4007 | |
| 3691 | 4008 | switch (offset & 0x7000) |
| r5302 | r5303 | |
| 3695 | 4012 | break; |
| 3696 | 4013 | case 0x1000: /* TODO: verify */ |
| 3697 | 4014 | if (data & 0x01) |
| 3698 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 4015 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 3699 | 4016 | else |
| 3700 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 4017 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 3701 | 4018 | /* vrom banking as well? */ |
| 3702 | 4019 | break; |
| 3703 | 4020 | case 0x2000: |
| r5302 | r5303 | |
| 3707 | 4024 | prg8_cd (space, data); |
| 3708 | 4025 | break; |
| 3709 | 4026 | case 0x6000: |
| 3710 | | chr4_0 (space->machine, data); |
| 4027 | chr4_0 (space->machine, data, CHRROM); |
| 3711 | 4028 | break; |
| 3712 | 4029 | case 0x7000: |
| 3713 | | chr4_4 (space->machine, data); |
| 4030 | chr4_4 (space->machine, data, CHRROM); |
| 3714 | 4031 | break; |
| 3715 | 4032 | } |
| 3716 | 4033 | } |
| 3717 | 4034 | |
| 3718 | 4035 | static WRITE8_HANDLER( mapper76_w ) |
| 3719 | 4036 | { |
| 3720 | | nes_state *state = space->machine->driver_data; |
| 3721 | 4037 | static int cmd=0; |
| 3722 | 4038 | |
| 3723 | 4039 | logerror("mapper76_w, offset: %04x, data: %02x\n", offset, data); |
| r5302 | r5303 | |
| 3729 | 4045 | { |
| 3730 | 4046 | switch(cmd&7) |
| 3731 | 4047 | { |
| 3732 | | case 2:chr2_0(space->machine, data);break; |
| 3733 | | case 3:chr2_2(space->machine, data);break; |
| 3734 | | case 4:chr2_4(space->machine, data);break; |
| 3735 | | case 5:chr2_6(space->machine, data);break; |
| 4048 | case 2:chr2_0(space->machine, data, CHRROM);break; |
| 4049 | case 3:chr2_2(space->machine, data, CHRROM);break; |
| 4050 | case 4:chr2_4(space->machine, data, CHRROM);break; |
| 4051 | case 5:chr2_6(space->machine, data, CHRROM);break; |
| 3736 | 4052 | case 6:(cmd&0x40)?prg8_cd(space, data):prg8_89(space, data);break; |
| 3737 | 4053 | case 7:prg8_ab(space, data);break; |
| 3738 | 4054 | default:logerror("mapper76 unsupported command: %02x, data: %02x\n", cmd, data);break; |
| 3739 | 4055 | } |
| 3740 | 4056 | } |
| 3741 | | case 0x2000: (data&1)?ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ):ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT);break; |
| 4057 | case 0x2000: (data&1)?set_nt_mirroring(PPU_MIRROR_HORZ):set_nt_mirroring(PPU_MIRROR_VERT);break; |
| 3742 | 4058 | default: logerror("mapper76 unmapped write, offset: %04x, data: %02x\n", offset, data);break; |
| 3743 | 4059 | } |
| 3744 | 4060 | } |
| r5302 | r5303 | |
| 3767 | 4083 | { |
| 3768 | 4084 | logerror("mapper78_w, offset: %04x, data: %02x\n", offset, data); |
| 3769 | 4085 | /* Switch 8k VROM bank */ |
| 3770 | | chr8 (space->machine, (data & 0xf0) >> 4); |
| 4086 | chr8 (space->machine, (data & 0xf0) >> 4, CHRROM); |
| 3771 | 4087 | |
| 3772 | 4088 | /* Switch 16k ROM bank */ |
| 3773 | 4089 | prg16_89ab (space, data & 0x0f); |
| r5302 | r5303 | |
| 3780 | 4096 | if ((offset-0x100) & 0x0100) |
| 3781 | 4097 | { |
| 3782 | 4098 | /* Select 8k VROM bank */ |
| 3783 | | chr8 (space->machine, data & 0x07); |
| 4099 | chr8 (space->machine, data & 0x07, CHRROM); |
| 3784 | 4100 | |
| 3785 | 4101 | /* Select 32k ROM bank? */ |
| 3786 | 4102 | prg32 (space, (data & 0x08) >> 3); |
| r5302 | r5303 | |
| 3794 | 4110 | |
| 3795 | 4111 | static WRITE8_HANDLER( mapper80_m_w ) |
| 3796 | 4112 | { |
| 3797 | | nes_state *state = space->machine->driver_data; |
| 3798 | | |
| 3799 | 4113 | logerror("mapper80_m_w, offset: %04x, data: %02x\n", offset, data); |
| 3800 | 4114 | |
| 3801 | 4115 | switch (offset) |
| 3802 | 4116 | { |
| 3803 | 4117 | case 0x1ef0: |
| 3804 | 4118 | /* Switch 2k VROM at $0000 */ |
| 3805 | | chr2_0 (space->machine, (data & 0x7f) >> 1); |
| 4119 | chr2_0 (space->machine, (data & 0x7f) >> 1, CHRROM); |
| 3806 | 4120 | if (data & 0x80) |
| 3807 | 4121 | { |
| 3808 | 4122 | /* Horizontal, $2000-$27ff */ |
| r5302 | r5303 | |
| 3818 | 4132 | break; |
| 3819 | 4133 | case 0x1ef1: |
| 3820 | 4134 | /* Switch 2k VROM at $0000 */ |
| 3821 | | chr2_2 (space->machine, (data & 0x7f) >> 1); |
| 4135 | chr2_2 (space->machine, (data & 0x7f) >> 1, CHRROM); |
| 3822 | 4136 | if (data & 0x80) |
| 3823 | 4137 | { |
| 3824 | 4138 | /* Horizontal, $2800-$2fff */ |
| r5302 | r5303 | |
| 3834 | 4148 | break; |
| 3835 | 4149 | case 0x1ef2: |
| 3836 | 4150 | /* Switch 1k VROM at $1000 */ |
| 3837 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 4151 | chr1_4(space->machine, data, CHRROM); |
| 4152 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 3838 | 4153 | break; |
| 3839 | 4154 | case 0x1ef3: |
| 3840 | 4155 | /* Switch 1k VROM at $1400 */ |
| 3841 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 4156 | chr1_5(space->machine, data, CHRROM); |
| 4157 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 3842 | 4158 | break; |
| 3843 | 4159 | case 0x1ef4: |
| 3844 | 4160 | /* Switch 1k VROM at $1800 */ |
| 3845 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 4161 | chr1_6(space->machine, data, CHRROM); |
| 4162 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 3846 | 4163 | break; |
| 3847 | 4164 | case 0x1ef5: |
| 3848 | 4165 | /* Switch 1k VROM at $1c00 */ |
| 3849 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 4166 | chr1_7(space->machine, data, CHRROM); |
| 4167 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 3850 | 4168 | break; |
| 3851 | 4169 | case 0x1efa: case 0x1efb: |
| 3852 | 4170 | /* Switch 8k ROM at $8000 */ |
| r5302 | r5303 | |
| 3868 | 4186 | |
| 3869 | 4187 | static WRITE8_HANDLER( mapper82_m_w ) |
| 3870 | 4188 | { |
| 3871 | | nes_state *state = space->machine->driver_data; |
| 3872 | 4189 | static int vrom_switch; |
| 3873 | 4190 | |
| 3874 | 4191 | /* This mapper has problems */ |
| r5302 | r5303 | |
| 3880 | 4197 | case 0x1ef0: |
| 3881 | 4198 | /* Switch 2k VROM at $0000 or $1000 */ |
| 3882 | 4199 | if (vrom_switch) |
| 3883 | | chr2_4 (space->machine, data); |
| 4200 | chr2_4 (space->machine, data, CHRROM); |
| 3884 | 4201 | else |
| 3885 | | chr2_0 (space->machine, data); |
| 4202 | chr2_0 (space->machine, data, CHRROM); |
| 3886 | 4203 | break; |
| 3887 | 4204 | case 0x1ef1: |
| 3888 | 4205 | /* Switch 2k VROM at $0800 or $1800 */ |
| 3889 | 4206 | if (vrom_switch) |
| 3890 | | chr2_6 (space->machine, data); |
| 4207 | chr2_6 (space->machine, data, CHRROM); |
| 3891 | 4208 | else |
| 3892 | | chr2_2 (space->machine, data); |
| 4209 | chr2_2 (space->machine, data, CHRROM); |
| 3893 | 4210 | break; |
| 3894 | 4211 | case 0x1ef2: |
| 3895 | 4212 | /* Switch 1k VROM at $1000 */ |
| 3896 | | ppu2c0x_set_videorom_bank(state->ppu, 4 ^ vrom_switch, 1, data, 64); |
| 4213 | chr1_x(space->machine, 4 ^ vrom_switch, data, CHRROM); |
| 4214 | //ppu2c0x_set_videorom_bank(state->ppu, 4 ^ vrom_switch, 1, data, 64); |
| 3897 | 4215 | break; |
| 3898 | 4216 | case 0x1ef3: |
| 3899 | 4217 | /* Switch 1k VROM at $1400 */ |
| 3900 | | ppu2c0x_set_videorom_bank(state->ppu, 5 ^ vrom_switch, 1, data, 64); |
| 4218 | chr1_x(space->machine, 5 ^ vrom_switch, data, CHRROM); |
| 4219 | // ppu2c0x_set_videorom_bank(state->ppu, 5 ^ vrom_switch, 1, data, 64); |
| 3901 | 4220 | break; |
| 3902 | 4221 | case 0x1ef4: |
| 3903 | 4222 | /* Switch 1k VROM at $1800 */ |
| 3904 | | ppu2c0x_set_videorom_bank(state->ppu, 6 ^ vrom_switch, 1, data, 64); |
| 4223 | chr1_x(space->machine, 6 ^ vrom_switch, data, CHRROM); |
| 4224 | // ppu2c0x_set_videorom_bank(state->ppu, 6 ^ vrom_switch, 1, data, 64); |
| 3905 | 4225 | break; |
| 3906 | 4226 | case 0x1ef5: |
| 3907 | 4227 | /* Switch 1k VROM at $1c00 */ |
| 3908 | | ppu2c0x_set_videorom_bank(state->ppu, 7 ^ vrom_switch, 1, data, 64); |
| 4228 | chr1_x(space->machine, 7 ^ vrom_switch, data, CHRROM); |
| 4229 | // ppu2c0x_set_videorom_bank(state->ppu, 7 ^ vrom_switch, 1, data, 64); |
| 3909 | 4230 | break; |
| 3910 | 4231 | case 0x1ef6: |
| 3911 | | (data&0x1)?ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT):ppu2c0x_set_mirroring(state->ppu,PPU_MIRROR_HORZ); |
| 4232 | (data&0x1)?set_nt_mirroring(PPU_MIRROR_VERT):set_nt_mirroring(PPU_MIRROR_HORZ); |
| 3912 | 4233 | //doc says 1= swapped. Causes in-game issues, but mostly fixes title screen |
| 3913 | 4234 | vrom_switch = ((data & 0x02) << 1); |
| 3914 | 4235 | break; |
| r5302 | r5303 | |
| 3947 | 4268 | } |
| 3948 | 4269 | |
| 3949 | 4270 | static void mapper83_set_chr( running_machine *machine ) { |
| 3950 | | chr1_0( machine, mapper83_data[0] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3951 | | chr1_1( machine, mapper83_data[1] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3952 | | chr1_2( machine, mapper83_data[2] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3953 | | chr1_3( machine, mapper83_data[3] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3954 | | chr1_4( machine, mapper83_data[4] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3955 | | chr1_5( machine, mapper83_data[5] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3956 | | chr1_6( machine, mapper83_data[6] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 3957 | | chr1_7( machine, mapper83_data[7] | ( ( mapper83_data[8] & 0x30 ) << 4 ) ); |
| 4271 | chr1_0( machine, mapper83_data[0] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4272 | chr1_1( machine, mapper83_data[1] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4273 | chr1_2( machine, mapper83_data[2] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4274 | chr1_3( machine, mapper83_data[3] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4275 | chr1_4( machine, mapper83_data[4] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4276 | chr1_5( machine, mapper83_data[5] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4277 | chr1_6( machine, mapper83_data[6] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 4278 | chr1_7( machine, mapper83_data[7] | ( ( mapper83_data[8] & 0x30 ) << 4 ), CHRROM ); |
| 3958 | 4279 | } |
| 3959 | 4280 | |
| 3960 | 4281 | static WRITE8_HANDLER( mapper83_w ) |
| 3961 | 4282 | { |
| 3962 | | nes_state *state = space->machine->driver_data; |
| 3963 | | |
| 3964 | 4283 | LOG_MMC(("mapper83_w, offset: %04x, data: %02x\n", offset, data)); |
| 3965 | 4284 | |
| 3966 | 4285 | switch( offset ) { |
| r5302 | r5303 | |
| 3975 | 4294 | case 0x0100: |
| 3976 | 4295 | switch( data & 0x03 ) { |
| 3977 | 4296 | case 0: |
| 3978 | | ppu2c0x_set_mirroring( state->ppu, PPU_MIRROR_VERT ); |
| 4297 | set_nt_mirroring(PPU_MIRROR_VERT ); |
| 3979 | 4298 | break; |
| 3980 | 4299 | case 1: |
| 3981 | | ppu2c0x_set_mirroring( state->ppu, PPU_MIRROR_HORZ ); |
| 4300 | set_nt_mirroring(PPU_MIRROR_HORZ ); |
| 3982 | 4301 | break; |
| 3983 | 4302 | case 2: |
| 3984 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 4303 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 3985 | 4304 | break; |
| 3986 | 4305 | case 3: |
| 3987 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 4306 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 3988 | 4307 | break; |
| 3989 | 4308 | } |
| 3990 | 4309 | break; |
| r5302 | r5303 | |
| 4024 | 4343 | |
| 4025 | 4344 | static WRITE8_HANDLER( konami_vrc7_w ) |
| 4026 | 4345 | { |
| 4027 | | nes_state *state = space->machine->driver_data; |
| 4028 | | |
| 4029 | 4346 | // logerror("konami_vrc7_w offset: %04x, data: %02x, scanline: %d\n", offset, data, current_scanline); |
| 4030 | 4347 | |
| 4031 | 4348 | switch (offset & 0x7018) |
| r5302 | r5303 | |
| 4048 | 4365 | |
| 4049 | 4366 | case 0x2000: |
| 4050 | 4367 | /* Switch 1k VROM at $0000 */ |
| 4051 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 1, data, 64); |
| 4368 | chr1_0(space->machine, data, CHRROM); |
| 4369 | // ppu2c0x_set_videorom_bank(state->ppu, 0, 1, data, 64); |
| 4052 | 4370 | break; |
| 4053 | 4371 | case 0x2008: case 0x2010: case 0x2018: |
| 4054 | 4372 | /* Switch 1k VROM at $0400 */ |
| 4055 | | ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64); |
| 4373 | chr1_1(space->machine, data, CHRROM); |
| 4374 | // ppu2c0x_set_videorom_bank(state->ppu, 1, 1, data, 64); |
| 4056 | 4375 | break; |
| 4057 | 4376 | case 0x3000: |
| 4058 | 4377 | /* Switch 1k VROM at $0800 */ |
| 4059 | | ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64); |
| 4378 | chr1_2(space->machine, data, CHRROM); |
| 4379 | // ppu2c0x_set_videorom_bank(state->ppu, 2, 1, data, 64); |
| 4060 | 4380 | break; |
| 4061 | 4381 | case 0x3008: case 0x3010: case 0x3018: |
| 4062 | 4382 | /* Switch 1k VROM at $0c00 */ |
| 4063 | | ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64); |
| 4383 | chr1_3(space->machine, data, CHRROM); |
| 4384 | // ppu2c0x_set_videorom_bank(state->ppu, 3, 1, data, 64); |
| 4064 | 4385 | break; |
| 4065 | 4386 | case 0x4000: |
| 4066 | 4387 | /* Switch 1k VROM at $1000 */ |
| 4067 | | ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 4388 | chr1_4(space->machine, data, CHRROM); |
| 4389 | // ppu2c0x_set_videorom_bank(state->ppu, 4, 1, data, 64); |
| 4068 | 4390 | break; |
| 4069 | 4391 | case 0x4008: case 0x4010: case 0x4018: |
| 4070 | 4392 | /* Switch 1k VROM at $1400 */ |
| 4071 | | ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 4393 | chr1_5(space->machine, data, CHRROM); |
| 4394 | // ppu2c0x_set_videorom_bank(state->ppu, 5, 1, data, 64); |
| 4072 | 4395 | break; |
| 4073 | 4396 | case 0x5000: |
| 4074 | 4397 | /* Switch 1k VROM at $1800 */ |
| 4075 | | ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 4398 | chr1_6(space->machine, data, CHRROM); |
| 4399 | // ppu2c0x_set_videorom_bank(state->ppu, 6, 1, data, 64); |
| 4076 | 4400 | break; |
| 4077 | 4401 | case 0x5008: case 0x5010: case 0x5018: |
| 4078 | 4402 | /* Switch 1k VROM at $1c00 */ |
| 4079 | | ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 4403 | chr1_7(space->machine, data, CHRROM); |
| 4404 | // ppu2c0x_set_videorom_bank(state->ppu, 7, 1, data, 64); |
| 4080 | 4405 | break; |
| 4081 | 4406 | |
| 4082 | 4407 | case 0x6000: |
| 4083 | 4408 | switch (data & 0x03) |
| 4084 | 4409 | { |
| 4085 | | case 0x00: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); break; |
| 4086 | | case 0x01: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); break; |
| 4087 | | case 0x02: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); break; |
| 4088 | | case 0x03: ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); break; |
| 4410 | case 0x00: set_nt_mirroring(PPU_MIRROR_VERT); break; |
| 4411 | case 0x01: set_nt_mirroring(PPU_MIRROR_HORZ); break; |
| 4412 | case 0x02: set_nt_mirroring(PPU_MIRROR_LOW); break; |
| 4413 | case 0x03: set_nt_mirroring(PPU_MIRROR_HIGH); break; |
| 4089 | 4414 | } |
| 4090 | 4415 | break; |
| 4091 | 4416 | case 0x6008: case 0x6010: case 0x6018: |
| r5302 | r5303 | |
| 4127 | 4452 | logerror("mapper87_m_w %04x:%02x\n", offset, data); |
| 4128 | 4453 | |
| 4129 | 4454 | /* TODO: verify */ |
| 4130 | | chr8 (space->machine, data >> 1); |
| 4455 | chr8 (space->machine, data >> 1, CHRROM); |
| 4131 | 4456 | } |
| 4132 | 4457 | static WRITE8_HANDLER( mapper89_w ) |
| 4133 | 4458 | { |
| 4134 | | nes_state *state = space->machine->driver_data; |
| 4135 | 4459 | int chr; |
| 4136 | 4460 | logerror("mapper89_m_w %04x:%02x\n", offset, data); |
| 4137 | 4461 | prg16_89ab(space, (data>>4)&7); |
| 4138 | 4462 | chr=(data&7)|((data&0x80)?8:0); |
| 4139 | | chr8(space->machine, chr); |
| 4140 | | (data&8)?ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH):ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 4463 | chr8(space->machine, chr, CHRROM); |
| 4464 | (data&8)?set_nt_mirroring(PPU_MIRROR_HIGH):set_nt_mirroring(PPU_MIRROR_LOW); |
| 4141 | 4465 | |
| 4142 | 4466 | } |
| 4143 | 4467 | |
| r5302 | r5303 | |
| 4150 | 4474 | case 0x0000: |
| 4151 | 4475 | switch (offset & 0x03) |
| 4152 | 4476 | { |
| 4153 | | case 0x00: chr2_0 (space->machine, data); break; |
| 4154 | | case 0x01: chr2_2 (space->machine, data); break; |
| 4155 | | case 0x02: chr2_4 (space->machine, data); break; |
| 4156 | | case 0x03: chr2_6 (space->machine, data); break; |
| 4477 | case 0x00: chr2_0 (space->machine, data, CHRROM); break; |
| 4478 | case 0x01: chr2_2 (space->machine, data, CHRROM); break; |
| 4479 | case 0x02: chr2_4 (space->machine, data, CHRROM); break; |
| 4480 | case 0x03: chr2_6 (space->machine, data, CHRROM); break; |
| 4157 | 4481 | } |
| 4158 | 4482 | break; |
| 4159 | 4483 | case 0x1000: |
| r5302 | r5303 | |
| 4175 | 4499 | if(data&0x80) |
| 4176 | 4500 | prg16_cdef (space, data & 0x0f); |
| 4177 | 4501 | if(data&0x40) |
| 4178 | | chr8 (space->machine, data & 0x0f); |
| 4502 | chr8 (space->machine, data & 0x0f, CHRROM); |
| 4179 | 4503 | |
| 4180 | 4504 | } |
| 4181 | 4505 | |
| r5302 | r5303 | |
| 4226 | 4550 | |
| 4227 | 4551 | static WRITE8_HANDLER( mapper97_w ) |
| 4228 | 4552 | { |
| 4229 | | nes_state *state = space->machine->driver_data; |
| 4230 | | |
| 4231 | 4553 | if(offset&0x4000) |
| 4232 | 4554 | return; |
| 4233 | 4555 | if(data&0x80) |
| 4234 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 4235 | | else ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 4556 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4557 | else set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4236 | 4558 | prg16_cdef(space, data&0x0F); |
| 4237 | 4559 | } |
| 4238 | 4560 | static WRITE8_HANDLER( mapper101_m_w ) |
| 4239 | 4561 | { |
| 4240 | 4562 | LOG_MMC(("mapper101_m_w %04x:%02x\n", offset, data)); |
| 4241 | 4563 | |
| 4242 | | chr8 (space->machine, data); |
| 4564 | chr8 (space->machine, data, CHRROM); |
| 4243 | 4565 | } |
| 4244 | 4566 | |
| 4245 | 4567 | static WRITE8_HANDLER( mapper101_w ) |
| r5302 | r5303 | |
| 4251 | 4573 | static WRITE8_HANDLER( mapper107_w ) |
| 4252 | 4574 | { |
| 4253 | 4575 | prg32(space, data>>1); |
| 4254 | | chr8(space->machine, data); |
| 4576 | chr8(space->machine, data, CHRROM); |
| 4255 | 4577 | } |
| 4256 | 4578 | |
| 4257 | 4579 | static WRITE8_HANDLER( mapper112_w ) |
| 4258 | 4580 | { |
| 4259 | | nes_state *state = space->machine->driver_data; |
| 4260 | | |
| 4261 | 4581 | LOG_MMC(("mapper112_w, offset: %04x, data: %02x\n", offset, data)); |
| 4262 | 4582 | |
| 4263 | 4583 | switch( offset ) { |
| r5302 | r5303 | |
| 4274 | 4594 | break; |
| 4275 | 4595 | case 2: |
| 4276 | 4596 | data &= 0xFE; |
| 4277 | | chr1_0( space->machine, data ); |
| 4278 | | chr1_1( space->machine, data + 1 ); |
| 4597 | chr1_0( space->machine, data, CHRROM ); |
| 4598 | chr1_1( space->machine, data + 1, CHRROM ); |
| 4279 | 4599 | break; |
| 4280 | 4600 | case 3: |
| 4281 | 4601 | data &= 0xFE; |
| 4282 | | chr1_2( space->machine, data ); |
| 4283 | | chr1_3( space->machine, data + 1 ); |
| 4602 | chr1_2( space->machine, data, CHRROM ); |
| 4603 | chr1_3( space->machine, data + 1, CHRROM ); |
| 4284 | 4604 | break; |
| 4285 | 4605 | case 4: |
| 4286 | | chr1_4( space->machine, data ); |
| 4606 | chr1_4( space->machine, data, CHRROM ); |
| 4287 | 4607 | break; |
| 4288 | 4608 | case 5: |
| 4289 | | chr1_5( space->machine, data ); |
| 4609 | chr1_5( space->machine, data, CHRROM ); |
| 4290 | 4610 | break; |
| 4291 | 4611 | case 6: |
| 4292 | | chr1_6( space->machine, data ); |
| 4612 | chr1_6( space->machine, data, CHRROM ); |
| 4293 | 4613 | break; |
| 4294 | 4614 | case 7: |
| 4295 | | chr1_7( space->machine, data ); |
| 4615 | chr1_7( space->machine, data, CHRROM ); |
| 4296 | 4616 | break; |
| 4297 | 4617 | } |
| 4298 | 4618 | break; |
| 4299 | 4619 | case 0x6000: |
| 4300 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4620 | set_nt_mirroring(( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4301 | 4621 | break; |
| 4302 | 4622 | } |
| 4303 | 4623 | } |
| r5302 | r5303 | |
| 4310 | 4630 | if(offset>0xFF) |
| 4311 | 4631 | return; |
| 4312 | 4632 | prg32(space, data>>3); |
| 4313 | | chr8(space->machine, data&7); |
| 4633 | chr8(space->machine, data&7, CHRROM); |
| 4314 | 4634 | } |
| 4315 | 4635 | static WRITE8_HANDLER( mapper133_l_w ) |
| 4316 | 4636 | { |
| r5302 | r5303 | |
| 4320 | 4640 | if(offset!=0x20) |
| 4321 | 4641 | return; |
| 4322 | 4642 | prg32(space, data>>2); |
| 4323 | | chr8(space->machine, data&3); |
| 4643 | chr8(space->machine, data&3, CHRROM); |
| 4324 | 4644 | } |
| 4325 | 4645 | |
| 4326 | 4646 | static WRITE8_HANDLER( mapper_140_m_w ) |
| 4327 | 4647 | { |
| 4328 | | chr8(space->machine, data&0x0f); |
| 4648 | chr8(space->machine, data&0x0f, CHRROM); |
| 4329 | 4649 | prg32(space, (data>>4)&0x03); |
| 4330 | 4650 | } |
| 4331 | 4651 | |
| r5302 | r5303 | |
| 4342 | 4662 | data = data|(memory_read_byte(space,offset)&1); |
| 4343 | 4663 | |
| 4344 | 4664 | /* Switch 8k VROM bank */ |
| 4345 | | chr8 (space->machine, data >> 4); |
| 4665 | chr8 (space->machine, data >> 4, CHRROM); |
| 4346 | 4666 | |
| 4347 | 4667 | /* Switch 32k prg bank */ |
| 4348 | 4668 | prg32 (space, data & 0x07); |
| 4349 | 4669 | } |
| 4350 | 4670 | static WRITE8_HANDLER( mapper154_w ) |
| 4351 | 4671 | { |
| 4352 | | nes_state *state = space->machine->driver_data; |
| 4353 | | |
| 4354 | 4672 | switch(offset&1) |
| 4355 | 4673 | { |
| 4356 | 4674 | case 0: |
| 4357 | 4675 | { |
| 4358 | | (data&0x40)?ppu2c0x_set_mirroring(state->ppu,PPU_MIRROR_HIGH):ppu2c0x_set_mirroring(state->ppu,PPU_MIRROR_LOW); |
| 4676 | (data&0x40)?set_nt_mirroring(PPU_MIRROR_HIGH):set_nt_mirroring(PPU_MIRROR_LOW); |
| 4359 | 4677 | mapper154_reg=data&7; |
| 4360 | 4678 | break; |
| 4361 | 4679 | } |
| r5302 | r5303 | |
| 4363 | 4681 | { |
| 4364 | 4682 | switch(mapper154_reg) |
| 4365 | 4683 | { |
| 4366 | | case 0:chr2_0(space->machine,(data)>>1);break; |
| 4367 | | case 1:chr2_2(space->machine,(data)>>1);break; |
| 4368 | | case 2:chr1_4(space->machine,(data)|0x40);break; |
| 4369 | | case 3:chr1_5(space->machine,(data)|0x40);break; |
| 4370 | | case 4:chr1_6(space->machine,(data)|0x40);break; |
| 4371 | | case 5:chr1_7(space->machine,(data)|0x40);break; |
| 4684 | case 0:chr2_0(space->machine,(data)>>1, CHRROM);break; |
| 4685 | case 1:chr2_2(space->machine,(data)>>1, CHRROM);break; |
| 4686 | case 2:chr1_4(space->machine,(data)|0x40, CHRROM);break; |
| 4687 | case 3:chr1_5(space->machine,(data)|0x40, CHRROM);break; |
| 4688 | case 4:chr1_6(space->machine,(data)|0x40, CHRROM);break; |
| 4689 | case 5:chr1_7(space->machine,(data)|0x40, CHRROM);break; |
| 4372 | 4690 | case 6:prg8_89(space,data);break; |
| 4373 | 4691 | case 7:prg8_ab(space,data);break; |
| 4374 | 4692 | |
| r5302 | r5303 | |
| 4379 | 4697 | } |
| 4380 | 4698 | static WRITE8_HANDLER( mapper88_w ) |
| 4381 | 4699 | { |
| 4382 | | switch(offset&0x8001) |
| 4700 | switch(offset&1) |
| 4383 | 4701 | { |
| 4384 | | case 0x8000: |
| 4702 | case 0: |
| 4385 | 4703 | { |
| 4386 | | //(data&0x40)?ppu2c0x_set_mirroring(state->ppu,PPU_MIRROR_HIGH):ppu2c0x_set_mirroring(state->ppu,PPU_MIRROR_LOW); |
| 4704 | //(data&0x40)?set_nt_mirroring(state->ppu,PPU_MIRROR_HIGH):set_nt_mirroring(state->ppu,PPU_MIRROR_LOW); |
| 4387 | 4705 | mapper154_reg=data&7; |
| 4388 | 4706 | break; |
| 4389 | 4707 | } |
| 4390 | | case 0x8001: |
| 4708 | case 1: |
| 4391 | 4709 | { |
| 4392 | 4710 | switch(mapper154_reg) |
| 4393 | 4711 | { |
| 4394 | | case 0:chr2_0(space->machine,(data&0x3F)>>1);break; |
| 4395 | | case 1:chr2_2(space->machine,(data&0x3F)>>1);break; |
| 4396 | | case 2:chr1_4(space->machine,(data&0x3F)|0x40);break; |
| 4397 | | case 3:chr1_5(space->machine,(data&0x3F)|0x40);break; |
| 4398 | | case 4:chr1_6(space->machine,(data&0x3F)|0x40);break; |
| 4399 | | case 5:chr1_7(space->machine,(data&0x3F)|0x40);break; |
| 4712 | case 0:chr2_0(space->machine,(data&0x3F)>>1, CHRROM);break; |
| 4713 | case 1:chr2_2(space->machine,(data&0x3F)>>1, CHRROM);break; |
| 4714 | case 2:chr1_4(space->machine,(data&0x3F)|0x40, CHRROM);break; |
| 4715 | case 3:chr1_5(space->machine,(data&0x3F)|0x40, CHRROM);break; |
| 4716 | case 4:chr1_6(space->machine,(data&0x3F)|0x40, CHRROM);break; |
| 4717 | case 5:chr1_7(space->machine,(data&0x3F)|0x40, CHRROM);break; |
| 4400 | 4718 | case 6:prg8_89(space,data);break; |
| 4401 | 4719 | case 7:prg8_ab(space,data);break; |
| 4402 | 4720 | |
| r5302 | r5303 | |
| 4414 | 4732 | |
| 4415 | 4733 | static WRITE8_HANDLER( mapper182_w ) |
| 4416 | 4734 | { |
| 4417 | | nes_state *state = space->machine->driver_data; |
| 4418 | | |
| 4419 | 4735 | LOG_MMC(("mapper182_w, offset: %04x, data: %02x\n", offset, data)); |
| 4420 | 4736 | |
| 4421 | 4737 | switch( offset & 0x7003 ) { |
| 4422 | 4738 | case 0x0001: |
| 4423 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4739 | set_nt_mirroring(( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4424 | 4740 | break; |
| 4425 | 4741 | case 0x2000: |
| 4426 | 4742 | MMC1_bank1 = data; |
| r5302 | r5303 | |
| 4428 | 4744 | case 0x4000: |
| 4429 | 4745 | switch( MMC1_bank1 ) { |
| 4430 | 4746 | case 0: |
| 4431 | | chr2_0( space->machine, data >> 1 ); |
| 4747 | chr2_0( space->machine, data >> 1, CHRROM ); |
| 4432 | 4748 | break; |
| 4433 | 4749 | case 1: |
| 4434 | | chr1_5( space->machine, data ); |
| 4750 | chr1_5( space->machine, data, CHRROM ); |
| 4435 | 4751 | break; |
| 4436 | 4752 | case 2: |
| 4437 | | chr2_2( space->machine, data >> 1 ); |
| 4753 | chr2_2( space->machine, data >> 1, CHRROM ); |
| 4438 | 4754 | break; |
| 4439 | 4755 | case 3: |
| 4440 | | chr1_7( space->machine, data ); |
| 4756 | chr1_7( space->machine, data, CHRROM ); |
| 4441 | 4757 | break; |
| 4442 | 4758 | case 4: |
| 4443 | 4759 | prg8_89( space, data ); |
| r5302 | r5303 | |
| 4446 | 4762 | prg8_ab( space, data ); |
| 4447 | 4763 | break; |
| 4448 | 4764 | case 6: |
| 4449 | | chr1_4( space->machine, data ); |
| 4765 | chr1_4( space->machine, data, CHRROM ); |
| 4450 | 4766 | break; |
| 4451 | 4767 | case 7: |
| 4452 | | chr1_6( space->machine, data ); |
| 4768 | chr1_6( space->machine, data, CHRROM ); |
| 4453 | 4769 | break; |
| 4454 | 4770 | } |
| 4455 | 4771 | break; |
| r5302 | r5303 | |
| 4487 | 4803 | |
| 4488 | 4804 | if(0==offset) |
| 4489 | 4805 | { |
| 4490 | | chr4_0(space->machine, data&0x0F); |
| 4491 | | chr4_4(space->machine, (data>>4)); |
| 4806 | chr4_0(space->machine, data&0x0F, CHRROM); |
| 4807 | chr4_4(space->machine, (data>>4), CHRROM); |
| 4492 | 4808 | } |
| 4493 | 4809 | } |
| 4494 | 4810 | |
| r5302 | r5303 | |
| 4505 | 4821 | |
| 4506 | 4822 | switch( offset & 0x03 ) { |
| 4507 | 4823 | case 0: |
| 4508 | | chr4_0( space->machine, data >> 2 ); |
| 4824 | chr4_0( space->machine, data >> 2, CHRROM ); |
| 4509 | 4825 | break; |
| 4510 | 4826 | case 1: |
| 4511 | | chr2_4( space->machine, data >> 1 ); |
| 4827 | chr2_4( space->machine, data >> 1, CHRROM ); |
| 4512 | 4828 | break; |
| 4513 | 4829 | case 2: |
| 4514 | | chr2_6( space->machine, data >> 1 ); |
| 4830 | chr2_6( space->machine, data >> 1 , CHRROM); |
| 4515 | 4831 | break; |
| 4516 | 4832 | case 3: |
| 4517 | 4833 | prg8_89(space, data); |
| r5302 | r5303 | |
| 4521 | 4837 | |
| 4522 | 4838 | static WRITE8_HANDLER( mapper200_w ) |
| 4523 | 4839 | { |
| 4524 | | nes_state *state = space->machine->driver_data; |
| 4525 | | |
| 4526 | 4840 | LOG_MMC(("mapper200_w, offset: %04x, data: %02x\n", offset, data )); |
| 4527 | 4841 | |
| 4528 | 4842 | prg16_89ab( space, offset & 0x07 ); |
| 4529 | 4843 | prg16_cdef( space, offset & 0x07 ); |
| 4530 | | chr8( space->machine, offset & 0x07 ); |
| 4844 | chr8( space->machine, offset & 0x07 , CHRROM); |
| 4531 | 4845 | |
| 4532 | | ppu2c0x_set_mirroring( state->ppu, ( offset & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4846 | set_nt_mirroring(( offset & 0x08 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4533 | 4847 | } |
| 4534 | 4848 | |
| 4535 | 4849 | static WRITE8_HANDLER( mapper201_w ) |
| r5302 | r5303 | |
| 4538 | 4852 | |
| 4539 | 4853 | if ( offset & 0x08 ) { |
| 4540 | 4854 | prg32( space, offset & 0x03 ); |
| 4541 | | chr8( space->machine, offset & 0x03 ); |
| 4855 | chr8( space->machine, offset & 0x03, CHRROM ); |
| 4542 | 4856 | } else { |
| 4543 | 4857 | prg32( space, 0 ); |
| 4544 | | chr8( space->machine, 0 ); |
| 4858 | chr8( space->machine, 0, CHRROM ); |
| 4545 | 4859 | } |
| 4546 | 4860 | } |
| 4547 | 4861 | |
| 4548 | 4862 | static WRITE8_HANDLER( mapper202_w ) |
| 4549 | 4863 | { |
| 4550 | | nes_state *state = space->machine->driver_data; |
| 4551 | 4864 | int bank = ( offset >> 1 ) & 0x07; |
| 4552 | 4865 | |
| 4553 | 4866 | LOG_MMC(("mapper202_w, offset: %04x, data: %02x\n", offset, data)); |
| 4554 | 4867 | |
| 4555 | 4868 | prg16_89ab( space, bank ); |
| 4556 | 4869 | prg16_cdef( space, bank + ( ( ( bank & 0x06 ) == 0x06 ) ? 1 : 0 ) ); |
| 4557 | | chr8( space->machine, bank ); |
| 4870 | chr8( space->machine, bank, CHRROM ); |
| 4558 | 4871 | |
| 4559 | | ppu2c0x_set_mirroring( state->ppu, ( offset & 0x01 ) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT ); |
| 4872 | set_nt_mirroring(( offset & 0x01 ) ? PPU_MIRROR_HORZ: PPU_MIRROR_VERT ); |
| 4560 | 4873 | } |
| 4561 | 4874 | |
| 4562 | 4875 | static WRITE8_HANDLER( mapper203_w ) |
| r5302 | r5303 | |
| 4565 | 4878 | |
| 4566 | 4879 | prg16_89ab( space, ( data >> 2 ) & 0x03 ); |
| 4567 | 4880 | prg16_cdef( space, ( data >> 2 ) & 0x03 ); |
| 4568 | | chr8( space->machine, data & 0x03 ); |
| 4881 | chr8( space->machine, data & 0x03, CHRROM ); |
| 4569 | 4882 | } |
| 4570 | 4883 | |
| 4571 | 4884 | static WRITE8_HANDLER( mapper206_w ) |
| r5302 | r5303 | |
| 4578 | 4891 | |
| 4579 | 4892 | static WRITE8_HANDLER( mapper225_w ) |
| 4580 | 4893 | { |
| 4581 | | nes_state *state = space->machine->driver_data; |
| 4582 | 4894 | int hi_bank; |
| 4583 | 4895 | int size_16; |
| 4584 | 4896 | int bank; |
| 4585 | 4897 | |
| 4586 | 4898 | LOG_MMC(("mapper225_w, offset: %04x, data: %02x\n", offset, data)); |
| 4587 | 4899 | |
| 4588 | | chr8 (space->machine, offset & 0x3f); |
| 4900 | chr8 (space->machine, offset & 0x3f, CHRROM); |
| 4589 | 4901 | hi_bank = offset & 0x40; |
| 4590 | 4902 | size_16 = offset & 0x1000; |
| 4591 | 4903 | bank = (offset & 0xf80) >> 7; |
| r5302 | r5303 | |
| 4602 | 4914 | prg32 (space, bank); |
| 4603 | 4915 | |
| 4604 | 4916 | if (offset & 0x2000) |
| 4605 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 4917 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4606 | 4918 | else |
| 4607 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 4919 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4608 | 4920 | } |
| 4609 | 4921 | |
| 4610 | 4922 | static WRITE8_HANDLER( mapper226_w ) |
| 4611 | 4923 | { |
| 4612 | | nes_state *state = space->machine->driver_data; |
| 4613 | 4924 | int hi_bank; |
| 4614 | 4925 | int size_16; |
| 4615 | 4926 | int bank; |
| r5302 | r5303 | |
| 4629 | 4940 | hi_bank = reg0 & 0x01; |
| 4630 | 4941 | size_16 = reg0 & 0x20; |
| 4631 | 4942 | if (reg0 & 0x40) |
| 4632 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 4943 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4633 | 4944 | else |
| 4634 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 4945 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4635 | 4946 | |
| 4636 | 4947 | bank = ((reg0 & 0x1e) >> 1) | ((reg1 & 0x01) << 4); |
| 4637 | 4948 | |
| r5302 | r5303 | |
| 4650 | 4961 | |
| 4651 | 4962 | static WRITE8_HANDLER( mapper227_w ) |
| 4652 | 4963 | { |
| 4653 | | nes_state *state = space->machine->driver_data; |
| 4654 | 4964 | int hi_bank; |
| 4655 | 4965 | int size_32; |
| 4656 | 4966 | int bank; |
| r5302 | r5303 | |
| 4681 | 4991 | } |
| 4682 | 4992 | |
| 4683 | 4993 | if (offset & 0x02) |
| 4684 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 4994 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4685 | 4995 | else |
| 4686 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 4996 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4687 | 4997 | } |
| 4688 | 4998 | |
| 4689 | 4999 | static WRITE8_HANDLER( mapper228_w ) |
| 4690 | 5000 | { |
| 4691 | 5001 | /* The address lines double as data */ |
| 4692 | 5002 | /* --mPPppppPP-cccc */ |
| 4693 | | nes_state *state = space->machine->driver_data; |
| 4694 | 5003 | int bank; |
| 4695 | 5004 | int chr; |
| 4696 | 5005 | |
| r5302 | r5303 | |
| 4731 | 5040 | } |
| 4732 | 5041 | |
| 4733 | 5042 | if (offset & 0x2000) |
| 4734 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 5043 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4735 | 5044 | else |
| 4736 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 5045 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4737 | 5046 | |
| 4738 | 5047 | /* Now handle vrom banking */ |
| 4739 | 5048 | chr = (data & 0x03) + ((offset & 0x0f) << 2); |
| 4740 | | chr8 (space->machine, chr); |
| 5049 | chr8 (space->machine, chr, CHRROM); |
| 4741 | 5050 | } |
| 4742 | 5051 | |
| 4743 | 5052 | static WRITE8_HANDLER( mapper229_w ) |
| 4744 | 5053 | { |
| 4745 | | nes_state *state = space->machine->driver_data; |
| 4746 | | |
| 4747 | 5054 | LOG_MMC(("mapper229_w, offset: %04x, data: %02x\n", offset, data)); |
| 4748 | 5055 | |
| 4749 | 5056 | if (offset & 0x20) |
| 4750 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HORZ); |
| 5057 | set_nt_mirroring(PPU_MIRROR_HORZ); |
| 4751 | 5058 | else |
| 4752 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 5059 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 4753 | 5060 | |
| 4754 | 5061 | if ((offset & 0x1e) == 0) |
| 4755 | 5062 | { |
| 4756 | 5063 | prg32 (space, 0); |
| 4757 | | chr8 (space->machine, 0); |
| 5064 | chr8 (space->machine, 0, CHRROM); |
| 4758 | 5065 | } |
| 4759 | 5066 | else |
| 4760 | 5067 | { |
| 4761 | 5068 | prg16_89ab (space, offset & 0x1f); |
| 4762 | 5069 | prg16_89ab (space, offset & 0x1f); |
| 4763 | | chr8 (space->machine, offset); |
| 5070 | chr8 (space->machine, offset, CHRROM); |
| 4764 | 5071 | } |
| 4765 | 5072 | } |
| 4766 | 5073 | |
| 4767 | 5074 | static WRITE8_HANDLER( mapper230_w ) |
| 4768 | 5075 | { |
| 4769 | | nes_state *state = space->machine->driver_data; |
| 4770 | | |
| 4771 | 5076 | LOG_MMC(("mapper230_w, offset: %04x, data: %02x\n", offset, data)); |
| 4772 | 5077 | |
| 4773 | 5078 | if ( 1 ) { |
| r5302 | r5303 | |
| 4779 | 5084 | } else { |
| 4780 | 5085 | prg32( space, ( ( data & 0x1E ) >> 1 ) + 4 ); |
| 4781 | 5086 | } |
| 4782 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x40 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 5087 | set_nt_mirroring(( data & 0x40 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4783 | 5088 | } |
| 4784 | 5089 | } |
| 4785 | 5090 | |
| r5302 | r5303 | |
| 4791 | 5096 | |
| 4792 | 5097 | bank = (data & 0x03) | ((data & 0x80) >> 5); |
| 4793 | 5098 | prg32 (space, bank); |
| 4794 | | chr8 (space->machine, (data & 0x70) >> 4); |
| 5099 | chr8 (space->machine, (data & 0x70) >> 4, CHRROM); |
| 4795 | 5100 | } |
| 4796 | 5101 | |
| 4797 | 5102 | static void mapper232_set_prg( const address_space *space ) |
| r5302 | r5303 | |
| 4816 | 5121 | LOG_MMC(("mapper240_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 4817 | 5122 | |
| 4818 | 5123 | prg32( space, data >> 4 ); |
| 4819 | | chr8( space->machine, data & 0x0F ); |
| 5124 | chr8( space->machine, data & 0x0F, CHRROM ); |
| 4820 | 5125 | } |
| 4821 | 5126 | |
| 4822 | 5127 | static READ8_HANDLER( mapper241_l_r ) |
| r5302 | r5303 | |
| 4833 | 5138 | |
| 4834 | 5139 | static WRITE8_HANDLER( mapper242_w ) |
| 4835 | 5140 | { |
| 4836 | | nes_state *state = space->machine->driver_data; |
| 4837 | | |
| 4838 | 5141 | LOG_MMC(("mapper242_w, offset: %04x, data: %02x\n", offset, data)); |
| 4839 | 5142 | |
| 4840 | 5143 | prg32( space, ( offset >> 3 ) & 0x0F ); |
| 4841 | 5144 | |
| 4842 | 5145 | switch( data & 0x03 ) { |
| 4843 | 5146 | case 0: |
| 4844 | | ppu2c0x_set_mirroring( state->ppu, PPU_MIRROR_VERT ); |
| 5147 | set_nt_mirroring(PPU_MIRROR_VERT ); |
| 4845 | 5148 | break; |
| 4846 | 5149 | case 1: |
| 4847 | | ppu2c0x_set_mirroring( state->ppu, PPU_MIRROR_HORZ ); |
| 5150 | set_nt_mirroring(PPU_MIRROR_HORZ ); |
| 4848 | 5151 | break; |
| 4849 | 5152 | case 2: |
| 4850 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 5153 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 4851 | 5154 | break; |
| 4852 | 5155 | case 3: |
| 4853 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_HIGH); |
| 5156 | set_nt_mirroring(PPU_MIRROR_HIGH); |
| 4854 | 5157 | break; |
| 4855 | 5158 | } |
| 4856 | 5159 | } |
| r5302 | r5303 | |
| 4866 | 5169 | return; |
| 4867 | 5170 | } |
| 4868 | 5171 | if ( offset < 0x00e5 ) { |
| 4869 | | chr8( space->machine, ( offset - 0x00a5 ) & 0x07 ); |
| 5172 | chr8( space->machine, ( offset - 0x00a5 ) & 0x07, CHRROM ); |
| 4870 | 5173 | } |
| 4871 | 5174 | } |
| 4872 | 5175 | |
| r5302 | r5303 | |
| 4889 | 5192 | prg8_ef( space, data ); |
| 4890 | 5193 | break; |
| 4891 | 5194 | case 0x0004: |
| 4892 | | chr2_0( space->machine, data ); |
| 5195 | chr2_0( space->machine, data, CHRROM ); |
| 4893 | 5196 | break; |
| 4894 | 5197 | case 0x0005: |
| 4895 | | chr2_2( space->machine, data ); |
| 5198 | chr2_2( space->machine, data, CHRROM ); |
| 4896 | 5199 | break; |
| 4897 | 5200 | case 0x0006: |
| 4898 | | chr2_4( space->machine, data ); |
| 5201 | chr2_4( space->machine, data, CHRROM ); |
| 4899 | 5202 | break; |
| 4900 | 5203 | case 0x0007: |
| 4901 | | chr2_6( space->machine, data ); |
| 5204 | chr2_6( space->machine, data, CHRROM ); |
| 4902 | 5205 | break; |
| 4903 | 5206 | } |
| 4904 | 5207 | } else { |
| r5302 | r5303 | |
| 4925 | 5228 | |
| 4926 | 5229 | static WRITE8_HANDLER( mapper248_w ) |
| 4927 | 5230 | { |
| 4928 | | nes_state *state = space->machine->driver_data; |
| 4929 | | |
| 4930 | 5231 | LOG_MMC(("mapper248_w, offset: %04x, data: %02x\n", offset, data)); |
| 4931 | 5232 | |
| 4932 | 5233 | switch( offset & 0x7001 ) { |
| r5302 | r5303 | |
| 4936 | 5237 | case 0x0001: |
| 4937 | 5238 | switch( MMC1_bank1 & 0x07 ) { |
| 4938 | 5239 | case 0: |
| 4939 | | chr2_0( space->machine, data >> 1 ); |
| 5240 | chr2_0( space->machine, data >> 1, CHRROM ); |
| 4940 | 5241 | break; |
| 4941 | 5242 | case 1: |
| 4942 | | chr2_2( space->machine, data >> 1 ); |
| 5243 | chr2_2( space->machine, data >> 1, CHRROM ); |
| 4943 | 5244 | break; |
| 4944 | 5245 | case 2: |
| 4945 | | chr1_4( space->machine, data ); |
| 5246 | chr1_4( space->machine, data, CHRROM ); |
| 4946 | 5247 | break; |
| 4947 | 5248 | case 3: |
| 4948 | | chr1_5( space->machine, data ); |
| 5249 | chr1_5( space->machine, data, CHRROM ); |
| 4949 | 5250 | break; |
| 4950 | 5251 | case 4: |
| 4951 | | chr1_6( space->machine, data ); |
| 5252 | chr1_6( space->machine, data, CHRROM ); |
| 4952 | 5253 | break; |
| 4953 | 5254 | case 5: |
| 4954 | | chr1_7( space->machine, data ); |
| 5255 | chr1_7( space->machine, data, CHRROM ); |
| 4955 | 5256 | break; |
| 4956 | 5257 | case 6: |
| 4957 | 5258 | MMC1_bank2 = data; |
| r5302 | r5303 | |
| 4964 | 5265 | } |
| 4965 | 5266 | break; |
| 4966 | 5267 | case 0x2000: |
| 4967 | | ppu2c0x_set_mirroring( state->ppu, ( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 5268 | set_nt_mirroring(( data & 0x01 ) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT ); |
| 4968 | 5269 | break; |
| 4969 | 5270 | case 0x4000: |
| 4970 | 5271 | IRQ_count_latch = data; |
| r5302 | r5303 | |
| 5019 | 5320 | int err = 0; |
| 5020 | 5321 | const mmc *mapper; |
| 5021 | 5322 | |
| 5022 | | /* Set the vram bank-switch values to the default */ |
| 5023 | | ppu2c0x_set_videorom_bank(state->ppu, 0, 8, 0, 64); |
| 5323 | if(nes.chr_chunks==0) |
| 5324 | chr8(machine, 0,CHRRAM); |
| 5325 | else chr8(machine, 0,CHRROM); |
| 5024 | 5326 | |
| 5025 | 5327 | /* Set the mapper irq callback */ |
| 5026 | 5328 | mapper = nes_mapper_lookup(mapperNum); |
| 5329 | |
| 5330 | if(mapper == NULL) |
| 5331 | fatalerror("Unimplemented Mapper"); |
| 5332 | |
| 5027 | 5333 | ppu2c0x_set_scanline_callback (state->ppu, mapper ? mapper->mmc_scanline : NULL); |
| 5028 | 5334 | ppu2c0x_set_hblank_callback (state->ppu, mapper ? mapper->mmc_hblank : NULL); |
| 5029 | 5335 | |
| r5302 | r5303 | |
| 5087 | 5393 | prg16_cdef (space, nes.prg_chunks-1); |
| 5088 | 5394 | break; |
| 5089 | 5395 | case 13: |
| 5396 | chr4_0(space->machine, 0, CHRRAM); |
| 5397 | prg32(space, 0); |
| 5398 | break; |
| 5090 | 5399 | case 3: |
| 5091 | 5400 | /* Doesn't bank-switch */ |
| 5092 | 5401 | prg32(space, 0); |
| 5093 | 5402 | break; |
| 5094 | 5403 | case 4: |
| 5095 | 5404 | case 118: |
| 5405 | case 119: |
| 5096 | 5406 | case 206: |
| 5097 | 5407 | /* Can switch 8k prg banks */ |
| 5098 | 5408 | IRQ_enable = 0; |
| r5302 | r5303 | |
| 5121 | 5431 | break; |
| 5122 | 5432 | case 7: |
| 5123 | 5433 | /* Bankswitches 32k at a time */ |
| 5124 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 5434 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 5125 | 5435 | prg16_89ab (space, 0); |
| 5126 | 5436 | prg16_cdef (space, nes.prg_chunks-1); |
| 5127 | 5437 | break; |
| r5302 | r5303 | |
| 5273 | 5583 | MMC1_bank1 = 0; |
| 5274 | 5584 | MMC1_bank2 = 0; |
| 5275 | 5585 | prg32(space, MMC1_bank1); |
| 5276 | | chr8(space->machine, MMC1_bank2); |
| 5586 | chr8(space->machine, MMC1_bank2, CHRROM); |
| 5277 | 5587 | break; |
| 5278 | 5588 | case 51: |
| 5279 | 5589 | MMC1_bank1 = 0x01; |
| r5302 | r5303 | |
| 5286 | 5596 | MMC1_bank2 = 0x00; |
| 5287 | 5597 | prg16_89ab( space, 0 ); |
| 5288 | 5598 | prg16_cdef( space, 0 ); |
| 5289 | | chr8(space->machine, 0); |
| 5599 | chr8(space->machine, 0, CHRROM); |
| 5290 | 5600 | break; |
| 5291 | 5601 | case 58: |
| 5292 | 5602 | prg32(space, 0); |
| 5293 | | chr8(space->machine, 0); |
| 5603 | chr8(space->machine, 0, CHRROM); |
| 5294 | 5604 | break; |
| 5295 | 5605 | case 61: |
| 5296 | 5606 | case 62: |
| r5302 | r5303 | |
| 5319 | 5629 | prg8_ab(space, 1); |
| 5320 | 5630 | //cd is bankable, but this should init all banks just fine. |
| 5321 | 5631 | prg16_cdef(space, nes.prg_chunks-1); |
| 5322 | | chr2_0(space->machine, 0); |
| 5323 | | chr2_2(space->machine, 1); |
| 5324 | | chr2_4(space->machine, 2); |
| 5325 | | chr2_6(space->machine, 3); |
| 5632 | chr2_0(space->machine, 0, CHRROM); |
| 5633 | chr2_2(space->machine, 1, CHRROM); |
| 5634 | chr2_4(space->machine, 2, CHRROM); |
| 5635 | chr2_6(space->machine, 3, CHRROM); |
| 5326 | 5636 | break; |
| 5327 | 5637 | case 79: |
| 5328 | 5638 | /* Mirroring always horizontal...? */ |
| r5302 | r5303 | |
| 5347 | 5657 | prg8_cd( space, 0x1E ); |
| 5348 | 5658 | prg8_ef( space, 0x1F ); |
| 5349 | 5659 | break; |
| 5660 | case 88: |
| 5661 | prg8_89(space, 0xC); |
| 5662 | prg8_ab(space, 0xD); |
| 5663 | prg8_cd(space, 0xE); |
| 5664 | prg8_ef(space, 0xF); |
| 5665 | break; |
| 5350 | 5666 | case 89: |
| 5351 | 5667 | prg16_89ab(space, 0); |
| 5352 | 5668 | prg16_cdef(space, nes.prg_chunks-1); |
| 5353 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_LOW); |
| 5669 | set_nt_mirroring(PPU_MIRROR_LOW); |
| 5354 | 5670 | break; |
| 5355 | 5671 | |
| 5356 | 5672 | case 91: |
| 5357 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 5673 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 5358 | 5674 | prg16_89ab (space, nes.prg_chunks-1); |
| 5359 | 5675 | prg16_cdef (space, nes.prg_chunks-1); |
| 5360 | 5676 | break; |
| r5302 | r5303 | |
| 5384 | 5700 | prg32(space, 0); |
| 5385 | 5701 | break; |
| 5386 | 5702 | case 154: |
| 5387 | | case 88: |
| 5388 | 5703 | prg16_89ab (space, nes.prg_chunks-2); |
| 5389 | 5704 | prg16_cdef (space, nes.prg_chunks-1); |
| 5390 | 5705 | break; |
| r5302 | r5303 | |
| 5403 | 5718 | break; |
| 5404 | 5719 | case 193: |
| 5405 | 5720 | prg32( space, ( nes.prg_chunks - 1 ) >> 1 ); |
| 5406 | | ppu2c0x_set_mirroring(state->ppu, PPU_MIRROR_VERT); |
| 5721 | set_nt_mirroring(PPU_MIRROR_VERT); |
| 5407 | 5722 | break; |
| 5408 | 5723 | case 200: |
| 5409 | 5724 | prg16_89ab( space, nes.prg_chunks - 1 ); |
| r5302 | r5303 | |
| 5411 | 5726 | break; |
| 5412 | 5727 | case 201: |
| 5413 | 5728 | prg32( space, 0 ); |
| 5414 | | chr8( space->machine, 0 ); |
| 5729 | chr8( space->machine, 0, CHRROM ); |
| 5415 | 5730 | break; |
| 5416 | 5731 | case 202: |
| 5417 | 5732 | case 203: |
| 5418 | 5733 | prg16_89ab( space, 0 ); |
| 5419 | 5734 | prg16_cdef( space, 0 ); |
| 5420 | | chr8( space->machine, 0 ); |
| 5735 | chr8( space->machine, 0, CHRROM ); |
| 5421 | 5736 | break; |
| 5422 | 5737 | case 225: |
| 5423 | 5738 | case 226: |
| r5302 | r5303 | |
| 5549 | 5864 | { 112, "Asper", NULL, NULL, NULL, mapper112_w, NULL, NULL, NULL }, |
| 5550 | 5865 | { 113, "Sachen/Hacker/Nina", mapper113_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 5551 | 5866 | { 118, "MMC3?", NULL, NULL, NULL, mapper118_w, NULL, NULL, mapper4_irq }, |
| 5552 | | // 119 - Pinbot |
| 5867 | { 119, "MMC3 - Pinbot", NULL, NULL, NULL, mapper119_w, NULL, NULL, mapper4_irq }, |
| 5553 | 5868 | { 133, "Sachen", mapper133_l_w, NULL, NULL, NULL, NULL, NULL, NULL }, |
| 5554 | 5869 | { 140, "Jaleco", NULL, NULL, mapper_140_m_w, NULL, NULL, NULL, NULL }, |
| 5555 | 5870 | { 144, "AGCI 50282", NULL, NULL, NULL, mapper144_w, NULL, NULL, NULL }, //Death Race only |