147.VGA256色模式编程

简介: 147.VGA256色模式编程
/*
     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);
   }
}
相关文章
|
Ubuntu Linux Docker
Ubuntu22.04上Docker的安装
通过以上详细的安装步骤和命令,您可以在Ubuntu 22.04系统上顺利安装
8559 12
|
机器学习/深度学习
【从零开始学习深度学习】24.神经网络中池化层的作用:最大池化与平均池化
【从零开始学习深度学习】24.神经网络中池化层的作用:最大池化与平均池化
确保你已经安装了`python-barcode`库。如果没有,可以通过pip来安装:
确保你已经安装了`python-barcode`库。如果没有,可以通过pip来安装:
|
机器学习/深度学习
一文弄清池化层(pooling)的作用
一文弄清池化层(pooling)的作用
|
消息中间件 缓存 NoSQL
「CDC架构」捕获数据变化的瑞士军刀Debezium介绍
「CDC架构」捕获数据变化的瑞士军刀Debezium介绍
|
应用服务中间件 nginx
413 request entity too large 解决办法
413 request entity too large 解决办法
5732 0
|
编解码 Python Windows
pip安装报错:UnicodeDecodeError &#39;utf-8&#39; codec can&#39;t decode byte 0xc3 in position 4
pip安装报错:UnicodeDecodeError &#39;utf-8&#39; codec can&#39;t decode byte 0xc3 in position 4
855 2
|
2天前
|
数据采集 人工智能 安全
|
11天前
|
云安全 监控 安全