Справочник функций

Ваш аккаунт

Войти через: 
Забыли пароль?
Регистрация
Информацию о новых материалах можно получать и без регистрации:

Последние темы форума

Показать новые сообщения »

Почтовая рассылка

Подписчиков: 11656
Последний выпуск: 19.06.2015

Работа с VESA 2.0 (WATCOM C)

#include <i86.h>
#include <mem.h>
#include <bios.h>

typedef unsigned short us;
typedef unsigned int word;
typedef unsigned char  uc;
typedef unsigned long  ul;

typedef struct SVBE_InfoBlock {
  uc VbeSignature[4];           // VBE Signature
  us VbeVersion;                // VBE Version
  ul OemStringPtr;              // Pointer to OEM String
  ul Capabilities;              // Capabilities of graphics cont.
  ul VideoModePtr;              // Pointer to Video Mode List
                                // Added for VBE 1.2+
  us TotalMemory;               // Number of 64kb memory blocks
                                // Added for VBE 2.0+
  us OemSoftwareRev;            // VBE implementation Software revision
  ul OemVendorNamePtr;          // Pointer to Vendor Name String
  ul OemProductNamePtr;         // Pointer to Product Name String
  ul OemProductRevPtr;          // Pointer to Product Revision String
  us AccelVbeVersion;           // VBE/AF Version
  ul AccelVideoModePtr;         // Pointer to Acclelerated Mode List
  uc Reserved20[216];           // Reserved for VBE implementation
                                // scratch area
  uc OemData[256];              // Data Area for OEM Strings
  uc NaVsyakiySloochay[100];    // 2e
} VBE_InfoBlock;

typedef struct SVBE_ModeInfoBlock {
  us ModeAttributes;            // mode attributes
  uc WinAAttributes;            // window A attributes
  uc WinBAttributes;            // window B attributes
  us WinGranularity;            // window granularity
  us WinSize;                   // window size
  us WinASegment;               // window A start segment
  us WinBSegment;               // window B start segment
  ul WinFuncPtr;                // pointer to window function
  us BytesPerScanLine;          // bytes per scan line
                                // Mandatory information for VBE 1.2 and above
  us XResolution;               // horizontal resolution in pixels or chars
  us YResolution;               // vertical resolution in pixels or chars
  uc XCharSize;                 // character cell width in pixels
  uc YCharSize;                 // character cell height in pixels
  uc NumberOfPlanes;            // number of memory planes
  uc BitsPerPixel;              // bits per pixel
  uc NumberOfBanks;             // number of banks
  uc MemoryModel;               // memory model type
  uc BankSize;                  // bank size in KB
  uc NumberOfImagePages;        // number of images
  uc Reserved12;                // reserved for page function
                                // Direct Color fields (required
                                // for direct/6 and YUV/7 memory models)
  uc RedMaskSize;               // size of direct color red mask in bits
  uc RedFieldPosition;          // bit position of lsb of red mask
  uc GreenMaskSize;             // size of direct color green mask in bits
  uc GreenFieldPosition;        // bit position of lsb of green mask
  uc BlueMaskSize;              // size of direct color blue mask in bits
  uc BlueFieldPosition;         // bit position of lsb of blue mask
  uc RsvdMaskSize;              // size of direct color reserved mask in bits
  uc RsvdFieldPosition;         // bit position of lsb of reserved mask
  uc DirectColorModeInfo;       // direct color mode attributes
                                // Mandatory information for VBE 2.0 and above
  ul PhysBasePtr;               // physical address for flat frame buffer
  ul OffScreenMemOffset;        // pointer to start of off screen memory
  us OffScreenMemSize;          // amount of off screen memory in 1k units
  uc Reserved20[206];           // remainder of ModeInfoBlock
  uc NaVsyakiySloochay[100];    // 2e
} VBE_ModeInfoBlock;

typedef struct SVBE_RMI {       // Rreal Mode Interrupt (RMI) structure
  ul EDI, ESI, EBP, ReservedByRMI,
     EBX, EDX, ECX, EAX;
  us flags,
     ES, DS,
     FS, GS,
     IP, CS,
     SP, SS;
} VBE_RMI;

ul                         bpc,bpl;
word                       maxx,maxy,mmode;
us VBE_FillInfoBlock       (VBE_InfoBlock *);
us VBE_FillModeInfoBlock   (VBE_ModeInfoBlock *, us vbemode);
us VBE_SetMode             (us vesamode, VBE_ModeInfoBlock *);
uc near *                  LFB;
VBE_InfoBlock far *        vinfo;
VBE_ModeInfoBlock far *    minfo;

