summaryrefslogtreecommitdiff
path: root/indra/lscript/lscript_execute/lscript_readlso.cpp
blob: c88b43ed835f9f9ed001cd91ae7241a44bd4a375 (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
/** 
 * @file lscript_readlso.cpp
 * @brief classes to read lso file
 *
 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#include "linden_common.h"

#include "lscript_readlso.h"
#include "lscript_library.h"
#include "lscript_alloc.h"

LLScriptLSOParse::LLScriptLSOParse(LLFILE *fp)
{
	U8  sizearray[4];
	size_t filesize;
	S32 pos = 0;
	if (fread(&sizearray, 1, 4, fp) != 4)
	{
		llwarns << "Short read" << llendl;
		filesize = 0;
	} else {
		filesize = bytestream2integer(sizearray, pos);
	}
	mRawData = new U8[filesize];
	fseek(fp, 0, SEEK_SET);
	if (fread(mRawData, 1, filesize, fp) != filesize)
	{
		llwarns << "Short read" << llendl;
	}

	initOpCodePrinting();
}

LLScriptLSOParse::LLScriptLSOParse(U8 *buffer)
{
	mRawData = buffer;
	initOpCodePrinting();
}

LLScriptLSOParse::~LLScriptLSOParse()
{
	delete [] mRawData;
}

void LLScriptLSOParse::printData(LLFILE *fp)
{
	


	printNameDesc(fp);

	printRegisters(fp);

	printGlobals(fp);

	printGlobalFunctions(fp);

	printStates(fp);

	printHeap(fp);
}

void LLScriptLSOParse::printNameDesc(LLFILE *fp)
{
	fprintf(fp, "=============================\n\n");
}

S32 gMajorVersion = 0;

void LLScriptLSOParse::printRegisters(LLFILE *fp)
{
	// print out registers first
	S32				i;

	fprintf(fp, "=============================\n");
	fprintf(fp, "Registers\n");
	fprintf(fp, "=============================\n");
	S32 version = get_register(mRawData, LREG_VN);
	if (version == LSL2_VERSION1_END_NUMBER)
	{
		gMajorVersion = LSL2_MAJOR_VERSION_ONE;
	}
	else if (version == LSL2_VERSION_NUMBER)
	{
		gMajorVersion = LSL2_MAJOR_VERSION_TWO;
	}
	for (i = LREG_IP; i < LREG_EOF; i++)
	{
		if (i < LREG_NCE)
		{
			fprintf(fp, "%s: 0x%X\n", gLSCRIPTRegisterNames[i], get_register(mRawData, (LSCRIPTRegisters)i));
		}
		else if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
		{
			U64 data = get_register_u64(mRawData, (LSCRIPTRegisters)i);
			fprintf(fp, "%s: 0x%X%X\n", gLSCRIPTRegisterNames[i], (U32)(data>>32), (U32)(data && 0xFFFFFFFF));
		}
	}
	fprintf(fp, "=============================\n\n");
}

void LLScriptLSOParse::printGlobals(LLFILE *fp)
{
	// print out registers first
	S32				varoffset;
	S32				ivalue;
	F32				fpvalue;
	LLVector3		vvalue;
	LLQuaternion	qvalue;
	char			name[256];		/*Flawfinder: ignore*/
	U8				type;

	S32 global_v_offset = get_register(mRawData, LREG_GVR);
	S32 global_f_offset = get_register(mRawData, LREG_GFR);

	fprintf(fp, "=============================\n");
	fprintf(fp, "[0x%X] Global Variables\n", global_v_offset);
	fprintf(fp, "=============================\n");


	while (global_v_offset < global_f_offset)
	{

		// get offset to skip past name
		varoffset = global_v_offset;
		bytestream2integer(mRawData, global_v_offset);
		(void)offset; //hush little compiler
		// get typeexport
		type = *(mRawData + global_v_offset++);

		// set name
		bytestream2char(name, mRawData, global_v_offset, sizeof(name));

		switch(type)
		{
		case LST_INTEGER:
			ivalue = bytestream2integer(mRawData, global_v_offset);
			fprintf(fp, "[0x%X] integer %s = %d\n", varoffset, name, ivalue);
			break;
		case LST_FLOATINGPOINT:
			fpvalue = bytestream2float(mRawData, global_v_offset);
			fprintf(fp, "[0x%X] integer %s = %f\n", varoffset, name, fpvalue);
			break;
		case LST_STRING:
			ivalue = bytestream2integer(mRawData, global_v_offset);
			fprintf(fp, "[0x%X] string %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
			break;
		case LST_KEY:
			ivalue = bytestream2integer(mRawData, global_v_offset);
			fprintf(fp, "[0x%X] key %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
			break;
		case LST_VECTOR:
			bytestream2vector(vvalue, mRawData, global_v_offset);
			fprintf(fp, "[0x%X] vector %s = < %f, %f, %f >\n", varoffset, name, vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
			break;
		case LST_QUATERNION:
			bytestream2quaternion(qvalue, mRawData, global_v_offset);
			fprintf(fp, "[0x%X] quaternion %s = < %f, %f, %f, %f >\n", varoffset, name, qvalue.mQ[VX], qvalue.mQ[VY], qvalue.mQ[VZ], qvalue.mQ[VS]);
			break;
		case LST_LIST:
			ivalue = bytestream2integer(mRawData, global_v_offset);
			fprintf(fp, "[0x%X] list %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
			break;
		default:
			break;
		}
	}

	fprintf(fp, "=============================\n\n");
}

void LLScriptLSOParse::printGlobalFunctions(LLFILE *fp)
{
	// print out registers first
	S32				i, offset;
//	LLVector3		vvalue;		unused
//	LLQuaternion	qvalue;		unused
	char			name[256];		/*Flawfinder: ignore*/
	U8				type;

	offset = get_register(mRawData, LREG_GFR);
	S32 start_of_state = get_register(mRawData, LREG_SR);
	if (start_of_state == offset)
		return;

	S32 global_f_offset = get_register(mRawData, LREG_GFR);

	fprintf(fp, "=============================\n");
	fprintf(fp, "[0x%X] Global Functions\n", global_f_offset);
	fprintf(fp, "=============================\n");


	S32 num_functions = bytestream2integer(mRawData, offset);
	S32 orig_function_offset;
	S32 function_offset;
	S32 next_function_offset = 0;
	S32 function_number = 0;
	S32 opcode_start;
	S32 opcode_end;

	for (i = 0; i < num_functions; i++)
	{
		// jump to function
		// if this is the first function
		if (i == 0)
		{
			if (i < num_functions - 1)
			{
				function_offset = bytestream2integer(mRawData, offset);
				next_function_offset = bytestream2integer(mRawData, offset);
				function_offset += global_f_offset;
				opcode_end = next_function_offset + global_f_offset;
			}
			else
			{
				function_offset = bytestream2integer(mRawData, offset);
				function_offset += global_f_offset;
				opcode_end = get_register(mRawData, LREG_SR);
			}
		}
		else if (i < num_functions - 1)
		{
			function_offset = next_function_offset;
			next_function_offset = bytestream2integer(mRawData, offset);
			function_offset += global_f_offset;
			opcode_end = next_function_offset + global_f_offset;
		}
		else
		{
			function_offset = next_function_offset;
			function_offset += global_f_offset;
			opcode_end = get_register(mRawData, LREG_SR);
		}
		orig_function_offset = function_offset;
		// where do the opcodes start
		opcode_start = bytestream2integer(mRawData, function_offset);
		opcode_start += orig_function_offset;
		bytestream2char(name, mRawData, function_offset, sizeof(name));
		// get return type
		type = *(mRawData + function_offset++);
		fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name);
		fprintf(fp, "\tReturn Type: %s\n", LSCRIPTTypeNames[type]);
		type = *(mRawData + function_offset++);
		S32 pcount = 0;
		while (type)
		{
			bytestream2char(name, mRawData, function_offset, sizeof(name));
			fprintf(fp, "\tParameter #%d: %s %s\n", pcount++, LSCRIPTTypeNames[type], name);
			type = *(mRawData + function_offset++);
		}
		fprintf(fp, "\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
		printOpCodeRange(fp, opcode_start, opcode_end, 2);
		function_number++;
	}

	fprintf(fp, "=============================\n\n");
}

void LLScriptLSOParse::printStates(LLFILE *fp)
{
	// print out registers first
	S32				i, offset;
	U32 			j, k;
//	LLVector3		vvalue;		unused
//	LLQuaternion	qvalue;		unused
	char			name[256];		/*Flawfinder: ignore*/

	S32 state_offset = get_register(mRawData, LREG_SR);

	fprintf(fp, "=============================\n");
	fprintf(fp, "[0x%X] States\n", state_offset);
	fprintf(fp, "=============================\n");

	offset = state_offset;
	S32 num_states = bytestream2integer(mRawData, offset);
	S32 state_info_offset;
	S32 event_jump_table;
	U64 event_handlers;
	S32 event_offset;
	S32 original_event_offset;
	S32 opcode_start;
	S32 worst_case_opcode_end;
	S32 opcode_end;
	S32 stack_size;
	S32 read_ahead;
	S32 first_jump = 0;

	for (i = 0; i < num_states; i++)
	{
		state_info_offset = bytestream2integer(mRawData, offset);
		if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
			event_handlers = bytestream2u64(mRawData, offset);
		else
			event_handlers = bytestream2integer(mRawData, offset);
		if (!first_jump)
		{
			first_jump = state_info_offset;
		}
		read_ahead = offset;
		if (offset < first_jump + state_offset)
		{
			worst_case_opcode_end = bytestream2integer(mRawData, read_ahead) + state_offset;
		}
		else
		{
			worst_case_opcode_end = get_register(mRawData, LREG_HR);
		}
		state_info_offset += state_offset;
		fprintf(fp, "[0x%X] ", state_info_offset);
		state_info_offset += LSCRIPTDataSize[LST_INTEGER];
		bytestream2char(name, mRawData, state_info_offset, sizeof(name));
		fprintf(fp, "%s\n", name);

		event_jump_table = state_info_offset;

		// run run through the handlers
		for (j = LSTT_STATE_BEGIN; j < LSTT_STATE_END; j++)
		{
			if (event_handlers & LSCRIPTStateBitField[j])
			{
				event_offset = bytestream2integer(mRawData, state_info_offset);
				stack_size = bytestream2integer(mRawData, state_info_offset);

				read_ahead = event_jump_table;

				S32 temp_end;

				opcode_end = worst_case_opcode_end;
				(void)opcode_end;

				for (k = LSTT_STATE_BEGIN; k < LSTT_STATE_END; k++)
				{
					if (event_handlers & LSCRIPTStateBitField[k])
					{
						temp_end = bytestream2integer(mRawData, read_ahead);
						bytestream2integer(mRawData, read_ahead);
						(void)dummy;
						if (  (temp_end < opcode_end)
							&&(temp_end > event_offset))
						{
							opcode_end = temp_end;
						}
					}
				}

				if (event_offset)
				{
					event_offset += event_jump_table;
					if (opcode_end < worst_case_opcode_end)
						opcode_end += event_jump_table;
					original_event_offset = event_offset;

					fprintf(fp, "\t[0x%X] ", event_offset);

					opcode_start = bytestream2integer(mRawData, event_offset);
					opcode_start += original_event_offset;

					switch(j)
					{
					case LSTT_STATE_ENTRY:	// LSTT_STATE_ENTRY
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_STATE_EXIT:	// LSTT_STATE_EXIT
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_TOUCH_START:	// LSTT_TOUCH_START
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_TOUCH:	// LSTT_TOUCH
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_TOUCH_END:	// LSTT_TOUCH_END
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_COLLISION_START:	// LSTT_COLLISION_START
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_COLLISION:	// LSTT_COLLISION
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_COLLISION_END:	// LSTT_COLLISION_END
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_LAND_COLLISION_START:	// LSTT_LAND_COLLISION_START
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_LAND_COLLISION:	// LSTT_LAND_COLLISION
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_LAND_COLLISION_END:	// LSTT_LAND_COLLISION_END
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_INVENTORY:	// LSTT_INVENTORY
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						break;
					case LSTT_ATTACH:	// LSTT_ATTACH
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						break;
					case LSTT_DATASERVER:	// LSTT_DATASERVER
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						break;
					case LSTT_TIMER:	// LSTT_TIMER
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_MOVING_START:	// LSTT_MOVING_START
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_MOVING_END:	// LSTT_MOVING_END
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_CHAT:	// LSTT_CHAT
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						break;
					case LSTT_OBJECT_REZ:	// LSTT_OBJECT_REZ
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						break;
					case LSTT_REMOTE_DATA:	// LSTT_REMOTE_DATA
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						break;
					case LSTT_REZ:	// LSTT_REZ
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_SENSOR:	// LSTT_SENSOR
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						break;
					case LSTT_NO_SENSOR:	// LSTT_NO_SENSOR
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_CONTROL:	// LSTT_CONTROL
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						break;
					case LSTT_LINK_MESSAGE:	// LSTT_LINK_MESSAGE
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						break;
					case LSTT_MONEY:	// LSTT_MONEY
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						break;
					case LSTT_EMAIL:	// LSTT_EMAIL
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						break;
					case LSTT_AT_TARGET:	// LSTT_AT_TARGET
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tvector %s\n", name);
						break;
					case LSTT_NOT_AT_TARGET:	// LSTT_NOT_AT_TARGET
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_AT_ROT_TARGET:	// LSTT_AT_ROT_TARGET
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tquaternion %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tquaternion %s\n", name);
						break;
					case LSTT_NOT_AT_ROT_TARGET:	// LSTT_NOT_AT_TARGET
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						break;
					case LSTT_RTPERMISSIONS:	// LSTT_RTPERMISSIONS
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						break;
					case LSTT_HTTP_RESPONSE:	// LSTT_REMOTE_DATA ?!?!?!
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tinteger %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tlist %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						break;
					case LSTT_HTTP_REQUEST:	// LSTT_HTTP_REQUEST
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "%s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tkey %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						bytestream2char(name, mRawData, event_offset, sizeof(name));
						fprintf(fp, "\t\tstring %s\n", name);
						break;
					default:
						break;
					}
					fprintf(fp, "\t\tStack Size: %d\n", stack_size);
					fprintf(fp, "\t\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
					printOpCodeRange(fp, opcode_start, opcode_end, 3);
				}
			}
		}
	}
	fprintf(fp, "=============================\n\n");
}

void LLScriptLSOParse::printHeap(LLFILE *fp)
{
	// print out registers first

	S32 heap_offset = get_register(mRawData, LREG_HR);
	S32 heap_pointer = get_register(mRawData, LREG_HP);
	fprintf(fp, "=============================\n");
	fprintf(fp, "[0x%X - 0x%X] Heap\n", heap_offset, heap_pointer);
	fprintf(fp, "=============================\n");

	lsa_fprint_heap(mRawData, fp);
	
	fprintf(fp, "=============================\n\n");
}

void lso_print_tabs(LLFILE *fp, S32 tabs)
{
	S32 i;
	for (i = 0; i < tabs; i++)
	{
		fprintf(fp, "\t");
	}
}

void LLScriptLSOParse::printOpCodes(LLFILE *fp, S32 &offset, S32 tabs)
{
	U8 opcode = *(mRawData + offset);
	mPrintOpCodes[opcode](fp, mRawData, offset, tabs);
}

void LLScriptLSOParse::printOpCodeRange(LLFILE *fp, S32 start, S32 end, S32 tabs)
{
	while (start < end)
	{
		printOpCodes(fp, start, tabs);
	}
}

void LLScriptLSOParse::initOpCodePrinting()
{
	S32 i;
	for (i = 0; i < 256; i++)
	{
		mPrintOpCodes[i] = print_noop;
	}
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NOOP]] = print_noop;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POP]] = print_pop;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPS]] = print_pops;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPL]] = print_popl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPV]] = print_popv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPQ]] = print_popq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPARG]] = print_poparg;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPIP]] = print_popip;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPBP]] = print_popbp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSP]] = print_popsp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSLR]] = print_popslr;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUP]] = print_dup;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPS]] = print_dups;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPL]] = print_dupl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPV]] = print_dupv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPQ]] = print_dupq;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORE]] = print_store;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORES]] = print_stores;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREL]] = print_storel;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREV]] = print_storev;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREQ]] = print_storeq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREG]] = print_storeg;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGS]] = print_storegs;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGL]] = print_storegl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGV]] = print_storegv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGQ]] = print_storegq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADP]] = print_loadp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADSP]] = print_loadsp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADLP]] = print_loadlp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADVP]] = print_loadvp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADQP]] = print_loadqp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGP]] = print_loadgp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGSP]] = print_loadgsp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGLP]] = print_loadglp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGVP]] = print_loadgvp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGQP]] = print_loadgqp;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSH]] = print_push;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHS]] = print_pushs;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHL]] = print_pushl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHV]] = print_pushv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHQ]] = print_pushq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHG]] = print_pushg;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGS]] = print_pushgs;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGL]] = print_pushgl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGV]] = print_pushgv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGQ]] = print_pushgq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHIP]] = print_puship;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHSP]] = print_pushsp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHBP]] = print_pushbp;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGB]] = print_pushargb;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGI]] = print_pushargi;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGF]] = print_pushargf;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGS]] = print_pushargs;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGV]] = print_pushargv;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGQ]] = print_pushargq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHE]] = print_pushe;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEV]] = print_pushev;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEQ]] = print_pusheq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGE]] = print_pusharge;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_ADD]] = print_add;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SUB]] = print_sub;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_MUL]] = print_mul;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DIV]] = print_div;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_MOD]] = print_mod;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_EQ]] = print_eq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEQ]] = print_neq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LEQ]] = print_leq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_GEQ]] = print_geq;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LESS]] = print_less;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_GREATER]] = print_greater;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITAND]] = print_bitand;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITOR]] = print_bitor;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITXOR]] = print_bitxor;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLAND]] = print_booland;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLOR]] = print_boolor;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHL]] = print_shl;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHR]] = print_shr;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEG]] = print_neg;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITNOT]] = print_bitnot;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLNOT]] = print_boolnot;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMP]] = print_jump;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPIF]] = print_jumpif;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPNIF]] = print_jumpnif;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STATE]] = print_state;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALL]] = print_call;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_RETURN]] = print_return;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CAST]] = print_cast;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOS]] = print_stacktos;
	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOL]] = print_stacktol;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PRINT]] = print_print;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB]] = print_calllib;

	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]] = print_calllib_two_byte;
}

