From 04102e36cb65a943e29dd4baaac7bb189c117939 Mon Sep 17 00:00:00 2001 From: cam900 Date: Fri, 27 Apr 2018 15:28:47 +0900 Subject: [PATCH] gunpey.cpp Cleanups (#3483) * gunpey.cpp : Minor cleanups, Fix object finder, Convert VRAM into std::unique_ptr, Fix bit manipulations * gunpey.cpp : Revert "Fix bit manipulations" * gunpey.cpp : Cleanup duplicates --- src/mame/drivers/gunpey.cpp | 46 +++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/mame/drivers/gunpey.cpp b/src/mame/drivers/gunpey.cpp index e45ac07507f..7f970f3b801 100644 --- a/src/mame/drivers/gunpey.cpp +++ b/src/mame/drivers/gunpey.cpp @@ -205,11 +205,12 @@ class gunpey_state : public driver_device { public: gunpey_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_oki(*this, "oki"), - m_wram(*this, "wram"), - m_palette(*this, "palette") + : driver_device(mconfig, type, tag) + , m_maincpu(*this, "maincpu") + , m_oki(*this, "oki") + , m_wram(*this, "wram") + , m_palette(*this, "palette") + , m_blit_rom(*this, "blit_data") { } // TODO: make these non-static and private @@ -247,9 +248,6 @@ private: uint16_t m_vram_bank; uint16_t m_vreg_addr; - uint8_t* m_blit_rom; - uint8_t* m_vram; - emu_timer *m_blitter_end_timer; // work variables for the decompression @@ -273,21 +271,25 @@ private: int next_node(struct huffman_node_s **res, struct state_s *s); int get_next_bit(struct state_s *s); - uint8_t m_irq_cause, m_irq_mask; std::unique_ptr m_blit_buffer; + std::unique_ptr m_vram; required_device m_maincpu; required_device m_oki; required_shared_ptr m_wram; required_device m_palette; + required_region_ptr m_blit_rom; }; void gunpey_state::video_start() { m_blit_buffer = std::make_unique(512*512); + m_vram = std::make_unique(0x400000); + std::fill_n(&m_vram[0], 0x400000, 0xff); m_blitter_end_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gunpey_state::blitter_end), this)); + save_pointer(NAME(m_vram.get()), 0x400000); } uint8_t gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,int count,uint8_t scene_gradient) @@ -382,18 +384,16 @@ uint8_t gunpey_state::draw_gfx(bitmap_ind16 &bitmap,const rectangle &cliprect,in if (xi2 & 1) { pix = (data & 0xf0)>>4; - col_offs = ((pix + color*0x10) & 0xff) << 1; - col_offs+= ((pix + color*0x10) >> 8)*0x800; - color_data = (m_vram[col_offs])|(m_vram[col_offs+1]<<8); } else { pix = (data & 0x0f); - col_offs = ((pix + color*0x10) & 0xff) << 1; - col_offs+= ((pix + color*0x10) >> 8)*0x800; - color_data = (m_vram[col_offs])|(m_vram[col_offs+1]<<8); } + col_offs = ((pix + color*0x10) & 0xff) << 1; + col_offs+= ((pix + color*0x10) >> 8)*0x800; + color_data = (m_vram[col_offs])|(m_vram[col_offs+1]<<8); + if(!(color_data & 0x8000)) { if(scene_gradient & 0x40) @@ -652,7 +652,7 @@ int gunpey_state::write_dest_byte(uint8_t usedata) inline uint8_t gunpey_state::get_vrom_byte(int x, int y) { - return m_blit_rom[(x)+2048 * (y)]; + return m_blit_rom[((x)+2048 * (y)) & m_blit_rom.mask()]; } struct state_s @@ -998,10 +998,10 @@ WRITE8_MEMBER(gunpey_state::blitter_w) if(offset == 0 && data == 2) // blitter trigger, 0->1 transition { - m_srcx = blit_ram[0x04]+(blit_ram[0x05]<<8); - m_srcy = blit_ram[0x06]+(blit_ram[0x07]<<8); - m_dstx = blit_ram[0x08]+(blit_ram[0x09]<<8); - m_dsty = blit_ram[0x0a]+(blit_ram[0x0b]<<8); + m_srcx = blit_ram[0x04]|(blit_ram[0x05]<<8); + m_srcy = blit_ram[0x06]|(blit_ram[0x07]<<8); + m_dstx = blit_ram[0x08]|(blit_ram[0x09]<<8); + m_dsty = blit_ram[0x0a]|(blit_ram[0x0b]<<8); m_xsize = blit_ram[0x0c]+1; m_ysize = blit_ram[0x0e]+1; int compression = blit_ram[0x01]; @@ -1013,7 +1013,7 @@ WRITE8_MEMBER(gunpey_state::blitter_w) { if(compression == 8) { - if (decompress_sprite(m_vram, m_srcx, m_srcy, m_xsize, m_ysize, m_dstx, m_dsty)) + if (decompress_sprite(m_vram.get(), m_srcx, m_srcy, m_xsize, m_ysize, m_dstx, m_dsty)) { logerror("[-] Failed to decompress sprite at %04x %04x\n", m_srcx, m_srcy); } @@ -1253,8 +1253,6 @@ ROM_START( gunpey ) ROM_REGION( 0x400000, "blit_data", 0 ) ROM_LOAD( "gp_rom3.025", 0x00000, 0x400000, CRC(f2d1f9f0) SHA1(0d20301fd33892074508b9d127456eae80cc3a1c) ) - ROM_REGION( 0x400000, "vram", ROMREGION_ERASEFF ) - ROM_REGION( 0x400000, "ymz", 0 ) ROM_LOAD( "gp_rom4.525", 0x000000, 0x400000, CRC(78dd1521) SHA1(91d2046c60e3db348f29f776def02e3ef889f2c1) ) // 11xxxxxxxxxxxxxxxxxxxx = 0xFF @@ -1264,8 +1262,6 @@ ROM_END DRIVER_INIT_MEMBER(gunpey_state,gunpey) { - m_blit_rom = memregion("blit_data")->base(); - m_vram = memregion("vram")->base(); } GAME( 2000, gunpey, 0, gunpey, gunpey, gunpey_state, gunpey, ROT0, "Bandai / Banpresto", "Gunpey (Japan)", 0 )