correct zbuffer clearing ( thanks @lephenixnoir)

This commit is contained in:
milang 2019-08-19 12:58:50 +02:00
parent 4ccf324e48
commit 308cb408a2
1 changed files with 4 additions and 38 deletions

View File

@ -24,48 +24,14 @@ static const uint32_t size_char = size_int32*sizeof(int32_t);
utile pour le DMA */
static const uint32_t size_blocks = size_char/32;
/* en attente de reponse
static int32_t address[size_uint32];
*/
// buffer situe a la fin de la RAM
static const int32_t *address = (void *)0x88080000 - size_char;
/** address
* addresse du zbuffer
**/
static int32_t* address=0;
static int32_t* clearval=0;
#define ALIGN 32
static void* buffer_malloc(uint_fast16_t size)
{
void *mem = malloc(size+ALIGN+sizeof(void*));
void **ptr = (void**)((uintptr_t)(mem+ALIGN+sizeof(void*)) & ~(ALIGN-1));
ptr[-1] = mem;
return ptr;
}
static void buffer_free(void *ptr)
{
free(((void**)ptr)[-1]);
}
#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 (address==0)
{
address = buffer_malloc(size_char);
clearval= buffer_malloc(32);
if (address==0||clearval==0) // cas de figure où il n'y a plus assez de RAM
{
dclear(C_WHITE);
dtext(1, 1, "Not enough RAM...", C_BLACK, C_NONE);
dupdate();
while (1==1)
getkey();
}
clearval[0]=3000; clearval[1]=3000; clearval[2]=3000; clearval[3]=3000; clearval[4]=3000; clearval[5]=3000; clearval[6]=3000; clearval[7]=3000;
}
// TODO déterminer le type d'effacement
if (isSH3())
{ // effacement CPU
uint_fast16_t indice;