shithub: cstory

Download patch

ref: 603cfdd9dbbbe541d674ec7e61a8aaecc8b1af5f
parent: ad5785611bfb6f71c7dd86d7d52e620cd5dbe208
parent: 0730bb74eff37e5cd2640eded4a11dd2f0a70003
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Sep 29 12:44:49 EDT 2020

Merge branch 'accurate' into portable

--- a/src/BossOhm.cpp
+++ b/src/BossOhm.cpp
@@ -263,9 +263,9 @@
 			if (gBoss[0].act_wait > 20 && gBoss[0].act_wait < 80 && !(gBoss[0].act_wait % 3))
 			{
 				if (Random(0, 9) < 8)
-					SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x333, 0, NULL, 0x100);
+					SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x10 * 0x200 / 10, 0, NULL, 0x100);
 				else
-					SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x333, 2, NULL, 0x100);
+					SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-0x100, 0x100), -0x10 * 0x200 / 10, 2, NULL, 0x100);
 
 				PlaySoundObject(39, SOUND_MODE_PLAY);
 			}
@@ -384,7 +384,7 @@
 
 			if (gBoss[0].act_wait < 30 && gBoss[0].act_wait % 5 == 0)
 			{
-				SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-341, 341), -0x333, 0, NULL, 0x100);
+				SetNpChar(48, gBoss[0].x, gBoss[0].y - (16 * 0x200), Random(-341, 341), -0x10 * 0x200 / 10, 0, NULL, 0x100);
 				PlaySoundObject(39, SOUND_MODE_PLAY);
 			}
 
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -19,6 +19,20 @@
 #include "Stage.h"
 #include "TextScr.h"
 
+enum CREDIT_MODE
+{
+	CREDIT_MODE_STOP,
+	CREDIT_MODE_SCROLL_READ,
+	CREDIT_MODE_SCROLL_WAIT
+};
+
+enum ILLUSTRATION_ACTION
+{
+	ILLUSTRATION_ACTION_IDLE,
+	ILLUSTRATION_ACTION_SLIDE_IN,
+	ILLUSTRATION_ACTION_SLIDE_OUT
+};
+
 struct CREDIT
 {
 	long size;
@@ -25,7 +39,7 @@
 	char *pData;
 	int offset;
 	int wait;
-	int mode;
+	CREDIT_MODE mode;
 	int start_x;
 };
 
@@ -40,7 +54,7 @@
 
 struct ILLUSTRATION
 {
-	int act_no;
+	ILLUSTRATION_ACTION act_no;
 	int x;
 };
 
@@ -62,10 +76,10 @@
 	for (s = 0; s < MAX_STRIP; ++s)
 	{
 		// Move up
-		if (Strip[s].flag & 0x80 && Credit.mode)
+		if (Strip[s].flag & 0x80 && Credit.mode != CREDIT_MODE_STOP)
 			Strip[s].y -= 0x100;
 		// Get removed when off-screen
-		if (Strip[s].y <= -0x2000)
+		if (Strip[s].y <= -16 * 0x200)
 			Strip[s].flag = 0;
 	}
 }
@@ -155,18 +169,18 @@
 {
 	switch (Illust.act_no)
 	{
-		case 0: // Off-screen to the left
+		case ILLUSTRATION_ACTION_IDLE: // Off-screen to the left
 			Illust.x = -160 * 0x200;
 			break;
 
-		case 1: // Move in from the left
+		case ILLUSTRATION_ACTION_SLIDE_IN: // Move in from the left
 			Illust.x += 40 * 0x200;
 			if (Illust.x > 0)
 				Illust.x = 0;
 			break;
 
-		case 2: // Move out from the right
-			Illust.x -= 0x5000;
+		case ILLUSTRATION_ACTION_SLIDE_OUT: // Move out from the right
+			Illust.x -= 40 * 0x200;
 			if (Illust.x < -160 * 0x200)
 				Illust.x = -160 * 0x200;
 			break;
@@ -177,7 +191,7 @@
 void PutIllust(void)
 {
 	RECT rcIllust = {0, 0, 160, 240};
-#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240
+#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Move this to CSE2EX
 	// Widescreen edit
 	RECT rcClip = {(WINDOW_WIDTH - 320) / 2, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
 	PutBitmap3(&rcClip, (Illust.x / 0x200) + ((WINDOW_WIDTH - 320) / 2), (WINDOW_HEIGHT - 240) / 2, &rcIllust, SURFACE_ID_CREDITS_IMAGE);
@@ -248,7 +262,6 @@
 
 	// Read data
 	fread(Credit.pData, 1, Credit.size, fp);
-	EncryptionBinaryData2((unsigned char*)Credit.pData, Credit.size);
 
 #ifdef FIX_MAJOR_BUGS
 	// The original game forgot to close the file
@@ -255,16 +268,18 @@
 	fclose(fp);
 #endif
 
+	EncryptionBinaryData2((unsigned char*)Credit.pData, Credit.size);
+
 	// Reset credits
 	Credit.offset = 0;
 	Credit.wait = 0;
-	Credit.mode = 1;
+	Credit.mode = CREDIT_MODE_SCROLL_READ;
 	Illust.x = -160 * 0x200;
-	Illust.act_no = 0;
+	Illust.act_no = ILLUSTRATION_ACTION_IDLE;
 
 	// Modify cliprect
 	grcGame.left = WINDOW_WIDTH / 2;
-#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240
+#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Move to CSE2EX
 	// These three are non-vanilla: for wide/tallscreen support
 	grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320;
 	grcGame.top = (WINDOW_HEIGHT - 240) / 2;
@@ -283,10 +298,10 @@
 // Get number from text (4 digit)
 static int GetScriptNumber(const char *text)
 {
-	return (text[0] - '0') * 1000 +
-		(text[1] - '0') * 100 +
-		(text[2] - '0') * 10 +
-		text[3] - '0';
+	return (text[0] - '0') * 1000
+	     + (text[1] - '0') * 100
+	     + (text[2] - '0') * 10
+	     + (text[3] - '0') * 1;
 }
 
 // Parse credits
@@ -304,7 +319,7 @@
 		{
 			case '[': // Create cast
 				// Get the range for the cast text
-				++Credit.offset;
+				Credit.offset += 1;
 
 				a = Credit.offset;
 
@@ -320,14 +335,15 @@
 
 				// Copy the text to the cast text
 				memcpy(text, &Credit.pData[Credit.offset], len);
-				text[len] = 0;
+				text[len] = '\0';
 
-				// Get cast id
+				// Get cast ID
 				Credit.offset = a;
-				len = GetScriptNumber(&Credit.pData[++Credit.offset]);
+				Credit.offset += 1;
+				len = GetScriptNumber(&Credit.pData[Credit.offset]);
 
 				// Create cast object
-				SetStripper(Credit.start_x, (WINDOW_HEIGHT * 0x200) + (8 * 0x200), text, len);
+				SetStripper(Credit.start_x, (WINDOW_HEIGHT + 8) * 0x200, text, len);
 
 				// Change offset
 				Credit.offset += 4;
@@ -334,24 +350,24 @@
 				return;
 
 			case '-': // Wait for X amount of frames
-				++Credit.offset;
+				Credit.offset += 1;
 				Credit.wait = GetScriptNumber(&Credit.pData[Credit.offset]);
 				Credit.offset += 4;
-				Credit.mode = 2;
+				Credit.mode = CREDIT_MODE_SCROLL_WAIT;
 				return;
 
 			case '+': // Change casts x-position
-				++Credit.offset;
+				Credit.offset += 1;
 				Credit.start_x = GetScriptNumber(&Credit.pData[Credit.offset]) * 0x200;
 				Credit.offset += 4;
 				return;
 
 			case '/': // Stop credits
-				Credit.mode = 0;
+				Credit.mode = CREDIT_MODE_STOP;
 				return;
 
 			case '!': // Change music
-				++Credit.offset;
+				Credit.offset += 1;
 				a = GetScriptNumber(&Credit.pData[Credit.offset]);
 				Credit.offset += 4;
 				ChangeMusic((MusicID)a);
@@ -358,12 +374,12 @@
 				return;
 
 			case '~': // Start fading out music
-				++Credit.offset;
+				Credit.offset += 1;
 				SetOrganyaFadeout();
 				return;
 
 			case 'j': // Jump to label
-				++Credit.offset;
+				Credit.offset += 1;
 
 				// Get number
 				b = GetScriptNumber(&Credit.pData[Credit.offset]);
@@ -372,25 +388,25 @@
 				Credit.offset += 4;
 
 				// Jump to specific label
-				if (1)
+				if (1) // This appears to be a hacked-up duplicate of some code from the below 'f' condition
 				{
 					while (Credit.offset < Credit.size)
 					{
 						if (Credit.pData[Credit.offset] == 'l')
 						{
-							// What is this
-							a = GetScriptNumber(&Credit.pData[++Credit.offset]);
+							Credit.offset += 1;
+							a = GetScriptNumber(&Credit.pData[Credit.offset]);
 							Credit.offset += 4;
+
 							if (b == a)
 								break;
 						}
-						else if (IsShiftJIS(Credit.pData[Credit.offset]))
-						{
-							Credit.offset += 2;
-						}
 						else
 						{
-							++Credit.offset;
+							if (IsShiftJIS(Credit.pData[Credit.offset]))
+								Credit.offset += 2;
+							else
+								Credit.offset += 1;
 						}
 					}
 				}
@@ -398,7 +414,7 @@
 				return;
 
 			case 'f': // Flag jump
-				++Credit.offset;
+				Credit.offset += 1;
 
 				// Read numbers XXXX:YYYY
 				a = GetScriptNumber(&Credit.pData[Credit.offset]);
@@ -414,18 +430,19 @@
 					{
 						if (Credit.pData[Credit.offset] == 'l')
 						{
-							a = GetScriptNumber(&Credit.pData[++Credit.offset]);
+							Credit.offset += 1;
+							a = GetScriptNumber(&Credit.pData[Credit.offset]);
 							Credit.offset += 4;
+
 							if (b == a)
 								break;
 						}
-						else if (IsShiftJIS(Credit.pData[Credit.offset]))
-						{
-							Credit.offset += 2;
-						}
 						else
 						{
-							++Credit.offset;
+							if (IsShiftJIS(Credit.pData[Credit.offset]))
+								Credit.offset += 2;
+							else
+								Credit.offset += 1;
 						}
 					}
 				}
@@ -433,7 +450,7 @@
 
 			default:
 				// Progress through file
-				++Credit.offset;
+				Credit.offset += 1;
 				break;
 		}
 	}
@@ -448,13 +465,13 @@
 	// Update script, or if waiting, decrement the wait value
 	switch (Credit.mode)
 	{
-		case 1:
+		case CREDIT_MODE_SCROLL_READ:
 			ActionCredit_Read();
 			break;
 
-		case 2:
+		case CREDIT_MODE_SCROLL_WAIT:
 			if (--Credit.wait <= 0)
-				Credit.mode = 1;
+				Credit.mode = CREDIT_MODE_SCROLL_READ;
 			break;
 	}
 }
@@ -463,13 +480,13 @@
 void SetCreditIllust(int a)
 {
 	ReloadIllust(a);
-	Illust.act_no = 1;
+	Illust.act_no = ILLUSTRATION_ACTION_SLIDE_IN;
 }
 
 // Slide illustration off-screen
 void CutCreditIllust(void)
 {
-	Illust.act_no = 2;
+	Illust.act_no = ILLUSTRATION_ACTION_SLIDE_OUT;
 }
 
 // Scene of the island falling
@@ -511,7 +528,7 @@
 		{
 			case 0:
 				// Move down
-				sprite.y += 0x33;
+				sprite.y += 0x200 / 10;
 				break;
 
 			case 1:
@@ -518,17 +535,17 @@
 				if (wait < 350)
 				{
 					// Move down at normal speed
-					sprite.y += 0x33;
+					sprite.y += 0x200 / 10;
 				}
 				else if (wait < 500)
 				{
 					// Move down slower
-					sprite.y += 0x19;
+					sprite.y += 0x200 / 20;
 				}
 				else if (wait < 600)
 				{
 					// Move down slow
-					sprite.y += 0xC;
+					sprite.y += 0x200 / 40;
 				}
 				else if (wait == 750)
 				{
--- a/src/MiniMap.cpp
+++ b/src/MiniMap.cpp
@@ -34,39 +34,39 @@
 		// No switch here.
 		if (a == 0)
 			Surface2Surface(x, line, &rcLevel[0], SURFACE_ID_MAP, SURFACE_ID_TEXT_BOX);
-		else if (a == 68 ||
-			a == 1 ||
-			a == 64 ||
-			a == 128 ||
-			a == 129 ||
-			a == 130 ||
-			a == 131 ||
-			a == 81 ||
-			a == 82 ||
-			a == 85 ||
-			a == 86 ||
-			a == 2 ||
-			a == 96 ||
-			a == 113 ||
-			a == 114 ||
-			a == 117 ||
-			a == 118 ||
-			a == 160 ||
-			a == 161 ||
-			a == 162 ||
-			a == 163)
+		else if (a == 68  ||
+		         a == 1   ||
+		         a == 64  ||
+		         a == 128 ||
+		         a == 129 ||
+		         a == 130 ||
+		         a == 131 ||
+		         a == 81  ||
+		         a == 82  ||
+		         a == 85  ||
+		         a == 86  ||
+		         a == 2   ||
+		         a == 96  ||
+		         a == 113 ||
+		         a == 114 ||
+		         a == 117 ||
+		         a == 118 ||
+		         a == 160 ||
+		         a == 161 ||
+		         a == 162 ||
+		         a == 163)
 			Surface2Surface(x, line, &rcLevel[1], SURFACE_ID_MAP, SURFACE_ID_TEXT_BOX);
-		else if (a == 67 ||
-			a == 99 ||
-			a == 80 ||
-			a == 83 ||
-			a == 84 ||
-			a == 87 ||
-			a == 96 ||	// This is already listed above, so that part of the expression is always false
-			a == 112 ||
-			a == 115 ||
-			a == 116 ||
-			a == 119)
+		else if (a == 67  ||
+		         a == 99  ||
+		         a == 80  ||
+		         a == 83  ||
+		         a == 84  ||
+		         a == 87  ||
+		         a == 96  ||	// This is already listed above, so this part of the expression is always false
+		         a == 112 ||
+		         a == 115 ||
+		         a == 116 ||
+		         a == 119)
 			Surface2Surface(x, line, &rcLevel[2], SURFACE_ID_MAP, SURFACE_ID_TEXT_BOX);
 		else
 			Surface2Surface(x, line, &rcLevel[3], SURFACE_ID_MAP, SURFACE_ID_TEXT_BOX);
@@ -123,8 +123,10 @@
 	rcMiniMap.top = 0;
 	rcMiniMap.bottom = gMap.length;
 
-	rcView.right = --rcView.left + gMap.width + 2;
-	rcView.bottom = --rcView.top + gMap.length + 2;
+	rcView.left -= 1;
+	rcView.right = rcView.left + gMap.width + 2;
+	rcView.top -= 1;
+	rcView.bottom = rcView.top + gMap.length + 2;
 	CortBox2(&rcMiniMap, 0, SURFACE_ID_MAP);
 
 	line = 0;
--- a/src/MyChar.cpp
+++ b/src/MyChar.cpp
@@ -259,14 +259,14 @@
 
 	if (gMC.flag & 0x100)
 	{
-		max_dash = 0x196;
-		max_move = 0x2FF;
-		gravity1 = 0x28;
-		gravity2 = 0x10;
-		jump = 0x280;
-		dash1 = 0x2A;
-		dash2 = 0x10;
-		resist = 0x19;
+		max_dash = 0x32C / 2;
+		max_move = 0x5FF / 2;
+		gravity1 = 0x50 / 2;
+		gravity2 = 0x20 / 2;
+		jump = 0x500 / 2;
+		dash1 = 0x200 / 6 / 2;
+		dash2 = 0x200 / 16 / 2;
+		resist = 0x200 / 10 / 2;
 	}
 	else
 	{
@@ -275,9 +275,9 @@
 		gravity1 = 0x50;
 		gravity2 = 0x20;
 		jump = 0x500;
-		dash1 = 0x55;
-		dash2 = 0x20;
-		resist = 0x33;
+		dash1 = 0x200 / 6;
+		dash2 = 0x200 / 16;
+		resist = 0x200 / 10;
 	}
 
 	// Don't create "?" effect
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -175,7 +175,7 @@
 	{
 		PlaySoundObject(17, SOUND_MODE_PLAY);
 		gMC.cond = 0;
-		SetDestroyNpChar(gMC.x, gMC.y, 0x1400, 0x40);
+		SetDestroyNpChar(gMC.x, gMC.y, 10 * 0x200, 0x40);
 		StartTextScript(40);
 	}
 }
--- a/src/NpcAct020.cpp
+++ b/src/NpcAct020.cpp
@@ -1241,7 +1241,7 @@
 
 	if (npc->act_no != 5)
 	{
-		npc->ym += 0x33;
+		npc->ym += 0x200 / 10;
 
 		if (npc->x < gMC.x)
 			npc->direct = 2;
--- a/src/NpcAct120.cpp
+++ b/src/NpcAct120.cpp
@@ -1203,7 +1203,7 @@
 			npc->direct = 2;
 	}
 
-	npc->ym += 0x33;
+	npc->ym += 0x200 / 10;
 	if (npc->ym > 0x5FF)
 		npc->ym = 0x5FF;
 
--- a/src/NpcAct180.cpp
+++ b/src/NpcAct180.cpp
@@ -271,13 +271,13 @@
 #else
 			if (npc->flag && 5)
 #endif
-				npc->ym += 0x10;
+				npc->ym += 0x200 / 32;
 			else
-				npc->ym += 0x33;
+				npc->ym += 0x200 / 10;
 		}
 		else
 		{
-			npc->ym += 0x33;
+			npc->ym += 0x200 / 10;
 		}
 	}
 
--- a/src/NpcAct260.cpp
+++ b/src/NpcAct260.cpp
@@ -1320,7 +1320,7 @@
 			break;
 	}
 
-	npc->ym += 0x33;
+	npc->ym += 0x200 / 10;
 	if (npc->ym > 0x5FF)
 		npc->ym = 0x5FF;
 
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -212,7 +212,8 @@
 			StopTextScript();
 			break;
 		}
-		else if (gKeyTrg & gKeyCancel)
+
+		if (gKeyTrg & gKeyCancel)
 		{
 			StopTextScript();
 			LoadTextScript_Stage(old_script_path.c_str());