games-puzzle/tod: add patch to fix fixed point math functions
authorStefan Strogin <steils@gentoo.org>
Fri, 14 Feb 2020 01:59:22 +0000 (03:59 +0200)
committerStefan Strogin <steils@gentoo.org>
Fri, 14 Feb 2020 02:10:11 +0000 (04:10 +0200)
Closes: https://bugs.gentoo.org/697090
Package-Manager: Portage-2.3.88, Repoman-2.3.20
Signed-off-by: Stefan Strogin <steils@gentoo.org>
games-puzzle/tod/files/tod-0-allegro.patch [new file with mode: 0644]
games-puzzle/tod/tod-0-r2.ebuild [moved from games-puzzle/tod/tod-0-r1.ebuild with 86% similarity]

diff --git a/games-puzzle/tod/files/tod-0-allegro.patch b/games-puzzle/tod/files/tod-0-allegro.patch
new file mode 100644 (file)
index 0000000..8b84a16
--- /dev/null
@@ -0,0 +1,154 @@
+From a8be33cd50b5f477f047e845426047da332d6273 Mon Sep 17 00:00:00 2001
+From: Stefan Strogin <steils@gentoo.org>
+Date: Fri, 14 Feb 2020 03:55:13 +0200
+Subject: [PATCH] Fix fixed point math functions (from media-libs/allegro)
+
+Bug: https://bugs.gentoo.org/697090
+Upstream-Status: Inappropriate [no upstream]
+Signed-off-by: Stefan Strogin <steils@gentoo.org>
+---
+ hgrcos.c |  2 +-
+ rec.c    | 58 ++++++++++++++++++++++++++++----------------------------
+ 2 files changed, 30 insertions(+), 30 deletions(-)
+
+diff --git a/hgrcos.c b/hgrcos.c
+index c65b469..442b18f 100644
+--- a/hgrcos.c
++++ b/hgrcos.c
+@@ -34,5 +34,5 @@ fixed hgrsin(fixed theta)
\r
+ fixed hgrtan(fixed theta)\r
+ {\r
+-  return fdiv(hgrcos(theta + 0xc00000), hgrcos(theta));\r
++  return fixdiv(hgrcos(theta + 0xc00000), hgrcos(theta));\r
+ }\r
+diff --git a/rec.c b/rec.c
+index bf6df2e..d02830a 100644
+--- a/rec.c
++++ b/rec.c
+@@ -214,7 +214,7 @@ void SetupLight1(void)
+     {\r
+       if(line[x] == c1)\r
+       {\r
+-        fixed f = fsqrt((x - 128) * (x - 128) + (y - 128) * (y - 128)); /* between 0 and 2 */\r
++        fixed f = fixsqrt((x - 128) * (x - 128) + (y - 128) * (y - 128)); /* between 0 and 2 */\r
+         fixed cosine = hgrcos(f << 10);\r
+         unsigned c = (cosine + 0x10000 + rand() % 0x1000) * 15 / 32768;\r
+         if(c > 63)\r
+@@ -223,8 +223,8 @@ void SetupLight1(void)
+       }\r
+       else if(line[x] == c2)\r
+       {\r
+-        fixed f = fsqrt((x - 128) * (x - 128) + (y - 128) * (y - 128)) +\r
+-                  (fcos(x << 20) + fcos(y << 20)) / 64 + 0x10000;\r
++        fixed f = fixsqrt((x - 128) * (x - 128) + (y - 128) * (y - 128)) +\r
++                  (fixcos(x << 20) + fixcos(y << 20)) / 64 + 0x10000;\r
+                   /* between 0 and 4 */\r
+         fixed cosine = hgrcos(f << 11);\r
+         unsigned c = (cosine + 0x10000 + rand() % 0x1000) * 15 / 32768;\r
+@@ -264,10 +264,10 @@ void ThetaLight(fixed theta)
+    * 3 4\r
+    * 567\r
+    */\r
+-  zpixel[1] = THETALIGHT_AMBIENT + fmul(THETALIGHT_POWER, s);\r
+-  zpixel[3] = THETALIGHT_AMBIENT + fmul(THETALIGHT_POWER, 0x10000 - c);\r
+-  zpixel[4] = THETALIGHT_AMBIENT + fmul(THETALIGHT_POWER, c);\r
+-  zpixel[6] = THETALIGHT_AMBIENT + fmul(THETALIGHT_POWER, 0x10000 - s);\r
++  zpixel[1] = THETALIGHT_AMBIENT + fixmul(THETALIGHT_POWER, s);\r
++  zpixel[3] = THETALIGHT_AMBIENT + fixmul(THETALIGHT_POWER, 0x10000 - c);\r
++  zpixel[4] = THETALIGHT_AMBIENT + fixmul(THETALIGHT_POWER, c);\r
++  zpixel[6] = THETALIGHT_AMBIENT + fixmul(THETALIGHT_POWER, 0x10000 - s);\r
\r
+   zpixel[0] = (zpixel[1] + zpixel[3])/2;\r
+   zpixel[2] = (zpixel[1] + zpixel[4])/2;\r
+@@ -304,20 +304,20 @@ void InitSidesPhi(Seven *seven, fixed phi, fixed zBase)
+   fixed m, zCos;\r
+   int scanlineWidth = 160 / nPlayers;\r
\r
+-  if(fcos(phi) == 0)\r
++  if(fixcos(phi) == 0)\r
+   {\r
+     phi -= 0x8000;\r
+   }\r
+-  zCos = fdiv(zBase, hgrcos(phi));\r
++  zCos = fixdiv(zBase, hgrcos(phi));\r
+   m = hgrtan(phi);\r
\r
+   for(i = 0; i < wHt; i++)\r
+   {\r
+-    fixed scanline = fdiv(i - wHt / 2, wHt / 2);\r
+-    fixed mline = fmul(m, scanline);\r
+-    fixed zLine = fmul(zCos, scanline);\r
+-    fixed y1 = fdiv(zLine, mline + 0x10000);\r
+-    fixed x1 = fdiv(zBase, mline + 0x10000);\r
++    fixed scanline = fixdiv(i - wHt / 2, wHt / 2);\r
++    fixed mline = fixmul(m, scanline);\r
++    fixed zLine = fixmul(zCos, scanline);\r
++    fixed y1 = fixdiv(zLine, mline + 0x10000);\r
++    fixed x1 = fixdiv(zBase, mline + 0x10000);\r
\r
+     if(x1 < 0)\r
+     {\r
+@@ -391,10 +391,10 @@ void RotateSides(Seven *seven, int theta)
+     ly = seven->leftY[i];\r
+     ry = seven->rightY[i];\r
\r
+-    seven->leftX[i]  = fmul(lx, c) - fmul(ly, s);\r
+-    seven->rightX[i] = fmul(rx, c) - fmul(ry, s);\r
+-    seven->leftY[i]  = fmul(ly, c) + fmul(lx, s);\r
+-    seven->rightY[i] = fmul(ry, c) + fmul(rx, s);\r
++    seven->leftX[i]  = fixmul(lx, c) - fixmul(ly, s);\r
++    seven->rightX[i] = fixmul(rx, c) - fixmul(ry, s);\r
++    seven->leftY[i]  = fixmul(ly, c) + fixmul(lx, s);\r
++    seven->rightY[i] = fixmul(ry, c) + fixmul(rx, s);\r
+   }\r
+ }\r
\r
+@@ -405,10 +405,10 @@ void ScaleSides(Seven *seven, int fac)
\r
+   for(i = 0; i < wHt; i++)\r
+   {\r
+-    seven->leftX[i]  = fmul(seven->leftX[i],  fac);\r
+-    seven->leftY[i]  = fmul(seven->leftY[i],  fac);\r
+-    seven->rightX[i] = fmul(seven->rightX[i], fac);\r
+-    seven->rightY[i] = fmul(seven->rightY[i], fac);\r
++    seven->leftX[i]  = fixmul(seven->leftX[i],  fac);\r
++    seven->leftY[i]  = fixmul(seven->leftY[i],  fac);\r
++    seven->rightX[i] = fixmul(seven->rightX[i], fac);\r
++    seven->rightY[i] = fixmul(seven->rightY[i], fac);\r
+   }\r
+ }\r
\r
+@@ -446,22 +446,22 @@ void DisplaceScanlines(Seven *seven, int ticks,
+   {\r
+     y = i - wHt / 2;\r
+     xOff = ((a * y / wHt + b) * y / wHt + c) * y / wHt + d +\r
+-           fmul(hgrcos(theta), amplitude);\r
+-    xOff += fmul((rand() & 0x7ff) - 0x400, noise);\r
++           fixmul(hgrcos(theta), amplitude);\r
++    xOff += fixmul((rand() & 0x7ff) - 0x400, noise);\r
+     theta += dtheta;\r
+     heatTheta += dheat;\r
\r
+-    yOff = fmul(hgrsin(heatTheta), heat);\r
++    yOff = fixmul(hgrsin(heatTheta), heat);\r
+   \r
+     lx = seven->leftX[i];\r
+     rx = seven->rightX[i];\r
+     ly = seven->leftY[i];\r
+     ry = seven->rightY[i];\r
\r
+-    seven->leftX[i]  = lx + fmul(rx - lx, xOff) - fmul(ry - ly, yOff);\r
+-    seven->rightX[i] = rx + fmul(rx - lx, xOff) - fmul(ry - ly, yOff);\r
+-    seven->leftY[i]  = ly + fmul(ry - ly, xOff) + fmul(rx - lx, yOff);\r
+-    seven->rightY[i] = ry + fmul(ry - ly, xOff) + fmul(rx - lx, yOff);\r
++    seven->leftX[i]  = lx + fixmul(rx - lx, xOff) - fixmul(ry - ly, yOff);\r
++    seven->rightX[i] = rx + fixmul(rx - lx, xOff) - fixmul(ry - ly, yOff);\r
++    seven->leftY[i]  = ly + fixmul(ry - ly, xOff) + fixmul(rx - lx, yOff);\r
++    seven->rightY[i] = ry + fixmul(ry - ly, xOff) + fixmul(rx - lx, yOff);\r
+   }\r
+ }\r
\r
+-- 
+2.25.0
+
similarity index 86%
rename from games-puzzle/tod/tod-0-r1.ebuild
rename to games-puzzle/tod/tod-0-r2.ebuild
index 0ed9a29063f0c7c3a634782e9913c7eb181364eb..9de46566b1374ebbf5f025369db33fe7db22fceb 100644 (file)
@@ -1,7 +1,8 @@
-# Copyright 1999-2018 Gentoo Foundation
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
+EAPI=7
+
 inherit desktop
 
 DESCRIPTION="Tetanus On Drugs simulates playing Tetris under the influence of drugs"
@@ -15,14 +16,14 @@ IUSE=""
 
 RDEPEND="media-libs/allegro:0[X]"
 DEPEND="${RDEPEND}
-       app-arch/unzip
-"
+       app-arch/unzip"
 
 S="${WORKDIR}"
 
 src_prepare() {
        default
        eapply "${FILESDIR}"/${P}-makefile.patch
+       eapply "${FILESDIR}"/${P}-allegro.patch
        sed -i \
                -e "s:idltd\.dat:/usr/share/${PN}/idltd.dat:" \
                rec.c || die