diff --git a/libs/ACSVM/include/CAPI/Scope.cpp b/libs/ACSVM/include/CAPI/Scope.cpp index e67a98dc6..f903704bd 100644 --- a/libs/ACSVM/include/CAPI/Scope.cpp +++ b/libs/ACSVM/include/CAPI/Scope.cpp @@ -300,6 +300,15 @@ bool ACSVM_MapScope_ScriptStop(ACSVM_MapScope *scope, ->scriptStop(name, {id.global, id.hub, id.map}); } +// +// ACSVM_MapScope_GetString +// +ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *scope, ACSVM::Word idx) +{ + return reinterpret_cast( + reinterpret_cast(scope)->getString(idx)); +} + // // ACSVM_MapScope_SetActive // diff --git a/libs/ACSVM/include/CAPI/Scope.h b/libs/ACSVM/include/CAPI/Scope.h index a7e857ae0..683f0388f 100644 --- a/libs/ACSVM/include/CAPI/Scope.h +++ b/libs/ACSVM/include/CAPI/Scope.h @@ -98,6 +98,8 @@ ACSVM_Word ACSVM_MapScope_ScriptStartTypeForced(ACSVM_MapScope *scope, bool ACSVM_MapScope_ScriptStop(ACSVM_MapScope *scope, ACSVM_ScriptName name, ACSVM_ScopeID id); +ACSVM_String *ACSVM_MapScope_GetString(ACSVM_MapScope *scope, ACSVM_Word idx); + void ACSVM_MapScope_SetActive(ACSVM_MapScope *scope, bool active); ACSVM_Array *ACSVM_ModuleScope_GetModArr (ACSVM_ModuleScope *scope, ACSVM_Word idx); diff --git a/libs/ACSVM/lib/libacsvm-capi.dll.a b/libs/ACSVM/lib/libacsvm-capi.dll.a index 83f1e671e..00609ebda 100644 Binary files a/libs/ACSVM/lib/libacsvm-capi.dll.a and b/libs/ACSVM/lib/libacsvm-capi.dll.a differ diff --git a/src/k_acs-func.c b/src/k_acs-func.c index 094fb4d17..4fc18d581 100644 --- a/src/k_acs-func.c +++ b/src/k_acs-func.c @@ -23,6 +23,10 @@ #include "m_random.h" #include "g_game.h" #include "d_player.h" +#include "r_defs.h" +#include "r_state.h" +#include "p_polyobj.h" +#include "taglist.h" /*-------------------------------------------------- bool ACS_CF_Random(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) @@ -31,10 +35,15 @@ --------------------------------------------------*/ bool ACS_CF_Random(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) { + INT32 low = 0; + INT32 high = 0; + (void)argC; - CONS_Printf("RANDOM %d thru %d\n", argV[0], argV[1]); - ACSVM_Thread_DataStk_Push(thread, P_RandomRange(PR_ACS, argV[0], argV[1])); + low = (INT32)argV[0]; + high = (INT32)argV[1]; + + ACSVM_Thread_DataStk_Push(thread, P_RandomRange(PR_ACS, low, high)); return false; } @@ -78,6 +87,68 @@ bool ACS_CF_PolyWait(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word ar return true; // Execution interrupted } +/*-------------------------------------------------- + bool ACS_CF_ChangeFloor(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) + + Changes a floor texture. +--------------------------------------------------*/ +bool ACS_CF_ChangeFloor(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) +{ + ACSVM_MapScope *map = NULL; + ACSVM_String *str = NULL; + const char *texName = NULL; + + INT32 secnum = -1; + INT32 tag = 0; + + (void)argC; + + tag = argV[0]; + + map = ACSVM_Thread_GetScopeMap(thread); + str = ACSVM_MapScope_GetString(map, argV[1]); + texName = ACSVM_String_GetStr(str); + + TAG_ITER_SECTORS(tag, secnum) + { + sector_t *sec = §ors[secnum]; + sec->floorpic = P_AddLevelFlatRuntime(texName); + } + + return false; +} + +/*-------------------------------------------------- + bool ACS_CF_ChangeCeiling(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) + + Changes a ceiling texture. +--------------------------------------------------*/ +bool ACS_CF_ChangeCeiling(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) +{ + ACSVM_MapScope *map = NULL; + ACSVM_String *str = NULL; + const char *texName = NULL; + + INT32 secnum = -1; + INT32 tag = 0; + + (void)argC; + + tag = argV[0]; + + map = ACSVM_Thread_GetScopeMap(thread); + str = ACSVM_MapScope_GetString(map, argV[1]); + texName = ACSVM_String_GetStr(str); + + TAG_ITER_SECTORS(tag, secnum) + { + sector_t *sec = §ors[secnum]; + sec->ceilingpic = P_AddLevelFlatRuntime(texName); + } + + return false; +} + /*-------------------------------------------------- bool ACS_CF_EndPrint(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC) diff --git a/src/k_acs.c b/src/k_acs.c index fd4e18601..def8a5db6 100644 --- a/src/k_acs.c +++ b/src/k_acs.c @@ -151,7 +151,7 @@ static void ACS_EnvThreadKilled(ACSVM_Environment const *env, ACSVM_Thread *thre /*-------------------------------------------------- static void ACS_AddCodeDataCallFunc( ACSVM_Environment *env, ACSVM_Word code, - char const *args, ACSVM_Word stack, ACSVM_Word func) + char const *args, ACSVM_Word argc, ACSVM_CallFunc func) Shortcut function to simplify adding CallFuncs. These are for code data ones; @@ -172,13 +172,13 @@ static void ACS_EnvThreadKilled(ACSVM_Environment const *env, ACSVM_Thread *thre --------------------------------------------------*/ static inline void ACS_AddCodeDataCallFunc(ACSVM_Environment *env, ACSVM_Word code, char const *args, ACSVM_Word argc, ACSVM_CallFunc func) { + ACSVM_Word funcId = ACSVM_Environment_AddCallFunc(env, func); + ACSVM_Code tCode = (argc != 0 ? ACSVM_Code_CallFunc : ACSVM_Code_CallFunc_Lit); + ACSVM_Environment_AddCodeDataACS0( - env, - code, - args, - ((argc > 0) ? ACSVM_Code_CallFunc_Lit : ACSVM_Code_CallFunc), - argc, - ACSVM_Environment_AddCallFunc(env, func) + env, code, + args, tCode, argc, + funcId ); } @@ -216,6 +216,10 @@ static void ACS_EnvConstruct(ACSVM_Environment *env) ACS_AddCodeDataCallFunc(env, 62, "W", 0, ACS_CF_TagWait); ACS_AddCodeDataCallFunc(env, 63, "", 1, ACS_CF_PolyWait); ACS_AddCodeDataCallFunc(env, 64, "W", 0, ACS_CF_PolyWait); + ACS_AddCodeDataCallFunc(env, 65, "", 2, ACS_CF_ChangeFloor); + ACS_AddCodeDataCallFunc(env, 66, "WWS", 0, ACS_CF_ChangeFloor); + ACS_AddCodeDataCallFunc(env, 67, "", 2, ACS_CF_ChangeCeiling); + ACS_AddCodeDataCallFunc(env, 68, "WWS", 0, ACS_CF_ChangeCeiling); // 69 to 79: Implemented by ACSVM // 81 to 82: Implemented by ACSVM diff --git a/src/k_acs.h b/src/k_acs.h index ecd829ba9..cf9ad0555 100644 --- a/src/k_acs.h +++ b/src/k_acs.h @@ -129,6 +129,8 @@ void ACS_Tick(void); bool ACS_CF_Random(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); bool ACS_CF_TagWait(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); bool ACS_CF_PolyWait(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); +bool ACS_CF_ChangeFloor(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); +bool ACS_CF_ChangeCeiling(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); bool ACS_CF_EndPrint(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); bool ACS_CF_PlayerCount(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC); bool ACS_CF_GameType(ACSVM_Thread *thread, ACSVM_Word const *argV, ACSVM_Word argC);