36VDPVRAM::LogicalVRAMDebuggable::LogicalVRAMDebuggable(
VDP& vdp_)
37 : SimpleDebuggable(vdp_.getMotherBoard(), vdp_.getName() ==
"VDP" ?
"VRAM" :
38 vdp_.getName() +
" VRAM",
39 "CPU view on video RAM given the current display mode.",
47 return vram.vdp.getDisplayMode().isPlanar()
48 ? ((address << 16) | (address >> 1)) & 0x1FFFF
52byte VDPVRAM::LogicalVRAMDebuggable::read(
unsigned address, EmuTime::param time)
55 return vram.cpuRead(
transform(address), time);
58void VDPVRAM::LogicalVRAMDebuggable::write(
59 unsigned address,
byte value, EmuTime::param time)
62 vram.cpuWrite(
transform(address), value, time);
68VDPVRAM::PhysicalVRAMDebuggable::PhysicalVRAMDebuggable(
69 VDP& vdp_,
unsigned actualSize_)
70 : SimpleDebuggable(vdp_.getMotherBoard(), vdp_.getName() ==
"VDP" ?
71 "physical VRAM" :
strCat(
"physical ", vdp_.getName(),
" VRAM"),
72 "VDP-screen-mode-independent view on the video RAM.",
77byte VDPVRAM::PhysicalVRAMDebuggable::read(
unsigned address, EmuTime::param time)
80 return vram.cpuRead(address, time);
83void VDPVRAM::PhysicalVRAMDebuggable::write(
84 unsigned address,
byte value, EmuTime::param time)
87 vram.cpuWrite(address, value, time);
93static constexpr unsigned bufferSize(
unsigned size)
105 , data(*vdp_.getDeviceConfig2().getXML(), bufferSize(
size))
106 , logicalVRAMDebug (vdp)
107 , physicalVRAMDebug(vdp,
size)
109 , vramTime(EmuTime::zero())
112 , vrMode(vdp.getVRMode())
113 , cmdReadWindow(data)
114 , cmdWriteWindow(data)
118 , bitmapVisibleWindow(data)
119 , bitmapCacheWindow(data)
120 , spriteAttribTable(data)
121 , spritePatternTable(data)
135 if (data.
size() != actualSize) {
136 assert(data.
size() > actualSize);
155 cmdEngine->
sync(time);
163 cmdEngine->
sync(time);
168void VDPVRAM::setSizeMask(EmuTime::param time)
170 unsigned newSizeMask = (
173 ? (std::bit_ceil(actualSize) - 1) | (1u << 16)
175 : (
std::
min(
std::bit_ceil(actualSize), 0x4000u) - 1) | (1u << 14)
188 sizeMask = newSizeMask;
190static constexpr unsigned swapAddr(
unsigned x)
196 return 1 | ((x & 0x007F) << 1) | ((x & 0x7FC0) << 2);
200 if (vrMode == newVRmode) {
210 for (
int i = 0x7FFF; i >=0; --i) {
215 for (
auto i :
xrange(0x8000)) {
223 renderer = newRenderer;
278 std::array<byte, 0x4000> tmp;
281 for (
unsigned addr8 = 0; addr8 < 0x4000; addr8 += 64) {
282 unsigned addr4 = (addr8 & 0x203F) |
283 ((addr8 & 0x1000) >> 6) |
284 ((addr8 & 0x0FC0) << 1);
286 subspan<64>(tmp, addr4));
290 for (
unsigned addr4 = 0; addr4 < 0x4000; addr4 += 64) {
291 unsigned addr8 = (addr4 & 0x203F) |
292 ((addr4 & 0x0040) << 6) |
293 ((addr4 & 0x1F80) >> 1);
295 subspan<64>(tmp, addr8));
303template<
typename Archive>
306 ar.serialize(
"baseAddr", baseAddr,
307 "baseMask", origBaseMask,
308 "indexMask", indexMask);
309 if constexpr (Archive::IS_LOADER) {
310 effectiveBaseMask = origBaseMask & sizeMask;
311 combiMask = ~effectiveBaseMask | indexMask;
316template<
typename Archive>
319 if constexpr (Archive::IS_LOADER) {
321 setSizeMask(
static_cast<MSXDevice&
>(vdp).getCurrentTime());
324 ar.serialize_blob(
"data", std::span{data.
data(), actualSize});
Represents a VDP display mode.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Abstract base class for Renderers.
virtual void updateDisplayMode(DisplayMode mode, EmuTime::param time)=0
Informs the renderer of a VDP display mode change.
virtual void updateSpritesEnabled(bool enabled, EmuTime::param time)=0
Informs the renderer of a VDP sprites enabled change.
virtual void updateDisplayEnabled(bool enabled, EmuTime::param time)=0
Informs the renderer of a VDP display enabled change.
void updateDisplayMode(DisplayMode mode, EmuTime::param time)
Informs the sprite checker of a VDP display mode change.
void updateDisplayEnabled(bool enabled, EmuTime::param time)
Informs the sprite checker of a VDP display enabled change.
void updateSpritesEnabled(bool enabled, EmuTime::param time)
Informs the sprite checker of sprite enable changes.
void updateDisplayMode(DisplayMode mode, bool cmdBit, EmuTime::param time)
Informs the command engine of a VDP display mode change.
void sync(EmuTime::param time)
Synchronizes the command engine with the VDP.
Manages VRAM contents and synchronizes the various users of the VRAM.
void updateSpritesEnabled(bool enabled, EmuTime::param time)
Used by the VDP to signal sprites enabled changes.
VRAMWindow spriteAttribTable
void clear()
Initialize VRAM content to power-up state.
void setRenderer(Renderer *renderer, EmuTime::param time)
void updateVRMode(bool mode, EmuTime::param time)
Change between VR=0 and VR=1 mode.
VRAMWindow bitmapCacheWindow
void updateDisplayEnabled(bool enabled, EmuTime::param time)
Used by the VDP to signal display enabled changes.
void updateDisplayMode(DisplayMode mode, bool cmdBit, EmuTime::param time)
Used by the VDP to signal display mode changes.
VRAMWindow bitmapVisibleWindow
void serialize(Archive &ar, unsigned version)
VRAMWindow spritePatternTable
VRAMWindow cmdWriteWindow
void change4k8kMapping(bool mapping8k)
TMS99x8 VRAM can be mapped in two ways.
Unified implementation of MSX Video Display Processors (VDPs).
bool isInsideFrame(EmuTime::param time) const
Is the given timestamp inside the current frame? Mainly useful for debugging, because relevant timest...
bool getVRMode() const
Returns current VR mode.
void setMask(unsigned newBaseMask, unsigned newIndexMask, unsigned newSizeMask, EmuTime::param time)
Sets the mask and enables this window.
void serialize(Archive &ar, unsigned version)
void setSizeMask(unsigned newSizeMask, EmuTime::param time)
Inform VRAMWindow of changed sizeMask.
VRAMWindow(const VRAMWindow &)=delete
void setObserver(VRAMObserver *newObserver)
Register an observer on this VRAM window.
void resetObserver()
Unregister the observer of this VRAM window.
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
This file implemented 3 utility functions:
constexpr void fill(ForwardRange &&range, const T &value)
auto copy(InputRange &&range, OutputIter out)
auto transform(InputRange &&range, OutputIter out, UnaryOperation op)
void swap(openmsx::MemBuffer< T > &l, openmsx::MemBuffer< T > &r) noexcept
size_t size(std::string_view utf8)
#define OUTER(type, member)
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
std::string strCat(Ts &&...ts)
constexpr auto xrange(T e)