📄 cfb.c
字号:
DELAY(2000); /* ???? check right time on specs! ???? */ /* use 4:1 input mux */ bt459_write_reg(regs, BT459_REG_CMD0, 0x40); /* no zooming, no panning */ bt459_write_reg(regs, BT459_REG_CMD1, 0x00); /* * signature test, X-windows cursor, no overlays, SYNC* PLL, * normal RAM select, 7.5 IRE pedestal, do sync */#ifndef PMAX bt459_write_reg(regs, BT459_REG_CMD2, 0xc2);#else /* PMAX */ bt459_write_reg(regs, BT459_REG_CMD2, 0xc0);#endif /* PMAX */ /* get all pixel bits */ bt459_write_reg(regs, BT459_REG_PRM, 0xff); /* no blinking */ bt459_write_reg(regs, BT459_REG_PBM, 0x00); /* no overlay */ bt459_write_reg(regs, BT459_REG_ORM, 0x00); /* no overlay blink */ bt459_write_reg(regs, BT459_REG_OBM, 0x00); /* no interleave, no underlay */ bt459_write_reg(regs, BT459_REG_ILV, 0x00); /* normal operation, no signature analysis */ bt459_write_reg(regs, BT459_REG_TEST, 0x00); /* * no blinking, 1bit cross hair, XOR reg&crosshair, * no crosshair on either plane 0 or 1, * regular cursor on both planes. */ bt459_write_reg(regs, BT459_REG_CCR, 0xc0); /* home cursor */ bt459_write_reg(regs, BT459_REG_CXLO, 0x00); bt459_write_reg(regs, BT459_REG_CXHI, 0x00); bt459_write_reg(regs, BT459_REG_CYLO, 0x00); bt459_write_reg(regs, BT459_REG_CYHI, 0x00); /* no crosshair window */ bt459_write_reg(regs, BT459_REG_WXLO, 0x00); bt459_write_reg(regs, BT459_REG_WXHI, 0x00); bt459_write_reg(regs, BT459_REG_WYLO, 0x00); bt459_write_reg(regs, BT459_REG_WYHI, 0x00); bt459_write_reg(regs, BT459_REG_WWLO, 0x00); bt459_write_reg(regs, BT459_REG_WWHI, 0x00); bt459_write_reg(regs, BT459_REG_WHLO, 0x00); bt459_write_reg(regs, BT459_REG_WHHI, 0x00); /* * Initialize screen info. */ fp->fbu->scrInfo.max_row = 56; fp->fbu->scrInfo.max_col = 80; fp->fbu->scrInfo.max_x = 1024; fp->fbu->scrInfo.max_y = 864; fp->fbu->scrInfo.max_cur_x = 1023; fp->fbu->scrInfo.max_cur_y = 863; fp->fbu->scrInfo.version = 11; fp->fbu->scrInfo.mthreshold = 4; fp->fbu->scrInfo.mscale = 2; fp->fbu->scrInfo.min_cur_x = 0; fp->fbu->scrInfo.min_cur_y = 0; fp->fbu->scrInfo.qe.timestamp_ms = TO_MS(time); fp->fbu->scrInfo.qe.eSize = PM_MAXEVQ; fp->fbu->scrInfo.qe.eHead = fp->fbu->scrInfo.qe.eTail = 0; fp->fbu->scrInfo.qe.tcSize = MOTION_BUFFER_SIZE; fp->fbu->scrInfo.qe.tcNext = 0; /* * Initialize the color map, the screen, and the mouse. */ cfbInitColorMap(); cfbScreenInit(); fbScroll(fp); fp->initialized = 1; if (cn_tab.cn_fb == (struct pmax_fb *)0) cn_tab.cn_fb = fp; return (1);}/* * ---------------------------------------------------------------------------- * * cfbScreenInit -- * * Initialize the screen. * * Results: * None. * * Side effects: * The screen is initialized. * * ---------------------------------------------------------------------------- */static voidcfbScreenInit(){ register struct pmax_fb *fp = &cfbfb; /* * Home the cursor. * We want an LSI terminal emulation. We want the graphics * terminal to scroll from the bottom. So start at the bottom. */ fp->row = 55; fp->col = 0; /* * Load the cursor with the default values * */ cfbLoadCursor(defCursor);}/* * ---------------------------------------------------------------------------- * * RestoreCursorColor -- * * Routine to restore the color of the cursor. * * Results: * None. * * Side effects: * None. * * ---------------------------------------------------------------------------- */static voidcfbRestoreCursorColor(){ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); register int i;#ifndef PMAX bt459_select_reg(regs, BT459_REG_CCOLOR_2); for (i = 0; i < 6; i++) { regs->addr_reg = cursor_RGB[i]; MachEmptyWriteBuffer(); }#else /* PMAX */ bt459_select_reg(regs, BT459_REG_CCOLOR_1); for (i = 0; i < 3; i++) { regs->addr_reg = cursor_RGB[i]; MachEmptyWriteBuffer(); } bt459_select_reg(regs, BT459_REG_CCOLOR_3); for (i = 3; i < 6; i++) { regs->addr_reg = cursor_RGB[i]; MachEmptyWriteBuffer(); }#endif /* PMAX */}/* * ---------------------------------------------------------------------------- * * CursorColor -- * * Set the color of the cursor. * * Results: * None. * * Side effects: * None. * * ---------------------------------------------------------------------------- */static voidcfbCursorColor(color) unsigned int color[];{ register int i, j; for (i = 0; i < 6; i++) cursor_RGB[i] = (u_char)(color[i] >> 8); cfbRestoreCursorColor();}/* *---------------------------------------------------------------------- * * PosCursor -- * * Postion the cursor. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */voidcfbPosCursor(x, y) register int x, y;{ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); register struct pmax_fb *fp = &cfbfb; if (y < fp->fbu->scrInfo.min_cur_y || y > fp->fbu->scrInfo.max_cur_y) y = fp->fbu->scrInfo.max_cur_y; if (x < fp->fbu->scrInfo.min_cur_x || x > fp->fbu->scrInfo.max_cur_x) x = fp->fbu->scrInfo.max_cur_x; fp->fbu->scrInfo.cursor.x = x; /* keep track of real cursor */ fp->fbu->scrInfo.cursor.y = y; /* position, indep. of mouse */ x += 219; y += 34; bt459_select_reg(regs, BT459_REG_CXLO); regs->addr_reg = x; MachEmptyWriteBuffer(); regs->addr_reg = x >> 8; MachEmptyWriteBuffer(); regs->addr_reg = y; MachEmptyWriteBuffer(); regs->addr_reg = y >> 8; MachEmptyWriteBuffer();}/* * ---------------------------------------------------------------------------- * * InitColorMap -- * * Initialize the color map. * * Results: * None. * * Side effects: * The colormap is initialized appropriately. * * ---------------------------------------------------------------------------- */static voidcfbInitColorMap(){ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); register int i; bt459_select_reg(regs, 0); regs->addr_cmap = 0; MachEmptyWriteBuffer(); regs->addr_cmap = 0; MachEmptyWriteBuffer(); regs->addr_cmap = 0; MachEmptyWriteBuffer(); for (i = 1; i < 256; i++) { regs->addr_cmap = 0xff; MachEmptyWriteBuffer(); regs->addr_cmap = 0xff; MachEmptyWriteBuffer(); regs->addr_cmap = 0xff; MachEmptyWriteBuffer(); } for (i = 0; i < 3; i++) { cursor_RGB[i] = 0x00; cursor_RGB[i + 3] = 0xff; } cfbRestoreCursorColor();}/* * ---------------------------------------------------------------------------- * * LoadColorMap -- * * Load the color map. * * Results: * None. * * Side effects: * The color map is loaded. * * ---------------------------------------------------------------------------- */static voidcfbLoadColorMap(ptr) ColorMap *ptr;{ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); if (ptr->index > 256) return; bt459_select_reg(regs, ptr->index); regs->addr_cmap = ptr->Entry.red; MachEmptyWriteBuffer(); regs->addr_cmap = ptr->Entry.green; MachEmptyWriteBuffer(); regs->addr_cmap = ptr->Entry.blue; MachEmptyWriteBuffer();}/* * Video on/off state. */static struct vstate { u_char color0[3]; /* saved color map entry zero */ u_char off; /* TRUE if display is off */} vstate;/* * ---------------------------------------------------------------------------- * * bt459_video_on * * Enable the video display. * * Results: * None. * * Side effects: * The display is enabled. * * ---------------------------------------------------------------------------- */static voidbt459_video_on(){ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); if (!vstate.off) return; /* restore old color map entry zero */ bt459_select_reg(regs, 0); regs->addr_cmap = vstate.color0[0]; MachEmptyWriteBuffer(); regs->addr_cmap = vstate.color0[1]; MachEmptyWriteBuffer(); regs->addr_cmap = vstate.color0[2]; MachEmptyWriteBuffer(); /* enable normal display */ bt459_write_reg(regs, BT459_REG_PRM, 0xff); bt459_write_reg(regs, BT459_REG_CCR, 0xc0); vstate.off = 0;}/* * ---------------------------------------------------------------------------- * * bt459_video_off * * Disable the video display. * * Results: * None. * * Side effects: * The display is disabled. * * ---------------------------------------------------------------------------- */static voidbt459_video_off(){ bt459_regmap_t *regs = (bt459_regmap_t *)(cfbfb.fr_addr + CFB_OFFSET_BT459); if (vstate.off) return; /* save old color map entry zero */ bt459_select_reg(regs, 0); vstate.color0[0] = regs->addr_cmap; vstate.color0[1] = regs->addr_cmap; vstate.color0[2] = regs->addr_cmap; /* set color map entry zero to zero */ bt459_select_reg(regs, 0); regs->addr_cmap = 0; MachEmptyWriteBuffer(); regs->addr_cmap = 0; MachEmptyWriteBuffer(); regs->addr_cmap = 0; MachEmptyWriteBuffer(); /* disable display */ bt459_write_reg(regs, BT459_REG_PRM, 0); bt459_write_reg(regs, BT459_REG_CCR, 0); vstate.off = 1;}/* * cfb keyboard and mouse input. Just punt to the generic ones in fb.c */voidcfbKbdEvent(ch) int ch;{ fbKbdEvent(ch, &cfbfb);}voidcfbMouseEvent(newRepPtr) MouseReport *newRepPtr;{ fbMouseEvent(newRepPtr, &cfbfb);}voidcfbMouseButtons(newRepPtr) MouseReport *newRepPtr;{ fbMouseButtons(newRepPtr, &cfbfb);}/* * Configure the mouse and keyboard based on machine type */static voidcfbConfigMouse(){ int s; s = spltty(); switch (pmax_boardtype) {#if NDC > 0 case DS_3MAX: dcDivertXInput = cfbKbdEvent; dcMouseEvent = cfbMouseEvent; dcMouseButtons = cfbMouseButtons; break;#endif#if NSCC > 1 case DS_3MIN: sccDivertXInput = cfbKbdEvent; sccMouseEvent = cfbMouseEvent; sccMouseButtons = cfbMouseButtons; break;#endif#if NDTOP > 0 case DS_MAXINE: dtopDivertXInput = cfbKbdEvent; dtopMouseEvent = cfbMouseEvent; dtopMouseButtons = cfbMouseButtons; break;#endif default: printf("Can't configure mouse/keyboard\n"); }; splx(s);}/* * and deconfigure them */static voidcfbDeconfigMouse(){ int s; s = spltty(); switch (pmax_boardtype) {#if NDC > 0 case DS_3MAX: dcDivertXInput = (void (*)())0; dcMouseEvent = (void (*)())0; dcMouseButtons = (void (*)())0; break;#endif#if NSCC > 1 case DS_3MIN: sccDivertXInput = (void (*)())0; sccMouseEvent = (void (*)())0; sccMouseButtons = (void (*)())0; break;#endif#if NDTOP > 0 case DS_MAXINE: dtopDivertXInput = (void (*)())0; dtopMouseEvent = (void (*)())0; dtopMouseButtons = (void (*)())0; break;#endif default: printf("Can't deconfigure mouse/keyboard\n"); };}#endif /* NCFB */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -