Added basic support for configuring the brightness level for the built-in screen init

This commit is contained in:
Aurora 2016-04-05 02:20:05 +02:00
parent bb437f6f7b
commit 6f8a9421ef
7 changed files with 30 additions and 13 deletions

View File

@ -59,7 +59,7 @@ $(dir_out)/$(name).dat: $(dir_build)/main.bin $(dir_out)
@dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144 @dd if=$(dir_build)/main.bin of=$@ bs=512 seek=144
$(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out) $(dir_out)/arm9loaderhax.bin: $(dir_build)/main.bin $(dir_out)
@cp -av $(dir_build)/main.bin $@ @cp -a $(dir_build)/main.bin $@
$(dir_out)/3ds/$(name): $(dir_out) $(dir_out)/3ds/$(name): $(dir_out)
@mkdir -p "$(dir_out)/3ds/$(name)" @mkdir -p "$(dir_out)/3ds/$(name)"

View File

@ -129,14 +129,14 @@ memcpy32: ; memcpy32(void *src, void *dst, unsigned int size)
bytes_read: .word 0 bytes_read: .word 0
fopen: .ascii "OPEN" fopen: .ascii "OPEN"
.pool .pool
firm_fname: .dcw "sdmc:/aurei/patched_firmware_sys.bin" firm_fname: .dcw "sdmc:/aurei/patched_firmware_sys.bin"
.word 0x0 .word 0x0
.pool .pool
twlfirm_fname: .dcw "sdmc:/aurei/patched_firmware_twl.bin" twlfirm_fname: .dcw "sdmc:/aurei/patched_firmware_twl.bin"
.word 0x0 .word 0x0
.pool .pool
agbfirm_fname: .dcw "sdmc:/aurei/patched_firmware_agb.bin" agbfirm_fname: .dcw "sdmc:/aurei/patched_firmware_agb.bin"
.word 0x0 .word 0x0
.align 4 .align 4
kernelcode_start: kernelcode_start:

View File

