vga13h.h
资源名称:flame [点击查看]
上传用户:hfstamp
上传日期:2007-01-14
资源大小:4k
文件大小:2k
源码类别:

图形图象

开发平台:

C/C++

  1. /*********************************************************/
  2. /*                     VGA13H模式函数                    */
  3. /*********************************************************/
  4. /*********************************************************/
  5. # if !defined(__DOS_DEF_)
  6. #    include <dos.h>
  7. # endif
  8. /* 此处定义了一些通用的宏 */
  9. # define BYTE  unsigned char
  10. # define WORD  unsigned int
  11. # define DWORD unsigned long
  12. # define BOOL  BYTE
  13. # define TRUE  1
  14. # define FALSE !TRUE
  15. /* BIOS 8*8 西文字库的段地址和偏移量 */
  16. WORD FONT_SEG;
  17. WORD FONT_OFF;
  18. void setmode();
  19. void waitkey();
  20. void closemode();
  21. void GetFontAdd();
  22. void locate(int Line,int Col);
  23. void pset(int x,int y,BYTE color);
  24. void setpal(int Color,BYTE r,BYTE g,BYTE b);
  25. BYTE ScanKey(void);
  26. BYTE point(int x,int y);
  27. /* 获取BIOS 8*8 西文字库的段地址和偏移量 */
  28. void GetFontAdd()
  29. {
  30.   struct REGPACK regs;
  31.   regs.r_bx=0x0300;
  32.   regs.r_ax=0x1130;
  33.   intr(0x10,&regs);
  34.   FONT_SEG=regs.r_es;
  35.   FONT_OFF=regs.r_bp;
  36. }
  37. /* 等待键盘输入 */
  38. void waitkey()
  39. {
  40.   _AX=0;
  41.   geninterrupt(0x16);
  42. }
  43. /* 设置VGA 13H模式 */
  44. void setmode()
  45. {
  46.   _AX=0x13;
  47.   geninterrupt(0x10);
  48.   GetFontAdd();
  49. }
  50. /* 设置文本模式 */
  51. void closemode()
  52. {
  53.   _AX=0x3;
  54.   geninterrupt(0x10);
  55. }
  56. /* 设置调色板 */
  57. void setpal(int Color,BYTE r,BYTE g,BYTE b)
  58. {
  59.   outportb(0x3c8,Color);
  60.   outportb(0x3c9,r);
  61.   outportb(0x3c9,g);
  62.   outportb(0x3c9,b);
  63. }
  64. /* 屏幕定位(用于输出字符)*/
  65. void locate(int Line,int Col)
  66. {
  67.   _DH=Line;
  68.   _DL=Col;
  69.   _AH=2;
  70.   _BX=0;
  71.   geninterrupt(0x10);
  72. }
  73. /* 从键盘缓冲区内直接读出扫描码 */
  74. BYTE ScanKey(void)
  75. {
  76.   int  start,end;
  77.   WORD key=0;
  78.   start=peek(0,0x41a);
  79.   end=peek(0,0x41c);
  80.   if (start==end) return(0);
  81.   else
  82.   {
  83.     key=peek(0x40,start);
  84.     start+=2;
  85.     if (start==0x3e) start=0x1e;
  86.     poke(0x40,0x1a,start);
  87.     return(key/256);
  88.   }
  89. }
  90. /* 在(X,Y)处绘点 */
  91. void pset(int x,int y,BYTE color)
  92. {
  93.   pokeb(0xa000,y*320+x,color);
  94. }
  95. /* 取(X,Y)处颜色 */
  96. BYTE point(int x,int y)
  97. {
  98.   return peekb(0xa000,y*320+x);
  99. }