112 lines
2.3 KiB
C++
112 lines
2.3 KiB
C++
|
#include <gint/display.h>
|
||
|
#include <gint/drivers/r61524.h>
|
||
|
|
||
|
#include <gint/keyboard.h>
|
||
|
|
||
|
#include <fxlibc/printf.h>
|
||
|
|
||
|
#include <libprof.h>
|
||
|
#include <gint/usb.h>
|
||
|
#include <gint/usb-ff-bulk.h>
|
||
|
|
||
|
bool screenshot = false;
|
||
|
bool record = false;
|
||
|
bool exitToOS = false;
|
||
|
|
||
|
static void get_inputs( void )
|
||
|
{
|
||
|
key_event_t ev;
|
||
|
while((ev = pollevent()).type != KEYEV_NONE)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
if(keydown(KEY_EXIT)) {exitToOS = true; };
|
||
|
|
||
|
if(keydown(KEY_7)) {screenshot = true; };
|
||
|
if(keydown(KEY_8)) {record = !record; };
|
||
|
}
|
||
|
|
||
|
static void update( float dt )
|
||
|
{
|
||
|
|
||
|
// all update stuff dependng on time will be done here
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
exitToOS = false;
|
||
|
float elapsedTime = 0.0f;
|
||
|
|
||
|
__printf_enable_fp();
|
||
|
__printf_enable_fixed();
|
||
|
|
||
|
usb_interface_t const *interfaces[] = { &usb_ff_bulk, NULL };
|
||
|
usb_open(interfaces, GINT_CALL_NULL);
|
||
|
|
||
|
prof_init();
|
||
|
prof_t perf_update, perf_render;
|
||
|
uint32_t time_update=0, time_render=0;
|
||
|
|
||
|
do
|
||
|
{
|
||
|
perf_update = prof_make();
|
||
|
prof_enter(perf_update);
|
||
|
|
||
|
{
|
||
|
// all the stuff to be update should be put here
|
||
|
|
||
|
// read inputs from the player
|
||
|
get_inputs( );
|
||
|
|
||
|
// update as per the time spend to do the loop
|
||
|
update( elapsedTime );
|
||
|
}
|
||
|
|
||
|
prof_leave(perf_update);
|
||
|
time_update = prof_time(perf_update);
|
||
|
|
||
|
perf_render = prof_make();
|
||
|
prof_enter(perf_render);
|
||
|
|
||
|
{
|
||
|
// all the stuff to be rendered should be put here
|
||
|
dclear( C_WHITE );
|
||
|
dprint(1,01, C_BLACK, "Update = %.0f microseconds", (float) time_update );
|
||
|
dprint(1,11, C_BLACK, "Render = %.0f microseconds", (float) time_render );
|
||
|
dprint(1,21, C_RED, ">Total = %.3f milliseconds", (float) elapsedTime / 1000.0f );
|
||
|
|
||
|
dprint(1,41, C_BLUE, "FPS = %.3f", (float) (1000000.0f / elapsedTime) );
|
||
|
|
||
|
//r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT);
|
||
|
dupdate();
|
||
|
}
|
||
|
|
||
|
prof_leave(perf_render);
|
||
|
time_render = prof_time(perf_render);
|
||
|
|
||
|
elapsedTime = ((float) (time_update+time_render));
|
||
|
|
||
|
if (screenshot && usb_is_open())
|
||
|
{
|
||
|
usb_fxlink_screenshot(false);
|
||
|
screenshot = false;
|
||
|
}
|
||
|
|
||
|
if(record && usb_is_open())
|
||
|
{
|
||
|
usb_fxlink_videocapture(false);
|
||
|
}
|
||
|
}
|
||
|
while (exitToOS==false);
|
||
|
|
||
|
|
||
|
prof_quit();
|
||
|
usb_close();
|
||
|
|
||
|
return 1;
|
||
|
}
|