2015-08-05 11:54:00 +02:00
|
|
|
/*
|
2016-07-05 16:05:53 +02:00
|
|
|
* This file is part of Luma3DS
|
2020-04-25 14:26:21 +02:00
|
|
|
* Copyright (C) 2016-2020 Aurora Wright, TuxSH
|
2016-03-23 02:27:53 +01:00
|
|
|
*
|
2016-07-05 16:05:53 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2017-06-05 02:02:04 +02:00
|
|
|
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
|
|
|
|
* * Requiring preservation of specified reasonable legal notices or
|
|
|
|
* author attributions in that material or in the Appropriate Legal
|
|
|
|
* Notices displayed by works containing it.
|
|
|
|
* * Prohibiting misrepresentation of the origin of that material,
|
|
|
|
* or requiring that modified versions of such material be marked in
|
|
|
|
* reasonable ways as different from the original version.
|
2016-07-05 16:05:53 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2016-04-23 01:43:11 +02:00
|
|
|
* Code to print to the screen by mid-kid @CakesFW
|
2016-09-08 23:07:03 +02:00
|
|
|
* https://github.com/mid-kid/CakesForeveryWan
|
2015-08-05 11:54:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "draw.h"
|
2018-05-24 00:55:38 +02:00
|
|
|
#include "memory.h"
|
2016-06-10 21:48:22 +02:00
|
|
|
#include "screen.h"
|
2016-05-09 03:41:00 +02:00
|
|
|
#include "utils.h"
|
2015-08-05 11:54:00 +02:00
|
|
|
#include "fs.h"
|
2017-05-07 17:58:44 +02:00
|
|
|
#include "fmt.h"
|
2017-05-08 01:11:24 +02:00
|
|
|
#include "font.h"
|
2017-12-29 03:50:06 +01:00
|
|
|
#include "config.h"
|
2016-03-23 02:27:53 +01:00
|
|
|
|
2016-07-02 14:44:01 +02:00
|
|
|
bool loadSplash(void)
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2017-06-09 17:29:26 +02:00
|
|
|
static const char *topSplashFile = "splash.bin",
|
|
|
|
*bottomSplashFile = "splashbottom.bin";
|
2016-09-13 14:54:14 +02:00
|
|
|
|
2016-10-12 02:28:08 +02:00
|
|
|
bool isTopSplashValid = getFileSize(topSplashFile) == SCREEN_TOP_FBSIZE,
|
2016-11-15 19:29:48 +01:00
|
|
|
isBottomSplashValid = getFileSize(bottomSplashFile) == SCREEN_BOTTOM_FBSIZE;
|
2016-09-13 14:54:14 +02:00
|
|
|
|
|
|
|
//Don't delay boot nor init the screens if no splash images or invalid splash images are on the SD
|
2016-11-15 19:29:48 +01:00
|
|
|
if(!isTopSplashValid && !isBottomSplashValid) return false;
|
|
|
|
|
|
|
|
initScreens();
|
2016-09-13 14:54:14 +02:00
|
|
|
|
2016-11-15 19:29:48 +01:00
|
|
|
if(isTopSplashValid) isTopSplashValid = fileRead(fbs[1].top_left, topSplashFile, SCREEN_TOP_FBSIZE) == SCREEN_TOP_FBSIZE;
|
|
|
|
if(isBottomSplashValid) isBottomSplashValid = fileRead(fbs[1].bottom, bottomSplashFile, SCREEN_BOTTOM_FBSIZE) == SCREEN_BOTTOM_FBSIZE;
|
2016-03-23 02:27:53 +01:00
|
|
|
|
2016-11-15 19:29:48 +01:00
|
|
|
if(!isTopSplashValid && !isBottomSplashValid) return false;
|
2016-07-18 18:51:04 +02:00
|
|
|
|
2016-11-15 19:29:48 +01:00
|
|
|
swapFramebuffers(true);
|
2017-12-29 03:50:06 +01:00
|
|
|
|
|
|
|
u32 durationIndex = MULTICONFIG(SPLASH_DURATION);
|
|
|
|
wait(1000ULL + (durationIndex * 2000ULL));
|
2016-08-15 13:11:27 +02:00
|
|
|
|
2016-11-15 19:29:48 +01:00
|
|
|
return true;
|
2016-03-23 02:27:53 +01:00
|
|
|
}
|
|
|
|
|
2017-05-07 17:58:44 +02:00
|
|
|
void drawCharacter(bool isTopScreen, u32 posX, u32 posY, u32 color, char character)
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2016-09-22 14:48:28 +02:00
|
|
|
u8 *select = isTopScreen ? fbs[0].top_left : fbs[0].bottom;
|
2016-03-23 02:27:53 +01:00
|
|
|
|
2016-09-13 14:54:14 +02:00
|
|
|
for(u32 y = 0; y < 8; y++)
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2016-03-29 17:43:53 +02:00
|
|
|
char charPos = font[character * 8 + y];
|
2016-03-23 02:27:53 +01:00
|
|
|
|
2016-09-13 14:54:14 +02:00
|
|
|
for(u32 x = 0; x < 8; x++)
|
2016-09-14 22:31:25 +02:00
|
|
|
if(((charPos >> (7 - x)) & 1) == 1)
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2016-09-13 14:54:14 +02:00
|
|
|
u32 screenPos = (posX * SCREEN_HEIGHT * 3 + (SCREEN_HEIGHT - y - posY - 1) * 3) + x * 3 * SCREEN_HEIGHT;
|
2016-04-13 01:08:13 +02:00
|
|
|
|
2016-03-29 17:43:53 +02:00
|
|
|
select[screenPos] = color >> 16;
|
|
|
|
select[screenPos + 1] = color >> 8;
|
|
|
|
select[screenPos + 2] = color;
|
2016-03-23 02:27:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-07 17:58:44 +02:00
|
|
|
u32 drawString(bool isTopScreen, u32 posX, u32 posY, u32 color, const char *string)
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2016-09-18 17:40:00 +02:00
|
|
|
for(u32 i = 0, line_i = 0; i < strlen(string); i++)
|
|
|
|
switch(string[i])
|
2016-04-02 17:58:06 +02:00
|
|
|
{
|
2016-09-18 17:40:00 +02:00
|
|
|
case '\n':
|
|
|
|
posY += SPACING_Y;
|
|
|
|
line_i = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '\t':
|
|
|
|
line_i += 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
//Make sure we never get out of the screen
|
|
|
|
if(line_i >= ((isTopScreen ? SCREEN_TOP_WIDTH : SCREEN_BOTTOM_WIDTH) - posX) / SPACING_X)
|
|
|
|
{
|
|
|
|
posY += SPACING_Y;
|
2016-09-18 18:05:51 +02:00
|
|
|
line_i = 1; //Little offset so we know the same string continues
|
|
|
|
if(string[i] == ' ') break; //Spaces at the start look weird
|
2016-09-18 17:40:00 +02:00
|
|
|
}
|
2016-09-18 18:05:51 +02:00
|
|
|
|
2017-05-07 17:58:44 +02:00
|
|
|
drawCharacter(isTopScreen, posX + line_i * SPACING_X, posY, color, string[i]);
|
2016-09-18 18:05:51 +02:00
|
|
|
|
2016-09-18 17:40:00 +02:00
|
|
|
line_i++;
|
|
|
|
break;
|
2016-03-23 02:27:53 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 17:43:53 +02:00
|
|
|
return posY;
|
2017-05-07 17:58:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 drawFormattedString(bool isTopScreen, u32 posX, u32 posY, u32 color, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char buf[DRAW_MAX_FORMATTED_STRING_SIZE + 1];
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
vsprintf(buf, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return drawString(isTopScreen, posX, posY, color, buf);
|
|
|
|
}
|