PDA

View Full Version : ** HELP ** Color driver and mouse



Sunny
11-19-2001, 07:49 AM
Please. If anyone is willing to help. I'm using a BGI driver that sets to 256 colors and high resolution. Only problem is that when i try to set to any video mode that is higher than 0 ( 320x240 ) the cursor doesn't get to be displayed. I'm working under DOS.


Thnx :)

VirtualAce
11-21-2001, 04:38 AM
I'm assuming based on your subject line that you mean the mouse cursor is not being displayed.

Hardware cursors usually only support certain resolutions and modes. The BGI driver may be using a screen mode/resolution that it does not support, or it is using it in a way that the mouse driver does not support. Either way it is not displaying the cursor because it would not look correct in the screen mode you are using. In fact, you probably don't what it to display the cursor because it would not be useful nor would it be displayed correctly.


Simple solution is to get the coordinates of the mouse cursor using subfunction 03h and then place your own mouse cursor at those coords. In order for your cursor to erase and redraw correctly (preserving the background) you will need to write some simple sprite blt functions. To prevent the cursor from blinking as it is constantly refreshed, only refresh and redraw when the mouse moves or is being moved. Check out the thread about mouse in 800x600x24 bit. There is a more thorough explanation there. Don't get confused about the 24 bit stuff, just ignore it and concentrate on the cursor drawing/redrawing/updating part of the post.

Sunny
11-21-2001, 06:48 AM
Well, thanks. Yes, i was well aware of the fact that the cursor works just that it was not being displayed. So i tried to display it myself, of course. Yes, i could retrieve the coordonates of the mouse ( X and Y location ) . So. ok i succeeded to draw the cursor. But when i decide to redraw the background i hav not yet devised some algoritm to prevent redraw over unless any movement has been made.

The way it goes till here:


void DrawMouse() // In a continuus loop
{
...
...
Get_Background_behind_mouse
DrawMouseCursorar_at_x_and_y
Redraw_Background_over

}

I havn't yet figured out how to detect if any movement has occured - and this would indeed help a lot, thus preventing the Blinkig. But otherwise, the blinking problem has not yet been solved.

Yes, i did look at the other thread, the one about 24 bit and mouse, but i did not find a solution to the blinking problem.


Anyways,
thank you very much.

VirtualAce
11-21-2001, 07:44 PM
The solution is in the other thread.


Here is some source for you in DOS Turbo C.

Sunny
11-22-2001, 04:12 AM
Gee... Don't know what to say. Thanks a lot.
Didn't expect the solution to be that simple, allthough i think i tried evey assembler thing i could think of. The source is REALLY good. I'm gonna see how it works in higher resolutions.

Thanks a lot.

VirtualAce
11-23-2001, 01:30 AM
No problem.

For higher resolution in real mode you willl need to learn about bank switching. If you are in protected mode, just get the address of the Linear Frame Buffer and plot to it just like in mode 13h.

The code I gave you will only work in mode 13h, but could easily be expanded to work in higher resolutions.

Sunny
11-23-2001, 01:25 PM
Thanks a lot again. Yes, i figured, 'cause when i switched
it to :
asm mov AX, 0x4f01
asm mov BX, 0x101

( 640x400x256colors )

while running under windows i got like ten consecutive blue screens, after
which ( i'm not kidding here ) i had to phisically turn off the pc. When i tried
to launch the compiler again ( Borland C++ 3.1 for DOS ) i only got
an error message saying something about memory fault. I had a backup though,
and i'm ok now. But yes, it doesn't work in higher res. And since you brought up the
subject about DPMI, would it be too much if i asked what it really is and how can
i use it? So far i understood it's a memory extender, i have to get some
address ( in assembly, of course ) and use that address somehow.

Thanks a lot again.


Sunny