manager.h 1.6 KB

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