shithub: cstory

Download patch

ref: 80e217edf30c14d569a0798f1e946f59da382ec0
parent: b3843d596c6daf204aba5b806acfd224f969d445
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Nov 15 15:24:53 EST 2019

Clean-up Fade.cpp

--- a/src/Fade.cpp
+++ b/src/Fade.cpp
@@ -23,18 +23,18 @@
 static FADE gFade;
 static unsigned long mask_color;
 
-void InitFade()
+void InitFade(void)
 {
 	memset(&gFade, 0, sizeof(FADE));
 	mask_color = GetCortBoxColor(RGB(0, 0, 0x20));
 }
 
-void SetFadeMask()
+void SetFadeMask(void)
 {
 	gFade.bMask = TRUE;
 }
 
-void ClearFade()
+void ClearFade(void)
 {
 	gFade.bMask = FALSE;
 	gFade.mode = 0;
@@ -42,14 +42,17 @@
 
 void StartFadeOut(signed char dir)
 {
+	int x;
+	int y;
+
 	gFade.mode = 2;
 	gFade.count = 0;
 	gFade.dir = dir;
 	gFade.bMask = FALSE;
 
-	for (int y = 0; y < FADE_HEIGHT; y++)
+	for (y = 0; y < FADE_HEIGHT; ++y)
 	{
-		for (int x = 0; x < FADE_WIDTH; x++)
+		for (x = 0; x < FADE_WIDTH; ++x)
 		{
 			gFade.ani_no[y][x] = 0;
 			gFade.flag[y][x] = FALSE;
@@ -67,9 +70,9 @@
 	gFade.dir = dir;
 	gFade.bMask = TRUE;
 
-	for (y = 0; y < FADE_HEIGHT; y++)
+	for (y = 0; y < FADE_HEIGHT; ++y)
 	{
-		for (x = 0; x < FADE_WIDTH; x++)
+		for (x = 0; x < FADE_WIDTH; ++x)
 		{
 			gFade.ani_no[y][x] = 15;
 			gFade.flag[y][x] = FALSE;
@@ -76,10 +79,10 @@
 		}
 	}
 
-	x = x;	// x is assigned to itself. Thanks, Pixel. (Most likely, the original code wasn't written the exact same way)
+	x = x;	// This probably doesn't match the original source code, but it produces the same assembly
 }
 
-void ProcFade()
+void ProcFade(void)
 {
 	int x;
 	int y;
@@ -90,93 +93,65 @@
 			switch (gFade.dir)
 			{
 				case 0:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == x)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 2:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if (gFade.count == x)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 1:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if ((FADE_HEIGHT - 1) - gFade.count == y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 3:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if (gFade.count == y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 4:
-					for (y = 0; y < (FADE_HEIGHT / 2); y++)
-					{
-						for (x = 0; x < (FADE_WIDTH / 2); x++)
-						{
+					for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+						for (x = 0; x < (FADE_WIDTH / 2); ++x)
 							if (gFade.count == x + y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = 0; y < (FADE_HEIGHT / 2); y++)
-					{
-						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
-						{
+
+					for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
 							if (gFade.count == y + ((FADE_WIDTH - 1) - x))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < (FADE_WIDTH / 2); x++)
-						{
+
+					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+						for (x = 0; x < (FADE_WIDTH / 2); ++x)
 							if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
-					{
-						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
-						{
+
+					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
 							if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 			}
 
-			for (y = 0; y < FADE_HEIGHT; y++)
-			{
-				for (x = 0; x < FADE_WIDTH; x++)
-				{
+			for (y = 0; y < FADE_HEIGHT; ++y)
+				for (x = 0; x < FADE_WIDTH; ++x)
 					if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x])
 						++gFade.ani_no[y][x];
-				}
-			}
 
 			if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
 			{
@@ -192,93 +167,65 @@
 			switch (gFade.dir)
 			{
 				case 0:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == x)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 2:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if (gFade.count == x)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 1:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if ((FADE_HEIGHT - 1) - gFade.count == y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 3:
-					for (y = 0; y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < FADE_WIDTH; x++)
-						{
+					for (y = 0; y < FADE_HEIGHT; ++y)
+						for (x = 0; x < FADE_WIDTH; ++x)
 							if (gFade.count == y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 
 				case 4:
-					for (y = 0; y < (FADE_HEIGHT / 2); y++)
-					{
-						for (x = 0; x < (FADE_WIDTH / 2); x++)
-						{
+					for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+						for (x = 0; x < (FADE_WIDTH / 2); ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == x + y)
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = 0; y < (FADE_HEIGHT / 2); y++)
-					{
-						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
-						{
+
+					for (y = 0; y < (FADE_HEIGHT / 2); ++y)
+						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == y + ((FADE_WIDTH - 1) - x))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
-					{
-						for (x = 0; x < (FADE_WIDTH / 2); x++)
-						{
+
+					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+						for (x = 0; x < (FADE_WIDTH / 2); ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == x + ((FADE_HEIGHT - 1) - y))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
-					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
-					{
-						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
-						{
+
+					for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; ++y)
+						for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; ++x)
 							if ((FADE_WIDTH - 1) - gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
 								gFade.flag[y][x] = TRUE;
-						}
-					}
+
 					break;
 			}
 
-			for (y = 0; y < FADE_HEIGHT; y++)
-			{
-				for (x = 0; x < FADE_WIDTH; x++)
-				{
+			for (y = 0; y < FADE_HEIGHT; ++y)
+				for (x = 0; x < FADE_WIDTH; ++x)
 					if (gFade.ani_no[y][x] > 0 && gFade.flag[y][x])
 						--gFade.ani_no[y][x];
-				}
-			}
 
 			if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
 				gFade.mode = 0;
@@ -287,8 +234,11 @@
 	}
 }
 
-void PutFade()
+void PutFade(void)
 {
+	int x;
+	int y;
+
 	RECT rect;
 	rect.top = 0;
 	rect.bottom = 16;
@@ -302,18 +252,18 @@
 	if (gFade.mode == 0)
 		return;
 
-	for (int y = 0; y < FADE_HEIGHT; y++)
+	for (y = 0; y < FADE_HEIGHT; ++y)
 	{
-		for (int x = 0; x < FADE_WIDTH; x++)
+		for (x = 0; x < FADE_WIDTH; ++x)
 		{
-			rect.left = 16 * gFade.ani_no[y][x];
+			rect.left = gFade.ani_no[y][x] * 16;
 			rect.right = rect.left + 16;
-			PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE);
+			PutBitmap3(&grcGame, x * 16, y * 16, &rect, SURFACE_ID_FADE);
 		}
 	}
 }
 
-BOOL GetFadeActive()
+BOOL GetFadeActive(void)
 {
 	if (gFade.mode == 0)
 		return FALSE;
--- a/src/Fade.h
+++ b/src/Fade.h
@@ -2,11 +2,11 @@
 
 #include "WindowsWrapper.h"
 
-void InitFade();
-void SetFadeMask();
-void ClearFade();
+void InitFade(void);
+void SetFadeMask(void);
+void ClearFade(void);
 void StartFadeOut(signed char dir);
 void StartFadeIn(signed char dir);
-void ProcFade();
-void PutFade();
-BOOL GetFadeActive();
+void ProcFade(void);
+void PutFade(void);
+BOOL GetFadeActive(void);