The response has been limited to 50k tokens of the smallest files in the repo. You can remove this limitation by removing the max tokens filter.
├── .clang-format
├── .github
    └── ISSUE_TEMPLATE
    │   ├── bug-report.md
    │   └── feature-request.md
├── .gitignore
├── .gitmodules
├── 3ds
    ├── Makefile
    ├── assets
    │   ├── app.rsf
    │   ├── audio.wav
    │   ├── banner.png
    │   ├── gfx
    │   │   ├── checkbox.png
    │   │   ├── checkpoint.png
    │   │   ├── noicon.png
    │   │   ├── sprites.t3s
    │   │   └── star.png
    │   ├── icon.png
    │   ├── romfs
    │   │   ├── PKSM.smdh
    │   │   └── config.json
    │   └── splash.bin
    ├── include
    │   ├── CheatManagerOverlay.hpp
    │   ├── DataMutex.hpp
    │   ├── ErrorOverlay.hpp
    │   ├── InfoOverlay.hpp
    │   ├── InputState.hpp
    │   ├── KeyboardManager.hpp
    │   ├── MainScreen.hpp
    │   ├── SmallVector.hpp
    │   ├── YesNoOverlay.hpp
    │   ├── alignsort_tuple.hpp
    │   ├── archive.hpp
    │   ├── cheatmanager.hpp
    │   ├── clickable.hpp
    │   ├── colors.hpp
    │   ├── configuration.hpp
    │   ├── directory.hpp
    │   ├── fsstream.hpp
    │   ├── gui.hpp
    │   ├── hid.hpp
    │   ├── io.hpp
    │   ├── loader.hpp
    │   ├── main.hpp
    │   ├── scrollable.hpp
    │   ├── server.hpp
    │   ├── smdh.hpp
    │   ├── spi.hpp
    │   ├── thread.hpp
    │   ├── title.hpp
    │   └── util.hpp
    └── source
    │   ├── CheatManagerOverlay.cpp
    │   ├── ErrorOverlay.cpp
    │   ├── InfoOverlay.cpp
    │   ├── KeyboardManager.cpp
    │   ├── MainScreen.cpp
    │   ├── YesNoOverlay.cpp
    │   ├── archive.cpp
    │   ├── cheatmanager.cpp
    │   ├── clickable.cpp
    │   ├── configuration.cpp
    │   ├── directory.cpp
    │   ├── fsstream.cpp
    │   ├── gui.cpp
    │   ├── io.cpp
    │   ├── loader.cpp
    │   ├── main.cpp
    │   ├── scrollable.cpp
    │   ├── server.cpp
    │   ├── smdh.cpp
    │   ├── spi.cpp
    │   ├── thread.cpp
    │   ├── title.cpp
    │   └── util.cpp
├── 3rd-party
    ├── ftp
    │   ├── ftp.c
    │   └── ftp.h
    ├── json
    │   └── json.hpp
    ├── mongoose
    │   ├── mg_locals.h
    │   ├── mongoose.c
    │   └── mongoose.h
    └── sha256
    │   ├── sha256.c
    │   └── sha256.h
├── LICENSE
├── Makefile
├── README.md
├── common
    ├── Overlay.hpp
    ├── Screen.cpp
    ├── Screen.hpp
    ├── common.cpp
    ├── common.hpp
    ├── iclickable.hpp
    ├── ihid.hpp
    ├── ihid.tcc
    ├── iscrollable.hpp
    ├── logging.cpp
    ├── logging.hpp
    ├── multiselection.cpp
    └── multiselection.hpp
└── switch
    ├── Makefile
    ├── icon.jpg
    ├── include
        ├── CheatManagerOverlay.hpp
        ├── ErrorOverlay.hpp
        ├── InfoOverlay.hpp
        ├── InputState.hpp
        ├── KeyboardManager.hpp
        ├── MainScreen.hpp
        ├── SDLHelper.hpp
        ├── SDL_FontCache.h
        ├── YesNoOverlay.hpp
        ├── account.hpp
        ├── cheatmanager.hpp
        ├── clickable.hpp
        ├── colors.hpp
        ├── configuration.hpp
        ├── directory.hpp
        ├── filesystem.hpp
        ├── hid.hpp
        ├── io.hpp
        ├── main.hpp
        ├── pksmbridge.hpp
        ├── scrollable.hpp
        ├── title.hpp
        └── util.hpp
    ├── romfs
        ├── checkbox.png
        ├── config.json
        ├── star.png
        └── web_root
        │   ├── css
        │       └── style.css
        │   ├── index.html
        │   └── js
        │       └── script.js
    └── source
        ├── CheatManagerOverlay.cpp
        ├── ErrorOverlay.cpp
        ├── InfoOverlay.cpp
        ├── KeyboardManager.cpp
        ├── MainScreen.cpp
        ├── SDLHelper.cpp
        ├── SDL_FontCache.c
        ├── YesNoOverlay.cpp
        ├── account.cpp
        ├── cheatmanager.cpp
        ├── clickable.cpp
        ├── configuration.cpp
        ├── directory.cpp
        ├── filesystem.cpp
        ├── io.cpp
        ├── main.cpp
        ├── pksmbridge.cpp
        ├── scrollable.cpp
        ├── title.cpp
        └── util.cpp


/.clang-format:
--------------------------------------------------------------------------------
 1 | ---
 2 | # BasedOnStyle:  LLVM
 3 | AccessModifierOffset: -4
 4 | AlignAfterOpenBracket: DontAlign
 5 | AlignConsecutiveAssignments: true
 6 | AlignConsecutiveDeclarations: false
 7 | AlignEscapedNewlinesLeft: false
 8 | AlignOperands:   true
 9 | AlignTrailingComments: true
10 | AllowAllParametersOfDeclarationOnNextLine: false
11 | AllowShortBlocksOnASingleLine: true
12 | AllowShortCaseLabelsOnASingleLine: false
13 | AllowShortFunctionsOnASingleLine: Inline
14 | AllowShortIfStatementsOnASingleLine: false
15 | AllowShortLoopsOnASingleLine: false
16 | #AlwaysBreakAfterDefinitionReturnType: None
17 | AlwaysBreakAfterReturnType: None
18 | AlwaysBreakBeforeMultilineStrings: false
19 | AlwaysBreakTemplateDeclarations: true
20 | BinPackArguments: true
21 | BinPackParameters: true
22 | BraceWrapping:   
23 |   AfterClass:      true
24 |   AfterControlStatement: true
25 |   AfterEnum:       true
26 |   AfterFunction:   true
27 |   AfterNamespace:  true
28 |   AfterStruct:     true
29 |   AfterUnion:      true
30 |   BeforeCatch:     true
31 |   BeforeElse:      true
32 |   IndentBraces:    false
33 | #  SplitEmptyFunction: true
34 | #  SplitEmptyRecord: true
35 | #  SplitEmptyNamespace: true
36 | BreakBeforeBinaryOperators: None
37 | BreakBeforeBraces: Stroustrup
38 | BreakBeforeTernaryOperators: true
39 | #BreakConstructorInitializers: AfterColon
40 | BreakConstructorInitializersBeforeComma: false
41 | BreakStringLiterals: true
42 | ColumnLimit:     150
43 | CommentPragmas:  '^ IWYU pragma:'
44 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
45 | ConstructorInitializerIndentWidth: 4
46 | ContinuationIndentWidth: 4
47 | Cpp11BracedListStyle: true
48 | DerivePointerAlignment: false
49 | DisableFormat:   false
50 | ExperimentalAutoDetectBinPacking: false
51 | FixNamespaceComments: false
52 | ForEachMacros:   [ foreach ]
53 | IncludeCategories: 
54 |   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
55 |     Priority:        2
56 |   - Regex:           '^(<|"(gtest|isl|json)/)'
57 |     Priority:        3
58 |   - Regex:           '.*'
59 |     Priority:        1
60 | IncludeIsMainRegex: '
#39;
61 | IndentCaseLabels: true
62 | IndentWidth:     4
63 | IndentWrappedFunctionNames: true
64 | KeepEmptyLinesAtTheStartOfBlocks: false
65 | MacroBlockBegin: ''
66 | MacroBlockEnd:   ''
67 | MaxEmptyLinesToKeep: 1
68 | NamespaceIndentation: All
69 | PenaltyBreakBeforeFirstCallParameter: 19
70 | PenaltyBreakComment: 300
71 | PenaltyBreakFirstLessLess: 120
72 | PenaltyBreakString: 1000
73 | PenaltyExcessCharacter: 1000000
74 | PenaltyReturnTypeOnItsOwnLine: 60
75 | PointerAlignment: Left
76 | ReflowComments:  true
77 | SortIncludes:    true
78 | SpaceAfterCStyleCast: false
79 | SpaceAfterTemplateKeyword: true
80 | SpaceBeforeAssignmentOperators: true
81 | SpaceBeforeParens: ControlStatements
82 | SpaceInEmptyParentheses: false
83 | SpacesBeforeTrailingComments: 1
84 | SpacesInAngles:  false
85 | SpacesInContainerLiterals: true
86 | SpacesInCStyleCastParentheses: false
87 | SpacesInParentheses: false
88 | SpacesInSquareBrackets: false
89 | Standard:        Cpp11
90 | ...
91 | 


--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | name: Bug Report
 3 | about: Please fill the fields with all the informations important for the maintainers
 4 |   to get your issue fixed or sorted out.
 5 | title: Bug Report
 6 | labels: ''
 7 | assignees: ''
 8 | 
 9 | ---
10 | 
11 | **Describe the bug**
12 | A clear and concise description of what the bug is.
13 | 
14 | **To Reproduce**
15 | Steps to reproduce the behavior:
16 | 1. Go to '...'
17 | 2. Click on '....'
18 | 3. Scroll down to '....'
19 | 4. See error
20 | 
21 | **Expected behavior**
22 | A clear and concise description of what you expected to happen.
23 | 
24 | **Screenshots**
25 | If applicable, add screenshots to help explain your problem.
26 | 
27 | **3DS:**
28 | - Entrypoint:
29 | - System version:
30 | - Checkpoint version:
31 | - Result code (if available):
32 | 
33 | **Switch:**
34 | - Entrypoint:
35 | - System version:
36 | - Checkpoint version:
37 | - SD Card Filesystem:
38 | - Result code (if available):
39 | 
40 | **Additional context**
41 | Add any other context about the problem here.
42 | 


--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request.md:
--------------------------------------------------------------------------------
 1 | ---
 2 | name: Feature Request
 3 | about: Suggest an idea for this project
 4 | title: Feature Request
 5 | labels: ''
 6 | assignees: ''
 7 | 
 8 | ---
 9 | 
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 | 
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 | 
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 | 
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 | 


--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
 1 | .vscode
 2 | cppcheck.log
 3 | 3ds/build/
 4 | 3ds/out/
 5 | 3ds/assets/romfs/gfx/
 6 | 3ds/assets/romfs/cheats/
 7 | switch/build/
 8 | switch/out/
 9 | switch/romfs/cheats/
10 | .vscode/
11 | .idea
12 | .DS_Store


--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "sharkive"]
2 | 	path = sharkive
3 | 	url = https://github.com/FlagBrew/sharkive
4 | 


--------------------------------------------------------------------------------
/3ds/assets/audio.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/audio.wav


--------------------------------------------------------------------------------
/3ds/assets/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/banner.png


--------------------------------------------------------------------------------
/3ds/assets/gfx/checkbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/gfx/checkbox.png


--------------------------------------------------------------------------------
/3ds/assets/gfx/checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/gfx/checkpoint.png


--------------------------------------------------------------------------------
/3ds/assets/gfx/noicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/gfx/noicon.png


--------------------------------------------------------------------------------
/3ds/assets/gfx/sprites.t3s:
--------------------------------------------------------------------------------
1 | --atlas -f rgba8888 -z auto
2 | checkbox.png
3 | checkpoint.png
4 | noicon.png
5 | star.png
6 | 


--------------------------------------------------------------------------------
/3ds/assets/gfx/star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/gfx/star.png


--------------------------------------------------------------------------------
/3ds/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/icon.png


--------------------------------------------------------------------------------
/3ds/assets/romfs/PKSM.smdh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/romfs/PKSM.smdh


--------------------------------------------------------------------------------
/3ds/assets/romfs/config.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "filter": [
 3 | 
 4 |   ],
 5 |   "favorites": [
 6 | 
 7 |   ],
 8 |   "additional_save_folders": {
 9 | 
10 |   },
11 |   "additional_extdata_folders": {
12 | 
13 |   },
14 |   "nand_saves": false,
15 |   "scan_cart": false,
16 |   "version": 3
17 | }


--------------------------------------------------------------------------------
/3ds/assets/splash.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/3ds/assets/splash.bin


--------------------------------------------------------------------------------
/3ds/include/CheatManagerOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CHEATMANAGEROVERLAY_HPP
28 | #define CHEATMANAGEROVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "YesNoOverlay.hpp"
32 | #include "cheatmanager.hpp"
33 | #include "colors.hpp"
34 | #include "directory.hpp"
35 | #include "scrollable.hpp"
36 | #include <memory>
37 | #include <string>
38 | 
39 | class Clickable;
40 | class Scrollable;
41 | 
42 | class CheatManagerOverlay : public Overlay {
43 | public:
44 |     CheatManagerOverlay(Screen& screen, const std::string& mtext);
45 |     ~CheatManagerOverlay(void);
46 |     void drawTop(void) const override;
47 |     void drawBottom(void) const override;
48 |     void update(const InputState& input) override;
49 | 
50 | protected:
51 |     void save(const std::string& key, Scrollable* s);
52 | 
53 | private:
54 |     bool multiSelected;
55 |     std::string existingCheat;
56 |     std::string key;
57 |     const size_t MAGIC_LEN = strlen(SELECTED_MAGIC);
58 |     std::shared_ptr<Scrollable> scrollable;
59 |     size_t currentIndex;
60 |     const float scale = 0.47f;
61 | 
62 |     C2D_Text multiSelectText, multiDeselectText;
63 |     C2D_TextBuf staticBuf, dynamicBuf;
64 | };
65 | 
66 | #endif


--------------------------------------------------------------------------------
/3ds/include/ErrorOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef ERROROVERLAY_HPP
28 | #define ERROROVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "clickable.hpp"
32 | #include "colors.hpp"
33 | #include "gui.hpp"
34 | #include "util.hpp"
35 | #include <memory>
36 | #include <string>
37 | 
38 | class Clickable;
39 | 
40 | class ErrorOverlay : public Overlay {
41 | public:
42 |     ErrorOverlay(Screen& screen, Result res, const std::string& mtext);
43 |     ~ErrorOverlay(void);
44 |     void drawTop(void) const override;
45 |     void drawBottom(void) const override;
46 |     void update(const InputState& input) override;
47 | 
48 | private:
49 |     u32 posx, posy;
50 |     const float size = 0.6f;
51 |     C2D_Text text, error;
52 |     C2D_TextBuf textBuf;
53 |     std::unique_ptr<Clickable> button;
54 | };
55 | 
56 | #endif


--------------------------------------------------------------------------------
/3ds/include/InfoOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef INFOOVERLAY_HPP
28 | #define INFOOVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "clickable.hpp"
32 | #include "colors.hpp"
33 | #include "gui.hpp"
34 | #include "util.hpp"
35 | #include <memory>
36 | #include <string>
37 | 
38 | class Clickable;
39 | 
40 | class InfoOverlay : public Overlay {
41 | public:
42 |     InfoOverlay(Screen& screen, const std::string& mtext);
43 |     ~InfoOverlay(void);
44 |     void drawTop(void) const override;
45 |     void drawBottom(void) const override;
46 |     void update(const InputState& input) override;
47 | 
48 | private:
49 |     u32 posx, posy;
50 |     const float size = 0.6f;
51 |     C2D_Text text;
52 |     C2D_TextBuf textBuf;
53 |     std::unique_ptr<Clickable> button;
54 | };
55 | 
56 | #endif


--------------------------------------------------------------------------------
/3ds/include/InputState.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef INPUTSTATE_HPP
28 | #define INPUTSTATE_HPP
29 | 
30 | #include <3ds.h>
31 | 
32 | using InputState = touchPosition;
33 | 
34 | #endif
35 | 


--------------------------------------------------------------------------------
/3ds/include/KeyboardManager.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef KEYBOARDMANAGER_HPP
28 | #define KEYBOARDMANAGER_HPP
29 | 
30 | #include "util.hpp"
31 | #include <3ds.h>
32 | #include <string>
33 | 
34 | class KeyboardManager {
35 | public:
36 |     static KeyboardManager& get(void)
37 |     {
38 |         static KeyboardManager mSingleton;
39 |         return mSingleton;
40 |     }
41 | 
42 |     KeyboardManager(KeyboardManager const&) = delete;
43 |     void operator=(KeyboardManager const&)  = delete;
44 | 
45 |     std::u16string keyboard(const std::string& suggestion);
46 |     int numericPad(void);
47 | 
48 |     static const size_t CUSTOM_PATH_LEN = 20;
49 | 
50 | private:
51 |     KeyboardManager(void);
52 |     virtual ~KeyboardManager(void) {}
53 | 
54 |     SwkbdState mSwkbd;
55 | };
56 | 
57 | #endif


--------------------------------------------------------------------------------
/3ds/include/MainScreen.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef MAINSCREEN_HPP
28 | #define MAINSCREEN_HPP
29 | 
30 | #include "CheatManagerOverlay.hpp"
31 | #include "ErrorOverlay.hpp"
32 | #include "InfoOverlay.hpp"
33 | #include "Screen.hpp"
34 | #include "YesNoOverlay.hpp"
35 | #include "clickable.hpp"
36 | #include "gui.hpp"
37 | #include "multiselection.hpp"
38 | #include "scrollable.hpp"
39 | #include "thread.hpp"
40 | #include <algorithm>
41 | #include <memory>
42 | #include <tuple>
43 | 
44 | class MainScreen : public Screen {
45 | public:
46 |     MainScreen(void);
47 |     ~MainScreen(void);
48 |     void drawTop(void) const override;
49 |     void drawBottom(void) const override;
50 |     void update(const InputState& input) override;
51 | 
52 | protected:
53 |     int selectorX(size_t i) const;
54 |     int selectorY(size_t i) const;
55 |     void drawSelector(void) const;
56 |     void handleEvents(const InputState& input);
57 |     void updateSelector(void);
58 |     void updateButtons(void);
59 |     std::string nameFromCell(size_t index) const;
60 | 
61 | private:
62 |     Hid<HidDirection::HORIZONTAL, HidDirection::VERTICAL> hid;
63 |     std::unique_ptr<Clickable> buttonBackup, buttonRestore, buttonCheats, buttonPlayCoins;
64 |     std::unique_ptr<Scrollable> directoryList;
65 |     char ver[10];
66 | 
67 |     C2D_Text ins1, ins2, ins3, ins4, c2dId, c2dMediatype;
68 |     C2D_Text checkpoint, version;
69 |     // instructions text
70 |     C2D_Text top_move, top_a, top_y, top_my, top_b, top_hb, bot_ts, bot_x, coins;
71 |     C2D_TextBuf dynamicBuf, staticBuf;
72 | 
73 |     const float scaleInst = 0.7f;
74 |     C2D_ImageTint checkboxTint;
75 |     C2D_ImageTint flagTint;
76 |     int selectionTimer;
77 |     int refreshTimer;
78 | };
79 | 
80 | #endif
81 | 


