aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/hotspots.cpp
blob: baa49dc102b401ae41695a1cb9f8ab680c5a1dd7 (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
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
/* 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.
 *
 * $URL$
 * $Id$
 *
 */

#include "gob/hotspots.h"
#include "gob/global.h"
#include "gob/helper.h"
#include "gob/draw.h"
#include "gob/game.h"
#include "gob/script.h"
#include "gob/inter.h"

namespace Gob {

Hotspots::Hotspot::Hotspot() {
	clear();
}

Hotspots::Hotspot::Hotspot(uint16 i,
		uint16 l, uint16 t, uint16 r, uint16 b, uint16 f, uint16 k,
		uint16 enter, uint16 leave, uint16 pos) {

	id        = i;
	left      = l;
	top       = t;
	right     = r;
	bottom    = b;
	flags     = f;
	key       = k;
	funcEnter = enter;
	funcLeave = leave;
	funcPos   = pos;
	script    = 0;
}

void Hotspots::Hotspot::clear() {
	id        = 0;
	left      = 0xFFFF;
	top       = 0;
	right     = 0;
	bottom    = 0;
	flags     = 0;
	key       = 0;
	funcEnter = 0;
	funcLeave = 0;
	funcPos   = 0;
	script    = 0;
}

Hotspots::Type Hotspots::Hotspot::getType() const {
	return (Type) (flags & 0xF);
}

MouseButtons Hotspots::Hotspot::getButton() const {
	uint8 buttonBits = ((flags & 0x70) >> 4);

	if (buttonBits == 0)
		return kMouseButtonsLeft;
	if (buttonBits == 1)
		return kMouseButtonsRight;
	if (buttonBits == 2)
		return kMouseButtonsAny;

	return kMouseButtonsNone;
}

uint16 Hotspots::Hotspot::getWindow() const {
	return (flags & 0x0F00);
}

uint8 Hotspots::Hotspot::getCursor() const {
	return (flags & 0xF000) >> 12;
}

uint8 Hotspots::Hotspot::getState(uint16 id) {
	return (id & 0xF000) >> 12;
}

uint8 Hotspots::Hotspot::getState() const {
	return getState(id);
}

bool Hotspots::Hotspot::isEnd() const {
	return (left == 0xFFFF);
}

bool Hotspots::Hotspot::isInput() const {
	if (getType() < kTypeInput1NoLeave)
		return false;

	if (getType() > kTypeInputFloatLeave)
		return false;

	return true;
}

bool Hotspots::Hotspot::isActiveInput() const {
	if (isEnd())
		return false;

	if (!isFilledEnabled())
		return false;

	if (!isInput())
		return false;

	return true;
}

bool Hotspots::Hotspot::isInputLeave() const {
	if (!isInput())
		return false;

	if (!(getType() & 1))
		return true;

	return false;
}

bool Hotspots::Hotspot::isFilled() const {
	return getState() & kStateFilled;
}

bool Hotspots::Hotspot::isFilledEnabled() const {
	return (getState() & kStateFilledDisabled) == kStateFilled;
}

bool Hotspots::Hotspot::isFilledNew() const {
	return getState() == kStateFilled;
}

bool Hotspots::Hotspot::isDisabled() const {
	return getState() & kStateDisabled;
}

bool Hotspots::Hotspot::isIn(uint16 x, uint16 y) const {
	// FIXME: the cast to int16 is a hack, to fix handling of Gob2 problems related to
	// hotspots with negative offset (to temporary disable them).
	if ((int16) x < (int16) left)
		return false;
	if ((int16) x > (int16) right)
		return false;
	if ((int16) y < (int16) top)
		return false;
	if ((int16) y > (int16) bottom)
		return false;

	return true;
}

bool Hotspots::Hotspot::buttonMatch(MouseButtons button) const {
	MouseButtons myButton = getButton();

	if (myButton == kMouseButtonsAny)
		// Any button allowed
		return true;

	if (myButton == kMouseButtonsNone)
		// No button allowed
		return false;

	if (myButton == button)
		// Exact match
		return true;

	return false;
}

void Hotspots::Hotspot::disable() {
	id |= (kStateDisabled << 12);
}

void Hotspots::Hotspot::enable() {
	id &= ~(kStateDisabled << 12);
}


Hotspots::Hotspots(GobEngine *vm) : _vm(vm) {
	_hotspots = new Hotspot[kHotspotCount];

	_shouldPush = false;

	_currentKey   = 0;
	_currentIndex = 0;
	_currentId    = 0;
}

Hotspots::~Hotspots() {
	delete[] _hotspots;

	// Pop the whole stack and free each element's memory
	while (!_stack.empty()) {

		StackEntry backup = _stack.pop();

		delete[] backup.hotspots;
	}
}

void Hotspots::clear() {
	_currentKey = 0;

	for (int i = 0; i < kHotspotCount; i++)
		_hotspots[i].clear();
}

uint16 Hotspots::add(uint16 id,
		uint16 left,  uint16 top, uint16 right, uint16 bottom,
		uint16 flags, uint16 key,
		uint16 funcEnter, uint16 funcLeave, uint16 funcPos) {

	Hotspot hotspot(id, left, top, right, bottom,
			flags, key, funcEnter, funcLeave, funcPos);

	return add(hotspot);
}

uint16 Hotspots::add(const Hotspot &hotspot) {
	for (int i = 0; i < kHotspotCount; i++) {
		Hotspot &spot = _hotspots[i];

		//     free space => add    same id => update
		if (! (spot.isEnd() || (spot.id == hotspot.id)))
			continue;

		// When updating, keep disabled state intact
		uint16 id = hotspot.id;
		if ((spot.id     & ~(kStateDisabled << 12)) ==
		     (hotspot.id & ~(kStateDisabled << 12)))
			id = spot.id;

		// Set
		spot    = hotspot;
		spot.id = id;

		// Remember the current script
		spot.script = _vm->_game->_script;

		debugC(1, kDebugHotspots, "Adding hotspot %03d: %3d+%3d+%3d+%3d - %04X, %04X, %04X - %5d, %5d, %5d",
				i, spot.left, spot.top, spot.right, spot.bottom,
				spot.id, spot.key, spot.flags, spot.funcEnter, spot.funcLeave, spot.funcPos);

		return i;
	}

	error("Hotspots::add(): Hotspot array full");
	return 0xFFFF;	// for compilers that don't support NORETURN
}

void Hotspots::remove(uint16 id) {
	for (int i = 0; i < kHotspotCount; i++) {
		if (_hotspots[i].id == id) {
			debugC(1, kDebugHotspots, "Removing hotspot %d: %X", i, id);
			_hotspots[i].clear();
		}
	}
}

void Hotspots::removeState(uint8 state) {
	for (int i = 0; i < kHotspotCount; i++) {
		Hotspot &spot = _hotspots[i];

		if (spot.getState() == state) {
			debugC(1, kDebugHotspots, "Removing hotspot %d: %X (by state %X)", i, spot.id, state);
			spot.clear();
		}
	}
}

void Hotspots::recalculate(bool force) {
	debugC(5, kDebugHotspots, "Recalculating hotspots");

	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		Hotspot &spot = _hotspots[i];

		if (!force && ((spot.flags & 0x80) != 0))
			// Not forcing a special hotspot
			continue;

		if (spot.funcPos == 0)
			// Simple coordinates don't need update
			continue;

		// Setting the needed script
		Script *curScript = _vm->_game->_script;

		_vm->_game->_script = spot.script;
		if (!_vm->_game->_script)
			_vm->_game->_script = curScript;

		// Calling the function that contains the positions
		_vm->_game->_script->call(spot.funcPos);

		// Calculate positions
		int16 left   = _vm->_game->_script->readValExpr();
		int16 top    = _vm->_game->_script->readValExpr();
		int16 width  = _vm->_game->_script->readValExpr();
		int16 height = _vm->_game->_script->readValExpr();

		// Re-read the flags too, if applicable
		uint16 flags = 0;
		if (spot.getState() == (kStateFilled | kStateType2))
			flags = _vm->_game->_script->readValExpr();

		// Apply backDelta, if needed
		if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != -1)) {
			left += _vm->_draw->_backDeltaX;
			top  += _vm->_draw->_backDeltaY;
		}

		// Clamping
		if (left < 0) {
			width += left;
			left   = 0;
		}
		if (top < 0) {
			height += top;
			top     = 0;
		}

		// Set the updated position
		spot.left   = left;
		spot.top    = top;
		spot.right  = left + width  - 1;
		spot.bottom = top  + height - 1;

		if (spot.getState() == (kStateFilled | kStateType2))
			spot.flags = flags;

		// Return
		_vm->_game->_script->pop();

		_vm->_game->_script = curScript;
	}
}

void Hotspots::push(uint8 all, bool force) {
	debugC(1, kDebugHotspots, "Pushing hotspots (%d, %d)", all, force);

	// Should we push at all?
	if (!_shouldPush && !force)
		return;

	// Count the hotspots
	uint32 size = 0;
	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		Hotspot &spot = _hotspots[i];

		     // Save all of them
		if ( (all == 1) ||
		     // Don't save the global ones
		    ((all == 0) && (spot.id >= 20)) ||
		     // Only save disabled ones
		    ((all == 2) && ((spot.getState() == (kStateFilledDisabled | kStateType1)) ||
		                    (spot.getState() == (kStateDisabled)) ||
		                    (spot.getState() == (kStateFilledDisabled | kStateType2))))) {
			size++;
		}

	}

	StackEntry backup;

	backup.shouldPush = _shouldPush;
	backup.size       = size;
	backup.key        = _currentKey;
	backup.id         = _currentId;
	backup.index      = _currentIndex;

	backup.hotspots = new Hotspot[size];

	// Copy the hotspots
	Hotspot *destPtr = backup.hotspots;
	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		Hotspot &spot = _hotspots[i];

		     // Save all of them
		if ( (all == 1) ||
		     // Don't save the global ones
		    ((all == 0) && (spot.id >= 20)) ||
		     // Only save disabled ones
		    ((all == 2) && ((spot.getState() == (kStateFilledDisabled | kStateType1)) ||
		                    (spot.getState() == (kStateDisabled)) ||
		                    (spot.getState() == (kStateFilledDisabled | kStateType2))))) {

			memcpy(destPtr, &spot, sizeof(Hotspot));
			destPtr++;

			spot.clear();
		}

	}

	// Reset current state
	_shouldPush   = false;
	_currentKey   = 0;
	_currentId    = 0;
	_currentIndex = 0;

	_stack.push(backup);
}

void Hotspots::pop() {
	debugC(1, kDebugHotspots, "Popping hotspots");

	assert(!_stack.empty());

	StackEntry backup = _stack.pop();

	// Find the end of the filled hotspot space
	int i;
	Hotspot *destPtr = _hotspots;
	for (i = 0; i < kHotspotCount; i++, destPtr++)
		if (destPtr->isEnd())
			break;

	if (((uint32) (kHotspotCount - i)) < backup.size)
		error("Hotspots::pop(): Not enough free space in the current Hotspot "
		      "array to pop %d elements (got %d)", backup.size, kHotspotCount - i);

	// Copy
	memcpy(destPtr, backup.hotspots, backup.size * sizeof(Hotspot));

	_shouldPush   = backup.shouldPush;
	_currentKey   = backup.key;
	_currentId    = backup.id;
	_currentIndex = backup.index;

	delete[] backup.hotspots;
}

bool Hotspots::isValid(uint16 key, uint16 id, uint16 index) const {
	if (index >= kHotspotCount)
		return false;

	if (key == 0)
		return false;

	if (!(Hotspot::getState(id) & kStateFilled))
		return false;

	return true;
}

void Hotspots::call(uint16 offset) {
	debugC(4, kDebugHotspots, "Calling hotspot function %d", offset);

	_vm->_game->_script->call(offset);

	_shouldPush = true;

	int16 stackSize = _stack.size();

	_vm->_inter->funcBlock(0);

	while (stackSize != _stack.size())
		pop();

	_shouldPush = false;

	_vm->_game->_script->pop();

	recalculate(false);
}

void Hotspots::enter(uint16 index) {
	debugC(2, kDebugHotspots, "Entering hotspot %d", index);

	if (index >= kHotspotCount) {
		warning("Hotspots::enter(): Index %d out of range", index);
		return;
	}

	Hotspot &spot = _hotspots[index];

	// If requested, write the ID into a variable
	if ((spot.getState() == (kStateFilled | kStateType1)) ||
	    (spot.getState() == (kStateFilled | kStateType2)))
		WRITE_VAR(17, -(spot.id & 0x0FFF));

	if (spot.funcEnter != 0)
		call(spot.funcEnter);
}

void Hotspots::leave(uint16 index) {
	debugC(2, kDebugHotspots, "Leaving hotspot %d", index);

	if (index >= kHotspotCount) {
		warning("Hotspots::leave(): Index %d out of range", index);
		return;
	}

	Hotspot &spot = _hotspots[index];

	// If requested, write the ID into a variable
	if ((spot.getState() == (kStateFilled | kStateType1)) ||
	    (spot.getState() == (kStateFilled | kStateType2)))
		WRITE_VAR(17, spot.id & 0x0FFF);

	if (spot.funcLeave != 0)
		call(spot.funcLeave);
}

int16 Hotspots::curWindow(int16 &dx, int16 &dy) const {
	if ((_vm->_draw->_renderFlags & 0x80)==0)
		return(0);
	for (int i = 0; i < 10; i++)
		if (_vm->_draw->_fascinWin[i].id != -1)
			if (_vm->_global->_inter_mouseX >= _vm->_draw->_fascinWin[i].left &&
				_vm->_global->_inter_mouseX < _vm->_draw->_fascinWin[i].left + _vm->_draw->_fascinWin[i].width &&
				_vm->_global->_inter_mouseY >= _vm->_draw->_fascinWin[i].top &&
				_vm->_global->_inter_mouseY < _vm->_draw->_fascinWin[i].top + _vm->_draw->_fascinWin[i].height)
				if (_vm->_draw->_fascinWin[i].id == _vm->_draw->_winCount-1) {
					dx = _vm->_draw->_fascinWin[i].left;
					dy = _vm->_draw->_fascinWin[i].top;
					if (_vm->_global->_inter_mouseX < _vm->_draw->_fascinWin[i].left + 12 &&
						_vm->_global->_inter_mouseY < _vm->_draw->_fascinWin[i].top  + 12 &&
						(VAR((_vm->_draw->_winVarArrayStatus / 4) + i) & 2))
						return(5);
					if (_vm->_global->_inter_mouseX >= _vm->_draw->_fascinWin[i].left + _vm->_draw->_fascinWin[i].width - 12 &&
						_vm->_global->_inter_mouseY < _vm->_draw->_fascinWin[i].top + 12 &&
						(VAR((_vm->_draw->_winVarArrayStatus / 4) + i) & 4))
						return(6);
					return(-i);
				}
	return(0);
}

uint16 Hotspots::checkMouse(Type type, uint16 &id, uint16 &index) const {
	id    = 0;
	index = 0;

	int16 dx = 0;
	int16 dy = 0;
	int16 winId = -1;

	if (_vm->getGameType() == kGameTypeFascination)
		winId = _vm->_draw->isOverWin(dx, dy);

	if (winId < 0) {
		winId = 0;
		dx = 0;
		dy = 0;
	} else
		winId *= 256;

	if (type == kTypeMove) {
		// Check where the mouse was moved to

		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
			const Hotspot &spot = _hotspots[i];

			if (spot.isDisabled())
				// Only consider enabled hotspots
				continue;

			if (spot.getType() > kTypeMove)
				// Only consider click and move hotspots
				continue;

			if (spot.getWindow() != winId)
				// Only check the current window
				continue;

			if (!spot.isIn(_vm->_global->_inter_mouseX - dx, _vm->_global->_inter_mouseY - dy))
				// If we're not in it, ignore it
				continue;

			id    = spot.id;
			index = i;

			return spot.key;
		}

		return 0;

	} else if (type == kTypeClick) {
		// Check if something was clicked

		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
			const Hotspot &spot = _hotspots[i];

			if (spot.isDisabled())
				// Only consider enabled hotspots
				continue;

			if (spot.getWindow() != winId)
				// Only check the active window
				continue;

			if (spot.getType() < kTypeMove)
				// Only consider hotspots that can be clicked
				continue;

			if (!spot.isIn(_vm->_global->_inter_mouseX - dx, _vm->_global->_inter_mouseY - dy))
				// If we're not in it, ignore it
				continue;

			if (!spot.buttonMatch(_vm->_game->_mouseButtons))
				// Don't follow hotspots with button requirements we don't meet
				continue;

			id    = spot.id;
			index = i;

			if ((spot.getType() == kTypeMove) || (spot.getType() == kTypeClick))
				// It's a move or click => return the key
				return spot.key;

			// Otherwise, the key has a different meaning, so ignore it
			return 0;
		}

		if (_vm->_game->_mouseButtons != kMouseButtonsLeft)
			// Let the right mouse button act as an escape key
			return kKeyEscape;

		return 0;

	}

	return 0;
}

bool Hotspots::checkHotspotChanged() {
	uint16 key, id, index;

	// Get the current hotspot
	key = checkMouse(kTypeMove, id, index);

	if (key == _currentKey)
		// Nothing changed => nothing to do
		return false;

	// Leave the old area
	if (isValid(_currentKey, _currentId,_currentIndex))
		leave(_currentIndex);

	_currentKey   = key;
	_currentId    = id;
	_currentIndex = index;

	// Enter the new one
	if (isValid(key, id, index))
		enter(index);

	return true;
}

uint16 Hotspots::check(uint8 handleMouse, int16 delay, uint16 &id, uint16 &index) {
	if (delay >= -1) {
		_currentKey   = 0;
		_currentId    = 0;
		_currentIndex = 0;
	}

	id    = 0;
	index = 0;

	if (handleMouse) {
		if ((_vm->_draw->_cursorIndex == -1) && (_currentKey == 0)) {
			// Last know state: No hotspot hit. Look if that changed

			_currentKey = checkMouse(kTypeMove, _currentId, _currentIndex);

			if (isValid(_currentKey, _currentId, _currentIndex))
				enter(_currentIndex);
		}
		_vm->_draw->animateCursor(-1);
	}

	uint32 startTime = _vm->_util->getTimeKey();

	// Update display
	_vm->_draw->blitInvalidated();
	_vm->_video->waitRetrace();

	uint16 key = 0;
	while (key == 0) {

		if (_vm->_inter->_terminate || _vm->shouldQuit()) {
			if (handleMouse)
				_vm->_draw->blitCursor();
			return 0;
		}

		// Anything changed?
		checkHotspotChanged();

		// Update display
		if (!_vm->_draw->_noInvalidated) {
			if (handleMouse)
				_vm->_draw->animateCursor(-1);
			else
				_vm->_draw->blitInvalidated();
			_vm->_video->waitRetrace();
		}

		if (handleMouse)
			_vm->_game->evaluateScroll();

		// Update keyboard and mouse state
		key = _vm->_game->checkKeys(&_vm->_global->_inter_mouseX,
				&_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons, handleMouse);

		if (!handleMouse && (_vm->_game->_mouseButtons != kMouseButtonsNone)) {
			// We don't want any mouse input but got one => Wait till it went away

			_vm->_util->waitMouseRelease(0);
			key = 3;
		}

		if (key != 0) {
			// Got a key press

			if (handleMouse & 1)
				_vm->_draw->blitCursor();

			id    = 0;
			index = 0;

			// Leave the current hotspot
			if (isValid(_currentKey, _currentId, _currentIndex))
				leave(_currentIndex);

			_currentKey = 0;
			break;
		}

		if (handleMouse) {

			if (_vm->_game->_mouseButtons != kMouseButtonsNone) {
				// Mouse button pressed
				int i;
				if (_vm->getGameType() == kGameTypeFascination)
					i = _vm->_draw->handleCurWin();
				else
					i = 0;
				if (!i) {
					_vm->_draw->animateCursor(2);
					if (delay > 0) {
						// If a delay was requested, wait the specified time
						_vm->_util->delay(delay);
					} else if (handleMouse & 1)
						_vm->_util->waitMouseRelease(1);

					_vm->_draw->animateCursor(-1);

					// Which region was clicked?
					key = checkMouse(kTypeClick, id, index);

					if ((key != 0) || (id != 0)) {
						// Got a valid region

						if ( (handleMouse & 1) &&
							  ((delay <= 0) || (_vm->_game->_mouseButtons == kMouseButtonsNone)))
							_vm->_draw->blitCursor();

						// If the hotspot changed, leave the old one
						if (key != _currentKey)
							leave(_currentIndex);

						_currentKey = 0;
						break;
					}

					if (handleMouse & 4)
						// Nothing further than one simple check was requested => return
						return 0;

					// Leave the current area
					if (_currentKey != 0)
						leave(_currentIndex);

					// No click, but do we have a move event? If so, enter that hotspot
					_currentKey = checkMouse(kTypeMove, _currentId, _currentIndex);
					if (isValid(_currentKey, _currentId, _currentIndex))
						enter(_currentIndex);
				} else {
					WRITE_VAR(16, (int32) i);
					if (id)
						id=0;
					if (index)
						index=0;
					return(0);
				}
			} else
				// No mouse button pressed, check whether the position changed at least
				checkHotspotChanged();
		}

		if ((delay == -2) && (key == 0) &&
		    (_vm->_game->_mouseButtons == kMouseButtonsNone)) {
			// Nothing found and no further handling requested. Return.

			id    = 0;
			index = 0;
			break;
		}

		if (handleMouse)
			_vm->_draw->animateCursor(-1);

		if ((delay < 0) && (key == 0) &&
		    (_vm->_game->_mouseButtons == kMouseButtonsNone)) {

			// Look if we've maybe reached the timeout

			uint32 curTime = _vm->_util->getTimeKey();
			if ((curTime + delay) > startTime) {
				// If so, return

				id    = 0;
				index = 0;
				break;
			}

		}

	// Sleep for a short amount of time
	_vm->_util->delay(10);

	}

	return key;
}

uint16 Hotspots::check(uint8 handleMouse, int16 delay) {
	uint16 id, index;

	// Check and ignore the id and index
	return Hotspots::check(handleMouse, delay, id, index);
}

uint16 Hotspots::updateInput(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
		uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
		Type type, int16 &duration, uint16 &id, uint16 &index) {

	if ((fontIndex >= Draw::kFontCount) || !_vm->_draw->_fonts[fontIndex]) {
		warning("Hotspots::updateInput(): Invalid font specified: %d", fontIndex);
		return 0;
	}

	// Check if we need to consider mouse events
	bool handleMouse = false;
	if ( (_vm->_game->_handleMouse != 0) &&
	    ((_vm->_global->_useMouse != 0) || (_vm->_game->_forceHandleMouse != 0)))
		handleMouse = true;

	const Font &font = *_vm->_draw->_fonts[fontIndex];

	// Current position in the string, preset to the end
	uint32 pos      = strlen(str);
	/* Size of input field in characters.
	 * If the font is not monospaced, we can't know that */
	uint32 editSize = font.isMonospaced() ? (width / font.getCharWidth()) : 0;

	uint16 key = 0;
	char tempStr[256];

	while (1) {
		// If we the edit field has enough space, add a space for the new character
		strncpy0(tempStr, str, 254);
		strcat(tempStr, " ");
		if ((editSize != 0) && strlen(tempStr) > editSize)
			strncpy0(tempStr, str, 255);

		// Clear input area
		fillRect(xPos, yPos,
		         font.isMonospaced() ? (editSize * font.getCharWidth()) : width, height,
		         backColor);

		// Print the current string, vertically centered
		printText(xPos, yPos + (height - font.getCharHeight()) / 2,
				tempStr, fontIndex, frontColor);

		// If we've reached the end of the input field, set the cursor to the last character
		if ((editSize != 0) && (pos == editSize))
			pos--;

		// The character under the cursor
		char curSym = tempStr[pos];

		if (_vm->_inter->_variables)
			WRITE_VAR(56, pos);

		bool first = true;
		while (1) {
			tempStr[0] = curSym;
			tempStr[1] = 0;

			// Draw cursor
			uint16 cursorX, cursorY, cursorWidth, cursorHeight;
			getTextCursorPos(font, str, pos, xPos, yPos, width, height,
					cursorX, cursorY, cursorWidth, cursorHeight);
			fillRect(cursorX, cursorY, cursorWidth, cursorHeight, frontColor);

			if (first) {
				// The first time, purge old information too
				key = check(handleMouse, -1, id, index);

				if (key == 0)
					// We didn't catch any input, let's try again with a real timeout
					key = check(handleMouse, -300, id, index);

				first = false;
			} else
				// Try to catch a character
				key = check(handleMouse, -300, id, index);

			tempStr[0] = curSym;
			tempStr[1] = 0;

			// Clear cursor
			getTextCursorPos(font, str, pos, xPos, yPos, width, height,
					cursorX, cursorY, cursorWidth, cursorHeight);
			fillRect(cursorX, cursorY, cursorWidth, cursorHeight, backColor);

			// Print the current string, vertically centered
			printText(cursorX, yPos + (height - font.getCharHeight()) / 2,
					tempStr, fontIndex, frontColor);

			if ((key != 0) || (id != 0))
				// We did get a key, stop looking
				break;

			// Try again
			key = check(handleMouse, -300, id, index);

			if ((key != 0) || (id != 0) ||
					_vm->_inter->_terminate || _vm->shouldQuit())
				// We did get a key, stop looking
				break;

			if (duration > 0) {
				// Look if we reached the time limit
				duration -= 600;
				if (duration <= 1) {
					// If so, abort
					key = 0;
					id  = 0;
					break;
				}
			}
		}

		if ((key == 0) || (id != 0) ||
				_vm->_inter->_terminate || _vm->shouldQuit())
			// Got no key, or a region ID instead, return
			return 0;

		switch (key) {
		case kKeyRight:
			// If possible, move the cursor right
			if (((editSize != 0) && ((pos > strlen(str)) || (pos > (editSize - 1)))) ||
			    ((editSize == 0) && (pos > strlen(str)))) {
				pos++;
				continue;
			}
			// Continue downwards instead
			return kKeyDown;

		case kKeyLeft:
			// If possible, move the cursor left
			if (pos > 0) {
				pos--;
				continue;
			}
			// Continue upwards instead
			return kKeyUp;

		case kKeyBackspace:
			if (pos > 0) {
				// Delete the character to the left
				_vm->_util->cutFromStr(str, pos - 1, 1);
				pos--;
				continue;
			} else {
				if (pos < strlen(str))
					// Delete the character to the right
					_vm->_util->cutFromStr(str, pos, 1);
			}

		case kKeyDelete:
			if (pos >= strlen(str))
				continue;

			// Delete the character to the right
			_vm->_util->cutFromStr(str, pos, 1);
			continue;

		case kKeyReturn:
		case kKeyF1:
		case kKeyF2:
		case kKeyF3:
		case kKeyF4:
		case kKeyF5:
		case kKeyF6:
		case kKeyF7:
		case kKeyF8:
		case kKeyF9:
		case kKeyF10:
		case kKeyUp:
		case kKeyDown:
			return key;

		case kKeyEscape:
			// If we got an escape event, wait until the mouse buttons have been released
			if (_vm->_global->_useMouse != 0)
				continue;

			_vm->_game->_forceHandleMouse = !_vm->_game->_forceHandleMouse;

			handleMouse = false;
			if ( (_vm->_game->_handleMouse != 0) &&
			    ((_vm->_global->_useMouse != 0) || (_vm->_game->_forceHandleMouse != 0)))
				handleMouse = true;

			while (_vm->_global->_pressedKeys[1] != 0)
				;
			continue;

		default:
			// Got a "normal" key

			uint16 savedKey = key;

			key &= 0xFF;

			if (((type == kTypeInputFloatNoLeave) || (type == kTypeInputFloatLeave)) &&
					 (key >= ' ') && (key <= 0xFF)) {

				// Only allow character found in numerical floating values

				const char *str1 = "0123456789-.,+ ";
				const char *str2 = "0123456789-,,+ ";

				if ((((savedKey >> 8) > 1) && ((savedKey >> 8) < 12)) &&
						((_vm->_global->_pressedKeys[42] != 0) ||
						 (_vm->_global->_pressedKeys[56] != 0)))
					key = ((savedKey >> 8) - 1) % 10 + '0';

				int i;
				for (i = 0; str1[i] != 0; i++) {
					if (key == str1[i]) {
						key = str2[i];
						break;
					}
				}

				if (i == (int16) strlen(str1))
					key = 0;
			}

			if ((key >= ' ') && (key <= 0xFF)) {
				if (editSize == 0) {
					// Length of the string + current character + next one
					int length = _vm->_draw->stringLength(str, fontIndex) +
						font.getCharWidth(' ') + font.getCharWidth(key);

					if (length > width)
						// We're above the limit, ignore the key
						continue;

					if (((int32) strlen(str)) >= (_vm->_global->_inter_animDataSize * 4 - 1))
						// Above the limit of character allowed in a string, ignore the key
						continue;

				} else {
					if (strlen(str) > editSize)
						// We're over the upper character limit for this field
						continue;
					else if (editSize == strlen(str))
						// We've reached the upper limit, overwrite the last character
						_vm->_util->cutFromStr(str, strlen(str) - 1, 1);
				}

				// Advance cursor
				pos++;
				tempStr[0] = key;
				tempStr[1] = 0;

				// Add character
				_vm->_util->insertStr(tempStr, str, pos - 1);
			}

		}
	}
}

uint16 Hotspots::handleInputs(int16 time, uint16 inputCount, uint16 &curInput,
		InputDesc *inputs, uint16 &id, uint16 &index) {

	// Redraw all texts in all inputs we currently manage
	updateAllTexts(inputs);

	for (int i = 0; i < 40; i++)
		WRITE_VAR(17 + i, 0);

	while (1) {
		// Find the hotspot index to our current input
		uint16 hotspotIndex = inputToHotspot(curInput);

		assert(hotspotIndex != 0xFFFF);

		Hotspot inputSpot = _hotspots[hotspotIndex];

		// Handle input events from that input field
		uint16 key = updateInput(inputSpot.left, inputSpot.top,
				inputSpot.right - inputSpot.left + 1,
				inputSpot.bottom - inputSpot.top + 1,
				inputs[curInput].backColor, inputs[curInput].frontColor,
				GET_VARO_STR(inputSpot.key), inputs[curInput].fontIndex,
				inputSpot.getType(), time, id, index);

		if (_vm->_inter->_terminate)
			return 0;

		switch (key) {
		case kKeyNone:
			if (id == 0)
				// No key and no hotspot => return
				return 0;

			if (_vm->_game->_mouseButtons != kMouseButtonsNone)
				// Clicked something, get the hotspot index
				index = findClickedInput(index);

			if (!_hotspots[index].isInput())
				// It's no input, return
				return 0;

			// Get the associated input index
			curInput = hotspotToInput(index);
			break;

		case kKeyF1:
		case kKeyF2:
		case kKeyF3:
		case kKeyF4:
		case kKeyF5:
		case kKeyF6:
		case kKeyF7:
		case kKeyF8:
		case kKeyF9:
		case kKeyF10:
			return key;

		case kKeyReturn:
			// Just one input => return
			if (inputCount == 1)
				return kKeyReturn;

			// End of input chain reached => wrap
			if (curInput == (inputCount - 1)) {
				curInput = 0;
				break;
			}

			// Next input
			curInput++;
			break;

		case kKeyDown:
			// Next input
			if ((inputCount - 1) > curInput)
				curInput++;
			break;

		case kKeyUp:
			// Previous input
			if (curInput > 0)
				curInput--;
			break;
		}
	}
}

void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
		uint16 &inputId, bool &hasInput, uint16 &inputCount) {

	ids[i] = 0;

	// Type and window
	byte type = _vm->_game->_script->readByte();
	byte window = 0;

	if ((type & 0x40) != 0) {
		// Got a window ID

		type  -= 0x40;
		window = _vm->_game->_script->readByte();
	}

	// Coordinates
	uint16 left, top, width, height, right, bottom;
	uint32 funcPos = 0;
	if ((type & 0x80) != 0) {
		// Complex coordinate expressions
		funcPos = _vm->_game->_script->pos();
		left    = _vm->_game->_script->readValExpr();
		top     = _vm->_game->_script->readValExpr();
		width   = _vm->_game->_script->readValExpr();
		height  = _vm->_game->_script->readValExpr();
	} else {
		// Immediate values
		funcPos = 0;
		left    = _vm->_game->_script->readUint16();
		top     = _vm->_game->_script->readUint16();
		width   = _vm->_game->_script->readUint16();
		height  = _vm->_game->_script->readUint16();
	}
	if (_vm->_draw->_renderFlags & 64) {
		warning("_renderFlags check added for Fascination");
		_vm->_draw->_invalidatedTops[0] = 0;
		_vm->_draw->_invalidatedLefts[0] = 0;
		_vm->_draw->_invalidatedRights[0] = 319;
		_vm->_draw->_invalidatedBottoms[0] = 199;
		_vm->_draw->_invalidatedCount = 1;
		if (window == 0) {
			_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0);
			_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0);
			_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0);
			_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0);
		} else
			if ((_vm->_draw->_fascinWin[window].id != -1) && (_vm->_draw->_fascinWin[window].id == _vm->_draw->_winCount - 1)) {
				left += _vm->_draw->_fascinWin[window].left;
				top  += _vm->_draw->_fascinWin[window].top;
				_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0);
				_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0);
				_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0);
				_vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0);
				left -= _vm->_draw->_fascinWin[window].left;
				top  -= _vm->_draw->_fascinWin[window].top;
			}
	}
	type &= 0x7F;

	// Apply global drawing offset
	if ((_vm->_draw->_renderFlags & RENDERFLAG_CAPTUREPOP) && (left != 0xFFFF)) {
		left += _vm->_draw->_backDeltaX;
		top  += _vm->_draw->_backDeltaY;
	}

	right  = left + width  - 1;
	bottom = top  + height - 1;

	// Enabling the hotspots again
	if ((type == kTypeEnable2) || (type == kTypeEnable1)) {
		uint8 wantedState = 0;
		if (type == kTypeEnable2)
			wantedState = kStateFilledDisabled | kStateType2;
		else
			wantedState = kStateFilledDisabled | kStateType1;

		_vm->_game->_script->skip(6);

		for (int j = 0; j < kHotspotCount; j++) {
			Hotspot &spot = _hotspots[j];

			if (spot.getState() == wantedState) {
				spot.enable();
				spot.funcEnter = _vm->_game->_script->pos();
				spot.funcLeave = _vm->_game->_script->pos();
			}
		}

		_vm->_game->_script->skipBlock();

		return;
	}

	int16 key   = 0;
	int16 flags = 0;
	Font *font = 0;
	uint32 funcEnter = 0, funcLeave = 0;

	// Evaluate parameters for the new hotspot
	switch (type) {
	case kTypeNone:
		_vm->_game->_script->skip(6);

		funcEnter = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		funcLeave = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		key   = i + ((kStateFilled | kStateType2) << 12);
		flags = type + (window << 8);
		break;

	case kTypeMove:
		key    = _vm->_game->_script->readInt16();
		ids[i] = _vm->_game->_script->readInt16();
		flags  = _vm->_game->_script->readInt16();

		funcEnter = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		funcLeave = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		if (key == 0)
			key = i + ((kStateFilled | kStateType2) << 12);

		flags = type + (window << 8) + (flags << 4);
		break;

	case kTypeInput1NoLeave:
	case kTypeInput1Leave:
	case kTypeInput2NoLeave:
	case kTypeInput2Leave:
	case kTypeInput3NoLeave:
	case kTypeInput3Leave:
	case kTypeInputFloatNoLeave:
	case kTypeInputFloatLeave:
		hasInput = true;

		_vm->_util->clearKeyBuf();

		// Input text parameters
		key                           = _vm->_game->_script->readVarIndex();
		inputs[inputCount].fontIndex  = _vm->_game->_script->readInt16();
		inputs[inputCount].backColor  = _vm->_game->_script->readByte();
		inputs[inputCount].frontColor = _vm->_game->_script->readByte();
		inputs[inputCount].length     = 0;
		inputs[inputCount].str        = 0;

		if ((type >= kTypeInput2NoLeave) && (type <= kTypeInput3Leave)) {
			uint16 length = _vm->_game->_script->readUint16();

			inputs[inputCount].str =
				(const char *) (_vm->_game->_script->getData() + _vm->_game->_script->pos());

			_vm->_game->_script->skip(length);
		}

		if (left == 0xFFFF) {
			if (!(type & 1))
				// No coordinates but a leave block => skip it
				_vm->_game->_script->skipBlock();
			break;
		}

		font = _vm->_draw->_fonts[inputs[inputCount].fontIndex];
		if (font->isMonospaced())
			right = left + width * font->getCharWidth() - 1;

		funcEnter = 0;
		funcPos   = 0;
		funcLeave = 0;
		if (!(type & 1)) {
			// Got a leave
			funcLeave = _vm->_game->_script->pos();
			_vm->_game->_script->skipBlock();
		}

		flags = type;

		inputCount++;
		break;

	case 20:
		inputId = i;
		// Fall through to case 2
	case kTypeClick:
		key    = _vm->_game->_script->readInt16();
		ids[i] = _vm->_game->_script->readInt16();
		flags  = _vm->_game->_script->readInt16();

		funcEnter = 0;

		funcLeave = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		flags = ((uint16) kTypeClick) + (window << 8) + (flags << 4);
		break;

	case kTypeClickEnter:
		key    = _vm->_game->_script->readInt16();
		ids[i] = _vm->_game->_script->readInt16();
		flags  = _vm->_game->_script->readInt16() & 3;

		funcEnter = _vm->_game->_script->pos();
		_vm->_game->_script->skipBlock();

		funcLeave = 0;

		flags = ((uint16) kTypeClick) + (window << 8) + (flags << 4);
		break;
	}

	// Add the new hotspot
	add(i | (kStateFilled << 12), left, top, right, bottom,
			flags, key, funcEnter, funcLeave, funcPos);
}

