Weird Results returned from Vesa.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
astrocrep

Weird Results returned from Vesa.

Post by astrocrep »

I use Function 4f00 to make sure its there,

then I do a get mode info (4f01) for mode 0x101 (640x480x8) and the resulting values loaded into my struct are as follows:

640 x 640 x 16

Umm what gives?? ??? ??? ???

Code: Select all

_VesaModeTest:    ; int (4b pointer, int mode)
        push    bp
        mov     bp, sp

;Takes the pointer of the passed struck and runs it.
   mov ax, ds
   mov es, ax
   mov ax, [BP+4]
   mov di, ax
   mov ax, 4F01h
   mov cx, [BP+6]
   int 10h

   cmp ax, 004fh
   je .1
   
   mov    ax, -1
        mov     sp, bp
        pop     bp
        ret

.1
; Vesa Seems ok Return the video given
   mov    ax, cx
        mov     sp, bp
        pop     bp
        ret
And the line I use to call this is as follows:

Code: Select all

if (VesaModeTest(&mib,0x101) == 0x101) printf("%i x %i x %i\n",mib.XResolution,mib.YResolution,mib.BitsPerPixel);
These results are the same in qemu and real hw.

Any Ideas?

Rich

P.S.

Thanks to Pype.Clicker for the idea of calling the vesa functions in external asm code. ;)
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

Ok, I fixed the first problem, but now I am even more stuck,

the value returned as the pointer for the lfb is 100h.

I thought maybe because I was in 16bit that it couldn't display the full address, just I switched the res (4101h, 640x480x8bit), switch to pmode and just write to the ptr to lfb and no dice, on top of that the top 1/4 of the screen as gray lines running down, with about 5 pixels in between.

Any ideas?

I have been reading VBE2.0.doc over and over,

Thanks

Rich
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

A few things I've noticed:

You can skip saving/making the stack frame, you don't use the stack for any local stuff.

Make the branches happen on the not often happening things, say, the call failing. Always optimize for success.

Can you post the struct definition?
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

This is my C code (16bit) that checks for vesa check to get the lfb and then sets the video mode

Code: Select all

mode = 0x4101

printf("VesaTest Returns: %x\n",VesaTest(&vib));
 if (strcmp(vib.sig,"VESA") == 0)
  {
   printf("VESA Signature Found, Total Video Ram: %iKb\n",vib.vid_mem_size * 64);
   printf("Video OEM String: %s\n",vib.oem_name);
   printf("Preforming Vesa Video Test for Mode %x...\n",mode);
   if (VesaModeTest(&mib,mode) == mode) 
   {
    printf("%i x %i x %i\n",mib.wd,mib.ht,mib.depth);
    printf("LFB %x\n",mib.lfb_adr);
    printf("Gonna do it, setting video and going to pmode.\n");
    pause(); 
    if (VesaSetMode(mode) == mode);
    else printf("Vesa Mode Set Failed...\n");
   }
   else printf("Vesa Mode Test Failed...\n");
  }
Attached is a couple of things:
1.) My asm file that runs the Vesa Related commands (16bit)
2.) The header file for the asm (not really important)
2.) My Header file that contains the structs which are based on the ones from Chris Giese   <[email protected]> very few modifications

Thanks For all the Help

Rich
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

Did a double check on RBIL and your struct does miss two entries, but they only matter for the linear address. Did you try checking out a memdump of the struct to see whether it's your printing code / struct or just plain the call to the function?
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

I can get the x and y res along w/ the pixel depth in that struct.

Soo, afaik, everything is working ok... but as we know, its not.

Sooo stumped... Think I maybe have to sleep on this one ???

Rich

Furthermore,

The thing is even when the res is switched, the screen has junk on it... the grey lines i mentioned before, but only 1/3 of the way... wierd...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

