aboutsummaryrefslogtreecommitdiff
path: root/engines/prince/hero.cpp
blob: 4b582d6cc648ea3c00ff0925820a87712ef61afb (plain)
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
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
/* 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.
 *
 */
#include "common/debug.h"
#include "common/random.h"

#include "prince/hero.h"
#include "prince/hero_set.h"
#include "prince/animation.h"
#include "prince/resource.h"
#include "prince/prince.h"
#include "prince/graphics.h"

namespace Prince {

Hero::Hero(PrinceEngine *vm, GraphicsMan *graph) : _vm(vm), _graph(graph)
	, _number(0), _visible(false), _state(MOVE), _middleX(0), _middleY(0)
	, _boreNum(1), _currHeight(0), _moveDelay(0), _shadMinus(0), _moveSetType(0)
	, _lastDirection(DOWN), _destDirection(DOWN), _talkTime(0), _boredomTime(0), _phase(0)
	, _specAnim(0), _drawX(0), _drawY(0), _zoomFactor(0), _scaleValue(0)
	, _shadZoomFactor(0), _shadScaleValue(0), _shadLineLen(0), _shadDrawX(0), _shadDrawY(0)
	, _frameXSize(0), _frameYSize(0), _scaledFrameXSize(0), _scaledFrameYSize(0)
{
	_zoomBitmap = (byte *)malloc(kZoomBitmapLen);
	_shadowBitmap = (byte *)malloc(2 * kShadowBitmapSize);
	_shadowLine = new byte[kShadowLineArraySize];
}

Hero::~Hero() {
	free(_zoomBitmap);
	free(_shadowBitmap);
	delete[] _shadowLine;
}

bool Hero::loadAnimSet(uint32 animSetNr) {
	if (animSetNr > sizeof(heroSetTable)) {
		return false;
	}

	_shadMinus = heroSetBack[animSetNr];

	for (uint32 i = 0; i < _moveSet.size(); i++) {
		delete _moveSet[i];
	}

	const HeroSetAnimNames &animSet = *heroSetTable[animSetNr];

	_moveSet.resize(kMoveSetSize);
	for (uint32 i = 0; i < kMoveSetSize; ++i) {
		debug("Anim set item %d %s", i, animSet[i]);
		Animation *anim = NULL;
		if (animSet[i] != NULL) {
			anim = new Animation();
			Resource::loadResource(anim, animSet[i], true);
		}
		_moveSet[i] = anim;
	}

	return true;
}

Graphics::Surface *Hero::getSurface() {
	if (_moveSet[_moveSetType]) {
		int16 phaseFrameIndex = _moveSet[_moveSetType]->getPhaseFrameIndex(_phase);
		Graphics::Surface *heroFrame = _moveSet[_moveSetType]->getFrame(phaseFrameIndex);
		return heroFrame;
	}
	return NULL;
}

//TEMP
void Hero::getState() {
	switch (_state) {
	case STAY:
		debug("STAY");
		break;
	case TURN:
		debug("TURN");
		break;
	case MOVE:
		debug("MOVE");
		break;
	case BORE:
		debug("BORE");
		break;
	case SPEC:
		debug("SPEC");
		break;
	case TALK:
		debug("TALK");
		break;
	case MVAN:
		debug("MVAN");
		break;
	case TRAN:
		debug("TRAN");
		break;
	case RUN:
		debug("RUN");
		break;
	case DMOVE:
		debug("DMOVE");
		break;
	}
}

int Hero::getScaledValue(int size) {
	int newSize = 0;
	int16 initScaleValue = _scaleValue;
	if (_scaleValue != 10000) {
		for(int i = 0; i < size; i++) {
			initScaleValue -= 100;
			if(initScaleValue >= 0) {
				newSize++;
			} else {
				initScaleValue += _scaleValue;
			}
		}
		return newSize;
	} else {
		return size;
	}
}

Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) {
	Graphics::Surface *zoomedFrame = new Graphics::Surface();
	zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8());
	
	int sprZoomX;
	int sprZoomY = _scaleValue;
	uint xSource = 0;
	uint ySource = 0;
	uint xDest = 0;
	uint yDest = 0;

	for (int i = 0; i < _scaledFrameYSize; i++) {
		// linear_loop:
		while(1) {
			sprZoomY -= 100;
			if (sprZoomY >= 0 || _scaleValue == 10000) {
				// all_r_y
				sprZoomX = _scaleValue;
				break; // to loop_lin
			} else {
				sprZoomY += _scaleValue;
				xSource = 0;
				ySource++;
			}
		}
		// loop_lin:
		for (int j = 0; j < _scaledFrameXSize; j++) {
			sprZoomX -= 100;
			if (sprZoomX >= 0) {
				// its_all_r
				memcpy(zoomedFrame->getBasePtr(xDest, yDest), heroFrame->getBasePtr(xSource, ySource), 1);
				xDest++;
			} else {
				sprZoomX += _scaleValue;
				j--;
			}
			xSource++;
		}
		xDest = 0;
		yDest++;
		xSource = 0;
		ySource++;
	}
	return zoomedFrame;
}

void Hero::countDrawPosition() {
	int16 tempMiddleY;
	int16 baseX = _moveSet[_moveSetType]->getBaseX();
	int16 baseY = _moveSet[_moveSetType]->getBaseY();
	// any chance?
	if (baseX == 320) {
		tempMiddleY = _middleY - (baseY - 240);
	} else {
		tempMiddleY = _middleY;
	}
	_frameXSize = _moveSet[_moveSetType]->getFrameWidth(_phase);
	_frameYSize = _moveSet[_moveSetType]->getFrameHeight(_phase);
	_scaledFrameXSize = getScaledValue(_frameXSize);
	_scaledFrameYSize = getScaledValue(_frameYSize);

	if (_zoomFactor != 0) {
		//notfullSize
		_drawX = _middleX - _scaledFrameXSize / 2;
		_drawY = tempMiddleY + 1 - _scaledFrameYSize;
		_vm->checkMasks(_drawX, _drawY - 1, _scaledFrameXSize, _scaledFrameYSize, _middleY);
	} else {
		//fullSize
		_drawX = _middleX - _frameXSize / 2;
		_drawY = tempMiddleY + 1 - _frameYSize;
		_vm->checkMasks(_drawX, _drawY - 1, _frameXSize, _frameYSize, _middleY);
	}
}

void Hero::plotPoint(int x, int y) {
	WRITE_UINT16(&_shadowLine[_shadLineLen * 4], x);
	WRITE_UINT16(&_shadowLine[_shadLineLen * 4 + 2], y);
}

static void plot(int x, int y, int color, void *data) {
	Hero *shadowLine = (Hero *)data;
	shadowLine->plotPoint(x, y);
	shadowLine->_shadLineLen++;
}

