GUI
Re: GUI
You can set vesa mode in realmode and use LFB ( you will need to check that your vesa supports it, most vesa2 do ), then you can use the LFB as easy as you could use 0A000H in the old dos days.
Re: GUI
Hi,
What Alberich probably wants to know is the best way to implement support for a mouse pointer (given limited developer time, etc). IMHO the answer to this is to mimic the hardware in software, in the legacy video driver. That way the GUI can give the video driver the data that describes the mouse pointer, and the video driver can blit the mouse pointer to the screen manually (and eventually, someone might be able to write video drivers that do use the video card's hardware accelerated pointer/cursor without anyone needing to change any other software).
The only problem here is trying to figure out the format for the mouse pointer data. You'd want a format that can be used easily by video drivers that support hardware accelerated mouse pointers. However, unfortunately different video cards do it differently.
AFAIK a lot of video cards use a pair of 32 * 32 bitmaps (an "AND mask" and an "OR mask") where a pixel underneath the mouse pointer is effected by the corresponding bit in both of these bitmaps. For example:
Also note that this format for mouse cursor data is used by the VBE AF specification, and is apparently similar to the format used by the "Windows 3.1 cursor file format".
However, for most modern video cards you could probably just use hardware accelerated 2D bit-blits (with alpha channel for transparency), so that you can have any colours you like (and any size mouse pointer you like).
Because of this I'd be tempted to use a 32-bpp format (alpha, red, green, blue), and then let the video driver convert this data into whatever format it needs (but I'd also make sure the mouse pointer data is either 32 * 32 or 64 * 64 to make it easier to convert to the "AND mask and OR mask" format, if necessary).
Cheers,
Brendan
I take a different view. The best way to draw a mouse pointer on the screen is to use the video card's hardware accelerated pointer/cursor, where (typically) you upload data that describes the mouse pointer into the video card, and then tell the video card where to display it if it moves.tantrikwizard wrote:the best way is always going to be a point of discussion, in the long run it will depend on your implementation.alberich wrote:...which is the best way to draw mouse pointer on screen? ...
What Alberich probably wants to know is the best way to implement support for a mouse pointer (given limited developer time, etc). IMHO the answer to this is to mimic the hardware in software, in the legacy video driver. That way the GUI can give the video driver the data that describes the mouse pointer, and the video driver can blit the mouse pointer to the screen manually (and eventually, someone might be able to write video drivers that do use the video card's hardware accelerated pointer/cursor without anyone needing to change any other software).
The only problem here is trying to figure out the format for the mouse pointer data. You'd want a format that can be used easily by video drivers that support hardware accelerated mouse pointers. However, unfortunately different video cards do it differently.
AFAIK a lot of video cards use a pair of 32 * 32 bitmaps (an "AND mask" and an "OR mask") where a pixel underneath the mouse pointer is effected by the corresponding bit in both of these bitmaps. For example:
Code: Select all
AND mask OR mask Result
0 0 Black pixel
0 1 White pixel
1 0 Transparent pixel
1 1 Inverted pixel
However, for most modern video cards you could probably just use hardware accelerated 2D bit-blits (with alpha channel for transparency), so that you can have any colours you like (and any size mouse pointer you like).
Because of this I'd be tempted to use a 32-bpp format (alpha, red, green, blue), and then let the video driver convert this data into whatever format it needs (but I'd also make sure the mouse pointer data is either 32 * 32 or 64 * 64 to make it easier to convert to the "AND mask and OR mask" format, if necessary).
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.
Re: GUI
GRUB can do the VESA mode switches for you, but only if you patch it. I think this is mentioned on the wiki somewhere, and I know for certain there's links to patches in a couple of threads on here. Or you can Google something like "GRUB vesa vbe patch". Ah, found the thread I was talking about: http://forum.osdev.org/viewtopic.php?f=1&p=139446quanganht wrote:I' using GRUB, so how to return to Unreal mode? Can GRUB setup Vesa for me?
Alternatively, you can use a v86 task to do this for you, but remember that v86 mode isn't available in long mode. For that reason, I plan to emulate all the 16-bit code with the help of x86emu.
Re: GUI
HI, anyone!
I tried to use VESA LFB modes, but they just work in assembly code. Trying to do the same in C or C++ environment makes me crash(e.g. it nothing happens)! Maybe it'd be normal to write in ASM(like MenuetOS) but i still want to use C++. I use BrokenThorn tutorial (written in MSVC++). But earlier I tried the same with other tutorials written in GCC. BUt anyway it doesn't work anywhere. I have made design of GUI, but I cann't improve it to my OS because of unworked LFB modes in C++. I thought that it can be caused by Paging, but even without paging nothing works (in ASM - works great!). Can anyone help?
Thanks!
I tried to use VESA LFB modes, but they just work in assembly code. Trying to do the same in C or C++ environment makes me crash(e.g. it nothing happens)! Maybe it'd be normal to write in ASM(like MenuetOS) but i still want to use C++. I use BrokenThorn tutorial (written in MSVC++). But earlier I tried the same with other tutorials written in GCC. BUt anyway it doesn't work anywhere. I have made design of GUI, but I cann't improve it to my OS because of unworked LFB modes in C++. I thought that it can be caused by Paging, but even without paging nothing works (in ASM - works great!). Can anyone help?
Thanks!
Don't think a ****, but in ukrainian schools English is TOO BAD!
-
- Member
- Posts: 153
- Joined: Sun Jan 07, 2007 9:40 am
- Contact:
Re: GUI
Setting VBE LFB is a hardware setting, its language independent. The problem is not the C/C++ language, theres a bug in your code.djsilence wrote:...I tried to use VESA LFB modes, but they just work in assembly code. Trying to do the same in C or C++ environment makes me crash...
Re: GUI
Well, bugs can happen because of the language... For example, if you have C + inline assembly, it can be buggier than simple assembly.tantrikwizard wrote:Setting VBE LFB is a hardware setting, its language independent. The problem is not the C/C++ language, theres a bug in your code.djsilence wrote:...I tried to use VESA LFB modes, but they just work in assembly code. Trying to do the same in C or C++ environment makes me crash...
Re: GUI
I've got tha same problem. I tried to do that fully in clear c++, in inline assemby (in GCC), tried writting _asm function in MSVC++ (using BrokenThorn tutorial that is written in MSVC++), and even tried to do asm function that is declared as global and is declared in C++ as external function and then just call it. Nothing helps. I use Dex demo wich is written in asm (like DexOS).
I tried do the next:
while OS still in ASM environment it fills screen in some color, then it calls _main() that is doing nothing (just return to the asm) and the I tried to fill screen in another color to determinate that it wirks. But the first time I fill screen it works and after main call it doesn't work. ?
I tried do the next:
while OS still in ASM environment it fills screen in some color, then it calls _main() that is doing nothing (just return to the asm) and the I tried to fill screen in another color to determinate that it wirks. But the first time I fill screen it works and after main call it doesn't work. ?
Don't think a ****, but in ukrainian schools English is TOO BAD!
Re: GUI
First do you return from function calls _main() OK, to test this try calling a beep function on return, here is a simple example
If you get no beep than your problem is your not returning, if it beeps, then your problem could be too do with regs not save etc.
Code: Select all
;----------------------------------------------------;
; Beep ;
;----------------------------------------------------;
Beep:
mov [Hz],0x200 ;Call this function, for beep
call Sound
call DeLay
call NoSound
ret
;----------------------------------------------------;
; Sound ;
;----------------------------------------------------;
Sound:
mov bx,[Hz]
mov ax,0x34dd
mov dx,0x0012
cmp dx,bx
jnc Done1
div bx
mov bx,ax
in al,0x61
test al,3
jnz A99
or al,3
out 0x61,al
mov al,0xb6
out 0x43,al
A99:
mov al,bl
out 0x42,al
mov al,bh
out 0x42,al
Done1:
ret
;----------------------------------------------------;
; NoSound ;
;----------------------------------------------------;
NoSound:
in al,0x61
and al,11111100b
out 0x61,al
ret
;----------------------------------------------------;
; DeLay ;
;----------------------------------------------------;
DeLay:
mov cx,[ms1]
jcxz A2
A1:
call DeLaYoneMS
loop A1
A2:
ret
;----------------------------------------------------;
; DeLaYoneMS ;
;----------------------------------------------------;
DeLaYoneMS:
push ecx
mov cx,[OneMS]
B1:
loop B1
pop ecx
ret
OneMS dw 40000
Hz dw 0
ms1 dw 1000
Re: GUI
Or if you want something much easier (in my opinion) you can use the Bochs Graphics Adapter (can be found on the wiki). It might not be what you're looking for but it still allows you to change video resolutions and draw pixels like you would with most other ways of accessing graphics.quanganht wrote:Is there any way to use VESA without returning to Unreal mode?
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: GUI
Another alternative (that will work on real hardware) is the protected mode entry point for VESA. Look up the specifications, it allows you to change video modes while in pmode. Idk how well its supported though.