drawing with VGA

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.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

so, if the max VGA resolution is 640x480x16 then i wont write a non vga driver, only for a 800x600 resolution.Thanks!
bigboyav
Posts: 10
Joined: Sat Dec 29, 2018 3:09 am

Re: drawing with VGA

Post by bigboyav »

Check out the below article, depending on your hardware your video ram should either be at 0xB8000 or 0xB0000. How you go about writing to your video ram depends on what mode your CPU is operating in, ex. if your in real mode you have to use segment registers. One other thing to keep in mind (this is mentioned in the below article) is that when writing to vram, 2 bytes are used to represent a character, one byte is for the actual character itself, and another byte is for the color of the character.

https://wiki.osdev.org/Printing_To_Screen
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

i already know that...i was wondering for graphics mode, which actually works for 320x200x16, but not for 640x480 and 720x480, the drawing function is broke, it draws lines(it should fill the screen) with different colors than the expected(generally white).i've said for a 800x600 mode because in http://www.ctyme.com/intr/rb-0069.htm, the mode 0x6A(listed as 6Ah), sets a 800x600 normally, almost in qemu.but i actually cant make a table for it and use a 800x600 mode.anyway dont worry about text mode

Thanks!

PD:also, 'cause i'm using graphic mode, the ram pointer is at 0xA0000
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

How are you changing the video mode? I assume you are in protected mode, and I seem to recall you use mulitboot? The problem is that using 0xA0000 as a base for video output, the region is using planar modes for some of the higher resolutions. You only have access part of the overall graphics memory. What you want to do is get the address of the Linear Frame Buffer (LFB) and use that address as the base for video memory.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

im changing the video mode with the VGA ports, its in the repo in vga.h and vga.c.
MichaelPetch wrote:I assume you are in protected mode, and I seem to recall you use mulitboot?.
if by multiboot you say grub, then yes.0xA0000 is base for video output ok no problem, but then the problem is that i'm not accessing all the video ram for doing 640x480 or 720x480?how can i get the LFB?

PD:if it's possible i wish to not use BIOS interrupts...i'd want to get the less amount of VM86 instructions, so i can take it out of the VM86 code and use paging correctly...

Thanks!
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

By VM86 do you mean running in a V8086 task? Or switching from protected mode to real mode (and then back? V8086 task run in protected mode and should work with paging if properly set up.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

a V8086 task, it doesn't work when paging is enabled...which(for E.G) leaves me without the shutdown by the APM method, so qemu wont shutdown properly.so i want to have the less V8086 task running while paging enabled, which is just a little bit after the kmain function is loaded
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

You can get GRUB to switch to a graphics mode at boot (based on specifying a width, height,and color depth of a video mode you want) and have it return a structure that includes the linear frame address of the video memory region in the multiboot information structure.
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

If paging doesn't work with your V8086 task then your code is faulty. Do you have the code available that you are using for your v8086 task? I assume you have a V8086 monitor.
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

MichaelPetch wrote:You can get GRUB to switch to a graphics mode at boot (based on specifying a width, height,and color depth of a video mode you want) and have it return a structure that includes the linear frame address of the video memory region in the multiboot information structure.
first:how do i change the video mode at boot?. 2:where i have a list of how to declare the structure so i can fill it?.
MichaelPetch wrote:If paging doesn't work with your V8086 task then your code is faulty. Do you have the code available that you are using for your v8086 task? I assume you have a V8086 monitor.
the code is in https://github.com/alberinfo/Slidoor-OS, in 'include', 'VM86'.se viewtopic.php?f=1&t=33350, and you'll se why it fails, but i dont know how to idmap the below 1mb.
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

The multiboot v1 documentation can be found here: https://www.gnu.org/software/grub/manua ... iboot.html . A header file (for C) that defines the structures use: https://www.gnu.org/software/grub/manua ... 002eh.html . An example multiboot header (and a link to some code) can be found here: viewtopic.php?f=1&t=27504
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

Thank you very much!!!
but dont know how to fill it with the grub data..do i have to copy ebx to the multiboot.h file?
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

well, i filled the table...but i'm not giving VBE data...i have set the 1<<2 flag(video flag) in 'FLAGS', and with mode set as auto(no preference).also the apm isn't fill, but other things like the segment, offset, or length of vbe_interface, are fill, but i don't know if they are correct.the boot_loader_name is correct.

Thanks!
MichaelPetch
Member
Member
Posts: 799
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: drawing with VGA

Post by MichaelPetch »

1<<2 or 1<<12?
alberinfo
Member
Member
Posts: 122
Joined: Wed Aug 29, 2018 4:42 pm

Re: drawing with VGA

Post by alberinfo »

1<<2.
Post Reply