/
display_loop.c
353 lines (299 loc) · 5.55 KB
/
display_loop.c
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
#include <setjmp.h>
#include <stdio.h>
#include "config.h"
#include "scrolltext/scrolltext.h"
#include "animations/snake.h"
#include "animations/program.h"
#include "animations/matrix.h"
#include "animations/gameoflife.h"
#include "animations/stonefly.h"
#include "animations/flyingdots.h"
#include "animations/breakout_demo.h"
#include "animations/ltn_ant.h"
#include "animations/bitmapscroller/laborlogo.h"
#include "animations/bitmapscroller/amphibian.h"
#include "animations/bitmapscroller/outofspec.h"
#include "animations/bitmapscroller/fairydust.h"
#include "animations/fpmath_patterns.h"
#include "animations/mherweg.h"
#include "animations/blackhole.h"
#include "animations/squares.h"
#ifdef ANIMATION_TIME
#include "animations/borg_time.h"
#endif
#include "borg_hw/borg_hw.h"
#include "can/borg_can.h"
#include "random/prng.h"
#include "random/persistentCounter.h"
#include "mcuf/mcuf.h"
#include "menu/menu.h"
#include "pixel.h"
#ifdef SMALLANIMATION_ROWWALK
# include "smallani/rowwalk.h"
#endif
#ifdef SMALLANIMATION_COLWALK
# include "smallani/colwalk.h"
#endif
#ifdef SMALLANIMATION_COLBOUNCE
# include "smallani/colbounce.h"
#endif
#ifdef JOYSTICK_SUPPORT
# include "joystick/joystick.h"
#endif
volatile unsigned char oldMode, oldOldmode, mode;
jmp_buf newmode_jmpbuf;
#ifndef MENU_SUPPORT
void snake_game(void);
void tetris(void);
void tetris_bastet(void);
void tetris_fp(void);
void borg_invaders(void);
void borg_breakout(unsigned char demomode);
#endif
void display_loop(){
// mcuf_serial_mode();
mode = setjmp(newmode_jmpbuf);
oldOldmode = oldMode;
#ifdef JOYSTICK_SUPPORT
waitForFire = 1;
#endif
for(;;){
#ifndef MENU_SUPPORT
clear_screen(0);
#endif
oldMode = mode;
switch(mode++) {
#ifdef ANIMATION_SCROLLTEXT
case 1:
scrolltext(scrolltext_text);
#ifdef RANDOM_SUPPORT
{
char a[28];
sprintf(a,"</# counter == %lu ", (unsigned long) percnt_get());
scrolltext(a);
}
#endif
#endif
#ifdef ANIMATION_TIME
#ifndef ANIMATION_SCROLLTEXT
case 1:
#endif
time_anim();
break;
#else
#ifdef ANIMATION_SCROLLTEXT
break;
#endif
#endif
#ifdef ANIMATION_SPIRAL
# ifndef SPIRAL_DELAY
# define SPIRAL_DELAY 5
# endif
case 2:
spiral(SPIRAL_DELAY);
break;
#endif
#ifdef ANIMATION_JOERN1
case 3:
joern1();
break;
#endif
#ifdef ANIMATION_SNAKE
case 4:
snake_animation();
break;
#endif
#ifdef ANIMATION_CHECKERBOARD
case 5:
checkerboard(20);
break;
#endif
#ifdef ANIMATION_FIRE
case 6:
fire();
break;
#endif
#ifdef ANIMATION_TIME
case 7:
time_anim();
break;
#endif
#ifdef ANIMATION_MATRIX
case 8:
matrix();
break;
#endif
#ifdef ANIMATION_RANDOM_BRIGHT
case 9:
random_bright(30);
break;
#endif
#ifdef ANIMATION_STONEFLY
case 10:
stonefly();
break;
#endif
#ifdef ANIMATION_GAMEOFLIFE
case 11:
gameoflife();
break;
#endif
#ifdef ANIMATION_FLYINGDOTS
case 12:
flyingdots();
break;
#endif
#ifdef ANIMATION_BREAKOUT
case 13:
breakout_demo();
break;
#endif
#ifdef ANIMATION_MHERWEG
case 14:
mherweg();
break;
#endif
#ifdef ANIMATION_TIME
case 15:
time_anim();
break;
#endif
#ifdef ANIMATION_LTN_ANT
case 16:
ltn_ant();
break;
#endif
#ifdef ANIMATION_LABORLOGO
case 17:
laborlogo();
break;
#endif
#ifdef ANIMATION_AMPHIBIAN
case 18:
amphibian();
break;
#endif
#ifdef ANIMATION_LOGO_OOS
case 19:
logo_OutOfSpec();
break;
#endif
#ifdef ANIMATION_FAIRYDUST
case 20:
fairydust();
break;
#endif
#ifdef ANIMATION_PLASMA
case 21:
plasma();
break;
#endif
#ifdef ANIMATION_PSYCHEDELIC
case 22:
psychedelic();
break;
#endif
#ifdef ANIMATION_BLACKHOLE
case 23:
blackhole();
break;
#endif
#ifdef ANIMATION_SQUARES
case 24:
squares();
break;
#endif
#ifdef ANIMATION_TESTS
case 31:
test_level(1);
break;
case 32:
test_level(2);
break;
case 33:
test_level(3);
break;
case 35:
test_palette();
test_palette2();
break;
#endif
#ifdef SMALLANIMATION_ROWWALK
case 36:
rowwalk(SMALLANIMATION_ROWWALK_COUNT,SMALLANIMATION_ROWWALK_SPEED);
break;
#endif
#ifdef SMALLANIMATION_COLWALK
case 37:
colwalk(SMALLANIMATION_COLWALK_COUNT,SMALLANIMATION_COLWALK_SPEED);
break;
#endif
#ifdef SMALLANIMATION_COLBOUNCE
case 38:
colbounce(SMALLANIMATION_COLBOUNCE_COUNT,SMALLANIMATION_COLBOUNCE_SPEED);
break;
#endif
#ifdef SMALLANIMATION_ROWBOUNCE
case 39:
rowbounce(SMALLANIMATION_ROWBOUNCE_COUNT,SMALLANIMATION_ROWBOUNCE_SPEED);
break;
#endif
#ifdef MENU_SUPPORT
case 42:
mode = 1;
break;
case 43:
menu();
mode = oldOldmode;
break;
#else
case 42:
#ifdef JOYSTICK_SUPPORT
if (JOYISFIRE)
mode = 43;
else
#endif
mode = 1;
break;
case 43:
#ifdef JOYSTICK_SUPPORT
waitForFire = 0; // avoid circular jumps
while (JOYISFIRE); // wait until user released the fire button
#endif
wait(25); // wait for button to settle
# ifdef GAME_TETRIS
tetris();
# endif
# ifdef GAME_BASTET
tetris_bastet();
# endif
# ifdef GAME_TETRIS_FP
tetris_fp();
# endif
# ifdef GAME_SPACE_INVADERS
borg_invaders();
# endif
# ifdef GAME_SNAKE
snake_game();
# endif
# ifdef GAME_BREAKOUT
borg_breakout(0);
# endif
#ifdef JOYSTICK_SUPPORT
while (JOYISFIRE); // avoid an unwanted restart of the game loop
#endif
wait(25); // wait for button to settle
mode = oldOldmode; // restore old animation mode
#ifdef JOYSTICK_SUPPORT
waitForFire = 1; // reenable joystick query of the wait() function
#endif
break;
#endif
#ifdef ANIMATION_OFF
case 0xFF:
off();
break;
#endif
}
}
}