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.

display-cg.h 3.5KB

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