OSDev.org https://forum.osdev.org/ |
|
drawing with VGA https://forum.osdev.org/viewtopic.php?f=1&t=33218 |
Page 1 of 3 |
Author: | alberinfo [ Fri Oct 05, 2018 12:19 pm ] |
Post subject: | drawing with VGA |
hi, i'm trying to write to screen with VGA.i can switch to some text and graphical modes, so that isn't the problem.but, i can't draw to screen. the idea is to write directly to video ram, and not using the bios.when i draw, it just draws something buggy, and also i can't set the color.how can i do it?. in my github repo, there is the way that i use to draw, but as i said, it's buggy. Thanks! |
Author: | SpyderTL [ Fri Oct 05, 2018 3:19 pm ] |
Post subject: | Re: drawing with VGA |
First, be sure you have called the BIOS function to enable the A20 address line. Without that, you will only have access to half of the video memory. Next, call BIOS function INT 10h with AL = 13h and AH = 0h to switch to Mode 13h. Then write 0x01 to address 0xA0000 (or address 0x00 with the DS register set to 0xA000), and the next 64,000 bytes. This should set the entire screen to blue. Let us know if it doesn't work, and we'll try to help you track down the issue. Thanks. |
Author: | alberinfo [ Fri Oct 05, 2018 5:53 pm ] |
Post subject: | Re: drawing with VGA |
the A20 line is enabled, see in "Bootloader.asm" before calling the kernel.as i said, i wont use BIOS interrupts, the VGA driver is for computers that cannot use VM8086.so let me rewrite the question;i want to draw with VGA graphical modes without BIOS. Thanks! |
Author: | Brendan [ Fri Oct 05, 2018 7:36 pm ] |
Post subject: | Re: drawing with VGA |
Hi, alberinfo wrote: i'm trying to write to screen with VGA.i can switch to some text and graphical modes, so that isn't the problem.but, i can't draw to screen. the idea is to write directly to video ram, and not using the bios.when i draw, it just draws something buggy, and also i can't set the color.how can i do it?. in my github repo, there is the way that i use to draw, but as i said, it's buggy. I have no idea what your code is trying to do. It looks like it tries to use direct IO port writes to set a "640*480 with 16 colours" VGA mode (which is a horribly bad idea on its own - far too many things can go wrong); but then the code to draw pixels looks like it's designed for a "640*480 with 65536 colours" mode (that is not a VGA mode and can't be set using standard VGA IO ports). Note that for "640*480 with 16 colours" VGA mode, video memory is split into 4 planes, where each plane contains one bit for each pixel and each pixel is spread across all 4 planes (a little bit like there's 4 separate 1-bit bitmaps). Normally you can't set a pixel with a single write (e.g. you need to change one bit in the first plane, then switch to the second plane, then change one bit in the second plane, then...); however there's various "write modes" (and masks and other logic) that (in theory) can be used to modify how the hardware processes a write and what it effects. Please note that:
In other words; you seem to be doing a lot of unnecessary work (virtual8086 mode, native VGA driver) to get everything wrong for no sane reason (because you've assumed that the OS should be able to change video modes after boot when it mostly should not). Cheers, Brendan |
Author: | alberinfo [ Sat Oct 06, 2018 8:50 am ] |
Post subject: | Re: drawing with VGA |
hi, thanks for your reply.but the idea for the operating system is to revive old computers, that doesn't work with new OS like windows or linux, like x86 computers, but also to be able to run in new computers.so VGA isn't the way, ok, but then, how to set a graphical mode and write to the screen without bios, and that it's capable to run in any graphics card, like a univesal method? Thanks! |
Author: | Brendan [ Sat Oct 06, 2018 11:16 am ] |
Post subject: | Re: drawing with VGA |
Hi, alberinfo wrote: thanks for your reply.but the idea for the operating system is to revive old computers, that doesn't work with new OS like windows or linux, like x86 computers, but also to be able to run in new computers. How old (e.g. so old that you need to worry about EGA too)? Don't forget that 64-bit 80x86 was released in 2003 (15 years ago), and for computers "old" mostly means "about 10 years old", which (for the low-end) translates to "dual core 64-bit CPU with 2 GiB or more RAM and a video card & monitor capable of 1366*768 or better". alberinfo wrote: so VGA isn't the way, ok, but then, how to set a graphical mode and write to the screen without bios, and that it's capable to run in any graphics card, like a univesal method? There is none. The only universal option is to use the firmware (including VBE on BIOS, and GOP and UGA on UEFI); and for UEFI systems you can't use GOP or UGA after boot (and can only continue using the video mode and framebuffer that was setup during boot). Cheers, Brendan |
Author: | alberinfo [ Sat Oct 06, 2018 11:30 am ] |
Post subject: | Re: drawing with VGA |
so, what about setting up a framebuffer in the 'kernelloader'?i think it could solve this problem |
Author: | Brendan [ Sat Oct 06, 2018 11:49 am ] |
Post subject: | Re: drawing with VGA |
Hi, alberinfo wrote: so, what about setting up a framebuffer in the 'kernelloader'?i think it could solve this problem I'm not sure what your "kernel loader" actually does; but if it has access to firmware's functions (or can get access to them) then it will work (and is the only option I'd recommend). Note that for multi-boot (e.g. GRUB) it's not so simple - if you boot from UEFI then the boot loader calls "exitBootServices()" before starting any of your code so none of your code can use the UEFI functions for video. In this case the only sane (easy, reliable-ish and future proof) option is to let the boot loader setup a video mode before starting your code (e.g. before starting your "kernel loader"?) and let the boot loader tell your code the details for the video mode it set up for you (framebuffer address, resolution, pixel format, pitch, etc). Cheers, Brendan |
Author: | BenLunt [ Sat Oct 06, 2018 12:38 pm ] |
Post subject: | Re: drawing with VGA |
alberinfo, I totally agree with Brendan's statement: Brendan wrote: ...the only sane (easy, reliable-ish and future proof) option is to let the boot loader setup a video mode before starting your code (e.g. before starting your "kernel loader"?) and let the boot loader tell your code the details for the video mode it set up for you (framebuffer address, resolution, pixel format, pitch, etc). This is the best way to do it and then once your kernel takes over, it can (if it so desires) search for and enumerate the video card, load a driver for it, then using that driver, change to a different/better video mode. Only this way is the best and most reliable way to do this. The enumeration of the video card can be early in the loading stage, where there is a flicker of the screen from the mode the firmware set to the new mode of the newly loaded driver, or it can be later in the stage where you have loaded/started your GUI and there let the driver change the mode. There is no easy way around it. You can't get to the best screen mode without a bit of work first. Sorry. Ben |
Author: | alberinfo [ Sun Oct 07, 2018 8:55 am ] |
Post subject: | Re: drawing with VGA |
ok.the bootloader is grub, the "kernelloader" is in my repo as "bootloader.asm".so in bootloader.asm i'm in protected mode, so the only way aviable for setting up a framebuffer is in grub? |
Author: | Schol-R-LEA [ Sun Oct 07, 2018 9:14 am ] |
Post subject: | Re: drawing with VGA |
Short of writing drivers for a number of different possible hardware configurations, yes. Note that to use modes not supported by the boot loader (whether GRUB or the UEFI loader), or most 2D or 3D acceleration features, you would need to write device-specific drivers eventually, anyway. |
Author: | alberinfo [ Mon Oct 08, 2018 5:08 pm ] |
Post subject: | Re: drawing with VGA |
i've made a way to draw through VGA set by the io ports(Yes, I know your recommendations for not setting a video mode through io ports, but I think I'm still at a very early stage of development to start writing specific drivers)which works fine.the max resolution that i can get is 640x480x16, which is not the best, but it's fine.i've seen that theres a horizontal table and a vertical table for the video modes, so i was thinking, can i write another table(in the repo ar tbl_hor(or ver for vertical res)_gra(or txt for text modes)and then the number of pixels), so i can use 800x600x16? |
Author: | Brendan [ Mon Oct 08, 2018 8:03 pm ] |
Post subject: | Re: drawing with VGA |
Hi, alberinfo wrote: i've made a way to draw through VGA set by the io ports(Yes, I know your recommendations for not setting a video mode through io ports, but I think I'm still at a very early stage of development to start writing specific drivers)which works fine.the max resolution that i can get is 640x480x16, which is not the best, but it's fine.i've seen that theres a horizontal table and a vertical table for the video modes, so i was thinking, can i write another table(in the repo ar tbl_hor(or ver for vertical res)_gra(or txt for text modes)and then the number of pixels), so i can use 800x600x16? In theory you can misconfigure a VGA controller to get a 800x600x16 video mode. The problem is that pixel clock isn't fast enough to match any standard/established video timing (it'd be something like "800x600x16 at 47 frames per second") so most monitors won't support it because they won't recognise the video timing. Note that the slowest standard/established video timing would be "800x600 at 56 Hz (non-interlaced)"; and this video timing needs a 36 MHz pixel clock (VGA only has 28.322 MHz). You'd also need to get the horizontal and vertical sync pulse polarities right (both positive not both negative like you'd use for 640*480) and make sure all the other timing (front porch width, sync pulse width, back porch width; for both horizontal and vertical timing) is correct. To set up a faster pixel clock (to get an 800x600 video mode timing the monitor is more likely to recognise) you need to use "non-standard, non-VGA", and that means you'd need a native driver for each specific video card. You should also understand that there's "safe mode timings" that all monitors are supposed to support (which includes the "640*480 at 60 Hz" timing that VGA provides); and everything else is optional and may not be supported by the monitor. For this reason, if you're not using a safe mode timing, then you should ask the monitor what it supports (by obtaining and parsing its EDID) before attempting to set a (potentially unsupported) video mode. Cheers, Brendan |
Author: | alberinfo [ Wed Oct 10, 2018 6:11 am ] |
Post subject: | Re: drawing with VGA |
thanks, but i wont write a specific driver just for a 800x600 resolution, also note that(as far as i understand) the 800x600 standard is established by SVGA and not by VGA. Thanks! |
Author: | mallard [ Wed Oct 10, 2018 6:43 am ] |
Post subject: | Re: drawing with VGA |
alberinfo wrote: the 800x600 standard is established by SVGA and not by VGA. That depends on what you mean by "standard"... An 800x600 16-colour mode is possible on a standard VGA card, but won't be compatible with a standard VGA monitor (most later SVGA multisync monitors will accept it though). The "standard" VGA video modes with BIOS assigned numbers are a reletively small subset of what the hardware is actually capable of. Also, SVGA was never really a "standard"; until VBE was established in the mid-late 1990s any software wanting to use "better than VGA" graphics capabilites needed hardware-specific drivers (or run under an OS with such drivers). That's one reason that that 800x600 16-colour mode was actually used occasionally (Windows 9x even included a driver for it); it could be used on most "SVGA" hardware and didn't require the developer to know exactly what variant of "SVGA" the user had. Anyway, unless you're programming impressive graphics demos for late-1980s to early-1990s hardware, it's probably best to stick to "standard" graphics modes (although the 320x240 "mode-X" mode is highly compatible and offers the advantage of sqaure pixels over the standard 320x200 mode, so might be worth some consideration). |
Page 1 of 3 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |