67 lines
1.6 KiB
C
67 lines
1.6 KiB
C
#include "zbuffer.h"
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <gint/display.h>
|
|
#include <gint/std/stdio.h>
|
|
#include <gint/std/stdlib.h>
|
|
#include <gint/keyboard.h>
|
|
#include <gint/dma.h>
|
|
#include <gint/hardware.h>
|
|
|
|
/* size_uint32
|
|
taille du zbuffer exprimée en uint32_t
|
|
utile pour l'effacement du zbuffer sur sh3 */
|
|
static const uint32_t size_int32 = FE_ZB_SIZE_X*FE_ZB_SIZE_Y;
|
|
|
|
/* size_char
|
|
taille du zbuffer exprimée en octets
|
|
utile pour malloc */
|
|
static const uint32_t size_char = size_int32*sizeof(int32_t);
|
|
|
|
/* size_char
|
|
taille du zbuffer exprimée en octets
|
|
utile pour le DMA */
|
|
static const uint32_t size_blocks = size_char/32;
|
|
|
|
// buffer situe a la fin de la RAM
|
|
static const int32_t *address = (void *)0x88080000 - size_char;
|
|
|
|
#include <gint/defs/attributes.h>
|
|
GALIGNED(32) GSECTION(".rodata") static const int32_t clearval[8]={3000,3000,3000,3000,3000,3000,3000,3000};
|
|
|
|
void FE_zbuffer_clear()
|
|
{
|
|
if (isSH3())
|
|
{ // effacement CPU
|
|
uint_fast16_t indice;
|
|
for (indice = 0; indice < size_int32; indice ++)
|
|
address[indice] = clearval[0];
|
|
}
|
|
else
|
|
{ // effacement DMA
|
|
dma_transfer(0, DMA_32B, size_blocks, &clearval, DMA_FIXED, address, DMA_INC);
|
|
}
|
|
}
|
|
|
|
void FE_start_rendering()
|
|
{
|
|
if (!isSH3())
|
|
dma_transfer_wait(0);
|
|
|
|
}
|
|
|
|
bool FE_zbuffer_set_dist(int32_t x, int32_t y, int32_t dist)
|
|
{
|
|
x %= FE_ZB_SIZE_X;
|
|
y %= FE_ZB_SIZE_Y;
|
|
const uint32_t indice = x * 64 + y;
|
|
if (address[indice]>dist && dist>0)
|
|
{
|
|
address[indice] = dist;
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|