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.

112 lines
3.5KB

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