Add DSi-Only screen

This commit is contained in:
RocketRobz 2020-12-02 23:32:18 -07:00
parent 149d0d42df
commit 97d56cd327
7 changed files with 95 additions and 1 deletions

View File

@ -18,7 +18,7 @@ BUILD := build
SOURCES := source SOURCES := source
INCLUDES := include INCLUDES := include
DATA := DATA :=
GRAPHICS := ../gfx
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation
@ -59,12 +59,14 @@ export ARM9ELF := $(CURDIR)/$(TARGET).elf
export DEPSDIR := $(CURDIR)/$(BUILD) export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) $(foreach dir,$(DATA),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 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 # use CXX for linking C++ projects, CC for standard C
@ -81,6 +83,7 @@ endif
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \ export OFILES := $(addsuffix .o,$(BINFILES)) \
$(PNGFILES:.png=.o) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
@ -120,6 +123,17 @@ $(ARM9ELF) : $(OFILES)
@echo $(notdir $<) @echo $(notdir $<)
@$(bin2o) @$(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 -include $(DEPSDIR)/*.d
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------

View File

@ -244,6 +244,9 @@ int verifyNocashFooter(nocash_footer_t *footer){
} }
int main(void) { int main(void) {
extern void dsiOnly(void);
dsiOnly();
consoleDemoInit(); consoleDemoInit();
iprintf("SafeNANDManager v1.0\n"); iprintf("SafeNANDManager v1.0\n");
iprintf("by Rocket Robz\n"); iprintf("by Rocket Robz\n");

53
arm9/source/dsi_only.c Normal file
View File

@ -0,0 +1,53 @@
#include <nds.h>
#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();
}
}

12
gfx/dsiOnly_bot.grit Normal file
View File

@ -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

BIN
gfx/dsiOnly_bot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

12
gfx/dsiOnly_top.grit Normal file
View File

@ -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

BIN
gfx/dsiOnly_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB