Advertisement
Guest User

GBVideo

a guest
Mar 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.13 KB | None | 0 0
  1. #ifndef __GBV_H__
  2. #define __GBV_H__
  3.  
  4. #define GBV_TILE_MEMORY_SIZE   6144
  5. #define GBV_BG_MAP_MEMORY_SIZE 1024
  6. #define GBV_OAM_MEMORY_SIZE    160
  7.  
  8. typedef char           gbv_s8;
  9. typedef short          gbv_s16;
  10. typedef unsigned char  gbv_u8;
  11. typedef unsigned short gbv_u16;
  12.  
  13. typedef unsigned char  gbv_io;
  14.  
  15. typedef enum {
  16.     GBV_RENDER_MODE_GRAYSCALE_8,    // 0-255
  17.     GBV_RENDER_MODE_GRAYSCALE_F32,  // normalized in intervale [0,1)
  18. } gbv_render_mode;
  19.  
  20. typedef struct {
  21.     gbv_u8 colors[4];
  22. } gbv_palette;
  23.  
  24. typedef enum {
  25.     GBV_LCDC_BG_ENABLE = 0x01,  /* enable bg display */
  26.     GBV_LCDC_OBJ_ENABLE = 0x02, /* enable obj display */
  27.     GBV_LCDC_OBJ_SIZE_SELECT = 0x04,    /* enable 8x16 obj mode */
  28.     GBV_LCDC_BG_MAP_SELECT = 0x08,  /* bg tile map display select */
  29.     GBV_LCDC_BG_DATA_SELECT = 0x10, /* bg & wnd tile data select */
  30.     GBV_LCDC_WND_ENABLE = 0x20, /* enable wnd display */
  31.     GBV_LCDC_WND_MAP_SELECT = 0x40, /* wnd tile map display select */
  32.     GBV_LCDC_CTRL = 0x80,   /* enable lcd */
  33. } gbv_lcdc_flag;
  34.  
  35. /*****************************/
  36. /*** I/O control registers ***/
  37. /*****************************/
  38.  
  39. /* lcd control */
  40. extern gbv_io gbv_io_lcdc;
  41.  
  42. /*
  43.     palettes:
  44.         - defined as 4 packed colors at 2 bits per color
  45.         - for objects, 00 means transparent
  46.  */
  47. extern gbv_io gbv_io_bgp;
  48. extern gbv_io gbv_io_obp0;
  49. extern gbv_io gbv_io_obp1;
  50.  
  51. /* bg scroll registers */
  52. extern gbv_io gbv_io_scx;
  53. extern gbv_io gbv_io_scy;
  54.  
  55. /* wnd position */
  56. extern gbv_io gbv_io_wx;
  57. extern gbv_io gbv_io_wy;
  58.  
  59. /*****************************/
  60. /************ API ************/
  61. /*****************************/
  62.  
  63. /* initialize system, provide 64k of memory */
  64. void gbv_init(void * memory);
  65.  
  66. /* utility function for lcd control */
  67. void gbv_lcdc_set(gbv_lcdc_flag flag);
  68. void gbv_lcdc_reset(gbv_lcdc_flag flag);
  69.  
  70. /* return raw pointers for data specification */
  71. gbv_u8 * ggbv_get_rom_data();
  72. gbv_u8 * gbv_get_tile_data();
  73. gbv_u8 * gbv_get_bg_map_data1();
  74. gbv_u8 * gbv_get_bg_map_data2();
  75. gbv_u8 * gbv_get_oam_data();
  76.  
  77. /* render all data to target buffer */
  78. void gbv_render(void * render_buffer, gbv_render_mode mode, gbv_palette * palette);
  79.  
  80. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement