Skip to content

Instantly share code, notes, and snippets.

@SonoSooS
Created February 22, 2017 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SonoSooS/c56dd359d2c071c234bdf363840efef6 to your computer and use it in GitHub Desktop.
Save SonoSooS/c56dd359d2c071c234bdf363840efef6 to your computer and use it in GitHub Desktop.
Screen brightness setter for 3DS
#include <3ds.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
gfxInit(GSP_RGBA8_OES, GSP_RGBA8_OES, false);
PrintConsole console;
consoleInit(GFX_BOTTOM, &console);
int redraw = 1;
u32 kDown = 0;
u8 bri = 1;
u32 regtop = 0x202240;
u32 regbot = 0x202A40;
while(aptMainLoop())
{
hidScanInput();
kDown = hidKeysDown();
if(kDown & KEY_SELECT) break;
if(kDown & KEY_UP) bri++;
if(kDown & KEY_DOWN) bri--;
if(kDown & KEY_LEFT) bri-=0x10;
if(kDown & KEY_RIGHT) bri+=0x10;
if(kDown & KEY_X)
{
u32 dmy = bri;
GSPGPU_WriteHWRegs(regtop, &dmy, 4);
}
if(kDown & KEY_Y)
{
u32 dmy = bri;
GSPGPU_WriteHWRegs(regbot, &dmy, 4);
}
if(kDown) redraw = 1;
if(redraw)
{
console.cursorX = 0;
console.cursorY = 0;
u32 britop = 0xF00FCACE;
u32 bribot = 0xF00FCACE;
GSPGPU_ReadHWRegs(regtop, &britop, 4);
GSPGPU_ReadHWRegs(regbot, &bribot, 4);
printf("REG: %02X\nTOP: %02X\nBOT: %02X\n", bri, britop, bribot);
redraw = 0;
}
gspWaitForVBlank();
}
ded:
gfxExit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment