diff --git a/CMakeLists.txt b/CMakeLists.txt index 3936853..645fa89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ find_package(Gint 2.9 REQUIRED) find_package(LibProf 2.4 REQUIRED) #set the color mode either to 1bit or 2bits -set(COLORMODE 1b) +set(COLORMODE 2b) fxconv_declare_converters(assets-fx/converters.py) @@ -34,6 +34,7 @@ add_custom_command( set(SOURCES src/main.c src/map.c + src/player.c # ... ) # Shared assets, fx-9860G-only assets and fx-CG-50-only assets diff --git a/src/main.c b/src/main.c index ff84a97..882cfd4 100644 --- a/src/main.c +++ b/src/main.c @@ -1,33 +1,141 @@ + #include #include -#include "map.h" + +#define USB_FEATURE 1 + +#if USB_FEATURE==1 + #include + #include +#endif //USB_FEATURE + #ifdef COLOR2BIT #include -#endif +#endif //COLOR2BIT +#include +#include + +#include "map.h" +#include "player.h" + + + + +struct Player MyPlayer = { 10, 5, 100 }; + + +bool exittoOS = false; + +bool screenshot = false; +bool record = false; + + + +static void get_inputs( void ) +{ + key_event_t ev; + while((ev = pollevent()).type != KEYEV_NONE) + { + + } + + /* Key binding for the Player action */ + /*************************************/ + + + if(keydown(KEY_EXIT)) exittoOS = true; + + if(keydown(KEY_LEFT)) PlayerLeft(); + if(keydown(KEY_RIGHT)) PlayerRight(); + if(keydown(KEY_UP)) PlayerUp(); + if(keydown(KEY_DOWN)) PlayerDown(); + if(keydown(KEY_SHIFT)) PlayerAction(); + + + +#if USB_FEATURE==1 + + if(keydown(KEY_7)) screenshot = true; + if(keydown(KEY_8)) record = !record; + +#endif //USB_FEATURE +} + + +#if USB_FEATURE==1 + + void USB_feature( void ) + { + if (screenshot && usb_is_open()) { + if (!dgray_enabled()) + usb_fxlink_screenshot(false); + else + usb_fxlink_screenshot_gray(false); + screenshot = false; + } + + if (record && usb_is_open()) { + if (!dgray_enabled()) + usb_fxlink_videocapture(false); + else + usb_fxlink_videocapture_gray(false); + } + } + +#endif + + + + int main(void) { + + #if USB_FEATURE==1 + usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL}; + usb_open(interfaces, GINT_CALL_NULL); + #endif + + dclear(C_WHITE); #ifdef COLOR2BIT dgray( DGRAY_ON ); #endif - RenderMap(); - dupdate(); + do + { + + RenderMap(); + + dupdate(); + + #if USB_FEATURE==1 + USB_feature(); + #endif + + get_inputs(); + + } + while (exittoOS == false); + - getkey(); #ifdef COLOR2BIT dgray( DGRAY_OFF ); #endif + #if USB_FEATURE==1 + usb_close(); + #endif + + return 1; } diff --git a/src/map.c b/src/map.c index 8b9ee72..da9f948 100644 --- a/src/map.c +++ b/src/map.c @@ -5,7 +5,7 @@ extern struct Map map_level0; struct Map *map_level = &map_level0; -void RenderMap(void) +void RenderMap( void ) { for (int u = 0; u < map_level->nblayers; u++) { diff --git a/src/player.c b/src/player.c new file mode 100644 index 0000000..cff022c --- /dev/null +++ b/src/player.c @@ -0,0 +1,30 @@ +#include "player.h" +#include "map.h" + +extern struct player; +extern struct Map *map_level; + +void PlayerLeft( void ) +{ + +} + +void PlayerRight( void ) +{ + +} + +void PlayerUp( void ) +{ + +} + +void PlayerDown( void ) +{ + +} + +void PlayerAction( void ) +{ + +} \ No newline at end of file diff --git a/src/player.h b/src/player.h new file mode 100644 index 0000000..094cc99 --- /dev/null +++ b/src/player.h @@ -0,0 +1,27 @@ +#ifndef PLAYER_H +#define PLAYER_H + +#include + + + +struct Player +{ + uint16_t x, y; + uint16_t life; +}; + + + +void PlayerLeft( void ); + +void PlayerRight( void ); + +void PlayerUp( void ); + +void PlayerDown( void ); + +void PlayerAction( void ); + + +#endif \ No newline at end of file