void Hero::showHeroShadow(Graphics::Surface *heroFrame) {
	Graphics::Surface *makeShadow = new Graphics::Surface();
	makeShadow->create(_frameXSize, _frameYSize, Graphics::PixelFormat::createFormatCLUT8());

	for (int y = 0; y < _frameYSize; y++) {
		byte *src = (byte *)heroFrame->getBasePtr(0, y);
		byte *dst = (byte *)makeShadow->getBasePtr(0, y);

		for (int x = 0; x < _frameXSize; x++, dst++, src++) {
			if (*src != 0xFF) {
				*dst = _graph->kShadowColor;
			} else {
				*dst = *src;
			}
		}
	}

	int destX = _middleX - _scaledFrameXSize / 2;
	int destY = _middleY - _shadMinus - 1;

	if (destY > 1 && destY < kMaxPicHeight) {
		int shadDirection;
		if (_lightY > destY) {
			shadDirection = 1;
		} else {
			shadDirection = 0;
		}

		_shadLineLen = 0;
		Graphics::drawLine(_lightX, _lightY, destX, destY, 0, &plot, this);

		byte *sprShadow = (byte *)_graph->_shadowTable70;

		_shadDrawX = destX - _vm->_picWindowX;
		_shadDrawY = destY - _vm->_picWindowY;

		int shadPosX = _shadDrawX;
		int shadPosY = _shadDrawY;
		int shadBitAddr = destY * kMaxPicWidth / 8 + destX / 8;
		int shadBitMask = 128 >> (destX % 8);

		int shadZoomY2 = _shadScaleValue;
		int shadZoomY = _scaleValue;

		int diffX = 0;
		int diffY = 0;

		int shadowHeroX = 0;
		int shadowHeroY = _frameYSize - 1;

		int shadLastY = 0;

		byte *shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY); // first pixel from last row of shadow hero
		byte *background = (byte *)_graph->_frontScreen->getBasePtr(_shadDrawX, _shadDrawY); // pixel of background where shadow sprite starts

		// banked2
		byte *shadowLineStart = _shadowLine + 8;

		int shadWallDown = 0;
		int shadWallBitAddr = 0;
		int shadWallBitMask = 0;
		byte *shadWallDestAddr = 0;
		int shadWallPosY = 0;
		int shadWallSkipX = 0;
		int shadWallModulo = 0;

		// linear_loop
		for (int i = 0; i < _frameYSize; i++) {
			int shadSkipX = 0;
			int ct_loop = 0;
			int sprModulo = 0;

			int j;
			//retry_line:
			for (j = _frameYSize - i; j > 0; j--) {
				shadZoomY -= 100;
				if (shadZoomY < 0 && _scaleValue != 10000) {
					shadZoomY += _scaleValue;
					shadowHeroY--;
					if (shadowHeroY < 0) {
						break;
					}
					shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
				} else {
					break;
				}
			}
			if (j == 0) {
				break;
			}
			if (shadowHeroY < 0) {
				break;
			}
			//line_y_ok
			if (shadLastY != shadPosY && shadPosY >= 0 && shadPosY < 480 && shadPosX < 640) {
				shadLastY = shadPosY;
				if (shadPosX < 0) {
					shadSkipX = -1 * shadPosX;
					background += shadSkipX;
					if (_frameXSize > shadSkipX) {
						shadowHero += shadSkipX;
						shadBitAddr += shadSkipX / 8;
						if ((shadSkipX % 8) != 0) {
							//loop_rotate:
							for (int a = 0; a < (shadSkipX % 8); a++) {
								if (shadBitMask == 1) {
									shadBitMask = 128;
									shadBitAddr++;
								} else {
									shadBitMask >>= 1;
								}
							}
						}
					} else {
						//skip_line
						//test it
					}
				} else {
					//x1_ok
					if (shadPosX + _frameXSize > 640) {
						ct_loop = 640 - shadPosX; // test it
						sprModulo = shadPosX + _frameXSize - 640;
					} else {
						//draw_line
						ct_loop = _frameXSize;
					}
				}
				//draw_line1
				//retry_line2
				int k;
				for (k = j; k > 0; k--) {
					shadZoomY2 -= 100;
					if (shadZoomY2 < 0 && _shadScaleValue != 10000) {
						shadZoomY2 += _shadScaleValue;
						shadowHeroY--;
						if (shadowHeroY < 0) {
							break;
						}
						shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
					} else {
						break;
					}
				}
				if (shadowHeroY < 0) {
					break;
				}
				if (k == 0) {
					break;
				}
				//line_y_ok_2:
				//copy_trans
				bool shadWDFlag = false;
				int shadZoomX = _scaleValue;
				int backgroundDiff = 0;
				int shadBitMaskCopyTrans = shadBitMask;
				int shadBitAddrCopyTrans = shadBitAddr;
				//ct_loop:
				for (int l = 0; l < ct_loop; l++) {
					shadZoomX -= 100;
					if (shadZoomX < 0 && _scaleValue != 10000) {
						shadZoomX += _scaleValue;
					} else {
						if (*shadowHero == _graph->kShadowColor) {
							if ((shadBitMaskCopyTrans & _shadowBitmap[shadBitAddrCopyTrans]) != 0) {
								if (shadWallDown == 0) {
									if ((shadBitMaskCopyTrans & _shadowBitmap[shadBitAddrCopyTrans + kShadowBitmapSize]) != 0) {
										shadWDFlag = true;
										//shadow
										*background = *(sprShadow + *background);
									}
								}
							} else {
								//shadow
								*background = *(sprShadow + *background);
							}
						}
						//ct_next
						if (shadBitMaskCopyTrans == 1) {
							shadBitMaskCopyTrans = 128;
							shadBitAddrCopyTrans++;
						} else {
							shadBitMaskCopyTrans >>= 1;
						}
						//okok
						backgroundDiff++;
						background = (byte *)_graph->_frontScreen->getBasePtr(_shadDrawX + diffX + backgroundDiff, _shadDrawY + diffY);
					}
					shadowHeroX++;
					shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
				}
				//byebyebye
				if (!shadWallDown && shadWDFlag) {
					shadWallDown = shadPosX;
					shadWallBitAddr = shadBitAddr;
					shadWallDestAddr = (byte *)_graph->_frontScreen->getBasePtr(_shadDrawX + diffX, _shadDrawY + diffY);
					shadWallBitMask = shadBitMask;
					shadWallPosY = shadPosY;
					shadWallSkipX = shadSkipX;
					shadWallModulo = sprModulo;
				}
				//byebye
				if (shadDirection != 0 && shadWallDown != 0) {
					int shadBitMaskWallCopyTrans = shadWallBitMask;
					int shadBitAddrWallCopyTrans = shadWallBitAddr;
					background = shadWallDestAddr;
					shadowHero = (byte *)makeShadow->getBasePtr(shadWallSkipX, shadowHeroY);

					if (ct_loop > shadWallSkipX && ct_loop - shadWallSkipX > shadWallModulo) {
						//WALL_copy_trans
						shadWDFlag = false;
						int shadZoomXWall = _scaleValue;
						int backgroundDiffWall = 0;
						int shadowHeroXWall = 0;
						//ct_loop:
						for (int m = 0; m < ct_loop; m++) {
							shadZoomXWall -= 100;
							if (shadZoomXWall < 0 && _scaleValue != 10000) {
								shadZoomXWall += _scaleValue;
							} else {
								//point_ok:
								if (*shadowHero == _graph->kShadowColor) {
									if ((shadBitMaskWallCopyTrans & _shadowBitmap[shadBitAddrWallCopyTrans + kShadowBitmapSize]) != 0) {
										*background = *(sprShadow + *background);
									}
								}
								//ct_next
								if (shadBitMaskWallCopyTrans == 1) {
									shadBitMaskWallCopyTrans = 128;
									shadBitAddrWallCopyTrans++;
								} else {
									shadBitMaskWallCopyTrans >>= 1;
								}
								//okok
								backgroundDiffWall++;
								background = shadWallDestAddr + backgroundDiffWall;
							}
							shadowHeroXWall++;
							shadowHero = (byte *)makeShadow->getBasePtr(shadWallSkipX + shadowHeroXWall, shadowHeroY);
						}
					}
					//krap2
					shadWallDestAddr -= kScreenWidth;
					shadWallBitAddr -= kMaxPicWidth / 8;
					shadWallPosY--;
				}
			}
			//skip_line
			//next_line
			if (*(shadowLineStart + 2) < *(shadowLineStart - 2)) {
				//minus_y
				shadBitAddr -= kMaxPicWidth / 8;
				shadPosY--;
				diffY--;
			} else if (*(shadowLineStart + 2) > *(shadowLineStart - 2)) {
				shadBitAddr += kMaxPicWidth / 8;
				shadPosY++;
				diffY++;
			}
			//no_change_y
			if (*shadowLineStart < *(shadowLineStart - 4)) {
				//minus_x
				shadPosX--;
				//rol
				if (shadBitMask == 128) {
					shadBitMask = 1;
					shadBitAddr--;
				} else {
					shadBitMask <<= 1;
				}
				diffX--;
			} else if (*shadowLineStart > *(shadowLineStart - 4)) {
				shadPosX++;
				//ror
				if (shadBitMask == 1) {
					shadBitMask = 128;
					shadBitAddr++;
				} else {
					shadBitMask >>= 1;
				}
				diffX++;
			}
			//no_change_x
			shadowLineStart += 4;
			shadowHeroY--;
			if (shadowHeroY < 0) {
				break;
			}
			shadowHeroX = 0;
			background = (byte *)_graph->_frontScreen->getBasePtr(_shadDrawX + diffX, _shadDrawY + diffY);
			shadowHero = (byte *)makeShadow->getBasePtr(shadowHeroX, shadowHeroY);
		}
		//koniec_bajki - end_of_a_story
	}
	makeShadow->free();
	delete makeShadow;
}

void Hero::showHeroAnimFrame() {
	if (_phase < _moveSet[_moveSetType]->getFrameCount() - 1) {
		_phase++;
	} else {
		_phase = 0;
	}
	countDrawPosition();
}

void Hero::setScale(int8 zoomBitmapValue) {
	if (zoomBitmapValue == 0) {
		_zoomFactor = 0;
		_scaleValue = 10000;
	} else {
		_zoomFactor = zoomBitmapValue;
		_scaleValue = 10000 / _zoomFactor;
	}
}

void Hero::selectZoom() {
	int8 zoomBitmapValue = *(_zoomBitmap + _middleY / 4 * kZoomBitmapWidth + _middleX / 4);
	setScale(zoomBitmapValue);
}

void Hero::setShadowScale(int32 shadowScale) {
	shadowScale = 100 - shadowScale;
	if (shadowScale == 0) {
		_shadZoomFactor = 0;
		_shadScaleValue = 10000;
	} else {
		_shadZoomFactor = shadowScale;
		_shadScaleValue = 10000 / _shadZoomFactor;
	}
}

void Hero::specialAnim() {
}

void Hero::rotateHero() {
	switch (_lastDirection) {
	case LEFT:
		switch (_destDirection) {
		case RIGHT:
			_moveSetType = Move_MLR;
			break;
		case UP:
			_moveSetType = Move_MLU;
			break;
		case DOWN:
			_moveSetType = Move_MLD;
			break;
		}
		break;
	case RIGHT:
		switch (_destDirection) {
		case LEFT:
			_moveSetType = Move_MRL;
			break;
		case UP:
			_moveSetType = Move_MRU;
			break;
		case DOWN:
			_moveSetType = Move_MRD;
			break;
		}
		break;
	case UP:
		switch (_destDirection) {
		case LEFT:
			_moveSetType = Move_MUL;
			break;
		case RIGHT:
			_moveSetType = Move_MUR;
			break;
		case DOWN:
			_moveSetType = Move_MUD;
			break;
		}
		break;
	case DOWN:
		switch (_destDirection) {
		case LEFT:
			_moveSetType = Move_MDL;
			break;
		case RIGHT:
			_moveSetType = Move_MDR;
			break;
		case UP:
			_moveSetType = Move_MDU;
			break;
		}
		break;
	}
}

