From ee37c0462370e4f34e6d191e4835c5e297f259d7 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 7 Mar 2018 12:02:03 +0000 Subject: [PATCH] Remove attempt at being compatible with the original ranges of ang and horiz values, and introduce a q16 version of drawrooms (and showroom) git-svn-id: https://svn.eduke32.com/eduke32@6735 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/build.h | 5 +++-- source/build/src/engine.cpp | 22 +++++++++++----------- source/build/src/polymost.cpp | 4 ++-- source/duke3d/src/game.cpp | 10 +++++----- source/duke3d/src/gamedef.cpp | 4 ++++ source/duke3d/src/gamedef.h | 2 ++ source/duke3d/src/gameexec.cpp | 21 +++++++++++---------- source/duke3d/src/gameexec.h | 2 +- 8 files changed, 39 insertions(+), 31 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index b9e3da4b5..f64a14884 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -1069,8 +1069,9 @@ void preparemirror(int32_t dax, int32_t day, fix16_t daang, int16_t dawall, int32_t *tposx, int32_t *tposy, fix16_t *tang); void completemirror(void); -int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, - fix16_t daang, fix16_t dahoriz, int16_t dacursectnum); +int32_t drawrooms_q16(int32_t daposx, int32_t daposy, int32_t daposz, fix16_t daang, fix16_t dahoriz, int16_t dacursectnum); +int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int16_t dahoriz, int16_t dacursectnum); + void drawmasks(void); void clearview(int32_t dacol); void clearallviews(int32_t dacol); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index ded4b866e..10776bc0c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -980,7 +980,7 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), int32_t odsprcnt = yax_spritesortcnt[yax_globallev]; #endif // +MAXSECTORS: force - drawrooms(globalposx,globalposy,globalposz,globalang,horiz,k+MAXSECTORS); + drawrooms_q16(globalposx,globalposy,globalposz,qglobalang,horiz,k+MAXSECTORS); if (numhere > 1) for (i=0; i<(numsectors+7)>>3; i++) lgotsector[i] |= gotsector[i]; @@ -1058,7 +1058,7 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), for (nmp=r_tror_nomaskpass; nmp>=0; nmp--) { yax_nomaskpass = nmp; - drawrooms(globalposx,globalposy,globalposz,globalang,horiz,k+MAXSECTORS); // +MAXSECTORS: force + drawrooms_q16(globalposx,globalposy,globalposz,qglobalang,horiz,k+MAXSECTORS); // +MAXSECTORS: force if (nmp==1) { @@ -1101,7 +1101,7 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), scansector_collectsprites = 0; // draw base level - drawrooms(globalposx,globalposy,globalposz,globalang,horiz, + drawrooms_q16(globalposx,globalposy,globalposz,qglobalang,horiz, osectnum + MAXSECTORS*didmirror); // if (scansector_collectsprites) // spritesortcnt = 0; @@ -7919,7 +7919,14 @@ void set_globalang(fix16_t ang) // // drawrooms // + int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, + int16_t daang, int16_t dahoriz, int16_t dacursectnum) +{ + return drawrooms_q16(daposx, daposy, daposz, fix16_from_int(daang), fix16_from_int(dahoriz), dacursectnum); +} + +int32_t drawrooms_q16(int32_t daposx, int32_t daposy, int32_t daposz, fix16_t daang, fix16_t dahoriz, int16_t dacursectnum) { int32_t i, j, /*cz, fz,*/ closest; @@ -7930,15 +7937,8 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, beforedrawrooms = 0; set_globalpos(daposx, daposy, daposz); - - // support the old range of values - if ((dahoriz & 0xFFFF0000) == 0) - dahoriz = fix16_from_int(dahoriz); - - if ((daang & 0xFFFF0000) == 0) - daang = fix16_from_int(daang); - set_globalang(daang); + global100horiz = dahoriz; // xdimenscale is scale(xdimen,yxaspect,320); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index 99da60351..5f25f12e4 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -5998,8 +5998,8 @@ void polymost_drawsprite(int32_t snum) float const ft[4] = { ((float)(globalposy - vv.y)) * ff.y + ((float)(globalposx - vv.x)) * ff.x, ((float)(globalposx - vv.x)) * ff.y - ((float)(globalposy - vv.y)) * ff.x, - singlobalang * ff.y + cosglobalang * ff.x, - singlobalang * ff.x - cosglobalang * ff.y }; + fsinglobalang * ff.y + fcosglobalang * ff.x, + fsinglobalang * ff.x - fcosglobalang * ff.y }; f = fviewingrange * -(1.f / (65536.f * 262144.f)); xtex.u = (float)ft[3] * f; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 9176de047..83898e794 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -521,7 +521,7 @@ static void G_SE40(int32_t smoothratio) if (getrendermode() == REND_POLYMER) polymer_setanimatesprites(G_DoSpriteAnimations, CAMERA(pos.x), CAMERA(pos.y), fix16_to_int(CAMERA(q16ang)), smoothratio); #endif - drawrooms(sprite[sprite2].x + x, sprite[sprite2].y + y, + drawrooms_q16(sprite[sprite2].x + x, sprite[sprite2].y + y, z + renderz, CAMERA(q16ang), CAMERA(q16horiz), sect); drawing_ror = 1 + level; @@ -616,12 +616,12 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz int32_t didmirror; yax_preparedrawrooms(); - didmirror = drawrooms(tposx,tposy,z,tang,q16horiz,g_mirrorSector[i]+MAXSECTORS); + didmirror = drawrooms_q16(tposx,tposy,z,tang,q16horiz,g_mirrorSector[i]+MAXSECTORS); yax_drawrooms(G_DoSpriteAnimations, g_mirrorSector[i], didmirror, smoothratio); } #ifdef USE_OPENGL else - drawrooms(tposx,tposy,z,tang,q16horiz,g_mirrorSector[i]+MAXSECTORS); + drawrooms_q16(tposx,tposy,z,tang,q16horiz,g_mirrorSector[i]+MAXSECTORS); // XXX: Sprites don't get drawn with TROR/Polymost #endif display_mirror = 1; @@ -759,7 +759,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) polymer_setanimatesprites(G_DoSpriteAnimations, pSprite->x, pSprite->y, fix16_to_int(CAMERA(q16ang)), smoothRatio); #endif yax_preparedrawrooms(); - drawrooms(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, CAMERA(q16ang), pSprite->yvel, pSprite->sectnum); + drawrooms_q16(pSprite->x, pSprite->y, pSprite->z - ZOFFSET6, CAMERA(q16ang), fix16_from_int(pSprite->yvel), pSprite->sectnum); yax_drawrooms(G_DoSpriteAnimations, pSprite->sectnum, 0, smoothRatio); G_DoSpriteAnimations(pSprite->x, pSprite->y, fix16_to_int(CAMERA(q16ang)), smoothRatio); drawmasks(); @@ -1030,7 +1030,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) gotpic[MIRROR>>3] |= (1<<(MIRROR&7)); #else yax_preparedrawrooms(); - drawrooms(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),CAMERA(sect)); + drawrooms_q16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),CAMERA(sect)); yax_drawrooms(G_DoSpriteAnimations, CAMERA(sect), 0, smoothRatio); #ifdef LEGACY_ROR if ((unsigned)ror_sprite < MAXSPRITES && drawing_ror == 1) // viewing from bottom diff --git a/source/duke3d/src/gamedef.cpp b/source/duke3d/src/gamedef.cpp index a8e9603b6..cfc154e94 100644 --- a/source/duke3d/src/gamedef.cpp +++ b/source/duke3d/src/gamedef.cpp @@ -465,6 +465,8 @@ static tokenmap_t const vm_keywords[] = { "shootvar", CON_SHOOTVAR }, { "showview", CON_SHOWVIEW }, { "showviewunbiased", CON_SHOWVIEWUNBIASED }, + { "showviewq16", CON_SHOWVIEWQ16 }, + { "showviewq16unbiased", CON_SHOWVIEWQ16UNBIASED }, { "sin", CON_SIN }, { "sizeat", CON_SIZEAT }, { "sizeto", CON_SIZETO }, @@ -4819,6 +4821,8 @@ DO_DEFSTATE: case CON_SHOWVIEW: case CON_SHOWVIEWUNBIASED: + case CON_SHOWVIEWQ16: + case CON_SHOWVIEWQ16UNBIASED: if (EDUKE32_PREDICT_FALSE(!g_parsingEventPtr && g_processingState == 0)) { C_ReportError(ERROR_EVENTONLY); diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index c0bbad26b..66e4e5bbb 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -1228,6 +1228,8 @@ enum ScriptKeywords_t CON_IFVARBE, // 422 CON_IFVARVARBE, // 423 CON_UNDEFINECHEAT, // 424 + CON_SHOWVIEWQ16, // 425 + CON_SHOWVIEWQ16UNBIASED,// 426 CON_END }; // KEEPINSYNC with the keyword list in lunatic/con_lang.lua diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index f4f0618ba..e9fb9b4b2 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1176,7 +1176,7 @@ int G_StartTrack(int const levelNum) } #endif -LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, +LUNATIC_EXTERN void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int32_t sect, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp) { if (g_screenCapture) @@ -1211,13 +1211,6 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec y2 = scale(y2,ydim-1,199); } - // 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; @@ -1235,7 +1228,7 @@ LUNATIC_EXTERN void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sec polymer_setanimatesprites(G_DoSpriteAnimations, vec.x, vec.y, fix16_to_int(a), smoothratio); #endif yax_preparedrawrooms(); - drawrooms(vec.x, vec.y, vec.z, a, horiz, sect); + drawrooms_q16(vec.x, vec.y, vec.z, a, horiz, sect); yax_drawrooms(G_DoSpriteAnimations, sect, 0, smoothratio); display_mirror = 2; @@ -2872,6 +2865,8 @@ nullquote: case CON_SHOWVIEW: case CON_SHOWVIEWUNBIASED: + case CON_SHOWVIEWQ16: + case CON_SHOWVIEWQ16UNBIASED: insptr++; { struct { @@ -2893,7 +2888,13 @@ nullquote: continue; } - 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)); + if (tw != CON_SHOWVIEWQ16 && tw != CON_SHOWVIEWQ16UNBIASED) + { + v.params[0] <<= 16; + v.params[1] <<= 16; + } + + 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 && tw != CON_SHOWVIEWQ16)); continue; } diff --git a/source/duke3d/src/gameexec.h b/source/duke3d/src/gameexec.h index 86a93ce09..d2d2e8622 100644 --- a/source/duke3d/src/gameexec.h +++ b/source/duke3d/src/gameexec.h @@ -111,7 +111,7 @@ static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNu void G_GetTimeDate(int32_t * const pValues); int G_StartTrack(int const levelNum); #ifdef LUNATIC -void G_ShowView(vec3_t vec, int32_t a, int32_t horiz, int32_t sect, +void G_ShowView(vec3_t vec, fix16_t a, fix16_t horiz, int32_t sect, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t unbiasedp); void P_AddWeaponMaybeSwitchI(int32_t snum, int32_t weap); void VM_FallSprite(int32_t i);