1v13d/src/FxEngine/zbuffer.c

40 lines
776 B
C

#include "zbuffer.h"
#include <stdbool.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
static const int size_uint32 = 128*64;
static uint32_t* address=0;
void FE_zbuffer_clear()
{
while (address==0)
{
address=malloc(size_uint32*sizeof(uint32_t));
if (address==0)
{
dclear(C_WHITE);
dtext(1,1,"Not enough RAM...",C_BLACK,C_NONE);
}
}
int indice=0;
// TODO ** ajouter le DMA pour les architectures sh4
for (indice=0; indice<4096; indice++)
address[indice]=0;
}
bool FE_zbuffer_set_dist(int x, int y, int dist)
{
x%=FE_ZB_SIZE_X;
y%=FE_ZB_SIZE_Y;
const int indice=x*y;
if (address[indice]==0 || address[indice]>dist)
{
address[indice]=dist;
return true;
}
else
return false;
}