Skip to content

Commit

Permalink
pow3000, pc8300, lambda: fixed display
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbbert committed Mar 17, 2024
1 parent ae71916 commit c644684
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/mame/sinclair/zx.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class zx_state : public driver_device
bool m_nmi_on = false, m_nmi_generator_active = false;
uint64_t m_base_vsync_clock = 0, m_vsync_start_time = 0;
uint32_t m_ypos = 0;
uint8_t m_const = 207;

uint8_t m_prev_refresh = 0;
uint8_t m_speaker_state = 0;
Expand Down
24 changes: 19 additions & 5 deletions src/mame/sinclair/zx_m.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ void zx_state::init_zx()
m_program->unmap_readwrite(0x8000, 0xffff);
else if(m_ram->size() < 16384)
m_program->unmap_readwrite(0x4000 + m_ram->size(), 0xffff);

m_const = 207;
if (m_region_gfx1)
m_const = 208;
}

void zx_state::machine_reset()
Expand Down Expand Up @@ -53,10 +57,10 @@ void zx_state::drop_sync()
m_vsync_active = false;
m_cassette->output(-1.0);

int xs = 2*((m_vsync_start_time - m_base_vsync_clock) % 207);
int ys = (m_vsync_start_time - m_base_vsync_clock) / 207;
int xe = 2*((time - m_base_vsync_clock) % 207);
int ye = (time - m_base_vsync_clock) / 207;
int xs = 2*((m_vsync_start_time - m_base_vsync_clock) % m_const);
int ys = (m_vsync_start_time - m_base_vsync_clock) / m_const;
int xe = 2*((time - m_base_vsync_clock) % m_const);
int ye = (time - m_base_vsync_clock) / m_const;
if(xs >= 384) {
xs = 0;
ys++;
Expand Down Expand Up @@ -106,7 +110,7 @@ void zx_state::drop_sync()
m_nmi_on = m_hsync_active = false;
recalc_hsync();
} else
m_ypos = ((time-m_base_vsync_clock)%207) < 192 ? 0 : -1;
m_ypos = ((time-m_base_vsync_clock)%m_const) < 192 ? 0 : -1;
}
}

Expand Down Expand Up @@ -198,6 +202,11 @@ uint8_t zx_state::pc8300_io_r(offs_t offset)
m_cassette->output(+1.0);
if(m_cassette_cur_level <= 0)
data &= 0x7f;

if (!m_vsync_active && !m_nmi_generator_active) {
m_vsync_active = true;
m_vsync_start_time = m_maincpu->total_cycles();
}
}

return data;
Expand Down Expand Up @@ -235,6 +244,11 @@ uint8_t zx_state::pow3000_io_r(offs_t offset)
m_cassette->output(+1.0);
if(m_cassette_cur_level <= 0)
data &= 0x7f;

if (!m_vsync_active && !m_nmi_generator_active) {
m_vsync_active = true;
m_vsync_start_time = m_maincpu->total_cycles();
}
}

return data;
Expand Down
16 changes: 8 additions & 8 deletions src/mame/sinclair/zx_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void zx_state::refresh_w(offs_t offset, uint8_t data)
m_prev_refresh = offset;
if(m_ula_char_buffer != 0xffff) {
uint64_t time = m_maincpu->total_cycles();
int x = 2*((time-m_base_vsync_clock) % 207);
int y = (time-m_base_vsync_clock) / 207;
int x = 2*((time-m_base_vsync_clock) % m_const);
int y = (time-m_base_vsync_clock) / m_const;
uint8_t pixels;
if(m_region_gfx1)
pixels = m_region_gfx1->base()[((m_ula_char_buffer & 0x3f) << 3) | (m_ypos & 7)];
Expand All @@ -62,10 +62,10 @@ void zx_state::refresh_w(offs_t offset, uint8_t data)
void zx_state::recalc_hsync()
{
uint64_t time = machine().time().as_ticks(m_maincpu->clock());
uint32_t step = (time - m_base_vsync_clock) % 207;
uint32_t step = (time - m_base_vsync_clock) % m_const;
uint32_t delta;
if (m_hsync_active)
delta = 207 - step;
delta = m_const - step;
else {
if(step < 192)
delta = 192 - step;
Expand All @@ -87,9 +87,9 @@ uint8_t zx_state::ula_low_r(offs_t offset)

if(m_nmi_on) {
uint64_t time = m_maincpu->total_cycles();
int pos = (time-m_base_vsync_clock) % 207;
int pos = (time-m_base_vsync_clock) % m_const;
if(pos >= 192)
m_maincpu->adjust_icount(pos - 207);
m_maincpu->adjust_icount(pos - m_const);
}
return cdata;
}
Expand All @@ -106,9 +106,9 @@ uint8_t zx_state::ula_high_r(offs_t offset)

if(m_nmi_on) {
uint64_t time = m_maincpu->total_cycles();
int pos = (time-m_base_vsync_clock) % 207;
int pos = (time-m_base_vsync_clock) % m_const;
if(pos >= 192)
m_maincpu->adjust_icount(pos - 207);
m_maincpu->adjust_icount(pos - m_const);
}

if(cdata & 0x40)
Expand Down

0 comments on commit c644684

Please sign in to comment.