Browse Source

First simple test with scratch memory, just to verify that it works.

tess_experiment
Nico de Poel 3 years ago
parent
commit
a6e9aa1b21
  1. 4
      memory.c
  2. 2
      memory.h
  3. 4
      world.c

4
memory.c

@ -15,14 +15,14 @@ void mem_scratch_reset()
scratch = scratch_start;
}
char *mem_scratch(unsigned short size)
void *mem_scratch(unsigned short size)
{
#if _DEBUG
if (scratch + size > scratch_start + 1024)
return NULL;
#endif
char *result = scratch;
void *result = scratch;
scratch += size;
return result;
}

2
memory.h

@ -7,7 +7,7 @@
* @param size The number of bytes to allocate. Be aware that the scratchpad memory only has 1024 bytes available.
* @return Pointer to the allocated buffer in scratchpad memory.
*/
char *mem_scratch(unsigned short size);
void *mem_scratch(unsigned short size);
void mem_scratch_reset();

4
world.c

@ -40,13 +40,15 @@ void world_load(const u_long *data, world_t *world)
void world_draw(const world_t *world)
{
SVECTOR vecs[3];
int p;
// The world doesn't move, so we just set the camera view-projection matrix
gte_SetRotMatrix(&vp_matrix);
gte_SetTransMatrix(&vp_matrix);
mem_scratch_reset();
SVECTOR *vecs = mem_scratch(sizeof(SVECTOR) * 3);
for (int faceIdx = 0; faceIdx < world->header->numFaces; ++faceIdx)
{
const ps1bsp_face_t *face = &world->faces[faceIdx];

Loading…
Cancel
Save