ref: 50492913a5bc5186c79471e14e85ce513c271204
parent: 8d351b307eaa85ea960760c04e5abb66ac2dd414
author: Tanguy Fautre <tanguy@fautre.com>
date: Sat Feb 15 15:07:47 EST 2020
Disable pixelsAllowed limit by default, causes too many pixels not to be drawn in cut scenes, logos, minimaps, etc.
--- a/Engine/src/draw.c
+++ b/Engine/src/draw.c
@@ -10,7 +10,9 @@
#include "build.h"
#include "draw.h"
-int32_t pixelsAllowed = 10000000000;
+#if RENDER_LIMIT_PIXELS
+int64_t pixelsAllowed = 10000000000;
+#endif
uint8_t *transluc = NULL;
@@ -20,20 +22,6 @@
#define shrd(a,b,c) (((b)<<(32-(c))) | ((a)>>(c)))
#define shld(a,b,c) (((b)>>(32-(c))) | ((a)<<(c)))
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/* --------------- WALLS RENDERING METHOD (USED TO BE HIGHLY OPTIMIZED ASSEMBLY) ----------------------------*/
extern int32_t asm1;
extern intptr_t asm2;
@@ -50,8 +38,6 @@
textureSetup = textureAddress;
}
-
-
//FCS: Draw ceiling/floors
//Draw a line from destination in the framebuffer to framebuffer-numPixels
void hlineasm4(int32_t numPixels, int32_t shade, uint32_t i4, uint32_t i5, uint8_t *dest){
@@ -73,8 +59,10 @@
source = i5 >> shifter;
source = shld(source,i4,bits);
source = texture[source];
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = globalpalwritten[shade|source];
dest--;
@@ -126,7 +114,9 @@
ebp &= rmach_esi;
i1 = ((i1&0xffffff00)|rmach_edx[i3]);
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
dest[numPixels - offset] = (i1&0xff);
texture -= ebp;
@@ -175,7 +165,9 @@
//Check if this colorIndex is the transparent color (255).
if ((colorIndex&0xff) != 255) {
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
{
i1 = ((i1&0xffffff00)|rmmach_edx[colorIndex]);
dest[numPixels - offset] = (i1 & 0xff);
@@ -204,8 +196,6 @@
//FCS: RENDER TOP AND BOTTOM COLUMN
int32_t prevlineasm1(int32_t i1, uint8_t* palette, int32_t i3, int32_t i4, uint8_t *source, uint8_t *dest)
{
-
-
if (i3 == 0)
{
if (!RENDER_DRAW_TOP_AND_BOTTOM_COLUMN)
@@ -215,11 +205,11 @@
i4 = ((uint32_t)i4) >> mach3_al;
i4 = (i4&0xffffff00) | source[i4];
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = palette[i4];
-
-
return i1;
} else {
return vlineasm1(i1,palette,i3,i4,source,dest);
@@ -241,8 +231,10 @@
temp = ((uint32_t)vplce) >> mach3_al;
temp = texture[temp];
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = palookupoffse[temp];
vplce += vince;
@@ -274,8 +266,10 @@
if (transrev)
colorIndex = ((colorIndex>>8)|(colorIndex<<8));
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = transluc[colorIndex];
}
@@ -329,7 +323,9 @@
if (transrev)
val = ((val>>8)|(val<<8));
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
((uint8_t *)i6)[tran2edi1] = transluc[val];
}
} else if (i4 == 255) { // skipdraw2
@@ -340,7 +336,9 @@
if (transrev)
val = ((val>>8)|(val<<8));
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
((uint8_t *)i6)[tran2edi] = transluc[val];
} else {
uint16_t l = ((uint8_t *)i6)[tran2edi]<<8;
@@ -351,11 +349,15 @@
l = ((l>>8)|(l<<8));
r = ((r>>8)|(r<<8));
}
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
{
((uint8_t *)i6)[tran2edi] = transluc[l];
((uint8_t *)i6)[tran2edi1] =transluc[r];
+#if RENDER_LIMIT_PIXELS
pixelsAllowed--;
+#endif
}
}
i6 += bytesperline;
@@ -378,8 +380,10 @@
if (temp != 255)
{
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
- *dest = palookupoffse[temp];
+#endif
+ *dest = palookupoffse[temp];
}
vplce += vince;
@@ -416,8 +420,10 @@
temp = ((uint32_t)vplce[i]) >> mach3_al;
temp = (((uint8_t *)(bufplce[i]))[temp]);
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
dest[index+i] = palookupoffse [i] [temp];
vplce[i] += vince[i];
@@ -444,8 +450,10 @@
do {
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed <= 0)
return;
+#endif
for (i = 0; i < 4; i++)
{
@@ -454,7 +462,9 @@
temp = (((uint8_t *)(bufplce[i]))[temp]);
if (temp != 255)
{
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
dest[index+i] = palookupoffse[i][temp];
}
vplce[i] += vince[i];
@@ -525,8 +535,10 @@
while(1) {
i1 = (i1&0xffffff00) | (((uint8_t *)spal_eax)[i1]&0xff);
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = i1;
dest += bytesperline;
@@ -585,8 +597,10 @@
if ((colorIndex&0xff) != 255)
{
colorIndex = (colorIndex&0xffffff00) | (((uint8_t *)spal_eax)[colorIndex]&0xff);
-
+
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = colorIndex;
}
@@ -666,7 +680,9 @@
colorIndex = transluc[val];
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = colorIndex;
}
@@ -738,7 +754,9 @@
//Skip transparent color.
if ((colorIndex&0xff) != 0xff){
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*dest = mmach_asm3[colorIndex];
}
i2 += mmach_asm1;
@@ -792,7 +810,9 @@
if (transrev)
val = ((val>>8)|(val<<8));
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*i6 = transluc[val];
}
@@ -899,7 +919,9 @@
eax = ((eax & 0xffffff00) | (*((uint8_t*)(ebx + edx))));
ebx = esi;
+#if RENDER_LIMIT_PIXELS
if (pixelsAllowed-- > 0)
+#endif
*((uint8_t *)i1) = (eax&0xff);
edx = edi;
--- a/Engine/src/draw.h
+++ b/Engine/src/draw.h
@@ -75,8 +75,10 @@
//FCS: In order to see how the engine renders different part of the screen you can set the following macros
//VISUALIZE RENDERER
-#define MAX_PIXEL_RENDERERED ((1600*1200)+20000 )
-extern int32_t pixelsAllowed;
+#define RENDER_LIMIT_PIXELS 0 // tanguyf: pixelsAllowed causes too many subtle rendering bugs to be left on by default
+#if RENDER_LIMIT_PIXELS
+extern int64_t pixelsAllowed;
+#endif
#define RENDER_DRAW_WALL_BORDERS 1
#define RENDER_DRAW_WALL_INSIDE 1
@@ -84,7 +86,7 @@
#define RENDER_DRAW_TOP_AND_BOTTOM_COLUMN 1
#define RENDER_SLOPPED_CEILING_AND_FLOOR 1
-#if RENDER_DRAW_WALL_BORDERS && RENDER_DRAW_WALL_INSIDE && RENDER_DRAW_CEILING_AND_FLOOR && RENDER_DRAW_TOP_AND_BOTTOM_COLUMN && RENDER_SLOPPED_CEILING_AND_FLOOR && MAX_PIXEL_RENDERERED!=0
+#if RENDER_DRAW_WALL_BORDERS && RENDER_DRAW_WALL_INSIDE && RENDER_DRAW_CEILING_AND_FLOOR && RENDER_DRAW_TOP_AND_BOTTOM_COLUMN && RENDER_SLOPPED_CEILING_AND_FLOOR
#define CLEAR_FRAMEBUFFER 0
#else
#define CLEAR_FRAMEBUFFER 1
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -2782,7 +2782,6 @@
}
}
-int pixelRenderable = 0;
//#include "keyboard.h"
//void WriteLastPaletteToFile(void);
//void WriteTranslucToFile(void);
@@ -2812,12 +2811,10 @@
}
*/
- pixelRenderable+=100;
- if (pixelRenderable >= MAX_PIXEL_RENDERERED)
- pixelRenderable = 0 ;
-
//pixelsAllowed = pixelRenderable;
+#if RENDER_LIMIT_PIXELS
pixelsAllowed = 100000000;
+#endif
//printf("%d\n",pixelsAllowed);
beforedrawrooms = 0;
--
⑨