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
Implementation of the Yamaha V9990 VDP as used in the GFX9000 cartridge by Sunrise.
Definition: V9990.hh:29
void writeVRAMP2(unsigned address, byte value)
Definition: V9990VRAM.hh:70
void sync(EmuTime::param time)
Synchronises the command engine with the V9990.
void writeVRAMP1(unsigned address, byte value)
Definition: V9990VRAM.hh:67
V9990VRAM(V9990 &vdp, EmuTime::param time)
Construct V9990 VRAM.
Definition: V9990VRAM.cc:8
void writeVRAMCPU(unsigned address, byte val, EmuTime::param time)
Definition: V9990VRAM.cc:48
byte readVRAMCPU(unsigned address, EmuTime::param time)
Definition: V9990VRAM.cc:41
byte readVRAMBx(unsigned address)
Definition: V9990VRAM.hh:54
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void writeVRAMBx(unsigned address, byte value)
Definition: V9990VRAM.hh:64
static constexpr unsigned VRAM_SIZE
VRAM Size.
Definition: V9990VRAM.hh:20
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 unsigned transformP1(unsigned address)
Definition: V9990VRAM.hh:40
byte readVRAMP2(unsigned address)
Definition: V9990VRAM.hh:60
static unsigned transformP2(unsigned address)
Definition: V9990VRAM.hh:43
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
static unsigned transformBx(unsigned address)
Definition: V9990VRAM.hh:37
Video RAM for the V9990.
Definition: V9990VRAM.hh:15
byte readVRAMDirect(unsigned address)
Definition: V9990VRAM.hh:74
void writeVRAMDirect(unsigned address, byte value)
Definition: V9990VRAM.hh:77
void setCmdEngine(V9990CmdEngine &cmdEngine_)
Definition: V9990VRAM.hh:84
void serialize(Archive &ar, unsigned version)
Definition: V9990VRAM.cc:55
void write(unsigned addr, byte value)
Definition: TrackedRam.hh:38