Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 经典 火焰源代码欣赏 C实现 不容错过
【标  题】:经典 火焰源代码欣赏 C实现 不容错过
【关键字】:
【来  源】:http://blog.csdn.net/panqiaomu/archive/2006/11/06/1369183.aspx

经典 火焰源代码欣赏 C实现 不容错过

Your Ad Here 自定义头文件:
/*********************************************************/
/*                     VGA13H模式函数                    */
/*********************************************************/
/*********************************************************/

if !defined(__DOS_DEF_)
#    include 
<dos.h>
# endif
/* 此处定义了一些通用的宏 */

# define BYTE  unsigned 
char
# define WORD  unsigned 
int
# define DWORD unsigned 
long
# define BOOL  BYTE
# define TRUE  
1
# define FALSE 
!TRUE

/* BIOS 8*8 西文字库的段地址和偏移量 */
WORD FONT_SEG;
WORD FONT_OFF;

void setmode();
void waitkey();
void closemode();
void GetFontAdd();
void locate(int Line,int Col);
void pset(int x,int y,BYTE color);
void setpal(int Color,BYTE r,BYTE g,BYTE b);
BYTE ScanKey(
void);
BYTE point(
int x,int y);

/* 获取BIOS 8*8 西文字库的段地址和偏移量 */
void GetFontAdd()
{
  
struct REGPACK regs;
  regs.r_bx
=0x0300;
  regs.r_ax
=0x1130;
  intr(
0x10,&regs);
  FONT_SEG
=regs.r_es;
  FONT_OFF
=regs.r_bp;
}


/* 等待键盘输入 */
void waitkey()
{
  _AX
=0;
  geninterrupt(
0x16);
}

/* 设置VGA 13H模式 */
void setmode()
{
  _AX
=0x13;
  geninterrupt(
0x10);
  GetFontAdd();
}


/* 设置文本模式 */
void closemode()
{
  _AX
=0x3;
  geninterrupt(
0x10);
}


/* 设置调色板 */
void setpal(int Color,BYTE r,BYTE g,BYTE b)
{
  outportb(
0x3c8,Color);
  outportb(
0x3c9,r);
  outportb(
0x3c9,g);
  outportb(
0x3c9,b);
}


/* 屏幕定位(用于输出字符)*/
void locate(int Line,int Col)
{
  _DH
=Line;
  _DL
=Col;
  _AH
=2;
  _BX
=0;
  geninterrupt(
0x10);
}


/* 从键盘缓冲区内直接读出扫描码 */
BYTE ScanKey(
void)
{
  
int  start,end;
  WORD key
=0;
  start
=peek(0,0x41a);
  end
=peek(0,0x41c);
  
if (start==end) return(0);
  
else
  
{
    key
=peek(0x40,start);
    start
+=2;
    
if (start==0x3e) start=0x1e;
    poke(
0x40,0x1a,start);
    
return(key/256);
  }

}


/* 在(X,Y)处绘点 */
void pset(int x,int y,BYTE color)
{
  pokeb(
0xa000,y*320+x,color);
}


/* 取(X,Y)处颜色 */
BYTE point(
int x,int y)
{
  
return peekb(0xa000,y*320+x);
}
 实现程序如下:
# include <stdlib.h>
# include 
"vga13h.h"
# include 
<dos.h>

void main()
{
  
int i,j;
  unsigned 
int x,y,c;
  setmode();
  
for (x=1;x<=32;x++)
  
{
    setpal(x,    x
*2-10,     0    );
    setpal(x
+3263,    x*2-10    );
    setpal(x
+6463,    63,    x*2-1);
    setpal(x
+9663,    63,    63   );
  }

  
while(ScanKey()!=1)
  
{
   
/*
   for (i=0;i<16;i++)
       for (j=0;j<16;j++)
       pset(random(300)+j,random(150)+i,random(256));
   
*/

   
for (x=0;x<320;x+=2)
   
{
     
for (y=1;y<=202;y+=2)
     
{
       c
=(point(x,y)+point(x+2,y)+point(x,y+2)+point(x+2,y+2))>>2;
       
if (c--)
       
{
      poke(
0xa000,(y-2)*320+x,(c<<8)+c);
      poke(
0xa000,(y-1)*320+x,(c<<8)+c);
       }

     }

     y
-=2;
     pset(x,y,random(
320));
   }

  }

  closemode();
}
C++_关于点的操作:【上一篇】
WINDOWS图像编程:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • Visual C#中随机数使用实例
  • 流行FrameWork整合之Spring??—— IoC反向控制篇
  • 常用品牌交换机端口镜像(Port Mirroring)配置
  • 一个完备的数据库连接池类(bczt)
  • 原创:::上VPN时也能访问外网了
  • RHLinux 下配置TP600E的声卡
  • 七类布线与光纤
  • 软件进步vs硬件进步
  • M3G内坐标系作用范围的混淆
  • 心痛了无痕
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.