Skip to content

Commit

Permalink
Add GBA/DS Phat color mode
Browse files Browse the repository at this point in the history
Only works in DSi-based themes for now

ALSO: Optimize color mode apply code and box art loading code
  • Loading branch information
RocketRobz committed Oct 21, 2023
1 parent b273ec6 commit 0179bb5
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 352 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ You can help translate TWiLight Menu++ on the [Crowdin project](https://crowdin.
- [Arisotura](https://github.com/Arisotura): ROM list from melonDS, and BIOS dumper code from [dsibiosdumper](https://github.com/Arisotura/dsibiosdumper)
- [devkitPro](https://github.com/devkitPro): Code used in nds-hb-menu, and the use of the bootloader, devkitARM, libnds, and libfat
- [Gericom](https://github.com/Gericom), TrolleyDave, and FAST6191: GBA SRAM-patching code, used in gbapatcher ([SRAM patching thread at GBAtemp](https://gbatemp.net/threads/reverse-engineering-gba-patching.60168/))
- [Gericom](https://github.com/Gericom) & [profi200](https://github.com/profi200): GBA color correction code, used in [GBARunner3](https://github.com/Gericom/GBARunner3)
- Nikokaro: Found no-tilt patches for *WarioWare: Twisted!*, and *Yoshi Topsy-Turvy*. ([GBAtemp thread](https://gbatemp.net/threads/gba-no-tilt-patches-for-ds-users.584128/))
- [profi200](https://github.com/profi200): Improved SD code from fastboot3DS
- RadDude McCoolguy, fintogive, KazoWAR, Vague Rant, [gamemasterplc](https://github.com/gamemasterplc), [Rocket Robz](https://github.com/RocketRobz), [ChampionLeake](https://github.com/ChampionLeake), [DeadSkullzJr](https://github.com/DeadSkullzJr), [spellboundtriangle](https://github.com/spellboundtriangle), [LedyBacer](https://github.com/LedyBacer): Widescreen cheats
Expand Down
12 changes: 4 additions & 8 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,11 @@ void updateBoxArt(void) {
rocketVideo_playVideo = false; // Clear top screen cubes
}
clearBoxArt();
if (dsiFeatures() && ms().showBoxArt == 2) {
tex().drawBoxArtFromMem(CURPOS); // Load box art
} else {
sprintf(boxArtPath, "%s:/_nds/TWiLightMenu/boxart/%s.png", sys().isRunFromSD() ? "sd" : "fat", boxArtFilename);
if ((bnrRomType[CURPOS] == 0) && (access(boxArtPath, F_OK) != 0)) {
sprintf(boxArtPath, "%s:/_nds/TWiLightMenu/boxart/%s.png", sys().isRunFromSD() ? "sd" : "fat", gameTid[CURPOS]);
}
tex().drawBoxArt(boxArtPath); // Load box art
sprintf(boxArtPath, "%s:/_nds/TWiLightMenu/boxart/%s.png", sys().isRunFromSD() ? "sd" : "fat", boxArtFilename);
if ((bnrRomType[CURPOS] == 0) && (access(boxArtPath, F_OK) != 0)) {
sprintf(boxArtPath, "%s:/_nds/TWiLightMenu/boxart/%s.png", sys().isRunFromSD() ? "sd" : "fat", gameTid[CURPOS]);
}
tex().drawBoxArt(boxArtPath, (dsiFeatures() && ms().showBoxArt == 2)); // Load box art
}
boxArtLoaded = true;
}
Expand Down
9 changes: 7 additions & 2 deletions romsel_dsimenutheme/arm9/source/graphics/Texture.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "Texture.h"
#include "paletteEffects.h"
#include "common/tonccpy.h"
#include "common/twlmenusettings.h"
#include "common/lodepng.h"
#include "common/ColorLut.h"
#include <math.h>

extern bool useTwlCfg;
Expand Down Expand Up @@ -212,10 +214,11 @@ void Texture::loadPaletted(FILE *file) noexcept {
fseek(file, 2 * sizeof(u32), SEEK_CUR);
u32 paletteLength = 0;
fread(&paletteLength, sizeof(u32), 1, file);
_paletteLength = (paletteLength >> 9); // palette length in shorts. / sizoef(unsighed shor)
_paletteLength = (paletteLength >> 9); // palette length in shorts. / sizeof(unsighed shor)

_palette = std::make_unique<u16[]>(_paletteLength);
fread(_palette.get(), sizeof(u16), _paletteLength, file);
effectColorModePalette(_palette.get(), _paletteLength);
}


Expand Down Expand Up @@ -279,7 +282,9 @@ u16 Texture::bmpToDS(u16 val) {
return 0;

// int blfLevel = ms().blfLevel;
if (ms().colorMode == 1) {
if (ms().colorMode == 2) {
return convertDSColorToPhat(((val >> 10) & 31) | (val & (31 << 5)) | ((val & 31) << 10) | BIT(15));
} else if (ms().colorMode == 1) {
u8 b = val & 31;
u8 g = (val >> 5) & 31;
u8 r = (val >> 10) & 31;
Expand Down
Loading

0 comments on commit 0179bb5

Please sign in to comment.