2 * Acess GUI (AxWin) Version 2
3 * By John Hodge (thePowersGang)
7 #include <acess/devices/terminal.h>
10 void Video_Setup(void);
11 void Video_Update(void);
12 void Video_FillRect(short X, short Y, short W, short H, uint32_t Color);
17 void Video_Setup(void)
22 giTerminalFD = open(gsTerminalDevice, OPENFLAG_READ|OPENFLAG_WRITE);
23 if( giTerminalFD == -1 )
25 fprintf(stderr, "ERROR: Unable to open '%s' (%i)\n", gsTerminalDevice, _errno);
30 tmpInt = giScreenWidth;
31 tmpInt = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, &tmpInt );
32 if(tmpInt != giScreenWidth)
34 fprintf(stderr, "Warning: Selected width (%i) is invalid, clipped to %i\n",
35 giScreenWidth, tmpInt);
36 giScreenWidth = tmpInt;
40 tmpInt = giScreenHeight;
41 tmpInt = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, &tmpInt );
42 if(tmpInt != giScreenHeight)
44 fprintf(stderr, "Warning: Selected height (%i) is invalid, clipped to %i\n",
45 giScreenHeight, tmpInt);
46 giScreenHeight = tmpInt;
50 tmpInt = TERM_MODE_FB;
51 ioctl( giTerminalFD, TERM_IOCTL_MODETYPE, &tmpInt );
53 // Force VT8 to be shown
54 ioctl( giTerminalFD, TERM_IOCTL_FORCESHOW, NULL );
56 // Create local framebuffer (back buffer)
57 gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 );
58 memset32( gpScreenBuffer, 0x8888FF, giScreenWidth*giScreenHeight );
62 void Video_Update(void)
64 //seek(giTerminalFD, 0, SEEK_SET);
65 seek(giTerminalFD, 0, 1);
66 write(giTerminalFD, giScreenWidth*giScreenHeight*4, gpScreenBuffer);
69 void Video_FillRect(short X, short Y, short W, short H, uint32_t Color)
71 uint32_t *buf = gpScreenBuffer + Y*giScreenWidth + X;
73 _SysDebug("Video_FillRect: (X=%i, Y=%i, W=%i, H=%i, Color=%08x)",
76 if(W < 0 || X < 0 || X >= giScreenWidth) return ;
77 if(X + W > giScreenWidth) W = giScreenWidth - X;
79 if(H < 0 || Y < 0 || Y >= giScreenHeight) return ;
80 if(Y + H > giScreenHeight) H = giScreenHeight - Y;
84 memset32( buf, Color, W );
89 void Video_DrawRect(short X, short Y, short W, short H, uint32_t Color)
91 Video_FillRect(X, Y, W, 1, Color);
92 Video_FillRect(X, Y+H-1, W, 1, Color);
93 Video_FillRect(X, Y, 1, H, Color);
94 Video_FillRect(X+W-1, Y, 1, H, Color);
97 void Video_DrawText(short X, short Y, short W, short H, void *Font, int Point, uint32_t Color, char *Text)