-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.h
223 lines (203 loc) · 5.37 KB
/
constants.h
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
#ifndef _CONST_H
#define _CONST_H
#define ACCEL 0x20
#define GRAVITY 0x60
#define MAX_SPEED 0x250
#define JUMP_VEL -0x500
#define PLAYER_WIDTH 7
#define PLAYER_HEIGHT 9
#define ENEMY_WIDTH 7
#define ENEMY_HEIGHT 9
#define COLLECTABLE_WIDTH 7
#define COLLECTABLE_HEIGHT 9
#define TURN_OFF 0xFF
#define MAX_ENEMY 5
#define MAX_LEVELS 7
#define MAX_COLLECTABLES 5
#define ANIM_FRAME_OFFSET 5
#define LIFE_TIMER_MAX 30
#define STAR_TIMER_MAX 15
uint8_t enemy_direction, old_enemy_direction;
const uint8_t palette_spr[16] = {0x00, 0x11, 0x26, 0x36, 0x00, 0x01, 0x21, 0x31, 0x00, 0x06, 0x16, 0x26, 0x00, 0x38, 0x19, 0x29};
const uint8_t palette_title[16] = {0x21, 0x00, 0x10, 0x30, 0x21, 0x01, 0x21, 0x31, 0x21, 0x06, 0x16, 0x26, 0x21, 0x38, 0x19, 0x29};
const uint8_t palette_bg1[16] = {0x20, 0x2, 0x17, 0x16, 0x0a, 0x12, 0x22, 0x32, 0x0a, 0x13, 0x15, 0x33, 0x0a, 0x14, 0x07, 0x34};
const uint8_t palette_bg2[16] = {0x20, 0x17, 0x21, 0x4, 0x22, 0x17, 0x21, 0x31, 0x22, 0x06, 0x15, 0x06, 0x22, 0x07, 0x17, 0x3c};
const uint8_t palette_bg3[16] = {0x20, 0x04, 0x1c, 0x4, 0x22, 0x17, 0x21, 0x31, 0x22, 0x06, 0x15, 0x06, 0x22, 0x07, 0x17, 0x3c};
#pragma bss-name(push, "ZEROPAGE")
uint8_t index, collision, collision_L, collision_R, collision_U, collision_D;
uint8_t object_L, object_R, object_U, object_D, map_coords;
const uint8_t *p_maps;
uint8_t eject_L, eject_R, eject_D, eject_U, map;
uint8_t lowX, highX, lowY, temp4, L_R_switch, enemy_index = 0, collectable_index = 0;
unsigned int old_x, upperLeft, up_l_back;
int score, old_score, total_score;
unsigned int scroll_x = 0, scroll_y = 0;
uint8_t lives, stars, game_level = 1, coins, total_coins, max_coins = 5, max_stars = 3, max_lives = 3;
uint8_t old_lives, old_stars, old_level = 1, old_coins, player_anim = 0;
uint8_t enemy_item_count = 0, collectables_item_count = 0, blink_life = 0,blink_cycle = 0,menu_select = 0;
uint8_t life_timer = LIFE_TIMER_MAX,star_timer = STAR_TIMER_MAX;
uint8_t half_dead_state = FALSE, invincible_state = 0,hit_dead = FALSE;
uint8_t level_offset = 1, game_mode, player_vel_state;
enum GAME_MODES
{
MODE_TITLE,
MODE_START,
MODE_HELP,
MODE_GAME,
MODE_PAUSE,
MODE_END,
MODE_GAME_OVER
};
enum PLAYER_STATES
{
STATE_DEAD,
STATE_ALIVE,
STATE_UNDEF,
STATE_JUMP_AIR,
STATE_JUMP_FALL,
};
enum PLAYER_DIR
{
LEFT = 11,
RIGHT = 0,
UP,
DOWN
};
enum PLAYER_ANIMS
{
PLAYER_ANIM_IDLE = 0,
PLAYER_ANIM_PUSH = 4,
PLAYER_ANIM_JUMP = 7,
PLAYER_ANIM_FALL,
PLAYER_ANIM_VICTORY,
PLAYER_ANIM_DEAD,
};
enum COLLECTABLE_ANIMS
{
COLLECTABLES_ANIM_COIN,
COLLECTABLE_ANIM_STAR,
COLLECTABLE_ANIM_LIFE,
//Coin animations.
COLLECTABLES_ANIM_COIN_M1,
COLLECTABLES_ANIM_COIN_M2,
COLLECTABLES_ANIM_COIN_M3,
COLLECTABLES_ANIM_COIN_M4,
};
enum ENEMY_TYPE
{
ENEMY_FIRE,
ENEMY_FIRE_BALL,
ENEMY_SWARS,
ENEMY_GLOUT,
ENEMY_BEAR,
ENEMY_GORILLA,
ENEMY_BAT,
ENEMY_OCTA,
ENEMY_THORN,
ENEMY_TENTA,
ENEMY_PUP,
ENEMY_MUSH,
};
enum COLLECTABLES_TYPE
{
COLLECTABLE_COIN,
COLLECTABLE_STAR,
COLLECTABLE_LIFE
};
enum SONG_TYPE
{
SONG_TITLE,
SONG_INGAME_A,
SONG_INGAME_B,
SONG_LEVEL_OVER,
SONG_LEVEL_CLEAR,
};
enum SFX_TYPE
{
SFX_DEAD,
SFX_PAUSE,
SFX_START,
SFX_STAR,
SFX_LIFE,
SFX_COIN,
SFX_HIT,
SFX_JUMP,
SFX_JUMP2,
SFX_WRONG,
SFX_HALF_DEAD,
};
#define COL_DOWN 0x80
#define COL_ALL 0x40
#define COL_NONE 0x0
const unsigned char is_solid[] = {
COL_NONE,
COL_ALL, //Floor Brick1
COL_ALL, //Platform Brick1
COL_NONE, //Decorations1
COL_NONE, //Decorations2
COL_NONE, //Decorations - Sky & Cloud
COL_NONE, //Decorations - Sky
COL_ALL, //Exit level brick.
COL_ALL, //Platform Brick2
COL_DOWN, //Platformer top1.
COL_DOWN, //Platformer top1.
COL_NONE, //Platformer bottom.
COL_NONE, //Platformer bottom.
COL_DOWN, //Platformer top2.
COL_DOWN, //Platformer top2.
COL_DOWN, //Platformer top2.
COL_NONE, //Platformer bottom.
COL_NONE, //Platformer bottom.
COL_NONE, //Platformer bottom.
COL_ALL, //Platform Brick3
COL_DOWN, //Round Bricks.
COL_ALL, //Round Bricks2.
COL_DOWN, //Enemy block1 (Lava)
COL_NONE, //Decorations - Sky
COL_DOWN, //Platform Brick Curved
COL_NONE, //Decorations - Background
COL_DOWN, //Square blocks
COL_DOWN, //Enemy block1 (Spider)
COL_NONE, //Directional brick fixed.
COL_NONE, //Platform block - Left.
COL_ALL, //Platform block = Mid.
COL_NONE, //Platform block = Right.
COL_ALL, //Green Platform block - Left.
COL_ALL, //Green Platform block - Mid.
COL_ALL, //Green Platform block - Right.
COL_DOWN, //Sand Platform block - Left.
COL_DOWN, //Sand Platform block - Mid.
COL_DOWN, //Sand Platform block - Right.
COL_ALL, //Green block.
COL_ALL, //Brown brick faced.
COL_ALL, //Ice Platform block - Left.
COL_ALL, //Ice Platform block - Mid.
COL_ALL, //Ice Platform block - Right.
};
//Colliion map for colliion detection.
#pragma bss-name(push, "BSS")
uint8_t c_map[240];
//Structures for Player and Enemy
typedef struct Base
{
unsigned char x;
unsigned char y;
unsigned char width;
unsigned char height;
} GenericBase;
GenericBase genericBase1, genericBase2;
typedef struct Sprite
{
unsigned int x; // low byte is sub-pixel
unsigned int y;
signed int vel_x; // speed, signed, low byte is sub-pixel
signed int vel_y;
uint8_t direction;
uint8_t state;
uint8_t type;
} Player, Enemy, Collectable;
Player playerRobo = {0x2FDF, 0xc200, 10, 8, RIGHT, STATE_ALIVE, -1};
#pragma bss-name(push, "ZEROPAGE")
Enemy enemy_list[MAX_ENEMY] = {NULL};
Collectable collectable_list[MAX_COLLECTABLES] = {NULL};
#endif