void Console_MoveToNextLine() { if (gConsole_CursorRow + 1 >= gConsole_Rows) { uint32_t lengthToCopyUp = ((gConsole_Rows - 1) * gConsole_Columns) * 2; memcpy((char*)gConsole_BaseMemory, ((char*)gConsole_BaseMemory) + (gConsole_Columns * 2), lengthToCopyUp); for (uint32_t index = 0; index < gConsole_Columns; ++index) { *(gConsole_BaseMemory + (((gConsole_Rows - 1) * gConsole_Columns) * 2) + (index * 2)) = ' '; } gConsole_CursorRow = gConsole_Rows - 1; } else ++gConsole_CursorRow; Console_MoveTo(0, gConsole_CursorRow); }
int main(void) { static FPSCounterState fps; uint32 frameFence = 0; uint32 nextFence; Intr_Init(); Intr_SetFaultHandlers(SVGA_DefaultFaultHandler); SVGA_Init(); GMR_Init(); Heap_Reset(); SVGA_SetMode(0, 0, 32); SVGA3D_Init(); Screen_Init(); ScreenDraw_Init(0); initScreens(); setup3D(); /* * One big circle, and a smaller one that overlaps the top-right * corner. (This tests positive and negative clipping extremes.) */ prepareCircle(&circles[0], 650, 400, 300); prepareCircle(&circles[1], 1000, 50, 250); while (1) { if (SVGA3DUtil_UpdateFPSCounter(&fps)) { Console_MoveTo(900, 730); Console_Format("%s ", fps.text); } drawCube(); /* * Flow control- one frame in the FIFO at a time. */ nextFence = SVGA_InsertFence(); SVGA_SyncToFence(frameFence); frameFence = nextFence; present(); } return 0; }
static void initScreens(void) { static const SVGAScreenObject screen = { .structSize = sizeof(SVGAScreenObject), .id = 0, .flags = SVGA_SCREEN_HAS_ROOT | SVGA_SCREEN_IS_PRIMARY, .size = { 1024, 768 }, .root = { 1000, 2000 }, }; Screen_Define(&screen); ScreenDraw_SetScreen(screen.id, screen.size.width, screen.size.height); Console_Clear(); Console_Format("Surface-to-Screen Blit Clipping Test\n"); ScreenDraw_Border(0, 0, screen.size.width, screen.size.height, 0xFF0000, 1); Console_MoveTo(20, 45); Console_Format("Stair-step clipping (small tiles)"); Console_MoveTo(20, 245); Console_Format("Top/bottom halves swapped"); Console_MoveTo(20, 445); Console_Format("Scaled bottom half, with hole"); Console_MoveTo(350, 65); Console_Format("Zoomed to 1.5x full screen, two circular clip regions"); Console_MoveTo(5, 660); Console_Format("Stair-step, clipped against screen edges"); } /* * presentWithClipBuf -- * * Present our surface to the screen, with clipping data from a ClipBuffer. * * The supplied ClipBuffer is always in screen coordinates. We * convert them into dest-relative coordinates for the * surface-to-screen blit. */ static void presentWithClipBuf(ClipBuffer *buf, int dstL, int dstT, int dstR, int dstB) { SVGASignedRect srcRect = { 0, 0, surfWidth, surfHeight }; SVGASignedRect dstRect = { dstL, dstT, dstR, dstB }; SVGASignedRect *clip; int i; SVGA3D_BeginBlitSurfaceToScreen(&colorImage, &srcRect, 0, &dstRect, &clip, buf->numRects); for (i = 0; i < buf->numRects; i++) { clip->left = buf->rects[i].left - dstL; clip->top = buf->rects[i].top - dstT; clip->right = buf->rects[i].right - dstL; clip->bottom = buf->rects[i].bottom - dstT; clip++; } SVGA_FIFOCommitAll(); }
void Console_MoveToTopLeft() { Console_MoveTo(0, 0); }