[mupen64plus-video-glide64] 01/02: Fix build with GCC6

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Jul 14 09:13:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch master
in repository mupen64plus-video-glide64.

commit 4cd681b60ef6e7f89f39ad270119413f2cfc5891
Author: Sven Eckelmann <sven at narfation.org>
Date:   Thu Jul 14 11:03:10 2016 +0200

    Fix build with GCC6
    
    min/max is also a C++ template and thus conflicts with the C defines.
---
 debian/changelog                         |   2 +
 debian/patches/Fix-build-with-GCC6.patch | 627 +++++++++++++++++++++++++++++++
 debian/patches/series                    |   1 +
 3 files changed, 630 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 89832a1..007b14e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ mupen64plus-video-glide64 (2.0.0+33+g764d9fe-4) UNRELEASED; urgency=medium
   * Sort debian control files with `wrap-and-sort -abst`
   * Upgraded to policy 3.9.7, no changes required
   * Upgraded to policy 3.9.8, no changes required
+  * debian/patches:
+    - Add Fix-build-with-GCC6.patch, Fix build with GCC6 (Closes: #831204)
 
  -- Sven Eckelmann <sven at narfation.org>  Mon, 25 Jan 2016 22:01:17 +0100
 
diff --git a/debian/patches/Fix-build-with-GCC6.patch b/debian/patches/Fix-build-with-GCC6.patch
new file mode 100644
index 0000000..61a288c
--- /dev/null
+++ b/debian/patches/Fix-build-with-GCC6.patch
@@ -0,0 +1,627 @@
+From: Sven Eckelmann <sven at narfation.org>
+Date: Thu, 14 Jul 2016 11:01:17 +0200
+Subject: Fix build with GCC6
+
+min/max is also a C++ template and thus conflicts with the C defines.
+
+Forwarded: no
+---
+ src/3dmath.cpp    |  4 ++--
+ src/TexBuffer.cpp | 10 +++++-----
+ src/TexCache.cpp  | 22 +++++++++++-----------
+ src/TexMod.h      | 12 ++++++------
+ src/TexModCI.h    | 54 +++++++++++++++++++++++++++---------------------------
+ src/UcodeFB.h     |  2 +-
+ src/Util.cpp      | 34 +++++++++++++++++-----------------
+ src/rdp.cpp       | 52 ++++++++++++++++++++++++++--------------------------
+ src/rdp.h         |  6 +++---
+ src/ucode06.h     | 20 ++++++++++----------
+ 10 files changed, 108 insertions(+), 108 deletions(-)
+
+diff --git a/src/3dmath.cpp b/src/3dmath.cpp
+index a12675c..c24bbfe 100644
+--- a/src/3dmath.cpp
++++ b/src/3dmath.cpp
+@@ -129,8 +129,8 @@ void calc_sphere (VERTEX *v)
+   int s_scale, t_scale;
+   if (settings.chopper)
+   {
+-    s_scale = min(rdp.tiles[rdp.cur_tile].org_s_scale >> 6, rdp.tiles[rdp.cur_tile].lr_s);
+-    t_scale = min(rdp.tiles[rdp.cur_tile].org_t_scale >> 6, rdp.tiles[rdp.cur_tile].lr_t);
++    s_scale = mini(rdp.tiles[rdp.cur_tile].org_s_scale >> 6, rdp.tiles[rdp.cur_tile].lr_s);
++    t_scale = mini(rdp.tiles[rdp.cur_tile].org_t_scale >> 6, rdp.tiles[rdp.cur_tile].lr_t);
+   }
+   else
+   {
+diff --git a/src/TexBuffer.cpp b/src/TexBuffer.cpp
+index 4fa8b09..922aa02 100644
+--- a/src/TexBuffer.cpp
++++ b/src/TexBuffer.cpp
+@@ -49,8 +49,8 @@
+ #include <string.h>
+ #endif // _WIN32
+ 
+-#define max(a,b) ((a) > (b) ? (a) : (b))
+-#define min(a,b) ((a) < (b) ? (a) : (b))
++#define maxi(a,b) ((a) > (b) ? (a) : (b))
++#define mini(a,b) ((a) < (b) ? (a) : (b))
+ 
+ static HIRES_COLOR_IMAGE * AllocateTextureBuffer(COLOR_IMAGE & cimage)
+ {
+@@ -60,13 +60,13 @@ static HIRES_COLOR_IMAGE * AllocateTextureBuffer(COLOR_IMAGE & cimage)
+   texbuf.width = cimage.width;
+   texbuf.height = cimage.height;
+   texbuf.format = (WORD)cimage.format;
+-    texbuf.scr_width = min(cimage.width * rdp.scale_x, settings.scr_res_x);
+-    float height = min(rdp.vi_height,cimage.height);
++    texbuf.scr_width = mini(cimage.width * rdp.scale_x, settings.scr_res_x);
++    float height = mini(rdp.vi_height,cimage.height);
+     if (cimage.status == ci_copy_self || (cimage.status == ci_copy && cimage.width == rdp.frame_buffers[rdp.main_ci_index].width)) 
+         height = rdp.vi_height;
+     texbuf.scr_height = height * rdp.scale_y;
+ 
+-  WORD max_size = max((WORD)texbuf.scr_width, (WORD)texbuf.scr_height);
++  WORD max_size = maxi((WORD)texbuf.scr_width, (WORD)texbuf.scr_height);
+   if (max_size > max_tex_size) //texture size is too large 
+     return 0;
+   DWORD tex_size;
+diff --git a/src/TexCache.cpp b/src/TexCache.cpp
+index cf3eff9..f5d551e 100644
+--- a/src/TexCache.cpp
++++ b/src/TexCache.cpp
+@@ -171,28 +171,28 @@ void GetTexInfo (int id, int tile)
+         if ((rdp.tiles[tile].clamp_s && tile_width <= 256) || (mask_width > 256))
+         {
+             // loading width
+-            width = min(mask_width, tile_width);
++            width = mini(mask_width, tile_width);
+             // actual width
+             rdp.tiles[tile].width = tile_width;
+         }
+         else
+         {
+             // wrap all the way
+-            width = min(mask_width, tile_width);    // changed from mask_width only
++            width = mini(mask_width, tile_width);    // changed from mask_width only
+             rdp.tiles[tile].width = width;
+         }
+ 
+         if ((rdp.tiles[tile].clamp_t && tile_height <= 256) || (mask_height > 256))
+         {
+             // loading height
+-            height = min(mask_height, tile_height);
++            height = mini(mask_height, tile_height);
+             // actual height
+             rdp.tiles[tile].height = tile_height;
+         }
+         else
+         {
+             // wrap all the way
+-            height = min(mask_height, tile_height);
++            height = mini(mask_height, tile_height);
+             rdp.tiles[tile].height = height;
+         }
+     }
+@@ -206,7 +206,7 @@ void GetTexInfo (int id, int tile)
+         if ((rdp.tiles[tile].clamp_s && tile_width <= 256) || (mask_width > 256))
+         {
+             // loading width
+-            width = min(mask_width, tile_width);
++            width = mini(mask_width, tile_width);
+             // actual width
+             rdp.tiles[tile].width = tile_width;
+         }
+@@ -220,7 +220,7 @@ void GetTexInfo (int id, int tile)
+         if ((rdp.tiles[tile].clamp_t && tile_height <= 256) || (mask_height > 256))
+         {
+             // loading height
+-            height = min(mask_height, tile_height);
++            height = mini(mask_height, tile_height);
+             // actual height
+             rdp.tiles[tile].height = tile_height;
+         }
+@@ -280,7 +280,7 @@ void GetTexInfo (int id, int tile)
+ 
+     // Texture too big for tmem & needs to wrap? (trees in mm)
+ 
+-    if (settings.wrap_big_tex && (rdp.tiles[tile].t_mem + min(height, tile_height) * (rdp.tiles[tile].line<<3) > 4096))
++    if (settings.wrap_big_tex && (rdp.tiles[tile].t_mem + mini(height, tile_height) * (rdp.tiles[tile].line<<3) > 4096))
+     {
+         RDP ("TEXTURE WRAPS TMEM!!! ");
+ 
+@@ -318,7 +318,7 @@ void GetTexInfo (int id, int tile)
+         crc = 0xFFFFFFFF;
+ //        unsigned __int64 * addr = (unsigned __int64 *)&rdp.tmem[rdp.tiles[tile].t_mem];
+         BYTE * addr = rdp.tmem + (rdp.tiles[tile].t_mem<<3);
+-        DWORD line2 = max(line,1);
++        DWORD line2 = maxi(line,1);
+         line2 <<= 3;
+         for (int y = 0; y < height; y++)
+         {
+@@ -975,7 +975,7 @@ void LoadTex (int id, int tmu)
+     }
+ 
+     // Calculate the maximum size
+-    int size_max = max (size_x, size_y);
++    int size_max = maxi(size_x, size_y);
+     DWORD real_x=size_max, real_y=size_max;
+     switch (size_max)
+     {
+@@ -1198,11 +1198,11 @@ void LoadTex (int id, int tmu)
+ 
+         int min_x, min_y;
+         if (rdp.tiles[td].mask_s != 0)
+-            min_x = min((int)real_x, 1<<rdp.tiles[td].mask_s);
++            min_x = mini((int)real_x, 1<<rdp.tiles[td].mask_s);
+         else
+             min_x = real_x;
+         if (rdp.tiles[td].mask_t != 0)
+-            min_y  = min((int)real_y, 1<<rdp.tiles[td].mask_t);
++            min_y  = mini((int)real_y, 1<<rdp.tiles[td].mask_t);
+         else
+             min_y = real_y;
+ 
+diff --git a/src/TexMod.h b/src/TexMod.h
+index 6f436a7..e7480c3 100644
+--- a/src/TexMod.h
++++ b/src/TexMod.h
+@@ -133,9 +133,9 @@ static void mod_col_inter_col1_using_tex (WORD *dst, int size, DWORD color0, DWO
+         percent_r = ((col >> 8) & 0xF) / 15.0f;
+         percent_g = ((col >> 4) & 0xF) / 15.0f;
+         percent_b = (col & 0xF) / 15.0f;
+-        r = min(15, (BYTE)((1.0f-percent_r) * cr0 + percent_r * cr1));
+-        g = min(15, (BYTE)((1.0f-percent_g) * cg0 + percent_g * cg1));
+-        b = min(15, (BYTE)((1.0f-percent_b) * cb0 + percent_b * cb1));
++        r = mini(15, (BYTE)((1.0f-percent_r) * cr0 + percent_r * cr1));
++        g = mini(15, (BYTE)((1.0f-percent_g) * cg0 + percent_g * cg1));
++        b = mini(15, (BYTE)((1.0f-percent_b) * cb0 + percent_b * cb1));
+         *(dst++) = a | (r << 8) | (g << 4) | b;
+     }
+ }
+@@ -313,15 +313,15 @@ static void mod_tex_sub_col_mul_fac_add_tex (WORD *dst, int size, DWORD color, D
+         col = *dst;
+         a = col & 0xF000;
+         r = (float)((col >> 8) & 0xF);
+-        r = /*max(*/(r - cr) * percent/*, 0.0f)*/ + r;
++        r = /*maxi(*/(r - cr) * percent/*, 0.0f)*/ + r;
+         if (r > 15.0f) r = 15.0f;
+         if (r < 0.0f) r = 0.0f;
+         g = (float)((col >> 4) & 0xF);
+-        g = /*max(*/(g - cg) * percent/*, 0.0f)*/ + g;
++        g = /*maxi(*/(g - cg) * percent/*, 0.0f)*/ + g;
+         if (g > 15.0f) g = 15.0f;
+         if (g < 0.0f) g = 0.0f;
+         b = (float)(col & 0xF);
+-        b = /*max(*/(b - cb) * percent/*, 0.0f)*/ + b;
++        b = /*maxi(*/(b - cb) * percent/*, 0.0f)*/ + b;
+         if (b > 15.0f) b = 15.0f;
+         if (b < 0.0f) b = 0.0f;
+ 
+diff --git a/src/TexModCI.h b/src/TexModCI.h
+index affcc27..3b9ff0f 100644
+--- a/src/TexModCI.h
++++ b/src/TexModCI.h
+@@ -35,8 +35,8 @@
+ //****************************************************************
+ 
+ #ifndef _WIN32
+-#define min(a,b) ((a) < (b) ? (a) : (b))
+-#define max(a,b) ((a) > (b) ? (a) : (b))
++#define mini(a,b) ((a) < (b) ? (a) : (b))
++#define maxi(a,b) ((a) > (b) ? (a) : (b))
+ #endif // _WIN32
+ 
+ static void mod_tex_inter_color_using_factor_CI (DWORD color, DWORD factor)
+@@ -58,9 +58,9 @@ static void mod_tex_inter_color_using_factor_CI (DWORD color, DWORD factor)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = (BYTE)(min(255, percent_i * r + percent * cr));
+-        g = (BYTE)(min(255, percent_i * g + percent * cg));
+-        b = (BYTE)(min(255, percent_i * b + percent * cb));
++        r = (BYTE)(mini(255, percent_i * r + percent * cr));
++        g = (BYTE)(mini(255, percent_i * g + percent * cg));
++        b = (BYTE)(mini(255, percent_i * b + percent * cb));
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -92,9 +92,9 @@ static void mod_tex_inter_col_using_col1_CI (DWORD color0, DWORD color1)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = (BYTE)(min(255, percent_r_i * r + percent_r * cr));
+-        g = (BYTE)(min(255, percent_g_i * g + percent_g * cg));
+-        b = (BYTE)(min(255, percent_b_i * b + percent_b * cb));
++        r = (BYTE)(mini(255, percent_r_i * r + percent_r * cr));
++        g = (BYTE)(mini(255, percent_g_i * g + percent_g * cg));
++        b = (BYTE)(mini(255, percent_b_i * b + percent_b * cb));
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -120,10 +120,10 @@ static void mod_full_color_sub_tex_CI (DWORD color)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        a = max(0, ca - a);
+-        r = max(0, cr - r);
+-        g = max(0, cg - g);
+-        b = max(0, cb - b);
++        a = maxi(0, ca - a);
++        r = maxi(0, cr - r);
++        g = maxi(0, cg - g);
++        b = maxi(0, cb - b);
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -152,9 +152,9 @@ static void mod_col_inter_col1_using_tex_CI (DWORD color0, DWORD color1)
+         percent_r = ((col&0xF800) >> 11) / 31.0f;
+         percent_g = ((col&0x07C0) >> 6) / 31.0f;
+         percent_b = ((col&0x003E) >> 1) / 31.0f;
+-        r = (BYTE)(min((1.0f-percent_r) * cr0 + percent_r * cr1, 255));
+-        g = (BYTE)(min((1.0f-percent_g) * cg0 + percent_g * cg1, 255));
+-        b = (BYTE)(min((1.0f-percent_b) * cb0 + percent_b * cb1, 255));
++        r = (BYTE)(mini((1.0f-percent_r) * cr0 + percent_r * cr1, 255));
++        g = (BYTE)(mini((1.0f-percent_g) * cg0 + percent_g * cg1, 255));
++        b = (BYTE)(mini((1.0f-percent_b) * cb0 + percent_b * cb1, 255));
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -215,9 +215,9 @@ static void mod_tex_scale_col_add_col_CI (DWORD color, DWORD factor)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = (BYTE)(min(base + percent_r * r, 255));
+-        g = (BYTE)(min(base + percent_g * g, 255));
+-        b = (BYTE)(min(base + percent_b * b, 255));
++        r = (BYTE)(mini(base + percent_r * r, 255));
++        g = (BYTE)(mini(base + percent_g * g, 255));
++        b = (BYTE)(mini(base + percent_b * b, 255));
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -243,9 +243,9 @@ static void mod_tex_add_col_CI (DWORD color)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = min(cr + r, 255);
+-        g = min(cg + g, 255);
+-        b = min(cb + b, 255);
++        r = mini(cr + r, 255);
++        g = mini(cg + g, 255);
++        b = mini(cb + b, 255);
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -270,9 +270,9 @@ static void mod_tex_sub_col_CI (DWORD color)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = max(r - cr, 0);
+-        g = max(g - cg, 0);
+-        b = max(b - cb, 0);
++        r = maxi(r - cr, 0);
++        g = maxi(g - cg, 0);
++        b = maxi(b - cb, 0);
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+@@ -340,9 +340,9 @@ static void mod_col_inter_tex_using_col1_CI (DWORD color0, DWORD color1)
+         r = (BYTE)((float)((col&0xF800) >> 11) / 31.0f * 255.0f);
+         g = (BYTE)((float)((col&0x07C0) >> 6) / 31.0f * 255.0f);
+         b = (BYTE)((float)((col&0x003E) >> 1) / 31.0f * 255.0f);
+-        r = (BYTE)(min(255, percent_r * r + percent_r_i * cr));
+-        g = (BYTE)(min(255, percent_g * g + percent_g_i * cg));
+-        b = (BYTE)(min(255, percent_b * b + percent_b_i * cb));
++        r = (BYTE)(mini(255, percent_r * r + percent_r_i * cr));
++        g = (BYTE)(mini(255, percent_g * g + percent_g_i * cg));
++        b = (BYTE)(mini(255, percent_b * b + percent_b_i * cb));
+         rdp.pal_8[i] = (WORD)(((WORD)(r >> 3) << 11) |
+                   ((WORD)(g >> 3) << 6) |
+                   ((WORD)(b >> 3) << 1) |
+diff --git a/src/UcodeFB.h b/src/UcodeFB.h
+index 8eb8964..87c2374 100644
+--- a/src/UcodeFB.h
++++ b/src/UcodeFB.h
+@@ -336,7 +336,7 @@ static void fb_setcolorimage()
+   {
+     if (rdp.cimg == rdp.main_ci) //switched to main fb again 
+     {
+-            cur_fb.height = max(cur_fb.height, rdp.frame_buffers[rdp.main_ci_index].height);
++            cur_fb.height = maxi(cur_fb.height, rdp.frame_buffers[rdp.main_ci_index].height);
+       rdp.main_ci_index = rdp.ci_count;
+         rdp.main_ci_end = rdp.cimg + ((cur_fb.width * cur_fb.height) << cur_fb.size >> 1);
+         cur_fb.status = ci_main;
+diff --git a/src/Util.cpp b/src/Util.cpp
+index ec682ec..fd0d582 100644
+--- a/src/Util.cpp
++++ b/src/Util.cpp
+@@ -51,8 +51,8 @@
+ #include <stdlib.h>
+ #endif // _WIN32
+ 
+-#define max(a,b) ((a) > (b) ? (a) : (b))
+-#define min(a,b) ((a) < (b) ? (a) : (b))
++#define maxi(a,b) ((a) > (b) ? (a) : (b))
++#define mini(a,b) ((a) < (b) ? (a) : (b))
+ 
+ #define Vj rdp.vtxbuf2[j]
+ #define Vi rdp.vtxbuf2[i]
+@@ -447,11 +447,11 @@ void DrawTri (VERTEX **vtx, WORD linew)
+       int index,i,j, min_256,max_256, cur_256,left_256,right_256;
+       float percent;
+       
+-      min_256 = min((int)vtx[0]->u0,(int)vtx[1]->u0); // bah, don't put two mins on one line
+-      min_256 = min(min_256,(int)vtx[2]->u0) >> 8;  // or it will be calculated twice
++      min_256 = mini((int)vtx[0]->u0,(int)vtx[1]->u0); // bah, don't put two mins on one line
++      min_256 = mini(min_256,(int)vtx[2]->u0) >> 8;  // or it will be calculated twice
+       
+-      max_256 = max((int)vtx[0]->u0,(int)vtx[1]->u0); // not like it makes much difference
+-      max_256 = max(max_256,(int)vtx[2]->u0) >> 8;  // anyway :P
++      max_256 = maxi((int)vtx[0]->u0,(int)vtx[1]->u0); // not like it makes much difference
++      max_256 = maxi(max_256,(int)vtx[2]->u0) >> 8;  // anyway :P
+       
+       for (cur_256=min_256; cur_256<=max_256; cur_256++)
+       {
+@@ -833,11 +833,11 @@ static void CalculateLOD(VERTEX **v, int n)
+         lodFactor = lodFactor / n;
+     }
+     long ilod = (long)lodFactor;
+-    int lod_tile = min((int)(log((double)ilod)/log(2.0)), rdp.cur_tile + rdp.mipmap_level);
++    int lod_tile = mini((int)(log((double)ilod)/log(2.0)), rdp.cur_tile + rdp.mipmap_level);
+     float lod_fraction = 1.0f;
+     if (lod_tile < rdp.cur_tile + rdp.mipmap_level)
+     {
+-        lod_fraction = max((float)modf(lodFactor / pow(2.0f,lod_tile),&intptr), rdp.prim_lodmin / 255.0f);
++        lod_fraction = maxi((float)modf(lodFactor / pow(2.0f,lod_tile),&intptr), rdp.prim_lodmin / 255.0f);
+     }
+     float detailmax;
+     if (cmb.dc0_detailmax < 0.5f)
+@@ -1162,7 +1162,7 @@ void clip_tri (WORD linew)
+     {
+         for (i = 0; i < n; i++)
+         {
+-            rdp.vtxbuf[i].f = 1.0f/max(16.0f,rdp.vtxbuf[i].f);
++            rdp.vtxbuf[i].f = 1.0f/maxi(16.0f,rdp.vtxbuf[i].f);
+         }
+     }
+     
+@@ -1339,10 +1339,10 @@ void update_scissor ()
+         rdp.update ^= UPDATE_SCISSOR;
+         
+         // KILL the floating point error with 0.01f
+-        rdp.scissor.ul_x = (DWORD) max(min((rdp.scissor_o.ul_x * rdp.scale_x + rdp.offset_x + 0.01f),settings.res_x),0);
+-        rdp.scissor.lr_x = (DWORD) max(min((rdp.scissor_o.lr_x * rdp.scale_x + rdp.offset_x + 0.01f),settings.res_x),0);
+-        rdp.scissor.ul_y = (DWORD) max(min((rdp.scissor_o.ul_y * rdp.scale_y + rdp.offset_y + 0.01f),settings.res_y),0);
+-        rdp.scissor.lr_y = (DWORD) max(min((rdp.scissor_o.lr_y * rdp.scale_y + rdp.offset_y + 0.01f),settings.res_y),0);
++        rdp.scissor.ul_x = (DWORD) maxi(mini((rdp.scissor_o.ul_x * rdp.scale_x + rdp.offset_x + 0.01f),settings.res_x),0);
++        rdp.scissor.lr_x = (DWORD) maxi(mini((rdp.scissor_o.lr_x * rdp.scale_x + rdp.offset_x + 0.01f),settings.res_x),0);
++        rdp.scissor.ul_y = (DWORD) maxi(mini((rdp.scissor_o.ul_y * rdp.scale_y + rdp.offset_y + 0.01f),settings.res_y),0);
++        rdp.scissor.lr_y = (DWORD) maxi(mini((rdp.scissor_o.lr_y * rdp.scale_y + rdp.offset_y + 0.01f),settings.res_y),0);
+         FRDP (" |- scissor - (%d, %d) -> (%d, %d)\n", rdp.scissor.ul_x, rdp.scissor.ul_y,
+             rdp.scissor.lr_x, rdp.scissor.lr_y);
+     }
+@@ -1660,10 +1660,10 @@ void update ()
+       float scale_y = (float)fabs(rdp.view_scale[1]);
+       //printf("scale_y %g\n", scale_y);
+       
+-      DWORD min_x = (DWORD) max(rdp.view_trans[0] - scale_x, 0);
+-      DWORD min_y = (DWORD) max(rdp.view_trans[1] - scale_y, 0);
+-      DWORD max_x = (DWORD) min(rdp.view_trans[0] + scale_x + 1, settings.res_x);
+-      DWORD max_y = (DWORD) min(rdp.view_trans[1] + scale_y + 1, settings.res_y);
++      DWORD min_x = (DWORD) maxi(rdp.view_trans[0] - scale_x, 0);
++      DWORD min_y = (DWORD) maxi(rdp.view_trans[1] - scale_y, 0);
++      DWORD max_x = (DWORD) mini(rdp.view_trans[0] + scale_x + 1, settings.res_x);
++      DWORD max_y = (DWORD) mini(rdp.view_trans[1] + scale_y + 1, settings.res_y);
+       
+       FRDP (" |- viewport - (%d, %d, %d, %d)\n", min_x, min_y, max_x, max_y);
+           grClipWindow (min_x, min_y, max_x, max_y);
+diff --git a/src/rdp.cpp b/src/rdp.cpp
+index cfa53a9..24f2f8b 100644
+--- a/src/rdp.cpp
++++ b/src/rdp.cpp
+@@ -538,10 +538,10 @@ static void DrawFrameBufferToScreen()
+     GR_BLEND_ZERO);
+   rdp.update |= UPDATE_COMBINE;
+ 
+-  float scale_x_dst = (float)settings.scr_res_x / rdp.vi_width;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
+-  float scale_y_dst = (float)settings.scr_res_y / rdp.vi_height;//(float)max(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
+-  float scale_x_src = (float)rdp.vi_width / (float)settings.scr_res_x;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
+-  float scale_y_src = (float)rdp.vi_height / (float)settings.scr_res_y;//(float)max(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
++  float scale_x_dst = (float)settings.scr_res_x / rdp.vi_width;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
++  float scale_y_dst = (float)settings.scr_res_y / rdp.vi_height;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
++  float scale_x_src = (float)rdp.vi_width / (float)settings.scr_res_x;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
++  float scale_y_src = (float)rdp.vi_height / (float)settings.scr_res_y;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
+   int src_width = d_lr_x - d_ul_x + 1;
+   int src_height = d_lr_y - d_ul_y + 1;
+   int dst_width, dst_height, ul_x, ul_y;
+@@ -762,8 +762,8 @@ static void CopyFrameBuffer (GrBuffer_t buffer = GR_BUFFER_BACKBUFFER)
+     }
+     else
+     {
+-      float scale_x = (float)settings.scr_res_x / rdp.vi_width;//(float)max(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
+-      float scale_y = (float)settings.scr_res_y / rdp.vi_height;//(float)max(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
++      float scale_x = (float)settings.scr_res_x / rdp.vi_width;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].width, rdp.ci_width);
++      float scale_y = (float)settings.scr_res_y / rdp.vi_height;//(float)maxi(rdp.frame_buffers[rdp.main_ci_index].height, rdp.ci_lower_bound);
+ 
+       FRDP("width: %d, height: %d, ul_y: %d, lr_y: %d, scale_x: %f, scale_y: %f, ci_width: %d, ci_height: %d\n",width, height, rdp.ci_upper_bound, rdp.ci_lower_bound, scale_x, scale_y, rdp.ci_width, rdp.ci_height);
+       GrLfbInfo_t info;
+@@ -959,7 +959,7 @@ EXPORT void CALL ProcessDList(void)
+ 
+     rdp.model_i = 0; // 0 matrices so far in stack
+     //stack_size can be less then 32! Important for Silicon Vally. Thanks Orkin!
+-    rdp.model_stack_size = min(32, (*(DWORD*)(gfx.DMEM+0x0FE4))>>6);
++    rdp.model_stack_size = mini(32, (*(DWORD*)(gfx.DMEM+0x0FE4))>>6);
+     if (rdp.model_stack_size == 0)
+       rdp.model_stack_size = 32;
+   rdp.fb_drawn = rdp.fb_drawn_front = FALSE;
+@@ -1797,10 +1797,10 @@ static void rdp_setconvert()
+ static void rdp_setscissor()
+ {
+     // clipper resolution is 320x240, scale based on computer resolution
+-    rdp.scissor_o.ul_x = /*min(*/(DWORD)(((rdp.cmd0 & 0x00FFF000) >> 14))/*, 320)*/;
+-    rdp.scissor_o.ul_y = /*min(*/(DWORD)(((rdp.cmd0 & 0x00000FFF) >> 2))/*, 240)*/;
+-    rdp.scissor_o.lr_x = /*min(*/(DWORD)(((rdp.cmd1 & 0x00FFF000) >> 14))/*, 320)*/;
+-    rdp.scissor_o.lr_y = /*min(*/(DWORD)(((rdp.cmd1 & 0x00000FFF) >> 2))/*, 240)*/;
++    rdp.scissor_o.ul_x = /*mini(*/(DWORD)(((rdp.cmd0 & 0x00FFF000) >> 14))/*, 320)*/;
++    rdp.scissor_o.ul_y = /*mini(*/(DWORD)(((rdp.cmd0 & 0x00000FFF) >> 2))/*, 240)*/;
++    rdp.scissor_o.lr_x = /*mini(*/(DWORD)(((rdp.cmd1 & 0x00FFF000) >> 14))/*, 320)*/;
++    rdp.scissor_o.lr_y = /*mini(*/(DWORD)(((rdp.cmd1 & 0x00000FFF) >> 2))/*, 240)*/;
+ 
+     rdp.ci_upper_bound = rdp.scissor_o.ul_y;
+     rdp.ci_lower_bound = rdp.scissor_o.lr_y;
+@@ -2300,10 +2300,10 @@ static void rdp_fillrect()
+             rdp.update |= UPDATE_ZBUF_ENABLED;
+             if (settings.fb_depth_clear)
+             {
+-        ul_x = min(max(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x);
+-        lr_x = min(max(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x);
+-        ul_y = min(max(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y);
+-        lr_y = min(max(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y);
++        ul_x = mini(maxi(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x);
++        lr_x = mini(maxi(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x);
++        ul_y = mini(maxi(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y);
++        lr_y = mini(maxi(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y);
+         //FIXME:unused? DWORD zi_height = lr_y - ul_y - 1;
+         //              rdp.zi_nb_pixels = rdp.zi_width * zi_height;
+         rdp.zi_lry = lr_y - 1;
+@@ -2365,10 +2365,10 @@ static void rdp_fillrect()
+         rdp.scissor.lr_y);
+ 
+     // KILL the floating point error with 0.01f
+-    DWORD s_ul_x = (DWORD)min(max(ul_x * rdp.scale_x + rdp.offset_x + 0.01f, rdp.scissor.ul_x), rdp.scissor.lr_x);
+-    DWORD s_lr_x = (DWORD)min(max(lr_x * rdp.scale_x + rdp.offset_x + 0.01f, rdp.scissor.ul_x), rdp.scissor.lr_x);
+-    DWORD s_ul_y = (DWORD)min(max(ul_y * rdp.scale_y + rdp.offset_y + 0.01f, rdp.scissor.ul_y), rdp.scissor.lr_y);
+-    DWORD s_lr_y = (DWORD)min(max(lr_y * rdp.scale_y + rdp.offset_y + 0.01f, rdp.scissor.ul_y), rdp.scissor.lr_y);
++    DWORD s_ul_x = (DWORD)mini(maxi(ul_x * rdp.scale_x + rdp.offset_x + 0.01f, rdp.scissor.ul_x), rdp.scissor.lr_x);
++    DWORD s_lr_x = (DWORD)mini(maxi(lr_x * rdp.scale_x + rdp.offset_x + 0.01f, rdp.scissor.ul_x), rdp.scissor.lr_x);
++    DWORD s_ul_y = (DWORD)mini(maxi(ul_y * rdp.scale_y + rdp.offset_y + 0.01f, rdp.scissor.ul_y), rdp.scissor.lr_y);
++    DWORD s_lr_y = (DWORD)mini(maxi(lr_y * rdp.scale_y + rdp.offset_y + 0.01f, rdp.scissor.ul_y), rdp.scissor.lr_y);
+ 
+     if (s_lr_x < 0.0f) s_lr_x = 0;
+     if (s_lr_y < 0.0f) s_lr_y = 0;
+@@ -2536,7 +2536,7 @@ static void rdp_setprimcolor()
+ {
+   rdp.prim_color = rdp.cmd1;
+     rdp.prim_lodmin = (rdp.cmd0 >> 8) & 0xFF;
+-  rdp.prim_lodfrac = max(rdp.cmd0 & 0xFF, rdp.prim_lodmin);
++  rdp.prim_lodfrac = maxi(rdp.cmd0 & 0xFF, rdp.prim_lodmin);
+     rdp.update |= UPDATE_COMBINE;
+ 
+     FRDP("setprimcolor: %08lx, lodmin: %d, lodfrac: %d\n", rdp.cmd1, rdp.prim_lodmin,
+@@ -2944,7 +2944,7 @@ static void rdp_setcolorimage()
+   if (rdp.zimg == rdp.cimg)
+   {
+     rdp.zi_width = rdp.ci_width;
+-    //    int zi_height = min((int)rdp.zi_width*3/4, (int)rdp.vi_height);
++    //    int zi_height = mini((int)rdp.zi_width*3/4, (int)rdp.vi_height);
+     //    rdp.zi_words = rdp.zi_width * zi_height;
+   }
+   DWORD format = (rdp.cmd0 >> 21) & 0x7;
+@@ -3265,10 +3265,10 @@ EXPORT void CALL FBWrite(unsigned int addr, unsigned int size)
+     DWORD shift_l = (a-rdp.cimg) >> 1;
+     DWORD shift_r = shift_l+2;
+ 
+-    d_ul_x = min(d_ul_x, shift_l%rdp.ci_width);
+-    d_ul_y = min(d_ul_y, shift_l/rdp.ci_width);
+-    d_lr_x = max(d_lr_x, shift_r%rdp.ci_width);
+-    d_lr_y = max(d_lr_y, shift_r/rdp.ci_width);
++    d_ul_x = mini(d_ul_x, shift_l%rdp.ci_width);
++    d_ul_y = mini(d_ul_y, shift_l/rdp.ci_width);
++    d_lr_x = maxi(d_lr_x, shift_r%rdp.ci_width);
++    d_lr_y = maxi(d_lr_y, shift_r/rdp.ci_width);
+ }
+ 
+ 
+@@ -3670,7 +3670,7 @@ EXPORT void CALL ProcessRDPList(void)
+ 
+     rdp.model_i = 0; // 0 matrices so far in stack
+     //stack_size can be less then 32! Important for Silicon Vally. Thanks Orkin!
+-    rdp.model_stack_size = min(32, (*(DWORD*)(gfx.DMEM+0x0FE4))>>6);
++    rdp.model_stack_size = mini(32, (*(DWORD*)(gfx.DMEM+0x0FE4))>>6);
+     if (rdp.model_stack_size == 0)
+       rdp.model_stack_size = 32;
+   rdp.fb_drawn = rdp.fb_drawn_front = FALSE;
+diff --git a/src/rdp.h b/src/rdp.h
+index 2a51053..57158ab 100644
+--- a/src/rdp.h
++++ b/src/rdp.h
+@@ -48,8 +48,8 @@
+ #include "glide.h"
+ 
+ //#ifdef GCC
+-#define max(a,b) ((a) > (b) ? (a) : (b))
+-#define min(a,b) ((a) < (b) ? (a) : (b))
++#define maxi(a,b) ((a) > (b) ? (a) : (b))
++#define mini(a,b) ((a) < (b) ? (a) : (b))
+ //#endif
+ 
+ extern char out_buf[2048];
+@@ -749,7 +749,7 @@ __inline void CalculateFog (VERTEX *v)
+ {
+     if (rdp.flags & FOG_ENABLED) 
+     {
+-        v->f = min(255.0f, max(0.0f, v->z_w * rdp.fog_multiplier + rdp.fog_offset));    
++        v->f = mini(255.0f, maxi(0.0f, v->z_w * rdp.fog_multiplier + rdp.fog_offset));    
+         v->a = (BYTE)v->f;
+     }
+     else
+diff --git a/src/ucode06.h b/src/ucode06.h
+index b4e1436..773283c 100644
+--- a/src/ucode06.h
++++ b/src/ucode06.h
+@@ -38,8 +38,8 @@
+ 
+ // STANDARD DRAWIMAGE - draws a 2d image based on the following structure
+ 
+-#define max(a,b) ((a) > (b) ? (a) : (b))
+-#define min(a,b) ((a) < (b) ? (a) : (b))
++#define maxi(a,b) ((a) > (b) ? (a) : (b))
++#define mini(a,b) ((a) < (b) ? (a) : (b))
+ 
+ void uc6_sprite2d ();
+ 
+@@ -170,8 +170,8 @@ void DrawDepthImage (DRAWIMAGE *d)
+   float scale_y_src = 1.0f/rdp.scale_y;
+   int src_width = d->imageW;
+   int src_height = d->imageH;
+-  int dst_width = min(int(src_width*scale_x_dst), (int)settings.scr_res_x);
+-  int dst_height = min(int(src_height*scale_y_dst), (int)settings.scr_res_y);
++  int dst_width = mini(int(src_width*scale_x_dst), (int)settings.scr_res_x);
++  int dst_height = mini(int(src_height*scale_y_dst), (int)settings.scr_res_y);
+ 
+ #if 1
+   if (0 && grFramebufferCopyExt) {
+@@ -460,7 +460,7 @@ void DrawImage (DRAWIMAGE *d)
+         cur_u = min_256_u + 1;
+         
+         // calculate intersection with this point
+-        nlr_v = min (min (cur_wrap_v*d->imageH, (cur_v<<y_shift)), lr_v);
++        nlr_v = mini(mini(cur_wrap_v*d->imageH, (cur_v<<y_shift)), lr_v);
+         nlr_y = my * nlr_v + by;
+         
+         nul_u = ul_u;
+@@ -472,7 +472,7 @@ void DrawImage (DRAWIMAGE *d)
+         while (1)
+         {
+             // calculate intersection with this point
+-            nlr_u = min (min (cur_wrap_u*d->imageW, (cur_u<<x_shift)), lr_u);
++            nlr_u = mini(mini(cur_wrap_u*d->imageW, (cur_u<<x_shift)), lr_u);
+             nlr_x = mx * nlr_u + bx;
+             
+             // ** Load the texture, constant portions have been set above
+@@ -902,11 +902,11 @@ static void draw_splitted_triangle(VERTEX **vtx)
+     int index,i,j, min_256,max_256, cur_256,left_256,right_256;
+     float percent;
+     
+-    min_256 = min((int)vtx[0]->u0,(int)vtx[1]->u0); // bah, don't put two mins on one line
+-    min_256 = min(min_256,(int)vtx[2]->u0) >> 8;  // or it will be calculated twice
++    min_256 = mini((int)vtx[0]->u0,(int)vtx[1]->u0); // bah, don't put two mins on one line
++    min_256 = mini(min_256,(int)vtx[2]->u0) >> 8;  // or it will be calculated twice
+     
+-    max_256 = max((int)vtx[0]->u0,(int)vtx[1]->u0); // not like it makes much difference
+-    max_256 = max(max_256,(int)vtx[2]->u0) >> 8;  // anyway :P
++    max_256 = maxi((int)vtx[0]->u0,(int)vtx[1]->u0); // not like it makes much difference
++    max_256 = maxi(max_256,(int)vtx[2]->u0) >> 8;  // anyway :P
+     
+     for (cur_256=min_256; cur_256<=max_256; cur_256++)
+     {
diff --git a/debian/patches/series b/debian/patches/series
index 0b6b7a5..4f37389 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 Add-printf-format-attribute.patch
+Fix-build-with-GCC6.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-video-glide64.git



More information about the Pkg-games-commits mailing list