diff --git a/src/mame/sinclair/zx.h b/src/mame/sinclair/zx.h index 2993bab875e..932cb485d89 100644 --- a/src/mame/sinclair/zx.h +++ b/src/mame/sinclair/zx.h @@ -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; diff --git a/src/mame/sinclair/zx_m.cpp b/src/mame/sinclair/zx_m.cpp index dd4b74e8001..847171f5c3d 100644 --- a/src/mame/sinclair/zx_m.cpp +++ b/src/mame/sinclair/zx_m.cpp @@ -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() @@ -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++; @@ -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; } } @@ -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; @@ -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; diff --git a/src/mame/sinclair/zx_v.cpp b/src/mame/sinclair/zx_v.cpp index 0aea732383f..9347dc7eb2f 100644 --- a/src/mame/sinclair/zx_v.cpp +++ b/src/mame/sinclair/zx_v.cpp @@ -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)]; @@ -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; @@ -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; } @@ -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)