gp9001.cpp : Make tilemap drawing routine related to cliprect, buffered_spriteram16 for sprite RAM (#4317)

This commit is contained in:
cam900 2018-11-24 17:47:10 +09:00 committed by Ivan Vangelista
parent 020c99b5f2
commit ac7590f8ee
2 changed files with 39 additions and 37 deletions

View File

@ -241,6 +241,16 @@ TILE_GET_INFO_MEMBER(gp9001vdp_device::get_tile_info)
//tileinfo.category = (attrib & 0x0f00) >> 8;
}
//-------------------------------------------------
// device_add_mconfig - device-specific machine
// configuration addiitons
//-------------------------------------------------
void gp9001vdp_device::device_add_mconfig(machine_config &config)
{
BUFFERED_SPRITERAM16(config, m_spriteram);
}
void gp9001vdp_device::create_tilemaps()
{
m_tm[2].tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(gp9001vdp_device::get_tile_info<2>),this),TILEMAP_SCAN_ROWS,16,16,32,32);
@ -255,16 +265,12 @@ void gp9001vdp_device::create_tilemaps()
void gp9001vdp_device::device_start()
{
m_sp.vram16_buffer = make_unique_clear<uint16_t[]>(SPRITERAM_SIZE/2);
create_tilemaps();
m_vint_out_cb.resolve();
m_raise_irq_timer = timer_alloc(TIMER_RAISE_IRQ);
save_pointer(NAME(m_sp.vram16_buffer), SPRITERAM_SIZE/2);
save_item(NAME(m_scroll_reg));
save_item(NAME(m_voffs));
for (int i = 0; i < 3; i++)
@ -613,12 +619,10 @@ READ_LINE_MEMBER(gp9001vdp_device::fblank_r)
void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, const uint8_t* primap )
{
uint16_t *source;
uint16_t const *source = (m_sp.use_sprite_buffer) ? m_spriteram->buffer() : m_spriteram->live();
if (m_sp.use_sprite_buffer) source = m_sp.vram16_buffer.get();
else source = &m_spriteram[0];
int total_elements = gfx(1)->elements();
int total_colors = gfx(1)->colors();
int const total_elements = gfx(1)->elements();
int const total_colors = gfx(1)->colors();
int old_x = (-(m_sp.scrollx)) & 0x1ff;
int old_y = (-(m_sp.scrolly)) & 0x1ff;
@ -721,7 +725,6 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
color %= total_colors;
const pen_t *paldata = &palette().pen(color * 16);
{
int yy, xx;
const uint8_t* srcdata = gfx(1)->get_data(sprite);
int count = 0;
int ystart, yend, yinc;
@ -753,11 +756,11 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
xinc = 1;
}
for (yy=ystart;yy!=yend;yy+=yinc)
for (int yy = ystart; yy != yend; yy += yinc)
{
int drawyy = yy + sy;
for (xx=xstart;xx!=xend;xx+=xinc)
for (int xx = xstart; xx != xend; xx += xinc)
{
int drawxx = xx + sx;
@ -796,12 +799,9 @@ void gp9001vdp_device::draw_sprites( bitmap_ind16 &bitmap, const rectangle &clip
Draw the game screen in the given bitmap_ind16.
***************************************************************************/
void gp9001vdp_device::draw_custom_tilemap( bitmap_ind16 &bitmap, int layer, const uint8_t* priremap, const uint8_t* pri_enable )
void gp9001vdp_device::draw_custom_tilemap( bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, const uint8_t* priremap, const uint8_t* pri_enable )
{
tilemap_t* tilemap = m_tm[layer].tmap;
int width = screen().width();
int height = screen().height();
int y,x;
bitmap_ind16 &tmb = tilemap->pixmap();
uint16_t* srcptr;
uint16_t* dstptr;
@ -810,7 +810,7 @@ void gp9001vdp_device::draw_custom_tilemap( bitmap_ind16 &bitmap, int layer, con
int scrollx = tilemap->scrollx(0);
int scrolly = tilemap->scrolly(0);
for (y=0;y<height;y++)
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
{
int realy = (y + scrolly) & 0x1ff;
@ -818,7 +818,7 @@ void gp9001vdp_device::draw_custom_tilemap( bitmap_ind16 &bitmap, int layer, con
dstptr = &bitmap.pix16(y);
dstpriptr = &this->custom_priority_bitmap->pix8(y);
for (x=0;x<width;x++)
for (int x = cliprect.left(); x <= cliprect.right(); x++)
{
int realx = (x + scrollx) & 0x1ff;
@ -860,9 +860,9 @@ void gp9001vdp_device::render_vdp(bitmap_ind16 &bitmap, const rectangle &cliprec
m_gfxrom_bank_dirty = false;
}
draw_custom_tilemap(bitmap, 0, gp9001_primap1, batsugun_prienable0);
draw_custom_tilemap(bitmap, 1, gp9001_primap1, batsugun_prienable0);
draw_custom_tilemap(bitmap, 2, gp9001_primap1, batsugun_prienable0);
draw_custom_tilemap(bitmap, cliprect, 0, gp9001_primap1, batsugun_prienable0);
draw_custom_tilemap(bitmap, cliprect, 1, gp9001_primap1, batsugun_prienable0);
draw_custom_tilemap(bitmap, cliprect, 2, gp9001_primap1, batsugun_prienable0);
draw_sprites(bitmap, cliprect, gp9001_sprprimap1);
}
@ -870,7 +870,7 @@ void gp9001vdp_device::render_vdp(bitmap_ind16 &bitmap, const rectangle &cliprec
void gp9001vdp_device::screen_eof(void)
{
/** Shift sprite RAM buffers *** Used to fix sprite lag **/
if (m_sp.use_sprite_buffer) memcpy(m_sp.vram16_buffer.get(),m_spriteram,SPRITERAM_SIZE);
if (m_sp.use_sprite_buffer) m_spriteram->copy();
// the IRQ appears to fire at line 0xe6
if (!m_vint_out_cb.isnull())

View File

@ -6,6 +6,8 @@
#pragma once
#include "video/bufsprite.h"
class gp9001vdp_device : public device_t,
public device_gfx_interface,
public device_video_interface,
@ -22,7 +24,7 @@ public:
auto vint_out_cb() { return m_vint_out_cb.bind(); }
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, const uint8_t* primap);
void draw_custom_tilemap(bitmap_ind16 &bitmap, int layer, const uint8_t* priremap, const uint8_t* pri_enable);
void draw_custom_tilemap(bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, const uint8_t* priremap, const uint8_t* pri_enable);
void render_vdp(bitmap_ind16 &bitmap, const rectangle &cliprect);
void screen_eof();
void create_tilemaps();
@ -64,6 +66,7 @@ public:
DECLARE_WRITE16_MEMBER(pipibibi_bootleg_scroll_w);
protected:
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
@ -123,7 +126,6 @@ private:
void set_scrolly_and_flip_reg(uint16_t data, uint16_t mem_mask, bool f);
bool use_sprite_buffer;
std::unique_ptr<uint16_t[]> vram16_buffer; // vram buffer for this layer
};
int get_tile_number(int layer, int index)
@ -159,7 +161,7 @@ private:
uint16_t m_gfxrom_bank[8]; /* Batrider object bank */
required_shared_ptr_array<uint16_t, 3> m_vram;
required_shared_ptr<uint16_t> m_spriteram;
required_device<buffered_spriteram16_device> m_spriteram;
devcb_write_line m_vint_out_cb;
emu_timer *m_raise_irq_timer;