manager.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * 6502 Memory manager - The peTI-NESulator Project
  3. * memory.h - Taken from the Quick6502 project
  4. *
  5. * Created by Manoël Trapier on 18/09/06.
  6. * Copyright (c) 2002-2019 986-Studio.
  7. *
  8. */
  9. #ifndef MEMORY_H
  10. #define MEMORY_H
  11. #include "types.h"
  12. #define ATTR_PAGE_HAVE_RDHOOK 0x20
  13. #define ATTR_PAGE_HAVE_WRHOOK 0x10
  14. #define ATTR_PAGE_WRITEABLE 0x08
  15. #define ATTR_PAGE_READABLE 0x04
  16. #define ATTR_PAGE_GHOST 0x02
  17. #define ATTR_PAGE_MAPPED 0x01
  18. typedef uint8_t (*func_rdhook)(uint8_t /* addr */);
  19. typedef void (*func_wrhook)(uint8_t addr, uint8_t data);
  20. /* Functions to manage pages data */
  21. void set_page_ptr(uint8_t page, uint8_t *ptr);
  22. void set_page_ptr_1k(uint8_t page, uint8_t *ptr);
  23. void set_page_ptr_2k(uint8_t page, uint8_t *ptr);
  24. void set_page_ptr_4k(uint8_t page, uint8_t *ptr);
  25. void set_page_ptr_8k(uint8_t page, uint8_t *ptr);
  26. void set_page_ptr_16k(uint8_t page, uint8_t *ptr);
  27. void set_page_ptr_32k(uint8_t page, uint8_t *ptr);
  28. uint8_t *get_page_ptr(uint8_t page);
  29. /* Functions to set pages attributes */
  30. void set_page_rd_hook(uint8_t page, func_rdhook func);
  31. void set_page_wr_hook(uint8_t page, func_wrhook func);
  32. void set_page_readable(uint8_t page, uint8_t value);
  33. void set_page_writeable(uint8_t page, uint8_t value);
  34. void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost);
  35. uint8_t get_page_attributes(uint8_t page);
  36. func_rdhook get_page_rdhook(uint8_t page);
  37. func_wrhook get_page_wrhook(uint8_t page);
  38. /* Generalist functions */
  39. void InitMemory();
  40. uint8_t ReadMemory(uint8_t page, uint8_t addr);
  41. void WriteMemory(uint8_t page, uint8_t addr, uint8_t value);
  42. void DumpMemoryState(FILE *fp);
  43. #endif