@ -2,13 +2,15 @@
void main(void) void main(void)
{ {
const u32 brightness[4] = {0x5F, 0x4C, 0x39, 0x26};
u32 brightnessLevel = *(vu32 *)0x24F04000;
vu32 *const arm11 = (u32 *)0x1FFFFFF8; vu32 *const arm11 = (u32 *)0x1FFFFFF8;
*(vu32 *)0x10141200 = 0x1007F; *(vu32 *)0x10141200 = 0x1007F;
*(vu32 *)0x10202014 = 0x00000001; *(vu32 *)0x10202014 = 0x00000001;
*(vu32 *)0x1020200C &= 0xFFFEFFFE; *(vu32 *)0x1020200C &= 0xFFFEFFFE;
*(vu32 *)0x10202240 = 0x45; *(vu32 *)0x10202240 = brightness[brightnessLevel];
*(vu32 *)0x10202A40 = 0x45; *(vu32 *)0x10202A40 = brightness[brightnessLevel];
*(vu32 *)0x10202244 = 0x1023E; *(vu32 *)0x10202244 = 0x1023E;
*(vu32 *)0x10202A44 = 0x1023E; *(vu32 *)0x10202A44 = 0x1023E;

View File

@ -38,8 +38,8 @@ static u32 firmSize,
selectedFirm, selectedFirm,
usePatchedFirm, usePatchedFirm,
emuOffset, emuOffset,
emuHeader, emuHeader;
config; u32 config;
void setupCFW(void) void setupCFW(void)
{ {

View File

@ -50,6 +50,9 @@ void initScreens(void)
{ {
if(PDN_GPU_CNT == 1) if(PDN_GPU_CNT == 1)
{ {
//Write brightness level for the stub to pick up
*(vu32 *)0x24F04000 = (config >> 10) & 3;
memcpy((void *)SCREENINIT_ADDRESS, screeninit, screeninit_size); memcpy((void *)SCREENINIT_ADDRESS, screeninit, screeninit_size);
*arm11 = SCREENINIT_ADDRESS; *arm11 = SCREENINIT_ADDRESS;

View File

@ -13,5 +13,7 @@
#define PDN_GPU_CNT (*(vu8 *)0x10141200) #define PDN_GPU_CNT (*(vu8 *)0x10141200)
u32 config;
void deinitScreens(void); void deinitScreens(void);
void initScreens(void); void initScreens(void);

View File

@ -72,6 +72,8 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
for(u32 i = 0; i < optionsAmount; i++) for(u32 i = 0; i < optionsAmount; i++)
options[i].enabled = (tempConfig >> i) & 1; options[i].enabled = (tempConfig >> i) & 1;
options[optionsAmount].enabled = (tempConfig >> 10) & 3;
//Pre-select the first configuration option //Pre-select the first configuration option
u32 selectedOption = 0; u32 selectedOption = 0;
@ -81,12 +83,17 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
u16 pressed = 0; u16 pressed = 0;
do { do {
options[optionsAmount].posY = drawString("Screen-init brightness: 4( ) 3( ) 2( ) 1( )", 10, 53, selectedOption == optionsAmount ? COLOR_RED : COLOR_WHITE);
for(u32 i = 0; i < optionsAmount; i++) for(u32 i = 0; i < optionsAmount; i++)
{ {
options[i].posY = drawString(optionsText[i], 10, !i ? 60 : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE); options[i].posY = drawString(optionsText[i], 10, !i ? options[optionsAmount].posY + 2 * SPACING_Y : options[i - 1].posY + SPACING_Y, selectedOption == i ? COLOR_RED : COLOR_WHITE);
drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK); drawCharacter('x', 10 + SPACING_X, options[i].posY, options[i].enabled ? (selectedOption == i ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK);
} }
for(u32 i = 0; i < 4; i++)
drawCharacter('x', 10 + (26 + 5 * i) * SPACING_X, options[optionsAmount].posY, options[optionsAmount].enabled == i ? (selectedOption == optionsAmount ? COLOR_RED : COLOR_WHITE) : COLOR_BLACK);
pressed = waitInput(); pressed = waitInput();
} }
while(!(pressed & MENU_BUTTONS)); while(!(pressed & MENU_BUTTONS));
@ -94,10 +101,10 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
switch(pressed) switch(pressed)
{ {
case BUTTON_UP: case BUTTON_UP:
selectedOption = !selectedOption ? optionsAmount - 1 : selectedOption - 1; selectedOption = !selectedOption ? optionsAmount : selectedOption - 1;
break; break;
case BUTTON_DOWN: case BUTTON_DOWN:
selectedOption = selectedOption == optionsAmount - 1 ? 0 : selectedOption + 1; selectedOption = selectedOption >= optionsAmount - 1 ? 0 : selectedOption + 1;
break; break;
case BUTTON_LEFT: case BUTTON_LEFT:
selectedOption = 0; selectedOption = 0;
@ -106,7 +113,8 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
selectedOption = optionsAmount - 1; selectedOption = optionsAmount - 1;
break; break;
case BUTTON_A: case BUTTON_A:
options[selectedOption].enabled = !options[selectedOption].enabled; if(selectedOption != optionsAmount) options[selectedOption].enabled = !options[selectedOption].enabled;
else options[optionsAmount].enabled = options[optionsAmount].enabled == 3 ? 0 : options[optionsAmount].enabled + 1;
break; break;
} }
@ -126,6 +134,8 @@ void configureCFW(const char *configPath, const char *patchedFirms[])
for(u32 i = 0; i < optionsAmount; i++) for(u32 i = 0; i < optionsAmount; i++)
tempConfig |= options[i].enabled << i; tempConfig |= options[i].enabled << i;
tempConfig |= options[optionsAmount].enabled << 10;
fileWrite(&tempConfig, configPath, 3); fileWrite(&tempConfig, configPath, 3);
//Zero the last booted FIRM flag //Zero the last booted FIRM flag