Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.7KB

  1. //---
  2. // gint:display-cg - fxcg50 rendering functions
  3. //
  4. // This module covers all 16-bit opaque rendering functions. For
  5. // gamma-related functions, color composition, check out a color library.
  6. //
  7. // All the functions in this module work on a 396x224 resolution - gint
  8. // lets you use the full surface!
  9. //---
  10. #ifndef GINT_DISPLAY_CG
  11. #define GINT_DISPLAY_CG
  12. #ifdef FXCG50
  13. #include <gint/defs/types.h>
  14. /* Dimensions of the VRAM */
  15. #define DWIDTH 396
  16. #define DHEIGHT 224
  17. /* gint VRAM address. This value must always point to a 32-aligned bufer of
  18. size 177408. Any function can use it freely to perform rendering or store
  19. data when not drawing. Triple buffering is already implemented in gint, see
  20. the dvram() function below.
  21. In this module, colors are in the 16-bit big-endian R5G6B5 format, as it is
  22. the format used by the display controller. */
  23. extern uint16_t *gint_vram;
  24. /* Provide a platform-agnostic definition of color_t.
  25. Some functions also support transparency, in which case they take an [int]
  26. as argument and recognize negative values as transparent. */
  27. typedef uint16_t color_t;
  28. enum {
  29. /* Compatibility with fx9860g color names */
  30. C_WHITE = 0xffff,
  31. C_LIGHT = 0xaaaa,
  32. C_DARK = 0x5555,
  33. C_BLACK = 0x0000,
  34. /* Other colors */
  35. C_RED = 0xf800,
  36. C_GREEN = 0x07e0,
  37. C_BLUE = 0x001f,
  38. C_NONE = -1,
  39. };
  40. /* RGB color maker. Takes three channels of value 0..31 each (the extra bit of
  41. green is not used). */
  42. #define C_RGB(r,g,b) (((r) << 11) | ((g) << 6) | (b))
  43. //---
  44. // Image rendering (bopti)
  45. //---
  46. /* image_t: Image files encoded for bopti
  47. This format is created by the fxSDK's [fxconv] tool from standard images. */
  48. typedef struct
  49. {
  50. /* Color profile (type of palette), could be extended into a bit field
  51. later on */
  52. uint16_t profile;
  53. /* Color code assigned to transparent pixels (unused in 16-bit) */
  54. uint16_t alpha;
  55. /* Full width and height, in pixels */
  56. uint16_t width;
  57. uint16_t height;
  58. /* Color palette:
  59. * 16-bit and 16-bit alpha: none
  60. * 8-bit: 256 colors (total 512 bytes)
  61. * 4-bit: 16 colors (total 32 bytes)
  62. Then raw pixel data in row-major order. */
  63. uint16_t data[];
  64. } GPACKED(4) image_t;
  65. //---
  66. // Video RAM management
  67. //---
  68. /* dvram() - Control video RAM address and triple buffering
  69. Normal rendering under gint uses double-buffering: there is one image
  70. displayed on the screen and one in memory, in a region called the video RAM
  71. (VRAM). The application draws frames in the VRAM then sends them to the
  72. screen only when they are finished, using dupdate().
  73. On fxcg50, the performance bottleneck is almost always the graphical
  74. rendering (especially in games) because the high amount of data, 173 kB per
  75. frame in full-resolution, makes graphics manipulation computationally
  76. expensive. The transfer also takes about 10 ms in itself.
  77. Since gint transfers data to the screen using the DMA, it is possible to run
  78. the application while the finished frame is being transferred. However,
  79. writing to the VRAM during this period will cause display artifacts since
  80. the VRAM it is still being read by the DMA.
  81. The solution to this is to use triple-buffering with the display and two
  82. VRAMs that are alternately being written to while the other is being
  83. transferred. The VRAM switching is handled by dupdate() and is activated
  84. whenever two VRAMs are configured.
  85. By default gint uses triple buffering with two VRAMs in the system stack.
  86. VRAMs must be contiguous, 32-aligned, (2*396*224)-byte buffers.
  87. @main Main VRAM area, used alone if [secondary] is NULL
  88. @secondary Additional VRAM area, enables triple buffering if non-NULL */
  89. void dvram(uint16_t *main, uint16_t *secondary);
  90. #endif /* FXCG50 */
  91. #endif /* GINT_DISPLAY_CG */