void SetVESAMode(int xmax, int ymax, int bpp)
 {
  static VBE_RMI          RMI;
  union REGS              r;
  struct SREGS            sr;
  us                      sel,seg,x,y,ic;
  ul                      phys;

   r.x.eax=0x0100;
  r.x.ebx=600>>4;
  int386(0x31,&r,&r);
  if (r.x.cflag)
   {
    puts (" ю DOS memory alocate error.");
    return;
   }
  seg = r.w.ax;                         // RM segment
  sel = r.w.dx;                         // PM selector
  vinfo = (VBE_InfoBlock far *) MK_FP (sel, 0);
  _fstrncpy ((uc far *) vinfo, "VBE2", 4);
  memset (&sr, 0, sizeof (sr));
  memset (&RMI, 0, sizeof (RMI));
  RMI.EAX = 0x00004f00;   // Get VBE Info
  RMI.ES = seg;
  RMI.EDI = 0;
  r.w.ax = 0x0300;
  r.h.bl = 0x10;
  r.h.bh = 0;
  r.w.cx = 0;
  sr.es = FP_SEG (&RMI);
  r.x.edi = FP_OFF (&RMI);
  int386x (0x31, &r, &r, &sr);
  if (r.x.cflag)
   {
    puts (" ю DPMI 300h failed.");
    return;
   }
  if ((us) RMI.EAX != 0x004f)
   {
    puts (" ю Error Getting Video Controller Info.");
    return;
   }
  if (vinfo -> VbeVersion > 4;
  int386 (0x31, &r, &r);
  if (r.x.cflag)
   {
    puts (" ю DOS memory alocate error.");
    return;
   }
  seg = r.w.ax;    // RM segment
  sel = r.w.dx;    // PM selector
  minfo = (VBE_ModeInfoBlock far *) MK_FP (sel, 0);
  memset (&sr, 0, sizeof (sr));
  memset (&RMI, 0, sizeof (RMI));
  mmode=0;
  for (ic=0x4100;icBitsPerPixel==bpp)&&(minfo->XResolution==xmax)&&
        (minfo->YResolution==ymax)&&((us)RMI.EAX==0x004f))
     {
      if (mmode==0) {mmode=ic;}
     }
   }
  if (mmode==0)
   {
    puts (" ю Video mode no found.");
    return;
   }
  RMI.EAX = 0x00004f01;   // Get VBE Mode Info
  RMI.ECX = mmode;
  RMI.ES = seg;
  RMI.EDI = 0;
  r.w.ax = 0x0300;
  r.h.bl = 0x10;
  r.h.bh = 0;
  r.w.cx = 0;
  sr.es = FP_SEG (&RMI);
  r.x.edi = FP_OFF (&RMI);
  int386x (0x31, &r, &r, &sr);
  phys=minfo->PhysBasePtr;
  if (minfo->BitsPerPixel==32) {bpc=4;}
  if (minfo->BitsPerPixel==24) {bpc=3;}
  if (minfo->BitsPerPixel==16) {bpc=2;}
  if (minfo->BitsPerPixel==15) {bpc=2;}
  if (minfo->BitsPerPixel==8) {bpc=1;}
  bpl=minfo->BytesPerScanLine;
  maxx=minfo->XResolution;
  maxy=minfo->YResolution;
  r.w.ax = 0x0800;
  r.w.bx = (phys >> 0x10);
  r.w.cx = (phys & 0xffff);
  r.w.si = (long)((maxy*bpl)>>16);
  r.w.di = maxy*bpl;
  int386 (0x31, &r, &r);
  if (r.x.cflag)
   {
    puts (" ю Error mapping physical to linear");
    return;
   }
  LFB = (uc near *) (((ul) r.w.bx >8);
  b=(long)(color>>16);
  addr=y*bpl+x*bpc;
  LFB[addr+0]=r;
  LFB[addr+1]=g;
  LFB[addr+2]=b;
 }

void ellipse(int x, int y, int a, int b, long color)
{
 int col,i,row,bnew;
 long a_square,b_square,two_a_square,two_b_square,four_a_square,four_b_square,d;

  b_square=b*b;
  a_square=a*a;
  row=b;
  col=0;
  two_a_square=a_squareb_square*(col))
  {
   putpixel(col+x,row+y,color);
   putpixel(col+x,y-row,color);
   putpixel(x-col,row+y,color);
   putpixel(x-col,y-row,color);
   if (d>=0)
   {
    row--;
    d-=four_a_square*(row);
   }
   d+=two_b_square*(3+(col0;i--) {ellipse((maxx/2),(maxy/2),i,i,(j to test or  to change mode");
  ch=getch();
  if (ch==13)
   {
    SetVESAMode(x,y,c);
    if (mmode!=0) {test();}
    SetVGAMode(3);
   }
  if (ch==32)
   {
    printf("XResolution=");x=atoi(gets(xs));
    printf("YResolution=");y=atoi(gets(ys));
    printf("BitsPerPixel=");c=atoi(gets(cs));
   }
  } while (ch!=27);
 }

Оставить комментарий

Комментарий:
можно использовать BB-коды
Максимальная длина комментария - 4000 символов.
 
Реклама на сайте | Обмен ссылками | Ссылки | Экспорт (RSS) | Контакты
Добавить статью | Добавить исходник | Добавить хостинг-провайдера | Добавить сайт в каталог