sgdk: memory.h Source File

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

memory.h
Go to the documentation of this file.

    00001
    00020 #ifndef _MEMORY_H_
    00021 #define _MEMORY_H_
    00022
    00023
    00028 #define ROM      0x00000000
    00029
    00033 #define RAM      0xE0FF0000
    00034
    00039 #define STACK_SIZE      0x0A00
    00040
    00044 #define MEMORY_HIGH     (0xE1000000 - 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
    00158 #if (ENABLE_NEWLIB == 0)
    00159 // enable standard libc compatibility
    00160 #define malloc(x)       MEM_alloc(x)
    00161 #define free(x)         MEM_free(x)
    00162 #endif  // ENABLE_NEWLIB
    00163
    00164
    00169 u16  MEM_getFree();
    00174 u16  MEM_getAllocated();
    00179 u16  MEM_getLargestFreeBlock();
    00180
    00192 void MEM_free(void *ptr);
    00207 void* MEM_alloc(u16 size);
    00208
    00214 void MEM_pack();
    00221 void MEM_dump();
    00222
    00223 #if (ENABLE_NEWLIB == 0)
    00224
    00237 void memset(void *to, u8 value, u16 len);
    00238 #endif  // ENABLE_NEWLIB
    00239
    00253 void memsetU16(u16 *to, u16 value, u16 len);
    00267 void memsetU32(u32 *to, u32 value, u16 len);
    00268
    00269 #if (ENABLE_NEWLIB == 0)
    00270
    00284 void memcpy(void *to, const void *from, u16 len);
    00285 #endif  // ENABLE_NEWLIB
    00286
    00290 void memcpyU16(u16 *to, const u16 *from, u16 len);
    00294 void memcpyU32(u32 *to, const u32 *from, u16 len);
    00295
    00299 void fastMemset(void *to, u8 value, u16 len);
    00303 void fastMemsetU16(u16 *to, u16 value, u16 len);
    00307 void fastMemsetU32(u32 *to, u32 value, u16 len);
    00311 void fastMemcpy(void *to, const void *from, u16 len);
    00315 void fastMemcpyU16(u16 *to, const u16 *from, u16 len);
    00319 void fastMemcpyU32(u32 *to, const u32 *from, u16 len);
    00320
    00321
    00322 #endif // _MEMORY_H_

All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines