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

📄 test.cpp

📁 DOS下利用VESA实现高分辨率、16bit色显示并输出汉字
💻 CPP
字号:
#include "video.h"
#include <alloc.h>

#define BOX_LEFT 200
#define BOX_TOP 200
#define BOX_RIGHT 400
#define BOX_BOTTOM 400
#define GRID_STEP 20
#define BOX_WIDTH 200

void DrawGrid(int iBackColor, int iGridColor);

void main()
{
    int x, y;
    int iOldX, iOldY;
    unsigned long i, inc;
    float sVolt;
    unsigned long iTemp;
    int iBus, iDevice;
    unsigned long iVidDid;

    int iRetVal;
    clrscr();

    iRetVal = InitGraph();
    if(iRetVal != 1)
    {
	printf("Error InitGraph!\n");
	return;
    }
    iRetVal = OpenEFont();
    if(iRetVal != 1)
    {
	printf("Error OpenEFont!\n");
	return;
    }
    iRetVal = OpenCFont();
    if(iRetVal != 1)
    {
	printf("Error OpenCFont!\n");
	return;
    }

    DrawGrid(0, RGB(0, 128, 0));
    getch();

    inc=0;
    while(!kbhit())
    {
	DrawGrid(0, RGB(0, 128, 0));
	for(i=0; i<BOX_WIDTH; i++)
	{
	    sVolt=90.0*sin(2.0*3.1415926*(i+inc)/50.0)+0x8-(rand()&0xf);
	    MemLine(iOldX, iOldY, 200+i, 300-sVolt, RGB(255, 255, 0));
	    iOldX=i+200;
	    iOldY=300-sVolt;
	}
	inc++;
	//sleep(1);
	for(iTemp=0; iTemp<100000; iTemp++)
	    sin(1);
    }

    getch();
    CloseGraph();
    CloseEFont();
    CloseCFont();
    clrscr();
}


void DrawGrid(int iBackColor, int iGridColor)
{
    int x, y;
    //Clear to backcolor
    for(y=BOX_TOP; y<BOX_BOTTOM; y++)
	for(x=BOX_LEFT; x<BOX_RIGHT; x++)
	    SetPoint(x, y, iBackColor);
    //Draw grid
    for(x=BOX_LEFT; x<=BOX_RIGHT; x=x+GRID_STEP)
	MemLine(x, BOX_TOP, x, BOX_BOTTOM, iGridColor);
    for(y=BOX_TOP; y<=BOX_BOTTOM; y=y+GRID_STEP)
	MemLine(BOX_LEFT, y, BOX_RIGHT, y, iGridColor);
}

⌨️ 快捷键说明

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