Collab_RPG/src/main.c
2023-07-09 22:20:53 +02:00

149 lines
4.8 KiB
C

#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <gint/cpu.h>
#include "config.h"
#if USB_FEATURE
#include <gint/usb-ff-bulk.h>
#include <gint/usb.h>
#endif //USB_FEATURE
#if !defined(FXCG50) && defined(COLOR2BIT)
#define GRAYMODEOK
#endif
#ifdef GRAYMODEOK
#include <gint/gray.h>
#endif //GRAYMODEOK
#include <stdint.h>
#include <stdbool.h>
#include "game.h"
#include "mapdata.h"
#include "dialogs.h"
extern bopti_image_t player_face_img;
/* Game data (defined in "game.h")*/
Game game = {
&map_level0,
{10*PXSIZE, 48*PXSIZE, 0, 0, 100, SPEED},
false, false, false, 0
};
/* screen capture management code */
#if USB_FEATURE==1
void USB_feature( void )
{
if (game.screenshot && usb_is_open()) {
#ifdef GRAYMODEOK // This is a trick, if GRAYMODEOK is defined then
// we make the code accessible
if (dgray_enabled())
usb_fxlink_screenshot_gray(false);
else
#endif
// else we just let the usual screeshot function
usb_fxlink_screenshot(false);
game.screenshot = false;
}
if (game.record && usb_is_open()) {
#ifdef GRAYMODEOK
if (dgray_enabled())
usb_fxlink_videocapture_gray(false);
else
#endif
usb_fxlink_videocapture(false);
}
}
#endif
/* Timer callback */
int update_time(void) {
game.frame_duration++;
return TIMER_CONTINUE;
}
int main(void) {
int timer;
timer = timer_configure(TIMER_TMU, 1000, GINT_CALL(update_time));
if(timer < 0){
return -1;
}
timer_start(timer);
#if USB_FEATURE==1
usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL};
usb_open(interfaces, GINT_CALL_NULL);
#endif
/* start grayscale engine */
#ifdef GRAYMODEOK
dgray(DGRAY_ON);
#endif
showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. Ut velit mauris, egestas sed, gravida nec, ornare ut, mi. Aenean ut orci vel massa suscipit pulvinar. Nulla sollicitudin. Fusce varius, ligula non tempus aliquam, nunc turpis ullamcorper nibh, in tempus sapien eros vitae ligula. Pellentesque rhoncus nunc et augue. Integer id felis. Curabitur aliquet pellentesque diam. Integer quis metus vitae elit lobortis egestas. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi vel erat non mauris convallis vehicula. Nulla et sapien. Integer tortor tellus, aliquam faucibus, convallis id, congue eu, quam. Mauris ullamcorper felis vitae erat. Proin feugiat, augue non elementum posuere, metus purus iaculis lectus, et tristique ligula justo vitae magna. Aliquam convallis sollicitudin purus. Praesent aliquam, enim at fermentum mollis, ligula massa adipiscing nisl, ac euismod nibh nisl eu lectus. Fusce vulputate sem at sapien. Vivamus leo. Aliquam euismod libero eu enim. Nulla nec felis sed leo placerat imperdiet. Aenean suscipit nulla in justo. Suspendisse cursus rutrum augue. Nulla tincidunt tincidunt mi. Curabitur iaculis, lorem vel rhoncus faucibus, felis magna fermentum augue, et ultricies lacus lorem varius purus. Curabitur eu amet.");
do{
/* clear screen */
dclear(C_WHITE);
/* render the map */
draw(&game);
/* start the logic of the game */
game_logic(&game);
/* Screen blit */
dupdate();
/* Screen capture feature if enabled */
#if USB_FEATURE==1
USB_feature();
#endif
/* Management of the inputs */
get_inputs(&game);
/* Run the game at max. 50fps */
while(game.frame_duration < 20) sleep();
/* Reset frame_duration for the next frame */
game.frame_duration = 0;
}while(!game.exittoOS); // want to exit ?
/* shutdown grayengine*/
#ifdef GRAYMODEOK
dgray(DGRAY_OFF);
#endif
/* close USB */
#if USB_FEATURE==1
usb_close();
#endif
timer_stop(timer);
return 1;
}