Skip to content

Commit bf079b7

Browse files
committed
Added experimental support for true color correction to mimic the look of the crappy GBA LCD. Thanks to hunterk and Pokefan531 for their work on the libretro shaders this is based on.
1 parent e7a6a72 commit bf079b7

File tree

10 files changed

+542
-16
lines changed

10 files changed

+542
-16
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Video-related settings.
7979
`float brightness` - Screen lift
8080
* Default: `0.0`
8181

82+
`string colorProfile` - Color correction profile. `none`, `gba`, `nds` or `nds_white`.
83+
* Default: `none`
84+
8285
### Audio
8386
Audio settings.
8487

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

262-
Copyright (C) 2021 derrek, profi200, d0k3
266+
Copyright (C) 2024 derrek, profi200, d0k3

include/arm11/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct
4646
float lcdGamma;
4747
float contrast;
4848
float brightness;
49+
u8 colorProfile; // 0 = none, 1 = GBA, 2 = DS phat, 3 = DS phat white.
4950

5051
// [audio]
5152
u8 audioOut; // 0 = auto, 1 = speakers, 2 = headphones.

include/arm11/fast_frame_convert.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
/*
4+
* This file is part of open_agb_firm
5+
* Copyright (C) 2024 profi200
6+
*
7+
* This program is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
23+
#ifdef __cplusplus
24+
extern "C"
25+
{
26+
#endif
27+
28+
void convert160pFrameFast(void);
29+
void convert240pFrameFast(void);
30+
31+
#ifdef __cplusplus
32+
} // extern "C"
33+
#endif

include/arm11/gpu_cmd_lists.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ extern "C"
2727
#endif
2828

2929
#define GPU_RENDER_BUF_ADDR (0x18180000)
30+
#define GPU_TEXTURE_ADDR (0x18200000)
31+
#define GPU_TEXTURE2_ADDR (0x18300000)
3032
#define GBA_INIT_LIST_SIZE (1136)
3133
#define GBA_LIST2_SIZE (448)
3234

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

3739

3840

39-
void patchGbaGpuCmdList(u8 scaleType);
41+
void patchGbaGpuCmdList(const u8 scaleType, const bool useSecondTexture);
4042

4143
#ifdef __cplusplus
4244
} // extern "C"

source/arm11/config.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"gbaGamma=2.2\n" \
3737
"lcdGamma=1.54\n" \
3838
"contrast=1.0\n" \
39-
"brightness=0.0\n\n" \
39+
"brightness=0.0\n" \
40+
"colorProfile=none\n\n" \
4041
"[audio]\n" \
4142
"audioOut=0\n" \
4243
"volume=127\n\n" \
@@ -61,6 +62,7 @@ OafConfig g_oafConfig =
6162
1.54f, // lcdGamma
6263
1.f, // contrast
6364
0.f, // brightness
65+
0, // colorProfile
6466

6567
// [audio]
6668
0, // Automatic audio output.
@@ -154,6 +156,19 @@ static int cfgIniCallback(void* user, const char* section, const char* name, con
154156
config->contrast = str2float(value);
155157
else if(strcmp(name, "brightness") == 0)
156158
config->brightness = str2float(value);
159+
else if(strcmp(name, "colorProfile") == 0)
160+
{
161+
if(strcmp(value, "none") == 0)
162+
config->colorProfile = 0;
163+
else if(strcmp(value, "gba") == 0)
164+
config->colorProfile = 1;
165+
else if(strcmp(value, "nds") == 0)
166+
config->colorProfile = 2;
167+
else if(strcmp(value, "nds_white") == 0)
168+
config->colorProfile = 3;
169+
//else if(strcmp(value, "custom") == 0) // TODO: Implement user provided profile.
170+
// config->colorProfile = 4;
171+
}
157172
}
158173
else if(strcmp(section, "audio") == 0)
159174
{

0 commit comments

Comments
 (0)