File: 02-enable-shading.patch

package info (click to toggle)
wolf4sdl 20251124-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 2,072 kB
  • sloc: cpp: 35,152; ansic: 3,476; makefile: 219; sh: 35
file content (175 lines) | stat: -rw-r--r-- 6,125 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Subject: Enable shading support as a command line option "--shading".
Author: Fabian Greffrath <fabian@debian.org>

--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,7 @@ SRCS += wl_agent.cpp
 SRCS += wl_atmos.cpp
 SRCS += wl_cloudsky.cpp
 SRCS += wl_debug.cpp
+SRCS += wl_shade.cpp
 SRCS += wl_draw.cpp
 SRCS += wl_floorceiling.cpp
 SRCS += wl_game.cpp
--- a/version.h
+++ b/version.h
@@ -29,7 +29,7 @@
 #endif
 
 //#define USE_FEATUREFLAGS    // Enables the level feature flags (see bottom of wl_def.h)
-//#define USE_SHADING         // Enables shading support (see wl_shade.cpp)
+#define USE_SHADING         // Enables shading support (see wl_shade.cpp)
 //#define USE_DIR3DSPR        // Enables directional 3d sprites (see wl_dir3dspr.cpp)
 //#define USE_FLOORCEILINGTEX // Enables floor and ceiling textures stored in the third mapplane (see wl_floorceiling.cpp)
 //#define USE_HIRES           // Enables high resolution textures/sprites (128x128)
--- a/wl_def.h
+++ b/wl_def.h
@@ -942,6 +942,7 @@ extern  int      param_mission;
 extern  boolean  param_ignorenumchunks;
 extern  boolean  always_run;
 extern  boolean  crosshair;
+extern  boolean  param_shading;
 
 
 void            NewGame (int difficulty,int episode);
--- a/wl_dir3dspr.cpp
+++ b/wl_dir3dspr.cpp
@@ -101,10 +101,11 @@ void Scale3DShaper(int x1, int x2, int s
                         if(scrstarty!=screndy && screndy>0)
                         {
 #ifdef USE_SHADING
+                            if (param_shading)
                             col=curshades[((byte *)shape)[newstart+j]];
-#else
-                            col=((byte *)shape)[newstart+j];
+                            else
 #endif
+                            col=((byte *)shape)[newstart+j];
                             if(scrstarty<0) scrstarty=0;
                             if(screndy>viewheight) screndy=viewheight,j=endy;
 
--- a/wl_draw.cpp
+++ b/wl_draw.cpp
@@ -306,10 +306,11 @@ void ScalePost()
     if(yw < 0) return;
 
 #ifdef USE_SHADING
+    if (param_shading)
     col = curshades[postsource[yw]];
-#else
-    col = postsource[yw];
+    else
 #endif
+    col = postsource[yw];
     yendoffs = yendoffs * vbufPitch + postx;
     while(yoffs <= yendoffs)
     {
@@ -325,10 +326,11 @@ void ScalePost()
             while(ywcount <= 0);
             if(yw < 0) break;
 #ifdef USE_SHADING
+            if (param_shading)
             col = curshades[postsource[yw]];
-#else
-            col = postsource[yw];
+            else
 #endif
+            col = postsource[yw];
         }
         yendoffs -= vbufPitch;
     }
@@ -639,16 +641,21 @@ void VGAClearScreen (void)
     int y;
     byte *ptr = vbuf;
 #ifdef USE_SHADING
+    if (param_shading)
+    {
     for(y = 0; y < viewheight / 2; y++, ptr += vbufPitch)
         memset(ptr, shadetable[GetShade((viewheight / 2 - y) << 3)][ceiling], viewwidth);
     for(; y < viewheight; y++, ptr += vbufPitch)
         memset(ptr, shadetable[GetShade((y - viewheight / 2) << 3)][0x19], viewwidth);
-#else
+    }
+    else
+#endif
+    {
     for(y = 0; y < viewheight / 2; y++, ptr += vbufPitch)
         memset(ptr, ceiling, viewwidth);
     for(; y < viewheight; y++, ptr += vbufPitch)
         memset(ptr, 0x19, viewwidth);
-#endif
+    }
 }
 
 //==========================================================================
@@ -755,10 +762,11 @@ void ScaleShape (int xcenter, int shapen
                             if(scrstarty!=screndy && screndy>0)
                             {
 #ifdef USE_SHADING
+                                if (param_shading)
                                 col=curshades[((byte *)shape)[newstart+j]];
-#else
-                                col=((byte *)shape)[newstart+j];
+                                else
 #endif
+                                col=((byte *)shape)[newstart+j];
                                 if(scrstarty<0) scrstarty=0;
                                 if(screndy>viewheight) screndy=viewheight,j=endy;
 
--- a/wl_floorceiling.cpp
+++ b/wl_floorceiling.cpp
@@ -66,16 +66,21 @@ void DrawFloorAndCeiling(byte *vbuf, uns
                     v = (gv >> (TILESHIFT - TEXTURESHIFT)) & (TEXTURESIZE - 1);
                     unsigned texoffs = (u << TEXTURESHIFT) + (TEXTURESIZE - 1) - v;
 #ifdef USE_SHADING
+                    if (param_shading)
+                    {
                     if(curtoptex)
                         vbuf[top_add] = curshades[toptex[texoffs]];
                     if(curbottex)
                         vbuf[bot_add] = curshades[bottex[texoffs]];
-#else
+                    }
+                    else
+#endif
+                    {
                     if(curtoptex)
                         vbuf[top_add] = toptex[texoffs];
                     if(curbottex)
                         vbuf[bot_add] = bottex[texoffs];
-#endif
+                    }
                 }
             }
             gu += du;
--- a/wl_main.cpp
+++ b/wl_main.cpp
@@ -92,6 +92,7 @@ int     param_audiobuffer = -1;
 int     param_mission = 0;
 boolean param_ignorenumchunks = false;
 boolean always_run = false;
+boolean param_shading = false;
 
 /*
 =============================================================================
@@ -1694,6 +1695,10 @@ void CheckParameters(int argc, char *arg
             fullscreen = true;
         else IFARG("--nograbmouse")
             grabmouse = false;
+#ifdef USE_SHADING
+        else IFARG("--shading")
+            param_shading = true;
+#endif
         else IFARG("--res")
         {
             if(i + 2 >= argc)
@@ -1830,6 +1835,9 @@ void CheckParameters(int argc, char *arg
             " --demotest             Skips right into the demo loop\n"
             " --fullscreen           Starts the game in fullscreen mode\n"
             " --nograbmouse          Does not grab the mouse in windowed mode\n"
+#ifdef USE_SHADING
+            " --shading              Enables shading support\n"
+#endif
             " --res <width> <height> Sets the screen resolution\n"
             "                        (must be multiple of 320x200)\n"
             " --resf <w> <h>         Sets any screen resolution >= 320x200\n"