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

📄 init256.h

📁 该模块包括作业调度的三个系统进程。P1、P2、P3进程功能的实现。 P1负责对用户作业预输入处理
💻 H
字号:
/******************************************************************************
*******************************************************************************
INIT256.H
*******************************************************************************
******************************************************************************/

int huge Return_SVGA64K(void)
{
 return(SVGA1024x768x65536); /* 返回各种分辨率的对应编号 0~6 宏定义参见 Svga64k.h */
}

int huge Return_SVGA256(void)
{
 return(SVGA800x600x256); /* 返回各种分辨率的对应编号 0~6 宏定义参见 Svga64k.h */
}

typedef struct    /*16Mrgb像素类型*/
{unsigned char b;
 unsigned char g;
 unsigned char r;
}rgb16M;

void putpoint65536(int x,int y,rgb16M color)
{
 setrgbpalette(1026,color.r>>3,color.g>>2,color.b>>3);
 putpixel(x,y,0);
}

int OK256()
{
 int width,height,i=DETECT,j=0,x0,y0,fp;
 int errorcode;
 if(COLOR_MODE == 16)
 {
    INIT_GRAPHICS_16_COLOR();
    INIT_16_COLOR();
    return(-4);
 }
 installuserdriver("Svga256",Return_SVGA256);/* 对于svga256必需执行该函数以安装BGI驱动 */
 initgraph(&i,&j,"");/* 执行TC默认的BGI初始化函数 */
 errorcode = graphresult();
 if (errorcode != grOk)
   {
        INIT_GRAPHICS_16_COLOR();
        INIT_16_COLOR();
        return(-4);
        /* 安装用户设备失败,返回-4 */
    }
 if(G_DISPLAY_BMP_PICTURE_256(800,600,"book256.OP",0)==FALSE)
    return(FALSE);
/* getch(); */
 return(TRUE);
}

int OK64K()
{
 int width,height,i=DETECT,j=0;
 installuserdriver("Svga64K",Return_SVGA64K);/*对于svga64k必需执行该函数以安装BGI驱动*/
 initgraph(&i,&j,"");/* 执行TC默认的BGI初始化函数 */
 if(G_DISPLAY_BMP_PICTURE_64K("025.bmp")==FALSE)
    return(FALSE);
 getch();
 return(TRUE);
}


INSTALL_GRAPH_DRIVER()
{
    /* 注册系统图形驱动设备,使程序的运行完全脱离系统的SVGA256.BGI库 */
/*    registerbgidriver(SVGA256_driver); */
    /* 注册系统图形驱动设备,使程序的运行完全脱离系统的EGAVGE.BGI库 */
    registerbgidriver(EGAVGA_driver);
}


int G_DISPLAY_BMP_PICTURE_64K(char *bmpfile)
{
 int width,height,i,j,x0,y0,fp;
 char fix;
 rgb16M *buffer;
 if((fp=open(bmpfile,O_RDONLY|O_BINARY))==-1)
 {
    return(FALSE);
 }
 lseek(fp,18,SEEK_SET);
 read(fp,&width,4);
 read(fp,&height,4);
 fix=width%4;
 x0=(1024-width)/2;y0=(768-height)/2;
 lseek(fp,54,SEEK_SET);
 buffer=(rgb16M *)malloc(width*sizeof(rgb16M));

 for(j=height-1;j>=0;j--)
 {read(fp,buffer,width*sizeof(rgb16M));
  lseek(fp,fix,SEEK_CUR);
  for(i=0;i<width;i++)
   putpoint65536(x0+i,y0+j,buffer[i]);
 }
 free(buffer);
 close(fp);
 return(TRUE);
}


int G_DISPLAY_BMP_PICTURE_256(int x,int y,char *bmpfile,int style)
{
 int width,height,i,j,x0,y0,fp;
 char fix;
 unsigned char *buffer,pix24b[4];
 DacPalette256 dac256;

 if(blue_color==1)
   return(FALSE);

 if((fp=open(bmpfile,O_RDONLY|O_BINARY))==-1)
 {
    return(FALSE);
 }
 lseek(fp,18,SEEK_SET);
 read(fp,&width,4);
 read(fp,&height,4);
 fix=(width%4)?(4-width%4):0;
 if(style==0)
 {
    x0=(getmaxx()-width)/2;
    y0=(getmaxy()-height)/2;
 }
 else
 {
    x0=x;
    y0=y;
 }
 lseek(fp,54,SEEK_SET);
 for(i=0;i<256;i++) /* 按照该图片的DAC色表设置色彩寄存器 */
 {read(fp,pix24b,4); /* 读取DAC分量信息 */
  dac256[i][0]=pix24b[2]>>2;dac256[i][1]=pix24b[1]>>2;dac256[i][2]=pix24b[0]>>2; /* 设置调色板 */
 }
 setvgapalette256(&dac256); /* 应用调色板, 定义参见 Svga256.h */
 buffer=(unsigned char *)malloc(width);
 for(j=height-1;j>=0;j--)
 {read(fp,buffer,width);
  lseek(fp,fix,SEEK_CUR);
  for(i=0;i<width;i++)
   putpixel(x0+i,y0+j,buffer[i]);
 }
 free(buffer);
 close(fp);
 return(TRUE);
}


INIT_256_COLOR_TABLE()
{
 int i;
 unsigned char pix24b[4];
 DacPalette256 dac256;
 for(i=0;i<256;i++) /* 按照该图片的DAC色表设置色彩寄存器 */
 {strncpy(pix24b,&color_table[i*4],4); /* 读取DAC分量信息 */
  dac256[i][0]=pix24b[2]>>2;dac256[i][1]=pix24b[1]>>2;dac256[i][2]=pix24b[0]>>2; /* 设置调色板 */
 }
 setvgapalette256(&dac256); /* 应用调色板, 定义参见 Svga256.h */
}

INIT_16_COLOR()
{
        yellow_color=YELLOW;
        blue_color=BLUE;
        red_color=RED;
        green_color=GREEN;
        line_color=9;
        white_color=WHITE;
        print_color=7;
        paper_color=BLACK;
        shutdown_color=11;
        systemp_death_color=14;
        black_color=BLACK;
        machine_color = 7;
}

INIT_GRAPHICS_16_COLOR()
{
    int i,j,errorcode;
        i=VGA;
        j=VGAHI;
        initgraph( &i, &j, "" );
        errorcode = graphresult();
        if (errorcode != grOk)
        {
            exit(0);
        }
}

⌨️ 快捷键说明

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