From 5c8f80e611662ffe1bb98819a8bac1060af3c13d Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 31 Jan 2019 14:36:54 +0000 Subject: [PATCH] Added some TSC commands and BossLife.cpp --- Makefile | 1 + src/BossLife.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ src/BossLife.h | 6 ++++ src/Game.cpp | 7 ++-- src/Profile.cpp | 5 +-- src/TextScr.cpp | 43 +++++++++++++++++++++++++ 6 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 src/BossLife.cpp create mode 100644 src/BossLife.h diff --git a/Makefile b/Makefile index ba9fac12..4e6b2edc 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ endif SOURCES = \ ArmsItem \ Back \ + BossLife \ BulHit \ Bullet \ Caret \ diff --git a/src/BossLife.cpp b/src/BossLife.cpp new file mode 100644 index 00000000..bfd51765 --- /dev/null +++ b/src/BossLife.cpp @@ -0,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; + } + } +} diff --git a/src/BossLife.h b/src/BossLife.h new file mode 100644 index 00000000..77d4404f --- /dev/null +++ b/src/BossLife.h @@ -0,0 +1,6 @@ +#pragma once + +void InitBossLife(void); +bool StartBossLife(int code_event); +bool StartBossLife2(void); +void PutBossLife(void); diff --git a/src/Game.cpp b/src/Game.cpp index 8421acb3..1b117843 100644 --- 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 @@ int ModeOpening() //InitStar(); InitFade(); InitFlash(); - //InitBossLife(); + InitBossLife(); ChangeMusic(0); TransferStage(72, 100, 3, 3); SetFrameTargetMyChar(16); @@ -441,7 +442,7 @@ int ModeAction() //ClearPermitStage(); //StartMapping(); InitFlags(); - //InitBossLife(); + InitBossLife(); if ((bContinue && LoadProfile(NULL)) || InitializeGame()) { @@ -517,7 +518,7 @@ int ModeAction() PutFlash(); PutCaret(frame_x, frame_y); PutValueView(frame_x, frame_y); - //PutBossLife(); + PutBossLife(); PutFade(); if (!(g_GameFlags & 4)) diff --git a/src/Profile.cpp b/src/Profile.cpp index d9465a35..e2a7d63e 100644 --- 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 @@ bool LoadProfile(char *name) ClearFade(); SetFrameMyChar(); SetFrameTargetMyChar(16); - //InitBossLife(); + InitBossLife(); CutNoise(); //InitStar(); ClearValueView(); @@ -154,7 +155,7 @@ bool InitializeGame() ClearFade(); SetFrameMyChar(); SetFrameTargetMyChar(16); - //InitBossLife(); + InitBossLife(); CutNoise(); ClearValueView(); //gCurlyShoot_wait = 0; diff --git a/src/TextScr.cpp b/src/TextScr.cpp index c1353781..a4843b0d 100644 --- 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 @@ int TextScriptProc() 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); @@ -968,6 +980,37 @@ int TextScriptProc() 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')) { w = GetTextScriptNo(gTS.p_read + 4);