From 439b60ae68aca63b8bb931847c7dd65eef8eed8a Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 3 Jul 2012 01:24:52 +0000 Subject: [PATCH] - Added support for Eternity Engine's function pointer ACS instructions. (Note that an alternative ACS compiler is necessary to use these instructions properly.) SVN r3731 (trunk) --- src/p_acs.cpp | 24 ++++++++++++++++++++++-- src/p_acs.h | 4 +++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 9a06f61eb..7fe6bbb1a 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4243,17 +4243,37 @@ int DLevelScript::RunScript () } break; + case PCD_PUSHFUNCTION: + { + int funcnum = NEXTBYTE; + PushToStack(funcnum | activeBehavior->GetLibraryID()); + break; + } case PCD_CALL: case PCD_CALLDISCARD: + case PCD_CALLSTACK: { int funcnum; int i; ScriptFunction *func; - FBehavior *module = activeBehavior; + FBehavior *module; SDWORD *mylocals; - funcnum = NEXTBYTE; + if(pcd == PCD_CALLSTACK) + { + funcnum = STACK(1); + module = FBehavior::StaticGetModule(funcnum>>16); + --sp; + + funcnum &= 0xFFFF; // Clear out tag + } + else + { + module = activeBehavior; + funcnum = NEXTBYTE; + } func = activeBehavior->GetFunction (funcnum, module); + if (func == NULL) { Printf ("Function %d in %s out of range\n", funcnum, ScriptPresentation(script).GetChars()); diff --git a/src/p_acs.h b/src/p_acs.h index 4ce82f6e0..da363958b 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -598,8 +598,10 @@ public: PCD_STRCPYTOMAPCHRANGE, // [FDARI] input range (copy string to all/part of array) PCD_STRCPYTOWORLDCHRANGE, PCD_STRCPYTOGLOBALCHRANGE, + PCD_PUSHFUNCTION, +/*360*/ PCD_CALLSTACK, -/*359*/ PCODE_COMMAND_COUNT +/*361*/ PCODE_COMMAND_COUNT }; // Some constants used by ACS scripts