Implement PrintFormat which scrolls the screen when overflowing
This commit is contained in:
parent
9cfcb0ddf7
commit
dfb8fb16fc
3 changed files with 26 additions and 0 deletions
|
@ -188,6 +188,16 @@ void Screen::ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2)
|
|||
}
|
||||
}
|
||||
|
||||
void Screen::ScrollUp(u32 pixels)
|
||||
{
|
||||
memcpy(
|
||||
framebuffer,
|
||||
framebuffer + pixels * 2 * pitch,
|
||||
(height - pixels * 2) * pitch
|
||||
);
|
||||
DrawRectangle(0, height - pixels, width, height, RGBA(0, 0, 0, 0xFF));
|
||||
}
|
||||
|
||||
void Screen::Clear(RGBA colour)
|
||||
{
|
||||
DrawRectangle(0, 0, width, height, colour);
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
void Clear(RGBA colour);
|
||||
|
||||
void ScrollArea(u32 x1, u32 y1, u32 x2, u32 y2);
|
||||
void ScrollUp(u32 pixels);
|
||||
|
||||
void WriteChar(bool petscii, u32 x, u32 y, unsigned char c, RGBA colour);
|
||||
u32 PrintText(bool petscii, u32 xPos, u32 yPos, char *ptr, RGBA TxtColour = RGBA(0xff, 0xff, 0xff, 0xff), RGBA BkColour = RGBA(0, 0, 0, 0xFF), bool measureOnly = false, u32* width = 0, u32* height = 0);
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -1867,6 +1867,21 @@ void DisplayMessage(int x, int y, bool LCD, const char* message, u32 textColour,
|
|||
#endif
|
||||
}
|
||||
|
||||
int y_pos = 184;
|
||||
void PrintFormat(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsnprintf(tempBuffer, tempBufferSize, format, args);
|
||||
va_end(args);
|
||||
|
||||
if (y_pos + 96 >= screenHeight) {
|
||||
screen.ScrollUp(8);
|
||||
y_pos -= 16;
|
||||
}
|
||||
screen.PrintText(false, 0, y_pos+=16, tempBuffer, COLOUR_WHITE, COLOUR_BLACK);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void kernel_main(unsigned int r0, unsigned int r1, unsigned int atags)
|
||||
|
|
Loading…
Reference in a new issue