├── compile.bat
├── clean and compile.bat
├── icon.bmp
├── make_cia
├── .gitignore
├── bootloader
├── source
│ ├── arm9mpu_reset.s
│ ├── bios.s
│ ├── boot.h
│ ├── dldi_patcher.h
│ ├── card.h
│ ├── fat.h
│ ├── io_dldi.h
│ ├── arm7clear.s
│ ├── i2c.h
│ ├── arm9clear.arm.c
│ ├── disc_io.h
│ ├── i2c.c
│ ├── io_dldi.s
│ ├── load_crt0.s
│ ├── sdmmc.h
│ ├── dldi_patcher.c
│ ├── boot.c
│ ├── sdmmc.c
│ └── fat.c
├── arm9code
│ └── mpu_reset.s
├── Makefile
└── load.ld
├── bootstub
├── Makefile
└── bootstub.s
├── arm9
├── source
│ ├── common
│ │ ├── systemdetails.cpp
│ │ ├── systemdetails.h
│ │ ├── nds_loader_arm9.h
│ │ ├── stringtool.h
│ │ ├── stringtool.cpp
│ │ ├── singleton.h
│ │ ├── inifile.h
│ │ ├── inifile.cpp
│ │ └── nds_loader_arm9.c
│ └── main.cpp
└── Makefile
├── LICENSE
├── .github
└── workflows
│ └── main.yml
├── README.md
├── arm7
├── source
│ └── main.c
└── Makefile
├── Makefile
└── Makefile_DSi
/compile.bat:
--------------------------------------------------------------------------------
1 | make
2 | pause
3 |
--------------------------------------------------------------------------------
/clean and compile.bat:
--------------------------------------------------------------------------------
1 | make clean
2 | make
3 | pause
4 |
--------------------------------------------------------------------------------
/icon.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlameKat53/ButtonBoot/HEAD/icon.bmp
--------------------------------------------------------------------------------
/make_cia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/FlameKat53/ButtonBoot/HEAD/make_cia
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.d
3 | *.elf
4 | *.map
5 | *.DS_Store
6 | *.nds
7 | *.bin
8 | */build/*
9 |
--------------------------------------------------------------------------------
/bootloader/source/arm9mpu_reset.s:
--------------------------------------------------------------------------------
1 | .arm
2 | .global mpu_reset, mpu_reset_end
3 |
4 | mpu_reset:
5 | .incbin "mpu_reset.bin"
6 | mpu_reset_end:
7 |
--------------------------------------------------------------------------------
/bootstub/Makefile:
--------------------------------------------------------------------------------
1 | include $(DEVKITARM)/base_tools
2 |
3 | TARGET := bootstub
4 |
5 | ../data/$(TARGET).bin: $(TARGET).elf
6 | $(OBJCOPY) -O binary $< $@
7 |
8 | $(TARGET).elf: $(TARGET).s Makefile
9 | $(CC) -Wl,-Ttext=0 -x assembler-with-cpp -nostartfiles -nostdlib $(TARGET).s -o $@
10 |
11 |
12 | clean:
13 | rm -f $(TARGET).elf $(TARGET).bin
14 |
--------------------------------------------------------------------------------
/bootloader/source/bios.s:
--------------------------------------------------------------------------------
1 | .text
2 | .align 4
3 |
4 | .thumb
5 |
6 | @---------------------------------------------------------------------------------
7 | .global swiDelay
8 | .thumb_func
9 | @---------------------------------------------------------------------------------
10 | swiDelay:
11 | @---------------------------------------------------------------------------------
12 | swi 0x03
13 | bx lr
14 |
--------------------------------------------------------------------------------
/bootloader/source/boot.h:
--------------------------------------------------------------------------------
1 | #ifndef _BOOT_H_
2 | #define _BOOT_H_
3 |
4 | #define resetMemory2_ARM9_size 0x400
5 | void __attribute__ ((long_call)) __attribute__((naked)) __attribute__((noreturn)) resetMemory2_ARM9();
6 | #define clearMasterBright_ARM9_size 0x200
7 | void __attribute__ ((long_call)) __attribute__((naked)) __attribute__((noreturn)) clearMasterBright_ARM9();
8 | #define startBinary_ARM9_size 0x100
9 | void __attribute__ ((long_call)) __attribute__((noreturn)) __attribute__((naked)) startBinary_ARM9 ();
10 | #define ARM9_START_FLAG (*(vu8*)0x02FFFDFB)
11 |
12 | #endif // _BOOT_H_
13 |
--------------------------------------------------------------------------------
/arm9/source/common/systemdetails.cpp:
--------------------------------------------------------------------------------
1 | #include "systemdetails.h"
2 |
3 | SystemDetails::SystemDetails()
4 | {
5 |
6 | _isRegularDS = true;
7 |
8 | fifoWaitValue32(FIFO_USER_06);
9 | if (fifoGetValue32(FIFO_USER_03) == 0)
10 | _arm7SCFGLocked = true; // If ButtonBoot4R4 is being run from flashcard, then arm7 SCFG is locked.
11 |
12 | u16 arm7_SNDEXCNT = fifoGetValue32(FIFO_USER_07);
13 | if (arm7_SNDEXCNT != 0)
14 | {
15 | _isRegularDS = false; // If sound frequency setting is found, then the console is not a DS Phat/Lite
16 | }
17 |
18 | // Restore value.
19 | fifoSendValue32(FIFO_USER_07, arm7_SNDEXCNT);
20 | }
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | MIT License
3 |
4 | Copyright (c) 2019
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/arm9/source/common/systemdetails.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #ifndef __SYSTEM_DETAILS__
3 | #define __SYSTEM_DETAILS__
4 | #include "singleton.h"
5 | #include
6 | #include
7 | #include
8 |
9 | class SystemDetails
10 | {
11 | public:
12 | SystemDetails();
13 | ~SystemDetails() {}
14 |
15 | public:
16 | bool arm7SCFGLocked() { return _arm7SCFGLocked; }
17 | bool flashcardUsed()
18 | {
19 | if (_flashcardUsed)
20 | return _flashcardUsed;
21 | if (!access("fat:/", F_OK))
22 | {
23 | _flashcardUsed = true;
24 | }
25 |
26 | return _flashcardUsed;
27 | }
28 | bool isRegularDS() { return _isRegularDS; }
29 | bool fatInitOk() { return _fatInitOk; }
30 | bool useNitroFS() { return _nitroFsInitOk; }
31 | void initFilesystem(const char *runningPath = NULL);
32 |
33 | private:
34 | bool _arm7SCFGLocked;
35 | bool _flashcardUsed;
36 | bool _isRegularDS;
37 | bool _fatInitOk;
38 | bool _nitroFsInitOk;
39 | };
40 |
41 | typedef singleton systemDetails_s;
42 |
43 | inline SystemDetails &sys() { return systemDetails_s::instance(); }
44 | #endif
--------------------------------------------------------------------------------
/bootloader/source/dldi_patcher.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------
2 |
3 | Copyright (C) 2005 Michael "Chishm" Chisholm
4 |
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | as published by the Free Software Foundation; either version 2
8 | of the License, or (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, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 | If you use this code, please give due credit and email me about your
20 | project at chishm@hotmail.com
21 | ------------------------------------------------------------------*/
22 |
23 | #ifndef DLDI_PATCHER_H
24 | #define DLDI_PATCHER_H
25 |
26 | #include
27 |
28 | typedef signed int addr_t;
29 | typedef unsigned char data_t;
30 | bool dldiPatchBinary (data_t *binData, u32 binSize);
31 |
32 | #endif // DLDI_PATCHER_H
33 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | #Based On: https://github.com/Universal-Team/Relaunch/blob/master/.github/workflows/build.yml
2 | name: Compile ButtonBoot
3 |
4 | on:
5 | push:
6 | paths-ignore:
7 | - 'README.md'
8 | pull_request:
9 | branches: ["*"]
10 | paths-ignore:
11 | - 'README.md'
12 | release:
13 | types: [created]
14 |
15 | jobs:
16 | build:
17 | runs-on: ubuntu-latest
18 | container: devkitpro/devkitarm
19 | name: Build with Docker using devkitARM
20 | outputs:
21 | commit_tag: ${{ steps.build.outputs.commit_tag }}
22 | commit_hash: ${{ steps.build.outputs.commit_hash }}
23 | author_name: ${{ steps.build.outputs.author_name }}
24 | committer_name: ${{ steps.build.outputs.committer_name }}
25 | commit_subject: ${{ steps.build.outputs.commit_subject }}
26 | commit_message: ${{ steps.build.outputs.commit_message }}
27 | steps:
28 | - name: Checkout repo
29 | uses: actions/checkout@v3
30 | with:
31 | submodules: recursive
32 | - name: Build
33 | id: build
34 | run: |
35 | make
36 |
37 | mkdir -p ~/artifacts
38 | cp ButtonBoot.nds ~/artifacts
39 |
40 | - name: Publish build to GH Actions
41 | uses: actions/upload-artifact@v3
42 | with:
43 | path: ~/artifacts/ButtonBoot.nds
44 | name: build
45 |
--------------------------------------------------------------------------------
/arm9/source/common/nds_loader_arm9.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------
2 | Copyright (C) 2005 - 2010
3 | Michael "Chishm" Chisholm
4 | Dave "WinterMute" Murphy
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | as published by the Free Software Foundation; either version 2
8 | of the License, or (at your option) any later version.
9 | This program is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 | You should have received a copy of the GNU General Public License
14 | along with this program; if not, write to the Free Software
15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 | ------------------------------------------------------------------*/
17 |
18 | #ifndef NDS_LOADER_ARM9_H
19 | #define NDS_LOADER_ARM9_H
20 |
21 | #ifdef __cplusplus
22 | extern "C"
23 | {
24 | #endif
25 |
26 | #define LOAD_DEFAULT_NDS 0
27 |
28 | int runNds(const void *loader, u32 loaderSize, u32 cluster, bool initDisc, bool dldiPatchNds, int argc, const char **argv, bool clearMasterBright);
29 |
30 | int runNdsFile(const char *filename, int argc, const char **argv, bool clearMasterBright);
31 |
32 | bool installBootStub(bool havedsiSD);
33 |
34 | #ifdef __cplusplus
35 | }
36 | #endif
37 |
38 | #endif // NDS_LOADER_ARM7_H
39 |
--------------------------------------------------------------------------------
/arm9/source/common/stringtool.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------
2 | Copyright (C) 2007 Acekard, www.acekard.com
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 | The above copyright notice and this permission notice shall be included in
10 | all copies or substantial portions of the Software.
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | THE SOFTWARE.
18 | ---------------------------------------------------------------------------------*/
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | #ifndef _STRINGTOOL_H_
29 | #define _STRINGTOOL_H_
30 |
31 | #include
32 |
33 | std::string formatString( const char* fmt, ... );
34 |
35 |
36 |
37 | #endif//_STRINGTOOL_H_
38 |
--------------------------------------------------------------------------------
/bootloader/source/card.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------
2 |
3 | Copyright (C) 2005 Michael "Chishm" Chisholm
4 |
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | as published by the Free Software Foundation; either version 2
8 | of the License, or (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, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 | If you use this code, please give due credit and email me about your
20 | project at chishm@hotmail.com
21 | ------------------------------------------------------------------*/
22 |
23 | #ifndef CARD_H
24 | #define CARD_H
25 |
26 | #include "disc_io.h"
27 | #include "io_dldi.h"
28 |
29 | static inline bool CARD_StartUp (void) {
30 | return _io_dldi.fn_startup();
31 | }
32 |
33 | static inline bool CARD_IsInserted (void) {
34 | return _io_dldi.fn_isInserted();
35 | }
36 |
37 | static inline bool CARD_ReadSector (u32 sector, void *buffer) {
38 | return _io_dldi.fn_readSectors(sector, 1, buffer);
39 | }
40 |
41 | static inline bool CARD_ReadSectors (u32 sector, int count, void *buffer) {
42 | return _io_dldi.fn_readSectors(sector, count, buffer);
43 | }
44 |
45 | #endif // CARD_H
46 |
--------------------------------------------------------------------------------
/bootloader/source/fat.h:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------
2 | fat.h
3 |
4 | NDS MP
5 | GBAMP NDS Firmware Hack Version 2.12
6 | An NDS aware firmware patch for the GBA Movie Player.
7 | By Michael Chisholm (Chishm)
8 |
9 | Filesystem code based on GBAMP_CF.c by Chishm (me).
10 |
11 | License:
12 | Copyright (C) 2005 Michael "Chishm" Chisholm
13 |
14 | This program is free software; you can redistribute it and/or
15 | modify it under the terms of the GNU General Public License
16 | as published by the Free Software Foundation; either version 2
17 | of the License, or (at your option) any later version.
18 |
19 | This program is distributed in the hope that it will be useful,
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | GNU General Public License for more details.
23 |
24 | You should have received a copy of the GNU General Public License
25 | along with this program; if not, write to the Free Software
26 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 |
28 | If you use this code, please give due credit and email me about your
29 | project at chishm@hotmail.com
30 | ------------------------------------------------------------------*/
31 |
32 | #ifndef FAT_H
33 | #define FAT_H
34 |
35 | #include
36 |
37 | #define CLUSTER_FREE 0x00000000
38 | #define CLUSTER_EOF 0x0FFFFFFF
39 | #define CLUSTER_FIRST 0x00000002
40 |
41 | bool FAT_InitFiles (bool initCard);
42 | u32 getBootFileCluster (const char* bootName);
43 | u32 fileRead (char* buffer, u32 cluster, u32 startOffset, u32 length);
44 | u32 FAT_ClustToSect (u32 cluster);
45 |
46 | #endif // FAT_H
47 |
--------------------------------------------------------------------------------
/arm9/source/common/stringtool.cpp:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------
2 | Copyright (C) 2007 Acekard, www.acekard.com
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 | The above copyright notice and this permission notice shall be included in
10 | all copies or substantial portions of the Software.
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17 | THE SOFTWARE.
18 | ---------------------------------------------------------------------------------*/
19 |
20 | #include "stringtool.h"
21 | #include
22 | #include
23 | #include
24 |
25 | std::string formatString( const char* fmt, ... )
26 | {
27 | const char * f = fmt;
28 | va_list argList;
29 | va_start(argList, fmt);
30 | char * ptempStr = NULL;
31 | size_t max_len = vasiprintf( &ptempStr, f, argList);
32 | std::string str( ptempStr );
33 | str.resize( max_len );
34 | free( ptempStr );
35 | va_end(argList);
36 | return str;
37 | }
38 |
--------------------------------------------------------------------------------
/bootloader/source/io_dldi.h:
--------------------------------------------------------------------------------
1 | /*--------------------------------------------------------------------------------------------
2 | io_dldi.h
3 |
4 | Reserved space for post-compilation adding of an extra driver
5 |
6 | Copyright (c) 2006 Michael "Chishm" Chisholm
7 |
8 | Redistribution and use in source and binary forms, with or without modification,
9 | are permitted provided that the following conditions are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright notice,
12 | this list of conditions and the following disclaimer.
13 | 2. Redistributions in binary form must reproduce the above copyright notice,
14 | this list of conditions and the following disclaimer in the documentation and/or
15 | other materials provided with the distribution.
16 | 3. The name of the author may not be used to endorse or promote products derived
17 | from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
29 | 2006-12-22 - Chishm
30 | * Original release
31 | --------------------------------------------------------------------------------------------*/
32 |
33 | #ifndef IO_DLDI_H
34 | #define IO_DLDI_H
35 |
36 | // 'DLDD'
37 | #define DEVICE_TYPE_DLDD 0x49444C44
38 |
39 | #include "disc_io.h"
40 |
41 | // export interface
42 | extern IO_INTERFACE _io_dldi ;
43 |
44 | #endif // define IO_DLDI_H
45 |
--------------------------------------------------------------------------------
/bootloader/source/arm7clear.s:
--------------------------------------------------------------------------------
1 | /*-----------------------------------------------------------------
2 |
3 | Copyright (C) 2005 Michael "Chishm" Chisholm
4 |
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | as published by the Free Software Foundation; either version 2
8 | of the License, or (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, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 |
19 | If you use this code, please give due credit and email me about your
20 | project at chishm@hotmail.com
21 | ------------------------------------------------------------------*/
22 |
23 | .arm
24 | .global arm7clearRAM
25 | .type arm7clearRAM STT_FUNC
26 | arm7clearRAM:
27 |
28 | push {r0-r9}
29 | // clear exclusive IWRAM
30 | // 0380:0000 to 0380:FFFF, total 64KiB
31 | mov r0, #0
32 | mov r1, #0
33 | mov r2, #0
34 | mov r3, #0
35 | mov r4, #0
36 | mov r5, #0
37 | mov r6, #0
38 | mov r7, #0
39 | mov r8, #0x03800000
40 | sub r8, #0x00008000
41 | mov r9, #0x03800000
42 | orr r9, r9, #0x10000
43 | clear_IWRAM_loop:
44 | stmia r8!, {r0, r1, r2, r3, r4, r5, r6, r7}
45 | cmp r8, r9
46 | blt clear_IWRAM_loop
47 |
48 | // clear most of EWRAM - except after RAM end - 0xc000, which has the bootstub
49 | mov r8, #0x02000000
50 |
51 | ldr r9,=0x4004008
52 | ldr r9,[r9]
53 | ands r9,r9,#0x8000
54 | bne dsi_mode
55 |
56 | mov r9, #0x02400000
57 | b ds_mode
58 | dsi_mode:
59 | mov r9, #0x03000000
60 | ds_mode:
61 | sub r9, #0x0000c000
62 | clear_EWRAM_loop:
63 | stmia r8!, {r0, r1, r2, r3, r4, r5, r6, r7}
64 | cmp r8, r9
65 | blt clear_EWRAM_loop
66 |
67 | pop {r0-r9}
68 |
69 | bx lr
70 |
71 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ButtonBoot
2 | Made by FlameKat53, Epicpkmn11, RocketRobz
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | How To Use
11 |
12 |
13 | - 1.) Get some .nds homebrew. (You can get some [here](https://www.gamebrew.org/wiki/List_of_DS_homebrew_applications))
14 |
15 | - 2.) Name your .nds files boot#.nds with # being one of these buttons; `A`, `B`, `X`, `Y`, `Start`, `Select`, `L`, `R`, `Left`, `Right`, `Down`, `Up`, or `Touch`. Alternatively, you can edit the `ButtonBoot.ini` file and set custom paths, names, and file extensions for your .nds files.
16 |
17 | - 3.) Put all of your .nds files into `_nds/extras/`, if you edited the .ini file with custom .nds paths you don't need to do this
18 |
19 | - 4.) Launch ButtonBoot and hold the button corresponding to the .nds file you want to launch.
20 |
21 | - 5.) Enjoy!
22 |
23 |
24 | How to Autoboot into the app
25 |
26 |
27 | - If you use an `r4isdhc.com` or `r4i-sdhc.com` card, get the special `R4.dat` from [here](https://cdn.discordapp.com/attachments/286686210225864725/558474658274607114/r4.dat), then rename `ButtonBoot.nds` to `_BOOT_DS.nds` and place it on the root of your microSD card.
28 |
29 | - If you use DSiWarehax, rename `ButtonBoot_DSi.nds` to `BOOT.NDS`
30 |
31 | Other
32 |
33 |
34 | - Please note retail .nds roms do not work, though YSMenu does.
35 | - [devkitPro](https://github.com/devkitPro), [WinterMute](https://github.com/WinterMute): Code used in nds-hb-menu, and the use of the bootloader, devkitARM, libnds, and libfat.
36 | - [CardIDGetter](https://github.com/RocketRobz/CardIDGetter), The arm7 code and Makefile's.
37 | - [TWiLightMenu](https://github.com/DS-Homebrew/TWiLightMenu), Inifile, bootstub, bootloader code and a lot more.
38 | - [GodMode9i](https://github.com/DS-Homebrew/GodMode9i), Some code from the GitHub Actions
--------------------------------------------------------------------------------
/bootloader/source/i2c.h:
--------------------------------------------------------------------------------
1 | /*---------------------------------------------------------------------------------
2 |
3 | I2C control for the ARM7
4 |
5 | Copyright (C) 2011
6 | Dave Murphy (WinterMute)
7 |
8 | This software is provided 'as-is', without any express or implied
9 | warranty. In no event will the authors be held liable for any
10 | damages arising from the use of this software.
11 |
12 | Permission is granted to anyone to use this software for any
13 | purpose, including commercial applications, and to alter it and
14 | redistribute it freely, subject to the following restrictions:
15 |
16 | 1. The origin of this software must not be misrepresented; you
17 | must not claim that you wrote the original software. If you use
18 | this software in a product, an acknowledgment in the product
19 | documentation would be appreciated but is not required.
20 | 2. Altered source versions must be plainly marked as such, and
21 | must not be misrepresented as being the original software.
22 | 3. This notice may not be removed or altered from any source
23 | distribution.
24 |
25 | ---------------------------------------------------------------------------------*/
26 | #ifndef I2C_ARM7_INCLUDE
27 | #define I2C_ARM7_INCLUDE
28 |
29 | #ifndef ARM7
30 | #error i2c header is for ARM7 only
31 | #endif
32 |
33 | #include
34 |
35 | #define REG_I2CDATA (*(vu8 *)0x4004500)
36 | #define REG_I2CCNT (*(vu8 *)0x4004501)
37 |
38 | static inline void i2cWaitBusy() {
39 | while(REG_I2CCNT & 0x80);
40 | }
41 |
42 | enum i2cDevices {
43 | I2C_CAM0 = 0x7A,
44 | I2C_CAM1 = 0x78,
45 | I2C_UNK1 = 0xA0,
46 | I2C_UNK2 = 0xE0,
47 | I2C_PM = 0x4A,
48 | I2C_UNK3 = 0x40,
49 | I2C_GPIO = 0x90
50 | };
51 |
52 | // Registers for Power Management (I2C_PM)
53 | #define I2CREGPM_BATUNK 0x00
54 | #define I2CREGPM_PWRIF 0x10
55 | #define I2CREGPM_PWRCNT 0x11
56 | #define I2CREGPM_MMCPWR 0x12
57 | #define I2CREGPM_BATTERY 0x20
58 | #define I2CREGPM_CAMLED 0x31
59 | #define I2CREGPM_VOL 0x40
60 | #define I2CREGPM_RESETFLAG 0x70
61 |
62 | u8 i2cWriteRegister(u8 device, u8 reg, u8 data);
63 | u8 i2cReadRegister(u8 device, u8 reg);
64 |
65 | #endif // I2C_ARM7_INCLUDE
--------------------------------------------------------------------------------
/arm9/source/common/singleton.h:
--------------------------------------------------------------------------------
1 | /*
2 | common/singleton.h
3 | Copyright (c) 2018 chyyran
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 | */
23 |
24 | #pragma once
25 | #ifndef _SINGLETON_H_
26 | #define _SINGLETON_H_
27 | #include
28 | #include
29 | #include // std::nothrow
30 |
31 | template
32 | class singleton
33 | {
34 |
35 | public:
36 | static inline T &instance(Args &&... args)
37 | {
38 | if (!_instance)
39 | make(std::forward(args)...);
40 | return *_instance;
41 | }
42 |
43 | private:
44 | static inline void make(Args... args)
45 | {
46 | if (!_instance)
47 | _instance = new (std::nothrow) T(std::forward(args)...);
48 | }
49 |
50 | static inline void reset()
51 | {
52 | if (_instance)
53 | {
54 | delete _instance;
55 | _instance = NULL;
56 | }
57 | }
58 |
59 | private:
60 | static T *_instance;
61 | };
62 |
63 | template
64 | T * singleton::_instance = NULL;
65 |
66 | #endif //_SINGLETON_H_
67 |
--------------------------------------------------------------------------------
/arm9/source/common/inifile.h:
--------------------------------------------------------------------------------
1 | /*
2 | inifile.h
3 | Copyright (C) 2007 Acekard, www.acekard.com
4 | Copyright (C) 2007-2009 somebody
5 | Copyright (C) 2009-2010 yellow wood goblin
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
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 | You should have received a copy of the GNU General Public License
15 | along with this program. If not, see .
16 | */
17 |
18 | #ifndef _INIFILE_H_
19 | #define _INIFILE_H_
20 |
21 | #include
22 | #include
23 | #include