-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.c
134 lines (119 loc) · 5.88 KB
/
globals.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
#include "globals.h"
struct sp1_Rect full_screen = {0, 0, 32, 24};
uint8_t random_value;
uint8_t tmp_val;
uint8_t tmp_val2;
uint8_t exit_count;
// or using UDG from just code
uint8_t map[25][32] = {
{C,A,A,A,A,A,A,A,A,A,A,A,A,A,A,M,M,A,A,A,A,A,A,A,A,A,A,A,A,A,A,D},
{B,0,0,0,0,0,0,0,0,0,0,0,0,0,0,B,B,0,0,0,0,0,0,0,0,0,0,0,0,0,0,B},
{B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B,B,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B},
{B,I,0,C,A,D,I,0,C,A,A,A,D,I,0,B,B,I,0,C,A,A,A,D,I,0,C,A,D,I,0,B},
{B,K,0,B,0,B,I,0,B,0,0,0,B,I,0,B,B,I,0,B,0,0,0,B,I,0,B,0,B,K,0,B},
{B,I,0,E,A,F,I,0,E,A,A,A,F,I,0,E,F,I,0,E,A,A,A,F,I,0,E,A,F,I,0,B},
{B,I,0,0,0,0,I,0,0,0,0,0,0,I,0,0,0,I,0,0,0,0,0,0,I,0,0,0,0,I,0,B},
{B,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,I,0,B},
{B,I,0,S,A,T,I,0,U,I,0,S,A,A,A,M,M,A,A,A,T,I,0,U,I,0,S,A,T,I,0,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I,I,I,I,I,I,I,I,I,I,0,B,B,I,I,I,I,0,B},
{E,A,A,A,A,A,J,J,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,J,J,A,A,A,A,A,F}
};
uint8_t * currentmap;
// 15
uint8_t pill_eaten = NONE;
struct spritep pacman;
struct spritep ghost_red;
struct spritep ghost_cyan;
struct spritep ghost_magenta;
struct spritep ghost_yellow;
struct bonus cherry;
struct sp1_ss* billboard;
struct sp1_ss* points_sp;
struct spritep * ghosts[4] = {&ghost_cyan, &ghost_red, &ghost_magenta, &ghost_yellow};
JOYFUNC joy;
// redefine this array to allow define keys
udk_t joy_keys = { IN_KEY_SCANCODE_SPACE, IN_KEY_SCANCODE_p, IN_KEY_SCANCODE_o, IN_KEY_SCANCODE_a, IN_KEY_SCANCODE_q };
uint16_t in;
// reusable vars
uint8_t row;
uint8_t col;
uint8_t current;
uint16_t points = 0;
uint8_t remaining_points;
uint8_t frame = 0;
uint8_t lives = 0;
uint8_t level = 0;
uint8_t repaint_lives = 1;
uint8_t reached_level = 0;
uint8_t slowticker = 0;
uint8_t showing_points = NONE;
uint8_t idx;
uint16_t matrixrow;
uint16_t matrixrow_ghost;
uint8_t map_num = 1;
struct spritep * collided_sprite;