From: enigma AT erols DOT com (enigma) Newsgroups: comp.os.msdos.djgpp,comp.graphics.algorithms Subject: Re: VESA 2.0 and NEAR PTR Date: Thu, 13 Mar 1997 03:51:06 GMT Organization: djgpp, i luv u ;) Lines: 128 Message-ID: <3327780b.7631253@news.erols.com> References: <33232BE7 DOT 2F3D AT nada DOT kth DOT se> NNTP-Posting-Host: dam-as14s68.erols.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp >int VBE_detect(VBE_VgaInfo *vbeinfo) { > __dpmi_regs regs; > > assert(sizeof(*vbeinfo) < _go32_info_block.size_of_transfer_buffer); > regs.x.ax = 0x4F00; > regs.x.di = __tb & 0x0F; > regs.x.es = (__tb >> 4) & 0xFFFF; > dosmemput(vbeinfo,sizeof(*vbeinfo),__tb); > __dpmi_int(0x10, ®s); > dosmemget(__tb, sizeof(*vbeinfo), vbeinfo); > if(strncmp(vbeinfo->VESASignature,"VESA",4) != 0) return 0; > else return vbeinfo->VESAVersion; >} ^^^ First problem: You never told the VESA driver you wanted VBE 2.0 Info. You should send 'VBE2' in the vesa signature on the struct. > > > >void VBE_getmodeinfo(unsigned short mode, VBE_ModeInfo *modeinfo) { > __dpmi_regs regs; > > assert(sizeof(*modeinfo) < _go32_info_block.size_of_transfer_buffer); > regs.x.ax = 0x4F01; > regs.x.cx = mode; > regs.x.di = __tb & 0x0F; > regs.x.es = (__tb >> 4) & 0xFFFF; > __dpmi_int(0x10, ®s); > dosmemget(__tb, sizeof(*modeinfo), modeinfo); > return; >} ^^ I always CHECK this bios call, cause it returns false 15% of the time. >/* >#define SUPPORTED 1 >#define NOT_SUPPORTED 0 > >int check_640x480x256(void) { > __dpmi_regs regs; > regs.x.ax = 0x4F02; > regs.x.bx = 0x4101; > __dpmi_int(0x10, ®s); > if(regs.x.ax == 0x4F) return SUPPORTED; > else return NOT_SUPPORTED; ^^ This does not check if it's supported. Only if the function returned without any errors. check the high byte.. > > >unsigned int linear_address; > >void VBE_get_linear_address(int mode) { > VBE_ModeInfo modeinfo; > __dpmi_meminfo mem; > > VBE_getmodeinfo(mode, &modeinfo); > mem.size = (unsigned long)(modeinfo.XResolution * modeinfo.YResolution >* modeinfo.BitsPerPixel/8); > mem.address = modeinfo.PhysBasePtr; > __dpmi_physical_address_mapping(&mem); > linear_address = mem.address; > return; >} > > >VBE_ModeInfo modeinfo; > > >void VBE_setmode(int mode) { > __dpmi_regs regs; > regs.x.ax = 0x4f02; > regs.x.bx = mode | 0x8000; > __dpmi_int(0x10, ®s); > return; >} check these, man.. VBE 2.0 sux >void settext() { > __dpmi_regs regs; > regs.x.ax = 3; > __dpmi_int(0x10, ®s); > return; >} > > >int main(void) { > /*if(VBE_detect(&vbeinfo) < 0x200) { > printf("Your card does not support VESA 2.0\n"); > exit(1); > }*/ why commented? > int mode = 0x4101; actually .. send in 101.. much better.. > VBE_getmodeinfo(mode, &modeinfo); > if(modeinfo.ModeAttributes & 0x8) > printf("Linear frame buffer found\n"); > else { > printf("Linear frame buffer not found\n"); > exit(1); > } > > VBE_get_linear_address(mode); > char* video = (char*)linear_address; > VBE_setmode(mode); // 640x480x256 > > getch(); > > __djgpp_nearptr_enable(); > video += __djgpp_conventional_base; > for(int i=0;i<640*480;i++) > video[ i ] = (unsigned char)(i&255); > __djgpp_nearptr_disable(); > > getch(); > settext(); > cout << modeinfo.PhysBasePtr << endl; > cout << int(video) << endl; > return 0; >} > >------------------------------ >please reply to newsgroup and mail... >d95-nlu AT nada DOT kth DOT se >------------------------------ tell me if i'm wrong. its late. i'm tired. i hate VBE 2.0, the docs are pages and pages.. mint enigma AT erols DOT com