| plan 9 kernel history: overview | file list | diff list |
1992/1113/pc/vga.c (diff list | history)
| 1992/1112/sys/src/9/pc/vga.c:17,30 – 1992/1113/sys/src/9/pc/vga.c:17,37 (short | long | prev | next) | ||
| 1991/0730 | int bwid; }out; | |
| 1992/1106 |
| |
| 1992/1113 | /* imported */ | |
| 1992/1112 | extern GSubfont defont0; | |
| 1992/1106 | ||
| 1992/1113 | /* exported */ GSubfont *defont; int islittle = 1; /* little endian bit ordering in bytes */ GBitmap gscreen; /* local */ static Lock vgalock; static GBitmap vgascreen; static ulong colormap[256][3]; | |
| 1991/0730 | /* * screen dimensions */ | |
| 1992/1112/sys/src/9/pc/vga.c:34,41 – 1992/1113/sys/src/9/pc/vga.c:41,46 | ||
| 1992/1106 | /* * 'soft' screen bitmap */ | |
| 1991/0730 | ||
| 1991/1113 | typedef struct VGAmode VGAmode; struct VGAmode | |
| 1992/1112/sys/src/9/pc/vga.c:48,54 – 1992/1113/sys/src/9/pc/vga.c:53,59 | ||
| 1991/1113 | }; | |
| 1991/0727 | /* | |
| 1992/1015 |
| |
| 1992/1113 | * 640x480 display, 1, 2, or 4 bit color. | |
| 1992/0414 | */ VGAmode mode12 = { | |
| 1992/1112/sys/src/9/pc/vga.c:70,75 – 1992/1113/sys/src/9/pc/vga.c:75,103 | ||
| 1992/1015 | 0x01, 0x10, 0x0f, 0x00, 0x00, | |
| 1992/0414 | }; | |
| 1992/0418 | ||
| 1992/1113 | /* * 640x480 display, 8 bit color. */ VGAmode mode13 = { /* general */ 0xe7, 0x00, /* sequence */ 0x03, 0x01, 0x0f, 0x00, 0x0e, /* crt */ 0x65, 0x4f, 0x50, 0x88, 0x55, 0x9a, 0x09, 0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x8b, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xA3, 0xff, /* graphics */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0f, 0xff, /* attribute */ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x41, 0x10, 0x0f, 0x00, 0x00, }; | |
| 1992/1106 | static Rectangle mbb; static Rectangle NULLMBB = {10000, 10000, -10000, -10000}; | |
| 1992/0430 | ||
| 1992/1112/sys/src/9/pc/vga.c:189,194 – 1992/1113/sys/src/9/pc/vga.c:217,223 | ||
| 1992/0502 | print("\n"); } | |
| 1992/1113 | #ifdef asdf | |
| 1992/0502 | void dumpmodes(void) { VGAmode *v; | |
| 1992/1112/sys/src/9/pc/vga.c:222,237 – 1992/1113/sys/src/9/pc/vga.c:251,298 | ||
| 1992/0423 | print(" %02x", inb(ARR)); } } | |
| 1992/1113 | #endif asdf | |
| 1992/0423 | ||
| 1992/1111 |
| |
| 1992/1113 | /* * expand 3 and 6 bits of color to 32 */ static ulong x3to32(uchar x) { ulong y; | |
| 1992/1111 | ||
| 1992/1113 | x = x&7; x= (x<<3)|x; y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); return y; } static ulong x6to32(uchar x) { ulong y; x = x&0x3f; y = (x<<(32-6))|(x<<(32-12))|(x<<(32-18))|(x<<(32-24))|(x<<(32-30)); return y; } | |
| 1992/0423 | void | |
| 1992/1106 | setscreen(int maxx, int maxy, int ldepth) | |
| 1992/0711 | { | |
| 1992/1106 |
| |
| 1992/1113 | int len, vgamaxy, width, i, x; | |
| 1992/1111 | uchar *p; | |
| 1992/1106 | ||
| 1992/1113 | if(ldepth == 3) setmode(&mode13); else setmode(&mode12); /* allocate a new soft bitmap area */ width = (maxx*(1<<ldepth))/32; len = width * BY2WD * maxy; p = xalloc(len); if(p == 0) panic("can't alloc screen bitmap"); | |
| 1992/1106 | mbb = NULLMBB; /* | |
| 1992/1112/sys/src/9/pc/vga.c:241,273 – 1992/1113/sys/src/9/pc/vga.c:302,327 | ||
| 1992/1109 | vgascreen.ldepth = 3; else vgascreen.ldepth = 0; | |
| 1992/1106 |
| |
| 1992/1110 | vgascreen.width = (maxx*(1<<vgascreen.ldepth))/32; | |
| 1992/1113 | vgamaxy = maxy % ((64*1024)/vgascreen.width); vgascreen.base = (void*)SCREENMEM; | |
| 1992/1112 | vgascreen.r.min = Pt(0, 0); | |
| 1992/1106 |
| |
| 1992/1113 | vgascreen.r.max = Pt(maxx, vgamaxy); | |
| 1992/1112 | vgascreen.clipr = vgascreen.r; | |
| 1992/1113 | memset(vgascreen.base, 0xff, vgascreen.width * BY2WD * vgamaxy); | |
| 1992/1106 | /* | |
| 1992/1109 | * setup new soft screen, free memory for old screen | |
| 1992/1106 | */ | |
| 1992/1113 | if(gscreen.base) xfree(gscreen.base); | |
| 1992/1106 | gscreen.ldepth = ldepth; | |
| 1992/1113 | gscreen.width = width; | |
| 1992/1112 | gscreen.r.min = Pt(0, 0); | |
| 1992/0603 | gscreen.r.max = Pt(maxx, maxy); | |
| 1992/1112 | gscreen.clipr = gscreen.r; | |
| 1992/1110 |
| |
| 1992/1109 |
| |
| 1992/1112 |
| |
| 1992/1111 |
| |
| 1992/1112 |
| |
| 1992/1111 |
| |
| 1992/1112 |
| |
| 1992/1107 |
| |
| 1992/1112 |
| |
| 1992/1113 | gscreen.base = (ulong*)p; memset(gscreen.base, 0xff, len); | |
| 1992/1106 | /* | |
| 1992/1112 | * set depth of cursor backup area | |
| 1992/1112/sys/src/9/pc/vga.c:280,295 – 1992/1113/sys/src/9/pc/vga.c:334,367 | ||
| 1992/0603 | out.pos.x = MINX; out.pos.y = 0; out.bwid = defont0.info[' '].width; | |
| 1992/1113 | /* * default color map */ switch(ldepth){ case 3: for(i = 0; i < 256; i++) setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1)); break; case 2: case 1: case 0: gscreen.ldepth = 3; for(i = 0; i < 16; i++){ x = x6to32((i*63)/15); setcolor(i, x, x, x); } gscreen.ldepth = ldepth; break; } | |
| 1992/0603 | } void | |
| 1991/0730 | screeninit(void) | |
| 1991/0723 | { | |
| 1992/1110 |
| |
| 1992/1113 | int i; | |
| 1991/0730 | ulong *l; | |
| 1991/0723 | ||
| 1992/0527 |
| |
| 1991/0929 | ||
| 1991/0727 | /* | |
| 1992/1106 | * arrow is defined as a big endian | |
| 1991/0801 | */ | |
| 1992/1112/sys/src/9/pc/vga.c:315,333 – 1992/1113/sys/src/9/pc/vga.c:387,392 | ||
| 1992/1106 | if(conf.maxy == 0) conf.maxy = MAXY; setscreen(conf.maxx, conf.maxy, conf.ldepth); | |
| 1992/1110 |
| |
| 1992/1111 |
| |
| 1992/1110 |
| |
| 1992/1112 |
| |
| 1992/1110 |
| |
| 1992/1112 |
| |
| 1992/1110 |
| |
| 1992/1112 |
| |
| 1991/0723 | } | |
| 1991/0727 | ||
| 1992/1106 | /* | |
| 1992/1112/sys/src/9/pc/vga.c:344,350 – 1992/1113/sys/src/9/pc/vga.c:403,410 | ||
| 1992/1106 | mbb.max.x = r.max.x; if (r.max.y > mbb.max.y) mbb.max.y = r.max.y; | |
| 1992/1113 | if (Dy(mbb) > 32 || Dx(mbb) > 32) mousescreenupdate(); | |
| 1992/1106 | } void | |
| 1992/1112/sys/src/9/pc/vga.c:369,376 – 1992/1113/sys/src/9/pc/vga.c:429,436 | ||
| 1992/1108 | /* * copy litte endian soft screen to big endian hard screen */ | |
| 1992/1106 |
| |
| 1992/1108 |
| |
| 1992/1113 | static void vgaupdate(void) | |
| 1992/1108 | { uchar *sp, *hp; | |
| 1992/1111 | int y, len, incs, inch, off, page, y2pg, ey; | |
| 1992/1112/sys/src/9/pc/vga.c:380,393 – 1992/1113/sys/src/9/pc/vga.c:440,445 | ||
| 1992/1108 | r = mbb; mbb = NULLMBB; | |
| 1992/1112 |
| |
| 1992/1108 | if(Dy(r) < 0) return; | |
| 1992/1112/sys/src/9/pc/vga.c:454,459 – 1992/1113/sys/src/9/pc/vga.c:506,512 | ||
| 1992/1111 | y2pg = (64*1024/BY2WD)/gscreen.width; off = (r.min.y % y2pg) * gscreen.width * BY2WD + r.min.x; hp = (uchar*)(vgascreen.base) + off; | |
| 1992/1113 | off = r.min.y * gscreen.width * BY2WD + r.min.x; | |
| 1992/1111 | sp = (uchar*)(gscreen.base) + off; len = r.max.x - r.min.x; if(len < 1) | |
| 1992/1112/sys/src/9/pc/vga.c:475,487 – 1992/1113/sys/src/9/pc/vga.c:528,549 | ||
| 1992/1111 | } break; | |
| 1992/1108 | } | |
| 1992/1113 | } | |
| 1992/1112 |
| |
| 1992/1113 | void screenupdate(void) { lock(&vgalock); vgaupdate(); unlock(&vgalock); } void mousescreenupdate(void) { if(canlock(&vgalock)){ vgaupdate(); unlock(&vgalock); | |
| 1992/1112 | } | |
| 1992/1108 | } | |
| 1992/1112/sys/src/9/pc/vga.c:497,507 – 1992/1113/sys/src/9/pc/vga.c:559,567 | ||
| 1992/1106 | r = Rect(0, out.pos.y, gscreen.r.max.x, out.pos.y+2*defont0.height); gbitblt(&gscreen, r.min, &gscreen, r, flipD[0]); mbbrect(r); | |
| 1992/1113 | vgaupdate(); | |
| 1991/0730 | } | |
| 1992/0402 |
| |
| 1991/0730 | void screenputs(char *s, int n) { | |
| 1992/1112/sys/src/9/pc/vga.c:541,547 – 1992/1113/sys/src/9/pc/vga.c:601,607 | ||
| 1991/1228 | } | |
| 1992/1106 | rs.max = Pt(gscreen.r.max.x, out.pos.y+defont0.height); mbbrect(rs); | |
| 1992/1113 | vgaupdate(); | |
| 1991/0730 | } int | |
| 1992/1112/sys/src/9/pc/vga.c:552,578 – 1992/1113/sys/src/9/pc/vga.c:612,625 | ||
| 1991/0730 | ||
| 1992/1106 | ||
| 1991/0730 | void | |
| 1992/1106 |
| |
| 1992/1112 |
| |
| 1992/1106 |
| |
| 1991/0730 | getcolor(ulong p, ulong *pr, ulong *pg, ulong *pb) { | |
| 1992/1112 | p &= (1<<(1<<gscreen.ldepth))-1; | |
| 1992/1113 | lock(&vgalock); *pr = colormap[p][0]; *pg = colormap[p][1]; *pb = colormap[p][2]; unlock(&vgalock); | |
| 1991/0730 | } int | |
| 1992/1112/sys/src/9/pc/vga.c:579,590 – 1992/1113/sys/src/9/pc/vga.c:626,640 | ||
| 1991/0730 | setcolor(ulong p, ulong r, ulong g, ulong b) { | |
| 1992/1112 | p &= (1<<(1<<gscreen.ldepth))-1; | |
| 1992/1113 | lock(&vgalock); colormap[p][0] = r; colormap[p][1] = g; colormap[p][2] = b; | |
| 1992/1112 | outb(CMWX, p); outb(CM, r>>(32-6)); outb(CM, g>>(32-6)); outb(CM, b>>(32-6)); | |
| 1992/1113 | unlock(&vgalock); | |
| 1992/1112 | return ~0; | |
| 1991/0730 | } | |
| 1992/1112/sys/src/9/pc/vga.c:605,610 – 1992/1113/sys/src/9/pc/vga.c:655,661 | ||
| 1991/0730 | void | |
| 1991/0904 | mouseclock(void) | |
| 1991/0730 | { | |
| 1992/1113 | spllo(); /* so we don't cause lost chars on the uart */ | |
| 1991/0730 | mouseupdate(1); | |
| 1991/0927 | } | |
| 1991/1113 | ||