diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 22cb27ea5..fc8144b12 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -711,8 +711,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) { if (ud.screen_tilting) { - renderSetRollAngle(pPlayer->orotscrnang + mulscale16(((pPlayer->rotscrnang - pPlayer->orotscrnang + 1024)&2047)-1024, smoothRatio)); - pPlayer->orotscrnang = pPlayer->rotscrnang; + renderSetRollAngle(fix16_to_float(pPlayer->oq16rotscrnang + mulscale16(((pPlayer->q16rotscrnang - pPlayer->oq16rotscrnang + fix16_from_int(1024))&0x7FFFFFF)-fix16_from_int(1024), smoothRatio))); + pPlayer->oq16rotscrnang = pPlayer->q16rotscrnang; } else { diff --git a/source/duke3d/src/gamedef.h b/source/duke3d/src/gamedef.h index 855720c91..25857061b 100644 --- a/source/duke3d/src/gamedef.h +++ b/source/duke3d/src/gamedef.h @@ -334,6 +334,9 @@ enum PlayerLabel_t PLAYER_WEAPRECCNT, PLAYER_INTERFACE_TOGGLE, PLAYER_ROTSCRNANG, + PLAYER_OROTSCRNANG, + PLAYER_Q16ROTSCRNANG, + PLAYER_OQ16ROTSCRNANG, PLAYER_DEAD_FLAG, PLAYER_SHOW_EMPTY_WEAPON, PLAYER_SCUBA_AMOUNT, diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index ff941de1b..41d3579a6 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -295,8 +295,8 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *pPlayer) pPlayer->q16horiz += F16(64); pPlayer->return_to_center = 9; - pPlayer->rotscrnang = nAngle >> 1; - pPlayer->look_ang = pPlayer->rotscrnang; + pPlayer->q16rotscrnang = fix16_from_int(nAngle >> 1); + pPlayer->look_ang = fix16_to_int(pPlayer->q16rotscrnang); } #endif diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 6613a0c5e..b0fe2cf18 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -466,6 +466,9 @@ memberlabel_t const PlayerLabels[]= { "weapreccnt", PLAYER_WEAPRECCNT, 0, 0, -1 }, { "interface_toggle_flag", PLAYER_INTERFACE_TOGGLE, 0, 0, -1 }, { "rotscrnang", PLAYER_ROTSCRNANG, 0, 0, -1 }, + { "orotscrnang", PLAYER_OROTSCRNANG, 0, 0, -1 }, + { "q16rotscrnang", PLAYER_Q16ROTSCRNANG, 0, 0, -1 }, + { "oq16rotscrnang", PLAYER_OQ16ROTSCRNANG, 0, 0, -1 }, { "dead_flag", PLAYER_DEAD_FLAG, 0, 0, -1 }, { "show_empty_weapon", PLAYER_SHOW_EMPTY_WEAPON, 0, 0, -1 }, { "scuba_amount", PLAYER_SCUBA_AMOUNT, 0, 0, -1 }, @@ -549,21 +552,25 @@ int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const switch (labelNum) { - case PLAYER_ANG: labelNum = fix16_to_int(ps.q16ang); break; - case PLAYER_OANG: labelNum = fix16_to_int(ps.oq16ang); break; - case PLAYER_ANGVEL: labelNum = fix16_to_int(ps.q16angvel); break; - case PLAYER_HORIZ: labelNum = fix16_to_int(ps.q16horiz); break; - case PLAYER_OHORIZ: labelNum = fix16_to_int(ps.oq16horiz); break; - case PLAYER_HORIZOFF: labelNum = fix16_to_int(ps.q16horizoff); break; - case PLAYER_OHORIZOFF: labelNum = fix16_to_int(ps.oq16horizoff); break; + case PLAYER_ANG: labelNum = fix16_to_int(ps.q16ang); break; + case PLAYER_OANG: labelNum = fix16_to_int(ps.oq16ang); break; + case PLAYER_ANGVEL: labelNum = fix16_to_int(ps.q16angvel); break; + case PLAYER_HORIZ: labelNum = fix16_to_int(ps.q16horiz); break; + case PLAYER_OHORIZ: labelNum = fix16_to_int(ps.oq16horiz); break; + case PLAYER_HORIZOFF: labelNum = fix16_to_int(ps.q16horizoff); break; + case PLAYER_OHORIZOFF: labelNum = fix16_to_int(ps.oq16horizoff); break; + case PLAYER_ROTSCRNANG: labelNum = fix16_to_int(ps.q16rotscrnang); break; + case PLAYER_OROTSCRNANG: labelNum = fix16_to_int(ps.oq16rotscrnang); break; - case PLAYER_Q16ANG: labelNum = ps.q16ang; break; - case PLAYER_OQ16ANG: labelNum = ps.oq16ang; break; - case PLAYER_Q16ANGVEL: labelNum = ps.q16angvel; break; - case PLAYER_Q16HORIZ: labelNum = ps.q16horiz; break; - case PLAYER_OQ16HORIZ: labelNum = ps.oq16horiz; break; - case PLAYER_Q16HORIZOFF: labelNum = ps.q16horizoff; break; - case PLAYER_OQ16HORIZOFF: labelNum = ps.oq16horizoff; break; + case PLAYER_Q16ANG: labelNum = ps.q16ang; break; + case PLAYER_OQ16ANG: labelNum = ps.oq16ang; break; + case PLAYER_Q16ANGVEL: labelNum = ps.q16angvel; break; + case PLAYER_Q16HORIZ: labelNum = ps.q16horiz; break; + case PLAYER_OQ16HORIZ: labelNum = ps.oq16horiz; break; + case PLAYER_Q16HORIZOFF: labelNum = ps.q16horizoff; break; + case PLAYER_OQ16HORIZOFF: labelNum = ps.oq16horizoff; break; + case PLAYER_Q16ROTSCRNANG: labelNum = ps.q16rotscrnang; break; + case PLAYER_OQ16ROTSCRNANG: labelNum = ps.oq16rotscrnang; break; case PLAYER_ACCESS_INCS: labelNum = ps.access_incs; break; case PLAYER_ACCESS_SPRITENUM: labelNum = ps.access_spritenum; break; @@ -664,7 +671,6 @@ int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const case PLAYER_RAPID_FIRE_HOLD: labelNum = ps.rapid_fire_hold; break; case PLAYER_RELOADING: labelNum = ps.reloading; break; case PLAYER_RETURN_TO_CENTER: labelNum = ps.return_to_center; break; - case PLAYER_ROTSCRNANG: labelNum = ps.rotscrnang; break; case PLAYER_RUNSPEED: labelNum = ps.runspeed; break; case PLAYER_SBS: labelNum = ps.sbs; break; case PLAYER_SCREAM_VOICE: labelNum = ps.scream_voice; break; @@ -743,21 +749,25 @@ void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const switch (labelNum) { - case PLAYER_HORIZ: ps.q16horiz = fix16_from_int(newValue); break; - case PLAYER_OHORIZ: ps.oq16horiz = fix16_from_int(newValue); break; - case PLAYER_OHORIZOFF: ps.oq16horizoff = fix16_from_int(newValue); break; - case PLAYER_ANG: ps.q16ang = fix16_from_int(newValue); break; - case PLAYER_OANG: ps.oq16ang = fix16_from_int(newValue); break; - case PLAYER_ANGVEL: ps.q16angvel = fix16_from_int(newValue); break; - case PLAYER_HORIZOFF: ps.q16horizoff = fix16_from_int(newValue); break; + case PLAYER_HORIZ: ps.q16horiz = fix16_from_int(newValue); break; + case PLAYER_OHORIZ: ps.oq16horiz = fix16_from_int(newValue); break; + case PLAYER_OHORIZOFF: ps.oq16horizoff = fix16_from_int(newValue); break; + case PLAYER_ANG: ps.q16ang = fix16_from_int(newValue); break; + case PLAYER_OANG: ps.oq16ang = fix16_from_int(newValue); break; + case PLAYER_ANGVEL: ps.q16angvel = fix16_from_int(newValue); break; + case PLAYER_HORIZOFF: ps.q16horizoff = fix16_from_int(newValue); break; + case PLAYER_ROTSCRNANG: ps.q16rotscrnang = fix16_from_int(newValue); break; + case PLAYER_OROTSCRNANG: ps.oq16rotscrnang = fix16_from_int(newValue); break; - case PLAYER_Q16HORIZ: ps.q16horiz = newValue; break; - case PLAYER_OQ16HORIZ: ps.oq16horiz = newValue; break; - case PLAYER_OQ16HORIZOFF: ps.oq16horizoff = newValue; break; - case PLAYER_Q16ANG: ps.q16ang = newValue; break; - case PLAYER_OQ16ANG: ps.oq16ang = newValue; break; - case PLAYER_Q16ANGVEL: ps.q16angvel = newValue; break; - case PLAYER_Q16HORIZOFF: ps.q16horizoff = newValue; break; + case PLAYER_Q16HORIZ: ps.q16horiz = newValue; break; + case PLAYER_OQ16HORIZ: ps.oq16horiz = newValue; break; + case PLAYER_OQ16HORIZOFF: ps.oq16horizoff = newValue; break; + case PLAYER_Q16ANG: ps.q16ang = newValue; break; + case PLAYER_OQ16ANG: ps.oq16ang = newValue; break; + case PLAYER_Q16ANGVEL: ps.q16angvel = newValue; break; + case PLAYER_Q16HORIZOFF: ps.q16horizoff = newValue; break; + case PLAYER_Q16ROTSCRNANG: ps.q16rotscrnang = newValue; break; + case PLAYER_OQ16ROTSCRNANG: ps.oq16rotscrnang = newValue; break; case PLAYER_ACCESS_INCS: ps.access_incs = newValue; break; case PLAYER_ACCESS_SPRITENUM: ps.access_spritenum = newValue; break; @@ -853,7 +863,6 @@ void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const case PLAYER_RAPID_FIRE_HOLD: ps.rapid_fire_hold = newValue; break; case PLAYER_RELOADING: ps.reloading = newValue; break; case PLAYER_RETURN_TO_CENTER: ps.return_to_center = newValue; break; - case PLAYER_ROTSCRNANG: ps.rotscrnang = newValue; break; case PLAYER_RUNSPEED: ps.runspeed = newValue; break; case PLAYER_SBS: ps.sbs = newValue; break; case PLAYER_SCREAM_VOICE: ps.scream_voice = newValue; break; diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index 259ce8a56..842b03f3e 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -4684,7 +4684,7 @@ void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer) pPlayer->vel.y = 0; sprite[pPlayer->i].xvel = 0; pPlayer->look_ang = 0; - pPlayer->rotscrnang = 0; + pPlayer->q16rotscrnang = 0; } static void P_DoWater(int const playerNum, int const playerBits, int const floorZ, int const ceilZ) @@ -4847,7 +4847,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ, pushmove(&pPlayer->pos, &pPlayer->cursectnum, 128L, (4L<<8), (20L<<8), CLIPMASK0); if (floorZ > ceilZ + ZOFFSET2 && pSprite->pal != 1) - pPlayer->rotscrnang = (pPlayer->dead_flag + ((floorZ+pPlayer->pos.z)>>7))&2047; + pPlayer->q16rotscrnang = fix16_from_int((pPlayer->dead_flag + ((floorZ+pPlayer->pos.z)>>7))) & 0x7FFFFFF; pPlayer->on_warping_sector = 0; } @@ -5103,10 +5103,10 @@ void P_ProcessInput(int playerNum) return; } - pPlayer->rotscrnang -= (pPlayer->rotscrnang >> 1); + pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_int(2))); - if (pPlayer->rotscrnang && !(pPlayer->rotscrnang >> 1)) - pPlayer->rotscrnang -= ksgn(pPlayer->rotscrnang); + if (pPlayer->q16rotscrnang && !fix16_sdiv(pPlayer->q16rotscrnang, fix16_from_int(2))) + pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_int(ksgn(fix16_to_int(pPlayer->q16rotscrnang)))); pPlayer->look_ang -= (pPlayer->look_ang >> 2); @@ -5119,7 +5119,7 @@ void P_ProcessInput(int playerNum) if (VM_OnEvent(EVENT_LOOKLEFT,pPlayer->i,playerNum) == 0) { pPlayer->look_ang -= 152; - pPlayer->rotscrnang += 24; + pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_int(24)); } } @@ -5129,7 +5129,7 @@ void P_ProcessInput(int playerNum) if (VM_OnEvent(EVENT_LOOKRIGHT,pPlayer->i,playerNum) == 0) { pPlayer->look_ang += 152; - pPlayer->rotscrnang -= 24; + pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_int(24)); } } diff --git a/source/duke3d/src/player.h b/source/duke3d/src/player.h index 9fb02977e..a1935db06 100644 --- a/source/duke3d/src/player.h +++ b/source/duke3d/src/player.h @@ -178,7 +178,8 @@ typedef struct { int16_t weaprecs[MAX_WEAPONS], weapon_sway, crack_time, bobcounter; - int16_t orotscrnang, rotscrnang, dead_flag; // JBF 20031220: added orotscrnang + int16_t dead_flag; + fix16_t oq16rotscrnang, q16rotscrnang; // JBF 20031220: added orotscrnang int16_t holoduke_on, pycount; int16_t transporter_hold, clipdist; diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 4a023dc6d..675c8b9bf 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -649,7 +649,7 @@ void P_ResetMultiPlayer(int playerNum) p.opyoff = 0; p.q16horiz = F16(100); p.q16horizoff = 0; - p.rotscrnang = 0; + p.q16rotscrnang = 0; p.runspeed = g_playerFriction; p.vel = { 0, 0, 0 }; p.wackedbyactor = -1; @@ -731,7 +731,7 @@ void P_ResetPlayer(int playerNum) p.one_eighty_count = 0; p.opyoff = 0; p.oq16horiz = F16(140); - p.orotscrnang = 1; // JBF 20031220 + p.oq16rotscrnang = fix16_one; // JBF 20031220 p.over_shoulder_on = 0; p.palette = BASEPAL; p.player_par = 0; @@ -745,7 +745,7 @@ void P_ResetPlayer(int playerNum) p.rapid_fire_hold = 0; p.reloading = 0; p.return_to_center = 9; - p.rotscrnang = 0; + p.q16rotscrnang = 0; p.sbs = 0; p.show_empty_weapon = 0; p.somethingonplayer = -1;