@@ -740,6 +740,137 @@ void Script_v1::o1_goblinFunc(FuncParams ¶ms) {
740
740
goblinOpcode (cmd, gobParams);
741
741
}
742
742
743
+ enum Type {
744
+ kTypeNone = 0 ,
745
+ kTypeMove = 1 ,
746
+ kTypeClick = 2 ,
747
+ kTypeInput1NoLeave = 3 ,
748
+ kTypeInput1Leave = 4 ,
749
+ kTypeInput2NoLeave = 5 ,
750
+ kTypeInput2Leave = 6 ,
751
+ kTypeInput3NoLeave = 7 ,
752
+ kTypeInput3Leave = 8 ,
753
+ kTypeInputFloatNoLeave = 9 ,
754
+ kTypeInputFloatLeave = 10 ,
755
+ kTypeEnable2 = 11 ,
756
+ kTypeEnable1 = 12 ,
757
+ kTypeClickEnter = 21
758
+ };
759
+
760
+ void Script_v1::hotspotsEvaluate ()
761
+ {
762
+ skip (1 );
763
+ byte count = readUint8 ();
764
+ printIndent ();
765
+ print (" set_hotspot_count(%d);\n " , count);
766
+
767
+ printIndent ();
768
+ print (" set_hotspot_properties(handleMouse=%d, duration=%d, leaveWinIndex=%d, hotspotIndex1=%d, hotspotIndex2=%d, needRecalc=%d)\n " ,
769
+ peekUint8 (0 ),
770
+ peekUint8 (1 ),
771
+ peekUint8 (2 ),
772
+ peekUint8 (3 ),
773
+ peekUint8 (4 ),
774
+ peekUint8 (5 ) != 0 );
775
+
776
+ skip (6 );
777
+
778
+ for (uint16 i = 0 ; i < count; i++) {
779
+ printIndent ();
780
+ print (" add_hotspot(%d, " , i);
781
+ byte type = readUint8 ();
782
+ print (" %d" , type);
783
+ if ((type & 0x40 ) != 0 ) {
784
+ type -= 0x40 ;
785
+ print (" , %d" , readUint8 ());
786
+ }
787
+ if ((type & 0x80 ) != 0 ) {
788
+ // Complex coordinate expressions
789
+ print (" , %d" , getPos ());
790
+ print (" , %s" , readExpr ().c_str ());
791
+ print (" , %s" , readExpr ().c_str ());
792
+ print (" , %s" , readExpr ().c_str ());
793
+ print (" , %s" , readExpr ().c_str ());
794
+ } else {
795
+ // Immediate values
796
+ print (" , %d" , readUint16 ());
797
+ print (" , %d" , readUint16 ());
798
+ print (" , %d" , readUint16 ());
799
+ print (" , %d" , readUint16 ());
800
+ }
801
+
802
+ type &= 0x7F ;
803
+
804
+ // Evaluate parameters for the new hotspot
805
+ switch (type) {
806
+ // TODO: handle kTypeEnable1 and kTypeEnable2 types
807
+ case kTypeNone :
808
+ skip (6 );
809
+ print (" , %d" , getPos ());
810
+ addFuncOffset (getPos ());
811
+ skipBlock ();
812
+ print (" , %d" , getPos ());
813
+ addFuncOffset (getPos ());
814
+ skipBlock ();
815
+ break ;
816
+
817
+ case kTypeMove :
818
+ print (" , %d" , readUint16 ());
819
+ print (" , %d" , readUint16 ());
820
+ print (" , %d" , readUint16 ());
821
+ print (" , %d" , getPos ());
822
+ addFuncOffset (getPos ());
823
+ skipBlock ();
824
+ print (" , %d" , getPos ());
825
+ addFuncOffset (getPos ());
826
+ skipBlock ();
827
+ break ;
828
+
829
+ case kTypeInput1NoLeave :
830
+ case kTypeInput1Leave :
831
+ case kTypeInput2NoLeave :
832
+ case kTypeInput2Leave :
833
+ case kTypeInput3NoLeave :
834
+ case kTypeInput3Leave :
835
+ case kTypeInputFloatNoLeave :
836
+ case kTypeInputFloatLeave :
837
+ print (" , %d" , readUint16 ());
838
+ print (" , %d" , readUint16 ());
839
+ print (" , %d" , readUint8 ());
840
+ print (" , %d" , readUint8 ());
841
+ if ((type >= kTypeInput2NoLeave ) && (type <= kTypeInput3Leave )) {
842
+ print (" , %d" , readUint16 ());
843
+ print (" , %s" , readString ());
844
+ }
845
+ skipBlock ();
846
+ break ;
847
+
848
+ case 20 :
849
+ case kTypeClick :
850
+ print (" , %d" , readUint16 ());
851
+ print (" , %d" , readUint16 ());
852
+ print (" , %d" , readUint16 ());
853
+ print (" , 0" );
854
+ print (" , %d" , getPos ());
855
+ addFuncOffset (getPos ());
856
+ skipBlock ();
857
+ break ;
858
+
859
+ case kTypeClickEnter :
860
+ print (" , %d" , readUint16 ());
861
+ print (" , %d" , readUint16 ());
862
+ print (" , %d" , readUint16 () & 3 );
863
+ print (" , %d" , getPos ());
864
+ addFuncOffset (getPos ());
865
+ skipBlock ();
866
+ print (" , 0" );
867
+ break ;
868
+ }
869
+
870
+ print (" );\n " );
871
+ }
872
+ }
873
+
743
874
void Script_v1::o1_callSub (FuncParams ¶ms) {
744
875
uint16 offset = readUint16 ();
745
876
@@ -753,8 +884,14 @@ void Script_v1::o1_callSub(FuncParams ¶ms) {
753
884
print (" sub_%d();\n " , offset);
754
885
if (offset >= 128 )
755
886
addFuncOffset (offset);
756
- } else if (peekUint8 () == 2 )
757
- print (" _hotspots->evaluate()(%d);\n " , offset);
887
+ } else if (peekUint8 () == 2 ) {
888
+ print (" _hotspots->evaluate()(%d) {\n " , offset);
889
+ incIndent ();
890
+ hotspotsEvaluate ();
891
+ decIndent ();
892
+ printIndent ();
893
+ print (" }\n " );
894
+ }
758
895
else
759
896
print (" <Unknown block type %d (%d)>\n " , peekUint8 (), offset);
760
897
0 commit comments