shithub: cstory

Download patch

ref: b89207b5861c20b6178b14ebbf40278fd69500d8
parent: 76dc1f81ec555507a47135b86eed334b729d4479
parent: c52812664e563190db5e2c377a9db4334c255e12
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Apr 19 18:46:04 EDT 2020

Merge branch 'accurate' into portable

--- a/src/Boss.cpp
+++ b/src/Boss.cpp
@@ -35,7 +35,7 @@
 
 void PutBossChar(int fx, int fy)
 {
-	char a = 0;
+	signed char a = 0;
 	int b;
 
 	int side;
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -8,8 +8,8 @@
 #include "File.h"
 #include "Main.h"
 
-static const char* const config_filename = "Config.dat";	// Not the original name
-static const char* const config_magic = "DOUKUTSU20041206";	// Not the original name
+static const char* const gConfigName = "Config.dat";
+static const char* const gProof = "DOUKUTSU20041206";
 
 BOOL LoadConfigData(CONFIG *conf)
 {
@@ -18,7 +18,7 @@
 
 	// Get path
 	char path[MAX_PATH];
-	sprintf(path, "%s/%s", gModulePath, config_filename);
+	sprintf(path, "%s/%s", gModulePath, gConfigName);
 
 	// Open file
 	FILE *fp = fopen(path, "rb");
@@ -46,7 +46,7 @@
 	fclose(fp);
 
 	// Check if version is not correct, and return if it failed
-	if (strcmp(conf->proof, config_magic))
+	if (strcmp(conf->proof, gProof))
 	{
 		memset(conf, 0, sizeof(CONFIG));
 		return FALSE;
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -50,6 +50,7 @@
 
 BOOL Flip_SystemTask(void)
 {
+	// TODO - Not the original variable names
 	static unsigned long timePrev;
 	static unsigned long timeNow;
 
@@ -412,7 +413,7 @@
 
 void BackupSurface(SurfaceID surf_no, const RECT *rect)
 {
-	static RenderBackend_Rect scaled_rect;
+	static RenderBackend_Rect scaled_rect;	// TODO - Not the original variable name
 	scaled_rect.left = rect->left * magnification;
 	scaled_rect.top = rect->top * magnification;
 	scaled_rect.right = rect->right * magnification;
@@ -511,7 +512,7 @@
 
 void CortBox(const RECT *rect, unsigned long col)
 {
-	static RenderBackend_Rect dst_rect;
+	static RenderBackend_Rect dst_rect;	// TODO - Not the original variable name
 	dst_rect.left = rect->left * magnification;
 	dst_rect.top = rect->top * magnification;
 	dst_rect.right = rect->right * magnification;
@@ -526,7 +527,7 @@
 
 void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
 {
-	static RenderBackend_Rect dst_rect;
+	static RenderBackend_Rect dst_rect;	// TODO - Not the original variable name
 	dst_rect.left = rect->left * magnification;
 	dst_rect.top = rect->top * magnification;
 	dst_rect.right = rect->right * magnification;
@@ -541,7 +542,9 @@
 	RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue);
 }
 
-BOOL DummiedOutLogFunction(int unknown)
+// Dummied-out log function
+// According to the Mac port, its name really is just "out".
+static BOOL out(int unknown)
 {
 	char unknown2[0x100];
 	int unknown3;
@@ -557,7 +560,8 @@
 	return TRUE;
 }
 
-int RestoreSurfaces(void)	// Guessed function name - this doesn't exist in the Linux port
+// TODO - Probably not the original variable name (this is an educated guess)
+int RestoreSurfaces(void)
 {
 	int s;
 	RECT rect;
@@ -570,7 +574,7 @@
 	{
 		++surfaces_regenerated;
 		RenderBackend_RestoreSurface(framebuffer);
-		DummiedOutLogFunction(0x62);
+		out(0x62);
 	}
 
 	for (s = 0; s < SURFACE_ID_MAX; ++s)
@@ -581,7 +585,7 @@
 			{
 				++surfaces_regenerated;
 				RenderBackend_RestoreSurface(surf[s]);
-				DummiedOutLogFunction(0x30 + s);
+				out(0x30 + s);
 
 				if (!surface_metadata[s].bSystem)
 				{
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -41,7 +41,7 @@
 		--gFrame.quake;
 	}
 
-	// This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6)
+	// This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6) or the Mac port
 /*	if (gFrame.x / 0x200 < 0)
 		gFrame.x = 0;
 	if (gFrame.y / 0x200 < 0)
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -34,7 +34,7 @@
 int gJoystickButtonTable[8];
 
 static BOOL bActive = TRUE;
-static BOOL bFps = FALSE;
+static BOOL bFPS = FALSE;
 
 static int windowWidth;
 static int windowHeight;
@@ -48,38 +48,38 @@
 // Framerate stuff
 void PutFramePerSecound(void)
 {
-	if (bFps)
+	if (bFPS)
 	{
-		const unsigned long fps = GetFramePerSecound();
+		const unsigned long fps = CountFramePerSecound();
 		PutNumber4(WINDOW_WIDTH - 40, 8, fps, FALSE);
 	}
 }
 
-unsigned long GetFramePerSecound(void)
+unsigned long CountFramePerSecound(void)
 {
-	unsigned long current_tick;
-	static BOOL need_new_base_tick = TRUE;
-	static unsigned long frames_this_second;
-	static unsigned long current_frame;
-	static unsigned long base_tick;
+	unsigned long current_tick;	// The original name for this variable is unknown
+	static BOOL first = TRUE;
+	static unsigned long max_count;
+	static unsigned long count;
+	static unsigned long wait;
 
-	if (need_new_base_tick)
+	if (first)
 	{
-		base_tick = Backend_GetTicks();
-		need_new_base_tick = FALSE;
+		wait = Backend_GetTicks();
+		first = FALSE;
 	}
 
 	current_tick = Backend_GetTicks();
-	++current_frame;
+	++count;
 
-	if (base_tick + 1000 <= current_tick)
+	if (wait + 1000 <= current_tick)
 	{
-		base_tick += 1000;
-		frames_this_second = current_frame;
-		current_frame = 0;
+		wait += 1000;
+		max_count = count;
+		count = 0;
 	}
 
-	return frames_this_second;
+	return max_count;
 }
 
 // TODO - Inaccurate stack frame
@@ -309,7 +309,7 @@
 	}
 
 	if (IsKeyFile("fps"))
-		bFps = TRUE;
+		bFPS = TRUE;
 
 	// Set rects
 	RECT rcLoading = {0, 0, 64, 8};
--- a/src/Main.h
+++ b/src/Main.h
@@ -10,7 +10,7 @@
 extern BOOL gbUseJoystick;
 
 void PutFramePerSecound(void);
-unsigned long GetFramePerSecound(void);
+unsigned long CountFramePerSecound(void);
 
 void InactiveWindow(void);
 void ActiveWindow(void);
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -27,13 +27,8 @@
 
 const char *gPassPixEve = "PXE";
 
-void InitNpChar(void)
+static void SetUniqueParameter(NPCHAR *npc)
 {
-	memset(gNPC, 0, sizeof(gNPC));
-}
-
-void SetUniqueParameter(NPCHAR *npc)
-{
 	int code = npc->code_char;
 	npc->surf = (SurfaceID)gNpcTable[code].surf;
 	npc->hit_voice = gNpcTable[code].hit_voice;
@@ -49,6 +44,11 @@
 	npc->view.back = gNpcTable[code].view.back * 0x200;
 	npc->view.top = gNpcTable[code].view.top * 0x200;
 	npc->view.bottom = gNpcTable[code].view.bottom * 0x200;
+}
+
+void InitNpChar(void)
+{
+	memset(gNPC, 0, sizeof(gNPC));
 }
 
 BOOL LoadEvent(const char *path_event)