Skip to content

Commit

Permalink
Manual: Add user-colored border at bottom of top bar
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Aug 22, 2024
1 parent c400c74 commit ec2e6b1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 17 deletions.
43 changes: 43 additions & 0 deletions manual/arm9/include/userpal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

//{{BLOCK(start_border0)

//======================================================================
//
// start_border0, 32x256@4,
// Transparent color : FF,00,FF
// + palette 16 entries, not compressed
// + bitmap not compressed
// Total size: 32 + 4096 = 4128
//
// Time-stamp: 2018-06-20, 11:35:44
// Exported by Cearn's GBA Image Transmogrifier, v0.8.14
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================

#ifndef START_BORDER_PAL_H
#define START_BORDER_PAL_H

const unsigned short palUserFont[16][2]
{
{0x2928, 0x4E0C}, // 0: gray
{0x10EC, 0x0137}, // 1: brown
{0x148F, 0x0C1F}, // 2: red
{0x3D4F, 0x7E3F}, // 3: pink
{0x114F, 0x025F}, // 4: orange
{0x11CF, 0x039E}, // 5: yellow
{0x11EB, 0x03F5}, // 6: yellow-green
{0x11E4, 0x03E0}, // 7: lively green
{0x1DA4, 0x2320}, // 8: green
{0x29C7, 0x4769}, // 9: pastel green
{0x3D86, 0x7AE6}, // 10: sky blue
{0x3D46, 0x7DE5}, // 11: light blue
{0x3CA5, 0x7C62}, // 12: blue
{0x348A, 0x6811}, // 13: violet
{0x388D, 0x741A}, // 14: purple
{0x288F, 0x481F} // 15: fuschia
};

#endif // START_BORDER_PAL_H

//}}BLOCK(start_border0)
4 changes: 2 additions & 2 deletions manual/arm9/source/errorScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ void checkSdEject(void) {
palette[i] = colorTable[palette[i]];
}
}
tonccpy(BG_PALETTE + 0xF8, palette, sizeof(palette));
tonccpy(BG_PALETTE_SUB + 0xF8, palette, sizeof(palette));
tonccpy(BG_PALETTE + 0xF6, palette, sizeof(palette));
tonccpy(BG_PALETTE_SUB + 0xF6, palette, sizeof(palette));

clearText();

Expand Down
4 changes: 2 additions & 2 deletions manual/arm9/source/graphics/FontGraphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ ITCM_CODE void FontGraphic::print(int x, int y, bool top, std::u16string_view te
for (int j = 0; j < tileWidth; j++) {
u8 px = fontTiles[(cachePos * tileSize) + (i * tileWidth + j) / 4] >> ((3 - ((i * tileWidth + j) % 4)) * 2) & 3;
if (px)
dst[(y + i) * 256 + j] = px + 0xF8;
dst[(y + i) * 256 + j] = px + 0xF6;
}
}
}
Expand All @@ -455,7 +455,7 @@ ITCM_CODE void FontGraphic::print(int x, int y, bool top, std::u16string_view te
for (int j = 0; j < tileWidth; j++) {
u8 px = fontTiles[(index * tileSize) + (i * tileWidth + j) / 4] >> ((3 - ((i * tileWidth + j) % 4)) * 2) & 3;
if (px)
dst[(y + i) * 256 + j] = px + 0xF8;
dst[(y + i) * 256 + j] = px + 0xF6;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion manual/arm9/source/graphics/fontHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void fontInit() {
// tonccpy(BG_PALETTE + 0xF8, palette, sizeof(palette));
// tonccpy(BG_PALETTE_SUB + 0xF8, palette, sizeof(palette));

extern u16 topBarPal[8];
extern u16 topBarPal[];
tonccpy(topBarPal, palette, sizeof(palette));

logPrint("Font inited\n");
Expand Down
33 changes: 23 additions & 10 deletions manual/arm9/source/graphics/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
------------------------------------------------------------------*/

#include "graphics.h"
#include "userpal.h"
#include "../errorScreen.h"
#include "fontHandler.h"
#include "fileCopy.h"
Expand All @@ -42,7 +43,7 @@ int screenBrightness = 31;
bool updatePalMidFrame = true;

u16 bmpImageBuffer[256*192] = {0};
u16 topBarPal[8] = {0}; // For both font and top bar palettes
u16 topBarPal[10] = {0}; // For both font and top bar palettes
static u16 pagePal[256] = {0};
u16* colorTable = NULL;
std::vector<u8> pageImage;
Expand Down Expand Up @@ -119,8 +120,8 @@ void vBlankHandler() {
if (controlBottomBright && !ms().macroMode) SetBrightness(1, screenBrightness);

if (updatePalMidFrame) {
tonccpy(BG_PALETTE + 0xF8, topBarPal, 8 * 2);
while (REG_VCOUNT != 16);
tonccpy(BG_PALETTE + 0xF6, topBarPal, 10 * 2);
while (REG_VCOUNT != 18);
tonccpy(BG_PALETTE, pagePal, 256 * 2);
}
}
Expand All @@ -146,14 +147,14 @@ void pageLoad(const std::string &filename) {
tonccpy(BG_PALETTE_SUB, pagePal, gif.gct().size() * 2);
}

dmaCopyWordsAsynch(0, pageImage.data(), bgGetGfxPtr(bg3Main)+(8*256), 176*256);
if (!ms().macroMode) dmaCopyWordsAsynch(1, pageImage.data()+(176*256), bgGetGfxPtr(bg3Sub), 192*256);
dmaCopyWordsAsynch(0, pageImage.data(), bgGetGfxPtr(bg3Main)+(9*256), 174*256);
if (!ms().macroMode) dmaCopyWordsAsynch(1, pageImage.data()+(174*256), bgGetGfxPtr(bg3Sub), 192*256);
while (dmaBusy(0) || dmaBusy(1));
}

void pageScroll(void) {
dmaCopyWordsAsynch(0, pageImage.data()+(pageYpos*256), bgGetGfxPtr(bg3Main)+(8*256), 176*256);
if (!ms().macroMode) dmaCopyWordsAsynch(1, pageImage.data()+((176+pageYpos)*256), bgGetGfxPtr(bg3Sub), 192*256);
dmaCopyWordsAsynch(0, pageImage.data()+(pageYpos*256), bgGetGfxPtr(bg3Main)+(9*256), 174*256);
if (!ms().macroMode) dmaCopyWordsAsynch(1, pageImage.data()+((174+pageYpos)*256), bgGetGfxPtr(bg3Sub), 192*256);
while (dmaBusy(0) || dmaBusy(1));
}

Expand All @@ -162,21 +163,33 @@ void topBarLoad(void) {
const auto &frame = gif.frame(0);
u16 *dst = bgGetGfxPtr(bg3Main);

extern bool useTwlCfg;
int favoriteColor = (int)(useTwlCfg ? *(u8*)0x02000444 : PersonalData->theme);
if (favoriteColor < 0 || favoriteColor >= 16) favoriteColor = 0; // Invalid color found, so default to gray

/* tonccpy(BG_PALETTE + 0xFC, gif.gct().data(), gif.gct().size() * 2);
if (colorTable) {
for (int i = 0xFC; i < (int)0xFC + gif.gct().size(); i++) {
BG_PALETTE[i] = colorTable[BG_PALETTE[i]];
}
} */
tonccpy(topBarPal+4, gif.gct().data(), gif.gct().size() * 2);
topBarPal[4+4] = palUserFont[favoriteColor][1];
topBarPal[4+5] = palUserFont[favoriteColor][0];
if (colorTable) {
for (int i = 0; i < (int)gif.gct().size(); i++) {
topBarPal[i+4] = colorTable[topBarPal[i+4]];
for (int i = 0; i < 6; i++) {
topBarPal[4+i] = colorTable[topBarPal[i+4]];
}
}

for (uint i = 0; i < frame.image.imageData.size(); i += 2) {
toncset16(dst++, (frame.image.imageData[i] + 0xFC) | (frame.image.imageData[i + 1] + 0xFC) << 8, 1);
toncset16(dst++, (frame.image.imageData[i] + 0xFA) | (frame.image.imageData[i + 1] + 0xFA) << 8, 1);
}
for (int i = 0; i < 256/2; i++) {
toncset16(dst++, 0xFEFE, 1);
}
for (int i = 0; i < 256/2; i++) {
toncset16(dst++, 0xFFFF, 1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions manual/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int manualScreen(void) {
manPageTitleX = 256 - manPageTitleX;
manPageTitleAlign = Alignment::right;
}
int ySizeSub = ms().macroMode ? 176 : 368;
int ySizeSub = ms().macroMode ? 174 : 366;

langInit();

Expand Down Expand Up @@ -408,7 +408,7 @@ int manualScreen(void) {
} else {
for (uint i=0;i<manPageLinks.size();i++) {
if (((touchStart.px >= manPageLinks[i].x) && (touchStart.px <= (manPageLinks[i].x + manPageLinks[i].w))) &&
(((touchStart.py + pageYpos) >= manPageLinks[i].y - (ms().macroMode ? 0 : 176)) && ((touchStart.py + pageYpos) <= (manPageLinks[i].y - (ms().macroMode ? 0 : 176) + manPageLinks[i].h)))) {
(((touchStart.py + pageYpos) >= manPageLinks[i].y - (ms().macroMode ? 0 : 174)) && ((touchStart.py + pageYpos) <= (manPageLinks[i].y - (ms().macroMode ? 0 : 174) + manPageLinks[i].h)))) {
pageYpos = 0;
returnPage = currentPage;
for (uint j=0;j<manPagesList.size();j++) {
Expand Down

0 comments on commit ec2e6b1

Please sign in to comment.