Skip to content

Commit 0223508

Browse files
committed
R4 & Wood themes: Fix overlooked bugs
1 parent c6c8f15 commit 0223508

File tree

6 files changed

+80
-77
lines changed

6 files changed

+80
-77
lines changed

romsel_aktheme/arm9/source/fileBrowse.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ void getGameInfo0(const int fileOffset, std::vector<DirEntry> dirContents) {
331331

332332
if (dirContents.at(fileOffset).isDirectory) {
333333
isDirectory[0] = true;
334+
bnriconPalLine[0] = 0;
335+
bnriconPalLoaded[0] = 0;
336+
bnriconframenumY[0] = 0;
337+
bannerFlip[0] = 0;
338+
bnriconisDSi[0] = false;
334339
bnrWirelessIcon[0] = 0;
335340
} else {
336341
isDirectory[0] = false;
@@ -400,6 +405,8 @@ void getGameInfo0(const int fileOffset, std::vector<DirEntry> dirContents) {
400405
}
401406
}
402407

408+
static bool iconsLoaded = false;
409+
403410
void loadIcons(const int screenOffset, std::vector<DirEntry> dirContents) {
404411
clearText(false);
405412

@@ -416,6 +423,11 @@ void loadIcons(const int screenOffset, std::vector<DirEntry> dirContents) {
416423
}
417424
if (dirContents.at(i).isDirectory) {
418425
isDirectory[n] = true;
426+
bnriconPalLine[n] = 0;
427+
bnriconPalLoaded[n] = 0;
428+
bnriconframenumY[n] = 0;
429+
bannerFlip[n] = 0;
430+
bnriconisDSi[n] = false;
419431
bnrWirelessIcon[n] = 0;
420432
} else {
421433
isDirectory[n] = false;
@@ -489,6 +501,7 @@ void loadIcons(const int screenOffset, std::vector<DirEntry> dirContents) {
489501
displayDiskIcon(false);
490502

491503
updateText(false);
504+
iconsLoaded = true;
492505
}
493506

494507
void refreshBanners(const int startRow, const int fileOffset, std::vector<DirEntry> dirContents) {
@@ -1282,7 +1295,11 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
12821295
refreshBanners(screenOffset, fileOffset, dirContents);
12831296
}
12841297
} else {
1285-
refreshBanners(screenOffset, fileOffset, dirContents);
1298+
if (displayIcons && !iconsLoaded) {
1299+
loadIcons(screenOffset, dirContents);
1300+
} else {
1301+
refreshBanners(screenOffset, fileOffset, dirContents);
1302+
}
12861303
}
12871304
updateSelectionBar();
12881305

@@ -1570,7 +1587,10 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
15701587
}
15711588
}
15721589
ms().secondaryDevice = !ms().secondaryDevice;
1590+
displayDiskIcon(!sys().isRunFromSD());
15731591
ms().saveSettings();
1592+
displayDiskIcon(false);
1593+
iconsLoaded = false;
15741594
return "null";
15751595
}
15761596

@@ -1582,7 +1602,10 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
15821602
ms().romfolder[ms().secondaryDevice] = getcwd(buf, 256);
15831603
CURPOS = 0;
15841604
PAGENUM = 0;
1605+
displayDiskIcon(!sys().isRunFromSD());
15851606
ms().saveSettings();
1607+
displayDiskIcon(false);
1608+
iconsLoaded = false;
15861609
return "null";
15871610
}
15881611

romsel_aktheme/arm9/source/graphics/graphics.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,11 +1592,9 @@ void vBlankHandler()
15921592
glBoxFilled(2, 19+(i*38), 253, 19+37+(i*38), selectionBarColor1); // Draw selection bar
15931593
} */
15941594
if ((i == cursorPosOnScreen) && (iconScale > 0)) {
1595-
if (isDirectory[i] && !customIcon[i]) drawIconFolder(5-iconShift, 22+(i*38)-iconShift, (1 << 12)+iconScale);
1596-
else drawIcon(i, 5-iconShift, 22+(i*38)-iconShift, (1 << 12)+iconScale);
1595+
drawIcon(i, 5-iconShift, 22+(i*38)-iconShift, (1 << 12)+iconScale);
15971596
} else {
1598-
if (isDirectory[i] && !customIcon[i]) drawIconFolder(5, 22+(i*38), 0);
1599-
else drawIcon(i, 5, 22+(i*38), 0);
1597+
drawIcon(i, 5, 22+(i*38), 0);
16001598
}
16011599
// if (bnrWirelessIcon > 0) glSprite(24, 12, GL_FLIP_NONE, &wirelessIcons[(bnrWirelessIcon-1) & 31]);
16021600
// Playback animated icons

