ref: 3d6f4785591eced3e4195a342980facd0adcb284
parent: 01b69307e00ee6c0a1366542b843f1495c79ea15
author: Thomas A. Birkel <[email protected]>
date: Fri Oct 14 20:53:43 EDT 2016
g_game.c: Add -shortticfix optional feature for Heretic/Hexen. Doom's turning code during demos accurately rounds the value to produce a smooth resolution, which Heretic and Hexen lack by default. The -shortticfix parameter allows for this to be fixed in these games. Partial implementation of #432
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -112,6 +112,7 @@
boolean demorecording;
boolean longtics;
boolean lowres_turn;
+boolean shortticfix; // properly calculates lowres turns like in doom
boolean demoplayback;
byte *demobuffer, *demo_p, *demoend;
boolean singledemo; // quit after playing a demo from cmdline
@@ -628,9 +629,29 @@
if (lowres_turn)
{
- // truncate angleturn to the nearest 256 boundary
- // for recording demos with single byte values for turn
- cmd->angleturn &= 0xff00;
+ if (shortticfix)
+ {
+ static signed short carry = 0;
+ signed short desired_angleturn;
+
+ desired_angleturn = cmd->angleturn + carry;
+
+ // round angleturn to the nearest 256 unit boundary
+ // for recording demos with single byte values for turn
+
+ cmd->angleturn = (desired_angleturn + 128) & 0xff00;
+
+ // Carry forward the error from the reduced resolution to the
+ // next tic, so that successive small movements can accumulate.
+
+ carry = desired_angleturn - cmd->angleturn;
+ }
+ else
+ {
+ // truncate angleturn to the nearest 256 boundary
+ // for recording demos with single byte values for turn
+ cmd->angleturn &= 0xff00;
+ }
}
}
@@ -1718,6 +1739,13 @@
// If not recording a longtics demo, record in low res
lowres_turn = !longtics;
+
+ //!
+ // @category demo
+ //
+ // Smooths out low turning resolution when recording a demo.
+ //
+ shortticfix = M_CheckParm("-shortticfix") != 0;
G_InitNew(skill, episode, map);
usergame = false;
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -95,6 +95,7 @@
boolean demorecording;
boolean longtics;
boolean lowres_turn;
+boolean shortticfix; // properly calculates lowres turns like in doom
boolean demoplayback;
byte *demobuffer, *demo_p, *demoend;
boolean singledemo; // quit after playing a demo from cmdline
@@ -629,9 +630,29 @@
if (lowres_turn)
{
- // truncate angleturn to the nearest 256 boundary
- // for recording demos with single byte values for turn
- cmd->angleturn &= 0xff00;
+ if (shortticfix)
+ {
+ static signed short carry = 0;
+ signed short desired_angleturn;
+
+ desired_angleturn = cmd->angleturn + carry;
+
+ // round angleturn to the nearest 256 unit boundary
+ // for recording demos with single byte values for turn
+
+ cmd->angleturn = (desired_angleturn + 128) & 0xff00;
+
+ // Carry forward the error from the reduced resolution to the
+ // next tic, so that successive small movements can accumulate.
+
+ carry = desired_angleturn - cmd->angleturn;
+ }
+ else
+ {
+ // truncate angleturn to the nearest 256 boundary
+ // for recording demos with single byte values for turn
+ cmd->angleturn &= 0xff00;
+ }
}
}
@@ -1869,6 +1890,13 @@
int maxsize;
// If not recording a longtics demo, record in low res
+
+ //!
+ // @category demo
+ //
+ // Smooths out low turning resolution when recording a demo.
+ //
+ shortticfix = M_CheckParm("-shortticfix") != 0;
lowres_turn = !longtics;