Skip to content

Commit

Permalink
Added experimental support for true color correction to mimic the loo…
Browse files Browse the repository at this point in the history
…k of the crappy GBA LCD. Thanks to hunterk and Pokefan531 for their work on the libretro shaders this is based on.
  • Loading branch information
profi200 committed Jul 22, 2024
1 parent e7a6a72 commit bf079b7
Show file tree
Hide file tree
Showing 10 changed files with 542 additions and 16 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Video-related settings.
`float brightness` - Screen lift
* Default: `0.0`

`string colorProfile` - Color correction profile. `none`, `gba`, `nds` or `nds_white`.
* Default: `none`

### Audio
Audio settings.

Expand Down Expand Up @@ -255,8 +258,9 @@ You may use this under the terms of the GNU General Public License GPL v3 or the
* **MAME**
* **No-Intro**
* **Wolfvak, Sono and all the other people in #GodMode9 on freenode/Discord**
* **endrift, Extrems and all the other people in #mgba on freenode**
* **endrift, Extrems and all the other people in #mgba on Libera.Chat**
* **Oleh Prypin (oprypin) for nightly.link**
* **hunterk and Pokefan531 for their amazing libretro shaders**
* ...everyone who contributed to **3dbrew.org**

Copyright (C) 2021 derrek, profi200, d0k3
Copyright (C) 2024 derrek, profi200, d0k3
1 change: 1 addition & 0 deletions include/arm11/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct
float lcdGamma;
float contrast;
float brightness;
u8 colorProfile; // 0 = none, 1 = GBA, 2 = DS phat, 3 = DS phat white.

// [audio]
u8 audioOut; // 0 = auto, 1 = speakers, 2 = headphones.
Expand Down
33 changes: 33 additions & 0 deletions include/arm11/fast_frame_convert.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#pragma once

/*
* This file is part of open_agb_firm
* Copyright (C) 2024 profi200
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/



#ifdef __cplusplus
extern "C"
{
#endif

void convert160pFrameFast(void);
void convert240pFrameFast(void);

#ifdef __cplusplus
} // extern "C"
#endif
4 changes: 3 additions & 1 deletion include/arm11/gpu_cmd_lists.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern "C"
#endif

#define GPU_RENDER_BUF_ADDR (0x18180000)
#define GPU_TEXTURE_ADDR (0x18200000)
#define GPU_TEXTURE2_ADDR (0x18300000)
#define GBA_INIT_LIST_SIZE (1136)
#define GBA_LIST2_SIZE (448)

Expand All @@ -36,7 +38,7 @@ extern u8 gbaGpuList2[GBA_LIST2_SIZE];



void patchGbaGpuCmdList(u8 scaleType);
void patchGbaGpuCmdList(const u8 scaleType, const bool useSecondTexture);

#ifdef __cplusplus
} // extern "C"
Expand Down
2 changes: 1 addition & 1 deletion libraries/libn3ds
Submodule libn3ds updated 2 files
+12 −2 include/util.h
+13 −8 source/util.c
17 changes: 16 additions & 1 deletion source/arm11/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"gbaGamma=2.2\n" \
"lcdGamma=1.54\n" \
"contrast=1.0\n" \
"brightness=0.0\n\n" \
"brightness=0.0\n" \
"colorProfile=none\n\n" \
"[audio]\n" \
"audioOut=0\n" \
"volume=127\n\n" \
Expand All @@ -61,6 +62,7 @@ OafConfig g_oafConfig =
1.54f, // lcdGamma
1.f, // contrast
0.f, // brightness
0, // colorProfile

// [audio]
0, // Automatic audio output.
Expand Down Expand Up @@ -154,6 +156,19 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
config->contrast = str2float(value);
else if(strcmp(name, "brightness") == 0)
config->brightness = str2float(value);
else if(strcmp(name, "colorProfile") == 0)
{
if(strcmp(value, "none") == 0)
config->colorProfile = 0;
else if(strcmp(value, "gba") == 0)
config->colorProfile = 1;
else if(strcmp(value, "nds") == 0)
config->colorProfile = 2;
else if(strcmp(value, "nds_white") == 0)
config->colorProfile = 3;
//else if(strcmp(value, "custom") == 0) // TODO: Implement user provided profile.
// config->colorProfile = 4;
}
}
else if(strcmp(section, "audio") == 0)
{
Expand Down
Loading

0 comments on commit bf079b7

Please sign in to comment.