--------------------------------------------------------------------------------
/3ds/include/YesNoOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef YESNOOVERLAY_HPP
28 | #define YESNOOVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "clickable.hpp"
32 | #include "colors.hpp"
33 | #include "gui.hpp"
34 | #include "hid.hpp"
35 | #include <functional>
36 | #include <memory>
37 | #include <string>
38 | 
39 | class Clickable;
40 | 
41 | class YesNoOverlay : public Overlay {
42 | public:
43 |     YesNoOverlay(Screen& screen, const std::string& mtext, const std::function<void()>& callbackYes, const std::function<void()>& callbackNo);
44 |     ~YesNoOverlay(void);
45 |     void drawTop(void) const override;
46 |     void drawBottom(void) const override;
47 |     void update(const InputState& input) override;
48 | 
49 | private:
50 |     u32 posx, posy;
51 |     C2D_TextBuf textBuf;
52 |     C2D_Text text;
53 |     std::unique_ptr<Clickable> buttonYes, buttonNo;
54 |     Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
55 |     std::function<void()> yesFunc, noFunc;
56 | };
57 | 
58 | #endif
59 | 


--------------------------------------------------------------------------------
/3ds/include/archive.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef ARCHIVE_HPP
28 | #define ARCHIVE_HPP
29 | 
30 | #include "KeyboardManager.hpp"
31 | #include "fsstream.hpp"
32 | #include "util.hpp"
33 | #include <3ds.h>
34 | 
35 | typedef enum { MODE_SAVE, MODE_EXTDATA } Mode_t;
36 | 
37 | namespace Archive {
38 |     Result init(void);
39 |     void exit(void);
40 | 
41 |     Mode_t mode(void);
42 |     void mode(Mode_t v);
43 |     FS_Archive sdmc(void);
44 | 
45 |     Result save(FS_Archive* archive, FS_MediaType mediatype, u32 lowid, u32 highid);
46 |     Result extdata(FS_Archive* archive, u32 extdata);
47 |     bool accessible(FS_MediaType mediatype, u32 lowid, u32 highid); // save
48 |     bool accessible(u32 extdata);                                   // extdata
49 |     bool setPlayCoins(void);
50 | }
51 | 
52 | #endif


--------------------------------------------------------------------------------
/3ds/include/cheatmanager.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CHEATMANAGER_HPP
28 | #define CHEATMANAGER_HPP
29 | 
30 | #include "io.hpp"
31 | #include "json.hpp"
32 | #include "main.hpp"
33 | #include <3ds.h>
34 | #include <bzlib.h>
35 | #include <stdio.h>
36 | #include <sys/stat.h>
37 | 
38 | #define SELECTED_MAGIC "\uE071 "
39 | 
40 | class CheatManager {
41 | public:
42 |     static CheatManager& getInstance(void)
43 |     {
44 |         static CheatManager mCheatManager;
45 |         return mCheatManager;
46 |     }
47 | 
48 |     bool areCheatsAvailable(const std::string& key);
49 |     void save(const std::string& key, const std::vector<std::string>& s);
50 | 
51 |     std::shared_ptr<nlohmann::json> cheats(void) { return mCheats; }
52 | 
53 | private:
54 |     CheatManager(void);
55 |     ~CheatManager() = default;
56 | 
57 |     CheatManager(CheatManager const&)   = delete;
58 |     void operator=(CheatManager const&) = delete;
59 | 
60 |     std::shared_ptr<nlohmann::json> mCheats;
61 | };
62 | 
63 | #endif


--------------------------------------------------------------------------------
/3ds/include/clickable.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CLICKABLE_HPP
28 | #define CLICKABLE_HPP
29 | 
30 | #include "colors.hpp"
31 | #include "gui.hpp"
32 | #include "iclickable.hpp"
33 | #include "main.hpp"
34 | #include <citro2d.h>
35 | #include <string>
36 | 
37 | class Clickable : public IClickable<u32> {
38 | public:
39 |     Clickable(int x, int y, u16 w, u16 h, u32 colorBg, u32 colorText, std::string message, bool centered)
40 |         : IClickable(x, y, w, h, colorBg, colorText, message, centered)
41 |     {
42 |         mTextBuf = C2D_TextBufNew(64);
43 |         C2D_TextParse(&mC2dText, mTextBuf, message.c_str());
44 |         C2D_TextOptimize(&mC2dText);
45 |     }
46 | 
47 |     virtual ~Clickable(void) { C2D_TextBufDelete(mTextBuf); }
48 | 
49 |     void draw(float size, u32 overlayWhenSelected) override;
50 |     void drawOutline(u32 color) override;
51 |     bool held(void) override;
52 |     bool released(void) override;
53 |     void c2dText(const std::string& text);
54 | 
55 | protected:
56 |     C2D_Text mC2dText;
57 |     C2D_TextBuf mTextBuf;
58 | };
59 | 
60 | #endif


--------------------------------------------------------------------------------
/3ds/include/colors.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef COLORS_HPP
28 | #define COLORS_HPP
29 | 
30 | #include <citro2d.h>
31 | 
32 | inline const u32 COLOR_OVERLAY    = C2D_Color32(0, 0, 0, 200);
33 | inline const u32 COLOR_WHITEMASK  = C2D_Color32(255, 255, 255, 80);
34 | inline const u32 COLOR_WHITE      = C2D_Color32(255, 255, 255, 255);
35 | inline const u32 COLOR_BLACK      = C2D_Color32(0, 0, 0, 255);
36 | inline const u32 COLOR_RED        = C2D_Color32(255, 0, 0, 255);
37 | inline const u32 COLOR_GOLD       = C2D_Color32(215, 183, 64, 255);
38 | inline const u32 COLOR_GREY_LIGHT = C2D_Color32(138, 138, 138, 255);
39 | 
40 | inline const u32 COLOR_BLACK_DARKERR = C2D_Color32(15, 15, 17, 255);
41 | inline const u32 COLOR_BLACK_DARKER  = C2D_Color32(22, 22, 26, 255);
42 | inline const u32 COLOR_BLACK_DARK    = C2D_Color32(27, 27, 31, 255);
43 | inline const u32 COLOR_BLACK_MEDIUM  = C2D_Color32(43, 43, 46, 255);
44 | inline const u32 COLOR_PURPLE_DARK   = C2D_Color32(9, 25, 69, 255);
45 | inline const u32 COLOR_PURPLE_LIGHT  = C2D_Color32(122, 66, 196, 255);
46 | inline const u32 COLOR_LIGHT_BLUE    = C2D_Color32(195, 240, 239, 255);
47 | 
48 | #endif


--------------------------------------------------------------------------------
/3ds/include/configuration.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CONFIGURATION_HPP
28 | #define CONFIGURATION_HPP
29 | 
30 | #include "json.hpp"
31 | #include <3ds/types.h>
32 | #include <memory>
33 | #include <string>
34 | #include <unordered_map>
35 | #include <unordered_set>
36 | #include <vector>
37 | 
38 | class Configuration {
39 | public:
40 |     static constexpr int CURRENT_VERSION = 3;
41 | 
42 |     static Configuration& getInstance(void)
43 |     {
44 |         static Configuration mConfiguration;
45 |         return mConfiguration;
46 |     }
47 | 
48 |     bool filter(u64 id);
49 |     bool favorite(u64 id);
50 |     bool nandSaves(void);
51 |     bool shouldScanCard(void);
52 |     std::vector<std::u16string> additionalSaveFolders(u64 id);
53 |     std::vector<std::u16string> additionalExtdataFolders(u64 id);
54 | 
55 |     void save(void);
56 | 
57 | private:
58 |     Configuration(void);
59 |     ~Configuration();
60 | 
61 |     Configuration(Configuration const&)  = delete;
62 |     void operator=(Configuration const&) = delete;
63 | 
64 |     void loadFromRomfs(void);
65 | 
66 |     std::unique_ptr<nlohmann::json> mJson;
67 |     std::unordered_set<u64> mFilterIds, mFavoriteIds;
68 |     std::unordered_map<u64, std::vector<std::u16string>> mAdditionalSaveFolders, mAdditionalExtdataFolders;
69 |     bool mNandSaves, mScanCard;
70 |     std::string BASEPATH = "/3ds/Checkpoint/config.json";
71 |     size_t oldSize       = 0;
72 | };
73 | 
74 | #endif


--------------------------------------------------------------------------------
/3ds/include/directory.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef DIRECTORY_HPP
28 | #define DIRECTORY_HPP
29 | 
30 | #include "util.hpp"
31 | #include <3ds.h>
32 | #include <string>
33 | #include <vector>
34 | 
35 | class Directory {
36 | public:
37 |     Directory(FS_Archive archive, const std::u16string& root);
38 |     ~Directory() = default;
39 | 
40 |     Result error(void);
41 |     std::u16string entry(size_t index);
42 |     bool folder(size_t index);
43 |     bool good(void);
44 |     size_t size(void);
45 | 
46 | private:
47 |     std::vector<FS_DirectoryEntry> mList;
48 |     Result mError;
49 |     bool mGood;
50 | };
51 | 
52 | #endif


--------------------------------------------------------------------------------
/3ds/include/fsstream.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef FSSTREAM_HPP
28 | #define FSSTREAM_HPP
29 | 
30 | #include <3ds.h>
31 | #include <string>
32 | 
33 | class FSStream {
34 | public:
35 |     FSStream(FS_Archive archive, const std::u16string& path, u32 flags);
36 |     FSStream(FS_Archive archive, const std::u16string& path, u32 flags, u32 size);
37 |     ~FSStream() = default;
38 | 
39 |     Result close(void);
40 |     bool eof(void);
41 |     bool good(void);
42 |     void offset(u32 o);
43 |     u32 offset(void);
44 |     u32 read(void* buf, u32 size);
45 |     Result result(void);
46 |     u32 size(void);
47 |     u32 write(const void* buf, u32 size);
48 | 
49 | private:
50 |     Handle mHandle;
51 |     u32 mSize;
52 |     u32 mOffset;
53 |     Result mResult;
54 |     bool mGood;
55 | };
56 | 
57 | #endif


--------------------------------------------------------------------------------
/3ds/include/gui.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef GUI_HPP
28 | #define GUI_HPP
29 | 
30 | #include "colors.hpp"
31 | #include "main.hpp"
32 | #include "sprites.h"
33 | #include <citro2d.h>
34 | 
35 | inline C3D_RenderTarget* g_top;
36 | inline C3D_RenderTarget* g_bottom;
37 | 
38 | inline C2D_SpriteSheet spritesheet;
39 | inline C2D_Image flag;
40 | inline C2D_Sprite checkbox, star;
41 | 
42 | namespace Gui {
43 |     void init(void);
44 |     void exit(void);
45 |     void frameEnd(void);
46 | 
47 |     void drawPulsingOutline(u32 x, u32 y, u16 w, u16 h, u8 size, u32 color);
48 |     void drawOutline(u32 x, u32 y, u16 w, u16 h, u8 size, u32 color);
49 | 
50 |     C2D_Image noIcon(void);
51 | }
52 | 
53 | #endif


--------------------------------------------------------------------------------
/3ds/include/hid.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef HID_HPP
28 | #define HID_HPP
29 | 
30 | #include "ihid.hpp"
31 | #include <3ds.h>
32 | 
33 | #define DELAY_TICKS 50000000
34 | 
35 | template <HidDirection ListDirection, HidDirection PageDirection>
36 | class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS> {
37 | public:
38 |     Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns) {}
39 | 
40 | private:
41 |     bool downDown() const override { return hidKeysDown() & KEY_DOWN; }
42 |     bool upDown() const override { return hidKeysDown() & KEY_UP; }
43 |     bool leftDown() const override { return hidKeysDown() & KEY_LEFT; }
44 |     bool rightDown() const override { return hidKeysDown() & KEY_RIGHT; }
45 |     bool leftTriggerDown() const override { return hidKeysDown() & KEY_L || hidKeysDown() & KEY_ZL; }
46 |     bool rightTriggerDown() const override { return hidKeysDown() & KEY_R || hidKeysDown() & KEY_ZR; }
47 |     bool downHeld() const override { return hidKeysHeld() & KEY_DOWN; }
48 |     bool upHeld() const override { return hidKeysHeld() & KEY_UP; }
49 |     bool leftHeld() const override { return hidKeysHeld() & KEY_LEFT; }
50 |     bool rightHeld() const override { return hidKeysHeld() & KEY_RIGHT; }
51 |     bool leftTriggerHeld() const override { return hidKeysHeld() & KEY_L || hidKeysHeld() & KEY_ZL; }
52 |     bool rightTriggerHeld() const override { return hidKeysHeld() & KEY_R || hidKeysHeld() & KEY_ZR; }
53 |     u64 tick() const override { return svcGetSystemTick(); }
54 | };
55 | 
56 | #endif
57 | 


--------------------------------------------------------------------------------
/3ds/include/io.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef IO_HPP
28 | #define IO_HPP
29 | 
30 | #include "KeyboardManager.hpp"
31 | #include "directory.hpp"
32 | #include "fsstream.hpp"
33 | #include "multiselection.hpp"
34 | #include "spi.hpp"
35 | #include "title.hpp"
36 | #include "util.hpp"
37 | #include <3ds.h>
38 | #include <tuple>
39 | 
40 | #define BUFFER_SIZE 0x50000
41 | 
42 | namespace io {
43 |     std::tuple<bool, Result, std::string> backup(size_t index, size_t cellIndex);
44 |     std::tuple<bool, Result, std::string> restore(size_t index, size_t cellIndex, const std::string& nameFromCell);
45 | 
46 |     Result copyDirectory(FS_Archive srcArch, FS_Archive dstArch, const std::u16string& srcPath, const std::u16string& dstPath);
47 |     void copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string& srcPath, const std::u16string& dstPath);
48 |     Result createDirectory(FS_Archive archive, const std::u16string& path);
49 |     void deleteBackupFolder(const std::u16string& path);
50 |     Result deleteFolderRecursively(FS_Archive arch, const std::u16string& path);
51 |     bool directoryExists(FS_Archive archive, const std::u16string& path);
52 |     bool fileExists(FS_Archive archive, const std::u16string& path);
53 |     bool fileExists(const std::string& path);
54 | }
55 | 
56 | #endif


--------------------------------------------------------------------------------
/3ds/include/loader.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef LOADER_HPP
28 | #define LOADER_HPP
29 | 
30 | #include "title.hpp"
31 | #include <atomic>
32 | #include <vector>
33 | 
34 | namespace TitleLoader {
35 |     void getTitle(Title& dst, int i);
36 |     int getTitleCount(void);
37 |     C2D_Image icon(int i);
38 |     bool favorite(int i);
39 | 
40 |     void loadTitles(bool forceRefreshParam);
41 |     void refreshDirectories(u64 id);
42 |     void loadTitlesThread(void);
43 |     void cartScan(void);
44 |     void cartScanFlagTestAndSet(void);
45 |     void clearCartScanFlag(void);
46 | 
47 |     bool validId(u64 id);
48 |     bool scanCard(void);
49 |     void exportTitleListCache(std::vector<Title>& list, const std::u16string& path);
50 |     void importTitleListCache(void);
51 | }
52 | 
53 | #endif // LOADER_HPP


--------------------------------------------------------------------------------
/3ds/include/main.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef MAIN_HPP
28 | #define MAIN_HPP
29 | 
30 | #include "Screen.hpp"
31 | #include "logging.hpp"
32 | #include <citro2d.h>
33 | #include <memory>
34 | #include <vector>
35 | 
36 | inline std::shared_ptr<Screen> g_screen = nullptr;
37 | inline bool g_bottomScrollEnabled       = false;
38 | inline float g_timer                    = 0;
39 | inline std::string g_selectedCheatKey;
40 | inline std::vector<std::string> g_selectedCheatCodes;
41 | inline volatile bool g_isLoadingTitles = false;
42 | inline int g_loadingTitlesCounter      = 0;
43 | inline int g_loadingTitlesLimit        = 0;
44 | 
45 | inline std::u16string g_currentFile;
46 | inline bool g_isTransferringFile = false;
47 | 
48 | #endif


