diff --git a/VERSION b/VERSION index bffc59fc1..89fa153fb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.2. \ No newline at end of file +0.1.3. \ No newline at end of file diff --git a/profiles/cclcc/scriptinput.lua b/profiles/cclcc/scriptinput.lua index c607e155b..374e1a60d 100644 --- a/profiles/cclcc/scriptinput.lua +++ b/profiles/cclcc/scriptinput.lua @@ -3,10 +3,10 @@ root.PADcustomSizeA = 43; root.PADcustomSizeB = 0; root.PADcustomType = 0; root.PADcustomA = { - 0x10000, - 0x20000, - 0x40000, - 0x80000, + root.PADinput.PAD1UP, + root.PADinput.PAD1DOWN, + root.PADinput.PAD1LEFT, + root.PADinput.PAD1RIGHT, root.PADinput.PAD1A | root.PADinput.PAD1START, root.PADinput.PAD1A, root.PADinput.PAD1B, @@ -31,18 +31,18 @@ root.PADcustomA = { 0, 0, 0, - 0x100000 | root.PADinput.PAD1UP, - 0x200000 | root.PADinput.PAD1DOWN, - 0x400000 | root.PADinput.PAD1LEFT, - 0x800000 | root.PADinput.PAD1RIGHT, + 0x100001, + 0x200002, + 0x400004, + 0x800008, 0x1000000, 0x2000000, 0x4000000, 0x8000000, root.PADinput.PAD1L2, root.PADinput.PAD1R2, - 0x40000 | root.PADinput.PAD1L2, - 0x80000 | root.PADinput.PAD1R2, + root.PADinput.PAD1LEFT | root.PADinput.PAD1L2, + root.PADinput.PAD1RIGHT | root.PADinput.PAD1R2, 0xF1000, root.PADinput.PAD1L1, root.PADinput.PAD1R1, diff --git a/profiles/chlcc/scriptinput.lua b/profiles/chlcc/scriptinput.lua index 8256a70d5..10c2afb62 100644 --- a/profiles/chlcc/scriptinput.lua +++ b/profiles/chlcc/scriptinput.lua @@ -42,10 +42,10 @@ root.PADcustomSizeA = 37; root.PADcustomSizeB = 0; root.PADcustomType = 0; root.PADcustomA = { - 0x10000, - 0x20000, - 0x40000, - 0x80000, + root.PADinput.PAD1UP, + root.PADinput.PAD1DOWN, + root.PADinput.PAD1LEFT, + root.PADinput.PAD1RIGHT, root.PADinput.PAD1A | root.PADinput.PAD1START, root.PADinput.PAD1A, root.PADinput.PAD1B, @@ -71,10 +71,10 @@ root.PADcustomA = { root.PADinput.PAD1L1, root.PADinput.PAD1A, root.PADinput.PAD1B, - 0x100000 | root.PADinput.PAD1UP, - 0x200000 | root.PADinput.PAD1DOWN, - 0x400000 | root.PADinput.PAD1LEFT, - 0x800000 | root.PADinput.PAD1RIGHT, + 0x100001, + 0x200002, + 0x400004, + 0x800008, 0x1000000, 0x2000000, 0x4000000, diff --git a/profiles/common/scriptinput.lua b/profiles/common/scriptinput.lua index 8363c4c27..696f0d209 100644 --- a/profiles/common/scriptinput.lua +++ b/profiles/common/scriptinput.lua @@ -39,10 +39,10 @@ root.Input = { } root.PADinput = { - PAD1UP = 1, - PAD1DOWN = 2, - PAD1LEFT = 4, - PAD1RIGHT = 8, + PAD1UP = 0x10000, + PAD1DOWN = 0x20000, + PAD1LEFT = 0x40000, + PAD1RIGHT = 0x80000, PAD1START = 0x10, PAD1SELECT = 0x20, PAD1L3 = 0x40, @@ -62,10 +62,10 @@ root.PADcustomType = 0; root.PADcustomSizeA = 43; root.PADcustomSizeB = 0; root.PADcustomA = { - 0x10000, - 0x20000, - 0x40000, - 0x80000, + root.PADinput.PAD1UP, + root.PADinput.PAD1DOWN, + root.PADinput.PAD1LEFT, + root.PADinput.PAD1RIGHT, root.PADinput.PAD1A | root.PADinput.PAD1START, root.PADinput.PAD1A, root.PADinput.PAD1B, @@ -90,18 +90,18 @@ root.PADcustomA = { 0, 0, 0, - 0x100000 | root.PADinput.PAD1UP, - 0x200000 | root.PADinput.PAD1DOWN, - 0x400000 | root.PADinput.PAD1LEFT, - 0x800000 | root.PADinput.PAD1RIGHT, + 0x100001, + 0x200002, + 0x400004, + 0x800008, 0x1000000, 0x2000000, 0x4000000, 0x8000000, root.PADinput.PAD1L2, root.PADinput.PAD1R2, - 0x40000 | root.PADinput.PAD1L2, - 0x80000 | root.PADinput.PAD1R2, + root.PADinput.PAD1LEFT | root.PADinput.PAD1L2, + root.PADinput.PAD1RIGHT | root.PADinput.PAD1R2, 0xF1000, root.PADinput.PAD1L1, root.PADinput.PAD1R1, diff --git a/profiles/dash/scriptinput.lua b/profiles/dash/scriptinput.lua index 4ff744627..75cba9bee 100644 --- a/profiles/dash/scriptinput.lua +++ b/profiles/dash/scriptinput.lua @@ -2,10 +2,10 @@ root.PADcustomSizeA = 43; root.PADcustomSizeB = 0; root.PADcustomType = 0; root.PADcustomA = { - 0x10000, - 0x20000, - 0x40000, - 0x80000, + root.PADinput.PAD1UP, + root.PADinput.PAD1DOWN, + root.PADinput.PAD1LEFT, + root.PADinput.PAD1RIGHT, root.PADinput.PAD1A | root.PADinput.PAD1START, root.PADinput.PAD1A, root.PADinput.PAD1B, @@ -30,18 +30,18 @@ root.PADcustomA = { 0, 0, 0, - 0x100000 | root.PADinput.PAD1UP, - 0x200000 | root.PADinput.PAD1DOWN, - 0x400000 | root.PADinput.PAD1LEFT, - 0x800000 | root.PADinput.PAD1RIGHT, + 0x100001, + 0x200002, + 0x400004, + 0x800008, 0x1000000, 0x2000000, 0x4000000, 0x8000000, root.PADinput.PAD1L2, root.PADinput.PAD1R2, - 0x40000 | root.PADinput.PAD1L2, - 0x80000 | root.PADinput.PAD1R2, + root.PADinput.PAD1LEFT | root.PADinput.PAD1L2, + root.PADinput.PAD1RIGHT | root.PADinput.PAD1R2, 0xF1000, root.PADinput.PAD1L1, root.PADinput.PAD1R1, diff --git a/profiles/mo6tw/scriptinput.lua b/profiles/mo6tw/scriptinput.lua index 3b9b644ed..d30d2020e 100644 --- a/profiles/mo6tw/scriptinput.lua +++ b/profiles/mo6tw/scriptinput.lua @@ -42,10 +42,10 @@ root.PADcustomSizeA = 41; root.PADcustomSizeB = 0; root.PADcustomType = 0; root.PADcustomA = { - 0x10000, - 0x20000, - 0x40000, - 0x80000, + root.PADinput.PAD1UP, + root.PADinput.PAD1DOWN, + root.PADinput.PAD1LEFT, + root.PADinput.PAD1RIGHT, root.PADinput.PAD1A | root.PADinput.PAD1START, root.PADinput.PAD1A, root.PADinput.PAD1B, @@ -70,10 +70,10 @@ root.PADcustomA = { root.PADinput.PAD1L1, root.PADinput.PAD1A, root.PADinput.PAD1B, - 0x100000 | root.PADinput.PAD1UP, - 0x200000 | root.PADinput.PAD1DOWN, - 0x400000 | root.PADinput.PAD1LEFT, - 0x800000 | root.PADinput.PAD1RIGHT, + 0x100001, + 0x200002, + 0x400004, + 0x800008, 0x1000000, 0x2000000, 0x4000000, diff --git a/src/game.cpp b/src/game.cpp index 720aa356d..27941fc34 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -251,11 +251,8 @@ void Update(float dt) { } if (Profile::GameFeatures & GameFeature::Renderer2D) { - if (ScrWork[SW_GAMESTATE] & 5 && !GetFlag(SF_GAMEPAUSE) && - !GetFlag(SF_SYSMENUDISABLE)) { - for (int i = 0; i < Profile::Dialogue::PageCount; i++) - DialoguePages[i].Update(dt); - } + for (int i = 0; i < Profile::Dialogue::PageCount; i++) + DialoguePages[i].Update(dt); } if ((Profile::GameFeatures & GameFeature::Renderer2D) && diff --git a/src/games/cclcc/savesystem.cpp b/src/games/cclcc/savesystem.cpp index 790a8bc8d..83d542be7 100644 --- a/src/games/cclcc/savesystem.cpp +++ b/src/games/cclcc/savesystem.cpp @@ -659,7 +659,7 @@ void SaveSystem::SetTipStatus(int tipId, bool isLocked, bool isUnread, } void SaveSystem::SetLineRead(int scriptId, int lineId) { - if (scriptId >= StoryScriptCount) return; + if (scriptId >= 255) return; int offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; if (offset == 0xFFFFFFFF) return; @@ -670,7 +670,7 @@ void SaveSystem::SetLineRead(int scriptId, int lineId) { } bool SaveSystem::IsLineRead(int scriptId, int lineId) { - if (scriptId >= StoryScriptCount) return false; + if (scriptId >= 255) return false; uint32_t offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; uint8_t flbit = Flbit[offset & 0b111]; diff --git a/src/games/cclcc/titlemenu.cpp b/src/games/cclcc/titlemenu.cpp index 220a5f076..4b294130e 100644 --- a/src/games/cclcc/titlemenu.cpp +++ b/src/games/cclcc/titlemenu.cpp @@ -215,10 +215,10 @@ void TitleMenu::Hide() { MenuLabel->Move({-Profile::DesignWidth / 2, 0.0f}); if (CurrentSubMenu) { CurrentSubMenu->Move({-Profile::DesignWidth / 2, 0.0f}); - CurrentSubMenu->HasFocus = false; } } - if (SecondaryFadeAnimation.IsOut() && CurrentSubMenu) { + if (CurrentSubMenu) { + CurrentSubMenu->HasFocus = false; if (CurrentSubMenu == ContinueItems) { HideContinueItems(); } else if (CurrentSubMenu == ExtraItems) { @@ -232,11 +232,11 @@ void TitleMenu::Hide() { SecondaryFadeAnimation.Progress = 0.0f; } MenuLabel->Hide(); - if (LastFocusedMenu != 0) { + if (LastFocusedMenu != nullptr) { UI::FocusedMenu = LastFocusedMenu; LastFocusedMenu->IsFocused = true; } else { - UI::FocusedMenu = 0; + UI::FocusedMenu = nullptr; } IsFocused = false; AllowsScriptInput = true; diff --git a/src/games/cclcc/yesnotrigger.cpp b/src/games/cclcc/yesnotrigger.cpp index 2292034d0..cef20583a 100644 --- a/src/games/cclcc/yesnotrigger.cpp +++ b/src/games/cclcc/yesnotrigger.cpp @@ -162,7 +162,7 @@ void YesNoTrigger::Update(float dt) { if (AllowInput) { DispSel = true; if (PADinputButtonWentDown & - (PAD1UP | PAD1DOWN | PAD1LEFT | PAD1RIGHT)) { + (PADcustom[0] | PADcustom[1] | PADcustom[2] | PADcustom[3])) { if (Selection == YesNoSelect::NONE) { Selection = YesNoSelect::YES; } else if (Selection == YesNoSelect::YES) { @@ -170,9 +170,9 @@ void YesNoTrigger::Update(float dt) { } else { Selection = YesNoSelect::YES; } - if (BgType == BGType::BG0 && - (CurArrIndex == 11 || CurArrIndex == 12)) { - Selection = YesNoSelect::YES; + if (BgType == BGType::BG1 && + (TargetArrIndex == 11 || TargetArrIndex == 12)) { + Selection = YesNoSelect::NO; Audio::Channels[Audio::AC_SSE]->Play("sysse", 4, false, 0.0f); } else { Audio::Channels[Audio::AC_SSE]->Play("sysse", 1, false, 0.0f); diff --git a/src/games/chlcc/savesystem.cpp b/src/games/chlcc/savesystem.cpp index f4676c3f6..72be77b9a 100644 --- a/src/games/chlcc/savesystem.cpp +++ b/src/games/chlcc/savesystem.cpp @@ -523,7 +523,7 @@ void SaveSystem::SetTipStatus(int tipId, bool isLocked, bool isUnread, } void SaveSystem::SetLineRead(int scriptId, int lineId) { - if (scriptId >= StoryScriptCount) return; + if (scriptId >= 255) return; int offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; if (offset == 0xFFFFFFFF) return; diff --git a/src/games/mo6tw/savesystem.cpp b/src/games/mo6tw/savesystem.cpp index ef8b7d6b5..b3faadf90 100644 --- a/src/games/mo6tw/savesystem.cpp +++ b/src/games/mo6tw/savesystem.cpp @@ -666,7 +666,7 @@ void SaveSystem::SetTipStatus(int tipId, bool isLocked, bool isUnread, } void SaveSystem::SetLineRead(int scriptId, int lineId) { - if (scriptId >= StoryScriptCount) return; + if (scriptId >= StoryScriptCount.value()) return; int offset = ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; @@ -678,7 +678,7 @@ void SaveSystem::SetLineRead(int scriptId, int lineId) { } bool SaveSystem::IsLineRead(int scriptId, int lineId) { - if (scriptId >= StoryScriptCount) return false; + if (scriptId >= StoryScriptCount.value()) return false; uint32_t offset = ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; diff --git a/src/profile/data/savesystem.cpp b/src/profile/data/savesystem.cpp index f7022fecc..001bf8ac1 100644 --- a/src/profile/data/savesystem.cpp +++ b/src/profile/data/savesystem.cpp @@ -39,7 +39,7 @@ void Configure() { AssertIs(LUA_TTABLE); StoryScriptCount = (int)lua_rawlen(LuaState, -1); - StoryScriptIDs = (uint32_t*)malloc(StoryScriptCount * sizeof(uint32_t)); + StoryScriptIDs.reserve(*StoryScriptCount); PushInitialIndex(); while (PushNextTableElement() != 0) { int i = EnsureGetKeyInt() - 1; diff --git a/src/profile/data/savesystem.h b/src/profile/data/savesystem.h index 8ebe5053d..fb1bd7af9 100644 --- a/src/profile/data/savesystem.h +++ b/src/profile/data/savesystem.h @@ -2,6 +2,7 @@ #include "../../data/savesystem.h" #include +#include namespace Impacto { namespace Profile { @@ -15,8 +16,8 @@ inline Impacto::SaveSystem::SaveDataType Type = Impacto::SaveSystem::SaveDataType::None; inline std::string SaveFilePath; -inline uint32_t* StoryScriptIDs; -inline int StoryScriptCount; +inline std::vector StoryScriptIDs; +inline std::optional StoryScriptCount; inline Impacto::SaveSystem::ScriptMessageDataPair* ScriptMessageData; inline uint16_t AlbumEvData[MaxAlbumEntries][MaxAlbumSubEntries]; inline uint16_t AlbumData[MaxAlbumEntries][MaxAlbumSubEntries][MaxCGSprites]; diff --git a/src/ui/widgets/cclcc/titlebutton.cpp b/src/ui/widgets/cclcc/titlebutton.cpp index 8d2f2b275..980b3903d 100644 --- a/src/ui/widgets/cclcc/titlebutton.cpp +++ b/src/ui/widgets/cclcc/titlebutton.cpp @@ -49,6 +49,13 @@ void TitleButton::Update(float dt) { } } +void TitleButton::Hide() { + Button::Hide(); + HighlightAnimation.Progress = 0.0f; + ChoiceBlinkAnimation.Progress = 0.0f; + PrevFocusState = false; +} + void TitleButton::Render() { // Calculate the blink effect to occur 4 times during the animation float blinkProgress = ChoiceBlinkAnimation.Progress * 4.0f; diff --git a/src/ui/widgets/cclcc/titlebutton.h b/src/ui/widgets/cclcc/titlebutton.h index 49944d44c..8cf5b1a82 100644 --- a/src/ui/widgets/cclcc/titlebutton.h +++ b/src/ui/widgets/cclcc/titlebutton.h @@ -15,6 +15,7 @@ class TitleButton : public Widgets::Button { void Render() override; void Update(float dt) override; void UpdateInput() override; + void Hide() override; bool IsSubButton = false; bool DisableInput = false; Animation HighlightAnimation; diff --git a/src/vm/interface/input.cpp b/src/vm/interface/input.cpp index 21f62d942..6883ce46c 100644 --- a/src/vm/interface/input.cpp +++ b/src/vm/interface/input.cpp @@ -29,7 +29,7 @@ void UpdatePADInput() { PADinputMouseWentDown = 0; PADinputButtonIsDown = 0; PADinputMouseIsDown = 0; - for (int i = 0; i < 16; i++) { + for (int i = 0; i < 20; i++) { int PADcode = (int)std::pow(2, i); int KBcode = PADToKeyboard[PADcode]; int GPcode = PADToController[PADcode]; diff --git a/src/vm/interface/input.h b/src/vm/interface/input.h index 0e68a8efc..45c27a4ac 100644 --- a/src/vm/interface/input.h +++ b/src/vm/interface/input.h @@ -5,12 +5,12 @@ namespace Impacto { namespace Vm { namespace Interface { - +// Might have to take this from lua file if older games use different consts enum PADinput { - PAD1UP = 1, - PAD1DOWN = 2, - PAD1LEFT = 4, - PAD1RIGHT = 8, + PAD1UP = 0x10000, + PAD1DOWN = 0x20000, + PAD1LEFT = 0x40000, + PAD1RIGHT = 0x80000, PAD1START = 0x10, PAD1SELECT = 0x20, PAD1L3 = 0x40,