GameBoy (Color) port of the GTA San Andreas arcade game Duality
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.

gbprinter.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * gbprinter.h
  3. * Duality
  4. *
  5. * Based on the gbprinter example from gbdk-2020:
  6. * https://github.com/gbdk-2020/gbdk-2020/tree/develop/gbdk-lib/examples/gb/gbprinter
  7. *
  8. * Copyright (C) 2025 Thomas Buck <thomas@xythobuz.de>
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * See <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef __GBPRINTER_H_INCLUDE__
  23. #define __GBPRINTER_H_INCLUDE__
  24. #include <gbdk/platform.h>
  25. #include <stdint.h>
  26. enum PRN_STATUS {
  27. // status flags from printer
  28. PRN_STATUS_LOWBAT = 0x80, // battery too low
  29. PRN_STATUS_ER2 = 0x40, // unspecified error
  30. PRN_STATUS_ER1 = 0x20, // paper jam
  31. PRN_STATUS_ER0 = 0x10, // packet error
  32. PRN_STATUS_UNTRAN = 0x08, // unprinted data in buffer
  33. PRN_STATUS_FULL = 0x04, // ready, triggered by DATA with len 0
  34. PRN_STATUS_BUSY = 0x02, // printer is printing
  35. PRN_STATUS_CHECKSUM = 0x01, // checksum error
  36. PRN_STATUS_OK = 0x00, // everything is fine
  37. // status flags from driver code
  38. PRN_STATUS_CANCELLED = 0x100, // user has aborted the print by pressing B
  39. PRN_STATUS_TIMEOUT = 0x200, // timeout waiting for printer response
  40. PRN_STATUS_NO_MAGIC = 0x400, // printer did not respond with proper 'alive'
  41. // masks to check for errors
  42. PRN_STATUS_MASK_ERRORS = 0x7F0,
  43. PRN_STATUS_MASK_ANY = 0x7FF,
  44. };
  45. #define PRN_PALETTE_NORMAL 0b11100100u
  46. #define PRN_PALETTE_INV 0b00011011u
  47. #define PRN_PALETTE_SC_W 0b00110100u
  48. #define PRN_PALETTE_SC_B 0b00011100u
  49. enum PRN_STATUS gbprinter_detect(void) BANKED;
  50. enum PRN_STATUS gbprinter_screenshot(uint8_t win, uint8_t palette) BANKED;
  51. uint8_t gbprinter_error(enum PRN_STATUS status, char *buff) BANKED;
  52. BANKREF_EXTERN(gbprinter)
  53. BANKREF_EXTERN(gbprinter_error)
  54. #endif // __GBPRINTER_H_INCLUDE__