--------------------------------------------------------------------------------
/3ds/include/scrollable.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SCROLLABLE_HPP
28 | #define SCROLLABLE_HPP
29 | 
30 | #include "clickable.hpp"
31 | #include "colors.hpp"
32 | #include "hid.hpp"
33 | #include "iscrollable.hpp"
34 | #include "main.hpp"
35 | #include <citro2d.h>
36 | #include <vector>
37 | 
38 | class Scrollable : public IScrollable<u32> {
39 | public:
40 |     Scrollable(int x, int y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
41 | 
42 |     virtual ~Scrollable() = default;
43 | 
44 |     void c2dText(size_t i, const std::string& v);
45 |     void draw(bool condition = false) override;
46 |     void setIndex(size_t i);
47 |     void push_back(u32 color, u32 colorMessage, const std::string& message, bool selected) override;
48 |     void resetIndex(void) override;
49 |     void updateSelection(void) override;
50 | 
51 | protected:
52 |     Hid<HidDirection::VERTICAL, HidDirection::HORIZONTAL> mHid;
53 | };
54 | 
55 | #endif
56 | 


--------------------------------------------------------------------------------
/3ds/include/server.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of PKSM
 3 |  *   Copyright (C) 2016-2025 Bernardo Giordano
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SERVER_HPP
28 | #define SERVER_HPP
29 | 
30 | #include <functional>
31 | #include <string>
32 | 
33 | namespace Server {
34 |     struct HttpResponse {
35 |         int statusCode;
36 |         std::string contentType;
37 |         std::string body;
38 |     };
39 | 
40 |     using HttpHandler = std::function<HttpResponse(const std::string& path, const std::string& requestData)>;
41 | 
42 |     void init(void);
43 |     void exit(void);
44 |     bool isRunning(void);
45 |     std::string getAddress(void);
46 | 
47 |     void registerHandler(const std::string& path, HttpHandler handler);
48 |     void unregisterHandler(const std::string& path);
49 | }
50 | 
51 | #endif


--------------------------------------------------------------------------------
/3ds/include/smdh.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SMDH_HPP
28 | #define SMDH_HPP
29 | 
30 | #include <3ds.h>
31 | #include <stdio.h>
32 | #include <string>
33 | 
34 | typedef struct {
35 |     u32 magic;
36 |     u16 version;
37 |     u16 reserved;
38 | } smdhHeader_s;
39 | 
40 | typedef struct {
41 |     u16 shortDescription[0x40];
42 |     u16 longDescription[0x80];
43 |     u16 publisher[0x40];
44 | } smdhTitle_s;
45 | 
46 | typedef struct {
47 |     u8 gameRatings[0x10];
48 |     u32 regionLock;
49 |     u8 matchMakerId[0xC];
50 |     u32 flags;
51 |     u16 eulaVersion;
52 |     u16 reserved;
53 |     u32 defaultFrame;
54 |     u32 cecId;
55 | } smdhSettings_s;
56 | 
57 | typedef struct {
58 |     smdhHeader_s header;
59 |     smdhTitle_s applicationTitles[16];
60 |     smdhSettings_s settings;
61 |     u8 reserved[0x8];
62 |     u8 smallIconData[0x480];
63 |     u16 bigIconData[0x900];
64 | } smdh_s;
65 | 
66 | smdh_s* loadSMDH(u32 low, u32 high, u8 media);
67 | smdh_s* loadSMDH(const std::string& path);
68 | 
69 | #endif


--------------------------------------------------------------------------------
/3ds/include/spi.hpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | /*
 28 |  *  This file is part of TWLSaveTool.
 29 |  *  Copyright (C) 2015-2016 TuxSH
 30 |  *
 31 |  *  TWLSaveTool is free software: you can redistribute it and/or modify
 32 |  *  it under the terms of the GNU General Public License as published by
 33 |  *  the Free Software Foundation, either version 2 of the License, or
 34 |  *  (at your option) any later version.
 35 |  *
 36 |  *  This program is distributed in the hope that it will be useful,
 37 |  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 38 |  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 39 |  *  GNU General Public License for more details.
 40 |  *
 41 |  *  You should have received a copy of the GNU General Public License
 42 |  *  along with this program.  If not, see <http://www.gnu.org/licenses/>
 43 |  */
 44 | 
 45 | #ifndef SPI_HPP
 46 | #define SPI_HPP
 47 | 
 48 | #include "logging.hpp"
 49 | #include <3ds.h>
 50 | #include <stdio.h>
 51 | #include <string.h>
 52 | 
 53 | extern "C" {
 54 | 
 55 | #define SPI_512B_EEPROM_CMD_WRLO 2
 56 | #define SPI_512B_EEPROM_CMD_WRHI 10
 57 | #define SPI_512B_EEPROM_CMD_RDLO 3
 58 | #define SPI_512B_EEPROM_CMD_RDHI 11
 59 | 
 60 | #define SPI_EEPROM_CMD_WRITE 2
 61 | 
 62 | #define SPI_CMD_PP 2
 63 | #define SPI_CMD_READ 3
 64 | #define SPI_CMD_RDSR 5
 65 | #define SPI_CMD_WREN 6
 66 | 
 67 | #define SPI_FLASH_CMD_PW 10
 68 | #define SPI_FLASH_CMD_RDID 0x9f
 69 | #define SPI_FLASH_CMD_SE 0xd8
 70 | 
 71 | #define SPI_FLG_WIP 1
 72 | #define SPI_FLG_WEL 2
 73 | 
 74 | extern u8* fill_buf;
 75 | 
 76 | typedef enum {
 77 |     NO_CHIP = -1,
 78 | 
 79 |     EEPROM_512B = 0,
 80 | 
 81 |     EEPROM_8KB       = 1,
 82 |     EEPROM_64KB      = 2,
 83 |     EEPROM_128KB     = 3,
 84 |     EEPROM_STD_DUMMY = 1,
 85 | 
 86 |     FLASH_256KB_1   = 4,
 87 |     FLASH_256KB_2   = 5,
 88 |     FLASH_512KB_1   = 6,
 89 |     FLASH_512KB_2   = 7,
 90 |     FLASH_1MB       = 8,
 91 |     FLASH_8MB       = 9, // <- can't restore savegames, and maybe not read them atm
 92 |     FLASH_STD_DUMMY = 4,
 93 | 
 94 |     FLASH_512KB_INFRARED = 10,
 95 |     FLASH_256KB_INFRARED = 11, // AFAIK, only "Active Health with Carol Vorderman" has such a flash save memory
 96 |     FLASH_INFRARED_DUMMY = 9,
 97 | 
 98 |     CHIP_LAST = 11,
 99 | } CardType;
100 | 
101 | Result SPIWriteRead(CardType type, void* cmd, u32 cmdSize, void* answer, u32 answerSize, void* data, u32 dataSize);
102 | Result SPIWaitWriteEnd(CardType type);
103 | Result SPIEnableWriting(CardType type);
104 | Result SPIReadJEDECIDAndStatusReg(CardType type, u32* id, u8* statusReg);
105 | Result SPIGetCardType(CardType* type, int infrared);
106 | u32 SPIGetPageSize(CardType type);
107 | u32 SPIGetCapacity(CardType type);
108 | Result SPIWriteSaveData(CardType type, u32 offset, void* data, u32 size);
109 | Result SPIReadSaveData(CardType type, u32 offset, void* data, u32 size);
110 | Result SPIEraseSector(CardType type, u32 offset);
111 | 
112 | } // extern "C"
113 | 
114 | #endif


--------------------------------------------------------------------------------
/3ds/include/title.hpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #ifndef TITLE_HPP
 28 | #define TITLE_HPP
 29 | 
 30 | #include "archive.hpp"
 31 | #include "configuration.hpp"
 32 | #include "directory.hpp"
 33 | #include "fsstream.hpp"
 34 | #include "gui.hpp"
 35 | #include "io.hpp"
 36 | #include "smdh.hpp"
 37 | #include "spi.hpp"
 38 | #include "util.hpp"
 39 | #include <algorithm>
 40 | #include <citro2d.h>
 41 | #include <string>
 42 | #include <vector>
 43 | 
 44 | extern "C" {
 45 | #include "sha256.h"
 46 | }
 47 | 
 48 | #define TID_PKSM 0x000400000EC10000
 49 | 
 50 | class Title {
 51 | public:
 52 |     ~Title(void);
 53 | 
 54 |     bool accessibleSave(void);
 55 |     bool accessibleExtdata(void);
 56 |     FS_CardType cardType(void);
 57 |     std::vector<std::u16string> extdata(void);
 58 |     u32 extdataId(void);
 59 |     std::u16string extdataPath(void);
 60 |     std::u16string fullExtdataPath(size_t index);
 61 |     u32 highId(void);
 62 |     C2D_Image icon(void);
 63 |     u64 id(void);
 64 |     bool isActivityLog(void);
 65 |     void load(void);
 66 |     bool load(u64 id, FS_MediaType mediaType, FS_CardType cardType);
 67 |     void load(u64 id, u8* productCode, bool accessibleSave, bool accessibleExtdata, std::u16string shortDescription, std::u16string longDescription,
 68 |         std::u16string savePath, std::u16string extdataPath, FS_MediaType media, FS_CardType cardType, CardType card);
 69 |     std::string longDescription(void);
 70 |     std::u16string getLongDescription(void);
 71 |     u32 lowId(void);
 72 |     FS_MediaType mediaType(void);
 73 |     std::string mediaTypeString(void);
 74 |     void refreshDirectories(void);
 75 |     std::u16string savePath(void);
 76 |     std::u16string fullSavePath(size_t index);
 77 |     std::vector<std::u16string> saves(void);
 78 |     void setIcon(C2D_Image icon);
 79 |     std::string shortDescription(void);
 80 |     std::u16string getShortDescription(void);
 81 |     CardType SPICardType(void);
 82 |     u32 uniqueId(void);
 83 | 
 84 |     char productCode[16];
 85 | 
 86 | private:
 87 |     bool mAccessibleSave;
 88 |     bool mAccessibleExtdata;
 89 |     std::u16string mShortDescription;
 90 |     std::u16string mLongDescription;
 91 |     std::u16string mSavePath;
 92 |     std::u16string mExtdataPath;
 93 | 
 94 |     std::vector<std::u16string> mSaves;
 95 |     std::vector<std::u16string> mFullSavePaths;
 96 |     std::vector<std::u16string> mExtdata;
 97 |     std::vector<std::u16string> mFullExtdataPaths;
 98 |     u64 mId;
 99 |     FS_MediaType mMedia;
100 |     FS_CardType mCard;
101 |     CardType mCardType;
102 |     C2D_Image mIcon;
103 | };
104 | 
105 | C2D_Image loadTextureFromBytes(u16* bigIconData);
106 | 
107 | #endif


--------------------------------------------------------------------------------
/3ds/include/util.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef UTIL_HPP
28 | #define UTIL_HPP
29 | 
30 | #include "archive.hpp"
31 | #include "common.hpp"
32 | #include "configuration.hpp"
33 | #include "gui.hpp"
34 | #include "logging.hpp"
35 | #include <3ds.h>
36 | #include <citro2d.h>
37 | #include <map>
38 | #include <queue>
39 | #include <sys/stat.h>
40 | 
41 | extern "C" {
42 | #include "sha256.h"
43 | }
44 | 
45 | Result consoleDisplayError(const std::string& message, Result res);
46 | void calculateTitleDBHash(u8* hash);
47 | Result servicesInit(void);
48 | 
49 | namespace StringUtils {
50 |     std::u16string removeForbiddenCharacters(std::u16string src);
51 |     std::u16string UTF8toUTF16(const char* src);
52 |     std::string splitWord(const std::string& text, float scaleX, float maxWidth);
53 |     float textWidth(const std::string& text, float scaleX);
54 |     float textWidth(const C2D_Text& text, float scaleX);
55 |     std::string wrap(const std::string& text, float scaleX, float maxWidth);
56 |     float textHeight(const std::string& text, float scaleY);
57 | }
58 | 
59 | #endif


--------------------------------------------------------------------------------
/3ds/source/ErrorOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "ErrorOverlay.hpp"
28 | 
29 | ErrorOverlay::ErrorOverlay(Screen& screen, Result res, const std::string& mtext) : Overlay(screen)
30 | {
31 |     textBuf = C2D_TextBufNew(128);
32 |     button  = std::make_unique<Clickable>(42, 162, 236, 36, COLOR_BLACK_DARK, COLOR_WHITE, "OK", true);
33 |     button->selected(true);
34 |     std::string t = StringUtils::wrap(mtext, size, 220);
35 |     std::string e = StringUtils::format("Error: 0x%08lX", res);
36 |     C2D_TextParse(&text, textBuf, t.c_str());
37 |     C2D_TextParse(&error, textBuf, e.c_str());
38 |     C2D_TextOptimize(&text);
39 |     C2D_TextOptimize(&error);
40 |     posx = ceilf(320 - StringUtils::textWidth(text, size)) / 2;
41 |     posy = 40 + ceilf(120 - StringUtils::textHeight(t, size)) / 2;
42 | }
43 | 
44 | ErrorOverlay::~ErrorOverlay(void)
45 | {
46 |     C2D_TextBufDelete(textBuf);
47 | }
48 | 
49 | void ErrorOverlay::drawTop(void) const
50 | {
51 |     C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
52 | }
53 | 
54 | void ErrorOverlay::drawBottom(void) const
55 | {
56 |     C2D_DrawRectSolid(0, 0, 0.5f, 320, 240, COLOR_OVERLAY);
57 |     C2D_DrawRectSolid(40, 40, 0.5f, 240, 160, COLOR_BLACK_DARKERR);
58 |     C2D_DrawText(&error, C2D_WithColor, 44, 44, 0.5f, 0.5f, 0.5f, COLOR_RED);
59 |     C2D_DrawText(&text, C2D_WithColor, posx, posy, 0.5f, size, size, COLOR_WHITE);
60 |     button->draw(0.7f, COLOR_RED);
61 |     Gui::drawPulsingOutline(42, 162, 236, 36, 2, COLOR_RED);
62 | }
63 | 
64 | void ErrorOverlay::update(const InputState& input)
65 | {
66 |     (void)input;
67 |     if (button->released() || (hidKeysDown() & KEY_A) || (hidKeysDown() & KEY_B)) {
68 |         screen.removeOverlay();
69 |     }
70 | }


--------------------------------------------------------------------------------
/3ds/source/InfoOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "InfoOverlay.hpp"
28 | 
29 | InfoOverlay::InfoOverlay(Screen& screen, const std::string& mtext) : Overlay(screen)
30 | {
31 |     textBuf = C2D_TextBufNew(64);
32 |     button  = std::make_unique<Clickable>(42, 162, 236, 36, COLOR_BLACK_DARK, COLOR_WHITE, "OK", true);
33 |     button->selected(true);
34 |     std::string t = StringUtils::wrap(mtext, size, 220);
35 |     C2D_TextParse(&text, textBuf, t.c_str());
36 |     C2D_TextOptimize(&text);
37 |     posx = ceilf(320 - StringUtils::textWidth(text, size)) / 2;
38 |     posy = 40 + ceilf(120 - StringUtils::textHeight(t, size)) / 2;
39 | }
40 | 
41 | InfoOverlay::~InfoOverlay(void)
42 | {
43 |     C2D_TextBufDelete(textBuf);
44 | }
45 | 
46 | void InfoOverlay::drawTop(void) const
47 | {
48 |     C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
49 | }
50 | 
51 | void InfoOverlay::drawBottom(void) const
52 | {
53 |     C2D_DrawRectSolid(0, 0, 0.5f, 320, 240, COLOR_OVERLAY);
54 |     C2D_DrawRectSolid(40, 40, 0.5f, 240, 160, COLOR_BLACK_DARKERR);
55 |     C2D_DrawText(&text, C2D_WithColor, posx, posy, 0.5f, size, size, COLOR_WHITE);
56 |     button->draw(0.7f, COLOR_PURPLE_DARK);
57 |     Gui::drawPulsingOutline(42, 162, 236, 36, 2, COLOR_PURPLE_DARK);
58 | }
59 | 
60 | void InfoOverlay::update(const InputState& input)
61 | {
62 |     (void)input;
63 |     if (button->released() || (hidKeysDown() & KEY_A) || (hidKeysDown() & KEY_B)) {
64 |         screen.removeOverlay();
65 |     }
66 | }


--------------------------------------------------------------------------------
/3ds/source/KeyboardManager.cpp:
--------------------------------------------------------------------------------
 1 | #include "KeyboardManager.hpp"
 2 | 
 3 | std::u16string KeyboardManager::keyboard(const std::string& suggestion)
 4 | {
 5 |     swkbdSetInitialText(&mSwkbd, suggestion.c_str());
 6 |     char buf[CUSTOM_PATH_LEN] = {0};
 7 |     SwkbdButton button        = swkbdInputText(&mSwkbd, buf, CUSTOM_PATH_LEN);
 8 |     buf[CUSTOM_PATH_LEN - 1]  = '\0';
 9 |     return button == SWKBD_BUTTON_CONFIRM ? StringUtils::removeForbiddenCharacters(StringUtils::UTF8toUTF16(buf)) : StringUtils::UTF8toUTF16("");
10 | }
11 | 
12 | int KeyboardManager::numericPad(void)
13 | {
14 |     static SwkbdState swkbd;
15 |     swkbdInit(&swkbd, SWKBD_TYPE_NUMPAD, 2, 3);
16 |     swkbdSetFeatures(&swkbd, SWKBD_FIXED_WIDTH);
17 |     swkbdSetValidation(&swkbd, SWKBD_NOTBLANK_NOTEMPTY, 0, 0);
18 |     char buf[4]        = {0};
19 |     SwkbdButton button = swkbdInputText(&swkbd, buf, sizeof(buf));
20 |     buf[3]             = '\0';
21 |     return button == SWKBD_BUTTON_CONFIRM ? atoi(buf) : -1;
22 | }
23 | 
24 | KeyboardManager::KeyboardManager(void)
25 | {
26 |     swkbdInit(&mSwkbd, SWKBD_TYPE_NORMAL, 2, CUSTOM_PATH_LEN - 1);
27 |     swkbdSetHintText(&mSwkbd, "Choose a name for your backup.");
28 | }


--------------------------------------------------------------------------------
/3ds/source/YesNoOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "YesNoOverlay.hpp"
28 | 
29 | YesNoOverlay::YesNoOverlay(
30 |     Screen& screen, const std::string& mtext, const std::function<void()>& callbackYes, const std::function<void()>& callbackNo)
31 |     : Overlay(screen), hid(2, 2)
32 | {
33 |     textBuf = C2D_TextBufNew(64);
34 |     C2D_TextParse(&text, textBuf, mtext.c_str());
35 |     C2D_TextOptimize(&text);
36 | 
37 |     yesFunc = callbackYes;
38 |     noFunc  = callbackNo;
39 | 
40 |     posx = ceilf(320 - text.width * 0.6) / 2;
41 |     posy = 40 + ceilf(120 - 0.6f * fontGetInfo(NULL)->lineFeed) / 2;
42 | 
43 |     buttonYes = std::make_unique<Clickable>(42, 162, 116, 36, COLOR_BLACK_DARKERR, COLOR_WHITE, "\uE000 Yes", true);
44 |     buttonNo  = std::make_unique<Clickable>(162, 162, 116, 36, COLOR_BLACK_DARKERR, COLOR_WHITE, "\uE001 No", true);
45 | }
46 | 
47 | YesNoOverlay::~YesNoOverlay(void)
48 | {
49 |     C2D_TextBufDelete(textBuf);
50 | }
51 | 
52 | void YesNoOverlay::drawTop(void) const
53 | {
54 |     C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
55 | }
56 | 
57 | void YesNoOverlay::drawBottom(void) const
58 | {
59 |     C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
60 |     C2D_DrawRectSolid(40, 40, 0.5f, 240, 160, COLOR_BLACK_DARKER);
61 |     C2D_DrawText(&text, C2D_WithColor, posx, posy, 0.5f, 0.6f, 0.6f, COLOR_WHITE);
62 |     C2D_DrawRectSolid(40, 160, 0.5f, 240, 40, COLOR_BLACK_MEDIUM);
63 | 
64 |     buttonYes->draw(0.7, 0);
65 |     buttonNo->draw(0.7, 0);
66 | 
67 |     if (hid.index() == 0) {
68 |         Gui::drawPulsingOutline(42, 162, 116, 36, 2, COLOR_PURPLE_DARK);
69 |     }
70 |     else {
71 |         Gui::drawPulsingOutline(162, 162, 116, 36, 2, COLOR_PURPLE_DARK);
72 |     }
73 | }
74 | 
75 | void YesNoOverlay::update(const InputState& input)
76 | {
77 |     (void)input;
78 |     hid.update(2);
79 | 
80 |     hid.index(buttonYes->held() ? 0 : buttonNo->held() ? 1 : hid.index());
81 |     buttonYes->selected(hid.index() == 0);
82 |     buttonNo->selected(hid.index() == 1);
83 | 
84 |     if (buttonYes->released() || ((hidKeysDown() & KEY_A) && hid.index() == 0)) {
85 |         yesFunc();
86 |     }
87 |     else if (buttonNo->released() || (hidKeysDown() & KEY_B) || ((hidKeysDown() & KEY_A) && hid.index() == 1)) {
88 |         noFunc();
89 |     }
90 | }


--------------------------------------------------------------------------------
/3ds/source/archive.cpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #include "archive.hpp"
 28 | 
 29 | static FS_Archive mSdmc;
 30 | static Mode_t mMode = MODE_SAVE;
 31 | 
 32 | Mode_t Archive::mode(void)
 33 | {
 34 |     return mMode;
 35 | }
 36 | 
 37 | void Archive::mode(Mode_t v)
 38 | {
 39 |     mMode = v;
 40 | }
 41 | 
 42 | Result Archive::init(void)
 43 | {
 44 |     return FSUSER_OpenArchive(&mSdmc, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
 45 | }
 46 | 
 47 | void Archive::exit(void)
 48 | {
 49 |     FSUSER_CloseArchive(mSdmc);
 50 | }
 51 | 
 52 | FS_Archive Archive::sdmc(void)
 53 | {
 54 |     return mSdmc;
 55 | }
 56 | 
 57 | Result Archive::save(FS_Archive* archive, FS_MediaType mediatype, u32 lowid, u32 highid)
 58 | {
 59 |     if (mediatype == MEDIATYPE_NAND) {
 60 |         const u32 path[2] = {mediatype, (0x00020000 | lowid >> 8)};
 61 |         return FSUSER_OpenArchive(archive, ARCHIVE_SYSTEM_SAVEDATA, {PATH_BINARY, 8, path});
 62 |     }
 63 |     else {
 64 |         const u32 path[3] = {mediatype, lowid, highid};
 65 |         return FSUSER_OpenArchive(archive, ARCHIVE_USER_SAVEDATA, {PATH_BINARY, 12, path});
 66 |     }
 67 |     return 0;
 68 | }
 69 | 
 70 | Result Archive::extdata(FS_Archive* archive, u32 ext)
 71 | {
 72 |     const u32 path[3] = {MEDIATYPE_SD, ext, 0};
 73 |     return FSUSER_OpenArchive(archive, ARCHIVE_EXTDATA, {PATH_BINARY, 12, path});
 74 | }
 75 | 
 76 | bool Archive::accessible(FS_MediaType mediatype, u32 lowid, u32 highid)
 77 | {
 78 |     FS_Archive archive;
 79 |     Result res = save(&archive, mediatype, lowid, highid);
 80 |     if (R_SUCCEEDED(res)) {
 81 |         FSUSER_CloseArchive(archive);
 82 |         return true;
 83 |     }
 84 |     return false;
 85 | }
 86 | 
 87 | bool Archive::accessible(u32 ext)
 88 | {
 89 |     FS_Archive archive;
 90 |     Result res = extdata(&archive, ext);
 91 |     if (R_SUCCEEDED(res)) {
 92 |         FSUSER_CloseArchive(archive);
 93 |         return true;
 94 |     }
 95 |     return false;
 96 | }
 97 | 
 98 | bool Archive::setPlayCoins(void)
 99 | {
100 |     FS_Archive archive;
101 |     const u32 path[3] = {MEDIATYPE_NAND, 0xF000000B, 0x00048000};
102 |     Result res        = FSUSER_OpenArchive(&archive, ARCHIVE_SHARED_EXTDATA, {PATH_BINARY, 0xC, path});
103 |     if (R_SUCCEEDED(res)) {
104 |         FSStream s(archive, StringUtils::UTF8toUTF16("/gamecoin.dat"), FS_OPEN_READ | FS_OPEN_WRITE);
105 |         if (s.good()) {
106 |             int coinAmount = KeyboardManager::get().numericPad();
107 |             if (coinAmount >= 0) {
108 |                 coinAmount = coinAmount > 300 ? 300 : coinAmount;
109 |                 s.offset(4);
110 |                 u8 buf[2] = {(u8)coinAmount, (u8)(coinAmount >> 8)};
111 |                 s.write(buf, 2);
112 |             }
113 | 
114 |             s.close();
115 |             FSUSER_CloseArchive(archive);
116 |             return true;
117 |         }
118 |         FSUSER_CloseArchive(archive);
119 |     }
120 |     return false;
121 | }


--------------------------------------------------------------------------------
/3ds/source/cheatmanager.cpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #include "cheatmanager.hpp"
 28 | 
 29 | CheatManager::CheatManager(void)
 30 | {
 31 |     mCheats = nullptr;
 32 |     if (io::fileExists("/3ds/Checkpoint/cheats.json")) {
 33 |         const std::string path = "/3ds/Checkpoint/cheats.json";
 34 |         FILE* in               = fopen(path.c_str(), "rt");
 35 |         if (in != NULL) {
 36 |             mCheats = std::make_shared<nlohmann::json>(nlohmann::json::parse(in, nullptr, false));
 37 |             fclose(in);
 38 |         }
 39 |         else {
 40 |             Logging::warning("Failed to open {} with errno {}.", path, errno);
 41 |         }
 42 |     }
 43 |     else {
 44 |         const std::string path = "romfs:/cheats/cheats.json.bz2";
 45 |         // load compressed archive in memory
 46 |         FILE* f = fopen(path.c_str(), "rb");
 47 |         if (f != NULL) {
 48 |             fseek(f, 0, SEEK_END);
 49 |             u32 size             = ftell(f);
 50 |             unsigned int destLen = CHEAT_SIZE_DECOMPRESSED;
 51 |             char* s              = new char[size];
 52 |             char* d              = new char[destLen + 1]();
 53 |             rewind(f);
 54 |             fread(s, 1, size, f);
 55 | 
 56 |             int r = BZ2_bzBuffToBuffDecompress(d, &destLen, s, size, 0, 0);
 57 |             if (r == BZ_OK) {
 58 |                 mCheats = std::make_shared<nlohmann::json>(nlohmann::json::parse(d));
 59 |             }
 60 | 
 61 |             delete[] s;
 62 |             delete[] d;
 63 |             fclose(f);
 64 |         }
 65 |         else {
 66 |             Logging::warning("Failed to open {} with errno {}.", path, errno);
 67 |         }
 68 |     }
 69 | }
 70 | 
 71 | bool CheatManager::areCheatsAvailable(const std::string& key)
 72 | {
 73 |     return mCheats->find(key) != mCheats->end();
 74 | }
 75 | 
 76 | void CheatManager::save(const std::string& key, const std::vector<std::string>& s)
 77 | {
 78 |     static size_t MAGIC_LEN = strlen(SELECTED_MAGIC);
 79 | 
 80 |     std::string cheatFile = "";
 81 |     auto cheats           = *CheatManager::getInstance().cheats().get();
 82 |     for (size_t i = 0; i < s.size(); i++) {
 83 |         std::string cellName = s.at(i);
 84 |         if (cellName.compare(0, MAGIC_LEN, SELECTED_MAGIC) == 0) {
 85 |             cellName = cellName.substr(MAGIC_LEN, cellName.length());
 86 |             cheatFile += "[" + cellName + "]\n";
 87 |             for (auto& it : cheats[key][cellName]) {
 88 |                 cheatFile += it.get<std::string>() + "\n";
 89 |             }
 90 |             cheatFile += "\n";
 91 |         }
 92 |     }
 93 | 
 94 |     const std::string outPath = "/cheats/" + key + ".txt";
 95 |     FILE* f                   = fopen(outPath.c_str(), "w");
 96 |     if (f != NULL) {
 97 |         fwrite(cheatFile.c_str(), 1, cheatFile.length(), f);
 98 |         fclose(f);
 99 |     }
100 |     else {
101 |         Logging::error("Failed to write {} with errno {}.", outPath, errno);
102 |     }
103 | }


--------------------------------------------------------------------------------
/3ds/source/clickable.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "clickable.hpp"
28 | 
29 | void Clickable::c2dText(const std::string& v)
30 | {
31 |     text(v);
32 |     mTextBuf = C2D_TextBufNew(64);
33 |     C2D_TextParse(&mC2dText, mTextBuf, v.c_str());
34 |     C2D_TextOptimize(&mC2dText);
35 | }
36 | 
37 | bool Clickable::held()
38 | {
39 |     touchPosition touch;
40 |     hidTouchRead(&touch);
41 |     return ((hidKeysHeld() & KEY_TOUCH) && touch.px > mx && touch.px < mx + mw && touch.py > my && touch.py < my + mh);
42 | }
43 | 
44 | bool Clickable::released(void)
45 | {
46 |     touchPosition touch;
47 |     hidTouchRead(&touch);
48 |     const bool on = touch.px > mx && touch.px < mx + mw && touch.py > my && touch.py < my + mh;
49 | 
50 |     if (on) {
51 |         mOldPressed = true;
52 |     }
53 |     else {
54 |         if (mOldPressed && !(touch.px > 0 || touch.py > 0)) {
55 |             mOldPressed = false;
56 |             return true;
57 |         }
58 |         mOldPressed = false;
59 |     }
60 | 
61 |     return false;
62 | }
63 | 
64 | void Clickable::draw(float size, u32 overlayWhenFocused)
65 | {
66 |     u8 r, g, b;
67 |     if (mSelected || held()) {
68 |         r = (overlayWhenFocused >> 0) & 0xFF;
69 |         g = (overlayWhenFocused >> 8) & 0xFF;
70 |         b = (overlayWhenFocused >> 16) & 0xFF;
71 |     }
72 |     else {
73 |         r = 0;
74 |         g = 0;
75 |         b = 0;
76 |     }
77 |     const float messageHeight = ceilf(size * fontGetInfo(NULL)->lineFeed);
78 |     const float messageWidth  = mCentered ? mC2dText.width * size : mw - 8;
79 | 
80 |     C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, mColorBg);
81 |     if (mCanChangeColorWhenSelected && held()) {
82 |         C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, C2D_Color32(r, g, b, 100));
83 |     }
84 |     if (!mCentered && mSelected) {
85 |         C2D_DrawRectSolid(mx + 4, my + 6, 0.5f, 4, mh - 12, COLOR_WHITE);
86 |     }
87 |     if (mSelected) {
88 |         C2D_DrawRectSolid(mx, my, 0.5f, mw, mh, C2D_Color32(r, g, b, 100));
89 |     }
90 |     int offset = ceilf(mx + (mw - messageWidth) / 2) + (!mCentered ? 8 : 0);
91 |     C2D_DrawText(&mC2dText, C2D_WithColor, offset, ceilf(my + (mh - messageHeight) / 2), 0.5f, size, size, mColorText);
92 | }
93 | 
94 | void Clickable::drawOutline(u32 color)
95 | {
96 |     Gui::drawPulsingOutline(mx, my, mw, mh, 2, color);
97 | }


--------------------------------------------------------------------------------
/3ds/source/directory.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "directory.hpp"
28 | 
29 | Directory::Directory(FS_Archive archive, const std::u16string& root)
30 | {
31 |     mGood = false;
32 |     mList.clear();
33 |     Handle handle;
34 | 
35 |     mError = FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_UTF16, root.data()));
36 |     if (R_FAILED(mError)) {
37 |         return;
38 |     }
39 | 
40 |     u32 result;
41 |     do {
42 |         FS_DirectoryEntry item;
43 |         mError = FSDIR_Read(handle, &result, 1, &item);
44 |         if (result == 1) {
45 |             mList.push_back(item);
46 |         }
47 |     } while (result);
48 | 
49 |     mError = FSDIR_Close(handle);
50 |     if (R_FAILED(mError)) {
51 |         mList.clear();
52 |         return;
53 |     }
54 | 
55 |     mGood = true;
56 | }
57 | 
58 | Result Directory::error(void)
59 | {
60 |     return mError;
61 | }
62 | 
63 | bool Directory::good(void)
64 | {
65 |     return mGood;
66 | }
67 | 
68 | std::u16string Directory::entry(size_t index)
69 | {
70 |     return index < mList.size() ? (char16_t*)mList.at(index).name : StringUtils::UTF8toUTF16("");
71 | }
72 | 
73 | bool Directory::folder(size_t index)
74 | {
75 |     return index < mList.size() ? (mList.at(index).attributes & FS_ATTRIBUTE_DIRECTORY) != 0 : false;
76 | }
77 | 
78 | size_t Directory::size(void)
79 | {
80 |     return mList.size();
81 | }


--------------------------------------------------------------------------------
/3ds/source/fsstream.cpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #include "fsstream.hpp"
 28 | 
 29 | FSStream::FSStream(FS_Archive archive, const std::u16string& path, u32 flags)
 30 | {
 31 |     mGood   = false;
 32 |     mSize   = 0;
 33 |     mOffset = 0;
 34 | 
 35 |     mResult = FSUSER_OpenFile(&mHandle, archive, fsMakePath(PATH_UTF16, path.data()), flags, 0);
 36 |     if (R_SUCCEEDED(mResult)) {
 37 |         FSFILE_GetSize(mHandle, (u64*)&mSize);
 38 |         mGood = true;
 39 |     }
 40 | }
 41 | 
 42 | FSStream::FSStream(FS_Archive archive, const std::u16string& path, u32 flags, u32 size)
 43 | {
 44 |     mGood   = false;
 45 |     mSize   = size;
 46 |     mOffset = 0;
 47 | 
 48 |     mResult = FSUSER_OpenFile(&mHandle, archive, fsMakePath(PATH_UTF16, path.data()), flags, 0);
 49 |     if (R_FAILED(mResult)) {
 50 |         mResult = FSUSER_CreateFile(archive, fsMakePath(PATH_UTF16, path.data()), 0, mSize);
 51 |         if (R_SUCCEEDED(mResult)) {
 52 |             mResult = FSUSER_OpenFile(&mHandle, archive, fsMakePath(PATH_UTF16, path.data()), flags, 0);
 53 |             if (R_SUCCEEDED(mResult)) {
 54 |                 mGood = true;
 55 |             }
 56 |         }
 57 |     }
 58 |     else {
 59 |         mGood = true;
 60 |     }
 61 | }
 62 | 
 63 | Result FSStream::close(void)
 64 | {
 65 |     mResult = FSFILE_Close(mHandle);
 66 |     return mResult;
 67 | }
 68 | 
 69 | bool FSStream::good(void)
 70 | {
 71 |     return mGood;
 72 | }
 73 | 
 74 | Result FSStream::result(void)
 75 | {
 76 |     return mResult;
 77 | }
 78 | 
 79 | u32 FSStream::size(void)
 80 | {
 81 |     return mSize;
 82 | }
 83 | 
 84 | u32 FSStream::read(void* buf, u32 sz)
 85 | {
 86 |     u32 rd  = 0;
 87 |     mResult = FSFILE_Read(mHandle, &rd, mOffset, buf, sz);
 88 |     if (R_FAILED(mResult)) {
 89 |         if (rd > sz) {
 90 |             rd = sz;
 91 |         }
 92 |     }
 93 |     mOffset += rd;
 94 |     return rd;
 95 | }
 96 | 
 97 | u32 FSStream::write(const void* buf, u32 sz)
 98 | {
 99 |     u32 wt  = 0;
100 |     mResult = FSFILE_Write(mHandle, &wt, mOffset, buf, sz, FS_WRITE_FLUSH);
101 |     mOffset += wt;
102 |     return wt;
103 | }
104 | 
105 | bool FSStream::eof(void)
106 | {
107 |     return mOffset >= mSize;
108 | }
109 | 
110 | u32 FSStream::offset(void)
111 | {
112 |     return mOffset;
113 | }
114 | 
115 | void FSStream::offset(u32 offset)
116 | {
117 |     mOffset = offset;
118 | }


--------------------------------------------------------------------------------
/3ds/source/gui.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "gui.hpp"
28 | 
29 | C2D_Image Gui::noIcon(void)
30 | {
31 |     return C2D_SpriteSheetGetImage(spritesheet, sprites_noicon_idx);
32 | }
33 | 
34 | void Gui::init(void)
35 | {
36 |     C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
37 |     C2D_Init(C2D_DEFAULT_MAX_OBJECTS);
38 |     C2D_Prepare();
39 | 
40 |     g_top    = C2D_CreateScreenTarget(GFX_TOP, GFX_LEFT);
41 |     g_bottom = C2D_CreateScreenTarget(GFX_BOTTOM, GFX_LEFT);
42 | 
43 |     spritesheet = C2D_SpriteSheetLoad("romfs:/gfx/sprites.t3x");
44 |     flag        = C2D_SpriteSheetGetImage(spritesheet, sprites_checkpoint_idx);
45 |     C2D_SpriteFromSheet(&checkbox, spritesheet, sprites_checkbox_idx);
46 |     C2D_SpriteSetDepth(&checkbox, 0.5f);
47 |     C2D_SpriteFromSheet(&star, spritesheet, sprites_star_idx);
48 |     C2D_SpriteSetDepth(&star, 0.5f);
49 | }
50 | 
51 | void Gui::exit(void)
52 | {
53 |     if (spritesheet) {
54 |         C2D_SpriteSheetFree(spritesheet);
55 |     }
56 |     C2D_Fini();
57 |     C3D_Fini();
58 | }
59 | 
60 | void Gui::frameEnd(void)
61 | {
62 |     C3D_FrameEnd(0);
63 |     g_timer += 0.025f;
64 | }
65 | 
66 | void Gui::drawPulsingOutline(u32 x, u32 y, u16 w, u16 h, u8 size, u32 color)
67 | {
68 |     u8 r                       = color & 0xFF;
69 |     u8 g                       = (color >> 8) & 0xFF;
70 |     u8 b                       = (color >> 16) & 0xFF;
71 |     float highlight_multiplier = fmax(0.0, fabs(fmod(g_timer, 1.0) - 0.5) / 0.5);
72 |     color = C2D_Color32(r + (255 - r) * highlight_multiplier, g + (255 - g) * highlight_multiplier, b + (255 - b) * highlight_multiplier, 255);
73 |     drawOutline(x, y, w, h, size, color);
74 | }
75 | 
76 | void Gui::drawOutline(u32 x, u32 y, u16 w, u16 h, u8 size, u32 color)
77 | {
78 |     C2D_DrawRectSolid(x - size, y - size, 0.5f, w + 2 * size, size, color); // top
79 |     C2D_DrawRectSolid(x - size, y, 0.5f, size, h, color);                   // left
80 |     C2D_DrawRectSolid(x + w, y, 0.5f, size, h, color);                      // right
81 |     C2D_DrawRectSolid(x - size, y + h, 0.5f, w + 2 * size, size, color);    // bottom
82 | }


--------------------------------------------------------------------------------
/3ds/source/main.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "main.hpp"
28 | #include "MainScreen.hpp"
29 | #include "thread.hpp"
30 | #include "util.hpp"
31 | #include <chrono>
32 | 
33 | int main()
34 | {
35 |     auto start = std::chrono::high_resolution_clock::now();
36 | 
37 |     Result res;
38 |     try {
39 |         res = servicesInit();
40 |     }
41 |     catch (const std::exception& e) {
42 |         res = consoleDisplayError(std::string("Error during services init. ") + e.what(), -1);
43 |         exit(res);
44 |     }
45 |     catch (...) {
46 |         res = consoleDisplayError("Unknown error during startup", -2);
47 |         exit(res);
48 |     }
49 | 
50 |     if (R_FAILED(res)) {
51 |         // at this point we already had an error message displayed
52 |         exit(res);
53 |     }
54 | 
55 |     try {
56 |         g_screen       = std::make_unique<MainScreen>();
57 |         auto uiIsReady = std::chrono::high_resolution_clock::now();
58 |         Logging::info("Loading took {} ms", std::chrono::duration_cast<std::chrono::milliseconds>(uiIsReady - start).count());
59 | 
60 |         while (aptMainLoop()) {
61 |             touchPosition touch;
62 |             hidScanInput();
63 |             hidTouchRead(&touch);
64 | 
65 |             if (hidKeysDown() & KEY_START) {
66 |                 if (!g_isLoadingTitles) {
67 |                     break;
68 |                 }
69 |             }
70 | 
71 |             C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
72 |             g_screen->doDrawTop();
73 |             C2D_SceneBegin(g_bottom);
74 |             g_screen->doDrawBottom();
75 |             Gui::frameEnd();
76 |             g_screen->doUpdate(InputState{touch});
77 |         }
78 |     }
79 |     catch (const std::exception& e) {
80 |         consoleDisplayError(std::string("Error during main. ") + e.what(), -5);
81 |     }
82 |     catch (...) {
83 |         res = consoleDisplayError("Unknown error during main", -6);
84 |     }
85 | 
86 |     exit(0);
87 | }
88 | 


--------------------------------------------------------------------------------
/3ds/source/scrollable.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "scrollable.hpp"
28 | #include "main.hpp"
29 | 
30 | void Scrollable::c2dText(size_t i, const std::string& v)
31 | {
32 |     ((Clickable*)mCells.at(i))->c2dText(v);
33 | }
34 | 
35 | void Scrollable::setIndex(size_t i)
36 | {
37 |     IScrollable::index(i);
38 |     mHid.index(mIndex);
39 |     mHid.page(mPage);
40 | }
41 | 
42 | void Scrollable::resetIndex(void)
43 | {
44 |     setIndex(0);
45 | }
46 | 
47 | void Scrollable::push_back(u32 color, u32 colorMessage, const std::string& message, bool selected)
48 | {
49 |     const float spacing = mh / mVisibleEntries;
50 |     Clickable* cell     = new Clickable(mx, my + (size() % mVisibleEntries) * spacing, mw, spacing, color, colorMessage, message, false);
51 |     cell->selected(selected);
52 |     mCells.push_back(cell);
53 | }
54 | 
55 | void Scrollable::updateSelection(void)
56 | {
57 |     touchPosition touch;
58 |     hidTouchRead(&touch);
59 | 
60 |     const u32 hu = (mHid.maxEntries(size()) + 1) * mh / mVisibleEntries;
61 | 
62 |     if (hidKeysHeld() & KEY_TOUCH && touch.py > (float)my && touch.py < (float)(my + hu) && touch.px > (float)mx && touch.px < (float)(mx + mw)) {
63 |         mHid.index((size_t)((touch.py - my) * mVisibleEntries / mh));
64 |     }
65 | 
66 |     mHid.update(size());
67 |     mIndex = mHid.index();
68 |     mPage  = mHid.page();
69 | }
70 | 
71 | void Scrollable::draw(bool condition)
72 | {
73 |     const size_t baseIndex = mVisibleEntries * mPage;
74 |     const size_t sz        = size() - baseIndex > mVisibleEntries ? mVisibleEntries : size() - baseIndex;
75 |     for (size_t i = baseIndex; i < baseIndex + sz; i++) {
76 |         mCells.at(i)->draw(0.5f, g_bottomScrollEnabled && mCells.at(i)->selected() ? COLOR_PURPLE_LIGHT : 0);
77 |     }
78 | 
79 |     size_t blankRows = mVisibleEntries - sz;
80 |     size_t rowHeight = mh / mVisibleEntries;
81 |     C2D_DrawRectSolid(mx, my + sz * rowHeight, 0.5f, mw, rowHeight * blankRows, COLOR_BLACK_DARKERR);
82 | 
83 |     // draw selector
84 |     for (size_t i = baseIndex; i < baseIndex + sz; i++) {
85 |         if (mCells.at(i)->selected()) {
86 |             mCells.at(i)->drawOutline(condition ? COLOR_PURPLE_DARK : COLOR_BLACK_MEDIUM);
87 |             break;
88 |         }
89 |     }
90 | }
91 | 


--------------------------------------------------------------------------------
/3ds/source/smdh.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "smdh.hpp"
28 | 
29 | smdh_s* loadSMDH(u32 low, u32 high, u8 media)
30 | {
31 |     Handle fileHandle;
32 | 
33 |     u32 archPath[]              = {low, high, media, 0x0};
34 |     static const u32 filePath[] = {0x0, 0x0, 0x2, 0x6E6F6369, 0x0};
35 |     smdh_s* smdh                = new smdh_s;
36 | 
37 |     FS_Path binArchPath = {PATH_BINARY, 0x10, archPath};
38 |     FS_Path binFilePath = {PATH_BINARY, 0x14, filePath};
39 | 
40 |     Result res = FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SAVEDATA_AND_CONTENT, binArchPath, binFilePath, FS_OPEN_READ, 0);
41 |     if (R_SUCCEEDED(res)) {
42 |         u32 read;
43 |         FSFILE_Read(fileHandle, &read, 0, smdh, sizeof(smdh_s));
44 |     }
45 |     else {
46 |         delete smdh;
47 |         smdh = NULL;
48 |     }
49 | 
50 |     FSFILE_Close(fileHandle);
51 |     return smdh;
52 | }
53 | 
54 | smdh_s* loadSMDH(const std::string& path)
55 | {
56 |     FILE* f = fopen(path.c_str(), "rb");
57 |     if (f != NULL) {
58 |         smdh_s* smdh = new smdh_s;
59 |         fread(smdh, 1, sizeof(smdh_s), f);
60 |         fclose(f);
61 |         return smdh;
62 |     }
63 |     return NULL;
64 | }


--------------------------------------------------------------------------------
/3rd-party/ftp/ftp.h:
--------------------------------------------------------------------------------
 1 | #ifndef FTP_H
 2 | #define FTP_H
 3 | 
 4 | /*! Loop status */
 5 | typedef enum {
 6 |   LOOP_CONTINUE, /*!< Continue looping */
 7 |   LOOP_RESTART,  /*!< Reinitialize */
 8 |   LOOP_EXIT,     /*!< Terminate looping */
 9 | } loop_status_t;
10 | 
11 | int           ftp_init(void);
12 | loop_status_t ftp_loop(void);
13 | void          ftp_exit(void);
14 | 
15 | #endif
16 | 


--------------------------------------------------------------------------------
/3rd-party/mongoose/mg_locals.h:
--------------------------------------------------------------------------------
 1 | #include <sys/socket.h>
 2 | #include <netinet/in.h>
 3 | #include <sys/types.h>
 4 | #include <sys/stat.h>
 5 | #include <arpa/inet.h>
 6 | #include <errno.h>
 7 | #include <stdlib.h>
 8 | #include <unistd.h>
 9 | #include <fcntl.h>
10 | 
11 | #define INVALID_SOCKET ((int)(~0))
12 | 
13 | typedef int sock_t;
14 | typedef struct stat cs_stat_t;
15 | #define DIRSEP '/'
16 | #define SIZE_T_FMT "lu"
17 | #define INT64_FMT "li"
18 | #define to64(x) strtoll(x, NULL, 10)
19 | #define closesocket(x) close(x)


--------------------------------------------------------------------------------
/3rd-party/sha256/sha256.h:
--------------------------------------------------------------------------------
 1 | /*********************************************************************
 2 | * Filename:   sha256.h
 3 | * Author:     Brad Conte (brad AT bradconte.com)
 4 | * Copyright:
 5 | * Disclaimer: This code is presented "as is" without any guarantees.
 6 | * Details:    Defines the API for the corresponding SHA1 implementation.
 7 | *********************************************************************/
 8 | 
 9 | #ifndef SHA256_H
10 | #define SHA256_H
11 | 
12 | /*************************** HEADER FILES ***************************/
13 | #include <stddef.h>
14 | 
15 | /****************************** MACROS ******************************/
16 | #define SHA256_BLOCK_SIZE 32            // SHA256 outputs a 32 byte digest
17 | 
18 | /**************************** DATA TYPES ****************************/
19 | typedef unsigned char BYTE;             // 8-bit byte
20 | typedef unsigned int  WORD;             // 32-bit word, change to "long" for 16-bit machines
21 | 
22 | typedef struct {
23 |     BYTE data[64];
24 |     WORD datalen;
25 |     unsigned long long bitlen;
26 |     WORD state[8];
27 | } SHA256_CTX;
28 | 
29 | /*********************** FUNCTION DECLARATIONS **********************/
30 | void sha256_init(SHA256_CTX *ctx);
31 | void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
32 | void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
33 | void sha256(unsigned char hash[], unsigned char data[], size_t len);
34 | 
35 | #endif   // SHA256_H


--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
 1 | SUBDIRS = 3ds switch
 2 | 
 3 | VERSION_MAJOR	:=	3
 4 | VERSION_MINOR	:=	10
 5 | VERSION_MICRO	:=	1
 6 | GIT_REV="$(shell git rev-parse --short HEAD)"
 7 | 
 8 | all: $(SUBDIRS)
 9 | 
10 | clean:
11 | 	@for dir in $(SUBDIRS); do $(MAKE) clean -C $dir; done
12 | 	@rm -f sharkive/build/*.json
13 | 	@rm -f 3ds/romfs/cheats/*.bz2
14 | 	@rm -f switch/romfs/cheats/*.bz2 
15 | 
16 | 3ds: 3ds_cheats
17 | 	@$(MAKE) -C 3ds VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV} CHEAT_SIZE_DECOMPRESSED=$(shell stat -t "sharkive/build/3ds.json" | awk '{print $2}')
18 | 
19 | switch: switch_cheats
20 | 	@$(MAKE) -C switch VERSION_MAJOR=${VERSION_MAJOR} VERSION_MINOR=${VERSION_MINOR} VERSION_MICRO=${VERSION_MICRO} GIT_REV=${GIT_REV} CHEAT_SIZE_DECOMPRESSED=$(shell stat -t "sharkive/build/switch.json" | awk '{print $2}')
21 | 
22 | format:
23 | 	@for dir in $(SUBDIRS); do $(MAKE) -C $dir format; done
24 | 
25 | cppcheck:
26 | 	@cppcheck . --enable=all --force 2> cppcheck.log
27 | 
28 | cheats: $(SUBDIRS:=_cheats)
29 | 
30 | 3ds_cheats:
31 | 	@$(MAKE) --always-make -C 3ds cheats
32 | 
33 | switch_cheats:
34 | 	@$(MAKE) --always-make -C switch cheats
35 | 
36 | .PHONY: $(SUBDIRS) clean format cppcheck cheats 3ds_cheats switch_cheats
37 | 


--------------------------------------------------------------------------------
/common/Overlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef OVERLAY_HPP
28 | #define OVERLAY_HPP
29 | 
30 | #include "Screen.hpp"
31 | #include <memory>
32 | 
33 | class Overlay {
34 | public:
35 |     Overlay(Screen& screen) : screen(screen), me(screen.currentOverlay) {}
36 |     virtual ~Overlay()                     = default;
37 |     virtual void update(const InputState&) = 0;
38 | #if defined(__3DS__)
39 |     virtual void drawTop() const    = 0;
40 |     virtual void drawBottom() const = 0;
41 | #elif defined(__SWITCH__)
42 |     virtual void draw() const = 0;
43 | #endif
44 | 
45 | protected:
46 |     Screen& screen;
47 |     std::shared_ptr<Overlay>& me;
48 | };
49 | 
50 | #endif


--------------------------------------------------------------------------------
/common/Screen.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "Screen.hpp"
28 | #include "Overlay.hpp"
29 | 
30 | #if defined(__3DS__)
31 | 
32 | void Screen::doDrawTop() const
33 | {
34 |     drawTop();
35 |     if (currentOverlay) {
36 |         currentOverlay->drawTop();
37 |     }
38 | }
39 | 
40 | void Screen::doDrawBottom() const
41 | {
42 |     drawBottom();
43 |     if (currentOverlay) {
44 |         currentOverlay->drawBottom();
45 |     }
46 | }
47 | #elif defined(__SWITCH__)
48 | 
49 | void Screen::doDraw() const
50 | {
51 |     draw();
52 |     if (currentOverlay) {
53 |         currentOverlay->draw();
54 |     }
55 | }
56 | 
57 | #endif
58 | 
59 | void Screen::doUpdate(const InputState& input)
60 | {
61 |     if (currentOverlay) {
62 |         currentOverlay->update(input);
63 |     }
64 |     else {
65 |         update(input);
66 |     }
67 | }
68 | 


--------------------------------------------------------------------------------
/common/Screen.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SCREEN_HPP
28 | #define SCREEN_HPP
29 | 
30 | #include "InputState.hpp"
31 | #include <memory>
32 | 
33 | class Overlay;
34 | 
35 | class Screen {
36 |     friend class Overlay;
37 | 
38 | public:
39 |     virtual ~Screen() = default;
40 |     // Call draw, then currentOverlay->draw if it exists
41 | #if defined(__3DS__)
42 |     void doDrawTop(void) const;
43 |     void doDrawBottom(void) const;
44 |     virtual void drawTop(void) const    = 0;
45 |     virtual void drawBottom(void) const = 0;
46 | #elif defined(__SWITCH__)
47 |     void doDraw() const;
48 |     virtual void draw() const = 0;
49 | #endif
50 |     // Call currentOverlay->update if it exists, and update if it doesn't
51 |     void doUpdate(const InputState&);
52 |     virtual void update(const InputState&) = 0;
53 |     void removeOverlay() { currentOverlay.reset(); }
54 |     void setOverlay(std::shared_ptr<Overlay>& overlay) { currentOverlay = overlay; }
55 | 
56 | protected:
57 |     // No point in restricting this to only being editable during update, especially since it's drawn afterwards. Allows setting it before the first
58 |     // draw loop is done
59 |     mutable std::shared_ptr<Overlay> currentOverlay;
60 | };
61 | 
62 | #endif


--------------------------------------------------------------------------------
/common/common.cpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #include "common.hpp"
 28 | 
 29 | std::string DateTime::timeStr(void)
 30 | {
 31 |     time_t unixTime;
 32 |     struct tm timeStruct;
 33 |     time(&unixTime);
 34 |     localtime_r(&unixTime, &timeStruct);
 35 |     return StringUtils::format("%02i:%02i:%02i", timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
 36 | }
 37 | 
 38 | std::string DateTime::dateTimeStr(void)
 39 | {
 40 |     time_t unixTime;
 41 |     struct tm timeStruct;
 42 |     time(&unixTime);
 43 |     localtime_r(&unixTime, &timeStruct);
 44 |     return StringUtils::format("%04i%02i%02i-%02i%02i%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday, timeStruct.tm_hour,
 45 |         timeStruct.tm_min, timeStruct.tm_sec);
 46 | }
 47 | 
 48 | std::string DateTime::logDateTime(void)
 49 | {
 50 |     time_t unixTime;
 51 |     struct tm timeStruct;
 52 |     time(&unixTime);
 53 |     localtime_r(&unixTime, &timeStruct);
 54 |     return StringUtils::format("%04i-%02i-%02i %02i:%02i:%02i", timeStruct.tm_year + 1900, timeStruct.tm_mon + 1, timeStruct.tm_mday,
 55 |         timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
 56 | }
 57 | 
 58 | std::string StringUtils::UTF16toUTF8(const std::u16string& src)
 59 | {
 60 |     static std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
 61 |     std::string dst = convert.to_bytes(src);
 62 |     return dst;
 63 | }
 64 | 
 65 | std::string StringUtils::removeForbiddenCharacters(std::string src)
 66 | {
 67 |     static const std::string illegalChars = ".,!\\/:?*\"<>|";
 68 |     for (size_t i = 0, sz = src.length(); i < sz; i++) {
 69 |         if (illegalChars.find(src[i]) != std::string::npos) {
 70 |             src[i] = ' ';
 71 |         }
 72 |     }
 73 | 
 74 |     size_t i;
 75 |     for (i = src.length() - 1; i > 0 && src[i] == ' '; i--)
 76 |         ;
 77 |     src.erase(i + 1, src.length() - i);
 78 | 
 79 |     return src;
 80 | }
 81 | 
 82 | std::string StringUtils::format(const std::string fmt_str, ...)
 83 | {
 84 |     va_list ap;
 85 |     char* fp = NULL;
 86 |     va_start(ap, fmt_str);
 87 |     vasprintf(&fp, fmt_str.c_str(), ap);
 88 |     va_end(ap);
 89 |     std::unique_ptr<char[]> formatted(fp);
 90 |     return std::string(formatted.get());
 91 | }
 92 | 
 93 | bool StringUtils::containsInvalidChar(const std::string& str)
 94 | {
 95 |     for (size_t i = 0, sz = str.length(); i < sz; i++) {
 96 |         if (!isascii(str[i])) {
 97 |             return true;
 98 |         }
 99 |     }
100 |     return false;
101 | }
102 | 
103 | void StringUtils::ltrim(std::string& s)
104 | {
105 |     s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) { return !std::isspace(ch); }));
106 | }
107 | 
108 | void StringUtils::rtrim(std::string& s)
109 | {
110 |     s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) { return !std::isspace(ch); }).base(), s.end());
111 | }
112 | 
113 | void StringUtils::trim(std::string& s)
114 | {
115 |     ltrim(s);
116 |     rtrim(s);
117 | }
118 | 
119 | char* getConsoleIP(void)
120 | {
121 |     struct in_addr in;
122 |     in.s_addr = gethostid();
123 |     return inet_ntoa(in);
124 | }


--------------------------------------------------------------------------------
/common/common.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef COMMON_HPP
28 | #define COMMON_HPP
29 | 
30 | #include <algorithm>
31 | #include <arpa/inet.h>
32 | #include <codecvt>
33 | #include <cstdio>
34 | #include <locale>
35 | #include <memory>
36 | #include <netinet/in.h>
37 | #include <stdarg.h>
38 | #include <string.h>
39 | #include <string>
40 | #include <sys/socket.h>
41 | #include <time.h>
42 | #include <unistd.h>
43 | 
44 | #define ATEXIT(func) atexit((void (*)())func)
45 | 
46 | namespace DateTime {
47 |     std::string timeStr(void);
48 |     std::string dateTimeStr(void);
49 |     std::string logDateTime(void);
50 | }
51 | 
52 | namespace StringUtils {
53 |     bool containsInvalidChar(const std::string& str);
54 |     std::string escapeJson(const std::string& s);
55 |     std::string format(const std::string fmt_str, ...);
56 |     std::string removeForbiddenCharacters(std::string src);
57 |     std::string UTF16toUTF8(const std::u16string& src);
58 |     void ltrim(std::string& s);
59 |     void rtrim(std::string& s);
60 |     void trim(std::string& s);
61 | }
62 | 
63 | char* getConsoleIP(void);
64 | 
65 | #endif


--------------------------------------------------------------------------------
/common/iclickable.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef ICLICKABLE_HPP
28 | #define ICLICKABLE_HPP
29 | 
30 | #include "InputState.hpp"
31 | #include <string>
32 | 
33 | typedef uint8_t u8;
34 | typedef uint16_t u16;
35 | typedef uint32_t u32;
36 | 
37 | template <typename T>
38 | class IClickable {
39 | public:
40 |     IClickable(int x, int y, u16 w, u16 h, T colorBg, T colorText, const std::string& message, bool centered)
41 |         : mx(x), my(y), mw(w), mh(h), mColorBg(colorBg), mColorText(colorText), mText(message), mCentered(centered)
42 |     {
43 |         mOldPressed                 = false;
44 |         mSelected                   = false;
45 |         mCanChangeColorWhenSelected = false;
46 |     }
47 | 
48 |     virtual ~IClickable()                    = default;
49 |     virtual void draw(float size, T overlay) = 0;
50 |     virtual void drawOutline(T color)        = 0;
51 |     virtual bool held(void)                  = 0;
52 |     virtual bool released(void)              = 0;
53 | 
54 |     void setColors(T bg, T text)
55 |     {
56 |         mColorBg   = bg;
57 |         mColorText = text;
58 |     }
59 | 
60 |     std::string text(void) { return mText; }
61 | 
62 |     void text(const std::string& v) { mText = v; }
63 | 
64 |     bool selected(void) { return mSelected; }
65 | 
66 |     void selected(bool selected) { mSelected = selected; }
67 | 
68 |     void canChangeColorWhenSelected(bool c) { mCanChangeColorWhenSelected = c; }
69 | 
70 | protected:
71 |     int mx;
72 |     int my;
73 |     u16 mw;
74 |     u16 mh;
75 |     T mColorBg;
76 |     T mColorText;
77 |     std::string mText;
78 |     bool mCanChangeColorWhenSelected;
79 |     bool mCentered;
80 |     bool mOldPressed;
81 |     bool mSelected;
82 | };
83 | 
84 | #endif


--------------------------------------------------------------------------------
/common/iscrollable.hpp:
--------------------------------------------------------------------------------
  1 | /*
  2 |  *   This file is part of Checkpoint
  3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
  4 |  *
  5 |  *   This program is free software: you can redistribute it and/or modify
  6 |  *   it under the terms of the GNU General Public License as published by
  7 |  *   the Free Software Foundation, either version 3 of the License, or
  8 |  *   (at your option) any later version.
  9 |  *
 10 |  *   This program is distributed in the hope that it will be useful,
 11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 |  *   GNU General Public License for more details.
 14 |  *
 15 |  *   You should have received a copy of the GNU General Public License
 16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 17 |  *
 18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
 19 |  *       * Requiring preservation of specified reasonable legal notices or
 20 |  *         author attributions in that material or in the Appropriate Legal
 21 |  *         Notices displayed by works containing it.
 22 |  *       * Prohibiting misrepresentation of the origin of that material,
 23 |  *         or requiring that modified versions of such material be marked in
 24 |  *         reasonable ways as different from the original version.
 25 |  */
 26 | 
 27 | #ifndef ISCROLLABLE_HPP
 28 | #define ISCROLLABLE_HPP
 29 | 
 30 | #include "InputState.hpp"
 31 | #include "iclickable.hpp"
 32 | #include <vector>
 33 | 
 34 | template <typename T>
 35 | class IScrollable {
 36 | public:
 37 |     IScrollable(int x, int y, u16 w, u16 h, size_t visibleEntries) : mx(x), my(y), mw(w), mh(h), mVisibleEntries(visibleEntries)
 38 |     {
 39 |         mIndex = 0;
 40 |         mPage  = 0;
 41 |     }
 42 | 
 43 |     virtual ~IScrollable() { flush(); }
 44 | 
 45 |     virtual void draw(bool condition = false)                                                  = 0;
 46 |     virtual void push_back(T color, T colorMessage, const std::string& message, bool selected) = 0;
 47 |     virtual void updateSelection(void)                                                         = 0;
 48 | 
 49 |     std::string cellName(size_t index) const { return mCells.at(index)->text(); }
 50 | 
 51 |     void cellName(size_t index, const std::string& name) { mCells.at(index)->text(name); }
 52 | 
 53 |     void flush(void)
 54 |     {
 55 |         for (size_t i = 0; i < size(); i++) {
 56 |             delete mCells[i];
 57 |         }
 58 |         mCells.clear();
 59 |     }
 60 | 
 61 |     size_t size(void) const { return mCells.size(); }
 62 | 
 63 |     size_t maxVisibleEntries(void)
 64 |     {
 65 |         return (size() - mPage * mVisibleEntries) > mVisibleEntries ? mVisibleEntries : size() - mPage * mVisibleEntries;
 66 |     }
 67 | 
 68 |     size_t index(void) { return mIndex + mPage * mVisibleEntries; }
 69 | 
 70 |     int page(void) { return mPage; }
 71 | 
 72 |     virtual void resetIndex(void)
 73 |     {
 74 |         mIndex = 0;
 75 |         mPage  = 0;
 76 |     }
 77 | 
 78 |     void index(size_t i)
 79 |     {
 80 |         mPage  = i / mVisibleEntries;
 81 |         mIndex = i - mPage * mVisibleEntries;
 82 |     }
 83 | 
 84 |     size_t visibleEntries(void) { return mVisibleEntries; }
 85 | 
 86 |     void selectRow(size_t i, bool selected) { mCells.at(i)->selected(selected); }
 87 | 
 88 | protected:
 89 |     int mx;
 90 |     int my;
 91 |     u16 mw;
 92 |     u16 mh;
 93 |     size_t mVisibleEntries;
 94 |     size_t mIndex;
 95 |     int mPage;
 96 |     std::vector<IClickable<T>*> mCells;
 97 | };
 98 | 
 99 | #endif
