2019-11-24 20:45:15 -08:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2010-2014 QuakeSpasm developers
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2019-12-02 07:00:56 -08:00
|
|
|
#ifndef spingle__pr_comp_h
|
|
|
|
#define spingle__pr_comp_h
|
2019-11-24 20:45:15 -08:00
|
|
|
|
|
|
|
// this file is shared by quake and qcc
|
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
typedef int32_t func_t;
|
|
|
|
typedef int32_t string_t;
|
2019-11-24 20:45:15 -08:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
ev_bad = -1,
|
|
|
|
ev_void = 0,
|
|
|
|
ev_string,
|
|
|
|
ev_float,
|
|
|
|
ev_vector,
|
|
|
|
ev_entity,
|
|
|
|
ev_field,
|
|
|
|
ev_function,
|
|
|
|
ev_pointer
|
|
|
|
} etype_t;
|
|
|
|
|
2019-11-28 16:24:30 -08:00
|
|
|
#define OFS_NULL 0
|
|
|
|
#define OFS_RETURN 1
|
|
|
|
#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
|
|
|
|
#define OFS_PARM1 7
|
|
|
|
#define OFS_PARM2 10
|
|
|
|
#define OFS_PARM3 13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NOT_F,
|
|
|
|
OP_NOT_V,
|
|
|
|
OP_NOT_S,
|
|
|
|
OP_NOT_ENT,
|
|
|
|
OP_NOT_FNC,
|
|
|
|
OP_IF,
|
|
|
|
OP_IFNOT,
|
|
|
|
OP_CALL0,
|
|
|
|
OP_CALL1,
|
|
|
|
OP_CALL2,
|
|
|
|
OP_CALL3,
|
|
|
|
OP_CALL4,
|
|
|
|
OP_CALL5,
|
|
|
|
OP_CALL6,
|
|
|
|
OP_CALL7,
|
|
|
|
OP_CALL8,
|
|
|
|
OP_STATE,
|
|
|
|
OP_GOTO,
|
|
|
|
OP_AND,
|
|
|
|
OP_OR,
|
|
|
|
|
|
|
|
OP_BITAND,
|
|
|
|
OP_BITOR
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct statement_s
|
|
|
|
{
|
2019-11-25 17:40:18 -08:00
|
|
|
uint16_t op;
|
|
|
|
int16_t a, b, c;
|
2019-11-24 20:45:15 -08:00
|
|
|
} dstatement_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-11-25 17:40:18 -08:00
|
|
|
uint16_t type; // if DEF_SAVEGLOBAL bit is set
|
|
|
|
// the variable needs to be saved in savegames
|
|
|
|
uint16_t ofs;
|
|
|
|
int32_t s_name;
|
2019-11-24 20:45:15 -08:00
|
|
|
} ddef_t;
|
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
#define DEF_SAVEGLOBAL (1<<15)
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
#define MAX_PARMS 8
|
2019-11-24 20:45:15 -08:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t first_statement; // negative numbers are builtins
|
|
|
|
int32_t parm_start;
|
|
|
|
int32_t locals; // total ints of parms + locals
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t profile; // runtime
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t s_name;
|
|
|
|
int32_t s_file; // source file defined in
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t numparms;
|
|
|
|
byte parm_size[MAX_PARMS];
|
2019-11-24 20:45:15 -08:00
|
|
|
} dfunction_t;
|
|
|
|
|
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
#define PROG_VERSION 6
|
2019-11-24 20:45:15 -08:00
|
|
|
typedef struct
|
|
|
|
{
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t version;
|
|
|
|
int32_t crc; // check of header file
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_statements;
|
|
|
|
int32_t numstatements; // statement 0 is an error
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_globaldefs;
|
|
|
|
int32_t numglobaldefs;
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_fielddefs;
|
|
|
|
int32_t numfielddefs;
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_functions;
|
|
|
|
int32_t numfunctions; // function 0 is an empty
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_strings;
|
|
|
|
int32_t numstrings; // first string is a null string
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t ofs_globals;
|
|
|
|
int32_t numglobals;
|
2019-11-24 20:45:15 -08:00
|
|
|
|
2019-11-25 17:40:18 -08:00
|
|
|
int32_t entityfields;
|
2019-11-24 20:45:15 -08:00
|
|
|
} dprograms_t;
|
|
|
|
|
2019-12-02 07:00:56 -08:00
|
|
|
#endif
|