- Added support for Eternity's JUMP table and PCD_GOTOSTACK (again, requires advanced compiler).

SVN r3990 (trunk)
This commit is contained in:
Braden Obrzut 2012-12-20 04:17:18 +00:00
parent 86291fcd96
commit e8731c7571
2 changed files with 16 additions and 0 deletions

View File

@ -1144,6 +1144,14 @@ FBehavior::FBehavior (int lumpnum, FileReader * fr, int len)
Functions += 8;
}
// Load JUMP points
chunk = (DWORD *)FindChunk (MAKE_ID('J','U','M','P'));
if (chunk != NULL)
{
for (i = 0;i < (int)LittleLong(chunk[1]);i += 4)
JumpPoints.Push(LittleLong(chunk[2 + i/4]));
}
// Initialize this object's map variables
memset (MapVarStore, 0, sizeof(MapVarStore));
chunk = (DWORD *)FindChunk (MAKE_ID('M','I','N','I'));
@ -5188,6 +5196,11 @@ int DLevelScript::RunScript ()
pc = activeBehavior->Ofs2PC (LittleLong(*pc));
break;
case PCD_GOTOSTACK:
pc = activeBehavior->Jump2PC (STACK(1));
sp--;
break;
case PCD_IFGOTO:
if (STACK(1))
pc = activeBehavior->Ofs2PC (LittleLong(*pc));

View File

@ -165,6 +165,7 @@ public:
void StartTypedScripts (WORD type, AActor *activator, bool always, int arg1, bool runNow);
DWORD PC2Ofs (int *pc) const { return (DWORD)((BYTE *)pc - Data); }
int *Ofs2PC (DWORD ofs) const { return (int *)(Data + ofs); }
int *Jump2PC (DWORD jumpPoint) const { return Ofs2PC(JumpPoints[jumpPoint]); }
ACSFormat GetFormat() const { return Format; }
ScriptFunction *GetFunction (int funcnum, FBehavior *&module) const;
int GetArrayVal (int arraynum, int index) const;
@ -213,6 +214,7 @@ private:
TArray<FBehavior *> Imports;
DWORD LibraryID;
char ModuleName[9];
TArray<int> JumpPoints;
static TArray<FBehavior *> StaticModules;
@ -602,6 +604,7 @@ public:
/*360*/ PCD_CALLSTACK, // from Eternity
PCD_SCRIPTWAITNAMED,
PCD_TRANSLATIONRANGE3,
PCD_GOTOSTACK,
/*363*/ PCODE_COMMAND_COUNT
};