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

📄 svgalib.c

📁 ELinks is an advanced and well-established feature-rich text mode web (HTTP/FTP/..) browser. ELinks
💻 C
📖 第 1 页 / 共 5 页
字号:
static void draw_hline_accel_box(struct graphics_device *dev, int left, int y, int right, long color){	HLINE_CLIP_PREFACE	vga_accel(ACCEL_SETFGCOLOR,color);	vga_accel(ACCEL_FILLBOX,left,y,right-left,1);	END_MOUSE}static void draw_vline_accel_line(struct graphics_device *dev, int x, int top, int bottom, long color){	VLINE_CLIP_PREFACE	vga_accel(ACCEL_SETFGCOLOR,color);	vga_accel(ACCEL_DRAWLINE,x,top,x,bottom-1);	END_MOUSE}static void draw_vline_accel_box(struct graphics_device *dev, int x, int top, int bottom, long color){	VLINE_CLIP_PREFACE	vga_accel(ACCEL_SETFGCOLOR,color);	vga_accel(ACCEL_FILLBOX,x,top,1,bottom-top);	END_MOUSE}static void draw_hline_linear(struct graphics_device *dev, int left, int y, int right, long color){	unsigned char *dest;	HLINE_CLIP_PREFACE	SYNC		dest=my_graph_mem+y*vga_linewidth+left*vga_bytes;	pixel_set(dest,(right-left)*vga_bytes,&color);	END_MOUSE}static void draw_vline_linear(struct graphics_device *dev, int x, int top, int bottom, long color){	unsigned char *dest;	int y;	VLINE_CLIP_PREFACE	SYNC	dest=my_graph_mem+top*vga_linewidth+x*vga_bytes;	for (y=(bottom-top);y;y--){		memcpy(dest,&color,vga_bytes);		dest+=vga_linewidth;	}	END_MOUSE}static void draw_hline_paged(struct graphics_device *dev, int left, int y, int right, long color){	int dest;	int len;	HLINE_CLIP_PREFACE		SYNC	len=(right-left)*vga_bytes;	dest=y*vga_linewidth+left*vga_bytes;	pixel_set_paged(dest,len,&color);	END_MOUSE}/* Works only for pixel length = 1 */static void draw_vline_paged_1(struct graphics_device *dev, int x, int top, int bottom, long color){	int dest,n, page,paga,remains;	int byte=*(char *)&color;	VLINE_CLIP_PREFACE;	SYNC	dest=top*vga_linewidth+x;	n=bottom-top;	page=dest>>16;	my_setpage(page);	again:	paga=dest&0xffff;	remains=(65535-paga)/vga_linewidth+1;	if (remains>=n){		for (;n;n--){			my_graph_mem[paga]=byte;			paga+=vga_linewidth;		}		vga_page=page;		END_MOUSE		return;	}else{		dest+=remains*vga_linewidth;		n-=remains;		for (;remains;remains--){			my_graph_mem[paga]=byte;			paga+=vga_linewidth;		}		vga_setpage(++page);		goto again;	}}			#ifdef t2c/* Works only for pixel length 2 */static void draw_vline_paged_2(struct graphics_device *dev, int x, int top, int bottom, long color){	int dest,page,n,paga,remains;	int word=*(t2c *)(void *)&color;	VLINE_CLIP_PREFACE;	SYNC	dest=top*vga_linewidth+(x<<1);	n=bottom-top;	page=dest>>16;	my_setpage(page);	again:	paga=dest&0xffff;	remains=(65534-paga)/vga_linewidth+1;	if (remains>=n){		for (;n;n--){			*(t2c *)(my_graph_mem+paga)=word;			paga+=vga_linewidth;		}		vga_page=page;		END_MOUSE		return;	}else{		dest+=remains*vga_linewidth;		n-=remains;		for (;remains;remains--){			*(t2c *)(my_graph_mem+paga)=word;			paga+=vga_linewidth;		}		vga_setpage(++page);		goto again;	}}#endif /* #ifdef t2c */			#ifdef t4c/* Works only for pixel length 4 */static void draw_vline_paged_4(struct graphics_device *dev, int x, int top, int bottom, long color){	unsigned long dest,page,paga,remains,n;	t4c val=*(t4c *)(void *)&color;	VLINE_CLIP_PREFACE;	SYNC	dest=top*(unsigned long)vga_linewidth+(x<<2);	n=bottom-top;	page=dest>>16;	my_setpage(page);	again:	paga=dest&0xffffUL;	remains=(65532-paga)/vga_linewidth+1;	if (remains>=n){		for (;n;n--){			*(t4c *)(my_graph_mem+paga)=val;			paga+=vga_linewidth;		}		vga_page=page;		END_MOUSE		return;	}else{		dest+=remains*vga_linewidth;		n-=remains;		for (;remains;remains--){			*(t4c *)(my_graph_mem+paga)=color;			paga+=vga_linewidth;		}		vga_setpage(++page);		goto again;	}}#endif /*t4c*/			/* Works only for pixel lengths power of two */static void draw_vline_paged_aligned(struct graphics_device *dev, int x, int top, int bottom, long color){	int dest,page,paga,remains,n;	VLINE_CLIP_PREFACE;	SYNC	dest=top*vga_linewidth+x*vga_bytes;	n=bottom-top;	page=dest>>16;	my_setpage(page);	again:	paga=dest&0xffff;	remains=(65536-paga-vga_bytes)/vga_linewidth+1;	if (remains>=n){		for (;n;n--){			memcpy(my_graph_mem+paga,&color,vga_bytes);			paga+=vga_linewidth;		}		vga_page=page;		END_MOUSE		return;	}else{		dest+=remains*vga_linewidth;		n-=remains;		for (;remains;remains--){			memcpy(my_graph_mem+paga,&color,vga_bytes);			paga+=vga_linewidth;		}		vga_setpage(++page);		goto again;	}}			/* Works for any pixel length */static void draw_vline_paged(struct graphics_device *dev, int x, int top, int bottom, long color){	int lina,page,paga,remains,n;	/* lina: linear address withing the screen	 * page: page number	 * paga: 16-bit address within the page	 * remains: how many bytes remain in the current page	 * n: how many pixels remain to be drawn	 */	VLINE_CLIP_PREFACE;	SYNC	lina=top*vga_linewidth+x*vga_bytes;	n=bottom-top;	page=lina>>16;	my_setpage(page);	again:	/* Invariant here: n>=1	 * lina points to a begin of pixel	 * page is set to page	 */	paga=lina&0xffff;	remains=65536-paga;	if (remains<vga_bytes){		memcpy(my_graph_mem+paga,&color,remains);		vga_setpage(++page);		memcpy(my_graph_mem,&color+remains,vga_bytes-remains);		lina+=vga_linewidth;		n--;		if (!n) goto end;		goto again;	}	remains=(remains-vga_bytes)/vga_linewidth+1;	if (remains>=n){		for (;n;n--){			memcpy(my_graph_mem+paga,&color,vga_bytes);			paga+=vga_linewidth;		}end:		vga_page=page;		END_MOUSE		return;	}else{		lina+=remains*vga_linewidth;		n-=remains;		for (;remains;remains--){			memcpy(my_graph_mem+paga,&color,vga_bytes);			paga+=vga_linewidth;		}		if (paga>=65536)vga_setpage(++page);		goto again;	}}		#define HSCROLL_CLIP_PREFACE \	int mouse_hidden;\	TEST_INACTIVITY_0\	if (!sc) return 0;\	if (sc>(dev->clip.x2-dev->clip.x1)||-sc>(dev->clip.x2-dev->clip.x1))\		return 1;\	TEST_MOUSE (dev->clip.x1,dev->clip.x2,dev->clip.y1,dev->clip.y2)									/* When sc is <0, moves the data left. Scrolls the whole clip window */static int hscroll_accel(struct graphics_device *dev, struct rect_set **ignore, int sc){	HSCROLL_CLIP_PREFACE	ignore=NULL;	if (sc>0){		/* Move data to the right */		vga_accel(ACCEL_SCREENCOPY,dev->clip.x1,dev->clip.y1,dev->clip.x1+sc,dev->clip.y1			,dev->clip.x2-dev->clip.x1-sc,dev->clip.y2-dev->clip.y1);	}else{		/* Move data to the left */		vga_accel(ACCEL_SCREENCOPY,dev->clip.x1-sc,dev->clip.y1,dev->clip.x1,dev->clip.y1			,dev->clip.x2-dev->clip.x1+sc,dev->clip.y2-dev->clip.y1);	}	END_MOUSE	return 1;}#define VSCROLL_CLIP_PREFACE \	int mouse_hidden;\	TEST_INACTIVITY_0\	if (!sc) return 0;\	if (sc>dev->clip.y2-dev->clip.y1||-sc>dev->clip.y2-dev->clip.y1) return 1;\	TEST_MOUSE (dev->clip.x1, dev->clip.x2, dev->clip.y1, dev->clip.y2)	/* Positive sc means data move down */static int vscroll_accel(struct graphics_device *dev, struct rect_set **ignore, int sc){	VSCROLL_CLIP_PREFACE	ignore=NULL;	if (sc>0){		/* Move down */		vga_accel(ACCEL_SCREENCOPY,dev->clip.x1,dev->clip.y1,dev->clip.x1,dev->clip.y1+sc			,dev->clip.x2-dev->clip.x1,dev->clip.y2-dev->clip.y1-sc);	}else{		/* Move up */		vga_accel(ACCEL_SCREENCOPY,dev->clip.x1,dev->clip.y1-sc,dev->clip.x1,dev->clip.y1			,dev->clip.x2-dev->clip.x1,dev->clip.y2-dev->clip.y1+sc);	}	END_MOUSE	return 1;}static int hscroll_scansegment(struct graphics_device *dev, struct rect_set **ignore, int sc){	int y;	int len;	HSCROLL_CLIP_PREFACE	SYNC		ignore=NULL;	if (sc>0){		/* Right */		len=dev->clip.x2-dev->clip.x1-sc;		for (y=dev->clip.y1;y<dev->clip.y2;y++){			vga_getscansegment(scroll_buffer,dev->clip.x1,y,len);			vga_drawscansegment(scroll_buffer,dev->clip.x1+sc,y,len);		}	}else{		/* Left */		len=dev->clip.x2-dev->clip.x1+sc;		for (y=dev->clip.y1;y<dev->clip.y2;y++){			vga_getscansegment(scroll_buffer,dev->clip.x1-sc,y,len);			vga_drawscansegment(scroll_buffer,dev->clip.x1,y,len);		}	}	END_MOUSE	return 1;}static int hscroll_linear(struct graphics_device *dev, struct rect_set **ignore, int sc){	unsigned char *dest, *src;	int y;	int len;	HSCROLL_CLIP_PREFACE	SYNC	ignore=NULL;	if (sc>0){		len=(dev->clip.x2-dev->clip.x1-sc)*vga_bytes;		src=my_graph_mem+vga_linewidth*dev->clip.y1+dev->clip.x1*vga_bytes;		dest=src+sc*vga_bytes;		for (y=dev->clip.y2-dev->clip.y1;y;y--){			memmove(dest,src,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}else{		len=(dev->clip.x2-dev->clip.x1+sc)*vga_bytes;		dest=my_graph_mem+vga_linewidth*dev->clip.y1+dev->clip.x1*vga_bytes;		src=dest-sc*vga_bytes;		for (y=dev->clip.y2-dev->clip.y1;y;y--){			memmove(dest,src,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}	END_MOUSE	return 1;}static int vscroll_scansegment(struct graphics_device *dev, struct rect_set **ignore, int sc){	int y;	int len;	VSCROLL_CLIP_PREFACE	SYNC	ignore=NULL;	len=dev->clip.x2-dev->clip.x1;	if (sc>0){		/* Down */		for (y=dev->clip.y2-1;y>=dev->clip.y1+sc;y--){			vga_getscansegment(scroll_buffer, dev->clip.x1,y-sc,len);			vga_drawscansegment(scroll_buffer,dev->clip.x1,y,len);		}	}else{		/* Up */		for (y=dev->clip.y1-sc;y<dev->clip.y2;y++){			vga_getscansegment(scroll_buffer,dev->clip.x1,y,len);			vga_drawscansegment(scroll_buffer, dev->clip.x1,y+sc,len);		}	}	END_MOUSE	return 1;}static int vscroll_linear(struct graphics_device *dev, struct rect_set **ignore, int sc){	unsigned char *dest, *src;	int y;	int len;	VSCROLL_CLIP_PREFACE	SYNC	ignore=NULL;	len=(dev->clip.x2-dev->clip.x1)*vga_bytes;	if (sc>0){		/* Down */		dest=my_graph_mem+(dev->clip.y2-1)*vga_linewidth+dev->clip.x1*vga_bytes;		src=dest-vga_linewidth*sc;		for (y=dev->clip.y2-dev->clip.y1-sc;y;y--){			memcpy(dest,src,len);			dest-=vga_linewidth;			src-=vga_linewidth;		}	}else{		/* Up */		dest=my_graph_mem+dev->clip.y1*vga_linewidth+dev->clip.x1*vga_bytes;		src=dest-vga_linewidth*sc;		for (y=dev->clip.y2-dev->clip.y1+sc;y;y--){			memcpy(dest,src,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}	END_MOUSE	return 1;}static inline void get_row(unsigned char *bptr, int lina, int len){	int page=lina>>16;	int paga=lina&0xffff;	int remains;		my_setpage(page);	remains=65536-paga;	again:	if (remains>=len){		memcpy(bptr,my_graph_mem+paga,len);		vga_page=page;		return;	}else{		memcpy(bptr,my_graph_mem+paga,remains);		paga=0;		bptr+=remains;		len-=remains;		remains=65536;		vga_setpage(++page);		goto again;	}}static int vscroll_paged(struct graphics_device *dev, struct rect_set **ignore, int sc){	int dest,src;	int y;	int len;	VSCROLL_CLIP_PREFACE	SYNC	ignore=NULL;	len=(dev->clip.x2-dev->clip.x1)*vga_bytes;	if (sc>0){		/* Down */		dest=(dev->clip.y2-1)*vga_linewidth+dev->clip.x1*vga_bytes;		src=dest-vga_linewidth*sc;		for (y=dev->clip.y2-dev->clip.y1-sc;y;y--){			get_row(scroll_buffer, src,len);			paged_memcpy(dest,scroll_buffer,len);			dest-=vga_linewidth;			src-=vga_linewidth;		}	}else{		/* Up */		dest=dev->clip.y1*vga_linewidth+dev->clip.x1*vga_bytes;		src=dest-vga_linewidth*sc;		for (y=dev->clip.y2-dev->clip.y1+sc;y;y--){			get_row(scroll_buffer, src,len);			paged_memcpy(dest,scroll_buffer,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}	END_MOUSE	return 1;}static int hscroll_paged(struct graphics_device *dev, struct rect_set **ignore, int sc){	int  dest,src;	int y;	int len;	HSCROLL_CLIP_PREFACE	SYNC		ignore=NULL;	if (sc>0){		len=(dev->clip.x2-dev->clip.x1-sc)*vga_bytes;		src=vga_linewidth*dev->clip.y1+dev->clip.x1*vga_bytes;		dest=src+sc*vga_bytes;		for (y=dev->clip.y2-dev->clip.y1;y;y--){			get_row(scroll_buffer, src,len);			paged_memcpy(dest,scroll_buffer,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}else{		len=(dev->clip.x2-dev->clip.x1+sc)*vga_bytes;		dest=vga_linewidth*dev->clip.y1+dev->clip.x1*vga_bytes;		src=dest-sc*vga_bytes;		for (y=dev->clip.y2-dev->clip.y1;y;y--){			get_row(scroll_buffer, src,len);			paged_memcpy(dest,scroll_buffer,len);			dest+=vga_linewidth;			src+=vga_linewidth;		}	}	END_MOUSE	return 1;}static void svga_set_clip_area(struct graphics_device *dev, struct rect *r)

⌨️ 快捷键说明

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