mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
CON stuff
git-svn-id: https://svn.eduke32.com/eduke32@1436 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
cc58eafd29
commit
64f4c975c2
5 changed files with 3710 additions and 3654 deletions
|
@ -29,10 +29,6 @@ DEALINGS IN THE SOFTWARE.
|
|||
#ifndef NEDMALLOC_H
|
||||
#define NEDMALLOC_H
|
||||
|
||||
#ifndef UNREFERENCED_PARAMETER
|
||||
#define UNREFERENCED_PARAMETER(x) x=x
|
||||
#endif
|
||||
|
||||
/* See malloc.c.h for what each function does.
|
||||
|
||||
REPLACE_SYSTEM_ALLOCATOR causes nedalloc's functions to be called malloc,
|
||||
|
|
|
@ -34,7 +34,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
/*#define FULLSANITYCHECKS*/
|
||||
|
||||
#include "nedmalloc.h"
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
|
|
@ -489,6 +489,7 @@ const char *keyw[] =
|
|||
"getarraysize", // 343
|
||||
"savenn", // 344
|
||||
"copy", // 345
|
||||
"<null>", // 346 internal inversion function
|
||||
"<null>"
|
||||
};
|
||||
|
||||
|
@ -1896,6 +1897,24 @@ static int32_t C_GetNextValue(int32_t type)
|
|||
return 0; // literal value
|
||||
}
|
||||
|
||||
static inline int32_t C_IntPow2(int32_t v)
|
||||
{
|
||||
return ((v!=0) && (v&(v-1))==0);
|
||||
}
|
||||
|
||||
static inline uint32_t C_Pow2IntLogBase2(int32_t v)
|
||||
{
|
||||
static const uint32_t b[] = {0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0,
|
||||
0xFF00FF00, 0xFFFF0000};
|
||||
register uint32_t r = (v & b[0]) != 0;
|
||||
int32_t i = 4;
|
||||
|
||||
for (; i > 0; i--)
|
||||
r |= ((v & b[i]) != 0) << i;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
|
||||
{
|
||||
switch (C_GetKeyword())
|
||||
|
@ -1904,6 +1923,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
|
|||
case CON_ENDA:
|
||||
case CON_ENDEVENT:
|
||||
case CON_ENDS:
|
||||
case CON_ELSE:
|
||||
g_scriptPtr = lastScriptPtr + &script[0];
|
||||
g_ifElseAborted = 1;
|
||||
C_ReportError(-1);
|
||||
|
@ -3884,17 +3904,44 @@ static int32_t C_ParseCommand(void)
|
|||
case CON_SHIFTVARL:
|
||||
case CON_SHIFTVARR:
|
||||
|
||||
// syntax: [rand|add|set]var <var1> <const1>
|
||||
// sets var1 to const1
|
||||
// adds const1 to var1 (const1 can be negative...)
|
||||
//printf("Found [add|set]var at line= %d\n",g_lineNumber);
|
||||
{
|
||||
intptr_t *inst = g_scriptPtr-1;
|
||||
char *tptr = textptr;
|
||||
// syntax: [rand|add|set]var <var1> <const1>
|
||||
// sets var1 to const1
|
||||
// adds const1 to var1 (const1 can be negative...)
|
||||
//printf("Found [add|set]var at line= %d\n",g_lineNumber);
|
||||
|
||||
// get the ID of the DEF
|
||||
if (tw != CON_ZSHOOT && tw != CON_EZSHOOT)
|
||||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
else C_GetNextVar();
|
||||
// get the ID of the DEF
|
||||
if (tw != CON_ZSHOOT && tw != CON_EZSHOOT)
|
||||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
else C_GetNextVar();
|
||||
|
||||
C_GetNextValue(LABEL_DEFINE); // the number to check against...
|
||||
C_GetNextValue(LABEL_DEFINE); // the number to check against...
|
||||
|
||||
if (tw == CON_DIVVAR || (tw == CON_MULVAR && *(g_scriptPtr-1) > 0))
|
||||
{
|
||||
int32_t i = *(g_scriptPtr-1);
|
||||
j = klabs(*(g_scriptPtr-1));
|
||||
|
||||
if (C_IntPow2(j))
|
||||
{
|
||||
*inst = ((tw == CON_DIVVAR) ? CON_SHIFTVARR : CON_SHIFTVARL);
|
||||
*(g_scriptPtr-1) = C_Pow2IntLogBase2(j);
|
||||
// initprintf("%s:%d: replacing multiply/divide with shift\n",g_szScriptFileName,g_lineNumber);
|
||||
|
||||
if (i == j)
|
||||
return 0;
|
||||
|
||||
*g_scriptPtr++ = CON_INV + (g_lineNumber<<12);
|
||||
textptr = tptr;
|
||||
C_GetNextVarType(GAMEVAR_READONLY);
|
||||
C_GetNextValue(LABEL_DEFINE);
|
||||
g_scriptPtr--;
|
||||
// initprintf("%s:%d: adding inversion\n",g_szScriptFileName,g_lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case CON_WRITEARRAYTOFILE:
|
||||
case CON_READARRAYFROMFILE:
|
||||
|
|
|
@ -903,6 +903,7 @@ enum ScriptKeywords_t
|
|||
CON_GETARRAYSIZE, // 343
|
||||
CON_SAVENN, // 344
|
||||
CON_COPY, // 345
|
||||
CON_INV, // 346
|
||||
CON_END
|
||||
};
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue