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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Originally written by Syn9 in FreeBASIC with SDL
* http://syn9.thehideoutgames.com/index_backup.php
*
* Ported to plain C for GCW-Zero handheld by Dmitry Smagin
* http://github.com/dmitrysmagin/griffon_legend
*
*
* Programming/Graphics: Daniel "Syn9" Kennedy
* Music/Sound effects: David Turner
*
* Beta testing and gameplay design help:
* Deleter, Cha0s, Aether Fox, and Kiz
*
*/
#ifndef GRIFFON_GRIFFON_H
#define GRIFFON_GRIFFON_H
#include "common/scummsys.h"
#include "common/events.h"
#include "common/random.h"
#include "engines/engine.h"
#include "audio/mixer.h"
#include "graphics/transparent_surface.h"
namespace Griffon {
class Console;
#define kSoundHandles 16
#define kMaxNPC 32
#define kMaxFloat 32
#define kMaxSpell 32
// spells
enum {
kSpellIce = 0,
kSpellSteel,
kSpellWood,
kSpellRock,
kSpellFire
};
// inventory items
enum {
kInvFlask = 0,
kInvDoubleFlask,
kInvShock,
kInvNormalKey,
kInvMasterKey
};
enum {
kSndBite = 0,
kSndCrystal,
kSndDoor,
kSndEnemyHit,
kSndIce,
kSndLever,
kSndLightning,
kSndMetalHit,
kSndPowerUp,
kSndRocks,
kSndSwordHit,
kSndThrow,
kSndChest,
kSndFire,
kSndBeep
};
// in game scripts
enum {
kScriptFlask = 0, // get flask
kScriptMasterKey = 2, // find master key
kScriptFindCrystal = 3, // find crystal
kScriptFindShield = 4, // find shield - obj 8
kScriptFindSword = 5, // find sword - obj 9
kScriptKeyChest = 6, // regular key chest
kScriptBlueFlask = 7, // blue flask
kScriptGardenMasterKey = 8, // garden's master key
kScriptLightningBomb = 9, // lightning bomb
kScriptBlueFlaskChest = 10, // blue flask chest
kScriptLightningChest = 11, // lightning chest
kScriptArmourChest = 12, // armour chest
kScriptCitadelMasterKey = 13, // citadel master key
kScriptEndOfGame = 14, // end of game
kScriptGetSword3 = 15, // get sword3
kScriptShield3 = 16, // shield3
kScriptArmour3 = 17, // armour3
kScriptKeyChest1 = 20, // key chest 1
kScriptLever = 60 // lever
};
// monsters
enum {
kMonsterBabyDragon = 1, // baby dragon
kMonsterOneWing = 2, // one wing
kMonsterBoss1 = 3, // boss 1
kMonsterBlackKnight = 4, // black knight
kMonsterFireHydra = 5, // fire hydra
kMonsterRedDragon = 6, // red dragon
kMonsterPriest = 7, // priest
kMonsterYellowDragon = 8, // yellow fire dragon
kMonsterTwoWing = 9, // two wing
kMonsterDragon2 = 10, // dragon2
kMonsterFinalBoss = 11, // final boss
kMonsterBatKitty = 12 // bat kitty
};
#define kEpsilon 0.001
struct Player {
float px;
float py;
float opx;
float opy;
int walkDir;
float walkFrame;
float walkSpeed;
float attackFrame;
float attackSpeed;
int hp;
int maxHp;
float hpflash;
int hpflashb;
int level;
int maxLevel;
int sword;
int shield;
int armour;
int foundSpell[5];
float spellCharge[5];
int inventory[5];
float attackStrength;
float spellStrength;
int spellDamage;
int swordDamage;
int exp;
int nextLevel;
int pause;
float itemselshade;
int ysort;
void reset();
};
struct BodySection {
float x;
float y;
int parentID;
int isbase;
int sprite;
int bonelength; // the 'bone' that connects the body sections
};
struct NPC {
float x;
float y;
int spriteset;
int x1; // patrol area
int y1;
int x2;
int y2;
int attitude;
int hp;
int maxhp;
int item1;
int item2;
int item3;
int script;
float frame;
float frame2; // end boss specific
int cframe;
bool onMap; // is this npc set to be genned in the mapfile
int ticks;
int pause;
int shake;
int movementmode;
int walkdir;
float walkspd;
int movingdir;
bool moving;
bool attacking;
float attackframe;
int cattackframe;
float attackspd;
int attackdelay;
int attacknext;
int attackattempt;
int spellDamage;
int attackDamage;
// one wing and firehydra specific
BodySection bodysection[31];
float swayAngle;
float swaySpeed;
float headTargetX[4];
float headTargetY[4];
int castPause;
// firehydra specific
int attacknext2[4];
bool attacking2[4];
int attackframe2[4];
// dragon2 specific
float floating;
};
struct Spell {
int spellnum;
float homex;
float homey;
float enemyx;
float enemyy;
float frame;
int damagewho; // 0 = npc, 1 = player
// for earthslide
float rocky[9]; // CHECKME: Looks unused
int rockimg[9];
int rockdeflect[9];
float strength;
// fire
int legalive[5];
// spell 6 specific
float fireballs[7][4]; // x,y,targetx, targety
int nfballs;
int ballon[7];
int npc;
};
struct AnimSet {
int x; // xyloc on spriteimageset
int y;
int xofs; // the actual place to paste the sprite in reference to the bodypart loc on screen
int yofs;
int w; // w/h of the sprite in the imageset
int h;
};
struct DataChunk {
byte *data;
int size;
};
struct FloatTextStruct {
float framesLeft;
float x;
float y;
int col;
char *text;
};
struct FloatIconStruct {
float framesLeft;
float x;
float y;
int ico;
};
struct AttackOffsetStruct {
float x;
float y;
bool completed;
};
struct Config {
bool music;
int musicVol;
bool effects;
int effectsVol;
};
struct ObjectInfoStruct {
int nFrames;
int xTiles;
int yTiles;
int speed;
int type;
int script;
};
enum {
kGameModeIntro,
kGameModePlay,
kGameModeNewGame,
kGameModeLoadGame
};
class GriffonEngine : public Engine {
public:
GriffonEngine(OSystem *syst);
~GriffonEngine();
virtual Common::Error run();
virtual void syncSoundSettings();
private:
Common::RandomSource *_rnd;
bool _shouldQuit;
int _gameMode;
Console *_console;
private:
// combat.cpp
void attack();
void castSpell(int spellnum, float homex, float homey, float enemyx, float enemyy, int damagewho);
void checkHit();
void damageNPC(int npcnum, int damage, int spell);
void damagePlayer(int damage);
// cutscenes.cpp
void showLogos();
void intro();
void endOfGame();
void theEnd();
// dialogs.cpp
void title(int mode);
void configMenu();
void saveLoadNew();
void renderSaveStates();
// draw.cpp
void drawAnims(int Layer);
void drawHud();
void drawNPCs(int mode);
void drawOver(int modx, int mody);
void drawPlayer();
void drawView();
void swash();
// engine.cpp
float RND();
void mainLoop();
void updateEngine();
void newGame();
// gfx.cpp
void addFloatIcon(int ico, float xloc, float yloc);
void addFloatText(const char *stri, float xloc, float yloc, int col);
void eventText(const char *stri);
void drawLine(Graphics::TransparentSurface *buffer, int x1, int y1, int x2, int y2, int col);
void drawString(Graphics::TransparentSurface *buffer, const char *stri, int xloc, int yloc, int col);
void drawProgress(int w, int wm);
// input.cpp
void checkInputs();
void handleWalking();
void checkTrigger();
void processTrigger(int trignum);
// logic.cpp
void updateAnims();
void updateY();
void updateNPCs();
void updateSpells();
void updateSpellsUnder();
// resources.cpp
void initialize();
Graphics::TransparentSurface *loadImage(const char *name, bool colorkey = false);
void loadMap(int mapnum);
void loadAnims();
void loadFont();
void loadItemImgs();
void loadTiles();
void loadTriggers();
void loadObjectDB();
// saveload.cpp
Common::String makeSaveGameName(int slot);
int loadState(int slotnum);
int loadPlayer(int slotnum);
int saveState(int slotnum);
// sound.cpp
void setChannelVolume(int channel, int volume);
int getSoundHandle();
int playSound(DataChunk *chunk, bool looped = false);
void pauseSoundChannel(int channel);
void haltSoundChannel(int channel);
void resumeSoundChannel(int channel);
bool isSoundChannelPlaying(int channel);
void setupAudio();
void updateMusic();
private:
Graphics::TransparentSurface *_video, *_videoBuffer, *_videoBuffer2, *_videoBuffer3;
// system
Graphics::TransparentSurface *_titleImg, *_titleImg2, *_inventoryImg;
Graphics::TransparentSurface *_logosImg, *_theEndImg;
Common::Event _event;
Graphics::TransparentSurface *_mapBg, *_clipBg, *_clipBg2;
unsigned int _clipSurround[4][4];
float _animSpeed; // CHECKME: it seems to always be 0.5
int _rampData[40][24];
int _curMap;
Graphics::TransparentSurface *_fontChr[224][5]; // 256 - 32
Graphics::TransparentSurface *_itemImg[21], *_windowImg;
Graphics::TransparentSurface *_spellImg;
bool _itemSelOn;
int _curItem, _itemTicks;
float _itemyloc;
bool _selEnemyOn;
int _curEnemy;
bool _forcePause;
bool _roomLock; // set to disable any room jumps while in the room
int _scriptFlag[100][10], _saveSlot; // script, flag
// timer related - move to local later
int _ticks, _ticksPassed, _nextTicks;
float _fp, _fps, _fpsr; // CHECKME: _fp and _fps seems to be integers
int _secsInGame, _secStart;
Graphics::TransparentSurface *mapImg[4];
Common::Rect rcSrc, rcDest;
// -----------special case
bool _dontDrawOver; // used in map24 so that the candles don't draw over the boss, default set to 0
// saveload info
Graphics::TransparentSurface *_saveLoadImg;
// post info
float _postInfo[21][3];
int _postInfoNbr;
// cloud info
Graphics::TransparentSurface *_cloudImg;
float _cloudAngle;
int _cloudsOn;
// spell info
Spell _spellInfo[kMaxSpell];
// player info
Player _player;
Player _playera;
bool _movingUp, _movingDown, _movingLeft, _movingRight;
bool _attacking;
int _asecstart;
// tile info
Graphics::TransparentSurface *_tiles[4];
int _tileinfo[3][40][24][3]; // maplayer, x, y, tiledata (tile, tilelayer)
// animation info
Graphics::TransparentSurface *_anims[100];
// id number 0&1 = players
Graphics::TransparentSurface *_animsAttack[100];
// attack anims
AttackOffsetStruct _playerAttackOfs[4][16];
FloatTextStruct _floatText[kMaxFloat];
FloatIconStruct _floatIcon[kMaxFloat];
// special for animset2
AnimSet _animSet2[7], _animSet9[7];
// object info
float _objectFrame[256][2];
int _lastObj;
// frame!, curframe
ObjectInfoStruct _objectInfo[33];
int _objectTile[33][9][3][3][2];
// [objnum] [frame] [x] [y] [tile/layer]
int _objectMap[21][15];
int _objectMapFull[1000][21][15];
// [mapnum] x, y set to 1 to make this objmap spot stay at -1
// trigger info
int _triggers[10000][9];
// [map#][index], [var]
// map#,x,y
int _triggerLoc[320][240], _triggerNbr;
// npc info
NPC _npcInfo[kMaxNPC];
int _lastNpc;
// music info
DataChunk *_musicGardens1, *_musicGardens2, *_musicGardens3, *_musicGardens4, *_musicBoss, *_musicMenu, *_musicEndOfGame;
int _musicChannel, _menuChannel;
bool _playingBoss, _playingGardens;
DataChunk *_sfx[15];
Audio::SoundHandle _handles[kSoundHandles];
Audio::Mixer *_mixer;
// set to 1 for normal key, set to 2 for master, set to 0 if unlocked
int _roomLocks[201], _lockType;
int _roomToUnlock;
bool _canUseKey;
bool _saidLocked;
bool _saidJammed;
// ysort
int _ysort[2401], _lasty, _firsty;
bool _pmenu;
Config config;
void saveConfig();
};
}
#endif // GRIFFON_GRIFFON_H
|