lol its in c
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.

40 lines
1.3 KiB

  1. #ifndef GBSDK_VIDEO_H
  2. #define GBSDK_VIDEO_H
  3. #include <stdint.h>
  4. #include <sdk/hardware.h>
  5. //Turn off the LCD, with the proper checks that this happens during VBLANK
  6. void lcd_off(void) __preserves_regs(b, c, d, e, h, l);
  7. //Copy to VRAM with STAT checks, so these function are safe to write to VRAM at any time.
  8. void vram_memcpy(uint16_t dst, void* src, uint16_t size) __preserves_regs(b, c);
  9. void vram_memset(uint16_t dst, uint8_t value, uint16_t size) __preserves_regs(b, c);
  10. inline void vram_set(uint16_t dst, uint8_t value) {
  11. while(rSTAT & STAT_BUSY) {}
  12. *((uint8_t*)dst) = value;
  13. }
  14. #if CGB
  15. #define PAL24(rgb) (((rgb & 0xF80000) >> 19) | ((rgb & 0x00F800) >> 6) | ((rgb & 0x0000F8) << 7))
  16. void cgb_background_palette(uint16_t* palette) __preserves_regs(b, c);
  17. void cgb_object_palette(uint16_t* palette) __preserves_regs(b, c);
  18. inline void cgb_gdma(uint16_t dst, const void* src, uint8_t count) {
  19. rHDMA1 = ((uint16_t)src) >> 8;
  20. rHDMA2 = ((uint16_t)src) & 0xFF;
  21. rHDMA3 = dst >> 8;
  22. rHDMA4 = dst & 0xFF;
  23. rHDMA5 = count - 1;
  24. }
  25. inline void cgb_hdma(uint16_t dst, const void* src, uint8_t count) {
  26. rHDMA1 = ((uint16_t)src) >> 8;
  27. rHDMA2 = ((uint16_t)src) & 0xFF;
  28. rHDMA3 = dst >> 8;
  29. rHDMA4 = dst & 0xFF;
  30. rHDMA5 = (count - 1) | 0x80;
  31. }
  32. #endif
  33. #endif//GBSDK_VIDEO_H