//***************************************************************************
//
//								ABLSTD.CPP
//
//***************************************************************************

#include "MW4Headers.hpp"
#include <stdio.h>

#ifndef ABLGEN_H
	#include "ablgen.h"
#endif

#ifndef ABLERR_H
	#include "ablerr.h"
#endif

#ifndef ABLSCAN_H
	#include "ablscan.h"
#endif

#ifndef ABLSYMT_H
	#include "ablsymt.h"
#endif

#ifndef ABLPARSE_H
	#include "ablparse.h"
#endif

#include "ablfuncs.hpp"
#include "ablexec.h"

namespace ABL
{

//***************************************************************************

	extern TokenCodeType  curToken;
	extern char       wordString[];
	extern TokenCodeType  followParmList[];
	extern TokenCodeType  statementEndList[];
	extern SymTableNodePtr  symTableDisplay[];
	extern long       level;
	extern TypePtr      IntegerTypePtr;
	extern TypePtr      CharTypePtr;
	extern TypePtr      RealTypePtr;
	extern TypePtr      BooleanTypePtr;
	extern Type       DummyType;

	extern SymTableNodePtr  CurRoutineIdPtr;

	stlport::vector<ABLRoutineTableEntry *> *g_ABLFunctions;

	int AddABLFunction (const char *name,ABLParseFunction parse,ABLExecuteFunction execute)
	{
		ABLRoutineTableEntry *newguy;
		int id;

// MSL 5.04 Merc Change
		Verify (g_ABLFunctions->size () <= 400);
		newguy = new ABLRoutineTableEntry;
		Verify (newguy);
		id = g_ABLFunctions->size ();
		g_ABLFunctions->push_back (newguy);
		newguy->Index (id);
		newguy->Execute (execute);
		newguy->Parse (parse);
		newguy->Name (name);
		enterStandardRoutine(newguy->Name (), id, DFN_FUNCTION);
		return id;
	}

	int AddSpecificABLFunction (const char *name,int index,ABLParseFunction parse,ABLExecuteFunction execute)
	{
		ABLRoutineTableEntry *newguy;

		Verify (g_ABLFunctions->size () <= 300);
		newguy = new ABLRoutineTableEntry;
		Verify (newguy);
		Verify ((*g_ABLFunctions)[index] == NULL);
		(*g_ABLFunctions)[index] = newguy;
		newguy->Index (index);
		newguy->Execute (execute);
		newguy->Parse (parse);
		newguy->Name (name);
		enterStandardRoutine(newguy->Name (), index, DFN_FUNCTION);
		return index;
	}


//***************************************************************************
// PARSING HELPER FUNCTIONS
//***************************************************************************

	void ABL_getInteger (bool lastParam = false);
	void ABL_getReal (bool lastParam = false);
	void ABL_getBoolean (bool lastParam = false);
	void ABL_getIntegerOrReal (bool lastParam = false);
	void ABL_getString (bool lastParam = false);
	void ABL_getIntegerArray (bool lastParam = false);
	void ABL_getRealArray (bool lastParam = false);

//---------------------------------------------------------------------------

	void ABL_getNoOpenParen (void)
	{

		if (curToken == TKN_LPAREN)
			syntaxError(ABL_ERR_SYNTAX_WRONG_NUMBER_OF_PARAMS);
	}

//---------------------------------------------------------------------------

	void ABL_getOpenParen (void)
	{

		if (curToken == TKN_LPAREN)
			getToken();
		else
			syntaxError(ABL_ERR_SYNTAX_WRONG_NUMBER_OF_PARAMS);
	}

//---------------------------------------------------------------------------

