ADVram.hh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef ADVRAM_HH
  2. #define ADVRAM_HH
  3. #include "MSXDevice.hh"
  4. namespace openmsx {
  5. class VDP;
  6. class VDPVRAM;
  7. /** Implementation of direct cpu access to VRAM. ADVram (Accesso
  8. * Direito à Vram is a rare hardware modification that allows the
  9. * CPU to access the video ram in the same way as ordinary ram.
  10. */
  11. class ADVram final : public MSXDevice
  12. {
  13. public:
  14. explicit ADVram(const DeviceConfig& config);
  15. /** This method is called on reset. Reset the mapper register and
  16. * the planar bit, if the device is configured with an enable bit
  17. * then that bit is reset as well.
  18. */
  19. void reset(EmuTime::param time) override;
  20. /** Read a byte from an IO port, change mode bits. The planar bit
  21. * and possibly the enable bit are set according to address lines
  22. * that are normally ignored for IO reads. Returns 255.
  23. */
  24. byte readIO(word port, EmuTime::param time) override;
  25. // default peekIO() implementation is ok.
  26. /** Write a byte to a given IO port, set mapper register. */
  27. void writeIO(word port, byte value, EmuTime::param time) override;
  28. /** Read a byte from a location in the video ram at a certain
  29. * time. If the device is enabled then the value returned comes
  30. * from the video ram, otherwise it returns 255.
  31. */
  32. byte readMem(word address, EmuTime::param time) override;
  33. /** Write a given byte at a certain time to a given location in
  34. * the video ram. If the device is enabled then the write is
  35. * redirected to the video ram, if it is not, nothing happens.
  36. */
  37. void writeMem(word address, byte value, EmuTime::param time) override;
  38. template<typename Archive>
  39. void serialize(Archive& ar, unsigned version);
  40. private:
  41. void init() override;
  42. inline unsigned calcAddress(word address) const;
  43. VDP* vdp;
  44. VDPVRAM* vram;
  45. /** Bit mask applied to logical addresses, reflects vram size. */
  46. /*const*/ unsigned mask;
  47. /** Base address of selected page in vram. */
  48. unsigned baseAddr;
  49. /** True if ADVram device is enabled. */
  50. bool enabled;
  51. /** True if ADVram device can be switched on or off by performing
  52. IO-reads. */
  53. const bool hasEnable;
  54. /** True if address bits are shuffled as is appropriate for screen
  55. 7 and higher. */
  56. bool planar;
  57. };
  58. } // namespace openmsx
  59. #endif // ADVRAM_HH