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.
 
 

40 lines
879 B

#include "common.h"
#include "memory.h"
#define PRIMBUFLEN 131072 // TODO: optimize this for a typical scene
static char primbuff[2][PRIMBUFLEN]; // Primitive buffer, just a raw buffer of bytes to use as a pool for primitives
static char *nextpri;
static char *primbuff_bounds;
char* const scratchpad = (char*)0x1F800000;
void *mem_scratch(char **scratch_offset, unsigned short size)
{
#if _DEBUG
if (*scratch_offset + size > scratchpad + 1024)
return NULL;
#endif
void *result = *scratch_offset;
*scratch_offset += size;
return result;
}
void mem_prim_reset(int db)
{
nextpri = primbuff[db];
primbuff_bounds = nextpri + PRIMBUFLEN;
}
void *mem_prim(size_t size)
{
#if _DEBUG
if (nextpri + size > primbuff_bounds)
return NULL; // TODO: report error
#endif
void *prim = nextpri;
nextpri += size;
return prim;
}