⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gx.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
		 );	*ip++ = CMD_LINES| RGB_CONST| LW_PERPKT;	*ip++ = 0x1ffffff;	*ip++ = 0x0;	*ip++ = UPD_ENABLE| UMET_COPY| ((buf&0x3)<<3);	lw = (h << 2) - 1;	y = (y << 3) + lw;	*ip++ = lw;	*ip++ = rgb;				/* rgb */	*ip++ = ( x            <<19) | y;	*ip++ = ((((x+w)<<3)-1)<<16) | y;	return (*_gx_sendPacket)(stampPacket);    }    return -1;}/* end gx_rect *//****************************************************************** **                                                              ** ** Routine to output a character to the screen                  ** **                                                              ** ******************************************************************/gx_blitc( c )    char c;{    int i;    c &= 0xff;    switch ( c )     {     case '\t':			/* tab		*/	for( i = 8 - (gxp->col & 0x7) ; i > 0 ; i-- )	    gx_blitc( ' ' );	break;     case '\n':			/* linefeed	*/	GX_DEBUG(GX_CONSOLE,		 gx_putchar('\n');		 if (gx_console & SLU3_DEV) break;		 );	if( gxp->row+1 >= gxp->max_row ) {	    gxp->row -= gx_scroll(_TEXT_SCROLL);	} else	    gxp->row++;	/*	 * Position the cursor to the next character location.	 */	if (!(gx_dev_inuse & GRAPHIC_DEV))	    GX_POS_CUR( gxp->col*_TEXT_WIDTH, gxp->row*_TEXT_HEIGHT );     case '\r':			/* return	*/	GX_DEBUG(GX_CONSOLE,		 gx_putchar('\r');		 if (gx_console & SLU3_DEV) break;		 );	gxp->col = 0;	break;     case '\b':			/* backspace	*/	GX_DEBUG(GX_CONSOLE,		 gx_putchar('\b');		 if (gx_console & SLU3_DEV) break;		 );	if( --gxp->col < 0 )	    gxp->col = 0;	break;     case '\007':		/* bell		*/	/*	 * Should we wait to see if we have auto configured 	 * before we do anything to the keyboard? - Vasu	 */	(*slu.kbd_putc)( LK_RING_BELL );	break;     default:	/*	 * If the next character will wrap around then 	 * increment row counter or scroll screen.	 */	if( gxp->col >= gxp->max_col ) {	    gxp->col = 0 ;	    if( gxp->row+1 >= gxp->max_row )		gxp->row -= gx_scroll(_TEXT_SCROLL);	    else		gxp->row++;	}	/*	 * 0xA1 to 0xFD are the printable characters added with 8-bit	 * support.	 */	if(( c >= ' ' && c <= '~' ) || ( c >= 0xA1 && c <= 0xFD)) 	{	    int xpix = gxp->col * _TEXT_WIDTH;	    int ypix = gxp->row * _TEXT_HEIGHT;	    i = c - ' ';	    if( 0 < i && i <= 221 )	    {		register unsigned short *f_row;		register int *pp;		int *stampPacket, *xyp, v1, v2, xya;		GX_DEBUG(GX_CONSOLE,			 gx_putchar(c);			 if (gx_console & SLU3_DEV) break;			 );		/* These are to skip the (32) 8-bit 		 * control chars, as well as DEL 		 * and 0xA0 which aren't printable */		/* Masked out above with 0x7f:		if (c > '~') 		    i -= 34; */		i *= _TEXT_HEIGHT;		f_row = &fg_font[i];		if (stampPacket = pp = (*_gx_getPacket)())		{		    *pp++ = CMD_LINES| RGB_FLAT| XY_PERPRIM| LW_PERPRIM;		    *pp++ = 0x4ffffff;		    *pp++ = 0x0;		    *pp++ = UPD_ENABLE| WE_XYMASK| UMET_COPY;		    xyp = pp;		    /* fg = character to draw */		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    i = (16<<2)-1;		    *pp++ = xya = CONSXYADDR(xpix, ypix);		    *pp++ = v1=   (xpix                    <<19)|((ypix<<3)+i);		    *pp++ = v2=((((xpix+_TEXT_WIDTH)<<3)-1)<<16)|(v1&0xffff);		    *pp++ = i;		    *pp++ = gx_textfg;		    /* opague background */		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp   ^ 0xffffffff;		    *pp++ = xya;		    *pp++ = v1;		    *pp++ = v2;		    *pp++ = i;		    *pp++ = gx_textbg;		    xyp = pp;		    /* lower part of fg character */		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = GX_GET2ROWS(f_row);		    *pp++ = 0x0;		    *pp++ = 0x0;		    *pp++ = 0x0;		    *pp++ = 0x0;		    *pp++ = 0x0;		    *pp++ = 0x0;		    i = ((_TEXT_HEIGHT-16)<<2)-1;  ypix += 16;		    *pp++ = xya = CONSXYADDR(xpix, ypix);		    *pp++ = v1=   (xpix                    <<19)|((ypix<<3)+i);		    *pp++ = v2=((((xpix+_TEXT_WIDTH)<<3)-1)<<16)|(v1&0xffff);		    *pp++ = i;		    *pp++ = gx_textfg;		    /* opague background */		    *pp++ = *xyp++ ^ 0xffffffff;		    *pp++ = *xyp   ^ 0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ =          0xffffffff;		    *pp++ = xya;		    *pp++ = v1;		    *pp++ = v2;		    *pp++ = i;		    *pp++ = gx_textbg;		    (*_gx_sendPacket)(stampPacket);		    gxp->col++;			/* increment column counter */		}	    }	    else if (i == 0)		/* <space> */	    {		GX_DEBUG(GX_CONSOLE,			 gx_putchar(' ');			 if (gx_console & SLU3_DEV) break;			 );		gx_rect(xpix, ypix, _TEXT_HEIGHT, _TEXT_WIDTH, 0x0, 0);		gxp->col++;		/* increment column counter */	    }	}	break;    }    return(0);}/* end gx_blitc *//******************************************************************** **                                                                ** ** Routine to direct kernel console output to display destination ** **                                                                ** ********************************************************************/gxputc( c )    register char c;{    register int xcons_status;    if (printstate & PANICPRINT) {	static int startingToPanic = 1;	gx_debug    = GX_PANIC;	gx_mouseon  = 0;		/* no mouse events accepted */	gx_serverp  = 0;		/* server is no longer running */	gx_console &= ~SLU3_DEV;	/* not just to slu3 console */	if (startingToPanic) {	    startingToPanic = 0; 	wbflush();	    GX_DEBUG(GX_TERSE,		     gx_puts("\n\007panic: resetting console!\n");		     );	    gx_init();			/* back to known output state */	}    }        xcons_status = xcons_chkq();        switch (xcons_status) {      case XCONS_CLOSED:	/* real console output; either to system console or forced to SLU3 */	gx_blitc(c & 0xff);	break;	      case XCONS_BLOCKED:	break;	      case XCONS_OK:	/* not panic'ing, routing to alternate console */	xconsrint(c);	break;    }}/* gxputc *//****************************************************************** **                                                              ** ** Routine to get a character from LK201.                       ** **                                                              ** ******************************************************************/gxgetc(data)    u_short	data;{    int	c;    /*     * Get a character from the keyboard,     */ loop:    /*     * Check for various keyboard errors     */    if( data == LK_POWER_ERROR || data == LK_KDOWN_ERROR ||       data == LK_INPUT_ERROR || data == LK_OUTPUT_ERROR)     {	if(!gx_inkbdreset) {	    mprintf(" Keyboard error, code = %x\n",data);	    gx_kbdreset();	}	return(0);    }    if( data < LK_LOWEST ) return(0);    /*     * See if its a state change key     */    switch ( data )     {     case LOCK:	gx_keyboard.lock ^= 0xffff; /* toggle */	if( gx_keyboard.lock )	    (*slu.kbd_putc)( LK_LED_ENABLE );	else	    (*slu.kbd_putc)( LK_LED_DISABLE );	(*slu.kbd_putc)( LED_3 );	data = (*slu.kbd_getc)();	goto loop;     case SHIFT:	gx_keyboard.shift ^= 0xffff;	data = (*slu.kbd_getc)();	goto loop;     case CNTRL:	gx_keyboard.cntrl ^= 0xffff;	data = (*slu.kbd_getc)();	goto loop;     case ALLUP:	gx_keyboard.cntrl = gx_keyboard.shift = 0;	data = (*slu.kbd_getc)();	goto loop;     case REPEAT:	c = gx_keyboard.last;	break;     default:	/*	 * Test for control characters. If set, see if the character	 * is elligible to become a control character.	 */	if( gx_keyboard.cntrl ) 	{	    c = q_key[ data ];	    if( c >= ' ' && c <= '~' )		c &= 0x1f;	} 	else if( gx_keyboard.lock || gx_keyboard.shift )	    c = q_shift_key[ data ];	else	    c = q_key[ data ];	break;	    }    gx_keyboard.last = c;    /*     * Check for special function keys     */    if( c & 0x80 )	return (0);    else	return (c);}/* gxgetc *//****************************************************************** **                                                              ** ** Routine to position the cursor to a particular spot.         ** **                                                              ** ******************************************************************/gx_pos_cur(x, y)    int x,y;{    int i, x0, y0;    register int s;    volatile int *vdac_data = &_gx_vdac->data;    if( y < gxp->min_cur_y || y > gxp->max_cur_y )	y = gxp->max_cur_y;    if( x < gxp->min_cur_x || x > gxp->max_cur_x )	x = gxp->max_cur_x;    gxp->cursor.x = x;		     /* keep track of real cursor */    gxp->cursor.y = y;		     /* position, indep. of mouse */    x0 = x + (BT459_H+BT459_X);    y0 = y + (BT459_V+BT459_Y);    IPLTTY(s);    BT459_SETADDR(_gx_vdac, BT459_CUR_XLO);    *vdac_data = _DUPBYTE0(x0); WBFLUSH();    *vdac_data = _DUPBYTE1(x0); WBFLUSH();    *vdac_data = _DUPBYTE0(y0); WBFLUSH();    *vdac_data = _DUPBYTE1(y0); WBFLUSH();    /* turn cursor back on */    BT459_SETADDR(_gx_vdac, BT459_CUR_CMD);    *vdac_data = 0xC0C0C0; WBFLUSH();    splx(s);#   ifdef GX_MULTIOPEN    for (i = 1; i < GX_MAX_INFOS; i++) {	gx_infos[i].info.cursor.x = x;	gx_infos[i].info.cursor.y = y;    }#   endif gx_multiopen    GX_DEBUG(GX_YOW,	     gx_printf("gx_pos_cur(%d,%d)\n", x,y);	     );}/* end gx_pos_cur *//****************************************************************** **                                                              ** ** Routine to scroll.                                           ** **                                                              ** ******************************************************************/gx_scroll(scroll)    int scroll;{    register int *pp, fY, tY, h;    int *stampPacket;    /*     * use vertical wrap-around when server running.     */    if (GX_HAVESERVER)	return (gxp->row);    fY = (scroll*_TEXT_HEIGHT)<<3;	/* from */    tY = 0<<3;				/* to */    h = (_TEXT_ROWS+1-scroll)*_TEXT_HEIGHT; /* # scanlines to move */    while (h > 0)    {	register int n = MIN(h, STAMP_MAX_CMDS);	h -= n;	if (stampPacket = pp = (*_gx_getPacket)())	{	    *pp++ = CMD_COPYSPANS| LW_PERPKT;	    *pp++ = (n<<24) | 0xffffff;	    *pp++ = 0x0;	    *pp++ = UPD_ENABLE| UMET_COPY| SPAN;	    *pp++ = 1;				/* linewidth */	    for ( ; n > 0; n--, fY += 8, tY += 8)	    {		*pp++ = (_TEXT_COLS*_TEXT_WIDTH)<<3;		*pp++ = fY;			/* x := 0 */		*pp++ = tY;	    }	    (*_gx_sendPacket)(stampPacket);	}	else {	    GX_DEBUG(GX_TERSE,		     gx_printf("gx_scroll - ~packet!\n");		     );	    return 0;	}    }    /* clear out bottom scroll lines */    gx_rect(0, (_TEXT_ROWS-scroll+1)*_TEXT_HEIGHT,	    scroll*_TEXT_HEIGHT, _TEXT_COLS*_TEXT_WIDTH, 0x0, 0);    return(scroll-1);}/* end gx_scroll *//***************************************************************** * Clear the bitmap						 * *****************************************************************/gx_clearbitmap(){    GX_DEBUG(GX_BLAB,	     gx_puts("gx_clearbitmap()\n");	     );    gx_rect(0, 0, 1024, 1280, 0x0, 0);}/* end gx_clearbitmap *//****************************************************************** **                                                              ** * Routine to initialize the mouse.                              ** **                                                              ** ****************************************************************** * * NOTE: *	This routine communicates with the mouse by directly *	manipulating the PMAX SLU registers. This is allowed *	ONLY because the mouse is initialized before the system *	is up far enough to need the SLU in interrupt mode. */gx_init_mouse(){    register u_short lpr;    int	id_byte1, id_byte2, id_byte3, id_byte4;    GX_DEBUG(GX_BLAB,	     gx_puts("gx_init_mouse(");	     );    /*     * Set SLU line parameters for mouse communication.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -