On notebook vga code doesn´t work

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
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

On notebook vga code doesn´t work

Post by FlashBurn »

I bought me a notebook for christmas and I wanted to test my os on this one, but it didn´t work :(

Now I found out that my getxy (vga) function doesn´t work on my NB. I don´t think that this is a problem of my code, but a problem of the notebook. Is here anyone who knows if there is some difference between the vga things on pcs and NBs?

Code: Select all

   	mov edx,3d4h	;Get Cursor Position MSB
   	mov al,0eh
   	out dx,al
   	
	add edx,1
   	in al,dx
   	shl eax,8		;Store MSB in ah
   	
	sub edx,1		;Get Cursor Position LSB
   	mov al,0fh
   	out dx,al
   	
	add edx,1
   	in al,dx		;Store LSB in al
   	
   	mov bl,80		;Divide to get XY coordinates (X in ah and Y in al)
   	div bl
It doesn´t get behind the 1st out command!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

have you checked that your notebook's video card is actually a vga compatible?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Post by FlashBurn »

I thought that all new graphic cards are vga compatible! If it isn´t, the other os´s like windows and linux should also not work, don´t they? Also I think a mobile x1800 (ati) should be vga compatible.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

This is the function from DexOS

Code: Select all

 ;'''''''''''''''''''''''''''''''''''''''''''''''''''';
 ; Sets cursor pos                                    ;
 ;----------------------------------------------------;
 ;                                                    ;
 ;  Input:                                            ;
 ;     [screen_x]    points to X                      ;
 ;                                                    ;
 ;     [screen_Y]    points to Y                      ;
 ;                                                    ;
 ; Output:                                            ;
 ;      None.                                         ;
 ;....................................................;

set_cursor_pos:
	push  eax
	push  ebx
	push  ecx
	push  edx
	xor   ebx,ebx
	mov   bl,[screen_x]
	mov   ecx,ebx
	mov   bl,[screen_y]
	mov   eax,80
	mul   bx
	add   eax,ecx
   mov   edx,0x3d4
	mov   ecx,eax
	mov   al,0x0f
	out   dx,al
	mov   eax,ecx
	inc   edx
	out   dx,al
	mov   al,0x0e
	dec   edx
	out   dx,al
	mov   eax,ecx
	mov   al,ah
	inc   edx
	out   dx,al			                     

	pop   edx
	pop   ecx
	pop   ebx
	pop   eax
	ret

Try DexOS or simular OS that use that and see if they work.
smbogan
Member
Member
Posts: 29
Joined: Tue Nov 21, 2006 3:17 pm

Post by smbogan »

Actually, they often do not all follow what you would expect from a VGA card. For example, my laptop will not display a graphics resolution properly below 1024 x 768 (or if it does, I'm not sure how to do it). The port values for a particular mode does not display the correct VGA mode. Normal VGA code looks fine in an emulator, but when ran natively it displays a mode that I didn't set it to. I've also tested the same code on a PC and it runs as expected.
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Post by FlashBurn »

@Dex

Thanks for your code, but my problem is the getxy function. I don´t get to the setxy function ;)

There must be a way, because windows does work, but Ubuntu has also problems with the vga code, but the 2D ati driver seems to work. Also seems the bios to work correctly!
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

FlashBurn wrote:but Ubuntu has also problems with the vga code
Big chance your card isn't completely VGA compatible.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Post by FlashBurn »

Big question is then, how can I find out if the used card is vga compatible or not? And where do I get information how to program such cards? Please do not tell me that there are not any information available. I thought that all newer cards are compatible.

Another option would be using vesa, but this isn´t an option at the moment :(
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,
FlashBurn wrote:Big question is then, how can I find out if the used card is vga compatible or not?
That's easy - it's not 100% VGA compatible at the hardware level (even though it might have "VGA compatible" BIOS functions).... ;)

In general, what you're doing isn't a good idea anyway - reading the current cursor position from VGA I/O ports is slow because reading (and writing) to any I/O ports is slow. A better idea would be to keep a copy in RAM, such that when you set the cursor position (and I/O ports) you set the values in RAM at the same time, and when you read the cursor position you only need to read the values from RAM - saving yourself slow I/O port reads and making your code less dependant on VGA compatibility.

An even better idea is to use BIOS functions during boot to turn the hardware cursor off, and then simulate your own cursor in software (if/when necessary). This is a little more work, but means your code can use the video card like a pure frame buffer without any I/O port accesses.
FlashBurn wrote:And where do I get information how to program such cards? Please do not tell me that there are not any information available. I thought that all newer cards are compatible.
Most modern video cards are slightly VGA compatible, ranging from BIOS functions only to most VGA I/O ports behaving the same. In general it's impossible to be 100% VGA compatible while providing more than a standard VGA card did. For example, for a 100% VGA compatible video card writing certain "undefined" values to the card's I/O ports should not cause the card to operate in higher resolutions or higher colour depths (but this is required in some way for SVGA).

AFAIK laptops are a little worse when it comes to "VGA compatibility", because often the LCD screen can only handle one screen resolution directly (and all other screen resolutions are a "pretend" subset of this). This isn't all that uncommon - for example, the standard 320 * 200 * 256 colour video mode actually has a resolution of 320 * 400 (as far as the monitor is concerned) and the video card pretends it's a 320 * 200 video mode by sending each scan line twice.

Anyway, unless you can work around the problem (e.g. as suggested above), then you'll need to write a video driver (or part of a video driver) to suit the specific video card. If it's an onboard Intel graphics chip you might be lucky. If it's not you're out of luck if VBE isn't an option.


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.
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Post by FlashBurn »

I used this method years ago, when I didn´t know how to get and set the cursor position. So it seems that I finally will go back to this method.

Thanks Brendan!
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

I do it in DexOS, ( that code snip is only call from a user program ) more like Brendan was saying, BOS user more like yours, you can see if you get the same problem by trying both ( i know some people do not like try code like this off the net, but it upto ).
This is from BOS

Code: Select all

;-----------------------------------;
;  get the cursor pos               ;
;            out: bh = x   bl = y   ;
;-----------------------------------;
getcursorxy:
	  push	  ax

	  call	  getcursor
	  mov	  ax, bx
	  mov	  bl, [screen_cols]
	  div	  bl
	  mov	  bl, al
	  mov	  bh, ah

	  pop	  ax
	  ret


;-------------------------------;
;  get the cursor pos           ;
;            out: bx = offset   ;
;-------------------------------;
getcursor:
	  push	  ax
	  push	  dx

	  mov	  dx, 0x3D4
	  mov	  al, 0x0E
	  out	  dx, al
	  inc	  dx
	  in	  al, dx
	  mov	  bh, al
	  mov	  al, 0x0F
	  dec	  dx
	  out	  dx, al
	  inc	  dx
	  in	  al, dx
	  mov	  bl, al

	  pop	  dx
	  pop	  ax
	  ret
I would be interested myself to know the answer as it will be more stuff to worry about :(.
FlashBurn
Member
Member
Posts: 313
Joined: Fri Oct 20, 2006 10:14 am

Post by FlashBurn »

@Dex

This code wont work, because it is the same as mine. The problem seems to be that the port isn´t used by teh graphics card.

@Brendan

I come to one problem when emulating the cursor. How can I make a cursor under a sign like an "A"? Without that the "A" is also blinking?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

FlashBurn wrote:I come to one problem when emulating the cursor. How can I make a cursor under a sign like an "A"? Without that the "A" is also blinking?
Without messing with VGA I/O ports, I'm not sure it's possible to have an underscore as the cursor.

I normally disable the blinking using the BIOS during boot, and then "xor" the attribute with 0x88 (i.e. change the intensity bit of the background and the foreground).

Of course I'm also wondering what you're doing with the cursor - IMHO it should only ever be visible when the computer is waiting for the user to type something, and shouldn't be visible otherwise... ;)


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
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

You need be sure it is the problem, have a look at your i/o ports range in the graphic card driver, under XP (sys) etc and see what that says.
Post Reply