-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiva-ge.h
80 lines (63 loc) · 2.07 KB
/
tiva-ge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef TIVA_GE_H
#define TIVA_GE_H
/*
Game engine. Provides functions for setup and the gameloop, which handles input for the user.
Graphics have to be handled by the game running, which can be set using a function pointer. This
function is run continuously and takes the elapsed time since the last loop.
*/
#include "InitGPIO.h"
#include "LCD.h"
#include "Input.h"
#include "systick.h"
#include "tiva-gc-inc.h"
typedef struct GE_Button
{
uint8_t pressed, held;
} GE_Button;
extern GE_Button SW1, SW2, SEL;
typedef struct GE_Joystick
{
point pos;
uint8_t changed;
uint8_t up, down, left, right;
point threshold;
} GE_Joystick;
extern GE_Joystick JS;
// function pointer main menu
// function pointer current game, can be null
// Performs input and screen initializations and clears screen to black.
void GE_Setup(void);
// Set the main menu function, without it the engine will not function properly as
// it is the function responsible for setting which game will be run.
// Param:
// func: pointer to void function
void GE_SetMainMenu(void (*func)(void));
// Set update function/game
// The logic for the game must be in a function to be looped by the game engine.
// Input is handled by the engine, and the elapsed time is given as a parameter.
// The function must return:
// 1: to keep looping
// 0: to break the loop and return to the main menu
// Param:
// func: pointer to function taking one float parameter and returning int
void GE_SetUpdate(int (*func)(void));
// Runs the main gameloop
void GE_Loop(void) __attribute__((noreturn));
// Get time from SysTick
// Return:
// Ticks since last reload
int GE_STGet(void);
// Get time from SysTick and reload
// Return:
// Ticks since last reload
int GE_STPop(void);
// See if SysTick reloaded since the last time this function was called
// Return:
// 1 if reloaded, 0 if not
char GE_STGetCount(void);
// Generate pseudo-random number
// Uses an xorshift with 3 shifts for a period of 2^32 - 1
// Return:
// 32 bit pseudo-random number
uint32_t GE_Rand(void);
#endif // TIVA_GE_H