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