mirror of
https://github.com/RocketRobz/SuperAllStarPhotoStudio.git
synced 2025-06-18 17:15:35 -04:00
DS(i): Bug fix + Adjust master brightness fade effects based on currently used screen effect/color LUT
This commit is contained in:
parent
d1272898f9
commit
78d650c71e
@ -67,7 +67,7 @@ extern int bg3Main;
|
|||||||
extern int bg3Sub;
|
extern int bg3Sub;
|
||||||
|
|
||||||
extern u16* colorTable;
|
extern u16* colorTable;
|
||||||
extern void applyColorLut(u16 *palette, int size);
|
extern void applyColorLutBitmap(u16 *palette, int size);
|
||||||
extern void copyPalette16(u16 *dst, const u16 *src, int size);
|
extern void copyPalette16(u16 *dst, const u16 *src, int size);
|
||||||
|
|
||||||
extern bool showCursor;
|
extern bool showCursor;
|
||||||
@ -158,7 +158,7 @@ void GFX::loadSheets() {
|
|||||||
for(unsigned i=0;i<image.size()/4;i++) {
|
for(unsigned i=0;i<image.size()/4;i++) {
|
||||||
charSpriteMem[i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
charSpriteMem[i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
||||||
}
|
}
|
||||||
applyColorLut(charSpriteMem, image.size()/4);
|
applyColorLutBitmap(charSpriteMem, image.size()/4);
|
||||||
image.clear();
|
image.clear();
|
||||||
lodepng::decode(image, width, height, "nitro:/graphics/gui/title.png");
|
lodepng::decode(image, width, height, "nitro:/graphics/gui/title.png");
|
||||||
bool alternatePixel = false;
|
bool alternatePixel = false;
|
||||||
@ -188,7 +188,7 @@ void GFX::loadSheets() {
|
|||||||
}
|
}
|
||||||
bmpImageBuffer[1][i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
bmpImageBuffer[1][i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
||||||
if (colorTable) {
|
if (colorTable) {
|
||||||
bmpImageBuffer[1][i] = colorTable[bmpImageBuffer[1][i] % 0x8000];
|
bmpImageBuffer[1][i] = colorTable[bmpImageBuffer[1][i] % 0x8000] | BIT(15);
|
||||||
}
|
}
|
||||||
if (charSpriteAlpha[i] == 255) {
|
if (charSpriteAlpha[i] == 255) {
|
||||||
bmpImageBuffer[0][i] = bmpImageBuffer[1][i];
|
bmpImageBuffer[0][i] = bmpImageBuffer[1][i];
|
||||||
@ -221,7 +221,7 @@ void GFX::loadSheets() {
|
|||||||
}
|
}
|
||||||
bmpImageBuffer2[1][i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
bmpImageBuffer2[1][i] = image[i*4]>>3 | (image[(i*4)+1]>>3)<<5 | (image[(i*4)+2]>>3)<<10 | BIT(15);
|
||||||
if (colorTable) {
|
if (colorTable) {
|
||||||
bmpImageBuffer2[1][i] = colorTable[bmpImageBuffer2[1][i] % 0x8000];
|
bmpImageBuffer2[1][i] = colorTable[bmpImageBuffer2[1][i] % 0x8000] | BIT(15);
|
||||||
}
|
}
|
||||||
if (charSpriteAlpha[i] == 255) {
|
if (charSpriteAlpha[i] == 255) {
|
||||||
bmpImageBuffer2[0][i] = bmpImageBuffer2[1][i];
|
bmpImageBuffer2[0][i] = bmpImageBuffer2[1][i];
|
||||||
@ -306,14 +306,10 @@ void GFX::loadBgSprite(void) {
|
|||||||
animateTitle = false;
|
animateTitle = false;
|
||||||
|
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
|
const u16 white = colorTable ? (colorTable[0xFFFF % 0x8000] | BIT(15)) : 0xFFFF;
|
||||||
swiWaitForVBlank(); // Prevent screen tearing
|
swiWaitForVBlank(); // Prevent screen tearing
|
||||||
if (colorTable) {
|
dmaFillHalfWords(white, bgGetGfxPtr(bg2Main), 0x18000);
|
||||||
dmaFillHalfWords(colorTable[0xFFFF % 0x8000], bgGetGfxPtr(bg2Main), 0x18000);
|
dmaFillHalfWords(white, bgGetGfxPtr(bg3Main), 0x18000);
|
||||||
dmaFillHalfWords(colorTable[0xFFFF % 0x8000], bgGetGfxPtr(bg3Main), 0x18000);
|
|
||||||
} else {
|
|
||||||
dmaFillHalfWords(0xFFFF, bgGetGfxPtr(bg2Main), 0x18000);
|
|
||||||
dmaFillHalfWords(0xFFFF, bgGetGfxPtr(bg3Main), 0x18000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timeOutside = 2; // Default is Nighttime
|
timeOutside = 2; // Default is Nighttime
|
||||||
@ -685,9 +681,9 @@ void GFX::loadBgSprite(void) {
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(bgSpriteMem, image.size()/4);
|
applyColorLutBitmap(bgSpriteMem, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(bgSpriteMem2, image.size()/4);
|
applyColorLutBitmap(bgSpriteMem2, image.size()/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bgSpriteLoaded = true;
|
bgSpriteLoaded = true;
|
||||||
@ -766,9 +762,9 @@ void GFX::loadBgSprite(void) {
|
|||||||
if ((p % 256) == 255) alternatePixel = !alternatePixel;
|
if ((p % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(bgSpriteMemExt[i-1], image.size()/4);
|
applyColorLutBitmap(bgSpriteMemExt[i-1], image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(bgSpriteMemExt2[i-1], image.size()/4);
|
applyColorLutBitmap(bgSpriteMemExt2[i-1], image.size()/4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (studioBg == 64) {
|
if (studioBg == 64) {
|
||||||
@ -898,9 +894,9 @@ bool GFX::loadCharSprite(int num, const char* t3xPathPose, const char* t3xPathAl
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(usePageFile ? charSpriteMem : charSpriteMem5, image.size()/4);
|
applyColorLutBitmap(usePageFile ? charSpriteMem : charSpriteMem5, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(charSpriteMem5_2, image.size()/4);
|
applyColorLutBitmap(charSpriteMem5_2, image.size()/4);
|
||||||
}
|
}
|
||||||
if (usePageFile) {
|
if (usePageFile) {
|
||||||
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
||||||
@ -971,9 +967,9 @@ bool GFX::loadCharSprite(int num, const char* t3xPathPose, const char* t3xPathAl
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(usePageFile ? charSpriteMem : charSpriteMem4, image.size()/4);
|
applyColorLutBitmap(usePageFile ? charSpriteMem : charSpriteMem4, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(charSpriteMem4_2, image.size()/4);
|
applyColorLutBitmap(charSpriteMem4_2, image.size()/4);
|
||||||
}
|
}
|
||||||
if (usePageFile) {
|
if (usePageFile) {
|
||||||
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
||||||
@ -1044,9 +1040,9 @@ bool GFX::loadCharSprite(int num, const char* t3xPathPose, const char* t3xPathAl
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(usePageFile ? charSpriteMem : charSpriteMem3, image.size()/4);
|
applyColorLutBitmap(usePageFile ? charSpriteMem : charSpriteMem3, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(charSpriteMem3_2, image.size()/4);
|
applyColorLutBitmap(charSpriteMem3_2, image.size()/4);
|
||||||
}
|
}
|
||||||
if (usePageFile) {
|
if (usePageFile) {
|
||||||
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
||||||
@ -1131,9 +1127,9 @@ bool GFX::loadCharSprite(int num, const char* t3xPathPose, const char* t3xPathAl
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(usePageFile ? charSpriteMem : charSpriteMem2, image.size()/4);
|
applyColorLutBitmap(usePageFile ? charSpriteMem : charSpriteMem2, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(charSpriteMem2_2, image.size()/4);
|
applyColorLutBitmap(charSpriteMem2_2, image.size()/4);
|
||||||
}
|
}
|
||||||
if (usePageFile) {
|
if (usePageFile) {
|
||||||
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
||||||
@ -1196,9 +1192,9 @@ bool GFX::loadCharSprite(int num, const char* t3xPathPose, const char* t3xPathAl
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(charSpriteMem, image.size()/4);
|
applyColorLutBitmap(charSpriteMem, image.size()/4);
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(charSpriteMem_2, image.size()/4);
|
applyColorLutBitmap(charSpriteMem_2, image.size()/4);
|
||||||
}
|
}
|
||||||
if (usePageFile && chracterSpriteFound[1]) {
|
if (usePageFile && chracterSpriteFound[1]) {
|
||||||
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
FILE* pageFile = fopen("fat:/_nds/pagefile.sys", "r+");
|
||||||
|
@ -59,9 +59,15 @@ int bg3Sub;
|
|||||||
u16* gfxSub;
|
u16* gfxSub;
|
||||||
|
|
||||||
u16* colorTable = NULL;
|
u16* colorTable = NULL;
|
||||||
|
bool invertedColors = false;
|
||||||
|
bool noWhiteFade = false;
|
||||||
|
|
||||||
// Ported from PAlib (obsolete)
|
// Ported from PAlib (obsolete)
|
||||||
void SetBrightness(u8 screen, s8 bright) {
|
void SetBrightness(u8 screen, s8 bright) {
|
||||||
|
if ((invertedColors && bright != 0) || (noWhiteFade && bright > 0)) {
|
||||||
|
bright -= bright*2; // Invert brightness to match the inverted colors
|
||||||
|
}
|
||||||
|
|
||||||
u16 mode = 1 << 14;
|
u16 mode = 1 << 14;
|
||||||
|
|
||||||
if (bright < 0) {
|
if (bright < 0) {
|
||||||
@ -70,7 +76,7 @@ void SetBrightness(u8 screen, s8 bright) {
|
|||||||
}
|
}
|
||||||
if (bright > 31)
|
if (bright > 31)
|
||||||
bright = 31;
|
bright = 31;
|
||||||
*(vu16 *)(0x0400006C + (0x1000 * screen)) = bright + mode;
|
*(vu16*)(0x0400006C + (0x1000 * screen)) = bright + mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear Text.
|
// Clear Text.
|
||||||
@ -90,13 +96,22 @@ void Gui__ChangeBrightness() {
|
|||||||
SetBrightness(1, (fadecolor==255 ? fadealpha : -fadealpha)/8);
|
SetBrightness(1, (fadecolor==255 ? fadealpha : -fadealpha)/8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyColorLut(u16 *palette, int size) {
|
/* void applyColorLut(u16 *palette, int size) {
|
||||||
if (!colorTable) {
|
if (!colorTable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
palette[i] = colorTable[palette[i] % 0x8000];
|
palette[i] = colorTable[palette[i] % 0x8000];
|
||||||
}
|
}
|
||||||
|
} */
|
||||||
|
|
||||||
|
void applyColorLutBitmap(u16 *palette, int size) {
|
||||||
|
if (!colorTable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
palette[i] = colorTable[palette[i] % 0x8000] | BIT(15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copies a palette and applies color LUT if loaded
|
// Copies a palette and applies color LUT if loaded
|
||||||
@ -156,6 +171,14 @@ void Gui::init(void) {
|
|||||||
fread(colorTable, 1, 0x10000, file);
|
fread(colorTable, 1, 0x10000, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
|
invertedColors =
|
||||||
|
(colorTable[0] >= 0xF000 && colorTable[0] <= 0xFFFF
|
||||||
|
&& colorTable[0x7FFF] >= 0x8000 && colorTable[0x7FFF] <= 0x8FFF);
|
||||||
|
if (!invertedColors) noWhiteFade = (colorTable[0x7FFF] < 0xF000);
|
||||||
|
|
||||||
|
SetBrightness(0, 31);
|
||||||
|
SetBrightness(1, 31);
|
||||||
|
|
||||||
tonccpy(VRAM_D, colorTable, 0x10000); // Copy LUT to VRAM
|
tonccpy(VRAM_D, colorTable, 0x10000); // Copy LUT to VRAM
|
||||||
delete[] colorTable; // Free up RAM space
|
delete[] colorTable; // Free up RAM space
|
||||||
colorTable = VRAM_D;
|
colorTable = VRAM_D;
|
||||||
|
@ -30,7 +30,7 @@ void ProductIdent::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
u16* bgLoc = new u16[256*192];
|
u16* bgLoc = new u16[256*192];
|
||||||
extern int bg2Main;
|
extern int bg2Main;
|
||||||
extern int bg3Main;
|
extern int bg3Main;
|
||||||
extern void applyColorLut(u16 *palette, int size);
|
extern void applyColorLutBitmap(u16 *palette, int size);
|
||||||
|
|
||||||
std::vector<unsigned char> image;
|
std::vector<unsigned char> image;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
@ -45,9 +45,9 @@ void ProductIdent::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
while (dmaBusy(0));
|
while (dmaBusy(0));
|
||||||
delete[] bgLoc;
|
delete[] bgLoc;
|
||||||
}
|
}
|
||||||
applyColorLut(bgGetGfxPtr(bg2Main), 0x18000/sizeof(u16));
|
applyColorLutBitmap(bgGetGfxPtr(bg2Main), 0x18000/sizeof(u16));
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(bgGetGfxPtr(bg3Main), 0x18000/sizeof(u16));
|
applyColorLutBitmap(bgGetGfxPtr(bg3Main), 0x18000/sizeof(u16));
|
||||||
}
|
}
|
||||||
graphicLoaded = true;
|
graphicLoaded = true;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ void RocketRobz::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
if (!graphicLoaded) {
|
if (!graphicLoaded) {
|
||||||
extern int bg2Main;
|
extern int bg2Main;
|
||||||
extern int bg3Main;
|
extern int bg3Main;
|
||||||
extern void applyColorLut(u16 *palette, int size);
|
extern void applyColorLutBitmap(u16 *palette, int size);
|
||||||
|
|
||||||
std::vector<unsigned char> image;
|
std::vector<unsigned char> image;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
@ -187,9 +187,9 @@ void RocketRobz::Logic(u32 hDown, u32 hHeld, touchPosition touch) {
|
|||||||
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
if ((i % 256) == 255) alternatePixel = !alternatePixel;
|
||||||
alternatePixel = !alternatePixel;
|
alternatePixel = !alternatePixel;
|
||||||
}
|
}
|
||||||
applyColorLut(bgGetGfxPtr(bg2Main), 0x18000/sizeof(u16));
|
applyColorLutBitmap(bgGetGfxPtr(bg2Main), 0x18000/sizeof(u16));
|
||||||
if (dsiFeatures()) {
|
if (dsiFeatures()) {
|
||||||
applyColorLut(bgGetGfxPtr(bg3Main), 0x18000/sizeof(u16));
|
applyColorLutBitmap(bgGetGfxPtr(bg3Main), 0x18000/sizeof(u16));
|
||||||
}
|
}
|
||||||
graphicLoaded = true;
|
graphicLoaded = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user