From 9be4690a30b9bd51568e362d7f6f2ef14361a145 Mon Sep 17 00:00:00 2001 From: Andrei Holub Date: Wed, 8 Oct 2025 12:49:02 -0400 Subject: [PATCH] sinclair/specnext.cpp: Improved blending modes --- src/mame/sinclair/specnext.cpp | 40 ++++++++++++++++++---------- src/mame/sinclair/specnext_tiles.cpp | 4 +-- src/mame/sinclair/specnext_tiles.h | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/mame/sinclair/specnext.cpp b/src/mame/sinclair/specnext.cpp index c1e6e2ba1cb11..e244b67789b97 100644 --- a/src/mame/sinclair/specnext.cpp +++ b/src/mame/sinclair/specnext.cpp @@ -959,33 +959,45 @@ u32 specnext_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, c { bitmap.fill(m_palette->pen_color(UTM_FALLBACK_PEN), cliprect); - if (m_nr_68_blend_mode != 0b11) - //if (m_nr_68_blend_mode == 0b00) + const bool is_textmode = BIT(m_nr_6b_tm_control, 3); + if (m_nr_68_blend_mode == 0b00) // Use ULA as blend layer { - if (m_nr_68_ula_en && BIT(~m_nr_6b_tm_control, 3)) + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), is_textmode ? 1 : 0xff); + if (m_nr_68_ula_en && !is_textmode) { if (m_nr_15_lores_en) m_lores->draw(screen, bitmap, clip256x192, 1); else m_ula_scr->draw(screen, bitmap, clip256x192, flash, 1); } - if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), 2); - if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(2), 8); + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(2), is_textmode ? 1 : 2); } - /* TODO No tests for modes below yet - else if (m_nr_68_blend_mode == 0b10) + else if (m_nr_68_blend_mode == 0b10) // Use result of ULA + Tilemap { + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), 1); + if (m_nr_68_ula_en && !is_textmode) + { + if (m_nr_15_lores_en) m_lores->draw(screen, bitmap, clip256x192, 1); + else m_ula_scr->draw(screen, bitmap, clip256x192, flash, 1); + } + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(2), 1); } - else if (m_nr_68_blend_mode == 0b11) + else if (m_nr_68_blend_mode == 0b11) // Use Tilemap as blend layer { + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), 1); + if (m_nr_68_ula_en && !is_textmode) + { + if (m_nr_15_lores_en) m_lores->draw(screen, bitmap, clip256x192, 2); + else m_ula_scr->draw(screen, bitmap, clip256x192, flash, 2); + } + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(2), 1); } - */ - else + else // No blending (disable blend) { - if (m_nr_68_ula_en && BIT(~m_nr_6b_tm_control, 3)) + if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), 2); + if (m_nr_68_ula_en && !is_textmode) { - if (m_nr_15_lores_en) m_lores->draw(screen, bitmap, clip256x192, 1); - else m_ula_scr->draw(screen, bitmap, clip256x192, flash, 1); + if (m_nr_15_lores_en) m_lores->draw(screen, bitmap, clip256x192, 2); + else m_ula_scr->draw(screen, bitmap, clip256x192, flash, 2); } - if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(1), 2); if (m_nr_6b_tm_en) m_tiles->draw(screen, bitmap, clip320x256, TILEMAP_DRAW_CATEGORY(2), 2); } // mixes only to 1 diff --git a/src/mame/sinclair/specnext_tiles.cpp b/src/mame/sinclair/specnext_tiles.cpp index 5cf55b0c0f441..cf709065ae850 100644 --- a/src/mame/sinclair/specnext_tiles.cpp +++ b/src/mame/sinclair/specnext_tiles.cpp @@ -110,7 +110,7 @@ void specnext_tiles_device::tilemap_update() m_tiles_info = m_host_ram_ptr + ((BIT(m_tm_map_base, 6) ? 7 : 5) << 14) + ((m_tm_map_base & 0x3f) << 8); } -void specnext_tiles_device::draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, u32 flags, u8 pcode) +void specnext_tiles_device::draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, u32 flags, u8 pcode, u8 priority_mask) { rectangle clip = rectangle{ m_clip_x1 << 1, (m_clip_x2 << 1) | 1, m_clip_y1, m_clip_y2 }; clip &= SCREEN_AREA; @@ -119,7 +119,7 @@ void specnext_tiles_device::draw(screen_device &screen, bitmap_rgb32 &bitmap, co clip &= cliprect; if (!clip.empty()) - m_tilemap[BIT(m_control, 6)]->draw(screen, bitmap, clip, flags, pcode); + m_tilemap[BIT(m_control, 6)]->draw(screen, bitmap, clip, flags, pcode, priority_mask); } void specnext_tiles_device::device_add_mconfig(machine_config &config) diff --git a/src/mame/sinclair/specnext_tiles.h b/src/mame/sinclair/specnext_tiles.h index 0d7593f2edc36..5d3f5e8ae4923 100644 --- a/src/mame/sinclair/specnext_tiles.h +++ b/src/mame/sinclair/specnext_tiles.h @@ -33,7 +33,7 @@ class specnext_tiles_device : public device_t, public device_gfx_interface void clip_y1_w(u8 clip_y1) { m_clip_y1 = clip_y1; } void clip_y2_w(u8 clip_y2) { m_clip_y2 = clip_y2; } - void draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, u32 flags, u8 pcode = 0xff); + void draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, u32 flags, u8 pcode = 0xff, u8 priority_mask = 0xff); protected: static constexpr u8 OVER_BORDER = 32;