Previous 15994 Revisions Next

r8312 Friday 25th June, 2010 at 08:34:43 UTC by Fabio Priuli
[NES] separating pcb-based emulation from the mapper-based code (part 1)
[src/mess/machine]nes_ines.c nes_mmc.c nes_pcb.c nes_unif.c

src/mess/machine/nes_pcb.c
r8311r8312
33003300 
33013301 *************************************************************/
33023302
3303#if 0
33043303static void vrc4_set_prg( running_machine *machine )
33053304{
33063305   nes_state *state = (nes_state *)machine->driver_data;
r8311r8312
33273326      cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
33283327   }
33293328}
3330#endif
33313329
33323330static WRITE8_HANDLER( konami_vrc4_w )
33333331{
r8311r8312
34983496 
34993497 *************************************************************/
35003498
3501#if 0
35023499static WRITE8_HANDLER( konami_vrc7_w )
35033500{
35043501   nes_state *state = (nes_state *)space->machine->driver_data;
r8311r8312
35713568   }
35723569}
35733570
3574#endif
3575
35763571/*************************************************************
35773572 
35783573 Namcot-163 board emulation
r8311r8312
57665761 
57675762 *************************************************************/
57685763
5769#if 0
57705764static void sachen_set_mirror( running_machine *machine, UINT8 nt ) // used by mappers 137, 138, 139, 141
57715765{
57725766   switch (nt)
r8311r8312
57895783         break;
57905784   }
57915785}
5792#endif
57935786
57945787static WRITE8_HANDLER( sachen_74x374_l_w )
57955788{
r8311r8312
69706963 
69716964 *************************************************************/
69726965
6973#if 0
69746966/* MIRROR_LOW and MIRROR_HIGH are swapped! */
69756967static void waixing_set_mirror( running_machine *machine, UINT8 nt )
69766968{
r8311r8312
69916983         break;
69926984   }
69936985}
6994#endif
69956986
69966987static void waixing_a_set_chr( running_machine *machine, int chr_base, int chr_mask )
69976988{
r8311r8312
82548245
82558246static WRITE8_HANDLER( unl_t230_w )
82568247{
8248   nes_state *state = (nes_state *)space->machine->driver_data;
8249   UINT8 bank;
82578250   LOG_MMC(("unl_t230_w offset: %04x, data: %02x\n", offset, data));
82588251   
8259   switch (offset & 0x7007)
8252   switch (offset & 0x700c)
82608253   {
82618254      case 0x0000:
82628255         break;
82638256      case 0x2000:
8264         data = (data << 1) & 0x1f;
8265         prg8_89(space->machine, data);
8266         prg8_ab(space->machine, data | 0x01);
8257         prg16_89ab(space->machine, data);
82678258         break;
8259
8260      // the part below works like VRC-2. how was the original board wired up?
8261      // was there a VRC2? if so, we can use VRC-2 and add proper pin settings to xml!
8262      case 0x1000:
8263      case 0x1004:
8264      case 0x1008:
8265      case 0x100c:
8266         switch (data & 0x03)
8267         {
8268         case 0x00: set_nt_mirroring(space->machine, PPU_MIRROR_VERT); break;
8269         case 0x01: set_nt_mirroring(space->machine, PPU_MIRROR_HORZ); break;
8270         case 0x02: set_nt_mirroring(space->machine, PPU_MIRROR_LOW); break;
8271         case 0x03: set_nt_mirroring(space->machine, PPU_MIRROR_HIGH); break;
8272         }
8273         break;
8274
8275      case 0x3000:
8276      case 0x3004:
8277      case 0x3008:
8278      case 0x300c:
8279      case 0x4000:
8280      case 0x4004:
8281      case 0x4008:
8282      case 0x400c:
8283      case 0x5000:
8284      case 0x5004:
8285      case 0x5008:
8286      case 0x500c:
8287      case 0x6000:
8288      case 0x6004:
8289      case 0x6008:
8290      case 0x600c:
8291         bank = ((offset & 0x7000) - 0x3000) / 0x0800 + ((offset & 0x0008) >> 2);
8292         if (offset & 0x0004)
8293            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0x0f) | (data << 4);
8294         else
8295            state->mmc_vrom_bank[bank] = (state->mmc_vrom_bank[bank] & 0xf0) | (data & 0x0f);
82688296         
8297         chr1_x(space->machine, bank, state->mmc_vrom_bank[bank], state->mmc_chr_source);
8298         break;
8299      case 0x7000:
8300         state->IRQ_count_latch &= ~0x0f;
8301         state->IRQ_count_latch |= data & 0x0f;
8302         break;
8303      case 0x7004:
8304         state->IRQ_count_latch &= ~0xf0;
8305         state->IRQ_count_latch |= (data << 4) & 0xf0;
8306         break;
8307      case 0x7008:
8308         state->IRQ_mode = data & 0x04;   // currently not implemented: 0 = prescaler mode / 1 = CPU mode
8309         state->IRQ_enable = data & 0x02;
8310         state->IRQ_enable_latch = data & 0x01;
8311         if (data & 0x02)
8312            state->IRQ_count = state->IRQ_count_latch;
8313         break;
8314         
82698315      default:
8270         konami_vrc2b_w(space, offset, data);
8316         logerror("unl_t230_w uncaught offset: %04x value: %02x\n", offset, data);
82718317         break;
82728318   }
82738319}
src/mess/machine/nes_unif.c
r8311r8312
239239      case WAIXING_TYPE_E:   // mapper 195
240240      case WAIXING_TYPE_H:   // mapper 245
241241      case BTL_SUPERBROS11:   // mapper 196
242      case UNL_KOF97:
242243      case NITRA_TDA:   // mapper 250
243244         if (state->four_screen_vram)   // only TXROM and DXROM have 4-screen mirroring
244245         {
r8311r8312
573574         chr8(machine, 0, CHRROM);
574575         break;
575576      case BTL_SMB2B:
576         mapper_initialize(machine, 50);
577         prg8_67(machine, 0x0f);
578         prg8_89(machine, 0x08);
579         prg8_ab(machine, 0x09);
580         prg8_cd(machine, 0);
581         prg8_ef(machine, 0x0b);
577582         break;
578583// mapper 51
579584      case BMC_BALLGAMES_11IN1:
r8311r8312
12371242         prg32(machine, 0);
12381243         chr8(machine, 0, CHRROM);
12391244         break;
1240      case UNL_KOF97:
1241         mapper_initialize(machine, 4);
1242         break;
12431245      case UNL_T230:
12441246         state->mmc_chr_source = state->chr_chunks ? CHRROM : CHRRAM;
12451247         prg16_89ab(machine, 0);
src/mess/machine/nes_mmc.c
r8311r8312
681681    MIRROR_HIGH and MIRROR_LOW compared to the above) and Sachen games use sachen_set_mirror (which has
682682    a slightly different MIRROR_HIGH, with page 0 set to 0) */
683683
684/*************************************************************
685684
686    Support for .nes Files
687
688*************************************************************/
689
690/* Include emulation of iNES Mappers for .nes files */
691#include "machine/nes_ines.c"
692
693
694685/*************************************************************
695686 
696687 Support for xml list
r8311r8312
711702#include "machine/nes_unif.c"
712703
713704
705/*************************************************************
706 
707 Support for .nes Files
708 
709 *************************************************************/
710
711/* Include emulation of iNES Mappers for .nes files */
712#include "machine/nes_ines.c"
713
src/mess/machine/nes_ines.c
r8311r8312
20362036
20372037*************************************************************/
20382038
2039static void vrc4_set_prg( running_machine *machine )
2039static void vrc4a_set_prg( running_machine *machine )
20402040{
20412041   nes_state *state = (nes_state *)machine->driver_data;
20422042   if (state->mmc_cmd1 & 0x02)
r8311r8312
20512051   }
20522052}
20532053
2054static void konami_irq( running_device *device, int scanline, int vblank, int blanked )
2055{
2056   nes_state *state = (nes_state *)device->machine->driver_data;
2057   /* Increment & check the IRQ scanline counter */
2058   if (state->IRQ_enable && (++state->IRQ_count == 0x100))
2059   {
2060      state->IRQ_count = state->IRQ_count_latch;
2061      state->IRQ_enable = state->IRQ_enable_latch;
2062      cpu_set_input_line(state->maincpu, M6502_IRQ_LINE, HOLD_LINE);
2063   }
2064}
2065
20662054static WRITE8_HANDLER( konami_vrc4a_w )
20672055{
20682056   nes_state *state = (nes_state *)space->machine->driver_data;
r8311r8312
20782066      case 0x0080:
20792067      case 0x00c0:
20802068         state->mmc_prg_bank[0] = data;
2081         vrc4_set_prg(space->machine);
2069         vrc4a_set_prg(space->machine);
20822070         break;
20832071
20842072      case 0x1000:
r8311r8312
20982086      case 0x1080:
20992087      case 0x10c0:
21002088         state->mmc_cmd1 = data & 0x02;
2101         vrc4_set_prg(space->machine);
2089         vrc4a_set_prg(space->machine);
21022090         break;
21032091
21042092      case 0x2000:
r8311r8312
22282216      case 0x0008:
22292217      case 0x000c:
22302218         state->mmc_prg_bank[0] = data;
2231         vrc4_set_prg(space->machine);
2219         vrc4a_set_prg(space->machine);
22322220         break;
22332221
22342222      case 0x1000:
r8311r8312
22482236      case 0x1004:
22492237      case 0x100c:
22502238         state->mmc_cmd1 = data & 0x02;
2251         vrc4_set_prg(space->machine);
2239         vrc4a_set_prg(space->machine);
22522240         break;
22532241
22542242      case 0x2000:
r8311r8312
45264514
45274515*************************************************************/
45284516
4529/* MIRROR_LOW and MIRROR_HIGH are swapped! */
4530static void waixing_set_mirror( running_machine *machine, UINT8 nt )
4531{
4532   switch (nt)
4533   {
4534   case 0:
4535   case 1:
4536      set_nt_mirroring(machine, nt ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
4537      break;
4538   case 2:
4539      set_nt_mirroring(machine, PPU_MIRROR_LOW);
4540      break;
4541   case 3:
4542      set_nt_mirroring(machine, PPU_MIRROR_HIGH);
4543      break;
4544   default:
4545      LOG_MMC(("Mapper set NT to invalid value %02x", nt));
4546      break;
4547   }
4548}
4549
45504517static void mapper74_set_chr( running_machine *machine, int chr_base, int chr_mask )
45514518{
45524519   nes_state *state = (nes_state *)machine->driver_data;
r8311r8312
50465013
50475014*************************************************************/
50485015
5049static WRITE8_HANDLER( konami_vrc7_w )
5016static WRITE8_HANDLER( mapper85_w )
50505017{
50515018   nes_state *state = (nes_state *)space->machine->driver_data;
50525019   UINT8 bank;
r8311r8312
66206587
66216588*************************************************************/
66226589
6623static void sachen_set_mirror( running_machine *machine, UINT8 nt ) // used by mappers 137, 138, 139, 141
6624{
6625   switch (nt)
6626   {
6627   case 0:
6628   case 1:
6629      set_nt_mirroring(machine, nt ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
6630      break;
6631   case 2:
6632      set_nt_page(machine, 0, CIRAM, 0, 1);
6633      set_nt_page(machine, 1, CIRAM, 1, 1);
6634      set_nt_page(machine, 2, CIRAM, 1, 1);
6635      set_nt_page(machine, 3, CIRAM, 1, 1);
6636      break;
6637   case 3:
6638      set_nt_mirroring(machine, PPU_MIRROR_LOW);
6639      break;
6640   default:
6641      LOG_MMC(("Mapper set NT to invalid value %02x", nt));
6642      break;
6643   }
6644}
6645
66466590static WRITE8_HANDLER( mapper137_l_w )
66476591{
66486592   nes_state *state = (nes_state *)space->machine->driver_data;
r8311r8312
1091510859   { 82, "Taito X1-017",              NULL, NULL, mapper82_m_w, NULL, NULL, NULL, NULL },
1091610860   { 83, "Cony",                      mapper83_l_w, mapper83_l_r, NULL, mapper83_w, NULL, NULL, NULL },
1091710861   { 84, "Pasofami hacked images?",   NULL, NULL, NULL, NULL, NULL, NULL, NULL },
10918   { 85, "Konami VRC 7",              NULL, NULL, NULL, konami_vrc7_w, NULL, NULL, konami_irq },
10862   { 85, "Konami VRC 7",              NULL, NULL, NULL, mapper85_w, NULL, NULL, konami_irq },
1091910863   { 86, "Jaleco JF13",               NULL, NULL, mapper86_m_w, NULL, NULL, NULL, NULL },
1092010864   { 87, "74139/74",                  NULL, NULL, mapper87_m_w, NULL, NULL, NULL, NULL },
1092110865   { 88, "Namcot 34x3",               NULL, NULL, NULL, mapper88_w, NULL, NULL, NULL },

Previous 15994 Revisions Next


© 1998-2018 The MESS Team