diff --git a/arm9/Makefile b/arm9/Makefile index afa7625..40b5f66 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -18,7 +18,7 @@ BUILD := build SOURCES := source INCLUDES := include DATA := - +GRAPHICS := ../gfx #--------------------------------------------------------------------------------- # options for code generation @@ -59,12 +59,14 @@ export ARM9ELF := $(CURDIR)/$(TARGET).elf export DEPSDIR := $(CURDIR)/$(BUILD) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ + $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) +PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C @@ -81,6 +83,7 @@ endif #--------------------------------------------------------------------------------- export OFILES := $(addsuffix .o,$(BINFILES)) \ + $(PNGFILES:.png=.o) \ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ @@ -120,6 +123,17 @@ $(ARM9ELF) : $(OFILES) @echo $(notdir $<) @$(bin2o) +#--------------------------------------------------------------------------------- +# This rule creates assembly source files using grit +# grit takes an image file and a .grit describing how the file is to be processed +# add additional rules like this for each image extension +# you use in the graphics folders +#--------------------------------------------------------------------------------- +%.s %.h : %.png %.grit +#--------------------------------------------------------------------------------- + grit $< -fts -o$* + + -include $(DEPSDIR)/*.d #--------------------------------------------------------------------------------------- diff --git a/arm9/source/arm9.c b/arm9/source/arm9.c index c55a5e3..2d124ec 100644 --- a/arm9/source/arm9.c +++ b/arm9/source/arm9.c @@ -244,6 +244,9 @@ int verifyNocashFooter(nocash_footer_t *footer){ } int main(void) { + extern void dsiOnly(void); + dsiOnly(); + consoleDemoInit(); iprintf("SafeNANDManager v1.0\n"); iprintf("by Rocket Robz\n"); diff --git a/arm9/source/dsi_only.c b/arm9/source/dsi_only.c new file mode 100644 index 0000000..7dd7c69 --- /dev/null +++ b/arm9/source/dsi_only.c @@ -0,0 +1,53 @@ +#include +#include "dsiOnly_top.h" +#include "dsiOnly_bot.h" + +static void dsiOnly_setBrightness(u8 screen, s8 bright) { + u16 mode = 1 << 14; + + if (bright < 0) { + mode = 2 << 14; + bright = -bright; + } + if (bright > 31) { + bright = 31; + } + *(u16*)(0x0400006C + (0x1000 * screen)) = bright + mode; +} + +void dsiOnly(void) { + if (isDSiMode()) return; // Proceed running on DSi + + *(u16*)0x0400006C |= BIT(14); + *(u16*)0x0400006C &= BIT(15); + dsiOnly_setBrightness(0, 31); + dsiOnly_setBrightness(1, 31); + + videoSetMode(MODE_4_2D); + videoSetModeSub(MODE_4_2D); + + vramSetBankA(VRAM_A_MAIN_BG); + vramSetBankB(VRAM_B_MAIN_BG); + vramSetBankC(VRAM_C_SUB_BG); + vramSetBankD(VRAM_D_LCD); + + // Display DSi Only screen + int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 1, 0); + decompress(dsiOnly_topBitmap, bgGetGfxPtr(bg3), LZ77Vram); + for (int i = 0; i < 16; i++) { + BG_PALETTE[i] = dsiOnly_topPal[i]; + } + + int bg3sub = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 1, 0); + decompress(dsiOnly_botBitmap, bgGetGfxPtr(bg3sub), LZ77Vram); + for (int i = 0; i < 16; i++) { + BG_PALETTE_SUB[i] = dsiOnly_botPal[i]; + } + + dsiOnly_setBrightness(0, 0); + dsiOnly_setBrightness(1, 0); + + while (1) { + swiWaitForVBlank(); + } +} \ No newline at end of file diff --git a/gfx/dsiOnly_bot.grit b/gfx/dsiOnly_bot.grit new file mode 100644 index 0000000..f5287cb --- /dev/null +++ b/gfx/dsiOnly_bot.grit @@ -0,0 +1,12 @@ +-W3 +#bitmap mode +-gb + +# disable alpha and set opaque bit for all pixels +-gT! + +# use lz77 compression +-gzl + +# Set the bit depth to 8 +-gB8 diff --git a/gfx/dsiOnly_bot.png b/gfx/dsiOnly_bot.png new file mode 100644 index 0000000..717c980 Binary files /dev/null and b/gfx/dsiOnly_bot.png differ diff --git a/gfx/dsiOnly_top.grit b/gfx/dsiOnly_top.grit new file mode 100644 index 0000000..f5287cb --- /dev/null +++ b/gfx/dsiOnly_top.grit @@ -0,0 +1,12 @@ +-W3 +#bitmap mode +-gb + +# disable alpha and set opaque bit for all pixels +-gT! + +# use lz77 compression +-gzl + +# Set the bit depth to 8 +-gB8 diff --git a/gfx/dsiOnly_top.png b/gfx/dsiOnly_top.png new file mode 100644 index 0000000..8a1129a Binary files /dev/null and b/gfx/dsiOnly_top.png differ