Quake BSP renderer for PS1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

38 lines
1.1 KiB

#ifndef __MEMORY_H__
#define __MEMORY_H__
#define SCRATCHLEN 1024
extern u_char* const scratchpad; // Starting address of scratchpad memory, i.e. the 1kB of data cache usable as fast RAM
#define PRIMBUFLEN 65536*2 // TODO: reduce this to what's needed for a typical scene
extern char *nextprim;
extern char *primbuf_bounds;
/**
* @brief Allocate a single primitive in the primitive buffer.
*
* @param size Size of the primitive struct to allocate.
* @return Pointer to the allocated struct in memory.
*/
INLINE void *mem_prim(size_t size)
{
void *prim = nextprim;
nextprim += size;
return prim;
}
/**
* @brief Check if it's safe to allocate the given number of primitives of the given size.
*
* @param size The size of each primitive to allocate.
* @param count The number of primitives to allocate.
* @return Whether the number of primitives can be allocated without exceeding the primitive buffer bounds.
*/
INLINE char mem_checkprim(size_t size, u_short count)
{
return nextprim + size * count < primbuf_bounds;
}
void mem_prim_reset(int db);
#endif // __MEMORY_H__