100 | 


--------------------------------------------------------------------------------
/common/logging.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of PKSM
 3 |  *   Copyright (C) 2016-2025 Bernardo Giordano
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef LOGGING_HPP
28 | #define LOGGING_HPP
29 | 
30 | #include <cstdio>
31 | #include <format>
32 | #include <string>
33 | 
34 | enum class LogLevel { TRACE, DEBUG, INFO, WARN, ERROR };
35 | 
36 | namespace Logging {
37 |     void init(void);
38 |     void initFileLogging(void);
39 |     void exit(void);
40 | 
41 |     void log(LogLevel level, const std::string& message);
42 |     void trace(const std::string& message);
43 |     void debug(const std::string& message);
44 |     void info(const std::string& message);
45 |     void warning(const std::string& message);
46 |     void error(const std::string& message);
47 | 
48 |     template <typename... Args>
49 |     void trace(std::format_string<Args...> fmt, Args&&... args)
50 |     {
51 |         trace(std::format(fmt, std::forward<Args>(args)...));
52 |     }
53 | 
54 |     template <typename... Args>
55 |     void debug(std::format_string<Args...> fmt, Args&&... args)
56 |     {
57 |         debug(std::format(fmt, std::forward<Args>(args)...));
58 |     }
59 | 
60 |     template <typename... Args>
61 |     void info(std::format_string<Args...> fmt, Args&&... args)
62 |     {
63 |         info(std::format(fmt, std::forward<Args>(args)...));
64 |     }
65 | 
66 |     template <typename... Args>
67 |     void warning(std::format_string<Args...> fmt, Args&&... args)
68 |     {
69 |         warning(std::format(fmt, std::forward<Args>(args)...));
70 |     }
71 | 
72 |     template <typename... Args>
73 |     void error(std::format_string<Args...> fmt, Args&&... args)
74 |     {
75 |         error(std::format(fmt, std::forward<Args>(args)...));
76 |     }
77 | }
78 | 
79 | #endif


--------------------------------------------------------------------------------
/common/multiselection.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "multiselection.hpp"
28 | 
29 | static std::vector<size_t> selEnt;
30 | 
31 | std::vector<size_t> MS::selectedEntries(void)
32 | {
33 |     return selEnt;
34 | }
35 | 
36 | bool MS::multipleSelectionEnabled(void)
37 | {
38 |     return !selEnt.empty();
39 | }
40 | 
41 | void MS::clearSelectedEntries(void)
42 | {
43 |     selEnt.clear();
44 | }
45 | 
46 | void MS::addSelectedEntry(size_t idx)
47 | {
48 |     int existing = -1;
49 |     for (size_t i = 0, sz = selEnt.size(); i < sz && existing == -1; i++) {
50 |         if (selEnt.at(i) == idx) {
51 |             existing = (int)i;
52 |         }
53 |     }
54 | 
55 |     if (existing == -1) {
56 |         selEnt.push_back(idx);
57 |     }
58 |     else {
59 |         selEnt.erase(selEnt.begin() + existing);
60 |     }
61 | }


--------------------------------------------------------------------------------
/common/multiselection.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include <cstddef>
28 | #include <vector>
29 | 
30 | namespace MS {
31 |     std::vector<size_t> selectedEntries(void);
32 |     bool multipleSelectionEnabled(void);
33 |     void clearSelectedEntries(void);
34 |     void addSelectedEntry(size_t idx);
35 | }


--------------------------------------------------------------------------------
/switch/icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/switch/icon.jpg


--------------------------------------------------------------------------------
/switch/include/CheatManagerOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CHEATMANAGEROVERLAY_HPP
28 | #define CHEATMANAGEROVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "SDLHelper.hpp"
32 | #include "YesNoOverlay.hpp"
33 | #include "cheatmanager.hpp"
34 | #include "clickable.hpp"
35 | #include "colors.hpp"
36 | #include "directory.hpp"
37 | #include "scrollable.hpp"
38 | #include <memory>
39 | #include <string>
40 | 
41 | class Clickable;
42 | class Scrollable;
43 | 
44 | class CheatManagerOverlay : public Overlay {
45 | public:
46 |     CheatManagerOverlay(Screen& screen, const std::string& mtext);
47 |     ~CheatManagerOverlay() = default;
48 |     void draw(void) const override;
49 |     void update(const InputState&) override;
50 | 
51 | protected:
52 |     void save(const std::string& key, Scrollable* s);
53 | 
54 | private:
55 |     bool multiSelected;
56 |     std::string existingCheat;
57 |     std::string key;
58 |     const size_t MAGIC_LEN = strlen(SELECTED_MAGIC);
59 |     std::shared_ptr<Scrollable> scrollable;
60 |     size_t currentIndex;
61 | };
62 | 
63 | #endif


--------------------------------------------------------------------------------
/switch/include/ErrorOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef ERROROVERLAY_HPP
28 | #define ERROROVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "SDLHelper.hpp"
32 | #include "clickable.hpp"
33 | #include "colors.hpp"
34 | #include <memory>
35 | #include <string>
36 | 
37 | class Clickable;
38 | 
39 | class ErrorOverlay : public Overlay {
40 | public:
41 |     ErrorOverlay(Screen& screen, Result res, const std::string& mtext);
42 |     ~ErrorOverlay() = default;
43 |     void draw(void) const override;
44 |     void update(const InputState&) override;
45 | 
46 | private:
47 |     u32 textw, texth;
48 |     std::string text;
49 |     std::unique_ptr<Clickable> button;
50 |     Result res;
51 | };
52 | 
53 | #endif


--------------------------------------------------------------------------------
/switch/include/InfoOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef INFOOVERLAY_HPP
28 | #define INFOOVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "SDLHelper.hpp"
32 | #include "clickable.hpp"
33 | #include "colors.hpp"
34 | #include <memory>
35 | #include <string>
36 | 
37 | class Clickable;
38 | 
39 | class InfoOverlay : public Overlay {
40 | public:
41 |     InfoOverlay(Screen& screen, const std::string& mtext);
42 |     ~InfoOverlay() = default;
43 |     void draw(void) const override;
44 |     void update(const InputState&) override;
45 | 
46 | private:
47 |     u32 textw, texth;
48 |     std::string text;
49 |     std::unique_ptr<Clickable> button;
50 | };
51 | 
52 | #endif


--------------------------------------------------------------------------------
/switch/include/InputState.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef INPUTSTATE_HPP
28 | #define INPUTSTATE_HPP
29 | 
30 | #include <switch.h>
31 | 
32 | struct InputState {
33 |     HidTouchScreenState touch;
34 |     u64 kDown;
35 |     u64 kHeld;
36 |     u64 kUp;
37 | };
38 | 
39 | #endif
40 | 


--------------------------------------------------------------------------------
/switch/include/KeyboardManager.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef KEYBOARDMANAGER_HPP
28 | #define KEYBOARDMANAGER_HPP
29 | 
30 | #include <string>
31 | #include <switch.h>
32 | #include <utility>
33 | 
34 | class KeyboardManager {
35 | public:
36 |     static KeyboardManager& get(void)
37 |     {
38 |         static KeyboardManager mSingleton;
39 |         return mSingleton;
40 |     }
41 | 
42 |     KeyboardManager(KeyboardManager const&) = delete;
43 |     void operator=(KeyboardManager const&)  = delete;
44 | 
45 |     std::pair<bool, std::string> keyboard(const std::string& suggestion);
46 | 
47 |     std::pair<bool, Result> isSystemKeyboardAvailable() { return std::make_pair(systemKeyboardAvailable, res); }
48 | 
49 |     static const size_t CUSTOM_PATH_LEN = 49;
50 | 
51 | private:
52 |     KeyboardManager(void);
53 |     virtual ~KeyboardManager() = default;
54 | 
55 |     Result res;
56 |     bool systemKeyboardAvailable;
57 | };
58 | 
59 | #endif


--------------------------------------------------------------------------------
/switch/include/MainScreen.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef MAINSCREEN_HPP
28 | #define MAINSCREEN_HPP
29 | 
30 | #include "CheatManagerOverlay.hpp"
31 | #include "ErrorOverlay.hpp"
32 | #include "InfoOverlay.hpp"
33 | #include "Screen.hpp"
34 | #include "YesNoOverlay.hpp"
35 | #include "clickable.hpp"
36 | #include "hid.hpp"
37 | #include "io.hpp"
38 | #include "main.hpp"
39 | #include "multiselection.hpp"
40 | #include "pksmbridge.hpp"
41 | #include "scrollable.hpp"
42 | #include <tuple>
43 | 
44 | typedef enum { TITLES, CELLS } entryType_t;
45 | 
46 | class Clickable;
47 | class Scrollable;
48 | 
49 | class MainScreen : public Screen {
50 | public:
51 |     MainScreen(const InputState&);
52 |     void draw(void) const override;
53 |     void update(const InputState& input) override;
54 | 
55 | protected:
56 |     int selectorX(size_t i) const;
57 |     int selectorY(size_t i) const;
58 |     void updateSelector(const InputState& input);
59 |     void handleEvents(const InputState& input);
60 |     std::string nameFromCell(size_t index) const;
61 |     void entryType(entryType_t type);
62 |     size_t index(entryType_t type) const;
63 |     void index(entryType_t type, size_t i);
64 |     void resetIndex(entryType_t type);
65 |     bool getPKSMBridgeFlag(void) const;
66 |     void setPKSMBridgeFlag(bool f);
67 |     void updateButtons(void);
68 |     std::string sortMode(void) const;
69 | 
70 | private:
71 |     entryType_t type;
72 |     int selectionTimer;
73 |     bool pksmBridge;
74 |     bool wantInstructions;
75 |     Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
76 |     std::unique_ptr<Scrollable> backupList;
77 |     std::unique_ptr<Clickable> buttonCheats, buttonBackup, buttonRestore;
78 |     char ver[8];
79 | };
80 | 
81 | #endif
82 | 


--------------------------------------------------------------------------------
/switch/include/SDLHelper.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SDLHELPER_HPP
28 | #define SDLHELPER_HPP
29 | 
30 | #include "SDL_FontCache.h"
31 | #include "colors.hpp"
32 | #include "logging.hpp"
33 | #include "main.hpp"
34 | #include <SDL2/SDL.h>
35 | #include <SDL2/SDL_image.h>
36 | #include <string>
37 | #include <switch.h>
38 | #include <unordered_map>
39 | 
40 | bool SDLH_Init(void);
41 | void SDLH_Exit(void);
42 | 
43 | void SDLH_ClearScreen(SDL_Color color);
44 | void SDLH_DrawRect(int x, int y, int w, int h, SDL_Color color);
45 | void SDLH_DrawText(int size, int x, int y, SDL_Color color, const char* text);
46 | void SDLH_LoadImage(SDL_Texture** texture, char* path);
47 | void SDLH_LoadImage(SDL_Texture** texture, u8* buff, size_t size);
48 | void SDLH_DrawImage(SDL_Texture* texture, int x, int y);
49 | void SDLH_DrawImageScale(SDL_Texture* texture, int x, int y, int w, int h);
50 | void SDLH_DrawIcon(std::string icon, int x, int y);
51 | void SDLH_GetTextDimensions(int size, const char* text, u32* w, u32* h);
52 | void SDLH_DrawTextBox(int size, int x, int y, SDL_Color color, int max, const char* text);
53 | void SDLH_Render(void);
54 | 
55 | void drawOutline(u32 x, u32 y, u16 w, u16 h, u8 size, SDL_Color color);
56 | void drawPulsingOutline(u32 x, u32 y, u16 w, u16 h, u8 size, SDL_Color color);
57 | std::string trimToFit(const std::string& text, u32 maxsize, size_t textsize);
58 | 
59 | #endif


--------------------------------------------------------------------------------
/switch/include/YesNoOverlay.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef YESNOOVERLAY_HPP
28 | #define YESNOOVERLAY_HPP
29 | 
30 | #include "Overlay.hpp"
31 | #include "SDLHelper.hpp"
32 | #include "clickable.hpp"
33 | #include "colors.hpp"
34 | #include "hid.hpp"
35 | #include <functional>
36 | #include <memory>
37 | #include <string>
38 | 
39 | class Clickable;
40 | 
41 | class YesNoOverlay : public Overlay {
42 | public:
43 |     YesNoOverlay(Screen& screen, const std::string& mtext, const std::function<void()>& callbackYes, const std::function<void()>& callbackNo);
44 |     ~YesNoOverlay() = default;
45 |     void draw(void) const override;
46 |     void update(const InputState&) override;
47 | 
48 | private:
49 |     u32 textw, texth;
50 |     std::string text;
51 |     std::unique_ptr<Clickable> buttonYes, buttonNo;
52 |     Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
53 |     std::function<void()> yesFunc, noFunc;
54 | };
55 | 
56 | #endif
57 | 


--------------------------------------------------------------------------------
/switch/include/account.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef ACCOUNT_HPP
28 | #define ACCOUNT_HPP
29 | 
30 | #include "SDLHelper.hpp"
31 | #include <map>
32 | #include <string.h>
33 | #include <string>
34 | #include <switch.h>
35 | #include <vector>
36 | 
37 | #define USER_ICON_SIZE 64
38 | 
39 | namespace std {
40 |     template <>
41 |     struct hash<AccountUid> {
42 |         size_t operator()(const AccountUid& a) const { return ((hash<u64>()(a.uid[0]) ^ (hash<u64>()(a.uid[1]) << 1)) >> 1); }
43 |     };
44 | }
45 | 
46 | inline bool operator==(const AccountUid& x, const AccountUid& y)
47 | {
48 |     return x.uid[0] == y.uid[0] && x.uid[1] == y.uid[1];
49 | }
50 | 
51 | inline bool operator==(const AccountUid& x, u64 y)
52 | {
53 |     return x.uid[0] == y && x.uid[1] == y;
54 | }
55 | 
56 | inline bool operator<(const AccountUid& x, const AccountUid& y)
57 | {
58 |     return x.uid[0] < y.uid[0] && x.uid[1] == y.uid[1];
59 | }
60 | 
61 | struct User {
62 |     AccountUid id;
63 |     std::string name;
64 |     std::string shortName;
65 |     SDL_Texture* icon;
66 | };
67 | 
68 | namespace Account {
69 |     Result init(void);
70 |     void exit(void);
71 | 
72 |     std::vector<AccountUid> ids(void);
73 |     SDL_Texture* icon(AccountUid id);
74 |     AccountUid selectAccount(void);
75 |     std::string username(AccountUid id);
76 |     std::string shortName(AccountUid id);
77 | }
78 | 
79 | #endif


--------------------------------------------------------------------------------
/switch/include/cheatmanager.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CHEATMANAGER_HPP
28 | #define CHEATMANAGER_HPP
29 | 
30 | #include "json.hpp"
31 | #include "main.hpp"
32 | #include <bzlib.h>
33 | #include <errno.h>
34 | #include <stdio.h>
35 | #include <switch.h>
36 | #include <sys/stat.h>
37 | 
38 | #define SELECTED_MAGIC "\uE071 "
39 | 
40 | class Scrollable;
41 | 
42 | class CheatManager {
43 | public:
44 |     static CheatManager& getInstance(void)
45 |     {
46 |         static CheatManager mCheatManager;
47 |         return mCheatManager;
48 |     }
49 | 
50 |     bool areCheatsAvailable(const std::string& key);
51 |     void save(const std::string& key, const std::vector<std::string>& s);
52 | 
53 |     std::shared_ptr<nlohmann::json> cheats() { return mCheats; }
54 | 
55 | private:
56 |     CheatManager();
57 |     ~CheatManager() = default;
58 | 
59 |     CheatManager(CheatManager const&)   = delete;
60 |     void operator=(CheatManager const&) = delete;
61 | 
62 |     std::shared_ptr<nlohmann::json> mCheats;
63 | };
64 | 
65 | #endif


--------------------------------------------------------------------------------
/switch/include/clickable.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CLICKABLE_HPP
28 | #define CLICKABLE_HPP
29 | 
30 | #include "SDLHelper.hpp"
31 | #include "iclickable.hpp"
32 | #include "main.hpp"
33 | #include <string>
34 | #include <switch.h>
35 | 
36 | class Clickable : public IClickable<SDL_Color> {
37 | public:
38 |     Clickable(int x, int y, u16 w, u16 h, SDL_Color colorBg, SDL_Color colorText, const std::string& message, bool centered)
39 |         : IClickable(x, y, w, h, colorBg, colorText, message, centered)
40 |     {
41 |     }
42 |     virtual ~Clickable() = default;
43 | 
44 |     void draw(float font, SDL_Color overlay) override;
45 |     bool held(void) override;
46 |     bool released(void) override;
47 |     void drawOutline(SDL_Color color) override;
48 | };
49 | 
50 | #endif


--------------------------------------------------------------------------------
/switch/include/colors.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef COLORS_HPP
28 | #define COLORS_HPP
29 | 
30 | #include "SDLHelper.hpp"
31 | 
32 | inline const SDL_Color COLOR_OVERLAY    = FC_MakeColor(0, 0, 0, 200);
33 | inline const SDL_Color COLOR_WHITEMASK  = FC_MakeColor(255, 255, 255, 80);
34 | inline const SDL_Color COLOR_WHITE      = FC_MakeColor(255, 255, 255, 255);
35 | inline const SDL_Color COLOR_BLACK      = FC_MakeColor(0, 0, 0, 255);
36 | inline const SDL_Color COLOR_RED        = FC_MakeColor(255, 81, 48, 255);
37 | inline const SDL_Color COLOR_GOLD       = FC_MakeColor(215, 183, 64, 255);
38 | inline const SDL_Color COLOR_GREY_LIGHT = FC_MakeColor(138, 138, 138, 255);
39 | 
40 | inline const SDL_Color COLOR_BLACK_DARKERR = FC_MakeColor(28, 28, 30, 255);
41 | inline const SDL_Color COLOR_BLACK_DARKER  = FC_MakeColor(36, 36, 40, 255);
42 | inline const SDL_Color COLOR_BLACK_DARK    = FC_MakeColor(42, 42, 46, 255);
43 | inline const SDL_Color COLOR_BLACK_MEDIUM  = FC_MakeColor(60, 60, 63, 255);
44 | inline const SDL_Color COLOR_PURPLE_DARK   = FC_MakeColor(9, 25, 69, 255);
45 | inline const SDL_Color COLOR_PURPLE_LIGHT  = FC_MakeColor(122, 66, 196, 255);
46 | 
47 | inline const SDL_Color COLOR_GREEN = FC_MakeColor(0, 254, 197, 255);
48 | 
49 | #endif


--------------------------------------------------------------------------------
/switch/include/configuration.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef CONFIGHANDLER_HPP
28 | #define CONFIGHANDLER_HPP
29 | 
30 | #include "io.hpp"
31 | #include "json.hpp"
32 | #include "util.hpp"
33 | #include <unordered_map>
34 | #include <unordered_set>
35 | #include <vector>
36 | extern "C" {
37 | #include "mongoose.h"
38 | }
39 | 
40 | #define CONFIG_VERSION 4
41 | 
42 | class Configuration {
43 | public:
44 |     static Configuration& getInstance(void)
45 |     {
46 |         static Configuration mConfiguration;
47 |         return mConfiguration;
48 |     }
49 | 
50 |     bool filter(u64 id);
51 |     bool favorite(u64 id);
52 |     bool isPKSMBridgeEnabled(void);
53 |     bool isFTPEnabled(void);
54 |     std::vector<std::string> additionalSaveFolders(u64 id);
55 |     void pollServer(void);
56 |     void save(void);
57 |     void load(void);
58 |     void parse(void);
59 |     const char* c_str(void);
60 |     nlohmann::json getJson(void);
61 | 
62 |     const std::string BASEPATH = "/switch/Checkpoint/config.json";
63 | 
64 | private:
65 |     Configuration(void);
66 |     ~Configuration(void);
67 | 
68 |     void store(void);
69 | 
70 |     Configuration(Configuration const&)  = delete;
71 |     void operator=(Configuration const&) = delete;
72 | 
73 |     nlohmann::json mJson;
74 |     bool PKSMBridgeEnabled;
75 |     bool FTPEnabled;
76 |     std::unordered_set<u64> mFilterIds, mFavoriteIds;
77 |     std::unordered_map<u64, std::vector<std::string>> mAdditionalSaveFolders;
78 | };
79 | 
80 | #endif


--------------------------------------------------------------------------------
/switch/include/directory.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef DIRECTORY_HPP
28 | #define DIRECTORY_HPP
29 | 
30 | #include <dirent.h>
31 | #include <errno.h>
32 | #include <string>
33 | #include <switch.h>
34 | #include <vector>
35 | 
36 | struct DirectoryEntry {
37 |     std::string name;
38 |     bool directory;
39 | };
40 | 
41 | class Directory {
42 | public:
43 |     Directory(const std::string& root);
44 |     ~Directory() = default;
45 | 
46 |     Result error(void);
47 |     std::string entry(size_t index);
48 |     bool folder(size_t index);
49 |     bool good(void);
50 |     size_t size(void);
51 | 
52 | private:
53 |     std::vector<struct DirectoryEntry> mList;
54 |     Result mError;
55 |     bool mGood;
56 | };
57 | 
58 | #endif


--------------------------------------------------------------------------------
/switch/include/filesystem.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef FILESYSTEM_HPP
28 | #define FILESYSTEM_HPP
29 | 
30 | #include "account.hpp"
31 | #include <switch.h>
32 | 
33 | namespace FileSystem {
34 |     Result mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID);
35 |     int mount(FsFileSystem fs);
36 |     void unmount(void);
37 | }
38 | 
39 | #endif


--------------------------------------------------------------------------------
/switch/include/hid.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef HID_HPP
28 | #define HID_HPP
29 | 
30 | #include "InputState.hpp"
31 | #include "ihid.hpp"
32 | #include <switch.h>
33 | 
34 | #define DELAY_TICKS 3000000
35 | 
36 | template <HidDirection ListDirection, HidDirection PageDirection>
37 | class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS> {
38 | public:
39 |     Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns), input(g_input) {}
40 |     Hid(size_t entries, size_t columns, const InputState& _input) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns), input(&_input)
41 |     {
42 |     }
43 | 
44 | private:
45 |     const InputState* input;
46 | 
47 |     bool downDown() const override { return input && input->kDown & HidNpadButton_AnyDown; }
48 |     bool upDown() const override { return input && input->kDown & HidNpadButton_AnyUp; }
49 |     bool leftDown() const override { return input && input->kDown & HidNpadButton_AnyLeft; }
50 |     bool rightDown() const override { return input && input->kDown & HidNpadButton_AnyRight; }
51 |     bool leftTriggerDown() const override { return input && input->kDown & HidNpadButton_L; }
52 |     bool rightTriggerDown() const override { return input && input->kDown & HidNpadButton_R; }
53 | 
54 |     bool downHeld() const override { return input && input->kHeld & HidNpadButton_AnyDown; }
55 |     bool upHeld() const override { return input && input->kHeld & HidNpadButton_AnyUp; }
56 |     bool leftHeld() const override { return input && input->kHeld & HidNpadButton_AnyLeft; }
57 |     bool rightHeld() const override { return input && input->kHeld & HidNpadButton_AnyRight; }
58 |     bool leftTriggerHeld() const override { return input && input->kHeld & HidNpadButton_L; }
59 |     bool rightTriggerHeld() const override { return input && input->kHeld & HidNpadButton_R; }
60 |     u64 tick() const override { return armGetSystemTick(); }
61 | };
62 | 
63 | #endif
64 | 


--------------------------------------------------------------------------------
/switch/include/io.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef IO_HPP
28 | #define IO_HPP
29 | 
30 | #include "KeyboardManager.hpp"
31 | #include "account.hpp"
32 | #include "directory.hpp"
33 | #include "multiselection.hpp"
34 | #include "title.hpp"
35 | #include "util.hpp"
36 | #include <dirent.h>
37 | #include <switch.h>
38 | #include <sys/stat.h>
39 | #include <tuple>
40 | #include <unistd.h>
41 | #include <utility>
42 | 
43 | #define BUFFER_SIZE 0x80000
44 | 
45 | namespace io {
46 |     std::tuple<bool, Result, std::string> backup(size_t index, AccountUid uid, size_t cellIndex);
47 |     std::tuple<bool, Result, std::string> restore(size_t index, AccountUid uid, size_t cellIndex, const std::string& nameFromCell);
48 | 
49 |     Result copyDirectory(const std::string& srcPath, const std::string& dstPath);
50 |     void copyFile(const std::string& srcPath, const std::string& dstPath);
51 |     Result createDirectory(const std::string& path);
52 |     Result deleteFolderRecursively(const std::string& path);
53 |     bool directoryExists(const std::string& path);
54 |     bool fileExists(const std::string& path);
55 | }
56 | 
57 | #endif


--------------------------------------------------------------------------------
/switch/include/main.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef MAIN_HPP
28 | #define MAIN_HPP
29 | 
30 | #include "InputState.hpp"
31 | #include "Screen.hpp"
32 | #include "account.hpp"
33 | #include "title.hpp"
34 | #include "util.hpp"
35 | #include <memory>
36 | #include <switch.h>
37 | 
38 | typedef enum { SORT_ALPHA, SORT_LAST_PLAYED, SORT_PLAY_TIME, SORT_MODES_COUNT } sort_t;
39 | 
40 | inline float g_currentTime = 0;
41 | inline AccountUid g_currentUId;
42 | inline bool g_backupScrollEnabled       = 0;
43 | inline bool g_notificationLedAvailable  = false;
44 | inline std::shared_ptr<Screen> g_screen = nullptr;
45 | inline bool g_ftpAvailable              = false;
46 | inline bool g_shouldExitNetworkLoop     = false;
47 | inline std::string g_selectedCheatKey;
48 | inline std::vector<std::string> g_selectedCheatCodes;
49 | inline u32 g_username_dotsize;
50 | inline sort_t g_sortMode         = SORT_ALPHA;
51 | inline const InputState* g_input = nullptr;
52 | inline std::string g_currentFile = "";
53 | inline bool g_isTransferringFile = false;
54 | 
55 | #endif


--------------------------------------------------------------------------------
/switch/include/pksmbridge.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "KeyboardManager.hpp"
28 | #include "account.hpp"
29 | #include "title.hpp"
30 | #include <arpa/inet.h>
31 | #include <errno.h>
32 | #include <netinet/in.h>
33 | #include <string.h>
34 | #include <string>
35 | #include <switch.h>
36 | #include <sys/socket.h>
37 | #include <sys/types.h>
38 | #include <tuple>
39 | #include <unistd.h>
40 | #include <utility>
41 | 
42 | #define PKSM_PORT 34567
43 | 
44 | bool isPKSMBridgeTitle(u64 id);
45 | std::tuple<bool, Result, std::string> sendToPKSMBrigde(size_t index, AccountUid uid, size_t cellIndex);
46 | std::tuple<bool, Result, std::string> recvFromPKSMBridge(size_t index, AccountUid uid, size_t cellIndex);


