Reverted buffer change to string.
This commit is contained in:
parent
8cc32a952f
commit
5ec2f38c9a
@ -10,8 +10,9 @@
|
||||
|
||||
#include "text.h"
|
||||
|
||||
static std::string bufferTop;
|
||||
static std::string bufferBottom;
|
||||
static char bufferTop[8192];
|
||||
static char bufferBottom[8192];
|
||||
static int cnt;
|
||||
|
||||
static int countLines(const std::string& str)
|
||||
{
|
||||
@ -41,7 +42,7 @@ static void deleteFirstLine(std::string* str)
|
||||
*str = str->substr(linebreak + 1);
|
||||
}
|
||||
|
||||
static void drawFrame(gfxScreen_t screen, u8 b, u8 g, u8 r)
|
||||
static void drawFrame(gfxScreen_t screen, char b, char g, char r)
|
||||
{
|
||||
int screenWidth;
|
||||
std::string textBuffer;
|
||||
@ -53,20 +54,24 @@ static void drawFrame(gfxScreen_t screen, u8 b, u8 g, u8 r)
|
||||
textBuffer = bufferBottom;
|
||||
}
|
||||
|
||||
// Fill screen with color (TODO: find more efficient way to do this)
|
||||
u8* bufAdr = gfxGetFramebuffer(screen, GFX_LEFT, NULL, NULL);
|
||||
for (int i = 0; i < screenWidth * 240 * 3; i += 3) {
|
||||
bufAdr[i] = b;
|
||||
bufAdr[i+1] = g;
|
||||
bufAdr[i+2] = r;
|
||||
int x, y;
|
||||
for (x = 1; x < screenWidth; x++) {
|
||||
for (y = 1; y < 240; y++) {
|
||||
u32 v=(y + x * 240) * 3;
|
||||
bufAdr[v] = b;
|
||||
bufAdr[v+1] = g;
|
||||
bufAdr[v+2] = r;
|
||||
}
|
||||
}
|
||||
|
||||
int lines = countLines(textBuffer);
|
||||
while (lines > (240 / fontDefault.height - 3)) {
|
||||
x = countLines(textBuffer);
|
||||
while (x > (240 / fontDefault.height - 3)) {
|
||||
deleteFirstLine(&textBuffer);
|
||||
lines--;
|
||||
x--;
|
||||
}
|
||||
gfxDrawText(screen, GFX_LEFT, NULL, textBuffer.c_str(), 240 - fontDefault.height * 3, 10);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
void drawFrames()
|
||||
@ -79,7 +84,7 @@ void drawFrames()
|
||||
|
||||
void print(gfxScreen_t screen, const char* format, ...)
|
||||
{
|
||||
std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom;
|
||||
char* textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom;
|
||||
va_list arguments;
|
||||
char newStr[512];
|
||||
|
||||
@ -87,7 +92,7 @@ void print(gfxScreen_t screen, const char* format, ...)
|
||||
vsprintf(newStr, format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
textBuffer += newStr;
|
||||
sprintf(&textBuffer[strlen(textBuffer)], newStr);
|
||||
svcOutputDebugString(newStr, strlen(newStr));
|
||||
|
||||
drawFrames();
|
||||
@ -95,8 +100,7 @@ void print(gfxScreen_t screen, const char* format, ...)
|
||||
|
||||
void clearScreen(gfxScreen_t screen)
|
||||
{
|
||||
std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom;
|
||||
textBuffer.clear();
|
||||
bufferTop[0] = 0;
|
||||
drawFrames();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user