Previous 15994 Revisions Next

r8385 Sunday 4th July, 2010 at 10:02:07 UTC by Fabio Priuli
[NES] more code shuffling and cleanups
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_mmc.c nes_mmc.h nes_pcb.c nes_unif.c

src/mess/machine/nes_pcb.c
r8384r8385
618618   return NULL;
619619}
620620
621int nes_get_pcb_id( running_machine *machine, const char *feature )
622{
623   const nes_pcb *pcb = nes_pcb_lookup(feature);
624   
625   if (pcb == NULL)
626      fatalerror("Unimplemented PCB type %s\n", feature);
627   
628   return pcb->pcb_id;
629}
621630
622631/************************************************
623632
r8384r8385
1194511954   //
1194611955};
1194711956
11948
1194911957const nes_pcb_intf *nes_pcb_intf_lookup( int pcb_id )
1195011958{
1195111959   int i;
r8384r8385
1195711965   return NULL;
1195811966}
1195911967
11960/*************************************************************
11961 
11962 nes_pcb_reset
11963 
11964 Resets the mmc bankswitch areas to their defaults.
11965 It returns a value "err" that indicates if it was
11966 successful. Possible values for err are:
11967 
11968 0 = success
11969 1 = no pcb found
11970 2 = pcb not supported
11971 
11972 *************************************************************/
11973
11974int nes_pcb_reset( running_machine *machine )
11975{
11976   nes_state *state = (nes_state *)machine->driver_data;
11977   int err = 0;
11978   const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id);
11979
11980   if (intf == NULL)
11981      fatalerror("Missing PCB interface\n");
11982
11983   /* Set the mapper irq callback */
11984   ppu2c0x_set_scanline_callback(state->ppu, intf ? intf->mmc_scanline : NULL);
11985   ppu2c0x_set_hblank_callback(state->ppu, intf ? intf->mmc_hblank : NULL);
11986
11987   err = pcb_initialize(machine, state->pcb_id);
11988
11989   return err;
11990}
11991
11992int nes_get_pcb_id( running_machine *machine, const char *feature )
11993{
11994   const nes_pcb *pcb = nes_pcb_lookup(feature);
11995
11996   if (pcb == NULL)
11997      fatalerror("Unimplemented PCB type %s\n", feature);
11998
11999   return pcb->pcb_id;
12000}
12001
1200211968void pcb_handlers_setup( running_machine *machine )
1200311969{
1200411970   nes_state *state = (nes_state *)machine->driver_data;
1200511971   const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id);
12006
11972   
1200711973   if (intf == NULL)
1200811974      fatalerror("Missing PCB interface\n");
12009
11975   
1201011976   if (intf)
1201111977   {
1201211978      state->mmc_write_low = intf->mmc_l.write;
r8384r8385
1202811994      state->mmc_read = NULL;   // in progress
1202911995      ppu_latch = NULL;
1203011996   }
12031
11997   
1203211998   state->mmc3_prg_cb = prg8_x;
1203311999   state->mmc3_chr_cb = chr1_x;
12034
12000   
1203512001   switch (state->pcb_id)
1203612002   {
1203712003      case STD_TXSROM:
r8384r8385
1211412080   }
1211512081}
1211612082
12083/*************************************************************
12084 
12085 pcb_initialize
12086
12087 Initialize all the necessary registers and quantities for
12088 emulation of each board
12089 
12090 *************************************************************/
12091
12092/* this is used by many boards (MMC3, MMC6 + most MMC3 pirate clone boards) */
12093static void mmc3_common_initialize( running_machine *machine, int prg_mask, int chr_mask, int IRQ_type )
12094{
12095   nes_state *state = (nes_state *)machine->driver_data;
12096   
12097   state->mmc3_alt_irq = IRQ_type;      // later MMC3 boards seem to use MMC6-type IRQ... more investigations are in progress at NESDev...
12098   state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;   // prg_bank[2] & prg_bank[3] remain always the same in most MMC3 variants
12099   state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;   // but some pirate clone mappers change them after writing certain registers
12100   state->mmc3_latch = 0;
12101   state->mmc3_wram_protect = 0x80;
12102   state->mmc_prg_base = state->mmc_chr_base = 0;
12103   state->mmc_prg_mask = prg_mask;
12104   state->mmc_chr_mask = chr_mask;
12105   mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12106   mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12107}
12108
12109// WIP code
12110static int pcb_initialize( running_machine *machine, int idx )
12111{
12112   nes_state *state = (nes_state *)machine->driver_data;
12113   int err = 0, i;
12114   
12115   /* basic PRG config */
12116   prg32(machine, 0);
12117   
12118   /* some boards will not use this, but directly CHRROM (resp. CHRRAM) if the board only has VROM (resp. VRAM) */
12119   state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
12120   chr8(machine, 0, state->mmc_chr_source);
12121   
12122   /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */
12123   for (i = 0; i < 4; i++)
12124      state->mmc_prg_bank[i] = 0;
12125   for (i = 0; i < 16; i++)
12126      state->mmc_vrom_bank[i] = 0;
12127   for (i = 0; i < 16; i++)
12128      state->mmc_extra_bank[i] = 0;
12129   
12130   state->mmc_latch1 = 0;
12131   state->mmc_latch2 = 0;
12132   
12133   /* Finally, we init IRQ-related quantities. */
12134   state->IRQ_enable = state->IRQ_enable_latch = 0;
12135   state->IRQ_count = state->IRQ_count_latch = 0;
12136   state->IRQ_toggle = 0;
12137   
12138   switch (idx)
12139   {
12140         /* many boards only needs PRG to point at first 32k and CHR at first 8k */
12141      case STD_NROM:   // mapper 0
12142      case HVC_FAMBASIC:
12143      case GG_NROM:
12144      case UXROM_CC:   // mapper 180
12145      case STD_CNROM:   // mapper 3, 185
12146      case BANDAI_PT554:
12147      case TENGEN_800008:
12148      case STD_BXROM:   // mapper 34
12149      case STD_GXROM:   // mapper 66
12150      case STD_MXROM:
12151      case BANDAI_OEKAKIDS:   // mapper 96
12152      case JALECO_JF11:   // mapper 140
12153      case JALECO_JF13:   // mapper 86
12154      case JALECO_JF19:   // mapper 92
12155      case DIS_74X377:   // mapper 11
12156      case DIS_74X161X138:   // mapper 38
12157      case CALTRON_6IN1:   // mapper 41
12158      case TXC_STRIKEWOLF:   // mapper 36
12159      case UNL_STUDYNGAME:   // mapper 39
12160      case RUMBLESTATION_BOARD:   // mapper 46
12161      case BMC_GKB:   // mapper 58
12162      case RCM_TETRISFAMILY:   // mapper 61
12163      case BMC_SUPER_700IN1:   // mapper 62
12164      case MAGICSERIES_MD:   // mapper 107
12165      case HES_BOARD:   // mapper 113
12166      case HES6IN1_BOARD:   // mapper 113
12167      case SACHEN_SA72008:   // mapper 133
12168      case SACHEN_TCU02:   // mapper 136
12169      case SACHEN_SA72007:   // mapper 145
12170      case SACHEN_TCU01:   // mapper 147
12171      case SACHEN_SA009:   // mapper 160
12172      case SACHEN_SA0037:   // mapper 148
12173      case SACHEN_SA0036:   // mapper 149
12174      case AGCI_50282:   // mapper 144
12175      case KAISER_KS7058:   // mapper 171
12176      case HENGEDIANZI_BOARD:   // mapper 177
12177      case WAIXING_SGZLZ:   // mapper 178
12178      case HENGEDIANZI_XJZB:   // mapper 179
12179      case BMC_21IN1:   // mapper 201
12180      case BMC_9999999IN1:   // mapper 213
12181      case RCM_GS2015:   // mapper 216
12182      case BMC_72IN1:   // mapper 225
12183      case BMC_76IN1:   // mapper 226
12184      case BMC_SUPER_42IN1:   // mapper 226
12185      case ACTENT_ACT52:   // mapper 228
12186      case CNE_SHLZ:   // mapper 240
12187      case TXC_MXMDHTWO:   // mapper 241
12188      case WAIXING_ZS:   // mapper 242
12189      case WAIXING_DQ8:   // mapper 242
12190      case CNE_DECATHLON:   // mapper 244
12191      case UNL_CC21:
12192      case BMC_VT5201:
12193      case BMC_WS:
12194      case UNL_EDU2K:
12195         break;
12196         
12197         /* other boards need additional initialization */
12198      case STD_UXROM:   // mapper 2
12199      case STD_UN1ROM:   // mapper 94
12200      case STD_JXROM:      // mapper 69
12201      case SUNSOFT_5B:
12202      case SUNSOFT_FME7:
12203      case NAMCOT_3425:   // mapper 95
12204      case DIS_74X139X74:   // mapper 87
12205      case DIS_74X161X161X32:   // mapper 152 & 70
12206      case BANDAI_LZ93:   // mapper 16, 157
12207      case BANDAI_LZ93EX:   // same + EEPROM
12208      case BANDAI_DATACH:
12209      case BANDAI_FCG:
12210      case IREM_HOLYDIV:   // mapper 78
12211      case IREM_G101:   // mapper 32
12212      case IREM_H3001:   // mapper 65
12213      case JALECO_SS88006:   // mapper 18
12214      case JALECO_JF16:   // mapper 78
12215      case JALECO_JF17:   // mapper 72
12216      case KONAMI_VRC1:   // mapper 75
12217      case KONAMI_VRC2:
12218      case KONAMI_VRC3:   // mapper 73
12219      case KONAMI_VRC4:
12220      case KONAMI_VRC6:
12221      case SUNSOFT_3:   // mapper 67
12222      case TAITO_TC0190FMC:   // mapper 33
12223      case TAITO_TC0190FMCP:   // mapper 48
12224      case TAITO_X1_005:   // mapper 80
12225      case TAITO_X1_005_A:   // mapper 207
12226      case TAITO_X1_017:   // mapper 82
12227      case NTDEC_ASDER:   // mapper 112
12228      case FUTUREMEDIA_BOARD:   // mapper 117
12229      case BTL_DRAGONNINJA:   // mapper 222
12230      case WAIXING_SGZ:   // mapper 252
12231      case UNL_T230:
12232      case BMC_NTD_03:
12233      case KAISER_KS7022:
12234      case UNL_SHJY3:
12235      case KAISER_KS7017:
12236      case KAISER_KS7032:
12237      case KAISER_KS202:
12238         prg16_89ab(machine, 0);
12239         prg16_cdef(machine, state->prg_chunks - 1);
12240         break;
12241         
12242      case STD_CPROM:   // mapper 13
12243         chr4_0(machine, 0, CHRRAM);
12244         chr4_4(machine, 0, CHRRAM);
12245         break;
12246      case STD_AXROM:   // mapper 7
12247         set_nt_mirroring(machine, PPU_MIRROR_LOW);
12248         break;
12249      case STD_SXROM:   // mapper 1, 155
12250      case STD_SOROM:
12251      case STD_SXROM_A:
12252      case STD_SOROM_A:
12253         state->mmc1_latch = 0;
12254         state->mmc1_count = 0;
12255         state->mmc_reg[0] = 0x0f;
12256         state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
12257         state->mmc1_reg_write_enable = 1;
12258         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
12259         mmc1_set_chr(machine);
12260         mmc1_set_prg(machine);
12261         wram_bank(machine, 0, (idx == STD_SOROM) ? NES_WRAM : NES_BATTERY);
12262         break;
12263      case STD_PXROM:   // mapper 9
12264         state->mmc_reg[0] = state->mmc_reg[2] = 0;
12265         state->mmc_reg[1] = state->mmc_reg[3] = 0;
12266         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
12267         prg8_89(machine, 0);
12268         prg8_ab(machine, (state->prg_chunks << 1) - 3);
12269         prg8_cd(machine, (state->prg_chunks << 1) - 2);
12270         prg8_ef(machine, (state->prg_chunks << 1) - 1);
12271         break;
12272      case STD_FXROM: // mapper 10
12273         state->mmc_reg[0] = state->mmc_reg[2] = 0;
12274         state->mmc_reg[1] = state->mmc_reg[3] = 0;
12275         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
12276         prg16_89ab(machine, 0);
12277         prg16_cdef(machine, state->prg_chunks - 1);
12278         break;
12279      case STD_TXROM:   // mapper 4
12280      case STD_TVROM:
12281      case STD_TKROM:
12282      case REXSOFT_DBZ5:   // mapper 12
12283      case WAIXING_TYPE_A:   // mapper 74
12284      case WAIXING_TYPE_A_1:
12285      case STD_TXSROM:   // mapper 118
12286      case STD_TQROM:   // mapper 119
12287      case WAIXING_SH2:   // mapper 165
12288      case WAIXING_TYPE_B:   // mapper 191
12289      case WAIXING_TYPE_C:   // mapper 192
12290      case WAIXING_TYPE_D:   // mapper 194
12291      case WAIXING_TYPE_E:   // mapper 195
12292      case WAIXING_TYPE_H:   // mapper 245
12293      case BTL_SUPERBROS11:   // mapper 196
12294      case UNL_H2288:      // mapper 123
12295      case UNL_KOF97:
12296      case UNL_603_5052:
12297      case NITRA_TDA:   // mapper 250
12298         if (state->four_screen_vram)   // only TXROM and DXROM have 4-screen mirroring
12299         {
12300            set_nt_page(machine, 0, CART_NTRAM, 0, 1);
12301            set_nt_page(machine, 1, CART_NTRAM, 1, 1);
12302            set_nt_page(machine, 2, CART_NTRAM, 2, 1);
12303            set_nt_page(machine, 3, CART_NTRAM, 3, 1);
12304         }
12305         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12306         break;
12307      case STD_HKROM:   // MMC6 (basically the same as TxROM, but alt IRQ behaviour)
12308         mmc3_common_initialize(machine, 0xff, 0xff, 1);
12309         state->mmc6_reg = 0xf0;
12310         state->mmc_latch2 = 0;   // this is used differently here compared to MMC3
12311         break;
12312      case PAL_ZZ:   // mapper 37
12313         mmc3_common_initialize(machine, 0x07, 0x7f, 0);
12314         break;
12315      case NES_QJ:   // mapper 47
12316         mmc3_common_initialize(machine, 0x0f, 0x7f, 0);
12317         break;
12318      case STD_EXROM:   // mapper 5
12319         state->MMC5_rom_bank_mode = 3;
12320         state->MMC5_vrom_bank_mode = 0;
12321         state->MMC5_vram_protect = 0;
12322         state->mmc5_high_chr = 0;
12323         state->mmc5_vram_control = 0;
12324         state->mmc5_split_scr = 0;
12325         memset(state->MMC5_vrom_bank, 0, ARRAY_LENGTH(state->MMC5_vrom_bank));
12326         state->mmc5_prg_mode = 3;
12327         state->mmc5_last_chr_a = 1;
12328         state->mmc5_prg_regs[0] = 0xfc;
12329         state->mmc5_prg_regs[1] = 0xfd;
12330         state->mmc5_prg_regs[2] = 0xfe;
12331         state->mmc5_prg_regs[3] = 0xff;
12332         memset(state->mmc5_vrom_regA, ~0, ARRAY_LENGTH(state->mmc5_vrom_regA));
12333         memset(state->mmc5_vrom_regB, ~0, ARRAY_LENGTH(state->mmc5_vrom_regB));
12334         prg16_89ab(machine, state->prg_chunks - 2);
12335         prg16_cdef(machine, state->prg_chunks - 1);
12336         break;
12337      case STD_NXROM:      // mapper 68
12338      case SUNSOFT_DCS:      // mapper 68
12339         state->mmc_reg[0] = 0;
12340         prg16_89ab(machine, 0);
12341         prg16_cdef(machine, state->prg_chunks - 1);
12342         break;
12343      case NAMCOT_34X3:   // mapper 88
12344      case STD_DXROM:   // mapper 206
12345      case STD_DRROM:
12346         if (state->four_screen_vram)   // only TXROM and DXROM have 4-screen mirroring
12347         {
12348            set_nt_page(machine, 0, CART_NTRAM, 0, 1);
12349            set_nt_page(machine, 1, CART_NTRAM, 1, 1);
12350            set_nt_page(machine, 2, CART_NTRAM, 2, 1);
12351            set_nt_page(machine, 3, CART_NTRAM, 3, 1);
12352         }
12353      case NAMCOT_3453:   // mapper 154
12354         prg16_89ab(machine, state->prg_chunks - 2);
12355         prg16_cdef(machine, state->prg_chunks - 1);
12356         break;
12357      case NAMCOT_3446:   // mapper 76
12358         prg8_89(machine, 0);
12359         prg8_ab(machine, 1);
12360         prg16_cdef(machine, state->prg_chunks - 1);
12361         chr2_0(machine, 0, CHRROM);
12362         chr2_2(machine, 1, CHRROM);
12363         chr2_4(machine, 2, CHRROM);
12364         chr2_6(machine, 3, CHRROM);
12365         break;
12366      case BANDAI_JUMP2:   // mapper 153
12367         for (i = 0; i < 8; i++)
12368            state->mmc_reg[i] = 0;
12369         prg16_89ab(machine, 0);
12370         prg16_cdef(machine, state->prg_chunks - 1);
12371         fjump2_set_prg(machine);
12372         break;
12373      case BANDAI_KARAOKE:   // mapper 188
12374         prg16_89ab(machine, 0);
12375         prg16_cdef(machine, (state->prg_chunks - 1) ^ 0x08);
12376         break;
12377      case IREM_LROG017:   // mapper 77
12378         chr2_2(machine, 0, CHRROM);
12379         chr2_4(machine, 1, CHRROM);
12380         chr2_6(machine, 2, CHRROM);
12381         break;
12382      case IREM_TAM_S1:   // mapper 97
12383         prg16_89ab(machine, state->prg_chunks - 1);
12384         prg16_cdef(machine, 0);
12385         break;
12386      case KONAMI_VRC7:   // mapper 85
12387         prg8_89(machine, 0);
12388         prg8_ab(machine, 0);
12389         prg8_cd(machine, 0);
12390         prg8_ef(machine, 0xff);
12391         break;
12392      case NAMCOT_163:   // mapper 19
12393         prg16_89ab(machine, 0);
12394         prg16_cdef(machine, state->prg_chunks - 1);
12395         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12396         break;
12397      case SUNSOFT_1:   // mapper 184
12398      case SUNSOFT_2:   // mapper 89 & 93
12399         prg16_89ab(machine, 0);
12400         prg16_cdef(machine, state->prg_chunks - 1);
12401         if (!state->hard_mirroring)
12402            set_nt_mirroring(machine, PPU_MIRROR_LOW);
12403         break;
12404         
12405         // mapper 14
12406      case REXSOFT_SL1632:
12407         state->mmc_extra_bank[2] = 0xfe;
12408         state->mmc_extra_bank[3] = 0xff;
12409         state->mmc_extra_bank[0] = state->mmc_extra_bank[1] = state->mmc_extra_bank[4] = state->mmc_extra_bank[5] = state->mmc_extra_bank[6] = 0;
12410         state->mmc_extra_bank[7] = state->mmc_extra_bank[8] = state->mmc_extra_bank[9] = state->mmc_extra_bank[0xa] = state->mmc_extra_bank[0xb] = 0;
12411         state->mmc_reg[0] = state->mmc_reg[1] = 0;
12412         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12413         break;
12414         // mapper 15
12415      case WAIXING_PS2:
12416         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12417         break;
12418         
12419         // mapper 35
12420      case UNL_SC127:
12421         // mapper 42
12422      case BTL_MARIOBABY:
12423      case BTL_AISENSHINICOL:
12424         prg32(machine, 0xff);
12425         break;
12426         
12427         // mapper 40
12428      case BTL_SMB2A:
12429         prg8_67(machine, 0xfe);
12430         prg8_89(machine, 0xfc);
12431         prg8_ab(machine, 0xfd);
12432         prg8_cd(machine, 0xfe);
12433         prg8_ef(machine, 0xff);
12434         break;
12435         
12436         // mapper 43
12437      case UNL_SMB2J:
12438         if (state->battery)
12439            memset(state->battery_ram, 0x2000, 0xff);
12440         else if (state->prg_ram)
12441            memset(state->wram, 0x2000, 0xff);
12442         break;
12443         // mapper 44
12444      case BMC_SUPERBIG_7IN1:
12445         // mapper 49
12446      case BMC_SUPERHIK_4IN1:
12447         mmc3_common_initialize(machine, 0x0f, 0x7f, 0);
12448         break;
12449         // mapper 45
12450      case BMC_HIK8IN1:
12451         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
12452         mmc3_common_initialize(machine, 0x3f, 0xff, 0);
12453         break;
12454         
12455         // mapper 50
12456      case BTL_SMB2B:
12457         prg8_67(machine, 0x0f);
12458         prg8_89(machine, 0x08);
12459         prg8_ab(machine, 0x09);
12460         prg8_cd(machine, 0);
12461         prg8_ef(machine, 0x0b);
12462         break;
12463         // mapper 51
12464      case BMC_BALLGAMES_11IN1:
12465         state->mmc_reg[0] = 0x01;
12466         state->mmc_reg[1] = 0x00;
12467         bmc_ball11_set_banks(machine);
12468         break;
12469         // mapper 52
12470      case BMC_MARIOPARTY_7IN1:
12471         state->map52_reg_written = 0;
12472         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
12473         break;
12474         // mapper 54
12475      case BMC_NOVELDIAMOND:
12476         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12477         break;
12478         // mapper 57
12479      case BMC_GKA:
12480         prg16_89ab(machine, 0);
12481         prg16_cdef(machine, 0);
12482         break;
12483         
12484         // mapper 64
12485      case TENGEN_800032:
12486         // mapper 158
12487      case TENGEN_800037:
12488         prg16_89ab(machine, state->prg_chunks - 1);
12489         prg16_cdef(machine, state->prg_chunks - 1);
12490         break;
12491         // mapper 71
12492      case CAMERICA_BF9097:
12493         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
12494      case CAMERICA_BF9093:
12495         prg32(machine, 0xff);
12496         break;
12497         
12498         // mapper 79 (& 146)
12499      case AVE_NINA06:
12500         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
12501         break;
12502         
12503         // mapper 83
12504      case CONY_BOARD:
12505         state->mapper83_reg[9] = 0x0f;
12506         prg8_cd(machine, 0x1e);
12507         prg8_ef(machine, 0x1f);
12508         break;
12509         
12510         // mapper 91
12511      case UNL_MK2:
12512         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12513         prg16_89ab(machine, state->prg_chunks - 1);
12514         prg16_cdef(machine, state->prg_chunks - 1);
12515         break;
12516         
12517         // mapper 104
12518      case CAMERICA_GOLDENFIVE:
12519         prg16_89ab(machine, 0x00);
12520         prg16_cdef(machine, 0x0f);
12521         break;
12522         // mapper 106
12523      case BTL_SMB3:
12524         prg8_89(machine, (state->prg_chunks << 1) - 1);
12525         prg8_ab(machine, 0);
12526         prg8_cd(machine, 0);
12527         prg8_ef(machine, (state->prg_chunks << 1) - 1);
12528         break;
12529         
12530         // mapper 108
12531      case WHIRLWIND_2706:
12532         prg32(machine, 0xff);
12533         break;
12534         
12535         // mapper 114
12536      case SUPERGAME_LIONKING:
12537         state->map114_reg = state->map114_reg_enabled = 0;
12538         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12539         break;
12540         // mapper 115
12541      case KASING_BOARD:
12542         state->mmc_reg[0] = 0;
12543         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12544         break;
12545         // mapper 116
12546      case SOMERI_SL12:
12547         state->mmc_prg_base = state->mmc_chr_base = 0;
12548         state->mmc_prg_mask = 0xff;
12549         state->mmc_chr_mask = 0xff;
12550         state->mmc_cmd1 = 2; // mode
12551         state->mmc3_latch = 0;
12552         state->mmc3_wram_protect = 0;
12553         // MMC1 regs
12554         state->mmc1_count = 0;
12555         state->mmc_reg[0] = 0x0c;
12556         state->mmc_reg[1] = 0x00;
12557         state->mmc_reg[2] = 0x00;
12558         state->mmc_reg[3] = 0x00;
12559         // MMC3 regs
12560         state->mmc_prg_bank[0] = 0x3c;
12561         state->mmc_prg_bank[1] = 0x3d;
12562         state->mmc_prg_bank[2] = 0xfe;
12563         state->mmc_prg_bank[3] = 0xff;
12564         state->mmc_vrom_bank[0] = 0x00;
12565         state->mmc_vrom_bank[1] = 0x01;
12566         state->mmc_vrom_bank[2] = 0x04;
12567         state->mmc_vrom_bank[3] = 0x05;
12568         state->mmc_vrom_bank[4] = 0x06;
12569         state->mmc_vrom_bank[5] = 0x07;
12570         // VRC2 regs
12571         state->mmc_prg_bank[4] = 0x00;
12572         state->mmc_prg_bank[5] = 0x01;
12573         for (i = 0; i < 8; ++i)
12574            state->mmc_vrom_bank[6 + i] = i;
12575         someri_mode_update(machine);
12576         break;
12577         
12578         // mapper 120
12579      case BTL_TOBIDASE:
12580         prg32(machine, 2);
12581         break;
12582         
12583         // mapper 121
12584      case KAY_PANDAPRINCE:
12585         state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0;
12586         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12587         break;
12588         
12589         // mapper 126
12590      case BMC_PJOY84:
12591         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12592         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
12593         pjoy84_set_base_mask(machine);
12594         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12595         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12596         break;
12597         
12598         // mapper 132
12599      case TXC_22211A:
12600         // mapper 172
12601      case TXC_22211B:
12602         // mapper 173
12603      case TXC_22211C:
12604         state->txc_reg[0] = state->txc_reg[1] = state->txc_reg[2] = state->txc_reg[3] = 0;
12605         break;
12606         
12607         // mapper 134
12608      case BMC_FAMILY_4646B:
12609         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
12610         break;
12611         
12612         // mapper 137
12613      case SACHEN_8259D:
12614         chr8(machine, state->chr_chunks - 1, CHRROM);
12615         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12616         break;
12617         // mapper 138
12618      case SACHEN_8259B:
12619         // mapper 139
12620      case SACHEN_8259C:
12621         // mapper 141
12622      case SACHEN_8259A:
12623         // mapper 150
12624      case SACHEN_74LS374:
12625         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12626         break;
12627         // mapper 143
12628      case SACHEN_TCA01:
12629         prg16_89ab(machine, 0);
12630         prg16_cdef(machine, 1);
12631         break;
12632         
12633         // mapper 156
12634      case OPENCORP_DAOU306:
12635         prg16_89ab(machine, state->prg_chunks - 2);
12636         prg16_cdef(machine, state->prg_chunks - 1);
12637         set_nt_mirroring(machine, PPU_MIRROR_LOW);
12638         break;
12639         // mapper 163
12640      case NANJING_BOARD:
12641         state->mmc_count = 0xff;
12642         state->mmc_reg[0] = 0xff;
12643         state->mmc_reg[1] = 0;
12644         prg16_89ab(machine, state->prg_chunks - 2);
12645         prg16_cdef(machine, state->prg_chunks - 1);
12646         break;
12647         // mapper 164
12648      case WAIXING_FFV:
12649         prg16_89ab(machine, 0);
12650         prg16_cdef(machine, 0x1f);
12651         break;
12652         // mapper 166
12653      case SUBOR_TYPE1:
12654         state->subor_reg[0] = state->subor_reg[1] = state->subor_reg[2] = state->subor_reg[3] = 0;
12655         prg16_89ab(machine, 0);
12656         prg16_cdef(machine, 0x07);
12657         break;
12658         // mapper 167
12659      case SUBOR_TYPE0:
12660         state->subor_reg[0] = state->subor_reg[1] = state->subor_reg[2] = state->subor_reg[3] = 0;
12661         prg16_89ab(machine, 0);
12662         prg16_cdef(machine, 0x20);
12663         break;
12664         
12665         // mapper 176
12666      case UNL_XZY:
12667         // mapper 182
12668      case HOSENKAN_BOARD:
12669         prg32(machine, (state->prg_chunks - 1) >> 1);
12670         break;
12671         
12672      case FUKUTAKE_BOARD:   // mapper 186
12673         prg16_89ab(machine, 0);
12674         prg16_cdef(machine, 0);
12675         break;
12676         
12677         // mapper 187
12678      case UNL_KOF96:
12679         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
12680         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12681         break;
12682         // mapper 189
12683      case TXC_TW:
12684         state->mmc_latch1 = 0;
12685         state->mmc_latch2 = 0x80;
12686         state->mmc_chr_base = 0;
12687         state->mmc_chr_mask = 0xff;
12688         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12689         break;
12690         // mapper 193
12691      case NTDEC_FIGHTINGHERO:
12692         prg32(machine, (state->prg_chunks - 1) >> 1);
12693         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12694         break;
12695         // mapper 197
12696      case UNL_SUPERFIGHTER3:
12697         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12698         unl_sf3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12699         break;
12700         // mapper 198
12701      case WAIXING_TYPE_F:
12702         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12703         state->mmc_prg_bank[0] = 0x00;
12704         state->mmc_prg_bank[1] = 0x01;
12705         state->mmc_prg_bank[2] = 0x4e;
12706         state->mmc_prg_bank[3] = 0x4f;
12707         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12708         break;
12709         // mapper 199
12710      case WAIXING_TYPE_G:
12711         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12712         state->mmc_prg_bank[0] = 0x00;
12713         state->mmc_prg_bank[1] = 0x01;
12714         state->mmc_prg_bank[2] = 0x3e;
12715         state->mmc_prg_bank[3] = 0x3f;
12716         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12717         state->mmc_vrom_bank[0] = 0x00;
12718         state->mmc_vrom_bank[1] = 0x02;
12719         state->mmc_vrom_bank[2] = 0x04;
12720         state->mmc_vrom_bank[3] = 0x05;
12721         state->mmc_vrom_bank[4] = 0x06;
12722         state->mmc_vrom_bank[5] = 0x07;
12723         state->mmc_vrom_bank[6] = 0x01;
12724         state->mmc_vrom_bank[7] = 0x03;
12725         waixing_g_set_chr(machine, state->mmc_chr_base, state->mmc_chr_mask);
12726         break;
12727         
12728         // mapper 200
12729      case BMC_36IN1:
12730         prg16_89ab(machine, state->prg_chunks - 1);
12731         prg16_cdef(machine, state->prg_chunks - 1);
12732         break;
12733         
12734         // mapper 202
12735      case BMC_150IN1:
12736         // mapper 203
12737      case BMC_35IN1:
12738         // mapper 204
12739      case BMC_64IN1:
12740         // mapper 214
12741      case BMC_SUPERGUN_20IN1:
12742         prg16_89ab(machine, 0);
12743         prg16_cdef(machine, 0);
12744         break;
12745         // mapper 205
12746      case BMC_15IN1:
12747         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
12748         state->mmc_prg_base = 0x10;   // this board has a diff prg_base
12749         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12750         break;
12751         
12752         // mapper 208
12753      case GOUDER_37017:
12754         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = state->mmc_reg[4] = 0;
12755         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12756         break;
12757         // mapper 212
12758      case BMC_SUPERHIK_300IN1:
12759         chr8(machine, 0xff, CHRROM);
12760         prg32(machine, 0xff);
12761         break;
12762         
12763         // mapper 215
12764      case SUPERGAME_BOOGERMAN:
12765         state->mmc_reg[0] = 0x00;
12766         state->mmc_reg[1] = 0xff;
12767         state->mmc_reg[2] = 0x04;
12768         state->mmc_reg[3] = 0;
12769         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
12770         sgame_boog_set_prg(machine);
12771         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
12772         break;
12773         
12774         // mapper 217
12775      case BMC_GOLDENCARD_6IN1:
12776         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12777         state->mmc_reg[0] = 0x00;
12778         state->mmc_reg[1] = 0xff;
12779         state->mmc_reg[2] = 0x03;
12780         state->mmc_reg[3] = 0;
12781         bmc_gc6in1_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12782         bmc_gc6in1_set_chr(machine, state->mmc_chr_source);
12783         break;
12784         // mapper 221
12785      case UNL_N625092:
12786         prg16_89ab(machine, 0);
12787         prg16_cdef(machine, 0);
12788         break;
12789         
12790         // mapper 223?
12791      case WAIXING_TYPE_I:
12792         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12793         state->mmc3_wram_protect = 0;
12794         break;
12795         
12796         // mapper 224?
12797      case WAIXING_TYPE_J:
12798         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12799         state->mmc_prg_bank[0] = 0x01;
12800         state->mmc_prg_bank[1] = 0x02;
12801         state->mmc_prg_bank[2] = 0x7e;
12802         state->mmc_prg_bank[3] = 0x7f;
12803         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
12804         break;
12805         
12806         // mapper 227
12807      case BMC_1200IN1:
12808         prg16_89ab(machine, 0);
12809         prg16_cdef(machine, 0);
12810         break;
12811         
12812         // mapper 229
12813      case BMC_31IN1:
12814         prg16_89ab(machine, 0);
12815         prg16_cdef(machine, 1);
12816         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12817         break;
12818         // mapper 230
12819      case BMC_22GAMES:
12820         prg16_89ab(machine, 0);
12821         prg16_cdef(machine, 7);
12822         break;
12823         // mapper 231
12824      case BMC_20IN1:
12825         prg16_89ab(machine, 0);
12826         prg16_cdef(machine, state->prg_chunks - 1);
12827         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12828         break;
12829         // mapper 232
12830      case CAMERICA_BF9096:
12831         state->mmc_latch1 = 0x18;
12832         state->mmc_latch2 = 0x00;
12833         bf9096_set_prg(machine);
12834         break;
12835         
12836         // mapper 243
12837      case SACHEN_74LS374_A:
12838         state->mmc_vrom_bank[0] = 3;
12839         chr8(machine, 3, CHRROM);
12840         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12841         break;
12842         
12843         // mapper 246
12844      case CNE_FSB:
12845         prg32(machine, 0xff);
12846         break;
12847         // mapper 249
12848      case WAIXING_SECURITY:
12849         state->mmc_reg[0] = 0;
12850         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12851         break;
12852         
12853         // mapper 254
12854      case BTL_PIKACHUY2K:
12855         state->mmc_reg[0] = 0xff;
12856         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12857         break;
12858         
12859         // mapper 255
12860      case BMC_110IN1:
12861         prg16_89ab(machine, 0);
12862         prg16_cdef(machine, 1);
12863         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12864         break;
12865         
12866         // UNIF only
12867      case BMC_64IN1NR:
12868         state->mmc_reg[0] = 0x80;
12869         state->mmc_reg[1] = 0x43;
12870         state->mmc_reg[2] = state->mmc_reg[3] = 0;
12871         bmc_64in1nr_set_prg(machine);
12872         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12873         break;
12874      case BMC_190IN1:
12875         prg16_89ab(machine, 0);
12876         prg16_cdef(machine, 0);
12877         break;
12878      case BMC_A65AS:
12879         prg16_89ab(machine, 0);
12880         prg16_cdef(machine, 7);
12881         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12882         break;
12883      case BMC_GS2004:
12884      case BMC_GS2013:
12885         prg32(machine, 0xff);
12886         break;
12887      case BMC_S24IN1SC03:
12888         state->mmc_reg[0] = 0x24;
12889         state->mmc_reg[1] = 0x9f;
12890         state->mmc_reg[2] = 0;
12891         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12892         break;
12893      case BMC_T262:
12894         state->mmc_latch1 = 0;
12895         state->mmc_latch2 = 0;
12896         prg16_89ab(machine, 0);
12897         prg16_cdef(machine, 7);
12898         break;
12899      case DREAMTECH_BOARD:
12900         prg16_89ab(machine, 0);
12901         prg16_cdef(machine, 8);
12902         break;
12903      case UNL_8237:
12904         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = 0;
12905         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12906         break;
12907      case UNL_AX5705:
12908         state->mmc_prg_bank[0] = 0;
12909         state->mmc_prg_bank[1] = 1;
12910         prg8_89(machine, state->mmc_prg_bank[0]);
12911         prg8_ab(machine, state->mmc_prg_bank[1]);
12912         prg8_cd(machine, 0xfe);
12913         prg8_ef(machine, 0xff);
12914         break;
12915      case UNL_RACERMATE:
12916         chr4_0(machine, 0, state->mmc_chr_source);
12917         chr4_4(machine, 0, state->mmc_chr_source);
12918         prg16_89ab(machine, 0);
12919         prg16_cdef(machine, state->prg_chunks - 1);
12920         break;
12921         
12922      case BMC_BENSHENG_BS5:
12923         state->mmc_prg_bank[0] = 0xff;
12924         state->mmc_prg_bank[1] = 0xff;
12925         state->mmc_prg_bank[2] = 0xff;
12926         state->mmc_prg_bank[3] = 0xff;
12927         bmc_bs5_update_banks(machine);
12928         break;
12929         
12930      case BMC_810544:
12931         prg16_89ab(machine, 0);
12932         prg16_cdef(machine, 0);
12933         set_nt_mirroring(machine, PPU_MIRROR_VERT);
12934         break;
12935         
12936      case BMC_G63IN1:
12937         bmc_gb63_update(machine);
12938         break;
12939         
12940      case BMC_FK23C:
12941         state->mmc_reg[0] = 4;
12942         state->mmc_reg[1] = 0xff;
12943         state->mmc_reg[2] = state->mmc_reg[3] = 0;
12944         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
12945         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12946         fk23c_set_prg(machine);
12947         fk23c_set_chr(machine);
12948         break;
12949         
12950      case BMC_FK23CA:
12951         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
12952         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
12953         mmc3_common_initialize(machine, 0xff, 0xff, 0);
12954         fk23c_set_prg(machine);
12955         fk23c_set_chr(machine);
12956         break;
12957         
12958         
12959      case FFE_MAPPER6:
12960         prg16_89ab(machine, 0);
12961         prg16_cdef(machine, 7);
12962         break;
12963      case FFE_MAPPER8:
12964         prg32(machine, 0);
12965         break;
12966      case FFE_MAPPER17:
12967         prg16_89ab(machine, 0);
12968         prg16_cdef(machine, state->prg_chunks - 1);
12969         break;
12970         
12971      case UNSUPPORTED_BOARD:
12972      default:
12973         /* Mapper not supported */
12974         err = 2;
12975         break;
12976   }
12977   
12978   return err;
12979}
12980
12981/*************************************************************
12982 
12983 nes_pcb_reset
12984 
12985 Resets the mmc bankswitch areas to their defaults.
12986 It returns a value "err" that indicates if it was
12987 successful. Possible values for err are:
12988 
12989 0 = success
12990 1 = no pcb found
12991 2 = pcb not supported
12992 
12993 *************************************************************/
12994
12995int nes_pcb_reset( running_machine *machine )
12996{
12997   nes_state *state = (nes_state *)machine->driver_data;
12998   int err = 0;
12999   const nes_pcb_intf *intf = nes_pcb_intf_lookup(state->pcb_id);
13000
13001   if (intf == NULL)
13002      fatalerror("Missing PCB interface\n");
13003
13004   /* Set the mapper irq callback */
13005   ppu2c0x_set_scanline_callback(state->ppu, intf ? intf->mmc_scanline : NULL);
13006   ppu2c0x_set_hblank_callback(state->ppu, intf ? intf->mmc_hblank : NULL);
13007
13008   err = pcb_initialize(machine, state->pcb_id);
13009
13010   return err;
13011}
src/mess/machine/nes.c
r8384r8385
660660      if ((magic[0] == 'N') && (magic[1] == 'E') && (magic[2] == 'S'))   /* If header starts with 'NES' it is iNES */
661661      {
662662         UINT32 prg_size;
663         state->format = 1;   // we use this to select between mapper_reset / unif_reset
664663         state->ines20 = 0;
665664         state->battery_size = NES_BATTERY_SIZE; // with iNES we can only support 8K WRAM battery (iNES 2.0 might fix this)
666665         state->prg_ram = 1;   // always map state->wram in bank5 (eventually, this should be enabled only for some mappers)
r8384r8385
988987         state->prg_chunks = 0;
989988         state->chr_chunks = 0;
990989
991         state->format = 2;   // we use this to select between mapper_reset / unif_reset
992
993990         image.fread(&buffer, 4);
994991         unif_ver = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
995992         logerror("UNIF file found, version %d\n", unif_ver);
r8384r8385
13091306      state->chr_chunks = chr_size / 0x2000;
13101307      state->vram_chunks = vram_size / 0x2000;
13111308
1312      state->format = 3;
13131309      state->pcb_id = nes_get_pcb_id(image.device().machine, image.get_feature("pcb"));
13141310
13151311      if (state->pcb_id == STD_TVROM || state->pcb_id == STD_DRROM || state->pcb_id == IREM_LROG017)
src/mess/machine/nes_unif.c
r8384r8385
153153   return NULL;
154154}
155155
156/* this is used by many boards (MMC3, MMC6 + most MMC3 pirate clone boards) */
157static void mmc3_common_initialize( running_machine *machine, int prg_mask, int chr_mask, int IRQ_type )
158{
159   nes_state *state = (nes_state *)machine->driver_data;
160
161   state->mmc3_alt_irq = IRQ_type;      // later MMC3 boards seem to use MMC6-type IRQ... more investigations are in progress at NESDev...
162   state->mmc_prg_bank[0] = state->mmc_prg_bank[2] = 0xfe;   // prg_bank[2] & prg_bank[3] remain always the same in most MMC3 variants
163   state->mmc_prg_bank[1] = state->mmc_prg_bank[3] = 0xff;   // but some pirate clone mappers change them after writing certain registers
164   state->mmc3_latch = 0;
165   state->mmc3_wram_protect = 0x80;
166   state->mmc_prg_base = state->mmc_chr_base = 0;
167   state->mmc_prg_mask = prg_mask;
168   state->mmc_chr_mask = chr_mask;
169   mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
170   mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
171}
172
173// WIP code
174static int pcb_initialize( running_machine *machine, int idx )
175{
176   nes_state *state = (nes_state *)machine->driver_data;
177   int err = 0, i;
178
179   /* basic PRG config */
180   prg32(machine, 0);
181
182   /* some boards will not use this, but directly CHRROM (resp. CHRRAM) if the board only has VROM (resp. VRAM) */
183   state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
184   chr8(machine, 0, state->mmc_chr_source);
185   
186   /* Here, we init a few helpers: 4 prg banks and 16 chr banks - some mappers use them */
187   for (i = 0; i < 4; i++)
188      state->mmc_prg_bank[i] = 0;
189   for (i = 0; i < 16; i++)
190      state->mmc_vrom_bank[i] = 0;
191   for (i = 0; i < 16; i++)
192      state->mmc_extra_bank[i] = 0;
193
194   state->mmc_latch1 = 0;
195   state->mmc_latch2 = 0;
196
197   /* Finally, we init IRQ-related quantities. */
198   state->IRQ_enable = state->IRQ_enable_latch = 0;
199   state->IRQ_count = state->IRQ_count_latch = 0;
200   state->IRQ_toggle = 0;
201   
202   switch (idx)
203   {
204      /* many boards only needs PRG to point at first 32k and CHR at first 8k */
205      case STD_NROM:   // mapper 0
206      case HVC_FAMBASIC:
207      case GG_NROM:
208      case UXROM_CC:   // mapper 180
209      case STD_CNROM:   // mapper 3, 185
210      case BANDAI_PT554:
211      case TENGEN_800008:
212      case STD_BXROM:   // mapper 34
213      case STD_GXROM:   // mapper 66
214      case STD_MXROM:
215      case BANDAI_OEKAKIDS:   // mapper 96
216      case JALECO_JF11:   // mapper 140
217      case JALECO_JF13:   // mapper 86
218      case JALECO_JF19:   // mapper 92
219      case DIS_74X377:   // mapper 11
220      case DIS_74X161X138:   // mapper 38
221      case CALTRON_6IN1:   // mapper 41
222      case TXC_STRIKEWOLF:   // mapper 36
223      case UNL_STUDYNGAME:   // mapper 39
224      case RUMBLESTATION_BOARD:   // mapper 46
225      case BMC_GKB:   // mapper 58
226      case RCM_TETRISFAMILY:   // mapper 61
227      case BMC_SUPER_700IN1:   // mapper 62
228      case MAGICSERIES_MD:   // mapper 107
229      case HES_BOARD:   // mapper 113
230      case HES6IN1_BOARD:   // mapper 113
231      case SACHEN_SA72008:   // mapper 133
232      case SACHEN_TCU02:   // mapper 136
233      case SACHEN_SA72007:   // mapper 145
234      case SACHEN_TCU01:   // mapper 147
235      case SACHEN_SA009:   // mapper 160
236      case SACHEN_SA0037:   // mapper 148
237      case SACHEN_SA0036:   // mapper 149
238      case AGCI_50282:   // mapper 144
239      case KAISER_KS7058:   // mapper 171
240      case HENGEDIANZI_BOARD:   // mapper 177
241      case WAIXING_SGZLZ:   // mapper 178
242      case HENGEDIANZI_XJZB:   // mapper 179
243      case BMC_21IN1:   // mapper 201
244      case BMC_9999999IN1:   // mapper 213
245      case RCM_GS2015:   // mapper 216
246      case BMC_72IN1:   // mapper 225
247      case BMC_76IN1:   // mapper 226
248      case BMC_SUPER_42IN1:   // mapper 226
249      case ACTENT_ACT52:   // mapper 228
250      case CNE_SHLZ:   // mapper 240
251      case TXC_MXMDHTWO:   // mapper 241
252      case WAIXING_ZS:   // mapper 242
253      case WAIXING_DQ8:   // mapper 242
254      case CNE_DECATHLON:   // mapper 244
255      case UNL_CC21:
256      case BMC_VT5201:
257      case BMC_WS:
258      case UNL_EDU2K:
259         break;
260
261      /* other boards need additional initialization */
262      case STD_UXROM:   // mapper 2
263      case STD_UN1ROM:   // mapper 94
264      case STD_JXROM:      // mapper 69
265      case SUNSOFT_5B:
266      case SUNSOFT_FME7:
267      case NAMCOT_3425:   // mapper 95
268      case DIS_74X139X74:   // mapper 87
269      case DIS_74X161X161X32:   // mapper 152 & 70
270      case BANDAI_LZ93:   // mapper 16, 157
271      case BANDAI_LZ93EX:   // same + EEPROM
272      case BANDAI_DATACH:
273      case BANDAI_FCG:
274      case IREM_HOLYDIV:   // mapper 78
275      case IREM_G101:   // mapper 32
276      case IREM_H3001:   // mapper 65
277      case JALECO_SS88006:   // mapper 18
278      case JALECO_JF16:   // mapper 78
279      case JALECO_JF17:   // mapper 72
280      case KONAMI_VRC1:   // mapper 75
281      case KONAMI_VRC2:
282      case KONAMI_VRC3:   // mapper 73
283      case KONAMI_VRC4:
284      case KONAMI_VRC6:
285      case SUNSOFT_3:   // mapper 67
286      case TAITO_TC0190FMC:   // mapper 33
287      case TAITO_TC0190FMCP:   // mapper 48
288      case TAITO_X1_005:   // mapper 80
289      case TAITO_X1_005_A:   // mapper 207
290      case TAITO_X1_017:   // mapper 82
291      case NTDEC_ASDER:   // mapper 112
292      case FUTUREMEDIA_BOARD:   // mapper 117
293      case BTL_DRAGONNINJA:   // mapper 222
294      case WAIXING_SGZ:   // mapper 252
295      case UNL_T230:
296      case BMC_NTD_03:
297      case KAISER_KS7022:
298      case UNL_SHJY3:
299      case KAISER_KS7017:
300      case KAISER_KS7032:
301      case KAISER_KS202:
302         prg16_89ab(machine, 0);
303         prg16_cdef(machine, state->prg_chunks - 1);
304         break;
305
306      case STD_CPROM:   // mapper 13
307         chr4_0(machine, 0, CHRRAM);
308         chr4_4(machine, 0, CHRRAM);
309         break;
310      case STD_AXROM:   // mapper 7
311         set_nt_mirroring(machine, PPU_MIRROR_LOW);
312         break;
313      case STD_SXROM:   // mapper 1, 155
314      case STD_SOROM:
315      case STD_SXROM_A:
316      case STD_SOROM_A:
317         state->mmc1_latch = 0;
318         state->mmc1_count = 0;
319         state->mmc_reg[0] = 0x0f;
320         state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
321         state->mmc1_reg_write_enable = 1;
322         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
323         mmc1_set_chr(machine);
324         mmc1_set_prg(machine);
325         wram_bank(machine, 0, (idx == STD_SOROM) ? NES_WRAM : NES_BATTERY);
326         break;
327      case STD_PXROM:   // mapper 9
328         state->mmc_reg[0] = state->mmc_reg[2] = 0;
329         state->mmc_reg[1] = state->mmc_reg[3] = 0;
330         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
331         prg8_89(machine, 0);
332         prg8_ab(machine, (state->prg_chunks << 1) - 3);
333         prg8_cd(machine, (state->prg_chunks << 1) - 2);
334         prg8_ef(machine, (state->prg_chunks << 1) - 1);
335         break;
336      case STD_FXROM: // mapper 10
337         state->mmc_reg[0] = state->mmc_reg[2] = 0;
338         state->mmc_reg[1] = state->mmc_reg[3] = 0;
339         state->mmc_latch1 = state->mmc_latch2 = 0xfe;
340         prg16_89ab(machine, 0);
341         prg16_cdef(machine, state->prg_chunks - 1);
342         break;
343      case STD_TXROM:   // mapper 4
344      case STD_TVROM:
345      case STD_TKROM:
346      case REXSOFT_DBZ5:   // mapper 12
347      case WAIXING_TYPE_A:   // mapper 74
348      case WAIXING_TYPE_A_1:
349      case STD_TXSROM:   // mapper 118
350      case STD_TQROM:   // mapper 119
351      case WAIXING_SH2:   // mapper 165
352      case WAIXING_TYPE_B:   // mapper 191
353      case WAIXING_TYPE_C:   // mapper 192
354      case WAIXING_TYPE_D:   // mapper 194
355      case WAIXING_TYPE_E:   // mapper 195
356      case WAIXING_TYPE_H:   // mapper 245
357      case BTL_SUPERBROS11:   // mapper 196
358      case UNL_H2288:      // mapper 123
359      case UNL_KOF97:
360      case UNL_603_5052:
361      case NITRA_TDA:   // mapper 250
362         if (state->four_screen_vram)   // only TXROM and DXROM have 4-screen mirroring
363         {
364            set_nt_page(machine, 0, CART_NTRAM, 0, 1);
365            set_nt_page(machine, 1, CART_NTRAM, 1, 1);
366            set_nt_page(machine, 2, CART_NTRAM, 2, 1);
367            set_nt_page(machine, 3, CART_NTRAM, 3, 1);
368         }
369         mmc3_common_initialize(machine, 0xff, 0xff, 0);
370         break;
371      case STD_HKROM:   // MMC6 (basically the same as TxROM, but alt IRQ behaviour)
372         mmc3_common_initialize(machine, 0xff, 0xff, 1);
373         state->mmc6_reg = 0xf0;
374         state->mmc_latch2 = 0;   // this is used differently here compared to MMC3
375         break;
376      case PAL_ZZ:   // mapper 37
377         mmc3_common_initialize(machine, 0x07, 0x7f, 0);
378         break;
379      case NES_QJ:   // mapper 47
380         mmc3_common_initialize(machine, 0x0f, 0x7f, 0);
381         break;
382      case STD_EXROM:   // mapper 5
383         state->MMC5_rom_bank_mode = 3;
384         state->MMC5_vrom_bank_mode = 0;
385         state->MMC5_vram_protect = 0;
386         state->mmc5_high_chr = 0;
387         state->mmc5_vram_control = 0;
388         state->mmc5_split_scr = 0;
389         memset(state->MMC5_vrom_bank, 0, ARRAY_LENGTH(state->MMC5_vrom_bank));
390         state->mmc5_prg_mode = 3;
391         state->mmc5_last_chr_a = 1;
392         state->mmc5_prg_regs[0] = 0xfc;
393         state->mmc5_prg_regs[1] = 0xfd;
394         state->mmc5_prg_regs[2] = 0xfe;
395         state->mmc5_prg_regs[3] = 0xff;
396         memset(state->mmc5_vrom_regA, ~0, ARRAY_LENGTH(state->mmc5_vrom_regA));
397         memset(state->mmc5_vrom_regB, ~0, ARRAY_LENGTH(state->mmc5_vrom_regB));
398         prg16_89ab(machine, state->prg_chunks - 2);
399         prg16_cdef(machine, state->prg_chunks - 1);
400         break;
401      case STD_NXROM:      // mapper 68
402      case SUNSOFT_DCS:      // mapper 68
403         state->mmc_reg[0] = 0;
404         prg16_89ab(machine, 0);
405         prg16_cdef(machine, state->prg_chunks - 1);
406         break;
407      case NAMCOT_34X3:   // mapper 88
408      case STD_DXROM:   // mapper 206
409      case STD_DRROM:
410         if (state->four_screen_vram)   // only TXROM and DXROM have 4-screen mirroring
411         {
412            set_nt_page(machine, 0, CART_NTRAM, 0, 1);
413            set_nt_page(machine, 1, CART_NTRAM, 1, 1);
414            set_nt_page(machine, 2, CART_NTRAM, 2, 1);
415            set_nt_page(machine, 3, CART_NTRAM, 3, 1);
416         }
417      case NAMCOT_3453:   // mapper 154
418         prg16_89ab(machine, state->prg_chunks - 2);
419         prg16_cdef(machine, state->prg_chunks - 1);
420         break;
421      case NAMCOT_3446:   // mapper 76
422         prg8_89(machine, 0);
423         prg8_ab(machine, 1);
424         prg16_cdef(machine, state->prg_chunks - 1);
425         chr2_0(machine, 0, CHRROM);
426         chr2_2(machine, 1, CHRROM);
427         chr2_4(machine, 2, CHRROM);
428         chr2_6(machine, 3, CHRROM);
429         break;
430      case BANDAI_JUMP2:   // mapper 153
431         for (i = 0; i < 8; i++)
432            state->mmc_reg[i] = 0;
433         prg16_89ab(machine, 0);
434         prg16_cdef(machine, state->prg_chunks - 1);
435         fjump2_set_prg(machine);
436         break;
437      case BANDAI_KARAOKE:   // mapper 188
438         prg16_89ab(machine, 0);
439         prg16_cdef(machine, (state->prg_chunks - 1) ^ 0x08);
440         break;
441      case IREM_LROG017:   // mapper 77
442         chr2_2(machine, 0, CHRROM);
443         chr2_4(machine, 1, CHRROM);
444         chr2_6(machine, 2, CHRROM);
445         break;
446      case IREM_TAM_S1:   // mapper 97
447         prg16_89ab(machine, state->prg_chunks - 1);
448         prg16_cdef(machine, 0);
449         break;
450      case KONAMI_VRC7:   // mapper 85
451         prg8_89(machine, 0);
452         prg8_ab(machine, 0);
453         prg8_cd(machine, 0);
454         prg8_ef(machine, 0xff);
455         break;
456      case NAMCOT_163:   // mapper 19
457         prg16_89ab(machine, 0);
458         prg16_cdef(machine, state->prg_chunks - 1);
459         set_nt_mirroring(machine, PPU_MIRROR_VERT);
460         break;
461      case SUNSOFT_1:   // mapper 184
462      case SUNSOFT_2:   // mapper 89 & 93
463         prg16_89ab(machine, 0);
464         prg16_cdef(machine, state->prg_chunks - 1);
465         if (!state->hard_mirroring)
466            set_nt_mirroring(machine, PPU_MIRROR_LOW);
467         break;
468
469// mapper 14
470      case REXSOFT_SL1632:
471         state->mmc_extra_bank[2] = 0xfe;
472         state->mmc_extra_bank[3] = 0xff;
473         state->mmc_extra_bank[0] = state->mmc_extra_bank[1] = state->mmc_extra_bank[4] = state->mmc_extra_bank[5] = state->mmc_extra_bank[6] = 0;
474         state->mmc_extra_bank[7] = state->mmc_extra_bank[8] = state->mmc_extra_bank[9] = state->mmc_extra_bank[0xa] = state->mmc_extra_bank[0xb] = 0;
475         state->mmc_reg[0] = state->mmc_reg[1] = 0;
476         mmc3_common_initialize(machine, 0xff, 0xff, 0);
477         break;
478// mapper 15
479      case WAIXING_PS2:
480         set_nt_mirroring(machine, PPU_MIRROR_VERT);
481         break;
482
483// mapper 35
484      case UNL_SC127:
485// mapper 42
486      case BTL_MARIOBABY:
487      case BTL_AISENSHINICOL:
488         prg32(machine, 0xff);
489         break;
490
491// mapper 40
492      case BTL_SMB2A:
493         prg8_67(machine, 0xfe);
494         prg8_89(machine, 0xfc);
495         prg8_ab(machine, 0xfd);
496         prg8_cd(machine, 0xfe);
497         prg8_ef(machine, 0xff);
498         break;
499
500// mapper 43
501      case UNL_SMB2J:
502         if (state->battery)
503            memset(state->battery_ram, 0x2000, 0xff);
504         else if (state->prg_ram)
505            memset(state->wram, 0x2000, 0xff);
506         break;
507// mapper 44
508      case BMC_SUPERBIG_7IN1:
509// mapper 49
510      case BMC_SUPERHIK_4IN1:
511         mmc3_common_initialize(machine, 0x0f, 0x7f, 0);
512         break;
513// mapper 45
514      case BMC_HIK8IN1:
515         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
516         mmc3_common_initialize(machine, 0x3f, 0xff, 0);
517         break;
518
519// mapper 50
520      case BTL_SMB2B:
521         prg8_67(machine, 0x0f);
522         prg8_89(machine, 0x08);
523         prg8_ab(machine, 0x09);
524         prg8_cd(machine, 0);
525         prg8_ef(machine, 0x0b);
526         break;
527// mapper 51
528      case BMC_BALLGAMES_11IN1:
529         state->mmc_reg[0] = 0x01;
530         state->mmc_reg[1] = 0x00;
531         bmc_ball11_set_banks(machine);
532         break;
533// mapper 52
534      case BMC_MARIOPARTY_7IN1:
535         state->map52_reg_written = 0;
536         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
537         break;
538// mapper 54
539      case BMC_NOVELDIAMOND:
540         set_nt_mirroring(machine, PPU_MIRROR_VERT);
541         break;
542// mapper 57
543      case BMC_GKA:
544         prg16_89ab(machine, 0);
545         prg16_cdef(machine, 0);
546         break;
547
548// mapper 64
549      case TENGEN_800032:
550// mapper 158
551      case TENGEN_800037:
552         prg16_89ab(machine, state->prg_chunks - 1);
553         prg16_cdef(machine, state->prg_chunks - 1);
554         break;
555// mapper 71
556      case CAMERICA_BF9097:
557         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
558      case CAMERICA_BF9093:
559         prg32(machine, 0xff);
560         break;
561
562// mapper 79 (& 146)
563      case AVE_NINA06:
564         set_nt_mirroring(machine, PPU_MIRROR_HORZ);
565         break;
566
567// mapper 83
568      case CONY_BOARD:
569         state->mapper83_reg[9] = 0x0f;
570         prg8_cd(machine, 0x1e);
571         prg8_ef(machine, 0x1f);
572         break;
573
574// mapper 91
575      case UNL_MK2:
576         set_nt_mirroring(machine, PPU_MIRROR_VERT);
577         prg16_89ab(machine, state->prg_chunks - 1);
578         prg16_cdef(machine, state->prg_chunks - 1);
579         break;
580
581// mapper 104
582      case CAMERICA_GOLDENFIVE:
583         prg16_89ab(machine, 0x00);
584         prg16_cdef(machine, 0x0f);
585         break;
586// mapper 106
587      case BTL_SMB3:
588         prg8_89(machine, (state->prg_chunks << 1) - 1);
589         prg8_ab(machine, 0);
590         prg8_cd(machine, 0);
591         prg8_ef(machine, (state->prg_chunks << 1) - 1);
592         break;
593         
594// mapper 108
595      case WHIRLWIND_2706:
596         prg32(machine, 0xff);
597         break;
598         
599// mapper 114
600      case SUPERGAME_LIONKING:
601         state->map114_reg = state->map114_reg_enabled = 0;
602         mmc3_common_initialize(machine, 0xff, 0xff, 0);
603         break;
604// mapper 115
605      case KASING_BOARD:
606         state->mmc_reg[0] = 0;
607         mmc3_common_initialize(machine, 0xff, 0xff, 0);
608         break;
609// mapper 116
610      case SOMERI_SL12:
611         state->mmc_prg_base = state->mmc_chr_base = 0;
612         state->mmc_prg_mask = 0xff;
613         state->mmc_chr_mask = 0xff;
614         state->mmc_cmd1 = 2; // mode
615         state->mmc3_latch = 0;
616         state->mmc3_wram_protect = 0;
617         // MMC1 regs
618         state->mmc1_count = 0;
619         state->mmc_reg[0] = 0x0c;
620         state->mmc_reg[1] = 0x00;
621         state->mmc_reg[2] = 0x00;
622         state->mmc_reg[3] = 0x00;
623         // MMC3 regs
624         state->mmc_prg_bank[0] = 0x3c;
625         state->mmc_prg_bank[1] = 0x3d;
626         state->mmc_prg_bank[2] = 0xfe;
627         state->mmc_prg_bank[3] = 0xff;
628         state->mmc_vrom_bank[0] = 0x00;
629         state->mmc_vrom_bank[1] = 0x01;
630         state->mmc_vrom_bank[2] = 0x04;
631         state->mmc_vrom_bank[3] = 0x05;
632         state->mmc_vrom_bank[4] = 0x06;
633         state->mmc_vrom_bank[5] = 0x07;
634         // VRC2 regs
635         state->mmc_prg_bank[4] = 0x00;
636         state->mmc_prg_bank[5] = 0x01;
637         for (i = 0; i < 8; ++i)
638            state->mmc_vrom_bank[6 + i] = i;
639         someri_mode_update(machine);
640         break;
641         
642// mapper 120
643      case BTL_TOBIDASE:
644         prg32(machine, 2);
645         break;
646         
647// mapper 121
648      case KAY_PANDAPRINCE:
649         state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0;
650         mmc3_common_initialize(machine, 0xff, 0xff, 0);
651         break;
652         
653// mapper 126
654      case BMC_PJOY84:
655         mmc3_common_initialize(machine, 0xff, 0xff, 0);
656         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
657         pjoy84_set_base_mask(machine);
658         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
659         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
660         break;
661
662// mapper 132
663      case TXC_22211A:
664// mapper 172
665      case TXC_22211B:
666// mapper 173
667      case TXC_22211C:
668         state->txc_reg[0] = state->txc_reg[1] = state->txc_reg[2] = state->txc_reg[3] = 0;
669         break;
670
671// mapper 134
672      case BMC_FAMILY_4646B:
673         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
674         break;
675
676// mapper 137
677      case SACHEN_8259D:
678         chr8(machine, state->chr_chunks - 1, CHRROM);
679         set_nt_mirroring(machine, PPU_MIRROR_VERT);
680         break;
681// mapper 138
682      case SACHEN_8259B:
683// mapper 139
684      case SACHEN_8259C:
685// mapper 141
686      case SACHEN_8259A:
687// mapper 150
688      case SACHEN_74LS374:
689         set_nt_mirroring(machine, PPU_MIRROR_VERT);
690         break;
691// mapper 143
692      case SACHEN_TCA01:
693         prg16_89ab(machine, 0);
694         prg16_cdef(machine, 1);
695         break;
696
697// mapper 156
698      case OPENCORP_DAOU306:
699         prg16_89ab(machine, state->prg_chunks - 2);
700         prg16_cdef(machine, state->prg_chunks - 1);
701         set_nt_mirroring(machine, PPU_MIRROR_LOW);
702         break;
703// mapper 163
704      case NANJING_BOARD:
705         state->mmc_count = 0xff;
706         state->mmc_reg[0] = 0xff;
707         state->mmc_reg[1] = 0;
708         prg16_89ab(machine, state->prg_chunks - 2);
709         prg16_cdef(machine, state->prg_chunks - 1);
710         break;
711// mapper 164
712      case WAIXING_FFV:
713         prg16_89ab(machine, 0);
714         prg16_cdef(machine, 0x1f);
715         break;
716// mapper 166
717      case SUBOR_TYPE1:
718         state->subor_reg[0] = state->subor_reg[1] = state->subor_reg[2] = state->subor_reg[3] = 0;
719         prg16_89ab(machine, 0);
720         prg16_cdef(machine, 0x07);
721         break;
722// mapper 167
723      case SUBOR_TYPE0:
724         state->subor_reg[0] = state->subor_reg[1] = state->subor_reg[2] = state->subor_reg[3] = 0;
725         prg16_89ab(machine, 0);
726         prg16_cdef(machine, 0x20);
727         break;
728
729// mapper 176
730      case UNL_XZY:
731// mapper 182
732      case HOSENKAN_BOARD:
733         prg32(machine, (state->prg_chunks - 1) >> 1);
734         break;
735
736      case FUKUTAKE_BOARD:   // mapper 186
737         prg16_89ab(machine, 0);
738         prg16_cdef(machine, 0);
739         break;
740
741// mapper 187
742      case UNL_KOF96:
743         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
744         mmc3_common_initialize(machine, 0xff, 0xff, 0);
745         break;
746// mapper 189
747      case TXC_TW:
748         state->mmc_latch1 = 0;
749         state->mmc_latch2 = 0x80;
750         state->mmc_chr_base = 0;
751         state->mmc_chr_mask = 0xff;
752         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
753         break;
754// mapper 193
755      case NTDEC_FIGHTINGHERO:
756         prg32(machine, (state->prg_chunks - 1) >> 1);
757         set_nt_mirroring(machine, PPU_MIRROR_VERT);
758         break;
759// mapper 197
760      case UNL_SUPERFIGHTER3:
761         mmc3_common_initialize(machine, 0xff, 0xff, 0);
762         unl_sf3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
763         break;
764// mapper 198
765      case WAIXING_TYPE_F:
766         mmc3_common_initialize(machine, 0xff, 0xff, 0);
767         state->mmc_prg_bank[0] = 0x00;
768         state->mmc_prg_bank[1] = 0x01;
769         state->mmc_prg_bank[2] = 0x4e;
770         state->mmc_prg_bank[3] = 0x4f;
771         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
772         break;
773// mapper 199
774      case WAIXING_TYPE_G:
775         mmc3_common_initialize(machine, 0xff, 0xff, 0);
776         state->mmc_prg_bank[0] = 0x00;
777         state->mmc_prg_bank[1] = 0x01;
778         state->mmc_prg_bank[2] = 0x3e;
779         state->mmc_prg_bank[3] = 0x3f;
780         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
781         state->mmc_vrom_bank[0] = 0x00;
782         state->mmc_vrom_bank[1] = 0x02;
783         state->mmc_vrom_bank[2] = 0x04;
784         state->mmc_vrom_bank[3] = 0x05;
785         state->mmc_vrom_bank[4] = 0x06;
786         state->mmc_vrom_bank[5] = 0x07;
787         state->mmc_vrom_bank[6] = 0x01;
788         state->mmc_vrom_bank[7] = 0x03;
789         waixing_g_set_chr(machine, state->mmc_chr_base, state->mmc_chr_mask);
790         break;
791
792// mapper 200
793      case BMC_36IN1:
794         prg16_89ab(machine, state->prg_chunks - 1);
795         prg16_cdef(machine, state->prg_chunks - 1);
796         break;
797
798// mapper 202
799      case BMC_150IN1:
800// mapper 203
801      case BMC_35IN1:
802// mapper 204
803      case BMC_64IN1:
804// mapper 214
805      case BMC_SUPERGUN_20IN1:
806         prg16_89ab(machine, 0);
807         prg16_cdef(machine, 0);
808         break;
809// mapper 205
810      case BMC_15IN1:
811         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
812         state->mmc_prg_base = 0x10;   // this board has a diff prg_base
813         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
814         break;
815
816// mapper 208
817      case GOUDER_37017:
818         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = state->mmc_reg[4] = 0;
819         mmc3_common_initialize(machine, 0xff, 0xff, 0);
820         break;
821// mapper 212
822      case BMC_SUPERHIK_300IN1:
823         chr8(machine, 0xff, CHRROM);
824         prg32(machine, 0xff);
825         break;
826
827// mapper 215
828      case SUPERGAME_BOOGERMAN:
829         state->mmc_reg[0] = 0x00;
830         state->mmc_reg[1] = 0xff;
831         state->mmc_reg[2] = 0x04;
832         state->mmc_reg[3] = 0;
833         mmc3_common_initialize(machine, 0x1f, 0xff, 0);
834         sgame_boog_set_prg(machine);
835         mmc3_set_chr(machine, state->mmc_chr_source, state->mmc_chr_base, state->mmc_chr_mask);
836         break;
837
838// mapper 217
839      case BMC_GOLDENCARD_6IN1:
840         mmc3_common_initialize(machine, 0xff, 0xff, 0);
841         state->mmc_reg[0] = 0x00;
842         state->mmc_reg[1] = 0xff;
843         state->mmc_reg[2] = 0x03;
844         state->mmc_reg[3] = 0;
845         bmc_gc6in1_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
846         bmc_gc6in1_set_chr(machine, state->mmc_chr_source);
847         break;
848// mapper 221
849      case UNL_N625092:
850         prg16_89ab(machine, 0);
851         prg16_cdef(machine, 0);
852         break;
853
854// mapper 223?
855      case WAIXING_TYPE_I:
856         mmc3_common_initialize(machine, 0xff, 0xff, 0);
857         state->mmc3_wram_protect = 0;
858         break;
859         
860// mapper 224?
861      case WAIXING_TYPE_J:
862         mmc3_common_initialize(machine, 0xff, 0xff, 0);
863         state->mmc_prg_bank[0] = 0x01;
864         state->mmc_prg_bank[1] = 0x02;
865         state->mmc_prg_bank[2] = 0x7e;
866         state->mmc_prg_bank[3] = 0x7f;
867         mmc3_set_prg(machine, state->mmc_prg_base, state->mmc_prg_mask);
868         break;
869
870// mapper 227
871      case BMC_1200IN1:
872         prg16_89ab(machine, 0);
873         prg16_cdef(machine, 0);
874         break;
875
876// mapper 229
877      case BMC_31IN1:
878         prg16_89ab(machine, 0);
879         prg16_cdef(machine, 1);
880         set_nt_mirroring(machine, PPU_MIRROR_VERT);
881         break;
882// mapper 230
883      case BMC_22GAMES:
884         prg16_89ab(machine, 0);
885         prg16_cdef(machine, 7);
886         break;
887// mapper 231
888      case BMC_20IN1:
889         prg16_89ab(machine, 0);
890         prg16_cdef(machine, state->prg_chunks - 1);
891         set_nt_mirroring(machine, PPU_MIRROR_VERT);
892         break;
893// mapper 232
894      case CAMERICA_BF9096:
895         state->mmc_latch1 = 0x18;
896         state->mmc_latch2 = 0x00;
897         bf9096_set_prg(machine);
898         break;
899
900// mapper 243
901      case SACHEN_74LS374_A:
902         state->mmc_vrom_bank[0] = 3;
903         chr8(machine, 3, CHRROM);
904         set_nt_mirroring(machine, PPU_MIRROR_VERT);
905         break;
906
907// mapper 246
908      case CNE_FSB:
909         prg32(machine, 0xff);
910         break;
911// mapper 249
912      case WAIXING_SECURITY:
913         state->mmc_reg[0] = 0;
914         mmc3_common_initialize(machine, 0xff, 0xff, 0);
915         break;
916
917// mapper 254
918      case BTL_PIKACHUY2K:
919         state->mmc_reg[0] = 0xff;
920         mmc3_common_initialize(machine, 0xff, 0xff, 0);
921         break;
922         
923// mapper 255
924      case BMC_110IN1:
925         prg16_89ab(machine, 0);
926         prg16_cdef(machine, 1);
927         set_nt_mirroring(machine, PPU_MIRROR_VERT);
928         break;
929
930// UNIF only
931      case BMC_64IN1NR:
932         state->mmc_reg[0] = 0x80;
933         state->mmc_reg[1] = 0x43;
934         state->mmc_reg[2] = state->mmc_reg[3] = 0;
935         bmc_64in1nr_set_prg(machine);
936         set_nt_mirroring(machine, PPU_MIRROR_VERT);
937         break;
938      case BMC_190IN1:
939         prg16_89ab(machine, 0);
940         prg16_cdef(machine, 0);
941         break;
942      case BMC_A65AS:
943         prg16_89ab(machine, 0);
944         prg16_cdef(machine, 7);
945         set_nt_mirroring(machine, PPU_MIRROR_VERT);
946         break;
947      case BMC_GS2004:
948      case BMC_GS2013:
949         prg32(machine, 0xff);
950         break;
951      case BMC_S24IN1SC03:
952         state->mmc_reg[0] = 0x24;
953         state->mmc_reg[1] = 0x9f;
954         state->mmc_reg[2] = 0;
955         mmc3_common_initialize(machine, 0xff, 0xff, 0);
956         break;
957      case BMC_T262:
958         state->mmc_latch1 = 0;
959         state->mmc_latch2 = 0;
960         prg16_89ab(machine, 0);
961         prg16_cdef(machine, 7);
962         break;
963      case DREAMTECH_BOARD:
964         prg16_89ab(machine, 0);
965         prg16_cdef(machine, 8);
966         break;
967      case UNL_8237:
968         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = 0;
969         mmc3_common_initialize(machine, 0xff, 0xff, 0);
970         break;
971      case UNL_AX5705:
972         state->mmc_prg_bank[0] = 0;
973         state->mmc_prg_bank[1] = 1;
974         prg8_89(machine, state->mmc_prg_bank[0]);
975         prg8_ab(machine, state->mmc_prg_bank[1]);
976         prg8_cd(machine, 0xfe);
977         prg8_ef(machine, 0xff);
978         break;
979      case UNL_RACERMATE:
980         chr4_0(machine, 0, state->mmc_chr_source);
981         chr4_4(machine, 0, state->mmc_chr_source);
982         prg16_89ab(machine, 0);
983         prg16_cdef(machine, state->prg_chunks - 1);
984         break;
985
986      case BMC_BENSHENG_BS5:
987         state->mmc_prg_bank[0] = 0xff;
988         state->mmc_prg_bank[1] = 0xff;
989         state->mmc_prg_bank[2] = 0xff;
990         state->mmc_prg_bank[3] = 0xff;
991         bmc_bs5_update_banks(machine);
992         break;
993
994      case BMC_810544:
995         prg16_89ab(machine, 0);
996         prg16_cdef(machine, 0);
997         set_nt_mirroring(machine, PPU_MIRROR_VERT);
998         break;
999
1000      case BMC_G63IN1:
1001         bmc_gb63_update(machine);
1002         break;
1003
1004      case BMC_FK23C:
1005         state->mmc_reg[0] = 4;
1006         state->mmc_reg[1] = 0xff;
1007         state->mmc_reg[2] = state->mmc_reg[3] = 0;
1008         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
1009         mmc3_common_initialize(machine, 0xff, 0xff, 0);
1010         fk23c_set_prg(machine);
1011         fk23c_set_chr(machine);
1012         break;
1013         
1014      case BMC_FK23CA:
1015         state->mmc_reg[0] = state->mmc_reg[1] = state->mmc_reg[2] = state->mmc_reg[3] = 0;
1016         state->mmc_reg[4] = state->mmc_reg[5] = state->mmc_reg[6] = state->mmc_reg[7] = 0xff;
1017         mmc3_common_initialize(machine, 0xff, 0xff, 0);
1018         fk23c_set_prg(machine);
1019         fk23c_set_chr(machine);
1020         break;
1021
1022
1023      case FFE_MAPPER6:
1024         prg16_89ab(machine, 0);
1025         prg16_cdef(machine, 7);
1026         break;
1027      case FFE_MAPPER8:
1028         prg32(machine, 0);
1029         break;
1030      case FFE_MAPPER17:
1031         prg16_89ab(machine, 0);
1032         prg16_cdef(machine, state->prg_chunks - 1);
1033         break;
1034         
1035      case UNSUPPORTED_BOARD:
1036      default:
1037         /* Mapper not supported */
1038         err = 2;
1039         break;
1040   }
1041
1042   return err;
1043}
1044
1045156/*************************************************************
1046157
1047158 unif_mapr_setup
src/mess/machine/nes_mmc.c
r8384r8385
136136#define LOG_MMC(x) do { if (VERBOSE) logerror x; } while (0)
137137#define LOG_FDS(x) do { if (VERBOSE) logerror x; } while (0)
138138
139static int pcb_initialize( running_machine *machine, int idx );
140
141139static void ffe_irq( running_device *device, int scanline, int vblank, int blanked );
142140static WRITE8_HANDLER( mapper6_l_w );
143141static WRITE8_HANDLER( mapper6_w );
src/mess/machine/nes_mmc.h
r8384r8385
106106   UNSUPPORTED_BOARD, UNKNOWN_BOARD, NO_BOARD
107107};
108108
109//extern int MMC1_extended; /* 0 = normal MMC1 cart, 1 = 512k MMC1, 2 = 1024k MMC1 */
109// these are used to setup the proper PCB ID, for each supported type of files
110int nes_get_pcb_id(running_machine *machine, const char *feature);   // for softlist
111void unif_mapr_setup(running_machine *machine, const char *board);   // for UNIF files
112int nes_get_mmc_id(running_machine *machine, int mapper);   // for iNES files
110113
111#define MMC5_VRAM
112
114// these are used to setup handlers and callbacks necessary to the emulation (resp. at start and reset)
115void pcb_handlers_setup(running_machine *machine);
113116int nes_pcb_reset(running_machine *machine);
114117
115void pcb_handlers_setup(running_machine *machine);
116void unif_mapr_setup(running_machine *machine, const char *board);
117int nes_get_pcb_id(running_machine *machine, const char *feature);
118int nes_get_mmc_id(running_machine *machine, int mapper);
119118
120119WRITE8_HANDLER( nes_low_mapper_w );
121120READ8_HANDLER( nes_low_mapper_r );
src/mess/includes/nes.h
r8384r8385
213213   UINT32 mapper_ram_size;
214214   UINT32 mapper_bram_size;
215215
216   int format;   // 1 = iNES, 2 = UNIF
217
218216   /* system variables which don't change at run-time */
219217   UINT16 mapper;      // for iNES
220218   UINT16 pcb_id;      // for UNIF & xml

Previous 15994 Revisions Next


© 1998-2018 The MESS Team