-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.cpp
111 lines (80 loc) · 2.03 KB
/
menu.cpp
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#if defined TEENSYDUINO || defined ARDUINO_AVR_NANO
#include "defines.h"
#include "menu.h"
#include "bootloader.h"
#include "paint.h"
#include "decay.h"
#include "host.h"
#include "isp.h"
#include "tiny.h"
#include "tetris.h"
#include "pong.h"
#include "anim.h"
#ifdef TEENSYDUINO
#define TOTAL_GAMES 9
#else
#define TOTAL_GAMES 8
#endif
CONST char game_name_0[] = "Anim";
CONST char game_name_1[] = "Blck";
CONST char game_name_2[] = "Pong";
CONST char game_name_3[] = "Draw";
CONST char game_name_4[] = "PEW";
CONST char game_name_5[] = "Fade";
CONST char game_name_6[] = "Host";
CONST char game_name_7[] = "Tiny";
CONST char game_name_8[] = "ISP";
CONST char* const game_name_table[] = {
game_name_0,
game_name_1,
game_name_2,
game_name_3,
game_name_4,
game_name_5,
game_name_6,
game_name_7,
game_name_8,
};
void menu::frame(pixelArray **strip, WII **wii) {
for (int i=0; i<PLAYERS; i++) {
if (!wii[i]->wiimoteConnected) continue;
if (wii[i]->getButtonClick(DOWN)) {
selected++;
if (selected >= TOTAL_GAMES) selected = 0;
} else if (wii[i]->getButtonClick(UP)) {
selected--;
if (selected < 0) selected = TOTAL_GAMES-1;
} else if (wii[i]->getButtonClick(TWO)) {
animation::delete_all();
strip[0]->clear();
switch (selected) {
case 0: new anim(); break;
case 1: new tetris(); break;
case 2: new pong(); break;
case 3: new paint(); break;
case 4: new decayPew(); break;
case 5: new decay(); break;
case 6: new host(); break;
case 7: new tiny(); break;
#ifdef TEENSYDUINO
case 8: new isp(); break;
#endif
}
return;
} else if (wii[i]->getButtonClick(B)) {
animation::delete_all();
strip[0]->clear();
new bootloader(true);
return;
}
}
#ifdef TEENSYDUINO
const char *text = game_name_table[selected];
#else
char text[10] = {0};
strcpy_P(text, (char*)pgm_read_word(&(game_name_table[selected])));
#endif
strip[0]->clear();
strip[0]->string(text, 1, GRID_HEIGHT-5, pix_colorx[selected]);
}
#endif //TEENSYDUINO || ARDUINO_AVR_NANO