Skip to content

Commit

Permalink
Change other instruction names to match FTEQW.
Browse files Browse the repository at this point in the history
Adds _F and _I type suffixes to lots of Quake-inherited opcodes that had
no type suffix but used floats (or ints).
  • Loading branch information
divVerent committed Nov 8, 2024
1 parent 7ae6274 commit be41f10
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 69 deletions.
40 changes: 20 additions & 20 deletions pr_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ typedef enum opcode_e
OP_NE_E,
OP_NE_FNC,

OP_LE,
OP_GE,
OP_LT,
OP_GT,
OP_LE_F,
OP_GE_F,
OP_LT_F,
OP_GT_F,

OP_LOAD_F,
OP_LOAD_V,
Expand Down Expand Up @@ -101,8 +101,8 @@ typedef enum opcode_e
OP_NOT_S,
OP_NOT_ENT,
OP_NOT_FNC,
OP_IF,
OP_IFNOT,
OP_IF_I,
OP_IFNOT_I,
OP_CALL0,
OP_CALL1,
OP_CALL2,
Expand All @@ -114,14 +114,14 @@ typedef enum opcode_e
OP_CALL8,
OP_STATE,
OP_GOTO,
OP_AND,
OP_OR,
OP_AND_F,
OP_OR_F,

OP_BITAND,
OP_BITOR,
OP_BITAND_F,
OP_BITOR_F,

// TODO: actually support Hexen 2?

OP_MULSTORE_F, //66 redundant, for h2 compat
OP_MULSTORE_VF, //67 redundant, for h2 compat
OP_MULSTOREP_F, //68
Expand Down Expand Up @@ -194,11 +194,11 @@ typedef enum opcode_e
OP_SUB_FI,
OP_SUB_IF,

OP_CONV_IF,
OP_CONV_FI,
OP_LOADP_IF,
OP_LOADP_FI,
OP_CONV_ITOF,
OP_CONV_FTOI,

OP_LOADP_ITOF,
OP_LOADP_FTOI,

OP_LOAD_I,

Expand Down Expand Up @@ -230,7 +230,7 @@ typedef enum opcode_e
OP_ADD_PIW,

OP_LOADA_F,
OP_LOADA_V,
OP_LOADA_V,
OP_LOADA_S,
OP_LOADA_ENT,
OP_LOADA_FLD,
Expand All @@ -241,7 +241,7 @@ typedef enum opcode_e
OP_LOAD_P,

OP_LOADP_F,
OP_LOADP_V,
OP_LOADP_V,
OP_LOADP_S,
OP_LOADP_ENT,
OP_LOADP_FLD,
Expand All @@ -252,7 +252,7 @@ typedef enum opcode_e
OP_GE_I,
OP_LT_I,
OP_GT_I,

