Browse Source

add debug options

improve makefile
hunting bugs
master
milang 1 year ago
parent
commit
7e5a61054b
No known key found for this signature in database GPG Key ID: D287C9D6C33D9035
9 changed files with 202 additions and 75 deletions
  1. +1
    -1
      Makefile
  2. +40
    -12
      configure
  3. +20
    -0
      include/fxengine/fxengine.h
  4. +1
    -8
      include/fxengine/triangle.h
  5. BIN
      libfxengine.a
  6. +112
    -0
      src/fxengine.c
  7. +23
    -10
      src/space.c
  8. +0
    -35
      src/triangle.c
  9. +5
    -9
      src/zbuffer.c

+ 1
- 1
Makefile View File

@@ -14,7 +14,7 @@ machine := -m3 -mb
# Compiler flags, assembler flags, dependency generation, archiving
cflags := $(machine) -ffreestanding -nostdlib -Wall -Wextra -std=c11 -Os \
-fstrict-volatile-bitfields -I include $(CONFIG.MACROS) \
$(CONFIG.CFLAGS) $(PROFILING)
$(CONFIG.CFLAGS) $(FLAGS)
sflags := $(CONFIG.MACROS)
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
arflags :=


+ 40
- 12
configure View File

@@ -15,21 +15,35 @@ output="Makefile.cfg"
help()
{
cat << EOF
Configuration script for the fxengine library.
Usage: $0 [options...]
Configuration script for the fxengine library.
Usage: $0 [options...]

You should build out-of-tree by creating a build directory and configuring from
there.

Specified target :

Build option:
--fxcg50

--enable-profiling
--fx9680g

By default, profiling is disabled, tht means you will not have access to fps. :(
If you don't send any option, fx9860g is set as default
* Note fxcg50 is not really supported now, but maybe someday it would happen !



Optional dependencies :

--libprof
By default, profiling is disabled, tht means you will not have access to fps. :(
This option enables fps count, but you need to have libprof (by Lephenixnoir) installed

--liblog
If you want more advanced debug options, you can add this to add a virtual stream used for
logging debug informations
You need tou have liblog (by me) installed





EOF
exit 0
@@ -44,7 +58,9 @@ fi
# Parsing arguments
#

add_cflags=
target=-DFX9860G
libprof=
liblog=

fail=false
for arg; do case "$arg" in
@@ -52,8 +68,17 @@ for arg; do case "$arg" in
help;;


--enable-profiling)
add_cflags=-DUSE_LIBPROF;;
--libprof)
libprof=-DUSE_LIBPROF;;

--liblog)
liblog=-DUSE_LIBLOG;;

--fx9860g)
target=-DFX9860G;;

--fxcg50)
target=-DFXCG50;;

*)
echo "error: unrecognized argument '$arg'";
@@ -76,8 +101,11 @@ fi

output_config()
{
echo -n "PROFILING ="
echo -n " $(echo $add_cflags)"
echo -n "FLAGS ="
echo -n " $(echo $target)"
echo -n " $(echo $libprof)"
echo -n " $(echo $liblog)"

echo ""
}



+ 20
- 0
include/fxengine/fxengine.h View File

@@ -0,0 +1,20 @@
#ifndef FE_FXENGINE
#define FE_FXENGINE

#include <stdint.h>

/**
* @brief Clears zbuffer, counts fps and log settings
*
* @param[in] libprof_channel The libprof channel to be used to count_fps
* if you don't use libprof channel, (default), you send what you want,
* it doesn't matters ;)
*/
void fe_update(const uint32_t libprof_channel);

/* updates and clears vram, than calls fe_update */
void fe_display(const uint32_t libprof_channel);

void fe_custom_panic();

#endif

+ 1
- 8
include/fxengine/triangle.h View File

@@ -35,14 +35,7 @@ typedef struct fe_triangle fe_triangle;
*/
void fe_display_triangle(const fe_triangle * face);

/**
* @brief Clears vram, zbuffer
*
* @param[in] libprof_channel The libprof channel to be used to count_fps
* if you don't use libprof channel, (default), you send what you want,
* it doesn't matters ;)
*/
void fe_render_update(const uint32_t libprof_channel);






BIN
libfxengine.a View File


+ 112
- 0
src/fxengine.c View File

@@ -0,0 +1,112 @@
#include <fxengine/fxengine.h>
#include <fxengine/zbuffer.h>

#include <gint/std/stdio.h>
#include <gint/display.h>

#include <gint/exc.h>
#include <gint/defs/attributes.h>


#ifdef USE_LIBPROF

#include <libprof.h>

#endif


#ifdef USE_LIBLOG

#include <liblog.h>

GNORETURN void system_error(uint32_t code)
{
ll_display_log();
while(1)
getkey();
}

#endif

void fe_custom_panic()
{

#ifdef USE_LIBLOG
gint_panic_set(system_error);
#endif

}


#ifdef USE_LIBPROF
static uint32_t frame_interval_min=1000000;
static uint32_t frame_interval_max=1;
static uint32_t fps=0;
#endif




int32_t fe_get_fps()
{
#ifdef USE_LIBPROF
return fps;
#else
return -1;
#endif
}


void fe_display(const uint32_t libprof_channel)
{
fe_update(libprof_channel);

dupdate();

#ifdef USE_LIBLOG
ll_log("VRAM contents sent.");
#endif
dclear(C_WHITE);

#ifdef USE_LIBLOG
ll_log("VRAM cleared.");
#endif
}