--------------------------------------------------------------------------------
/switch/include/scrollable.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef SCROLLABLE_HPP
28 | #define SCROLLABLE_HPP
29 | 
30 | #include "SDLHelper.hpp"
31 | #include "clickable.hpp"
32 | #include "colors.hpp"
33 | #include "hid.hpp"
34 | #include "iscrollable.hpp"
35 | #include <switch.h>
36 | #include <vector>
37 | 
38 | class Scrollable : public IScrollable<SDL_Color> {
39 | public:
40 |     Scrollable(u32 x, u32 y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
41 | 
42 |     virtual ~Scrollable() = default;
43 | 
44 |     void draw(bool condition = false) override;
45 |     void setIndex(size_t i);
46 |     void push_back(SDL_Color color, SDL_Color colorMessage, const std::string& message, bool selected) override;
47 |     void resetIndex(void) override;
48 |     void updateSelection(void) override;
49 |     void text(size_t i, const std::string& v);
50 | 
51 | protected:
52 |     Hid<HidDirection::VERTICAL, HidDirection::HORIZONTAL> mHid;
53 | };
54 | 
55 | #endif
56 | 


--------------------------------------------------------------------------------
/switch/include/title.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef TITLE_HPP
28 | #define TITLE_HPP
29 | 
30 | #include "SDLHelper.hpp"
31 | #include "account.hpp"
32 | #include "configuration.hpp"
33 | #include "filesystem.hpp"
34 | #include "io.hpp"
35 | #include <algorithm>
36 | #include <stdlib.h>
37 | #include <string>
38 | #include <switch.h>
39 | #include <unordered_map>
40 | #include <vector>
41 | 
42 | class Title {
43 | public:
44 |     void init(u8 saveDataType, u64 titleid, AccountUid userID, const std::string& name, const std::string& author);
45 |     ~Title() = default;
46 | 
47 |     std::string author(void);
48 |     std::string displayName(void);
49 |     SDL_Texture* icon(void);
50 |     u64 id(void);
51 |     std::string name(void);
52 |     std::string path(void);
53 |     u64 playTimeNanoseconds(void);
54 |     std::string playTime(void);
55 |     void playTimeNanoseconds(u64 playTimeNanoseconds);
56 |     u32 lastPlayedTimestamp(void);
57 |     void lastPlayedTimestamp(u32 lastPlayedTimestamp);
58 |     std::string fullPath(size_t index);
59 |     void refreshDirectories(void);
60 |     u64 saveId();
61 |     void saveId(u64 id);
62 |     std::vector<std::string> saves(void);
63 |     u8 saveDataType(void);
64 |     AccountUid userId(void);
65 |     std::string userName(void);
66 | 
67 | private:
68 |     u64 mId;
69 |     u64 mSaveId;
70 |     AccountUid mUserId;
71 |     std::string mUserName;
72 |     std::string mName;
73 |     std::string mSafeName;
74 |     std::string mAuthor;
75 |     std::string mPath;
76 |     std::vector<std::string> mSaves;
77 |     std::vector<std::string> mFullSavePaths;
78 |     u8 mSaveDataType;
79 |     std::string mDisplayName;
80 |     u64 mPlayTimeNanoseconds;
81 |     u32 mLastPlayedTimestamp;
82 | };
83 | 
84 | void getTitle(Title& dst, AccountUid uid, size_t i);
85 | size_t getTitleCount(AccountUid uid);
86 | void loadTitles(void);
87 | void sortTitles(void);
88 | void rotateSortMode(void);
89 | void refreshDirectories(u64 id);
90 | bool favorite(AccountUid uid, int i);
91 | void freeIcons(void);
92 | SDL_Texture* smallIcon(AccountUid uid, size_t i);
93 | std::unordered_map<std::string, std::string> getCompleteTitleList(void);
94 | 
95 | #endif


--------------------------------------------------------------------------------
/switch/include/util.hpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #ifndef UTIL_HPP
28 | #define UTIL_HPP
29 | 
30 | #include "account.hpp"
31 | #include "common.hpp"
32 | #include "io.hpp"
33 | #include <switch.h>
34 | #include <sys/stat.h>
35 | extern "C" {
36 | #include "ftp.h"
37 | }
38 | 
39 | // debug
40 | #include <arpa/inet.h>
41 | #include <sys/errno.h>
42 | #include <sys/socket.h>
43 | 
44 | void servicesExit(void);
45 | Result servicesInit(void);
46 | HidsysNotificationLedPattern blinkLedPattern(u8 times);
47 | void blinkLed(u8 times);
48 | 
49 | namespace StringUtils {
50 |     std::string removeAccents(std::string str);
51 |     std::string removeNotAscii(std::string str);
52 |     std::u16string UTF8toUTF16(const char* src);
53 | }
54 | 
55 | #endif
56 | 


--------------------------------------------------------------------------------
/switch/romfs/checkbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/switch/romfs/checkbox.png


--------------------------------------------------------------------------------
/switch/romfs/config.json:
--------------------------------------------------------------------------------
 1 | {
 2 |   "filter": [
 3 | 
 4 |   ],
 5 |   "favorites": [
 6 | 
 7 |   ],
 8 |   "additional_save_folders": {
 9 | 
10 |   },
11 |   "pksm-bridge": false,
12 |   "ftp-enabled": false,
13 |   "version": 4
14 | }


--------------------------------------------------------------------------------
/switch/romfs/star.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BernardoGiordano/Checkpoint/3f94b5c8816a323348c8f84eeaf5a53d2c3bebe6/switch/romfs/star.png


--------------------------------------------------------------------------------
/switch/romfs/web_root/css/style.css:
--------------------------------------------------------------------------------
1 | main>.container {
2 |   padding: 5rem 4rem;
3 | }
4 | 
5 | .topSpacing {
6 |   margin-top: 1rem;
7 | }


--------------------------------------------------------------------------------
/switch/romfs/web_root/index.html:
--------------------------------------------------------------------------------
 1 | <!doctype html>
 2 | <html lang="en" class="h-100">
 3 | 
 4 | <head>
 5 |   <meta charset="utf-8">
 6 |   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 7 |   <meta name="description" content="">
 8 |   <meta name="author" content="Bernardo Giordano, FlagBrew">
 9 |   <title>Checkpoint Configuration Panel</title>
10 | 
11 |   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
12 |     integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
13 |   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
14 |   <link rel="stylesheet" href="css/style.css">
15 |   <script src="https://code.jquery.com/jquery-3.3.1.min.js"
16 |     integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
17 |   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
18 |     integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
19 |   </script>
20 |   <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
21 |   <script src="js/script.js"></script>
22 | </head>
23 | 
24 | <body class="d-flex flex-column h-100">
25 |   <header>
26 |     <nav class="navbar navbar-dark fixed-top bg-dark">
27 |       <span class="navbar-brand mb-0 h1">Checkpoint Configuration</span>
28 |       <button id="button-save" onclick="saveSettings();" class="btn btn-outline-success" type="submit">Save</button>
29 |     </nav>
30 |   </header>
31 | 
32 |   <main role="main" class="flex-shrink-0">
33 |     <div class="container">
34 |       <div class="custom-control custom-checkbox topSpacing">
35 |         <input id="enable-pksm-bridge" type="checkbox" class="custom-control-input">
36 |         <label class="custom-control-label" for="enable-pksm-bridge">Enable PKSM-Bridge</label>
37 |       </div>
38 |       <div class="custom-control custom-checkbox topSpacing">
39 |         <input id="enable-ftp" type="checkbox" class="custom-control-input">
40 |         <label class="custom-control-label" for="enable-ftp">Enable FTP Server</label>
41 |       </div>
42 |       <div class="topSpacing">
43 |         <h4 class="d-flex justify-content-between align-items-center mb-3">
44 |           <span class="text">Filter titles</span>
45 |           <span id="filter-badge" class="badge badge-secondary badge-pill">0</span>
46 |         </h4>
47 |         <ul id="filter-list" class="list-group mb-3">
48 |         </ul>
49 |         <div class="input-group">
50 |           <input id="input-filter" type="text" class="form-control" placeholder="Title ID">
51 |           <div class="input-group-append">
52 |             <button id="button-filter" type="submit" onclick="pushToFilter();" class="btn btn-secondary">Filter</button>
53 |           </div>
54 |         </div>
55 |       </div>
56 | 
57 |       <div class="topSpacing">
58 |         <h4 class="d-flex justify-content-between align-items-center mb-3">
59 |           <span class="text">Favorites</span>
60 |           <span id="favorites-badge" class="badge badge-warning badge-pill">0</span>
61 |         </h4>
62 |         <ul id="favorites-list" class="list-group mb-3">
63 |         </ul>
64 | 
65 |         <div class="input-group">
66 |           <input id="input-favorites" type="text" class="form-control" placeholder="Title ID">
67 |           <div class="input-group-append">
68 |             <button type="submit" onclick="pushToFavorites();" class="btn btn-warning">Favorite</button>
69 |           </div>
70 |         </div>
71 |       </div>
72 | 
73 |       <div class="topSpacing">
74 |         <h4 class="d-flex justify-content-between align-items-center mb-3">
75 |           <span class="text">Additional folders</span>
76 |         </h4>
77 |         <ul id="folders-list" class="list-group mb-3">
78 |         </ul>
79 | 
80 |         <div class="panel-group list-group mb-3" id="accordion">
81 |           <div id="additional-saves-list" class="panel panel-default">
82 |           </div>
83 |         </div>
84 |       </div>
85 |     </div>
86 |   </main>
87 | 
88 | </html>


--------------------------------------------------------------------------------
/switch/source/ErrorOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "ErrorOverlay.hpp"
28 | 
29 | ErrorOverlay::ErrorOverlay(Screen& screen, Result mres, const std::string& mtext) : Overlay(screen)
30 | {
31 |     res  = mres;
32 |     text = mtext;
33 |     SDLH_GetTextDimensions(28, text.c_str(), &textw, &texth);
34 |     button = std::make_unique<Clickable>(322, 462, 636, 56, COLOR_BLACK_DARKERR, COLOR_WHITE, "OK", true);
35 |     button->selected(true);
36 | }
37 | 
38 | void ErrorOverlay::draw(void) const
39 | {
40 |     SDLH_DrawRect(0, 0, 1280, 720, COLOR_OVERLAY);
41 |     SDLH_DrawRect(320, 200, 640, 260, COLOR_BLACK);
42 |     SDLH_DrawText(20, 330, 210, COLOR_RED, StringUtils::format("Error: 0x%0llX", res).c_str());
43 |     SDLH_DrawText(28, ceilf(1280 - textw) / 2, 200 + ceilf((260 - texth) / 2), COLOR_WHITE, text.c_str());
44 |     button->draw(28, COLOR_RED);
45 |     drawPulsingOutline(322, 462, 636, 56, 4, COLOR_RED);
46 | }
47 | 
48 | void ErrorOverlay::update(const InputState& input)
49 | {
50 |     const u64 kDown = input.kDown;
51 |     if (button->released() || (kDown & HidNpadButton_A) || (kDown & HidNpadButton_B)) {
52 |         screen.removeOverlay();
53 |     }
54 | }


--------------------------------------------------------------------------------
/switch/source/InfoOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "InfoOverlay.hpp"
28 | 
29 | InfoOverlay::InfoOverlay(Screen& screen, const std::string& mtext) : Overlay(screen)
30 | {
31 |     text = mtext;
32 |     SDLH_GetTextDimensions(28, text.c_str(), &textw, &texth);
33 |     button = std::make_unique<Clickable>(322, 462, 636, 56, COLOR_BLACK_DARK, COLOR_WHITE, "OK", true);
34 |     button->selected(true);
35 | }
36 | 
37 | void InfoOverlay::draw(void) const
38 | {
39 |     SDLH_DrawRect(0, 0, 1280, 720, COLOR_OVERLAY);
40 |     SDLH_DrawRect(320, 200, 640, 260, COLOR_BLACK_DARK);
41 |     SDLH_DrawText(28, ceilf(1280 - textw) / 2, 200 + ceilf((260 - texth) / 2), COLOR_WHITE, text.c_str());
42 |     button->draw(28, COLOR_PURPLE_DARK);
43 |     drawPulsingOutline(322, 462, 636, 56, 4, COLOR_PURPLE_DARK);
44 | }
45 | 
46 | void InfoOverlay::update(const InputState& input)
47 | {
48 |     const u64 kDown = input.kDown;
49 |     if (button->released() || (kDown & HidNpadButton_A) || (kDown & HidNpadButton_B)) {
50 |         screen.removeOverlay();
51 |     }
52 | }


--------------------------------------------------------------------------------
/switch/source/KeyboardManager.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "KeyboardManager.hpp"
28 | 
29 | KeyboardManager::KeyboardManager(void)
30 | {
31 |     systemKeyboardAvailable = false;
32 |     if (appletGetAppletType() == AppletType_Application) {
33 |         SwkbdConfig kbd;
34 |         res = swkbdCreate(&kbd, 0);
35 |         if (R_SUCCEEDED(res)) {
36 |             systemKeyboardAvailable = true;
37 |             swkbdClose(&kbd);
38 |         }
39 |     }
40 | }
41 | 
42 | std::pair<bool, std::string> KeyboardManager::keyboard(const std::string& suggestion)
43 | {
44 |     if (systemKeyboardAvailable) {
45 |         SwkbdConfig kbd;
46 |         if (R_SUCCEEDED(swkbdCreate(&kbd, 0))) {
47 |             swkbdConfigMakePresetDefault(&kbd);
48 |             swkbdConfigSetInitialText(&kbd, suggestion.c_str());
49 |             swkbdConfigSetStringLenMax(&kbd, CUSTOM_PATH_LEN);
50 |             char tmpoutstr[CUSTOM_PATH_LEN] = {0};
51 |             Result res                      = swkbdShow(&kbd, tmpoutstr, CUSTOM_PATH_LEN);
52 |             swkbdClose(&kbd);
53 |             if (R_SUCCEEDED(res)) {
54 |                 return std::make_pair(true, std::string(tmpoutstr));
55 |             }
56 |         }
57 |     }
58 |     return std::make_pair(false, suggestion);
59 | }


--------------------------------------------------------------------------------
/switch/source/YesNoOverlay.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "YesNoOverlay.hpp"
28 | 
29 | YesNoOverlay::YesNoOverlay(
30 |     Screen& screen, const std::string& mtext, const std::function<void()>& callbackYes, const std::function<void()>& callbackNo)
31 |     : Overlay(screen), hid(2, 2)
32 | {
33 |     text    = mtext;
34 |     yesFunc = callbackYes;
35 |     noFunc  = callbackNo;
36 |     SDLH_GetTextDimensions(28, text.c_str(), &textw, &texth);
37 |     buttonYes = std::make_unique<Clickable>(322, 462, 316, 56, COLOR_BLACK_DARK, COLOR_WHITE, "Yes", true);
38 |     buttonNo  = std::make_unique<Clickable>(642, 462, 316, 56, COLOR_BLACK_DARK, COLOR_WHITE, "No", true);
39 | }
40 | 
41 | void YesNoOverlay::draw(void) const
42 | {
43 |     SDLH_DrawRect(0, 0, 1280, 720, COLOR_OVERLAY);
44 |     SDLH_DrawRect(320, 200, 640, 260, COLOR_BLACK_DARK);
45 |     SDLH_DrawText(28, ceilf(1280 - textw) / 2, 200 + ceilf((260 - texth) / 2), COLOR_WHITE, text.c_str());
46 |     drawOutline(322, 462, 316, 56, 2, COLOR_GREY_LIGHT);
47 |     drawOutline(642, 462, 316, 56, 2, COLOR_GREY_LIGHT);
48 |     buttonYes->draw(28, COLOR_PURPLE_DARK);
49 |     buttonNo->draw(28, COLOR_PURPLE_DARK);
50 | 
51 |     if (hid.index() == 0) {
52 |         drawPulsingOutline(324, 464, 312, 52, 4, COLOR_PURPLE_DARK);
53 |     }
54 |     else {
55 |         drawPulsingOutline(644, 464, 312, 52, 4, COLOR_PURPLE_DARK);
56 |     }
57 | }
58 | 
59 | void YesNoOverlay::update(const InputState& input)
60 | {
61 |     hid.update(2);
62 | 
63 |     hid.index(buttonYes->held() ? 0 : buttonNo->held() ? 1 : hid.index());
64 |     buttonYes->selected(hid.index() == 0);
65 |     buttonNo->selected(hid.index() == 1);
66 | 
67 |     const u64 kDown = input.kDown;
68 | 
69 |     if (buttonYes->released() || ((kDown & HidNpadButton_A) && hid.index() == 0)) {
70 |         yesFunc();
71 |     }
72 |     else if (buttonNo->released() || (kDown & HidNpadButton_B) || ((kDown & HidNpadButton_A) && hid.index() == 1)) {
73 |         noFunc();
74 |     }
75 | }


--------------------------------------------------------------------------------
/switch/source/clickable.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "clickable.hpp"
28 | 
29 | bool Clickable::held()
30 | {
31 |     return g_input->touch.count > 0 && g_input->touch.touches[0].y > (unsigned)my && g_input->touch.touches[0].y < (unsigned)(my + mh) &&
32 |            g_input->touch.touches[0].x > (unsigned)mx && g_input->touch.touches[0].x < (unsigned)(mx + mw);
33 | }
34 | 
35 | bool Clickable::released()
36 | {
37 |     const auto [on, currentlyTouching] = [this]() {
38 |         return std::make_pair(g_input->touch.count > 0 && g_input->touch.touches[0].y > (unsigned)my &&
39 |                                   g_input->touch.touches[0].y < (unsigned)(my + mh) && g_input->touch.touches[0].x > (unsigned)mx &&
40 |                                   g_input->touch.touches[0].x < (unsigned)(mx + mw),
41 |             g_input->touch.count > 0);
42 |     }();
43 | 
44 |     if (on) {
45 |         mOldPressed = true;
46 |     }
47 |     else {
48 |         if (mOldPressed && !currentlyTouching) {
49 |             mOldPressed = false;
50 |             return true;
51 |         }
52 |         mOldPressed = false;
53 |     }
54 | 
55 |     return false;
56 | }
57 | 
58 | void Clickable::draw(float font, SDL_Color overlay)
59 | {
60 |     u32 textw, texth;
61 |     SDLH_GetTextDimensions(font, mText.c_str(), &textw, &texth);
62 |     const u32 messageWidth = mCentered ? textw : mw - 20;
63 | 
64 |     SDLH_DrawRect(mx, my, mw, mh, mColorBg);
65 |     if (mCanChangeColorWhenSelected && held()) {
66 |         SDLH_DrawRect(mx, my, mw, mh, FC_MakeColor(overlay.r, overlay.g, overlay.b, 100));
67 |     }
68 |     if (!mCentered && mSelected) {
69 |         SDLH_DrawRect(mx + 4, my + 6, 4, mh - 12, COLOR_WHITE);
70 |     }
71 |     if (mSelected) {
72 |         SDLH_DrawRect(mx, my, mw, mh, FC_MakeColor(overlay.r, overlay.g, overlay.b, 100));
73 |     }
74 |     u32 offset = mx + (mw - messageWidth) / 2 + (!mCentered ? 8 : 0);
75 |     SDLH_DrawTextBox(font, offset, my + (mh - texth) / 2 + 2, mColorText, mw - 4 * 2, mText.c_str());
76 | }
77 | 
78 | void Clickable::drawOutline(SDL_Color color)
79 | {
80 |     drawPulsingOutline(mx, my, mw, mh, 4, color);
81 | }


--------------------------------------------------------------------------------
/switch/source/directory.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "directory.hpp"
28 | 
29 | Directory::Directory(const std::string& root)
30 | {
31 |     mGood  = false;
32 |     mError = 0;
33 |     mList.clear();
34 | 
35 |     DIR* dir = opendir(root.c_str());
36 |     struct dirent* ent;
37 | 
38 |     if (dir == NULL) {
39 |         mError = (Result)errno;
40 |     }
41 |     else {
42 |         while ((ent = readdir(dir))) {
43 |             std::string name         = std::string(ent->d_name);
44 |             bool directory           = ent->d_type == DT_DIR;
45 |             struct DirectoryEntry de = {name, directory};
46 |             mList.push_back(de);
47 |         }
48 |     }
49 | 
50 |     closedir(dir);
51 |     mGood = true;
52 | }
53 | 
54 | Result Directory::error(void)
55 | {
56 |     return mError;
57 | }
58 | 
59 | bool Directory::good(void)
60 | {
61 |     return mGood;
62 | }
63 | 
64 | std::string Directory::entry(size_t index)
65 | {
66 |     return index < mList.size() ? mList.at(index).name : "";
67 | }
68 | 
69 | bool Directory::folder(size_t index)
70 | {
71 |     return index < mList.size() ? mList.at(index).directory : false;
72 | }
73 | 
74 | size_t Directory::size(void)
75 | {
76 |     return mList.size();
77 | }


--------------------------------------------------------------------------------
/switch/source/filesystem.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "filesystem.hpp"
28 | 
29 | Result FileSystem::mount(FsFileSystem* fileSystem, u64 titleID, AccountUid userID)
30 | {
31 |     return fsOpen_SaveData(fileSystem, titleID, userID);
32 | }
33 | 
34 | int FileSystem::mount(FsFileSystem fs)
35 | {
36 |     return fsdevMountDevice("save", fs);
37 | }
38 | 
39 | void FileSystem::unmount(void)
40 | {
41 |     fsdevUnmountDevice("save");
42 | }


--------------------------------------------------------------------------------
/switch/source/main.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "main.hpp"
28 | #include "MainScreen.hpp"
29 | extern "C" {
30 | #include "ftp.h"
31 | }
32 | 
33 | static void networkLoop(void)
34 | {
35 |     while (appletMainLoop() && !g_shouldExitNetworkLoop) {
36 |         Configuration::getInstance().pollServer();
37 |         if (g_ftpAvailable && Configuration::getInstance().isFTPEnabled()) {
38 |             ftp_loop();
39 |         }
40 |     }
41 | }
42 | 
43 | int main(void)
44 | {
45 |     Result res = servicesInit();
46 |     if (R_FAILED(res)) {
47 |         servicesExit();
48 |         exit(res);
49 |     }
50 | 
51 |     InputState input;
52 |     g_input = &input;
53 |     PadState pad;
54 |     padInitializeDefault(&pad);
55 | 
56 |     g_screen = std::make_unique<MainScreen>(input);
57 | 
58 |     loadTitles();
59 |     // get the user IDs
60 |     std::vector<AccountUid> userIds = Account::ids();
61 |     // set g_currentUId to a default user in case we loaded at least one user
62 |     if (g_currentUId == 0)
63 |         g_currentUId = userIds.at(0);
64 | 
65 |     Thread networkThread;
66 |     threadCreate(&networkThread, (ThreadFunc)networkLoop, nullptr, nullptr, 16 * 1000, 0x2C, -2);
67 |     threadStart(&networkThread);
68 | 
69 |     while (appletMainLoop()) {
70 |         padUpdate(&pad);
71 | 
72 |         input.kDown = padGetButtonsDown(&pad);
73 |         if (input.kDown & HidNpadButton_Plus)
74 |             break;
75 | 
76 |         input.kHeld = padGetButtons(&pad);
77 |         input.kUp   = padGetButtonsUp(&pad);
78 |         hidGetTouchScreenStates(&input.touch, 1);
79 | 
80 |         g_screen->doDraw();
81 |         g_screen->doUpdate(input);
82 |         SDLH_Render();
83 |     }
84 | 
85 |     g_shouldExitNetworkLoop = true;
86 |     threadWaitForExit(&networkThread);
87 |     threadClose(&networkThread);
88 | 
89 |     servicesExit();
90 |     exit(0);
91 | }
92 | 


--------------------------------------------------------------------------------
/switch/source/scrollable.cpp:
--------------------------------------------------------------------------------
 1 | /*
 2 |  *   This file is part of Checkpoint
 3 |  *   Copyright (C) 2017-2025 Bernardo Giordano, FlagBrew
 4 |  *
 5 |  *   This program is free software: you can redistribute it and/or modify
 6 |  *   it under the terms of the GNU General Public License as published by
 7 |  *   the Free Software Foundation, either version 3 of the License, or
 8 |  *   (at your option) any later version.
 9 |  *
10 |  *   This program is distributed in the hope that it will be useful,
11 |  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 |  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 |  *   GNU General Public License for more details.
14 |  *
15 |  *   You should have received a copy of the GNU General Public License
16 |  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 |  *
18 |  *   Additional Terms 7.b and 7.c of GPLv3 apply to this file:
19 |  *       * Requiring preservation of specified reasonable legal notices or
20 |  *         author attributions in that material or in the Appropriate Legal
21 |  *         Notices displayed by works containing it.
22 |  *       * Prohibiting misrepresentation of the origin of that material,
23 |  *         or requiring that modified versions of such material be marked in
24 |  *         reasonable ways as different from the original version.
25 |  */
26 | 
27 | #include "scrollable.hpp"
28 | 
29 | void Scrollable::text(size_t i, const std::string& v)
30 | {
31 |     ((Clickable*)mCells.at(i))->text(v);
32 | }
33 | 
34 | void Scrollable::setIndex(size_t i)
35 | {
36 |     IScrollable::index(i);
37 |     mHid.index(mIndex);
38 |     mHid.page(mPage);
39 | }
40 | 
41 | void Scrollable::resetIndex(void)
42 | {
43 |     mHid.index(0);
44 |     mHid.page(0);
45 | }
46 | 
47 | void Scrollable::push_back(SDL_Color color, SDL_Color colorMessage, const std::string& message, bool selected)
48 | {
49 |     const float spacing = mh / mVisibleEntries;
50 |     Clickable* cell     = new Clickable(mx, my + (size() % mVisibleEntries) * spacing, mw, spacing, color, colorMessage, message, false);
51 |     cell->selected(selected);
52 |     mCells.push_back(cell);
53 | }
54 | 
55 | void Scrollable::updateSelection(void)
56 | {
57 |     const int hu = (mHid.maxEntries(size()) + 1) * mh / mVisibleEntries;
58 | 
59 |     if (g_input->touch.count > 0 && g_input->touch.touches[0].y > (float)my && g_input->touch.touches[0].y < (float)(my + hu) &&
60 |         g_input->touch.touches[0].x > (float)mx && g_input->touch.touches[0].x < (float)(mx + mw)) {
61 |         mHid.index(ceilf((g_input->touch.touches[0].y - my) * mVisibleEntries / mh));
62 |     }
63 | 
64 |     mHid.update(size());
65 |     mIndex = mHid.index();
66 |     mPage  = mHid.page();
67 | }
68 | 
69 | void Scrollable::draw(bool condition)
70 | {
71 |     const size_t baseIndex = mVisibleEntries * mPage;
72 |     const size_t sz        = size() - baseIndex > mVisibleEntries ? mVisibleEntries : size() - baseIndex;
73 |     for (size_t i = baseIndex; i < baseIndex + sz; i++) {
74 |         mCells.at(i)->draw(20, g_backupScrollEnabled && mCells.at(i)->selected() ? COLOR_PURPLE_LIGHT : COLOR_BLACK);
75 |     }
76 | 
77 |     size_t blankRows = mVisibleEntries - sz;
78 |     size_t rowHeight = mh / mVisibleEntries;
79 |     SDLH_DrawRect(mx, my + sz * rowHeight, mw, rowHeight * blankRows, COLOR_BLACK_DARKER);
80 | 
81 |     // draw selector
82 |     for (size_t i = baseIndex; i < baseIndex + sz; i++) {
83 |         if (mCells.at(i)->selected()) {
84 |             mCells.at(i)->drawOutline(condition ? COLOR_PURPLE_DARK : COLOR_GREY_LIGHT);
85 |             break;
86 |         }
87 |     }
88 | }
89 | 


--------------------------------------------------------------------------------