shithub: cstory

Download patch

ref: 5c8f80e611662ffe1bb98819a8bac1060af3c13d
parent: 8954e9aaca1e08ba86fbd476925cf051f5047e71
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Jan 31 09:36:54 EST 2019

Added some TSC commands and BossLife.cpp

--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,7 @@
 SOURCES = \
 	ArmsItem \
 	Back \
+	BossLife \
 	BulHit \
 	Bullet \
 	Caret \
--- /dev/null
+++ b/src/BossLife.cpp
@@ -1,0 +1,84 @@
+#include "BossLife.h"
+
+#include "Draw.h"
+#include "NpChar.h"
+#include "WindowsWrapper.h"
+
+static struct
+{
+	bool flag;
+	int *pLife;
+	int max;
+	int br;
+	int count;
+} gBL;
+
+void InitBossLife(void)
+{
+	gBL.flag = false;
+}
+
+bool StartBossLife(int code_event)
+{
+	for (int i = 0; i < 0x200; ++i)
+	{
+		if (gNPC[i].code_event == code_event)
+		{
+			gBL.flag = true;
+			gBL.max = gNPC[i].life;
+			gBL.br = gNPC[i].life;
+			gBL.pLife = &gNPC[i].life;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+bool StartBossLife2(void)
+{
+	// TODO uncomment me when Boss.cpp is done!
+//	gBL.flag = true;
+//	gBL.max = gBoss[0].life;
+//	gBL.br = gBoss[0].life;
+//	gBL.pLife = &gBoss[0].life;
+	return true;
+}
+
+void PutBossLife(void)
+{
+	RECT rcText = {0, 48, 32, 56};
+	RECT rcBox1 = {0, 0, 244, 8};
+	RECT rcBox2 = {0, 16, 244, 24};
+	RECT rcLife = {0, 24, 0, 32};
+	RECT rcBr = {0, 32, 232, 40};
+
+	if (gBL.flag)
+	{
+		if (*gBL.pLife >= 1)
+		{
+			rcLife.right = 198 * *gBL.pLife / gBL.max;
+	
+			if (gBL.br <= *gBL.pLife)
+			{
+				gBL.count = 0;
+			}
+			else if (++gBL.count > 30)
+			{
+				--gBL.br;
+			}
+	
+			rcBr.right = 198 * gBL.br / gBL.max;
+
+			PutBitmap3(&grcGame, 32, 220, &rcBox1, SURFACE_ID_TEXT_BOX);
+			PutBitmap3(&grcGame, 32, 228, &rcBox2, SURFACE_ID_TEXT_BOX);
+			PutBitmap3(&grcGame, 72, 224, &rcBr, SURFACE_ID_TEXT_BOX);
+			PutBitmap3(&grcGame, 72, 224, &rcLife, SURFACE_ID_TEXT_BOX);
+			PutBitmap3(&grcGame, 40, 224, &rcText, SURFACE_ID_TEXT_BOX);
+		}
+		else
+		{
+			gBL.flag = false;
+		}
+	}
+}
--- /dev/null
+++ b/src/BossLife.h
@@ -1,0 +1,6 @@
+#pragma once
+
+void InitBossLife(void);
+bool StartBossLife(int code_event);
+bool StartBossLife2(void);
+void PutBossLife(void);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -37,6 +37,7 @@
 #include "Draw.h"
 #include "Ending.h"
 #include "Flash.h"
+#include "BossLife.h"
 
 int g_GameFlags;
 int gCounter;
@@ -103,7 +104,7 @@
 	//InitStar();
 	InitFade();
 	InitFlash();
-	//InitBossLife();
+	InitBossLife();
 	ChangeMusic(0);
 	TransferStage(72, 100, 3, 3);
 	SetFrameTargetMyChar(16);
@@ -441,7 +442,7 @@
 	//ClearPermitStage();
 	//StartMapping();
 	InitFlags();
-	//InitBossLife();
+	InitBossLife();
 	
 	if ((bContinue && LoadProfile(NULL)) || InitializeGame())
 	{
@@ -517,7 +518,7 @@
 			PutFlash();
 			PutCaret(frame_x, frame_y);
 			PutValueView(frame_x, frame_y);
-			//PutBossLife();
+			PutBossLife();
 			PutFade();
 			
 			if (!(g_GameFlags & 4))
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -14,6 +14,7 @@
 #include "ValueView.h"
 #include "Stage.h"
 #include "Game.h"
+#include "BossLife.h"
 
 const char *gDefaultName = "Profile.dat";
 const char *gProfileCode = "Do041220";
@@ -130,7 +131,7 @@
 	ClearFade();
 	SetFrameMyChar();
 	SetFrameTargetMyChar(16);
-	//InitBossLife();
+	InitBossLife();
 	CutNoise();
 	//InitStar();
 	ClearValueView();
@@ -154,7 +155,7 @@
 	ClearFade();
 	SetFrameMyChar();
 	SetFrameTargetMyChar(16);
-	//InitBossLife();
+	InitBossLife();
 	CutNoise();
 	ClearValueView();
 	//gCurlyShoot_wait = 0;
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -21,6 +21,8 @@
 #include "Sound.h"
 #include "Organya.h"
 #include "Game.h"
+#include "Map.h"
+#include "BossLife.h"
 
 #define IS_COMMAND(c1, c2, c3) gTS.data[gTS.p_read + 1] == c1 && gTS.data[gTS.p_read + 2] == c2 && gTS.data[gTS.p_read + 3] == c3
 
@@ -840,6 +842,16 @@
 						else
 							gTS.p_read += 13;
 					}
+					else if (IS_COMMAND('I','T','J'))
+					{
+						x = GetTextScriptNo(gTS.p_read + 4);
+						z = GetTextScriptNo(gTS.p_read + 9);
+
+						if (CheckItem(x))
+							JumpTextScript(z);
+						else
+							gTS.p_read += 13;
+					}
 					else if (IS_COMMAND('S','S','S'))
 					{
 						x = GetTextScriptNo(gTS.p_read + 4);
@@ -967,6 +979,37 @@
 						z = GetTextScriptNo(gTS.p_read + 19);
 						SetNpChar(w, x << 13, y << 13, 0, 0, z, 0, 0x100);
 						gTS.p_read += 23;
+					}
+					else if (IS_COMMAND('C','M','P'))
+					{
+						x = GetTextScriptNo(gTS.p_read + 4);
+						y = GetTextScriptNo(gTS.p_read + 9);
+						z = GetTextScriptNo(gTS.p_read + 14);
+						ChangeMapParts(x, y, z);
+						gTS.p_read += 18;
+					}
+					else if (IS_COMMAND('B','S','L'))
+					{
+						z = GetTextScriptNo(gTS.p_read + 4);
+
+						if (z)
+							StartBossLife(z);
+						else
+							StartBossLife2();
+
+						gTS.p_read += 8;
+					}
+					else if (IS_COMMAND('M','Y','D'))
+					{
+						z = GetTextScriptNo(gTS.p_read + 4);
+						SetMyCharDirect(z);
+						gTS.p_read += 8;
+					}
+					else if (IS_COMMAND('M','Y','B'))
+					{
+						z = GetTextScriptNo(gTS.p_read + 4);
+						BackStepMyChar(z);
+						gTS.p_read += 8;
 					}
 					else if (IS_COMMAND('M','N','P'))
 					{
--