sgdk
memory.h
Go to the documentation of this file.
00001 
00020 #ifndef _MEMORY_H_
00021 #define _MEMORY_H_
00022 
00023 
00028 #define ROM      0x000000
00029 
00033 #define RAM      0xFF0000
00034 
00039 #define STACK_SIZE      0x0A00
00040 
00044 #define MEMORY_HIGH     (0x01000000 - STACK_SIZE)
00045 
00046 
00051 #define GET_DWORDFROMPBYTE(src)     ((src[0] << 24) | (src[1] << 16) | (src[2] << 8) | (src[3] << 0))
00052 
00056 #define GET_DWORDFROMPBYTE_LI(src)  ((src[0] << 0) | (src[1] << 8) | (src[2] << 16) | (src[3] << 24))
00057 
00061 #define GET_WORDFROMPBYTE(src)      ((src[0] << 8) | (src[1] << 0))
00062 
00066 #define GET_WORDFROMPBYTE_LI(src)   ((src[0] << 0) | (src[1] << 8))
00067 
00071 #define GET_DWORDFROMPWORD(src)     ((src[0] << 16) | (src[1] << 0))
00072 
00076 #define GET_DWORDFROMPWORD_LI(src)  ((src[0] << 0) | (src[1] << 16))
00077 
00078 
00083 #define SWAP_u8(x, y)       \
00084 {                           \
00085     u8 swp;                 \
00086                             \
00087     swp = x;                \
00088     x = y;                  \
00089     y = swp;                \
00090 }
00091 
00096 #define SWAP_s8(x, y)       \
00097 {                           \
00098     s8 swp;                 \
00099                             \
00100     swp = x;                \
00101     x = y;                  \
00102     y = swp;                \
00103 }
00104 
00109 #define SWAP_u16(x, y)      \
00110 {                           \
00111     u16 swp;                \
00112                             \
00113     swp = x;                \
00114     x = y;                  \
00115     y = swp;                \
00116 }
00117 
00122 #define SWAP_s16(x, y)      \
00123 {                           \
00124     s16 swp;                \
00125                             \
00126     swp = x;                \
00127     x = y;                  \
00128     y = swp;                \
00129 }
00130 
00135 #define SWAP_u32(x, y)      \
00136 {                           \
00137     u32 swp;                \
00138                             \
00139     swp = x;                \
00140     x = y;                  \
00141     y = swp;                \
00142 }
00143 
00148 #define SWAP_s32(x, y)      \
00149 {                           \
00150     s32 swp;                \
00151                             \
00152     swp = x;                \
00153     x = y;                  \
00154     y = swp;                \
00155 }
00156 
00157 
00162 u16  MEM_getFree();
00167 u16  MEM_getAllocated();
00172 u16  MEM_getLargestFreeBlock();
00173 
00185 void MEM_free(void *ptr);
00200 void* MEM_alloc(u16 size);
00201 
00207 void MEM_pack();
00214 void MEM_dump();
00215 
00216 #if (ENABLE_NEWLIB == 0)
00217 
00230 void memset(void *to, u8 value, u16 len);
00231 #endif  // ENABLE_NEWLIB
00232 
00246 void memsetU16(u16 *to, u16 value, u16 len);
00260 void memsetU32(u32 *to, u32 value, u16 len);
00261 
00262 #if (ENABLE_NEWLIB == 0)
00263 
00277 void memcpy(void *to, const void *from, u16 len);
00278 #endif  // ENABLE_NEWLIB
00279 
00283 void memcpyU16(u16 *to, const u16 *from, u16 len);
00287 void memcpyU32(u32 *to, const u32 *from, u16 len);
00288 
00292 void fastMemset(void *to, u8 value, u16 len);
00296 void fastMemsetU16(u16 *to, u16 value, u16 len);
00300 void fastMemsetU32(u32 *to, u32 value, u16 len);
00304 void fastMemcpy(void *to, const void *from, u16 len);
00308 void fastMemcpyU16(u16 *to, const u16 *from, u16 len);
00312 void fastMemcpyU32(u32 *to, const u32 *from, u16 len);
00313 
00314 
00315 #endif // _MEMORY_H_
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines