Renderer.hh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #ifndef RENDERER_HH
  2. #define RENDERER_HH
  3. #include "VRAMObserver.hh"
  4. #include "openmsx.hh"
  5. #include <cstdint>
  6. namespace openmsx {
  7. class PostProcessor;
  8. class DisplayMode;
  9. class RawFrame;
  10. /** Abstract base class for Renderers.
  11. * A Renderer is a class that converts VDP state to visual
  12. * information (for example, pixels on a screen).
  13. *
  14. * The update methods are called exactly before the change occurs in
  15. * the VDP, so that the renderer can update itself to the specified
  16. * time using the old settings.
  17. */
  18. class Renderer : public VRAMObserver
  19. {
  20. public:
  21. virtual ~Renderer() = default;
  22. /** See VDP::getPostProcessor. */
  23. virtual PostProcessor* getPostProcessor() const = 0;
  24. /** Reinitialise Renderer state.
  25. */
  26. virtual void reInit() = 0;
  27. /** Signals the start of a new frame.
  28. * The Renderer can use this to get fixed-per-frame settings from
  29. * the VDP, such as PAL/NTSC timing.
  30. * @param time The moment in emulated time the frame starts.
  31. */
  32. virtual void frameStart(EmuTime::param time) = 0;
  33. /** Signals the end of a frame.
  34. * @param time The moment in emulated time the frame ends.
  35. * Note: this is the same time stamp as the start of the next frame.
  36. */
  37. virtual void frameEnd(EmuTime::param time) = 0;
  38. /** Informs the renderer of a VDP transparency enable/disable change.
  39. * @param enabled The new transparency state.
  40. * @param time The moment in emulated time this change occurs.
  41. */
  42. virtual void updateTransparency(bool enabled, EmuTime::param time) = 0;
  43. /** Informs the renderer of a VDP superimposing change.
  44. * @param videoSource Video that should be superimposed, nullptr if none.
  45. * @param time The moment in emulated time this change occurs.
  46. */
  47. virtual void updateSuperimposing(const RawFrame* videoSource,
  48. EmuTime::param time) = 0;
  49. /** Informs the renderer of a VDP foreground color change.
  50. * @param color The new foreground color.
  51. * @param time The moment in emulated time this change occurs.
  52. */
  53. virtual void updateForegroundColor(int color, EmuTime::param time) = 0;
  54. /** Informs the renderer of a VDP background color change.
  55. * @param color The new background color.
  56. * @param time The moment in emulated time this change occurs.
  57. */
  58. virtual void updateBackgroundColor(int color, EmuTime::param time) = 0;
  59. /** Informs the renderer of a VDP blink foreground color change.
  60. * @param color The new blink foreground color.
  61. * @param time The moment in emulated time this change occurs.
  62. */
  63. virtual void updateBlinkForegroundColor(int color, EmuTime::param time) = 0;
  64. /** Informs the renderer of a VDP blink background color change.
  65. * @param color The new blink background color.
  66. * @param time The moment in emulated time this change occurs.
  67. */
  68. virtual void updateBlinkBackgroundColor(int color, EmuTime::param time) = 0;
  69. /** Informs the renderer of a VDP blinking state change.
  70. * @param enabled The new blink state.
  71. * @param time The moment in emulated time this change occurs.
  72. */
  73. virtual void updateBlinkState(bool enabled, EmuTime::param time) = 0;
  74. /** Informs the renderer of a VDP palette change.
  75. * @param index The index [0..15] in the palette that changes.
  76. * @param grb The new definition for the changed palette index:
  77. * bit 10..8 is green, bit 6..4 is red and bit 2..0 is blue;
  78. * all other bits are zero.
  79. * @param time The moment in emulated time this change occurs.
  80. */
  81. virtual void updatePalette(int index, int grb, EmuTime::param time) = 0;
  82. /** Informs the renderer of a vertical scroll change.
  83. * @param scroll The new scroll value.
  84. * @param time The moment in emulated time this change occurs.
  85. */
  86. virtual void updateVerticalScroll(int scroll, EmuTime::param time) = 0;
  87. /** Informs the renderer of a horizontal scroll change:
  88. * the lower scroll value has changed.
  89. * @param scroll The new scroll value.
  90. * @param time The moment in emulated time this change occurs.
  91. */
  92. virtual void updateHorizontalScrollLow(byte scroll, EmuTime::param time) = 0;
  93. /** Informs the renderer of a horizontal scroll change:
  94. * the higher scroll value has changed.
  95. * @param scroll The new scroll value.
  96. * @param time The moment in emulated time this change occurs.
  97. */
  98. virtual void updateHorizontalScrollHigh(byte scroll, EmuTime::param time) = 0;
  99. /** Informs the renderer of a horizontal scroll change:
  100. * the border mask has been enabled/disabled.
  101. * @param masked true iff enabled.
  102. * @param time The moment in emulated time this change occurs.
  103. */
  104. virtual void updateBorderMask(bool masked, EmuTime::param time) = 0;
  105. /** Informs the renderer of a horizontal scroll change:
  106. * the multi page setting has changed.
  107. * @param multiPage The new multi page flag.
  108. * @param time The moment in emulated time this change occurs.
  109. */
  110. virtual void updateMultiPage(bool multiPage, EmuTime::param time) = 0;
  111. /** Informs the renderer of a horizontal adjust change.
  112. * Note that there is no similar method for vertical adjust updates,
  113. * because vertical adjust is calculated at start of frame and
  114. * then fixed.
  115. * @param adjust The new adjust value.
  116. * @param time The moment in emulated time this change occurs.
  117. */
  118. virtual void updateHorizontalAdjust(int adjust, EmuTime::param time) = 0;
  119. /** Informs the renderer of a VDP display enabled change.
  120. * Both the regular border start/end and forced blanking by clearing
  121. * the display enable bit are considered display enabled changes.
  122. * @param enabled The new display enabled state.
  123. * @param time The moment in emulated time this change occurs.
  124. */
  125. virtual void updateDisplayEnabled(bool enabled, EmuTime::param time) = 0;
  126. /** Informs the renderer of a VDP display mode change.
  127. * @param mode The new display mode.
  128. * @param time The moment in emulated time this change occurs.
  129. */
  130. virtual void updateDisplayMode(DisplayMode mode, EmuTime::param time) = 0;
  131. /** Informs the renderer of a name table base address change.
  132. * @param addr The new base address.
  133. * @param time The moment in emulated time this change occurs.
  134. */
  135. virtual void updateNameBase(int addr, EmuTime::param time) = 0;
  136. /** Informs the renderer of a pattern table base address change.
  137. * @param addr The new base address.
  138. * @param time The moment in emulated time this change occurs.
  139. */
  140. virtual void updatePatternBase(int addr, EmuTime::param time) = 0;
  141. /** Informs the renderer of a color table base address change.
  142. * @param addr The new base address.
  143. * @param time The moment in emulated time this change occurs.
  144. */
  145. virtual void updateColorBase(int addr, EmuTime::param time) = 0;
  146. /** Informs the renderer of a VDP sprites enabled change.
  147. * @param enabled The new sprites enabled state.
  148. * @param time The moment in emulated time this change occurs.
  149. */
  150. virtual void updateSpritesEnabled(bool enabled, EmuTime::param time) = 0;
  151. /** Sprite palette in Graphic 7 mode.
  152. * Each palette entry is a word in GRB format:
  153. * bit 10..8 is green, bit 6..4 is red and bit 2..0 is blue.
  154. */
  155. static const uint16_t GRAPHIC7_SPRITE_PALETTE[16];
  156. protected:
  157. Renderer() = default;
  158. };
  159. } // namespace openmsx
  160. #endif