-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprogramming.c
95 lines (78 loc) · 1.91 KB
/
programming.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
void draw_instructions() {
//16 is first arrow tile in 'background.tiles'
//programming[19] = 16;
//20x18
unsigned char first_tile_location = 12;
int counter = 0;
for (; counter < 20; counter++) {
int col = counter % 5;
int row = counter / 5;
int base_tile = first_tile_location + (program[counter] * 4);
int topleft = ((col * 3) + 63) + (row * 60);
int topright = topleft + 1;
int bottomleft = topleft + 20;
int bottomright = bottomleft + 1;
if (counter >= 10) {
topleft += 20;
topright += 20;
bottomleft += 20;
bottomright += 20;
}
if (counter >= 15) {
topleft += 20;
topright += 20;
bottomleft += 20;
bottomright += 20;
}
if (program[counter] == 0) {
current_level[topleft] = 0;
current_level[topright] = 0;
current_level[bottomleft] = 0;
current_level[bottomright] = 0;
} else {
current_level[topleft] = base_tile;
current_level[topright] = base_tile + 1;
current_level[bottomleft] = base_tile + 2;
current_level[bottomright] = base_tile + 3;
}
}
//update background
set_bkg_tiles(0, 0, 20, 18, current_level);
}
void update_programming() {
if(cursor_update())
draw_instructions();
}
void init_programming() {
DISPLAY_OFF;
screen = 3;
reset_sprites();
display_programming();
draw_instructions();
cursor_init();
DISPLAY_ON;
}
void set_command(int row, int col, char dir) {
int program_location = (row * 5) + col;
//cycling
if (program[program_location] == 6 && dir > 0)
program[program_location] = 0;
else if (program[program_location] == 0 && dir < 0)
program[program_location] = 6;
else
program[program_location] = program[program_location] + dir;
}
/*
0 empty
1 forward
2 turnleft
3 turnright
4 transmit
5 function 1
6 function 2
*/
/*
0-09 main program
10-14 function 1
15-19 function 2
*/