mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Initial checkin of m32-script.
git-svn-id: https://svn.eduke32.com/eduke32@1493 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fe6e27e819
commit
ea0e088da5
11 changed files with 7461 additions and 9 deletions
|
@ -125,7 +125,10 @@ GAMEOBJS=$(OBJ)/game.$o \
|
|||
$(JMACTOBJ)
|
||||
|
||||
EDITOROBJS=$(OBJ)/astub.$o \
|
||||
$(OBJ)/mathutil.$o
|
||||
$(OBJ)/m32def.$o \
|
||||
$(OBJ)/m32exec.$o \
|
||||
$(OBJ)/m32vars.$o \
|
||||
$(OBJ)/mathutil.$o
|
||||
|
||||
# PLATFORM SPECIFIC SETTINGS
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ int32_t _getnumber16(char *namestart, int32_t num, int32_t maxnumber, char sign,
|
|||
void printmessage256(int32_t x, int32_t y, char *name);
|
||||
void _printmessage16(const char *fmt, ...);
|
||||
|
||||
extern int32_t lastpm16time;
|
||||
#define printmessage16(fmt, ...) lastpm16time = totalclock, _printmessage16(fmt, ## __VA_ARGS__)
|
||||
|
||||
extern char lastpm16buf[156];
|
||||
|
|
217
polymer/eduke32/build/include/m32script.h
Normal file
217
polymer/eduke32/build/include/m32script.h
Normal file
|
@ -0,0 +1,217 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
Copyright (C) 2004, 2007 - EDuke32 developers
|
||||
|
||||
This file is part of EDuke32
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#ifndef _m32script_h_
|
||||
#define _m32script_h_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "compat.h"
|
||||
#include "build.h"
|
||||
#include "editor.h"
|
||||
|
||||
#define MAXQUOTES 2048
|
||||
#define MAXQUOTELEN 128
|
||||
|
||||
// Some misc #defines
|
||||
#define NO 0
|
||||
#define YES 1
|
||||
|
||||
typedef int32_t instype;
|
||||
typedef int32_t ofstype;
|
||||
|
||||
extern char *ScriptQuotes[MAXQUOTES+1], *ScriptQuoteRedefinitions[MAXQUOTES+1];
|
||||
extern int32_t g_numQuoteRedefinitions;
|
||||
|
||||
//extern int16_t neartagsector, neartagwall, neartagsprite;
|
||||
//extern int32_t neartaghitdist;
|
||||
|
||||
extern int32_t X_DoExecute(int32_t once);
|
||||
extern void X_OnEvent(register int32_t iEventID, register int32_t iActor);
|
||||
|
||||
extern void X_ScriptInfo(void);
|
||||
extern void C_ReportError(int32_t iError);
|
||||
|
||||
extern int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags);
|
||||
extern int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32_t dwFlags);
|
||||
extern void Gv_Init(void);
|
||||
|
||||
extern int32_t __fastcall Gv_GetVarX(register int32_t id);
|
||||
extern void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue);
|
||||
extern int32_t __fastcall Gv_GetVarN(register int32_t id); // 'N' for "no side-effects"... vars only!
|
||||
|
||||
extern void SetGAMEPalette(void);
|
||||
extern void SetWATERPalette(void);
|
||||
extern void SetSLIMEPalette(void);
|
||||
extern void SetBOSS1Palette(void);
|
||||
|
||||
extern instype *script ,*insptr;
|
||||
extern int32_t *labelval;
|
||||
extern uint8_t *labeltype;
|
||||
extern int32_t g_numLabels, g_numDefaultLabels;
|
||||
extern int32_t g_scriptSize;
|
||||
extern char *label;
|
||||
//extern int32_t label_allocsize;
|
||||
|
||||
extern hashtable_t labelH;
|
||||
|
||||
#define MAXLABELLEN 32
|
||||
|
||||
//extern uint8_t waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768];
|
||||
//extern char currentboardfilename[BMAX_PATH];
|
||||
|
||||
|
||||
enum GameEvent_t {
|
||||
EVENT_ENTER3DMODE,
|
||||
EVENT_ANALYZESPRITES,
|
||||
EVENT_INSERTSPRITE2D,
|
||||
EVENT_INSERTSPRITE3D,
|
||||
MAXEVENTS
|
||||
};
|
||||
|
||||
extern ofstype aEventOffsets[MAXEVENTS];
|
||||
extern uint8_t aEventEnabled[MAXEVENTS];
|
||||
|
||||
|
||||
enum GamevarFlags_t {
|
||||
MAXGAMEVARS = 1024, // must be a power of two between 256 and 4096, inclusive
|
||||
MAXVARLABEL = MAXLABELLEN, //26,
|
||||
|
||||
GAMEVAR_PERBLOCK = 0x00000001, // per-block (state, event, or top-level) variable
|
||||
GAMEVAR_USER_MASK = (0x00000001),
|
||||
|
||||
GAMEVAR_RESET = 0x00000008, // marks var for to default
|
||||
GAMEVAR_DEFAULT = 0x00000100, // allow override
|
||||
GAMEVAR_SECRET = 0x00000200, // don't dump...
|
||||
|
||||
GAMEVAR_SYSTEM = 0x00000800, // cannot change mode flags...(only default value)
|
||||
GAMEVAR_READONLY = 0x00001000, // values are read-only (no setvar allowed)
|
||||
GAMEVAR_INTPTR = 0x00002000, // plValues is a pointer to an int32_t
|
||||
|
||||
GAMEVAR_SHORTPTR = 0x00008000, // plValues is a pointer to a short
|
||||
GAMEVAR_CHARPTR = 0x00010000, // plValues is a pointer to a char
|
||||
// GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state
|
||||
GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars
|
||||
};
|
||||
|
||||
enum GamearrayFlags_t {
|
||||
MAXGAMEARRAYS = (MAXGAMEVARS>>2), // must be lower than MAXGAMEVARS
|
||||
MAXARRAYLABEL = MAXVARLABEL,
|
||||
GAMEARRAY_NORMAL = 0,
|
||||
GAMEARRAY_READONLY = 0x00001000,
|
||||
|
||||
GAMEARRAY_OFCHAR = 0x00000001,
|
||||
GAMEARRAY_OFSHORT = 0x00000002,
|
||||
GAMEARRAY_OFINT = 0x00000004,
|
||||
GAMEARRAY_TYPEMASK = 0x00000007,
|
||||
|
||||
GAMEARRAY_VARSIZE = 0x00000020,
|
||||
|
||||
GAMEARRAY_RESET = 0x00000008,
|
||||
/// GAMEARRAY_NORESET = 0x00000001,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
intptr_t lValue; // pointer when (dwFlags & GAMEVAR_*PTR)
|
||||
int32_t *plValues; // array of values when (dwFlags & GAMEVAR_PERBLOCK)
|
||||
} val;
|
||||
intptr_t lDefault;
|
||||
char *szLabel;
|
||||
uint32_t dwFlags;
|
||||
} gamevar_t;
|
||||
|
||||
typedef struct {
|
||||
char *szLabel;
|
||||
void *vals; // array of values, type determined by (dwFlags & GAMEARRAY_TYPEMASK)
|
||||
uint32_t dwFlags;
|
||||
int32_t size; // id to size gamevar when (dwFlags & GAMEARRAY_VARSIZE)
|
||||
} gamearray_t;
|
||||
|
||||
extern gamevar_t aGameVars[MAXGAMEVARS];
|
||||
extern gamearray_t aGameArrays[MAXGAMEARRAYS];
|
||||
extern int32_t g_gameVarCount, g_systemVarCount;
|
||||
extern int32_t g_gameArrayCount, g_systemArrayCount;
|
||||
|
||||
|
||||
|
||||
extern int32_t g_iReturnVarID;
|
||||
extern int32_t g_iLoTagID; // var ID of "LOTAG"
|
||||
extern int32_t g_iHiTagID; // var ID of "HITAG"
|
||||
extern int32_t g_iTextureID; // var ID of "TEXTURE"
|
||||
extern int32_t g_iThisActorID; // var ID of "I" ///"THISACTOR"
|
||||
|
||||
extern int32_t g_numRealPalettes;
|
||||
extern int32_t g_scriptDebug;
|
||||
|
||||
extern int32_t g_numQuoteRedefinitions;
|
||||
|
||||
extern hashtable_t gamevarH;
|
||||
extern hashtable_t arrayH;
|
||||
extern hashtable_t keywH;
|
||||
extern hashtable_t gamefuncH;
|
||||
|
||||
|
||||
extern int16_t asksave;
|
||||
|
||||
extern vec3_t pos;
|
||||
extern int16_t ang;
|
||||
extern int16_t cursectnum;
|
||||
extern int32_t searchx;
|
||||
/*
|
||||
extern int16_t searchstat;
|
||||
extern int16_t searchwall;
|
||||
extern int16_t searchsector;
|
||||
extern int16_t searchbottomwall;
|
||||
*/
|
||||
extern int16_t pointhighlight;
|
||||
extern int16_t linehighlight;
|
||||
extern int16_t highlightcnt;
|
||||
extern int16_t highlightsectorcnt;
|
||||
/*
|
||||
extern int32_t temppicnum;
|
||||
extern int32_t tempcstat;
|
||||
extern int32_t templotag;
|
||||
extern int32_t temphitag;
|
||||
extern int32_t tempextra;
|
||||
extern int32_t tempshade;
|
||||
extern uint32_t temppal;
|
||||
extern uint32_t tempvis;
|
||||
extern uint32_t tempxrepeat;
|
||||
extern uint32_t tempyrepeat;
|
||||
*/
|
||||
extern int32_t startposx;
|
||||
extern int32_t startposy;
|
||||
extern int32_t startposz;
|
||||
extern int16_t startang;
|
||||
extern int16_t startsectnum;
|
||||
|
||||
extern int32_t mousxplc;
|
||||
extern int32_t mousyplc;
|
||||
|
||||
extern int16_t highlight[];
|
||||
extern int16_t highlightsector[];
|
||||
|
||||
extern int32_t numsprites;
|
||||
|
||||
#endif
|
|
@ -17,6 +17,7 @@
|
|||
#include "winlayer.h"
|
||||
#endif
|
||||
|
||||
#include "m32script.h"
|
||||
|
||||
#define TIMERINTSPERSECOND 120
|
||||
|
||||
|
@ -1105,6 +1106,8 @@ void editinput(void)
|
|||
|
||||
updatenumsprites();
|
||||
asksave = 1;
|
||||
|
||||
X_OnEvent(EVENT_INSERTSPRITE3D, i);
|
||||
}
|
||||
|
||||
keystatus[0x1f] = 0;
|
||||
|
@ -3163,6 +3166,8 @@ SKIP:
|
|||
printmessage16("Sprite inserted.");
|
||||
updatenumsprites();
|
||||
asksave = 1;
|
||||
|
||||
X_OnEvent(EVENT_INSERTSPRITE2D, i);
|
||||
}
|
||||
|
||||
keystatus[0x1f] = 0;
|
||||
|
@ -4719,6 +4724,8 @@ CANCEL:
|
|||
pos.z = oposz;
|
||||
searchx = scale(searchx,xdimgame,xdim2d);
|
||||
searchy = scale(searchy,ydimgame,ydim2d-STATUS2DSIZ);
|
||||
|
||||
X_OnEvent(EVENT_ENTER3DMODE, -1);
|
||||
}
|
||||
|
||||
void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
|
||||
|
|
|
@ -44,6 +44,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "macros.h"
|
||||
#include "fastlz.h"
|
||||
|
||||
#include "m32script.h"
|
||||
#include "m32def.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
@ -3775,6 +3778,7 @@ void drawtileinfo(char *title,int32_t x,int32_t y,int32_t picnum,int32_t shade,i
|
|||
int32_t i,j;
|
||||
int32_t scale=65536;
|
||||
int32_t x1;
|
||||
int32_t oviewingrange=viewingrange, oyxaspect=yxaspect;
|
||||
|
||||
j = xdimgame>640?0:1;
|
||||
i = ydimgame>>6;
|
||||
|
@ -3783,7 +3787,10 @@ void drawtileinfo(char *title,int32_t x,int32_t y,int32_t picnum,int32_t shade,i
|
|||
if (j)x1/=2;
|
||||
x1=(int32_t)(x1*(320./xdimgame));
|
||||
scale=(int32_t)(scale/(max(tilesizx[picnum],tilesizy[picnum])/24.));
|
||||
|
||||
setaspect(65536L, (int32_t)divscale16(ydim*320L,xdim*200L));
|
||||
rotatesprite((x1+13)<<16,(y+11)<<16,scale,0,picnum,shade,pal,2,0L,0L,xdim-1L,ydim-1L);
|
||||
setaspect(oviewingrange, oyxaspect);
|
||||
|
||||
x=(int32_t)(x*(xdimgame/320.));
|
||||
y=(int32_t)(y*(ydimgame/200.));
|
||||
|
@ -8839,6 +8846,104 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm)
|
|||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
// M32 script vvv
|
||||
static int32_t osdcmd_include(const osdfuncparm_t *parm)
|
||||
{
|
||||
if (parm->numparms != 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
C_Compile(parm->parms[0], 1);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int32_t osdcmd_scriptinfo(const osdfuncparm_t *parm)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(parm);
|
||||
C_CompilationInfo();
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int32_t osdcmd_do(const osdfuncparm_t *parm)
|
||||
{
|
||||
intptr_t tscrofs;
|
||||
char *tp;
|
||||
int32_t slen;
|
||||
|
||||
if (parm->numparms < 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
tscrofs = (g_scriptPtr-script);
|
||||
|
||||
slen = Bstrlen(parm->raw+2);
|
||||
tp = Bmalloc(slen+2);
|
||||
if (!tp)
|
||||
{
|
||||
initprintf("OUT OF MEMORY!\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
Bmemcpy(tp, parm->raw+2, slen);
|
||||
tp[slen] = '\n';
|
||||
tp[slen+1] = '\0';
|
||||
|
||||
C_Compile(tp, 0);
|
||||
Bfree(tp);
|
||||
if (g_numCompilerErrors == 0)
|
||||
{
|
||||
*g_scriptPtr = CON_RETURN + (g_lineNumber<<12);
|
||||
insptr = script + tscrofs;
|
||||
Bmemcpy(&vm, &vm_default, sizeof(vmstate_t));
|
||||
X_DoExecute(0);
|
||||
// asksave = 1; // handled in Access(Sprite|Sector|Wall)
|
||||
}
|
||||
g_scriptPtr = script + tscrofs;
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int32_t osdcmd_endisableevent(const osdfuncparm_t *parm)
|
||||
{
|
||||
int32_t i, j, enable;
|
||||
char buf[64] = "EVENT_";
|
||||
|
||||
if (parm->numparms < 1)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
enable = !Bstrcasecmp(parm->name, "enableevent");
|
||||
|
||||
if (parm->numparms == 1)
|
||||
{
|
||||
if (!Bstrcasecmp(parm->parms[0], "all"))
|
||||
{
|
||||
for (i=0; i<MAXEVENTS; i++)
|
||||
aEventEnabled[i] = enable?1:0;
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->parms[0], "show"))
|
||||
{
|
||||
for (i=0; i<MAXEVENTS; i++)
|
||||
if (aEventOffsets[i] >= 0)
|
||||
OSD_Printf("%s: %s\n", label+(i*MAXLABELLEN), aEventEnabled[i]?"on":"off");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<parm->numparms; i++)
|
||||
{
|
||||
if (isdigit(parm->parms[i][0]))
|
||||
j = atoi(parm->parms[i]);
|
||||
else if (!Bstrncmp(parm->parms[i], "EVENT_", 6))
|
||||
j = hash_find(&labelH, parm->parms[i]);
|
||||
else
|
||||
{
|
||||
Bstrncat(buf, parm->parms[i], sizeof(buf)-6-1);
|
||||
j = hash_find(&labelH, parm->parms[i]);
|
||||
}
|
||||
|
||||
if (j>=0 && j<MAXEVENTS)
|
||||
aEventEnabled[j] = enable?1:0;
|
||||
}
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int32_t registerosdcommands(void)
|
||||
{
|
||||
OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
|
||||
|
@ -8866,6 +8971,13 @@ static int32_t registerosdcommands(void)
|
|||
OSD_RegisterFunction("pk_quickmapcycling", "pk_quickmapcycling: allows cycling of maps with (Shift-)Ctrl-X", osdcmd_vars_pk);
|
||||
OSD_RegisterFunction("testplay_addparam", "testplay_addparam \"string\": set additional parameters for test playing", osdcmd_testplay_addparam);
|
||||
OSD_RegisterFunction("showheightindicators", "showheightindicators [012]: toggles height indicators in 2D mode", osdcmd_showheightindicators);
|
||||
|
||||
// M32 script
|
||||
OSD_RegisterFunction("include", "include <filnames...>: compiles one or more M32 script files", osdcmd_include);
|
||||
OSD_RegisterFunction("do", "do (m32 script ...): executes M32 script statements", osdcmd_do);
|
||||
OSD_RegisterFunction("scriptinfo", "scriptinfo: shows information about compiled M32 script", osdcmd_scriptinfo);
|
||||
OSD_RegisterFunction("enableevent", "enableevent <all|show||EVENT_...|(event number)>", osdcmd_endisableevent);
|
||||
OSD_RegisterFunction("disableevent", "disableevent <all|show|EVENT_...|(event number)>", osdcmd_endisableevent);
|
||||
return 0;
|
||||
}
|
||||
#define DUKEOSD
|
||||
|
@ -10187,6 +10299,7 @@ void ExtAnalyzeSprites(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i=0,tspr=&tsprite[0]; i<spritesortcnt; i++,tspr++)
|
||||
{
|
||||
frames=0;
|
||||
|
@ -10314,6 +10427,8 @@ void ExtAnalyzeSprites(void)
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
X_OnEvent(EVENT_ANALYZESPRITES, -1);
|
||||
}
|
||||
|
||||
#define MESSAGEX 3 // (xdimgame>>1)
|
||||
|
@ -10689,28 +10804,28 @@ void faketimerhandler(void)
|
|||
|
||||
extern int16_t brightness;
|
||||
|
||||
static inline void SetBOSS1Palette()
|
||||
void SetBOSS1Palette(void)
|
||||
{
|
||||
if (acurpalette==3) return;
|
||||
acurpalette=3;
|
||||
setbrightness(brightness,BOSS1palette,0);
|
||||
}
|
||||
|
||||
static inline void SetSLIMEPalette()
|
||||
void SetSLIMEPalette(void)
|
||||
{
|
||||
if (acurpalette==2) return;
|
||||
acurpalette=2;
|
||||
setbrightness(brightness,SLIMEpalette,0);
|
||||
}
|
||||
|
||||
static inline void SetWATERPalette()
|
||||
void SetWATERPalette(void)
|
||||
{
|
||||
if (acurpalette==1) return;
|
||||
acurpalette=1;
|
||||
setbrightness(brightness,WATERpalette,0);
|
||||
}
|
||||
|
||||
static inline void SetGAMEPalette()
|
||||
void SetGAMEPalette(void)
|
||||
{
|
||||
if (acurpalette==0) return;
|
||||
acurpalette=0;
|
||||
|
|
3221
polymer/eduke32/source/m32def.c
Normal file
3221
polymer/eduke32/source/m32def.c
Normal file
File diff suppressed because it is too large
Load diff
491
polymer/eduke32/source/m32def.h
Normal file
491
polymer/eduke32/source/m32def.h
Normal file
|
@ -0,0 +1,491 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
Copyright (C) 2004, 2007 - EDuke32 developers
|
||||
|
||||
This file is part of EDuke32
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#ifndef _m32def_h_
|
||||
#define _m32def_h_
|
||||
|
||||
extern int32_t g_iReturnVarID; // var ID of "RETURN"
|
||||
extern int32_t g_iLoTagID; // var ID of "LOTAG"
|
||||
extern int32_t g_iHiTagID; // var ID of "HITAG"
|
||||
extern int32_t g_iTextureID; // var ID of "TEXTURE"
|
||||
|
||||
extern int32_t g_iThisActorID; // var ID of "I" ///"THISACTOR"
|
||||
|
||||
extern int32_t g_iSpriteVarID;
|
||||
extern int32_t g_iSectorVarID;
|
||||
extern int32_t g_iWallVarID;
|
||||
|
||||
#define ABORTERRCNT 8
|
||||
#define CON_ERROR OSD_ERROR "Line %d, %s: "
|
||||
|
||||
extern char g_szScriptFileName[BMAX_PATH];
|
||||
extern int32_t g_totalLines,g_lineNumber;
|
||||
extern int32_t g_numCompilerErrors,g_numCompilerWarnings;
|
||||
|
||||
extern instype *g_scriptPtr;
|
||||
|
||||
void C_Compile(const char *filenameortext, int32_t isfilename);
|
||||
void C_CompilationInfo(void);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t ofs;
|
||||
int32_t codesize;
|
||||
char name[MAXLABELLEN];
|
||||
} statesinfo_t;
|
||||
|
||||
extern statesinfo_t *statesinfo;
|
||||
extern int32_t g_stateCount;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
int16_t lId;
|
||||
int16_t flags; // 1: read-only
|
||||
int32_t min, max;
|
||||
} memberlabel_t;
|
||||
|
||||
extern const memberlabel_t SectorLabels[];
|
||||
extern const memberlabel_t WallLabels[];
|
||||
extern const memberlabel_t SpriteLabels[];
|
||||
|
||||
|
||||
typedef struct {
|
||||
char* token; int32_t val;
|
||||
} tokenmap_t;
|
||||
|
||||
extern const tokenmap_t iter_tokens[];
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32_t g_i;
|
||||
// VM state: either ==0 (top-level), >=1 and < MAXEVENTS+1 (event),
|
||||
// or >= MAXEVENTS+1 and < MAXEVENTS+1+g_stateCount (state)
|
||||
int32_t g_st;
|
||||
spritetype *g_sp;
|
||||
int32_t g_errorFlag, g_returnFlag;
|
||||
} vmstate_t;
|
||||
|
||||
extern vmstate_t vm;
|
||||
extern vmstate_t vm_default;
|
||||
|
||||
|
||||
extern int32_t g_errorLineNum;
|
||||
extern int32_t g_tw;
|
||||
extern const char *keyw[];
|
||||
|
||||
enum SystemString_t {
|
||||
STR_MAPFILENAME,
|
||||
STR_VERSION,
|
||||
};
|
||||
|
||||
enum ScriptError_t
|
||||
{
|
||||
ERROR_CLOSEBRACKET,
|
||||
ERROR_EVENTONLY,
|
||||
ERROR_EXCEEDSMAXTILES,
|
||||
ERROR_EXPECTEDKEYWORD,
|
||||
ERROR_FOUNDWITHIN,
|
||||
ERROR_ISAKEYWORD,
|
||||
ERROR_NOENDSWITCH,
|
||||
ERROR_NOTAGAMEDEF,
|
||||
ERROR_NOTAGAMEVAR,
|
||||
ERROR_NOTAGAMEARRAY,
|
||||
ERROR_GAMEARRAYBNC,
|
||||
ERROR_GAMEARRAYBNO,
|
||||
ERROR_INVALIDARRAYWRITE,
|
||||
ERROR_EXPECTEDSIMPLEVAR,
|
||||
ERROR_OPENBRACKET,
|
||||
ERROR_PARAMUNDEFINED,
|
||||
ERROR_SYMBOLNOTRECOGNIZED,
|
||||
ERROR_SYNTAXERROR,
|
||||
ERROR_VARREADONLY,
|
||||
ERROR_VARTYPEMISMATCH,
|
||||
ERROR_LABELINUSE,
|
||||
// WARNING_BADGAMEVAR,
|
||||
WARNING_DUPLICATECASE,
|
||||
WARNING_DUPLICATEDEFINITION,
|
||||
WARNING_LABELSONLY,
|
||||
WARNING_NAMEMATCHESVAR,
|
||||
WARNING_CONSTANTBITSIZE,
|
||||
};
|
||||
|
||||
|
||||
enum SectorLabel_t
|
||||
{
|
||||
SECTOR_WALLPTR,
|
||||
SECTOR_WALLNUM,
|
||||
SECTOR_CEILINGZ,
|
||||
SECTOR_FLOORZ,
|
||||
SECTOR_CEILINGSTAT,
|
||||
SECTOR_FLOORSTAT,
|
||||
SECTOR_CEILINGPICNUM,
|
||||
SECTOR_CEILINGSLOPE,
|
||||
SECTOR_CEILINGSHADE,
|
||||
SECTOR_CEILINGPAL,
|
||||
SECTOR_CEILINGXPANNING,
|
||||
SECTOR_CEILINGYPANNING,
|
||||
SECTOR_FLOORPICNUM,
|
||||
SECTOR_FLOORSLOPE,
|
||||
SECTOR_FLOORSHADE,
|
||||
SECTOR_FLOORPAL,
|
||||
SECTOR_FLOORXPANNING,
|
||||
SECTOR_FLOORYPANNING,
|
||||
SECTOR_VISIBILITY,
|
||||
SECTOR_ALIGNTO,
|
||||
SECTOR_LOTAG,
|
||||
SECTOR_HITAG,
|
||||
SECTOR_EXTRA,
|
||||
SECTOR_END
|
||||
};
|
||||
|
||||
enum WallLabel_t
|
||||
{
|
||||
WALL_X,
|
||||
WALL_Y,
|
||||
WALL_POINT2,
|
||||
WALL_NEXTWALL,
|
||||
WALL_NEXTSECTOR,
|
||||
WALL_CSTAT,
|
||||
WALL_PICNUM,
|
||||
WALL_OVERPICNUM,
|
||||
WALL_SHADE,
|
||||
WALL_PAL,
|
||||
WALL_XREPEAT,
|
||||
WALL_YREPEAT,
|
||||
WALL_XPANNING,
|
||||
WALL_YPANNING,
|
||||
WALL_LOTAG,
|
||||
WALL_HITAG,
|
||||
WALL_EXTRA,
|
||||
WALL_END
|
||||
};
|
||||
|
||||
enum SpriteLabel_t
|
||||
{
|
||||
SPRITE_X,
|
||||
SPRITE_Y,
|
||||
SPRITE_Z,
|
||||
SPRITE_CSTAT,
|
||||
SPRITE_PICNUM,
|
||||
SPRITE_SHADE,
|
||||
SPRITE_PAL,
|
||||
SPRITE_CLIPDIST,
|
||||
SPRITE_DETAIL,
|
||||
SPRITE_XREPEAT,
|
||||
SPRITE_YREPEAT,
|
||||
SPRITE_XOFFSET,
|
||||
SPRITE_YOFFSET,
|
||||
SPRITE_SECTNUM,
|
||||
SPRITE_STATNUM,
|
||||
SPRITE_ANG,
|
||||
SPRITE_OWNER,
|
||||
SPRITE_XVEL,
|
||||
SPRITE_YVEL,
|
||||
SPRITE_ZVEL,
|
||||
SPRITE_LOTAG,
|
||||
SPRITE_HITAG,
|
||||
SPRITE_EXTRA,
|
||||
SPRITE_END
|
||||
};
|
||||
|
||||
enum IterationTypes_t
|
||||
{
|
||||
ITER_ALLSPRITES,
|
||||
ITER_ALLSECTORS,
|
||||
ITER_ALLWALLS,
|
||||
ITER_SELSPRITES,
|
||||
ITER_SELSECTORS,
|
||||
ITER_SELWALLS,
|
||||
ITER_DRAWNSPRITES,
|
||||
ITER_SPRITESOFSECTOR,
|
||||
ITER_WALLSOFSECTOR,
|
||||
ITER_RANGE,
|
||||
ITER_END
|
||||
};
|
||||
|
||||
enum ScriptKeywords_t
|
||||
{
|
||||
// basic commands
|
||||
CON_NULLOP,
|
||||
CON_DEFINE,
|
||||
CON_INCLUDE,
|
||||
CON_DEFSTATE,
|
||||
CON_ENDS,
|
||||
CON_STATE,
|
||||
CON_ONEVENT,
|
||||
CON_ENDEVENT,
|
||||
CON_GAMEVAR,
|
||||
|
||||
// control flow (except if*)
|
||||
CON_ELSE,
|
||||
CON_RETURN,
|
||||
CON_BREAK,
|
||||
CON_SWITCH,
|
||||
CON_CASE,
|
||||
CON_DEFAULT,
|
||||
CON_ENDSWITCH,
|
||||
CON_GETCURRADDRESS,
|
||||
CON_JUMP,
|
||||
CON_LEFTBRACE,
|
||||
CON_RIGHTBRACE,
|
||||
|
||||
// more basic commands
|
||||
CON_SETSECTOR,
|
||||
CON_GETSECTOR,
|
||||
CON_SETWALL,
|
||||
CON_GETWALL,
|
||||
CON_SETSPRITE, //+
|
||||
CON_GETSPRITE, //+
|
||||
CON_GETTSPR,
|
||||
CON_SETTSPR,
|
||||
|
||||
// arrays
|
||||
CON_GAMEARRAY,
|
||||
CON_SETARRAY,
|
||||
CON_GETARRAYSIZE,
|
||||
CON_RESIZEARRAY,
|
||||
CON_COPY,
|
||||
/// CON_WRITEARRAYTOFILE,
|
||||
/// CON_READARRAYFROMFILE,
|
||||
|
||||
// var ops
|
||||
CON_RANDVAR,
|
||||
CON_DISPLAYRANDVAR,
|
||||
CON_SETVAR,
|
||||
CON_ADDVAR,
|
||||
CON_SUBVAR,
|
||||
CON_MULVAR,
|
||||
CON_DIVVAR,
|
||||
CON_MODVAR,
|
||||
CON_ANDVAR,
|
||||
CON_ORVAR,
|
||||
CON_XORVAR,
|
||||
CON_SHIFTVARL,
|
||||
CON_SHIFTVARR,
|
||||
// varvar ops
|
||||
CON_RANDVARVAR,
|
||||
CON_DISPLAYRANDVARVAR,
|
||||
CON_SETVARVAR,
|
||||
CON_ADDVARVAR,
|
||||
CON_SUBVARVAR,
|
||||
CON_MULVARVAR,
|
||||
CON_DIVVARVAR,
|
||||
CON_MODVARVAR,
|
||||
CON_ANDVARVAR,
|
||||
CON_ORVARVAR,
|
||||
CON_XORVARVAR,
|
||||
CON_SIN,
|
||||
CON_COS,
|
||||
|
||||
// random
|
||||
CON_DISPLAYRAND,
|
||||
|
||||
// other math
|
||||
CON_INV,
|
||||
CON_SQRT,
|
||||
CON_MULSCALE,
|
||||
CON_DIST,
|
||||
CON_LDIST,
|
||||
CON_GETANGLE,
|
||||
CON_GETINCANGLE,
|
||||
|
||||
CON_FOR,
|
||||
|
||||
// if & while var
|
||||
CON_IFVARL,
|
||||
CON_IFVARLE,
|
||||
CON_IFVARG,
|
||||
CON_IFVARGE,
|
||||
CON_IFVARE,
|
||||
CON_IFVARN,
|
||||
CON_IFVARAND,
|
||||
CON_IFVAROR,
|
||||
CON_IFVARXOR,
|
||||
CON_IFVAREITHER,
|
||||
CON_IFVARBOTH,
|
||||
CON_WHILEVARN,
|
||||
CON_WHILEVARL,
|
||||
|
||||
// if & while varvar
|
||||
CON_IFVARVARL,
|
||||
CON_IFVARVARLE,
|
||||
CON_IFVARVARG,
|
||||
CON_IFVARVARGE,
|
||||
CON_IFVARVARE,
|
||||
CON_IFVARVARN,
|
||||
CON_IFVARVARAND,
|
||||
CON_IFVARVAROR,
|
||||
CON_IFVARVARXOR,
|
||||
CON_IFVARVAREITHER,
|
||||
CON_IFVARVARBOTH,
|
||||
CON_WHILEVARVARN,
|
||||
CON_WHILEVARVARL,
|
||||
|
||||
// other if*
|
||||
CON_IFRND,
|
||||
|
||||
// if* using current sprite
|
||||
CON_IFANGDIFFL,
|
||||
CON_IFSPRITEPAL,
|
||||
CON_IFACTOR,
|
||||
CON_IFPDISTL,
|
||||
CON_IFPDISTG,
|
||||
/// CON_IFGAPZL,
|
||||
/// CON_IFFLOORDISTL,
|
||||
/// CON_IFCEILINGDISTL,
|
||||
/// CON_IFSOUND,
|
||||
|
||||
CON_IFINSIDE,
|
||||
|
||||
CON_IFAWAYFROMWALL,
|
||||
CON_IFCANSEE,
|
||||
CON_IFONWATER,
|
||||
CON_IFINWATER,
|
||||
CON_IFOUTSIDE,
|
||||
/// CON_IFHITSPACE,
|
||||
/// CON_IFINSPACE,
|
||||
/// CON_IFINOUTERSPACE,
|
||||
/// CON_IFCANSEETARGET,
|
||||
/// CON_IFNOSOUNDS,
|
||||
|
||||
// BUILD functions
|
||||
CON_INSERTSPRITE,
|
||||
CON_DUPSPRITE,
|
||||
CON_DELETESPRITE,
|
||||
CON_LASTWALL,
|
||||
CON_UPDATESECTOR,
|
||||
CON_UPDATESECTORZ,
|
||||
CON_GETZRANGE,
|
||||
CON_HITSCAN,
|
||||
CON_CANSEE,
|
||||
CON_CANSEESPR,
|
||||
CON_NEARTAG,
|
||||
CON_ROTATEPOINT,
|
||||
CON_DRAGPOINT,
|
||||
CON_GETCEILZOFSLOPE,
|
||||
CON_GETFLORZOFSLOPE,
|
||||
CON_BSETSPRITE, // was CON_SETSPRITE
|
||||
CON_CHANGESPRITESTAT,
|
||||
CON_CHANGESPRITESECT,
|
||||
CON_HEADSPRITESTAT,
|
||||
CON_PREVSPRITESTAT,
|
||||
CON_NEXTSPRITESTAT,
|
||||
CON_HEADSPRITESECT,
|
||||
CON_PREVSPRITESECT,
|
||||
CON_NEXTSPRITESECT,
|
||||
CON_SECTOROFWALL,
|
||||
|
||||
// stuff
|
||||
CON_ADDLOGVAR,
|
||||
CON_ADDLOG,
|
||||
CON_DEBUG,
|
||||
|
||||
// strings
|
||||
CON_DEFINEQUOTE,
|
||||
CON_REDEFINEQUOTE,
|
||||
CON_QUOTE,
|
||||
CON_ERRORINS,
|
||||
CON_PRINTMESSAGE16,
|
||||
CON_PRINTMESSAGE256,
|
||||
CON_PRINTEXT256,
|
||||
CON_QSPRINTF,
|
||||
CON_QSTRCAT,
|
||||
CON_QSTRCPY,
|
||||
CON_QSTRLEN,
|
||||
// CON_QGETSYSSTR,
|
||||
CON_QSTRNCAT,
|
||||
CON_QSUBSTR,
|
||||
|
||||
// findnear*
|
||||
CON_FINDNEARSPRITE,
|
||||
CON_FINDNEARSPRITEVAR,
|
||||
CON_FINDNEARSPRITE3D,
|
||||
CON_FINDNEARSPRITE3DVAR,
|
||||
CON_FINDNEARSPRITEZ,
|
||||
CON_FINDNEARSPRITEZVAR,
|
||||
|
||||
CON_GETTICKS,
|
||||
CON_GETTIMEDATE,
|
||||
CON_SETASPECT,
|
||||
|
||||
// vvv stuff using current sprite
|
||||
CON_SETI,
|
||||
CON_SIZEAT,
|
||||
CON_CSTAT,
|
||||
CON_CSTATOR,
|
||||
CON_CLIPDIST,
|
||||
CON_SPRITEPAL,
|
||||
CON_CACTOR,
|
||||
CON_SPGETLOTAG,
|
||||
CON_SPGETHITAG,
|
||||
CON_SECTGETLOTAG,
|
||||
CON_SECTGETHITAG,
|
||||
CON_GETTEXTUREFLOOR,
|
||||
CON_GETTEXTURECEILING,
|
||||
/// CON_KILLIT,
|
||||
|
||||
// left to define later/undecided
|
||||
|
||||
// sound
|
||||
/// CON_SOUND,
|
||||
/// CON_SOUNDVAR,
|
||||
/// CON_SOUNDONCE,
|
||||
/// CON_STOPSOUND,
|
||||
/// CON_GLOBALSOUND,
|
||||
/// CON_SOUNDONCEVAR,
|
||||
/// CON_STOPALLSOUNDS,
|
||||
/// CON_STOPSOUNDVAR,
|
||||
/// CON_GLOBALSOUNDVAR,
|
||||
|
||||
// drawing
|
||||
/// CON_MYOS,
|
||||
/// CON_MYOSPAL,
|
||||
/// CON_MYOSX,
|
||||
/// CON_MYOSPALX,
|
||||
/// CON_MINITEXT,
|
||||
/// CON_GAMETEXT,
|
||||
/// CON_DIGITALNUMBER,
|
||||
/// CON_SHOWVIEW,
|
||||
/// CON_GAMETEXTZ,
|
||||
/// CON_DIGITALNUMBERZ,
|
||||
CON_ROTATESPRITE16,
|
||||
CON_ROTATESPRITE,
|
||||
CON_SETGAMEPALETTE,
|
||||
|
||||
/// CON_TIME,
|
||||
/// CON_GETANGLETOTARGET,
|
||||
/// CON_ANGOFF,
|
||||
/// CON_ANGOFFVAR,
|
||||
/// CON_PRECACHE,
|
||||
/// CON_SAVEGAMEVAR,
|
||||
/// CON_READGAMEVAR,
|
||||
/// CON_SETDEFNAME,
|
||||
/// CON_SETCFGNAME,
|
||||
|
||||
CON_END
|
||||
};
|
||||
|
||||
#endif
|
2335
polymer/eduke32/source/m32exec.c
Normal file
2335
polymer/eduke32/source/m32exec.c
Normal file
File diff suppressed because it is too large
Load diff
462
polymer/eduke32/source/m32structures.c
Normal file
462
polymer/eduke32/source/m32structures.c
Normal file
|
@ -0,0 +1,462 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
Copyright (C) 2004, 2007 - EDuke32 developers
|
||||
|
||||
This file is part of EDuke32
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// this is all the crap for accessing the game's structs through the CON VM
|
||||
// I got a 3-4 fps gain by inlining these...
|
||||
|
||||
#include "compat.h"
|
||||
#include "m32script.h"
|
||||
#include "m32def.h"
|
||||
|
||||
|
||||
// how: bitfield: 1=set? 2=vars? 4=use spriteext[].tspr? (otherwise use tsprite[])
|
||||
#define ACCESS_SET 1
|
||||
#define ACCESS_USEVARS 2
|
||||
#define ACCESS_SPRITEEXT 4
|
||||
|
||||
|
||||
static int32_t __fastcall X_AccessWall(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
|
||||
{
|
||||
int32_t lValue;
|
||||
int32_t i = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar1) : lVar1;
|
||||
|
||||
if (i<0 || i >= numwalls)
|
||||
goto badwall;
|
||||
|
||||
if (how&ACCESS_SET)
|
||||
{
|
||||
if (WallLabels[lLabelID].flags & 1)
|
||||
goto readonly;
|
||||
|
||||
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
|
||||
|
||||
asksave = 1;
|
||||
|
||||
if (WallLabels[lLabelID].min != 0 || WallLabels[lLabelID].max != 0)
|
||||
{
|
||||
if (lValue < WallLabels[lLabelID].min)
|
||||
lValue = WallLabels[lLabelID].min;
|
||||
if (lValue > WallLabels[lLabelID].max)
|
||||
lValue = WallLabels[lLabelID].max;
|
||||
}
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case WALL_X: wall[i].x=lValue; break;
|
||||
case WALL_Y: wall[i].y=lValue; break;
|
||||
case WALL_POINT2: wall[i].point2=lValue; break;
|
||||
case WALL_NEXTWALL: wall[i].nextwall=lValue; break;
|
||||
case WALL_NEXTSECTOR: wall[i].nextsector=lValue; break;
|
||||
case WALL_CSTAT:
|
||||
wall[i].cstat = lValue&0x03ff;
|
||||
break;
|
||||
case WALL_PICNUM: wall[i].picnum=lValue; break;
|
||||
case WALL_OVERPICNUM: wall[i].overpicnum=lValue; break;
|
||||
case WALL_SHADE: wall[i].shade=lValue; break;
|
||||
case WALL_PAL: wall[i].pal=lValue; break;
|
||||
case WALL_XREPEAT: wall[i].xrepeat=lValue; break;
|
||||
case WALL_YREPEAT: wall[i].yrepeat=lValue; break;
|
||||
case WALL_XPANNING: wall[i].xpanning=lValue; break;
|
||||
case WALL_YPANNING: wall[i].ypanning=lValue; break;
|
||||
case WALL_LOTAG: wall[i].lotag=lValue; break;
|
||||
case WALL_HITAG: wall[i].hitag=lValue; break;
|
||||
case WALL_EXTRA: wall[i].extra=lValue; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (lLabelID)
|
||||
{
|
||||
case WALL_X: lValue=wall[i].x; break;
|
||||
case WALL_Y: lValue=wall[i].y; break;
|
||||
case WALL_POINT2: lValue=wall[i].point2; break;
|
||||
case WALL_NEXTWALL: lValue=wall[i].nextwall; break;
|
||||
case WALL_NEXTSECTOR: lValue=wall[i].nextsector; break;
|
||||
case WALL_CSTAT: lValue=wall[i].cstat; break;
|
||||
case WALL_PICNUM: lValue=wall[i].picnum; break;
|
||||
case WALL_OVERPICNUM: lValue=wall[i].overpicnum; break;
|
||||
case WALL_SHADE: lValue=wall[i].shade; break;
|
||||
case WALL_PAL: lValue=wall[i].pal; break;
|
||||
case WALL_XREPEAT: lValue=wall[i].xrepeat; break;
|
||||
case WALL_YREPEAT: lValue=wall[i].yrepeat; break;
|
||||
case WALL_XPANNING: lValue=wall[i].xpanning; break;
|
||||
case WALL_YPANNING: lValue=wall[i].ypanning; break;
|
||||
case WALL_LOTAG: lValue=wall[i].lotag; break;
|
||||
case WALL_HITAG: lValue=wall[i].hitag; break;
|
||||
case WALL_EXTRA: lValue=wall[i].extra; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (how&ACCESS_USEVARS)
|
||||
Gv_SetVarX(lVar2, lValue);
|
||||
|
||||
return lValue;
|
||||
}
|
||||
|
||||
badwall:
|
||||
OSD_Printf(CON_ERROR "Invalid wall %d\n",g_errorLineNum,keyw[g_tw],i);
|
||||
return -1;
|
||||
readonly:
|
||||
OSD_Printf(CON_ERROR "Wall structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],WallLabels[lLabelID].name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// how: bitfield: 1=set? 2=vars?
|
||||
static int32_t __fastcall X_AccessSector(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
|
||||
{
|
||||
int32_t lValue;
|
||||
int32_t i = (how&ACCESS_USEVARS) ? sprite[vm.g_i].sectnum : lVar1;
|
||||
|
||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
||||
i = Gv_GetVarX(lVar1);
|
||||
|
||||
if (i<0 || i >= numsectors)
|
||||
goto badsector;
|
||||
|
||||
if (how&ACCESS_SET)
|
||||
{
|
||||
if (SectorLabels[lLabelID].flags & 1)
|
||||
goto readonly;
|
||||
|
||||
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
|
||||
|
||||
asksave = 1;
|
||||
|
||||
if (SectorLabels[lLabelID].min != 0 || SectorLabels[lLabelID].max != 0)
|
||||
{
|
||||
if (lValue < SectorLabels[lLabelID].min)
|
||||
lValue = SectorLabels[lLabelID].min;
|
||||
if (lValue > SectorLabels[lLabelID].max)
|
||||
lValue = SectorLabels[lLabelID].max;
|
||||
}
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SECTOR_WALLPTR: sector[i].wallptr=lValue; break;
|
||||
case SECTOR_WALLNUM: sector[i].wallnum=lValue; break;
|
||||
case SECTOR_CEILINGZ: sector[i].ceilingz=lValue; break;
|
||||
case SECTOR_FLOORZ: sector[i].floorz=lValue; break;
|
||||
case SECTOR_CEILINGSTAT:
|
||||
sector[i].ceilingstat = lValue&0x01ff;
|
||||
break;
|
||||
case SECTOR_FLOORSTAT:
|
||||
sector[i].floorstat = lValue&0x01ff;
|
||||
break;
|
||||
case SECTOR_CEILINGPICNUM: sector[i].ceilingpicnum=lValue; break;
|
||||
case SECTOR_CEILINGSLOPE: sector[i].ceilingheinum=lValue; break;
|
||||
case SECTOR_CEILINGSHADE: sector[i].ceilingshade=lValue; break;
|
||||
case SECTOR_CEILINGPAL: sector[i].ceilingpal=lValue; break;
|
||||
case SECTOR_CEILINGXPANNING: sector[i].ceilingxpanning=lValue; break;
|
||||
case SECTOR_CEILINGYPANNING: sector[i].ceilingypanning=lValue; break;
|
||||
case SECTOR_FLOORPICNUM: sector[i].floorpicnum=lValue; break;
|
||||
case SECTOR_FLOORSLOPE: sector[i].floorheinum=lValue; break;
|
||||
case SECTOR_FLOORSHADE: sector[i].floorshade=lValue; break;
|
||||
case SECTOR_FLOORPAL: sector[i].floorpal=lValue; break;
|
||||
case SECTOR_FLOORXPANNING: sector[i].floorxpanning=lValue; break;
|
||||
case SECTOR_FLOORYPANNING: sector[i].floorypanning=lValue; break;
|
||||
case SECTOR_VISIBILITY: sector[i].visibility=lValue; break;
|
||||
case SECTOR_ALIGNTO: sector[i].filler=lValue; break;
|
||||
case SECTOR_LOTAG: sector[i].lotag=lValue; break;
|
||||
case SECTOR_HITAG: sector[i].hitag=lValue; break;
|
||||
case SECTOR_EXTRA: sector[i].extra=lValue; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SECTOR_WALLPTR: lValue=sector[i].wallptr; break;
|
||||
case SECTOR_WALLNUM: lValue=sector[i].wallnum; break;
|
||||
case SECTOR_CEILINGZ: lValue=sector[i].ceilingz; break;
|
||||
case SECTOR_FLOORZ: lValue=sector[i].floorz; break;
|
||||
case SECTOR_CEILINGSTAT: lValue=sector[i].ceilingstat; break;
|
||||
case SECTOR_FLOORSTAT: lValue=sector[i].floorstat; break;
|
||||
case SECTOR_CEILINGPICNUM: lValue=sector[i].ceilingpicnum; break;
|
||||
case SECTOR_CEILINGSLOPE: lValue=sector[i].ceilingheinum; break;
|
||||
case SECTOR_CEILINGSHADE: lValue=sector[i].ceilingshade; break;
|
||||
case SECTOR_CEILINGPAL: lValue=sector[i].ceilingpal; break;
|
||||
case SECTOR_CEILINGXPANNING: lValue=sector[i].ceilingxpanning; break;
|
||||
case SECTOR_CEILINGYPANNING: lValue=sector[i].ceilingypanning; break;
|
||||
case SECTOR_FLOORPICNUM: lValue=sector[i].floorpicnum; break;
|
||||
case SECTOR_FLOORSLOPE: lValue=sector[i].floorheinum; break;
|
||||
case SECTOR_FLOORSHADE: lValue=sector[i].floorshade; break;
|
||||
case SECTOR_FLOORPAL: lValue=sector[i].floorpal; break;
|
||||
case SECTOR_FLOORXPANNING: lValue=sector[i].floorxpanning; break;
|
||||
case SECTOR_FLOORYPANNING: lValue=sector[i].floorypanning; break;
|
||||
case SECTOR_VISIBILITY: lValue=sector[i].visibility; break;
|
||||
case SECTOR_ALIGNTO: lValue=sector[i].filler; break;
|
||||
case SECTOR_LOTAG: lValue=sector[i].lotag; break;
|
||||
case SECTOR_HITAG: lValue=sector[i].hitag; break;
|
||||
case SECTOR_EXTRA: lValue=sector[i].extra; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (how&ACCESS_USEVARS)
|
||||
Gv_SetVarX(lVar2, lValue);
|
||||
|
||||
return lValue;
|
||||
}
|
||||
|
||||
badsector:
|
||||
OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],i);
|
||||
return -1;
|
||||
readonly:
|
||||
OSD_Printf(CON_ERROR "Sector structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],SectorLabels[lLabelID].name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// how: bitfield: 1=set? 2=vars?
|
||||
static int32_t __fastcall X_AccessSprite(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
|
||||
{
|
||||
int32_t lValue;
|
||||
register int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
||||
|
||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
||||
i = Gv_GetVarX(lVar1);
|
||||
|
||||
if (i < 0 || i >= MAXSPRITES)
|
||||
goto badactor;
|
||||
|
||||
if (how&ACCESS_SET)
|
||||
{
|
||||
if (SpriteLabels[lLabelID].flags & 1)
|
||||
goto readonly;
|
||||
|
||||
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
|
||||
|
||||
asksave = 1;
|
||||
|
||||
if (SpriteLabels[lLabelID].min != 0 || SpriteLabels[lLabelID].max != 0)
|
||||
{
|
||||
if (lValue < SpriteLabels[lLabelID].min)
|
||||
lValue = SpriteLabels[lLabelID].min;
|
||||
if (lValue > SpriteLabels[lLabelID].max)
|
||||
lValue = SpriteLabels[lLabelID].max;
|
||||
}
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SPRITE_X: sprite[i].x=lValue; break;
|
||||
case SPRITE_Y: sprite[i].y=lValue; break;
|
||||
case SPRITE_Z: sprite[i].z=lValue; break;
|
||||
case SPRITE_CSTAT:
|
||||
sprite[i].cstat = lValue&0xe3ff;
|
||||
break;
|
||||
case SPRITE_PICNUM: sprite[i].picnum=lValue; break;
|
||||
case SPRITE_SHADE: sprite[i].shade=lValue; break;
|
||||
case SPRITE_PAL: sprite[i].pal=lValue; break;
|
||||
case SPRITE_CLIPDIST: sprite[i].clipdist=lValue; break;
|
||||
case SPRITE_DETAIL: sprite[i].filler=lValue; break;
|
||||
case SPRITE_XREPEAT: sprite[i].xrepeat=lValue; break;
|
||||
case SPRITE_YREPEAT: sprite[i].yrepeat=lValue; break;
|
||||
case SPRITE_XOFFSET: sprite[i].xoffset=lValue; break;
|
||||
case SPRITE_YOFFSET: sprite[i].yoffset=lValue; break;
|
||||
case SPRITE_SECTNUM: changespritesect(i,lValue); break;
|
||||
case SPRITE_STATNUM: changespritestat(i,lValue); break;
|
||||
case SPRITE_ANG:
|
||||
sprite[i].ang = lValue&2047;
|
||||
break;
|
||||
case SPRITE_OWNER: sprite[i].owner=lValue; break;
|
||||
case SPRITE_XVEL: sprite[i].xvel=lValue; break;
|
||||
case SPRITE_YVEL: sprite[i].yvel=lValue; break;
|
||||
case SPRITE_ZVEL: sprite[i].zvel=lValue; break;
|
||||
case SPRITE_LOTAG: sprite[i].lotag=lValue; break;
|
||||
case SPRITE_HITAG: sprite[i].hitag=lValue; break;
|
||||
case SPRITE_EXTRA: sprite[i].extra=lValue; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SPRITE_X: lValue=sprite[i].x; break;
|
||||
case SPRITE_Y: lValue=sprite[i].y; break;
|
||||
case SPRITE_Z: lValue=sprite[i].z; break;
|
||||
case SPRITE_CSTAT: lValue=sprite[i].cstat; break;
|
||||
case SPRITE_PICNUM: lValue=sprite[i].picnum; break;
|
||||
case SPRITE_SHADE: lValue=sprite[i].shade; break;
|
||||
case SPRITE_PAL: lValue=sprite[i].pal; break;
|
||||
case SPRITE_CLIPDIST: lValue=sprite[i].clipdist; break;
|
||||
case SPRITE_DETAIL: lValue=sprite[i].filler; break;
|
||||
case SPRITE_XREPEAT: lValue=sprite[i].xrepeat; break;
|
||||
case SPRITE_YREPEAT: lValue=sprite[i].yrepeat; break;
|
||||
case SPRITE_XOFFSET: lValue=sprite[i].xoffset; break;
|
||||
case SPRITE_YOFFSET: lValue=sprite[i].yoffset; break;
|
||||
case SPRITE_SECTNUM: lValue=sprite[i].sectnum; break;
|
||||
case SPRITE_STATNUM: lValue=sprite[i].statnum; break;
|
||||
case SPRITE_ANG: lValue=sprite[i].ang; break;
|
||||
case SPRITE_OWNER: lValue=sprite[i].owner; break;
|
||||
case SPRITE_XVEL: lValue=sprite[i].xvel; break;
|
||||
case SPRITE_YVEL: lValue=sprite[i].yvel; break;
|
||||
case SPRITE_ZVEL: lValue=sprite[i].zvel; break;
|
||||
case SPRITE_LOTAG: lValue=sprite[i].lotag; break;
|
||||
case SPRITE_HITAG: lValue=sprite[i].hitag; break;
|
||||
case SPRITE_EXTRA: lValue=sprite[i].extra; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (how&ACCESS_USEVARS)
|
||||
Gv_SetVarX(lVar2, lValue);
|
||||
|
||||
return lValue;
|
||||
}
|
||||
badactor:
|
||||
// OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d) from spr %d pic %d gv %s\n",g_errorLineNum,keyw[g_tw],
|
||||
// SpriteLabels[lLabelID].name,i,vm.g_i,vm.g_sp->picnum,
|
||||
// (lVar1<MAXGAMEVARS)?aGameVars[lVar1].szLabel:"extended");
|
||||
OSD_Printf(CON_ERROR "tried to set %s on invalid target sprite (%d)\n",g_errorLineNum,keyw[g_tw],
|
||||
SpriteLabels[lLabelID].name,i);
|
||||
return -1;
|
||||
readonly:
|
||||
OSD_Printf(CON_ERROR "Sprite structure member `%s' is read-only.\n",g_errorLineNum,keyw[g_tw],SpriteLabels[lLabelID].name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// how: bitfield: 1=set? 2=vars? 4=use spriteext[].tspr? (otherwise use tsprite[])
|
||||
static int32_t __fastcall X_AccessTsprite(int32_t how, int32_t lVar1, int32_t lLabelID, int32_t lVar2)
|
||||
{
|
||||
int32_t lValue;
|
||||
int32_t i = (how&ACCESS_USEVARS) ? vm.g_i : lVar1;
|
||||
spritetype *datspr;
|
||||
|
||||
if ((how&ACCESS_USEVARS) && lVar1 != g_iThisActorID)
|
||||
i = Gv_GetVarX(lVar1);
|
||||
|
||||
if (how&ACCESS_SPRITEEXT)
|
||||
{
|
||||
if (i < 0 || i >= MAXSPRITES)
|
||||
goto badsprite;
|
||||
datspr = spriteext[i].tspr;
|
||||
if (!datspr)
|
||||
goto badtspr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i<0 || i>=spritesortcnt)
|
||||
goto badsprite;
|
||||
datspr = &tsprite[i];
|
||||
}
|
||||
|
||||
if (how&ACCESS_SET)
|
||||
{
|
||||
lValue = (how&ACCESS_USEVARS) ? Gv_GetVarX(lVar2) : lVar2;
|
||||
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SPRITE_X: datspr->x=lValue; break;
|
||||
case SPRITE_Y: datspr->y=lValue; break;
|
||||
case SPRITE_Z: datspr->z=lValue; break;
|
||||
case SPRITE_CSTAT:
|
||||
datspr->cstat = lValue&0xe3ff;
|
||||
break;
|
||||
case SPRITE_PICNUM: datspr->picnum=lValue; break;
|
||||
case SPRITE_SHADE: datspr->shade=lValue; break;
|
||||
case SPRITE_PAL: datspr->pal=lValue; break;
|
||||
case SPRITE_CLIPDIST: datspr->clipdist=lValue; break;
|
||||
case SPRITE_DETAIL: datspr->filler=lValue; break;
|
||||
case SPRITE_XREPEAT: datspr->xrepeat=lValue; break;
|
||||
case SPRITE_YREPEAT: datspr->yrepeat=lValue; break;
|
||||
case SPRITE_XOFFSET: datspr->xoffset=lValue; break;
|
||||
case SPRITE_YOFFSET: datspr->yoffset=lValue; break;
|
||||
case SPRITE_SECTNUM: datspr->sectnum=lValue; break;
|
||||
case SPRITE_STATNUM: datspr->statnum=lValue; break;
|
||||
case SPRITE_ANG:
|
||||
datspr->ang = lValue&2047;
|
||||
break;
|
||||
case SPRITE_OWNER: datspr->owner=lValue; break;
|
||||
case SPRITE_XVEL: datspr->xvel=lValue; break;
|
||||
case SPRITE_YVEL: datspr->yvel=lValue; break;
|
||||
case SPRITE_ZVEL: datspr->zvel=lValue; break;
|
||||
case SPRITE_LOTAG: datspr->lotag=lValue; break;
|
||||
case SPRITE_HITAG: datspr->hitag=lValue; break;
|
||||
case SPRITE_EXTRA: datspr->extra=lValue; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (lLabelID)
|
||||
{
|
||||
case SPRITE_X: lValue=datspr->x; break;
|
||||
case SPRITE_Y: lValue=datspr->y; break;
|
||||
case SPRITE_Z: lValue=datspr->z; break;
|
||||
case SPRITE_CSTAT: lValue=datspr->cstat; break;
|
||||
case SPRITE_PICNUM: lValue=datspr->picnum; break;
|
||||
case SPRITE_SHADE: lValue=datspr->shade; break;
|
||||
case SPRITE_PAL: lValue=datspr->pal; break;
|
||||
case SPRITE_CLIPDIST: lValue=datspr->clipdist; break;
|
||||
case SPRITE_DETAIL: lValue=datspr->filler; break;
|
||||
case SPRITE_XREPEAT: lValue=datspr->xrepeat; break;
|
||||
case SPRITE_YREPEAT: lValue=datspr->yrepeat; break;
|
||||
case SPRITE_XOFFSET: lValue=datspr->xoffset; break;
|
||||
case SPRITE_YOFFSET: lValue=datspr->yoffset; break;
|
||||
case SPRITE_SECTNUM: lValue=datspr->sectnum; break;
|
||||
case SPRITE_STATNUM: lValue=datspr->statnum; break;
|
||||
case SPRITE_ANG: lValue=datspr->ang; break;
|
||||
case SPRITE_OWNER: lValue=datspr->owner; break;
|
||||
case SPRITE_XVEL: lValue=datspr->xvel; break;
|
||||
case SPRITE_YVEL: lValue=datspr->yvel; break;
|
||||
case SPRITE_ZVEL: lValue=datspr->zvel; break;
|
||||
case SPRITE_LOTAG: lValue=datspr->lotag; break;
|
||||
case SPRITE_HITAG: lValue=datspr->hitag; break;
|
||||
case SPRITE_EXTRA: lValue=datspr->extra; break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (how&ACCESS_USEVARS)
|
||||
Gv_SetVarX(lVar2, lValue);
|
||||
|
||||
return lValue;
|
||||
}
|
||||
|
||||
badsprite:
|
||||
OSD_Printf(CON_ERROR "invalid target sprite (%d)\n",g_errorLineNum,keyw[g_tw],i);
|
||||
return -1;
|
||||
badtspr:
|
||||
OSD_Printf(CON_ERROR "Internal bug, tsprite is unavailable\n",g_errorLineNum,keyw[g_tw]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#undef ACCESS_SET
|
||||
#undef ACCESS_USEVARS
|
||||
#undef ACCESS_SPRITEEXT
|
600
polymer/eduke32/source/m32vars.c
Normal file
600
polymer/eduke32/source/m32vars.c
Normal file
|
@ -0,0 +1,600 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 1996, 2003 - 3D Realms Entertainment
|
||||
Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements)
|
||||
Copyright (C) 2004, 2007 - EDuke32 developers
|
||||
|
||||
This file is part of EDuke32
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "m32script.h"
|
||||
#include "m32def.h"
|
||||
#include "osd.h"
|
||||
|
||||
#define _m32vars_c_
|
||||
#include "m32structures.c"
|
||||
|
||||
static void Gv_Clear(void)
|
||||
{
|
||||
// only call this function ONCE...
|
||||
int32_t i=(MAXGAMEVARS-1);
|
||||
|
||||
//AddLog("Gv_Clear");
|
||||
|
||||
for (; i>=0; i--)
|
||||
{
|
||||
if (aGameVars[i].szLabel)
|
||||
Bfree(aGameVars[i].szLabel);
|
||||
aGameVars[i].szLabel = NULL;
|
||||
aGameVars[i].dwFlags = 0;
|
||||
|
||||
if ((aGameVars[i].dwFlags & GAMEVAR_USER_MASK) && aGameVars[i].val.plValues)
|
||||
{
|
||||
Bfree(aGameVars[i].val.plValues);
|
||||
aGameVars[i].val.plValues = NULL;
|
||||
}
|
||||
aGameVars[i].val.lValue=0;
|
||||
aGameVars[i].dwFlags |= GAMEVAR_RESET;
|
||||
if (i >= MAXGAMEARRAYS)
|
||||
continue;
|
||||
if (aGameArrays[i].szLabel)
|
||||
Bfree(aGameArrays[i].szLabel);
|
||||
aGameArrays[i].szLabel = NULL;
|
||||
|
||||
if (aGameArrays[i].vals)
|
||||
Bfree(aGameArrays[i].vals);
|
||||
aGameArrays[i].vals = NULL;
|
||||
aGameArrays[i].dwFlags |= GAMEARRAY_RESET;
|
||||
}
|
||||
g_gameVarCount = g_gameArrayCount = 0;
|
||||
hash_init(&gamevarH);
|
||||
hash_init(&arrayH);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t Gv_NewArray(const char *pszLabel, void *arrayptr, intptr_t asize, uint32_t dwFlags)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (g_gameArrayCount >= MAXGAMEARRAYS)
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: too many arrays!\n",g_szScriptFileName,g_lineNumber);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Bstrlen(pszLabel) > (MAXARRAYLABEL-1))
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXARRAYLABEL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = hash_find(&arrayH, pszLabel);
|
||||
if (i>=0 && !(aGameArrays[i].dwFlags & GAMEARRAY_RESET))
|
||||
{
|
||||
// found it it's a duplicate in error
|
||||
// g_numCompilerWarnings++;
|
||||
// C_ReportError(WARNING_DUPLICATEDEFINITION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(dwFlags&GAMEARRAY_VARSIZE) && (asize<=0 || asize>=65536))
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: invalid array size %d. Must be between 1 and 65536\n",g_szScriptFileName,g_lineNumber,(int32_t)asize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = g_gameArrayCount;
|
||||
|
||||
if (aGameArrays[i].szLabel == NULL)
|
||||
aGameArrays[i].szLabel = Bcalloc(MAXARRAYLABEL, sizeof(char));
|
||||
if (aGameArrays[i].szLabel != pszLabel)
|
||||
Bstrcpy(aGameArrays[i].szLabel, pszLabel);
|
||||
|
||||
if (!(dwFlags & GAMEARRAY_TYPEMASK))
|
||||
aGameArrays[i].vals = Bcalloc(asize, sizeof(int32_t));
|
||||
else
|
||||
aGameArrays[i].vals = arrayptr;
|
||||
|
||||
aGameArrays[i].size = asize;
|
||||
aGameArrays[i].dwFlags = dwFlags & ~GAMEARRAY_RESET;
|
||||
|
||||
g_gameArrayCount++;
|
||||
hash_replace(&arrayH, aGameArrays[i].szLabel, i);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Gv_NewVar(const char *pszLabel, intptr_t lValue, uint32_t dwFlags)
|
||||
{
|
||||
int32_t i, j;
|
||||
|
||||
//Bsprintf(g_szBuf,"Gv_NewVar(%s, %d, %X)",pszLabel, lValue, dwFlags);
|
||||
//AddLog(g_szBuf);
|
||||
|
||||
if (g_gameVarCount >= MAXGAMEVARS)
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: too many gamevars!\n",g_szScriptFileName,g_lineNumber);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Bstrlen(pszLabel) > (MAXVARLABEL-1))
|
||||
{
|
||||
g_numCompilerErrors++;
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",g_szScriptFileName,g_lineNumber,pszLabel, MAXVARLABEL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = hash_find(&gamevarH,pszLabel);
|
||||
|
||||
if (i >= 0 && !(aGameVars[i].dwFlags & GAMEVAR_RESET))
|
||||
{
|
||||
// found it...
|
||||
if (aGameVars[i].dwFlags & (GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
C_ReportError(-1);
|
||||
initprintf("%s:%d: warning: cannot redefine internal gamevar `%s'.\n",g_szScriptFileName,g_lineNumber,label+(g_numLabels<<6));
|
||||
return 0;
|
||||
}
|
||||
else if (!(aGameVars[i].dwFlags & GAMEVAR_DEFAULT) && !(aGameVars[i].dwFlags & GAMEVAR_SYSTEM))
|
||||
{
|
||||
// it's a duplicate in error
|
||||
// g_numCompilerWarnings++;
|
||||
// C_ReportError(WARNING_DUPLICATEDEFINITION);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
i = g_gameVarCount;
|
||||
|
||||
// Set values
|
||||
if ((aGameVars[i].dwFlags & GAMEVAR_SYSTEM) == 0)
|
||||
{
|
||||
if (aGameVars[i].szLabel == NULL)
|
||||
aGameVars[i].szLabel = Bcalloc(MAXVARLABEL, sizeof(uint8_t));
|
||||
if (aGameVars[i].szLabel != pszLabel)
|
||||
Bstrcpy(aGameVars[i].szLabel,pszLabel);
|
||||
aGameVars[i].dwFlags = dwFlags;
|
||||
|
||||
if (aGameVars[i].dwFlags & GAMEVAR_USER_MASK)
|
||||
{
|
||||
// only free if not system
|
||||
if (aGameVars[i].val.plValues)
|
||||
Bfree(aGameVars[i].val.plValues);
|
||||
aGameVars[i].val.plValues = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// if existing is system, they only get to change default value....
|
||||
aGameVars[i].lDefault = lValue;
|
||||
aGameVars[i].dwFlags &= ~GAMEVAR_RESET;
|
||||
|
||||
if (i == g_gameVarCount)
|
||||
{
|
||||
// we're adding a new one.
|
||||
hash_add(&gamevarH, aGameVars[i].szLabel, g_gameVarCount++);
|
||||
}
|
||||
|
||||
if (aGameVars[i].dwFlags & GAMEVAR_PERBLOCK)
|
||||
{
|
||||
if (!aGameVars[i].val.plValues)
|
||||
aGameVars[i].val.plValues = Bcalloc(1+MAXEVENTS+g_stateCount, sizeof(int32_t));
|
||||
for (j=0; j<1+MAXEVENTS+g_stateCount; j++)
|
||||
aGameVars[i].val.plValues[j] = lValue;
|
||||
}
|
||||
else aGameVars[i].val.lValue = lValue;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetVarN(register int32_t id) // 'N' for "no side-effects"... vars only!
|
||||
{
|
||||
if (id == g_iThisActorID)
|
||||
return vm.g_i;
|
||||
|
||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarN(): invalid var index %d\n",g_errorLineNum,keyw[g_tw],index);
|
||||
vm.g_errorFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
id &= (MAXGAMEVARS-1);
|
||||
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
case 0:
|
||||
return aGameVars[id].val.lValue;
|
||||
case GAMEVAR_PERBLOCK:
|
||||
return aGameVars[id].val.plValues[vm.g_st];
|
||||
case GAMEVAR_INTPTR:
|
||||
return *((int32_t*)aGameVars[id].val.lValue);
|
||||
case GAMEVAR_SHORTPTR:
|
||||
return *((int16_t*)aGameVars[id].val.lValue);
|
||||
case GAMEVAR_CHARPTR:
|
||||
return *((uint8_t*)aGameVars[id].val.lValue);
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarN(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
vm.g_errorFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetVarX(register int32_t id)
|
||||
{
|
||||
if (id == g_iThisActorID)
|
||||
return vm.g_i;
|
||||
|
||||
if ((id & 0x0000FFFF) == MAXGAMEVARS)
|
||||
return ((int16_t)(id>>16));
|
||||
|
||||
{
|
||||
register int32_t negateResult = id&(MAXGAMEVARS<<1);
|
||||
|
||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||
{
|
||||
if (id&(MAXGAMEVARS<<2)) // array
|
||||
{
|
||||
register int32_t index;
|
||||
int32_t siz;
|
||||
|
||||
index = (int32_t)((id>>16)&0xffff);
|
||||
if (!(id&MAXGAMEVARS))
|
||||
index = Gv_GetVarN(index);
|
||||
|
||||
id &= (MAXGAMEARRAYS-1);
|
||||
|
||||
if (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE)
|
||||
siz = Gv_GetVarN(aGameArrays[id].size);
|
||||
else
|
||||
siz = aGameArrays[id].size;
|
||||
|
||||
if (index < 0 || index >= siz)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPEMASK)
|
||||
{
|
||||
case 0:
|
||||
case GAMEARRAY_OFINT:
|
||||
return ((((int32_t *)aGameArrays[id].vals)[index] ^ -negateResult) + negateResult);
|
||||
case GAMEARRAY_OFSHORT:
|
||||
return ((((int16_t *)aGameArrays[id].vals)[index] ^ -negateResult) + negateResult);
|
||||
case GAMEARRAY_OFCHAR:
|
||||
return ((((uint8_t *)aGameArrays[id].vals)[index] ^ -negateResult) + negateResult);
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
vm.g_errorFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
||||
{
|
||||
register int32_t index, memberid;
|
||||
|
||||
index = (id>>16)&0x7fff;
|
||||
if (!(id&MAXGAMEVARS))
|
||||
index = Gv_GetVarN(index);
|
||||
|
||||
memberid = (id>>2)&31;
|
||||
|
||||
switch (id&3)
|
||||
{
|
||||
case 0: //if (id == g_iSpriteVarID)
|
||||
return ((X_AccessSprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||
case 1: //else if (id == g_iSectorVarID)
|
||||
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||
return ((X_AccessSector(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||
case 2: //else if (id == g_iWallVarID)
|
||||
return ((X_AccessWall(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||
case 3:
|
||||
return ((X_AccessTsprite(0, index, memberid, 0) ^ -negateResult) + negateResult);
|
||||
// default:
|
||||
// OSD_Printf(CON_ERROR "Gv_GetVarX() (special): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
// return -1;
|
||||
}
|
||||
}
|
||||
|
||||
id &= (MAXGAMEVARS-1);
|
||||
|
||||
if (!negateResult)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
||||
vm.g_errorFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
case 0:
|
||||
return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_PERBLOCK:
|
||||
return ((aGameVars[id].val.plValues[vm.g_st] ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_INTPTR:
|
||||
return ((*((int32_t*)aGameVars[id].val.lValue) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_SHORTPTR:
|
||||
return ((*((int16_t*)aGameVars[id].val.lValue) ^ -negateResult) + negateResult);
|
||||
case GAMEVAR_CHARPTR:
|
||||
return ((*((uint8_t*)aGameVars[id].val.lValue) ^ -negateResult) + negateResult);
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_GetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
vm.g_errorFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue)
|
||||
{
|
||||
if (id & (0xFFFFFFFF-(MAXGAMEVARS-1)))
|
||||
{
|
||||
if (id&(MAXGAMEVARS<<2)) // array
|
||||
{
|
||||
register int32_t index;
|
||||
int32_t siz;
|
||||
|
||||
index = (id>>16)&0xffff;
|
||||
if (!(id&MAXGAMEVARS))
|
||||
index = Gv_GetVarN(index);
|
||||
|
||||
id &= (MAXGAMEARRAYS-1);
|
||||
|
||||
if (aGameArrays[id].dwFlags & GAMEARRAY_VARSIZE)
|
||||
siz = Gv_GetVarN(aGameArrays[id].size);
|
||||
else siz = aGameArrays[id].size;
|
||||
|
||||
if (index < 0 || index >= siz)
|
||||
{
|
||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid array index (%s[%d])\n",g_errorLineNum,keyw[g_tw],aGameArrays[id].szLabel,index);
|
||||
vm.g_errorFlag = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPEMASK)
|
||||
{
|
||||
case 0:
|
||||
case GAMEARRAY_OFINT:
|
||||
((int32_t *)aGameArrays[id].vals)[index] = lValue;
|
||||
return;
|
||||
case GAMEARRAY_OFSHORT:
|
||||
((int16_t *)aGameArrays[id].vals)[index] = (int16_t)lValue;
|
||||
return;
|
||||
case GAMEARRAY_OFCHAR:
|
||||
((uint8_t *)aGameArrays[id].vals)[index] = (uint8_t)lValue;
|
||||
return;
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_SetVarX() (array): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
vm.g_errorFlag = 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
||||
{
|
||||
register int32_t index, memberid;
|
||||
|
||||
index = (id>>16)&0x7fff;
|
||||
if (!(id&MAXGAMEVARS))
|
||||
index = Gv_GetVarN(index);
|
||||
|
||||
memberid = (id>>2)&31;
|
||||
|
||||
switch (id&3)
|
||||
{
|
||||
case 0: //if (id == g_iSpriteVarID)
|
||||
X_AccessSprite(1, index, memberid, lValue);
|
||||
return;
|
||||
case 1: //else if (id == g_iSectorVarID)
|
||||
// if (index == vm.g_i) index = sprite[vm.g_i].sectnum;
|
||||
X_AccessSector(1, index, memberid, lValue);
|
||||
return;
|
||||
case 2: //else if (id == g_iWallVarID)
|
||||
X_AccessWall(1, index, memberid, lValue);
|
||||
return;
|
||||
case 3:
|
||||
X_AccessTsprite(1, index, memberid, lValue);
|
||||
return;
|
||||
// default:
|
||||
// OSD_Printf(CON_ERROR "Gv_SetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
// return;
|
||||
}
|
||||
}
|
||||
|
||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): invalid gamevar ID (%d)\n",g_errorLineNum,keyw[g_tw],id);
|
||||
vm.g_errorFlag = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aGameVars[id].dwFlags &
|
||||
(GAMEVAR_USER_MASK|GAMEVAR_INTPTR|GAMEVAR_SHORTPTR|GAMEVAR_CHARPTR))
|
||||
{
|
||||
case 0:
|
||||
aGameVars[id].val.lValue=lValue;
|
||||
return;
|
||||
case GAMEVAR_PERBLOCK:
|
||||
aGameVars[id].val.plValues[vm.g_st] = lValue;
|
||||
return;
|
||||
case GAMEVAR_INTPTR:
|
||||
*((int32_t*)aGameVars[id].val.lValue)=(int32_t)lValue;
|
||||
return;
|
||||
case GAMEVAR_SHORTPTR:
|
||||
*((int16_t*)aGameVars[id].val.lValue)=(int16_t)lValue;
|
||||
return;
|
||||
case GAMEVAR_CHARPTR:
|
||||
*((uint8_t*)aGameVars[id].val.lValue)=(uint8_t)lValue;
|
||||
return;
|
||||
default:
|
||||
OSD_Printf(CON_ERROR "Gv_SetVarX(): WTF??\n",g_errorLineNum,keyw[g_tw]);
|
||||
vm.g_errorFlag = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void Gv_AddSystemVars(void)
|
||||
{
|
||||
// only call ONCE
|
||||
int32_t hlcnt_id, hlscnt_id;
|
||||
|
||||
//AddLog("Gv_AddSystemVars");
|
||||
|
||||
// special vars for struct access; must be at top and in this order
|
||||
g_iSpriteVarID = g_gameVarCount;
|
||||
Gv_NewVar("sprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
g_iSectorVarID = g_gameVarCount;
|
||||
Gv_NewVar("sector", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
g_iWallVarID = g_gameVarCount;
|
||||
Gv_NewVar("wall", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
Gv_NewVar("tsprite", -1, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SPECIAL);
|
||||
|
||||
g_iReturnVarID = g_gameVarCount;
|
||||
Gv_NewVar("RETURN", 0, GAMEVAR_SYSTEM);
|
||||
g_iLoTagID = g_gameVarCount;
|
||||
Gv_NewVar("LOTAG", 0, GAMEVAR_SYSTEM);
|
||||
g_iHiTagID = g_gameVarCount;
|
||||
Gv_NewVar("HITAG", 0, GAMEVAR_SYSTEM);
|
||||
g_iTextureID = g_gameVarCount;
|
||||
Gv_NewVar("TEXTURE", 0, GAMEVAR_SYSTEM);
|
||||
g_iThisActorID = g_gameVarCount;
|
||||
Gv_NewVar("I", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM); // THISACTOR
|
||||
|
||||
Gv_NewVar("xdim",(intptr_t)&xdim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("ydim",(intptr_t)&ydim, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("windowx1",(intptr_t)&windowx1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("windowx2",(intptr_t)&windowx2, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("windowy1",(intptr_t)&windowy1, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("windowy2",(intptr_t)&windowy2, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
Gv_NewVar("totalclock",(intptr_t)&totalclock, GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_READONLY);
|
||||
|
||||
Gv_NewVar("viewingrange",(intptr_t)&viewingrange, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||
Gv_NewVar("yxaspect",(intptr_t)&yxaspect, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||
/// Gv_NewVar("framerate",(intptr_t)&g_currentFrameRate, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||
Gv_NewVar("CLIPMASK0", CLIPMASK0, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("CLIPMASK1", CLIPMASK1, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
|
||||
Gv_NewVar("MAXSPRITES",MAXSPRITES, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("MAXSECTORS",MAXSECTORS, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("MAXWALLS",MAXWALLS, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("MAXTILES",MAXTILES, GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
|
||||
/// Gv_NewVar("display_mirror",(intptr_t)&display_mirror, GAMEVAR_SYSTEM | GAMEVAR_CHARPTR);
|
||||
Gv_NewVar("randomseed",(intptr_t)&randomseed, GAMEVAR_SYSTEM | GAMEVAR_INTPTR);
|
||||
|
||||
Gv_NewVar("numwalls",(intptr_t)&numwalls, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY);
|
||||
Gv_NewVar("numsectors",(intptr_t)&numsectors, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY);
|
||||
Gv_NewVar("numsprites",(intptr_t)&numsprites, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||
Gv_NewVar("numtiles",(intptr_t)&numtiles, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY);
|
||||
|
||||
#ifdef POLYMOST
|
||||
Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
#endif
|
||||
|
||||
// current position
|
||||
Gv_NewVar("posx",(intptr_t)&pos.x, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("posy",(intptr_t)&pos.y, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("posz",(intptr_t)&pos.z, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("ang",(intptr_t)&ang, GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("cursectnum",(intptr_t)&cursectnum, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
|
||||
Gv_NewVar("searchx",(intptr_t)&searchx, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("searchy",(intptr_t)&searchx, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("searchstat",(intptr_t)&searchstat, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("searchwall",(intptr_t)&searchwall, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("searchsector",(intptr_t)&searchsector, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("searchbottomwall",(intptr_t)&searchbottomwall, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
|
||||
Gv_NewVar("pointhighlight",(intptr_t)&pointhighlight, GAMEVAR_SHORTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("linehighlight",(intptr_t)&linehighlight, GAMEVAR_SHORTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
|
||||
hlcnt_id = g_gameVarCount;
|
||||
Gv_NewVar("highlightcnt",(intptr_t)&highlightcnt, GAMEVAR_SHORTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
hlscnt_id = g_gameVarCount;
|
||||
Gv_NewVar("highlightsectorcnt",(intptr_t)&highlightsectorcnt, GAMEVAR_SHORTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
|
||||
// clipboard contents
|
||||
Gv_NewVar("temppicnum",(intptr_t)&temppicnum, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempcstat",(intptr_t)&tempcstat, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("templotag",(intptr_t)&templotag, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("temphitag",(intptr_t)&temphitag, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempextra",(intptr_t)&tempextra, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempshade",(intptr_t)&tempshade, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("temppal",(intptr_t)&temppal, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempvis",(intptr_t)&tempvis, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempxrepeat",(intptr_t)&tempxrepeat, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
Gv_NewVar("tempyrepeat",(intptr_t)&tempyrepeat, GAMEVAR_INTPTR|GAMEVAR_SYSTEM|GAMEVAR_READONLY);
|
||||
|
||||
// starting position
|
||||
Gv_NewVar("startposx",(intptr_t)&startposx, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("startposy",(intptr_t)&startposy, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("startposz",(intptr_t)&startposz, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("startang",(intptr_t)&startang, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("startsectnum",(intptr_t)&startsectnum, GAMEVAR_READONLY | GAMEVAR_SHORTPTR | GAMEVAR_SYSTEM);
|
||||
|
||||
Gv_NewVar("mousxplc",(intptr_t)&mousxplc, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
Gv_NewVar("mousyplc",(intptr_t)&mousyplc, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
|
||||
|
||||
g_systemVarCount = g_gameVarCount;
|
||||
|
||||
Gv_NewArray("highlight", (void *)highlight, hlcnt_id,
|
||||
GAMEARRAY_READONLY|GAMEARRAY_OFSHORT|GAMEARRAY_VARSIZE);
|
||||
Gv_NewArray("highlightsector", (void *)highlightsector, hlscnt_id,
|
||||
GAMEARRAY_READONLY|GAMEARRAY_OFSHORT|GAMEARRAY_VARSIZE);
|
||||
Gv_NewArray("sintable", (void *)sintable, 2048,
|
||||
GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
|
||||
Gv_NewArray("hsect", (void *)headspritesect, MAXSECTORS+1, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("nsect", (void *)prevspritesect, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("psect", (void *)nextspritesect, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("hstat", (void *)headspritestat, MAXSTATUS+1, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("nstat", (void *)prevspritestat, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("pstat", (void *)nextspritestat, MAXSPRITES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
|
||||
Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
|
||||
|
||||
Gv_NewArray("show2dsector", (void *)show2dsector, (MAXSECTORS+7)>>3, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR);
|
||||
Gv_NewArray("show2dwall", (void *)show2dwall, (MAXWALLS+7)>>3, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR);
|
||||
Gv_NewArray("show2dsprite", (void *)show2dsprite, (MAXSPRITES+7)>>3, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR);
|
||||
|
||||
g_systemArrayCount = g_gameArrayCount;
|
||||
}
|
||||
|
||||
void Gv_Init(void)
|
||||
{
|
||||
// only call ONCE
|
||||
|
||||
// initprintf("Initializing game variables\n");
|
||||
//AddLog("Gv_Init");
|
||||
|
||||
Gv_Clear();
|
||||
Gv_AddSystemVars();
|
||||
}
|
|
@ -101,10 +101,10 @@ static void SearchSectorsForward();
|
|||
static void SearchSectorsBackward();
|
||||
static inline void SpriteName(int16_t spritenum, char *lo2);
|
||||
static void PrintStatus(char *string,int32_t num,char x,char y,char color);
|
||||
static inline void SetBOSS1Palette();
|
||||
static inline void SetSLIMEPalette();
|
||||
static inline void SetWATERPalette();
|
||||
static inline void SetGAMEPalette();
|
||||
void SetBOSS1Palette();
|
||||
void SetSLIMEPalette();
|
||||
void SetWATERPalette();
|
||||
void SetGAMEPalette();
|
||||
|
||||
extern int32_t grid;
|
||||
|
||||
|
|
Loading…
Reference in a new issue