From 84d31c7783f385646a1319e993bdbbf36285501e Mon Sep 17 00:00:00 2001 From: Milang Date: Sat, 17 Aug 2019 17:47:05 +0200 Subject: [PATCH] add DMA >> experimental --- src/FxEngine/zbuffer.c | 70 +++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/src/FxEngine/zbuffer.c b/src/FxEngine/zbuffer.c index 0f358a7..ea9bc88 100644 --- a/src/FxEngine/zbuffer.c +++ b/src/FxEngine/zbuffer.c @@ -6,6 +6,7 @@ #include #include #include +#include /** size_uint32 * taille du zbuffer exprimée en uint32_t @@ -24,41 +25,48 @@ static const uint32_t size_char = size_uint32*sizeof(int32_t); **/ static int32_t* address=0; +const int32_t clearval=3000; + void FE_zbuffer_clear() { - if (address==0) - { - address = malloc(size_char); - if (address==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(); - } - } - // TODO déterminer le type d'effacement - - // effacement fait par le CPU - uint32_t indice; - for (indice = 0; indice < size_uint32; indice ++) - address[indice] = 3000; - - // effacement fait par le DMA - // TODO + if (address==0) + { + address = malloc(size_char); + if (address==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(); + } + } + // TODO déterminer le type d'effacement + if (isSH3()) + { // effacement fait par le CPU + uint32_t indice; + for (indice = 0; indice < size_uint32; indice ++) + address[indice] = clearval; + } + else + { // effacement fait par le DMA + dma_transfer(0, DMA_32B, size_uint32, &clearval, DMA_FIXED, + address, DMA_INC); + } + + } 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; + 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; }