Gv_FillWithVars

git-svn-id: https://svn.eduke32.com/eduke32@6323 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-07-05 05:38:11 +00:00
parent 93d8d8a890
commit 8d3e0a630e
2 changed files with 246 additions and 260 deletions

View file

@ -2008,33 +2008,28 @@ skip_check:
case CON_QSTRDIM: case CON_QSTRDIM:
insptr++; insptr++;
{ {
vec2_t dim = { 0, 0, };
int const widthVar = *insptr++; int const widthVar = *insptr++;
int const heightVar = *insptr++; int const heightVar = *insptr++;
int32_t params[16];
Gv_GetManyVars(16, params); struct {
int32_t tileNum;
vec3_t vect;
int32_t blockAngle, quoteNum, orientation;
vec2_t offset, between;
int32_t f;
vec2_t bound[2];
} v;
Gv_FillWithVars(v);
int const tileNum = params[0]; if (EDUKE32_PREDICT_FALSE(v.tileNum < 0 || v.tileNum + 127 >= MAXTILES))
vec3_t vect = { params[1], params[2], params[3] }; CON_ERRPRINTF("invalid base tilenum %d\n", v.tileNum);
int const blockAngle = params[4]; else if (EDUKE32_PREDICT_FALSE((unsigned)v.quoteNum >= MAXQUOTES || apStrings[v.quoteNum] == NULL))
int const quoteNum = params[5]; CON_ERRPRINTF("invalid quote ID %d\n", v.quoteNum);
int const orientation = params[6] & (ROTATESPRITE_MAX - 1);
vec2_t offset = { params[7], params[8] };
vec2_t between = { params[9], params[10] };
int const f = params[11];
vec2_t upperLeft = { params[12], params[13] };
vec2_t lowerRight = { params[14], params[15] };
if (EDUKE32_PREDICT_FALSE(tileNum < 0 || tileNum + 255 >= MAXTILES))
CON_ERRPRINTF("invalid base tilenum %d\n", tileNum);
else if (EDUKE32_PREDICT_FALSE((unsigned)quoteNum >= MAXQUOTES || apStrings[quoteNum] == NULL))
CON_ERRPRINTF("invalid quote ID %d\n", quoteNum);
else else
{ {
dim = G_ScreenTextSize(tileNum, vect.x, vect.y, vect.z, blockAngle, apStrings[quoteNum], vec2_t dim = G_ScreenTextSize(v.tileNum, v.vect.x, v.vect.y, v.vect.z, v.blockAngle, apStrings[v.quoteNum],
2 | orientation, offset.x, offset.y, between.x, between.y, f, 2 | v.orientation, v.offset.x, v.offset.y, v.between.x, v.between.y, v.f,
upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y); v.bound[0].x, v.bound[0].y, v.bound[1].x, v.bound[1].y);
Gv_SetVarX(widthVar, dim.x); Gv_SetVarX(widthVar, dim.x);
Gv_SetVarX(heightVar, dim.y); Gv_SetVarX(heightVar, dim.y);
@ -2177,45 +2172,40 @@ skip_check:
case CON_QSUBSTR: case CON_QSUBSTR:
insptr++; insptr++;
{ {
int32_t params[4]; struct {
int32_t outputQuote, inputQuote, quotePos, quoteLength;
} v;
Gv_FillWithVars(v);
Gv_GetManyVars(4, params); if (EDUKE32_PREDICT_FALSE((unsigned)v.outputQuote>=MAXQUOTES || apStrings[v.outputQuote] == NULL))
int const outputQuote = params[0];
int const inputQuote = params[1];
if (EDUKE32_PREDICT_FALSE((unsigned)outputQuote>=MAXQUOTES || apStrings[outputQuote] == NULL))
{ {
CON_ERRPRINTF("invalid quote ID %d\n", outputQuote); CON_ERRPRINTF("invalid quote ID %d\n", v.outputQuote);
continue; continue;
} }
if (EDUKE32_PREDICT_FALSE((unsigned)inputQuote>=MAXQUOTES || apStrings[inputQuote] == NULL)) if (EDUKE32_PREDICT_FALSE((unsigned)v.inputQuote>=MAXQUOTES || apStrings[v.inputQuote] == NULL))
{ {
CON_ERRPRINTF("invalid quote ID %d\n", inputQuote); CON_ERRPRINTF("invalid quote ID %d\n", v.inputQuote);
continue; continue;
} }
int quotePos = params[2]; if (EDUKE32_PREDICT_FALSE((unsigned)v.quotePos >= MAXQUOTELEN))
int quoteLength = params[3];
if (EDUKE32_PREDICT_FALSE((unsigned)quotePos >= MAXQUOTELEN))
{ {
CON_ERRPRINTF("invalid start position %d\n", quotePos); CON_ERRPRINTF("invalid start position %d\n", v.quotePos);
continue; continue;
} }
if (EDUKE32_PREDICT_FALSE(quoteLength < 0)) if (EDUKE32_PREDICT_FALSE(v.quoteLength < 0))
{ {
CON_ERRPRINTF("invalid length %d\n", quoteLength); CON_ERRPRINTF("invalid length %d\n", v.quoteLength);
continue; continue;
} }
char * pOutput = apStrings[outputQuote]; char * pOutput = apStrings[v.outputQuote];
char const *pInput = apStrings[inputQuote]; char const *pInput = apStrings[v.inputQuote];
while (*pInput && quotePos--) pInput++; while (*pInput && v.quotePos--) pInput++;
while ((*pOutput = *pInput) && quoteLength--) while ((*pOutput = *pInput) && v.quoteLength--)
{ {
pOutput++; pOutput++;
pInput++; pInput++;
@ -2459,27 +2449,25 @@ nullquote:
case CON_MYOSPAL: case CON_MYOSPAL:
insptr++; insptr++;
{ {
int32_t values[5]; struct {
Gv_GetManyVars(5, values); vec2_t pos;
int32_t tilenum, shade, orientation;
vec2_t const pos = *(vec2_t *)values; } v;
int const tilenum = values[2]; Gv_FillWithVars(v);
int const shade = values[3];
int const orientation = values[4];
switch (tw) switch (tw)
{ {
case CON_MYOS: case CON_MYOS:
VM_DrawTile(pos.x, pos.y, tilenum, shade, orientation); VM_DrawTile(v.pos.x, v.pos.y, v.tilenum, v.shade, v.orientation);
break; break;
case CON_MYOSPAL: case CON_MYOSPAL:
VM_DrawTilePal(pos.x, pos.y, tilenum, shade, orientation, Gv_GetVarX(*insptr++)); VM_DrawTilePal(v.pos.x, v.pos.y, v.tilenum, v.shade, v.orientation, Gv_GetVarX(*insptr++));
break; break;
case CON_MYOSX: case CON_MYOSX:
VM_DrawTileSmall(pos.x, pos.y, tilenum, shade, orientation); VM_DrawTileSmall(v.pos.x, v.pos.y, v.tilenum, v.shade, v.orientation);
break; break;
case CON_MYOSPALX: case CON_MYOSPALX:
VM_DrawTilePalSmall(pos.x, pos.y, tilenum, shade, orientation, Gv_GetVarX(*insptr++)); VM_DrawTilePalSmall(v.pos.x, v.pos.y, v.tilenum, v.shade, v.orientation, Gv_GetVarX(*insptr++));
break; break;
} }
continue; continue;
@ -2548,8 +2536,7 @@ nullquote:
{ {
int const wallNum = Gv_GetVarX(*insptr++); int const wallNum = Gv_GetVarX(*insptr++);
vec2_t n; vec2_t n;
Gv_FillWithVars(n);
Gv_GetManyVars(2, (int32_t *)&n);
if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls)) if (EDUKE32_PREDICT_FALSE((unsigned)wallNum >= (unsigned)numwalls))
{ {
@ -2566,8 +2553,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec2_t in; vec2_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(2, (int32_t *) &in);
if (EDUKE32_PREDICT_FALSE((unsigned)in.x >= MAXSPRITES || (unsigned)in.y >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned)in.x >= MAXSPRITES || (unsigned)in.y >= MAXSPRITES))
{ {
@ -2584,8 +2570,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec2_t in; vec2_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(2, (int32_t *) &in);
if (EDUKE32_PREDICT_FALSE((unsigned)in.x >= MAXSPRITES || (unsigned)in.y >= MAXSPRITES)) if (EDUKE32_PREDICT_FALSE((unsigned)in.x >= MAXSPRITES || (unsigned)in.y >= MAXSPRITES))
{ {
@ -2602,8 +2587,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec2_t in; vec2_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(2, (int32_t *)&in);
Gv_SetVarX(out, getangle(in.x, in.y)); Gv_SetVarX(out, getangle(in.x, in.y));
continue; continue;
} }
@ -2613,8 +2597,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec2_t in; vec2_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(2, (int32_t *)&in);
Gv_SetVarX(out, G_GetAngleDelta(in.x, in.y)); Gv_SetVarX(out, G_GetAngleDelta(in.x, in.y));
continue; continue;
} }
@ -2624,8 +2607,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec3_t in; vec3_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(3, (int32_t *)&in);
Gv_SetVarX(out, mulscale(in.x, in.y, in.z)); Gv_SetVarX(out, mulscale(in.x, in.y, in.z));
continue; continue;
} }
@ -2635,8 +2617,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec3_t in; vec3_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(3, (int32_t *)&in);
Gv_SetVarX(out, divscale(in.x, in.y, in.z)); Gv_SetVarX(out, divscale(in.x, in.y, in.z));
continue; continue;
} }
@ -2646,8 +2627,7 @@ nullquote:
{ {
int const out = *insptr++; int const out = *insptr++;
vec3_t in; vec3_t in;
Gv_FillWithVars(in);
Gv_GetManyVars(3, (int32_t *)&in);
Gv_SetVarX(out, scale(in.x, in.y, in.z)); Gv_SetVarX(out, scale(in.x, in.y, in.z));
continue; continue;
} }
@ -2661,7 +2641,7 @@ nullquote:
insptr++; insptr++;
{ {
int32_t params[4]; int32_t params[4];
Gv_GetManyVars(4, params); Gv_FillWithVars(params);
aGameVars[g_returnVarID].global = nextsectorneighborz(params[0], params[1], params[2], params[3]); aGameVars[g_returnVarID].global = nextsectorneighborz(params[0], params[1], params[2], params[3]);
} }
continue; continue;
@ -2908,28 +2888,26 @@ nullquote:
case CON_SHOWVIEWUNBIASED: case CON_SHOWVIEWUNBIASED:
insptr++; insptr++;
{ {
struct {
vec3_t vec; vec3_t vec;
Gv_GetManyVars(3, (int32_t *)&vec);
int32_t params[3]; int32_t params[3];
Gv_GetManyVars(3, params);
vec2_t scrn[2]; vec2_t scrn[2];
Gv_GetManyVars(4, (int32_t *)scrn); } v;
Gv_FillWithVars(v);
if (EDUKE32_PREDICT_FALSE(scrn[0].x < 0 || scrn[0].y < 0 || scrn[1].x >= 320 || scrn[1].y >= 200)) if (EDUKE32_PREDICT_FALSE(v.scrn[0].x < 0 || v.scrn[0].y < 0 || v.scrn[1].x >= 320 || v.scrn[1].y >= 200))
{ {
CON_ERRPRINTF("incorrect coordinates\n"); CON_ERRPRINTF("incorrect coordinates\n");
continue; continue;
} }
if (EDUKE32_PREDICT_FALSE((unsigned)params[2] >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)v.params[2] >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector %d\n", params[2]); CON_ERRPRINTF("Invalid sector %d\n", v.params[2]);
continue; continue;
} }
G_ShowView(vec, params[0], params[1], params[2], scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y, (tw != CON_SHOWVIEW)); G_ShowView(v.vec, v.params[0], v.params[1], v.params[2], v.scrn[0].x, v.scrn[0].y, v.scrn[1].x, v.scrn[1].y, (tw != CON_SHOWVIEW));
continue; continue;
} }
@ -2939,40 +2917,35 @@ nullquote:
case CON_ROTATESPRITE: case CON_ROTATESPRITE:
insptr++; insptr++;
{ {
int32_t params[8]; struct {
vec3_t pos;
Gv_GetManyVars(8, params); int32_t ang, tilenum, shade, pal, orientation;
} v;
vec3_t pos = *(vec3_t *)params; Gv_FillWithVars(v);
int const ang = params[3];
int const tilenum = params[4];
int const shade = params[5];
int const pal = params[6];
int orientation = params[7] & (ROTATESPRITE_MAX - 1);
int32_t alpha = (tw == CON_ROTATESPRITEA) ? Gv_GetVarX(*insptr++) : 0; int32_t alpha = (tw == CON_ROTATESPRITEA) ? Gv_GetVarX(*insptr++) : 0;
vec2_t scrn[2]; vec2_t bound[2];
Gv_GetManyVars(4, (int32_t *) scrn); Gv_FillWithVars(bound);
if (tw != CON_ROTATESPRITE16 && !(orientation&ROTATESPRITE_FULL16)) if (tw != CON_ROTATESPRITE16 && !(v.orientation&ROTATESPRITE_FULL16))
{ {
pos.x <<= 16; v.pos.x <<= 16;
pos.y <<= 16; v.pos.y <<= 16;
} }
if (EDUKE32_PREDICT_FALSE((unsigned) tilenum >= MAXTILES)) if (EDUKE32_PREDICT_FALSE((unsigned) v.tilenum >= MAXTILES))
{ {
CON_ERRPRINTF("invalid tilenum %d\n", tilenum); CON_ERRPRINTF("invalid tilenum %d\n", v.tilenum);
continue; continue;
} }
int32_t blendidx = 0; int32_t blendidx = 0;
NEG_ALPHA_TO_BLEND(alpha, blendidx, orientation); NEG_ALPHA_TO_BLEND(alpha, blendidx, v.orientation);
rotatesprite_(pos.x, pos.y, pos.z, ang, tilenum, shade, pal, 2 | orientation, alpha, blendidx, rotatesprite_(v.pos.x, v.pos.y, v.pos.z, v.ang, v.tilenum, v.shade, v.pal, 2 | (v.orientation & (ROTATESPRITE_MAX - 1)),
scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y); alpha, blendidx, bound[0].x, bound[0].y, bound[1].x, bound[1].y);
continue; continue;
} }
@ -2980,32 +2953,30 @@ nullquote:
case CON_GAMETEXTZ: case CON_GAMETEXTZ:
insptr++; insptr++;
{ {
int32_t params[11]; struct {
Gv_GetManyVars(11, params); int32_t tilenum;
vec2_t pos;
int32_t nQuote, shade, pal, orientation;
vec2_t bound[2];
} v;
Gv_FillWithVars(v);
int const tilenum = params[0]; int32_t const z = (tw == CON_GAMETEXTZ) ? Gv_GetVarX(*insptr++) : 65536;
vec2_t const pos = { params[1], params[2] };
int const nQuote = params[3];
int const shade = params[4];
int const pal = params[5];
int const orientation = params[6] & (ROTATESPRITE_MAX - 1);
vec2_t const bound1 = *(vec2_t *)&params[7];
vec2_t const bound2 = *(vec2_t *)&params[9];
int32_t z = (tw == CON_GAMETEXTZ) ? Gv_GetVarX(*insptr++) : 65536;
if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum + 255 >= MAXTILES)) if (EDUKE32_PREDICT_FALSE(v.tilenum < 0 || v.tilenum + 127 >= MAXTILES))
{ {
CON_ERRPRINTF("invalid base tilenum %d\n", tilenum); CON_ERRPRINTF("invalid base tilenum %d\n", v.tilenum);
continue; continue;
} }
if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL)) if (EDUKE32_PREDICT_FALSE((unsigned)v.nQuote >= MAXQUOTES || apStrings[v.nQuote] == NULL))
{ {
CON_ERRPRINTF("invalid quote ID %d\n", nQuote); CON_ERRPRINTF("invalid quote ID %d\n", v.nQuote);
continue; continue;
} }
G_PrintGameText(tilenum, pos.x >> 1, pos.y, apStrings[nQuote], shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, z, 0); G_PrintGameText(v.tilenum, v.pos.x >> 1, v.pos.y, apStrings[v.nQuote], v.shade, v.pal, v.orientation & (ROTATESPRITE_MAX - 1),
v.bound[0].x, v.bound[0].y, v.bound[1].x, v.bound[1].y, z, 0);
continue; continue;
} }
@ -3013,84 +2984,74 @@ nullquote:
case CON_DIGITALNUMBERZ: case CON_DIGITALNUMBERZ:
insptr++; insptr++;
{ {
int32_t params[11]; struct {
Gv_GetManyVars(11, params); int32_t tilenum;
vec2_t pos;
int32_t nQuote, shade, pal, orientation;
vec2_t bound[2];
} v;
Gv_FillWithVars(v);
int const tilenum = params[0]; int32_t const nZoom = (tw == CON_DIGITALNUMBERZ) ? Gv_GetVarX(*insptr++) : 65536;
vec2_t const pos = { params[1], params[2] };
int const q = params[3];
int const shade = params[4];
int const pal = params[5];
int const orientation = params[6] & (ROTATESPRITE_MAX - 1);
vec2_t const bound1 = *(vec2_t *)&params[7];
vec2_t const bound2 = *(vec2_t *)&params[9];
int32_t nZoom = (tw == CON_DIGITALNUMBERZ) ? Gv_GetVarX(*insptr++) : 65536;
// NOTE: '-' not taken into account, but we have rotatesprite() bound check now anyway // NOTE: '-' not taken into account, but we have rotatesprite() bound check now anyway
if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+9 >= MAXTILES)) if (EDUKE32_PREDICT_FALSE(v.tilenum < 0 || v.tilenum+9 >= MAXTILES))
{ {
CON_ERRPRINTF("invalid base tilenum %d\n", tilenum); CON_ERRPRINTF("invalid base tilenum %d\n", v.tilenum);
continue; continue;
} }
G_DrawTXDigiNumZ(tilenum, pos.x, pos.y, q, shade, pal, orientation, bound1.x, bound1.y, bound2.x, bound2.y, nZoom); G_DrawTXDigiNumZ(v.tilenum, v.pos.x, v.pos.y, v.nQuote, v.shade, v.pal, v.orientation & (ROTATESPRITE_MAX - 1),
v.bound[0].x, v.bound[0].y, v.bound[1].x, v.bound[1].y, nZoom);
continue; continue;
} }
case CON_MINITEXT: case CON_MINITEXT:
insptr++; insptr++;
{ {
int32_t params[5]; struct {
Gv_GetManyVars(5, params); vec2_t pos;
int32_t nQuote, shade, pal;
} v;
Gv_FillWithVars(v);
vec2_t const pos = { params[0], params[1] }; if (EDUKE32_PREDICT_FALSE((unsigned)v.nQuote >= MAXQUOTES || apStrings[v.nQuote] == NULL))
int const nQuote = params[2];
int const shade = params[3], pal = params[4];
if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL))
{ {
CON_ERRPRINTF("invalid quote ID %d\n", nQuote); CON_ERRPRINTF("invalid quote ID %d\n", v.nQuote);
continue; continue;
} }
minitextshade(pos.x, pos.y, apStrings[nQuote], shade, pal, 2+8+16); minitextshade(v.pos.x, v.pos.y, apStrings[v.nQuote], v.shade, v.pal, 2+8+16);
continue; continue;
} }
case CON_SCREENTEXT: case CON_SCREENTEXT:
insptr++; insptr++;
{ {
int32_t params[20]; struct {
Gv_GetManyVars(20, params); int32_t tilenum;
vec3_t v;
int32_t blockangle, charangle, nQuote, shade, pal, orientation, alpha;
vec2_t spacing, between;
int32_t nFlags;
vec2_t bound[2];
} v;
Gv_FillWithVars(v);
int const tilenum = params[0]; if (EDUKE32_PREDICT_FALSE(v.tilenum < 0 || v.tilenum+127 >= MAXTILES))
vec3_t const v = *(vec3_t *)&params[1];
int const blockangle = params[4];
int const charangle = params[5];
int const nQuote = params[6];
int const shade = params[7];
int const pal = params[8];
int const orientation = params[9] & (ROTATESPRITE_MAX - 1);
int const alpha = params[10];
vec2_t const spacing = *(vec2_t *) &params[11];
vec2_t const between = *(vec2_t *) &params[13];
int const nFlags = params[15];
vec2_t const scrn[2] = { *(vec2_t *)&params[16], *(vec2_t *)&params[18] };
if (EDUKE32_PREDICT_FALSE(tilenum < 0 || tilenum+255 >= MAXTILES))
{ {
CON_ERRPRINTF("invalid base tilenum %d\n", tilenum); CON_ERRPRINTF("invalid base tilenum %d\n", v.tilenum);
continue; continue;
} }
if (EDUKE32_PREDICT_FALSE((unsigned)nQuote >= MAXQUOTES || apStrings[nQuote] == NULL)) if (EDUKE32_PREDICT_FALSE((unsigned)v.nQuote >= MAXQUOTES || apStrings[v.nQuote] == NULL))
{ {
CON_ERRPRINTF("invalid quote ID %d\n", nQuote); CON_ERRPRINTF("invalid quote ID %d\n", v.nQuote);
continue; continue;
} }
G_ScreenText(tilenum, v.x, v.y, v.z, blockangle, charangle, apStrings[nQuote], shade, pal, 2 | orientation, G_ScreenText(v.tilenum, v.v.x, v.v.y, v.v.z, v.blockangle, v.charangle, apStrings[v.nQuote], v.shade, v.pal, 2 | (v.orientation & (ROTATESPRITE_MAX - 1)),
alpha, spacing.x, spacing.y, between.x, between.y, nFlags, scrn[0].x, scrn[0].y, scrn[1].x, scrn[1].y); v.alpha, v.spacing.x, v.spacing.y, v.between.x, v.between.y, v.nFlags, v.bound[0].x, v.bound[0].y, v.bound[1].x, v.bound[1].y);
continue; continue;
} }
@ -3102,26 +3063,31 @@ nullquote:
case CON_GETZRANGE: case CON_GETZRANGE:
insptr++; insptr++;
{ {
struct {
vec3_t vect; vec3_t vect;
Gv_GetManyVars(3, (int32_t *)&vect); int32_t sectNum;
} v;
Gv_FillWithVars(v);
int const sectnum = Gv_GetVarX(*insptr++);
int const ceilzvar = *insptr++; int const ceilzvar = *insptr++;
int const ceilhitvar = *insptr++; int const ceilhitvar = *insptr++;
int const florzvar = *insptr++; int const florzvar = *insptr++;
int const florhitvar = *insptr++; int const florhitvar = *insptr++;
int const walldist = Gv_GetVarX(*insptr++);
int const clipmask = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) struct {
int32_t walldist, clipmask;
} v2;
Gv_FillWithVars(v2);
if (EDUKE32_PREDICT_FALSE((unsigned)v.sectNum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector %d\n", sectnum); CON_ERRPRINTF("Invalid sector %d\n", v.sectNum);
continue; continue;
} }
int32_t ceilz, ceilhit, florz, florhit; int32_t ceilz, ceilhit, florz, florhit;
getzrange(&vect, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); getzrange(&v.vect, v.sectNum, &ceilz, &ceilhit, &florz, &florhit, v2.walldist, v2.clipmask);
Gv_SetVarX(ceilzvar, ceilz); Gv_SetVarX(ceilzvar, ceilz);
Gv_SetVarX(ceilhitvar, ceilhit); Gv_SetVarX(ceilhitvar, ceilhit);
Gv_SetVarX(florzvar, florz); Gv_SetVarX(florzvar, florz);
@ -3155,7 +3121,7 @@ nullquote:
{ {
int32_t returnVar = *insptr++; int32_t returnVar = *insptr++;
vec2_t da; vec2_t da;
Gv_GetManyVars(2, (int32_t *)&da); Gv_FillWithVars(da);
int64_t const hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y; int64_t const hypsq = (int64_t)da.x*da.x + (int64_t)da.y*da.y;
Gv_SetVarX(returnVar, (hypsq > (int64_t) INT32_MAX) Gv_SetVarX(returnVar, (hypsq > (int64_t) INT32_MAX)
@ -3168,11 +3134,11 @@ nullquote:
case CON_RAYINTERSECT: case CON_RAYINTERSECT:
insptr++; insptr++;
{ {
struct {
vec3_t vec[2]; vec3_t vec[2];
Gv_GetManyVars(6, (int32_t *)vec);
vec2_t vec2[2]; vec2_t vec2[2];
Gv_GetManyVars(4, (int32_t *)vec2); } v;
Gv_FillWithVars(v);
int const intxvar = *insptr++; int const intxvar = *insptr++;
int const intyvar = *insptr++; int const intyvar = *insptr++;
@ -3180,10 +3146,16 @@ nullquote:
int const retvar = *insptr++; int const retvar = *insptr++;
vec3_t in; vec3_t in;
int ret = (tw == CON_LINEINTERSECT) int ret = (tw == CON_LINEINTERSECT)
? lintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, ? lintersect(v.vec[0].x, v.vec[0].y, v.vec[0].z,
vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z) v.vec[1].x, v.vec[1].y, v.vec[1].z,
: rayintersect(vec[0].x, vec[0].y, vec[0].z, vec[1].x, vec[1].y, vec[1].z, vec2[0].x, vec2[0].y, v.vec2[0].x, v.vec2[0].y,
vec2[1].x, vec2[1].y, &in.x, &in.y, &in.z); v.vec2[1].x, v.vec2[1].y,
&in.x, &in.y, &in.z)
: rayintersect(v.vec[0].x, v.vec[0].y, v.vec[0].z,
v.vec[1].x, v.vec[1].y, v.vec[1].z,
v.vec2[0].x, v.vec2[0].y,
v.vec2[1].x, v.vec2[1].y,
&in.x, &in.y, &in.z);
Gv_SetVarX(retvar, ret); Gv_SetVarX(retvar, ret);
@ -3211,19 +3183,19 @@ nullquote:
insptr -= 2; insptr -= 2;
typedef struct {
vec3_t vec3; vec3_t vec3;
Gv_GetManyVars(3, (int32_t *)&vec3); int32_t sectNum32;
int const sectReturn = *insptr++;
vec2_t vec2; vec2_t vec2;
Gv_GetManyVars(2, (int32_t *)&vec2);
vec3dist_t dist; vec3dist_t dist;
Gv_GetManyVars(3, (int32_t *)&dist); int32_t clipMask;
} clipmoveparams_t;
int const clipMask = Gv_GetVarX(*insptr++); int32_t const sectReturn = insptr[offsetof(clipmoveparams_t, sectNum32)/sizeof(int32_t)];
int16_t sectNum = Gv_GetVarX(sectReturn);
clipmoveparams_t v;
Gv_FillWithVars(v);
int16_t sectNum = v.sectNum32;
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors))
{ {
@ -3233,10 +3205,10 @@ nullquote:
} }
Gv_SetVarX(returnVar, Gv_SetVarX(returnVar,
clipmovex(&vec3, &sectNum, vec2.x, vec2.y, dist.w, dist.f, dist.c, clipMask, (tw == CON_CLIPMOVENOSLIDE))); clipmovex(&v.vec3, &sectNum, v.vec2.x, v.vec2.y, v.dist.w, v.dist.f, v.dist.c, v.clipMask, (tw == CON_CLIPMOVENOSLIDE)));
Gv_SetVarX(sectReturn, sectNum); Gv_SetVarX(sectReturn, v.sectNum32);
Gv_SetVarX(xReturn, vec3.x); Gv_SetVarX(xReturn, v.vec3.x);
Gv_SetVarX(yReturn, vec3.y); Gv_SetVarX(yReturn, v.vec3.y);
continue; continue;
} }
@ -3244,13 +3216,12 @@ nullquote:
case CON_HITSCAN: case CON_HITSCAN:
insptr++; insptr++;
{ {
struct {
vec3_t vect; vec3_t vect;
Gv_GetManyVars(3, (int32_t *)&vect); int32_t sectnum;
int const sectnum = Gv_GetVarX(*insptr++);
vec3_t v; vec3_t v;
Gv_GetManyVars(3, (int32_t *) &v); } v;
Gv_FillWithVars(v);
int const sectReturn = *insptr++; int const sectReturn = *insptr++;
int const wallReturn = *insptr++; int const wallReturn = *insptr++;
@ -3260,14 +3231,14 @@ nullquote:
int const zReturn = *insptr++; int const zReturn = *insptr++;
int const clipType = Gv_GetVarX(*insptr++); int const clipType = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)sectnum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)v.sectnum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector %d\n", sectnum); CON_ERRPRINTF("Invalid sector %d\n", v.sectnum);
continue; continue;
} }
hitdata_t hit; hitdata_t hit;
hitscan((const vec3_t *)&vect, sectnum, v.x, v.y, v.z, &hit, clipType); hitscan(&v.vect, v.sectnum, v.v.x, v.v.y, v.v.z, &hit, clipType);
Gv_SetVarX(sectReturn, hit.sect); Gv_SetVarX(sectReturn, hit.sect);
Gv_SetVarX(wallReturn, hit.wall); Gv_SetVarX(wallReturn, hit.wall);
@ -3281,40 +3252,41 @@ nullquote:
case CON_CANSEE: case CON_CANSEE:
insptr++; insptr++;
{ {
struct {
vec3_t vec1; vec3_t vec1;
Gv_GetManyVars(3, (int32_t *) &vec1); int32_t firstSector;
int const firstSector = Gv_GetVarX(*insptr++);
vec3_t vec2; vec3_t vec2;
Gv_GetManyVars(3, (int32_t *) &vec2); int32_t secondSector;
} v;
Gv_FillWithVars(v);
int const secondSector = Gv_GetVarX(*insptr++);
int const returnVar = *insptr++; int const returnVar = *insptr++;
if (EDUKE32_PREDICT_FALSE((unsigned)firstSector >= (unsigned)numsectors || if (EDUKE32_PREDICT_FALSE((unsigned)v.firstSector >= (unsigned)numsectors ||
(unsigned)secondSector >= (unsigned)numsectors)) (unsigned)v.secondSector >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector\n"); CON_ERRPRINTF("Invalid sector\n");
Gv_SetVarX(returnVar, 0); Gv_SetVarX(returnVar, 0);
} }
Gv_SetVarX(returnVar, cansee(vec1.x, vec1.y, vec1.z, firstSector, vec2.x, vec2.y, vec2.z, secondSector)); Gv_SetVarX(returnVar, cansee(v.vec1.x, v.vec1.y, v.vec1.z, v.firstSector, v.vec2.x, v.vec2.y, v.vec2.z, v.secondSector));
continue; continue;
} }
case CON_ROTATEPOINT: case CON_ROTATEPOINT:
insptr++; insptr++;
{ {
struct {
vec2_t point[2]; vec2_t point[2];
Gv_GetManyVars(4, (int32_t *)point); int32_t angle;
} v;
Gv_FillWithVars(v);
int const angle = Gv_GetVarX(*insptr++);
int const xReturn = *insptr++; int const xReturn = *insptr++;
int const yReturn = *insptr++; int const yReturn = *insptr++;
vec2_t result; vec2_t result;
rotatepoint(point[0], point[1], angle, &result); rotatepoint(v.point[0], v.point[1], v.angle, &result);
Gv_SetVarX(xReturn, result.x); Gv_SetVarX(xReturn, result.x);
Gv_SetVarX(yReturn, result.y); Gv_SetVarX(yReturn, result.y);
@ -3332,28 +3304,33 @@ nullquote:
// int32_t neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size) // int32_t neartagrange, //Choose maximum distance to scan (scale: 1024=largest grid size)
// char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag // char tagsearch) //1-lotag only, 2-hitag only, 3-lotag&hitag
struct {
vec3_t point; vec3_t point;
Gv_GetManyVars(3, (int32_t *)&point); int32_t sectNum, nAngle;
int const sectNum = Gv_GetVarX(*insptr++); } v;
int const nAngle = Gv_GetVarX(*insptr++); Gv_FillWithVars(v);
int const sectReturn = *insptr++; int const sectReturn = *insptr++;
int const wallReturn = *insptr++; int const wallReturn = *insptr++;
int const spriteReturn = *insptr++; int const spriteReturn = *insptr++;
int const distReturn = *insptr++; int const distReturn = *insptr++;
int const tagRange = Gv_GetVarX(*insptr++);
int const tagSearch = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors)) struct {
int32_t tagRange, tagSearch;
} v2;
Gv_FillWithVars(v2);
if (EDUKE32_PREDICT_FALSE((unsigned)v.sectNum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector %d\n", sectNum); CON_ERRPRINTF("Invalid sector %d\n", v.sectNum);
continue; continue;
} }
int16_t neartagsector, neartagwall, neartagsprite; int16_t neartagsector, neartagwall, neartagsprite;
int32_t neartaghitdist; int32_t neartaghitdist;
neartag(point.x, point.y, point.z, sectNum, nAngle, &neartagsector, &neartagwall, &neartagsprite, neartag(v.point.x, v.point.y, v.point.z, v.sectNum, v.nAngle, &neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, tagRange, tagSearch, NULL); &neartaghitdist, v2.tagRange, v2.tagSearch, NULL);
Gv_SetVarX(sectReturn, neartagsector); Gv_SetVarX(sectReturn, neartagsector);
Gv_SetVarX(wallReturn, neartagwall); Gv_SetVarX(wallReturn, neartagwall);
@ -3377,38 +3354,39 @@ nullquote:
case CON_MOVESPRITE: case CON_MOVESPRITE:
insptr++; insptr++;
{ {
int const spriteNum = Gv_GetVarX(*insptr++); struct {
int32_t spriteNum;
vec3_t vect; vec3_t vect;
int32_t clipType;
} v;
Gv_FillWithVars(v);
Gv_GetManyVars(3, (int32_t *)&vect); if (EDUKE32_PREDICT_FALSE((unsigned)v.spriteNum >= MAXSPRITES))
int const clipType = Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum); CON_ERRPRINTF("invalid sprite ID %d\n", v.spriteNum);
insptr++; insptr++;
continue; continue;
} }
Gv_SetVarX(*insptr++, A_MoveSprite(spriteNum, &vect, clipType)); Gv_SetVarX(*insptr++, A_MoveSprite(v.spriteNum, &v.vect, v.clipType));
continue; continue;
} }
case CON_SETSPRITE: case CON_SETSPRITE:
insptr++; insptr++;
{ {
int const spriteNum = Gv_GetVarX(*insptr++); struct {
int32_t spriteNum;
vec3_t vect; vec3_t vect;
} v;
Gv_FillWithVars(v);
Gv_GetManyVars(3, (int32_t *)&vect); if (EDUKE32_PREDICT_FALSE((unsigned)v.spriteNum >= MAXSPRITES))
if (EDUKE32_PREDICT_FALSE((unsigned)spriteNum >= MAXSPRITES))
{ {
CON_ERRPRINTF("invalid sprite ID %d\n", spriteNum); CON_ERRPRINTF("invalid sprite ID %d\n", v.spriteNum);
continue; continue;
} }
setsprite(spriteNum, &vect); setsprite(v.spriteNum, &v.vect);
continue; continue;
} }
@ -3416,19 +3394,19 @@ nullquote:
case CON_GETCEILZOFSLOPE: case CON_GETCEILZOFSLOPE:
insptr++; insptr++;
{ {
int const sectNum = Gv_GetVarX(*insptr++); struct {
int32_t sectNum;
vec2_t vect; vec2_t vect;
Gv_GetManyVars(2, (int32_t *)&vect); } v;
Gv_FillWithVars(v);
if (EDUKE32_PREDICT_FALSE((unsigned)sectNum >= (unsigned)numsectors)) if (EDUKE32_PREDICT_FALSE((unsigned)v.sectNum >= (unsigned)numsectors))
{ {
CON_ERRPRINTF("Invalid sector %d\n", sectNum); CON_ERRPRINTF("Invalid sector %d\n", v.sectNum);
insptr++; insptr++;
continue; continue;
} }
Gv_SetVarX(*insptr++, (tw == CON_GETFLORZOFSLOPE ? getflorzofslope : getceilzofslope)(v.sectNum, v.vect.x, v.vect.y));
Gv_SetVarX(*insptr++, (tw == CON_GETFLORZOFSLOPE) ? getflorzofslope(sectNum, vect.x, vect.y) :
getceilzofslope(sectNum, vect.x, vect.y));
continue; continue;
} }
@ -3436,7 +3414,7 @@ nullquote:
insptr++; insptr++;
{ {
vec2_t vect = { 0, 0 }; vec2_t vect = { 0, 0 };
Gv_GetManyVars(2, (int32_t *)&vect); Gv_FillWithVars(vect);
int const returnVar = *insptr++; int const returnVar = *insptr++;
int16_t sectNum = sprite[vm.spriteNum].sectnum; int16_t sectNum = sprite[vm.spriteNum].sectnum;
@ -3450,7 +3428,7 @@ nullquote:
insptr++; insptr++;
{ {
vec3_t vect = { 0, 0, 0 }; vec3_t vect = { 0, 0, 0 };
Gv_GetManyVars(3, (int32_t *)&vect); Gv_FillWithVars(vect);
int const returnVar = *insptr++; int const returnVar = *insptr++;
int16_t sectNum = sprite[vm.spriteNum].sectnum; int16_t sectNum = sprite[vm.spriteNum].sectnum;
@ -3620,7 +3598,7 @@ nullquote:
insptr++; insptr++;
{ {
int32_t params[5]; int32_t params[5];
Gv_GetManyVars(5, params); Gv_FillWithVars(params);
A_RadiusDamage(vm.spriteNum, params[0], params[1], params[2], params[3], params[4]); A_RadiusDamage(vm.spriteNum, params[0], params[1], params[2], params[3], params[4]);
} }
continue; continue;
@ -4921,7 +4899,7 @@ finish_qsprintf:
int32_t index; int32_t index;
} v; } v;
Gv_GetManyVars(sizeof(v)/sizeof(int32_t), (int32_t *)&v); Gv_FillWithVars(v);
drawline256(v.pos[0].x, v.pos[0].y, v.pos[1].x, v.pos[1].y, v.index); drawline256(v.pos[0].x, v.pos[0].y, v.pos[1].x, v.pos[1].y, v.index);
} }
@ -4935,7 +4913,7 @@ finish_qsprintf:
int32_t index, rgb; int32_t index, rgb;
} v; } v;
Gv_GetManyVars(sizeof(v)/sizeof(int32_t), (int32_t *)&v); Gv_FillWithVars(v);
palette_t const p = { (uint8_t)(v.rgb & 0xFF), (uint8_t)((v.rgb >> 8) & 0xFF), (uint8_t)((v.rgb >> 16) & 0xFF), (uint8_t)v.index }; palette_t const p = { (uint8_t)(v.rgb & 0xFF), (uint8_t)((v.rgb >> 8) & 0xFF), (uint8_t)((v.rgb >> 16) & 0xFF), (uint8_t)v.index };

View file

@ -107,6 +107,14 @@ int __fastcall Gv_GetVarX(int id);
void __fastcall Gv_GetManyVars(int const count, int32_t * const rv); void __fastcall Gv_GetManyVars(int const count, int32_t * const rv);
void __fastcall Gv_SetVarX(int const id, int const lValue); void __fastcall Gv_SetVarX(int const id, int const lValue);
template <typename T>
static FORCE_INLINE void Gv_FillWithVars(T & rv)
{
EDUKE32_STATIC_ASSERT(sizeof(T) % sizeof(int32_t) == 0);
EDUKE32_STATIC_ASSERT(sizeof(T) > sizeof(int32_t));
Gv_GetManyVars(sizeof(T)/sizeof(int32_t), (int32_t *)&rv);
}
int Gv_GetVarByLabel(const char *szGameLabel,int const lDefault,int const spriteNum,int const playerNum); int Gv_GetVarByLabel(const char *szGameLabel,int const lDefault,int const spriteNum,int const playerNum);
int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags); int32_t Gv_NewArray(const char *pszLabel,void *arrayptr,intptr_t asize,uint32_t dwFlags);
int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags); int32_t Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);