src/mess/machine/nes_pcb.c
| r8377 | r8378 | |
| 429 | 429 | { "SACHEN-8259D", SACHEN_8259D }, |
| 430 | 430 | { "UNL-SACHEN-8259D", SACHEN_8259D }, |
| 431 | 431 | { "UNL-SACHEN-74LS374N", SACHEN_74LS374 }, |
| 432 | | { "UNL-SACHEN-74LS374N-A", SACHEN_74LS374_A },/* FIXME: Made up boards the different mirroring handling */ |
| 432 | { "UNL-SACHEN-74LS374N-A", SACHEN_74LS374_A }, /* FIXME: Made up boards the different mirroring handling */ |
| 433 | 433 | { "UNL-TC-U01-1.5M", SACHEN_TCU01 }, |
| 434 | 434 | { "TENGEN-800032", TENGEN_800032 }, |
| 435 | 435 | { "TENGEN-800037", TENGEN_800037 }, |
| 436 | 436 | { "WAIXING-A", WAIXING_TYPE_A }, |
| 437 | { "WAIXING-A-1", WAIXING_TYPE_A_1 }, /* FIXME: Made up boards the different CHRRAM banks (see Ji Jia Zhan Shi) */ |
| 437 | 438 | { "WAIXING-B", WAIXING_TYPE_B }, |
| 438 | 439 | { "WAIXING-C", WAIXING_TYPE_C }, |
| 439 | 440 | { "WAIXING-D", WAIXING_TYPE_D }, |
| r8377 | r8378 | |
| 441 | 442 | { "WAIXING-F", WAIXING_TYPE_F }, |
| 442 | 443 | { "WAIXING-G", WAIXING_TYPE_G }, |
| 443 | 444 | { "WAIXING-H", WAIXING_TYPE_H }, |
| 445 | { "WAIXING-I", WAIXING_TYPE_I }, |
| 446 | { "WAIXING-J", WAIXING_TYPE_J }, |
| 444 | 447 | { "WAIXING-SGZLZ", WAIXING_SGZLZ }, |
| 445 | 448 | { "WAIXING-SEC", WAIXING_SECURITY }, |
| 446 | 449 | { "WAIXING-SGZ", WAIXING_SGZ }, |
| r8377 | r8378 | |
| 448 | 451 | { "WAIXING-FFV", WAIXING_FFV }, |
| 449 | 452 | { "WAIXING-ZS", WAIXING_ZS }, |
| 450 | 453 | { "WAIXING-DQ8", WAIXING_DQ8 }, |
| 451 | | { "WAIXING-SH2", UNSUPPORTED_BOARD }, |
| 454 | { "WAIXING-SH2", WAIXING_SH2 }, |
| 452 | 455 | // |
| 453 | 456 | { "TXC-TW", TXC_TW }, |
| 454 | 457 | { "TXC-STRIKEWOLF", TXC_STRIKEWOLF }, |
| r8377 | r8378 | |
| 7648 | 7651 | } |
| 7649 | 7652 | } |
| 7650 | 7653 | |
| 7651 | | static void waixing_a_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7654 | /* Luo Ke Ren X only works with this */ |
| 7655 | static void waixing_a_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7652 | 7656 | { |
| 7653 | | nes_state *state = (nes_state *)machine->driver_data; |
| 7654 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7655 | | UINT8 chr_src[6]; |
| 7656 | | int i; |
| 7657 | int chr_src = (bank <= 9) ? CHRRAM : CHRROM; |
| 7658 | chr1_x(machine, start, bank, chr_src); |
| 7659 | } |
| 7657 | 7660 | |
| 7658 | | for (i = 0; i < 6; i++) |
| 7659 | | chr_src[i] = ((state->mmc_vrom_bank[i] == 8) || (state->mmc_vrom_bank[i] == 9)) ? CHRRAM : CHRROM; |
| 7660 | | |
| 7661 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 7662 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 7663 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 7664 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 7665 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 7666 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 7667 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 7668 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7661 | /* Ji Jia Zhan Shi only works with this */ |
| 7662 | static void waixing_a1_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7663 | { |
| 7664 | int chr_src = ((bank == 8) || (bank == 9)) ? CHRRAM : CHRROM; |
| 7665 | chr1_x(machine, start, bank, chr_src); |
| 7669 | 7666 | } |
| 7670 | 7667 | |
| 7671 | 7668 | static WRITE8_HANDLER( waixing_a_w ) |
| 7672 | 7669 | { |
| 7673 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 7674 | | UINT8 MMC3_helper, cmd; |
| 7675 | 7670 | LOG_MMC(("waixing_a_w, offset: %04x, data: %02x\n", offset, data)); |
| 7676 | 7671 | |
| 7677 | 7672 | switch (offset & 0x6001) |
| 7678 | 7673 | { |
| 7679 | | case 0x0000: |
| 7680 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7681 | | state->mmc_latch1 = data; |
| 7682 | | |
| 7683 | | /* Has PRG Mode changed? */ |
| 7684 | | if (MMC3_helper & 0x40) |
| 7685 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7686 | | |
| 7687 | | /* Has CHR Mode changed? */ |
| 7688 | | if (MMC3_helper & 0x80) |
| 7689 | | waixing_a_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7690 | | break; |
| 7691 | | |
| 7692 | | case 0x0001: |
| 7693 | | cmd = state->mmc_latch1 & 0x07; |
| 7694 | | switch (cmd) |
| 7695 | | { |
| 7696 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7697 | | case 2: case 3: case 4: case 5: |
| 7698 | | state->mmc_vrom_bank[cmd] = data; |
| 7699 | | waixing_a_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7700 | | break; |
| 7701 | | case 6: |
| 7702 | | case 7: |
| 7703 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7704 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7705 | | break; |
| 7706 | | } |
| 7707 | | break; |
| 7708 | | |
| 7709 | 7674 | case 0x2000: |
| 7710 | 7675 | waixing_set_mirror(space->machine, data); //maybe data & 0x03? |
| 7711 | 7676 | break; |
| r8377 | r8378 | |
| 7735 | 7700 | |
| 7736 | 7701 | *************************************************************/ |
| 7737 | 7702 | |
| 7738 | | static void waixing_b_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7703 | static void waixing_b_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7739 | 7704 | { |
| 7740 | | nes_state *state = (nes_state *)machine->driver_data; |
| 7741 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7742 | | UINT8 chr_src[6]; |
| 7743 | | int i; |
| 7744 | | |
| 7745 | | for (i = 0; i < 6; i++) |
| 7746 | | chr_src[i] = (state->mmc_vrom_bank[i] & 0x80) ? CHRRAM : CHRROM; |
| 7747 | | |
| 7748 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 7749 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 7750 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 7751 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 7752 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 7753 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 7754 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 7755 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7705 | int chr_src = BIT(bank, 7) ? CHRRAM : CHRROM; |
| 7706 | chr1_x(machine, start, bank, chr_src); |
| 7756 | 7707 | } |
| 7757 | 7708 | |
| 7758 | | static WRITE8_HANDLER( waixing_b_w ) |
| 7759 | | { |
| 7760 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 7761 | | UINT8 MMC3_helper, cmd; |
| 7762 | | LOG_MMC(("waixing_b_w, offset: %04x, data: %02x\n", offset, data)); |
| 7763 | | |
| 7764 | | switch (offset & 0x6001) |
| 7765 | | { |
| 7766 | | case 0x0000: |
| 7767 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7768 | | state->mmc_latch1 = data; |
| 7769 | | |
| 7770 | | /* Has PRG Mode changed? */ |
| 7771 | | if (MMC3_helper & 0x40) |
| 7772 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7773 | | |
| 7774 | | /* Has CHR Mode changed? */ |
| 7775 | | if (MMC3_helper & 0x80) |
| 7776 | | waixing_b_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7777 | | break; |
| 7778 | | |
| 7779 | | case 0x0001: |
| 7780 | | cmd = state->mmc_latch1 & 0x07; |
| 7781 | | switch (cmd) |
| 7782 | | { |
| 7783 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7784 | | case 2: case 3: case 4: case 5: |
| 7785 | | state->mmc_vrom_bank[cmd] = data; |
| 7786 | | waixing_b_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7787 | | break; |
| 7788 | | case 6: |
| 7789 | | case 7: |
| 7790 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7791 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7792 | | break; |
| 7793 | | } |
| 7794 | | break; |
| 7795 | | |
| 7796 | | default: |
| 7797 | | waixing_a_w(space, offset, data); |
| 7798 | | break; |
| 7799 | | } |
| 7800 | | } |
| 7801 | | |
| 7802 | 7709 | /************************************************************* |
| 7803 | 7710 | |
| 7804 | 7711 | Waixing Board Type C |
| r8377 | r8378 | |
| 7815 | 7722 | |
| 7816 | 7723 | *************************************************************/ |
| 7817 | 7724 | |
| 7818 | | static void waixing_c_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7725 | static void waixing_c_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7819 | 7726 | { |
| 7820 | | nes_state *state = (nes_state *)machine->driver_data; |
| 7821 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7822 | | UINT8 chr_src[6]; |
| 7823 | | int i; |
| 7824 | | |
| 7825 | | for (i = 0; i < 6; i++) |
| 7826 | | chr_src[i] = ((state->mmc_vrom_bank[i] == 0x08) || (state->mmc_vrom_bank[i] == 0x09) || (state->mmc_vrom_bank[i] == 0x0a) || (state->mmc_vrom_bank[i] == 0x0b)) ? CHRRAM : CHRROM; |
| 7827 | | |
| 7828 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 7829 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 7830 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 7831 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 7832 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 7833 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 7834 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 7835 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7727 | int chr_src = ((bank == 0x08) || (bank == 0x09) || (bank == 0x0a) || (bank == 0x0b)) ? CHRRAM : CHRROM; |
| 7728 | chr1_x(machine, start, bank, chr_src); |
| 7836 | 7729 | } |
| 7837 | 7730 | |
| 7838 | | static WRITE8_HANDLER( waixing_c_w ) |
| 7839 | | { |
| 7840 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 7841 | | UINT8 MMC3_helper, cmd; |
| 7842 | | LOG_MMC(("waixing_c_w, offset: %04x, data: %02x\n", offset, data)); |
| 7843 | | |
| 7844 | | switch (offset & 0x6001) |
| 7845 | | { |
| 7846 | | case 0x0000: |
| 7847 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7848 | | state->mmc_latch1 = data; |
| 7849 | | |
| 7850 | | /* Has PRG Mode changed? */ |
| 7851 | | if (MMC3_helper & 0x40) |
| 7852 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7853 | | |
| 7854 | | /* Has CHR Mode changed? */ |
| 7855 | | if (MMC3_helper & 0x80) |
| 7856 | | waixing_c_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7857 | | break; |
| 7858 | | |
| 7859 | | case 0x0001: |
| 7860 | | cmd = state->mmc_latch1 & 0x07; |
| 7861 | | switch (cmd) |
| 7862 | | { |
| 7863 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7864 | | case 2: case 3: case 4: case 5: |
| 7865 | | state->mmc_vrom_bank[cmd] = data; |
| 7866 | | waixing_c_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7867 | | break; |
| 7868 | | case 6: |
| 7869 | | case 7: |
| 7870 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7871 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7872 | | break; |
| 7873 | | } |
| 7874 | | break; |
| 7875 | | |
| 7876 | | default: |
| 7877 | | waixing_a_w(space, offset, data); |
| 7878 | | break; |
| 7879 | | } |
| 7880 | | } |
| 7881 | | |
| 7882 | 7731 | /************************************************************* |
| 7883 | 7732 | |
| 7884 | 7733 | Waixing Board Type D |
| r8377 | r8378 | |
| 7895 | 7744 | |
| 7896 | 7745 | *************************************************************/ |
| 7897 | 7746 | |
| 7898 | | static void waixing_d_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7747 | static void waixing_d_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7899 | 7748 | { |
| 7900 | | nes_state *state = (nes_state *)machine->driver_data; |
| 7901 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7902 | | UINT8 chr_src[6]; |
| 7903 | | int i; |
| 7904 | | |
| 7905 | | for (i = 0; i < 6; i++) |
| 7906 | | chr_src[i] = (state->mmc_vrom_bank[i] < 0x02) ? CHRRAM : CHRROM; |
| 7907 | | |
| 7908 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 7909 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 7910 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 7911 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 7912 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 7913 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 7914 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 7915 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7749 | int chr_src = (bank < 0x02) ? CHRRAM : CHRROM; |
| 7750 | chr1_x(machine, start, bank, chr_src); |
| 7916 | 7751 | } |
| 7917 | 7752 | |
| 7918 | | static WRITE8_HANDLER( waixing_d_w ) |
| 7919 | | { |
| 7920 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 7921 | | UINT8 MMC3_helper, cmd; |
| 7922 | | LOG_MMC(("waixing_d_w, offset: %04x, data: %02x\n", offset, data)); |
| 7923 | | |
| 7924 | | switch (offset & 0x6001) |
| 7925 | | { |
| 7926 | | case 0x0000: |
| 7927 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 7928 | | state->mmc_latch1 = data; |
| 7929 | | |
| 7930 | | /* Has PRG Mode changed? */ |
| 7931 | | if (MMC3_helper & 0x40) |
| 7932 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7933 | | |
| 7934 | | /* Has CHR Mode changed? */ |
| 7935 | | if (MMC3_helper & 0x80) |
| 7936 | | waixing_d_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7937 | | break; |
| 7938 | | |
| 7939 | | case 0x0001: |
| 7940 | | cmd = state->mmc_latch1 & 0x07; |
| 7941 | | switch (cmd) |
| 7942 | | { |
| 7943 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 7944 | | case 2: case 3: case 4: case 5: |
| 7945 | | state->mmc_vrom_bank[cmd] = data; |
| 7946 | | waixing_d_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 7947 | | break; |
| 7948 | | case 6: |
| 7949 | | case 7: |
| 7950 | | state->mmc_prg_bank[cmd - 6] = data; |
| 7951 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7952 | | break; |
| 7953 | | } |
| 7954 | | break; |
| 7955 | | |
| 7956 | | default: |
| 7957 | | waixing_a_w(space, offset, data); |
| 7958 | | break; |
| 7959 | | } |
| 7960 | | } |
| 7961 | | |
| 7962 | 7753 | /************************************************************* |
| 7963 | 7754 | |
| 7964 | 7755 | Waixing Board Type E |
| r8377 | r8378 | |
| 7976 | 7767 | |
| 7977 | 7768 | *************************************************************/ |
| 7978 | 7769 | |
| 7979 | | static void waixing_e_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 7770 | static void waixing_e_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7980 | 7771 | { |
| 7981 | | nes_state *state = (nes_state *)machine->driver_data; |
| 7982 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 7983 | | UINT8 chr_src[6]; |
| 7984 | | int i; |
| 7985 | | |
| 7986 | | for (i = 0; i < 6; i++) |
| 7987 | | chr_src[i] = (state->mmc_vrom_bank[i] < 0x04) ? CHRRAM : CHRROM; |
| 7988 | | |
| 7989 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), chr_src[0]); |
| 7990 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), chr_src[0]); |
| 7991 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), chr_src[1]); |
| 7992 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), chr_src[1]); |
| 7993 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 7994 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 7995 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 7996 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7772 | int chr_src = (bank < 0x04) ? CHRRAM : CHRROM; |
| 7773 | chr1_x(machine, start, bank, chr_src); |
| 7997 | 7774 | } |
| 7998 | 7775 | |
| 7999 | | static WRITE8_HANDLER( waixing_e_w ) |
| 8000 | | { |
| 8001 | | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8002 | | UINT8 MMC3_helper, cmd; |
| 8003 | | LOG_MMC(("waixing_e_w, offset: %04x, data: %02x\n", offset, data)); |
| 8004 | | |
| 8005 | | switch (offset & 0x6001) |
| 8006 | | { |
| 8007 | | case 0x0000: |
| 8008 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 8009 | | state->mmc_latch1 = data; |
| 8010 | | |
| 8011 | | /* Has PRG Mode changed? */ |
| 8012 | | if (MMC3_helper & 0x40) |
| 8013 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8014 | | |
| 8015 | | /* Has CHR Mode changed? */ |
| 8016 | | if (MMC3_helper & 0x80) |
| 8017 | | waixing_e_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8018 | | break; |
| 8019 | | |
| 8020 | | case 0x0001: |
| 8021 | | cmd = state->mmc_latch1 & 0x07; |
| 8022 | | switch (cmd) |
| 8023 | | { |
| 8024 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8025 | | case 2: case 3: case 4: case 5: |
| 8026 | | state->mmc_vrom_bank[cmd] = data; |
| 8027 | | waixing_e_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8028 | | break; |
| 8029 | | case 6: |
| 8030 | | case 7: |
| 8031 | | state->mmc_prg_bank[cmd - 6] = data; |
| 8032 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8033 | | break; |
| 8034 | | } |
| 8035 | | break; |
| 8036 | | |
| 8037 | | default: |
| 8038 | | waixing_a_w(space, offset, data); |
| 8039 | | break; |
| 8040 | | } |
| 8041 | | } |
| 8042 | | |
| 8043 | 7776 | /************************************************************* |
| 8044 | 7777 | |
| 8045 | 7778 | Waixing Board Type F |
| r8377 | r8378 | |
| 8054 | 7787 | |
| 8055 | 7788 | *************************************************************/ |
| 8056 | 7789 | |
| 8057 | | static void waixing_f_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 8058 | | { |
| 8059 | | nes_state *state = (nes_state *)machine->driver_data; |
| 8060 | | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 8061 | | |
| 8062 | | prg8_89(machine, prg_base | (state->mmc_prg_bank[0 ^ prg_flip] & prg_mask)); |
| 8063 | | prg8_ab(machine, prg_base | (state->mmc_prg_bank[1] & prg_mask)); |
| 8064 | | prg8_cd(machine, prg_base | (state->mmc_prg_bank[2 ^ prg_flip] & prg_mask)); |
| 8065 | | prg8_ef(machine, prg_base | (state->mmc_prg_bank[3] & prg_mask)); |
| 8066 | | } |
| 8067 | | |
| 8068 | 7790 | static WRITE8_HANDLER( waixing_f_w ) |
| 8069 | 7791 | { |
| 8070 | 7792 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8071 | | UINT8 MMC3_helper, cmd; |
| 7793 | UINT8 cmd; |
| 8072 | 7794 | LOG_MMC(("waixing_f_w, offset: %04x, data: %02x\n", offset, data)); |
| 8073 | 7795 | |
| 8074 | 7796 | switch (offset & 0x6001) |
| 8075 | 7797 | { |
| 8076 | | case 0x0000: |
| 8077 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 8078 | | state->mmc_latch1 = data; |
| 8079 | | |
| 8080 | | /* Has PRG Mode changed? */ |
| 8081 | | if (MMC3_helper & 0x40) |
| 8082 | | waixing_f_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8083 | | |
| 8084 | | /* Has CHR Mode changed? */ |
| 8085 | | if (MMC3_helper & 0x80) |
| 8086 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 8087 | | break; |
| 8088 | | |
| 8089 | 7798 | case 0x0001: |
| 8090 | 7799 | cmd = state->mmc_latch1 & 0x07; |
| 8091 | | switch (cmd) |
| 8092 | | { |
| 8093 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8094 | | case 2: case 3: case 4: case 5: |
| 8095 | | state->mmc_vrom_bank[cmd] = data; |
| 8096 | | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 8097 | | break; |
| 8098 | | case 6: |
| 8099 | | case 7: |
| 7800 | if (cmd >= 6) |
| 7801 | { |
| 8100 | 7802 | state->mmc_prg_bank[cmd - 6] = data & ((data > 0x3f) ? 0x4f : 0x3f); |
| 8101 | | waixing_f_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8102 | | break; |
| 8103 | | } |
| 7803 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 7804 | } |
| 7805 | else |
| 7806 | waixing_a_w(space, offset, data); |
| 8104 | 7807 | break; |
| 8105 | 7808 | |
| 8106 | 7809 | default: |
| r8377 | r8378 | |
| 8124 | 7827 | |
| 8125 | 7828 | *************************************************************/ |
| 8126 | 7829 | |
| 7830 | static void waixing_g_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7831 | { |
| 7832 | int chr_src = (bank < 0x08) ? CHRRAM : CHRROM; |
| 7833 | chr1_x(machine, start, bank, chr_src); |
| 7834 | } |
| 7835 | |
| 8127 | 7836 | static void waixing_g_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8128 | 7837 | { |
| 8129 | 7838 | nes_state *state = (nes_state *)machine->driver_data; |
| 8130 | 7839 | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 8131 | | UINT8 chr_src[8]; |
| 8132 | | int i; |
| 8133 | 7840 | |
| 8134 | | for (i = 0; i < 8; i++) |
| 8135 | | chr_src[i] = (state->mmc_vrom_bank[i] < 0x08) ? CHRRAM : CHRROM; |
| 8136 | | |
| 8137 | | chr1_x(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & chr_mask), chr_src[0]); |
| 8138 | | chr1_x(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[6] & chr_mask), chr_src[6]); |
| 8139 | | chr1_x(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & chr_mask), chr_src[1]); |
| 8140 | | chr1_x(machine, chr_page ^ 3, chr_base | (state->mmc_vrom_bank[7] & chr_mask), chr_src[7]); |
| 8141 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), chr_src[2]); |
| 8142 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), chr_src[3]); |
| 8143 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), chr_src[4]); |
| 8144 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), chr_src[5]); |
| 7841 | state->mmc3_chr_cb(machine, chr_page ^ 0, chr_base | (state->mmc_vrom_bank[0] & chr_mask), state->mmc_chr_source); |
| 7842 | state->mmc3_chr_cb(machine, chr_page ^ 1, chr_base | (state->mmc_vrom_bank[6] & chr_mask), state->mmc_chr_source); |
| 7843 | state->mmc3_chr_cb(machine, chr_page ^ 2, chr_base | (state->mmc_vrom_bank[1] & chr_mask), state->mmc_chr_source); |
| 7844 | state->mmc3_chr_cb(machine, chr_page ^ 3, chr_base | (state->mmc_vrom_bank[7] & chr_mask), state->mmc_chr_source); |
| 7845 | state->mmc3_chr_cb(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), state->mmc_chr_source); |
| 7846 | state->mmc3_chr_cb(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), state->mmc_chr_source); |
| 7847 | state->mmc3_chr_cb(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), state->mmc_chr_source); |
| 7848 | state->mmc3_chr_cb(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), state->mmc_chr_source); |
| 8145 | 7849 | } |
| 8146 | 7850 | |
| 8147 | 7851 | static WRITE8_HANDLER( waixing_g_w ) |
| r8377 | r8378 | |
| 8149 | 7853 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8150 | 7854 | UINT8 MMC3_helper, cmd; |
| 8151 | 7855 | LOG_MMC(("waixing_g_w, offset: %04x, data: %02x\n", offset, data)); |
| 8152 | | |
| 7856 | |
| 8153 | 7857 | switch (offset & 0x6001) |
| 8154 | 7858 | { |
| 8155 | 7859 | case 0x0000: |
| 8156 | 7860 | MMC3_helper = state->mmc_latch1 ^ data; |
| 8157 | 7861 | state->mmc_latch1 = data; |
| 8158 | | |
| 7862 | |
| 8159 | 7863 | /* Has PRG Mode changed? */ |
| 8160 | 7864 | if (MMC3_helper & 0x40) |
| 8161 | 7865 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8162 | | |
| 7866 | |
| 8163 | 7867 | /* Has CHR Mode changed? */ |
| 8164 | 7868 | if (MMC3_helper & 0x80) |
| 8165 | 7869 | waixing_g_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8166 | 7870 | break; |
| 8167 | | |
| 7871 | |
| 8168 | 7872 | case 0x0001: |
| 8169 | 7873 | cmd = state->mmc_latch1 & 0x0f; |
| 8170 | 7874 | switch (cmd) |
| 8171 | | { |
| 7875 | { |
| 8172 | 7876 | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8173 | 7877 | case 2: case 3: case 4: case 5: |
| 8174 | 7878 | state->mmc_vrom_bank[cmd] = data; |
| r8377 | r8378 | |
| 8185 | 7889 | state->mmc_vrom_bank[cmd - 4] = data; |
| 8186 | 7890 | waixing_g_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8187 | 7891 | break; |
| 8188 | | } |
| 7892 | } |
| 8189 | 7893 | break; |
| 8190 | 7894 | |
| 8191 | 7895 | default: |
| 8192 | | txrom_w(space, offset, data); |
| 7896 | waixing_a_w(space, offset, data); |
| 8193 | 7897 | break; |
| 8194 | 7898 | } |
| 8195 | 7899 | } |
| r8377 | r8378 | |
| 8209 | 7913 | |
| 8210 | 7914 | *************************************************************/ |
| 8211 | 7915 | |
| 7916 | static void waixing_h_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 7917 | { |
| 7918 | if (source == CHRROM) |
| 7919 | chr1_x(machine, start, bank, source); |
| 7920 | } |
| 7921 | |
| 8212 | 7922 | static WRITE8_HANDLER( waixing_h_w ) |
| 8213 | 7923 | { |
| 8214 | 7924 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8215 | | UINT8 cmd, map245_helper; |
| 7925 | UINT8 cmd; |
| 8216 | 7926 | LOG_MMC(("waixing_h_w, offset: %04x, data: %02x\n", offset, data)); |
| 8217 | 7927 | |
| 8218 | 7928 | switch (offset & 0x6001) |
| 8219 | 7929 | { |
| 8220 | 7930 | case 0x0001: |
| 8221 | | cmd = state->mmc_latch1 & 0x0f; |
| 7931 | cmd = state->mmc_latch1 & 0x07; |
| 8222 | 7932 | switch (cmd) |
| 8223 | | { |
| 7933 | { |
| 8224 | 7934 | case 0: // in this case we set prg_base in addition to state->mmc_vrom_bank! |
| 8225 | 7935 | state->mmc_prg_base = (data << 5) & 0x40; |
| 8226 | 7936 | state->mmc_prg_mask = 0x3f; |
| 8227 | 7937 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8228 | | case 1: case 2: case 3: case 4: case 5: |
| 8229 | | state->mmc_vrom_bank[cmd] = data; |
| 8230 | | if (state->chr_chunks > 0) |
| 8231 | | mmc3_set_chr(space->machine, CHRROM, state->mmc_chr_base, state->mmc_chr_mask); |
| 8232 | | else // according to Disch's docs, state->mmc_latch1&0x80 swaps 4k CHRRAM banks |
| 8233 | | { |
| 8234 | | map245_helper = /*(state->mmc_latch1 & 0x80) ? 1 : */0; |
| 8235 | | chr4_0(space->machine, 0 ^ map245_helper, CHRRAM); |
| 8236 | | chr4_4(space->machine, 1 ^ map245_helper, CHRRAM); |
| 8237 | | } |
| 7938 | txrom_w(space, offset, data); |
| 7939 | default: |
| 7940 | txrom_w(space, offset, data); |
| 8238 | 7941 | break; |
| 8239 | | case 6: |
| 8240 | | case 7: |
| 8241 | | state->mmc_prg_bank[cmd - 6] = data; |
| 8242 | | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8243 | | break; |
| 8244 | | } |
| 7942 | } |
| 8245 | 7943 | break; |
| 8246 | 7944 | |
| 8247 | 7945 | case 0x2001: |
| r8377 | r8378 | |
| 8295 | 7993 | break; |
| 8296 | 7994 | case 0x7000: |
| 8297 | 7995 | switch (offset & 0x0c) |
| 8298 | | { |
| 7996 | { |
| 8299 | 7997 | case 0x00: |
| 8300 | 7998 | state->IRQ_count_latch = (state->IRQ_count_latch & 0xf0) | (data & 0x0f); |
| 8301 | 7999 | break; |
| r8377 | r8378 | |
| 8311 | 8009 | case 0x0c: |
| 8312 | 8010 | state->IRQ_enable = state->IRQ_enable_latch; |
| 8313 | 8011 | break; |
| 8314 | | } |
| 8012 | } |
| 8315 | 8013 | break; |
| 8316 | 8014 | } |
| 8317 | 8015 | } |
| r8377 | r8378 | |
| 8338 | 8036 | switch (offset) |
| 8339 | 8037 | { |
| 8340 | 8038 | case 0x700: |
| 8341 | | set_nt_mirroring(space->machine, BIT(data, 0) ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8039 | set_nt_mirroring(space->machine, data ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8342 | 8040 | break; |
| 8343 | 8041 | case 0x701: |
| 8344 | 8042 | state->mmc_latch1 = (state->mmc_latch1 & 0x0c) | ((data >> 1) & 0x03); |
| r8377 | r8378 | |
| 8365 | 8063 | |
| 8366 | 8064 | static WRITE8_HANDLER( waixing_ffv_l_w ) |
| 8367 | 8065 | { |
| 8066 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8067 | UINT8 mmc_helper; |
| 8368 | 8068 | LOG_MMC(("waixing_ffv_l_w, offset: %04x, data: %02x\n", offset, data)); |
| 8369 | | offset += 0x4100; /* the checks work better on addresses */ |
| 8069 | offset += 0x100; /* the checks work better on addresses */ |
| 8370 | 8070 | |
| 8371 | | if (0x5000 == (offset & 0x7300)) |
| 8372 | | prg32(space->machine, data); |
| 8071 | if (0x1000 == (offset & 0x1200)) |
| 8072 | { |
| 8073 | state->mmc_reg[BIT(offset, 8)] = data; |
| 8074 | mmc_helper = BIT(state->mmc_reg[1], 0) << 5; |
| 8075 | switch (state->mmc_reg[0] & 0x70) |
| 8076 | { |
| 8077 | case 0x00: |
| 8078 | case 0x20: |
| 8079 | case 0x40: |
| 8080 | case 0x60: |
| 8081 | prg16_89ab(space->machine, mmc_helper | ((state->mmc_reg[0] >> 1) & 0x10) | (state->mmc_reg[0] & 0x0f)); |
| 8082 | prg16_cdef(space->machine, mmc_helper & 0x1f); |
| 8083 | break; |
| 8084 | case 0x50: |
| 8085 | prg32(space->machine, (mmc_helper >> 1) | (state->mmc_reg[0] & 0x0f)); |
| 8086 | break; |
| 8087 | case 0x70: |
| 8088 | prg16_89ab(space->machine, mmc_helper | ((state->mmc_reg[0] << 1) & 0x10) | (state->mmc_reg[0] & 0x0f)); |
| 8089 | prg16_cdef(space->machine, mmc_helper & 0x1f); |
| 8090 | break; |
| 8091 | } |
| 8092 | } |
| 8373 | 8093 | } |
| 8374 | 8094 | |
| 8375 | | static WRITE8_HANDLER( waixing_ffv_w ) |
| 8376 | | { |
| 8377 | | LOG_MMC(("waixing_ffv_w, offset: %04x, data: %02x\n", offset, data)); |
| 8378 | | if ((offset & 0x7300) == 0x5000) |
| 8379 | | prg32(space->machine, data); |
| 8380 | | } |
| 8381 | | |
| 8382 | 8095 | /************************************************************* |
| 8383 | 8096 | |
| 8384 | 8097 | Waixing Zhan Shi Board |
| r8377 | r8378 | |
| 8504 | 8217 | |
| 8505 | 8218 | *************************************************************/ |
| 8506 | 8219 | |
| 8507 | | static void waixing_sec_set_prg( running_machine *machine, int prg_base, int prg_mask ) |
| 8220 | static void waixing_sec_prg_cb( running_machine *machine, int start, int bank ) |
| 8508 | 8221 | { |
| 8509 | 8222 | nes_state *state = (nes_state *)machine->driver_data; |
| 8510 | | int i; |
| 8223 | |
| 8224 | if (state->mmc_reg[0]) |
| 8225 | bank = ((bank & 0x01)) | ((bank >> 3) & 0x02) | ((bank >> 1) & 0x04) | ((bank << 2) & 0x18); |
| 8511 | 8226 | |
| 8512 | | if (state->map249_reg) |
| 8513 | | { |
| 8514 | | for (i = 0; i < 4; i ++) // should this apply only to bank[0],bank[1]? |
| 8515 | | { |
| 8516 | | state->mmc_prg_bank[i] = ((state->mmc_prg_bank[i] & 0x01)) | ((state->mmc_prg_bank[i] >> 3) & 0x02) | |
| 8517 | | ((state->mmc_prg_bank[i] >> 1) & 0x04) | ((state->mmc_prg_bank[i] << 2) & 0x18); |
| 8518 | | } |
| 8519 | | } |
| 8520 | | |
| 8521 | | mmc3_set_prg(machine, prg_base, prg_mask); |
| 8227 | prg8_x(machine, start, bank); |
| 8522 | 8228 | } |
| 8523 | 8229 | |
| 8524 | | static void waixing_sec_set_chr( running_machine *machine, int chr_base, int chr_mask ) |
| 8230 | static void waixing_sec_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8525 | 8231 | { |
| 8526 | 8232 | nes_state *state = (nes_state *)machine->driver_data; |
| 8527 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 8528 | | int i; |
| 8529 | 8233 | |
| 8530 | | if (state->map249_reg) |
| 8531 | | { |
| 8532 | | for (i = 0; i < 6; i ++) |
| 8533 | | { |
| 8534 | | state->mmc_vrom_bank[i] = ((state->mmc_vrom_bank[i] & 0x03)) | ((state->mmc_vrom_bank[i] >> 1) & 0x04) | |
| 8535 | | ((state->mmc_vrom_bank[i] >> 4) & 0x08) | ((state->mmc_vrom_bank[i] >> 2) & 0x10) | |
| 8536 | | ((state->mmc_vrom_bank[i] << 3) & 0x20) | ((state->mmc_vrom_bank[i] << 2) & 0xc0); |
| 8537 | | } |
| 8538 | | } |
| 8539 | | |
| 8540 | | chr1_x(machine, chr_page ^ 0, chr_base | ((state->mmc_vrom_bank[0] & ~0x01) & chr_mask), state->mmc_chr_source); |
| 8541 | | chr1_x(machine, chr_page ^ 1, chr_base | ((state->mmc_vrom_bank[0] | 0x01) & chr_mask), state->mmc_chr_source); |
| 8542 | | chr1_x(machine, chr_page ^ 2, chr_base | ((state->mmc_vrom_bank[1] & ~0x01) & chr_mask), state->mmc_chr_source); |
| 8543 | | chr1_x(machine, chr_page ^ 3, chr_base | ((state->mmc_vrom_bank[1] | 0x01) & chr_mask), state->mmc_chr_source); |
| 8544 | | chr1_x(machine, chr_page ^ 4, chr_base | (state->mmc_vrom_bank[2] & chr_mask), state->mmc_chr_source); |
| 8545 | | chr1_x(machine, chr_page ^ 5, chr_base | (state->mmc_vrom_bank[3] & chr_mask), state->mmc_chr_source); |
| 8546 | | chr1_x(machine, chr_page ^ 6, chr_base | (state->mmc_vrom_bank[4] & chr_mask), state->mmc_chr_source); |
| 8547 | | chr1_x(machine, chr_page ^ 7, chr_base | (state->mmc_vrom_bank[5] & chr_mask), state->mmc_chr_source); |
| 8234 | if (state->mmc_reg[0]) |
| 8235 | bank = ((bank & 0x03)) | ((bank >> 1) & 0x04) | ((bank >> 4) & 0x08) | |
| 8236 | ((bank >> 2) & 0x10) | ((bank << 3) & 0x20) | ((bank << 2) & 0xc0); |
| 8237 | |
| 8238 | chr1_x(machine, start, bank, source); |
| 8548 | 8239 | } |
| 8549 | 8240 | |
| 8550 | 8241 | static WRITE8_HANDLER( waixing_sec_l_w ) |
| r8377 | r8378 | |
| 8556 | 8247 | |
| 8557 | 8248 | if (offset == 0x1000) |
| 8558 | 8249 | { |
| 8559 | | state->map249_reg = data & 0x02; |
| 8560 | | waixing_sec_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8561 | | waixing_sec_set_chr(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8250 | state->mmc_reg[0] = data & 0x02; |
| 8251 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8252 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 8562 | 8253 | } |
| 8563 | 8254 | } |
| 8564 | 8255 | |
| 8565 | | static WRITE8_HANDLER( waixing_sec_w ) |
| 8256 | /************************************************************* |
| 8257 | |
| 8258 | Waixing SH2 Board |
| 8259 | |
| 8260 | Games: Fire Emblem (C) and Fire Emblem Gaiden (C) |
| 8261 | |
| 8262 | MMC3 clone with different access to CHR |
| 8263 | |
| 8264 | iNES: mapper 165 |
| 8265 | |
| 8266 | In MESS: Partially Supported. |
| 8267 | |
| 8268 | *************************************************************/ |
| 8269 | |
| 8270 | static void waixing_sh2_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8566 | 8271 | { |
| 8272 | nes_state *state = (nes_state *)machine->driver_data; |
| 8273 | |
| 8274 | chr4_0(machine, state->mmc_reg[0], state->mmc_reg[0] ? CHRRAM : CHRROM); |
| 8275 | chr4_4(machine, state->mmc_reg[1], state->mmc_reg[1] ? CHRRAM : CHRROM); |
| 8276 | } |
| 8277 | |
| 8278 | READ8_HANDLER( waixing_sh2_chr_r ) |
| 8279 | { |
| 8567 | 8280 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8568 | | UINT8 MMC3_helper, cmd; |
| 8569 | | LOG_MMC(("waixing_sec_w, offset: %04x, data: %02x\n", offset, data)); |
| 8281 | int bank = offset >> 10; |
| 8282 | UINT8 val = state->chr_map[bank].access[offset & 0x3ff]; // this would be usual return value |
| 8283 | int chr_helper; |
| 8570 | 8284 | |
| 8571 | | switch (offset & 0x6001) |
| 8285 | switch (offset & 0xff8) |
| 8572 | 8286 | { |
| 8573 | | case 0x0000: |
| 8574 | | MMC3_helper = state->mmc_latch1 ^ data; |
| 8575 | | state->mmc_latch1 = data; |
| 8576 | | |
| 8577 | | /* Has PRG Mode changed? */ |
| 8578 | | if (MMC3_helper & 0x40) |
| 8579 | | waixing_sec_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8580 | | |
| 8581 | | /* Has CHR Mode changed? */ |
| 8582 | | if (MMC3_helper & 0x80) |
| 8583 | | waixing_sec_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8584 | | break; |
| 8585 | | |
| 8586 | | case 0x0001: |
| 8587 | | cmd = state->mmc_latch1 & 0x07; |
| 8588 | | switch (cmd) |
| 8589 | | { |
| 8590 | | case 0: case 1: // these do not need to be separated: we take care of them in set_chr! |
| 8591 | | case 2: case 3: case 4: case 5: |
| 8592 | | state->mmc_vrom_bank[cmd] = data; |
| 8593 | | waixing_sec_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask); |
| 8594 | | break; |
| 8595 | | case 6: |
| 8596 | | case 7: |
| 8597 | | state->mmc_prg_bank[cmd - 6] = data; |
| 8598 | | waixing_sec_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8599 | | break; |
| 8600 | | } |
| 8601 | | break; |
| 8602 | | |
| 8603 | | default: |
| 8604 | | txrom_w(space, offset, data); |
| 8605 | | break; |
| 8287 | case 0xfd0: chr_helper = (bank & 0x4) | 0x0; break; |
| 8288 | case 0xfe8: chr_helper = (bank & 0x4) | 0x2; break; |
| 8289 | default: return val; |
| 8606 | 8290 | } |
| 8291 | |
| 8292 | state->mmc_reg[offset >> 12] = chr_helper; |
| 8293 | if (offset & 0x1000) |
| 8294 | chr4_4(space->machine, state->mmc_reg[1], state->mmc_reg[1] ? CHRRAM : CHRROM); |
| 8295 | else |
| 8296 | chr4_0(space->machine, state->mmc_reg[0], state->mmc_reg[0] ? CHRRAM : CHRROM); |
| 8297 | |
| 8298 | return val; |
| 8607 | 8299 | } |
| 8608 | 8300 | |
| 8609 | 8301 | /************************************************************* |
| 8610 | 8302 | |
| 8611 | 8303 | Board UNL-8237 |
| 8612 | 8304 | |
| 8613 | | Games: Pochahontas 2 |
| 8305 | Games: Pocahontas 2 |
| 8614 | 8306 | |
| 8615 | 8307 | MMC3 clone |
| 8616 | 8308 | |
| 8617 | | In MESS: Not working |
| 8309 | In MESS: Supported |
| 8618 | 8310 | |
| 8619 | 8311 | *************************************************************/ |
| 8620 | 8312 | |
| 8621 | | static void unl_8237_set_prg( running_machine *machine ) |
| 8313 | static void unl_8237_prg_cb( running_machine *machine, int start, int bank ) |
| 8622 | 8314 | { |
| 8623 | 8315 | nes_state *state = (nes_state *)machine->driver_data; |
| 8624 | | UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0; |
| 8625 | | |
| 8316 | |
| 8626 | 8317 | if (!(state->unl_8237_reg[0] & 0x80)) |
| 8627 | | { |
| 8628 | | prg8_89(machine, state->mmc_prg_bank[0 ^ prg_flip]); |
| 8629 | | prg8_ab(machine, state->mmc_prg_bank[1]); |
| 8630 | | prg8_cd(machine, state->mmc_prg_bank[2 ^ prg_flip]); |
| 8631 | | prg8_ef(machine, state->mmc_prg_bank[3]); |
| 8632 | | } |
| 8318 | prg8_x(machine, start, bank); |
| 8633 | 8319 | } |
| 8634 | 8320 | |
| 8635 | | static void unl_8237_set_chr( running_machine *machine ) |
| 8321 | static void unl_8237_chr_cb( running_machine *machine, int start, int bank, int source ) |
| 8636 | 8322 | { |
| 8637 | 8323 | nes_state *state = (nes_state *)machine->driver_data; |
| 8638 | | UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5; |
| 8639 | | UINT8 bank[8]; |
| 8640 | | int i; |
| 8324 | bank |= ((state->unl_8237_reg[1] << 6) & 0x100); |
| 8641 | 8325 | |
| 8642 | | for(i = 0; i < 6; i++) |
| 8643 | | bank[i] = state->mmc_vrom_bank[i] | ((state->unl_8237_reg[1] << 6) & 0x100); |
| 8644 | | |
| 8645 | | chr1_x(machine, chr_page ^ 0, (bank[0] & ~0x01), CHRROM); |
| 8646 | | chr1_x(machine, chr_page ^ 1, (bank[0] | 0x01), CHRROM); |
| 8647 | | chr1_x(machine, chr_page ^ 2, (bank[1] & ~0x01), CHRROM); |
| 8648 | | chr1_x(machine, chr_page ^ 3, (bank[1] | 0x01), CHRROM); |
| 8649 | | chr1_x(machine, chr_page ^ 4, bank[2], CHRROM); |
| 8650 | | chr1_x(machine, chr_page ^ 5, bank[3], CHRROM); |
| 8651 | | chr1_x(machine, chr_page ^ 6, bank[4], CHRROM); |
| 8652 | | chr1_x(machine, chr_page ^ 7, bank[5], CHRROM); |
| 8326 | chr1_x(machine, start, bank, source); |
| 8653 | 8327 | } |
| 8654 | 8328 | |
| 8655 | 8329 | static WRITE8_HANDLER( unl_8237_l_w ) |
| r8377 | r8378 | |
| 8672 | 8346 | } |
| 8673 | 8347 | } |
| 8674 | 8348 | else |
| 8675 | | unl_8237_set_prg(space->machine); |
| 8349 | mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask); |
| 8676 | 8350 | } |
| 8677 | 8351 | |
| 8678 | 8352 | if (offset == 0x1001) |
| 8679 | 8353 | { |
| 8680 | 8354 | state->unl_8237_reg[1] = data; |
| 8681 | | unl_8237_set_chr(space->machine); |
| 8355 | mmc3_set_chr(space->machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask); |
| 8682 | 8356 | } |
| 8683 | 8357 | } |
| 8684 | 8358 | |
| 8685 | 8359 | static WRITE8_HANDLER( unl_8237_w ) |
| 8686 | 8360 | { |
| 8687 | 8361 | nes_state *state = (nes_state *)space->machine->driver_data; |
| 8688 | | UINT8 unl_8237_helper, cmd; |
| 8689 | 8362 | static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5}; |
| 8690 | 8363 | LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data)); |
| 8691 | 8364 | |
| 8692 | 8365 | switch (offset & 0x7000) |
| 8693 | 8366 | { |
| 8367 | case 0x0000: |
| 8368 | case 0x1000: |
| 8369 | set_nt_mirroring(space->machine, (data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8370 | break; |
| 8371 | |
| 8694 | 8372 | case 0x2000: |
| 8695 | 8373 | case 0x3000: |
| 8696 | 8374 | state->unl_8237_reg[2] = 1; |
| 8697 | 8375 | data = (data & 0xc0) | conv_table[data & 0x07]; |
| 8698 | | unl_8237_helper = state->mmc_latch1 ^ data; |
| 8699 | | state->mmc_latch1 = data; |
| 8700 | | |
| 8701 | | /* Has PRG Mode changed? */ |
| 8702 | | if (unl_8237_helper & 0x40) |
| 8703 | | unl_8237_set_prg(space->machine); |
| 8704 | | |
| 8705 | | /* Has CHR Mode changed? */ |
| 8706 | | if (unl_8237_helper & 0x80) |
| 8707 | | unl_8237_set_chr(space->machine); |
| 8376 | txrom_w(space, 0x8000, data); |
| 8708 | 8377 | break; |
| 8709 | 8378 | |
| 8710 | 8379 | case 0x4000: |
| r8377 | r8378 | |
| 8712 | 8381 | if (state->unl_8237_reg[2]) |
| 8713 | 8382 | { |
| 8714 | 8383 | state->unl_8237_reg[2] = 0; |
| 8715 | | cmd = state->mmc_latch1 & 0x07; |
| 8716 | | switch (cmd) |
| 8717 | | { |
| 8718 | | case 0: case 1: |
| 8719 | | case 2: case 3: case 4: case 5: |
| 8720 | | state->mmc_vrom_bank[cmd] = data; |
| 8721 | | unl_8237_set_chr(space->machine); |
| 8722 | | break; |
| 8723 | | case 6: |
| 8724 | | case 7: |
| 8725 | | state->mmc_prg_bank[cmd - 6] = data; |
| 8726 | | unl_8237_set_prg(space->machine); |
| 8727 | | break; |
| 8728 | | } |
| 8384 | txrom_w(space, 0x8001, data); |
| 8729 | 8385 | } |
| 8730 | 8386 | break; |
| 8731 | 8387 | |
| 8732 | | case 0x0000: |
| 8733 | | case 0x1000: |
| 8734 | | set_nt_mirroring(space->machine, (data | (data >> 7)) & 0x01 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 8735 | | break; |
| 8736 | | |
| 8737 | 8388 | case 0x6000: |
| 8738 | 8389 | break; |
| 8739 | 8390 | |
| r8377 | r8378 | |
| 11982 | 11633 | { TXC_STRIKEWOLF, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w), NULL, NULL, NULL }, |
| 11983 | 11634 | { TXC_MXMDHTWO, NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL }, |
| 11984 | 11635 | { WAIXING_TYPE_A, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11985 | | { WAIXING_TYPE_B, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_b_w), NULL, NULL, mmc3_irq }, |
| 11986 | | { WAIXING_TYPE_C, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_c_w), NULL, NULL, mmc3_irq }, |
| 11987 | | { WAIXING_TYPE_D, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_d_w), NULL, NULL, mmc3_irq }, |
| 11988 | | { WAIXING_TYPE_E, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_e_w), NULL, NULL, mmc3_irq }, |
| 11636 | { WAIXING_TYPE_A_1, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11637 | { WAIXING_TYPE_B, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11638 | { WAIXING_TYPE_C, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11639 | { WAIXING_TYPE_D, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11640 | { WAIXING_TYPE_E, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_a_w), NULL, NULL, mmc3_irq }, |
| 11989 | 11641 | { WAIXING_TYPE_F, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_f_w), NULL, NULL, mmc3_irq }, |
| 11990 | 11642 | { WAIXING_TYPE_G, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_g_w), NULL, NULL, mmc3_irq }, |
| 11991 | 11643 | { WAIXING_TYPE_H, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_h_w), NULL, NULL, mmc3_irq }, |
| 11644 | { WAIXING_TYPE_I, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff |
| 11645 | { WAIXING_TYPE_J, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff |
| 11992 | 11646 | { WAIXING_SGZ, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_sgz_w), NULL, NULL, konami_irq }, |
| 11993 | 11647 | { WAIXING_SGZLZ, NES_WRITEONLY(waixing_sgzlz_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 11994 | | { WAIXING_FFV, NES_WRITEONLY(waixing_ffv_l_w), NES_NOACCESS, NES_WRITEONLY(waixing_ffv_w), NULL, NULL, NULL }, |
| 11648 | { WAIXING_FFV, NES_WRITEONLY(waixing_ffv_l_w), NES_NOACCESS, NES_NOACCESS, NULL, NULL, NULL }, |
| 11995 | 11649 | { WAIXING_ZS, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_zs_w), NULL, NULL, NULL }, |
| 11996 | 11650 | { WAIXING_DQ8, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_dq8_w), NULL, NULL, NULL }, |
| 11997 | | { WAIXING_SECURITY, NES_WRITEONLY(waixing_sec_l_w), NES_NOACCESS, NES_WRITEONLY(waixing_sec_w), NULL, NULL, mmc3_irq }, |
| 11651 | { WAIXING_SECURITY, NES_WRITEONLY(waixing_sec_l_w), NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, |
| 11652 | { WAIXING_SH2, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txrom_w), NULL, NULL, mmc3_irq }, // this is MMC3 + possibly additional WRAM added in 0x5000-0x5fff |
| 11998 | 11653 | { WAIXING_PS2, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_ps2_w), NULL, NULL, NULL }, |
| 11999 | 11654 | { UNL_8237, NES_WRITEONLY(unl_8237_l_w), NES_NOACCESS, NES_WRITEONLY(unl_8237_w), NULL, NULL, mmc3_irq }, |
| 12000 | 11655 | { UNL_AX5705, NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_ax5705_w), NULL, NULL, NULL }, |
| r8377 | r8378 | |
| 12168 | 11823 | |
| 12169 | 11824 | switch (state->pcb_id) |
| 12170 | 11825 | { |
| 11826 | case WAIXING_TYPE_A: |
| 11827 | state->mmc3_chr_cb = waixing_a_chr_cb; |
| 11828 | break; |
| 11829 | case WAIXING_TYPE_A_1: |
| 11830 | state->mmc3_chr_cb = waixing_a1_chr_cb; |
| 11831 | break; |
| 11832 | case WAIXING_TYPE_B: |
| 11833 | state->mmc3_chr_cb = waixing_b_chr_cb; |
| 11834 | break; |
| 11835 | case WAIXING_TYPE_C: |
| 11836 | state->mmc3_chr_cb = waixing_c_chr_cb; |
| 11837 | break; |
| 11838 | case WAIXING_TYPE_D: |
| 11839 | state->mmc3_chr_cb = waixing_d_chr_cb; |
| 11840 | break; |
| 11841 | case WAIXING_TYPE_E: |
| 11842 | state->mmc3_chr_cb = waixing_e_chr_cb; |
| 11843 | break; |
| 11844 | case WAIXING_TYPE_G: |
| 11845 | state->mmc3_chr_cb = waixing_g_chr_cb; |
| 11846 | break; |
| 11847 | case WAIXING_TYPE_H: |
| 11848 | state->mmc3_chr_cb = waixing_h_chr_cb; |
| 11849 | break; |
| 11850 | case WAIXING_SECURITY: |
| 11851 | state->mmc3_prg_cb = waixing_sec_prg_cb; |
| 11852 | state->mmc3_chr_cb = waixing_sec_chr_cb; |
| 11853 | break; |
| 11854 | case WAIXING_SH2: |
| 11855 | state->mmc3_chr_cb = waixing_sh2_chr_cb; |
| 11856 | break; |
| 11857 | case UNL_8237: |
| 11858 | state->mmc3_prg_cb = unl_8237_prg_cb; |
| 11859 | state->mmc3_chr_cb = unl_8237_chr_cb; |
| 11860 | break; |
| 12171 | 11861 | case SUPERGAME_BOOGERMAN: |
| 12172 | 11862 | state->mmc3_prg_cb = sgame_boog_prg_cb; |
| 12173 | 11863 | state->mmc3_chr_cb = sgame_boog_chr_cb; |