1v13d/src/FxEngine/zbuffer.c

41 lines
824 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 const int size_octets = size_uint32*sizeof(uint32_t);
static uint32_t* address=0;
void FE_zbuffer_clear()
{
while (address==0)
{
address=malloc(size_octets);
if (address==0)
{
dclear(C_WHITE);
dtext(1,1,"Not enough RAM...",C_BLACK,C_NONE);
}
}
uint32_t indice=0;
// TODO ** ajouter le DMA pour les architectures sh4
for (indice=0; indice<size_uint32; indice++)
address[indice]=3000;
}
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*64+y;
if (address[indice]>dist&&dist>0)
{
address[indice]=dist;
return true;
}
else
return false;
}