| plan 9 kernel history: overview | file list | diff list |
1993/0918/carrera/screen.c (diff list | history)
| 1993/0916/sys/src/9/carrera/screen.c:42,48 – 1993/0918/sys/src/9/carrera/screen.c:42,47 (short | long | prev | next) | ||
| 1993/0906 | uchar crt[0x19]; uchar graphics[9]; uchar attribute[0x15]; | |
| 1993/0907 | struct { uchar viden; uchar sr6; | |
| 1993/0916/sys/src/9/carrera/screen.c:89,105 – 1993/0918/sys/src/9/carrera/screen.c:88,108 | ||
| 1993/0906 | extern GSubfont defont0; GSubfont *defont; | |
| 1993/0918 | 0, 0, (1024*(1<<3))/32, 3, { 0, 0, 1024, 768 }, { 0, 0, 1024, 768 }, 0 }; GBitmap vgascreen = { | |
| 1993/0907 | EISA(0xA0000), | |
| 1993/0906 | 0, (1024*(1<<3))/32, | |
| 1993/0916/sys/src/9/carrera/screen.c:145,237 – 1993/0918/sys/src/9/carrera/screen.c:148,209 | ||
| 1993/0906 | static Point cursor; static int h, w; extern Cursor arrow; | |
| 1993/0918 | static ulong colormap[256][3]; static Rectangle mbb; static Rectangle NULLMBB = {10000, 10000, -10000, -10000}; static int isscroll; | |
| 1993/0906 | ||
| 1993/0916 |
| |
| 1993/0906 | void | |
| 1993/0918 | defont = &defont0; | |
| 1993/0906 |
| |
| 1993/0918 | window.min = Pt(50, 50); window.max = add(window.min, Pt(10+w*100, 10+h*40)); | |
| 1993/0906 | gbitblt(&gscreen, window.min, &gscreen, window, Zero); window = inset(window, 5); cursor = window.min; window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; | |
| 1993/0918 | mbb = gscreen.r; screenupdate(); | |
| 1993/0906 | } | |
| 1993/0908 |
| |
| 1993/0918 | /* * expand 3 and 6 bits of color to 32 */ static ulong x3to32(uchar x) { ulong y; | |
| 1993/0908 | ||
| 1993/0918 | 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; } | |
| 1993/0906 | void screeninit(void) { | |
| 1993/0907 |
| |
| 1993/0918 | int i; | |
| 1993/0907 | ||
| 1993/0906 | setmode(&dfltmode); | |
| 1993/0908 |
| |
| 1993/0906 |
| |
| 1993/0918 | for(i = 0; i < 256; i++) setcolor(i, x3to32(i>>5), x3to32(i>>2), x3to32(i<<1)); | |
| 1993/0906 | ||
| 1993/0908 |
| |
| 1993/0907 |
| |
| 1993/0918 | /* allocate a new soft bitmap area */ gscreen.base = xalloc(1024*1024); | |
| 1993/0907 |
| |
| 1993/0906 |
| |
| 1993/0907 |
| |
| 1993/0906 | gbitblt(&gscreen, Pt(0, 0), &gscreen, gscreen.r, 0); | |
| 1993/0907 |
| |
| 1993/0906 |
| |
| 1993/0918 | memmove(&arrow, &fatarrow, sizeof(fatarrow)); | |
| 1993/0906 | screenwin(); } | |
| 1993/0916/sys/src/9/carrera/screen.c:247,254 – 1993/0918/sys/src/9/carrera/screen.c:219,253 | ||
| 1993/0906 | r = Rpt(Pt(window.min.x, window.max.y-o), window.max); gbitblt(&gscreen, r.min, &gscreen, r, Zero); cursor.y -= o; | |
| 1993/0918 | isscroll = 1; | |
| 1993/0906 | } | |
| 1993/0918 | void mbbrect(Rectangle r) { if (r.min.x < mbb.min.x) mbb.min.x = r.min.x; if (r.min.y < mbb.min.y) mbb.min.y = r.min.y; if (r.max.x > mbb.max.x) mbb.max.x = r.max.x; if (r.max.y > mbb.max.y) mbb.max.y = r.max.y; } void mbbpt(Point p) { if (p.x < mbb.min.x) mbb.min.x = p.x; if (p.y < mbb.min.y) mbb.min.y = p.y; if (p.x >= mbb.max.x) mbb.max.x = p.x+1; if (p.y >= mbb.max.y) mbb.max.y = p.y+1; } | |
| 1993/0906 | static void screenputc(char *buf) { | |
| 1993/0916/sys/src/9/carrera/screen.c:276,286 – 1993/0918/sys/src/9/carrera/screen.c:275,285 | ||
| 1993/0906 | default: if(cursor.x >= window.max.x-w) screenputc("\n"); | |
| 1993/0918 | ||
| 1993/0906 | cursor = gsubfstring(&gscreen, cursor, &defont0, buf, S); } } | |
| 1993/0916/sys/src/9/carrera/screen.c:288,294 – 1993/0918/sys/src/9/carrera/screen.c:287,293 | ||
| 1993/0906 | Rune r; char buf[4]; | |
| 1993/0918 | if((getstatus() & IE) == 0) { | |
| 1993/0906 | /* don't deadlock trying to print in interrupt */ if(!canlock(&screenlock)) return; | |
| 1993/0916/sys/src/9/carrera/screen.c:296,302 – 1993/0918/sys/src/9/carrera/screen.c:295,302 | ||
| 1993/0906 | else lock(&screenlock); | |
| 1993/0918 | mbbpt(cursor); while(n > 0) { | |
| 1993/0906 | i = chartorune(&r, s); if(i == 0){ s++; | |
| 1993/0916/sys/src/9/carrera/screen.c:309,360 – 1993/0918/sys/src/9/carrera/screen.c:309,346 | ||
| 1993/0906 | s += i; screenputc(buf); } | |
| 1993/0918 | if(isscroll) { mbb = window; isscroll = 0; } else mbbpt(Pt(cursor.x, cursor.y+h)); screenupdate(); | |
| 1993/0906 | unlock(&screenlock); } | |
| 1993/0918 | p &= (1<<(1<<gscreen.ldepth))-1; *pr = colormap[p][0]; *pg = colormap[p][1]; *pb = colormap[p][2]; | |
| 1993/0906 | } int setcolor(ulong p, ulong r, ulong g, ulong b) { | |
| 1993/0918 | p &= (1<<(1<<gscreen.ldepth))-1; colormap[p][0] = r; colormap[p][1] = g; colormap[p][2] = b; EISAOUTB(CMWX, 255-p); EISAOUTB(CM, r>>(32-6)); EISAOUTB(CM, g>>(32-6)); EISAOUTB(CM, b>>(32-6)); return ~0; | |
| 1993/0906 | } void | |
| 1993/0916/sys/src/9/carrera/screen.c:384,401 – 1993/0918/sys/src/9/carrera/screen.c:370,375 | ||
| 1993/0906 | } void | |
| 1993/0916/sys/src/9/carrera/screen.c:490,495 – 1993/0918/sys/src/9/carrera/screen.c:464,470 | ||
| 1993/0907 | EISAOUTB(0x3C6, 0xFF); /* pel mask */ EISAOUTB(0x3C8, 0x00); /* pel write address */ | |
| 1993/0918 | ||
| 1993/0907 | EISAOUTB(0x3bf, 0x03); /* hercules compatibility reg */ EISAOUTB(0x3d8, 0xa0); /* display mode control register */ | |
| 1993/0916/sys/src/9/carrera/screen.c:512,609 – 1993/0918/sys/src/9/carrera/screen.c:487,551 | ||
| 1993/0906 | srout(1, v->sequencer[1]); | |
| 1993/0908 | } | |
| 1993/0918 | #define swiz(s) (s<<24)|((s>>8)&0xff00)|((s<<8)&0xff0000)|(s>>24) | |
| 1993/0908 |
| |
| 1993/0918 | void twizzle(uchar *f, uchar *t) | |
| 1993/0908 | { | |
| 1993/0918 | ulong in1, in2; | |
| 1993/0908 |
| |
| 1993/0918 | in1 = *(ulong*)f; in2 = *(ulong*)(f+4); *(ulong*)t = swiz(in2); *(ulong*)(t+4) = swiz(in1); | |
| 1993/0908 | } void | |
| 1993/0918 | screenupdate(void) | |
| 1993/0908 | { | |
| 1993/0918 | uchar *sp, *hp, *edisp; int i, y, len, off, page, inc; Rectangle r; | |
| 1993/0908 |
| |
| 1993/0918 | r = mbb; mbb = NULLMBB; | |
| 1993/0908 |
| |
| 1993/0918 | if(Dy(r) < 0) return; | |
| 1993/0908 |
| |
| 1993/0918 | if(r.min.x < 0) r.min.x = 0; if(r.min.y < 0) r.min.y = 0; if(r.max.x > gscreen.r.max.x) r.max.x = gscreen.r.max.x; if(r.max.y > gscreen.r.max.y) r.max.y = gscreen.r.max.y; | |
| 1993/0908 |
| |
| 1993/0918 | r.min.x &= ~7; len = r.max.x - r.min.x; len = (len+7)&~7; if(len <= 0) return; | |
| 1993/0908 |
| |
| 1993/0918 | inc = gscreen.width*4; off = r.min.y * inc + r.min.x; sp = ((uchar*)gscreen.base) + off; page = off>>16; off &= (1<<16)-1; hp = edisp = 0; for(y = r.min.y; y < r.max.y; y++){ if(hp >= edisp){ hp = ((uchar*)vgascreen.base) + off; edisp = ((uchar*)vgascreen.base) + 64*1024; EISAOUTB(0x3cd, (page<<4) | page); off = r.min.x; page++; } for(i = 0; i < len; i += 8) twizzle(sp+i, hp+i); hp += inc; sp += inc; | |
| 1993/0908 | } | |
| 1993/0906 | } | |