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)
28 tg_rect(0, 0, 0, 80, 25, 0);
31 void tg_fgcolor(int col)
37 void tg_bgcolor(int col)
43 void tg_color(int col)
46 bgcol = (col >> 4) & 0xf;
55 #define CRTC_ADDR_PORT 0x3d4
56 #define CRTC_DATA_PORT 0x3d5
57 #define REG_CRTC_CURH 0xe
58 #define REG_CRTC_CURL 0xf
60 void tg_setcursor(int x, int y)
62 unsigned int addr = y * 80 + x;
64 outpw(CRTC_ADDR_PORT, (addr & 0xff00) | REG_CRTC_CURH);
65 outpw(CRTC_ADDR_PORT, (addr << 8) | REG_CRTC_CURL);
68 void tg_text(int x, int y, const char *fmt, ...)
73 tg_vtext(x, y, fmt, ap);
77 void tg_vtext(int x, int y, const char *fmt, va_list ap)
80 unsigned short *fbptr = framebuf + y * 80 + x;
82 vsprintf(buf, fmt, ap);
86 *fbptr++ = *ptr++ | attr;
90 void tg_rect(const char *label, int x, int y, int xsz, int ysz, unsigned int flags)
93 unsigned short *fbptr = framebuf + y * 80 + x;
95 for(i=0; i<ysz; i++) {
96 for(j=0; j<xsz; j++) {
97 fbptr[j] = attr | bgchar;
102 if(flags & TGFX_FRAME) {
103 fbptr = framebuf + y * 80 + x;
104 for(i=0; i<xsz-2; i++) {
105 fbptr[i + 1] = attr | 0xcd;
106 fbptr[(ysz-1) * 80 + i + 1] = attr | 0xcd;
108 for(i=0; i<ysz-2; i++) {
109 fbptr[(i + 1) * 80] = attr | 0xba;
110 fbptr[(xsz-1) + (i + 1) * 80] = attr | 0xba;
112 fbptr[0] = attr | 0xc9;
113 fbptr[xsz-1] = attr | 0xbb;
114 fbptr += (ysz - 1) * 80;
115 fbptr[0] = attr | 0xc8;
116 fbptr[xsz-1] = attr | 0xbc;
120 tg_text(x + 2, y, "%s", label);
124 int tg_gchar(int gchar)