run_api.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* API passed to loaded program at PROGRAM_API_ADDR. Used by run command and by programs run via run (e.g. prog, space). */
  2. #ifndef RUN_API_H
  3. #define RUN_API_H
  4. #define PROGRAM_API_ADDR 0x30F00
  5. #define IO_KEY_ESC 0x1B
  6. #define IO_KEY_SPACE 0x20
  7. #define IO_KEY_LEFT 0x100
  8. #define IO_KEY_RIGHT 0x101
  9. /* Function pointer types for the program API. */
  10. typedef void (*prog_draw_string_xy_t)(unsigned int x0, unsigned int y0,
  11. const char *str, unsigned int r_fg, unsigned int g_fg, unsigned int b_fg,
  12. int transparent_bg);
  13. typedef unsigned int (*prog_get_cols_t)(void);
  14. typedef unsigned int (*prog_get_rows_t)(void);
  15. typedef int (*prog_poll_key_t)(void);
  16. typedef int (*prog_poll_key_with_hw_t)(void);
  17. typedef unsigned int (*prog_get_fb_width_t)(void);
  18. typedef unsigned int (*prog_get_fb_height_t)(void);
  19. typedef void (*prog_clear_rgb_t)(unsigned int r, unsigned int g, unsigned int b);
  20. typedef void (*prog_put_pixel_rgb_t)(unsigned int x, unsigned int y,
  21. unsigned int r, unsigned int g, unsigned int b);
  22. typedef unsigned int (*prog_get_ticks_ms_t)(void);
  23. struct prog_api {
  24. prog_draw_string_xy_t draw_string_xy;
  25. prog_get_cols_t get_cols;
  26. prog_get_rows_t get_rows;
  27. prog_poll_key_t poll_key;
  28. prog_poll_key_with_hw_t poll_key_with_hw;
  29. prog_get_fb_width_t get_fb_width;
  30. prog_get_fb_height_t get_fb_height;
  31. prog_clear_rgb_t clear_rgb;
  32. prog_put_pixel_rgb_t put_pixel_rgb;
  33. prog_get_ticks_ms_t get_ticks_ms;
  34. };
  35. #endif