diff --git a/libs/gamecode/opcodes.py b/libs/gamecode/opcodes.py index a8dd96bbc..fe786d988 100644 --- a/libs/gamecode/opcodes.py +++ b/libs/gamecode/opcodes.py @@ -3,6 +3,7 @@ bitmap_txt = """ 0 0001 mmss store 0 0010 mmss push 0 0011 mmss pop +0 0111 01t0 wedge2 0 1ccc ttss compare 0 0000 00nn 0 0000 0000 noop @@ -520,6 +521,18 @@ swizzle_formats = { "swizzle_types": float_t, }, } +wedge2_formats = { + "opcode": "OP_WEDGE_{wedge_type[t]}_2", + "mnemonic": "wedge.{wedge_type[t]}", + "opname": "wedge", + "format": "%Ga, %Gb, %gc", + "widths": "2, 2, 1", + "types": "{wedge_types[t]}", + "args": { + "wedge_type": ['F', 'D'], + "wedge_types": float_t, + }, +} return_formats = { "opcode": "OP_RETURN", "mnemonic": "return", @@ -619,6 +632,7 @@ group_map = { "udivops": udivops_formats, "vecops": vecops_formats, "vecops2": vecops2_formats, + "wedge2": wedge2_formats, "with": with_formats, } diff --git a/libs/gamecode/pr_exec.c b/libs/gamecode/pr_exec.c index e4d893536..d92b97352 100644 --- a/libs/gamecode/pr_exec.c +++ b/libs/gamecode/pr_exec.c @@ -2291,6 +2291,21 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth) // 0 0110 // spare // 0 0111 + case OP_WEDGE_F_2: + { + auto a = OPA(vec2); + auto b = OPB(vec2); + OPC(float) = a[0] * b[1] - a[1] * b[0]; + } + break; + // spare + case OP_WEDGE_D_2: + { + auto a = OPA(dvec2); + auto b = OPB(dvec2); + OPC(double) = a[0] * b[1] - a[1] * b[0]; + } + break; // spare #define OP_cmp_1(OP, T, rt, cmp, ct) \ diff --git a/libs/gamecode/test/test-vector.c b/libs/gamecode/test/test-vector.c index 46c0b9efb..6536c156c 100644 --- a/libs/gamecode/test/test-vector.c +++ b/libs/gamecode/test/test-vector.c @@ -28,7 +28,7 @@ static pr_vec4_t float_globals_init[] = { static pr_vec4_t float_globals_expect[] = { {3, 4, 5, 12}, - {63, 0, -33, 56}, + {63, 16, -33, 56}, {1, 2, 3, 8}, {4, 5, 6, 8}, @@ -54,6 +54,7 @@ static pr_vec4_t float_globals_expect[] = { static dstatement_t float_vector_statements[] = { { OP(0, 0, 0, OP_CDOT_F), 0, 2, 4 }, + { OP(0, 0, 0, OP_WEDGE_F_2), 0, 2, 5 }, { OP(0, 0, 0, OP_CMUL_F), 0, 2, 6 }, { OP(0, 0, 0, OP_VDOT_F), 8, 12, 16 }, { OP(0, 0, 0, OP_CROSS_F), 8, 12, 20 }, @@ -102,7 +103,7 @@ static pr_dvec4_t double_globals_init[] = { static pr_dvec4_t double_globals_expect[] = { {3, 4, 5, 12}, - {63, 0, -33, 56}, + {63, 16, -33, 56}, {1, 2, 3, 8}, {4, 5, 6, 8}, @@ -128,6 +129,7 @@ static pr_dvec4_t double_globals_expect[] = { static dstatement_t double_vector_statements[] = { { OP(0, 0, 0, OP_CDOT_D), 0, 4, 8 }, + { OP(0, 0, 0, OP_WEDGE_D_2), 0, 4, 10 }, { OP(0, 0, 0, OP_CMUL_D), 0, 4, 12 }, { OP(0, 0, 0, OP_VDOT_D), 16, 24, 32 }, { OP(0, 0, 0, OP_CROSS_D), 16, 24, 40 },