openMSX
V9990VRAM.cc
Go to the documentation of this file.
1#include "V9990.hh"
2
3#include "V9990VRAM.hh"
4
5#include "serialize.hh"
6
7namespace openmsx {
8
9V9990VRAM::V9990VRAM(V9990& vdp_, EmuTime::param /*time*/)
10 : vdp(vdp_)
11 , data(vdp.getDeviceConfig2(), vdp.getName() + " VRAM",
12 "V9990 Video RAM", VRAM_SIZE)
13{
14}
15
17{
18 // Initialize memory. Alternate 0x00/0xff every 512 bytes.
19 std::span s = data.getWriteBackdoor();
20 assert((s.size() % 1024) == 0);
21 while (!s.empty()) {
22 ranges::fill(s.subspan( 0, 512), 0x00);
23 ranges::fill(s.subspan(512, 512), 0xff);
24 s = s.subspan(1024);
25 }
26}
27
28unsigned V9990VRAM::mapAddress(unsigned address) const
29{
30 address &= 0x7FFFF; // change to assert?
31 switch (vdp.getDisplayMode()) {
33 return transformP1(address);
35 return transformP2(address);
36 default /* Bx */:
37 return transformBx(address);
38 }
39}
40
41byte V9990VRAM::readVRAMCPU(unsigned address, EmuTime::param time)
42{
43 // note: used for both normal and debug read
44 sync(time);
45 return data[mapAddress(address)];
46}
47
48void V9990VRAM::writeVRAMCPU(unsigned address, byte value, EmuTime::param time)
49{
50 sync(time);
51 data.write(mapAddress(address), value);
52}
53
54template<typename Archive>
55void V9990VRAM::serialize(Archive& ar, unsigned /*version*/)
56{
57 ar.serialize("data", data);
58}
60
61} // namespace openmsx
void write(size_t addr, byte value)
Definition TrackedRam.hh:41
std::span< byte > getWriteBackdoor()
Definition TrackedRam.hh:55
Video RAM for the V9990.
Definition V9990VRAM.hh:17
void writeVRAMCPU(unsigned address, byte val, EmuTime::param time)
Definition V9990VRAM.cc:48
V9990VRAM(V9990 &vdp, EmuTime::param time)
Construct V9990 VRAM.
Definition V9990VRAM.cc:9
void serialize(Archive &ar, unsigned version)
Definition V9990VRAM.cc:55
void sync(EmuTime::param time)
Update VRAM state to specified moment in time.
Definition V9990VRAM.hh:34
byte readVRAMCPU(unsigned address, EmuTime::param time)
Definition V9990VRAM.cc:41
static unsigned transformP2(unsigned address)
Definition V9990VRAM.hh:44
static unsigned transformBx(unsigned address)
Definition V9990VRAM.hh:38
static unsigned transformP1(unsigned address)
Definition V9990VRAM.hh:41
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition V9990.hh:35
V9990DisplayMode getDisplayMode() const
Return the current display mode.
Definition V9990.hh:196
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr void fill(ForwardRange &&range, const T &value)
Definition ranges.hh:315
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)