From: _ <1s AT ge1ties DOT com> Newsgroups: comp.os.msdos.djgpp Subject: Re: Help! Confused by problems with VESA programming. Date: Wed, 09 Jul 1997 11:48:36 +0200 Organization: Aktiefront Red de Eikel. Message-ID: <33C35E74.79EA@ge1ties.com> References: <5psfn0$mpi$1 AT pulp DOT ucs DOT ualberta DOT ca> <33C24657 DOT 4AF6 AT cornell DOT edu> <5pvbbs$j1q$1 AT pulp DOT ucs DOT ualberta DOT ca> Reply-To: 1 AT 1 DOT com NNTP-Posting-Host: 145.220.196.73 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 140 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jon Martin wrote: > > "A. Sinan Unur" writes: > > >Jon Martin wrote: > >> > >> int main(void) > >> { > >> VBE_VgaInfo vgainfo; > >> VBE_ModeInfo modeinfo; > >> unsigned char colour; > >> int done = 0; > >> int y; > >> unsigned char virtscreen[307200]; > > >i haven't checked the rest of the code but this probably is the culprit. > >the default stack size for djgpp programs is 256K. you are asking for > >about 300K. you could stubedit this to 1 Mb and see if it makes a > >difference. however, a better programming practice would be to allocate > >the memory for the virtual screen from the heap (using malloc). > > I tried this (using malloc), but it did not change anything (the bugs > scurried elsewhere). I stripped it down to a bare minimum, to help reduce > clutter. The printf in the loop reveals that everything works fine up to > pixel 3921 (the 3922nd iteration of the loop). Then it crashes, often locking > my computer _hard_. Here is the new, stripped down main(), everything else > remains unchanged. > > int main(void) > { > VBE_VgaInfo vgainfo; > VBE_ModeInfo modeinfo; > int y; > > printf("finished startup stuff\n"); > fflush(stdout); > > if (VBE_detect(&vgainfo) < 200) > { > printf("Your card does not support VESA 2.0\n"); > fflush(stdout); > exit(1); > } > > printf("finished checking for VBE 2\n"); > fflush(stdout); > > VBE_getmodeinfo(0x101, &modeinfo); > > printf("finished getting modeinfo\n"); > fflush(stdout); > > if (modeinfo.ModeAttributes & 0x8) > { > printf("Linear frame buffer found\n"); > fflush(stdout); > } > else > { > printf("Linear frame buffer not found\n"); > fflush(stdout); > exit(1); > } > > printf("finished checking for LFB\n"); > fflush(stdout); > > VBE_get_linear_address(0x101); > > printf("finished getting linear address for 0x101\n"); > fflush(stdout); > > make_selector(); > > printf("finished making selector\n"); > fflush(stdout); > > VBE_setmode(0x4101); > > printf("finished setting mode 0x4101\n"); > fflush(stdout); > > for (y = 0; y < 307200; ++y) > { > _farpokeb(video_selector, y, 12); > > printf("finished setting pixel %d\n", y); > fflush(stdout); > } > > printf("finished looping thing\n"); > fflush(stdout); > > getchar(); > > printf("finished getting a char\n"); > fflush(stdout); > > textmode(LASTMODE); > > printf("finished returning to text mode (via textmode())\n"); > fflush(stdout); > > /* > VBE_setmode(0x03); > > printf("finished returning to text mode (via VBE_setmode())\n"); > fflush(stdout); > */ > > return(0); > } > -- > Serve Gonk. > Jon Martin jmartin AT obed DOT cs DOT ualberta DOT ca <-- finger for more info > http://elycion.geology.ualberta.ca/~jon/ > Department of Computing Science at University of Alberta. 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; This should be changed to regs.x.di = __tb & 0xfffF; regs.x.es = (__tb & 0xFFFF0000)>>4; Do this also in function VBE_getmodeinfo(0x101, &modeinfo); I've got some example source code that's almost the same as yours, but works for me at http://www.geocities.com/ResearchTriangle/5603/famebuffer_example.html