Refactored some more variable names, simplified some code

This commit is contained in:
archshift 2014-11-22 00:48:18 -08:00
parent d450e21f06
commit e193e1992f
5 changed files with 30 additions and 28 deletions

View File

@ -1,18 +1,17 @@
#pragma once
typedef struct {
struct charDesc_s {
char c;
int x, y, w, h, xo, yo, xa;
u8* data;
} charDesc_s;
};
typedef struct
{
struct font_s {
u8* data;
charDesc_s* desc;
u8 height;
u8 color[3];
} font_s;
};
extern u8 font1Data[];
extern charDesc_s font1Desc[];

View File

@ -5,9 +5,9 @@
#include "output.h"
#include "test_fs.h"
static int testCounter = 0;
static unsigned int testCounter = 0;
static void (*tests[]) (void) = {
FS_TestAll
FS::TestAll
};
int main()
@ -25,7 +25,7 @@ int main()
drawFrames();
hidScanInput();
if (hidKeysDown() & KEY_B) {
if (hidKeysDown() & KEY_START) {
break;
} else if (hidKeysDown() & KEY_A) {
clearScreen(GFX_TOP);

View File

@ -12,7 +12,6 @@
static std::string bufferTop;
static std::string bufferBottom;
static int cnt;
static int countLines(const std::string& str)
{
@ -42,7 +41,7 @@ static void deleteFirstLine(std::string* str)
*str = str->substr(linebreak + 1);
}
static void drawFrame(gfxScreen_t screen, char b, char g, char r)
static void drawFrame(gfxScreen_t screen, u8 b, u8 g, u8 r)
{
int screenWidth;
std::string textBuffer;
@ -54,24 +53,20 @@ static void drawFrame(gfxScreen_t screen, char b, char g, char r)
textBuffer = bufferBottom;
}
// Fill screen with color (TODO: find more efficient way to do this)
u8* bufAdr = gfxGetFramebuffer(screen, GFX_LEFT, NULL, NULL);
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;
}
for (int i = 0; i < screenWidth * 240 * 3; i += 3) {
bufAdr[i] = b;
bufAdr[i+1] = g;
bufAdr[i+2] = r;
}
x = countLines(textBuffer);
while (x > (240 / fontDefault.height - 3)) {
int lines = countLines(textBuffer);
while (lines > (240 / fontDefault.height - 3)) {
deleteFirstLine(&textBuffer);
x--;
lines--;
}
gfxDrawText(screen, GFX_LEFT, NULL, textBuffer.c_str(), 240 - fontDefault.height * 3, 10);
cnt++;
gfxDrawText(screen, GFX_LEFT, NULL, textBuffer.c_str(), 240 - fontDefault.height * 3, 10);
}
void drawFrames()
@ -100,7 +95,8 @@ void print(gfxScreen_t screen, const char* format, ...)
void clearScreen(gfxScreen_t screen)
{
bufferTop[0] = 0;
std::string& textBuffer = (screen == GFX_TOP) ? bufferTop : bufferBottom;
textBuffer.clear();
drawFrames();
}

View File

@ -4,7 +4,9 @@
#include "test.h"
static void FS_TestSdmc()
namespace FS {
static void TestSDMC()
{
FS_archive sdmcArchive = (FS_archive) { 0x00000009, { PATH_EMPTY, 1, (u8*) "" } };
@ -80,15 +82,17 @@ static void FS_TestSdmc()
}
void FS_TestAll()
void TestAll()
{
TestResult("FS", "Initializing service", [&]{
return fsInit();
});
FS_TestSdmc();
TestSDMC();
TestResult("FS", "Exiting service", [&]{
return fsExit();
});
}
} // namespace

View File

@ -1,4 +1,7 @@
#pragma once
void FS_TestAll();
namespace FS {
void TestAll();
}