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).

Not handling IF/IFNOT yet, but documenting a plan.
  • Loading branch information
divVerent committed Nov 8, 2024
1 parent 7ae6274 commit 9f02f5f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 58 deletions.
36 changes: 18 additions & 18 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 @@ -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
20 changes: 10 additions & 10 deletions prvm_edict.c
Original file line number Diff line number Diff line change
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
20 changes: 10 additions & 10 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 @@ -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
47 changes: 27 additions & 20 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 @@ -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 @@ -691,6 +691,13 @@ prvm_eval_t *src;

HANDLE_OPCODE(OP_IF):
//spike FIXME -- dp redefined IF[_I] as IF_F
// TODO: plan is:
// - Add IF_F, IFNOT_F.
// - Rename this to IF_I, IFNOT_I.
// - Add sv_gameplayfix variable to remap IF_I and IFNOT_I to IF_F and IFNOT_F on progs load.
// - Define this fix for Nexuiz.
// - Add generation of IF_F, IFNOT_F instructions to gmqcc.
// - Move Xonotic to that.
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
// although mostly unneeded, thanks to the only float being false being 0x0 and 0x80000000 (negative zero)
Expand Down Expand Up @@ -873,10 +880,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 9f02f5f

Please sign in to comment.