sinclair/next/specnext_layer2.cpp: Latched pixels read between screen updates.

This commit is contained in:
Andrei I. Holub 2026-05-25 19:59:14 -04:00
parent ecb1e7a292
commit 2fe5feb1ff
2 changed files with 19 additions and 2 deletions

View File

@ -155,11 +155,15 @@ void specnext_layer2_device::draw_16(screen_device &screen, bitmap_rgb32 &bitmap
screen, bitmap, blendprio, clip, info, offset_h, offset_v,
[this, &blend_op] (u16 pen_base, const u8 *scr, u32 *pix, u8 *prio, u32 *bprio, u16 &hpos, u16 &vpos, bool skip_second)
{
const u8 byte_val = (hpos & 1)
? (u32(scr - m_host_ram_ptr) == m_pixel_latch_off ? m_pixel_latch : *scr)
: *scr;
if (hpos & 1)
hpos ^= 1;
else
{
const u16 idx = (pen_base | (m_palette_offset << 4)) + (*scr >> 4);
const u16 idx = (pen_base | (m_palette_offset << 4)) + (byte_val >> 4);
const rgb_t pen = palette().pen_color(idx);
const bool is_prio_color = m_pen_priority[idx];
blend_op(prio[0], pix[0], bprio[0], pen, is_prio_color);
@ -167,11 +171,16 @@ void specnext_layer2_device::draw_16(screen_device &screen, bitmap_rgb32 &bitmap
if (!skip_second)
{
const u16 idx = (pen_base | (m_palette_offset << 4)) + (*scr & 0x0f);
const u16 idx = (pen_base | (m_palette_offset << 4)) + (byte_val & 0x0f);
const rgb_t pen = palette().pen_color(idx);
const bool is_prio_color = m_pen_priority[idx];
blend_op(prio[1], pix[1], bprio[1], pen, is_prio_color);
}
else
{
m_pixel_latch = byte_val;
m_pixel_latch_off = scr - m_host_ram_ptr;
}
});
}
@ -247,11 +256,16 @@ void specnext_layer2_device::device_start()
save_item(NAME(m_clip_x2));
save_item(NAME(m_clip_y1));
save_item(NAME(m_clip_y2));
save_item(NAME(m_pixel_latch));
save_item(NAME(m_pixel_latch_off));
m_pixel_latch_off = ~u32(0);
}
void specnext_layer2_device::device_reset()
{
memset(m_pen_priority, 0, 512 * 4);
m_pixel_latch_off = ~u32(0);
}
// device type definition

View File

@ -47,6 +47,9 @@ protected:
virtual void device_start() override ATTR_COLD;
virtual void device_reset() override ATTR_COLD;
u8 m_pixel_latch;
u32 m_pixel_latch_off;
private:
template <typename FunctionClass> void draw_256(screen_device &screen, bitmap_rgb32 &bitmap, bitmap_rgb32 &blendprio, const rectangle &cliprect, FunctionClass blend_op);
template <typename FunctionClass> void draw_16(screen_device &screen, bitmap_rgb32 &bitmap, bitmap_rgb32 &blendprio, const rectangle &cliprect, FunctionClass blend_op);