CharacterConverter.hh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef CHARACTERCONVERTER_HH
  2. #define CHARACTERCONVERTER_HH
  3. #include "openmsx.hh"
  4. namespace openmsx {
  5. class VDP;
  6. class VDPVRAM;
  7. class DisplayMode;
  8. /** Utility class for converting VRAM contents to host pixels.
  9. */
  10. template <class Pixel>
  11. class CharacterConverter
  12. {
  13. public:
  14. /** Create a new bitmap scanline converter.
  15. * @param vdp The VDP of which the VRAM will be converted.
  16. * @param palFg Pointer to 16-entries array that specifies
  17. * VDP foreground color index to host pixel mapping.
  18. * This is kept as a pointer, so any changes to the palette
  19. * are immediately picked up by convertLine.
  20. * @param palBg Pointer to 16-entries array that specifies
  21. * VDP background color index to host pixel mapping.
  22. * This is kept as a pointer, so any changes to the palette
  23. * are immediately picked up by convertLine.
  24. */
  25. CharacterConverter(VDP& vdp, const Pixel* palFg, const Pixel* palBg);
  26. /** Convert a line of V9938 VRAM to 512 host pixels.
  27. * Call this method in non-planar display modes (Graphic4 and Graphic5).
  28. * @param linePtr Pointer to array where host pixels will be written to.
  29. * @param line Display line number [0..255].
  30. */
  31. void convertLine(Pixel* linePtr, int line);
  32. /** Select the display mode to use for scanline conversion.
  33. * @param mode The new display mode.
  34. */
  35. void setDisplayMode(DisplayMode mode);
  36. private:
  37. inline void renderText1 (Pixel* pixelPtr, int line);
  38. inline void renderText1Q (Pixel* pixelPtr, int line);
  39. inline void renderText2 (Pixel* pixelPtr, int line);
  40. inline void renderGraphic1(Pixel* pixelPtr, int line);
  41. inline void renderGraphic2(Pixel* pixelPtr, int line);
  42. inline void renderMulti (Pixel* pixelPtr, int line);
  43. inline void renderMultiQ (Pixel* pixelPtr, int line);
  44. inline void renderBogus (Pixel* pixelPtr);
  45. inline void renderBlank (Pixel* pixelPtr);
  46. inline void renderMultiHelper(Pixel* pixelPtr, int line,
  47. int mask, int patternQuarter);
  48. const byte* getNamePtr(int line, int scroll);
  49. VDP& vdp;
  50. VDPVRAM& vram;
  51. const Pixel* const palFg;
  52. const Pixel* const palBg;
  53. unsigned modeBase;
  54. };
  55. } // namespace openmsx
  56. #endif