void print_noop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tNOOP\n", offset++);
}

void print_pop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOP\n", offset++);
}

void print_pops(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPS\n", offset++);
}

void print_popl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPL\n", offset++);
}

void print_popv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPV\n", offset++);
}

void print_popq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPQ\n", offset++);
}

void print_poparg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPARG ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_popip(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPIP\n", offset++);
}

void print_popbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPBP\n", offset++);
}

void print_popsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPSP\n", offset++);
}

void print_popslr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPOPSLR\n", offset++);
}

void print_dup(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDUP\n", offset++);
}

void print_dups(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDUPS\n", offset++);
}

void print_dupl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDUPL\n", offset++);
}

void print_dupv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDUPV\n", offset++);
}

void print_dupq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDUPQ\n", offset++);
}

void print_store(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTORE $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_stores(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTORES $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_storel(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREL $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_storev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREV $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_storeq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREQ $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_storeg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREG ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_storegs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGS ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_storegl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGL ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_storegv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGV ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_storegq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGQ ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_loadp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREP $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_loadsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREPS $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_loadlp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREPL $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_loadvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREVP $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_loadqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREQP $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_loadgp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_loadgsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGSP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_loadglp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGLP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_loadgvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGVP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_loadgqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTOREGQP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
}

void print_push(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSH $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHS $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHL $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHV $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHQ $BP + ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHG ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
}

void print_pushgs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHGS ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
}

void print_pushgl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHGL ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
}

void print_pushgv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHGV ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
}

void print_pushgq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHGQ ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
}

void print_puship(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHIP\n", offset++);
}

void print_pushbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHBP\n", offset++);
}

void print_pushsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHSP\n", offset++);
}

void print_pushargb(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGB ", offset++);
	arg = *(buffer + offset++);
	fprintf(fp, "%d\n", (U32)arg);
}

void print_pushargi(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGI ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_pushargf(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	F32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGF ", offset++);
	arg = bytestream2float(buffer, offset);
	fprintf(fp, "%f\n", arg);
}

void print_pushargs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	char arg[1024];		/*Flawfinder: ignore*/
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGS ", offset++);
	bytestream2char(arg, buffer, offset, sizeof(arg));
	fprintf(fp, "%s\n", arg);
}

void print_pushargv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	LLVector3 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
	bytestream2vector(arg, buffer, offset);
	fprintf(fp, "< %f, %f, %f >\n", arg.mV[VX], arg.mV[VY], arg.mV[VZ]);
}

void print_pushargq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	LLQuaternion arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
	bytestream2quaternion(arg, buffer, offset);
	fprintf(fp, "< %f, %f, %f, %f >\n", arg.mQ[VX], arg.mQ[VY], arg.mQ[VZ], arg.mQ[VS]);
}

