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
|
/* 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$
*
*/
#ifdef ENABLE_LOL
#ifndef KYRA_LOL_H
#define KYRA_LOL_H
#include "kyra/kyra_v1.h"
#include "kyra/script_tim.h"
#include "kyra/script.h"
#include "kyra/sound.h"
#include "kyra/gui_lol.h"
#include "kyra/text_lol.h"
#include "common/list.h"
namespace Kyra {
class Screen_LoL;
class WSAMovie_v2;
struct Button;
struct LoLCharacter {
uint16 flags;
char name[11];
uint8 raceClassSex;
int16 id;
uint8 curFaceFrame;
uint8 defaultFaceFrame;
uint8 field_12;
const uint16 *defaultModifiers;
uint16 itemsMight[8];
uint16 field_27[2];
uint8 field_2B;
uint16 field_2C;
uint16 field_2E;
uint16 field_30;
uint16 field_32;
uint16 field_34;
uint8 field_36;
uint16 itemsProtection;
int16 hitPointsCur;
uint16 hitPointsMax;
int16 magicPointsCur;
uint16 magicPointsMax;
uint8 field_41;
uint16 damageSuffered;
uint16 weaponHit;
uint16 totalMightModifier;
uint16 totalProtectionModifier;
uint16 might;
uint16 protection;
int16 nextAnimUpdateCountdown;
uint16 items[11];
uint8 skillLevels[3];
uint8 skillModifiers[3];
int32 experiencePts[3];
uint8 arrayUnk2[5];
uint8 arrayUnk1[5];
};
struct SpellProperty {
uint16 spellNameCode;
uint16 mpRequired[4];
uint16 unkArr[8];
uint16 flags;
};
struct LevelBlockProperty {
uint8 walls[4];
uint16 assignedObjects;
uint16 drawObjects;
uint8 direction;
uint8 flags;
};
struct MonsterProperty {
uint8 shapeIndex;
uint8 maxWidth;
uint16 fightingStats[10];
uint16 unk2[8];
uint16 unk3[8];
uint16 itemProtection;
uint16 might;
uint8 speedTotalWaitTicks;
uint8 skillLevel;
uint16 flags;
uint16 unk5;
uint16 unk6[5];
uint8 unk7[4];
uint8 sounds[3];
};
struct MonsterInPlay {
uint16 nextAssignedObject;
uint16 nextDrawObject;
uint8 flyingHeight;
uint16 blockPropertyIndex;
uint16 x;
uint16 y;
int8 shiftStep;
uint16 destX;
uint16 destY;
uint8 destDirection;
uint8 anon8;
uint8 anonh;
uint8 currentSubFrame;
uint8 mode;
int8 fightCurTick;
uint8 id;
uint8 direction;
uint8 facing;
uint16 flags;
uint8 field_1B;
uint8 field_1C;
int16 might;
uint8 speedTick;
uint8 type;
MonsterProperty *properties;
uint8 field_25;
uint8 field_26;
uint8 field_27;
uint16 assignedItems;
uint8 field_2A[4];
};
struct ItemInPlay {
uint16 nextAssignedObject;
uint16 nextDrawObject;
uint8 flyingHeight;
uint16 blockPropertyIndex;
uint16 x;
uint16 y;
int8 level;
uint16 itemPropertyIndex;
uint16 shpCurFrame_flg;
uint8 destDirection;
uint8 anon8;
uint8 anonh;
uint8 currentSubFrame;
};
struct ItemProperty {
uint16 nameStringId;
uint8 shpIndex;
uint16 flags;
uint16 type;
uint8 itemScriptFunc;
int8 might;
uint8 skill;
uint8 protection;
uint16 unkB;
uint8 unkD;
};
struct LevelShapeProperty {
uint16 shapeIndex[10];
uint8 scaleFlag[10];
int16 shapeX[10];
int16 shapeY[10];
int8 next;
uint8 flags;
};
struct CompassDef {
uint8 shapeIndex;
int8 x;
int8 y;
uint8 flags;
};
struct ButtonDef {
uint16 buttonflags;
uint16 keyCode;
uint16 keyCode2;
int16 x;
int16 y;
uint16 w;
uint16 h;
uint16 index;
uint16 screenDim;
};
struct OpenDoorState {
uint16 block;
int8 wall;
int8 state;
};
struct FlyingObject {
uint8 enable;
uint8 a;
uint16 charNum;
uint16 item;
uint16 x;
uint16 y;
uint8 flyingHeight;
uint8 direction;
uint8 distance;
int8 field_D;
uint8 c;
uint8 flags;
uint8 wallFlags;
};
struct FlyingObjectShape {
uint8 shapeFront;
uint8 shapeBack;
uint8 shapeLeft;
uint8 drawFlags;
uint8 flipFlags;
};
class LoLEngine : public KyraEngine_v1 {
friend class GUI_LoL;
friend class TextDisplayer_LoL;
friend class TIMInterpreter_LoL;
public:
LoLEngine(OSystem *system, const GameFlags &flags);
~LoLEngine();
Screen *screen();
GUI *gui() const;
private:
Screen_LoL *_screen;
GUI_LoL *_gui;
TIMInterpreter *_tim;
Common::Error init();
Common::Error go();
// initialization
void initStaticResource();
void preInit();
void loadItemIconShapes();
int mainMenu();
void startup();
void startupNew();
// options
int _monsterDifficulty;
bool _smoothScrollingEnabled;
bool _floatingCursorsEnabled;
// main loop
void runLoop();
void update();
void updateEnvironmentalSfx(int soundId);
// mouse
void setMouseCursorToIcon(int icon);
void setMouseCursorToItemInHand();
uint8 *getItemIconShapePtr(int index);
bool posWithinRect(int mouseX, int mouseY, int x1, int y1, int x2, int y2);
int _floatingMouseArrowControl;
// intro
void setupPrologueData(bool load);
void showIntro();
struct CharacterPrev {
const char *name;
int x, y;
int attrib[3];
};
static const CharacterPrev _charPreviews[];
WSAMovie_v2 *_chargenWSA;
static const uint8 _chargenFrameTable[];
int chooseCharacter();
void kingSelectionIntro();
void kingSelectionReminder();
void kingSelectionOutro();
void processCharacterSelection();
void updateSelectionAnims();
int selectionCharInfo(int character);
void selectionCharInfoIntro(char *file);
int getCharSelection();
int selectionCharAccept();
int _charSelection;
int _charSelectionInfoResult;
uint32 _selectionAnimTimers[4];
uint8 _selectionAnimFrames[4];
static const uint8 _selectionAnimIndexTable[];
static const uint16 _selectionPosTable[];
static const uint8 _selectionChar1IdxTable[];
static const uint8 _selectionChar2IdxTable[];
static const uint8 _selectionChar3IdxTable[];
static const uint8 _selectionChar4IdxTable[];
static const uint8 _reminderChar1IdxTable[];
static const uint8 _reminderChar2IdxTable[];
static const uint8 _reminderChar3IdxTable[];
static const uint8 _reminderChar4IdxTable[];
static const uint8 _charInfoFrameTable[];
// timers
void setupTimers();
void enableTimer(int id);
void enableSysTimer(int sysTimer);
void disableSysTimer(int sysTimer);
void timerProcessDoors(int timerNum);
void timerProcessMonsters(int timerNum);
void timerSub3(int timerNum);
void timerProcessFlyingObjects(int timerNum);
void timerRunSceneAnimScript(int timerNum);
void timerSub6(int timerNum);
void timerUpdatePortraitAnimations(int skipUpdate);
void timerUpdateLampState(int timerNum);
void timerFadeMessageText(int timerNum);
static const uint8 _clock2Timers[];
static const uint8 _numClock2Timers;
// sound
void loadTalkFile(int index);
void snd_playVoiceFile(int track) {}
bool snd_playCharacterSpeech(int id, int8 speaker, int);
int snd_characterSpeaking();
void snd_stopSpeech(bool setFlag);
void snd_playSoundEffect(int track, int volume);
void snd_processEnvironmentalSoundEffect(int soundId, int block);
void snd_loadSoundFile(int track);
int snd_playTrack(int track);
int snd_stopMusic();
int _lastSpeechId;
int _lastSpeaker;
char _activeVoiceFile[13];
uint32 _activeVoiceFileTotalTime;
int _lastSfxTrack;
int _lastMusicTrack;
int _curMusicFileIndex;
char _curMusicFileExt;
int _environmentSfx;
int _environmentSfxVol;
int _environmentSfxDistThreshold;
int _nextSpeechId;
int _nextSpeaker;
int _curTlkFile;
int _speechFlag;
char **_ingameSoundList;
int _ingameSoundListSize;
const uint8 *_musicTrackMap;
int _musicTrackMapSize;
const uint16 *_ingameSoundIndex;
int _ingameSoundIndexSize;
const uint8 *_ingameGMSoundIndex;
int _ingameGMSoundIndexSize;
const uint8 *_ingameMT32SoundIndex;
int _ingameMT32SoundIndexSize;
/*const uint8 *_ingameADLSoundIndex;
int _ingameADLSoundIndexSize;*/
// gui
void gui_drawPlayField();
void gui_drawScene(int pageNum);
void gui_drawAllCharPortraitsWithStats();
void gui_drawCharPortraitWithStats(int charNum);
void gui_drawBox(int x, int y, int w, int h, int frameColor1, int frameColor2, int fillColor);
void gui_drawCharFaceShape(int charNum, int x, int y, int pageNum);
void gui_highlightPortraitFrame(int charNum);
void gui_drawLiveMagicBar(int x, int y, int curPoints, int unk, int maxPoints, int w, int h, int col1, int col2, int flag);
void gui_drawMoneyBox(int pageNum);
void gui_drawInventory();
void gui_drawInventoryItem(int index);
void gui_drawCompass();
void gui_drawScroll();
void gui_highlightSelectedSpell(int unk);
void gui_displayCharInventory(int charNum);
void gui_printCharInventoryStats(int charNum);
void gui_printCharacterStats(int index, int redraw, int value);
void gui_changeCharacterStats(int charNum);
void gui_drawCharInventoryItem(int itemIndex);
void gui_drawBarGraph(int x, int y, int w, int h, int32 curVal, int32 maxVal, int col1, int col2);
int gui_enableControls();
int gui_disableControls(int controlMode);
void gui_toggleButtonDisplayMode(int shapeIndex, int mode);
void gui_toggleFightButtons(bool disable);
void gui_prepareForSequence(int x, int y, int w, int h, int buttonFlags);
void gui_specialSceneSuspendControls(int controlMode);
void gui_specialSceneRestoreControls(int restoreLamp);
bool _weaponsDisabled;
int _lastButtonShape;
uint32 _buttonPressTimer;
int _selectedCharacter;
int _compassDirection;
int _compassUnk;
int _compassDirectionIndex;
int _charInventoryUnk;
const CompassDef *_compassDefs;
int _compassDefsSize;
void gui_updateInput();
void gui_triggerEvent(int eventType);
void gui_enableDefaultPlayfieldButtons();
void gui_enableSequenceButtons(int x, int y, int w, int h, int enableFlags);
void gui_specialSceneRestoreButtons();
void gui_enableCharInventoryButtons(int charNum);
void gui_resetButtonList();
void gui_initButtonsFromList(const int16 *list);
void gui_setFaceFramesControlButtons(int index, int xOffs);
void gui_initCharInventorySpecialButtons(int charNum);
void gui_initMagicScrollButtons();
void gui_initMagicSubmenu(int charNum);
void gui_initButton(int index, int x = -1, int y = -1, int val = -1);
void gui_notifyButtonListChanged() { if (_gui) _gui->_buttonListChanged = true; }
void assignButtonCallback(Button *button, int index);
Button *_activeButtons;
ButtonDef _sceneWindowButton;
bool _preserveEvents;
int clickedUpArrow(Button *button);
int clickedDownArrow(Button *button);
int clickedLeftArrow(Button *button);
int clickedRightArrow(Button *button);
int clickedTurnLeftArrow(Button *button);
int clickedTurnRightArrow(Button *button);
int clickedAttackButton(Button *button);
int clickedMagicButton(Button *button);
int clickedMagicSubmenu(Button *button);
int clickedScreen(Button *button);
int clickedPortraitLeft(Button *button);
int clickedLiveMagicBarsLeft(Button *button);
int clickedPortraitEtcRight(Button *button);
int clickedCharInventorySlot(Button *button);
int clickedExitCharInventory(Button *button);
int clickedSceneDropItem(Button *button);
int clickedScenePickupItem(Button *button);
int clickedInventorySlot(Button *button);
int clickedInventoryScroll(Button *button);
int clickedWall(Button *button);
int clickedSequenceWindow(Button *button);
int clickedScroll(Button *button);
int clickedUnk23(Button *button);
int clickedUnk24(Button *button);
int clickedSceneThrowItem(Button *button);
int clickedOptions(Button *button);
int clickedRestParty(Button *button);
int clickedMoneyBox(Button *button);
int clickedCompass(Button *button);
int clickedAutomap(Button *button);
int clickedLamp(Button *button);
int clickedUnk32(Button *button);
const ButtonDef *_buttonData;
int _buttonDataSize;
const int16 *_buttonList1;
int _buttonList1Size;
const int16 *_buttonList2;
int _buttonList2Size;
const int16 *_buttonList3;
int _buttonList3Size;
const int16 *_buttonList4;
int _buttonList4Size;
const int16 *_buttonList5;
int _buttonList5Size;
const int16 *_buttonList6;
int _buttonList6Size;
const int16 *_buttonList7;
int _buttonList7Size;
const int16 *_buttonList8;
int _buttonList8Size;
// text
bool characterSays(int track, int charId, bool redraw);
int playCharacterScriptChat(int charId, int mode, int unk1, char *str, EMCState *script, const uint16 *paramList, int16 paramIndex);
TextDisplayer_LoL *_txt;
// emc scripts
void runInitScript(const char *filename, int optionalFunc);
void runInfScript(const char *filename);
void runLevelScript(int block, int sub);
void runLevelScriptCustom(int block, int sub, int charNum, int item, int reg3, int reg4);
bool checkSceneUpdateNeed(int func);
EMCData _scriptData;
bool _suspendScript;
uint16 _scriptDirection;
uint16 _currentDirection;
uint16 _currentBlock;
bool _sceneUpdateRequired;
int16 _visibleBlockIndex[18];
uint16 _gameFlags[16];
uint16 _globalScriptVars[16];
// emc opcode
int olol_setWallType(EMCState *script);
int olol_getWallType(EMCState *script);
int olol_drawScene(EMCState *script);
int olol_delay(EMCState *script);
int olol_setGameFlag(EMCState *script);
int olol_testGameFlag(EMCState *script);
int olol_loadLevelGraphics(EMCState *script);
int olol_loadCmzFile(EMCState *script);
int olol_loadMonsterShapes(EMCState *script);
int olol_deleteHandItem(EMCState *script);
int olol_allocItemPropertiesBuffer(EMCState *script);
int olol_setItemProperty(EMCState *script);
int olol_makeItem(EMCState *script);
int olol_createLevelItem(EMCState *script);
int olol_getItemPara(EMCState *script);
int olol_getCharacterStat(EMCState *script);
int olol_setCharacterStat(EMCState *script);
int olol_loadLevelShapes(EMCState *script);
int olol_closeLevelShapeFile(EMCState *script);
int olol_loadDoorShapes(EMCState *script);
int olol_initAnimStruct(EMCState *script);
int olol_playAnimationPart(EMCState *script);
int olol_freeAnimStruct(EMCState *script);
int olol_getDirection(EMCState *script);
int olol_setMusicTrack(EMCState *script);
int olol_setSequenceButtons(EMCState *script);
int olol_setDefaultButtonState(EMCState *script);
int olol_checkRectForMousePointer(EMCState *script);
int olol_clearDialogueField(EMCState *script);
int olol_setupBackgroundAnimationPart(EMCState *script);
int olol_startBackgroundAnimation(EMCState *script);
int olol_fadeToBlack(EMCState *script);
int olol_fadePalette(EMCState *script);
int olol_loadBitmap(EMCState *script);
int olol_stopBackgroundAnimation(EMCState *script);
int olol_getGlobalScriptVar(EMCState *script);
int olol_setGlobalScriptVar(EMCState *script);
int olol_getGlobalVar(EMCState *script);
int olol_setGlobalVar(EMCState *script);
int olol_triggerDoorSwitch(EMCState *script);
int olol_updateBlockAnimations(EMCState *script);
int olol_mapShapeToBlock(EMCState *script);
int olol_resetBlockShapeAssignment(EMCState *script);
int olol_copyRegion(EMCState *script);
int olol_initMonster(EMCState *script);
int olol_fadeClearSceneWindow(EMCState *script);
int olol_fadeSequencePalette(EMCState *script);
int olol_redrawPlayfield(EMCState *script);
int olol_loadNewLevel(EMCState *script);
int olol_dummy0(EMCState *script);
int olol_loadMonsterProperties(EMCState *script);
int olol_battleHitSkillTest(EMCState *script);
int olol_moveMonster(EMCState *script);
int olol_dialogueBox(EMCState *script);
int olol_giveTakeMoney(EMCState *script);
int olol_checkMoney(EMCState *script);
int olol_setScriptTimer(EMCState *script);
int olol_createHandItem(EMCState *script);
int olol_characterJoinsParty(EMCState *script);
int olol_loadTimScript(EMCState *script);
int olol_runTimScript(EMCState *script);
int olol_releaseTimScript(EMCState *script);
int olol_initSceneWindowDialogue(EMCState *script);
int olol_restoreAfterSceneWindowDialogue(EMCState *script);
int olol_getItemInHand(EMCState *script);
int olol_giveItemToMonster(EMCState *script);
int olol_loadLangFile(EMCState *script);
int olol_playSoundEffect(EMCState *script);
int olol_processDialogue(EMCState *script);
int olol_stopTimScript(EMCState *script);
int olol_getWallFlags(EMCState *script);
int olol_changeMonsterSettings(EMCState *script);
int olol_playCharacterScriptChat(EMCState *script);
int olol_update(EMCState *script);
int olol_drawExitButton(EMCState *script);
int olol_loadSoundFile(EMCState *script);
int olol_playMusicTrack(EMCState *script);
int olol_stopCharacterSpeech(EMCState *script);
int olol_setPaletteBrightness(EMCState *script);
int olol_printMessage(EMCState *script);
int olol_playDialogueTalkText(EMCState *script);
int olol_checkMonsterTypeHostility(EMCState *script);
int olol_setNextFunc(EMCState *script);
int olol_dummy1(EMCState *script);
int olol_suspendMonster(EMCState *script);
int olol_setDoorState(EMCState *script);
int olol_processButtonClick(EMCState *script);
int olol_savePage5(EMCState *script);
int olol_restorePage5(EMCState *script);
int olol_initDialogueSequence(EMCState *script);
int olol_restoreAfterDialogueSequence(EMCState *script);
int olol_setSpecialSceneButtons(EMCState *script);
int olol_prepareSpecialScene(EMCState *script);
int olol_restoreAfterSpecialScene(EMCState *script);
int olol_assignCustomSfx(EMCState *script);
int olol_resetPortraitsAndDisableSysTimer(EMCState *script);
int olol_enableSysTimer(EMCState *script);
int olol_disableControls(EMCState *script);
int olol_enableControls(EMCState *script);
int olol_queueSpeech(EMCState *script);
int olol_getItemPrice(EMCState *script);
int olol_getLanguage(EMCState *script);
// tim scripts
TIM *_activeTim[10];
// tim opcode
void setupOpcodeTable();
Common::Array<const TIMOpcode*> _timIntroOpcodes;
int tlol_setupPaletteFade(const TIM *tim, const uint16 *param);
int tlol_loadPalette(const TIM *tim, const uint16 *param);
int tlol_setupPaletteFadeEx(const TIM *tim, const uint16 *param);
int tlol_processWsaFrame(const TIM *tim, const uint16 *param);
int tlol_displayText(const TIM *tim, const uint16 *param);
int tlol_initSceneWindowDialogue(const TIM *tim, const uint16 *param);
int tlol_restoreAfterSceneWindowDialogue(const TIM *tim, const uint16 *param);
int tlol_giveItem(const TIM *tim, const uint16 *param);
int tlol_setPartyPosition(const TIM *tim, const uint16 *param);
int tlol_fadeClearWindow(const TIM *tim, const uint16 *param);
int tlol_copyRegion(const TIM *tim, const uint16 *param);
int tlol_characterChat(const TIM *tim, const uint16 *param);
int tlol_drawScene(const TIM *tim, const uint16 *param);
int tlol_update(const TIM *tim, const uint16 *param);
int tlol_loadSoundFile(const TIM *tim, const uint16 *param);
int tlol_playMusicTrack(const TIM *tim, const uint16 *param);
int tlol_playDialogueTalkText(const TIM *tim, const uint16 *param);
int tlol_playSoundEffect(const TIM *tim, const uint16 *param);
int tlol_startBackgroundAnimation(const TIM *tim, const uint16 *param);
int tlol_stopBackgroundAnimation(const TIM *tim, const uint16 *param);
Common::Array<const TIMOpcode*> _timIngameOpcodes;
// translation
int _lang;
uint8 *_landsFile;
uint8 *_levelLangFile;
int _lastUsedStringBuffer;
char _stringBuffer[5][512]; // TODO: The original used a size of 512, it looks a bit large.
// Maybe we can someday reduce the size.
char *getLangString(uint16 id);
uint8 *getTableEntry(uint8 *buffer, uint16 id);
static const char * const _languageExt[];
// graphics
void setupScreenDims();
void initSceneWindowDialogue(int controlMode);
void restoreAfterSceneWindowDialogue(int redraw);
void initDialogueSequence(int controlMode, int pageNum);
void restoreAfterDialogueSequence(int controlMode);
void resetPortraitsAndDisableSysTimer();
void toggleSelectedCharacterFrame(bool mode);
void fadeText();
void setPaletteBrightness(uint8 *palette, int brightness, int modifier);
void generateBrightnessPalette(uint8 *src, uint8 *dst, int brightness, int modifier);
void updateSequenceBackgroundAnimations();
void savePage5();
void restorePage5();
bool _dialogueField;
uint8 **_itemIconShapes;
int _numItemIconShapes;
uint8 **_itemShapes;
int _numItemShapes;
uint8 **_gameShapes;
int _numGameShapes;
uint8 **_thrownShapes;
int _numThrownShapes;
uint8 **_effectShapes;
int _numEffectShapes;
uint8 **_fireballShapes;
int _numFireballShapes;
const int8 *_gameShapeMap;
int _gameShapeMapSize;
uint8 *_characterFaceShapes[40][3];
bool _pageSavedFlag;
// characters
bool addCharacter(int id);
void setFaceFrames(int charNum, int defaultFrame, int unk2, int redraw);
void setFaceFramesUnkArrays(int charNum, int unk1, int unk2, int unk3);
int countActiveCharacters();
void loadCharFaceShapes(int charNum, int id);
void calcCharPortraitXpos();
void updatePortraitSpeechAnim();
void updatePortraits();
void initTextFading(int textType, int clearField);
void setCharFaceFrame(int charNum, int frameNum);
void faceFrameRefresh(int charNum);
void recalcCharacterStats(int charNum);
int calculateCharacterStats(int charNum, int index);
int calculateProtection(int index);
void increaseExperience(int charNum, int skill, uint32 points);
LoLCharacter *_characters;
uint16 _activeCharsXpos[3];
int _updateFlags;
int _updateCharNum;
int _updatePortraitSpeechAnimDuration;
int _portraitSpeechAnimMode;
int _updateCharV3;
int _textColourFlag;
bool _fadeText;
int _hideInventory;
uint32 _palUpdateTimer;
uint32 _updatePortraitNext;
int _loadLevelFlag;
int _levelFlagUnk;
int _unkCharNum;
int _charStatsTemp[5];
const LoLCharacter *_charDefaults;
int _charDefaultsSize;
const uint16 *_charDefsMan;
int _charDefsManSize;
const uint16 *_charDefsWoman;
int _charDefsWomanSize;
const uint16 *_charDefsKieran;
int _charDefsKieranSize;
const uint16 *_charDefsAkshel;
int _charDefsAkshelSize;
const int32 *_expRequirements;
int _expRequirementsSize;
// lamp
void resetLampStatus();
void setLampMode(bool lampOn);
void updateLampStatus();
int _lampOilStatus;
int _brightness;
int _lampStatusUnk;
uint32 _lampStatusTimer;
bool _lampStatusSuspended;
// level
void loadLevel(int index);
void addLevelItems();
void loadLevelWLL(int index, bool mapShapes);
void assignBlockObject(uint16 *cmzItemIndex, uint16 item);
int assignLevelShapes(int index);
uint8 *getLevelShapes(int index);
void loadLevelCmzFile(int index);
void loadCMZ_Sub(int index1, int index2);
void loadCmzFile(const char *file);
void loadLevelShpDat(const char *shpFile, const char *datFile, bool flag);
void loadLevelGraphics(const char *file, int specialColor, int weight, int vcnLen, int vmpLen, const char *palFile);
void resetItems(int flag);
void disableMonsters();
void resetBlockProperties();
bool testWallFlag(int block, int direction, int flag);
bool testWallInvisibility(int block, int direction);
void drawScene(int pageNum);
void generateBlockDrawingBuffer();
void generateVmpTileData(int16 startBlockX, uint8 startBlockY, uint8 wllVmpIndex, int16 vmpOffset, uint8 numBlocksX, uint8 numBlocksY);
void generateVmpTileDataFlipped(int16 startBlockX, uint8 startBlockY, uint8 wllVmpIndex, int16 vmpOffset, uint8 numBlocksX, uint8 numBlocksY);
bool hasWall(int index);
void assignVisibleBlocks(int block, int direction);
void drawVcnBlocks();
void drawSceneShapes();
void setLevelShapesDim(int index, int16 &x1, int16 &x2, int dim);
void scaleLevelShapesDim(int index, int16 &y1, int16 &y2, int dim);
void drawLevelModifyScreenDim(int dim, int16 x1, int16 y1, int16 x2, int16 y2);
void drawDecorations(int index);
void drawBlockEffects(int index, int type);
void drawScriptShapes(int pageNum);
void setWallType(int block, int wall, int val);
void updateSceneWindow();
void prepareSpecialScene(int fieldType, int hasDialogue, int suspendGui, int allowSceneUpdate, int controlMode, int fadeFlag);
int restoreAfterSpecialScene(int fadeFlag, int redrawPlayField, int releaseTimScripts, int sceneUpdateMode);
void setSequenceButtons(int x, int y, int w, int h, int enableFlags);
void setSpecialSceneButtons(int x, int y, int w, int h, int enableFlags);
void setDefaultButtonState();
void updateCompass();
void moveParty(uint16 direction, int unk1, int unk2, int buttonShape);
bool checkBlockPassability(uint16 block, uint16 direction);
void notifyBlockNotPassable(int scrollFlag);
uint16 calcNewBlockPosition(uint16 curBlock, uint16 direction);
uint16 calcBlockIndex(uint16 x, uint16 y);
void calcCoordinates(uint16 &x, uint16 &y, int block, uint16 xOffs, uint16 yOffs);
void calcCoordinatesForSingleCharacter(int charNum, int16 &x, int16 &y);
void calcCoordinatesAddDirectionOffset(int16 &x, int16 &y, int direction);
int clickedWallShape(uint16 block, uint16 direction);
int clickedLever(uint16 block, uint16 direction);
int clicked3(uint16 block, uint16 direction);
int clickedWallOnlyScript(uint16 block);
int clickedDoorSwitch(uint16 block, uint16 direction);
int clicked6(uint16 block, uint16 direction);
bool clickedShape(int shapeIndex);
void processDoorSwitch(uint16 block, int unk);
void openCloseDoor(uint16 block, int openClose);
void resetDoors();
void movePartySmoothScrollBlocked(int speed);
void movePartySmoothScrollUp(int speed);
void movePartySmoothScrollDown(int speed);
void movePartySmoothScrollLeft(int speed);
void movePartySmoothScrollRight(int speed);
void movePartySmoothScrollTurnLeft(int speed);
void movePartySmoothScrollTurnRight(int speed);
int smoothScrollDrawSpecialShape(int pageNum);
void updateAutoMap(int block);
OpenDoorState _openDoorState[3];
int _emcDoorState;
uint8 *_scrollSceneBuffer;
uint32 _smoothScrollTimer;
int _smoothScrollModeNormal;
const uint8 *_scrollXTop;
int _scrollXTopSize;
const uint8 *_scrollYTop;
int _scrollYTopSize;
const uint8 *_scrollXBottom;
int _scrollXBottomSize;
const uint8 *_scrollYBottom;
int _scrollYBottomSize;
int _unkFlag;
int _nextScriptFunc;
uint8 _currentLevel;
int _sceneDefaultUpdate;
int _lvlBlockIndex;
int _lvlShapeIndex;
bool _unkDrawLevelBool;
uint8 *_vcnBlocks;
uint8 *_vcnShift;
uint8 *_vcnExpTable;
uint16 *_vmpPtr;
uint16 *_blockDrawingBuffer;
uint8 *_sceneWindowBuffer;
LevelShapeProperty *_levelShapeProperties;
uint8 **_levelShapes;
uint8 *_scriptAssignedLevelShape;
char _lastSuppFile[12];
char _lastOverridePalFile[12];
char *_lastOverridePalFilePtr;
int _lastSpecialColor;
int _lastSpecialColorWeight;
int _sceneDrawVarDown;
int _sceneDrawVarRight;
int _sceneDrawVarLeft;
int _wllProcessFlag;
uint8 *_trueLightTable2;
uint8 *_trueLightTable1;
int _loadSuppFilesFlag;
uint8 *_wllVmpMap;
int8 *_wllShapeMap;
uint8 *_wllBuffer3;
uint8 *_wllBuffer4;
uint8 *_wllWallFlags;
int16 *_lvlShapeTop;
int16 *_lvlShapeBottom;
int16 *_lvlShapeLeftRight;
LevelBlockProperty *_levelBlockProperties;
LevelBlockProperty *_visibleBlocks[18];
uint16 _partyPosX;
uint16 _partyPosY;
Common::SeekableReadStream *_lvlShpFileHandle;
uint16 _lvlShpNum;
uint16 _levelFileDataSize;
LevelShapeProperty *_levelFileData;
uint8 *_doorShapes[2];
int _shpDmX;
int _shpDmY;
uint16 _dmScaleW;
uint16 _dmScaleH;
int _lastMouseRegion;
int _seqWindowX1, _seqWindowY1, _seqWindowX2, _seqWindowY2, _seqTrigger;
int _spsWindowX, _spsWindowY, _spsWindowW, _spsWindowH;
uint8 *_tempBuffer5120;
const char *const * _levelDatList;
int _levelDatListSize;
const char *const * _levelShpList;
int _levelShpListSize;
const int8 *_dscUnk1;
int _dscUnk1Size;
const int8 *_dscShapeIndex;
int _dscShapeIndexSize;
const uint8 *_dscOvlMap;
int _dscOvlMapSize;
const uint16 *_dscShapeScaleW;
int _dscShapeScaleWSize;
const uint16 *_dscShapeScaleH;
int _dscShapeScaleHSize;
const int16 *_dscShapeX;
int _dscShapeXSize;
const int8 *_dscShapeY;
int _dscShapeYSize;
const uint8 *_dscTileIndex;
int _dscTileIndexSize;
const uint8 *_dscUnk2;
int _dscUnk2Size;
const uint8 *_dscDoorShpIndex;
int _dscDoorShpIndexSize;
const int8 *_dscDim1;
int _dscDim1Size;
const int8 *_dscDim2;
int _dscDim2Size;
const uint8 *_dscBlockMap;
int _dscBlockMapSize;
const uint8 *_dscDimMap;
int _dscDimMapSize;
const uint16 *_dscDoorMonsterScaleTable;
int _dscDoorMonsterScaleTableSize;
const uint16 *_dscDoor4;
int _dscDoor4Size;
const uint8 *_dscShapeOvlIndex;
int _dscShapeOvlIndexSize;
const int8 *_dscBlockIndex;
int _dscBlockIndexSize;
const uint8 *_dscDoor1;
int _dscDoor1Size;
const int16 *_dscDoorMonsterX;
int _dscDoorMonsterXSize;
const int16 *_dscDoorMonsterY;
int _dscDoorMonsterYSize;
int _sceneDrawPage1;
int _sceneDrawPage2;
// items
void giveCredits(int credits, int redraw);
void takeCredits(int credits, int redraw);
int makeItem(int itemType, int curFrame, int flags);
void placeMoveLevelItem(int itemIndex, int level, int block, int xOffs, int yOffs, int flyingHeight);
bool addItemToInventory(int itemIndex);
bool testUnkItemFlags(int itemIndex);
void deleteItem(int itemIndex);
ItemInPlay *findObject(uint16 index);
void runItemScript(int charNum, int item, int sub, int next, int reg4);
void setHandItem(uint16 itemIndex);
void setItemPosition(int item, uint16 x, uint16 y, int flyingHeight, int b);
void removeLevelItem(int item, int block);
bool throwItem(int a, int item, int x, int y, int flyingHeight, int direction, int, int charNum, int c);
void endObjectFlight(FlyingObject *t, int x, int y, int objectOnNextBlock);
void processObjectFlight(FlyingObject *t, int x, int y);
void updateObjectFlightPosition(FlyingObject *t);
void objectFlightProcessHits(FlyingObject *t, int x, int y, int objectOnNextBlock);
void updateFlyingObjects(FlyingObject *t);
void assignItemToBlock(uint16 *assignedBlockObjects, int id);
int checkDrawObjectSpace(int itemX, int itemY, int partyX, int partyY);
int checkSceneForItems(uint16 *blockDrawObjects, int colour);
uint8 _moneyColumnHeight[5];
uint16 _credits;
ItemInPlay *_itemsInPlay;
ItemProperty *_itemProperties;
int _itemInHand;
uint16 _inventory[48];
int _inventoryCurItem;
int _currentControlMode;
int _specialSceneFlag;
int _lastCharInventory;
FlyingObject *_flyingObjects;
EMCData _itemScript;
const uint8 *_charInvIndex;
int _charInvIndexSize;
const uint8 *_charInvDefs;
int _charInvDefsSize;
const uint16 *_inventorySlotDesc;
int _inventorySlotDescSize;
const uint16 *_itemCost;
int _itemCostSize;
const uint8 *_stashSetupData;
int _stashSetupDataSize;
const int8 *_sceneItemOffs;
int _sceneItemOffsSize;
const FlyingObjectShape *_flyingItemShapes;
int _flyingItemShapesSize;
// monsters
void loadMonsterShapes(const char *file, int monsterIndex, int b);
void releaseMonsterShapes(int monsterIndex);
int disableMonstersForBlock(int block);
void setMonsterMode(MonsterInPlay *monster, int mode);
bool updateMonsterAdjustBlocks(MonsterInPlay *monster);
void placeMonster(MonsterInPlay *monster, uint16 x, uint16 y);
int calcMonsterDirection(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
void setMonsterDirection(MonsterInPlay *monster, int dir);
void monsterDropItems(MonsterInPlay *monster);
void removeAssignedObjectFromBlock(LevelBlockProperty *l, int id);
void removeDrawObjectFromBlock(LevelBlockProperty *l, int id);
void assignMonsterToBlock(uint16 *assignedBlockObjects, int id);
void giveItemToMonster(MonsterInPlay *monster, uint16 item);
int checkBlockBeforeObjectPlacement(int x, int y, int objectWidth, int testFlag, int wallFlag);
int checkBlockForWallsAndSufficientSpace(int block, int x, int y, int objectWidth, int testFlag, int wallFlag);
int calcMonsterSkillLevel(int id, int a);
bool checkBlockOccupiedByParty(int x, int y, int testFlag);
const uint16 *getCharacterOrMonsterStats(int id);
void drawBlockObjects(int blockArrayIndex);
void drawMonster(uint16 id);
int getMonsterCurFrame(MonsterInPlay *m, uint16 dirFlags);
void reassignDrawObjects(uint16 direction, uint16 itemIndex, LevelBlockProperty *l, bool flag);
void redrawSceneItem();
int calcItemMonsterPosition(ItemInPlay *i, uint16 direction);
void calcSpriteRelPosition(uint16 x1, uint16 y1, int &x2, int &y2, uint16 direction);
void drawDoor(uint8 *shape, uint8 *table, int index, int unk2, int w, int h, int flags);
void drawDoorOrMonsterShape(uint8 *shape, uint8 *table, int x, int y, int flags, const uint8 *ovl);
uint8 *drawItemOrMonster(uint8 *shape, uint8 *ovl, int x, int y, int fineX, int fineY, int flags, int tblValue, bool flip);
int calcDrawingLayerParameters(int srcX, int srcY, int &x2, int &y2, uint16 &w, uint16 &h, uint8 *shape, int flip);
void updateMonster(MonsterInPlay *monster);
void moveMonster(MonsterInPlay *monster);
void walkMonster(MonsterInPlay *monster);
bool chasePartyWithDistanceAttacks(MonsterInPlay *monster);
void chasePartyWithCloseAttacks(MonsterInPlay *monster);
int walkMonsterCalcNextStep(MonsterInPlay *monster);
int getMonsterDistance(uint16 block1, uint16 block2);
int walkMonster_s3(uint16 monsterBlock, int direction, int distance, uint16 curBlock);
int walkMonsterCheckDest(int x, int y, MonsterInPlay *monster, int unk);
void getNextStepCoords(int16 monsterX, int16 monsterY, int &newX, int &newY, uint16 direction);
void rearrangeAttackingMonster(MonsterInPlay *monster);
void moveStrayingMonster(MonsterInPlay *monster);
void killMonster(MonsterInPlay *monster);
MonsterInPlay *_monsters;
MonsterProperty *_monsterProperties;
uint8 **_monsterShapes;
uint8 **_monsterPalettes;
uint8 **_monsterShapesEx;
uint8 _monsterUnk[3];
uint16 _monsterCurBlock;
int _monsterLastWalkDirection;
int _monsterCountUnk;
int _monsterShiftAlt;
const uint16 *_monsterModifiers;
int _monsterModifiersSize;
const int8 *_monsterShiftOffs;
int _monsterShiftOffsSize;
const uint8 *_monsterDirFlags;
int _monsterDirFlagsSize;
const uint8 *_monsterScaleX;
int _monsterScaleXSize;
const uint8 *_monsterScaleY;
int _monsterScaleYSize;
const uint16 *_monsterScaleWH;
int _monsterScaleWHSize;
// misc
void delay(uint32 millis, bool cUpdate = false, bool isMainLoop = false);
uint8 getRandomNumberSpecial();
uint8 _unkBt1;
uint8 _unkBt2;
uint16 _unkWordArraySize8[8];
uint8 *_pageBuffer1;
uint8 *_pageBuffer2;
uint32 _rndSpecial;
// fight
int battleHitSkillTest(int16 attacker, int16 target, int skill);
int calcInflictableDamage(int16 attacker, int16 target, int hitType);
void battleHit_sub2(int16 target, int damageInflicted, int16 attacker, uint32 b);
void battleHit_sub3(MonsterInPlay *monster, int16 target, int16 damageInflicted);
int calcInflictableDamagePerStat(int16 attacker, int16 target, uint16 stat2m, int index, int hitType);
uint16 getClosestMonster(int x, int y);
uint16 getClosestPartyMember(int x, int y);
// spells
bool notEnoughMagic(int charNum, int spellNum, int spellLevel);
int8 _availableSpells[7];
int _selectedSpell;
const SpellProperty *_spellProperties;
int _spellPropertiesSize;
int _subMenuIndex;
uint16 _unkIceSHpFlag;
// unneeded
void setWalkspeed(uint8) {}
void removeHandItem() {}
bool lineIsPassable(int, int) { return false; }
// save
Common::Error loadGameState(int slot) { return Common::kNoError; }
Common::Error saveGameState(int slot, const char *saveName, const Graphics::Surface *thumbnail) { return Common::kNoError; }
};
} // end of namespace Kyra
#endif
#endif // ENABLE_LOL
|