void Hero::showHero() {
	if (_visible) {
		// Is he talking?
		if (_talkTime == 0) { //?
			// Scale of hero
			selectZoom();
			switch (_state) {
			case STAY:
				//if(OptionsFlag == false) {
				//if(OpcodePC == null) {
				_boredomTime++;
				if (_boredomTime == 200) { // 140 for second hero
					_boredomTime = 0;
					_state = BORE;
				}
				switch (_lastDirection) {
				case LEFT:
					_moveSetType = Move_SL;
					break;
				case RIGHT:
					_moveSetType = Move_SR;
					break;
				case UP:
					_moveSetType = Move_SU;
					break;
				case DOWN:
					_moveSetType = Move_SD;
					break;
				}
				break;
			case TURN:
				/*
				if(_lastDirection == _destDirection) {
					_state = STAY;
				} else {
					_frame = 0;
					rotateHero();
					_lastDirection = _destDirection;
				}
				*/
				break;
			case MOVE:
				switch (_lastDirection) {
				case LEFT:
					_moveSetType = Move_ML;
					break;
				case RIGHT:
					_moveSetType = Move_MR;
					break;
				case UP:
					_moveSetType = Move_MU;
					break;
				case DOWN:
					_moveSetType = Move_MD;
					break;
				}
				break;
			case BORE:
				//if (_direction == UP) {
				switch (_boreNum) {
				case 0:
					_moveSetType = Move_BORED1;
					break;
				case 1:
					_moveSetType = Move_BORED2;
					break;
				}
				if (_phase == _moveSet[_moveSetType]->getFrameCount() - 1) {
					_boreNum = _vm->_randomSource.getRandomNumber(1); // rand one of two 'bored' animation
					_lastDirection = DOWN;
					_state = STAY;
				}
				break;
			case SPEC:
				//specialAnim();
				break;
			case TALK:
				switch (_lastDirection) {
				case LEFT:
					_moveSetType = Move_TL;
					break;
				case RIGHT:
					_moveSetType = Move_TR;
					break;
				case UP:
					_moveSetType = Move_TU;
					break;
				case DOWN:
					_moveSetType = Move_TD;
					break;
				}
				break;
			case TRAN:
				break;
			case RUN:
				break;
			case DMOVE:
				break;
			}
		} else {
			_talkTime--; // o ile?
		}
		showHeroAnimFrame();
	} else {
		// no hero visible
		return;
	}
}

void Hero::scrollHero() {
	//FLAGI+SCROLLTYPE ??
	//int scrollType = 0;
	int position = _middleX;

	/*
	switch (scrollType) {
	case 0:
		position = _middleX;
		break;
	case 1:
		break;
	case 2:
		break;
	}
	*/

	int locationWidth = _vm->_sceneWidth;
	int difference = locationWidth - _vm->kNormalWidth / 2;

	int destValue = 0;
	if (position > _vm->kNormalWidth / 2) {
		destValue = difference - _vm->kNormalWidth / 2;
	}
	if (position < difference) {
		destValue = position - _vm->kNormalWidth / 2;
	}
	if(destValue < 0) {
		destValue = 0;
	}
	_vm->_picWindowX = destValue;
	_drawX -= destValue;
}

}

/* vim: set tabstop=4 noexpandtab: */