2019-10-24 17:27:13 +02:00
|
|
|
#define GINT_NEED_VRAM
|
2019-09-19 21:07:16 +02:00
|
|
|
#include <gint/display.h>
|
2019-10-24 17:27:13 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <fxengine/fxengine.h>
|
|
|
|
#ifdef USE_LIBPROF
|
2019-09-19 21:07:16 +02:00
|
|
|
#include <libprof.h>
|
2019-10-24 17:27:13 +02:00
|
|
|
#endif
|
|
|
|
#include <gint/std/stdlib.h>
|
2019-10-31 11:00:26 +01:00
|
|
|
#include <gint/std/string.h>
|
2019-10-24 17:27:13 +02:00
|
|
|
#include <stdbool.h>
|
2019-10-31 11:00:26 +01:00
|
|
|
#include <fxengine/renderlist.h>
|
|
|
|
#include <fxengine/render/buffer.h>
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
// FPS count
|
|
|
|
#ifdef USE_LIBPROF
|
|
|
|
static uint32_t frame_interval_min=1000000;
|
|
|
|
static uint32_t frame_interval_max=1;
|
|
|
|
static uint32_t fps=0;
|
2019-09-19 21:07:16 +02:00
|
|
|
#endif
|
2019-10-24 17:27:13 +02:00
|
|
|
uint32_t fe_get_fps()
|
|
|
|
{return fps;}
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
// Triple buffering
|
|
|
|
#define BUFFER_SIZE 256
|
|
|
|
static uint32_t triple_buffering_area[2*BUFFER_SIZE]; // 2 buffers supplémentaires
|
|
|
|
static uint32_t * const temp_buffers[2] = {&triple_buffering_area[0], &triple_buffering_area[BUFFER_SIZE]};
|
2019-10-26 15:13:33 +02:00
|
|
|
static uint32_t * gint_vram=0;
|
2019-10-24 17:27:13 +02:00
|
|
|
static uint32_t working_buffer=0;
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-26 15:13:33 +02:00
|
|
|
static void check_vram()
|
|
|
|
{
|
|
|
|
if (gint_vram==0)
|
|
|
|
gint_vram=vram;
|
|
|
|
}
|
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
void fe_callback_start()
|
|
|
|
{
|
|
|
|
vram=gint_vram;
|
|
|
|
memcpy(gint_vram, temp_buffers[1-working_buffer], sizeof(uint32_t)*BUFFER_SIZE);
|
|
|
|
}
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
void fe_callback_end()
|
|
|
|
{
|
|
|
|
vram=temp_buffers[working_buffer];
|
|
|
|
}
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
void fe_draw()
|
2019-09-19 21:07:16 +02:00
|
|
|
{
|
2019-10-24 17:27:13 +02:00
|
|
|
memcpy(gint_vram, temp_buffers[1-working_buffer], sizeof(uint32_t)*BUFFER_SIZE);
|
2019-09-19 21:07:16 +02:00
|
|
|
}
|
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
void switch_frame()
|
|
|
|
{
|
|
|
|
working_buffer=1-working_buffer;
|
|
|
|
vram=temp_buffers[working_buffer];
|
|
|
|
dclear(C_WHITE);
|
|
|
|
}
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-26 15:13:33 +02:00
|
|
|
static volatile bool quit=true;
|
2019-10-26 15:17:02 +02:00
|
|
|
|
2019-10-24 17:27:13 +02:00
|
|
|
void fe_load()
|
2019-09-19 21:07:16 +02:00
|
|
|
{
|
2019-10-26 15:13:33 +02:00
|
|
|
check_vram();
|
|
|
|
quit=false;
|
2019-10-24 17:27:13 +02:00
|
|
|
while (1)
|
|
|
|
{
|
2019-10-31 11:00:26 +01:00
|
|
|
fe_clear_zbuffer();
|
|
|
|
fe_render();
|
2019-10-26 15:44:56 +02:00
|
|
|
switch_frame();
|
2019-10-24 17:27:13 +02:00
|
|
|
if (quit)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Free some malloc
|
2019-10-26 15:44:56 +02:00
|
|
|
//// as object list
|
2019-10-24 17:27:13 +02:00
|
|
|
}
|
2019-09-19 21:07:16 +02:00
|
|
|
|
2019-10-26 15:17:02 +02:00
|
|
|
void fe_quit()
|
|
|
|
{
|
|
|
|
quit=1;
|
2019-10-31 11:00:26 +01:00
|
|
|
}
|