void terminit(void) { memdefont = getmemdefont(); out.pos.x = MINX; out.pos.y = 0; out.bwid = memdefont->info[' '].width; screenwin(); screenputs = termscreenputs; }
void screeninit(void) { int i; /* map the lcd regs into the kernel's virtual space */ lcd = (struct sa1110regs*)mapspecial(LCDREGS, sizeof(struct sa1110regs));; framebuf = xspanalloc(sizeof *framebuf, 0x100, 0); vscreen = xalloc(sizeof(ushort)*Wid*Ht); lcdpower(1); lcdinit(); gscreen = &xgscreen; xgdata.ref = 1; i = 0; if (landscape) { gscreen->r = Rect(0, 0, Ht, Wid); gscreen->clipr = gscreen->r; gscreen->width = Ht/2; xgdata.bdata = (uchar *)framebuf->pixel; while (i < Wid*Ht*1/3) framebuf->pixel[i++] = 0xf800; /* red */ while (i < Wid*Ht*2/3) framebuf->pixel[i++] = 0xffff; /* white */ while (i < Wid*Ht*3/3) framebuf->pixel[i++] = 0x001f; /* blue */ } else { gscreen->r = Rect(0, 0, Wid, Ht); gscreen->clipr = gscreen->r; gscreen->width = Wid/2; xgdata.bdata = (uchar *)vscreen; while (i < Wid*Ht*1/3) vscreen[i++] = 0xf800; /* red */ while (i < Wid*Ht*2/3) vscreen[i++] = 0xffff; /* white */ while (i < Wid*Ht*3/3) vscreen[i++] = 0x001f; /* blue */ flushmemscreen(gscreen->r); } memimageinit(); memdefont = getmemdefont(); out.pos.x = MINX; out.pos.y = 0; out.bwid = memdefont->info[' '].width; blanktime = 3; /* minutes */ screenwin(); // screenputs = bitsyscreenputs; screenputs = nil; }
void screeninit(void) { uchar *fb; int set; ulong chan; set = screensize() == 0; fb = fbinit(set, &xgscreen.r.max.x, &xgscreen.r.max.y, &xgscreen.depth); if(fb == nil){ print("can't initialise %dx%dx%d framebuffer \n", xgscreen.r.max.x, xgscreen.r.max.y, xgscreen.depth); return; } xgscreen.clipr = xgscreen.r; switch(xgscreen.depth){ default: print("unsupported screen depth %d\n", xgscreen.depth); xgscreen.depth = 16; /* fall through */ case 16: chan = RGB16; break; case 24: chan = BGR24; break; case 32: chan = ARGB32; break; } memsetchan(&xgscreen, chan); conf.monitor = 1; xgdata.bdata = fb; xgdata.ref = 1; gscreen = &xgscreen; gscreen->width = wordsperline(gscreen->r, gscreen->depth); memimageinit(); memdefont = getmemdefont(); screenwin(); screenputs = myscreenputs; swcursorinit(); }
void screeninit(int x, int y, char *chanstr) { Point p, q; char *greet; char buf[128]; Memimage *grey; Rectangle r; int chan; cursorver = 0; memimageinit(); chan = strtochan(chanstr); if(chan == 0) error("bad screen channel string"); r = Rect(0, 0, x, y); gscreen = allocmemimage(r, chan); if(gscreen == nil){ snprint(buf, sizeof buf, "can't allocate screen image: %r"); error(buf); } offscreen = Pt(x + 100, y + 100); cursorr = Rect(0, 0, CURSORDIM, CURSORDIM); cursorset = allocmemimage(cursorr, GREY8); cursorclear = allocmemimage(cursorr, GREY1); if(cursorset == nil || cursorclear == nil){ freememimage(gscreen); freememimage(cursorset); freememimage(cursorclear); gscreen = nil; cursorset = nil; cursorclear = nil; snprint(buf, sizeof buf, "can't allocate cursor images: %r"); error(buf); } drawlock(); /* * set up goo for screenputs */ memdefont = getmemdefont(); back = memwhite; conscol = memblack; /* a lot of work to get a grey color */ curscol = allocmemimage(Rect(0,0,1,1), RGBA32); curscol->flags |= Frepl; curscol->clipr = gscreen->r; memfillcolor(curscol, 0xff0000ff); memfillcolor(gscreen, 0x444488FF); w = memdefont->info[' '].width; h = memdefont->height; window.min = addpt(gscreen->r.min, Pt(20,20)); window.max.x = window.min.x + Dx(gscreen->r)*3/4-40; window.max.y = window.min.y + Dy(gscreen->r)*3/4-100; memimagedraw(gscreen, window, memblack, ZP, memopaque, ZP, S); window = insetrect(window, 4); memimagedraw(gscreen, window, memwhite, ZP, memopaque, ZP, S); /* a lot of work to get a grey color */ grey = allocmemimage(Rect(0,0,1,1), CMAP8); grey->flags |= Frepl; grey->clipr = gscreen->r; memfillcolor(grey, 0xAAAAAAFF); memimagedraw(gscreen, Rect(window.min.x, window.min.y, window.max.x, window.min.y+h+5+6), grey, ZP, nil, ZP, S); freememimage(grey); window = insetrect(window, 5); greet = " Plan 9 Console "; p = addpt(window.min, Pt(10, 0)); q = memsubfontwidth(memdefont, greet); memimagestring(gscreen, p, conscol, ZP, memdefont, greet); window.min.y += h+6; curpos = window.min; window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; flushmemscreen(gscreen->r); drawunlock(); setcursor(&arrow); }
int screensize(int x, int y, int z, uint32_t chan) { Proc *up = externup(); VGAscr *scr; void *oldsoft; lock(&vgascreenlock); if(waserror()){ unlock(&vgascreenlock); nexterror(); } memimageinit(); scr = &vgascreen[0]; oldsoft = softscreen; if(scr->paddr == 0){ int width = (x*z)/BI2WD; void *p; p = malloc(width*BY2WD*y); if(p == nil) error("no memory for vga soft screen"); gscreendata.bdata = softscreen = p; if(scr->dev && scr->dev->page){ scr->vaddr = KADDR(VGAMEM()); scr->apsize = 1<<16; } scr->useflush = 1; } else{ gscreendata.bdata = scr->vaddr; scr->useflush = scr->dev && scr->dev->flush; } scr->gscreen = nil; if(gscreen) freememimage(gscreen); gscreen = allocmemimaged(Rect(0,0,x,y), chan, &gscreendata); if(gscreen == nil) error("no memory for vga memimage"); vgaimageinit(chan); scr->palettedepth = 6; /* default */ scr->gscreendata = &gscreendata; scr->memdefont = getmemdefont(); scr->gscreen = gscreen; physgscreenr = gscreen->r; unlock(&vgascreenlock); poperror(); if(oldsoft) free(oldsoft); memimagedraw(gscreen, gscreen->r, memblack, ZP, nil, ZP, S); flushmemscreen(gscreen->r); if(didswcursorinit) swcursorinit(); drawcmap(); return 0; }
void main(int argc, char **argv) { char *mtpt, *srvname; mtpt = nil; srvname = "font"; ARGBEGIN{ case 'D': chatty9p++; break; case 'F': chattyfuse++; break; case 'm': mtpt = EARGF(usage()); break; case 's': srvname = EARGF(usage()); break; case 'p': pflag++; break; default: usage(); }ARGEND xsrv.attach = xattach; xsrv.open = xopen; xsrv.read = xread; xsrv.stat = xstat; xsrv.walk1 = xwalk1; xsrv.destroyfid = xdestroyfid; fmtinstall('R', Rfmt); fmtinstall('P', Pfmt); memimageinit(); defont = getmemdefont(); loadfonts(); qsort(xfont, nxfont, sizeof xfont[0], fontcmp); if(pflag) { if(argc != 1 || chatty9p || chattyfuse) usage(); dump(argv[0]); exits(0); } if(pflag || argc != 0) usage(); /* * Check twice -- if there is an exited instance * mounted there, the first access will fail but unmount it. */ if(mtpt && access(mtpt, AEXIST) < 0 && access(mtpt, AEXIST) < 0) sysfatal("mountpoint %s does not exist", mtpt); xsrv.foreground = 1; threadpostmountsrv(&xsrv, srvname, mtpt, 0); }