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

📄 bitmapif.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1992, 1993 *	The Regents of the University of California.  All rights reserved. * * This code is derived from software contributed to Berkeley by * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: $Hdr: bitmapif.c,v 4.300 91/06/09 06:14:40 root Rel41 $ SONY * *	@(#)bitmapif.c	8.1 (Berkeley) 6/10/93 */#ifdef IPC_MRX#include <sys/param.h>#include <sys/types.h>#include <news3400/iop/framebuf.h>#include <news3400/iop/fbreg.h>#else#include <sys/param.h>#include <sys/types.h>#include <news3400/iop/framebuf.h>#include <news3400/iop/fbreg.h>#endif#include <news3400/fb/fbdefs.h>#include <news3400/bm/vt100.h>#include <news3400/bm/bitmapif.h>extern int bm_todo;extern int tmode;#ifdef CPU_SINGLEextern char *ext_fnt_addr[];extern char *ext_fnt24_addr[];#else /* CPU_SINGLE */extern char **ext_fnt_addr;extern char **ext_fnt24_addr;#define lock_bitmap()#define unlock_bitmap()#endif /* CPU_SINGLE */extern	SCREEN	screen;#ifdef IPC_MRXextern int bitmap_use;#endif#ifdef CPU_SINGLE#include <machine/cpu.h>#define PRE_EMPT	need_resched()#else#define	PRE_EMPT#endifshort zero[32 * 2];struct	csr_buf local_csr_buf;#ifdef CPU_SINGLEstruct fb_map rommap;#endifbitmapinit(){	fbbm_rop_reset(consfb);	if (!consfb->Mono) {		lock_bitmap();		fbbm_init_palette(consfb);		unlock_bitmap();	}}bm_pallet_read(entry)	int entry;{	lPalette lp;	sPalette palette;#ifdef CPU_SINGLE	struct fb_map rommap;#endif	lock_bitmap();	lp.count = 1;#ifdef CPU_SINGLE	lp.palette = (sPalette *)&rommap;	rommap.fm_vaddr = (caddr_t)&palette;	rommap.fm_offset = 0;#else	lp.palette = &palette;#endif	palette.index = entry;	fbbm_get_palette(consfb, &lp);	unlock_bitmap();	return((palette.rgb.r << 16) | (palette.rgb.g << 8) | palette.rgb.b);}bm_pallet_write(entry, val)	int entry;	int val;{	lPalette lp;	sPalette palette;#ifdef CPU_SINGLE	struct fb_map rommap;#endif	lock_bitmap();	lp.count = 1;#ifdef CPU_SINGLE	lp.palette = (sPalette *)&rommap;	rommap.fm_vaddr = (caddr_t)&palette;	rommap.fm_offset = 0;#else	lp.palette = &palette;#endif	palette.index = entry;	palette.rgb.r = ((val >> 16) & 0xff);	palette.rgb.g = ((val >> 8) & 0xff);	palette.rgb.b = (val & 0xff);	fbbm_set_palette(consfb, &lp);	unlock_bitmap();	return(val);}unsignedsftjis_to_jis(h, l)	register unsigned int h, l;{	if ((h >= JVR1S) && (h <= JVR1E))		h -= JVR1S;	else if ((h >= JVR2S) && (h <= JVR2E))		h = h - JVR2S + 0x1f;	else		return (0);	h <<= 1;	if ((l >= JHR1S) && (l <= JHR1E))		l -= JHR1S;	else if ((l >= JHR2S) && (l <= JHR2E))		l = l - JHR2S + 0x3f;	else if ((l >= JHR3S) && (l <= JHR3E)) {		l -= JHR3S;		h++;	} else		return (0);	return(((h + 0x21) << 8) + l + 0x21);}setropfunc(func, transp, fore, aux)	int func, fore, aux;{	char tmp[4];	register int i = consfb->fbNplane;	register char *funcp = consfb->funcvec;	consfb->func = func;	consfb->fore = fore;	consfb->aux = aux;	consfb->trans = transp;	tmp[0] = TRANS(transp, (func & 0x0c) | (func>>2));	tmp[1] = TRANS(transp, (func>>2) | ((func<<2) & 0x0c));	tmp[2] = TRANS(transp, func);	tmp[3] = TRANS(transp, (func<<2) & 0x0c | func & 3);	while (--i >= 0) {		*funcp++ = tmp[((fore & 1) << 1) | (aux & 1)];		fore >>= 1; aux >>= 1;	}}move_rect(src_x, src_y, width, height, dst_x, dst_y, rop)	int src_x, src_y;	int width, height;	int dst_x, dst_y;	int rop;{	lRectangle sr;	lPoint dp;			sr.origin.x = src_x;	sr.origin.y = src_y;	sr.extent.x = width;	sr.extent.y = height;	dp.x = dst_x;	dp.y = dst_y;	lock_bitmap();	setropfunc(rop, 0, consfb->planemask, 0);	fbbm_rop_init(consfb, consfb->funcvec);	fbbm_rop_copy(consfb, &sr, &dp, 0, consfb->planemask);	unlock_bitmap();}clear_rect(x, y, width, height, rop, fore, aux)	int x, y;	int width, height;	int rop;	int fore;	int aux;{	lRectangle dr;	dr.origin.x = x;	dr.origin.y = y;	dr.extent.x = width;	dr.extent.y = height;	lock_bitmap();	setropfunc(rop, 0, fore, aux);	fbbm_rop_cinit(consfb, consfb->planemask, 1);	fbbm_rop_clear(consfb, &dr);	unlock_bitmap();}line(param)	short *param;{	lPoint p[2];	lRectangle clip;	p[0].x = param[0];	p[0].y = param[1];	p[1].x = param[2];	p[1].y = param[3];	clip = consfb->VisRect;	lock_bitmap();	fbbm_rop_vect(consfb, &clip, param[4] & 0xf,		      fbbm_get_pixel(consfb, param[5]), 0, 1,		      consfb->planemask, 2, p, LINE_SLD, 1, 0);	unlock_bitmap();}/* *  cursor on *  cursor_on(x, y, plane) puts cursor at position (x, y) with color = plane,  *  if cursor sw is off. *  At the same time the image of cursor position is saved. */cursor_on(p)	lPoint *p;{	register struct csr_buf *csr_bp = &local_csr_buf;	register lRectangle *dr;	if (screen.s_term_mode & DECCSR_ACTV &&	    bm_todo <= 0 && csr_bp->csr_sw == C_OFF) {		if (csr_bp->csr_number == 2 && p->x != rit_m)			dr = &char_r2;		else			dr = &char_r1;		dr->origin = *p;		lock_bitmap();		setropfunc(BF_DI, 0, consfb->planemask, 0);		fbbm_rop_init(consfb, consfb->funcvec);		fbbm_rop_copy(consfb, dr, dr, 0, (fcolor^bcolor) & consfb->planemask);		unlock_bitmap();		csr_bp->csr_sw = C_ON;		csr_bp->csr_p = *p;	}}/* *  cursor off *  cursor_off() turns off cursor. *  The image of cursor position which has previously saved by cursor_on *  is restored. */cursor_off(){	register  struct  csr_buf  *csr_bp = &local_csr_buf;	register lRectangle *dr;	if (screen.s_term_mode & DECCSR_ACTV && csr_bp->csr_sw == C_ON) {		if (csr_bp->csr_number == 2 && csr_bp->csr_x != rit_m)			dr = &char_r2;		else			dr = &char_r1;		dr->origin = csr_bp->csr_p;		lock_bitmap();		setropfunc(BF_DI, 0, consfb->planemask, 0);		fbbm_rop_init(consfb, consfb->funcvec);		fbbm_rop_copy(consfb, dr, dr, 0, (fcolor^bcolor) & consfb->planemask);		unlock_bitmap();		csr_bp->csr_sw = C_OFF;	}}/* *  move lines *  move_lines(sl, nl, dl)  moves nl lines starting at line sl to line dl. */move_lines(sl, nl, dl)	int sl, nl, dl;{	move_rect(x_ofst, char_h*(sl - 1) + y_ofst, char_w*(rit_m - LFT_M + 1),		char_h*nl, x_ofst, char_h*(dl - 1) + y_ofst, BF_S);	PRE_EMPT;}/* *  move chars *  move_chars(sx, sy, nchar, dx) moves nchar characters at position (sx, sy) *  to (dx, sy). */move_chars(sx, sy, nchar, dx)	int sx, sy;	int nchar;	int dx;{	move_rect(char_w*(sx - 1) + x_ofst, char_h*(sy - 1) + y_ofst,

⌨️ 快捷键说明

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