📄 mfb.c
字号:
* * Results: * None. * * Side effects: * The screen is initialized. * * ---------------------------------------------------------------------------- */static voidmfbScreenInit(){ register struct pmax_fb *fp = &mfbfb; /* * 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 = 66; fp->col = 0; /* * Load the cursor with the default values * */ mfbLoadCursor(defCursor);}/* * ---------------------------------------------------------------------------- * * RestoreCursorColor -- * * Routine to restore the color of the cursor. * * Results: * None. * * Side effects: * None. * * ---------------------------------------------------------------------------- */static voidmfbRestoreCursorColor(){ bt455_regmap_t *regs = (bt455_regmap_t *)(mfbfb.fr_chipaddr + MFB_OFFSET_BT455); ColorMap cm; u_char fg; if (cursor_RGB[0] || cursor_RGB[1] || cursor_RGB[2]) cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0xffff; else cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0; cm.index = 8; mfbLoadColorMap(&cm); cm.index = 9; mfbLoadColorMap(&cm); if (cursor_RGB[3] || cursor_RGB[4] || cursor_RGB[5]) fg = 0xf; else fg = 0; regs->addr_ovly = fg; MachEmptyWriteBuffer(); regs->addr_ovly = fg; MachEmptyWriteBuffer(); regs->addr_ovly = fg; MachEmptyWriteBuffer();}/* * ---------------------------------------------------------------------------- * * CursorColor -- * * Set the color of the cursor. * * Results: * None. * * Side effects: * None. * * ---------------------------------------------------------------------------- */static voidmfbCursorColor(color) unsigned int color[];{ register int i, j; for (i = 0; i < 6; i++) cursor_RGB[i] = (u_char)(color[i] >> 8); mfbRestoreCursorColor();}/* *---------------------------------------------------------------------- * * PosCursor -- * * Postion the cursor. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */voidmfbPosCursor(x, y) register int x, y;{ bt431_regmap_t *regs = (bt431_regmap_t *)(mfbfb.fr_chipaddr + MFB_OFFSET_BT431); register struct pmax_fb *fp = &mfbfb; 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 */#define lo(v) ((v)&0xff)#define hi(v) (((v)&0xf00)>>8) /* * Cx = x + D + H - P * P = 37 if 1:1, 52 if 4:1, 57 if 5:1 * D = pixel skew between outdata and external data * H = pixels between HSYNCH falling and active video * * Cy = y + V - 32 * V = scanlines between HSYNCH falling, two or more * clocks after VSYNCH falling, and active video */ bt431_write_reg(regs, BT431_REG_CXLO, lo(x + 360)); BT431_WRITE_REG_AUTOI(regs, hi(x + 360)); BT431_WRITE_REG_AUTOI(regs, lo(y + 36)); BT431_WRITE_REG_AUTOI(regs, hi(y + 36));}/* * ---------------------------------------------------------------------------- * * InitColorMap -- * * Initialize the color map. * * Results: * None. * * Side effects: * The colormap is initialized appropriately. * * ---------------------------------------------------------------------------- */static voidmfbInitColorMap(blackpix) int blackpix;{ ColorMap cm; register int i; cm.index = 0; if (blackpix) cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0xffff; else cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0; mfbLoadColorMap(&cm); if (blackpix) cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0; else cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0xffff; for (i = 1; i < 16; i++) { cm.index = i; mfbLoadColorMap(&cm); } for (i = 0; i < 3; i++) { cursor_RGB[i] = 0; cursor_RGB[i + 3] = 0xff; } mfbRestoreCursorColor();}/* * ---------------------------------------------------------------------------- * * LoadColorMap -- * * Load the color map. * * Results: * None. * * Side effects: * The color map is loaded. * * ---------------------------------------------------------------------------- */static voidmfbLoadColorMap(ptr) ColorMap *ptr;{ bt455_regmap_t *regs = (bt455_regmap_t *)(mfbfb.fr_chipaddr + MFB_OFFSET_BT455); if (ptr->index > 15) return; BT455_SELECT_ENTRY(regs, ptr->index); regs->addr_cmap_data = ptr->Entry.red >> 12; MachEmptyWriteBuffer(); regs->addr_cmap_data = ptr->Entry.green >> 12; MachEmptyWriteBuffer(); regs->addr_cmap_data = ptr->Entry.blue >> 12; MachEmptyWriteBuffer();}/* * Video on/off state. */static struct vstate { u_char color0[6]; /* saved color map entry zero */ u_char off; /* TRUE if display is off */ u_char cursor[6]; /* saved cursor color */} vstate;/* * ---------------------------------------------------------------------------- * * bt455_video_on * * Enable the video display. * * Results: * None. * * Side effects: * The display is enabled. * * ---------------------------------------------------------------------------- */static voidbt455_video_on(){ register int i; bt455_regmap_t *regs = (bt455_regmap_t *)(mfbfb.fr_chipaddr + MFB_OFFSET_BT455); if (!vstate.off) return; /* restore old color map entry zero */ BT455_SELECT_ENTRY(regs, 0); for (i = 0; i < 6; i++) { regs->addr_cmap_data = vstate.color0[i]; MachEmptyWriteBuffer(); cursor_RGB[i] = vstate.cursor[i]; } mfbRestoreCursorColor(); vstate.off = 0;}/* * ---------------------------------------------------------------------------- * * bt455_video_off * * Disable the video display. * * Results: * None. * * Side effects: * The display is disabled. * * ---------------------------------------------------------------------------- */static voidbt455_video_off(){ register int i; bt455_regmap_t *regs = (bt455_regmap_t *)(mfbfb.fr_chipaddr + MFB_OFFSET_BT455); ColorMap cm; if (vstate.off) return; /* save old color map entry zero */ BT455_SELECT_ENTRY(regs, 0); for (i = 0; i < 6; i++) { vstate.color0[i] = regs->addr_cmap_data; vstate.cursor[i] = cursor_RGB[i]; cursor_RGB[i] = 0; } /* set color map entry zero to zero */ cm.index = 0; cm.Entry.red = cm.Entry.green = cm.Entry.blue = 0; mfbLoadColorMap(&cm); cm.index = 1; mfbLoadColorMap(&cm); mfbRestoreCursorColor(); vstate.off = 1;}/* * mfb keyboard and mouse input. Just punt to the generic ones in fb.c */voidmfbKbdEvent(ch) int ch;{ fbKbdEvent(ch, &mfbfb);}voidmfbMouseEvent(newRepPtr) MouseReport *newRepPtr;{ fbMouseEvent(newRepPtr, &mfbfb);}voidmfbMouseButtons(newRepPtr) MouseReport *newRepPtr;{ fbMouseButtons(newRepPtr, &mfbfb);}/* * Configure the mouse and keyboard based on machine type */static voidmfbConfigMouse(){ int s; s = spltty(); switch (pmax_boardtype) {#if NDC > 0 case DS_3MAX: dcDivertXInput = mfbKbdEvent; dcMouseEvent = mfbMouseEvent; dcMouseButtons = mfbMouseButtons; break;#endif#if NSCC > 1 case DS_3MIN: sccDivertXInput = mfbKbdEvent; sccMouseEvent = mfbMouseEvent; sccMouseButtons = mfbMouseButtons; break;#endif#if NDTOP > 0 case DS_MAXINE: dtopDivertXInput = mfbKbdEvent; dtopMouseEvent = mfbMouseEvent; dtopMouseButtons = mfbMouseButtons; break;#endif default: printf("Can't configure mouse/keyboard\n"); }; splx(s);}/* * and deconfigure them */static voidmfbDeconfigMouse(){ 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"); };}/* * Generic register access */static voidbt431_select_reg(regs, regno) bt431_regmap_t *regs;{ regs->addr_lo = SET_VALUE(regno & 0xff); regs->addr_hi = SET_VALUE((regno >> 8) & 0xff); MachEmptyWriteBuffer();}static void bt431_write_reg(regs, regno, val) bt431_regmap_t *regs;{ bt431_select_reg(regs, regno); regs->addr_reg = SET_VALUE(val); MachEmptyWriteBuffer();}static u_charbt431_read_reg(regs, regno) bt431_regmap_t *regs;{ bt431_select_reg(regs, regno); return (GET_VALUE(regs->addr_reg));}static voidbt431_init(regs) bt431_regmap_t *regs;{ register int i; /* use 4:1 input mux */ bt431_write_reg(regs, BT431_REG_CMD, BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS| BT431_CMD_4_1_MUX|BT431_CMD_THICK_1); /* home cursor */ BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); /* no crosshair window */ BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00); BT431_WRITE_REG_AUTOI(regs, 0x00);}#endif /* NMFB */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -