From 40d655100cc1f14917cb98cde8e80c02c2b9b018 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 3 Oct 2009 13:20:31 +0000 Subject: [PATCH] m32script: stuff for fiddling with polymer lights git-svn-id: https://svn.eduke32.com/eduke32@1521 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/m32script.h | 1 + polymer/eduke32/source/astub.c | 2 ++ polymer/eduke32/source/m32def.c | 13 ++++++++++++- polymer/eduke32/source/m32def.h | 3 +++ polymer/eduke32/source/m32exec.c | 23 +++++++++++++++++++++-- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/include/m32script.h b/polymer/eduke32/build/include/m32script.h index 44d170de4..db3b52519 100644 --- a/polymer/eduke32/build/include/m32script.h +++ b/polymer/eduke32/build/include/m32script.h @@ -94,6 +94,7 @@ enum GameEvent_t { EVENT_KEYS2D, EVENT_KEYS3D, EVENT_OVERHEADEDITOR, + EVENT_PREKEYS3D, MAXEVENTS }; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 8d55572f8..6920c9f29 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4504,6 +4504,8 @@ static void Keys3d(void) enddrawing(); } + X_OnEvent(EVENT_PREKEYS3D, -1); + if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_V]) // ' V { keystatus[KEYSC_V] = 0; diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index 8621fc6f2..a9e21f272 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -246,6 +246,7 @@ const char *keyw[] = "displayrand", + "clamp", "inv", // inversion function.. not internal "sqrt", "mulscale", @@ -306,6 +307,7 @@ const char *keyw[] = "ifoutside", // BUILD functions + "resetkey", "insertsprite", "dupsprite", "deletesprite", @@ -342,6 +344,7 @@ const char *keyw[] = "definequote", "redefinequote", + "print", "quote", "error", "printmessage16", @@ -2516,10 +2519,15 @@ repeatcase: break; // *** other math + case CON_CLAMP: + C_GetNextVarType(GAMEVAR_READONLY); + C_GetManyVars(2); + return 0; + case CON_INV: C_GetNextVarType(GAMEVAR_READONLY); return 0; - + case CON_SQRT: { // syntax sqrt @@ -2699,6 +2707,7 @@ repeatcase: } // *** BUILD functions + case CON_RESETKEY: case CON_INSERTSPRITE: case CON_DUPSPRITE: case CON_DELETESPRITE: @@ -2876,6 +2885,7 @@ repeatcase: } return 0; + case CON_PRINT: case CON_QUOTE: case CON_ERRORINS: case CON_PRINTMESSAGE16: @@ -3079,6 +3089,7 @@ static void C_AddDefaultDefinitions(void) C_AddDefinition("EVENT_KEYS2D", EVENT_KEYS2D, LABEL_EVENT); C_AddDefinition("EVENT_KEYS3D", EVENT_KEYS3D, LABEL_EVENT); C_AddDefinition("EVENT_OVERHEADEDITOR", EVENT_OVERHEADEDITOR, LABEL_EVENT); + C_AddDefinition("EVENT_PREKEYS3D", EVENT_PREKEYS3D, LABEL_EVENT); C_AddDefinition("CLIPMASK0", CLIPMASK0, LABEL_DEFINE); C_AddDefinition("CLIPMASK1", CLIPMASK1, LABEL_DEFINE); diff --git a/polymer/eduke32/source/m32def.h b/polymer/eduke32/source/m32def.h index befced666..7ab6336e9 100644 --- a/polymer/eduke32/source/m32def.h +++ b/polymer/eduke32/source/m32def.h @@ -308,6 +308,7 @@ enum ScriptKeywords_t CON_DISPLAYRAND, // other math + CON_CLAMP, CON_INV, CON_SQRT, CON_MULSCALE, @@ -382,6 +383,7 @@ enum ScriptKeywords_t /// CON_IFNOSOUNDS, // BUILD functions + CON_RESETKEY, CON_INSERTSPRITE, CON_DUPSPRITE, CON_DELETESPRITE, @@ -420,6 +422,7 @@ enum ScriptKeywords_t // strings CON_DEFINEQUOTE, CON_REDEFINEQUOTE, + CON_PRINT, CON_QUOTE, CON_ERRORINS, CON_PRINTMESSAGE16, diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 31a97928c..ff7b82c1f 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -823,6 +823,17 @@ skip_check: continue; // *** other math + case CON_CLAMP: + insptr++; + { + int32_t var=*insptr++, min=Gv_GetVarX(*insptr++), max=Gv_GetVarX(*insptr++); + int32_t val=Gv_GetVarX(var); + + if (valmax) Gv_SetVarX(var, max); + } + continue; + case CON_INV: Gv_SetVarX(*(insptr+1), -Gv_GetVarX(*(insptr+1))); insptr += 2; @@ -1334,6 +1345,7 @@ badindex: case CON_IFHITKEY: case CON_IFHOLDKEY: + case CON_RESETKEY: insptr++; { int32_t key=Gv_GetVarX(*insptr); @@ -1343,9 +1355,13 @@ badindex: vm.g_errorFlag = 1; continue; } - X_DoConditional(keystatus[key]); - if (tw==CON_IFHITKEY) + if (tw != CON_RESETKEY) + X_DoConditional(keystatus[key]); + else + insptr++; + + if (tw != CON_IFHOLDKEY) { if (!(key==0 || key==KEYSC_ESC || key==KEYSC_TILDE || key==KEYSC_gENTER || key==KEYSC_LALT || key==KEYSC_RALT || key==KEYSC_LCTRL || key==KEYSC_RCTRL || @@ -2027,6 +2043,7 @@ badindex: } continue; + case CON_PRINT: case CON_QUOTE: case CON_ERRORINS: case CON_PRINTMESSAGE16: @@ -2046,6 +2063,8 @@ badindex: X_ERROR_INVALIDQUOTE(i, ScriptQuotes); + if (tw==CON_PRINT) + OSD_Printf("%s\n", ScriptQuotes[i]); if (tw==CON_QUOTE) message("%s", ScriptQuotes[i]); else if (tw==CON_PRINTMESSAGE16)