├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── LICENSE
├── Makefile
├── Makefile_DSi
├── README.md
├── arm7
├── Makefile
└── source
│ └── main.c
├── arm9
├── Makefile
└── source
│ ├── common
│ ├── inifile.cpp
│ ├── inifile.h
│ ├── nds_loader_arm9.c
│ ├── nds_loader_arm9.h
│ ├── singleton.h
│ ├── stringtool.cpp
│ ├── stringtool.h
│ ├── systemdetails.cpp
│ └── systemdetails.h
│ └── main.cpp
├── bootloader
├── Makefile
├── arm9code
│ └── mpu_reset.s
├── load.ld
└── source
│ ├── arm7clear.s
│ ├── arm9clear.arm.c
│ ├── arm9mpu_reset.s
│ ├── bios.s
│ ├── boot.c
│ ├── boot.h
│ ├── card.h
│ ├── disc_io.h
│ ├── dldi_patcher.c
│ ├── dldi_patcher.h
│ ├── fat.c
│ ├── fat.h
│ ├── i2c.c
│ ├── i2c.h
│ ├── io_dldi.h
│ ├── io_dldi.s
│ ├── load_crt0.s
│ ├── sdmmc.c
│ └── sdmmc.h
├── bootstub
├── Makefile
└── bootstub.s
├── clean and compile.bat
├── compile.bat
├── icon.bmp
└── make_cia
/.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 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.o
2 | *.d
3 | *.elf
4 | *.map
5 | *.DS_Store
6 | *.nds
7 | *.bin
8 | */build/*
9 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #---------------------------------------------------------------------------------
2 | .SUFFIXES:
3 | #---------------------------------------------------------------------------------
4 | .SECONDARY:
5 |
6 | ifeq ($(strip $(DEVKITARM)),)
7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM")
8 | endif
9 |
10 | include $(DEVKITARM)/ds_rules
11 |
12 | export VERSION_MAJOR := 1
13 | export VERSION_MINOR := 0
14 | export VERSION_PATCH := 0
15 |
16 |
17 | VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
18 | #---------------------------------------------------------------------------------
19 | # TARGET is the name of the output
20 | # BUILD is the directory where object files & intermediate files will be placed
21 | # SOURCES is a list of directories containing source code
22 | # INCLUDES is a list of directories containing extra header files
23 | # DATA is a list of directories containing binary files embedded using bin2o
24 | # GRAPHICS is a list of directories containing image files to be converted with grit
25 | #---------------------------------------------------------------------------------
26 | TARGET := ButtonBoot
27 | BUILD := build
28 | SOURCES := source
29 | INCLUDES := include
30 | DATA := data
31 |
32 | #---------------------------------------------------------------------------------
33 | # options for code generation
34 | #---------------------------------------------------------------------------------
35 | ARCH := -mthumb -mthumb-interwork
36 |
37 | CFLAGS := -g -Wall -O2 \
38 | -ffunction-sections -fdata-sections \
39 | -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
40 | -ffast-math \
41 | $(ARCH)
42 |
43 | CFLAGS += $(INCLUDE) -DARM9
44 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11
45 |
46 | ASFLAGS := -g $(ARCH)
47 | LDFLAGS = -specs=ds_arm9.specs -g -Wl,--gc-sections $(ARCH) -Wl,-Map,$(notdir $*.map)
48 |
49 |
50 | #---------------------------------------------------------------------------------
51 | # list of directories containing libraries, this must be the top level containing
52 | # include and lib
53 | #---------------------------------------------------------------------------------
54 | LIBDIRS := $(LIBNDS)
55 |
56 | #---------------------------------------------------------------------------------
57 | # no real need to edit anything past this point unless you need to add additional
58 | # rules for different file extensions
59 | #---------------------------------------------------------------------------------
60 | ifneq ($(BUILD),$(notdir $(CURDIR)))
61 | #---------------------------------------------------------------------------------
62 | export TOPDIR := $(CURDIR)
63 |
64 | export OUTPUT := $(CURDIR)/$(TARGET)
65 |
66 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
67 |
68 | export DEPSDIR := $(CURDIR)/$(BUILD)
69 |
70 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
71 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
72 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
73 | BINFILES := load.bin bootstub.bin
74 |
75 | #---------------------------------------------------------------------------------
76 | # use CXX for linking C++ projects, CC for standard C
77 | #---------------------------------------------------------------------------------
78 | ifeq ($(strip $(CPPFILES)),)
79 | #---------------------------------------------------------------------------------
80 | export LD := $(CC)
81 | #---------------------------------------------------------------------------------
82 | else
83 | #---------------------------------------------------------------------------------
84 | export LD := $(CXX)
85 | #---------------------------------------------------------------------------------
86 | endif
87 | #---------------------------------------------------------------------------------
88 |
89 | export OFILES := $(addsuffix .o,$(BINFILES)) \
90 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
91 |
92 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
93 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
94 | -I$(CURDIR)/$(BUILD)
95 |
96 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
97 |
98 | icons := $(wildcard *.bmp)
99 |
100 | ifneq (,$(findstring $(TARGET).bmp,$(icons)))
101 | export GAME_ICON := $(CURDIR)/$(TARGET).bmp
102 | else
103 | ifneq (,$(findstring icon.bmp,$(icons)))
104 | export GAME_ICON := $(CURDIR)/icon.bmp
105 | endif
106 | endif
107 |
108 | export GAME_TITLE := $(TARGET)
109 |
110 | .PHONY: bootloader bootstub clean arm7/$(TARGET).elf arm9/$(TARGET).elf
111 |
112 | all: bootloader bootstub $(TARGET).nds
113 |
114 | dist: all
115 | @rm -fr hbmenu
116 | @mkdir hbmenu
117 | @cp $(TARGET).nds hbmenu/BOOT.NDS
118 | @cp BootStrap/_BOOT_MP.NDS BootStrap/TTMENU.DAT BootStrap/_DS_MENU.DAT BootStrap/ez5sys.bin BootStrap/akmenu4.nds hbmenu
119 | @tar -cvjf $(TARGET)-$(VERSION).tar.bz2 hbmenu testfiles README.html COPYING hbmenu -X exclude.lst
120 |
121 | $(TARGET).nds: $(TARGET).arm7 $(TARGET).arm9
122 | # simple nds srl without dsi extended header thx Robz!
123 | ndstool -h 0x200 -c $(TARGET).nds -7 $(TARGET).arm7.elf -9 $(TARGET).arm9.elf -b icon.bmp "ButtonBoot;FlameKat53, Epicpkmn11"
124 |
125 | $(TARGET).arm7: arm7/$(TARGET).elf
126 | cp arm7/$(TARGET).elf $(TARGET).arm7.elf
127 |
128 | $(TARGET).arm9: arm9/$(TARGET).elf
129 | cp arm9/$(TARGET).elf $(TARGET).arm9.elf
130 |
131 | #---------------------------------------------------------------------------------
132 | arm7/$(TARGET).elf:
133 | @$(MAKE) -C arm7
134 |
135 | #---------------------------------------------------------------------------------
136 | arm9/$(TARGET).elf:
137 | @$(MAKE) -C arm9
138 |
139 | #---------------------------------------------------------------------------------
140 | #$(BUILD):
141 | #@[ -d $@ ] || mkdir -p $@
142 | #@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
143 | #---------------------------------------------------------------------------------
144 | clean:
145 | @echo clean ...
146 | @rm -fr data
147 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds
148 | @rm -fr $(TARGET).arm7.elf
149 | @rm -fr $(TARGET).arm9.elf
150 | @$(MAKE) -C bootloader clean
151 | @$(MAKE) -C bootstub clean
152 | @$(MAKE) -C arm9 clean
153 | @$(MAKE) -C arm7 clean
154 |
155 | data:
156 | @mkdir -p data
157 |
158 | bootloader: data
159 | @$(MAKE) -C bootloader
160 |
161 | bootstub: data
162 | @$(MAKE) -C bootstub
163 |
164 | #---------------------------------------------------------------------------------
165 | else
166 |
167 | #---------------------------------------------------------------------------------
168 | # main targets
169 | #---------------------------------------------------------------------------------
170 | #$(OUTPUT).nds : $(OUTPUT).elf
171 | #$(OUTPUT).elf : $(OFILES)
172 |
173 | #---------------------------------------------------------------------------------
174 | %.bin.o : %.bin
175 | #---------------------------------------------------------------------------------
176 | @echo $(notdir $<)
177 | $(bin2o)
178 |
179 | #---------------------------------------------------------------------------------
180 | # This rule creates assembly source files using grit
181 | # grit takes an image file and a .grit describing how the file is to be processed
182 | # add additional rules like this for each image extension
183 | # you use in the graphics folders
184 | #---------------------------------------------------------------------------------
185 | %.s %.h : %.bmp %.grit
186 | #---------------------------------------------------------------------------------
187 | grit $< -fts -o$*
188 |
189 |
190 | #---------------------------------------------------------------------------------
191 | %.s %.h : %.png %.grit
192 | #---------------------------------------------------------------------------------
193 | grit $< -fts -o$*
194 |
195 | -include $(DEPSDIR)/*.d
196 |
197 | #---------------------------------------------------------------------------------------
198 | endif
199 | #---------------------------------------------------------------------------------------
200 |
--------------------------------------------------------------------------------
/Makefile_DSi:
--------------------------------------------------------------------------------
1 | #---------------------------------------------------------------------------------
2 | .SUFFIXES:
3 | #---------------------------------------------------------------------------------
4 | .SECONDARY:
5 |
6 | ifeq ($(strip $(DEVKITARM)),)
7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM")
8 | endif
9 |
10 | include $(DEVKITARM)/ds_rules
11 |
12 | export VERSION_MAJOR := 1
13 | export VERSION_MINOR := 0
14 | export VERSION_PATCH := 0
15 |
16 |
17 | VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
18 | #---------------------------------------------------------------------------------
19 | # TARGET is the name of the output
20 | # BUILD is the directory where object files & intermediate files will be placed
21 | # SOURCES is a list of directories containing source code
22 | # INCLUDES is a list of directories containing extra header files
23 | # DATA is a list of directories containing binary files embedded using bin2o
24 | # GRAPHICS is a list of directories containing image files to be converted with grit
25 | #---------------------------------------------------------------------------------
26 | TARGET := ButtonBoot
27 | BUILD := build
28 | SOURCES := source
29 | INCLUDES := include
30 | DATA := data
31 |
32 | #---------------------------------------------------------------------------------
33 | # options for code generation
34 | #---------------------------------------------------------------------------------
35 | ARCH := -mthumb -mthumb-interwork
36 |
37 | CFLAGS := -g -Wall -O2 \
38 | -ffunction-sections -fdata-sections \
39 | -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
40 | -ffast-math \
41 | $(ARCH)
42 |
43 | CFLAGS += $(INCLUDE) -DARM9
44 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++11
45 |
46 | ASFLAGS := -g $(ARCH)
47 | LDFLAGS = -specs=ds_arm9.specs -g -Wl,--gc-sections $(ARCH) -Wl,-Map,$(notdir $*.map)
48 |
49 |
50 | #---------------------------------------------------------------------------------
51 | # list of directories containing libraries, this must be the top level containing
52 | # include and lib
53 | #---------------------------------------------------------------------------------
54 | LIBDIRS := $(LIBNDS)
55 |
56 | #---------------------------------------------------------------------------------
57 | # no real need to edit anything past this point unless you need to add additional
58 | # rules for different file extensions
59 | #---------------------------------------------------------------------------------
60 | ifneq ($(BUILD),$(notdir $(CURDIR)))
61 | #---------------------------------------------------------------------------------
62 | export TOPDIR := $(CURDIR)
63 |
64 | export OUTPUT := $(CURDIR)/$(TARGET)
65 |
66 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
67 |
68 | export DEPSDIR := $(CURDIR)/$(BUILD)
69 |
70 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
71 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
72 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
73 | BINFILES := load.bin bootstub.bin
74 |
75 | #---------------------------------------------------------------------------------
76 | # use CXX for linking C++ projects, CC for standard C
77 | #---------------------------------------------------------------------------------
78 | ifeq ($(strip $(CPPFILES)),)
79 | #---------------------------------------------------------------------------------
80 | export LD := $(CC)
81 | #---------------------------------------------------------------------------------
82 | else
83 | #---------------------------------------------------------------------------------
84 | export LD := $(CXX)
85 | #---------------------------------------------------------------------------------
86 | endif
87 | #---------------------------------------------------------------------------------
88 |
89 | export OFILES := $(addsuffix .o,$(BINFILES)) \
90 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
91 |
92 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
93 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
94 | -I$(CURDIR)/$(BUILD)
95 |
96 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
97 |
98 | icons := $(wildcard *.bmp)
99 |
100 | ifneq (,$(findstring $(TARGET).bmp,$(icons)))
101 | export GAME_ICON := $(CURDIR)/$(TARGET).bmp
102 | else
103 | ifneq (,$(findstring icon.bmp,$(icons)))
104 | export GAME_ICON := $(CURDIR)/icon.bmp
105 | endif
106 | endif
107 |
108 | export GAME_TITLE := $(TARGET)
109 |
110 | .PHONY: bootloader bootstub clean arm7/$(TARGET).elf arm9/$(TARGET).elf
111 |
112 | all: bootloader bootstub $(TARGET).nds
113 |
114 | dist: all
115 | @rm -fr hbmenu
116 | @mkdir hbmenu
117 | @cp $(TARGET).nds hbmenu/BOOT.NDS
118 | @cp BootStrap/_BOOT_MP.NDS BootStrap/TTMENU.DAT BootStrap/_DS_MENU.DAT BootStrap/ez5sys.bin BootStrap/akmenu4.nds hbmenu
119 | @tar -cvjf $(TARGET)-$(VERSION).tar.bz2 hbmenu testfiles README.html COPYING hbmenu -X exclude.lst
120 |
121 | $(TARGET).nds: $(TARGET).arm7 $(TARGET).arm9
122 | ndstool -c $(TARGET).nds -7 $(TARGET).arm7.elf -9 $(TARGET).arm9.elf \
123 | -g HBBA 01 "BUTTONBOOT" -z 80040000 -u 00030004 -a 00000143 -b icon.bmp "ButtonBoot;FlameKat53, Epicpkmn11"
124 |
125 | $(TARGET).arm7: arm7/$(TARGET).elf
126 | cp arm7/$(TARGET).elf $(TARGET).arm7.elf
127 |
128 | $(TARGET).arm9: arm9/$(TARGET).elf
129 | cp arm9/$(TARGET).elf $(TARGET).arm9.elf
130 |
131 | #---------------------------------------------------------------------------------
132 | arm7/$(TARGET).elf:
133 | @$(MAKE) -C arm7
134 |
135 | #---------------------------------------------------------------------------------
136 | arm9/$(TARGET).elf:
137 | @$(MAKE) -C arm9
138 |
139 | #---------------------------------------------------------------------------------
140 | #$(BUILD):
141 | #@[ -d $@ ] || mkdir -p $@
142 | #@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
143 | #---------------------------------------------------------------------------------
144 | clean:
145 | @echo clean ...
146 | @rm -fr data
147 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds
148 | @rm -fr $(TARGET).arm7.elf
149 | @rm -fr $(TARGET).arm9.elf
150 | @$(MAKE) -C bootloader clean
151 | @$(MAKE) -C bootstub clean
152 | @$(MAKE) -C arm9 clean
153 | @$(MAKE) -C arm7 clean
154 |
155 | data:
156 | @mkdir -p data
157 |
158 | bootloader: data
159 | @$(MAKE) -C bootloader
160 |
161 | bootstub: data
162 | @$(MAKE) -C bootstub
163 |
164 | #---------------------------------------------------------------------------------
165 | else
166 |
167 | #---------------------------------------------------------------------------------
168 | # main targets
169 | #---------------------------------------------------------------------------------
170 | #$(OUTPUT).nds : $(OUTPUT).elf
171 | #$(OUTPUT).elf : $(OFILES)
172 |
173 | #---------------------------------------------------------------------------------
174 | %.bin.o : %.bin
175 | #---------------------------------------------------------------------------------
176 | @echo $(notdir $<)
177 | $(bin2o)
178 |
179 | #---------------------------------------------------------------------------------
180 | # This rule creates assembly source files using grit
181 | # grit takes an image file and a .grit describing how the file is to be processed
182 | # add additional rules like this for each image extension
183 | # you use in the graphics folders
184 | #---------------------------------------------------------------------------------
185 | %.s %.h : %.bmp %.grit
186 | #---------------------------------------------------------------------------------
187 | grit $< -fts -o$*
188 |
189 |
190 | #---------------------------------------------------------------------------------
191 | %.s %.h : %.png %.grit
192 | #---------------------------------------------------------------------------------
193 | grit $< -fts -o$*
194 |
195 | -include $(DEPSDIR)/*.d
196 |
197 | #---------------------------------------------------------------------------------------
198 | endif
199 | #---------------------------------------------------------------------------------------
200 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/arm7/Makefile:
--------------------------------------------------------------------------------
1 |
2 | export ARM7_MAJOR := 0
3 | export ARM7_MINOR := 6
4 | export ARM7_PATCH := 0
5 |
6 | VERSTRING := $(ARM7_MAJOR).$(ARM7_MINOR).$(ARM7_PATCH)
7 | #---------------------------------------------------------------------------------
8 | .SUFFIXES:
9 | #---------------------------------------------------------------------------------
10 | ifeq ($(strip $(DEVKITARM)),)
11 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM)
12 | endif
13 |
14 | include $(DEVKITARM)/ds_rules
15 | #---------------------------------------------------------------------------------
16 | # TARGET is the name of the output
17 | # BUILD is the directory where object files & intermediate files will be placed
18 | # SOURCES is a list of directories containing source code
19 | # INCLUDES is a list of directories containing extra header files
20 | #---------------------------------------------------------------------------------
21 | TARGET := ButtonBoot
22 | BUILD := build
23 | SOURCES := source
24 | INCLUDES := include build
25 |
26 | #---------------------------------------------------------------------------------
27 | # options for code generation
28 | #---------------------------------------------------------------------------------
29 | ARCH := -march=armv4t -mthumb -mthumb-interwork
30 |
31 | CFLAGS := -g -Wall -O2\
32 | -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
33 | -ffast-math \
34 | $(ARCH)
35 |
36 | CFLAGS += $(INCLUDE) -DARM7
37 |
38 | ASFLAGS := -g $(ARCH)
39 | LDFLAGS = -specs=ds_arm7.specs -g $(ARCH) -Wl,--nmagic -Wl,-Map,$(notdir $*).map
40 |
41 |
42 | #---------------------------------------------------------------------------------
43 | # any extra libraries we wish to link with the project
44 | #---------------------------------------------------------------------------------
45 | LIBS := -lnds7
46 |
47 |
48 | #---------------------------------------------------------------------------------
49 | # list of directories containing libraries, this must be the top level containing
50 | # include and lib
51 | #---------------------------------------------------------------------------------
52 | LIBDIRS := $(LIBNDS)
53 |
54 |
55 | #---------------------------------------------------------------------------------
56 | # no real need to edit anything past this point unless you need to add additional
57 | # rules for different file extensions
58 | #---------------------------------------------------------------------------------
59 | ifneq ($(BUILD),$(notdir $(CURDIR)))
60 | #---------------------------------------------------------------------------------
61 |
62 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
63 |
64 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
65 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
66 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
67 |
68 | export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
69 |
70 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
71 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
72 | -I$(CURDIR)/$(BUILD)
73 |
74 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
75 |
76 | export DEPSDIR := $(CURDIR)/$(BUILD)
77 |
78 | export OUTPUT := $(CURDIR)/$(TARGET)
79 |
80 | #---------------------------------------------------------------------------------
81 | # use CXX for linking C++ projects, CC for standard C
82 | #---------------------------------------------------------------------------------
83 | ifeq ($(strip $(CPPFILES)),)
84 | #---------------------------------------------------------------------------------
85 | export LD := $(CC)
86 | #---------------------------------------------------------------------------------
87 | else
88 | #---------------------------------------------------------------------------------
89 | export LD := $(CXX)
90 | #---------------------------------------------------------------------------------
91 | endif
92 | #---------------------------------------------------------------------------------
93 |
94 | .PHONY: all $(BUILD) clean
95 |
96 | all : $(BUILD)
97 |
98 | #---------------------------------------------------------------------------------
99 | $(BUILD):
100 | @[ -d $@ ] || mkdir -p $@
101 | @$(MAKE) -C $(BUILD) -f $(CURDIR)/Makefile
102 |
103 |
104 | #---------------------------------------------------------------------------------
105 | dist: all
106 | #---------------------------------------------------------------------------------
107 | @tar --exclude=*CVS* --exclude=.svn -cvjf default_arm7-src-$(VERSTRING).tar.bz2 source Makefile
108 | @tar -cvjf default_arm7-$(VERSTRING).tar.bz2 default.elf
109 |
110 | #---------------------------------------------------------------------------------
111 | install: all
112 | #---------------------------------------------------------------------------------
113 | cp $(TARGET).elf $(LIBNDS)
114 |
115 | #---------------------------------------------------------------------------------
116 | clean:
117 | @echo clean ...
118 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).arm7
119 |
120 |
121 | #---------------------------------------------------------------------------------
122 | else
123 |
124 | DEPENDS := $(OFILES:.o=.d)
125 |
126 | #---------------------------------------------------------------------------------
127 | # main targets
128 | #---------------------------------------------------------------------------------
129 |
130 | $(OUTPUT).elf : $(OFILES) $(LIBNDS)/lib/libnds7.a
131 |
132 | -include $(DEPENDS)
133 |
134 | #---------------------------------------------------------------------------------------
135 | endif
136 | #---------------------------------------------------------------------------------------
137 |
--------------------------------------------------------------------------------
/arm7/source/main.c:
--------------------------------------------------------------------------------
1 |
2 | /*---------------------------------------------------------------------------------
3 | default ARM7 core
4 | Copyright (C) 2005 - 2010
5 | Michael Noland (joat)
6 | Jason Rogers (dovoto)
7 | Dave Murphy (WinterMute)
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 | Permission is granted to anyone to use this software for any
12 | purpose, including commercial applications, and to alter it and
13 | redistribute it freely, subject to the following restrictions:
14 | 1. The origin of this software must not be misrepresented; you
15 | must not claim that you wrote the original software. If you use
16 | this software in a product, an acknowledgment in the product
17 | documentation would be appreciated but is not required.
18 | 2. Altered source versions must be plainly marked as such, and
19 | must not be misrepresented as being the original software.
20 | 3. This notice may not be removed or altered from any source
21 | distribution.
22 | ---------------------------------------------------------------------------------*/
23 | #include
24 |
25 | //---------------------------------------------------------------------------------
26 | void VblankHandler(void) {
27 | //---------------------------------------------------------------------------------
28 | }
29 |
30 | //---------------------------------------------------------------------------------
31 | void VcountHandler() {
32 | //---------------------------------------------------------------------------------
33 | inputGetAndSend();
34 | }
35 |
36 | volatile bool exitflag = false;
37 |
38 | //---------------------------------------------------------------------------------
39 | void powerButtonCB() {
40 | //---------------------------------------------------------------------------------
41 | exitflag = true;
42 | }
43 |
44 | //---------------------------------------------------------------------------------
45 | int main() {
46 | //---------------------------------------------------------------------------------
47 | nocashMessage("ARM7 main.c main");
48 |
49 | // clear sound registers
50 | dmaFillWords(0, (void*)0x04000400, 0x100);
51 |
52 | REG_SOUNDCNT |= SOUND_ENABLE;
53 | writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP );
54 | powerOn(POWER_SOUND);
55 |
56 | ledBlink(0);
57 |
58 | irqInit();
59 |
60 | fifoInit();
61 |
62 | SetYtrigger(80);
63 |
64 | installSystemFIFO();
65 |
66 | irqSet(IRQ_VCOUNT, VcountHandler);
67 | irqSet(IRQ_VBLANK, VblankHandler);
68 |
69 | irqEnable( IRQ_VBLANK | IRQ_VCOUNT );
70 |
71 | setPowerButtonCB(powerButtonCB);
72 |
73 | // Keep the ARM7 mostly idle
74 | while (!exitflag) {
75 | // fifocheck();
76 | swiWaitForVBlank();
77 | }
78 | return 0;
79 | }
80 |
--------------------------------------------------------------------------------
/arm9/Makefile:
--------------------------------------------------------------------------------
1 |
2 | #---------------------------------------------------------------------------------
3 | .SUFFIXES:
4 | #---------------------------------------------------------------------------------
5 |
6 | ifeq ($(strip $(DEVKITARM)),)
7 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM")
8 | endif
9 |
10 | include $(DEVKITARM)/ds_rules
11 |
12 | #---------------------------------------------------------------------------------
13 | # TARGET is the name of the output
14 | # BUILD is the directory where object files & intermediate files will be placed
15 | # SOURCES is a list of directories containing source code
16 | # INCLUDES is a list of directories containing extra header files
17 | # DATA is a list of directories containing binary files embedded using bin2o
18 | # GRAPHICS is a list of directories containing image files to be converted with grit
19 | # MAXMOD_SOUNDBANK contains a directory of music and sound effect files
20 | #---------------------------------------------------------------------------------
21 | TARGET := ButtonBoot
22 | BUILD := build
23 | SOURCES := source source/common
24 | INCLUDES := include
25 | DATA := ../data
26 |
27 | #---------------------------------------------------------------------------------
28 | # options for code generation
29 | #---------------------------------------------------------------------------------
30 | ARCH := -mthumb -mthumb-interwork
31 |
32 | CFLAGS := -g -Wall -O2\
33 | -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
34 | -ffast-math \
35 | $(ARCH)
36 |
37 | CFLAGS += $(INCLUDE) -DARM9
38 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
39 |
40 | ASFLAGS := -g $(ARCH)
41 | LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
42 |
43 | #---------------------------------------------------------------------------------
44 | # any extra libraries we wish to link with the project (order is important)
45 | #---------------------------------------------------------------------------------
46 | LIBS := -lfat -lnds9
47 |
48 |
49 | #---------------------------------------------------------------------------------
50 | # list of directories containing libraries, this must be the top level containing
51 | # include and lib
52 | #---------------------------------------------------------------------------------
53 | LIBDIRS := $(CURDIR) ../ $(LIBNDS)
54 |
55 | #---------------------------------------------------------------------------------
56 | # no real need to edit anything past this point unless you need to add additional
57 | # rules for different file extensions
58 | #---------------------------------------------------------------------------------
59 | ifneq ($(BUILD),$(notdir $(CURDIR)))
60 | #---------------------------------------------------------------------------------
61 |
62 | export OUTPUT := $(CURDIR)/$(TARGET)
63 |
64 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
65 | $(foreach dir,$(DATA),$(CURDIR)/$(dir))
66 |
67 | export DEPSDIR := $(CURDIR)/$(BUILD)
68 |
69 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
70 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
71 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
72 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
73 |
74 | #---------------------------------------------------------------------------------
75 | # use CXX for linking C++ projects, CC for standard C
76 | #---------------------------------------------------------------------------------
77 | ifeq ($(strip $(CPPFILES)),)
78 | #---------------------------------------------------------------------------------
79 | export LD := $(CC)
80 | #---------------------------------------------------------------------------------
81 | else
82 | #---------------------------------------------------------------------------------
83 | export LD := $(CXX)
84 | #---------------------------------------------------------------------------------
85 | endif
86 | #---------------------------------------------------------------------------------
87 |
88 | export OFILES := $(addsuffix .o,$(BINFILES)) \
89 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
90 |
91 | export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
92 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
93 | -I$(CURDIR)/$(BUILD)
94 |
95 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
96 |
97 |
98 | export OUTPUT := $(CURDIR)/$(TARGET)
99 |
100 | .PHONY: $(BUILD) clean
101 |
102 | all : $(BUILD)
103 |
104 | #---------------------------------------------------------------------------------
105 | $(BUILD):
106 | @[ -d $@ ] || mkdir -p $@
107 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
108 | #---------------------------------------------------------------------------------
109 | clean:
110 | @echo clean ...
111 | @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds *.bin
112 |
113 | #---------------------------------------------------------------------------------
114 | else
115 |
116 | DEPENDS := $(OFILES:.o=.d)
117 |
118 | #---------------------------------------------------------------------------------
119 | # main targets
120 | #---------------------------------------------------------------------------------
121 | $(OUTPUT).elf : $(OFILES)
122 |
123 | #---------------------------------------------------------------------------------
124 | %.bin.o : %.bin
125 | #---------------------------------------------------------------------------------
126 | @echo $(notdir $<)
127 | $(bin2o)
128 |
129 | #---------------------------------------------------------------------------------
130 | # This rule creates assembly source files using grit
131 | # grit takes an image file and a .grit describing how the file is to be processed
132 | # add additional rules like this for each image extension
133 | # you use in the graphics folders
134 | #---------------------------------------------------------------------------------
135 | %.s %.h : %.bmp %.grit
136 | #---------------------------------------------------------------------------------
137 | grit $< -fts -o$*
138 |
139 |
140 | #---------------------------------------------------------------------------------
141 | %.s %.h : %.png %.grit
142 | #---------------------------------------------------------------------------------
143 | grit $< -fts -o$*
144 |
145 | -include $(DEPSDIR)/*.d
146 |
147 | #---------------------------------------------------------------------------------------
148 | endif
149 | #---------------------------------------------------------------------------------------
150 |
--------------------------------------------------------------------------------
/arm9/source/common/inifile.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | inifile.cpp
3 | Copyright (C) 2007 Acekard, www.acekard.com
4 | Copyright (C) 2007-2009 somebody
5 | Copyright (C) 2009 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 | #include
19 | #include
20 | #include "inifile.h"
21 | #include "stringtool.h"
22 |
23 | static bool freadLine(FILE* f,std::string& str)
24 | {
25 | str.clear();
26 | __read:
27 | char p=0;
28 |
29 | size_t readed=fread(&p,1,1,f);
30 | if(0==readed)
31 | {
32 | str="";
33 | return false;
34 | }
35 | if('\n'==p||'\r'==p)
36 | {
37 | str="";
38 | return true;
39 | }
40 |
41 | while(p!='\n'&&p!='\r'&&readed)
42 | {
43 | str+=p;
44 | readed=fread(&p,1,1,f);
45 | }
46 |
47 | if(str.empty()||""==str)
48 | {
49 | goto __read;
50 | }
51 |
52 | return true;
53 | }
54 |
55 | static void trimString(std::string& str)
56 | {
57 | size_t first=str.find_first_not_of(" \t"),last;
58 | if(first==str.npos)
59 | {
60 | str="";
61 | }
62 | else
63 | {
64 | last=str.find_last_not_of(" \t");
65 | if(first>0||(last+1)0)
88 | {
89 | m_FileContainer.clear();
90 | }
91 | }
92 |
93 | void CIniFile::SetString(const std::string& Section,const std::string& Item,const std::string& Value)
94 | {
95 | if(GetFileString(Section,Item)!=Value)
96 | {
97 | SetFileString(Section,Item,Value);
98 | m_bModified=true;
99 | }
100 | }
101 |
102 | void CIniFile::SetInt(const std::string& Section,const std::string& Item,int Value)
103 | {
104 | std::string strtemp=formatString("%d",Value);
105 |
106 | if(GetFileString(Section,Item)!=strtemp)
107 | {
108 | SetFileString(Section,Item,strtemp);
109 | m_bModified=true;
110 | }
111 | }
112 |
113 | std::string CIniFile::GetString(const std::string& Section,const std::string& Item)
114 | {
115 | return GetFileString(Section,Item);
116 | }
117 |
118 | std::string CIniFile::GetString(const std::string& Section,const std::string& Item,const std::string& DefaultValue)
119 | {
120 | std::string temp=GetString(Section,Item);
121 | if(!m_bLastResult)
122 | {
123 | SetString(Section,Item,DefaultValue);
124 | temp=DefaultValue;
125 | }
126 | return temp;
127 | }
128 |
129 | void CIniFile::GetStringVector(const std::string& Section,const std::string& Item,std::vector< std::string >& strings,char delimiter)
130 | {
131 | std::string strValue=GetFileString(Section,Item);
132 | strings.clear();
133 | size_t pos;
134 | while((pos=strValue.find(delimiter),strValue.npos!=pos))
135 | {
136 | const std::string string=strValue.substr(0,pos);
137 | if(string.length())
138 | {
139 | strings.push_back(string);
140 | }
141 | strValue=strValue.substr(pos+1,strValue.npos);
142 | }
143 | if(strValue.length())
144 | {
145 | strings.push_back(strValue);
146 | }
147 | }
148 |
149 | void CIniFile::SetStringVector(const std::string& Section,const std::string& Item,std::vector& strings,char delimiter)
150 | {
151 | std::string strValue;
152 | for(size_t ii=0;ii2&&'0'==value[0]&&('x'==value[1]||'X'==value[1]))
164 | return strtol(value.c_str(),NULL,16);
165 | else
166 | return strtol(value.c_str(),NULL,10);
167 | }
168 |
169 | int CIniFile::GetInt(const std::string& Section,const std::string& Item,int DefaultValue)
170 | {
171 | int temp;
172 | temp=GetInt(Section,Item);
173 | if(!m_bLastResult)
174 | {
175 | SetInt(Section,Item,DefaultValue);
176 | temp=DefaultValue;
177 | }
178 | return temp;
179 | }
180 |
181 | bool CIniFile::LoadIniFile(const std::string& FileName)
182 | {
183 | //dbg_printf("load %s\n",FileName.c_str());
184 | if(FileName!="") m_sFileName=FileName;
185 |
186 | FILE* f=fopen(FileName.c_str(),"rb");
187 |
188 | if(NULL==f) return false;
189 |
190 | //check for utf8 bom.
191 | char bom[3];
192 | if(fread(bom,3,1,f)==1&&bom[0]==0xef&&bom[1]==0xbb&&bom[2]==0xbf) ;
193 | else fseek(f,0,SEEK_SET);
194 |
195 | std::string strline("");
196 | m_FileContainer.clear();
197 |
198 | while(freadLine(f,strline))
199 | {
200 | trimString(strline);
201 | if(strline!=""&&';'!=strline[0]&&'/'!=strline[0]&&'!'!=strline[0]) m_FileContainer.push_back(strline);
202 | }
203 |
204 | fclose(f);
205 |
206 | m_bLastResult=false;
207 | m_bModified=false;
208 |
209 | return true;
210 | }
211 |
212 | bool CIniFile::SaveIniFileModified(const std::string& FileName)
213 | {
214 | if(m_bModified==true)
215 | {
216 | return SaveIniFile(FileName);
217 | }
218 |
219 | return true;
220 | }
221 |
222 | bool CIniFile::SaveIniFile(const std::string& FileName)
223 | {
224 | if(FileName!="")
225 | m_sFileName=FileName;
226 |
227 | FILE* f=fopen(m_sFileName.c_str(),"wb");
228 | if(NULL==f)
229 | {
230 | return false;
231 | }
232 |
233 | for(size_t ii=0;ii0)
239 | {
240 | if(!m_FileContainer[ii-1].empty()&&m_FileContainer[ii-1]!="")
241 | fwrite("\r\n",1,2,f);
242 | }
243 | if(!strline.empty()&&strline!="")
244 | {
245 | fwrite(strline.c_str(),1,strline.length(),f);
246 | fwrite("\r\n",1,2,f);
247 | }
248 | }
249 |
250 | fclose(f);
251 |
252 | m_bModified=false;
253 |
254 | return true;
255 | }
256 |
257 | std::string CIniFile::GetFileString(const std::string& Section,const std::string& Item)
258 | {
259 | std::string strline;
260 | std::string strSection;
261 | std::string strItem;
262 | std::string strValue;
263 |
264 | size_t ii=0;
265 | size_t iFileLines=m_FileContainer.size();
266 |
267 | if(m_bReadOnly)
268 | {
269 | cSectionCache::iterator it=m_Cache.find(Section);
270 | if((it!=m_Cache.end())) ii=it->second;
271 | }
272 |
273 | m_bLastResult=false;
274 |
275 | if(iFileLines>=0)
276 | {
277 | while(ii0&&rBracketPos!=std::string::npos)
284 | {
285 | strSection=strline.substr(1,rBracketPos-1);
286 | if(m_bReadOnly) m_Cache.insert(std::make_pair(strSection,ii-1));
287 | if(strSection==Section)
288 | {
289 | while(ii0&&rBracketPos!=std::string::npos)
339 | {
340 | strSection=strline.substr(1,rBracketPos-1);
341 | if(strSection==Section)
342 | {
343 | while(ii.
16 | */
17 |
18 | #ifndef _INIFILE_H_
19 | #define _INIFILE_H_
20 |
21 | #include
22 | #include
23 | #include