tamalib.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * TamaLIB - A hardware agnostic Tamagotchi P1 emulation library
  3. *
  4. * Copyright (C) 2021 Jean-Christophe Rona <jc@rona.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef _TAMALIB_H_
  21. #define _TAMALIB_H_
  22. #include "cpu.h"
  23. #include "hw.h"
  24. #include "hal.h"
  25. #define tamalib_set_button(btn, state) hw_set_button(btn, state)
  26. #define tamalib_set_speed(speed) cpu_set_speed(speed)
  27. #define tamalib_get_state() cpu_get_state()
  28. #define tamalib_refresh_hw() cpu_refresh_hw()
  29. #define tamalib_reset() cpu_reset()
  30. #define tamalib_add_bp(list, addr) cpu_add_bp(list, addr)
  31. #define tamalib_free_bp(list) cpu_free_bp(list)
  32. typedef enum {
  33. EXEC_MODE_PAUSE,
  34. EXEC_MODE_RUN,
  35. EXEC_MODE_STEP,
  36. EXEC_MODE_NEXT,
  37. EXEC_MODE_TO_CALL,
  38. EXEC_MODE_TO_RET,
  39. } exec_mode_t;
  40. void tamalib_release(void);
  41. bool_t tamalib_init(const u12_t* program, breakpoint_t* breakpoints, u32_t freq);
  42. void tamalib_set_framerate(u8_t framerate);
  43. u8_t tamalib_get_framerate(void);
  44. void tamalib_register_hal(hal_t* hal);
  45. void tamalib_set_exec_mode(exec_mode_t mode);
  46. /* NOTE: Only one of these two functions must be used in the main application
  47. * (tamalib_step() should be used only if tamalib_mainloop() does not fit the
  48. * main application execution flow).
  49. */
  50. void tamalib_step(void);
  51. void tamalib_mainloop(void);
  52. #endif /* _TAMALIB_H_ */