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