AvailMem()
:
void AvailMem( MemInfo *minfo, uint32 memflags )
memflags
argument specifies the type of memory you want to find out about. If you want to find out how much of all types of memory is available, use MEMTYPE_ANY
as the value of the flags argument. To find out how much DRAM is available, use MEMTYPE_DRAM
; for VRAM, use MEMTYPE_VRAM
. You can also use the flag MEMTYPE_BANKSELECT
together with either MEMTYPE_BANK1
or MEMTYPE_BANK2
to get information about a specific VRAM bank. Other flags you can include are MEMTYPE_DMA
, MEMTYPE_CEL
, MEMTYPE_AUDIO
, and MEMTYPE_DSP
. For complete descriptions of these flags, see Allocating Memory.
Note: When you call AvailMem(),
you can only request information about one memory type. Attempting to find out about more than one memory type can produce unexpected results.
The information about available memory is returned in a MemInfo structure pointed to by the minfo
argument:
This structure contains the following information:
typedef struct MemInfo
{
uint32 minfo_SysFree;
uint32 minfo_SysLargest;
uint32 minfo_TaskFree;
uint32 minfo_TaskLargest;
} MemInfo;
GetMemType()
:
uint32 GetMemType( void *p )
p
argument is a pointer to the memory location to identify. The function returns memory allocation flags (such as MEMTYPE_VRAM
) which describe the type of memory. For descriptions of these flags, see Allocating a Memory Block.
GetPageSize()
function:
int32 GetPageSize( uint32 memflags )
memflags
argument contains memory allocation flags for the page size of the memory type you specify. There are currently only three page sizes: one for DRAM and two for VRAM. You can, however, include any of the following flags: MEMTYPE_ANY
, MEMTYPE_VRAM
, MEMTYPE_DRAM
, MEMTYPE_BANKSELECT
, MEMTYPE_BANK1
, MEMTYPE_BANK2
, MEMTYPE_DMA
, MEMTYPE_CEL
, MEMTYPE_AUDIO
, and MEMTYPE_DSP
. (For complete descriptions of these flags, see Allocating a Memory Block.) Normally, you should include just one flag which specifies the one type of memory in which you're interested. Including more than one flag can produce an unexpected result.The return value contains the size of the page for the specified memory type, in bytes.
GetBankBits()
macro:
uint32 GetBankBits( void *a )
a
argument is a pointer to a memory location. The macro returns a set of memory flags in which the following flags can be set:
When a task allocates VRAM, the memory block contains memory from one VRAM bank or the other; it never contains memory from both banks. Thus, if any memory location in a block is in one VRAM bank, the entire block is in the same bank.
ASSERT()
macros. Portfolio validates memory pointers that are passed to it, and rejects any corrupt ones.
The IsMemReadable()
and IsMemWritable()
functions let your code verify the validity of pointers.
bool IsMemReadable(void *mem, int32 size);
bool IsMemWritable(void *mem, int32 size);