VESA VBE Problems

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.
Post Reply
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

VESA VBE Problems

Post by Ycep »

Hi guys. I have an problem about finding VBE mode for 800x600 with 24-bit color depth, and seems that is something wrong with my code. Newest code: pastebin.
Top of the file is filled with Mode Info Block and Controller Info Block.
Scroll down a bit and you will find InitVBE, which seems to be problematic.
Mode won't set correctly nor on Bochs, nor on VMWare.
Any help?
Current problem: Now it passes through 30 modes and seem that VMware can't find 800x600 video mode nor with 24-bit color depth nor 32-bit color depth. The data may be corrupt.
Last edited by Ycep on Wed Sep 14, 2016 4:42 am, edited 1 time in total.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: VESA VBE Problems

Post by Octacone »

Make sure that you are calling those functions from real mode. Why do you want to use a 24 bit mode anyways? Are you doing all the necessary mode scanning?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: VESA VBE Problems

Post by Ch4ozz »

I cant see a direct error in your code, but you should debug first of all to see WHICH call exactly fails.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: VESA VBE Problems

Post by neon »

Code: Select all

cmp ax, 0x4F
je .damn
I noticed those two lines in a number of places throughout the code. However, al=4fh and ah=0 means that it is supported and the interrupt call was a success. In other words, if "ax = 0x4f" then the interrupt call was a success and not an error.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: VESA VBE Problems

Post by Ch4ozz »

neon wrote:

Code: Select all

cmp ax, 0x4F
je .damn
I noticed those two lines in a number of places throughout the code. However, al=4fh and ah=0 means that it is supported and the interrupt call was a success. In other words, if "ax = 0x4f" then the interrupt call was a success and not an error.
Haha your right, I didnt even check that part...
I shouldnt assume stuff sometimes huh
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: VESA VBE Problems

Post by Ycep »

Thanks both of you guys. Now it gets stuck in this part:

Code: Select all

  cmp dx, 0xFFFF
  je .damn2
  mov ax, 0x4f01
  mov cx, dx
  mov di, ModeBlock
  int 0x10
  cmp ax, 0x4F
  jne .damn
  mov ax, 800
  cmp [ModeBlock.xres], ax 
  jne .loop
  mov ax, 600
  cmp [ModeBlock.yres], ax
  jne .loop
  mov ax, 24
  cmp [ModeBlock.bpp], ax
  jne .loop
  mov eax, ModeBlock.pointer
  push eax
  mov ax, 0x4F02
  mov bx, dx
  or bx, 0x4000
  int 0x10
  cmp ax, 0x4f
  jne .damn
Anywhooo?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: VESA VBE Problems

Post by Brendan »

Hi,
Lukand wrote:Thanks both of you guys. Now it gets stuck in this part:
The nice thing about emulators like Bochs is that you can:
  • Enable the "magic breakpoint" feature (when configuring and compiling Bochs); then insert an "xchg bx,bx" instruction anywhere you like in your source code to make Bochs' debugger stop at that point.
  • Use Bochs' debugger to single-step from one instruction to the next
  • Examine the state of the CPU (registers, etc), the contents of memory, the state of various devices (PIT, PIC, etc)
These things combined mean that you can know exactly what is happening at every instruction.

Note that by pre-setting the signature field to to "VBE2" you're telling the "Get Controller Information" function that you've got a 512 byte buffer for its information; and VBE can store the list of video mode numbers in the "reserved" part of your 512 byte area. Your "InfoBlock" structure is not 512 bytes; so VBE just corrupts whatever is after that, and whatever is after that corrupts your "InfoBlock" structure. More specifically, each time you use the "Get Mode Information" function it trashes the "reserved" part of that 512 byte "InfoBlock" area that probably contains the list of video mode numbers, so (apart from the first time) you're probably asking VBE for mode information for dodgy/corrupted video mode numbers.

Note that the "ModeBlock" needs to be 256 bytes too. I don't know what is after that in memory (or what else you're corrupting).

Apart from that; "cli" then "hlt" breaks if you or firmware get an NMI or SMI (it "unhalts" the CPU, so CPU begins executing whatever is after the "hlt") and it'd be better to do a ".die: hlt" and "jmp .die" with interrupts left enabled, so that on real computers "control+alt+delete" and other IRQs (like the one for turning off floppy motor) still work.

Also, most real video cards (not emulators) typically only support 24-bpp (old video cards) or 32-bpp (most/newer video cards); which means that when your code actually works it probably won't help much on real hardware anyway. My advice is to generate all your graphics in a "standard for you" format (e.g. 32-bpp) in a buffer in RAM, and then have multiple different functions to convert that into whatever the video mode happens to want (either during or before blitting it to display memory). This makes it much much easier to support many different pixel formats (and can have significant other advantages later on when your code gets more advanced).


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: VESA VBE Problems

Post by BrightLight »

Lukand wrote:

Code: Select all

  mov ax, 24
  cmp [ModeBlock.bpp], ax
  jne .loop
The color depth is a byte value, not a word.
Lukand wrote:

Code: Select all

  mov eax, ModeBlock.pointer
This should be mov eax, [ModeBlock.pointer].
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: VESA VBE Problems

Post by Ycep »

@Brendan thanks for suggestions.
@omarrx24 #-o . Whoops. Thank you a lot too.
User avatar
Ycep
Member
Member
Posts: 401
Joined: Mon Dec 28, 2015 11:11 am

Re: VESA VBE Problems

Post by Ycep »

It seems that VMware can't find mode for 800x600 with 24-bit nor 32-bit color depth. It finds 30 modes, of which no one is 800x600 with 24-bit color depth.

@Brendan : Thank you a lot! That 512-byte and 256-byte thing fixed it a bit.
Why do Bochs Debugger won't appear in Win32? (in bochsdbg.exe)? I want to check all modes that it found, because it may be corrupt again.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: VESA VBE Problems

Post by BrightLight »

I can confirm VMware supports 800x600x32. Perhaps you are doing something wrong then, but your post is not very informative...
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Post Reply