fxengine/src/zbuffer.c

51 lines
1.2 KiB
C

#include <render/zbuffer.h>
#include <fxengine/parameters.h>
#include <stdbool.h>
#include <stdint.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
#include <gint/defs/attributes.h>
static const int size_uint32 = render_width * render_height;
static const int size_char = size_uint32 * sizeof(uint32_t);
// zbuffer et clear val sont 32B alignés pour ajouter éventuellement le DMA
static int32_t *zbuffer = (void *)0x88080000 - (((size_char >> 5) << 5) + 1);
// gint doesn't provide any prototype for that function which is implemented
extern void dma_memset(void *dst, uint32_t l, size_t size);
void render_zbuffer_clear()
{
uint32_t indice = 0;
if (isSH3())
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = render_max_dist;
else
dma_memset(zbuffer, render_max_dist, size_char);
}
bool render_zbuffer_set_px(const uint32_t x, const uint32_t y, const uint32_t dist)
{
const int indice = x * render_height + y;
if (zbuffer[indice]>dist && dist>=render_min_dist && dist<=render_max_dist)
{
zbuffer[indice] = dist;
return true;
}
return false;
}