bool Hotspots::evaluateFind(uint16 key, int16 timeVal, const uint16 *ids,
		uint16 hotspotIndex1, uint16 hotspotIndex2, uint16 endIndex,
		int16 &duration, uint16 &id, uint16 &index, bool &finished) {

	if (id != 0)
		// We already found a hotspot, nothing to do
		return true;

	if (key != 0) {
		// We've got a key

		// Find the hotspot with that key associated
		findKey(key, id, index);
		if (id != 0)
			// Found it
			return true;

		// Try it case insensitively
		findKeyCaseInsensitive(key, id, index);
		if (id != 0)
			// Found it
			return true;

		return false;
	}

	if (duration != 0) {
		// We've got a time duration

		if        (hotspotIndex1 != 0) {
			finished =
				leaveNthPlain(hotspotIndex1, endIndex, timeVal, ids, id, index, duration);
		} else if (hotspotIndex2 != 0) {
			findNthPlain(hotspotIndex2, endIndex, id, index);
		} else {
			// Enter the first hotspot
			for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
				Hotspot &spot = _hotspots[i];
				if (spot.isFilledNew()) {
					id    = spot.id;
					index = i;
					break;
				}
			}

			// Leave the current hotspot
			if ((_currentKey != 0) && (_hotspots[_currentIndex].funcLeave != 0))
				call(_hotspots[_currentIndex].funcLeave);

			_currentKey = 0;
		}

		if (id != 0)
			return true;

		return false;
	}

	return false;
}

void Hotspots::evaluate() {
	InputDesc inputs[20];
	uint16 ids[kHotspotCount];

	// Push all local hotspots
	push(0);

	// Find the current end of the hotspot block
	uint16 endIndex = 0;
	while (!_hotspots[endIndex].isEnd())
		endIndex++;

	_shouldPush = false;

	_vm->_game->_script->skip(1);

	// Number of new hotspots
	byte count = _vm->_game->_script->readByte();

	// Parameters of this block
	_vm->_game->_handleMouse = _vm->_game->_script->peekByte(0);
	int16 duration           = _vm->_game->_script->peekByte(1);
	byte hotspotIndex1       = _vm->_game->_script->peekByte(3);
	byte hotspotIndex2       = _vm->_game->_script->peekByte(4);
	bool needRecalculation   = _vm->_game->_script->peekByte(5) != 0;

	// Seconds -> Milliseconds
	duration *= 1000;

	if ((hotspotIndex1 != 0) || (hotspotIndex2 != 0)) {
		duration /= 100;
		if (_vm->_game->_script->peekByte(1) == 100)
			duration = 2;
	}

	int16 timeVal = duration;

	_vm->_game->_script->skip(6);

	setCurrentHotspot(0, 0);

	bool finishedDuration = false;

	uint16 id      = 0;
	uint16 inputId = 0xFFFF;
	uint16 index   = 0;

	bool   hasInput   = false;
	uint16 inputCount = 0;

	// Adding new hotspots
	for (uint16 i = 0; i < count; i++)
		evaluateNew(i, ids, inputs, inputId, hasInput, inputCount);

	// Recalculate all hotspots if requested
	if (needRecalculation)
		recalculate(true);

	_vm->_game->_forceHandleMouse = 0;
	_vm->_util->clearKeyBuf();

	while ((id == 0) && !_vm->_inter->_terminate && !_vm->shouldQuit()) {
		uint16 key = 0;
		if (hasInput) {
			// Input

			uint16 curInput = 0;

			key = handleInputs(duration, inputCount, curInput, inputs, id, index);

			// Notify the script of the current input index
			WRITE_VAR(17 + 38, curInput);
			if (key == kKeyReturn) {
				// Return pressed, invoke input leave
				findFirstInputLeave(id, inputId, index);
				break;
			}
		} else
			// Normal move or click check
			key = check(_vm->_game->_handleMouse, -duration, id, index);

		key = convertSpecialKey(key);

		// Try to find a fitting hotspot
		Hotspots::evaluateFind(key, timeVal, ids, hotspotIndex1, hotspotIndex2, endIndex,
				duration, id, index, finishedDuration);

		if (finishedDuration)
			break;

		if ((id == 0) || (_hotspots[index].funcLeave != 0))
			// We don't have a new ID, but haven't yet handled the leave function
			continue;

		_vm->_inter->storeMouse();

		setCurrentHotspot(ids, id);

		// Enter it
		if (_hotspots[index].funcEnter != 0)
			call(_hotspots[index].funcEnter);

		setCurrentHotspot(0, 0);
		id = 0;
	}

	if ((id & 0xFFF) == inputId)
		matchInputStrings(inputs);

	if (_vm->_game->_handleMouse == 1)
		_vm->_draw->blitCursor();

	if (!_vm->_inter->_terminate && (!finishedDuration)) {
		_vm->_game->_script->seek(_hotspots[index].funcLeave);

		_vm->_inter->storeMouse();
		if (getCurrentHotspot() == 0) {
			// No hotspot currently handled, now we'll handle the newly found one

			setCurrentHotspot(ids, id);
		}
	} else
		_vm->_game->_script->setFinished(true);

	for (int i = 0; i < count; i++)
		// Remove all local hotspots
		remove(i + (kStateFilled << 12));

	for (int i = 0; i < kHotspotCount; i++) {
		Hotspot &spot = _hotspots[i];

		// Disable the ones still there
		if ((spot.getState() == (kStateFilled | kStateType1)) ||
				(spot.getState() == (kStateFilled | kStateType2)))
				spot.disable();
	}

}

