aboutsummaryrefslogtreecommitdiff
path: root/engines/lilliput/script.cpp
blob: 8ba4253453295959d0c9412d34b71c2011ab98b7 (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
/* 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 "lilliput/lilliput.h"
#include "lilliput/script.h"
#include "common/debug.h"

namespace Lilliput {

LilliputScript::LilliputScript(LilliputEngine *vm) : _vm(vm), _currScript(NULL) {
	_byte129A0 = 0xFF;
	_byte16F08 = 0;
	_byte1855D = 0;
	_byte12A04 = 0;
	_byte10806 = 0;
	_byte12FE4 = 0xFF;

	_word1855E = 0;
	_word16F00 = -1;
	_word10802 = -1;
	_word10804 = 0;
	_word15FFB = 0;
	_word15FFD = 0;
	_word12A00 = 0;
	_word12A02 = 0;

	_savedBuffer215Ptr = NULL;

	for (int i = 0; i < 20; i++) {
		_array122E9[i] = 0;
		_array122FD[i] = 0;
	}

	for (int i = 0; i < 40; i++) {
		_array10B29[i] = 1;
		_array128EF[i] = 15;
		_array10AB1[i] = 0;
		_array12811[i] = 16;
	}
}

LilliputScript::~LilliputScript() {
}

byte LilliputScript::handleOpcodeType1(int curWord) {
	debugC(2, kDebugScript, "handleOpcodeType1(0x%x)", curWord);
	switch (curWord) {
	case 0x0:
		return OC_sub173DF();
		break;
	case 0x1:
		return OC_sub173F0();
		break;
	case 0x2:
		return OC_sub1740A();
		break;
	case 0x3:
		return OC_sub17434();
		break;
	case 0x4:
		return OC_sub17468();
		break;
	case 0x5:
		return OC_getRandom();
		break;
	case 0x6:
		return OC_sub1748C();
		break;
	case 0x7:
		return OC_compWord18776();
		break;
	case 0x8:
		return OC_checkSaveFlag();
		break;
	case 0x9:
		return OC_sub174C8();
		break;
	case 0xA:
		return OC_sub174D8();
		break;
	case 0xB:
		return OC_sub1750E();
		break;
	case 0xC:
		return OC_compareCoords_1();
		break;
	case 0xD:
		return OC_compareCoords_2();
		break;
	case 0xE:
		return OC_sub1757C();
		break;
	case 0xF:
		return OC_sub1759E();
		break;
	case 0x10:
		return OC_compWord16EF8();
		break;
	case 0x11:
		return OC_sub175C8();
		break;
	case 0x12:
		return OC_sub17640();
		break;
	case 0x13:
		return OC_sub176C4();
		break;
	case 0x14:
		return OC_compWord10804();
		break;
	case 0x15:
		return OC_sub17766();
		break;
	case 0x16:
		return OC_sub17782();
		break;
	case 0x17:
		return OC_sub1779E();
		break;
	case 0x18:
		return OC_sub177C6();
		break;
	case 0x19:
		return OC_compWord16EFE();
		break;
	case 0x1A:
		return OC_sub177F5();
		break;
	case 0x1B:
		return OC_sub17812();
		break;
	case 0x1C:
		return OC_sub17825();
		break;
	case 0x1D:
		return OC_sub17844();
		break;
	case 0x1E:
		return OC_sub1785C();
		break;
	case 0x1F:
		return OC_sub17886();
		break;
	case 0x20:
		return OC_sub178A8();
		break;
	case 0x21:
		return OC_sub178BA();
		break;
	case 0x22:
		return OC_sub178C2();
		break;
	case 0x23:
		return OC_sub178D2();
		break;
	case 0x24:
		return OC_sub178E8();
		break;
	case 0x25:
		return OC_sub178FC();
		break;
	case 0x26:
		return OC_sub1790F();
		break;
	case 0x27:
		return OC_sub1792A();
		break;
	case 0x28:
		return OC_sub1793E();
		break;
	case 0x29:
		return OC_sub1795E();
		break;
	case 0x2A:
		return OC_sub1796E();
		break;
	case 0x2B:
		return OC_sub17984();
		break;
	case 0x2C:
		return OC_checkSavedMousePos();
		break;
	case 0x2D:
		return OC_sub179AE();
		break;
	case 0x2E:
		return OC_sub179C2();
		break;
	case 0x2F:
		return OC_sub179E5();
		break;
	case 0x30:
		return OC_sub17A07();
		break;
	case 0x31:
		return OC_sub17757();
		break;
	default:
		error("Unexpected opcode %d", curWord);
		break;
	}
}

void LilliputScript::handleOpcodeType2(int curWord) {
	debugC(2, kDebugScript, "handleOpcodeType2(0x%x)", curWord);
	switch (curWord) {
	case 0x0:
		OC_setWord18821();
		break;
	case 0x1:
		OC_sub17A3E();
		break;
	case 0x2:
		OC_sub17D57();
		break;
	case 0x3:
		OC_sub17D7F();
		break;
	case 0x4:
		OC_sub17DB9();
		break;
	case 0x5:
		OC_sub17DF9();
		break;
	case 0x6:
		OC_sub17E07();
		break;
	case 0x7:
		OC_sub17E15();
		break;
	case 0x8:
		OC_sub17B03();
		break;
	case 0x9:
		OC_getRandom_type2();
		break;
	case 0xA:
		OC_sub17A66();
		break;
	case 0xB:
		OC_sub17A8D();
		break;
	case 0xC:
		OC_saveAndQuit();
		break;
	case 0xD:
		OC_sub17B93();
		break;
	case 0xE:
		OC_sub17E37();
		break;
	case 0xF:
		OC_resetByte1714E();
		break;
	case 0x10:
		OC_deleteSavegameAndQuit();
		break;
	case 0x11:
		OC_incByte16F04();
		break;
	case 0x12:
		OC_sub17BA5();
		break;
	case 0x13:
		OC_setByte18823();
		break;
	case 0x14:
		OC_sub17BB7();
		break;
	case 0x15:
		OC_sub17BF2();
		break;
	case 0x16:
		OC_sub17ACC();
		break;
	case 0x17:
		OC_resetByte16F04();
		break;
	case 0x18:
		OC_sub17AE1();
		break;
	case 0x19:
		OC_sub17AEE();
		break;
	case 0x1A:
		OC_setWord10804();
		break;
	case 0x1B:
		OC_sub17C0E();
		break;
	case 0x1C:
		OC_sub17C55();
		break;
	case 0x1D:
		OC_sub17C76();
		break;
	case 0x1E:
		OC_sub17AFC();
		break;
	case 0x1F:
		OC_sub17C8B();
		break;
	case 0x20:
		OC_sub17CA2();
		break;
	case 0x21:
		OC_sub17CB9();
		break;
	case 0x22:
		OC_sub17CD1();
		break;
	case 0x23:
		OC_resetWord16EFE();
		break;
	case 0x24:
		OC_sub17CEF();
		break;
	case 0x25:
		OC_sub17D1B();
		break;
	case 0x26:
		OC_sub17D23();
		break;
	case 0x27:
		OC_sub17E6D();
		break;
	case 0x28:
		OC_sub17E7E();
		break;
	case 0x29:
		OC_sub17E99();
		break;
	case 0x2A:
		OC_sub17EC5();
		break;
	case 0x2B:
		OC_sub17EF4();
		break;
	case 0x2C:
		OC_sub17F08();
		break;
	case 0x2D:
		OC_sub17F4F();
		break;
	case 0x2E:
		OC_sub17F68();
		break;
	case 0x2F:
		OC_getNextVal();
		break;
	case 0x30:
		OC_sub17FD2();
		break;
	case 0x31:
		OC_sub17FDD();
		break;
	case 0x32:
		OC_setByte10B29();
		break;
	case 0x33:
		OC_sub18007();
		break;
	case 0x34:
		OC_sub18014();
		break;
	case 0x35:
		OC_sub1801D();
		break;
	case 0x36:
		OC_sub1805D();
		break;
	case 0x37:
		OC_sub18074();
		break;
	case 0x38:
		OC_sub1808B();
		break;
	case 0x39:
		OC_sub18099();
		break;
	case 0x3A:
		OC_sub180C3();
		break;
	case 0x3B:
		OC_sub1810A();
		break;
	case 0x3C:
		OC_sub1812D();
		break;
	case 0x3D:
		OC_sub1817F();
		break;
	case 0x3E:
		OC_sub181BB();
		break;
	case 0x3F:
		OC_sub18213();
		break;
	case 0x40:
		OC_sub18252();
		break;
	case 0x41:
		OC_sub18260();
		break;
	case 0x42:
		OC_sub182EC();
		break;
	case 0x43:
		OC_unkPaletteFunction_1();
		break;
	case 0x44:
		OC_unkPaletteFunction_2();
		break;
	case 0x45:
		OC_loadAndDisplayCUBESx_GFX();
		break;
	case 0x46:
		OC_sub1834C();
		break;
	case 0x47:
		OC_sub18359();
		break;
	case 0x48:
		OC_sub18367();
		break;
	case 0x49:
		OC_sub17D04();
		break;
	case 0x4A:
		OC_sub18387();
		break;
	case 0x4B:
		OC_setByte14835();
		break;
	case 0x4C:
		OC_setByte14837();
		break;
	case 0x4D:
		OC_sub183A2();
		break;
	case 0x4E:
		OC_sub183C6();
		break;
	case 0x4F:
		OC_loadFile_AERIAL_GFX();
		break;
	case 0x50:
		OC_sub17E22();
		break;
	case 0x51:
		OC_sub1844A();
		break;
	case 0x52:
		OC_sub1847F();
		break;
	case 0x53:
		OC_displayVGAFile();
		break;
	case 0x54:
		OC_sub184D7();
		break;
	case 0x55:
		OC_displayTitleScreen();
		break;
	case 0x56:
		OC_sub1853B();
		break;
	case 0x57:
		OC_sub1864D();
		break;
	case 0x58:
		OC_initArr18560();
		break;
	case 0x59:
		OC_sub18678();
		break;
	case 0x5A:
		OC_sub18690();
		break;
	case 0x5B:
		OC_setWord10802();
		break;
	case 0x5C:
		OC_sub186A1();
		break;
	case 0x5D:
		OC_sub186E5_snd();
		break;
	case 0x5E:
		OC_sub1870A_snd();
		break;
	case 0x5F:
		OC_sub18725_snd();
		break;
	case 0x60:
		OC_sub18733_snd();
		break;
	case 0x61:
		OC_sub1873F_snd();
		break;
	case 0x62:
		OC_sub18746_snd();
		break;
	case 0x63:
		OC_sub1875D_snd();
		break;
	case 0x64:
		OC_sub18764();
		break;
	case 0x65:
		OC_sub1853B();
		break;
	default:
		error("Unknown opcode %d", curWord);
		break;
	}
}

int LilliputScript::handleOpcode(Common::MemoryReadStream *script) {
	debugC(2, kDebugScript, "handleOpcode");
	_currScript = script;
	uint16 curWord = _currScript->readUint16LE();
	if (curWord == 0xFFF6)
		return 0xFF;

	for (; curWord != 0xFFF8; curWord = _currScript->readUint16LE()) {
		byte mask = 0; 
		if (curWord > 1000) {
			curWord -= 1000;
			mask = 1;
		}
		byte result = handleOpcodeType1(curWord);
		if ((result ^ mask) == 0) {
			do {
				curWord = _currScript->readUint16LE();
			} while (curWord != 0xFFF7);
			return 0;
		}
	}

	_vm->_byte1714E = 1;

	for (;;) {
		curWord = _currScript->readUint16LE();
		if (curWord == 0xFFF7)
			return _vm->_byte1714E;

		handleOpcodeType2(curWord);
	}
}

void LilliputScript::runScript(Common::MemoryReadStream script) {
	debugC(1, kDebugScript, "runScript");
	_byte16F05_ScriptHandler = 1;
	
	while (handleOpcode(&script) != 0xFF)
		;
}

void LilliputScript::runMenuScript(Common::MemoryReadStream script) {
	debugC(1, kDebugScript, "runMenuScript");
	warning("========================== Menu Script ==============================");
	_byte16F05_ScriptHandler = 0;
	
	while (handleOpcode(&script) == 0)
		;
}

void LilliputScript::sub185ED(byte index, byte subIndex) {
	debugC(2, kDebugScript, "sub185ED");
	if (_vm->_arr18560[index]._field0 != 1)
		return;

	warning("TODO: display function #1");
}

byte LilliputScript::compareValues(byte var1, int oper, int var2) {
	debugC(2, kDebugScript, "compareValues(%d, %c, %d)", var1, oper & 0xFF, var2);
	switch (oper & 0xFF) {
	case '<':
		return (var1 < var2);
	case '>':
		return (var1 > var2);
	default:
		return (var1 == var2);
		break;
	}
}

void LilliputScript::computeOperation(byte *bufPtr, int oper, int var2) {
	debugC(1, kDebugScript, "computeOperation(bufPtr, %c, %d)", oper & 0xFF, var2 & 0xFF);

	switch (oper & 0xFF) {
	case '=':
		bufPtr[0] = var2 & 0xFF;
		break;
	case '+': {
		int tmpVal = bufPtr[0] + var2;
		if (tmpVal > 0xFF)
			bufPtr[0] = 0xFF;
		else
			bufPtr[0] = (byte)tmpVal;
		}
		break;
	case '-': {
		int tmpVal = bufPtr[0] - var2;
		if (tmpVal < 0)
			bufPtr[0] = 0;
		else
			bufPtr[0] = (byte)tmpVal;
		}
		break;
	case '*': {
		int tmpVal = bufPtr[0] * var2;
		bufPtr[0] = tmpVal & 0xFF;
		}
		break;
	case '/': {
		if (var2 != 0)
			bufPtr[0] /= var2;
		}
		break;
	default: {
		warning("computeOperation : oper %d", oper);
		if (var2 != 0) {
			byte tmpVal = bufPtr[0] / var2;
			if (tmpVal < 0)
				bufPtr[0] = 0xFF;
			else 
				bufPtr[0] = 0;
		}
		break;
		}
	}
}

void LilliputScript::sub185B4_display() {
	if (_byte12A04 == _byte1855D)
		return;

	_byte1855D = _byte12A04;
	
	assert(_word1855E < 8);
	int subIndex = _word1855E;
	sub185ED(0, subIndex);
	sub185ED(1, subIndex);
	sub185ED(2, subIndex);
	sub185ED(3, subIndex);

	// In the original, increment by 2 as it's an array of words
	++subIndex;
	if (subIndex == 8)
		subIndex = 0;

	_word1855E = subIndex;
}

void LilliputScript::sub1823E(byte var1, byte var2, byte *curBufPtr) {
	debugC(1, kDebugScript, "sub1823E(%d, %d, curBufPtr)", var1, var2);

	assert ((var1 >= 0) && (var1 < 40));
	_array10B29[var1] = 0;
	curBufPtr[0] = var2;
	curBufPtr[1] = 0;
	curBufPtr[2] = 0;
	curBufPtr[3] = 0;
}

void LilliputScript::sub17B6C(int var1) {
	debugC(1, kDebugScript, "sub17B6C(%d)", var1);

	if (var1 == 0) {
		int curWord = 0;
		while (curWord != 0xFFF6)
			curWord = _currScript->readUint16LE();
		
		_currScript->seek(_currScript->pos() - 4);
		return;
	}

	++var1;
	int curVal = 0;
	int tmpVal;
	while (curVal < var1) {
		tmpVal = _currScript->readUint16LE();
		if (tmpVal == 0xFFF7)
			++curVal;
	}

	_currScript->seek(_currScript->pos() - 2);
}

int LilliputScript::getValue1() {
	debugC(2, kDebugScript, "getValue1()");
	int curWord = _currScript->readUint16LE();
	if (curWord < 1000)
		return curWord;

	switch (curWord) {
	case 1000:
		return (int)_byte129A0;
	case 1001:
		return _vm->_rulesBuffer2PrevIndx;
	case 1002:
		return _word16F00;
	case 1003:
		return (int)_vm->_rulesBuffer2_15[6];
	case 1004:
		return _word10804;
	default:
		warning("getValue1: Unexpected large value %d", curWord);
		return curWord;
	}
}

int LilliputScript::getValue2() {
	debugC(2, kDebugScript, "getValue2()");

	int curWord = _currScript->readUint16LE();
	int tmpVal = curWord >> 8;
	switch(tmpVal) {
	case 0xFF:
		assert((_vm->_rulesBuffer2PrevIndx >= 0) && (_vm->_rulesBuffer2PrevIndx < 40));
		return ((_vm->_rulesBuffer2_13[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_rulesBuffer2_14[_vm->_rulesBuffer2PrevIndx]);
	case 0xFE: {
		int index = curWord & 0xFF;
		assert((index >= 0) && (index < 40));
		return ((_vm->_rulesBuffer2_13[index] << 8) + _vm->_rulesBuffer2_14[index]);
		}
	case 0xFD:
		return _vm->_word16EFA;
	case 0xFC: {
		int index = curWord & 0xFF;
		assert(index < 40);
		byte var1 = _vm->_rulesBuffer2_1[index] >> 3;
		byte var2 = _vm->_rulesBuffer2_2[index] >> 3;

		return (var1 << 8) + var2;
		}
	case 0xFB: {
		int index = _word16F00;
		assert(index < 40);
		byte var1 = _vm->_rulesBuffer2_1[index] >> 3;
		byte var2 = _vm->_rulesBuffer2_2[index] >> 3;

		return (var1 << 8) + var2;
		}
	case 0xFA:
		return ((_vm->_byte10999[_vm->_rulesBuffer2PrevIndx] << 8) + _vm->_byte109C1[_vm->_rulesBuffer2PrevIndx]);
	case 0xF9:
		return ((_vm->_rulesBuffer2_15[4] << 8) + _vm->_rulesBuffer2_15[5]);
	case 0xF8: {
		int index = curWord & 0xFF;
		assert((index >= 0) && (index < 40));
		return _vm->_rulesBuffer12_3[index];
		}
	case 0xF7: {
		int index = _vm->_rulesBuffer2_15[6];
		assert(index < 40);
		byte var1 = _vm->_rulesBuffer2_1[index] >> 3;
		byte var2 = _vm->_rulesBuffer2_2[index] >> 3;

		return (var1 << 8) + var2;
		}
	case 0xF6:
		return _vm->_savedMousePosDivided;
	default:
		warning("getValue2 - 0x%x - High value %d", tmpVal, curWord);
		return curWord;
	}
}

void LilliputScript::sub130B6() {
	debugC(1, kDebugScript, "sub130B6()");
	assert(_vm->_word12F68_ERULES <= 20);
	for (int i = 0; i < _vm->_word12F68_ERULES; i++) {
		if (_array122E9[i] == 3)
			_array122E9[i] = 2;
	}
}

byte *LilliputScript::getBuffer215Ptr() {
	debugC(2, kDebugScript, "getBuffer215Ptr()");
	int tmpVal = getValue1();
	tmpVal *= 32;
	tmpVal += _currScript->readUint16LE();

	assert(tmpVal < 40 * 32);
	return &_vm->_rulesBuffer2_15[tmpVal];
}

byte LilliputScript::OC_sub173DF() {
	warning("OC_sub173DF");
	return 0;
}
byte LilliputScript::OC_sub173F0() {
	warning("OC_sub173F0");
	return 0;
}
byte LilliputScript::OC_sub1740A() {
	warning("OC_sub1740A");
	return 0;
}

byte LilliputScript::OC_sub17434() {
	debugC(1, kDebugScript, "OC_sub17434()");

	byte *tmpArr = getBuffer215Ptr();
	byte var1 = tmpArr[0];
	uint16 oper = _currScript->readUint16LE();
	int16 var2 = _currScript->readUint16LE();

	return compareValues(var1, oper, var2);
}

byte LilliputScript::OC_sub17468() {
	warning("OC_sub17468");
	return 0;
}

byte LilliputScript::OC_getRandom() {
	warning("OC_getRandom");
	return 0;
}
byte LilliputScript::OC_sub1748C() {
	warning("OC_sub1748C");
	return 0;
}
byte LilliputScript::OC_compWord18776() {
	warning("OC_compWord18776");
	return 0;
}
byte LilliputScript::OC_checkSaveFlag() {
	debugC(1, kDebugScript, "OC_checkSaveFlag()");

	if (_vm->_saveFlag)
		return 1;

	return 0;
}

byte LilliputScript::OC_sub174C8() {
	warning("OC_sub174C8");
	return 0;
}

byte LilliputScript::OC_sub174D8() {
	debugC(1, kDebugScript, "OC_sub174D8()");

	byte tmpVal = getValue1() & 0xFF;
	int curWord = _currScript->readUint16LE();
	
	if (curWord == 3000) {
		int index;
		for (index = 0; index < _vm->_word10807_ERULES; index++) {
			if (_vm->_rulesBuffer2_5[index] == tmpVal) {
				_word16F00 = index;
				return 1;
			}
		}
	} else {
		_currScript->seek(_currScript->pos() - 2);
		int index = getValue1();
		assert(index < 40);
		if (_vm->_rulesBuffer2_5[index] == tmpVal) {
			_word16F00 = index;
			return 1;
		}
	}

	return 0;
}

byte LilliputScript::OC_sub1750E() {
	warning("OC_sub1750E");
	return 0;
}
byte LilliputScript::OC_compareCoords_1() {
	warning("compareCoords_1");
	return 0;
}
byte LilliputScript::OC_compareCoords_2() {
	warning("compareCoords_2");
	return 0;
}
byte LilliputScript::OC_sub1757C() {
	warning("OC_sub1757C");
	return 0;
}
byte LilliputScript::OC_sub1759E() {
	warning("OC_sub1759E");
	return 0;
}

byte LilliputScript::OC_compWord16EF8() {
	debugC(1, kDebugScript, "OC_compWord16EF8()");
	
	int tmpVal = getValue1();
	if (tmpVal == _vm->_rulesBuffer2PrevIndx)
		return 1;
	return 0;
}

byte LilliputScript::OC_sub175C8() {
	warning("OC_sub175C8");
	return 0;
}
byte LilliputScript::OC_sub17640() {
	warning("OC_sub17640");
	return 0;
}
byte LilliputScript::OC_sub176C4() {
	warning("OC_sub176C4");
	return 0;
}
byte LilliputScript::OC_compWord10804() {
	warning("OC_compWord10804");
	return 0;
}
byte LilliputScript::OC_sub17766() {
	warning("OC_sub17766");
	return 0;
}
byte LilliputScript::OC_sub17782() {
	warning("OC_sub17782");
	return 0;
}
byte LilliputScript::OC_sub1779E() {
	warning("OC_sub1779E");
	return 0;
}
byte LilliputScript::OC_sub177C6() {
	debugC(1, kDebugScript, "OC_sub177C6()");

	int index = _currScript->readUint16LE();
	if (_vm->_rulesBuffer2_1[index] == 0xFFFF)
		return 0;

	return 1;
}
byte LilliputScript::OC_compWord16EFE() {
	debugC(1, kDebugScript, "OC_compWord16EFE()");
	byte curByte = _currScript->readUint16LE() & 0xFF;
	byte tmpVal = _vm->_word16EFE >> 8;

	if (curByte != tmpVal)
		return 0;

	_word16F00 = (_vm->_word16EFE & 0xFF);
	return 1;
}

byte LilliputScript::OC_sub177F5() {
	warning("OC_sub177F5");
	return 0;
}

byte LilliputScript::OC_sub17812() {
	debugC(1, kDebugScript, "OC_sub17812()");

	byte curByte = (_currScript->readUint16LE() & 0xFF);
	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	if (_vm->_ptr_rulesBuffer2_15[0] == curByte)
		return 1;
	return 0;
}

byte LilliputScript::OC_sub17825() {
	debugC(1, kDebugScript, "OC_sub17825()");

	byte tmpVal = (_currScript->readUint16LE() & 0xFF);
	
	if ((_vm->_byte16F07_menuId != 1) && (_vm->_byte16F07_menuId != 3))
		return 0;

	if (tmpVal == _byte12FE4)
		return 1;

	return 0;
}

byte LilliputScript::OC_sub17844() {
	warning("OC_sub17844");
	return 0;
}

byte LilliputScript::OC_sub1785C() {
	debugC(1, kDebugScript, "OC_sub1785C()");

	byte curByte = (_currScript->readUint16LE() & 0xFF);
	int count = 0;

	for (int i = 0; i < _vm->_word10807_ERULES; i++) {
		if (curByte == _vm->_rulesBuffer2_15[(32 * i)])
			++count;
	}

	int oper = _currScript->readUint16LE();
	int var2 = _currScript->readUint16LE();

	return compareValues(count, oper, var2);
}

byte LilliputScript::OC_sub17886() {
	warning("OC_sub17886");
	return 0;
}
byte LilliputScript::OC_sub178A8() {
	warning("OC_sub178A8");
	return 0;
}
byte LilliputScript::OC_sub178BA() {
	warning("OC_sub178BA");
	return 0;
}
byte LilliputScript::OC_sub178C2() {
	debugC(1, kDebugScript, "OC_sub178C2()");

	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	if (_vm->_ptr_rulesBuffer2_15[2] == 1)
		return 1;
	return 0;
}
byte LilliputScript::OC_sub178D2() {
	warning("OC_sub178D2");
	return 0;
}
byte LilliputScript::OC_sub178E8() {
	warning("OC_sub178E8");
	return 0;
}
byte LilliputScript::OC_sub178FC() {
	warning("OC_sub178FC");
	return 0;
}
byte LilliputScript::OC_sub1790F() {
	warning("OC_sub1790F");
	return 0;
}

byte LilliputScript::OC_sub1792A() {
	debugC(1, kDebugScript, "OC_sub1792A()");

	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	byte curByte = (_currScript->readUint16LE() & 0xFF);

	if (_vm->_ptr_rulesBuffer2_15[1] == curByte)
		return 1;

	return 0;
}

byte LilliputScript::OC_sub1793E() {
	warning("OC_sub1793E");
	return 0;
}

byte LilliputScript::OC_sub1795E() {
	debugC(1, kDebugScript, "OC_sub1795E()");

	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	if (_vm->_ptr_rulesBuffer2_15[3] == 1)
		return 1;

	return 0;
}

byte LilliputScript::OC_sub1796E() {
	warning("OC_sub1796E");
	return 0;
}
byte LilliputScript::OC_sub17984() {
	debugC(1, kDebugScript, "OC_sub17984()");

	int index = _currScript->readUint16LE();
	int var2 = _currScript->readUint16LE();

	assert(index < 20);

	if (_array122E9[index] == (var2 & 0xFF))
		return 1;

	return 0;
}
byte LilliputScript::OC_checkSavedMousePos() {
	warning("OC_checkSavedMousePos");
	return 0;
}
byte LilliputScript::OC_sub179AE() {
	warning("OC_sub179AE");
	return 0;
}
byte LilliputScript::OC_sub179C2() {
	warning("OC_sub179C2");
	return 0;
}
byte LilliputScript::OC_sub179E5() {
	warning("OC_sub179E5");
	return 0;
}
byte LilliputScript::OC_sub17A07() {
	warning("OC_sub17A07");
	return 0;
}
byte LilliputScript::OC_sub17757() {
	warning("OC_sub17757");
	return 0;
}

void LilliputScript::OC_setWord18821() {
	warning("OC_setWord18821");
}
void LilliputScript::OC_sub17A3E() {
	warning("OC_sub17A3E");
}
void LilliputScript::OC_sub17D57() {
	warning("OC_sub17D57");
}
void LilliputScript::OC_sub17D7F() {
	warning("OC_sub17D7F");
}
void LilliputScript::OC_sub17DB9() {
	warning("OC_sub17DB9");
}
void LilliputScript::OC_sub17DF9() {
	warning("OC_sub17DF9");
}
void LilliputScript::OC_sub17E07() {
	warning("OC_sub17E07");
}
void LilliputScript::OC_sub17E15() {
	warning("OC_sub17E15");
}
void LilliputScript::OC_sub17B03() {
	debugC(1, kDebugScript, "OC_sub17B03()");

	byte *bufPtr = getBuffer215Ptr();
	int oper = _currScript->readUint16LE();
	int var2 = _currScript->readUint16LE();

	computeOperation(bufPtr, oper, var2);
}
void LilliputScript::OC_getRandom_type2() {
	warning("OC_getRandom_type2");
}
void LilliputScript::OC_sub17A66() {
	warning("OC_sub17A66");
}
void LilliputScript::OC_sub17A8D() {
	debugC(1, kDebugScript, "OC_sub17A8D()");

	int tmpVal = getValue1();
	assert(tmpVal < 40);

	if (tmpVal == _word10804)
		_word10802 = 0xFFFF;

	_vm->_rulesBuffer2_1[tmpVal] = 0xFFFF;
	_vm->_rulesBuffer2_2[tmpVal] = 0xFFFF;
}
void LilliputScript::OC_saveAndQuit() {
	warning("OC_saveAndQuit");
}
void LilliputScript::OC_sub17B93() {
	debugC(1, kDebugScript, "OC_sub17B93()");
	int var1 = _currScript->readUint16LE();

	sub17B6C(var1);
}

void LilliputScript::OC_sub17E37() {
	warning("OC_sub17E37");
}
void LilliputScript::OC_resetByte1714E() {
	warning("OC_resetByte1714E");
}
void LilliputScript::OC_deleteSavegameAndQuit() {
	warning("OC_deleteSavegameAndQuit");
}
void LilliputScript::OC_incByte16F04() {
	warning("OC_incByte16F04");
}

void LilliputScript::OC_sub17BA5() {
	debugC(1, kDebugScript, "OC_sub17BA5()");
	
	byte *tmpArr = getBuffer215Ptr();
	byte oper = (_currScript->readUint16LE() & 0xFF);
	byte var2 = getBuffer215Ptr()[0];
	computeOperation(tmpArr, oper, var2);
}

void LilliputScript::OC_setByte18823() {
	warning("OC_setByte18823");
}
void LilliputScript::OC_sub17BB7() {
	debugC(1, kDebugScript, "OC_sub17BB7()");

	int index = _currScript->readUint16LE();
	int var1 = getValue1();

	_vm->sub170EE(var1);
	int tmpIndex = _vm->_rulesBuffer2PrevIndx;

	assert(index < _vm->_gameScriptIndexSize);
	int scriptIndex = _vm->_arrayGameScriptIndex[index];

	_scriptStack.push(_currScript);
	warning("===> push");
	if (_byte16F05_ScriptHandler == 0) {
		_vm->_byte1714E = 0;
		runMenuScript(Common::MemoryReadStream(&_vm->_arrayGameScripts[scriptIndex], _vm->_arrayGameScriptIndex[index + 1] - _vm->_arrayGameScriptIndex[index]));
	} else {
		runScript(Common::MemoryReadStream(&_vm->_arrayGameScripts[scriptIndex], _vm->_arrayGameScriptIndex[index + 1] - _vm->_arrayGameScriptIndex[index]));
	}
	warning("===> pop");
	_currScript = _scriptStack.pop();

	_vm->sub170EE(tmpIndex);
}

void LilliputScript::OC_sub17BF2() {
	debugC(1, kDebugScript, "OC_sub17BF2()");

	OC_sub17BB7();
	sub17B6C(0);
}

void LilliputScript::OC_sub17ACC() {
	warning("OC_sub17ACC");
}
void LilliputScript::OC_resetByte16F04() {
	warning("OC_resetByte16F04");
}
void LilliputScript::OC_sub17AE1() {
	warning("OC_sub17AE1");
}
void LilliputScript::OC_sub17AEE() {
	warning("OC_sub17AEE");
}
void LilliputScript::OC_setWord10804() {
	debugC(1, kDebugScript, "OC_setWord10804()");

	_word10804 = getValue1();
}
void LilliputScript::OC_sub17C0E() {
	warning("OC_sub17C0E");
}
void LilliputScript::OC_sub17C55() {
	warning("OC_sub17C55");
}
void LilliputScript::OC_sub17C76() {
	warning("OC_sub17C76");
}
void LilliputScript::OC_sub17AFC() {
	warning("OC_sub17AFC");
}
void LilliputScript::OC_sub17C8B() {
	warning("OC_sub17C8B");
}
void LilliputScript::OC_sub17CA2() {
	warning("OC_sub17CA2");
}
void LilliputScript::OC_sub17CB9() {
	warning("OC_sub17CB9");
}
void LilliputScript::OC_sub17CD1() {
	warning("OC_sub17CD1");
}
void LilliputScript::OC_resetWord16EFE() {
	warning("OC_resetWord16EFE");
}
void LilliputScript::OC_sub17CEF() {
	warning("OC_sub17CEF");
}

void LilliputScript::OC_sub17D1B() {
	debugC(1, kDebugScript, "OC_sub17D1B()");

	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	++_vm->_ptr_rulesBuffer2_15[1];
}

void LilliputScript::OC_sub17D23() {
	warning("OC_sub17D23");
}
void LilliputScript::OC_sub17E6D() {
	warning("OC_sub17E6D");
}
void LilliputScript::OC_sub17E7E() {
	warning("OC_sub17E7E");
}
void LilliputScript::OC_sub17E99() {
	warning("OC_sub17E99");
}
void LilliputScript::OC_sub17EC5() {
	warning("OC_sub17EC5");
}
void LilliputScript::OC_sub17EF4() {
	warning("OC_sub17EF4");
}
void LilliputScript::OC_sub17F08() {
	warning("OC_sub17F08");
}
void LilliputScript::OC_sub17F4F() {
	warning("OC_sub17F4F");
}
void LilliputScript::OC_sub17F68() {
	warning("OC_sub17F68");
}
void LilliputScript::OC_getNextVal() {
	warning("OC_getNextVal");
}
void LilliputScript::OC_sub17FD2() {
	warning("OC_sub17FD2");
}

void LilliputScript::OC_sub17FDD() {
	debugC(1, kDebugScript, "OC_sub17FDD()");

	int index = _currScript->readUint16LE();
	
	int tmpVal = (_vm->_rulesBuffer2PrevIndx * 32) + index;
	assert (tmpVal < 40 * 32);
	_array10AB1[_vm->_rulesBuffer2PrevIndx] = _vm->_rulesBuffer2_16[tmpVal];
	_array12811[_vm->_rulesBuffer2PrevIndx] = 16;
}

void LilliputScript::OC_setByte10B29() {
	warning("OC_setByte10B29");
}

void LilliputScript::OC_sub18007() {
	debugC(1, kDebugScript, "OC_sub18007()");

	int curWord = _currScript->readUint16LE();
	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	_vm->_ptr_rulesBuffer2_15[2] = curWord & 0xFF;
}

void LilliputScript::OC_sub18014() {
	debugC(1, kDebugScript, "OC_sub18014()");

	assert(_vm->_ptr_rulesBuffer2_15 != NULL);
	_vm->_ptr_rulesBuffer2_15[2] = 0;
}

void LilliputScript::OC_sub1801D() {
	warning("OC_sub1801D");
}
void LilliputScript::OC_sub1805D() {
	warning("OC_sub1805D");
}
void LilliputScript::OC_sub18074() {
	warning("OC_sub18074");
}
void LilliputScript::OC_sub1808B() {
	warning("OC_sub1808B");
}
void LilliputScript::OC_sub18099() {
	debugC(1, kDebugScript, "OC_sub18099()");

	int index = _currScript->readUint16LE();
	assert((index >= 0) && (index < 20));
	int curWord = _currScript->readUint16LE();

	_array122E9[index] = (curWord & 0xFF);
	_array122FD[index] = (curWord >> 8);

	warning("TODO: display function #8");
	
}
void LilliputScript::OC_sub180C3() {
	warning("OC_sub180C3");
}
void LilliputScript::OC_sub1810A() {
	warning("OC_sub1810A");
}

void LilliputScript::OC_sub1812D() {
	debugC(1, kDebugScript, "OC_sub1812D()");

	_vm->_rulesBuffer2_3[_vm->_rulesBuffer2PrevIndx] = (_currScript->readUint16LE() & 0xFF);
}

void LilliputScript::OC_sub1817F() {
	warning("OC_sub1817F");
}
void LilliputScript::OC_sub181BB() {
	warning("OC_sub181BB");
}
void LilliputScript::OC_sub18213() {
	warning("OC_sub18213");
}
void LilliputScript::OC_sub18252() {
	warning("OC_sub18252");
}
void LilliputScript::OC_sub18260() {
	warning("OC_sub18260");
}
void LilliputScript::OC_sub182EC() {
	warning("OC_sub182EC");
}
void LilliputScript::OC_unkPaletteFunction_1() {
	warning("OC_unkPaletteFunction_1");
}
void LilliputScript::OC_unkPaletteFunction_2() {
	warning("OC_unkPaletteFunction_2");
}

void LilliputScript::OC_loadAndDisplayCUBESx_GFX() {
	debugC(1, kDebugScript, "OC_loadAndDisplayCUBESx_GFX()");

	int curWord = _currScript->readUint16LE();
	assert((curWord >= 0) && (curWord <= 9));
	Common::String fileName = Common::String::format("CUBES%d.GFX", curWord);
	_byte10806 = curWord + 0x30;
	warning("TODO: load %s then display things", fileName.c_str());
}

void LilliputScript::OC_sub1834C() {
	debugC(1, kDebugScript, "OC_sub1834C()");

	byte curWord = _currScript->readUint16LE() & 0xFF;
	assert(_vm->_ptr_rulesBuffer2_15 != NULL);

	_vm->_ptr_rulesBuffer2_15[3] = curWord;
}
void LilliputScript::OC_sub18359() {
	warning("OC_sub18359");
}
void LilliputScript::OC_sub18367() {
	warning("OC_sub18367");
}
void LilliputScript::OC_sub17D04() {
	debugC(1, kDebugScript, "OC_sub17D04()");

	byte var1 = getValue1();
	byte var2 = _currScript->readUint16LE() & 0xFF;
	
	sub1823E(var1, var2, &_vm->_rulesBuffer2_15[var1]);
}

void LilliputScript::OC_sub18387() {
	warning("OC_sub18387");
}
void LilliputScript::OC_setByte14835() {
	warning("OC_setByte14835");
}
void LilliputScript::OC_setByte14837() {
	warning("OC_setByte14837");
}
void LilliputScript::OC_sub183A2() {
	warning("OC_sub183A2");
}
void LilliputScript::OC_sub183C6() {
	warning("OC_sub183C6");
}
void LilliputScript::OC_loadFile_AERIAL_GFX() {
	warning("OC_loadFile_AERIAL_GFX");
}
void LilliputScript::OC_sub17E22() {
	warning("OC_sub17E22");
}
void LilliputScript::OC_sub1844A() {
	warning("OC_sub1844A");
}
void LilliputScript::OC_sub1847F() {
	debugC(1, kDebugScript, "OC_sub1847F()");
	byte *buf215Ptr = getBuffer215Ptr();
	byte tmpVal = buf215Ptr[0];
	int curWord = _currScript->readUint16LE();
	assert(curWord != 0);
	int var1 = tmpVal / curWord;
	int var2 = _currScript->readUint16LE();
	int var3 = _currScript->readUint16LE();

	if (_byte16F08 != 1) {
		warning("TODO: OC_sub1847F - Display Function 5");
		warning("TODO: OC_sub1847F - sub_18BE6");
		warning("TODO: OC_sub1847F - Display Function 4");
	}
}

void LilliputScript::OC_displayVGAFile() {
	debugC(1, kDebugScript, "OC_displayVGAFile()");

	_byte12A09 = 1;
	warning("TODO: unkPaletteFunction_1");
	int curWord = _currScript->readUint16LE();
	int index = _vm->_rulesChunk3[curWord];
	Common::String fileName = Common::String((const char *)&_vm->_rulesChunk4[index]);
	_word1881B = -1;
	_vm->displayVGAFile(fileName);
	warning("TODO: unkPaletteFunction_2");
}
void LilliputScript::OC_sub184D7() {
	warning("OC_sub184D7");
}
void LilliputScript::OC_displayTitleScreen() {
	debugC(1, kDebugScript, "OC_displayTitleScreen()");

	_vm->_byte184F4 = (_currScript->readUint16LE() & 0xFF);
	_vm->_sound_byte16F06 = _vm->_byte184F4;

	// TODO: Rewrite keyboard handling (this code was in a separated function)
	_vm->_keyboard_nextIndex = 0;
	_vm->_keyboard_oldIndex = 0;
	//
	_vm->_mouseButton = 0;
	_vm->_byte16F09 = 0;

	for (;;) {
		sub185B4_display();
		_vm->pollEvent();
		if (_vm->_keyboard_nextIndex != _vm->_keyboard_oldIndex) {
			_vm->_byte16F09 = _vm->_keyboard_getch();
			_vm->_keyboard_getch();
			break;
		}
		
		if (_vm->_mouseButton & 1)
			break;
		
		if ((_vm->_byte184F4 != 0) && (_vm->_sound_byte16F06 == 0))
			break;
	}
	
	_vm->_mouseButton = 0;
}

void LilliputScript::OC_sub1853B() {
	debugC(1, kDebugScript, "OC_initArr1853B()");

	warning("TODO: unkPaletteFunction_1");
	_byte16F08 = 0;
	_byte15FFA = 0;
	sub130B6();
	warning("TODO: Display function sub15CBC();");
	warning("TODO: unkPaletteFunction_2");
	_byte12A09 = 0;
	warning("TODO: call sound function #5");
}

void LilliputScript::OC_sub1864D() {
	warning("OC_sub1864D");
}

void LilliputScript::OC_initArr18560() {
	debugC(1, kDebugScript, "OC_initArr18560()");

	int curWord = _currScript->readUint16LE();
	assert (curWord < 4);
	_vm->_arr18560[curWord]._field0 = 1;
	_vm->_arr18560[curWord]._field1 = _currScript->readUint16LE();
	_vm->_arr18560[curWord]._field3 = _currScript->readUint16LE();

	for (int i = 0; i < 8; i++)
		_vm->_arr18560[curWord]._field5[i] = _currScript->readUint16LE();
}

void LilliputScript::OC_sub18678() {
	debugC(1, kDebugScript, "OC_initArr18578()");
	_savedBuffer215Ptr = getBuffer215Ptr();
	_word15FFB = _currScript->readUint16LE();
	_word15FFD = _currScript->readUint16LE();
}
void LilliputScript::OC_sub18690() {
	warning("OC_sub18690");
}
void LilliputScript::OC_setWord10802() {
	debugC(1, kDebugScript, "OC_setWord10802()");

	_word10802 = getValue1();
}
void LilliputScript::OC_sub186A1() {
	warning("OC_sub186A1");
}
void LilliputScript::OC_sub186E5_snd() {
	warning("OC_sub186E5_snd");
}

void LilliputScript::OC_sub1870A_snd() {
	debugC(1, kDebugScript, "OC_sub1870A_snd()");

	int var3 = getValue2();
	int var4 = var3;
	int var2 = (_word12A00 << 8) + _word12A02;
	int var1 = (_currScript->readUint16LE() & 0xFF);
	warning("TODO: ovlContentOVL Function 2");
}

void LilliputScript::OC_sub18725_snd() {
	debugC(1, kDebugScript, "OC_sub18725_snd()");

	int var4 = getValue1() | 0xFF00;
	warning("TODO: ovlContentOVL Function 3");
}

void LilliputScript::OC_sub18733_snd() {
	debugC(1, kDebugScript, "OC_sub18733_snd()");

	int var4 = getValue2();
	warning("TODO: ovlContentOVL Function 3");
}

void LilliputScript::OC_sub1873F_snd() {
	debugC(1, kDebugScript, "OC_sub1873F_snd()");

	warning("TODO: ovlContentOVL Function 4");
}

void LilliputScript::OC_sub18746_snd() {
	debugC(1, kDebugScript, "OC_sub18746_snd()");

	int var4 = -1;
	int var2 = (_word12A00 << 8) + _word12A02;
	int var1 = _currScript->readUint16LE() & 0xFF;
	warning("TODO: ovlContentOVL Function 2");
}

void LilliputScript::OC_sub1875D_snd() {
	debugC(1, kDebugScript, "OC_sub1875D_snd()");

	warning("TODO: ovlContentOVL Function 6");
}

void LilliputScript::OC_sub18764() {
	debugC(1, kDebugScript, "OC_sub18764()");

	int index = getValue1();
	int var1 = _currScript->readUint16LE();

	assert(index < 40);
	_array128EF[index] = var1 & 0xFF;
}

} // End of namespace