More topcat fixes (#3933)

* topcat: add has_changed() function (nw)

* topcat: don't write to plane if not enabled (nw)

* topcat: fix initialization order (nw)
This commit is contained in:
dxl 2018-08-31 23:52:22 +02:00 committed by R. Belmont
parent a8b903c4ec
commit 49d1ee4d17
4 changed files with 36 additions and 12 deletions

View File

@ -158,11 +158,20 @@ WRITE_LINE_MEMBER(dio16_98543_device::vblank_w)
for (auto &tc: m_topcat)
tc->vblank_w(state);
}
uint32_t dio16_98543_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
int startx[TOPCAT_COUNT], starty[TOPCAT_COUNT];
int endx[TOPCAT_COUNT], endy[TOPCAT_COUNT];
bool changed = false;
for (auto& tc: m_topcat)
changed |= tc->has_changed();
if (!changed)
return UPDATE_HAS_NOT_CHANGED;
for (int i = 0; i < TOPCAT_COUNT; i++)
m_topcat[i]->get_cursor_pos(startx[i], starty[i], endx[i], endy[i]);

View File

@ -134,17 +134,26 @@ WRITE_LINE_MEMBER(dio16_98544_device::vblank_w)
uint32_t dio16_98544_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
int startx, starty, endx, endy;
m_topcat->get_cursor_pos(startx, starty, endx, endy);
if (!m_topcat->has_changed())
return UPDATE_HAS_NOT_CHANGED;
for (int y = 0; y < m_v_pix; y++) {
uint32_t *scanline = &bitmap.pix32(y);
for (int x = 0; x < 1024; x++) {
for (int x = 0; x < m_h_pix; x++) {
uint8_t tmp = m_vram[y * m_h_pix + x];
if (y >= starty && y <= endy && x >= startx && x <= endx)
tmp |= 0xff;
*scanline++ = tmp ? rgb_t(255,255,255) : rgb_t(0, 0, 0);
}
}
m_topcat->get_cursor_pos(startx, starty, endx, endy);
for(int y = starty; y <= endy; y++) {
uint32_t *scanline = &bitmap.pix32(y);
memset(scanline + startx, 0xff, (endx - startx) << 2);
}
return 0;
}

View File

@ -53,6 +53,8 @@ void topcat_device::device_start()
save_item(NAME(m_fb_enable));
save_item(NAME(m_unknown_reg4a));
save_item(NAME(m_unknown_reg4c));
save_item(NAME(m_cursor_state));
save_item(NAME(m_changed));
}
//-------------------------------------------------
@ -80,19 +82,21 @@ READ16_MEMBER(topcat_device::vram_r)
WRITE16_MEMBER(topcat_device::vram_w)
{
if (mem_mask & m_plane_mask) {
if (mem_mask & m_plane_mask && (m_fb_write_enable & (m_plane_mask << 8))) {
bool src = data & m_plane_mask;
bool dst = m_vram[offset * 2 + 1] & m_plane_mask;
execute_rule(src, (replacement_rule_t)((m_pixel_replacement_rule >> 8) & 0x0f), dst);
modify_vram_offset(offset * 2 + 1, dst);
}
if (mem_mask & (m_plane_mask << 8)) {
if (mem_mask & (m_plane_mask << 8) && (m_fb_write_enable & (m_plane_mask << 8))) {
bool src = data & (m_plane_mask << 8);
bool dst = m_vram[offset * 2] & m_plane_mask;
execute_rule(src, (replacement_rule_t)((m_pixel_replacement_rule >> 8) & 0x0f), dst);
modify_vram_offset(offset * 2, dst);
}
m_changed = true;
}
void topcat_device::get_cursor_pos(int &startx, int &starty, int &endx, int &endy)
@ -103,10 +107,10 @@ void topcat_device::get_cursor_pos(int &startx, int &starty, int &endx, int &end
endx = m_cursor_x_pos + m_cursor_width;
endy = m_cursor_y_pos;
} else {
startx = 0;
starty = 0;
endx = 0;
endy = 0;
startx = -1;
starty = -1;
endx = -1;
endy = -1;
}
}
@ -114,6 +118,7 @@ TIMER_CALLBACK_MEMBER(topcat_device::cursor_callback)
{
m_cursor_timer->adjust(attotime::from_hz(5));
m_cursor_state ^= true;
m_changed = true;
}
void topcat_device::update_cursor(int x, int y, uint16_t ctrl, uint8_t width)
@ -347,6 +352,7 @@ WRITE16_MEMBER(topcat_device::ctrl_w)
if (!m_write_enable)
return;
m_changed = true;
switch (offset) {
case TOPCAT_REG_VBLANK:
m_vblank = data;

View File

@ -20,12 +20,11 @@
class topcat_device : public device_t
{
public:
template <class Object> devcb_base& set_int_write_cb(Object &&cb)
{ return m_int_write_func.set_callback(std::forward<Object>(cb)); }
topcat_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
bool has_changed() { bool ret = m_changed; m_changed = false; return ret; };
void set_fb_width(int _pixels) { m_fb_width = _pixels; }
void set_fb_height(int _pixels) { m_fb_height = _pixels; }
void set_planemask(int _mask) { m_plane_mask = _mask; }
@ -157,6 +156,7 @@ private:
bool m_read_enable;
bool m_write_enable;
bool m_fb_enable;
bool m_changed;
required_shared_ptr<uint8_t> m_vram;
};