void fe_update(const uint32_t libprof_channel)
{
///dupdate();
#ifdef USE_LIBPROF
// gestion du temps avec libprof
if (prof_elapsed)
{
prof_leave(libprof_channel);
uint32_t frame_interval = prof_time(libprof_channel);
//sleep_us(0, MINIMUM_FRAME_DELAY-frame_interval);
if (frame_interval<frame_interval_min)
frame_interval_min = frame_interval;
if (frame_interval>frame_interval_max)
frame_interval_max = frame_interval;
fps=1000000/frame_interval;
}
else
{
prof_init(libprof_channel+1, 0);
}
//dupdate();
prof_clear(libprof_channel);
prof_enter(libprof_channel);
#endif
fe_zbuffer_clear();

#ifdef USE_LIBLOG
char fps_str[10];
sprintf(fps_str, ">> FPS = %d", fps);
ll_log(fps_str);
#else
ll_log(">> FPS not available");
#endif
//dclear(C_WHITE);
}


+ 23
- 10
src/space.c View File

@@ -2,8 +2,13 @@
#include <fxengine/camera.h>

#include <gint/std/stdlib.h>
#include <gint/std/stdio.h>
#include <gint/std/string.h>

#ifdef USE_LIBLOG
#include <liblog.h>
#endif

double fe_matrix[3][3]=
{
{0,0,0},
@@ -15,7 +20,7 @@ fe_ipoint fe_translate_delta;
static double reducted_cos(const double a)
{
double u= 1.0;
const double a2 = a * a;
const double a2 = a * a;
for(int32_t p = 17; p>=1; p -= 2)
u = 1 - a2 / (p * p + p) * u;
return u;
@@ -25,10 +30,10 @@ static double reducted_cos(const double a)
double fe_modulo_2pi(double a)
{
while (a<=-pi)
a += pi2;
while (a>pi)
a -= pi2;
return a;
a += pi2;
while (a>pi)
a -= pi2;
return a;
}

double fe_cos(double angle)
@@ -52,9 +57,9 @@ double fe_sin(double angle)
void fe_vertex_translate(fe_ivertex * v)
{
static fe_ipoint temp;
temp.x = v->real.x - fe_translate_delta.x;
temp.y = v->real.y - fe_translate_delta.y;
temp.z = v->real.z - fe_translate_delta.z;
temp.x = 64*(v->real.x - fe_translate_delta.x);
temp.y = 64*(v->real.y - fe_translate_delta.y);
temp.z = 64*(v->real.z - fe_translate_delta.z);

v->translated.x = (double)(fe_matrix[0][0]*(double)temp.x + fe_matrix[0][1]*(double)temp.y + fe_matrix[0][2]*(double)temp.z);
v->translated.z = (double)(fe_matrix[1][0]*(double)temp.x + fe_matrix[1][1]*(double)temp.y + fe_matrix[1][2]*(double)temp.z);
@@ -62,8 +67,7 @@ void fe_vertex_translate(fe_ivertex * v)

//v->translated.x*=10;
//v->translated.y*=10;
v->translated.x*=64;
v->translated.y*=64;
v->translated.z/=64;
if (v->translated.z>0)
{
v->translated.x/=v->translated.z;
@@ -79,6 +83,15 @@ void fe_vertex_translate(fe_ivertex * v)

v->translated.x+=fe_x_mid;
v->translated.y+=fe_y_mid;

#ifdef USE_LIBLOG
char str[50];
sprintf(str, "Vrtx X:%d Y:%d Z:%d",
v->translated.x,
v->translated.y,
v->translated.z);
ll_log(str);
#endif
}



+ 0
- 35
src/triangle.c View File

@@ -10,41 +10,6 @@
#include <gint/display.h>
#include <gint/clock.h>

#ifdef USE_LIBPROF
static uint32_t frame_interval_min=1000000;
static uint32_t frame_interval_max=1;
#endif

void fe_render_update(const uint32_t libprof_channel)
{
dupdate();
#ifdef USE_LIBPROF
// gestion du temps avec libprof
if (prof_elapsed)
{
prof_leave(libprof_channel);
uint32_t frame_interval = prof_time(libprof_channel);
//sleep_us(0, MINIMUM_FRAME_DELAY-frame_interval);
if (frame_interval<frame_interval_min)
frame_interval_min = frame_interval;
if (frame_interval>frame_interval_max)
frame_interval_max = frame_interval;
}
else
{
prof_init(libprof_channel+1, 0);
}
//dupdate();
prof_clear(libprof_channel);
prof_enter(libprof_channel);
#endif
fe_zbuffer_clear();

///fe_set(dh, dv, roulis, camera);

dclear(C_WHITE);
}

/**
* @brief Orientation of the face
*


+ 5
- 9
src/zbuffer.c View File

@@ -28,15 +28,11 @@ extern void dma_memset(void *dst, uint32_t l, size_t size);
void fe_zbuffer_clear()
{
uint32_t indice = 0;
/*
if (isSH3())
*/
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = fe_max_dist;
/*
else
dma_memset(zbuffer, fe_max_dist, size_char);
*/
for (indice = 0; indice < size_uint32; indice ++)
zbuffer[indice] = fe_max_dist;
#ifdef USE_LIBLOG
ll_log(">> ZBuffer cleared.");
#endif
}

bool fe_zbuffer_set_px(const uint32_t x, const uint32_t y, const uint32_t dist)


Loading…
Cancel
Save