Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
!/tools/gba-db/gba_db.py
/tools/gba-db/gba.*
!/tools/gba-db/gba.csv
/open_agb_firm*.*
/open_agb_firm*.*
/ctr_firm_builder-master
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ General settings.
`bool useSavesFolder` - Use `/3ds/open_agb_firm/saves` for save files instead of the ROM directory.
* Default: `true`

`bool enableBacklightHotkeys` - Enables/disables the backlight adjustment hotkeys.
* Default: `true`

`bool enableScreenshotHotkey` - Enables/disables the hardware frame dump hotkey.
* Default: `true`

### Video
Video-related settings.

Expand Down Expand Up @@ -157,6 +163,38 @@ UP=UP,CP_UP
DOWN=DOWN,CP_DOWN
```

### Hotkeys
Hotkey input settings. These use the same formatting as regular inputs. Entries with multiple buttons are treated as button combos (all buttons must be pressed), unlike regular inputs.

`takeScreenshot` - Button map for dumping hardware frame output.
* Default: `SELECT,Y`

`backlightUp` - Button map for increasing screen brightness.
* Default: `X,UP`

`backlightDown` - Button map for decreasing screen brightness.
* Default: `X,DOWN`

`backlightOff` - Button map for turning off LCD backlight.
* Default: `X,LEFT`

`backlightOn` - Button map for turning on LCD backlight.
* Default: `X,RIGHT`

`skipPatching` - Button map for skipping patching upon game launch.
* Default: `X`

Notes: The general setting `enableBacklightHotkeys` must be set to `true` to use the backlight hotkeys. `enableScreenshotHotkey` must be `true` to dump hardware frames.

Example which maps Y + D-Pad to backlight controls:
```
[hotkeys]
backlightUp=Y,UP
backlightDown=Y,DOWN
backlightOff=Y,LEFT
backlightOn=Y,RIGHT
```

### Game
Game-specific settings. Only intended to be used in the per-game settings (romName.ini in `/3ds/open_agb_firm/saves`).

Expand Down Expand Up @@ -292,4 +330,4 @@ You may use this under the terms of the GNU General Public License GPL v3 or the
* **[hunterk and Pokefan531 for their amazing libretro shaders](https://forums.libretro.com/t/real-gba-and-ds-phat-colors/1540/220)**
* ...everyone who contributed to **3dbrew.org**

Copyright (C) 2024 derrek, profi200, d0k3
Copyright (C) 2024 derrek, profi200, d0k3
12 changes: 11 additions & 1 deletion include/arm11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ typedef struct
bool directBoot;
bool useGbaDb;
bool useSavesFolder;
bool enableBacklightHotkeys;
bool enableScreenshotHotkey;

// [video]
u8 scaler; // 0 = 1:1/none, 1 = bilinear (GPU) x1.5, 2 = matrix (hardware) x1.5.
Expand All @@ -56,6 +58,14 @@ typedef struct
// [input]
u32 buttonMaps[10]; // A, B, Select, Start, Right, Left, Up, Down, R, L.

// [hotkeys]
u32 takeScreenshot;
u32 backlightUp;
u32 backlightDown;
u32 backlightOff;
u32 backlightOn;
u32 skipPatching;

// [game]
u8 saveSlot;
u8 saveType;
Expand All @@ -73,4 +83,4 @@ Result parseOafConfig(const char *const path, OafConfig *cfg, const bool newCfgO

#ifdef __cplusplus
} // extern "C"
#endif
#endif
81 changes: 60 additions & 21 deletions source/arm11/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,28 @@


#define INI_BUF_SIZE (1024u)
#define DEFAULT_CONFIG "[general]\n" \
"backlight=64\n" \
"backlightSteps=5\n" \
"directBoot=false\n" \
"useGbaDb=true\n" \
"useSavesFolder=true\n\n" \
\
"[video]\n" \
"scaler=matrix\n" \
"colorProfile=none\n" \
"contrast=1.0\n" \
"brightness=0.0\n" \
"saturation=1.0\n\n" \
\
"[audio]\n" \
"audioOut=auto\n" \
"volume=127\n\n" \
\
"[advanced]\n" \
"saveOverride=false\n" \
#define DEFAULT_CONFIG "[general]\n" \
"backlight=64\n" \
"backlightSteps=5\n" \
"directBoot=false\n" \
"useGbaDb=true\n" \
"useSavesFolder=true\n" \
"enableBacklightHotkeys=true\n" \
"enableScreenshotHotkey=true\n\n" \
\
"[video]\n" \
"scaler=matrix\n" \
"colorProfile=none\n" \
"contrast=1.0\n" \
"brightness=0.0\n" \
"saturation=1.0\n\n" \
\
"[audio]\n" \
"audioOut=auto\n" \
"volume=127\n\n" \
\
"[advanced]\n" \
"saveOverride=false\n" \
"defaultSave=sram_256k"


Expand All @@ -59,6 +61,8 @@ OafConfig g_oafConfig =
false, // directBoot
true, // useGbaDb
true, // useSavesFolder
true, // enableBacklightHotkeys
true, // enableScreenshotHotkey

// [video]
2, // scaler
Expand All @@ -85,6 +89,14 @@ OafConfig g_oafConfig =
0 // L
},

// [hotkeys]
2052, // takeScreenshot (SELECT+Y, hex: 805)
1088, // backlightUp (X+UP, hex: 440)
1152, // backlightDown (X+DOWN, hex: 480)
1056, // backlightOff (X+LEFT, hex: 420)
1040, // backlightOn (X+RIGHT, hex: 410)
1024, // skipPatching (X, hex: 400)

// [game]
0, // saveSlot
255, // saveType
Expand Down Expand Up @@ -148,6 +160,10 @@ static int cfgIniCallback(void *user, const char *section, const char *name, con
config->useGbaDb = (strcmp(value, "true") == 0 ? true : false);
else if(strcmp(name, "useSavesFolder") == 0)
config->useSavesFolder = (strcmp(value, "true") == 0 ? true : false);
else if(strcmp(name, "enableBacklightHotkeys") == 0)
config->enableBacklightHotkeys = (strcmp(value, "true") == 0 ? true : false);
else if(strcmp(name, "enableScreenshotHotkey") == 0)
config->enableScreenshotHotkey = (strcmp(value, "true") == 0 ? true : false);
}
else if(strcmp(section, "video") == 0)
{
Expand Down Expand Up @@ -215,6 +231,29 @@ static int cfgIniCallback(void *user, const char *section, const char *name, con
config->buttonMaps[shift] = map;
}
}
else if(strcmp(section, "hotkeys") == 0)
{
// get the button (combo) set for this hotkey
const u32 map = parseButtons(value);

// if map isn't zero...
if (map != 0)
{
// set the mapping to its corrisponding variable based on name
if(strcmp(name, "takeScreenshot") == 0)
config->takeScreenshot = map;
else if(strcmp(name, "backlightUp") == 0)
config->backlightUp = map;
else if(strcmp(name, "backlightDown") == 0)
config->backlightDown = map;
else if(strcmp(name, "backlightOff") == 0)
config->backlightOff = map;
else if(strcmp(name, "backlightOn") == 0)
config->backlightOn = map;
else if(strcmp(name, "skipPatching") == 0)
config->skipPatching = map;
}
}
else if(strcmp(section, "game") == 0)
{
if(strcmp(name, "saveSlot") == 0)
Expand Down Expand Up @@ -320,4 +359,4 @@ Result parseOafConfig(const char *const path, OafConfig *cfg, const bool newCfgO
free(iniBuf);

return res;
}
}
6 changes: 3 additions & 3 deletions source/arm11/oaf_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ static void gbaGfxHandler(void *args)
GFX_waitForPPF();
GFX_swapBuffers();

// Trigger only if both are held and at least one is detected as newly pressed down.
if(hidKeysHeld() == (KEY_Y | KEY_SELECT) && hidKeysDown() != 0)
// Trigger only if enableScreenshotHotkey setting is true, and key(s) are held and at least one is detected as newly pressed down.
if (g_oafConfig.enableScreenshotHotkey && hidKeysHeld() == g_oafConfig.takeScreenshot && hidKeysDown() != 0)
dumpFrameTex();
}

Expand Down Expand Up @@ -516,4 +516,4 @@ void OAF_videoExit(void)
deleteEvent(g_convFinishedEvent);
g_convFinishedEvent = 0;
}
}
}
13 changes: 7 additions & 6 deletions source/arm11/open_agb_firm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ static void updateBacklight(void)
{
// Adjust LCD brightness up.
const s16 steps = g_oafConfig.backlightSteps;
if(kHeld == (KEY_X | KEY_DUP))
if(kHeld == g_oafConfig.backlightUp)
changeBacklight(steps);

// Adjust LCD brightness down.
if(kHeld == (KEY_X | KEY_DDOWN))
if(kHeld == g_oafConfig.backlightDown)
changeBacklight(-steps);

// Disable backlight switching in debug builds on 2DS.
Expand All @@ -145,14 +145,14 @@ static void updateBacklight(void)
#endif
{
// Turn off backlight.
if(backlightOn && kHeld == (KEY_X | KEY_DLEFT))
if(backlightOn && kHeld == g_oafConfig.backlightOff)
{
backlightOn = false;
GFX_powerOffBacklight(lcd);
}

// Turn on backlight.
if(!backlightOn && kHeld == (KEY_X | KEY_DRIGHT))
if(!backlightOn && kHeld == g_oafConfig.backlightOn)
{
backlightOn = true;
GFX_powerOnBacklight(lcd);
Expand Down Expand Up @@ -364,7 +364,8 @@ void oafUpdate(void)
LGY11_setInputState(pressed);

CODEC_runHeadphoneDetection();
updateBacklight();
if (g_oafConfig.enableBacklightHotkeys)
updateBacklight();
waitForEvent(g_frameReadyEvent);
clearEvent(g_frameReadyEvent);
}
Expand All @@ -375,4 +376,4 @@ void oafFinish(void)
OAF_videoExit();
g_frameReadyEvent = 0;
LGY11_deinit();
}
}
3 changes: 2 additions & 1 deletion source/arm11/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "oaf_error_codes.h"
#include "util.h"
#include "arm11/drivers/hid.h"
#include "arm11/config.h"
#include "drivers/lgy_common.h"
#include "arm11/fmt.h"
#include "fs.h"
Expand Down Expand Up @@ -240,7 +241,7 @@ Result patchRom(const char *const gamePath, u32 *romSize) {

//if X is held during launch, skip patching
hidScanInput();
if(hidKeysHeld() == KEY_X)
if(hidKeysHeld() == g_oafConfig.skipPatching)
return res;

//get base path for game with 'gba' extension removed
Expand Down