OP_LE_IF,
OP_GE_IF,
OP_LT_IF,
Expand Down Expand Up @@ -295,7 +295,7 @@ typedef enum opcode_e
OP_GSTOREP_ENT,
OP_GSTOREP_FLD,
OP_GSTOREP_S,
OP_GSTOREP_FNC,
OP_GSTOREP_FNC,
OP_GSTOREP_V,
OP_GADDRESS,
OP_GLOAD_I,
Expand Down
24 changes: 12 additions & 12 deletions prvm_edict.c
Original file line number Diff line number Diff line change
Expand Up @@ -2288,8 +2288,8 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char *filename, unsigned char *data
}
switch (op)
{
case OP_IF:
case OP_IFNOT:
case OP_IF_I:
case OP_IFNOT_I:
b = (short)b;
if (a >= prog->progs_numglobals || b + i < 0 || b + i >= prog->progs_numstatements)
prog->error_cmd("%s: out of bounds IF/IFNOT (statement %d) in %s", __func__, i, prog->name);
Expand Down Expand Up @@ -2327,8 +2327,8 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char *filename, unsigned char *data
case OP_SUB_I:
case OP_SUB_FI:
case OP_SUB_IF:
case OP_CONV_IF:
case OP_CONV_FI:
case OP_CONV_ITOF:
case OP_CONV_FTOI:
case OP_LOAD_I:
case OP_BITAND_I:
case OP_BITOR_I:
Expand Down Expand Up @@ -2394,14 +2394,14 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char *filename, unsigned char *data
case OP_MUL_FV:
case OP_MUL_VF:
case OP_DIV_F:
case OP_BITAND:
case OP_BITOR:
case OP_GE:
case OP_LE:
case OP_GT:
case OP_LT:
case OP_AND:
case OP_OR:
case OP_BITAND_F:
case OP_BITOR_F:
case OP_GE_F:
case OP_LE_F:
case OP_GT_F:
case OP_LT_F:
case OP_AND_F:
case OP_OR_F:
case OP_EQ_F:
case OP_EQ_V:
case OP_EQ_S:
Expand Down
26 changes: 13 additions & 13 deletions prvm_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ static const char *prvm_opnames[] =
"^2NE_E",
"^2NE_FNC",

"^2LE",
"^2GE",
"^2LT",
"^2GT",
"^2LE_F",
"^2GE_F",
"^2LT_F",
"^2GT_F",

"^6LOAD_F",
"^6LOAD_V",
Expand Down Expand Up @@ -83,8 +83,8 @@ static const char *prvm_opnames[] =
"^2NOT_S",
"^2NOT_ENT",
"^2NOT_FNC",
"^5IF",
"^5IFNOT",
"^5IF_I",
"^5IFNOT_I",
"^3CALL0",
"^3CALL1",
"^3CALL2",
Expand All @@ -96,11 +96,11 @@ static const char *prvm_opnames[] =
"^3CALL8",
"^1STATE",
"^5GOTO",
"^2AND",
"^2OR",
"^2AND_F",
"^2OR_F",

"BITAND",
"BITOR",
"BITAND_F",
"BITOR_F",



Expand Down Expand Up @@ -176,8 +176,8 @@ NULL,
"SUB_FI",
"SUB_IF",

"CONV_IF",
"CONV_FI",
"CONV_ITOF",
"CONV_FTOI",

NULL,
NULL,
Expand Down Expand Up @@ -344,7 +344,7 @@ static void PRVM_PrintStatement(prvm_prog_t *prog, mstatement_t *s)
} else {
if (s->operand[0] >= 0) Con_Printf( "%s", PRVM_GlobalString(prog, s->operand[0], valuebuf, sizeof(valuebuf)));
}
if (s->op == OP_IF || s->op == OP_IFNOT) {
if (s->op == OP_IF_I || s->op == OP_IFNOT_I) {
Con_Printf(", statement %i", (int)(s - prog->statements) + s->operand[1]);
} else {
if (s->operand[1] >= 0) Con_Printf(", %s", PRVM_GlobalString(prog, s->operand[1], valuebuf, sizeof(valuebuf)));
Expand Down
48 changes: 24 additions & 24 deletions prvm_execprogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ prvm_eval_t *src;
&&handle_OP_NE_E,
&&handle_OP_NE_FNC,

&&handle_OP_LE,
&&handle_OP_GE,
&&handle_OP_LT,
&&handle_OP_GT,
&&handle_OP_LE_F,
&&handle_OP_GE_F,
&&handle_OP_LT_F,
&&handle_OP_GT_F,

&&handle_OP_LOAD_F,
&&handle_OP_LOAD_V,
Expand Down Expand Up @@ -97,8 +97,8 @@ prvm_eval_t *src;
&&handle_OP_NOT_S,
&&handle_OP_NOT_ENT,
&&handle_OP_NOT_FNC,
&&handle_OP_IF,
&&handle_OP_IFNOT,
&&handle_OP_IF_I,
&&handle_OP_IFNOT_I,
&&handle_OP_CALL0,
&&handle_OP_CALL1,
&&handle_OP_CALL2,
Expand All @@ -110,11 +110,11 @@ prvm_eval_t *src;
&&handle_OP_CALL8,
&&handle_OP_STATE,
&&handle_OP_GOTO,
&&handle_OP_AND,
&&handle_OP_OR,
&&handle_OP_AND_F,
&&handle_OP_OR_F,

&&handle_OP_BITAND,
&&handle_OP_BITOR,
&&handle_OP_BITAND_F,
&&handle_OP_BITOR_F,

NULL,
NULL,
Expand Down Expand Up @@ -176,8 +176,8 @@ prvm_eval_t *src;
&&handle_OP_SUB_I,
&&handle_OP_SUB_FI,
&&handle_OP_SUB_IF,
&&handle_OP_CONV_IF,
&&handle_OP_CONV_FI,
&&handle_OP_CONV_ITOF,
&&handle_OP_CONV_FTOI,

NULL,
NULL,
Expand Down Expand Up @@ -385,28 +385,28 @@ prvm_eval_t *src;
OPC->_float = 0.0f;
}
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_BITAND):
HANDLE_OPCODE(OP_BITAND_F):
OPC->_float = (prvm_int_t)OPA->_float & (prvm_int_t)OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_BITOR):
HANDLE_OPCODE(OP_BITOR_F):
OPC->_float = (prvm_int_t)OPA->_float | (prvm_int_t)OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_GE):
HANDLE_OPCODE(OP_GE_F):
OPC->_float = OPA->_float >= OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_LE):
HANDLE_OPCODE(OP_LE_F):
OPC->_float = OPA->_float <= OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_GT):
HANDLE_OPCODE(OP_GT_F):
OPC->_float = OPA->_float > OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_LT):
HANDLE_OPCODE(OP_LT_F):
OPC->_float = OPA->_float < OPB->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_AND):
HANDLE_OPCODE(OP_AND_F):
OPC->_float = PRVM_FLOAT_IS_TRUE_FOR_INT(OPA->_int) && PRVM_FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add AND_I to be used by fteqcc for anything not a float
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_OR):
HANDLE_OPCODE(OP_OR_F):
OPC->_float = PRVM_FLOAT_IS_TRUE_FOR_INT(OPA->_int) || PRVM_FLOAT_IS_TRUE_FOR_INT(OPB->_int); // TODO change this back to float, and add OR_I to be used by fteqcc for anything not a float
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_NOT_F):
Expand Down Expand Up @@ -668,7 +668,7 @@ prvm_eval_t *src;

//==================

HANDLE_OPCODE(OP_IFNOT):
HANDLE_OPCODE(OP_IFNOT_I):
//spike FIXME -- dp redefined IFNOT[_I] as IFNOT_F, which breaks if(0x80000000)
//spike FIXME -- you should add separate IFNOT_I/IFNOT_F opcodes and remap IFNOT_I to ITNOT_F in v6 progs for compat.
if(!FLOAT_IS_TRUE_FOR_INT(OPA->_int))
Expand All @@ -689,7 +689,7 @@ prvm_eval_t *src;
}
DISPATCH_OPCODE();

HANDLE_OPCODE(OP_IF):
HANDLE_OPCODE(OP_IF_I):
//spike FIXME -- dp redefined IF[_I] as IF_F
if(FLOAT_IS_TRUE_FOR_INT(OPA->_int))
// TODO add an "int-if", and change this one, as well as the FLOAT_IS_TRUE_FOR_INT usages, to OPA->_float
Expand Down Expand Up @@ -873,10 +873,10 @@ prvm_eval_t *src;
HANDLE_OPCODE(OP_DIV_FI):
OPC->_float = OPA->_float / (prvm_vec_t) OPB->_int;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_CONV_IF):
HANDLE_OPCODE(OP_CONV_ITOF):
OPC->_float = OPA->_int;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_CONV_FI):
HANDLE_OPCODE(OP_CONV_FTOI):
OPC->_int = OPA->_float;
DISPATCH_OPCODE();
HANDLE_OPCODE(OP_BITAND_I):
Expand Down

0 comments on commit be41f10

Please sign in to comment.