still debugging direct memory access controller (I gonna suicide)

This commit is contained in:
Milang 2019-08-17 19:25:16 +02:00
parent e9c5f9935d
commit 94b7f6e7c6
2 changed files with 42 additions and 32 deletions

View File

@ -8,6 +8,10 @@
#include <gint/keyboard.h>
#include <gint/dma.h>
#include <gint/hardware.h>
/** size_uint32
* taille du zbuffer exprimée en uint32_t
* utile pour l'effacement du zbuffer sur sh3
@ -16,10 +20,16 @@ static const uint32_t size_uint32 = FE_ZB_SIZE_X*FE_ZB_SIZE_Y;
/** size_char
* taille du zbuffer exprimée en octets
* sera utile pour le DMA Controller
* utile pour malloc
**/
static const uint32_t size_char = size_uint32*sizeof(int32_t);
/* size_char
taille du zbuffer exprimée en octets
utile pour le DMA */
static const uint32_t size_blocks = size_char/32;
/** address
* addresse du zbuffer
**/
@ -28,14 +38,15 @@ static int32_t* address=0;
const int32_t clearval=3000;
#define ALIGN 4
static void* buffer_malloc(uint32_t size)
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;
}
void buffer_free(void *ptr)
static void buffer_free(void *ptr)
{
free(((void**)ptr)[-1]);
}
@ -56,7 +67,7 @@ void FE_zbuffer_clear()
}
}
// TODO déterminer le type d'effacement
if (/*isSH3()*/1)
if (isSH3())
{ // effacement CPU
uint_fast16_t indice;
for (indice = 0; indice < size_uint32; indice ++)
@ -64,14 +75,14 @@ void FE_zbuffer_clear()
}
else
{ // effacement DMA
dma_transfer(0, DMA_32B, size_uint32, &clearval, DMA_FIXED, address, DMA_INC);
dma_transfer(0, DMA_32B, size_blocks, &clearval, DMA_FIXED, address, DMA_INC);
}
}
void FE_start_rendering()
{
/*if (!isSH3())
dma_transfer_wait(0);*/
if (!isSH3())
dma_transfer_wait(0);
}

View File

@ -10,30 +10,29 @@
int main(void)
{
init_controls();
dclear(C_WHITE);
FE_point point[4]={{{10,0,0},{0,0,0}},{{10,10,0},{0,0,0}},{{10,0,10},{0,0,0}},{{10,10,10},{0,0,0}}};
FE_face face={&point[0],&point[1],&point[2],1,2};
FE_face face2={&point[3],&point[1],&point[2],0,2};
init_controls();
dclear(C_WHITE);
FE_point point[4]={{{10,0,0},{0,0,0}},{{10,10,0},{0,0,0}},{{10,0,10},{0,0,0}},{{10,10,10},{0,0,0}}};
FE_face face={&point[0],&point[1],&point[2],1,2};
FE_face face2={&point[3],&point[1],&point[2],0,2};
while (1)
{
FE_new_frame();
reload_fps_displaying();
for (int i=0;i<4;i++)
{
FE_calc(&point[i]);
if (point[i].translated.z>0)
{
dpixel(point[i].translated.x,point[i].translated.y,C_BLACK);
}
}
FE_start_rendering();
FE_draw_face(&face);
FE_draw_face(&face2);
display_fps(100,56);
}
getkey();
return 1;
while (1)
{
FE_new_frame();
reload_fps_displaying();
display_fps(100,56);
for (int i=0;i<4;i++)
{
FE_calc(&point[i]);
if (point[i].translated.z>0)
{
dpixel(point[i].translated.x,point[i].translated.y,C_BLACK);
}
}
FE_start_rendering();
FE_draw_face(&face);
FE_draw_face(&face2);
}
getkey();
return 1;
}