Previous 15994 Revisions Next

r8378 Friday 2nd July, 2010 at 13:49:02 UTC by Fabio Priuli
[NES] simplified, improved and added more MMC3 clone boards
[src/mess/machine]nes.c nes_ines.c nes_mmc.h nes_pcb.c nes_unif.c

src/mess/machine/nes_pcb.c
r8377r8378
429429   { "SACHEN-8259D",     SACHEN_8259D },
430430   { "UNL-SACHEN-8259D", SACHEN_8259D },
431431   { "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 */
433433   { "UNL-TC-U01-1.5M",  SACHEN_TCU01 },
434434   { "TENGEN-800032",    TENGEN_800032 },
435435   { "TENGEN-800037",    TENGEN_800037 },
436436   { "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) */
437438   { "WAIXING-B",        WAIXING_TYPE_B },
438439   { "WAIXING-C",        WAIXING_TYPE_C },
439440   { "WAIXING-D",        WAIXING_TYPE_D },
r8377r8378
441442   { "WAIXING-F",        WAIXING_TYPE_F },
442443   { "WAIXING-G",        WAIXING_TYPE_G },
443444   { "WAIXING-H",        WAIXING_TYPE_H },
445   { "WAIXING-I",        WAIXING_TYPE_I },
446   { "WAIXING-J",        WAIXING_TYPE_J },
444447   { "WAIXING-SGZLZ",    WAIXING_SGZLZ },
445448   { "WAIXING-SEC",      WAIXING_SECURITY },
446449   { "WAIXING-SGZ",      WAIXING_SGZ },
r8377r8378
448451   { "WAIXING-FFV",      WAIXING_FFV },
449452   { "WAIXING-ZS",       WAIXING_ZS },
450453   { "WAIXING-DQ8",      WAIXING_DQ8 },
451   { "WAIXING-SH2",      UNSUPPORTED_BOARD },
454   { "WAIXING-SH2",      WAIXING_SH2 },
452455//
453456   { "TXC-TW",           TXC_TW },
454457   { "TXC-STRIKEWOLF",   TXC_STRIKEWOLF },
r8377r8378
76487651   }
76497652}
76507653
7651static void waixing_a_set_chr( running_machine *machine, int chr_base, int chr_mask )
7654/* Luo Ke Ren X only works with this */
7655static void waixing_a_chr_cb( running_machine *machine, int start, int bank, int source )
76527656{
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}
76577660
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 */
7662static 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);
76697666}
76707667
76717668static WRITE8_HANDLER( waixing_a_w )
76727669{
7673   nes_state *state = (nes_state *)space->machine->driver_data;
7674   UINT8 MMC3_helper, cmd;
76757670   LOG_MMC(("waixing_a_w, offset: %04x, data: %02x\n", offset, data));
76767671
76777672   switch (offset & 0x6001)
76787673   {
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
77097674      case 0x2000:
77107675         waixing_set_mirror(space->machine, data);   //maybe data & 0x03?
77117676         break;
r8377r8378
77357700
77367701 *************************************************************/
77377702
7738static void waixing_b_set_chr( running_machine *machine, int chr_base, int chr_mask )
7703static void waixing_b_chr_cb( running_machine *machine, int start, int bank, int source )
77397704{
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);
77567707}
77577708
7758static 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
78027709/*************************************************************
78037710
78047711 Waixing Board Type C
r8377r8378
78157722
78167723 *************************************************************/
78177724
7818static void waixing_c_set_chr( running_machine *machine, int chr_base, int chr_mask )
7725static void waixing_c_chr_cb( running_machine *machine, int start, int bank, int source )
78197726{
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);
78367729}
78377730
7838static 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
78827731/*************************************************************
78837732
78847733 Waixing Board Type D
r8377r8378
78957744
78967745 *************************************************************/
78977746
7898static void waixing_d_set_chr( running_machine *machine, int chr_base, int chr_mask )
7747static void waixing_d_chr_cb( running_machine *machine, int start, int bank, int source )
78997748{
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);
79167751}
79177752
7918static 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
79627753/*************************************************************
79637754
79647755 Waixing Board Type E
r8377r8378
79767767
79777768 *************************************************************/
79787769
7979static void waixing_e_set_chr( running_machine *machine, int chr_base, int chr_mask )
7770static void waixing_e_chr_cb( running_machine *machine, int start, int bank, int source )
79807771{
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);
79977774}
79987775
7999static 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
80437776/*************************************************************
80447777
80457778 Waixing Board Type F
r8377r8378
80547787
80557788 *************************************************************/
80567789
8057static 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
80687790static WRITE8_HANDLER( waixing_f_w )
80697791{
80707792   nes_state *state = (nes_state *)space->machine->driver_data;
8071   UINT8 MMC3_helper, cmd;
7793   UINT8 cmd;
80727794   LOG_MMC(("waixing_f_w, offset: %04x, data: %02x\n", offset, data));
80737795
80747796   switch (offset & 0x6001)
80757797   {
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
80897798      case 0x0001:
80907799         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         {
81007802            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);
81047807         break;
81057808
81067809      default:
r8377r8378
81247827
81257828 *************************************************************/
81267829
7830static 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
81277836static void waixing_g_set_chr( running_machine *machine, int chr_base, int chr_mask )
81287837{
81297838   nes_state *state = (nes_state *)machine->driver_data;
81307839   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
8131   UINT8 chr_src[8];
8132   int i;
81337840
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);
81457849}
81467850
81477851static WRITE8_HANDLER( waixing_g_w )
r8377r8378
81497853   nes_state *state = (nes_state *)space->machine->driver_data;
81507854   UINT8 MMC3_helper, cmd;
81517855   LOG_MMC(("waixing_g_w, offset: %04x, data: %02x\n", offset, data));
8152
7856   
81537857   switch (offset & 0x6001)
81547858   {
81557859      case 0x0000:
81567860         MMC3_helper = state->mmc_latch1 ^ data;
81577861         state->mmc_latch1 = data;
8158
7862         
81597863         /* Has PRG Mode changed? */
81607864         if (MMC3_helper & 0x40)
81617865            mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
8162
7866         
81637867         /* Has CHR Mode changed? */
81647868         if (MMC3_helper & 0x80)
81657869            waixing_g_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
81667870         break;
8167
7871         
81687872      case 0x0001:
81697873         cmd = state->mmc_latch1 & 0x0f;
81707874         switch (cmd)
8171      {
7875         {
81727876         case 0: case 1:   // these do not need to be separated: we take care of them in set_chr!
81737877         case 2: case 3: case 4: case 5:
81747878            state->mmc_vrom_bank[cmd] = data;
r8377r8378
81857889            state->mmc_vrom_bank[cmd - 4] = data;
81867890            waixing_g_set_chr(space->machine, state->mmc_chr_base, state->mmc_chr_mask);
81877891            break;
8188      }
7892         }
81897893         break;
81907894
81917895      default:
8192         txrom_w(space, offset, data);
7896         waixing_a_w(space, offset, data);
81937897         break;
81947898   }
81957899}
r8377r8378
82097913
82107914 *************************************************************/
82117915
7916static 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
82127922static WRITE8_HANDLER( waixing_h_w )
82137923{
82147924   nes_state *state = (nes_state *)space->machine->driver_data;
8215   UINT8 cmd, map245_helper;
7925   UINT8 cmd;
82167926   LOG_MMC(("waixing_h_w, offset: %04x, data: %02x\n", offset, data));
82177927
82187928   switch (offset & 0x6001)
82197929   {
82207930      case 0x0001:
8221         cmd = state->mmc_latch1 & 0x0f;
7931         cmd = state->mmc_latch1 & 0x07;
82227932         switch (cmd)
8223      {
7933         {
82247934         case 0:    // in this case we set prg_base in addition to state->mmc_vrom_bank!
82257935            state->mmc_prg_base = (data << 5) & 0x40;
82267936            state->mmc_prg_mask = 0x3f;
82277937            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);
82387941            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         }
82457943         break;
82467944
82477945      case 0x2001:
r8377r8378
82957993         break;
82967994      case 0x7000:
82977995         switch (offset & 0x0c)
8298      {
7996         {
82997997         case 0x00:
83007998            state->IRQ_count_latch = (state->IRQ_count_latch & 0xf0) | (data & 0x0f);
83017999            break;
r8377r8378
83118009         case 0x0c:
83128010            state->IRQ_enable = state->IRQ_enable_latch;
83138011            break;
8314      }
8012         }
83158013         break;
83168014   }
83178015}
r8377r8378
83388036   switch (offset)
83398037   {
83408038      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);
83428040         break;
83438041      case 0x701:
83448042         state->mmc_latch1 = (state->mmc_latch1 & 0x0c) | ((data >> 1) & 0x03);
r8377r8378
83658063
83668064static WRITE8_HANDLER( waixing_ffv_l_w )
83678065{
8066   nes_state *state = (nes_state *)space->machine->driver_data;
8067   UINT8 mmc_helper;
83688068   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 */
83708070
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   }
83738093}
83748094
8375static 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
83828095/*************************************************************
83838096
83848097 Waixing Zhan Shi Board
r8377r8378
85048217
85058218 *************************************************************/
85068219
8507static void waixing_sec_set_prg( running_machine *machine, int prg_base, int prg_mask )
8220static void waixing_sec_prg_cb( running_machine *machine, int start, int bank )
85088221{
85098222   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);
85118226
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);
85228228}
85238229
8524static void waixing_sec_set_chr( running_machine *machine, int chr_base, int chr_mask )
8230static void waixing_sec_chr_cb( running_machine *machine, int start, int bank, int source )
85258231{
85268232   nes_state *state = (nes_state *)machine->driver_data;
8527   UINT8 chr_page = (state->mmc_latch1 & 0x80) >> 5;
8528   int i;
85298233
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);
85488239}
85498240
85508241static WRITE8_HANDLER( waixing_sec_l_w )
r8377r8378
85568247
85578248   if (offset == 0x1000)
85588249   {
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);
85628253   }
85638254}
85648255
8565static 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
8270static void waixing_sh2_chr_cb( running_machine *machine, int start, int bank, int source )
85668271{
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
8278READ8_HANDLER( waixing_sh2_chr_r )
8279{
85678280   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;
85708284
8571   switch (offset & 0x6001)
8285   switch (offset & 0xff8)
85728286   {
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;
86068290   }
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;   
86078299}
86088300
86098301/*************************************************************
86108302
86118303 Board UNL-8237
86128304
8613 Games: Pochahontas 2
8305 Games: Pocahontas 2
86148306
86158307 MMC3 clone
86168308
8617 In MESS: Not working
8309 In MESS: Supported
86188310
86198311 *************************************************************/
86208312
8621static void unl_8237_set_prg( running_machine *machine )
8313static void unl_8237_prg_cb( running_machine *machine, int start, int bank )
86228314{
86238315   nes_state *state = (nes_state *)machine->driver_data;
8624   UINT8 prg_flip = (state->mmc_latch1 & 0x40) ? 2 : 0;
8625
8316   
86268317   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);
86338319}
86348320
8635static void unl_8237_set_chr( running_machine *machine )
8321static void unl_8237_chr_cb( running_machine *machine, int start, int bank, int source )
86368322{
86378323   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);
86418325
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);
86538327}
86548328
86558329static WRITE8_HANDLER( unl_8237_l_w )
r8377r8378
86728346         }
86738347      }
86748348      else
8675         unl_8237_set_prg(space->machine);
8349         mmc3_set_prg(space->machine, state->mmc_prg_base, state->mmc_prg_mask);
86768350   }
86778351
86788352   if (offset == 0x1001)
86798353   {
86808354      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);
86828356   }
86838357}
86848358
86858359static WRITE8_HANDLER( unl_8237_w )
86868360{
86878361   nes_state *state = (nes_state *)space->machine->driver_data;
8688   UINT8 unl_8237_helper, cmd;
86898362   static const UINT8 conv_table[8] = {0,2,6,1,7,3,4,5};
86908363   LOG_MMC(("unl_8237_w offset: %04x, data: %02x\n", offset, data));
86918364
86928365   switch (offset & 0x7000)
86938366   {
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         
86948372      case 0x2000:
86958373      case 0x3000:
86968374         state->unl_8237_reg[2] = 1;
86978375         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);
87088377         break;
87098378
87108379      case 0x4000:
r8377r8378
87128381         if (state->unl_8237_reg[2])
87138382         {
87148383            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);
87298385         }
87308386         break;
87318387
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
87378388      case 0x6000:
87388389         break;
87398390
r8377r8378
1198211633   { TXC_STRIKEWOLF,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(txc_strikewolf_w),      NULL, NULL, NULL },
1198311634   { TXC_MXMDHTWO,         NES_READONLY(txc_mxmdhtwo_l_r), NES_NOACCESS, NES_WRITEONLY(txc_mxmdhtwo_w), NULL, NULL, NULL },
1198411635   { 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 },
1198911641   { WAIXING_TYPE_F,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_f_w),           NULL, NULL, mmc3_irq },
1199011642   { WAIXING_TYPE_G,       NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_g_w),           NULL, NULL, mmc3_irq },
1199111643   { 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
1199211646   { WAIXING_SGZ,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_sgz_w),         NULL, NULL, konami_irq },
1199311647   { 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 },
1199511649   { WAIXING_ZS,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_zs_w),          NULL, NULL, NULL },
1199611650   { 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
1199811653   { WAIXING_PS2,          NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(waixing_ps2_w),         NULL, NULL, NULL },
1199911654   { UNL_8237,             NES_WRITEONLY(unl_8237_l_w), NES_NOACCESS, NES_WRITEONLY(unl_8237_w),      NULL, NULL, mmc3_irq },
1200011655   { UNL_AX5705,           NES_NOACCESS, NES_NOACCESS, NES_WRITEONLY(unl_ax5705_w),          NULL, NULL, NULL },
r8377r8378
1216811823
1216911824   switch (state->pcb_id)
1217011825   {
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;
1217111861      case SUPERGAME_BOOGERMAN:
1217211862         state->mmc3_prg_cb = sgame_boog_prg_cb;
1217311863         state->mmc3_chr_cb = sgame_boog_chr_cb;
src/mess/machine/nes.c
r8377r8378
175175      memory_install_read8_handler(space, 0x4020, 0x40ff, 0, 0, unl_6035052_extra_r);
176176      memory_install_write8_handler(space, 0x4020, 0x40ff, 0, 0, unl_6035052_extra_w);
177177   }
178
179   if (state->pcb_id == WAIXING_SH2)
180      memory_install_read8_handler(cpu_get_address_space(devtag_get_device(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0, 0x1fff, 0, 0, waixing_sh2_chr_r);
178181}
179182
180183// to be probably removed (it does nothing since a long time)
src/mess/machine/nes_unif.c
r8377r8378
343343      case STD_TKROM:
344344      case REXSOFT_DBZ5:   // mapper 12
345345      case WAIXING_TYPE_A:   // mapper 74
346      case WAIXING_TYPE_A_1:
346347      case STD_TXSROM:   // mapper 118
347348      case STD_TQROM:   // mapper 119
349      case WAIXING_SH2:   // mapper 165
348350      case WAIXING_TYPE_B:   // mapper 191
349351      case WAIXING_TYPE_C:   // mapper 192
350352      case WAIXING_TYPE_D:   // mapper 194
r8377r8378
666668         break;
667669// mapper 164
668670      case WAIXING_FFV:
669         prg32(machine, 0xff);
671         prg16_89ab(machine, 0);
672         prg16_cdef(machine, 0x1f);
670673         break;
671674// mapper 166
672675      case SUBOR_TYPE1:
r8377r8378
713716         break;
714717// mapper 198
715718      case WAIXING_TYPE_F:
719         mmc3_common_initialize(machine, 0xff, 0xff, 0);
716720         state->mmc_prg_bank[0] = 0x00;
717721         state->mmc_prg_bank[1] = 0x01;
718722         state->mmc_prg_bank[2] = 0x4e;
719723         state->mmc_prg_bank[3] = 0x4f;
720         state->mmc_latch1 = 0;
721         state->mmc_latch2 = 0x80;
722         state->mmc_prg_base = state->mmc_chr_base = 0;
723         state->mmc_prg_mask = state->mmc_chr_mask = 0xff;
724         waixing_f_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
725         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
724         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
726725         break;
727726// mapper 199
728727      case WAIXING_TYPE_G:
728         mmc3_common_initialize(machine, 0xff, 0xff, 0);
729729         state->mmc_prg_bank[0] = 0x00;
730730         state->mmc_prg_bank[1] = 0x01;
731731         state->mmc_prg_bank[2] = 0x3e;
732732         state->mmc_prg_bank[3] = 0x3f;
733         state->mmc_latch1 = 0;
734         state->mmc_latch2 = 0x80;
735         state->mmc_prg_base = state->mmc_chr_base = 0;
736         state->mmc_prg_mask = state->mmc_chr_mask = 0xff;
737733         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
734         state->mmc_vrom_bank[0] = 0x00;
735         state->mmc_vrom_bank[1] = 0x02;
736         state->mmc_vrom_bank[2] = 0x04;
737         state->mmc_vrom_bank[3] = 0x05;
738         state->mmc_vrom_bank[4] = 0x06;
739         state->mmc_vrom_bank[5] = 0x07;
740         state->mmc_vrom_bank[6] = 0x01;
741         state->mmc_vrom_bank[7] = 0x03;
738742         waixing_g_set_chr(machine, state->mmc_chr_base, state->mmc_chr_mask);
739743         break;
744
740745// mapper 200
741746      case BMC_36IN1:
742747         prg16_89ab(machine, state->prg_chunks - 1);
r8377r8378
799804         prg16_cdef(machine, 0);
800805         break;
801806
807// mapper 223?
808      case WAIXING_TYPE_I:
809         mmc3_common_initialize(machine, 0xff, 0xff, 0);
810         state->mmc_latch2 = 0;
811         break;
812         
813// mapper 224?
814      case WAIXING_TYPE_J:
815         mmc3_common_initialize(machine, 0xff, 0xff, 0);
816         state->mmc_prg_bank[0] = 0x01;
817         state->mmc_prg_bank[1] = 0x02;
818         state->mmc_prg_bank[2] = 0x7e;
819         state->mmc_prg_bank[3] = 0x7f;
820         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
821         break;
822
802823// mapper 227
803824      case BMC_1200IN1:
804825         prg16_89ab(machine, 0);
r8377r8378
842863         break;
843864// mapper 249
844865      case WAIXING_SECURITY:
866         state->mmc_reg[0] = 0;
845867         mmc3_common_initialize(machine, 0xff, 0xff, 0);
846         state->map249_reg = 0;
847         waixing_sec_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
848         waixing_sec_set_chr(machine, state->mmc_chr_base, state->mmc_chr_mask);
849868         break;
850869
851870// mapper 254
r8377r8378
907926         break;
908927      case UNL_8237:
909928         state->unl_8237_reg[0] = state->unl_8237_reg[1] = state->unl_8237_reg[2] = 0;
910         state->mmc_prg_bank[0] = 0x00;
911         state->mmc_prg_bank[1] = 0x01;
912         state->mmc_prg_bank[2] = 0xfe;
913         state->mmc_prg_bank[3] = 0xff;
914         state->mmc_latch1 = 0;
915         state->mmc_latch2 = 0x80;
916         unl_8237_set_prg(machine);
917         unl_8237_set_chr(machine);
929         mmc3_common_initialize(machine, 0xff, 0xff, 0);
918930         break;
919931      case UNL_AX5705:
920932         state->mmc_prg_bank[0] = 0;
src/mess/machine/nes_mmc.h
r8377r8378
9393   HENGEDIANZI_BOARD, HENGEDIANZI_XJZB, SUBOR_TYPE0, SUBOR_TYPE1,
9494   KAISER_KS7058, KAISER_KS7032, KAISER_KS7022, KAISER_KS7017, KAISER_KS202, CONY_BOARD,
9595   CNE_DECATHLON, CNE_FSB, CNE_SHLZ, RCM_GS2015, RCM_TETRISFAMILY,
96   WAIXING_TYPE_A, WAIXING_TYPE_B, WAIXING_TYPE_C, WAIXING_TYPE_D,
96   WAIXING_TYPE_A, WAIXING_TYPE_A_1, WAIXING_TYPE_B, WAIXING_TYPE_C, WAIXING_TYPE_D,
9797   WAIXING_TYPE_E, WAIXING_TYPE_F, WAIXING_TYPE_G, WAIXING_TYPE_H,
98   WAIXING_SGZLZ, WAIXING_SGZ, WAIXING_ZS, WAIXING_SECURITY,
98   WAIXING_TYPE_I, WAIXING_TYPE_J,
99   WAIXING_SGZLZ, WAIXING_SGZ, WAIXING_ZS, WAIXING_SECURITY, WAIXING_SH2,
99100   WAIXING_DQ8, WAIXING_FFV, WAIXING_PS2, SUPERGAME_LIONKING, SUPERGAME_BOOGERMAN,
100101   KAY_PANDAPRINCE, HOSENKAN_BOARD, NITRA_TDA, GOUDER_37017, NANJING_BOARD,
101102   WHIRLWIND_2706,
r8377r8378
128129READ8_HANDLER( ks7017_extra_r );
129130WRITE8_HANDLER( unl_6035052_extra_w );
130131READ8_HANDLER( unl_6035052_extra_r );
132READ8_HANDLER( waixing_sh2_chr_r );
131133
132134//TEMPORARY PPU STUFF
133135
src/mess/machine/nes_ines.c
r8377r8378
348348   // 162 Unused
349349   { 163, NANJING_BOARD},
350350   { 164, WAIXING_FFV },
351   // 165 Waixing SH2 (Fire Emblem & Fire Emblem Gaiden Chinese) - Unsupported
351   { 165, WAIXING_SH2 },
352352   { 166, SUBOR_TYPE1 },
353353   { 167, SUBOR_TYPE0 },
354354   { 168, UNL_RACERMATE },
r8377r8378
406406   // 220 Unused
407407   { 221, UNL_N625092 },
408408   { 222, BTL_DRAGONNINJA },
409   // 223 Waixing Type I - Unsupported
410   // 224 Waixing Type J - Unsupported
409   { 223, WAIXING_TYPE_I },   // (according to NEStopia source, it's MMC3 with more WRAM)
410   { 224, WAIXING_TYPE_J },   // (according to NEStopia source, it's MMC3 with more WRAM)
411411   { 225, BMC_72IN1 },
412412   { 226, BMC_76IN1 },
413413   { 227, BMC_1200IN1 },

Previous 15994 Revisions Next


© 1998-2018 The MESS Team