void print_pushe(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHE\n", offset++);
}

void print_pushev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHEV\n", offset++);
}

void print_pusheq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHEQ\n", offset++);
}

void print_pusharge(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPUSHARGE ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}


void print_add(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tADD ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_sub(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSUB ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_mul(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tMUL ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_div(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tDIV ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_mod(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tMOD ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_eq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tEQ ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_neq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tNEQ ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_leq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tLEQ ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_geq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tGEQ ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_less(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tLESS ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_greater(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tGREATER ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}


void print_bitand(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBITAND\n", offset++);
}

void print_bitor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBITOR\n", offset++);
}

void print_bitxor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBITXOR\n", offset++);
}

void print_booland(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBOOLAND\n", offset++);
}

void print_boolor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBOOLOR\n", offset++);
}

void print_shl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSHL\n", offset++);
}

void print_shr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSHR\n", offset++);
}


void print_neg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 type;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tNEG ", offset++);
	type = *(buffer + offset++);
	fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
}

void print_bitnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBITNOT\n", offset++);
}

void print_boolnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tBOOLNOT\n", offset++);
}

void print_jump(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tJUMP ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_jumpif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	U8 type;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tJUMPIF ", offset++);
	type = *(buffer + offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
}

void print_jumpnif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	U8 type;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tJUMPNIF ", offset++);
	type = *(buffer + offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
}

void print_state(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTATE ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_call(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tCALL ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_return(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tRETURN\n", offset++);
}

void print_cast(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 types;
	U8 type1;
	U8 type2;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tCAST ", offset++);
	types = *(buffer + offset++);
	type1 = types >> 4;
	type2 = types & 0xf;
	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
}

void print_stacktos(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTACKTOS ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_stacktol(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	S32 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tSTACKTOL ", offset++);
	arg = bytestream2integer(buffer, offset);
	fprintf(fp, "%d\n", arg);
}

void print_print(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tPRINT ", offset++);
	U8 type = *(buffer + offset++);
	fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
}

void print_calllib(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U8 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tCALLLIB ", offset++);
	arg = *(buffer + offset++);
	fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
}


void print_calllib_two_byte(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
{
	U16 arg;
	lso_print_tabs(fp, tabs);
	fprintf(fp, "[0x%X]\tCALLLIB_TWO_BYTE ", offset++);
	arg = bytestream2u16(buffer, offset);
	fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
}