1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  *
22  *              Originally written by Syn9 in FreeBASIC with SDL
23  *              http://syn9.thehideoutgames.com/index_backup.php
24  *
25  *            Ported to plain C for GCW-Zero handheld by Dmitry Smagin
26  *                http://github.com/dmitrysmagin/griffon_legend
27  *
28  *
29  *                 Programming/Graphics: Daniel "Syn9" Kennedy
30  *                     Music/Sound effects: David Turner
31  *
32  *                   Beta testing and gameplay design help:
33  *                    Deleter, Cha0s, Aether Fox, and Kiz
34  *
35  */
36 
37 #include "common/system.h"
38 
39 #include "griffon/griffon.h"
40 
41 namespace Griffon {
42 
43 // map in inventory menu
44 const int invmap[4][7][13] = {
45 	// map 0
46 	{
47 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
48 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
49 		{0, 0, 0, 0, 0, 43, 44, 45, 46, 0, 0, 0, 0},
50 		{0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0},
51 		{0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0},
52 		{0, 0, 0, 0, 4, 5, 0, 0, 0, 0, 0, 0, 0},
53 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
54 	},
55 	// map 1
56 	{
57 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
58 		{0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0},
59 		{0, 0, 19, 20, 21, 22, 0, 0, 0, 27, 0, 0, 0},
60 		{0, 0, 16, 17, 18, 0, 0, 0, 29, 30, 31, 0, 0},
61 		{0, 0, 12, 0, 13, 14, 0, 32, 33, 34, 35, 36, 0},
62 		{0, 8, 7, 6, 9, 10, 0, 37, 38, 39, 40, 41, 0},
63 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
64 	},
65 	// map 2
66 	{
67 		{0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0},
68 		{0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0},
69 		{0, 0, 0, 0, 0, 63, 64, 65, 0, 0, 0, 0, 0},
70 		{0, 0, 0, 0, 58, 59, 60, 61, 62, 0, 0, 0, 0},
71 		{0, 0, 0, 0, 0, 55, 56, 57, 0, 0, 0, 0, 0},
72 		{0, 0, 0, 0, 50, 51, 52, 53, 54, 0, 0, 0, 0},
73 		{0, 0, 0, 0, 0, 48, 47, 49, 0, 0, 0, 0, 0}
74 	},
75 
76 	// map 3
77 	{
78 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
79 		{0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0},
80 		{0, 0, 0, 79, 80, 81, 0, 74, 72, 0, 0, 0, 0},
81 		{0, 0, 0, 78, 0, 0, 0, 73, 70, 69, 68, 0, 0},
82 		{0, 0, 77, 76, 75, 0, 0, 0, 71, 0, 0, 0, 0},
83 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
84 		{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
85 	}
86 };
87 
88 
game_fillrect(Graphics::TransparentSurface * surface,int x,int y,int w,int h,int color)89 void game_fillrect(Graphics::TransparentSurface *surface, int x, int y, int w, int h, int color) {
90 	surface->fillRect(Common::Rect(x, y, x + w, y + h), color);
91 }
92 
drawAnims(int Layer)93 void GriffonEngine::drawAnims(int Layer) {
94 	for (int sx = 0; sx <= 19; sx++) {
95 		for (int sy = 0; sy <= 14; sy++) {
96 			int o = _objectMap[sx][sy];
97 
98 			if (o > -1) {
99 				int xtiles = _objectInfo[o].xTiles;
100 				int ytiles = _objectInfo[o].yTiles;
101 				int cframe = _objectFrame[o][1];
102 
103 				for (int x = 0; x <= xtiles - 1; x++) {
104 					for (int y = 0; y <= ytiles - 1; y++) {
105 						int x1 = (sx + x) * 16;
106 						int y1 = (sy + y) * 16;
107 
108 						if (_objectTile[o][cframe][x][y][1] == Layer) {
109 							int c = _objectTile[o][cframe][x][y][0] - 1;
110 							int curtilel = 3;
111 							int curtilex = c % 20;
112 							int curtiley = (c - curtilex) / 20;
113 
114 							if (_curMap == 58 && _scriptFlag[kScriptLever][0] > 0)
115 								curtilex = 1;
116 							if (_curMap == 54 && _scriptFlag[kScriptLever][0] > 1)
117 								curtilex = 1;
118 							rcSrc.left = curtilex * 16;
119 							rcSrc.top = curtiley * 16;
120 							rcSrc.setWidth(16);
121 							rcSrc.setHeight(16);
122 
123 							rcDest.left = x1;
124 							rcDest.top = y1;
125 							rcDest.setWidth(16);
126 							rcDest.setHeight(16);
127 
128 							_tiles[curtilel]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
129 						}
130 
131 						if (Layer == 1) {
132 							for (int l = 1; l <= 2; l++) {
133 								int c = _tileinfo[l][sx + x][sy + y][0];
134 								if (c > 0) {
135 									int cl = _tileinfo[l][sx + x][sy + y][1];
136 
137 									c = c - 1;
138 									int curtile = c;
139 									int curtilel = cl;
140 									int curtilex = c % 20;
141 									int curtiley = (c - curtilex) / 20;
142 
143 									rcSrc.left = curtilex * 16;
144 									rcSrc.top = curtiley * 16;
145 									rcSrc.setWidth(16);
146 									rcSrc.setHeight(16);
147 
148 									rcDest.left = (sx + x) * 16;
149 									rcDest.top = (sy + y) * 16;
150 									rcDest.setWidth(16);
151 									rcDest.setHeight(16);
152 
153 									bool pass = true;
154 									if (curtilel == 1) {
155 										for (int ff = 0; ff <= 5; ff++) {
156 											int ffa = 20 * 5 - 1 + ff * 20;
157 											int ffb = 20 * 5 + 4 + ff * 20;
158 											if (curtile > ffa && curtile < ffb)
159 												pass = false;
160 										}
161 									}
162 
163 									if (pass)
164 										_tiles[curtilel]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
165 								}
166 							}
167 						}
168 					}
169 				}
170 			}
171 		}
172 	}
173 }
174 
hud_recalc(int a,int b,int c)175 int hud_recalc(int a, int b, int c) {
176 	int result = a * b / c;
177 	return MIN(result, b);
178 }
179 
180 #define RGB(R, G, B) (_videoBuffer->format.RGBToColor((R), (G), (B)))
181 
drawHud()182 void GriffonEngine::drawHud() {
183 	//sprintf(line, "_fps: %i, map: %i, exp: %i/%i", (int)_fps, _curmap, _player.exp, _player.nextlevel);
184 	//drawString(_videobuffer, line, 0, 0, 0);
185 
186 	_itemyloc = 0;
187 
188 	game_fillrect(_videoBuffer2, 0, 0, 320, 240, 0);
189 
190 	for (int i = 0; i < kMaxFloat; i++) {
191 		if (_floatText[i].framesLeft > 0) {
192 			int fc = _floatText[i].col;
193 			int c = fc, c2 = 3;
194 
195 			if (fc == 4)
196 				c = 1;
197 			else if (fc == 5)
198 				c = 0;
199 			else if (fc == 1 || fc == 3)
200 				c2 = 2;
201 
202 			if (fc != 0) {
203 				drawString(_videoBuffer, _floatText[i].text, (int)(_floatText[i].x) + 0, (int)(_floatText[i].y) - 1, c2);
204 				drawString(_videoBuffer, _floatText[i].text, (int)(_floatText[i].x) + 0, (int)(_floatText[i].y) + 1, c2);
205 				drawString(_videoBuffer, _floatText[i].text, (int)(_floatText[i].x) - 1, (int)(_floatText[i].y) + 0, c2);
206 				drawString(_videoBuffer, _floatText[i].text, (int)(_floatText[i].x) + 1, (int)(_floatText[i].y) + 0, c2);
207 			}
208 
209 			drawString(_videoBuffer, _floatText[i].text, (int)(_floatText[i].x), (int)(_floatText[i].y), c);
210 		}
211 
212 		if (_floatIcon[i].framesLeft > 0) {
213 			int ico = _floatIcon[i].ico;
214 			int ix = _floatIcon[i].x;
215 			int iy = _floatIcon[i].y;
216 
217 			rcDest.left = ix;
218 			rcDest.top = iy;
219 
220 			if (ico != 99)
221 				_itemImg[ico]->blit(*_videoBuffer, rcDest.left, rcDest.top);
222 			if (ico == 99) {
223 				int alpha = (int)(RND() * 96) + 96;
224 
225 				rcSrc.left = 16 * (int)(RND() * 2);
226 				rcSrc.top = 80;
227 				rcSrc.setWidth(16);
228 				rcSrc.setHeight(16);
229 
230 				rcDest.left = ix;
231 				rcDest.top = iy;
232 
233 				_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc, TS_ARGB(alpha, 255, 255, 255));
234 			}
235 		}
236 	}
237 
238 	if (!_itemSelOn) {
239 		int sy = 211;
240 		int nx = 19 * 8 + 13;
241 
242 		rcSrc.left = nx - 17 + 48;
243 		rcSrc.top = sy;
244 
245 		// spells in game
246 		if (_player.foundSpell[0]) {
247 			for (int i = 0; i < 5; i++) {
248 				rcSrc.left = rcSrc.left + 17;
249 
250 				if (_player.foundSpell[i]) {
251 					_itemImg[7 + i]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
252 
253 					game_fillrect(_videoBuffer, rcSrc.left, sy + 16, 16, 4, RGB(0, 32, 32));
254 					game_fillrect(_videoBuffer, rcSrc.left + 1, sy + 17,
255 					              hud_recalc(_player.spellCharge[i], 14, 100), 2,
256 					              ABS(_player.spellCharge[i] - 100) < kEpsilon ? RGB(255, 128, 32) : RGB(0, 224, 64));
257 				}
258 			}
259 		}
260 		return;
261 	}
262 
263 	if (_selEnemyOn == false) {
264 		rcDest = Common::Rect(320, 240);
265 		_videoBuffer2->fillRect(rcDest, 0);
266 		_videoBuffer2->setAlpha((int)(_player.itemselshade * 4));
267 		_videoBuffer2->blit(*_videoBuffer);
268 
269 		int sy = 202;
270 		rcSrc.left = 46;
271 		rcSrc.top = 46;
272 
273 		_inventoryImg->setAlpha(160, true); // 128
274 		_inventoryImg->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
275 		_inventoryImg->setAlpha(255, true);
276 
277 		int sx = 54;
278 		sy = 55;
279 
280 		// draw map 9,77
281 		rcDest.left = 46 + 9;
282 		rcDest.top = 46 + 77;
283 
284 		int amap = 0;
285 		if (_curMap > 46)
286 			amap = 2;
287 		if (_curMap > 67)
288 			amap = 3;
289 		if (_curMap > 5 && _curMap < 42)
290 			amap = 1;
291 		mapImg[amap]->blit(*_videoBuffer, rcDest.left, rcDest.top);
292 
293 		long ccc = _videoBuffer->format.RGBToColor(128 + 127 * sin(3.141592 * 2 * _itemyloc / 16), 0, 0);
294 
295 		for (int b = 0; b <= 6; b++) {
296 			for (int a = 0; a <= 12; a++) {
297 				if (invmap[amap][b][a] == _curMap) {
298 					game_fillrect(_videoBuffer, 46 + 9 + a * 9 + 2, 46 + 77 + b * 9 + 1, 6, 6, ccc);
299 				}
300 			}
301 		}
302 
303 		if (amap == 1) {
304 			drawString(_videoBuffer, "L1", 46 + 9, 46 + 77, 0);
305 			drawString(_videoBuffer, "L2", 46 + 9 + 7 * 9, 46 + 77, 0);
306 		}
307 
308 		char line[128];
309 		sprintf(line, "Health: %i/%i", _player.hp, _player.maxHp);
310 		drawString(_videoBuffer, line, sx, sy, _player.hp <= _player.maxHp * 0.25 ? (int)_player.hpflash : 0);
311 
312 		sprintf(line, "Level : %i", _player.level);
313 		if (_player.level == _player.maxLevel)
314 			strcpy(line, "Level : MAX");
315 		drawString(_videoBuffer, line, sx, sy + 8, 0);
316 
317 		// experience
318 		game_fillrect(_videoBuffer, sx + 64, sy + 16, 16, 4, RGB(0, 32, 32));
319 		game_fillrect(_videoBuffer, sx + 65, sy + 17,
320 		              hud_recalc(_player.exp, 14, _player.nextLevel), 2, RGB(0, 224, 64));
321 
322 		// attack strength
323 		game_fillrect(_videoBuffer, sx + 1, sy + 16, 56, 6, RGB(0, 32, 32));
324 		game_fillrect(_videoBuffer, sx + 1, sy + 17,
325 		              hud_recalc(_player.attackStrength, 54, 100), 2,
326 		              ABS(_player.attackStrength - 100) < kEpsilon ? RGB(255, 128, 32) : RGB(0, 64, 224));
327 
328 		// spell strength
329 		game_fillrect(_videoBuffer, sx + 1, sy + 19,
330 		              hud_recalc(_player.spellStrength, 54, 100), 2,
331 		              ABS(_player.spellStrength - 100) < kEpsilon ? RGB(224, 0, 0) : RGB(128, 0, 224));
332 
333 		// time
334 		int ase = _secStart + _secsInGame;
335 		int h = ((ase - (ase % 3600)) / 3600);
336 		ase -= h * 3600;
337 		int m = ((ase - (ase % 60)) / 60);
338 		int s = (ase - m * 60);
339 
340 		sprintf(line, "%02i:%02i:%02i", h, m, s);
341 		drawString(_videoBuffer, line, 46 + 38 - strlen(line) * 4, 46 + 49, 0);
342 
343 		drawString(_videoBuffer, "Use", 193, 55, 0);
344 		drawString(_videoBuffer, "Cast", 236, 55, 0);
345 
346 		rcSrc.left = 128;
347 		rcSrc.top = 91;
348 
349 		int ss = (_player.sword - 1) * 3;
350 		if (_player.sword == 3)
351 			ss = 18;
352 		_itemImg[ss]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
353 
354 		rcSrc.left = rcSrc.left + 16;
355 		ss = (_player.shield - 1) * 3 + 1;
356 		if (_player.shield == 3)
357 			ss = 19;
358 		_itemImg[ss]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
359 
360 		rcSrc.left = rcSrc.left + 16;
361 		ss = (_player.armour - 1) * 3 + 2;
362 		if (_player.armour == 3)
363 			ss = 20;
364 		_itemImg[ss]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
365 
366 		for (int i = 0; i <= 4; i++) {
367 			sx = 188;
368 			sy = 70 + i * 24;
369 			rcSrc.left = sx;
370 			rcSrc.top = sy;
371 			if (i == 0)
372 				_itemImg[6]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
373 			else if (i == 1)
374 				_itemImg[12]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
375 			else if (i == 2)
376 				_itemImg[17]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
377 			else if (i == 3)
378 				_itemImg[16]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
379 			else if (i == 4)
380 				_itemImg[14]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
381 
382 			sprintf(line, "x%i", _player.inventory[i]);
383 			drawString(_videoBuffer, line, sx + 17, sy + 7, 0);
384 		}
385 
386 		// spells in menu
387 		if (_player.foundSpell[0]) {
388 			for (int i = 0; i < 5; i++) {
389 				rcSrc.left = 243;
390 				rcSrc.top = 67 + i * 24;
391 				sy = rcSrc.top;
392 
393 				if (_player.foundSpell[i]) {
394 					_itemImg[7 + i]->blit(*_videoBuffer, rcSrc.left, rcSrc.top);
395 
396 					game_fillrect(_videoBuffer, rcSrc.left, sy + 16, 16, 4, RGB(0, 32, 32));
397 					game_fillrect(_videoBuffer, rcSrc.left + 1, sy + 17,
398 					              hud_recalc(_player.spellCharge[i], 14, 100), 2,
399 					              ABS(_player.spellCharge[i] - 100) < kEpsilon ? RGB(255, 128, 32) : RGB(0, 224, 64));
400 				}
401 			}
402 		}
403 
404 		if (_itemSelOn) {
405 			for (int i = 0; i <= 4; i++) {
406 				if (_curItem == 5 + i) {
407 					rcDest.left = (float)(243 - 12 + 3 * sin(3.141592 * 2 * _itemyloc / 16));
408 					rcDest.top = 67 + 24 * i;
409 					_itemImg[15]->blit(*_videoBuffer, rcDest.left, rcDest.top);
410 				} else if (_curItem == i) {
411 					rcDest.left = (float)(189 - 12 + 3 * sin(3.141592 * 2 * _itemyloc / 16));
412 					rcDest.top = 70 + 24 * i;
413 					_itemImg[15]->blit(*_videoBuffer, rcDest.left, rcDest.top);
414 				}
415 			}
416 		}
417 	}
418 
419 	if (_selEnemyOn) {
420 		if (_curEnemy > _lastNpc) {
421 			int pst = _curEnemy - _lastNpc - 1;
422 			rcDest.left = _postInfo[pst][0];
423 			rcDest.top = (float)(_postInfo[pst][1] - 4 - sin(3.141592 / 8 * _itemyloc));
424 		} else {
425 			rcDest.left = _npcInfo[_curEnemy].x + 4;
426 			rcDest.top = (float)(_npcInfo[_curEnemy].y + 4 - 16 - sin(3.141592 / 8 * _itemyloc));
427 		}
428 
429 		_itemImg[13]->blit(*_videoBuffer, rcDest.left, rcDest.top);
430 	}
431 }
432 
drawNPCs(int mode)433 void GriffonEngine::drawNPCs(int mode) {
434 	unsigned int ccc = _videoBuffer->format.RGBToColor(255, 128, 32);
435 	int fst = _firsty;
436 	int lst = _lasty;
437 
438 	if (mode == 0)
439 		lst = _player.ysort;
440 	else if (mode == 1)
441 		fst = _player.ysort;
442 
443 	for (int yy = fst; yy <= lst; yy++) {
444 
445 		if (_ysort[yy] > 0) {
446 			int i = _ysort[yy];
447 
448 			if (_npcInfo[i].hp > 0) {
449 				int npx = (int)(_npcInfo[i].x);
450 				int npy = (int)(_npcInfo[i].y);
451 
452 				int sprite = _npcInfo[i].spriteset;
453 
454 				int wdir = _npcInfo[i].walkdir;
455 
456 				// spriteset1 specific
457 				if (_npcInfo[i].spriteset == kMonsterBabyDragon) {
458 
459 					if (!_npcInfo[i].attacking) {
460 
461 						int cframe = _npcInfo[i].cframe;
462 
463 						rcSrc.left = (int)(cframe / 4) * 24;
464 						rcSrc.top = wdir * 24;
465 						rcSrc.setWidth(24);
466 						rcSrc.setHeight(24);
467 
468 						rcDest.left = npx;
469 						rcDest.top = npy;
470 						rcDest.setWidth(24);
471 						rcDest.setHeight(24);
472 
473 						if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
474 							_npcInfo[i].shake = _ticks + 50;
475 							rcDest.left += (int)(RND() * 3) - 1;
476 							rcDest.top += (int)(RND() * 3) - 1;
477 						}
478 
479 						_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
480 					} else {
481 						int cframe = _npcInfo[i].cattackframe;
482 
483 						rcSrc.left = (int)(cframe / 4) * 24;
484 						rcSrc.top = wdir * 24;
485 						rcSrc.setWidth(24);
486 						rcSrc.setHeight(24);
487 
488 						rcDest.left = npx;
489 						rcDest.top = npy;
490 						rcDest.setWidth(24);
491 						rcDest.setHeight(24);
492 
493 						_animsAttack[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
494 					}
495 
496 				}
497 
498 				// onewing
499 				if (_npcInfo[i].spriteset == kMonsterOneWing) {
500 					for (int f = 0; f < 7; f++) {
501 						int s = _npcInfo[i].bodysection[f].sprite;
502 						rcSrc.left = _animSet2[s].x;
503 						rcSrc.top = _animSet2[s].y;
504 						rcSrc.setWidth(_animSet2[s].w);
505 						rcSrc.setHeight(_animSet2[s].h);
506 
507 						rcDest.left = _npcInfo[i].bodysection[f].x - _animSet2[s].xofs;
508 						rcDest.top = _npcInfo[i].bodysection[f].y - _animSet2[s].yofs + 2;
509 
510 						_anims[2]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
511 					}
512 
513 				}
514 
515 				// twowing
516 				if (_npcInfo[i].spriteset == kMonsterTwoWing) {
517 					for (int f = 0; f < 7; f++) {
518 						int yp = 0;
519 
520 						if (f == 0 && (_curMap == 53 || _curMap == 57 || _curMap == 61 || _curMap == 65 || _curMap == 56 || _curMap > 66) && _scriptFlag[kScriptLever][0] > 0)
521 							yp = 16;
522 						int s = _npcInfo[i].bodysection[f].sprite;
523 						rcSrc.left = _animSet9[s].x;
524 						rcSrc.top = _animSet9[s].y + yp;
525 						rcSrc.setWidth(_animSet9[s].w);
526 						rcSrc.setHeight(_animSet9[s].h);
527 
528 						rcDest.left = _npcInfo[i].bodysection[f].x - _animSet9[s].xofs;
529 						rcDest.top = _npcInfo[i].bodysection[f].y - _animSet9[s].yofs + 2;
530 
531 						_anims[9]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
532 					}
533 
534 				}
535 
536 
537 				//  boss 1
538 				if (_npcInfo[i].spriteset == kMonsterBoss1) {
539 					if (!_npcInfo[i].attacking) {
540 						int cframe = _npcInfo[i].cframe;
541 						rcSrc.left = (int)(cframe / 4) * 24;
542 					} else {
543 						rcSrc.left = 4 * 24;
544 					}
545 
546 					rcSrc.top = 0;
547 					rcSrc.setWidth(24);
548 					rcSrc.setHeight(48);
549 
550 					rcDest.left = npx - 2;
551 					rcDest.top = npy - 24;
552 
553 					_anims[3]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
554 
555 				}
556 
557 				// black knight
558 				if (_npcInfo[i].spriteset == kMonsterBlackKnight) {
559 					if (!_npcInfo[i].attacking) {
560 						int cframe = _npcInfo[i].cframe;
561 						rcSrc.left = (int)(cframe / 4) * 24;
562 					} else {
563 						rcSrc.left = 4 * 24;
564 					}
565 					rcSrc.top = 0;
566 					rcSrc.setWidth(24);
567 					rcSrc.setHeight(48);
568 
569 					rcDest.left = npx - 2;
570 					rcDest.top = npy - 24;
571 
572 					_anims[4]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
573 				}
574 
575 
576 				// firehydra
577 				if (_npcInfo[i].spriteset == kMonsterFireHydra) {
578 					for (int ff = 0; ff <= 2; ff++) {
579 						if (_npcInfo[i].hp > 10 * ff * 20) {
580 							rcSrc.left = 16 * (int)(RND() * 2);
581 							rcSrc.top = 80;
582 							rcSrc.setWidth(16);
583 							rcSrc.setHeight(16);
584 
585 							rcDest.left = _npcInfo[i].bodysection[10 * ff].x - 8;
586 							rcDest.top = _npcInfo[i].bodysection[10 * ff].y - 8;
587 
588 							int x = 192 + ((int)(_itemyloc + ff * 5) % 3) * 64;
589 							if (x > 255)
590 								x = 255;
591 							_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc, TS_ARGB(x, 255, 255, 255));
592 
593 							for (int f = 1; f <= 8; f++) {
594 								rcSrc.left = 16 * (int)(RND() * 2);
595 								rcSrc.top = 80;
596 								rcSrc.setWidth(16);
597 								rcSrc.setHeight(16);
598 
599 								rcDest.left = _npcInfo[i].bodysection[ff * 10 + f].x - 8 + (int)(RND() * 3) - 1;
600 								rcDest.top = _npcInfo[i].bodysection[ff * 10 + f].y - 8 + (int)(RND() * 3) - 1;
601 
602 								x = 192 + f % 3 * 64;
603 								if (x > 255)
604 									x = 255;
605 								_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc, TS_ARGB(x, 255, 255, 255));
606 							}
607 
608 							rcSrc.left = 0;
609 							rcSrc.top = 0;
610 							rcSrc.setWidth(42);
611 							rcSrc.setHeight(36);
612 
613 							rcDest.left = _npcInfo[i].bodysection[10 * ff + 9].x - 21;
614 							rcDest.top = _npcInfo[i].bodysection[10 * ff + 9].y - 21;
615 
616 							_spellImg->setAlpha(192, true);
617 							_anims[5]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
618 						}
619 
620 					}
621 
622 				}
623 
624 				// red dragon
625 				if (_npcInfo[i].spriteset == kMonsterRedDragon) {
626 					int cframe = _npcInfo[i].cframe;
627 
628 					rcSrc.left = (int)(cframe / 4) * 24;
629 					rcSrc.top = wdir * 24;
630 					rcSrc.setWidth(24);
631 					rcSrc.setHeight(24);
632 
633 					rcDest.left = npx;
634 					rcDest.top = npy;
635 					rcDest.setWidth(24);
636 					rcDest.setHeight(24);
637 
638 					if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
639 						_npcInfo[i].shake = _ticks + 50;
640 						rcDest.left = rcDest.left + (int)(RND() * 3) - 1;
641 						rcDest.top = rcDest.top + (int)(RND() * 3) - 1;
642 					}
643 
644 					_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
645 				}
646 
647 				// wizard
648 				if (_npcInfo[i].spriteset == kMonsterPriest) {
649 					// if(_npcinfo[i].attacking == 0) {
650 					int cframe = _npcInfo[i].cframe;
651 
652 					rcSrc.left = (int)(cframe / 4) * 24;
653 					rcSrc.top = wdir * 24;
654 					rcSrc.setWidth(24);
655 					rcSrc.setHeight(24);
656 
657 					rcDest.left = npx;
658 					rcDest.top = npy;
659 					rcDest.setWidth(24);
660 					rcDest.setHeight(24);
661 
662 					if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
663 						_npcInfo[i].shake = _ticks + 50;
664 						rcDest.left = rcDest.left + (int)(RND() * 3) - 1;
665 						rcDest.top = rcDest.top + (int)(RND() * 3) - 1;
666 					}
667 					_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
668 				}
669 
670 				// yellow dragon
671 				if (_npcInfo[i].spriteset == kMonsterYellowDragon) {
672 					int cframe = _npcInfo[i].cframe;
673 
674 					rcSrc.left = (int)(cframe / 4) * 24;
675 					rcSrc.top = wdir * 24;
676 					rcSrc.setWidth(24);
677 					rcSrc.setHeight(24);
678 
679 					rcDest.left = npx;
680 					rcDest.top = npy;
681 					rcDest.setWidth(24);
682 					rcDest.setHeight(24);
683 
684 					if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
685 						_npcInfo[i].shake = _ticks + 50;
686 						rcDest.left = rcDest.left + (int)(RND() * 3) - 1;
687 						rcDest.top = rcDest.top + (int)(RND() * 3) - 1;
688 					}
689 					_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
690 				}
691 
692 
693 				// dragon2
694 				if (_npcInfo[i].spriteset == kMonsterDragon2) {
695 					if (!_npcInfo[i].attacking) {
696 						_npcInfo[i].floating = _npcInfo[i].floating + 0.25 * _fpsr;
697 						while (_npcInfo[i].floating >= 16)
698 							_npcInfo[i].floating = _npcInfo[i].floating - 16;
699 
700 						float frame = _npcInfo[i].frame;
701 
702 						frame += 0.5 * _fpsr;
703 						while (frame >= 16)
704 							frame -= 16;
705 
706 						int cframe = (int)(frame);
707 						if (cframe < 0)
708 							cframe = 0;
709 
710 						_npcInfo[i].frame = frame;
711 						_npcInfo[i].cframe = cframe;
712 
713 						rcSrc.left = 74 * wdir;
714 						rcSrc.top = (int)(cframe / 4) * 48;
715 						rcSrc.setWidth(74);
716 						rcSrc.setHeight(48);
717 
718 						rcDest.left = npx + 12 - 37;
719 						rcDest.top = (float)(npy + 12 - 32 - 3 * sin(3.141592 * 2 * _npcInfo[i].floating / 16));
720 						rcDest.setWidth(24);
721 						rcDest.setHeight(24);
722 
723 						if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
724 							_npcInfo[i].shake = _ticks + 50;
725 							rcDest.left = rcDest.left + (int)(RND() * 3) - 1;
726 							rcDest.top = rcDest.top + (int)(RND() * 3) - 1;
727 						}
728 
729 						_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
730 					} else {
731 						_npcInfo[i].floating = _npcInfo[i].floating + 0.25 * _fpsr;
732 						while (_npcInfo[i].floating >= 16)
733 							_npcInfo[i].floating = _npcInfo[i].floating - 16;
734 
735 						int cframe = _npcInfo[i].cattackframe;
736 
737 						rcSrc.left = 74 * wdir;
738 						rcSrc.top = (int)(cframe / 4) * 48;
739 						rcSrc.setWidth(74);
740 						rcSrc.setHeight(48);
741 
742 						rcDest.left = npx + 12 - 37;
743 						rcDest.top = (float)(npy + 12 - 32 - 3 * sin(3.141592 * 2 * _npcInfo[i].floating / 16));
744 						rcDest.setWidth(24);
745 						rcDest.setHeight(24);
746 
747 						_animsAttack[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
748 					}
749 				}
750 
751 				// end boss
752 				if (_npcInfo[i].spriteset == kMonsterFinalBoss) {
753 
754 					_npcInfo[i].floating = _npcInfo[i].floating + .3 * _fpsr;
755 					while (_npcInfo[i].floating >= 16)
756 						_npcInfo[i].floating = _npcInfo[i].floating - 16;
757 
758 
759 					float frame = _npcInfo[i].frame2;
760 
761 					frame += 0.5 * _fpsr;
762 					while (frame >= 16)
763 						frame -= 16;
764 
765 					_npcInfo[i].frame2 = frame;
766 
767 					int sx = npx + 12 - 40;
768 					int sy = (float)(npy + 12 - 50 - 3 * sin(3.141592 * 2 * _npcInfo[i].floating / 16));
769 
770 					for (int fr = 0; fr <= 3; fr++) {
771 						int alpha = 128 + (int)(RND() * 96);
772 
773 						rcSrc.left = 16 * (int)(RND() * 2);
774 						rcSrc.top = 80;
775 						rcSrc.setWidth(16);
776 						rcSrc.setHeight(16);
777 
778 						rcDest.left = sx + 32 + (int)(RND() * 3) - 1;
779 						rcDest.top = sy - (int)(RND() * 6);
780 
781 						_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc, TS_ARGB(alpha, 255, 255, 255));
782 					}
783 
784 					for (int ii = 0; ii <= 8; ii++) {
785 						for (int i2 = 0; i2 <= 3; i2++) {
786 							rcSrc.left = 16 * (int)(RND() * 2);
787 							rcSrc.top = 80;
788 							rcSrc.setWidth(16);
789 							rcSrc.setHeight(16);
790 
791 							float fr3 = frame - 3 + i2;
792 							if (fr3 < 0)
793 								fr3 += 16;
794 
795 							rcDest.left = (float)(sx + 36 + ii * 8 - ii * cos(3.14159 * 2 * (fr3 - ii) / 16) * 2);
796 							rcDest.top = (float)(sy + 16 + ii * sin(3.14159 * 2 * (fr3 - ii) / 16) * 3 - ii); //  * 4
797 
798 							int alpha = i2 / 3 * 224;
799 
800 							_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc, TS_ARGB(alpha, 255, 255, 255));
801 
802 							int xloc = rcDest.left;
803 							int yloc = rcDest.top;
804 							int xdif = (xloc + 8) - (_player.px + 12);
805 							int ydif = (yloc + 8) - (_player.py + 12);
806 
807 							if ((ABS(xdif) < 8 && ABS(ydif) < 8) && _player.pause < _ticks) {
808 								float damage = (float)_npcInfo[i].spellDamage * (1.0 + RND() * 0.5);
809 
810 								if (_player.hp > 0) {
811 									damagePlayer(damage);
812 									if (config.effects) {
813 										int snd = playSound(_sfx[kSndFire]);
814 										setChannelVolume(snd, config.effectsVol);
815 									}
816 								}
817 
818 							}
819 
820 
821 							rcDest.left = (float)(sx + 36 - ii * 8 + ii * cos(3.14159 * 2 * (fr3 - ii) / 16) * 2);
822 							rcDest.top = (float)(sy + 16 + ii * sin(3.14159 * 2 * (fr3 - ii) / 16) * 3 - ii); //  * 4
823 
824 							_spellImg->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
825 
826 							xloc = rcDest.left;
827 							yloc = rcDest.top;
828 							xdif = (xloc + 8) - (_player.px + 12);
829 							ydif = (yloc + 8) - (_player.py + 12);
830 
831 							if ((ABS(xdif) < 8 && ABS(ydif) < 8) && _player.pause < _ticks) {
832 								float damage = (float)_npcInfo[i].spellDamage * (1.0 + RND() * 0.5);
833 
834 								if (_player.hp > 0) {
835 									damagePlayer(damage);
836 									if (config.effects) {
837 										int snd = playSound(_sfx[kSndFire]);
838 										setChannelVolume(snd, config.effectsVol);
839 									}
840 								}
841 							}
842 						}
843 					}
844 
845 					if (!_npcInfo[i].attacking) {
846 						int cframe = (int)(frame);
847 						rcSrc.left = 0;
848 						rcSrc.top = 72 * (int)(cframe / 4);
849 						rcSrc.setWidth(80);
850 						rcSrc.setHeight(72);
851 
852 						rcDest.left = sx;
853 						rcDest.top = sy;
854 
855 						if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
856 							_npcInfo[i].shake = _ticks + 50;
857 							rcDest.left = rcDest.top + (int)(RND() * 3) - 1;
858 							rcDest.left = rcDest.top + (int)(RND() * 3) - 1;
859 						}
860 
861 						_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
862 					} else {
863 						int cframe = (int)(_npcInfo[i].cattackframe);
864 
865 						rcSrc.left = 0;
866 						rcSrc.top = 72 * (int)(cframe / 4);
867 						rcSrc.setWidth(80);
868 						rcSrc.setHeight(72);
869 
870 						rcDest.left = sx;
871 						rcDest.top = sy;
872 
873 						_animsAttack[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
874 					}
875 				}
876 
877 				// bat kitty
878 				if (_npcInfo[i].spriteset == kMonsterBatKitty) {
879 					_npcInfo[i].floating = _npcInfo[i].floating + 1 * _fpsr;
880 					while (_npcInfo[i].floating >= 16)
881 						_npcInfo[i].floating = _npcInfo[i].floating - 16;
882 
883 					float frame = _npcInfo[i].frame;
884 
885 					frame += 0.5 * _fpsr;
886 					while (frame >= 16)
887 						frame -= 16;
888 
889 					int cframe = (int)(frame);
890 					if (cframe < 0)
891 						cframe = 0;
892 
893 					_npcInfo[i].frame = frame;
894 					_npcInfo[i].cframe = cframe;
895 
896 					rcSrc.left = 0;
897 					rcSrc.top = 0;
898 					rcSrc.setWidth(99);
899 					rcSrc.setHeight(80);
900 
901 					rcDest.left = npx + 12 - 50;
902 					rcDest.top = (float)(npy + 12 - 64 + 2 * sin(3.141592 * 2 * _npcInfo[i].floating / 16));
903 					rcDest.setWidth(99);
904 					rcDest.setHeight(80);
905 
906 					if (_npcInfo[i].pause > _ticks && _npcInfo[i].shake < _ticks) {
907 						_npcInfo[i].shake = _ticks + 50;
908 						rcDest.left = rcDest.left + (int)(RND() * 3) - 1;
909 						rcDest.top = rcDest.top + (int)(RND() * 3) - 1;
910 					}
911 
912 					_anims[sprite]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
913 				}
914 
915 				rcDest.left = npx + 4;
916 				rcDest.top = npy + 22;
917 				rcDest.setWidth(16);
918 				rcDest.setHeight(4);
919 
920 				_videoBuffer->fillRect(rcDest, 0);
921 
922 				rcDest.left = npx + 5;
923 				rcDest.top = npy + 23;
924 
925 
926 				int ww = 14 * _npcInfo[i].hp / _npcInfo[i].maxhp;
927 				ww = CLIP(ww, 1, 14);
928 
929 				rcDest.setWidth(ww);
930 				rcDest.setHeight(2);
931 
932 
933 				_videoBuffer->fillRect(rcDest, ccc);
934 
935 				bool pass = true;
936 
937 				if (_npcInfo[i].spriteset == kMonsterBoss1)
938 					pass = false;
939 
940 				if (pass)
941 					drawOver(npx, npy);
942 			}
943 		}
944 	}
945 }
946 
drawOver(int modx,int mody)947 void GriffonEngine::drawOver(int modx, int mody) {
948 	int npx = modx + 12;
949 	int npy = mody + 20;
950 
951 	int lx = (int)npx / 16;
952 	int ly = (int)npy / 16;
953 
954 	for (int xo = -1; xo <= 1; xo++) {
955 		for (int yo = -1; yo <= 1; yo++) {
956 
957 			int sx = lx + xo;
958 			int sy = ly + yo;
959 
960 			int sx2 = sx * 16;
961 			int sy2 = sy * 16;
962 
963 			if (sx > -1 && sx < 40 && sy > -1 && sy < 24) {
964 				int curtile = _tileinfo[2][sx][sy][0];
965 				int curtilel = _tileinfo[2][sx][sy][1];
966 
967 				if (curtile > 0) {
968 					curtile = curtile - 1;
969 					int curtilex = curtile % 20;
970 					int curtiley = (curtile - curtilex) / 20;
971 
972 					rcSrc.left = curtilex * 16;
973 					rcSrc.top = curtiley * 16;
974 					rcSrc.setWidth(16);
975 					rcSrc.setHeight(16);
976 
977 					rcDest.left = sx2;
978 					rcDest.top = sy2;
979 					rcDest.setWidth(16);
980 					rcDest.setHeight(16);
981 
982 					bool pass = true;
983 					if (curtilel == 1) {
984 						for (int ff = 0; ff <= 5; ff++) {
985 							int ffa = 20 * 5 - 1 + ff * 20;
986 							int ffb = 20 * 5 + 4 + ff * 20;
987 							if (curtile > ffa && curtile < ffb)
988 								pass = false;
989 						}
990 					}
991 
992 					if (pass)
993 						_tiles[curtilel]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
994 				}
995 			}
996 		}
997 	}
998 }
999 
drawPlayer()1000 void GriffonEngine::drawPlayer() {
1001 	int f = 0;
1002 	if (_player.armour == 3)
1003 		f = 13;
1004 
1005 	if (!_attacking) {
1006 		rcSrc.left = (int)(_player.walkFrame / 4) * 24;
1007 		rcSrc.top = _player.walkDir * 24;
1008 		rcSrc.setWidth(24);
1009 		rcSrc.setHeight(24);
1010 
1011 		rcDest.left = (int)(_player.px);
1012 		rcDest.top = (int)(_player.py);
1013 		rcDest.setWidth(24);
1014 		rcDest.setHeight(24);
1015 
1016 		_anims[f]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
1017 	} else {
1018 		rcSrc.left = (int)(_player.attackFrame / 4) * 24;
1019 		rcSrc.top = _player.walkDir * 24;
1020 		rcSrc.setWidth(24);
1021 		rcSrc.setHeight(24);
1022 
1023 		rcDest.left = (int)(_player.px);
1024 		rcDest.top = (int)(_player.py);
1025 		rcDest.setWidth(24);
1026 		rcDest.setHeight(24);
1027 
1028 		_animsAttack[f]->blit(*_videoBuffer, rcDest.left, rcDest.top, Graphics::FLIP_NONE, &rcSrc);
1029 	}
1030 
1031 	long ccc = _videoBuffer->format.RGBToColor(224, 224, 64);
1032 
1033 	bool pass = false;
1034 	if (_player.hp <= _player.maxHp * 0.25)
1035 		pass = true;
1036 
1037 	if (pass) {
1038 		ccc = _videoBuffer->format.RGBToColor(255, 255, 255);
1039 		if ((int)(_player.hpflash) == 1)
1040 			ccc = _videoBuffer->format.RGBToColor(255, 0, 0);
1041 	}
1042 
1043 	int sss = 6;
1044 	if (_player.foundSpell[0])
1045 		sss = 8;
1046 	int npx = _player.px;
1047 	int npy = _player.py;
1048 	rcDest.left = npx + 4;
1049 	rcDest.top = npy + 22;
1050 	rcDest.setWidth(16);
1051 	rcDest.setHeight(sss);
1052 
1053 	_videoBuffer->fillRect(rcDest, 0);
1054 
1055 	rcDest.left = npx + 5;
1056 	rcDest.top = npy + 23;
1057 
1058 	int ww = 14 * _player.hp / _player.maxHp;
1059 	ww = CLIP(ww, 1, 14);
1060 
1061 	rcDest.setWidth(ww);
1062 	rcDest.setHeight(2);
1063 
1064 	_videoBuffer->fillRect(rcDest, ccc);
1065 
1066 	ccc = _videoBuffer->format.RGBToColor(0, 224, 64);
1067 	if (ABS(_player.attackStrength - 100) < kEpsilon)
1068 		ccc = _videoBuffer->format.RGBToColor(255, 128, 32);
1069 
1070 	ww = 14 * _player.attackStrength / 100;
1071 	if (ww > 14)
1072 		ww = 14;
1073 
1074 	int ww2 = 14 * _player.spellStrength / 100;
1075 	if (ww2 > 14)
1076 		ww2 = 14;
1077 
1078 	rcDest.top = rcDest.top + 2;
1079 	rcDest.setWidth(ww);
1080 	rcDest.setHeight(2);
1081 
1082 	_videoBuffer->fillRect(rcDest, ccc);
1083 
1084 	ccc = _videoBuffer->format.RGBToColor(128, 0, 224);
1085 	if (ABS(_player.spellStrength - 100) < kEpsilon)
1086 		ccc = _videoBuffer->format.RGBToColor(224, 0, 0);
1087 
1088 	rcDest.top = rcDest.top + 2;
1089 	rcDest.setWidth(ww2);
1090 	rcDest.setHeight(2);
1091 
1092 	_videoBuffer->fillRect(rcDest, ccc);
1093 }
1094 
drawView()1095 void GriffonEngine::drawView() {
1096 	_videoBuffer->copyRectToSurface(_mapBg->getPixels(), _mapBg->pitch, 0, 0, _mapBg->w, _mapBg->h);
1097 
1098 	updateSpellsUnder();
1099 
1100 	drawAnims(0);
1101 
1102 	// ------dontdrawover = special case to make boss work right in room 24
1103 	if (_dontDrawOver)
1104 		drawAnims(1);
1105 	drawNPCs(0);
1106 
1107 	drawPlayer();
1108 
1109 	drawNPCs(1);
1110 	if (!_dontDrawOver)
1111 		drawAnims(1);
1112 
1113 	drawOver((int)_player.px, (int)_player.py);
1114 
1115 	updateSpells();
1116 
1117 	if (_cloudsOn) {
1118 		Common::Rect rc;
1119 		rc.left = (float)(256 + 256 * cos(3.141592 / 180 * _cloudAngle));
1120 		rc.top = (float)(192 + 192 * sin(3.141592 / 180 * _cloudAngle));
1121 		rc.setWidth(320);
1122 		rc.setHeight(240);
1123 
1124 		_cloudImg->blit(*_videoBuffer, 0, 0, Graphics::FLIP_NONE, &rc);
1125 	}
1126 
1127 	drawHud();
1128 
1129 	g_system->copyRectToScreen(_videoBuffer->getPixels(), _videoBuffer->pitch, 0, 0, _videoBuffer->w, _videoBuffer->h);
1130 }
1131 
swash()1132 void GriffonEngine::swash() {
1133 	float y = 0.0;
1134 	do {
1135 		y += 1 * _fpsr;
1136 
1137 		_videoBuffer->setAlpha((int)y);
1138 		_videoBuffer->fillRect(Common::Rect(0, 0, _videoBuffer->w, _videoBuffer->h), 0);
1139 
1140 		g_system->copyRectToScreen(_videoBuffer->getPixels(), _videoBuffer->pitch, 0, 0, _videoBuffer->w, _videoBuffer->h);
1141 		g_system->updateScreen();
1142 
1143 		g_system->getEventManager()->pollEvent(_event);
1144 		g_system->delayMillis(10);
1145 
1146 		_ticksPassed = _ticks;
1147 		_ticks = g_system->getMillis();
1148 
1149 		_ticksPassed = _ticks - _ticksPassed;
1150 		_fpsr = (float)_ticksPassed / 24.0;
1151 
1152 		_fp++;
1153 		if (_ticks > _nextTicks) {
1154 			_nextTicks = _ticks + 1000;
1155 			_fps = _fp;
1156 			_fp = 0;
1157 		}
1158 
1159 		_cloudAngle += 0.01 * _fpsr;
1160 		while (_cloudAngle >= 360)
1161 			_cloudAngle = _cloudAngle - 360;
1162 
1163 		if (y > 10)
1164 			break;
1165 	} while (1);
1166 
1167 	y = 0;
1168 	do {
1169 		y += _fpsr;
1170 
1171 		_videoBuffer->setAlpha((int)(y * 25));
1172 		_mapBg->blit(*_videoBuffer);
1173 
1174 		if (_cloudsOn) {
1175 			rcDest.left = (float)(256 + 256 * cos(3.141592 / 180 * _cloudAngle));
1176 			rcDest.top = (float)(192 + 192 * sin(3.141592 / 180 * _cloudAngle));
1177 			rcDest.setWidth(320);
1178 			rcDest.setHeight(240);
1179 
1180 			_cloudImg->blit(*_videoBuffer, 0, 0, Graphics::FLIP_NONE, &rcDest);
1181 		}
1182 
1183 		g_system->copyRectToScreen(_videoBuffer->getPixels(), _videoBuffer->pitch, 0, 0, _videoBuffer->w, _videoBuffer->h);
1184 		g_system->updateScreen();
1185 
1186 		g_system->getEventManager()->pollEvent(_event);
1187 		g_system->delayMillis(10);
1188 
1189 		_ticksPassed = _ticks;
1190 		_ticks = g_system->getMillis();
1191 
1192 		_ticksPassed = _ticks - _ticksPassed;
1193 		_fpsr = (float)_ticksPassed / 24.0;
1194 
1195 		_fp++;
1196 		if (_ticks > _nextTicks) {
1197 			_nextTicks = _ticks + 1000;
1198 			_fps = _fp;
1199 			_fp = 0;
1200 		}
1201 
1202 		_cloudAngle += 0.01 * _fpsr;
1203 		while (_cloudAngle >= 360)
1204 			_cloudAngle -= 360;
1205 
1206 	} while (y <= 10);
1207 
1208 
1209 	_videoBuffer->setAlpha(255);
1210 }
1211 
1212 
1213 } // end of namespace Griffon
1214