💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Tetris › files › 228c473db8b452d97863e2fb33f… captured on 2023-12-28 at 15:48:21. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-09-08)
-=-=-=-=-=-=-
0 /* See LICENSE file for copyright and license details. */
1 #include "backend.h"
2 #include "Pokitto.h"
3
4 Pokitto::Core tetris;
5
6 uint8 palette[] = {
7 /* blocks */
8 3,
9 6,
10 12,
11 4,
12 5,
13 10,
14 7,
15 /* borders */
16 0,
17 0,
18 0,
19 0,
20 0,
21 0,
22 0,
23 9, /* background */
24 1, /* text */
25 };
26
27 int backend_width = 110;
28 int backend_height = 88;
29
30 int backend_init() {
31 tetris.begin();
32 return 0;
33 }
34
35 void backend_fill(int x, int y, int w, int h, int c) {
36 tetris.display.setColor(palette[c]);
37 tetris.display.fillRect(x, y, w, h);
38 }
39
40 void backend_draw(int x, int y, int w, int h, int c) {
41 tetris.display.setColor(palette[c]);
42 tetris.display.drawRect(x, y, w, h);
43 }
44
45 uint8 backend_input() {
46 while (tetris.isRunning() && !tetris.update()) continue;
47 if (!tetris.isRunning()) return QUIT;
48 uint8 state = 0;
49 if (tetris.buttons.pressed(BTN_A))
50 state |= ROTATE;
51 if (tetris.buttons.pressed(BTN_LEFT))
52 state |= LEFT;
53 if (tetris.buttons.pressed(BTN_RIGHT))
54 state |= RIGHT;
55 if (tetris.buttons.pressed(BTN_DOWN))
56 state |= DOWN;
57 return state;
58 }
59
60 void backend_refresh() {
61 }
62
63 void backend_clean() {
64 }
65