7 static unsigned short attr = 0x0700;
8 static int bgcol = 0, fgcol = 7;
9 static int bgchar = ' ';
10 static unsigned short *framebuf = (unsigned short*)0xb8000;
12 #define UPD_ATTR attr = (fgcol << 8) | (bgcol << 12)
16 tg_rect(0, 0, 0, 80, 25, 0);
19 void tg_fgcolor(int col)
25 void tg_bgcolor(int col)
31 void tg_color(int col)
34 bgcol = (col >> 4) & 0xf;
43 #define CRTC_ADDR_PORT 0x3d4
44 #define CRTC_DATA_PORT 0x3d5
45 #define REG_CRTC_CURH 0xe
46 #define REG_CRTC_CURL 0xf
48 void tg_setcursor(int x, int y)
50 unsigned int addr = y * 80 + x;
52 outpw(CRTC_ADDR_PORT, (addr & 0xff00) | REG_CRTC_CURH);
53 outpw(CRTC_ADDR_PORT, (addr << 8) | REG_CRTC_CURL);
56 void tg_text(int x, int y, const char *fmt, ...)
61 tg_vtext(x, y, fmt, ap);
65 void tg_vtext(int x, int y, const char *fmt, va_list ap)
68 unsigned short *fbptr = framebuf + y * 80 + x;
70 vsprintf(buf, fmt, ap);
74 *fbptr++ = *ptr++ | attr;
78 void tg_rect(const char *label, int x, int y, int xsz, int ysz, unsigned int flags)
81 unsigned short *fbptr = framebuf + y * 80 + x;
83 for(i=0; i<ysz; i++) {
84 for(j=0; j<xsz; j++) {
85 fbptr[j] = attr | bgchar;
90 if(flags & TGFX_FRAME) {
91 fbptr = framebuf + y * 80 + x;
92 for(i=0; i<xsz-2; i++) {
93 fbptr[i + 1] = attr | 0xcd;
94 fbptr[(ysz-1) * 80 + i + 1] = attr | 0xcd;
96 for(i=0; i<ysz-2; i++) {
97 fbptr[(i + 1) * 80] = attr | 0xba;
98 fbptr[(xsz-1) + (i + 1) * 80] = attr | 0xba;
100 fbptr[0] = attr | 0xc9;
101 fbptr[xsz-1] = attr | 0xbb;
102 fbptr += (ysz - 1) * 80;
103 fbptr[0] = attr | 0xc8;
104 fbptr[xsz-1] = attr | 0xbc;
108 tg_text(x + 2, y, "%s", label);