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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
#ifndef GAME_STRUCTURES__HEADER__
#define GAME_STRUCTURES__HEADER__
/* *************************************
* Defines
* *************************************/
#define GAME_MAX_AIRCRAFT 32
#define GAME_MAX_CHARACTERS 8
#define GAME_MAX_PARKING 32
#define GAME_MAX_RWY_LENGTH 16
#define GAME_MAX_MAP_SIZE 0x400
#define CHEAT_ARRAY_SIZE 16
#define AIRCRAFT_MAX_TARGETS 48
#define PLAYER_MAX_WAYPOINTS AIRCRAFT_MAX_TARGETS
#define GAME_MAX_SEQUENCE_KEYS 12
/* *************************************
* Structs and enums
* *************************************/
typedef struct t_Camera
{
int32_t X_Offset;
int32_t Y_Offset;
int8_t X_Speed;
int8_t Y_Speed;
uint8_t Speed_Timer;
}TYPE_CAMERA;
typedef enum t_fldir
{
DEPARTURE = 0x01,
ARRIVAL = 0x02
}FL_DIR;
typedef enum t_flstate
{
STATE_IDLE,
STATE_PARKED,
STATE_UNBOARDING,
STATE_TAXIING,
STATE_HOLDING_RWY,
STATE_ENTERING_RWY,
STATE_READY_FOR_TAKEOFF,
STATE_TAKEOFF,
STATE_CLIMBING,
STATE_APPROACH,
STATE_FINAL,
STATE_USER_STOPPED,
STATE_AUTO_STOPPED,
STATE_LANDED,
MAX_STATES
}FL_STATE;
typedef enum t_LevelDifficulty
{
LEVEL_DIFFICULTY_EASY = 0,
LEVEL_DIFFICULTY_MEDIUM,
LEVEL_DIFFICULTY_HARD
}LEVEL_DIFFICULTY;
typedef struct t_isopos
{
short x;
short y;
short z;
}TYPE_ISOMETRIC_POS;
typedef struct t_isofix16pos
{
fix16_t x;
fix16_t y;
fix16_t z;
}TYPE_ISOMETRIC_FIX16_POS;
typedef struct t_cartpos
{
short x;
short y;
}TYPE_CARTESIAN_POS;
typedef struct t_tileData
{
bool ShowTile;
TYPE_CARTESIAN_POS CartPos;
unsigned char r;
unsigned char g;
unsigned char b;
}TYPE_TILE_DATA;
typedef struct t_flightData
{
FL_DIR FlightDirection[GAME_MAX_AIRCRAFT];
char strFlightNumber[GAME_MAX_AIRCRAFT][GAME_MAX_CHARACTERS];
uint8_t Passengers[GAME_MAX_AIRCRAFT];
uint8_t Hours[GAME_MAX_AIRCRAFT];
uint8_t Minutes[GAME_MAX_AIRCRAFT];
uint8_t Parking[GAME_MAX_AIRCRAFT];
uint16_t RemainingTime[GAME_MAX_AIRCRAFT];
uint8_t nAircraft;
uint8_t nRemainingAircraft;
uint8_t ActiveAircraft;
FL_STATE State[GAME_MAX_AIRCRAFT];
bool Finished[GAME_MAX_AIRCRAFT];
}TYPE_FLIGHT_DATA;
typedef enum t_livery
{
AIRCRAFT_LIVERY_UNKNOWN = 0,
AIRCRAFT_LIVERY_0
}AIRCRAFT_LIVERY;
typedef enum t_direction
{
NO_DIRECTION,
DIR_NORTH,
DIR_SOUTH,
DIR_EAST,
DIR_WEST
}DIRECTION;
typedef enum t_aircraftAttitude
{
AIRCRAFT_STATE_NEUTRAL = 0,
AIRCRAFT_STATE_UP_5_DEGREES,
AIRCRAFT_STATE_UP_15_DEGREES,
AIRCRAFT_STATE_DOWN_5_DEGREES,
}AIRCRAFT_ATTITUDE;
typedef struct t_aircraftData
{
AIRCRAFT_LIVERY Livery;
DIRECTION Direction;
AIRCRAFT_ATTITUDE Attitude;
FL_STATE State;
// Target tile (used to calculate direction and movement)
uint16_t Target[AIRCRAFT_MAX_TARGETS];
uint8_t TargetIdx;
// Used to relate TYPE_AIRCRAFT_DATA and TYPE_FLIGHT_DATA
uint8_t FlightDataIdx;
// Position data (real pos inside map)
TYPE_ISOMETRIC_FIX16_POS IsoPos;
fix16_t Speed;
short TargetSpeed;
bool TargetReached;
// Used for target reached detection
fix16_t XPos_Old;
// Used for target reached detection
fix16_t YPos_Old;
}TYPE_AIRCRAFT_DATA;
typedef struct
{
// ## State flags ##
// Player is on the game
bool Active;
// Player requests showing aircraft data menu
bool ShowAircraftData;
// Player on runway selection mode (when FL_STATE == APPROACH)
bool SelectRunway;
// Player on taxiway + runway selection mode (when FL_STATE == PARKED)
bool SelectTaxiwayRunway;
// Player on taxiway + parking selection mode (when FL_STATE == LANDED)
bool SelectTaxiwayParking;
// Tiles selected by player are not valid for establishing a new path
bool InvalidPath;
// Player has locked the camera at a determined aircraft
bool LockTarget;
// Player is unboarding passengers
bool Unboarding;
// Stores indexes for player-specific active aircraft
// Used to relate SelectedAircraft against FlightData index
uint8_t ActiveAircraftList[GAME_MAX_AIRCRAFT];
// Flight direction to be managed by player (see 2-player mode)
FL_DIR FlightDirection;
// Number of active aircraft for current player (could be not equal to total active aircraft!)
uint8_t ActiveAircraft;
// When too many aircraft are active, they are separated into different pages
uint8_t FlightDataPage;
// Selected aircraft on aircraft data list
uint8_t SelectedAircraft;
// Aircraft being followed by camera
uint8_t LockedAircraft;
// Index for GameRwy buffer on "Select runway" mode
uint16_t SelectedRunway;
// Tile pointed to by cursor
uint16_t SelectedTile;
// Conversion between selected aircraft from data list and actual flight data index
uint8_t FlightDataSelectedAircraft;
// Waypoints added to list when player is tracing a path for an aircraft.
// For example: when determining path from runway to parking.
uint16_t Waypoints[PLAYER_MAX_WAYPOINTS];
// Internal index for waypoint management.
uint8_t WaypointIdx;
// Another internal index to keep last desired selected point by user when defining a path.
uint8_t LastWaypointIdx;
// If player is unboarding passengers, then a sequence of keys is generated to make unboarding
// process a bit more difficult and challenging.
unsigned short UnboardingSequence[GAME_MAX_SEQUENCE_KEYS];
// Index inside UnboardingSequence[]
uint8_t UnboardingSequenceIdx;
// Show passengers left
uint8_t PassengersLeftSelectedAircraft;
// Lookup tables defined on GameRenderTerrainPrecalculations() to be later used on
// GameRenderTerrain().
TYPE_TILE_DATA TileData[GAME_MAX_MAP_SIZE];
// Player camera instance.
TYPE_CAMERA Camera;
// Array of tiles which will change their RGB values when displayed under certain player states.
uint16_t RwyArray[GAME_MAX_RWY_LENGTH];
// Remaining time for next aircraft (if any).
uint16_t NextAircraftTime;
// Number of remaining aircraft in STATE_IDLE.
uint16_t RemainingAircraft;
// Pad callbacks.
bool (*const PadKeyPressed_Callback)(unsigned short);
bool (*const PadKeyReleased_Callback)(unsigned short);
bool (*const PadKeySinglePress_Callback)(unsigned short);
bool (*const PadDirectionKeyPressed_Callback)(void);
unsigned short (*const PadLastKeySinglePressed_Callback)(void);
}TYPE_PLAYER;
typedef enum t_fontflags
{
FONT_NOFLAGS = 1 << 0,
FONT_CENTERED = 1 << 1,
FONT_WRAP_LINE = 1 << 2,
FONT_BLEND_EFFECT = 1 << 3,
FONT_1HZ_FLASH = 1 << 4,
FONT_2HZ_FLASH = 1 << 5
}FONT_FLAGS;
typedef struct t_Font
{
GsSprite spr;
short char_spacing;
short char_w;
short char_h;
char init_ch;
uint8_t char_per_row;
uint8_t max_ch_wrap;
volatile FONT_FLAGS flags;
short spr_w;
short spr_h;
short spr_u;
short spr_v;
}TYPE_FONT;
typedef struct t_Timer
{
uint32_t time;
uint32_t orig_time;
bool repeat_flag;
bool busy;
void (*Timeout_Callback)(void);
}TYPE_TIMER;
typedef struct t_Cheat
{
unsigned short Combination[CHEAT_ARRAY_SIZE];
void (*Callback)(void);
}TYPE_CHEAT;
// TYPE_PLT_CONFIG is used for PLT file generation.
typedef struct t_PltConfig
{
uint8_t MaxTime; // Minutes
uint8_t nRunway;
uint8_t ParkingArray[GAME_MAX_PARKING];
LEVEL_DIFFICULTY Level;
bool TwoPlayers;
uint8_t maxLostFlights;
}TYPE_PLT_CONFIG;
#endif // GAME_STRUCTURES__HEADER__
|