Greatly improved readability of main.c
This commit is contained in:
parent
4b99487f8a
commit
ea24bf9f92
@ -16,17 +16,27 @@ s32 pcCos(u16 v)
|
||||
return costable[v&0x1FF];
|
||||
}
|
||||
|
||||
int countLines(char* str)
|
||||
int countLines(const char* str)
|
||||
{
|
||||
if(!str)return 0;
|
||||
int cnt; for(cnt=1;*str=='\n'?++cnt:*str;str++);
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
int cnt = 1;
|
||||
while (*str == '\n' ? ++cnt : *str)
|
||||
str++;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
void cutLine(char* str)
|
||||
{
|
||||
if(!str || !*str)return;
|
||||
char* str2=str; for(;*str2&&*(str2+1)&&*str2!='\n';str2++); str2++;
|
||||
if (!str || !*str)
|
||||
return;
|
||||
|
||||
char* str2 = str;
|
||||
while ((*str2) && (*(str2 + 1)) && (*str2 != '\n'))
|
||||
str2++;
|
||||
str2++;
|
||||
|
||||
memmove(str, str2, strlen(str2) + 1);
|
||||
}
|
||||
|
||||
@ -34,20 +44,23 @@ void drawFrame()
|
||||
{
|
||||
u8* bufAdr = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
int i, j;
|
||||
for(i=1;i<400;i++)
|
||||
int x, y;
|
||||
for (x = 1; x < 400; x++)
|
||||
{
|
||||
for(j=1;j<240;j++)
|
||||
for (y = 1; y < 240; y++)
|
||||
{
|
||||
u32 v=(j+i*240)*3;
|
||||
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
|
||||
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
|
||||
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
|
||||
u32 v=(y + x * 240) * 3;
|
||||
bufAdr[v] = (pcCos(x + cnt) + 4096) / 32;
|
||||
bufAdr[v+1] = (pcCos(y - 256 + cnt) + 4096) / 64;
|
||||
bufAdr[v+2] = (pcCos(x + 128 - cnt) + 4096) / 32;
|
||||
}
|
||||
}
|
||||
gfxDrawText(GFX_TOP, GFX_LEFT, NULL, "ftPONY v0.0002\n", 240 - fontDefault.height * 1, 10);
|
||||
i = countLines(superStr);
|
||||
while(i>240/fontDefault.height-3){cutLine(superStr);i--;}
|
||||
x = countLines(superStr);
|
||||
while (x > (240 / fontDefault.height - 3)) {
|
||||
cutLine(superStr);
|
||||
x--;
|
||||
}
|
||||
gfxDrawText(GFX_TOP, GFX_LEFT, NULL, superStr, 240 - fontDefault.height * 3, 20);
|
||||
cnt++;
|
||||
|
||||
@ -60,7 +73,6 @@ int main()
|
||||
srvInit();
|
||||
aptInit();
|
||||
hidInit(NULL);
|
||||
irrstInit(NULL);
|
||||
gfxInit();
|
||||
gfxSet3D(false);
|
||||
|
||||
@ -106,7 +118,6 @@ int main()
|
||||
}
|
||||
|
||||
gfxExit();
|
||||
irrstExit();
|
||||
hidExit();
|
||||
aptExit();
|
||||
srvExit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user