From dfd33a0a000d7f9fee3cb3dc75e3cdffd91e0b87 Mon Sep 17 00:00:00 2001 From: util1 Date: Thu, 18 Jul 2019 20:29:34 +0200 Subject: [PATCH] ajout de la fonction bool FE_ZBuffer::setDist(int x, int y, int dist) --- FxEngine/zbuffer/zbuffer.cpp | 25 ++++++++++++++++++++++++- FxEngine/zbuffer/zbuffer.h | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/FxEngine/zbuffer/zbuffer.cpp b/FxEngine/zbuffer/zbuffer.cpp index 1ba04bb..d691e8e 100644 --- a/FxEngine/zbuffer/zbuffer.cpp +++ b/FxEngine/zbuffer/zbuffer.cpp @@ -1,9 +1,32 @@ #include "zbuffer.h" int FE_ZBuffer::m_sign=1; -int* FE_ZBuffer::m_data=0; +unsigned short* FE_ZBuffer::m_data=calloc(8192,sizeof(unsigned short)); void FE_ZBuffer::clear() { m_sign*=-1; + while (m_data==NULL) + {} + int* clearVal=(int*)m_data; + int indice=0; + + // TODO ** ajouter le DMA pour les architectures sh4 + for (indice=0; indice<4096; indice++) + clearVal[indice]=0; +} + +bool FE_ZBuffer::setDist(int x, int y, int dist) +{ + short ndist=(short)dist; + x%=FE_ZB_SIZE_X; + y%=FE_ZB_SIZE_Y; + const int indice=x*y; + if (m_data[indice]=0 || m_data[indice]>ndist) + { + m_data[indice]=ndist; + return true; + } + else + return false; } \ No newline at end of file diff --git a/FxEngine/zbuffer/zbuffer.h b/FxEngine/zbuffer/zbuffer.h index 153102b..bb22f60 100644 --- a/FxEngine/zbuffer/zbuffer.h +++ b/FxEngine/zbuffer/zbuffer.h @@ -11,7 +11,7 @@ public: static void clear(); // does not really clear the zbuffer, but changes encoding sign for the next frame ** on 1st frame, allocates data static bool setDist(int x, int y, int dist); // if you are allowed to draw the pixel on vram private: - static int* m_data; + static unsigned short* m_data; static int m_sign; }