Page 1 of 3
VESA
Posted: Fri Sep 24, 2004 3:04 pm
by Vladaz
Hello,
I started programming my OS's GUI and i stuck on VESA. I programmed a function that puts a pixel on the screen. Also i programmed a function that should draw the background, but it just draws a bold line. What is wrong? I'm using 118h 1024x768x16M mode
Re:VESA
Posted: Fri Sep 24, 2004 3:07 pm
by Dreamsmith
There's a bug in your code. (Sorry, can't be any more specific than that, given the lack of specific information in the question.)
Re:VESA
Posted: Fri Sep 24, 2004 3:46 pm
by Vladaz
Maybe there is no bug, but I missed something. Maybe do you know a good manual about VESA?
One friend told me about banks or something, that i have to change or swap those banks, but i don't know about it, because im newbie on GUI and VESA.
Re:VESA
Posted: Fri Sep 24, 2004 4:51 pm
by Dreamsmith
Google for the VBE BIOS specification, first result is
www.vesa.org/vbe3.pdf -- read it. Second, either before your OS switches to protected mode, or after if you have Virtual-8086 support, make the call to switch to a video mode of your choosing, being careful to set the "linear framebuffer" bit. By setting up a linear framebuffer, you don't need to bank-switch or resort to any other primitive, 80's style tricks to access video memory.
Re:VESA
Posted: Sat Sep 25, 2004 9:07 am
by Vladaz
So how can i set linear frame buffer?
Re:VESA
Posted: Sat Sep 25, 2004 9:39 am
by Dreamsmith
You set the linear framebuffer bit when you request the video mode. See the document linked to in my previous post for details.
Re:VESA
Posted: Sat Sep 25, 2004 10:18 am
by ASHLEY4
You put a 4 at the beginning of the mode number's, so for
"640*480*256" the mode number is 0x101 for bank mode
or 0x4101 for lfb.
You can do this for the mode number's.
To use lfb in pmode (nopaging) you simply do this
Code: Select all
mov ax,linear_sel
mov es,ax
mov edi,[ModeInfo_PhysBasePtr]
mov ecx, 640*480
mov al,byte[color]
rep stosb
ps: this "ModeInfo_PhysBasePtr" is in the vesa_info you should of filled in.
\\\\||////
(@@)
ASHLEY4.
Re:VESA
Posted: Sat Sep 25, 2004 12:39 pm
by Vladaz
So i updated in my bootloader to use VESA to this:
VESA:
mov ax, 4F00h
mov bx, 0x1000
mov es, bx
mov di, 0x10
int 10h
mov ax, 0x4F02
mov bx, 0x4118
int 10h
And what about that code that you wrote to me to use in pmode without paging? If I use PMODE, so I have to use that code? And if yes, so where can I find linear_sel , ModeInfo_PhysBasePtr etc. ?
Im using 0x118 vesa mode, maybe thats wrong?
Re:VESA
Posted: Sat Sep 25, 2004 3:55 pm
by ASHLEY4
Go here:
http://board.flatassembler.net/viewtopic.php?t=2301
To my message by me (ASHLEY4) and download
"vesa256.zip" this has full code ,and a bin file put this on the boot sector of a floppy with rawrite etc.
To run the demo.
In the code you will fined the mode numbers for 640*480*256 lfb, put the mode you want in place of that number.
Take a look at the code to see how its done.
and let me know if demo works on you pc.
ps: if you put another mode in, you will need to mod the fill screen with pixals, as in the size of screen x the number of bytes per pixel.
\\\\||////
(@@)
ASHLEY4.
Re:VESA
Posted: Sun Sep 26, 2004 3:54 pm
by Vladaz
When I chage video mode to 0x4118 and change
mov ecx,640*480/4
to
mov ecx,1024*768/4
it just fills less than half of screen.
That's because there was mistake:
mov ecx,640*480/4 is wrong.
It should be replaced with this:
mov ecx,640*480 I think or somethink similar.
I changed to mov ecx, 1024*768 because I'm using 0x4118
Maybe just my PC was having some problems, or maybe there really was a problem.
BTW, I tested it on Virtual PC.
Thanks, it really helped to me. Can I make some changes on it and integrated it to my OS?
Re:VESA
Posted: Sun Sep 26, 2004 4:59 pm
by ASHLEY4
Hi thanks for letting me know it works ok.
Code: Select all
mov [color],0xcccccccc
render_screen:
mov edi,[ModeInfo_PhysBasePtr]
mov ecx,640*480/4
mov eax,[color]
cld
rep stosd ;<*** this is stosd, not stosb
It may look wrong, but i used a "stosd" to mov a dword, instead of "stosb", if i had used "stosb" then you would be right, but as i am only filling the screen in one color it is quicker to move a dword and divide 640*480 by 4.
Also your problem with only filling half of the screen, is because the demo goes in pmode, you are going over 1mb, so you need to enable A20 to fill rest of screen.
I f you look at my demo for the 512b compo, you will notice that at the bottom is black, i faded it to black to hide the last 1 & 1/2 inch's which was not filled with color because
the a20 was not enabled ( i only had 512 bytes, to get into pmode, with full 24bit vesa graphics, atapi driver, and ipod image, cdplayer, menu ) so no room for A20.
Screenshot here:
http://www.falconrybells.co.uk/page2.htm
down load here:
http://512.decard.net/?body=entries
Give it a try, may not work on all pc, some of the code for the demo you down loaded is from it.
\\\\||////
(@@)
ASHLEY4.
Re:VESA
Posted: Sun Sep 26, 2004 5:31 pm
by ASHLEY4
Forgot to put, yes you may do with it what you like, a mention would be nice () .
This will fill your screen, once A20 is enabled.
Code: Select all
;*****************************
; render's graphic screen.
;*****************************
mov [color],0xcccccccc
render_screen:
mov edi,[ModeInfo_PhysBasePtr]
mov ecx,1024*768
mov eax,[color]
cld
rep stosd
My mode in the demo you down loaded was for 256 color's , so it only has 1 byte per pixal, your's vesa mode is for 4 bytes per pixal.
\\\\||////
(@@)
ASHLEY4.
Re:VESA
Posted: Mon Sep 27, 2004 3:03 pm
by Vladaz
OK, going big thanks for you, because you helped me a little
You are using a structure, but I had to erase that structure, because i have kernel, and i couldn't find another way how to do it. I need VESA to work on my kernel too, so I instead of having so much work and using structure, I put all info about VESA to memory, so I can reach that memory from my kernel and work with VESA.
Thanks.
Re:VESA
Posted: Tue Oct 12, 2004 1:36 pm
by Vladaz
Problems again :'( .
I was having a break for a week, and now I am continuing on VESA programming.
It doesn't put pixel on the screen.
I am initializeing VESA like this:
Code: Select all
VESA:
mov ax, 4f00h
mov bx, 0x1000
mov es, bx
mov di, 0x0FFF
int 10h
cmp ax, 004Fh
jne novesa
mov ax, 4f01h ; set vesa screen mode information
mov bx, 0x1000
mov es, bx
mov di, 0x11FF
mov cx, 0x4118
int 10h
mov ax, 4f02h ; set vesa screen mode
mov bx, 0x4118
int 10h
cmp ax, 004Fh
jne novesa2
jmp PMode
novesa:
mov si, msgNoVesa
call Print
novesa2:
mov si, msgNoVesa2
call Print
I put pixel like this:
Code: Select all
mov eax, [0x111FF+0x28]
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
What is wrong here? Can someone help me please?
Re:VESA
Posted: Tue Oct 12, 2004 6:01 pm
by oswizard
Code: Select all
mov eax, [0x111FF+0x28]
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
mov byte [eax], 0xFF
inc eax
The very first move is wrong. What you are doing is moving to eax the value stored at [0x111FF+0x28], not the address 0x111FF+0x28. If you change "mov" to "lea", it should work.
Your VESA info is going to 0x10FFF, and your mode info is at 0x111FF. Why the unaligned addresses? It might be marginally faster to put them at 0x11000 and 0x11000+sizeof(mode_info).