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
81
82
|
#ifndef MAIN_H_
#define MAIN_H_
#include <avr/io.h>
/** Game types */
#define GAMEID_TETRIS 1
/** Board types */
#define BOARDID_PLAIN 1
#define BOARDID_MYAVR 2
/** Programmversion */
enum program_version {
VERSION = 5,
};
/** Taster Hardwarebits */
enum button_bits {
BTNBIT_UP = PINC0,
BTNBIT_LEFT = PINC1,
BTNBIT_RIGHT = PINC2,
BTNBIT_DOWN = PINC3,
BTNBIT_A = PINC4,
BTNBIT_B = PINC5,
};
/** Taster ID Nummern. */
enum button {
BTN_UP,
BTN_LEFT,
BTN_RIGHT,
BTN_DOWN,
BTN_A,
BTN_B,
NR_BTN,
};
/** Tasterereignis ID Nummer */
enum button_action {
BTNACT_PRESSED,
BTNACT_RELEASED,
};
/** Zuordnung eines Tasters zu einem Ereignis. */
struct button_event {
/** Die ID des Tasters. */
enum button button;
/** Die ID des Ereignisses. */
enum button_action action;
};
/** Ringpuffer der Tasterereignisse. */
struct button_event_queue {
/** Der Ringpuffer */
struct button_event events[16];
/** Anzahl der Elemente im Ringpuffer. */
uint8_t nr_events;
/** Schreibindex fuer den Rungpuffer. */
uint8_t write_index;
/** Leseindex fuer den Ringpuffer. */
uint8_t read_index;
};
/** Schnittstellendefinition zur Spiellogik. */
struct game_interface {
/** Zeiger auf Funktion zur Tastenauswertung. */
void (*handle_button)(const struct button_event *event);
/** Zeiger auf Funktion fuer autofire-delay. */
uint8_t (*get_autofire_delay)(enum button button);
/** Zeiger auf 100 Hertz Tick-Funktion. */
void (*do_100hz_tick)(void);
/** Zeiger auf Funktion zur periodischen Abarbeitung. */
void (*periodic_work)(void);
/** Zeiger auf Initialisierungsfunktion. */
void (*init)(void);
};
#endif /* MAIN_H_ */
|