From: Wouter V. <m97...@us...> - 2013-12-29 21:14:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "openMSX (main)". The branch, master has been updated via 6ff459214a189857979f0be6203420489dcf5904 (commit) from 63fb16423d2544808f50332a804dae02e6b24d51 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6ff459214a189857979f0be6203420489dcf5904 Author: wouter <ver...@gm...> Date: Sun Dec 29 22:13:29 2013 +0100 Fixed VRAM corruption with 40MHz Z80 See sd_snatcher's post of 29-12-2013, 01:02 here: http://www.msx.org/forum/msx-talk/openmsx/wanted-feedback-mac-os-x-users?page=8 The (remaining) problem was not that there was too fast VRAM access (two accesses too fast after each other) but that the VRAM address registers were already changed before the request was actually executed. See comments in code for more details. ----------------------------------------------------------------------- Summary of changes: src/video/VDP.cc | 23 ++++++++++++++++++++++- src/video/VDP.hh | 3 ++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/video/VDP.cc b/src/video/VDP.cc index 948403b..e1600fb 100644 --- a/src/video/VDP.cc +++ b/src/video/VDP.cc @@ -834,6 +834,7 @@ void VDP::scheduleCpuVramAccess(bool isRead, byte write, EmuTime::param time) // E.g. OUT (#98),A followed by IN A,(#98) returns the just written value. if (!isRead) cpuVramData = write; cpuVramReqIsRead = isRead; + cpuVramReqAddr = (controlRegs[14] << 14) | vramPointer; // see below if (unlikely(cpuAccessScheduled())) { // Already scheduled. Do nothing. // The old request has been overwritten by the new request! @@ -845,7 +846,24 @@ void VDP::scheduleCpuVramAccess(bool isRead, byte write, EmuTime::param time) void VDP::executeCpuVramAccess(EmuTime::param time) { - int addr = (controlRegs[14] << 14) | vramPointer; + // We don't know whether the vram address is calculated now or already + // when the vram request gets scheduled. It's also not possible to test + // this difference on real HW (AFAIK). Though it does make a difference + // when e.g. emulating an overclocked Z80 (40Mhz) in combination with + // 'too_fast_vram_access=ignore'. See also this forum post: + // http://www.msx.org/forum/msx-talk/openmsx/wanted-feedback-mac-os-x-users?pa + // sd_snatcher's post of 29-12-2013, 01:02 + // If I have to guess then I'd say the address is only calculated at + // this moment because that saves some hardware registers, and looking + // at the rest of the VDP design, the Yamaha engineers really tried to + // save registers whenever possible. + // Still, to fix the artificial turbo-Z80 scenario, we now calculate + // the address early. + // It's possible that once we emulate proper turbo-Z80 emulation (switch + // back to 3.5MHz speed when accessing the VDP) we can remove this part + // again from the VDP emulation. + //int addr = (controlRegs[14] << 14) | vramPointer; + int addr = cpuVramReqAddr; if (displayMode.isPlanar()) { // note: also extended VRAM is interleaved, // because there is only 64kB it's interleaved @@ -1558,6 +1576,9 @@ void VDP::serialize(Archive& ar, unsigned version) } else { ar.serialize("readAhead", cpuVramData); } + if (ar.versionAtLeast(version, 6)) { + ar.serialize("cpuVramReqAddr", cpuVramReqAddr); + } ar.serialize("cpuExtendedVram", cpuExtendedVram); ar.serialize("displayEnabled", displayEnabled); byte mode = displayMode.getByte(); diff --git a/src/video/VDP.hh b/src/video/VDP.hh index 2b8ead4..9360a23 100644 --- a/src/video/VDP.hh +++ b/src/video/VDP.hh @@ -875,6 +875,7 @@ private: * variable indicates whether the pending request is read or write. */ bool cpuVramReqIsRead; + unsigned cpuVramReqAddr; /** Does CPU interface access main VRAM (false) or extended VRAM (true)? * This is determined by MXC (R#45, bit 6). @@ -902,7 +903,7 @@ private: /** Cached version of tooFastAccess setting. */ bool allowTooFastAccess; }; -SERIALIZE_CLASS_VERSION(VDP, 5); +SERIALIZE_CLASS_VERSION(VDP, 6); } // namespace openmsx hooks/post-receive -- openMSX (main) |