fxengine/src/zbuffer.c

54 lines
1.2 KiB
C

#include <fxengine/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>
#include <gint/hardware.h>
static const int size_uint32 = fe_width * fe_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
// AND THE DMA STILL DON'T WOOORK :(
extern void dma_memset(void *dst, uint32_t l, size_t size);
void fe_zbuffer_clear()
{
uint32_t indice = 0;
/*
if (isSH3())
*/
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = fe_max_dist;
/*
else
dma_memset(zbuffer, fe_max_dist, size_char);
*/
}
bool fe_zbuffer_set_px(const uint32_t x, const uint32_t y, const uint32_t dist)
{
const int indice = x * fe_height + y;
if (zbuffer[indice]>dist && dist>=fe_min_dist && dist<=fe_max_dist)
{
zbuffer[indice] = dist;
return true;
}
return false;
}