shithub: cstory

Download patch

ref: 0510e017e16e54423d50e921d722c1c4e68979b7
parent: 355b3036355510bea73b1f16bce426ce43e2f680
parent: 2cb7bfbd3d32106a2c6aaa60b226591b38f0c72f
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Sep 9 22:03:31 EDT 2019

Merge branch 'accurate' into portable

--- a/assets/resources/afxres.h
+++ b/assets/resources/afxres.h
@@ -1,3 +1,3 @@
 // Quick-and-dirty shim to make CSE2.rc work in newer versions of Visual Studio
 
-#include "winres.h"
+#include "windows.h"
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -150,9 +150,6 @@
 			PutBitmap4(&grcGame, 320 - 4 * gBack.fx % 320, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
 
 			break;
-
-		default:
-			return;
 	}
 }
 
@@ -173,13 +170,13 @@
 	{
 		case 3:
 			x_1 = fx / 0x4000;
-			x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
+			x_2 = x_1 + (((WINDOW_WIDTH + (32 - 1)) / 32) + 1);
 			y_1 = 0;
 			y_2 = y_1 + 32;
 
 			for (y = y_1; y < y_2; y++)
 			{
-				ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
+				ypos = (y * 32 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
 
 				if (ypos < -32)
 					continue;
@@ -189,63 +186,12 @@
 
 				for (x = x_1; x < x_2; x++)
 				{
-					xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200;
+					xpos = (x * 32 * 0x200) / 0x200 - fx / 0x200;
 					PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
-					if (!y)
+					if (y == 0)
 						PutBitmap3(&grcGame, xpos, ypos, &rcWater[0], SURFACE_ID_LEVEL_BACKGROUND);
 				}
 			}
 
 	}
-/*
-	// Draw black bars
-	if (!(g_GameFlags & 8)) // Detect if credits are running
-	{
-		const BOOL fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point
-
-		// Get focus rect
-		int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8);
-		int focusY = gFrame.y + (WINDOW_HEIGHT << 8) - (240 << 8);
-		int focusR = focusX + (320 << 9);
-		int focusB = focusY + (240 << 9);
-
-		// Get borders
-		const int barLeft = fromFocus ? focusX : -0x1000;
-		const int barTop = fromFocus ? focusY : -0x1000;
-
-		const int barRight = fromFocus ? focusR : (gMap.width << 13) - 0x1000;
-		const int barBottom = fromFocus ? focusB : (gMap.length << 13) - 0x1000;
-
-		// Draw bars
-		RECT barRect;
-
-		// Left
-		barRect.left = 0;
-		barRect.top = 0;
-		barRect.right = (barLeft - gFrame.x) >> 9;
-		barRect.bottom = WINDOW_HEIGHT;
-		CortBox(&barRect, 0x000000);
-
-		// Top
-		barRect.left = 0;
-		barRect.top = 0;
-		barRect.right = WINDOW_WIDTH;
-		barRect.bottom = (barTop - gFrame.y) >> 9;
-		CortBox(&barRect, 0x000000);
-
-		// Right
-		barRect.left = (barRight - gFrame.x) >> 9;
-		barRect.top = 0;
-		barRect.right = WINDOW_WIDTH;
-		barRect.bottom = WINDOW_HEIGHT;
-		CortBox(&barRect, 0x000000);
-
-		// Bottom
-		barRect.left = 0;
-		barRect.top = (barBottom - gFrame.y) >> 9;
-		barRect.right = WINDOW_WIDTH;
-		barRect.bottom = WINDOW_HEIGHT;
-		CortBox(&barRect, 0x000000);
-	}
-	*/
 }
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -112,26 +112,26 @@
 	if (x < 0 || y < 0 || x >= gMap.width || y >= gMap.length)
 		return 0;
 
-	const size_t a = *(gMap.data + x + gMap.width * y);
+	const size_t a = *(gMap.data + x + (y * gMap.width));	// Yes, the original code really does do this
 	return gMap.atrb[a];
 }
 
 void DeleteMapParts(int x, int y)
 {
-	*(gMap.data + x + gMap.width * y) = 0;
+	*(gMap.data + x + (y * gMap.width)) = 0;
 }
 
 void ShiftMapParts(int x, int y)
 {
-	*(gMap.data + x + gMap.width * y) -= 1;
+	*(gMap.data + x + (y * gMap.width)) -= 1;
 }
 
 BOOL ChangeMapParts(int x, int y, unsigned char no)
 {
-	if (*(gMap.data + x + gMap.width * y) == no)
+	if (*(gMap.data + x + (y * gMap.width)) == no)
 		return FALSE;
 
-	*(gMap.data + x + gMap.width * y) = no;
+	*(gMap.data + x + (y * gMap.width)) = no;
 
 	for (int i = 0; i < 3; i++)
 		SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, 0, 0, 0, 0, 0);
@@ -152,10 +152,10 @@
 	int num_x;
 
 	// Get range to draw
-	num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1;
-	num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1;
-	put_x = (fx / 0x200 + 8) / 0x10;
-	put_y = (fy / 0x200 + 8) / 0x10;
+	num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
+	num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
+	put_x = (fx / 0x200 + 8) / 16;
+	put_y = (fy / 0x200 + 8) / 16;
 
 	for (j = put_y; j < put_y + num_y; j++)
 	{
@@ -169,12 +169,12 @@
 				continue;
 
 			// Draw tile
-			rect.left = 16 * (gMap.data[offset] % 0x10);
-			rect.top = 16 * (gMap.data[offset] / 0x10);
+			rect.left = 16 * (gMap.data[offset] % 16);
+			rect.top = 16 * (gMap.data[offset] / 16);
 			rect.right = rect.left + 16;
 			rect.bottom = rect.top + 16;
 
-			PutBitmap3(&grcGame, 0x10 * i - 8 - fx / 0x200, 0x10 * j - 8 - fy / 0x200, &rect, SURFACE_ID_LEVEL_TILESET);
+			PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
 		}
 	}
 }
@@ -193,8 +193,8 @@
 	int num_x;
 
 	// Get range to draw
-	num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
-	num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
+	num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
+	num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
 	put_x = (fx / 0x200 + 8) / 16;
 	put_y = (fy / 0x200 + 8) / 16;
 
@@ -210,15 +210,15 @@
 				continue;
 
 			// Draw tile
-			rect.left = 16 * (gMap.data[offset] % 0x10);
-			rect.top = 16 * (gMap.data[offset] / 0x10);
+			rect.left = 16 * (gMap.data[offset] % 16);
+			rect.top = 16 * (gMap.data[offset] / 16);
 			rect.right = rect.left + 16;
 			rect.bottom = rect.top + 16;
 
-			PutBitmap3(&grcGame, 16 * i - 8 - fx / 0x200, 16 * j - 8 - fy / 0x200, &rect, SURFACE_ID_LEVEL_TILESET);
+			PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_LEVEL_TILESET);
 
 			if (atrb == 0x43)
-				PutBitmap3(&grcGame, 16 * i - 8 - fx / 0x200, 16 * j - 8 - fy / 0x200, &rcSnack, SURFACE_ID_NPC_SYM);
+				PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rcSnack, SURFACE_ID_NPC_SYM);
 		}
 	}
 }
@@ -240,8 +240,8 @@
 	count += 2;
 
 	// Get range to draw
-	num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
-	num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
+	num_x = ((WINDOW_WIDTH + (16 - 1)) / 16) + 1;
+	num_y = ((WINDOW_HEIGHT + (16 - 1)) / 16) + 1;
 	put_x = (fx / 0x200 + 8) / 16;
 	put_y = (fy / 0x200 + 8) / 16;
 
@@ -267,7 +267,7 @@
 			{
 				case 128:
 				case 160:
-					rect.left = 224 + (count % 0x10);
+					rect.left = 224 + (count % 16);
 					rect.right = rect.left + 16;
 					rect.top = 48;
 					rect.bottom = rect.top + 16;
@@ -276,12 +276,12 @@
 				case 161:
 					rect.left = 224;
 					rect.right = rect.left + 16;
-					rect.top = 48 + (count % 0x10);
+					rect.top = 48 + (count % 16);
 					rect.bottom = rect.top + 16;
 					break;
 				case 130:
 				case 162:
-					rect.left = 240 - (count % 0x10);
+					rect.left = 240 - (count % 16);
 					rect.right = rect.left + 16;
 					rect.top = 48;
 					rect.bottom = rect.top + 16;
@@ -290,12 +290,12 @@
 				case 163:
 					rect.left = 224;
 					rect.right = rect.left + 16;
-					rect.top = 64 - (count % 0x10);
+					rect.top = 64 - (count % 16);
 					rect.bottom = rect.top + 16;
 					break;
 			}
 
-			PutBitmap3(&grcGame, 16 * i - 8 - fx / 0x200, 16 * j - 8 - fy / 0x200, &rect, SURFACE_ID_CARET);
+			PutBitmap3(&grcGame, (i * 16 - 8) - (fx / 0x200), (j * 16 - 8) - (fy / 0x200), &rect, SURFACE_ID_CARET);
 		}
 	}
 }
--