TwlIPL/build/debugsoft/MakerTitle/TitleList/src/screen.c
(no author) 31733c2458 同一メーカータイトル一覧のテストアプリをコミット
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@2099 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2008-08-05 05:22:35 +00:00

125 lines
3.4 KiB
C

/*---------------------------------------------------------------------------*
Project: TwlSDK - demos - os - reset-1
File: font.c
Copyright 2003 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#ifdef SDK_TWL
#include <twl.h>
#else
#include <nitro.h>
#endif
#include "screen.h"
u16 gScreen[2][32 * 32];
// ** these code are refer to rtc sample. thanks.
/*---------------------------------------------------------------------------*
Name: ClearScreen
Description: clear screen buffer
Arguments: None.
Returns: None.
*---------------------------------------------------------------------------*/
void ClearScreen(void)
{
MI_CpuClearFast((void *)gScreen[0], sizeof(gScreen) / 2);
}
void ClearSubScreen(void)
{
MI_CpuClearFast((void *)gScreen[1], sizeof(gScreen) / 2);
}
/*---------------------------------------------------------------------------*
Name: PrintString
Description: enter string into screen buffer
string must be within 32 chars
Arguments: x : x
y : y
palette : color (0-15)
text : string. end mark is NULL
Returns: None.
*---------------------------------------------------------------------------*/
void PrintString(s16 x, s16 y, u8 palette, char *text, ...)
{
va_list vlist;
char temp[32 + 2], *tempPtr;
s32 i;
u16 *p, *pLimit;
u32 index = (u32)(y / 24);
y = (s16)(y % 24);
va_start(vlist, text);
(void)vsnprintf(temp, 33, text, vlist);
va_end(vlist);
*(u16 *)(&temp[32]) = 0;
p = &gScreen[index][((y * 32) + x) % (32 * 32)];
pLimit = &gScreen[index][32 * 32];
tempPtr = &temp[0];
for (i = 0; *tempPtr; i++, tempPtr++)
{
*p = (u16)((palette << 12) | *tempPtr);
if (++p >= pLimit)
{
p = &gScreen[index][0];
}
}
}
/*---------------------------------------------------------------------------*
Name: ColorString
Description: change string color which is put in screen buffer
Arguments: x : x
y : y
length : number of characters to change color
palette : color (0-15)
Returns: None.
*---------------------------------------------------------------------------*/
void ColorString(s16 x, s16 y, s16 length, u8 palette)
{
s32 i;
u16 *p, *pLimit;
u32 index = (u32)(y / 24);
y = (s16)(y % 24);
if (length < 0)
return;
p = &gScreen[index][((y * 32) + x) % (32 * 32)];
pLimit = &gScreen[index][32 * 32];
for (i = 0; i < length; i++)
{
u16 temp = *p;
temp &= 0x0fff;
temp |= (palette << 12);
*p = temp;
if (++p >= pLimit)
{
p = &gScreen[index][0];
}
}
}