mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-28 14:41:57 +00:00
added support for vector bitwise operators emulation.
fix some compile issues git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5061 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
88eee17e70
commit
1c90422226
5 changed files with 76 additions and 3 deletions
|
@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifndef HAVE_CDPLAYER
|
||||||
|
//nothing
|
||||||
|
#elif defined(__CYGWIN__)
|
||||||
#include "cd_null.c"
|
#include "cd_null.c"
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#include "quakedef.h"
|
#include "quakedef.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_CDPLAYER
|
||||||
|
//nothing
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//not really needed, but nice none-the-less.
|
//not really needed, but nice none-the-less.
|
||||||
#include "winquake.h"
|
#include "winquake.h"
|
||||||
|
@ -54,3 +57,4 @@ qboolean CDAudio_Startup(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#if SDL_MAJOR_VERSION >= 2
|
#ifndef HAVE_CDPLAYER
|
||||||
|
//nothing
|
||||||
|
#elif SDL_MAJOR_VERSION >= 2
|
||||||
//sdl2 has no cd support. sod off.
|
//sdl2 has no cd support. sod off.
|
||||||
#include "cd_null.c"
|
#include "cd_null.c"
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -417,6 +417,11 @@ enum qcop_e {
|
||||||
OP_SUB_EI,
|
OP_SUB_EI,
|
||||||
OP_SUB_EF,
|
OP_SUB_EF,
|
||||||
|
|
||||||
|
OP_BITAND_V,
|
||||||
|
OP_BITOR_V,
|
||||||
|
OP_BITNOT_V,
|
||||||
|
OP_BITXOR_V,
|
||||||
|
|
||||||
OP_NUMOPS
|
OP_NUMOPS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -681,6 +681,11 @@ QCC_opcode_t pr_opcodes[] =
|
||||||
{7, "-", "SUB_EI", 4, ASSOC_LEFT, &type_entity, &type_integer, &type_entity},
|
{7, "-", "SUB_EI", 4, ASSOC_LEFT, &type_entity, &type_integer, &type_entity},
|
||||||
{7, "-", "SUB_EF", 4, ASSOC_LEFT, &type_entity, &type_float, &type_entity},
|
{7, "-", "SUB_EF", 4, ASSOC_LEFT, &type_entity, &type_float, &type_entity},
|
||||||
|
|
||||||
|
{7, "&", "BITAND_V", 5, ASSOC_LEFT, &type_vector, &type_vector, &type_vector},
|
||||||
|
{7, "|", "BITOR_V", 5, ASSOC_LEFT, &type_vector, &type_vector, &type_vector},
|
||||||
|
{7, "~", "BITNOT_V", -1, ASSOC_LEFT, &type_vector, &type_void, &type_vector},
|
||||||
|
{7, "^", "BITXOR_V", 3, ASSOC_LEFT, &type_vector, &type_vector, &type_vector},
|
||||||
|
|
||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -932,6 +937,7 @@ QCC_opcode_t *opcodes_orstore[] =
|
||||||
&pr_opcodes[OP_BITOR_I],
|
&pr_opcodes[OP_BITOR_I],
|
||||||
&pr_opcodes[OP_BITOR_IF],
|
&pr_opcodes[OP_BITOR_IF],
|
||||||
&pr_opcodes[OP_BITOR_FI],
|
&pr_opcodes[OP_BITOR_FI],
|
||||||
|
&pr_opcodes[OP_BITOR_V],
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
QCC_opcode_t *opcodes_orstorep[] =
|
QCC_opcode_t *opcodes_orstorep[] =
|
||||||
|
@ -943,6 +949,7 @@ QCC_opcode_t *opcodes_xorstore[] =
|
||||||
{
|
{
|
||||||
&pr_opcodes[OP_BITXOR_I],
|
&pr_opcodes[OP_BITXOR_I],
|
||||||
&pr_opcodes[OP_BITXOR_F],
|
&pr_opcodes[OP_BITXOR_F],
|
||||||
|
&pr_opcodes[OP_BITXOR_V],
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
QCC_opcode_t *opcodes_andstore[] =
|
QCC_opcode_t *opcodes_andstore[] =
|
||||||
|
@ -951,6 +958,7 @@ QCC_opcode_t *opcodes_andstore[] =
|
||||||
&pr_opcodes[OP_BITAND_I],
|
&pr_opcodes[OP_BITAND_I],
|
||||||
&pr_opcodes[OP_BITAND_IF],
|
&pr_opcodes[OP_BITAND_IF],
|
||||||
&pr_opcodes[OP_BITAND_FI],
|
&pr_opcodes[OP_BITAND_FI],
|
||||||
|
&pr_opcodes[OP_BITAND_V],
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
QCC_opcode_t *opcodes_clearstore[] =
|
QCC_opcode_t *opcodes_clearstore[] =
|
||||||
|
@ -1038,14 +1046,17 @@ QCC_opcode_t *opcodeprioritized[TOP_PRIORITY+1][128] =
|
||||||
&pr_opcodes[OP_BITAND_I],
|
&pr_opcodes[OP_BITAND_I],
|
||||||
&pr_opcodes[OP_BITAND_IF],
|
&pr_opcodes[OP_BITAND_IF],
|
||||||
&pr_opcodes[OP_BITAND_FI],
|
&pr_opcodes[OP_BITAND_FI],
|
||||||
|
&pr_opcodes[OP_BITAND_V],
|
||||||
|
|
||||||
&pr_opcodes[OP_BITOR_F],
|
&pr_opcodes[OP_BITOR_F],
|
||||||
&pr_opcodes[OP_BITOR_I],
|
&pr_opcodes[OP_BITOR_I],
|
||||||
&pr_opcodes[OP_BITOR_IF],
|
&pr_opcodes[OP_BITOR_IF],
|
||||||
&pr_opcodes[OP_BITOR_FI],
|
&pr_opcodes[OP_BITOR_FI],
|
||||||
|
&pr_opcodes[OP_BITOR_V],
|
||||||
|
|
||||||
&pr_opcodes[OP_BITXOR_I],
|
&pr_opcodes[OP_BITXOR_I],
|
||||||
&pr_opcodes[OP_BITXOR_F],
|
&pr_opcodes[OP_BITXOR_F],
|
||||||
|
&pr_opcodes[OP_BITXOR_V],
|
||||||
|
|
||||||
&pr_opcodes[OP_RSHIFT_I],
|
&pr_opcodes[OP_RSHIFT_I],
|
||||||
&pr_opcodes[OP_RSHIFT_F],
|
&pr_opcodes[OP_RSHIFT_F],
|
||||||
|
@ -2346,10 +2357,24 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
|
||||||
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
||||||
optres_constantarithmatic++;
|
optres_constantarithmatic++;
|
||||||
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(eval_a) | QCC_PR_RoundFloatConst(eval_b));
|
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(eval_a) | QCC_PR_RoundFloatConst(eval_b));
|
||||||
|
case OP_BITOR_V:
|
||||||
|
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
||||||
|
optres_constantarithmatic++;
|
||||||
|
return QCC_MakeVectorConst(
|
||||||
|
(int)eval_a->vector[0] | (int)eval_b->vector[0],
|
||||||
|
(int)eval_a->vector[1] | (int)eval_b->vector[1],
|
||||||
|
(int)eval_a->vector[2] | (int)eval_b->vector[2]);
|
||||||
case OP_BITAND_F:
|
case OP_BITAND_F:
|
||||||
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
||||||
optres_constantarithmatic++;
|
optres_constantarithmatic++;
|
||||||
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(eval_a) & QCC_PR_RoundFloatConst(eval_b));
|
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(eval_a) & QCC_PR_RoundFloatConst(eval_b));
|
||||||
|
case OP_BITAND_V:
|
||||||
|
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
||||||
|
optres_constantarithmatic++;
|
||||||
|
return QCC_MakeVectorConst(
|
||||||
|
(int)eval_a->vector[0] & (int)eval_b->vector[0],
|
||||||
|
(int)eval_a->vector[1] & (int)eval_b->vector[1],
|
||||||
|
(int)eval_a->vector[2] & (int)eval_b->vector[2]);
|
||||||
case OP_MUL_F:
|
case OP_MUL_F:
|
||||||
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
|
||||||
optres_constantarithmatic++;
|
optres_constantarithmatic++;
|
||||||
|
@ -2624,6 +2649,9 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
|
||||||
case OP_BITNOT_I:
|
case OP_BITNOT_I:
|
||||||
QCC_FreeTemp(var_a);
|
QCC_FreeTemp(var_a);
|
||||||
return QCC_MakeIntConst(~eval_a->_int);
|
return QCC_MakeIntConst(~eval_a->_int);
|
||||||
|
case OP_BITNOT_V:
|
||||||
|
QCC_FreeTemp(var_a);
|
||||||
|
return QCC_MakeVectorConst(~(int)eval_a->vector[0], ~(int)eval_a->vector[1], ~(int)eval_a->vector[2]);
|
||||||
case OP_CONV_FTOI:
|
case OP_CONV_FTOI:
|
||||||
QCC_FreeTemp(var_a);
|
QCC_FreeTemp(var_a);
|
||||||
optres_constantarithmatic++;
|
optres_constantarithmatic++;
|
||||||
|
@ -3241,6 +3269,22 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
|
||||||
return var_c;
|
return var_c;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OP_BITAND_V:
|
||||||
|
case OP_BITOR_V:
|
||||||
|
op = &pr_opcodes[((op - pr_opcodes)==OP_BITAND_V)?OP_BITAND_F:OP_BITOR_F];
|
||||||
|
var_c = QCC_GetTemp(type_vector);
|
||||||
|
var_a.cast = type_float;
|
||||||
|
var_b.cast = type_float;
|
||||||
|
var_c.cast = type_float;
|
||||||
|
QCC_PR_SimpleStatement(op, var_a, var_b, var_c, true);
|
||||||
|
var_a.ofs++; var_b.ofs++; var_c.ofs++;
|
||||||
|
QCC_PR_SimpleStatement(op, var_a, var_b, var_c, true);
|
||||||
|
var_a.ofs++; var_b.ofs++; var_c.ofs++;
|
||||||
|
QCC_PR_SimpleStatement(op, var_a, var_b, var_c, true);
|
||||||
|
var_a.ofs++; var_b.ofs++; var_c.ofs++;
|
||||||
|
var_c.cast = type_vector;
|
||||||
|
var_c.ofs -= 3;
|
||||||
|
return var_c;
|
||||||
case OP_ADD_I:
|
case OP_ADD_I:
|
||||||
{
|
{
|
||||||
QCC_sref_t fnc = QCC_PR_GetSRef(NULL, "AddInt", NULL, false, 0, 0);
|
QCC_sref_t fnc = QCC_PR_GetSRef(NULL, "AddInt", NULL, false, 0, 0);
|
||||||
|
@ -3393,6 +3437,14 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
|
||||||
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_F], var_b, var_a, NULL, 0);
|
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_F], var_b, var_a, NULL, 0);
|
||||||
return QCC_PR_StatementFlags(&pr_opcodes[OP_BITOR_F], var_c, var_a, NULL, 0);
|
return QCC_PR_StatementFlags(&pr_opcodes[OP_BITOR_F], var_c, var_a, NULL, 0);
|
||||||
|
|
||||||
|
case OP_BITXOR_V:
|
||||||
|
// r = (a & ~b) | (b & ~a);
|
||||||
|
var_c = QCC_PR_StatementFlags(&pr_opcodes[OP_BITNOT_V], var_b, nullsref, NULL, STFL_PRESERVEA);
|
||||||
|
var_c = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_V], var_a, var_c, NULL, STFL_PRESERVEA);
|
||||||
|
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITNOT_V], var_a, nullsref, NULL, 0);
|
||||||
|
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_V], var_b, var_a, NULL, 0);
|
||||||
|
return QCC_PR_StatementFlags(&pr_opcodes[OP_BITOR_V], var_c, var_a, NULL, 0);
|
||||||
|
|
||||||
case OP_IF_S:
|
case OP_IF_S:
|
||||||
tmp = QCC_MakeFloatConst(0);
|
tmp = QCC_MakeFloatConst(0);
|
||||||
tmp.cast = type_string;
|
tmp.cast = type_string;
|
||||||
|
@ -3481,6 +3533,12 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
|
||||||
var_b = var_a;
|
var_b = var_a;
|
||||||
var_a = QCC_MakeFloatConst(-1); //divVerent says -1 is safe, even with floats. I guess I'm just too paranoid.
|
var_a = QCC_MakeFloatConst(-1); //divVerent says -1 is safe, even with floats. I guess I'm just too paranoid.
|
||||||
break;
|
break;
|
||||||
|
case OP_BITNOT_V:
|
||||||
|
op = &pr_opcodes[OP_SUB_V];
|
||||||
|
var_b = var_a;
|
||||||
|
var_a = QCC_MakeVectorConst(-1, -1, -1);
|
||||||
|
var_a.sym->referenced=true;
|
||||||
|
break;
|
||||||
|
|
||||||
case OP_DIVSTORE_F:
|
case OP_DIVSTORE_F:
|
||||||
op = &pr_opcodes[OP_DIV_F];
|
op = &pr_opcodes[OP_DIV_F];
|
||||||
|
@ -7599,6 +7657,8 @@ QCC_ref_t *QCC_PR_RefTerm (QCC_ref_t *retbuf, unsigned int exprflags)
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_F], e, nullsref, NULL);
|
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_F], e, nullsref, NULL);
|
||||||
else if (t == ev_integer)
|
else if (t == ev_integer)
|
||||||
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, nullsref, NULL); //functions are integer values too.
|
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, nullsref, NULL); //functions are integer values too.
|
||||||
|
else if (t == ev_vector)
|
||||||
|
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_V], e, nullsref, NULL); //functions are integer values too.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e2 = nullsref; // shut up compiler warning;
|
e2 = nullsref; // shut up compiler warning;
|
||||||
|
|
Loading…
Reference in a new issue