PageRenderTime 1182ms CodeModel.GetById 171ms app.highlight 880ms RepoModel.GetById 116ms app.codeStats 1ms

/indra/lscript/lscript_execute/lscript_readlso.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1588 lines | 1374 code | 172 blank | 42 comment | 41 complexity | 72f490ea59b6a0fbb097cae43f9405a8 MD5 | raw file
   1/** 
   2 * @file lscript_readlso.cpp
   3 * @brief classes to read lso file
   4 *
   5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
   6 * Second Life Viewer Source Code
   7 * Copyright (C) 2010, Linden Research, Inc.
   8 * 
   9 * This library is free software; you can redistribute it and/or
  10 * modify it under the terms of the GNU Lesser General Public
  11 * License as published by the Free Software Foundation;
  12 * version 2.1 of the License only.
  13 * 
  14 * This library is distributed in the hope that it will be useful,
  15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17 * Lesser General Public License for more details.
  18 * 
  19 * You should have received a copy of the GNU Lesser General Public
  20 * License along with this library; if not, write to the Free Software
  21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  22 * 
  23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  24 * $/LicenseInfo$
  25 */
  26
  27#include "linden_common.h"
  28
  29#include "lscript_readlso.h"
  30#include "lscript_library.h"
  31#include "lscript_alloc.h"
  32
  33LLScriptLSOParse::LLScriptLSOParse(LLFILE *fp)
  34{
  35	U8  sizearray[4];
  36	size_t filesize;
  37	S32 pos = 0;
  38	if (fread(&sizearray, 1, 4, fp) != 4)
  39	{
  40		llwarns << "Short read" << llendl;
  41		filesize = 0;
  42	} else {
  43		filesize = bytestream2integer(sizearray, pos);
  44	}
  45	mRawData = new U8[filesize];
  46	fseek(fp, 0, SEEK_SET);
  47	if (fread(mRawData, 1, filesize, fp) != filesize)
  48	{
  49		llwarns << "Short read" << llendl;
  50	}
  51
  52	initOpCodePrinting();
  53}
  54
  55LLScriptLSOParse::LLScriptLSOParse(U8 *buffer)
  56{
  57	mRawData = buffer;
  58	initOpCodePrinting();
  59}
  60
  61LLScriptLSOParse::~LLScriptLSOParse()
  62{
  63	delete [] mRawData;
  64}
  65
  66void LLScriptLSOParse::printData(LLFILE *fp)
  67{
  68	
  69
  70
  71	printNameDesc(fp);
  72
  73	printRegisters(fp);
  74
  75	printGlobals(fp);
  76
  77	printGlobalFunctions(fp);
  78
  79	printStates(fp);
  80
  81	printHeap(fp);
  82}
  83
  84void LLScriptLSOParse::printNameDesc(LLFILE *fp)
  85{
  86	fprintf(fp, "=============================\n\n");
  87}
  88
  89S32 gMajorVersion = 0;
  90
  91void LLScriptLSOParse::printRegisters(LLFILE *fp)
  92{
  93	// print out registers first
  94	S32				i;
  95
  96	fprintf(fp, "=============================\n");
  97	fprintf(fp, "Registers\n");
  98	fprintf(fp, "=============================\n");
  99	S32 version = get_register(mRawData, LREG_VN);
 100	if (version == LSL2_VERSION1_END_NUMBER)
 101	{
 102		gMajorVersion = LSL2_MAJOR_VERSION_ONE;
 103	}
 104	else if (version == LSL2_VERSION_NUMBER)
 105	{
 106		gMajorVersion = LSL2_MAJOR_VERSION_TWO;
 107	}
 108	for (i = LREG_IP; i < LREG_EOF; i++)
 109	{
 110		if (i < LREG_NCE)
 111		{
 112			fprintf(fp, "%s: 0x%X\n", gLSCRIPTRegisterNames[i], get_register(mRawData, (LSCRIPTRegisters)i));
 113		}
 114		else if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
 115		{
 116			U64 data = get_register_u64(mRawData, (LSCRIPTRegisters)i);
 117			fprintf(fp, "%s: 0x%X%X\n", gLSCRIPTRegisterNames[i], (U32)(data>>32), (U32)(data && 0xFFFFFFFF));
 118		}
 119	}
 120	fprintf(fp, "=============================\n\n");
 121}
 122
 123void LLScriptLSOParse::printGlobals(LLFILE *fp)
 124{
 125	// print out registers first
 126	S32				offset, varoffset;
 127	S32				ivalue;
 128	F32				fpvalue;
 129	LLVector3		vvalue;
 130	LLQuaternion	qvalue;
 131	char			name[256];		/*Flawfinder: ignore*/
 132	U8				type;
 133
 134	S32 global_v_offset = get_register(mRawData, LREG_GVR);
 135	S32 global_f_offset = get_register(mRawData, LREG_GFR);
 136
 137	fprintf(fp, "=============================\n");
 138	fprintf(fp, "[0x%X] Global Variables\n", global_v_offset);
 139	fprintf(fp, "=============================\n");
 140
 141
 142	while (global_v_offset < global_f_offset)
 143	{
 144
 145		// get offset to skip past name
 146		varoffset = global_v_offset;
 147		offset = bytestream2integer(mRawData, global_v_offset);
 148		
 149		// get typeexport
 150		type = *(mRawData + global_v_offset++);
 151
 152		// set name
 153		bytestream2char(name, mRawData, global_v_offset, sizeof(name));
 154
 155		switch(type)
 156		{
 157		case LST_INTEGER:
 158			ivalue = bytestream2integer(mRawData, global_v_offset);
 159			fprintf(fp, "[0x%X] integer %s = %d\n", varoffset, name, ivalue);
 160			break;
 161		case LST_FLOATINGPOINT:
 162			fpvalue = bytestream2float(mRawData, global_v_offset);
 163			fprintf(fp, "[0x%X] integer %s = %f\n", varoffset, name, fpvalue);
 164			break;
 165		case LST_STRING:
 166			ivalue = bytestream2integer(mRawData, global_v_offset);
 167			fprintf(fp, "[0x%X] string %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
 168			break;
 169		case LST_KEY:
 170			ivalue = bytestream2integer(mRawData, global_v_offset);
 171			fprintf(fp, "[0x%X] key %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
 172			break;
 173		case LST_VECTOR:
 174			bytestream2vector(vvalue, mRawData, global_v_offset);
 175			fprintf(fp, "[0x%X] vector %s = < %f, %f, %f >\n", varoffset, name, vvalue.mV[VX], vvalue.mV[VY], vvalue.mV[VZ]);
 176			break;
 177		case LST_QUATERNION:
 178			bytestream2quaternion(qvalue, mRawData, global_v_offset);
 179			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]);
 180			break;
 181		case LST_LIST:
 182			ivalue = bytestream2integer(mRawData, global_v_offset);
 183			fprintf(fp, "[0x%X] list %s = 0x%X\n", varoffset, name, ivalue + get_register(mRawData, LREG_HR) - 1);
 184			break;
 185		default:
 186			break;
 187		}
 188	}
 189
 190	fprintf(fp, "=============================\n\n");
 191}
 192
 193void LLScriptLSOParse::printGlobalFunctions(LLFILE *fp)
 194{
 195	// print out registers first
 196	S32				i, offset;
 197//	LLVector3		vvalue;		unused
 198//	LLQuaternion	qvalue;		unused
 199	char			name[256];		/*Flawfinder: ignore*/
 200	U8				type;
 201
 202	offset = get_register(mRawData, LREG_GFR);
 203	S32 start_of_state = get_register(mRawData, LREG_SR);
 204	if (start_of_state == offset)
 205		return;
 206
 207	S32 global_f_offset = get_register(mRawData, LREG_GFR);
 208
 209	fprintf(fp, "=============================\n");
 210	fprintf(fp, "[0x%X] Global Functions\n", global_f_offset);
 211	fprintf(fp, "=============================\n");
 212
 213
 214	S32 num_functions = bytestream2integer(mRawData, offset);
 215	S32 orig_function_offset;
 216	S32 function_offset;
 217	S32 next_function_offset = 0;
 218	S32 function_number = 0;
 219	S32 opcode_start;
 220	S32 opcode_end;
 221
 222	for (i = 0; i < num_functions; i++)
 223	{
 224		// jump to function
 225		// if this is the first function
 226		if (i == 0)
 227		{
 228			if (i < num_functions - 1)
 229			{
 230				function_offset = bytestream2integer(mRawData, offset);
 231				next_function_offset = bytestream2integer(mRawData, offset);
 232				function_offset += global_f_offset;
 233				opcode_end = next_function_offset + global_f_offset;
 234			}
 235			else
 236			{
 237				function_offset = bytestream2integer(mRawData, offset);
 238				function_offset += global_f_offset;
 239				opcode_end = get_register(mRawData, LREG_SR);
 240			}
 241		}
 242		else if (i < num_functions - 1)
 243		{
 244			function_offset = next_function_offset;
 245			next_function_offset = bytestream2integer(mRawData, offset);
 246			function_offset += global_f_offset;
 247			opcode_end = next_function_offset + global_f_offset;
 248		}
 249		else
 250		{
 251			function_offset = next_function_offset;
 252			function_offset += global_f_offset;
 253			opcode_end = get_register(mRawData, LREG_SR);
 254		}
 255		orig_function_offset = function_offset;
 256		// where do the opcodes start
 257		opcode_start = bytestream2integer(mRawData, function_offset);
 258		opcode_start += orig_function_offset;
 259		bytestream2char(name, mRawData, function_offset, sizeof(name));
 260		// get return type
 261		type = *(mRawData + function_offset++);
 262		fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name);
 263		fprintf(fp, "\tReturn Type: %s\n", LSCRIPTTypeNames[type]);
 264		type = *(mRawData + function_offset++);
 265		S32 params;
 266		params = 0;
 267		S32 pcount = 0;
 268		while (type)
 269		{
 270			bytestream2char(name, mRawData, function_offset, sizeof(name));
 271			fprintf(fp, "\tParameter #%d: %s %s\n", pcount++, LSCRIPTTypeNames[type], name);
 272			type = *(mRawData + function_offset++);
 273		}
 274		fprintf(fp, "\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
 275		printOpCodeRange(fp, opcode_start, opcode_end, 2);
 276		function_number++;
 277	}
 278
 279	fprintf(fp, "=============================\n\n");
 280}
 281
 282void LLScriptLSOParse::printStates(LLFILE *fp)
 283{
 284	// print out registers first
 285	S32				i, offset;
 286	U32 			j, k;
 287//	LLVector3		vvalue;		unused
 288//	LLQuaternion	qvalue;		unused
 289	char			name[256];		/*Flawfinder: ignore*/
 290
 291	S32 state_offset = get_register(mRawData, LREG_SR);
 292
 293	fprintf(fp, "=============================\n");
 294	fprintf(fp, "[0x%X] States\n", state_offset);
 295	fprintf(fp, "=============================\n");
 296
 297	offset = state_offset;
 298	S32 num_states = bytestream2integer(mRawData, offset);
 299	S32 state_info_offset;
 300	S32 event_jump_table;
 301	U64 event_handlers;
 302	S32 event_offset;
 303	S32 original_event_offset;
 304	S32 opcode_start;
 305	S32 worst_case_opcode_end;
 306	S32 opcode_end;
 307	S32 stack_size;
 308	S32 read_ahead;
 309	S32 first_jump = 0;
 310
 311	for (i = 0; i < num_states; i++)
 312	{
 313		state_info_offset = bytestream2integer(mRawData, offset);
 314		if (gMajorVersion == LSL2_MAJOR_VERSION_TWO)
 315			event_handlers = bytestream2u64(mRawData, offset);
 316		else
 317			event_handlers = bytestream2integer(mRawData, offset);
 318		if (!first_jump)
 319		{
 320			first_jump = state_info_offset;
 321		}
 322		read_ahead = offset;
 323		if (offset < first_jump + state_offset)
 324		{
 325			worst_case_opcode_end = bytestream2integer(mRawData, read_ahead) + state_offset;
 326		}
 327		else
 328		{
 329			worst_case_opcode_end = get_register(mRawData, LREG_HR);
 330		}
 331		state_info_offset += state_offset;
 332		fprintf(fp, "[0x%X] ", state_info_offset);
 333		state_info_offset += LSCRIPTDataSize[LST_INTEGER];
 334		bytestream2char(name, mRawData, state_info_offset, sizeof(name));
 335		fprintf(fp, "%s\n", name);
 336
 337		event_jump_table = state_info_offset;
 338
 339		// run run through the handlers
 340		for (j = LSTT_STATE_BEGIN; j < LSTT_STATE_END; j++)
 341		{
 342			if (event_handlers & LSCRIPTStateBitField[j])
 343			{
 344				event_offset = bytestream2integer(mRawData, state_info_offset);
 345				stack_size = bytestream2integer(mRawData, state_info_offset);
 346
 347				read_ahead = event_jump_table;
 348
 349				S32 temp_end;
 350				S32 dummy;
 351
 352				opcode_end = worst_case_opcode_end;
 353
 354				for (k = LSTT_STATE_BEGIN; k < LSTT_STATE_END; k++)
 355				{
 356					if (event_handlers & LSCRIPTStateBitField[k])
 357					{
 358						temp_end = bytestream2integer(mRawData, read_ahead);
 359						dummy = bytestream2integer(mRawData, read_ahead);
 360						if (  (temp_end < opcode_end)
 361							&&(temp_end > event_offset))
 362						{
 363							opcode_end = temp_end;
 364						}
 365					}
 366				}
 367
 368				if (event_offset)
 369				{
 370					event_offset += event_jump_table;
 371					if (opcode_end < worst_case_opcode_end)
 372						opcode_end += event_jump_table;
 373					original_event_offset = event_offset;
 374
 375					fprintf(fp, "\t[0x%X] ", event_offset);
 376
 377					opcode_start = bytestream2integer(mRawData, event_offset);
 378					opcode_start += original_event_offset;
 379
 380					switch(j)
 381					{
 382					case LSTT_STATE_ENTRY:	// LSTT_STATE_ENTRY
 383						bytestream2char(name, mRawData, event_offset, sizeof(name));
 384						fprintf(fp, "%s\n", name);
 385						break;
 386					case LSTT_STATE_EXIT:	// LSTT_STATE_EXIT
 387						bytestream2char(name, mRawData, event_offset, sizeof(name));
 388						fprintf(fp, "%s\n", name);
 389						break;
 390					case LSTT_TOUCH_START:	// LSTT_TOUCH_START
 391						bytestream2char(name, mRawData, event_offset, sizeof(name));
 392						fprintf(fp, "%s\n", name);
 393						bytestream2char(name, mRawData, event_offset, sizeof(name));
 394						fprintf(fp, "\t\tkey %s\n", name);
 395						bytestream2char(name, mRawData, event_offset, sizeof(name));
 396						fprintf(fp, "\t\tvector %s\n", name);
 397						break;
 398					case LSTT_TOUCH:	// LSTT_TOUCH
 399						bytestream2char(name, mRawData, event_offset, sizeof(name));
 400						fprintf(fp, "%s\n", name);
 401						bytestream2char(name, mRawData, event_offset, sizeof(name));
 402						fprintf(fp, "\t\tkey %s\n", name);
 403						bytestream2char(name, mRawData, event_offset, sizeof(name));
 404						fprintf(fp, "\t\tvector %s\n", name);
 405						break;
 406					case LSTT_TOUCH_END:	// LSTT_TOUCH_END
 407						bytestream2char(name, mRawData, event_offset, sizeof(name));
 408						fprintf(fp, "%s\n", name);
 409						bytestream2char(name, mRawData, event_offset, sizeof(name));
 410						fprintf(fp, "\t\tkey %s\n", name);
 411						bytestream2char(name, mRawData, event_offset, sizeof(name));
 412						fprintf(fp, "\t\tvector %s\n", name);
 413						break;
 414					case LSTT_COLLISION_START:	// LSTT_COLLISION_START
 415						bytestream2char(name, mRawData, event_offset, sizeof(name));
 416						fprintf(fp, "%s\n", name);
 417						bytestream2char(name, mRawData, event_offset, sizeof(name));
 418						fprintf(fp, "\t\tkey %s\n", name);
 419						bytestream2char(name, mRawData, event_offset, sizeof(name));
 420						fprintf(fp, "\t\tvector %s\n", name);
 421						bytestream2char(name, mRawData, event_offset, sizeof(name));
 422						fprintf(fp, "\t\tvector %s\n", name);
 423						break;
 424					case LSTT_COLLISION:	// LSTT_COLLISION
 425						bytestream2char(name, mRawData, event_offset, sizeof(name));
 426						fprintf(fp, "%s\n", name);
 427						bytestream2char(name, mRawData, event_offset, sizeof(name));
 428						fprintf(fp, "\t\tkey %s\n", name);
 429						bytestream2char(name, mRawData, event_offset, sizeof(name));
 430						fprintf(fp, "\t\tvector %s\n", name);
 431						bytestream2char(name, mRawData, event_offset, sizeof(name));
 432						fprintf(fp, "\t\tvector %s\n", name);
 433						break;
 434					case LSTT_COLLISION_END:	// LSTT_COLLISION_END
 435						bytestream2char(name, mRawData, event_offset, sizeof(name));
 436						fprintf(fp, "%s\n", name);
 437						bytestream2char(name, mRawData, event_offset, sizeof(name));
 438						fprintf(fp, "\t\tkey %s\n", name);
 439						bytestream2char(name, mRawData, event_offset, sizeof(name));
 440						fprintf(fp, "\t\tvector %s\n", name);
 441						bytestream2char(name, mRawData, event_offset, sizeof(name));
 442						fprintf(fp, "\t\tvector %s\n", name);
 443						break;
 444					case LSTT_LAND_COLLISION_START:	// LSTT_LAND_COLLISION_START
 445						bytestream2char(name, mRawData, event_offset, sizeof(name));
 446						fprintf(fp, "%s\n", name);
 447						bytestream2char(name, mRawData, event_offset, sizeof(name));
 448						fprintf(fp, "\t\tvector %s\n", name);
 449						break;
 450					case LSTT_LAND_COLLISION:	// LSTT_LAND_COLLISION
 451						bytestream2char(name, mRawData, event_offset, sizeof(name));
 452						fprintf(fp, "%s\n", name);
 453						bytestream2char(name, mRawData, event_offset, sizeof(name));
 454						fprintf(fp, "\t\tvector %s\n", name);
 455						break;
 456					case LSTT_LAND_COLLISION_END:	// LSTT_LAND_COLLISION_END
 457						bytestream2char(name, mRawData, event_offset, sizeof(name));
 458						fprintf(fp, "%s\n", name);
 459						bytestream2char(name, mRawData, event_offset, sizeof(name));
 460						fprintf(fp, "\t\tvector %s\n", name);
 461						break;
 462					case LSTT_INVENTORY:	// LSTT_INVENTORY
 463						bytestream2char(name, mRawData, event_offset, sizeof(name));
 464						fprintf(fp, "%s\n", name);
 465						bytestream2char(name, mRawData, event_offset, sizeof(name));
 466						fprintf(fp, "\t\tinteger %s\n", name);
 467						break;
 468					case LSTT_ATTACH:	// LSTT_ATTACH
 469						bytestream2char(name, mRawData, event_offset, sizeof(name));
 470						fprintf(fp, "%s\n", name);
 471						bytestream2char(name, mRawData, event_offset, sizeof(name));
 472						fprintf(fp, "\t\tkey %s\n", name);
 473						break;
 474					case LSTT_DATASERVER:	// LSTT_DATASERVER
 475						bytestream2char(name, mRawData, event_offset, sizeof(name));
 476						fprintf(fp, "%s\n", name);
 477						bytestream2char(name, mRawData, event_offset, sizeof(name));
 478						fprintf(fp, "\t\tkey %s\n", name);
 479						bytestream2char(name, mRawData, event_offset, sizeof(name));
 480						fprintf(fp, "\t\tstring %s\n", name);
 481						break;
 482					case LSTT_TIMER:	// LSTT_TIMER
 483						bytestream2char(name, mRawData, event_offset, sizeof(name));
 484						fprintf(fp, "%s\n", name);
 485						break;
 486					case LSTT_MOVING_START:	// LSTT_MOVING_START
 487						bytestream2char(name, mRawData, event_offset, sizeof(name));
 488						fprintf(fp, "%s\n", name);
 489						break;
 490					case LSTT_MOVING_END:	// LSTT_MOVING_END
 491						bytestream2char(name, mRawData, event_offset, sizeof(name));
 492						fprintf(fp, "%s\n", name);
 493						break;
 494					case LSTT_CHAT:	// LSTT_CHAT
 495						bytestream2char(name, mRawData, event_offset, sizeof(name));
 496						fprintf(fp, "%s\n", name);
 497						bytestream2char(name, mRawData, event_offset, sizeof(name));
 498						fprintf(fp, "\t\tinteger %s\n", name);
 499						bytestream2char(name, mRawData, event_offset, sizeof(name));
 500						fprintf(fp, "\t\tkey %s\n", name);
 501						bytestream2char(name, mRawData, event_offset, sizeof(name));
 502						fprintf(fp, "\t\tstring %s\n", name);
 503						break;
 504					case LSTT_OBJECT_REZ:	// LSTT_OBJECT_REZ
 505						bytestream2char(name, mRawData, event_offset, sizeof(name));
 506						fprintf(fp, "%s\n", name);
 507						bytestream2char(name, mRawData, event_offset, sizeof(name));
 508						fprintf(fp, "\t\tkey %s\n", name);
 509						break;
 510					case LSTT_REMOTE_DATA:	// LSTT_REMOTE_DATA
 511						bytestream2char(name, mRawData, event_offset, sizeof(name));
 512						fprintf(fp, "%s\n", name);
 513						bytestream2char(name, mRawData, event_offset, sizeof(name));
 514						fprintf(fp, "\t\tinteger %s\n", name);
 515						bytestream2char(name, mRawData, event_offset, sizeof(name));
 516						fprintf(fp, "\t\tkey %s\n", name);
 517						bytestream2char(name, mRawData, event_offset, sizeof(name));
 518						fprintf(fp, "\t\tinteger %s\n", name);
 519						bytestream2char(name, mRawData, event_offset, sizeof(name));
 520						fprintf(fp, "\t\tstring %s\n", name);
 521						break;
 522					case LSTT_REZ:	// LSTT_REZ
 523						bytestream2char(name, mRawData, event_offset, sizeof(name));
 524						fprintf(fp, "%s\n", name);
 525						break;
 526					case LSTT_SENSOR:	// LSTT_SENSOR
 527						bytestream2char(name, mRawData, event_offset, sizeof(name));
 528						fprintf(fp, "%s\n", name);
 529						bytestream2char(name, mRawData, event_offset, sizeof(name));
 530						fprintf(fp, "\t\tinteger %s\n", name);
 531						break;
 532					case LSTT_NO_SENSOR:	// LSTT_NO_SENSOR
 533						bytestream2char(name, mRawData, event_offset, sizeof(name));
 534						fprintf(fp, "%s\n", name);
 535						break;
 536					case LSTT_CONTROL:	// LSTT_CONTROL
 537						bytestream2char(name, mRawData, event_offset, sizeof(name));
 538						fprintf(fp, "%s\n", name);
 539						bytestream2char(name, mRawData, event_offset, sizeof(name));
 540						fprintf(fp, "\t\tkey %s\n", name);
 541						bytestream2char(name, mRawData, event_offset, sizeof(name));
 542						fprintf(fp, "\t\tinteger %s\n", name);
 543						bytestream2char(name, mRawData, event_offset, sizeof(name));
 544						fprintf(fp, "\t\tinteger %s\n", name);
 545						break;
 546					case LSTT_LINK_MESSAGE:	// LSTT_LINK_MESSAGE
 547						bytestream2char(name, mRawData, event_offset, sizeof(name));
 548						fprintf(fp, "%s\n", name);
 549						bytestream2char(name, mRawData, event_offset, sizeof(name));
 550						fprintf(fp, "\t\tinteger %s\n", name);
 551						bytestream2char(name, mRawData, event_offset, sizeof(name));
 552						fprintf(fp, "\t\tstring %s\n", name);
 553						bytestream2char(name, mRawData, event_offset, sizeof(name));
 554						fprintf(fp, "\t\tkey %s\n", name);
 555						break;
 556					case LSTT_MONEY:	// LSTT_MONEY
 557						bytestream2char(name, mRawData, event_offset, sizeof(name));
 558						fprintf(fp, "%s\n", name);
 559						bytestream2char(name, mRawData, event_offset, sizeof(name));
 560						fprintf(fp, "\t\tkey %s\n", name);
 561						bytestream2char(name, mRawData, event_offset, sizeof(name));
 562						fprintf(fp, "\t\tinteger %s\n", name);
 563						break;
 564					case LSTT_EMAIL:	// LSTT_EMAIL
 565						bytestream2char(name, mRawData, event_offset, sizeof(name));
 566						fprintf(fp, "%s\n", name);
 567						bytestream2char(name, mRawData, event_offset, sizeof(name));
 568						fprintf(fp, "\t\tstring %s\n", name);
 569						bytestream2char(name, mRawData, event_offset, sizeof(name));
 570						fprintf(fp, "\t\tstring %s\n", name);
 571						bytestream2char(name, mRawData, event_offset, sizeof(name));
 572						fprintf(fp, "\t\tstring %s\n", name);
 573						bytestream2char(name, mRawData, event_offset, sizeof(name));
 574						fprintf(fp, "\t\tinteger %s\n", name);
 575						break;
 576					case LSTT_AT_TARGET:	// LSTT_AT_TARGET
 577						bytestream2char(name, mRawData, event_offset, sizeof(name));
 578						fprintf(fp, "%s\n", name);
 579						bytestream2char(name, mRawData, event_offset, sizeof(name));
 580						fprintf(fp, "\t\tinteger %s\n", name);
 581						bytestream2char(name, mRawData, event_offset, sizeof(name));
 582						fprintf(fp, "\t\tvector %s\n", name);
 583						bytestream2char(name, mRawData, event_offset, sizeof(name));
 584						fprintf(fp, "\t\tvector %s\n", name);
 585						break;
 586					case LSTT_NOT_AT_TARGET:	// LSTT_NOT_AT_TARGET
 587						bytestream2char(name, mRawData, event_offset, sizeof(name));
 588						fprintf(fp, "%s\n", name);
 589						break;
 590					case LSTT_AT_ROT_TARGET:	// LSTT_AT_ROT_TARGET
 591						bytestream2char(name, mRawData, event_offset, sizeof(name));
 592						fprintf(fp, "%s\n", name);
 593						bytestream2char(name, mRawData, event_offset, sizeof(name));
 594						fprintf(fp, "\t\tinteger %s\n", name);
 595						bytestream2char(name, mRawData, event_offset, sizeof(name));
 596						fprintf(fp, "\t\tquaternion %s\n", name);
 597						bytestream2char(name, mRawData, event_offset, sizeof(name));
 598						fprintf(fp, "\t\tquaternion %s\n", name);
 599						break;
 600					case LSTT_NOT_AT_ROT_TARGET:	// LSTT_NOT_AT_TARGET
 601						bytestream2char(name, mRawData, event_offset, sizeof(name));
 602						fprintf(fp, "%s\n", name);
 603						break;
 604					case LSTT_RTPERMISSIONS:	// LSTT_RTPERMISSIONS
 605						bytestream2char(name, mRawData, event_offset, sizeof(name));
 606						fprintf(fp, "%s\n", name);
 607						fprintf(fp, "\t\tinteger %s\n", name);
 608						bytestream2char(name, mRawData, event_offset, sizeof(name));
 609						break;
 610					case LSTT_HTTP_RESPONSE:	// LSTT_REMOTE_DATA ?!?!?!
 611						bytestream2char(name, mRawData, event_offset, sizeof(name));
 612						fprintf(fp, "%s\n", name);
 613						bytestream2char(name, mRawData, event_offset, sizeof(name));
 614						fprintf(fp, "\t\tkey %s\n", name);
 615						bytestream2char(name, mRawData, event_offset, sizeof(name));
 616						fprintf(fp, "\t\tinteger %s\n", name);
 617						bytestream2char(name, mRawData, event_offset, sizeof(name));
 618						fprintf(fp, "\t\tlist %s\n", name);
 619						bytestream2char(name, mRawData, event_offset, sizeof(name));
 620						fprintf(fp, "\t\tstring %s\n", name);
 621						break;
 622					case LSTT_HTTP_REQUEST:	// LSTT_HTTP_REQUEST
 623						bytestream2char(name, mRawData, event_offset, sizeof(name));
 624						fprintf(fp, "%s\n", name);
 625						bytestream2char(name, mRawData, event_offset, sizeof(name));
 626						fprintf(fp, "\t\tkey %s\n", name);
 627						bytestream2char(name, mRawData, event_offset, sizeof(name));
 628						fprintf(fp, "\t\tstring %s\n", name);
 629						bytestream2char(name, mRawData, event_offset, sizeof(name));
 630						fprintf(fp, "\t\tstring %s\n", name);
 631						break;
 632					default:
 633						break;
 634					}
 635					fprintf(fp, "\t\tStack Size: %d\n", stack_size);
 636					fprintf(fp, "\t\t\tOpCodes: 0x%X - 0x%X\n", opcode_start, opcode_end);
 637					printOpCodeRange(fp, opcode_start, opcode_end, 3);
 638				}
 639			}
 640		}
 641	}
 642	fprintf(fp, "=============================\n\n");
 643}
 644
 645void LLScriptLSOParse::printHeap(LLFILE *fp)
 646{
 647	// print out registers first
 648
 649	S32 heap_offset = get_register(mRawData, LREG_HR);
 650	S32 heap_pointer = get_register(mRawData, LREG_HP);
 651	fprintf(fp, "=============================\n");
 652	fprintf(fp, "[0x%X - 0x%X] Heap\n", heap_offset, heap_pointer);
 653	fprintf(fp, "=============================\n");
 654
 655	lsa_fprint_heap(mRawData, fp);
 656	
 657	fprintf(fp, "=============================\n\n");
 658}
 659
 660void lso_print_tabs(LLFILE *fp, S32 tabs)
 661{
 662	S32 i;
 663	for (i = 0; i < tabs; i++)
 664	{
 665		fprintf(fp, "\t");
 666	}
 667}
 668
 669void LLScriptLSOParse::printOpCodes(LLFILE *fp, S32 &offset, S32 tabs)
 670{
 671	U8 opcode = *(mRawData + offset);
 672	mPrintOpCodes[opcode](fp, mRawData, offset, tabs);
 673}
 674
 675void LLScriptLSOParse::printOpCodeRange(LLFILE *fp, S32 start, S32 end, S32 tabs)
 676{
 677	while (start < end)
 678	{
 679		printOpCodes(fp, start, tabs);
 680	}
 681}
 682
 683void LLScriptLSOParse::initOpCodePrinting()
 684{
 685	S32 i;
 686	for (i = 0; i < 256; i++)
 687	{
 688		mPrintOpCodes[i] = print_noop;
 689	}
 690	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NOOP]] = print_noop;
 691
 692	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POP]] = print_pop;
 693	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPS]] = print_pops;
 694	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPL]] = print_popl;
 695	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPV]] = print_popv;
 696	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPQ]] = print_popq;
 697	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPARG]] = print_poparg;
 698	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPIP]] = print_popip;
 699	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPBP]] = print_popbp;
 700	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSP]] = print_popsp;
 701	mPrintOpCodes[LSCRIPTOpCodes[LOPC_POPSLR]] = print_popslr;
 702
 703	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUP]] = print_dup;
 704	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPS]] = print_dups;
 705	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPL]] = print_dupl;
 706	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPV]] = print_dupv;
 707	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DUPQ]] = print_dupq;
 708
 709	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORE]] = print_store;
 710	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STORES]] = print_stores;
 711	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREL]] = print_storel;
 712	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREV]] = print_storev;
 713	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREQ]] = print_storeq;
 714	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREG]] = print_storeg;
 715	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGS]] = print_storegs;
 716	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGL]] = print_storegl;
 717	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGV]] = print_storegv;
 718	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STOREGQ]] = print_storegq;
 719	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADP]] = print_loadp;
 720	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADSP]] = print_loadsp;
 721	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADLP]] = print_loadlp;
 722	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADVP]] = print_loadvp;
 723	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADQP]] = print_loadqp;
 724	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGP]] = print_loadgp;
 725	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGSP]] = print_loadgsp;
 726	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGLP]] = print_loadglp;
 727	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGVP]] = print_loadgvp;
 728	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LOADGQP]] = print_loadgqp;
 729
 730	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSH]] = print_push;
 731	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHS]] = print_pushs;
 732	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHL]] = print_pushl;
 733	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHV]] = print_pushv;
 734	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHQ]] = print_pushq;
 735	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHG]] = print_pushg;
 736	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGS]] = print_pushgs;
 737	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGL]] = print_pushgl;
 738	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGV]] = print_pushgv;
 739	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHGQ]] = print_pushgq;
 740	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHIP]] = print_puship;
 741	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHSP]] = print_pushsp;
 742	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHBP]] = print_pushbp;
 743	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGB]] = print_pushargb;
 744	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGI]] = print_pushargi;
 745	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGF]] = print_pushargf;
 746	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGS]] = print_pushargs;
 747	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGV]] = print_pushargv;
 748	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGQ]] = print_pushargq;
 749	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHE]] = print_pushe;
 750	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEV]] = print_pushev;
 751	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHEQ]] = print_pusheq;
 752	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PUSHARGE]] = print_pusharge;
 753
 754	mPrintOpCodes[LSCRIPTOpCodes[LOPC_ADD]] = print_add;
 755	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SUB]] = print_sub;
 756	mPrintOpCodes[LSCRIPTOpCodes[LOPC_MUL]] = print_mul;
 757	mPrintOpCodes[LSCRIPTOpCodes[LOPC_DIV]] = print_div;
 758	mPrintOpCodes[LSCRIPTOpCodes[LOPC_MOD]] = print_mod;
 759
 760	mPrintOpCodes[LSCRIPTOpCodes[LOPC_EQ]] = print_eq;
 761	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEQ]] = print_neq;
 762	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LEQ]] = print_leq;
 763	mPrintOpCodes[LSCRIPTOpCodes[LOPC_GEQ]] = print_geq;
 764	mPrintOpCodes[LSCRIPTOpCodes[LOPC_LESS]] = print_less;
 765	mPrintOpCodes[LSCRIPTOpCodes[LOPC_GREATER]] = print_greater;
 766
 767	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITAND]] = print_bitand;
 768	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITOR]] = print_bitor;
 769	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITXOR]] = print_bitxor;
 770
 771	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLAND]] = print_booland;
 772	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLOR]] = print_boolor;
 773
 774	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHL]] = print_shl;
 775	mPrintOpCodes[LSCRIPTOpCodes[LOPC_SHR]] = print_shr;
 776
 777	mPrintOpCodes[LSCRIPTOpCodes[LOPC_NEG]] = print_neg;
 778	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BITNOT]] = print_bitnot;
 779	mPrintOpCodes[LSCRIPTOpCodes[LOPC_BOOLNOT]] = print_boolnot;
 780
 781	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMP]] = print_jump;
 782	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPIF]] = print_jumpif;
 783	mPrintOpCodes[LSCRIPTOpCodes[LOPC_JUMPNIF]] = print_jumpnif;
 784
 785	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STATE]] = print_state;
 786	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALL]] = print_call;
 787	mPrintOpCodes[LSCRIPTOpCodes[LOPC_RETURN]] = print_return;
 788	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CAST]] = print_cast;
 789	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOS]] = print_stacktos;
 790	mPrintOpCodes[LSCRIPTOpCodes[LOPC_STACKTOL]] = print_stacktol;
 791
 792	mPrintOpCodes[LSCRIPTOpCodes[LOPC_PRINT]] = print_print;
 793
 794	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB]] = print_calllib;
 795
 796	mPrintOpCodes[LSCRIPTOpCodes[LOPC_CALLLIB_TWO_BYTE]] = print_calllib_two_byte;
 797}
 798
 799void print_noop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 800{
 801	lso_print_tabs(fp, tabs);
 802	fprintf(fp, "[0x%X]\tNOOP\n", offset++);
 803}
 804
 805void print_pop(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 806{
 807	lso_print_tabs(fp, tabs);
 808	fprintf(fp, "[0x%X]\tPOP\n", offset++);
 809}
 810
 811void print_pops(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 812{
 813	lso_print_tabs(fp, tabs);
 814	fprintf(fp, "[0x%X]\tPOPS\n", offset++);
 815}
 816
 817void print_popl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 818{
 819	lso_print_tabs(fp, tabs);
 820	fprintf(fp, "[0x%X]\tPOPL\n", offset++);
 821}
 822
 823void print_popv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 824{
 825	lso_print_tabs(fp, tabs);
 826	fprintf(fp, "[0x%X]\tPOPV\n", offset++);
 827}
 828
 829void print_popq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 830{
 831	lso_print_tabs(fp, tabs);
 832	fprintf(fp, "[0x%X]\tPOPQ\n", offset++);
 833}
 834
 835void print_poparg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 836{
 837	S32 arg;
 838	lso_print_tabs(fp, tabs);
 839	fprintf(fp, "[0x%X]\tPOPARG ", offset++);
 840	arg = bytestream2integer(buffer, offset);
 841	fprintf(fp, "%d\n", arg);
 842}
 843
 844void print_popip(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 845{
 846	lso_print_tabs(fp, tabs);
 847	fprintf(fp, "[0x%X]\tPOPIP\n", offset++);
 848}
 849
 850void print_popbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 851{
 852	lso_print_tabs(fp, tabs);
 853	fprintf(fp, "[0x%X]\tPOPBP\n", offset++);
 854}
 855
 856void print_popsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 857{
 858	lso_print_tabs(fp, tabs);
 859	fprintf(fp, "[0x%X]\tPOPSP\n", offset++);
 860}
 861
 862void print_popslr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 863{
 864	lso_print_tabs(fp, tabs);
 865	fprintf(fp, "[0x%X]\tPOPSLR\n", offset++);
 866}
 867
 868void print_dup(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 869{
 870	lso_print_tabs(fp, tabs);
 871	fprintf(fp, "[0x%X]\tDUP\n", offset++);
 872}
 873
 874void print_dups(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 875{
 876	lso_print_tabs(fp, tabs);
 877	fprintf(fp, "[0x%X]\tDUPS\n", offset++);
 878}
 879
 880void print_dupl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 881{
 882	lso_print_tabs(fp, tabs);
 883	fprintf(fp, "[0x%X]\tDUPL\n", offset++);
 884}
 885
 886void print_dupv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 887{
 888	lso_print_tabs(fp, tabs);
 889	fprintf(fp, "[0x%X]\tDUPV\n", offset++);
 890}
 891
 892void print_dupq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 893{
 894	lso_print_tabs(fp, tabs);
 895	fprintf(fp, "[0x%X]\tDUPQ\n", offset++);
 896}
 897
 898void print_store(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 899{
 900	S32 arg;
 901	lso_print_tabs(fp, tabs);
 902	fprintf(fp, "[0x%X]\tSTORE $BP + ", offset++);
 903	arg = bytestream2integer(buffer, offset);
 904	fprintf(fp, "%d\n", arg);
 905}
 906
 907void print_stores(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 908{
 909	S32 arg;
 910	lso_print_tabs(fp, tabs);
 911	fprintf(fp, "[0x%X]\tSTORES $BP + ", offset++);
 912	arg = bytestream2integer(buffer, offset);
 913	fprintf(fp, "%d\n", arg);
 914}
 915
 916void print_storel(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 917{
 918	S32 arg;
 919	lso_print_tabs(fp, tabs);
 920	fprintf(fp, "[0x%X]\tSTOREL $BP + ", offset++);
 921	arg = bytestream2integer(buffer, offset);
 922	fprintf(fp, "%d\n", arg);
 923}
 924
 925void print_storev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 926{
 927	S32 arg;
 928	lso_print_tabs(fp, tabs);
 929	fprintf(fp, "[0x%X]\tSTOREV $BP + ", offset++);
 930	arg = bytestream2integer(buffer, offset);
 931	fprintf(fp, "%d\n", arg);
 932}
 933
 934void print_storeq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 935{
 936	S32 arg;
 937	lso_print_tabs(fp, tabs);
 938	fprintf(fp, "[0x%X]\tSTOREQ $BP + ", offset++);
 939	arg = bytestream2integer(buffer, offset);
 940	fprintf(fp, "%d\n", arg);
 941}
 942
 943void print_storeg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 944{
 945	S32 arg;
 946	lso_print_tabs(fp, tabs);
 947	fprintf(fp, "[0x%X]\tSTOREG ", offset++);
 948	arg = bytestream2integer(buffer, offset);
 949	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
 950}
 951
 952void print_storegs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 953{
 954	S32 arg;
 955	lso_print_tabs(fp, tabs);
 956	fprintf(fp, "[0x%X]\tSTOREGS ", offset++);
 957	arg = bytestream2integer(buffer, offset);
 958	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
 959}
 960
 961void print_storegl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 962{
 963	S32 arg;
 964	lso_print_tabs(fp, tabs);
 965	fprintf(fp, "[0x%X]\tSTOREGL ", offset++);
 966	arg = bytestream2integer(buffer, offset);
 967	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
 968}
 969
 970void print_storegv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 971{
 972	S32 arg;
 973	lso_print_tabs(fp, tabs);
 974	fprintf(fp, "[0x%X]\tSTOREGV ", offset++);
 975	arg = bytestream2integer(buffer, offset);
 976	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
 977}
 978
 979void print_storegq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 980{
 981	S32 arg;
 982	lso_print_tabs(fp, tabs);
 983	fprintf(fp, "[0x%X]\tSTOREGQ ", offset++);
 984	arg = bytestream2integer(buffer, offset);
 985	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
 986}
 987
 988void print_loadp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 989{
 990	S32 arg;
 991	lso_print_tabs(fp, tabs);
 992	fprintf(fp, "[0x%X]\tSTOREP $BP + ", offset++);
 993	arg = bytestream2integer(buffer, offset);
 994	fprintf(fp, "%d\n", arg);
 995}
 996
 997void print_loadsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
 998{
 999	S32 arg;
1000	lso_print_tabs(fp, tabs);
1001	fprintf(fp, "[0x%X]\tSTOREPS $BP + ", offset++);
1002	arg = bytestream2integer(buffer, offset);
1003	fprintf(fp, "%d\n", arg);
1004}
1005
1006void print_loadlp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1007{
1008	S32 arg;
1009	lso_print_tabs(fp, tabs);
1010	fprintf(fp, "[0x%X]\tSTOREPL $BP + ", offset++);
1011	arg = bytestream2integer(buffer, offset);
1012	fprintf(fp, "%d\n", arg);
1013}
1014
1015void print_loadvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1016{
1017	S32 arg;
1018	lso_print_tabs(fp, tabs);
1019	fprintf(fp, "[0x%X]\tSTOREVP $BP + ", offset++);
1020	arg = bytestream2integer(buffer, offset);
1021	fprintf(fp, "%d\n", arg);
1022}
1023
1024void print_loadqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1025{
1026	S32 arg;
1027	lso_print_tabs(fp, tabs);
1028	fprintf(fp, "[0x%X]\tSTOREQP $BP + ", offset++);
1029	arg = bytestream2integer(buffer, offset);
1030	fprintf(fp, "%d\n", arg);
1031}
1032
1033void print_loadgp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1034{
1035	S32 arg;
1036	lso_print_tabs(fp, tabs);
1037	fprintf(fp, "[0x%X]\tSTOREGP ", offset++);
1038	arg = bytestream2integer(buffer, offset);
1039	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
1040}
1041
1042void print_loadgsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1043{
1044	S32 arg;
1045	lso_print_tabs(fp, tabs);
1046	fprintf(fp, "[0x%X]\tSTOREGSP ", offset++);
1047	arg = bytestream2integer(buffer, offset);
1048	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
1049}
1050
1051void print_loadglp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1052{
1053	S32 arg;
1054	lso_print_tabs(fp, tabs);
1055	fprintf(fp, "[0x%X]\tSTOREGLP ", offset++);
1056	arg = bytestream2integer(buffer, offset);
1057	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
1058}
1059
1060void print_loadgvp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1061{
1062	S32 arg;
1063	lso_print_tabs(fp, tabs);
1064	fprintf(fp, "[0x%X]\tSTOREGVP ", offset++);
1065	arg = bytestream2integer(buffer, offset);
1066	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
1067}
1068
1069void print_loadgqp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1070{
1071	S32 arg;
1072	lso_print_tabs(fp, tabs);
1073	fprintf(fp, "[0x%X]\tSTOREGQP ", offset++);
1074	arg = bytestream2integer(buffer, offset);
1075	fprintf(fp, "%d\n", arg + get_register(buffer, LREG_GVR));
1076}
1077
1078void print_push(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1079{
1080	S32 arg;
1081	lso_print_tabs(fp, tabs);
1082	fprintf(fp, "[0x%X]\tPUSH $BP + ", offset++);
1083	arg = bytestream2integer(buffer, offset);
1084	fprintf(fp, "%d\n", arg);
1085}
1086
1087void print_pushs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1088{
1089	S32 arg;
1090	lso_print_tabs(fp, tabs);
1091	fprintf(fp, "[0x%X]\tPUSHS $BP + ", offset++);
1092	arg = bytestream2integer(buffer, offset);
1093	fprintf(fp, "%d\n", arg);
1094}
1095
1096void print_pushl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1097{
1098	S32 arg;
1099	lso_print_tabs(fp, tabs);
1100	fprintf(fp, "[0x%X]\tPUSHL $BP + ", offset++);
1101	arg = bytestream2integer(buffer, offset);
1102	fprintf(fp, "%d\n", arg);
1103}
1104
1105void print_pushv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1106{
1107	S32 arg;
1108	lso_print_tabs(fp, tabs);
1109	fprintf(fp, "[0x%X]\tPUSHV $BP + ", offset++);
1110	arg = bytestream2integer(buffer, offset);
1111	fprintf(fp, "%d\n", arg);
1112}
1113
1114void print_pushq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1115{
1116	S32 arg;
1117	lso_print_tabs(fp, tabs);
1118	fprintf(fp, "[0x%X]\tPUSHQ $BP + ", offset++);
1119	arg = bytestream2integer(buffer, offset);
1120	fprintf(fp, "%d\n", arg);
1121}
1122
1123void print_pushg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1124{
1125	S32 arg;
1126	lso_print_tabs(fp, tabs);
1127	fprintf(fp, "[0x%X]\tPUSHG ", offset++);
1128	arg = bytestream2integer(buffer, offset);
1129	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
1130}
1131
1132void print_pushgs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1133{
1134	S32 arg;
1135	lso_print_tabs(fp, tabs);
1136	fprintf(fp, "[0x%X]\tPUSHGS ", offset++);
1137	arg = bytestream2integer(buffer, offset);
1138	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
1139}
1140
1141void print_pushgl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1142{
1143	S32 arg;
1144	lso_print_tabs(fp, tabs);
1145	fprintf(fp, "[0x%X]\tPUSHGL ", offset++);
1146	arg = bytestream2integer(buffer, offset);
1147	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
1148}
1149
1150void print_pushgv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1151{
1152	S32 arg;
1153	lso_print_tabs(fp, tabs);
1154	fprintf(fp, "[0x%X]\tPUSHGV ", offset++);
1155	arg = bytestream2integer(buffer, offset);
1156	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
1157}
1158
1159void print_pushgq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1160{
1161	S32 arg;
1162	lso_print_tabs(fp, tabs);
1163	fprintf(fp, "[0x%X]\tPUSHGQ ", offset++);
1164	arg = bytestream2integer(buffer, offset);
1165	fprintf(fp, "0x%X\n", arg + get_register(buffer, LREG_GVR));
1166}
1167
1168void print_puship(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1169{
1170	lso_print_tabs(fp, tabs);
1171	fprintf(fp, "[0x%X]\tPUSHIP\n", offset++);
1172}
1173
1174void print_pushbp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1175{
1176	lso_print_tabs(fp, tabs);
1177	fprintf(fp, "[0x%X]\tPUSHBP\n", offset++);
1178}
1179
1180void print_pushsp(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1181{
1182	lso_print_tabs(fp, tabs);
1183	fprintf(fp, "[0x%X]\tPUSHSP\n", offset++);
1184}
1185
1186void print_pushargb(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1187{
1188	U8 arg;
1189	lso_print_tabs(fp, tabs);
1190	fprintf(fp, "[0x%X]\tPUSHARGB ", offset++);
1191	arg = *(buffer + offset++);
1192	fprintf(fp, "%d\n", (U32)arg);
1193}
1194
1195void print_pushargi(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1196{
1197	S32 arg;
1198	lso_print_tabs(fp, tabs);
1199	fprintf(fp, "[0x%X]\tPUSHARGI ", offset++);
1200	arg = bytestream2integer(buffer, offset);
1201	fprintf(fp, "%d\n", arg);
1202}
1203
1204void print_pushargf(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1205{
1206	F32 arg;
1207	lso_print_tabs(fp, tabs);
1208	fprintf(fp, "[0x%X]\tPUSHARGF ", offset++);
1209	arg = bytestream2float(buffer, offset);
1210	fprintf(fp, "%f\n", arg);
1211}
1212
1213void print_pushargs(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1214{
1215	char arg[1024];		/*Flawfinder: ignore*/
1216	lso_print_tabs(fp, tabs);
1217	fprintf(fp, "[0x%X]\tPUSHARGS ", offset++);
1218	bytestream2char(arg, buffer, offset, sizeof(arg));
1219	fprintf(fp, "%s\n", arg);
1220}
1221
1222void print_pushargv(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1223{
1224	LLVector3 arg;
1225	lso_print_tabs(fp, tabs);
1226	fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
1227	bytestream2vector(arg, buffer, offset);
1228	fprintf(fp, "< %f, %f, %f >\n", arg.mV[VX], arg.mV[VY], arg.mV[VZ]);
1229}
1230
1231void print_pushargq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1232{
1233	LLQuaternion arg;
1234	lso_print_tabs(fp, tabs);
1235	fprintf(fp, "[0x%X]\tPUSHARGV ", offset++);
1236	bytestream2quaternion(arg, buffer, offset);
1237	fprintf(fp, "< %f, %f, %f, %f >\n", arg.mQ[VX], arg.mQ[VY], arg.mQ[VZ], arg.mQ[VS]);
1238}
1239
1240void print_pushe(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1241{
1242	lso_print_tabs(fp, tabs);
1243	fprintf(fp, "[0x%X]\tPUSHE\n", offset++);
1244}
1245
1246void print_pushev(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1247{
1248	lso_print_tabs(fp, tabs);
1249	fprintf(fp, "[0x%X]\tPUSHEV\n", offset++);
1250}
1251
1252void print_pusheq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1253{
1254	lso_print_tabs(fp, tabs);
1255	fprintf(fp, "[0x%X]\tPUSHEQ\n", offset++);
1256}
1257
1258void print_pusharge(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1259{
1260	S32 arg;
1261	lso_print_tabs(fp, tabs);
1262	fprintf(fp, "[0x%X]\tPUSHARGE ", offset++);
1263	arg = bytestream2integer(buffer, offset);
1264	fprintf(fp, "%d\n", arg);
1265}
1266
1267
1268void print_add(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1269{
1270	U8 types;
1271	U8 type1;
1272	U8 type2;
1273	lso_print_tabs(fp, tabs);
1274	fprintf(fp, "[0x%X]\tADD ", offset++);
1275	types = *(buffer + offset++);
1276	type1 = types >> 4;
1277	type2 = types & 0xf;
1278	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1279}
1280
1281void print_sub(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1282{
1283	U8 types;
1284	U8 type1;
1285	U8 type2;
1286	lso_print_tabs(fp, tabs);
1287	fprintf(fp, "[0x%X]\tSUB ", offset++);
1288	types = *(buffer + offset++);
1289	type1 = types >> 4;
1290	type2 = types & 0xf;
1291	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1292}
1293
1294void print_mul(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1295{
1296	U8 types;
1297	U8 type1;
1298	U8 type2;
1299	lso_print_tabs(fp, tabs);
1300	fprintf(fp, "[0x%X]\tMUL ", offset++);
1301	types = *(buffer + offset++);
1302	type1 = types >> 4;
1303	type2 = types & 0xf;
1304	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1305}
1306
1307void print_div(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1308{
1309	U8 types;
1310	U8 type1;
1311	U8 type2;
1312	lso_print_tabs(fp, tabs);
1313	fprintf(fp, "[0x%X]\tDIV ", offset++);
1314	types = *(buffer + offset++);
1315	type1 = types >> 4;
1316	type2 = types & 0xf;
1317	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1318}
1319
1320void print_mod(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1321{
1322	U8 types;
1323	U8 type1;
1324	U8 type2;
1325	lso_print_tabs(fp, tabs);
1326	fprintf(fp, "[0x%X]\tMOD ", offset++);
1327	types = *(buffer + offset++);
1328	type1 = types >> 4;
1329	type2 = types & 0xf;
1330	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1331}
1332
1333void print_eq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1334{
1335	U8 types;
1336	U8 type1;
1337	U8 type2;
1338	lso_print_tabs(fp, tabs);
1339	fprintf(fp, "[0x%X]\tEQ ", offset++);
1340	types = *(buffer + offset++);
1341	type1 = types >> 4;
1342	type2 = types & 0xf;
1343	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1344}
1345
1346void print_neq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1347{
1348	U8 types;
1349	U8 type1;
1350	U8 type2;
1351	lso_print_tabs(fp, tabs);
1352	fprintf(fp, "[0x%X]\tNEQ ", offset++);
1353	types = *(buffer + offset++);
1354	type1 = types >> 4;
1355	type2 = types & 0xf;
1356	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1357}
1358
1359void print_leq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1360{
1361	U8 types;
1362	U8 type1;
1363	U8 type2;
1364	lso_print_tabs(fp, tabs);
1365	fprintf(fp, "[0x%X]\tLEQ ", offset++);
1366	types = *(buffer + offset++);
1367	type1 = types >> 4;
1368	type2 = types & 0xf;
1369	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1370}
1371
1372void print_geq(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1373{
1374	U8 types;
1375	U8 type1;
1376	U8 type2;
1377	lso_print_tabs(fp, tabs);
1378	fprintf(fp, "[0x%X]\tGEQ ", offset++);
1379	types = *(buffer + offset++);
1380	type1 = types >> 4;
1381	type2 = types & 0xf;
1382	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1383}
1384
1385void print_less(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1386{
1387	U8 types;
1388	U8 type1;
1389	U8 type2;
1390	lso_print_tabs(fp, tabs);
1391	fprintf(fp, "[0x%X]\tLESS ", offset++);
1392	types = *(buffer + offset++);
1393	type1 = types >> 4;
1394	type2 = types & 0xf;
1395	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1396}
1397
1398void print_greater(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1399{
1400	U8 types;
1401	U8 type1;
1402	U8 type2;
1403	lso_print_tabs(fp, tabs);
1404	fprintf(fp, "[0x%X]\tGREATER ", offset++);
1405	types = *(buffer + offset++);
1406	type1 = types >> 4;
1407	type2 = types & 0xf;
1408	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1409}
1410
1411
1412void print_bitand(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1413{
1414	lso_print_tabs(fp, tabs);
1415	fprintf(fp, "[0x%X]\tBITAND\n", offset++);
1416}
1417
1418void print_bitor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1419{
1420	lso_print_tabs(fp, tabs);
1421	fprintf(fp, "[0x%X]\tBITOR\n", offset++);
1422}
1423
1424void print_bitxor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1425{
1426	lso_print_tabs(fp, tabs);
1427	fprintf(fp, "[0x%X]\tBITXOR\n", offset++);
1428}
1429
1430void print_booland(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1431{
1432	lso_print_tabs(fp, tabs);
1433	fprintf(fp, "[0x%X]\tBOOLAND\n", offset++);
1434}
1435
1436void print_boolor(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1437{
1438	lso_print_tabs(fp, tabs);
1439	fprintf(fp, "[0x%X]\tBOOLOR\n", offset++);
1440}
1441
1442void print_shl(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1443{
1444	lso_print_tabs(fp, tabs);
1445	fprintf(fp, "[0x%X]\tSHL\n", offset++);
1446}
1447
1448void print_shr(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1449{
1450	lso_print_tabs(fp, tabs);
1451	fprintf(fp, "[0x%X]\tSHR\n", offset++);
1452}
1453
1454
1455void print_neg(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1456{
1457	U8 type;
1458	lso_print_tabs(fp, tabs);
1459	fprintf(fp, "[0x%X]\tNEG ", offset++);
1460	type = *(buffer + offset++);
1461	fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
1462}
1463
1464void print_bitnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1465{
1466	lso_print_tabs(fp, tabs);
1467	fprintf(fp, "[0x%X]\tBITNOT\n", offset++);
1468}
1469
1470void print_boolnot(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1471{
1472	lso_print_tabs(fp, tabs);
1473	fprintf(fp, "[0x%X]\tBOOLNOT\n", offset++);
1474}
1475
1476void print_jump(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1477{
1478	S32 arg;
1479	lso_print_tabs(fp, tabs);
1480	fprintf(fp, "[0x%X]\tJUMP ", offset++);
1481	arg = bytestream2integer(buffer, offset);
1482	fprintf(fp, "%d\n", arg);
1483}
1484
1485void print_jumpif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1486{
1487	S32 arg;
1488	U8 type;
1489	lso_print_tabs(fp, tabs);
1490	fprintf(fp, "[0x%X]\tJUMPIF ", offset++);
1491	type = *(buffer + offset++);
1492	arg = bytestream2integer(buffer, offset);
1493	fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
1494}
1495
1496void print_jumpnif(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1497{
1498	S32 arg;
1499	U8 type;
1500	lso_print_tabs(fp, tabs);
1501	fprintf(fp, "[0x%X]\tJUMPNIF ", offset++);
1502	type = *(buffer + offset++);
1503	arg = bytestream2integer(buffer, offset);
1504	fprintf(fp, "%s, %d\n", LSCRIPTTypeNames[type], arg);
1505}
1506
1507void print_state(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1508{
1509	S32 arg;
1510	lso_print_tabs(fp, tabs);
1511	fprintf(fp, "[0x%X]\tSTATE ", offset++);
1512	arg = bytestream2integer(buffer, offset);
1513	fprintf(fp, "%d\n", arg);
1514}
1515
1516void print_call(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1517{
1518	S32 arg;
1519	lso_print_tabs(fp, tabs);
1520	fprintf(fp, "[0x%X]\tCALL ", offset++);
1521	arg = bytestream2integer(buffer, offset);
1522	fprintf(fp, "%d\n", arg);
1523}
1524
1525void print_return(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1526{
1527	lso_print_tabs(fp, tabs);
1528	fprintf(fp, "[0x%X]\tRETURN\n", offset++);
1529}
1530
1531void print_cast(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1532{
1533	U8 types;
1534	U8 type1;
1535	U8 type2;
1536	lso_print_tabs(fp, tabs);
1537	fprintf(fp, "[0x%X]\tCAST ", offset++);
1538	types = *(buffer + offset++);
1539	type1 = types >> 4;
1540	type2 = types & 0xf;
1541	fprintf(fp, "%s, %s\n", LSCRIPTTypeNames[type1], LSCRIPTTypeNames[type2]);
1542}
1543
1544void print_stacktos(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1545{
1546	S32 arg;
1547	lso_print_tabs(fp, tabs);
1548	fprintf(fp, "[0x%X]\tSTACKTOS ", offset++);
1549	arg = bytestream2integer(buffer, offset);
1550	fprintf(fp, "%d\n", arg);
1551}
1552
1553void print_stacktol(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1554{
1555	S32 arg;
1556	lso_print_tabs(fp, tabs);
1557	fprintf(fp, "[0x%X]\tSTACKTOL ", offset++);
1558	arg = bytestream2integer(buffer, offset);
1559	fprintf(fp, "%d\n", arg);
1560}
1561
1562void print_print(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1563{
1564	lso_print_tabs(fp, tabs);
1565	fprintf(fp, "[0x%X]\tPRINT ", offset++);
1566	U8 type = *(buffer + offset++);
1567	fprintf(fp, "%s\n", LSCRIPTTypeNames[type]);
1568}
1569
1570void print_calllib(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1571{
1572	U8 arg;
1573	lso_print_tabs(fp, tabs);
1574	fprintf(fp, "[0x%X]\tCALLLIB ", offset++);
1575	arg = *(buffer + offset++);
1576	fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
1577}
1578
1579
1580void print_calllib_two_byte(LLFILE *fp, U8 *buffer, S32 &offset, S32 tabs)
1581{
1582	U16 arg;
1583	lso_print_tabs(fp, tabs);
1584	fprintf(fp, "[0x%X]\tCALLLIB_TWO_BYTE ", offset++);
1585	arg = bytestream2u16(buffer, offset);
1586	fprintf(fp, "%d (%s)\n", (U32)arg, gScriptLibrary.mFunctions[arg].mName);
1587}
1588