ajout commentaires

This commit is contained in:
Milang 2019-08-16 15:27:15 +02:00
parent 9ac6860700
commit 0c85e41ff1
3 changed files with 46 additions and 20 deletions

View File

@ -9,7 +9,5 @@ unsigned char const FE_textures[3][8]=
bool FE_get_pixel(int num,int x, int y)
{
x%=8;
y%=8;
return ((1<<(7-x)) & (FE_textures[num][y]));
}

View File

@ -1,39 +1,58 @@
#include "zbuffer.h"
#include <stdbool.h>
#include <gint/display.h>
#include <gint/std/stdio.h>
#include <gint/std/stdlib.h>
#include <gint/keyboard.h>
static const int size_uint32 = 128*64;
static const int size_octets = size_uint32*sizeof(uint32_t);
/** size_uint32
* taille du zbuffer exprimée en uint32_t
* utile pour l'effacement du zbuffer sur sh3
**/
static const int size_uint32 = FE_ZB_SIZE_X*FE_ZB_SIZE_X;
/** size_char
* taille du zbuffer exprimée en octets
* sera utile pour le DMA Controller
**/
static const int size_char = size_uint32*sizeof(uint32_t);
/** address
* addresse du zbuffer
**/
static uint32_t* address=0;
void FE_zbuffer_clear()
{
while (address==0)
{
address=malloc(size_octets);
if (address==0)
address = malloc(size_octets);
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);
dtext(1, 1, "Not enough RAM...", C_BLACK, C_NONE);
}
}
uint32_t indice=0;
// TODO ** ajouter le DMA pour les architectures sh4
for (indice=0; indice<size_uint32; indice++)
address[indice]=3000;
// TODO déterminer le type d'effacement
// effacement fait par le CPU
uint32_t indice = 0;
for (indice = 0; indice < size_uint32; indice ++)
address[indice] = 3000;
// effacement fait par le DMA
// TODO
}
bool FE_zbuffer_set_dist(int x, int y, int dist)
{
x%=FE_ZB_SIZE_X;
y%=FE_ZB_SIZE_Y;
const int indice=x*64+y;
if (address[indice]>dist&&dist>0)
x %= FE_ZB_SIZE_X;
y %= FE_ZB_SIZE_Y;
const int indice = x * 64 + y;
if (address[indice]>dist && dist>0)
{
address[indice]=dist;
address[indice] = dist;
return true;
}
else

View File

@ -1,13 +1,22 @@
#ifndef FE_ZBUFFER
#define FE_ZBUFFER
#include <stdbool.h>
// nouveauté ! le zbuffer occupe tout l'écran, le rendu 3d offre donc de meilleures possibilités
/** Taille du z_buffer **/
#define FE_ZB_SIZE_X 128
#define FE_ZB_SIZE_Y 64
void FE_zbuffer_clear(); // does not really clear the zbuffer, but changes encoding sign for the next frame ** on 1st frame, allocates data
/** FE_zbuffer_clear
* effacer le z buffer pour un nouveau cycle de dessin
* TODO : ajouter effacement avec le DMA Controller pour les modèles ayant un processeur SH4-A
**/
void FE_zbuffer_clear();
#include <stdbool.h>
/** FE_zbuffer_set_dist
* change la distance d'un pixel du zbuffer
* retourne true si il faut dessiner le pixel
* retourne false si le pixel est déjà existant
**/
bool FE_zbuffer_set_dist(int x, int y, int dist); // if you are allowed to draw the pixel on vram
#endif