From 308cb408a21b6504215300a897acaf105de0359d Mon Sep 17 00:00:00 2001 From: milang Date: Mon, 19 Aug 2019 12:58:50 +0200 Subject: [PATCH] correct zbuffer clearing ( thanks @lephenixnoir) --- src/FxEngine/zbuffer.c | 42 ++++-------------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/src/FxEngine/zbuffer.c b/src/FxEngine/zbuffer.c index fdbaf71..150debe 100644 --- a/src/FxEngine/zbuffer.c +++ b/src/FxEngine/zbuffer.c @@ -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 +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;