LunaCON: showview and showviewunbiased.

git-svn-id: https://svn.eduke32.com/eduke32@3861 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-06-07 14:26:32 +00:00
parent 5e5f80d61b
commit 16b3cb6a42
6 changed files with 133 additions and 75 deletions

View file

@ -1062,6 +1062,85 @@ int32_t G_StartTrack(int32_t level)
return 1;
}
LUNATIC_EXTERN void G_ShowView(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t sect,
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp)
{
int32_t smoothratio = calc_smoothratio(totalclock, ototalclock);
#ifdef USE_OPENGL
int32_t oprojhacks;
#endif
if (g_screenCapture)
return;
if (offscreenrendering)
{
clearview(0);
return;
}
if (x1 > x2) swaplong(&x1,&x2);
if (y1 > y2) swaplong(&y1,&y2);
if (!unbiasedp)
{
// The showview command has a rounding bias towards zero,
// e.g. floor((319*1680)/320) == 1674
x1 = scale(x1,xdim,320);
y1 = scale(y1,ydim,200);
x2 = scale(x2,xdim,320);
y2 = scale(y2,ydim,200);
}
else
{
// This will map the maximum 320-based coordinate to the
// maximum real screen coordinate:
// floor((319*1679)/319) == 1679
x1 = scale(x1,xdim-1,319);
y1 = scale(y1,ydim-1,199);
x2 = scale(x2,xdim-1,319);
y2 = scale(y2,ydim-1,199);
}
horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX);
#ifdef USE_OPENGL
oprojhacks = glprojectionhacks;
glprojectionhacks = 0;
#endif
{
int32_t o = newaspect_enable;
newaspect_enable = r_usenewaspect;
setaspect_new_use_dimen = 1;
setview(x1,y1,x2,y2);
setaspect_new_use_dimen = 0;
newaspect_enable = o;
}
G_DoInterpolations(smoothratio);
G_HandleMirror(x, y, z, a, horiz, smoothratio);
#ifdef POLYMER
if (getrendermode() == REND_POLYMER)
polymer_setanimatesprites(G_DoSpriteAnimations, x,y,a,smoothratio);
#endif
yax_preparedrawrooms();
drawrooms(x,y,z,a,horiz,sect);
yax_drawrooms(G_DoSpriteAnimations, sect, 0, smoothratio);
display_mirror = 2;
G_DoSpriteAnimations(x,y,a,smoothratio);
display_mirror = 0;
drawmasks();
G_RestoreInterpolations();
G_UpdateScreenArea();
#ifdef USE_OPENGL
glprojectionhacks = oprojhacks;
#endif
}
#if !defined LUNATIC
GAMEEXEC_STATIC void VM_Execute(int32_t loop)
{
@ -2592,90 +2671,21 @@ nullquote:
int32_t y1=Gv_GetVarX(*insptr++);
int32_t x2=Gv_GetVarX(*insptr++);
int32_t y2=Gv_GetVarX(*insptr++);
int32_t smoothratio = calc_smoothratio(totalclock, ototalclock);
#ifdef USE_OPENGL
int32_t oprojhacks;
#endif
if (g_screenCapture) continue;
if (offscreenrendering)
{
clearview(0);
continue;
}
if (x1 > x2) swaplong(&x1,&x2);
if (y1 > y2) swaplong(&y1,&y2);
if (tw == CON_SHOWVIEW)
{
// The showview command has a rounding bias towards zero,
// e.g. floor((319*1680)/320) == 1674
x1 = scale(x1,xdim,320);
y1 = scale(y1,ydim,200);
x2 = scale(x2,xdim,320);
y2 = scale(y2,ydim,200);
}
else
{
// This will map the maximum 320-based coordinate to the
// maximum real screen coordinate:
// floor((319*1679)/319) == 1679
x1 = scale(x1,xdim-1,319);
y1 = scale(y1,ydim-1,199);
x2 = scale(x2,xdim-1,319);
y2 = scale(y2,ydim-1,199);
}
if ((x1 < 0 || y1 < 0 || x2 >= xdim || y2 >= ydim))
if (x1 < 0 || y1 < 0 || x2 >= 320 || y2 >= 200)
{
CON_ERRPRINTF("incorrect coordinates\n");
continue;
}
if ((unsigned)sect >= (unsigned)numsectors)
{
CON_ERRPRINTF("Invalid sector %d\n", sect);
continue;
}
horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX);
G_ShowView(x, y, z, a, horiz, sect, x1, y1, x2, y2, (tw != CON_SHOWVIEW));
#ifdef USE_OPENGL
oprojhacks = glprojectionhacks;
glprojectionhacks = 0;
#endif
{
int32_t o = newaspect_enable;
newaspect_enable = r_usenewaspect;
setaspect_new_use_dimen = 1;
setview(x1,y1,x2,y2);
setaspect_new_use_dimen = 0;
newaspect_enable = o;
}
G_DoInterpolations(smoothratio);
G_HandleMirror(x, y, z, a, horiz, smoothratio);
#ifdef POLYMER
if (getrendermode() == REND_POLYMER)
polymer_setanimatesprites(G_DoSpriteAnimations, x,y,a,smoothratio);
#endif
yax_preparedrawrooms();
drawrooms(x,y,z,a,horiz,sect);
yax_drawrooms(G_DoSpriteAnimations, sect, 0, smoothratio);
display_mirror = 2;
G_DoSpriteAnimations(x,y,a,smoothratio);
display_mirror = 0;
drawmasks();
G_RestoreInterpolations();
G_UpdateScreenArea();
#ifdef USE_OPENGL
glprojectionhacks = oprojhacks;
#endif
continue;
}

View file

@ -835,6 +835,16 @@ function _qstrdim(tilenum, x, y, z, blockangle, q, orientation,
return dim.x, dim.y
end
function _showview(x, y, z, a, horiz, sect, x1, y1, x2, y2, unbiasedp)
check_sector_idx(sect)
if (x1 < 0 or y1 < 0 or x2 >= 320 or y2 >= 200 or x2 < x1 or y2 < y1) then
local str = format("(%d,%d)--(%d,%d)", x1, y1, x2, y2)
error("invalid coordinates "..str, 2)
end
ffiC.G_ShowView(x, y, z, a, horiz, sect, x1, y1, x2, y2, unbiasedp);
end
local D = {
-- TODO: dynamic tile remapping

View file

@ -651,7 +651,6 @@ void G_DrawTXDigiNumZ(int32_t starttile, int32_t x,int32_t y,int32_t n,int32_t s
int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const char *t,
int32_t s, int32_t p, int32_t o,
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t z);
typedef struct {
int32_t x, y;
} vec2_t;
@ -666,6 +665,8 @@ vec2_t G_ScreenTextSize(const int32_t font,
int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween,
const int32_t f,
int32_t x1, int32_t y1, int32_t x2, int32_t y2);
void G_ShowView(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t sect,
int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp);
void G_SaveMapState(void);
void G_RestoreMapState(void);

View file

@ -209,6 +209,9 @@ S_ChangeSoundPitch;
minitext_;
G_DrawTXDigiNumZ;
G_PrintGameText;
G_ScreenText;
G_ScreenTextSize;
G_ShowView;
G_SaveMapState;
G_RestoreMapState;

View file

@ -2469,9 +2469,9 @@ local Cinner = {
setaspect = cmd(R,R)
/ "_con._setaspect(%1,%2)",
showview = cmd(R,R,R,R,R,R,R,R,R,R) -- 10R
/ "", -- TODO
/ function(...) return format("_con._showview("..n_s_fmt(10)..",0)", ...) end,
showviewunbiased = cmd(R,R,R,R,R,R,R,R,R,R) -- 10R
/ "", -- TODO
/ function(...) return format("_con._showview("..n_s_fmt(10)..",1)", ...) end,
smaxammo = cmd(R,R)
/ PLS".max_ammo_amount[%1]=%2",
gmaxammo = cmd(R,W)

View file

@ -58,3 +58,37 @@ onevent EVENT_DISPLAYREST
rotatesprite 160 70 zoom 0 SPINNINGNUKEICON 0 0 0 windowx1 windowy1 windowx2 windowy2
endevent
// Following code from the wiki 'showview' entry, with modifications
gamevar x 0 0
gamevar y 0 0
gamevar z 0 0
gamevar ang 0 0
gamevar horiz 0 0
gamevar temp 0 0
gamevar sect 0 0
onevent EVENT_DISPLAYREST
getplayer[THISACTOR].posx x
getplayer[THISACTOR].posy y
getplayer[THISACTOR].posz z
getplayer[THISACTOR].ang ang
getplayer[THISACTOR].horiz horiz
getplayer[THISACTOR].horizoff temp
addvarvar horiz temp
// Head cam.
subvar z 16384
updatesectorz x y z sect
// This upper view should be a bit wider.
ifvarg sect -1
showviewunbiased x y z ang horiz sect 16 8 156 39
// Groin cam.
addvar z 16384
addvar z 4096
updatesectorz x y z sect
ifvarg sect -1
showview x y z ang horiz sect 16 39 156 70
endevent