Fix up CON to work with Q16.16 values

git-svn-id: https://svn.eduke32.com/eduke32@6727 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-03-07 04:21:31 +00:00
parent 5f13160dd6
commit 3b6bb3b7a3
5 changed files with 68 additions and 24 deletions

View file

@ -371,7 +371,7 @@ void G_DisplayRest(int32_t smoothratio);
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio); void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio);
void G_DrawBackground(void); void G_DrawBackground(void);
void G_DrawFrags(void); void G_DrawFrags(void);
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, fix16_t horiz, int32_t smoothratio); void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t horiz, int32_t smoothratio);
void G_DrawRooms(int32_t snum,int32_t smoothratio); void G_DrawRooms(int32_t snum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
int G_FPSLimit(void); int G_FPSLimit(void);

View file

@ -1211,7 +1211,14 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec
y2 = scale(y2,ydim-1,199); y2 = scale(y2,ydim-1,199);
} }
horiz = clamp(horiz, HORIZ_MIN, HORIZ_MAX); // support the old range of values
if ((horiz & 0xFFFF0000) == 0)
horiz = fix16_from_int(horiz);
if ((a & 0xFFFF0000) == 0)
a = fix16_from_int(a);
horiz = fix16_clamp(horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
int const onewaspect = newaspect_enable; int const onewaspect = newaspect_enable;
newaspect_enable = r_usenewaspect; newaspect_enable = r_usenewaspect;
@ -1225,14 +1232,14 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec
G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio); G_HandleMirror(vec.x, vec.y, vec.z, a, horiz, smoothratio);
#ifdef POLYMER #ifdef POLYMER
if (getrendermode() == REND_POLYMER) if (getrendermode() == REND_POLYMER)
polymer_setanimatesprites(G_DoSpriteAnimations, vec.x,vec.y,a,smoothratio); polymer_setanimatesprites(G_DoSpriteAnimations, vec.x, vec.y, fix16_to_int(a), smoothratio);
#endif #endif
yax_preparedrawrooms(); yax_preparedrawrooms();
drawrooms(vec.x,vec.y,vec.z,a,horiz,sect); drawrooms(vec.x, vec.y, vec.z, a, horiz, sect);
yax_drawrooms(G_DoSpriteAnimations, sect, 0, smoothratio); yax_drawrooms(G_DoSpriteAnimations, sect, 0, smoothratio);
display_mirror = 2; display_mirror = 2;
G_DoSpriteAnimations(vec.x,vec.y,a,smoothratio); G_DoSpriteAnimations(vec.x, vec.y, fix16_to_int(a), smoothratio);
display_mirror = 0; display_mirror = 0;
drawmasks(); drawmasks();
G_RestoreInterpolations(); G_RestoreInterpolations();

View file

@ -652,6 +652,10 @@ int __fastcall Gv_GetVar(int gameVar, int spriteNum, int playerNum)
case GAMEVAR_INT32PTR: returnValue = *(int32_t *)aGameVars[gameVar].global; break; case GAMEVAR_INT32PTR: returnValue = *(int32_t *)aGameVars[gameVar].global; break;
case GAMEVAR_INT16PTR: returnValue = *(int16_t *)aGameVars[gameVar].global; break; case GAMEVAR_INT16PTR: returnValue = *(int16_t *)aGameVars[gameVar].global; break;
case GAMEVAR_UINT8PTR: returnValue = *(char *)aGameVars[gameVar].global; break; case GAMEVAR_UINT8PTR: returnValue = *(char *)aGameVars[gameVar].global; break;
case GAMEVAR_Q16PTR:
returnValue = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
break;
default: EDUKE32_UNREACHABLE_SECTION(returnValue = 0; break); default: EDUKE32_UNREACHABLE_SECTION(returnValue = 0; break);
} }
@ -806,6 +810,10 @@ void __fastcall Gv_SetVar(int const gameVar, int const newValue, int const sprit
case GAMEVAR_INT32PTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break; case GAMEVAR_INT32PTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break;
case GAMEVAR_INT16PTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break; case GAMEVAR_INT16PTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break;
case GAMEVAR_UINT8PTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break; case GAMEVAR_UINT8PTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break;
case GAMEVAR_Q16PTR:
*(fix16_t *)aGameVars[gameVar].global
= aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue);
break;
} }
} }
return; return;
@ -1001,9 +1009,13 @@ int __fastcall Gv_GetVarX(int gameVar)
returnValue = aGameVars[gameVar].pValues[vm.spriteNum]; returnValue = aGameVars[gameVar].pValues[vm.spriteNum];
else switch (varFlags) else switch (varFlags)
{ {
case GAMEVAR_INT32PTR: returnValue = (*((int32_t *)aGameVars[gameVar].global)); break; case GAMEVAR_INT32PTR: returnValue = (*(int32_t *)aGameVars[gameVar].global); break;
case GAMEVAR_INT16PTR: returnValue = (*((int16_t *)aGameVars[gameVar].global)); break; case GAMEVAR_INT16PTR: returnValue = (*(int16_t *)aGameVars[gameVar].global); break;
case GAMEVAR_UINT8PTR: returnValue = (*((uint8_t *)aGameVars[gameVar].global)); break; case GAMEVAR_UINT8PTR: returnValue = (*(uint8_t *)aGameVars[gameVar].global); break;
case GAMEVAR_Q16PTR:
returnValue = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
break;
} }
} }
@ -1057,9 +1069,13 @@ void __fastcall Gv_GetManyVars(int const numVars, int32_t * const outBuf)
{ {
switch (varFlags) switch (varFlags)
{ {
case GAMEVAR_INT32PTR: value = (*((int32_t *)aGameVars[gameVar].global)); break; case GAMEVAR_INT32PTR: value = *(int32_t *)aGameVars[gameVar].global; break;
case GAMEVAR_INT16PTR: value = (*((int16_t *)aGameVars[gameVar].global)); break; case GAMEVAR_INT16PTR: value = *(int16_t *)aGameVars[gameVar].global; break;
case GAMEVAR_UINT8PTR: value = (*((uint8_t *)aGameVars[gameVar].global)); break; case GAMEVAR_UINT8PTR: value = *(uint8_t *)aGameVars[gameVar].global; break;
case GAMEVAR_Q16PTR:
value = aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? *(int32_t *)aGameVars[gameVar].global
: fix16_to_int(*(fix16_t *)aGameVars[gameVar].global);
break;
} }
} }
@ -1088,9 +1104,13 @@ void __fastcall Gv_SetVarX(int const gameVar, int const newValue)
} }
else switch (varFlags) else switch (varFlags)
{ {
case GAMEVAR_INT32PTR: *((int32_t *)aGameVars[gameVar].global) = (int32_t)newValue; break; case GAMEVAR_INT32PTR: *(int32_t *)aGameVars[gameVar].global = (int32_t)newValue; break;
case GAMEVAR_INT16PTR: *((int16_t *)aGameVars[gameVar].global) = (int16_t)newValue; break; case GAMEVAR_INT16PTR: *(int16_t *)aGameVars[gameVar].global = (int16_t)newValue; break;
case GAMEVAR_UINT8PTR: *((uint8_t *)aGameVars[gameVar].global) = (uint8_t)newValue; break; case GAMEVAR_UINT8PTR: *(uint8_t *)aGameVars[gameVar].global = (uint8_t)newValue; break;
case GAMEVAR_Q16PTR:
*(fix16_t *)aGameVars[gameVar].global
= aGameVars[gameVar].flags & GAMEVAR_SPECIAL ? (int32_t)newValue : fix16_from_int((int16_t)newValue);
break;
} }
return; return;
@ -1543,8 +1563,10 @@ static void Gv_AddSystemVars(void)
Gv_NewVar("camerax",(intptr_t)&ud.camerapos.x, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("camerax",(intptr_t)&ud.camerapos.x, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR);
Gv_NewVar("cameray",(intptr_t)&ud.camerapos.y, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameray",(intptr_t)&ud.camerapos.y, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR);
Gv_NewVar("cameraz",(intptr_t)&ud.camerapos.z, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameraz",(intptr_t)&ud.camerapos.z, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR);
Gv_NewVar("cameraang",(intptr_t)&ud.cameraq16ang, GAMEVAR_SYSTEM | GAMEVAR_INT16PTR); // XXX FIXME Gv_NewVar("cameraang",(intptr_t)&ud.cameraq16ang, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR);
Gv_NewVar("camerahoriz",(intptr_t)&ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_INT16PTR); // XXX FIXME Gv_NewVar("camerahoriz",(intptr_t)&ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR);
Gv_NewVar("cameraq16ang", (intptr_t) &ud.cameraq16ang, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR | GAMEVAR_SPECIAL);
Gv_NewVar("cameraq16horiz", (intptr_t) &ud.cameraq16horiz, GAMEVAR_SYSTEM | GAMEVAR_Q16PTR | GAMEVAR_SPECIAL);
Gv_NewVar("camerasect",(intptr_t)&ud.camerasect, GAMEVAR_SYSTEM | GAMEVAR_INT16PTR); Gv_NewVar("camerasect",(intptr_t)&ud.camerasect, GAMEVAR_SYSTEM | GAMEVAR_INT16PTR);
Gv_NewVar("cameradist",(intptr_t)&g_cameraDistance, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameradist",(intptr_t)&g_cameraDistance, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR);
Gv_NewVar("cameraclock",(intptr_t)&g_cameraClock, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR); Gv_NewVar("cameraclock",(intptr_t)&g_cameraClock, GAMEVAR_SYSTEM | GAMEVAR_INT32PTR);
@ -1702,6 +1724,8 @@ void Gv_RefreshPointers(void)
aGameVars[Gv_GetVarIndex("cameraz")].global = (intptr_t)&ud.camerapos.z; aGameVars[Gv_GetVarIndex("cameraz")].global = (intptr_t)&ud.camerapos.z;
aGameVars[Gv_GetVarIndex("cameraang")].global = (intptr_t)&ud.cameraq16ang; // XXX FIXME aGameVars[Gv_GetVarIndex("cameraang")].global = (intptr_t)&ud.cameraq16ang; // XXX FIXME
aGameVars[Gv_GetVarIndex("camerahoriz")].global = (intptr_t)&ud.cameraq16horiz; // XXX FIXME aGameVars[Gv_GetVarIndex("camerahoriz")].global = (intptr_t)&ud.cameraq16horiz; // XXX FIXME
aGameVars[Gv_GetVarIndex("cameraq16ang")].global = (intptr_t) &ud.cameraq16ang; // XXX FIXME
aGameVars[Gv_GetVarIndex("cameraq16horiz")].global = (intptr_t) &ud.cameraq16horiz; // XXX FIXME
aGameVars[Gv_GetVarIndex("camerasect")].global = (intptr_t)&ud.camerasect; aGameVars[Gv_GetVarIndex("camerasect")].global = (intptr_t)&ud.camerasect;
aGameVars[Gv_GetVarIndex("cameradist")].global = (intptr_t)&g_cameraDistance; aGameVars[Gv_GetVarIndex("cameradist")].global = (intptr_t)&g_cameraDistance;
aGameVars[Gv_GetVarIndex("cameraclock")].global = (intptr_t)&g_cameraClock; aGameVars[Gv_GetVarIndex("cameraclock")].global = (intptr_t)&g_cameraClock;

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define gamevars_h_ #define gamevars_h_
#include "gamedef.h" #include "gamedef.h"
#include "fix16.hpp"
#define MAXGAMEVARS 2048 // must be a power of two #define MAXGAMEVARS 2048 // must be a power of two
#define MAXVARLABEL 26 #define MAXVARLABEL 26
@ -42,10 +43,11 @@ enum GamevarFlags_t
GAMEVAR_INT32PTR = 0x00002000, // plValues is a pointer to an int32_t GAMEVAR_INT32PTR = 0x00002000, // plValues is a pointer to an int32_t
GAMEVAR_INT16PTR = 0x00008000, // plValues is a pointer to a short GAMEVAR_INT16PTR = 0x00008000, // plValues is a pointer to a short
GAMEVAR_UINT8PTR = 0x00010000, // plValues is a pointer to a char GAMEVAR_UINT8PTR = 0x00010000, // plValues is a pointer to a char
GAMEVAR_PTR_MASK = (GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_UINT8PTR),
GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state GAMEVAR_NORESET = 0x00020000, // var values are not reset when restoring map state
GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars GAMEVAR_SPECIAL = 0x00040000, // flag for structure member shortcut vars
GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets
GAMEVAR_Q16PTR = 0x00100000, // plValues is a pointer to a q16.16
GAMEVAR_PTR_MASK = (GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_UINT8PTR | GAMEVAR_Q16PTR),
}; };
#if !defined LUNATIC #if !defined LUNATIC
@ -172,9 +174,15 @@ void Gv_FinalizeWeaponDefaults(void);
break; \ break; \
aGameVars[id].pValues[vm.spriteNum] operator operand; \ aGameVars[id].pValues[vm.spriteNum] operator operand; \
break; \ break; \
case GAMEVAR_INT32PTR: *((int32_t *)aGameVars[id].global) operator(int32_t) operand; break; \ case GAMEVAR_INT32PTR: *(int32_t *)aGameVars[id].global operator(int32_t) operand; break; \
case GAMEVAR_INT16PTR: *((int16_t *)aGameVars[id].global) operator(int16_t) operand; break; \ case GAMEVAR_INT16PTR: *(int16_t *)aGameVars[id].global operator(int16_t) operand; break; \
case GAMEVAR_UINT8PTR: *((uint8_t *)aGameVars[id].global) operator(uint8_t) operand; break; \ case GAMEVAR_UINT8PTR: *(uint8_t *)aGameVars[id].global operator(uint8_t) operand; break; \
case GAMEVAR_Q16PTR: \
{ \
Fix16 *pfix = (Fix16 *)aGameVars[id].global; \
*pfix operator operand; \
break; \
} \
} \ } \
} }
@ -220,6 +228,12 @@ skip:
var = (uint8_t)libdivide_s32_do(var, dptr); var = (uint8_t)libdivide_s32_do(var, dptr);
return; return;
} }
case GAMEVAR_Q16PTR:
{
fix16_t & var = *(fix16_t *)aGameVars[id].global;
var = fix16_div(var, fix16_from_int(operand));
return;
}
} }
*iptr = libdivide_s32_do(*iptr, dptr); *iptr = libdivide_s32_do(*iptr, dptr);

View file

@ -1228,8 +1228,7 @@ static uint8_t *svdiff;
#include "gamedef.h" #include "gamedef.h"
#if !defined LUNATIC #if !defined LUNATIC
# define SV_SKIPMASK (/*GAMEVAR_SYSTEM|*/GAMEVAR_READONLY|GAMEVAR_INT32PTR| \ #define SV_SKIPMASK (/*GAMEVAR_SYSTEM|*/ GAMEVAR_READONLY | GAMEVAR_PTR_MASK | /*GAMEVAR_NORESET |*/ GAMEVAR_SPECIAL)
GAMEVAR_INT16PTR|GAMEVAR_UINT8PTR /*|GAMEVAR_NORESET*/ |GAMEVAR_SPECIAL)
static char svgm_vars_string [] = "blK:vars"; static char svgm_vars_string [] = "blK:vars";
// setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called // setup gamevar data spec for snapshotting and diffing... gamevars must be loaded when called