Skip to content

Commit bc74a1d

Browse files
committed
sinclair/next/specnext.cpp: Various improvements.
* Forced more updates on tilemap writes. * Better handeling DivMMC CS instant switch. * Pulled up unmapped value on 0x2ffd, 0x3ffd reads. * next/specnext_layer2.cpp: Improved half-pixel rendering.
1 parent b185344 commit bc74a1d

2 files changed

Lines changed: 35 additions & 11 deletions

File tree

src/mame/sinclair/next/specnext.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,9 +2413,11 @@ void specnext_state::reg_w(offs_t nr_wr_reg, u8 nr_wr_dat)
24132413
nr_6c_tm_default_attr_w(nr_wr_dat);
24142414
break;
24152415
case 0x6e:
2416+
m_screen->update_now();
24162417
nr_6e_tilemap_base_w(BIT(nr_wr_dat, 7), BIT(nr_wr_dat, 0, 6));
24172418
break;
24182419
case 0x6f:
2420+
m_screen->update_now();
24192421
nr_6f_tilemap_tiles_w(BIT(nr_wr_dat, 7), BIT(nr_wr_dat, 0, 6));
24202422
break;
24212423
case 0x70:
@@ -2693,7 +2695,7 @@ TIMER_CALLBACK_MEMBER(specnext_state::irq_off)
26932695

26942696
TIMER_CALLBACK_MEMBER(specnext_state::irq_on)
26952697
{
2696-
LOGINTVVV("<Frame IRQ>\n");
2698+
LOGINTVVV("<ULA/Frame IRQ>\n");
26972699
m_im2_ula->irq_w(ASSERT_LINE);
26982700
if (m_nr_c0_int_mode_pulse_0_im2_1 == 0)
26992701
m_irq_off_timer->adjust(m_maincpu->clocks_to_attotime(32));
@@ -2830,6 +2832,7 @@ u8 specnext_state::do_m1(offs_t offset)
28302832
m_divmmc->automap_nmi_delayed_on_w(0);
28312833

28322834
m_divmmc->cpu_m1_n_w(1);
2835+
m_divmmc->cpu_mreq_n_w(1);
28332836
m_divmmc->clock_w();
28342837
bank_update(0, 2);
28352838

@@ -3050,10 +3053,10 @@ void specnext_state::map_io(address_map &map)
30503053
}));
30513054

