Mail Archives: djgpp/1997/07/09/21:49:07
Jon Martin wrote:
>
> "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.
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
- Raw text -