1v13d/src/FxEngine/zbuffer.c

41 lines
824 B
C
Raw Normal View History

2019-07-21 20:14:54 +02:00
#include "zbuffer.h"
#include <stdbool.h>
2019-07-23 15:52:20 +02:00
#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);
2019-07-21 20:14:54 +02:00
2019-07-23 15:52:20 +02:00
static uint32_t* address=0;
2019-07-21 20:14:54 +02:00
void FE_zbuffer_clear()
{
while (address==0)
2019-07-23 15:52:20 +02:00
{
address=malloc(size_octets);
2019-07-23 15:52:20 +02:00
if (address==0)
{
dclear(C_WHITE);
dtext(1,1,"Not enough RAM...",C_BLACK,C_NONE);
}
}
uint32_t indice=0;
2019-07-21 20:14:54 +02:00
// TODO ** ajouter le DMA pour les architectures sh4
for (indice=0; indice<size_uint32; indice++)
2019-07-26 14:39:08 +02:00
address[indice]=3000;
2019-07-21 20:14:54 +02:00
}
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;
2019-07-26 14:39:08 +02:00
if (address[indice]>dist&&dist>0)
2019-07-21 20:14:54 +02:00
{
2019-07-23 15:52:20 +02:00
address[indice]=dist;
2019-07-21 20:14:54 +02:00
return true;
}
else
return false;
}