openMSX
V9990VRAM.hh
Go to the documentation of this file.
1#ifndef V9990VRAM_HH
2#define V9990VRAM_HH
3
4#include "V9990CmdEngine.hh"
5#include "TrackedRam.hh"
6#include "EmuTime.hh"
7#include "openmsx.hh"
8
9namespace openmsx {
10
11class V9990;
12
16{
17public:
20 static constexpr unsigned VRAM_SIZE = 512 * 1024; // 512kB
21
26 V9990VRAM(V9990& vdp, EmuTime::param time);
27
28 void clear();
29
33 inline void sync(EmuTime::param time) {
34 cmdEngine->sync(time);
35 }
36
37 [[nodiscard]] static inline unsigned transformBx(unsigned address) {
38 return ((address & 1) << 18) | ((address & 0x7FFFE) >> 1);
39 }
40 [[nodiscard]] static inline unsigned transformP1(unsigned address) {
41 return address;
42 }
43 [[nodiscard]] static inline unsigned transformP2(unsigned address) {
44 // Verified on a real Graphics9000
45 if (address < 0x78000) {
46 return transformBx(address);
47 } else if (address < 0x7C000) {
48 return address - 0x3C000;
49 } else {
50 return address;
51 }
52 }
53
54 [[nodiscard]] inline byte readVRAMBx(unsigned address) {
55 return data[transformBx(address)];
56 }
57 [[nodiscard]] inline byte readVRAMP1(unsigned address) {
58 return data[transformP1(address)];
59 }
60 [[nodiscard]] inline byte readVRAMP2(unsigned address) {
61 return data[transformP2(address)];
62 }
63
64 inline void writeVRAMBx(unsigned address, byte value) {
65 data.write(transformBx(address), value);
66 }
67 inline void writeVRAMP1(unsigned address, byte value) {
68 data.write(transformP1(address), value);
69 }
70 inline void writeVRAMP2(unsigned address, byte value) {
71 data.write(transformP2(address), value);
72 }
73
74 [[nodiscard]] inline byte readVRAMDirect(unsigned address) {
75 return data[address];
76 }
77 inline void writeVRAMDirect(unsigned address, byte value) {
78 data.write(address, value);
79 }
80
81 [[nodiscard]] byte readVRAMCPU(unsigned address, EmuTime::param time);
82 void writeVRAMCPU(unsigned address, byte val, EmuTime::param time);
83
84 void setCmdEngine(V9990CmdEngine& cmdEngine_) { cmdEngine = &cmdEngine_; }
85
86 template<typename Archive>
87 void serialize(Archive& ar, unsigned version);
88
89private:
90 unsigned mapAddress(unsigned address);
91
92private:
95 V9990& vdp;
96
97 V9990CmdEngine* cmdEngine = nullptr;
98
101 TrackedRam data;
102};
103
104} // namespace openmsx
105
106#endif
void write(size_t addr, byte value)
Definition: TrackedRam.hh:41
void sync(EmuTime::param time)
Synchronizes the command engine with the V9990.
Video RAM for the V9990.
Definition: V9990VRAM.hh:16
void writeVRAMCPU(unsigned address, byte val, EmuTime::param time)
Definition: V9990VRAM.cc:46
void writeVRAMP2(unsigned address, byte value)
Definition: V9990VRAM.hh:70
V9990VRAM(V9990 &vdp, EmuTime::param time)
Construct V9990 VRAM.
Definition: V9990VRAM.cc:7
void writeVRAMP1(unsigned address, byte value)
Definition: V9990VRAM.hh:67
byte readVRAMDirect(unsigned address)
Definition: V9990VRAM.hh:74
void serialize(Archive &ar, unsigned version)
Definition: V9990VRAM.cc:53
byte readVRAMP1(unsigned address)
Definition: V9990VRAM.hh:57
void sync(EmuTime::param time)
Update VRAM state to specified moment in time.
Definition: V9990VRAM.hh:33
static constexpr unsigned VRAM_SIZE
VRAM Size.
Definition: V9990VRAM.hh:20
byte readVRAMCPU(unsigned address, EmuTime::param time)
Definition: V9990VRAM.cc:39
void writeVRAMDirect(unsigned address, byte value)
Definition: V9990VRAM.hh:77
void setCmdEngine(V9990CmdEngine &cmdEngine_)
Definition: V9990VRAM.hh:84
static unsigned transformP2(unsigned address)
Definition: V9990VRAM.hh:43
void writeVRAMBx(unsigned address, byte value)
Definition: V9990VRAM.hh:64
static unsigned transformBx(unsigned address)
Definition: V9990VRAM.hh:37
byte readVRAMP2(unsigned address)
Definition: V9990VRAM.hh:60
byte readVRAMBx(unsigned address)
Definition: V9990VRAM.hh:54
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:34
This file implemented 3 utility functions:
Definition: Autofire.cc:9