home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Emulation / Atari800 / mem.h < prev    next >
C/C++ Source or Header  |  1998-02-23  |  4KB  |  134 lines

  1. /*******************************************************
  2.  ** mem.h                                             **
  3.  ** Memory-Handler                                    **
  4.  ** Speicherzugriffe, RAM,ROM,Hardware                **
  5.  *******************************************************/
  6.  
  7. #ifndef MEM_H
  8.  
  9. #ifndef __ATARI__
  10. #include "atari.h"
  11. #endif
  12.  
  13.  
  14. typedef unsigned char mtype;
  15. typedef int ATPtr;
  16.  
  17. #ifndef TRUE
  18. #define TRUE 1
  19. #endif
  20. #ifndef FALSE
  21. #define FALSE 0
  22. #endif
  23. #ifndef NULL
  24. #define NULL 0L
  25. #endif
  26.  
  27.  
  28. typedef mtype (*MemGet)(void);
  29. typedef int (*MemPut)(mtype byte);
  30.  
  31. struct Cart {
  32.     int type;
  33.     int active;
  34.     int num_secs;     /* Number of discrete sections that can be mapped into
  35.              currently limited to four */
  36.     struct {
  37.     ATPtr lo,hi;   /* address ranges of the sections in memory */
  38.     int offset;   /* offset of this section from the start of the image */
  39.     int active;   /* whether this section is enabled */
  40.     } secs[4];
  41.  
  42.     mtype *image;     /* keeps the image itself */
  43.     mtype *saveback;  /* keeps the RAM under the image */
  44. };
  45.  
  46.  
  47. /* Cart-Types */
  48.  
  49. extern mtype memory[65536];
  50. extern MemGet mget[65536];
  51. extern MemPut mput[65536];
  52.  
  53.  
  54. /* Lo-level memory access. Must be redefined if memory type changes */
  55.  
  56. /* These are strictly for the CPU module */
  57.  
  58. #ifdef DEBUG
  59. #define GetByte(addr)      (mget[addr]?mget[(regPC=PC)?(addr):(0)]():memory[addr])
  60. #define PutByte(addr,byte) if (mput[addr]) {                          \
  61.                  regPC=PC;                            \
  62.                  if (mput[addr](byte)) goto halt_cpu; \
  63.                } else memory[addr]=byte;             
  64.  
  65. #else
  66. #define GetByte(addr)      (mget[addr]?mget[addr]():memory[addr])
  67. #define PutByte(addr,byte) if (mput[addr]) {                             \
  68.                  if (mput[addr](byte)) goto halt_cpu;    \
  69.                } else memory[addr]=byte;             
  70. #endif
  71.  
  72. /* This is for all the remaining stuff. */
  73.  
  74. #define IsRAM(addr)        (mput[addr]!=NULL)
  75.  
  76. #define Peek(addr)         ((int)((mget[addr]?mget[addr]():memory[addr])&0xff))
  77. #define DPeek(addr)        ((Peek(addr))|(((Peek(addr+1))<<8)))
  78. #define Poke(addr,byte)    if (mput[addr]) {                     \
  79.                  mput[addr](byte);               \
  80.                } else memory[addr]=byte;         
  81.  
  82. /* The same for the ANTIC module. Might differ in the future if the XE 
  83.    simulation is setup properly... */
  84.  
  85. #define APeek(addr)        ((int)((mget[addr]?mget[addr]():memory[addr])&0xff))
  86. #define DAPeek(addr)       ((Peek(addr))|(((Peek(addr+1))<<8)))
  87.  
  88. void SetRAM(int lower,int upper);
  89. void SetROM(int lower,int upper);
  90. void SetHW(int address,int mask,MemGet read,MemPut write);
  91. void SetBlank(int lower,int upper);
  92. int LoadMem(int fd,int addr,int size);
  93. int load_image (char *filename, int addr, int nbytes);
  94. void EnablePILL (void);
  95. void CopyFromMem(ATPtr to,UBYTE *,int size);
  96. void CopyToMem(UBYTE *,ATPtr from,int size);
  97.  
  98. void TurnOffCart(void);
  99. void TurnOnCart(void);
  100. void RemoveCart(void);
  101. void InsertCart(struct Cart *ct);
  102. void EnableBasic(void);
  103. void DisableBasic(void);
  104. int CartInserted(void);
  105. void EnableOs(void);
  106. void DisableOs(void);
  107. void EnableSelftest(void);
  108. void DisableSelftest(void);
  109. void RemoveCurrent(void);
  110. void ChangeMapping(int map0,int map1,int map2, int map3);
  111. int CartType(void);
  112.  
  113. int Read5200Rom(char *filename,int fd);
  114. int ReadOSABRom(char *filename,int fd);
  115. int ReadXLRom(char *filename,int fd);
  116. int ReadBasic(char *filename,int fd);
  117. int Insert_8K_ROM (char *filename,int fd);
  118. int Insert_16K_ROM (char *filename,int fd);
  119. int Insert_OSS_ROM (char *filename,int fd);
  120. int Insert_DB_ROM (char *filename,int fd);
  121. int Insert_32K_5200ROM (char *filename,int fd);
  122. int Insert_16K_5200ROM (char *filename,int fd);
  123.  
  124. void SelectXEBank(int bank);
  125. int Free_XE_Banks(void);
  126. int Build_XE_Banks(void);
  127. void FreeCarts(void);
  128.  
  129. int RomGet(ATPtr ad);
  130. int RomDGet(ATPtr ad);
  131. void RomSet(ATPtr ad,int v);
  132.  
  133. #endif
  134.