delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/12/19:47:20

From: jmartin AT obed DOT cs DOT ualberta DOT ca (Jon Martin)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help! Confused by problems with VESA programming.
Date: 9 Jul 1997 06:33:32 GMT
Organization: U of Eh?
Lines: 116
Message-ID: <5pvbbs$j1q$1@pulp.ucs.ualberta.ca>
References: <5psfn0$mpi$1 AT pulp DOT ucs DOT ualberta DOT ca> <33C24657 DOT 4AF6 AT cornell DOT edu>
Reply-To: jmartin AT obed DOT cs DOT ualberta DOT ca
NNTP-Posting-Host: obed.cs.ualberta.ca
Originator: jmartin AT obed-le0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"A. Sinan Unur" <asu1 AT cornell DOT edu> 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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019