Are you really using a 4-byte pointer? If so, then you're loading your segment address as your video mode.
astrocrep wrote: The thing is even when the res is switched, the screen has junk on it... the grey lines i mentioned before, but only 1/3 of the way... wierd...
If you use the linear address, that's logical. You are missing two aux bytes just before it, so you take something slightly different to draw to.
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

not to ask a stupid question,

but what do you mean?

are you talking in the asm file, my skills w/ asm stink horribly.

Any suggestions?

Thanks

Rich

P.S. AFAIK, it sets the right video mode because I can tell by the window resizing.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

astrocrep wrote: not to ask a stupid question,

but what do you mean?

are you talking in the asm file, my skills w/ asm stink horribly.

Any suggestions?

Thanks

Rich

P.S. AFAIK, it sets the right video mode because I can tell by the window resizing.
The setting function might do the right thing, but the rest doesn't.

does your C function pass a 4-byte pointer to the asm code? If so, adjust the ebp+6 to ebp+8, so you skip over the entire pointer.

You miss two values in the C struct header, just before the linear address. Add them (both bytes) and check your docs on what they mean.
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

thanks, ill be looking right now,

Rich
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

Ok we're getting somewhere, I can see my pmode code drawing dots, but the screen is still slightly stripped, I could be that the memory is dirty, although, iirc, Setting the vmode clears the ram, but no biggie. And the changing 6 to 8 didn't work, But adding those 2 variables did, I can't believe I missed those, thanks for all your help!

Rich
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

astrocrep wrote: Ok we're getting somewhere, I can see my pmode code drawing dots, but the screen is still slightly stripped, I could be that the memory is dirty, although, iirc, Setting the vmode clears the ram, but no biggie. And the changing 6 to 8 didn't work, But adding those 2 variables did, I can't believe I missed those, thanks for all your help!

Rich
Are you setting exactly 0x101? That mode doesn't ask for a linear framebuffer, so in a way, the entire pointer would be wrong since it wasn't defined. It probably does point somewhere, but it only uses a single page.

The flag for LFB mode was either 0x4000 or 0x8000, believe it was 0x4000. That gets you 0x4101. Try that (after checking!)?

PS: if you have msn or icq you can add me to your list and get even quicker replies :)
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

Thats what I am using , 0x4101, and it mainly works

However, the wierd thing is, is I am only able to use the first 64 colors, from 65 to 255 its all black, I can reach all the way to the bottom of the screen, but not access all the colors.

Code: Select all

vidmem = (char *)vlfb;
  
  for (i=0;i<640*480;i++)
   vidmem[i] = i;
Is how I am doing it.

Pic included to help explain,

Thanks

Rich
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Weird Results returned from Vesa.

Post by Candy »

astrocrep wrote: Thats what I am using , 0x4101, and it mainly works

However, the wierd thing is, is I am only able to use the first 64 colors, from 65 to 255 its all black, I can reach all the way to the bottom of the screen, but not access all the colors.

Code: Select all

vidmem = (char *)vlfb;
  
  for (i=0;i<640*480;i++)
   vidmem[i] = i;
Is how I am doing it.

Pic included to help explain,

Thanks

Rich
You need a palette for you to see anything, usually. In QBasic the palette for 256-color is usually almost filled, but I have no idea what it is in this mode.

In any case, don't count on it being something, set it yourself. Try setting all to pure white and see if you can use your monitor as a backup light.


You can probably, but not for long, use the vga method of setting palette entries. Output a byte to 0x3c8 indicating the color you want to change, and then output 3 bytes to 0x3c9 that indicate the red/green/blue levels for them (afaik they're 0-63 rgb levels, but you can set that to 0-255 by reprogramming the ramdac).
astrocrep

Re:Weird Results returned from Vesa.

Post by astrocrep »

Ok ill look into it!

Thanks for all the help tonight its very much appreciated.

I need to get to bed, its 2:40am here and I got work in less then 6 hours :o

Thanks again

Rich
Post Reply