-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonki.h
230 lines (201 loc) · 5.04 KB
/
monki.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
224
225
226
227
228
229
230
#pragma bss-name(push, "ZEROPAGE")
#include "HERO/monki_climb.c"
#include "HERO/monki_jump.c"
#include "HERO/monki_reach.c"
#include "playfield.c"
#include "title.c"
// LIVES / SCORE / TIMER:
#define START_TIMER 0x58
#define START_LIVES 0x32
#define START_SCORE 0x30
#define ZERO_LIVES 0x30
#define ITEM_1UP 0x90
#define ITEM_DEATH 0x91
#define ITEM_TIMEEXT 0xA1
// COORDINATES:
#define LEFT_POLE 0x50
#define RIGHT_POLE 0xA8
#define MID_POINT 0x7C
#define MONKI_TOP 0x20
#define MONKI_BOTTOM 0xD0
// CONSTANTS:
#define GAME_SPEED 3
#define ANIMATION_SPEED 12
#define MAX_MONKIFRAME 6
// TEXTS:
unsigned char GAMEOVER_TEXT[] = "GAME OVER";
unsigned char GAMENAME_TEXT[] = "MONKI KONG";
unsigned char GAMEPAUSED_TEXT[] = "PAUSED";
unsigned char PRESSSTART_TEXT[] = "press start";
unsigned char TIMER_TEXT[] = "TIMER:";
unsigned char LIVES_TEXT[] = "MONKI:";
unsigned char SCORE_TEXT[] = "SCORE:";
// color palettes
unsigned char palette_sp[]={
0x0F, 0x02, 0x21, 0x27,
0x0F, 0x06, 0x36, 0x16,
0x0F, 0x19, 0x29, 0x16,
0x0F, 0x0F, 0x06, 0x30
};
unsigned char palette_bg[]={
0x0F, 0x20, 0x10, 0x30
};
const unsigned char *monki_anim_left[] = { monki_f1, monki_f2, monki_f3, monki_f4, monki_f3, monki_f2 };
const unsigned char *monki_anim_right[] = { monki_f5, monki_f6, monki_f7, monki_f8, monki_f7, monki_f6 };
const unsigned char *monki_anim_jump_l[] = { monki_f9, monki_f10, monki_f11, monki_f12, monki_f11, monki_f10 };
const unsigned char *monki_anim_jump_r[] = { monki_f9, monki_f10, monki_f11, monki_f12, monki_f11, monki_f10 };
const unsigned char *monki_anim_reach_l[] = { monki_f13 };
const unsigned char *monki_anim_reach_r[] = { monki_f14 };
const unsigned char **monki_states[] = {
monki_anim_left,
monki_anim_right,
monki_anim_jump_l,
monki_anim_jump_r,
monki_anim_reach_l,
monki_anim_reach_r
};
const unsigned char *titles[] = {
title_row_1,
title_row_2,
title_row_3,
title_row_4,
title_row_5,
title_row_6
};
const unsigned char *poles[] = {
left_pole, right_pole
};
// first arg is object type, second arg is color:
const int number_of_object_types = 12;
unsigned char object_types[12][2]={
{ 0x91, 0x01 }, // Adam
{ 0x90, 0x01 }, // 1up
{ 0xA0, 0x01 }, // casette
{ 0xB0, 0x01 }, // elleboog
{ 0xB1, 0x01 }, // fiets
{ 0xB4, 0x00 }, // lamp
{ 0xC3, 0x00 }, // LP
{ 0xC4, 0x02 }, // rups
{ 0xC5, 0x01 }, // TENT
{ 0xC6, 0x00 }, // LAMP2
{ 0xA1, 0x02 }, // diabolo
{ 0xD3, 0x00 }, // walkman
};
// MOVEMENT:
enum {
TOP,
RIGHT,
LEFT,
DOWN,
UP
};
// SOUND:
enum {
SFX_JUMP, // 0
SFX_DING, // 1
SFX_IMPACT, // 2
SFX_1UP, // 3
SFX_DEATH, // 4
SFX_GAMEOVER // 5
};
// SCENES:
enum {
TITLE,
STARTGAME,
PLAYING,
GAMEOVER,
PAUSE
};
// ANIMATIONS:
enum {
CLIMBING_LEFT,
CLIMBING_RIGHT,
JUMPING_RIGHT,
JUMPING_LEFT,
REACHING_LEFT,
REACHING_RIGHT
};
unsigned char player_one;
unsigned char temp1;
unsigned char temp2;
unsigned char *temp3;
unsigned char lives=START_LIVES;
unsigned char score=START_SCORE;
unsigned char timer=START_TIMER;
unsigned char gap_color=0x01;
int monki_x=LEFT_POLE;
int monki_y=MONKI_TOP;
int left_gap_y;
int right_gap_y;
unsigned int x;
unsigned int y;
unsigned int i;
unsigned int j;
unsigned int nr;
unsigned int hs_letter;
unsigned int hs_pos;
unsigned int game_mode=TITLE;
unsigned int monki_state=CLIMBING_LEFT;
unsigned int on_left_pole=TRUE;
unsigned int is_gameover=FALSE;
unsigned int is_jumping=FALSE;
unsigned int is_paused=FALSE;
unsigned int is_reaching=FALSE;
unsigned int title_screen_active=FALSE;
unsigned int key_down=FALSE;
unsigned int key_down_frame=0;
unsigned int active_object=0;
unsigned int leaderboard_pos=6;
int game_frame=0;
int animation_frame=0;
int monki_frame=0;
int monki_moving=FALSE;
#pragma bss-name(push, "BSS")
// OBJECTS
struct Object {
unsigned int x;
unsigned int y;
unsigned int type;
unsigned int grabbed;
};
struct Object objects[64];
typedef struct Highscorer {
unsigned int score;
unsigned char initials[4];
} Highscorer;
struct Highscorer highscorers[5];
unsigned char initials[4]="AAA\0";
unsigned int highscores[5];
// PROTOTYPES
void drawEnterInitials( void );
void drawGaps( void );
void drawLeaderboard( void );
void drawMonki( void );
void drawNumbers( char x, char y, char nr );
void drawNumbersToBg();
void drawObjects( void );
void drawPlayfield( void );
void drawScoreboard( void );
void drawStaticPoles();
void monkiDies( void );
void monkiGrabs( void );
void monkiJumps( int direction );
void monkiMoves( int direction, int amount );
void titleScreen( void );
void startGame( void );
void runGame( void );
void pauseGame( void );
void gameover( void );
void initGame( void );
void setupObjects( void );
void updateMonkiState( void );
void updateMovement( void );
void updateScroll( void );
void updateTimer( void );
void upkeep( void );
void frame( int direction );
void hasHighscore( void );
void clear_bg( void );
int monkiCanMove( int direction );
int randRange( int low, int high );
int compareScore(const void *a, const void *b);