diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-09 19:26:13 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2018-07-09 19:26:13 +0200 |
| commit | f0b654b9bf3bc2a93c1f89d4cc3edcf77b948555 (patch) | |
| tree | 91b7404dca0b6eb136cb7f9b144435419144b777 /System.h | |
| parent | d85464781580796bbcc744ae732e56d1920e3b0f (diff) | |
| download | pocketempires-f0b654b9bf3bc2a93c1f89d4cc3edcf77b948555.tar.gz | |
Game has been restructured in favor of OOP
Diffstat (limited to 'System.h')
| -rw-r--r-- | System.h | 96 |
1 files changed, 13 insertions, 83 deletions
@@ -1,102 +1,32 @@ -#ifndef __SYSTEM_HEADER__ -#define __SYSTEM_HEADER__ - -#ifdef __cplusplus -extern "C" -{ -#endif +#ifndef SYSTEM_H__ +#define SYSTEM_H__ /* ************************************** - * Includes * + * Includes * * **************************************/ -#include "Global_Inc.h" +#include <Gamebuino.h> /* ************************************** - * Defines * + * Defines * * **************************************/ -#define TIMEBASE_1_SECOND 1 -#define TIMEBASE_1_MINUTE TIMEBASE_1_SECOND * 60 - /* ************************************** - * Structs and enums * + * Structs and enums * * **************************************/ -typedef struct t_Timer -{ - uint32_t time; - uint32_t orig_time; - bool repeat_flag; - bool busy; - void (*Timeout_Callback)(void); -}TYPE_TIMER; - -typedef struct t_CollisionBlock -{ - uint16_t x; - uint16_t y; - uint8_t w; - uint8_t h; -}TYPE_COLLISION_BLOCK; - /* ************************************** - * Global Prototypes * + * Global Variables * * **************************************/ -// Calls init routines -void SystemInit(void); -// Calls srand() using current global_timer value as seed -void SystemSetRandSeed(void); -// Tells whether srand() has been called using a pseudo-random value -bool SystemIsRandSeedSet(void); -// Stops program flow during X cycles -void SystemWaitCycles(uint32_t cycles); -// To be called from GfxDrawScene after each cycle -void SystemRunTimers(void); -// 1 cycle-length flag with a frequency of 1 Hz -bool System1SecondTick(void); -// 1 cycle-length flag with a frequency of 10 Hz -bool System100msTick(void); -// Returns random value between given minimum and maximum values -uint32_t SystemRand(uint32_t min, uint32_t max); -// Increases global timer by 1 step -void SystemIncreaseGlobalTimer(void); -// (Experimental) -uint64_t SystemGetGlobalTimer(void); -// Returns whether critical section of code is being entered -bool SystemIsBusy(void); -// Returns whether indicated value is contained inside buffer -bool SystemContains_u8(uint8_t value, uint8_t* buffer, size_t sz); -// Overload for uint16_t -bool SystemContains_u16(uint16_t value, uint16_t * buffer, size_t sz); -// Creates a timer instance wiht a determined value and associates it to a callback -// Once time expires, callback is automatically called right after GfxDrawScene(). -TYPE_TIMER * SystemCreateTimer(uint32_t seconds, bool rf, void (*timer_callback)(void) ); -// Reportedly, sets all timer data to zero. -void SystemResetTimers(void); -// To be called every cycle (i.e.: inside GfxDrawScene() ). -void SystemUserTimersHandler(void); -// Sets timer remaining time to initial value. -void SystemTimerRestart(TYPE_TIMER * timer); -// Flushes a timer pointed to by timer. -void SystemTimerRemove(TYPE_TIMER * timer); -// Compares two arrays of unsigned short type. -bool SystemArrayCompare(unsigned short * arr1, unsigned short * arr2, size_t sz); -// Checks collision of two objects -bool SystemCollisionCheck(TYPE_COLLISION_BLOCK* c1, TYPE_COLLISION_BLOCK* c2); -// Transforms integer to string. Use this instead of sprintf() as much as possible. -// Returns the number of bytes written into "str". In case of error, 0 is returned. -size_t Systemitoa(char* str, size_t sz, int16_t value); -// Return hypothenuse of two points -uint32_t SystemGetHyp(uint16_t x, uint16_t y); +/* Gamebuino object is only visible for + * and accessed by C++ source files. */ +extern Gamebuino gb; /* ************************************** - * Global Variables * + * Global Prototypes * * **************************************/ -#ifdef __cplusplus -} -#endif +void SystemInit(void); -#endif //__SYSTEM_HEADER__ +#endif /* SYSTEM_H__ */ |
