[gamecode] Decode the swizzle operand

-yx00 is much easier to interpret than some "random" number.
This commit is contained in:
Bill Currie 2023-08-24 20:17:17 +09:00
parent 5f22fd07d9
commit fb6d3f2f86
2 changed files with 24 additions and 1 deletions

View file

@ -511,7 +511,7 @@ swizzle_formats = {
"opcode": "OP_SWIZZLE_{swiz_type[t]}",
"mnemonic": "swizzle.{swiz_type[t]}",
"opname": "swizzle",
"format": "%Ga %sb %gc",
"format": "%Ga.%Sb %gc",
"widths": "4, 0, 4",
"types": "{swizzle_types[t]}",
"args": {

View file

@ -1182,6 +1182,26 @@ global_string (pr_debug_data_t *data, pr_ptr_t offset, qfot_type_t *type,
return dstr->str;
}
static const char *
swizzle_string (pr_debug_data_t *data, pr_uint_t swiz)
{
progs_t *pr = data->pr;
prdeb_resources_t *res = pr->pr_debug_resources;
static char swizzle_components[] = "xyzw";
const char *swizzle = "";
for (int i = 0; i < 4; i++) {
if (swiz & (0x1000 << i)) {
swizzle = va (res->va, "%s0", swizzle);
} else {
swizzle = va (res->va, "%s%s%c", swizzle,
swiz & (0x100 << i) ? "-" : "",
swizzle_components[(swiz >> 2 * i) & 3]);
}
}
return swizzle;
}
const char *
PR_Debug_ValueString (progs_t *pr, pr_ptr_t offset, qfot_type_t *type,
dstring_t *dstr)
@ -1806,6 +1826,9 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
case 's':
str = dsprintf (res->dva, "%d", (short) opval);
break;
case 'S':
str = swizzle_string (&data, opval);
break;
case 'O':
str = dsprintf (res->dva, "%04x",
addr + (short) opval);