@@ -37,11 +37,8 @@ extern bool rocketVideo_playVideo;
3737extern u8 *rotatingCubesLocation;
3838
3939// #include <nds/arm9/decompress.h>
40- // extern u16 bmpImageBuffer[256*192];
4140extern bool showColon;
4241
43- static u16 _bmpImageBuffer[256 * 192 ] = {0 };
44- static u16 * _bmpImageBuffer2 = (u16 *)_bmpImageBuffer;
4542static u16 _bgMainBuffer[256 * 192 ] = {0 };
4643static u16 _bgSubBuffer[256 * 192 ] = {0 };
4744static u16 _photoBuffer[208 * 156 ] = {0 };
@@ -50,12 +47,12 @@ static u16* _bgSubBuffer2 = (u16*)_bgSubBuffer;
5047static u16 * _photoBuffer2 = (u16 *)_photoBuffer;
5148// DSi mode double-frame buffers
5249// static u16* _frameBuffer[2] = {(u16*)0x02F80000, (u16*)0x02F98000};
53- static u16 * _frameBufferBot[2 ] = {( u16 *)_bmpImageBuffer, ( u16 *)_bmpImageBuffer };
50+ static u16 * _frameBufferBot[2 ] = {NULL };
5451
5552static bool topBorderBufferLoaded = false ;
5653bool boxArtColorDeband = false ;
5754
58- static u8 * boxArtCache = ( u8 *) NULL ; // Size: 0x1B8000
55+ static u8 * boxArtCache = NULL ; // Size: 0x1B8000
5956static bool boxArtFound[40 ] = {false };
6057uint boxArtWidth = 0 , boxArtHeight = 0 ;
6158
@@ -993,6 +990,9 @@ void ThemeTextures::drawBoxArt(const char *filename, bool inMem) {
993990 bool alternatePixel = false ;
994991 if (boxArtWidth > 256 || boxArtHeight > 192 ) return ;
995992
993+ u16 * bmpImageBuffer = new u16 [256 * 192 ];
994+ u16 * bmpImageBuffer2 = boxArtColorDeband ? new u16 [256 * 192 ] : NULL ;
995+
996996 imageXpos = (256 -boxArtWidth)/2 ;
997997 imageYpos = (192 -boxArtHeight)/2 ;
998998
@@ -1025,9 +1025,9 @@ void ThemeTextures::drawBoxArt(const char *filename, bool inMem) {
10251025 color = colorTable[color % 0x8000 ];
10261026 }
10271027 if (alpha == 255 ) {
1028- _bmpImageBuffer [i] = color;
1028+ bmpImageBuffer [i] = color;
10291029 } else {
1030- _bmpImageBuffer [i] = alphablend (color, _bgSubBuffer[(photoY*256 )+photoX], alpha);
1030+ bmpImageBuffer [i] = alphablend (color, _bgSubBuffer[(photoY*256 )+photoX], alpha);
10311031 }
10321032 if (boxArtColorDeband) {
10331033 if (alternatePixel) {
@@ -1056,9 +1056,9 @@ void ThemeTextures::drawBoxArt(const char *filename, bool inMem) {
10561056 color = colorTable[color % 0x8000 ];
10571057 }
10581058 if (alpha == 255 ) {
1059- _bmpImageBuffer2 [i] = color;
1059+ bmpImageBuffer2 [i] = color;
10601060 } else {
1061- _bmpImageBuffer2 [i] = alphablend (color, _bgSubBuffer2[(photoY*256 )+photoX], alpha);
1061+ bmpImageBuffer2 [i] = alphablend (color, _bgSubBuffer2[(photoY*256 )+photoX], alpha);
10621062 }
10631063 if ((i % boxArtWidth) == boxArtWidth-1 ) alternatePixel = !alternatePixel;
10641064 alternatePixel = !alternatePixel;
@@ -1070,8 +1070,8 @@ void ThemeTextures::drawBoxArt(const char *filename, bool inMem) {
10701070 }
10711071 }
10721072
1073- u16 *src = _bmpImageBuffer ;
1074- u16 *src2 = _bmpImageBuffer2 ;
1073+ u16 *src = bmpImageBuffer ;
1074+ u16 *src2 = bmpImageBuffer2 ;
10751075 for (uint y = 0 ; y < boxArtHeight; y++) {
10761076 for (uint x = 0 ; x < boxArtWidth; x++) {
10771077 _bgSubBuffer[(y+imageYpos) * 256 + imageXpos + x] = *(src++);
@@ -1081,6 +1081,11 @@ void ThemeTextures::drawBoxArt(const char *filename, bool inMem) {
10811081 }
10821082 }
10831083 commitBgSubModify ();
1084+
1085+ delete[] bmpImageBuffer;
1086+ if (boxArtColorDeband) {
1087+ delete[] bmpImageBuffer2;
1088+ }
10841089}
10851090
10861091#define MAX_PHOTO_WIDTH 208
@@ -1456,7 +1461,6 @@ void ThemeTextures::applyUserPaletteToAllGrfTextures() {
14561461 _settingsIconTexture->applyUserPaletteFile (TFN_PALETTE_ICON_SETTINGS, effectDSiArrowButtonPalettes);
14571462}
14581463
1459- u16 *ThemeTextures::bmpImageBuffer () { return _bmpImageBuffer; }
14601464u16 *ThemeTextures::bgSubBuffer2 () { return _bgSubBuffer2; }
14611465u16 *ThemeTextures::photoBuffer () { return _photoBuffer; }
14621466u16 *ThemeTextures::photoBuffer2 () { return _photoBuffer2; }
@@ -1627,7 +1631,6 @@ void ThemeTextures::videoSetup() {
16271631 boxArtColorDeband = (ms ().boxArtColorDeband && !ms ().macroMode && (sys ().isRegularDS () ? sys ().dsDebugRam () : ndmaEnabled ()) && !rotatingCubesLoaded && ms ().theme != TWLSettings::EThemeHBL);
16281632
16291633 if (boxArtColorDeband) {
1630- _bmpImageBuffer2 = new u16 [256 * 192 ];
16311634 _bgSubBuffer2 = new u16 [256 * 192 ];
16321635 _photoBuffer2 = new u16 [208 * 156 ];
16331636 _frameBufferBot[0 ] = new u16 [256 * 192 ];
0 commit comments