src/mame/video/ppu2c0x.c
| r5333 | r5334 | |
| 80 | 80 | typedef struct |
| 81 | 81 | { |
| 82 | 82 | bitmap_t *bitmap; /* target bitmap */ |
| 83 | | UINT8 *videomem; /* video mem */ |
| 84 | | UINT8 *videoram; /* video ram */ |
| 85 | 83 | UINT8 *spriteram; /* sprite ram */ |
| 86 | 84 | pen_t *colortable; /* color table modified at run time */ |
| 87 | 85 | pen_t *colortable_mono; /* monochromatic color table modified at run time */ |
| r5333 | r5334 | |
| 92 | 90 | ppu2c0x_scanline_cb scanline_callback_proc; /* optional scanline callback */ |
| 93 | 91 | ppu2c0x_hblank_cb hblank_callback_proc; /* optional hblank callback */ |
| 94 | 92 | 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]; |
| 99 | 93 | int regs[PPU_MAX_REG]; /* registers */ |
| 100 | 94 | int refresh_data; /* refresh-related */ |
| 101 | 95 | int refresh_latch; /* refresh-related */ |
| r5333 | r5334 | |
| 109 | 103 | int tile_page; /* current tile page */ |
| 110 | 104 | int sprite_page; /* current sprite page */ |
| 111 | 105 | int back_color; /* background color */ |
| 112 | | UINT8 *ppu_page[4]; /* ppu pages */ |
| 113 | 106 | int nes_vram[8]; /* keep track of 8 .5k vram pages to speed things up */ |
| 114 | 107 | UINT8 palette_ram[0x20]; /* shouldn't be in main memory! */ |
| 115 | 108 | int scan_scale; /* scan scale */ |
| r5333 | r5334 | |
| 179 | 172 | /* default address map */ |
| 180 | 173 | // make this INTERNAL, default should just be enough to avoid compile errors, print error messages! |
| 181 | 174 | static 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) |
| 183 | 176 | ADDRESS_MAP_END |
| 184 | 177 | |
| 185 | 178 | void ppu2c0x_init_palette( running_machine *machine, int first_entry ) |
| r5333 | r5334 | |
| 318 | 311 | static DEVICE_START( ppu2c0x ) |
| 319 | 312 | { |
| 320 | 313 | ppu2c0x_chip *chip = get_token(device); |
| 321 | | // const ppu2c0x_interface *intf = get_interface(device); |
| 322 | 314 | |
| 323 | 315 | memset(chip, 0, sizeof(*chip)); |
| 324 | 316 | chip->scanlines_per_frame = (int) device_get_info_int(device, PPU2C0XINFO_INT_SCANLINES_PER_FRAME); |
| r5333 | r5334 | |
| 527 | 519 | |
| 528 | 520 | static void draw_sprites( const device_config *device, UINT8 *line_priority ) |
| 529 | 521 | { |
| 530 | | // const ppu2c0x_interface *intf = get_interface(device); |
| 531 | 522 | ppu2c0x_chip *this_ppu = get_token(device); |
| 532 | 523 | |
| 533 | 524 | /* cache some values locally */ |
| r5333 | r5334 | |
| 1017 | 1008 | /* set the vram bank-switch values to the default */ |
| 1018 | 1009 | for (i = 0; i < 8; i++) |
| 1019 | 1010 | this_ppu->nes_vram[i] = i * 64; |
| 1020 | | |
| 1021 | | // if (this_ppu->has_videorom) |
| 1022 | | // ppu2c0x_set_videorom_bank(device, 0, 8, 0, 512); |
| 1023 | 1011 | } |
| 1024 | 1012 | |
| 1025 | 1013 | /************************************* |
| r5333 | r5334 | |
| 1266 | 1254 | /* see if it's on the chargen portion */ |
| 1267 | 1255 | if (tempAddr < 0x2000) |
| 1268 | 1256 | { |
| 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); |
| 1280 | 1259 | |
| 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); |
| 1284 | 1262 | } |
| 1285 | 1263 | |
| 1286 | 1264 | else |
src/mame/drivers/multigam.c
| r5333 | r5334 | |
| 50 | 50 | PPU external bus interface |
| 51 | 51 | |
| 52 | 52 | *******************************************************/ |
| 53 | |
| 53 | 54 | static UINT8* nt_ram; |
| 54 | 55 | static UINT8* nt_page[4]; |
| 55 | 56 | |
| r5333 | r5334 | |
| 84 | 85 | break; |
| 85 | 86 | } |
| 86 | 87 | } |
| 88 | |
| 87 | 89 | static WRITE8_HANDLER (multigam_nt_w) |
| 88 | 90 | { |
| 89 | 91 | int page = ((offset & 0xc00) >> 10); |
| 90 | 92 | nt_page[page][offset & 0x3ff] = data; |
| 91 | 93 | } |
| 94 | |
| 95 | |
| 92 | 96 | static READ8_HANDLER (multigam_nt_r) |
| 93 | 97 | { |
| 94 | 98 | int page = ((offset & 0xc00) >> 10); |
| r5333 | r5334 | |
| 101 | 105 | int offset = bank * (bank_size_in_kb * 0x400); |
| 102 | 106 | /* bank_size_in_kb is used to determine how large the "bank" parameter is */ |
| 103 | 107 | /* 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) |
| 105 | 109 | { |
| 106 | 110 | j = i + start + 1; |
| 107 | 111 | memory_set_bankptr(machine, j, memory_region(machine, "gfx1") + offset); |
| r5333 | r5334 | |
| 214 | 218 | |
| 215 | 219 | static WRITE8_HANDLER(multigam_switch_gfx_rom) |
| 216 | 220 | { |
| 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))); |
| 218 | 222 | set_mirroring(data & 0x40 ? PPU_MIRROR_HORZ : PPU_MIRROR_VERT); |
| 219 | 223 | multigam_game_gfx_bank = data; |
| 220 | 224 | }; |
| r5333 | r5334 | |
| 601 | 605 | /* our ppu interface */ |
| 602 | 606 | static const ppu2c0x_interface ppu_interface = |
| 603 | 607 | { |
| 604 | | "gfx1", /* vrom gfx region */ |
| 605 | 608 | 0, /* gfxlayout num */ |
| 606 | 609 | 0, /* color base */ |
| 607 | 610 | PPU_MIRROR_NONE, /* mirroring */ |
| r5333 | r5334 | |
| 643 | 646 | static MACHINE_START( multigam ) |
| 644 | 647 | { |
| 645 | 648 | 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 | |
| 646 | 654 | 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); |
| 647 | 655 | memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x0000, 0x1fff, 0, 0, SMH_BANK(1), 0); |
| 648 | 656 | memory_set_bankptr(machine, 1, memory_region(machine, "gfx1")); |
| r5333 | r5334 | |
| 651 | 659 | static MACHINE_START( multigm3 ) |
| 652 | 660 | { |
| 653 | 661 | 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 | |
| 654 | 667 | 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); |
| 655 | 668 | |
| 656 | 669 | memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x0000, 0x03ff, 0, 0, SMH_BANK(1), 0); |
| r5333 | r5334 | |
| 661 | 674 | memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x1400, 0x17ff, 0, 0, SMH_BANK(6), 0); |
| 662 | 675 | memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x1800, 0x1bff, 0, 0, SMH_BANK(7), 0); |
| 663 | 676 | 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); |
| 664 | 679 | }; |
| 665 | 680 | |
| 666 | 681 | static MACHINE_DRIVER_START( multigam ) |
src/mame/drivers/cham24.c
| r5333 | r5334 | |
| 265 | 265 | /* our ppu interface */ |
| 266 | 266 | static const ppu2c0x_interface ppu_interface = |
| 267 | 267 | { |
| 268 | | "gfx1", /* vrom gfx region */ |
| 269 | 268 | 0, /* gfxlayout num */ |
| 270 | 269 | 0, /* color base */ |
| 271 | 270 | PPU_MIRROR_NONE, /* mirroring */ |
| r5333 | r5334 | |
| 291 | 290 | |
| 292 | 291 | /* need nametable ram, though. I doubt this uses more than 2k, but it starts up configured for 4 */ |
| 293 | 292 | 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; |
| 294 | 297 | |
| 295 | 298 | /* and read/write handlers */ |
| 296 | 299 | memory_install_readwrite8_handler(cpu_get_address_space(cputag_get_cpu(machine, "ppu"), ADDRESS_SPACE_PROGRAM), 0x2000, 0x3eff, 0, 0, nt_r, nt_w); |