	void ABL_getInteger (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if (paramType != IntegerTypePtr)
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

	//---------------------------------------------------------------------------

	void ABL_getIntegerForRevealNavPoint (bool lastParam)
	{
		// This is a solution for bug 1050.  If the keyword identifier is revealnavpoint,
		// We go ahead and check if the team dropzone really exists.  
		// If it does exist we go ahead and call the routine and parse.
		// If not we skip the dropzone and continue processing next statment
		if (searchSymTableDisplay(wordString) != NULL)
		{
			TypePtr paramType = baseType(expression());
			if (paramType != IntegerTypePtr)
				syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		}
		else
		{
			uncrunchToken();
			uncrunchSymTableNodePtr();
			uncrunchToken();
			uncrunchToken();
			uncrunchStatementMarker();
			getToken();
			uncrunchToken();
		}

		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}
//---------------------------------------------------------------------------

	void ABL_getReal (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if (paramType != RealTypePtr)
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//---------------------------------------------------------------------------

	void ABL_getBoolean (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if (paramType != BooleanTypePtr)
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//---------------------------------------------------------------------------

	void ABL_getIntegerOrReal (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if ((paramType != IntegerTypePtr) && (paramType != RealTypePtr))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//---------------------------------------------------------------------------

	void ABL_getString (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if ((paramType->form != FRM_ARRAY) || (paramType->info.array.elementTypePtr != CharTypePtr))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//---------------------------------------------------------------------------

	void ABL_getIntegerArray (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if ((paramType->form != FRM_ARRAY) || (paramType->info.array.elementTypePtr != IntegerTypePtr))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//---------------------------------------------------------------------------

	void ABL_getRealArray (bool lastParam)
	{

		TypePtr paramType = baseType(expression());
		if ((paramType->form != FRM_ARRAY) || (paramType->info.array.elementTypePtr != RealTypePtr))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		if (lastParam)
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		else
			ifTokenGetElseError(TKN_COMMA, ABL_ERR_SYNTAX_MISSING_COMMA);
	}

//***************************************************************************
// STANDARD ROUTINE PARSING FUNCTIONS
//***************************************************************************

	TypePtr stdReturn (void)
	{

		// RETURN function
		//
		//		PARAMS: <same as function return type>
		//
		//		RETURN: NONE

		if (curToken == TKN_LPAREN)
		{
			getToken();
			TypePtr paramType = baseType(expression());
			if (paramType != baseType((TypePtr)(CurRoutineIdPtr->typePtr)))
				syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
			ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		}
		else if (CurRoutineIdPtr->typePtr != NULL)
			syntaxError(ABL_ERR_SYNTAX_WRONG_NUMBER_OF_PARAMS);
		return NULL;
	}

//***************************************************************************

	TypePtr stdPrint (void)
	{

		// PRINT function:
		//
		//		PARAMS:	integer or real or string
		//
		//		RETURN: NONE

		ABL_getOpenParen();

		TypePtr paramType = baseType(expression());
		if ((paramType != IntegerTypePtr) &&
				(paramType != RealTypePtr) &&
				(paramType != CharTypePtr) &&
				((paramType->form != FRM_ARRAY) || (paramType->info.array.elementTypePtr != CharTypePtr)))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);
		ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);
		return NULL;
	}

//***************************************************************************

	TypePtr stdConcat (void)
	{

		// PRINT function:
		//
		//		PARAMS:	char array
		//
		//				integer, real or char array
		//
		//		RETURN: integer (resulting length, not including NULL)

		ABL_getOpenParen();
		ABL_getString();

		TypePtr paramType = baseType(expression());
		if ((paramType != IntegerTypePtr) &&
				(paramType != RealTypePtr) &&
				(paramType != CharTypePtr) &&
				(paramType != BooleanTypePtr) &&
				((paramType->form != FRM_ARRAY) || (paramType->info.array.elementTypePtr != CharTypePtr)))
			syntaxError(ABL_ERR_SYNTAX_INCOMPATIBLE_TYPES);

		ifTokenGetElseError(TKN_RPAREN, ABL_ERR_SYNTAX_MISSING_RPAREN);

		return(IntegerTypePtr);
	}

//***************************************************************************

	TypePtr stdAbs (void)
	{

		// ABS function:
		//
		//		PARAMS:	real
		//
		//		RETURN: real

		ABL_getOpenParen();
		ABL_getReal(true);
		return(RealTypePtr);
	}

//***************************************************************************

	TypePtr stdRound (void)
	{

		// ROUND function:
		//
		//		PARAMS:	real
		//
		//		RETURN: integer

		ABL_getOpenParen();
		ABL_getReal(true);
		return(IntegerTypePtr);
	}

//***************************************************************************

	TypePtr stdTrunc (void)
	{

		// TRUNC function:
		//
		//		PARAMS:	real
		//
		//		RETURN: integer

		ABL_getOpenParen();
		ABL_getIntegerOrReal(true);
		return(IntegerTypePtr);
	}

//***************************************************************************

	TypePtr stdSqrt (void)
	{

		// ABS function:
		//
		//		PARAMS:	real
		//
		//		RETURN: real

		ABL_getOpenParen();
		ABL_getIntegerOrReal(true);
		return(RealTypePtr);
	}

//***************************************************************************

	TypePtr stdRandom (void)
	{

		// RANDOM function:
		//
		//		PARAMS:	integer
		//
		//		RETURN: integer

		ABL_getOpenParen();
		ABL_getInteger(true);
		return(IntegerTypePtr);
	}

//***************************************************************************

	TypePtr stdGetModHandle (void)
	{

		// HANDLE function:
		//
		//		PARAMS:	NONE
		//
		//		RETURN: integer

		ABL_getNoOpenParen();
		return(IntegerTypePtr);
	}

//***************************************************************************

	TypePtr stdGetModName (void)
	{

		// HANDLE function:
		//
		//		PARAMS:	NONE
		//
		//		RETURN: string

		ABL_getNoOpenParen();
//	return(StringTypePtr);
		return(NULL);
	}

//***************************************************************************

	TypePtr stdSetModName (void)
	{

		// HANDLE function:
		//
		//		PARAMS:	string
		//
		//		RETURN: NONE

		ABL_getOpenParen();
		ABL_getString(true);
		return NULL;
	}

//***************************************************************************

	TypePtr stdSetMaxLoops (void)
	{

		//----------------------------------------------------------------------
		//
		//	SET MAX LOOPS function:
		//
		//		Sets the max number of loops that may occur (in a for, while or
		//		repeat loop) before an infinite loop run-time error occurs.
		//
		//		PARAMS:	integer
		//
		//		RETURN: none
		//
		//----------------------------------------------------------------------

		ABL_getOpenParen();
		ABL_getInteger(true);
		return(NULL);
	}

//***************************************************************************

	TypePtr stdFatal (void)
	{

		//----------------------------------------------------------------------
		//
		//	FATAL function:
		//
		//		If the debugger is active, this immediately jumps into debug mode.
		//		Otherwise, it causes a fatal and exits the game (displaying the
		//		string passed in).
		//
		//		PARAMS:	integer							fatal code to display
		//
		//				char[]							message
		//
		//		RETURN: none
		//
		//----------------------------------------------------------------------

		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getString(true);
		return(NULL);
	}

//***************************************************************************

	TypePtr stdAssert (void)
	{

		//----------------------------------------------------------------------
		//
		//	ASSERT function:
		//
		//		If the debugger is active, this immediately jumps into debug mode
		//		if expression is FALSE. Otherwise, the assert statement is ignored
		//		unless the #debug directive has been issued in the module. If
		//		so, a fatal occurs and exits the game (displaying the
		//		string passed in).
		//
		//		PARAMS:	boolean							expression
		//
		//				integer							assert code to display
		//
		//				char[]							message
		//
		//		RETURN: none
		//
		//----------------------------------------------------------------------

		ABL_getOpenParen();
		ABL_getBoolean();
		ABL_getInteger();
		ABL_getString(true);
		return(NULL);
	}

//***************************************************************************

	TypePtr stdHandle (void)
	{

		// HANDLE function:
		//
		//		PARAMS:	NONE
		//
		//		RETURN: integer

		ABL_getNoOpenParen();
		return(IntegerTypePtr);
	}

    TypePtr ParseNoParamReal (void) // jcem
    {
		ABL_getNoOpenParen ();
		return RealTypePtr;
    }
	TypePtr ParseNoParamInteger (void)
	{
		ABL_getNoOpenParen ();
		return IntegerTypePtr;
	}
	TypePtr ParseNoParamBoolean (void)
	{
		ABL_getNoOpenParen ();
		return BooleanTypePtr;
	}
	TypePtr ParseNoParam (void)
	{
		ABL_getNoOpenParen ();
		return NULL;
	}
	TypePtr ParseOneBoolean (void)
	{
		ABL_getOpenParen ();
		ABL_getBoolean (true);
		return NULL;
	}
	TypePtr ParseOneIntegerInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return IntegerTypePtr;
	}
	TypePtr ParseOneIntegerBoolean (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}
	TypePtr ParseOneInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr ParseOneIntegerForRevealNavPoint (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerForRevealNavPoint (true);
		return NULL;
	}
	TypePtr ParseTwoIntegerInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return IntegerTypePtr;
	}
	TypePtr ParseTwoIntegerBoolean (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}
	TypePtr ParseTwoInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr ParseIntegerReal (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr ParseTwoIntegerReal (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getReal (true);
		return NULL;
	}
	TypePtr ParseThreeInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr ParseFourInteger (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr ParseIntegerBoolean (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return NULL;
	}
	TypePtr ParseString (void)
	{
		ABL_getOpenParen();
		ABL_getString (true);
		return NULL;
	}
	TypePtr ParseStringBoolean (void)
	{
		ABL_getOpenParen();
		ABL_getString (true);
		return BooleanTypePtr;
	}
	TypePtr ParseStringInteger (void)
	{
		ABL_getOpenParen();
		ABL_getString ();
		ABL_getInteger(true);
		return NULL;
	}

	TypePtr hbFindObject()
	{
		ABL_getOpenParen();
		ABL_getInteger();	// AI
		ABL_getInteger();	// FA_ alignment
		ABL_getInteger();	// FT_ type
		ABL_getInteger();	// FC_ criteria
		ABL_getInteger();	// FF_ flags
		ABL_getInteger(true);	// distance
		return IntegerTypePtr;
	}
	TypePtr hbFindObjectExcept()
	{
		ABL_getOpenParen();
		ABL_getInteger();	// AI
		ABL_getInteger();	// FA_ alignment
		ABL_getInteger();	// FT_ type
		ABL_getInteger();	// FC_ criteria
		ABL_getInteger();	// FF_ flags
		ABL_getInteger();	// distance
		ABL_getInteger(true);	// object ID
		return IntegerTypePtr;
	}
	TypePtr ParsePlayerAI (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return NULL;
	}
	TypePtr hbgetLocation (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerArray(true);
		return NULL;
	}
	TypePtr hbDistance (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerArray();
		ABL_getIntegerArray(true);
		return IntegerTypePtr;
	}
	TypePtr hbgetNearestPathPoint (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getIntegerArray(true);
		return NULL;
	}
	TypePtr hbsetSkill (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr hbsetSkillLevel (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr hbSetFiringDelay (void)
	{
		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getReal();
		ABL_getReal(true);
		return NULL;
	}

	TypePtr hbsetEliteLevel (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr hbisWithin (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}
	TypePtr hbisWithinLoc (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerArray();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}

	TypePtr hbisEqual (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerOrReal ();
		ABL_getIntegerOrReal (true);
		return BooleanTypePtr;
	}
	TypePtr hbisLesser (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerOrReal ();
		ABL_getIntegerOrReal (true);
		return BooleanTypePtr;
	}
	TypePtr hbisGreater (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerOrReal ();
		ABL_getIntegerOrReal (true);
		return BooleanTypePtr;
	}
	TypePtr hbisWithinNav (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}
	TypePtr hbtimeLesser (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerOrReal (true);
		return BooleanTypePtr;
	}
	TypePtr hbtimeGreater (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerOrReal (true);
		return BooleanTypePtr;
	}
	TypePtr hbteleport (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerArray(true);
		return NULL;
	}
	TypePtr hbteleportAndLook (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
        ABL_getIntegerArray (); // point
        ABL_getInteger ();
		ABL_getIntegerArray(true); // point
		return NULL;
	}

	TypePtr hbSetCombatLeash (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerArray ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbpauseTimer (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return NULL;
	}

	TypePtr hbLaunchSignalFlare(void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerArray(true);
		return NULL;
	}
	TypePtr hbLaunchFireworks(void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerArray();
		ABL_getInteger(true);
		return NULL;
	}

//orders

	TypePtr hborderFormOnSpot(void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getIntegerArray ();
		ABL_getIntegerArray ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return NULL;
	}
	TypePtr hborderFormationMove(void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}
	TypePtr hborderMoveTo (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getBoolean ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}
	TypePtr hborderMoveResumePatrol (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getBoolean ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}
	TypePtr hborderMoveFollow (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}
	TypePtr hborderMoveSit (void)
	{
		ABL_getOpenParen ();
		ABL_getBoolean (true);
		return NULL;
	}
	TypePtr hborderMoveToLocPoint (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerArray();
		ABL_getInteger ();
		ABL_getBoolean ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}
	TypePtr hborderMoveToObject (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return BooleanTypePtr;
	}
	TypePtr hborderAttack (void)
	{
		ABL_getOpenParen ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}
	TypePtr hborderAttackTactic (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getBoolean (true);
		return BooleanTypePtr;
	}

	TypePtr hborderShootPoint (void)
	{
		ABL_getOpenParen ();
		ABL_getIntegerArray();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbGroupAllWithin()
	{
		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getInteger();
		ABL_getInteger(true);
		return(BooleanTypePtr);
	}

//camera ship

	TypePtr hbplay2DAnim (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}


	TypePtr hbsetinternalcamera (void)
	{
		ABL_getOpenParen ();
		ABL_getBoolean (true);
		return NULL;
	}

	TypePtr hbsetactivecamera (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbsetcameraFOV (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbfadetoblack (void)
	{
		ABL_getOpenParen ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbfadefromblack (void)
	{
		ABL_getOpenParen ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbfadetowhite (void)
	{
		ABL_getOpenParen ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbfadefromwhite (void)
	{
		ABL_getOpenParen ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbcamerafollowobject (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbcamerafollowpath (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbcameraposition (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbcameraoffset (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getBoolean (true);
		return NULL;
	}

	TypePtr hboverridecamerapitch (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hboverridecamerayaw (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}


	TypePtr hboverridecameraroll (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbtargetfollowobject (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbtargetfollowpath (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();
		ABL_getInteger (true);
		return NULL;
	}

	TypePtr hbtargetposition (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal (true);
		return NULL;
	}

	TypePtr hbtargetoffset (void)
	{
		ABL_getOpenParen ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getReal ();
		ABL_getBoolean (true);
		return NULL;
	}



//***************************************************************************

//***************************************************************************

	TypePtr hbGetMemoryReal (void)
	{

		//----------------------------------------------------------------------
		//
		//	GET MEMORY REAL function:
		//
		//		Returns current real value in memory cell of pilot.
		//
		//		PARAMS:	integer
		//
		//		RETURN: real
		//
		//----------------------------------------------------------------------

		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getInteger(true);
		return(RealTypePtr);
	}

//***************************************************************************

	TypePtr hbSetMemoryInteger (void)
	{

		//-------------------------------
		// SET MEMORY INTEGER function:
		//
		//		PARAMS:	integer, integer
		//
		//		RETURN: NONE
		//-------------------------------

		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getInteger();
		ABL_getInteger(true);
		return NULL;
	}

//***************************************************************************

	TypePtr hbSetMemoryReal (void)
	{

		//-------------------------------
		// SET MEMORY REAL function:
		//
		//		PARAMS:	integer, real
		//
		//		RETURN: NONE
		//-------------------------------

		ABL_getOpenParen();
		ABL_getInteger();
		ABL_getInteger();
		ABL_getReal(true);
		return NULL;
	}

	TypePtr ParseEndMission (void)
	{
		ABL_getOpenParen ();
		ABL_getBoolean ();
		ABL_getInteger (true);
		return NULL;
	}

//***************************************************************************

//---------------------------------------------------------------------------

	TypePtr hbSetDebugString (void)
	{

		//----------------------------------------------------------------------
		//
		//	Set Debug String function:
		//
		//		Sets the debug string for the specified object.
		//
		//		PARAMS:	integer				object id
		//
		//				integer				string id
		//
		//				char[]				string
		//
		//		RETURN: NONE
		//
		//----------------------------------------------------------------------

		ABL_getOpenParen();
		ABL_getInteger(false);
		ABL_getInteger(false);
		ABL_getString(true);
		return(NULL);
	}

	TypePtr ParseShowTimer (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();				// timer id
		ABL_getInteger ();				// objective id
		ABL_getInteger ();				// time offset
		ABL_getBoolean ();				// time on left
		ABL_getInteger ();				// color
		ABL_getBoolean (true);		// visible
		return NULL;
	}
	TypePtr ParseShowHelpArrow (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();				// rotation
		ABL_getIntegerArray ();			// point
		ABL_getInteger ();				// color
		ABL_getBoolean (true);		// visible
		return NULL;
	}
	TypePtr ParseMakeColor (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();				// red
		ABL_getInteger ();        // green
		ABL_getInteger ();        // blue
		ABL_getInteger (true);    // alpha
		return IntegerTypePtr;
	}
	TypePtr ParseSetHelpArrow (void)
	{
		ABL_getOpenParen ();
		ABL_getInteger ();				// rotation
		ABL_getInteger ();				// x
		ABL_getInteger ();				// y
		ABL_getInteger ();				// color
		ABL_getBoolean ();				// visible
		ABL_getInteger (true);			// time
		return NULL;
	}

	TypePtr ParsePlayLancemateSound (void)
	{
		ABL_getOpenParen ();
		ABL_getString ();
		ABL_getInteger (true);				// lanceid

		return BooleanTypePtr;
	}

	TypePtr ParseStartMusic (void)
	{
		ABL_getOpenParen ();
		ABL_getString ();				// wav name
		ABL_getReal ();					// time to fade out old music
		ABL_getReal ();					// time to fade in new music
		ABL_getInteger (true);			// volume for new music

		return BooleanTypePtr;
	}

//***************************************************************************

	TypePtr standardRoutineCall (SymTableNodePtr routineIdPtr)
	{
		Verify ((*g_ABLFunctions)[routineIdPtr->defn.info.routine.key] != NULL);
		return(*g_ABLFunctions)[routineIdPtr->defn.info.routine.key]->Parse ();
	}

//***************************************************************************

}