romsel_aktheme/arm9/source/iconTitle.cpp

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ extern u16* colorTable;
7878
extern int cursorPosOnScreen;
7979

8080
static int iconTexID[4];
81-
static int folderTexID;
8281
sNDSHeaderExt ndsHeader;
8382
sNDSBannerExt ndsBanner;
8483

@@ -87,7 +86,6 @@ static char16_t cachedTitle[4][TITLE_CACHE_SIZE];
8786

8887
static u32 arm9StartSig[4];
8988

90-
static glImage folderIcon[1];
9189
static glImage ndsIcon[4][(32 / 32) * (256 / 32)];
9290
static u16 dsi_palette[4][8][16];
9391
static u16 _paletteCache[4][16];
@@ -171,6 +169,26 @@ void loadIcon(int num, u8 *tilesSrc, u16 *palSrc, bool twl)//(u8(*tilesSrc)[(32
171169
);
172170
}
173171

172+
void loadFolderIcon(int num)
173+
{
174+
glDeleteTextures(1, &iconTexID[num]);
175+
swiCopy(icon_folderPal, _paletteCache[num], 4 * sizeof(u16) | COPY_MODE_COPY | COPY_MODE_WORD);
176+
iconTexID[num] =
177+
glLoadTileSet(ndsIcon[num], // pointer to glImage array
178+
32, // sprite width
179+
32, // sprite height
180+
32, // bitmap image width
181+
32, // bitmap image height
182+
GL_RGB16, // texture type for glTexImage2D() in videoGL.h
183+
TEXTURE_SIZE_32, // sizeX for glTexImage2D() in videoGL.h
184+
TEXTURE_SIZE_32, // sizeY for glTexImage2D() in videoGL.h
185+
TEXGEN_OFF | GL_TEXTURE_COLOR0_TRANSPARENT,
186+
16, // Length of the palette to use (16 colors)
187+
(u16*) icon_folderPal, // Image palette
188+
(u8*) icon_folderBitmap // Raw image data
189+
);
190+
}
191+
174192
void loadUnkIcon(int num)
175193
{
176194
glDeleteTextures(1, &iconTexID[num]);
@@ -691,39 +709,12 @@ void reloadIconPalettes() {
691709

692710
void loadConsoleIcons()
693711
{
694-
u16* newPalette;
695-
696-
// Folder
697-
glDeleteTextures(1, &folderTexID);
698-
699-
newPalette = (u16*)icon_folderPal;
700-
if (colorTable) {
701-
for (int i2 = 0; i2 < 16; i2++) {
702-
*(newPalette+i2) = colorTable[*(newPalette+i2)];
703-
}
704-
}
705-
folderTexID =
706-
glLoadTileSet(folderIcon, // pointer to glImage array
707-
32, // sprite width
708-
32, // sprite height
709-
32, // bitmap image width
710-
32, // bitmap image height
711-
GL_RGB16, // texture type for glTexImage2D() in videoGL.h
712-
TEXTURE_SIZE_32, // sizeX for glTexImage2D() in videoGL.h
713-
TEXTURE_SIZE_32, // sizeY for glTexImage2D() in videoGL.h
714-
TEXGEN_OFF | GL_TEXTURE_COLOR0_TRANSPARENT,
715-
16, // Length of the palette to use (16 colors)
716-
(u16*) newPalette, // Image palette
717-
(u8*) icon_folderBitmap // Raw image data
718-
);
719-
720-
721712
if (!colorTable) {
722713
return;
723714
}
724715

725716
// Unknown
726-
newPalette = (u16*)icon_unkPal;
717+
u16* newPalette = (u16*)icon_unkPal;
727718
for (int i2 = 0; i2 < 16; i2++) {
728719
*(newPalette+i2) = colorTable[*(newPalette+i2)];
729720
}
@@ -881,7 +872,6 @@ void iconTitleInit()
881872
}
882873
}
883874

884-
void drawIconFolder(int Xpos, int Ypos, s32 scale) { (scale == 0) ? glSprite(Xpos, Ypos, GL_FLIP_NONE, folderIcon) : glSpriteScale(Xpos, Ypos, scale, GL_FLIP_NONE, folderIcon); }
885875
void drawIcon(int num, int Xpos, int Ypos, s32 scale) {
886876
(scale == 0) ? glSprite(Xpos, Ypos, bannerFlip[num], &ndsIcon[num][bnriconframenumY[num] & 31]) : glSpriteScale(Xpos, Ypos, scale, bannerFlip[num], &ndsIcon[num][bnriconframenumY[num] & 31]);
887877
if (bnriconPalLine[num] != bnriconPalLoaded[num]) {
@@ -1292,17 +1282,16 @@ void iconUpdate(int num, bool isDir, const char* name)
12921282
{
12931283
const bool isNds = (bnrRomType[num] == 0);
12941284

1295-
if (isDir) {
1296-
// icon
1297-
clearIcon(num);
1298-
} else if (customIcon[num] > 0 || (customIcon[num] && isNds)) {
1285+
if (customIcon[num] > 0 || (customIcon[num] && isNds)) {
12991286
if (customIcon[num] == -1) {
13001287
loadUnkIcon(num);
13011288
} else if (bnriconisDSi[num]) {
13021289
loadIcon(num, ndsBanner.dsi_icon[0], ndsBanner.dsi_palette[0], true);
13031290
} else {
13041291
loadIcon(num, ndsBanner.icon, ndsBanner.palette, false);
13051292
}
1293+
} else if (isDir) {
1294+
loadFolderIcon(num);
13061295
} else if (extension(name, {".argv"})) {
13071296
// look through the argv file for the corresponding nds/app file
13081297
FILE *fp;

romsel_r4theme/arm9/source/fileBrowse.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,11 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
10841084

10851085
if (dirContents.at(fileOffset).isDirectory) {
10861086
isDirectory = true;
1087+
bnriconPalLine = 0;
1088+
bnriconPalLoaded = 0;
1089+
bnriconframenumY = 0;
1090+
bannerFlip = 0;
1091+
bnriconisDSi = false;
10871092
bnrWirelessIcon = 0;
10881093
} else {
10891094
isDirectory = false;

romsel_r4theme/arm9/source/graphics/graphics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ void vBlankHandler()
596596
glBoxFilled(35, 23, 217, 64, RGB15(0, 0, 0));
597597
glBoxFilled(77, 24, 216, 63, RGB15(31, 31, 31));
598598
glSprite(36, 24, GL_FLIP_NONE, iconboxImage);
599-
if (isDirectory && !customIcon) drawIconFolder(40, 28);
600-
else drawIcon(40, 28);
599+
drawIcon(40, 28);
601600
if (bnrWirelessIcon > 0) glSprite(24, 12, GL_FLIP_NONE, &wirelessIcons[(bnrWirelessIcon-1) & 31]);
602601
// Playback animated icons
603602
if (bnriconisDSi) {

romsel_r4theme/arm9/source/iconTitle.cpp

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
extern u16* colorTable;
7777

7878
static int iconTexID;
79-
static int folderTexID;
8079
sNDSHeaderExt ndsHeader;
8180
sNDSBannerExt ndsBanner;
8281

@@ -85,7 +84,6 @@ static char16_t cachedTitle[TITLE_CACHE_SIZE];
8584

8685
static u32 arm9StartSig[4];
8786

88-
static glImage folderIcon[1];
8987
static glImage ndsIcon[(32 / 32) * (256 / 32)];
9088
static u16 dsi_palette[8][16];
9189
static u16 _paletteCache[16];
@@ -176,6 +174,26 @@ void loadIcon(u8 *tilesSrc, u16 *palSrc, bool twl)//(u8(*tilesSrc)[(32 * 32) / 2
176174
);
177175
}
178176

177+
void loadFolderIcon()
178+
{
179+
glDeleteTextures(1, &iconTexID);
180+
swiCopy(icon_folderPal, _paletteCache, 4 * sizeof(u16) | COPY_MODE_COPY | COPY_MODE_WORD);
181+
iconTexID =
182+
glLoadTileSet(ndsIcon, // pointer to glImage array
183+
32, // sprite width
184+
32, // sprite height
185+
32, // bitmap image width
186+
32, // bitmap image height
187+
GL_RGB16, // texture type for glTexImage2D() in videoGL.h
188+
TEXTURE_SIZE_32, // sizeX for glTexImage2D() in videoGL.h
189+
TEXTURE_SIZE_32, // sizeY for glTexImage2D() in videoGL.h
190+
TEXGEN_OFF | GL_TEXTURE_COLOR0_TRANSPARENT,
191+
16, // Length of the palette to use (16 colors)
192+
(u16*) icon_folderPal, // Image palette
193+
(u8*) icon_folderBitmap // Raw image data
194+
);
195+
}
196+
179197
void loadUnkIcon()
180198
{
181199
glDeleteTextures(1, &iconTexID);
@@ -685,39 +703,12 @@ void reloadIconPalettes() {
685703

686704
void loadConsoleIcons()
687705
{
688-
u16* newPalette;
689-
690-
// Folder
691-
glDeleteTextures(1, &folderTexID);
692-
693-
newPalette = (u16*)icon_folderPal;
694-
if (colorTable) {
695-
for (int i2 = 0; i2 < 16; i2++) {
696-
*(newPalette+i2) = colorTable[*(newPalette+i2)];
697-
}
698-
}
699-
folderTexID =
700-
glLoadTileSet(folderIcon, // pointer to glImage array
701-
32, // sprite width
702-
32, // sprite height
703-
32, // bitmap image width
704-
32, // bitmap image height
705-
GL_RGB16, // texture type for glTexImage2D() in videoGL.h
706-
TEXTURE_SIZE_32, // sizeX for glTexImage2D() in videoGL.h
707-
TEXTURE_SIZE_32, // sizeY for glTexImage2D() in videoGL.h
708-
TEXGEN_OFF | GL_TEXTURE_COLOR0_TRANSPARENT,
709-
16, // Length of the palette to use (16 colors)
710-
(u16*) newPalette, // Image palette
711-
(u8*) icon_folderBitmap // Raw image data
712-
);
713-
714-
715706
if (!colorTable) {
716707
return;
717708
}
718709

719710
// Unknown
720-
newPalette = (u16*)icon_unkPal;
711+
u16* newPalette = (u16*)icon_unkPal;
721712
for (int i2 = 0; i2 < 16; i2++) {
722713
*(newPalette+i2) = colorTable[*(newPalette+i2)];
723714
}
@@ -864,7 +855,6 @@ static void clearIcon()
864855
loadIcon(clearTiles, blackPalette, true);
865856
}
866857

867-
void drawIconFolder(int Xpos, int Ypos) { glSprite(Xpos, Ypos, GL_FLIP_NONE, folderIcon); }
868858
void drawIcon(int Xpos, int Ypos) {
869859
glSprite(Xpos, Ypos, bannerFlip, &ndsIcon[bnriconframenumY & 31]);
870860
if (bnriconPalLine != bnriconPalLoaded) {
@@ -1281,17 +1271,16 @@ void iconUpdate(bool isDir, const char* name)
12811271

12821272
const bool isNds = (bnrRomType == 0);
12831273

1284-
if (isDir) {
1285-
// icon
1286-
clearIcon();
1287-
} else if (customIcon > 0 || (customIcon && isNds)) {
1274+
if (customIcon > 0 || (customIcon && isNds)) {
12881275
if (customIcon == -1) {
12891276
loadUnkIcon();
12901277
} else if (bnriconisDSi) {
12911278
loadIcon(ndsBanner.dsi_icon[0], ndsBanner.dsi_palette[0], true);
12921279
} else {
12931280
loadIcon(ndsBanner.icon, ndsBanner.palette, false);
12941281
}
1282+
} else if (isDir) {
1283+
loadFolderIcon();
12951284
} else if (extension(name, {".argv"})) {
12961285
// look through the argv file for the corresponding nds/app file
12971286
FILE *fp;

0 commit comments

Comments
 (0)