Previous 15994 Revisions Next

r4507 Thursday 16th April, 2009 at 16:45:55 UTC by Wilbert Pol
Re-enabled nintendo.a. Marked nes drivers as GAME_NOT_WORKING.
[src/mess]mess.mak messdriv.c
[src/mess/drivers]nes.c
[src/mess/includes]nes.h
[src/mess/machine]nes.c nes_mmc.c nes_mmc.h
[src/mess/video]nes.c

src/mess/video/nes.c
r4506r4507
1313
1414int nes_vram_sprite[8]; /* Used only by mmc5 for now */
1515static int last_frame_flip = 0;
16static double nes_scanlines_per_frame;
1617
17static void ppu_nmi(running_machine *machine, int num, int *ppu_regs)
18{
19   cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
20}
21
2218static void nes_vh_reset(running_machine *machine)
2319{
24   ppu2c0x_reset( machine, 0, 1 );
25}
20   ppu2c0x_set_vidaccess_callback(devtag_get_device(machine,"ppu"), nes_ppu_vidaccess);
21   ppu2c0x_set_scanlines_per_frame(devtag_get_device(machine,"ppu"), ceil(nes_scanlines_per_frame));
2622
27static void nes_vh_start(running_machine *machine, ppu_t ppu_type, double scanlines_per_frame)
28{
29   ppu2c0x_interface ppu_interface;
30
31   last_frame_flip =  0;
32
33   memset(&ppu_interface, 0, sizeof(ppu_interface));
34   ppu_interface.type            = ppu_type;
35   ppu_interface.num            = 1;
36   ppu_interface.vrom_region[0]   = nes.chr_chunks ? "gfx1" : NULL;
37   ppu_interface.mirroring[0]      = PPU_MIRROR_NONE;
38   ppu_interface.nmi_handler[0]   = ppu_nmi;
39
40   ppu2c0x_init(machine, &ppu_interface);
41   ppu2c0x_set_vidaccess_callback(0, nes_ppu_vidaccess);
42   ppu2c0x_set_scanlines_per_frame(0, ceil(scanlines_per_frame));
43
4423   if (nes.four_screen_vram)
4524   {
46      ppu2c0x_set_mirroring(0, PPU_MIRROR_4SCREEN);
25      ppu2c0x_set_mirroring(devtag_get_device(machine,"ppu"), PPU_MIRROR_4SCREEN);
4726   }
4827   else
4928   {
5029      switch(nes.hard_mirroring)
5130      {
5231         case 0:
53            ppu2c0x_set_mirroring(0, PPU_MIRROR_HORZ);
32            ppu2c0x_set_mirroring(devtag_get_device(machine,"ppu"), PPU_MIRROR_HORZ);
5433            break;
5534         case 1:
56            ppu2c0x_set_mirroring(0, PPU_MIRROR_VERT);
35            ppu2c0x_set_mirroring(devtag_get_device(machine,"ppu"), PPU_MIRROR_VERT);
5736            break;
37         default:
38            ppu2c0x_set_mirroring(devtag_get_device(machine,"ppu"), PPU_MIRROR_NONE );
39            break;
5840      }
5941   }
42}
6043
61   add_reset_callback(machine, nes_vh_reset);
44static void nes_vh_start(running_machine *machine, double scanlines_per_frame)
45{
46   last_frame_flip =  0;
47   nes_scanlines_per_frame = scanlines_per_frame;
6248
63   /* Reset the mapper variables. Will also mark the char-gen ram as dirty */
64   mapper_reset(machine, nes.mapper);
49   add_reset_callback(machine, nes_vh_reset);
6550}
6651
6752
6853
6954VIDEO_START( nes_ntsc )
7055{
71   nes_vh_start(machine, PPU_2C02, PPU_NTSC_SCANLINES_PER_FRAME);
56   nes_vh_start(machine, PPU_NTSC_SCANLINES_PER_FRAME);
7257}
7358
7459VIDEO_START( nes_pal )
7560{
76   nes_vh_start(machine, PPU_2C07, PPU_PAL_SCANLINES_PER_FRAME);
61   nes_vh_start(machine, PPU_PAL_SCANLINES_PER_FRAME);
7762}
7863
7964PALETTE_INIT( nes )
r4506r4507
9075
9176VIDEO_UPDATE( nes )
9277{
78   nes_state *state = screen->machine->driver_data;
79
9380   /* render the ppu */
94   ppu2c0x_render( 0, bitmap, 0, 0, 0, 0 );
81   ppu2c0x_render( state->ppu, bitmap, 0, 0, 0, 0 );
9582
9683   /* if this is a disk system game, check for the flip-disk key */
9784   if (nes.mapper == 20)
src/mess/includes/nes.h
r4506r4507
9797READ8_HANDLER( nes_IN0_r );
9898READ8_HANDLER( nes_IN1_r );
9999
100int nes_ppu_vidaccess( running_machine *machine, int num, int address, int data );
100int nes_ppu_vidaccess( const device_config *device, int address, int data );
101101
102102void nes_partialhash(char *dest, const unsigned char *data,
103103   unsigned long length, unsigned int functions);
src/mess/messdriv.c
r4506r4507
6262//   DRIVER( falcon40 )   /* Atari Falcon040 (prototype)                  */
6363
6464   /* NINTENDO */
65//0130u4   DRIVER( nes )      /* Nintendo Entertainment System               */
66//0130u4   DRIVER( nespal )   /* Nintendo Entertainment System               */
67//0130u4   DRIVER( famicom )
68//0130u4   DRIVER( famitwin )   /* Sharp Famicom Twin System                  */
69//0130u4   DRIVER( gameboy )   /* Nintendo Game Boy Handheld                  */
70//0130u4   DRIVER( supergb )   /* Nintendo Super Game Boy SNES Cartridge         */
71//0130u4   DRIVER( gbpocket )   /* Nintendo Game Boy Pocket Handheld            */
72//0130u4   DRIVER( gbcolor )   /* Nintendo Game Boy Color Handheld               */
73//0130u4   DRIVER( snes )      /* Nintendo Super Nintendo NTSC                  */
74//0130u4   DRIVER( snespal )   /* Nintendo Super Nintendo PAL                  */
75//0130u4   DRIVER( n64 )      /* Nintendo N64                              */
76//0130u4   DRIVER( pokemini )   /* Nintendo Pokemon Mini                     */
65   DRIVER( nes )      /* Nintendo Entertainment System               */
66   DRIVER( nespal )   /* Nintendo Entertainment System               */
67   DRIVER( famicom )
68   DRIVER( famitwin )   /* Sharp Famicom Twin System                  */
69   DRIVER( gameboy )   /* Nintendo Game Boy Handheld                  */
70   DRIVER( supergb )   /* Nintendo Super Game Boy SNES Cartridge         */
71   DRIVER( gbpocket )   /* Nintendo Game Boy Pocket Handheld            */
72   DRIVER( gbcolor )   /* Nintendo Game Boy Color Handheld               */
73   DRIVER( snes )      /* Nintendo Super Nintendo NTSC                  */
74   DRIVER( snespal )   /* Nintendo Super Nintendo PAL                  */
75   DRIVER( n64 )      /* Nintendo N64                              */
76   DRIVER( pokemini )   /* Nintendo Pokemon Mini                     */
7777
78//0130u4   DRIVER( megaduck )   /* Megaduck                                 */
78   DRIVER( megaduck )   /* Megaduck                                 */
7979
8080   /* SEGA */
8181   DRIVER( sg1000 )   /* Sega SG-1000 (Japan)                        */
src/mess/machine/nes.c
r4506r4507
7272
7373static void init_nes_core (running_machine *machine)
7474{
75   nes_state *state = machine->driver_data;
7675   const address_space *space = cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM );
7776
78   state->ppu = devtag_get_device(machine, "ppu");
79   state->sound = devtag_get_device(machine, "nessound");
80   state->cart = devtag_get_device(machine, "cart");
81
8277   /* We set these here in case they weren't set in the cart loader */
8378   nes.rom = memory_region(machine, "maincpu");
8479   nes.vrom = memory_region(machine, "gfx1");
r4506r4507
168163   memcpy (nes_battery_ram, battery_data, BATTERY_SIZE);
169164}
170165
171int nes_ppu_vidaccess( running_machine *machine, int num, int address, int data )
166int nes_ppu_vidaccess( const device_config *device, int address, int data )
172167{
173168   /* TODO: this is a bit of a hack, needed to get Argus, ASO, etc to work */
174169   /* but, B-Wings, submath (j) seem to use this location differently... */
r4506r4507
183178
184179MACHINE_RESET( nes )
185180{
181   nes_state *state = machine->driver_data;
182
183   state->ppu = devtag_get_device(machine, "ppu");
184   state->sound = devtag_get_device(machine, "nessound");
185   state->cart = devtag_get_device(machine, "cart");
186
186187   /* Some carts have extra RAM and require it on at startup, e.g. Metroid */
187188   nes.mid_ram_enable = 1;
188189
r4506r4507
192193   /* Reset the serial input ports */
193194   in_0.shift = 0;
194195   in_1.shift = 0;
196
197   cputag_reset( machine, "maincpu" );
195198}
196199
197200MACHINE_START( nes )
r4506r4507
211214
212215 READ8_HANDLER ( nes_IN0_r )
213216{
217   nes_state *state = space->machine->driver_data;
214218   int ret;
215219
216220   /* Some games expect bit 6 to be set because the last entry on the data bus shows up */
r4506r4507
227231      UINT32 pix, color_base;
228232
229233      /* get the pixel at the gun position */
230      pix = ppu2c0x_get_pixel( 0, x, y );
234      pix = ppu2c0x_get_pixel( state->ppu, x, y );
231235
232236      /* get the color base from the ppu */
233      color_base = ppu2c0x_get_colorbase( 0 );
237      color_base = ppu2c0x_get_colorbase( state->ppu );
234238
235239      /* look at the screen and see if the cursor is over a bright pixel */
236240      if ( ( pix == color_base + 0x20 ) || ( pix == color_base + 0x30 ) ||
r4506r4507
254258
255259 READ8_HANDLER ( nes_IN1_r )
256260{
261   nes_state *state = space->machine->driver_data;
257262   int ret;
258263
259264   /* Some games expect bit 6 to be set because the last entry on the data bus shows up */
r4506r4507
271276      UINT32 pix, color_base;
272277
273278      /* get the pixel at the gun position */
274      pix = ppu2c0x_get_pixel( 0, x, y );
279      pix = ppu2c0x_get_pixel( state->ppu, x, y );
275280
276281      /* get the color base from the ppu */
277      color_base = ppu2c0x_get_colorbase( 0 );
282      color_base = ppu2c0x_get_colorbase( state->ppu );
278283
279284      /* look at the screen and see if the cursor is over a bright pixel */
280285      if ( ( pix == color_base + 0x20 ) || ( pix == color_base + 0x30 ) ||
src/mess/machine/nes_mmc.c
r4506r4507
5050write8_space_func mmc_write_mid;
5151read8_space_func mmc_read_mid;
5252write8_space_func mmc_write;
53/*void (*ppu_latch)(offs_t offset);*/
5453
5554static int vrom_bank[16];
5655static int mult1, mult2;
r4506r4507
13901389}
13911390
13921391
1393static void mapper9_latch (running_machine *machine, offs_t offset)
1392static void mapper9_latch (const device_config *device, offs_t offset)
13941393{
13951394   if ((offset & 0x3ff0) == 0x0fd0)
13961395   {
13971396      logerror ("mapper9 vrom latch switch (bank 0 low): %02x\n", MMC2_bank0);
13981397      MMC2_bank0_latch = 0xfd;
1399      chr4_0 (machine, MMC2_bank0);
1398      chr4_0 (device->machine, MMC2_bank0);
14001399   }
14011400   else if ((offset & 0x3ff0) == 0x0fe0)
14021401   {
14031402      logerror ("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank0_hi);
14041403      MMC2_bank0_latch = 0xfe;
1405      chr4_0 (machine, MMC2_bank0_hi);
1404      chr4_0 (device->machine, MMC2_bank0_hi);
14061405   }
14071406   else if ((offset & 0x3ff0) == 0x1fd0)
14081407   {
14091408      logerror ("mapper9 vrom latch switch (bank 1 low): %02x\n", MMC2_bank1);
14101409      MMC2_bank1_latch = 0xfd;
1411      chr4_4 (machine, MMC2_bank1);
1410      chr4_4 (device->machine, MMC2_bank1);
14121411   }
14131412   else if ((offset & 0x3ff0) == 0x1fe0)
14141413   {
14151414      logerror ("mapper9 vrom latch switch (bank 0 high): %02x\n", MMC2_bank1_hi);
14161415      MMC2_bank1_latch = 0xfe;
1417      chr4_4 (machine, MMC2_bank1_hi);
1416      chr4_4 (device->machine, MMC2_bank1_hi);
14181417   }
14191418}
14201419
r4506r4507
14651464}
14661465
14671466
1468static void mapper10_latch (running_machine *machine, offs_t offset)
1467static void mapper10_latch (const device_config *device, offs_t offset)
14691468{
14701469   if ((offset & 0x3ff0) == 0x0fd0)
14711470   {
14721471      logerror ("mapper10 vrom latch switch (bank 0 low): %02x\n", MMC2_bank0);
14731472      MMC2_bank0_latch = 0xfd;
1474      chr4_0 (machine, MMC2_bank0);
1473      chr4_0 (device->machine, MMC2_bank0);
14751474   }
14761475   else if ((offset & 0x3ff0) == 0x0fe0)
14771476   {
14781477      logerror ("mapper10 vrom latch switch (bank 0 high): %02x\n", MMC2_bank0_hi);
14791478      MMC2_bank0_latch = 0xfe;
1480      chr4_0 (machine, MMC2_bank0_hi);
1479      chr4_0 (device->machine, MMC2_bank0_hi);
14811480   }
14821481   else if ((offset & 0x3ff0) == 0x1fd0)
14831482   {
14841483      logerror ("mapper10 vrom latch switch (bank 1 low): %02x\n", MMC2_bank1);
14851484      MMC2_bank1_latch = 0xfd;
1486      chr4_4 (machine, MMC2_bank1);
1485      chr4_4 (device->machine, MMC2_bank1);
14871486   }
14881487   else if ((offset & 0x3ff0) == 0x1fe0)
14891488   {
14901489      logerror ("mapper10 vrom latch switch (bank 0 high): %02x\n", MMC2_bank1_hi);
14911490      MMC2_bank1_latch = 0xfe;
1492      chr4_4 (machine, MMC2_bank1_hi);
1491      chr4_4 (device->machine, MMC2_bank1_hi);
14931492   }
14941493}
14951494
src/mess/machine/nes_mmc.h
r4506r4507
99   read8_space_func mmc_read_low; /* $4100-$5fff read routine */
1010   write8_space_func mmc_write_mid; /* $6000-$7fff write routine */
1111   write8_space_func mmc_write; /* $8000-$ffff write routine */
12   void (*ppu_latch)(running_machine *machine, offs_t offset);
12   void (*ppu_latch)(const device_config *device, offs_t offset);
1313   ppu2c0x_scanline_cb      mmc_scanline;
1414   ppu2c0x_hblank_cb      mmc_hblank;
1515} mmc;
src/mess/mess.mak
r4506r4507
302302   $(MESSOBJ)/nascom1.a \
303303   $(MESSOBJ)/nec.a \
304304   $(MESSOBJ)/necpc.a \
305   $(MESSOBJ)/nintendo.a \
305306   $(MESSOBJ)/nokia.a \
306307   $(MESSOBJ)/ondra.a \
307308   $(MESSOBJ)/orion.a \
r4506r4507
357358   $(MESSOBJ)/z80ne.a \
358359   $(MESSOBJ)/shared.a \
359360
360#   $(MESSOBJ)/nintendo.a \
361361
362362
363363
src/mess/drivers/nes.c
r4506r4507
3636
3737static WRITE8_HANDLER(nes_vh_sprite_dma_w)
3838{
39   ppu2c0x_spriteram_dma(space, 0, data);
39   nes_state *state = space->machine->driver_data;
40   ppu2c0x_spriteram_dma(space, state->ppu, data);
4041}
4142
4243static ADDRESS_MAP_START( nes_map, ADDRESS_SPACE_PROGRAM, 8 )
4344   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_MIRROR(0x1800)               /* RAM */
44   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(ppu2c0x_0_r, ppu2c0x_0_w)      /* PPU registers */
45   AM_RANGE(0x2000, 0x3fff) AM_DEVREADWRITE("ppu", ppu2c0x_r, ppu2c0x_w)      /* PPU registers */
4546   AM_RANGE(0x4000, 0x4013) AM_DEVREADWRITE("nessound", nes_psg_r, nes_psg_w)      /* PSG primary registers */
4647   AM_RANGE(0x4014, 0x4014) AM_WRITE(nes_vh_sprite_dma_w)            /* stupid address space hole */
4748   AM_RANGE(0x4015, 0x4015) AM_DEVREADWRITE("nessound", psg_4015_r, psg_4015_w)      /* PSG status / first control register */
r4506r4507
213214   ROM_FILL( 0x0000, 0x10000, 0x00 )
214215ROM_END
215216
217
218static void ppu_nmi(const device_config *device, int *ppu_regs)
219{
220   cpu_set_input_line(device->machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE);
221}
222
223
224static ppu2c0x_interface nes_ppu_interface =
225{
226   NULL/*"gfx1"*/,
227   0,
228   0,
229   PPU_MIRROR_NONE,
230   ppu_nmi,
231   0
232};
233
234
216235static MACHINE_DRIVER_START( nes )
217236   /* basic machine hardware */
218237   MDRV_CPU_ADD("maincpu", N2A03, NTSC_CLOCK)
r4506r4507
225244   // cycles for the actual vblank period.
226245   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((113.66/(NTSC_CLOCK/1000000)) * (PPU_VBLANK_LAST_SCANLINE_NTSC-PPU_VBLANK_FIRST_SCANLINE+1+2)))
227246
247   MDRV_DRIVER_DATA( nes_state )
248
228249   MDRV_MACHINE_START( nes )
229250   MDRV_MACHINE_RESET( nes )
230251
r4506r4507
237258
238259   MDRV_PALETTE_LENGTH(4*16*8)
239260
261   MDRV_PPU2C02_ADD( "ppu", nes_ppu_interface )
262
240263    /* sound hardware */
241264   MDRV_SPEAKER_STANDARD_MONO("mono")
242265   MDRV_SOUND_ADD("nessound", NES, NTSC_CLOCK)
r4506r4507
256279   /* basic machine hardware */
257280   MDRV_CPU_REPLACE("maincpu", N2A03, PAL_CLOCK)
258281
282   MDRV_DEVICE_REMOVE( "ppu" )
283   MDRV_PPU2C07_ADD( "ppu", nes_ppu_interface )
284
259285   /* video hardware */
260286   MDRV_SCREEN_MODIFY("screen")
261287   MDRV_SCREEN_REFRESH_RATE(53.355)
r4506r4507
311337***************************************************************************/
312338
313339/*     YEAR  NAME      PARENT    COMPAT MACHINE   INPUT     INIT      CONFIG    COMPANY   FULLNAME */
314CONS( 1983, famicom,   0,        0,      famicom,  famicom,  0,         famicom,   "Nintendo",   "Famicom" , 0)
315CONS( 1986, famitwin,  famicom,  0,      famicom,  famicom,  0,         famicom,   "Sharp",   "Famicom Twin" , 0)
316CONS( 1985, nes,       0,        0,      nes,      nes,      0,        0,      "Nintendo",   "Nintendo Entertainment System (NTSC)" , 0)
317CONS( 1987, nespal,    nes,      0,      nespal,   nes,      0,         0,      "Nintendo",   "Nintendo Entertainment System (PAL)" , 0)
340CONS( 1983, famicom,   0,        0,      famicom,  famicom,  0,         famicom,   "Nintendo",   "Famicom" , GAME_NOT_WORKING)
341CONS( 1986, famitwin,  famicom,  0,      famicom,  famicom,  0,         famicom,   "Sharp",   "Famicom Twin" , GAME_NOT_WORKING)
342CONS( 1985, nes,       0,        0,      nes,      nes,      0,        0,      "Nintendo",   "Nintendo Entertainment System (NTSC)" , GAME_NOT_WORKING)
343CONS( 1987, nespal,    nes,      0,      nespal,   nes,      0,         0,      "Nintendo",   "Nintendo Entertainment System (PAL)" , GAME_NOT_WORKING)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team