Previous 15994 Revisions Next

r5334 Saturday 1st August, 2009 at 12:14:38 UTC by Fabio Priuli
[NES] Cleaned up PPU interface and struct. Sync'd MAME files as well.
[src/mame/drivers]cham24.c multigam.c
[src/mame/video]playch10.c ppu2c0x.c ppu2c0x.h vsnes.c
[src/mess/drivers]nes.c

src/mame/video/vsnes.c
r5333r5334
2727/* our ppu interface                                            */
2828const ppu2c0x_interface vsnes_ppu_interface_1 =
2929{
30   "gfx1",            /* vrom gfx region */
3130   0,               /* gfxlayout num */
3231   0,               /* color base */
3332   PPU_MIRROR_NONE,   /* mirroring */
r5333r5334
3736/* our ppu interface for dual games                             */
3837const ppu2c0x_interface vsnes_ppu_interface_2 =
3938{
40   "gfx2",            /* vrom gfx region */
4139   1,               /* gfxlayout num */
4240   64,               /* color base */
4341   PPU_MIRROR_NONE,   /* mirroring */
src/mame/video/playch10.c
r5333r5334
6969
7070const ppu2c0x_interface playch10_ppu_interface =
7171{
72   "gfx2",            /* vrom gfx region */
7372   1,               /* gfxlayout num */
7473   256,            /* color base */
7574   PPU_MIRROR_NONE,   /* mirroring */
76   ppu_irq,         /* irq */
77   0               /* vram */
75   ppu_irq            /* irq */
7876};
7977
8078const ppu2c0x_interface playch10_ppu_interface_hboard =
8179{
82   "gfx2",            /* vrom gfx region */
8380   1,               /* gfxlayout num */
8481   256,            /* color base */
8582   PPU_MIRROR_NONE,   /* mirroring */
86   ppu_irq,         /* irq */
87   1               /* vram */
83   ppu_irq            /* irq */
8884};
8985
9086static TILE_GET_INFO( get_bg_tile_info )
src/mame/video/ppu2c0x.c
r5333r5334
8080typedef struct
8181{
8282   bitmap_t            *bitmap;            /* target bitmap */
83   UINT8               *videomem;            /* video mem */
84   UINT8               *videoram;            /* video ram */
8583   UINT8               *spriteram;            /* sprite ram */
8684   pen_t               *colortable;         /* color table modified at run time */
8785   pen_t               *colortable_mono;      /* monochromatic color table modified at run time */
r5333r5334
9290   ppu2c0x_scanline_cb      scanline_callback_proc;   /* optional scanline callback */
9391   ppu2c0x_hblank_cb      hblank_callback_proc;   /* optional hblank callback */
9492   ppu2c0x_vidaccess_cb   vidaccess_callback_proc;/* optional video access callback */
95   int                  has_videorom;         /* whether we access a video rom or not */
96   int                  videorom_banks;         /* number of banks in the videorom (if available) */
97   int                  has_videoram;
98   int                  videoram_banks_indices[0x2000/VIDEOMEM_PAGE_SIZE];
9993   int                  regs[PPU_MAX_REG];      /* registers */
10094   int                  refresh_data;         /* refresh-related */
10195   int                  refresh_latch;         /* refresh-related */
r5333r5334
109103   int                  tile_page;            /* current tile page */
110104   int                  sprite_page;         /* current sprite page */
111105   int                  back_color;            /* background color */
112   UINT8               *ppu_page[4];         /* ppu pages */
113106   int                  nes_vram[8];         /* keep track of 8 .5k vram pages to speed things up */
114107   UINT8               palette_ram[0x20];      /* shouldn't be in main memory! */
115108   int                  scan_scale;            /* scan scale */
r5333r5334
179172/* default address map */
180173// make this INTERNAL, default should just be enough to avoid compile errors, print error messages!
181174static ADDRESS_MAP_START( ppu2c0x, 0, 8 )
182   AM_RANGE(0x3f00, 0x3fff) AM_READWRITE (ppu2c0x_palette_read, ppu2c0x_palette_write)
175   AM_RANGE(0x3f00, 0x3fff) AM_READWRITE(ppu2c0x_palette_read, ppu2c0x_palette_write)
183176ADDRESS_MAP_END
184177
185178void ppu2c0x_init_palette( running_machine *machine, int first_entry )
r5333r5334
318311static DEVICE_START( ppu2c0x )
319312{
320313   ppu2c0x_chip *chip = get_token(device);
321   // const ppu2c0x_interface *intf = get_interface(device);
322314
323315   memset(chip, 0, sizeof(*chip));
324316   chip->scanlines_per_frame = (int) device_get_info_int(device, PPU2C0XINFO_INT_SCANLINES_PER_FRAME);
r5333r5334
527519
528520static void draw_sprites( const device_config *device, UINT8 *line_priority )
529521{
530   // const ppu2c0x_interface *intf = get_interface(device);
531522   ppu2c0x_chip *this_ppu = get_token(device);
532523
533524   /* cache some values locally */
r5333r5334
10171008   /* set the vram bank-switch values to the default */
10181009   for (i = 0; i < 8; i++)
10191010      this_ppu->nes_vram[i] = i * 64;
1020
1021//  if (this_ppu->has_videorom)
1022//      ppu2c0x_set_videorom_bank(device, 0, 8, 0, 512);
10231011}
10241012
10251013/*************************************
r5333r5334
12661254            /* see if it's on the chargen portion */
12671255            if (tempAddr < 0x2000)
12681256            {
1269               /* if we have a videorom mapped there, dont write and log the problem */
1270               if (this_ppu->has_videorom && !this_ppu->has_videoram)
1271               {
1272                  /* if there is a vidaccess callback, assume it coped with it */
1273                  if (this_ppu->vidaccess_callback_proc == NULL)
1274                     logerror("PPU: Attempting to write to the chargen when there's a ROM there!\n");
1275               }
1276               else
1277               {
1278                  /* store the data */
1279                  memory_write_byte(device->space[0], tempAddr, data);
1257               /* store the data */
1258               memory_write_byte(device->space[0], tempAddr, data);
12801259
1281                  /* mark the char dirty */
1282                  // gfx_element_mark_dirty(device->machine->gfx[intf->gfx_layout_number], tempAddr >> 4);
1283               }
1260               /* mark the char dirty */
1261               // gfx_element_mark_dirty(device->machine->gfx[intf->gfx_layout_number], tempAddr >> 4);
12841262            }
12851263
12861264            else
src/mame/video/ppu2c0x.h
r5333r5334
8787typedef struct _ppu2c0x_interface ppu2c0x_interface;
8888struct _ppu2c0x_interface
8989{
90   const char *   vrom_region;         /* region id of gfx vrom (or REGION_INVALID if none) */
9190   int            gfx_layout_number;      /* gfx layout number used by each chip */
9291   int            color_base;            /* color base to use per ppu */
9392   int            mirroring;            /* mirroring options (PPU_MIRROR_* flag) */
9493   ppu2c0x_nmi_cb   nmi_handler;         /* NMI handler */
95   int            vram_enabled;         /* PPU uses vram together with vrom */
9694};
9795
9896
src/mame/drivers/multigam.c
r5333r5334
5050   PPU external bus interface
5151
5252*******************************************************/
53
5354static UINT8* nt_ram;
5455static UINT8* nt_page[4];
5556
r5333r5334
8485      break;
8586   }
8687}
88
8789static WRITE8_HANDLER (multigam_nt_w)
8890{
8991   int page = ((offset & 0xc00) >> 10);
9092   nt_page[page][offset & 0x3ff] = data;
9193}
94
95
9296static READ8_HANDLER (multigam_nt_r)
9397{
9498   int page = ((offset & 0xc00) >> 10);
r5333r5334
101105   int offset = bank * (bank_size_in_kb * 0x400);
102106   /* bank_size_in_kb is used to determine how large the "bank" parameter is */
103107   /* count determines the size of the area mapped in KB */
104   for (i = 0; i < count; i++)
108   for (i = 0; i < count; i++, offset += 0x400)
105109   {
106110      j = i + start + 1;
107111      memory_set_bankptr(machine, j, memory_region(machine, "gfx1") + offset);
r5333r5334
214218
215219static WRITE8_HANDLER(multigam_switch_gfx_rom)
216220{
217   memory_set_bankptr(space->machine, 1, memory_region(space->machine, "gfx1") + (0x2000 * data));
221   memory_set_bankptr(space->machine, 1, memory_region(space->machine, "gfx1") + (0x2000 * (data & 0x3f)));
218222   set_mirroring(data & 0x40 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT);
219223   multigam_game_gfx_bank = data;
220224};
r5333r5334
601605/* our ppu interface                                            */
602606static const ppu2c0x_interface ppu_interface =
603607{
604   "gfx1",            /* vrom gfx region */
605608   0,               /* gfxlayout num */
606609   0,               /* color base */
607610   PPU_MIRROR_NONE,   /* mirroring */
r5333r5334
643646static MACHINE_START( multigam )
644647{
645648   nt_ram = auto_alloc_array(machine, UINT8, 0x1000);
649   nt_page[0] = nt_ram;
650   nt_page[1] = nt_ram + 0x400;
651   nt_page[2] = nt_ram + 0x800;
652   nt_page[3] = nt_ram + 0xc00;
653
646654   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, multigam_nt_r, multigam_nt_w);
647655   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x0000, 0x1fff, 0, 0, SMH_BANK(1), 0);
648656   memory_set_bankptr(machine, 1, memory_region(machine, "gfx1"));
r5333r5334
651659static MACHINE_START( multigm3 )
652660{
653661   nt_ram = auto_alloc_array(machine, UINT8, 0x1000);
662   nt_page[0] = nt_ram;
663   nt_page[1] = nt_ram + 0x400;
664   nt_page[2] = nt_ram + 0x800;
665   nt_page[3] = nt_ram + 0xc00;
666
654667   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, multigam_nt_r, multigam_nt_w);
655668
656669   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x0000, 0x03ff, 0, 0, SMH_BANK(1), 0);
r5333r5334
661674   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x1400, 0x17ff, 0, 0, SMH_BANK(6), 0);
662675   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x1800, 0x1bff, 0, 0, SMH_BANK(7), 0);
663676   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x1c00, 0x1fff, 0, 0, SMH_BANK(8), 0);
677
678   set_videorom_bank(machine, 0, 8, 0, 8);
664679};
665680
666681static MACHINE_DRIVER_START( multigam )
src/mame/drivers/cham24.c
r5333r5334
265265/* our ppu interface                                            */
266266static const ppu2c0x_interface ppu_interface =
267267{
268   "gfx1",            /* vrom gfx region */
269268   0,               /* gfxlayout num */
270269   0,               /* color base */
271270   PPU_MIRROR_NONE,   /* mirroring */
r5333r5334
291290
292291   /* need nametable ram, though. I doubt this uses more than 2k, but it starts up configured for 4 */
293292   nt_ram = auto_alloc_array(machine, UINT8, 0x1000);
293   nt_page[0] = nt_ram;
294   nt_page[1] = nt_ram + 0x400;
295   nt_page[2] = nt_ram + 0x800;
296   nt_page[3] = nt_ram + 0xc00;
294297
295298   /* and read/write handlers */
296299   memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, nt_r, nt_w);
src/mess/drivers/nes.c
r5333r5334
176176
177177static const ppu2c0x_interface nes_ppu_interface =
178178{
179   NULL, //"gfx1",
180179   0,
181180   0,
182181   PPU_MIRROR_NONE,
183   ppu_nmi,
184   0
182   ppu_nmi
185183};
186184
187185

Previous 15994 Revisions Next


© 1998-2018 The MESS Team