int16 Hotspots::findCursor(uint16 x, uint16 y) const {
	int16 cursor = 0;

	int16 deltax = 0;
	int16 deltay = 0;

	if ( _vm->getGameType() == kGameTypeFascination ) {
		cursor = curWindow(deltax, deltay);
	}
	if (cursor == 0) {
		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
			const Hotspot &spot = _hotspots[i];

			if ((spot.getWindow() != 0) || spot.isDisabled())
				// Ignore disabled and non-main-windowed hotspots
				continue;

			if (!spot.isIn(x, y))
				// We're not in that hotspot, ignore it
				continue;

			if (spot.getCursor() == 0) {
				// Hotspot doesn't itself specify a cursor...
				if (spot.getType() >= kTypeInput1NoLeave) {
					// ...but the type has a generic one
					cursor = 3;
					break;
				} else if ((spot.getButton() != kMouseButtonsRight) && (cursor == 0))
					// ...but there's a generic "click" cursor
					cursor = 1;
			} else if (cursor == 0)
				// Hotspot had an attached cursor index
				cursor = spot.getCursor();
		}
	} else {
		if (cursor < 0) {
			int16 curType = - cursor * 256;
			cursor = 0;
			for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
				const Hotspot &spot = _hotspots[i];
				// this check is /really/ Fascination specific. 
				// It's illogical, so if it's to be reused in Adi games... Be careful!
				if ((spot.flags & 0xFF00) == curType)
					if (spot.isIn(x - deltax, y - deltay)) {
						if (spot.getType() < kTypeInput1NoLeave)
							cursor = 1;
						else
							cursor = 3;
						break;
					}
			}
		}
		if (_vm->_draw->_cursorAnimLow[cursor] == -1)
		// If the cursor is invalid... there's a generic "click" cursor
			cursor = 1;
	}

	return cursor;
}

void Hotspots::oPlaytoons_F_1B() {
	int16 shortId;
	int16 longId;
	int16 var2;
	int16 fontIndex;
	int16 var4;

	uint16 left;
	uint16 top;
	uint16 right;
	uint16 bottom;

	shortId = _vm->_game->_script->readValExpr();
	var2 = _vm->_game->_script->readValExpr();

	_vm->_game->_script->evalExpr(0);

	fontIndex = _vm->_game->_script->readValExpr();
	var4 = _vm->_game->_script->readValExpr();

//  this variable is always set to 0 in Playtoons
//	var_4 += unk_var;

	for (int i = 0; i < kHotspotCount; i++) {
		if (_hotspots[i].isEnd()) {
			return;
		}
		if ((_hotspots[i].id == 0xD000 + shortId) || (_hotspots[i].id == 0xB000 + shortId) ||
			(_hotspots[i].id == 0x4000 + shortId)) {
			longId = _hotspots[i].id;
			warning("oPlaytoons_F_1B: shortId %d, var2 %d fontIndex %d var4 %d - longId %d", shortId, var2, fontIndex, var4, longId);

			left = _hotspots[i].left;
			top = _hotspots[i].top;
			right = _hotspots[i].right;
			bottom = _hotspots[i].bottom;

			left += 2;
			top += 2;
			right -= 2;
			bottom -= 2;
			if ((_vm->_draw->_needAdjust != 2) && (_vm->_draw->_needAdjust != 10)) {
				left += 2;
				top += 2;
				right -= 2;
				bottom -= 2;
			}
//			oPlaytoons_sub_F_1B(0x8000 + var2, left, top, right, bottom, _vm->_game->_script->getResultStr(), var3, var4, shortId);
			_vm->_draw->oPlaytoons_sub_F_1B(0x8000+ var2, left, top, right, bottom, _vm->_game->_script->getResultStr(), fontIndex, var4, shortId);
			return;
		}
	}
	warning("shortId not found %d", shortId);
	return;
}

uint16 Hotspots::inputToHotspot(uint16 input) const {
	uint16 inputIndex = 0;
	for (int i = 0; i < kHotspotCount; i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isActiveInput())
			// Not an active input
			continue;

		if (inputIndex == input)
			// We've found our input
			return i;

		// Next one
		inputIndex++;
	}

	// None found
	return 0xFFFF;
}

uint16 Hotspots::hotspotToInput(uint16 hotspot) const {
	uint16 input = 0;

	for (int i = 0; i < kHotspotCount; i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isActiveInput())
			// Not an active input
			continue;

		if (i == hotspot)
			// We've found our hotspot
			break;

		// Next one
		input++;
	}

	return input;
}

uint16 Hotspots::findClickedInput(uint16 index) const {
	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		const Hotspot &spot = _hotspots[i];

		if (spot.getWindow() != 0)
			// Ignore other windows
			continue;

		if (spot.isDisabled())
			// Ignore disabled hotspots
			continue;

		if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
			// This one wasn't it
			continue;

		if (spot.getCursor() != 0)
			// This one specifies a cursor, so we don't want it
			continue;

		if (!spot.isInput())
			// It's no input
			continue;

		index = i;
		break;
	}

	return index;
}

bool Hotspots::findFirstInputLeave(uint16 &id, uint16 &inputId, uint16 &index) const {
	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isFilledEnabled())
			// Not filled or disabled
			continue;

		if (!spot.isInputLeave())
			// Not an input with a leave function
			continue;

		id      = spot.id;
		inputId = spot.id & 0x7FFF;
		index   = i;
		return true;
	}

	return false;
}

bool Hotspots::findKey(uint16 key, uint16 &id, uint16 &index) const {
	id    = 0;
	index = 0;

	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isFilledEnabled())
			// Not filled or disabled
			continue;

		//      Key match              Catch all
		if ((spot.key == key) || (spot.key == 0x7FFF)) {
			id    = spot.id;
			index = i;
			return true;
		}
	}

	return false;
}

bool Hotspots::findKeyCaseInsensitive(uint16 key, uint16 &id, uint16 &index) const {
	id    = 0;
	index = 0;

	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isFilledEnabled())
			// Not filled or disabled, ignore
			continue;

		if ((spot.key & 0xFF00) != 0)
			continue;

		if (spot.key == 0)
			// No associated key, ignore
			continue;

		// Compare
		if (toupper(key & 0xFF) == toupper(spot.key)) {
			id    = spot.id;
			index = i;
			return true;
		}
	}

	return false;
}

