147.VGA256色模式编程

news/2024/10/20 6:24:06/
/*VGA256.c -- VGA 256 色编程
*/
#include "dos.h"
#include "conio.h"
#include "stdio.h"void InitScr();
void RstScr();
void PutPoint(int x, int y, int Color);
void Rect(int x1, int y1, int x2, int y2, int Color);
void LineV(int x1, int y1, int x2, int y2, int Color);int main()
{int x1, y1, x2, y2, i, j;x1 = y1 = 0;x2 = 319;y2 = 199;InitScr();for (i = 0; i < 256; i++)LineV(i, 0, i, 199, i);for( i = 18; i < 100; i++)Rect(x1++, y1++, x2--, y2--, i);for( i = 18; i < 50; i++)Rect(x1--, y1--, x2++, y2++, i);getch();RstScr();
}void InitScr()
{union REGS In;In.x.ax = 0x13;                 /*进入13H模式  */int86(0x10, &In, &In);
}void RstScr()
{union REGS In;In.x.ax = 0x03;             /* 退出13H模式 */int86(0x10, &In, &In);
}/* 直接写视频缓冲区 */
void PutPoint(int x, int y, int Color)   /* 画点函数 */
{char far *p;p = (char far *) (0x0a0000000L);* (x+y*320+p) = Color;
}/* 利用VGA BIOS中断在屏幕上画点, 速度慢
void PutPoint(int x, int y, int Color)
{union REGS  In;In.h.ah = 0x0C;In.h.al = Color;In.x.cx = x;In.x.dx = y;In.h.bh = 0;int86(0x10, &In, &In);
}
*/void LineV(int x1, int y1, int x2, int y2, int Color)  /* 画一垂直线 */
{int i;for (i = 0; i < 199; i++)PutPoint(x1, i, Color);
}void Rect(int x1, int y1, int x2, int y2, int Color)  /* 画一矩形*/
{int i;for(i = x1; i <= x2; i++){PutPoint(i, y1, Color);PutPoint(i, y2, Color);}for(i = y1; i <= y2; i++){PutPoint(x1, i, Color);PutPoint(x2, i, Color);}
}


http://www.ppmy.cn/news/351296.html

相关文章

用c语言系统以菜单方式工作,20XX年C语言综合编程训练.ppt

C语言综合编程训练;C程序组成;五 子 棋 游 戏 程 序;五 子 棋 游 戏 程 序;功 能 分 析;定义核心数据结构;程序的模块划分;程 序 的 编 制 细 节;bioskey;用 户 手 册;设计任务系统以菜单方式工作(文本菜单或图形菜单)输入数据模块&#xff0c;数据用文件保存输出数据模块&…

c语言编程暂停的系统调用,C语言编程常见问题解答之系统调用.doc

C语言编程常见问题解答之系统调用,c语言函数调用,java调用c语言,c语言调用dll,python调用c语言,c语言调用汇编函数,c语言中函数的调用,c语言调用matlab函数,c语言函数的调用,c语言递归调用 C语言编程常见问题解答之系统调用 PC中最主要的难题之一&#xff0c;也是最容易引起误解…

超级vga显示卡_VESA 编程介绍(一)标准VGA BIOS及超级VGA模式号

VESA编程介绍 (1)标准VGA BIOS及超级VGA模式号 --------------------------------------------------------------------------------- 相关章节: (1): 标准VGA BIOS及超级VGA模式号 (2):CPU显存控制 (3):扩展的VGA BIOS (4): 扩展的VGA BIOS(续)及应用举例 ----------------…

鼠标绘图 c语言,c语言高级编程技术教程 图形显示方式与鼠标输入.doc

c语言高级编程技术教程 图形显示方式与鼠标输入 c语言高级编程技术教程 图形显示方式和鼠标输入 图形显示方式和鼠标输入 问题的提出编写程序,使用鼠标进行如下操作:按住鼠标器的任意键并移动,十字光 标将随鼠标而移动,根据按键的不同采用不同的形状来画出相应的移动轨迹:…

C语言图形编程中的绘图函数~

一、屏幕和视口设置与清除函数 36. setviewport() 设置图形视口函数 37. clearviewport()清除图形视口函数 38. cleardevice() 清除屏幕函数 39. getviewsettings() 获取图形视口设置函数 二、调色板和颜色函数 40. setpalette()设置调色板函数 41. se…

C语言编程之利用ellipse and rectangle 画图

问题描述&#xff1a;利用ellipse and rectangle 画图。 程序源码&#xff1a; #include "stdio.h" #include "graphics.h" #include "conio.h" void main() { int driverVGA,modeVGAHI; int i,num15,top50; int left20,right50; initgraph(&a…

c语言图形方式初始化,c语言图形方式下的编程.doc

c语言图形方式下的编程.doc C语言图形方式下的编程 学习目标 了解PC显示系统的结构 C语言图形初始化的一般方法 C语言常用的图形处理函数 显示系统简介 PC机显示系统一般是由显示器和显示卡组成。显示器(Monitor)是独立于主机的一种外部设备。显示卡(Adapter)是插在Pc主机上的一…

经典C语言编程100例——题目+答案代码(51-60)

【程序 51】 题目&#xff1a;学习使用按位与 & 。 1.程序分析&#xff1a;0&00; 0&10; 1&00; 1&11 2.程序源代码&#xff1a; #include "stdio.h" main() { int a,b; a077; ba&3; printf("\40: The a & b(decimal) is %d \n&quo…