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 
9 namespace openmsx {
10 
11 class V9990;
12 
15 class V9990VRAM
16 {
17 public:
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  static inline unsigned transformBx(unsigned address) {
38  return ((address & 1) << 18) | ((address & 0x7FFFE) >> 1);
39  }
40  static inline unsigned transformP1(unsigned address) {
41  return address;
42  }
43  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  inline byte readVRAMBx(unsigned address) {
55  return data[transformBx(address)];
56  }
57  inline byte readVRAMP1(unsigned address) {
58  return data[transformP1(address)];
59  }
60  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  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  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 
89 private:
90  unsigned mapAddress(unsigned address);
91 
94  V9990& vdp;
95 
96  V9990CmdEngine* cmdEngine;
97 
100  TrackedRam data;
101 };
102 
103 } // namespace openmsx
104 
105 #endif
openmsx::V9990VRAM::readVRAMDirect
byte readVRAMDirect(unsigned address)
Definition: V9990VRAM.hh:74
openmsx::V9990VRAM
Video RAM for the V9990.
Definition: V9990VRAM.hh:15
openmsx::V9990CmdEngine
Command engine.
Definition: V9990CmdEngine.hh:20
openmsx.hh
openmsx::V9990VRAM::VRAM_SIZE
static constexpr unsigned VRAM_SIZE
VRAM Size.
Definition: V9990VRAM.hh:20
openmsx::V9990VRAM::writeVRAMBx
void writeVRAMBx(unsigned address, byte value)
Definition: V9990VRAM.hh:64
openmsx::V9990VRAM::readVRAMBx
byte readVRAMBx(unsigned address)
Definition: V9990VRAM.hh:54
openmsx::V9990VRAM::clear
void clear()
Definition: V9990VRAM.cc:15
openmsx::V9990VRAM::readVRAMP2
byte readVRAMP2(unsigned address)
Definition: V9990VRAM.hh:60
openmsx::V9990VRAM::setCmdEngine
void setCmdEngine(V9990CmdEngine &cmdEngine_)
Definition: V9990VRAM.hh:84
openmsx::V9990VRAM::transformP2
static unsigned transformP2(unsigned address)
Definition: V9990VRAM.hh:43
openmsx::V9990
V9990
Definition: V9990.cc:974
openmsx::V9990VRAM::transformP1
static unsigned transformP1(unsigned address)
Definition: V9990VRAM.hh:40
openmsx::V9990VRAM::transformBx
static unsigned transformBx(unsigned address)
Definition: V9990VRAM.hh:37
openmsx::V9990VRAM::serialize
void serialize(Archive &ar, unsigned version)
Definition: V9990VRAM.cc:55
V9990CmdEngine.hh
openmsx::V9990VRAM::readVRAMP1
byte readVRAMP1(unsigned address)
Definition: V9990VRAM.hh:57
TrackedRam.hh
openmsx::V9990CmdEngine::sync
void sync(EmuTime::param time)
Synchronises the command engine with the V9990.
Definition: V9990CmdEngine.hh:40
openmsx::TrackedRam::write
void write(unsigned addr, byte value)
Definition: TrackedRam.hh:38
openmsx::V9990VRAM::sync
void sync(EmuTime::param time)
Update VRAM state to specified moment in time.
Definition: V9990VRAM.hh:33
EmuTime.hh
openmsx::V9990VRAM::readVRAMCPU
byte readVRAMCPU(unsigned address, EmuTime::param time)
Definition: V9990VRAM.cc:41
openmsx::V9990VRAM::writeVRAMDirect
void writeVRAMDirect(unsigned address, byte value)
Definition: V9990VRAM.hh:77
openmsx::V9990VRAM::V9990VRAM
V9990VRAM(V9990 &vdp, EmuTime::param time)
Construct V9990 VRAM.
Definition: V9990VRAM.cc:8
openmsx::V9990VRAM::writeVRAMCPU
void writeVRAMCPU(unsigned address, byte val, EmuTime::param time)
Definition: V9990VRAM.cc:48
openmsx::V9990VRAM::writeVRAMP2
void writeVRAMP2(unsigned address, byte value)
Definition: V9990VRAM.hh:70
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::V9990VRAM::writeVRAMP1
void writeVRAMP1(unsigned address, byte value)
Definition: V9990VRAM.hh:67
openmsx::TrackedRam
Definition: TrackedRam.hh:9
openmsx::V9990
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition: V9990.hh:30