bool Hotspots::findNthPlain(uint16 n, uint16 startIndex, uint16 &id, uint16 &index) const {
	id    = 0;
	index = 0;

	uint16 counter = 0;
	for (int i = startIndex; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
		const Hotspot &spot = _hotspots[i];

		if (!spot.isFilledNew())
			// Not filled, ignore
			continue;

		if (++counter != n)
			// Not yet the one we want
			continue;

		id    = spot.id;
		index = i;
		return true;
	}

	return false;
}

bool Hotspots::leaveNthPlain(uint16 n, uint16 startIndex, int16 timeVal, const uint16 *ids,
		uint16 &id, uint16 &index, int16 &duration) {

	id    = 0;
	index = 0;

	if (!findNthPlain(n, startIndex, id, index))
		// Doesn't exist
		return false;

	_vm->_inter->storeMouse();

	if (getCurrentHotspot() != 0)
		// We already handle a hotspot
		return false;

	setCurrentHotspot(ids, id);

	const Hotspot &spot = _hotspots[index];
	if (spot.funcLeave != 0) {
		// It has a leave function

		uint32 startTime, callTime;

		// Call the leave and time it
		startTime = _vm->_util->getTimeKey();
		call(spot.funcLeave);
		callTime = _vm->_util->getTimeKey() - startTime;

		// Remove the time it took from the time we have available
		duration = CLIP<int>(timeVal - callTime, 2, timeVal);
	}

	if (getCurrentHotspot() == 0) {
		id    = 0;
		index = 0;
	}

	return getCurrentHotspot() != 0;
}

void Hotspots::setCurrentHotspot(const uint16 *ids, uint16 id) const {
	if (!ids) {
		WRITE_VAR(16, 0);
		return;
	}

	if (Hotspot::getState(id) == kStateFilled)
		WRITE_VAR(16, ids[id & 0xFFF]);
	else
		WRITE_VAR(16, id & 0xFFF);
}

uint32 Hotspots::getCurrentHotspot() const {
	return VAR(16);
}

void Hotspots::cleanFloatString(const Hotspot &spot) const {
	char *to, *from;

	to = from = GET_VARO_STR(spot.key);
	for (int i = 0; (i < 257) && (*from != '\0'); i++, from++) {
		char c = *from;

		// Skip spaces
		if (c == ' ')
			continue;

		// Convert decimal separator if necessary
		if ((_vm->_global->_language == kLanguageBritish) && (c == '.'))
			c = ',';

		*to++ = c;
	}

	*to = '\0';
}

void Hotspots::checkStringMatch(const Hotspot &spot, const InputDesc &input,
		uint16 inputPos) const {

	const char *str = input.str;

	char tempStr[256];
	char spotStr[256];

	strncpy0(tempStr, GET_VARO_STR(spot.key), 255);

	if (spot.getType() < kTypeInput3NoLeave)
		_vm->_util->cleanupStr(tempStr);

	uint16 pos = 0;
	do {
		strncpy0(spotStr, str, 255);

		pos += strlen(str) + 1;
		str += strlen(str) + 1;

		if (spot.getType() < kTypeInput3NoLeave)
			_vm->_util->cleanupStr(spotStr);

		// Compare the entered string with the string we wanted
		if (strcmp(tempStr, spotStr) == 0) {
			WRITE_VAR(17, VAR(17) + 1);
			WRITE_VAR(17 + inputPos, 1);
			break;
		}
	} while (input.length > pos);
}

void Hotspots::matchInputStrings(const InputDesc *inputs) const {
	uint16 strInputCount = 0;
	uint16 inputIndex    = 0;
	uint16 inputPos      = 1;

	for (int i = 0; i < kHotspotCount; i++) {
		const Hotspot &spot = _hotspots[i];

		// Looking for all enabled inputs
		if (spot.isEnd())
			continue;
		if (!spot.isFilledEnabled())
			continue;
		if (!spot.isInput())
			continue;

		if (spot.getType() >= kTypeInputFloatNoLeave)
			cleanFloatString(spot);

		if ((spot.getType() >= kTypeInput2NoLeave) && (spot.getType() <= kTypeInput3Leave)) {

			// Look if we find a match between the wanted and the typed string
			checkStringMatch(spot, inputs[inputIndex], inputPos);
			strInputCount++;
		} else
			WRITE_VAR(17 + inputPos, 2);

		inputIndex++;
		inputPos++;
	}

	// Notify the scripts if we reached the requested hotspot
	WRITE_VAR(17, (uint32) (strInputCount == ((uint16) VAR(17))));
}

uint16 Hotspots::convertSpecialKey(uint16 key) const {
	if (((key & 0xFF) >= ' ') && ((key & 0xFF) <= 0xFF) &&
			((key >> 8) > 1) && ((key >> 8) < 12))
		key = '0' + (((key >> 8) - 1) % 10) + (key & 0xFF00);

	return key;
}

void Hotspots::getTextCursorPos(const Font &font, const char *str,
		uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
		uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const {

	if (!font.isMonospaced()) {
		// Cursor to the right of the current character

		cursorX      = x;
		cursorY      = y;
		cursorWidth  = 1;
		cursorHeight = height;

		// Iterate through the string and add each character's width
		for (uint32 i = 0; i < pos; i++)
			cursorX += font.getCharWidth(str[i]);

	} else {
		// Cursor underlining the current character

		cursorX      = x + font.getCharWidth() * pos;
		cursorY      = y + height - 1;
		cursorWidth  = font.getCharWidth();
		cursorHeight = 1;
	}
}

void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const {
	_vm->_draw->_destSurface  = 21;
	_vm->_draw->_destSpriteX  = x;
	_vm->_draw->_destSpriteY  = y;
	_vm->_draw->_spriteRight  = width;
	_vm->_draw->_spriteBottom = height;
	_vm->_draw->_backColor    = color;

	_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
}

void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {
	_vm->_draw->_destSpriteX  = x;
	_vm->_draw->_destSpriteY  = y;
	_vm->_draw->_frontColor   = color;
	_vm->_draw->_fontIndex    = fontIndex;
	_vm->_draw->_textToPrint  = str;
	_vm->_draw->_transparency = 1;

	_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
}

void Hotspots::updateAllTexts(const InputDesc *inputs) const {
	uint16 input = 0;

	for (int i = 0; i < kHotspotCount; i++) {
		const Hotspot &spot = _hotspots[i];

		if (spot.isEnd())
			// It's an end, we don't want it
			continue;

		if (!spot.isFilledEnabled())
			// This one's either not used or disabled
			continue;

		if (!spot.isInput())
			// Not an input
			continue;

		// Get its text
		char tempStr[256];
		strncpy0(tempStr, GET_VARO_STR(spot.key), 255);

		// Coordinates
		uint16 x      = spot.left;
		uint16 y      = spot.top;
		uint16 width  = spot.right  - spot.left + 1;
		uint16 height = spot.bottom - spot.top  + 1;
		// Clear the background
		fillRect(x, y, width, height, inputs[input].backColor);

		// Center the text vertically
		y += (height - _vm->_draw->_fonts[_vm->_draw->_fontIndex]->getCharHeight()) / 2;

		// Draw it
		printText(x, y, tempStr, inputs[input].fontIndex, inputs[input].frontColor);

		input++;
	}
}
} // End of namespace Gob