30523055
map(0x2001, 0x2001).mirror(0x0ffc).lr8(NAME([]() {
3053-
return /*m_nr_d8_io_trap_fdc_en ? ... :*/ 0x00;
3056+
return /*m_nr_d8_io_trap_fdc_en ? ... :*/ 0xff;
30543057
}));
30553058
map(0x3001, 0x3001).mirror(0x0ffc).lrw8(NAME([]() {
3056-
return /*m_nr_d8_io_trap_fdc_en ? ... :*/ 0x00;
3059+
return /*m_nr_d8_io_trap_fdc_en ? ... :*/ 0xff;
30573060
}), NAME([this](u8 data) {
30583061
if (m_nr_d8_io_trap_fdc_en)
30593062
{

src/mame/sinclair/next/specnext_layer2.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,21 @@ void specnext_layer2_device::draw_256(screen_device &screen, bitmap_rgb32 &bitma
121121
const u16 offset_v = m_offset_v - info[2];
122122
clip.offset(offset_h, offset_v);
123123
clip &= cliprect;
124-
clip.setx(clip.left() & ~1, clip.right() | 1);
125124

126125
do_draw(
127126
screen, bitmap, blendprio, clip, info, offset_h, offset_v,
128-
[this, &blend_op] (u16 pen_base, const u8 *scr, u32 *pix, u8 *prio, u32 *bprio, u16 &hpos, u16 &vpos)
127+
[this, &blend_op] (u16 pen_base, const u8 *scr, u32 *pix, u8 *prio, u32 *bprio, u16 &hpos, u16 &vpos, bool skip_second)
129128
{
130129
const u16 idx = pen_base + ((*scr + (m_palette_offset << 4)) % 0x100);
131130
const rgb_t pen = palette().pen_color(idx);
132131
const bool is_prio_color = m_pen_priority[idx];
133-
blend_op(prio[0], pix[0], bprio[0], pen, is_prio_color);
134-
blend_op(prio[1], pix[1], bprio[1], pen, is_prio_color);
132+
if (hpos & 1)
133+
hpos ^= 1;
134+
else
135+
blend_op(prio[0], pix[0], bprio[0], pen, is_prio_color);
136+
137+
if (!skip_second)
138+
blend_op(prio[1], pix[1], bprio[1], pen, is_prio_color);
135139
});
136140
}
137141

@@ -149,7 +153,7 @@ void specnext_layer2_device::draw_16(screen_device &screen, bitmap_rgb32 &bitmap
149153

150154
do_draw(
151155
screen, bitmap, blendprio, clip, info, offset_h, offset_v,
152-
[this, &blend_op] (u16 pen_base, const u8 *scr, u32 *pix, u8 *prio, u32 *bprio, u16 &hpos, u16 &vpos)
156+
[this, &blend_op] (u16 pen_base, const u8 *scr, u32 *pix, u8 *prio, u32 *bprio, u16 &hpos, u16 &vpos, bool skip_second)
153157
{
154158
if (hpos & 1)
155159
hpos ^= 1;
@@ -161,6 +165,7 @@ void specnext_layer2_device::draw_16(screen_device &screen, bitmap_rgb32 &bitmap
161165
blend_op(prio[0], pix[0], bprio[0], pen, is_prio_color);
162166
}
163167

168+
if (!skip_second)
164169
{
165170
const u16 idx = (pen_base | (m_palette_offset << 4)) + (*scr & 0x0f);
166171
const rgb_t pen = palette().pen_color(idx);
@@ -179,18 +184,34 @@ void specnext_layer2_device::do_draw(screen_device &screen, bitmap_rgb32 &bitmap
179184
const u16 pen_base = m_layer2_palette_select ? m_palette_alt_offset : m_palette_base_offset;
180185
u16 x_min = ((clip.left() - offset_h) >> 1) + m_scroll_x;
181186
const bool x_scrollover = m_scroll_x >= info[0] && info[3] == 256;
182-
if (x_scrollover) x_min -= info[0];
187+
if (x_scrollover)
188+
x_min -= info[0]; // scrolls over
189+
else
190+
x_min %= info[0]; // wraps around
191+
183192
for (u16 vpos = clip.top(); vpos <= clip.bottom(); vpos++)
184193
{
185-
const u16 y = (vpos - offset_v + m_scroll_y) % info[1];
194+
u16 y = vpos - offset_v + m_scroll_y;
195+
if (m_scroll_y >= info[1] && info[4] == 256)
196+
y -= info[1]; // scrolls over
197+
else
198+
y %= info[1]; // wraps around
199+
186200
u16 x = x_min;
187201
const u8 *scr = m_host_ram_ptr + (m_layer2_active_bank << 14) + (y * info[4]) + (x * info[3]);
188202
u32 *pix = &(bitmap.pix(vpos, clip.left()));
189203
u8 *prio = &(screen.priority().pix(vpos, clip.left()));
190204
u32 *bprio = &(blendprio.pix(vpos, clip.left()));
205+
if (clip.left() & 1)
206+
{
207+
pix -= 1;
208+
prio -= 1;
209+
bprio -= 1;
210+
}
191211
for (u16 hpos = clip.left(); hpos <= clip.right(); hpos += 2, pix += 2, prio += 2, bprio += 2)
192212
{
193-
plot_op(pen_base, scr, pix, prio, bprio, hpos, vpos);
213+
// (hpos & 1) skips first pixel reading and decreases hpos reference.
214+
plot_op(pen_base, scr, pix, prio, bprio, hpos, vpos, hpos == clip.right() && (~hpos & 1));
194215

195216
++x %= info[0];
196217
if (x == 0 && !x_scrollover)

0 commit comments

Comments
 (0)