OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:13 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How to work with VGA video mod? How to encode pixels?
PostPosted: Mon Jul 22, 2019 7:22 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 296
Hey.
Based on this page, you can understand that the standard VGA BIOS memory includes VGA 320 * 200 with 256 colors. I have a question, how to use a particular mod? How to write in bit color?


Top
 Profile  
 
 Post subject: Re: How to work with VGA video mod? How to encode pixels?
PostPosted: Mon Jul 22, 2019 9:42 am 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
Little note at first, if you want use graphic mode and you want use BIOS, dont work with VGA, implement VESA, it contain all modes what you need. VGA is good if you want write driver for graphic card, because you can learn a lot about it.

How use particular mode? At first you must make a decision if you want start graphic mode from BIOS, or without BIOS. If you dont want use BIOS, complete code is in http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c .

Here is code for writing pixels:
Code:
void write_vga_pixel(uint32_t line, uint32_t column, uint8_t color) {
    uint8_t *vga_memory = (uint8_t *) 0xA0000;
    uint32_t offset=0;

    offset=( (line*320) + column);

    vga_memory[offset]=color;
}

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: How to work with VGA video mod? How to encode pixels?
PostPosted: Mon Jul 22, 2019 10:42 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 296
Klakap wrote:
Little note at first, if you want use graphic mode and you want use BIOS, dont work with VGA, implement VESA, it contain all modes what you need. VGA is good if you want write driver for graphic card, because you can learn a lot about it.

How use particular mode? At first you must make a decision if you want start graphic mode from BIOS, or without BIOS. If you dont want use BIOS, complete code is in http://files.osdev.org/mirrors/geezer/osd/graphics/modes.c .

Here is code for writing pixels:
Code:
void write_vga_pixel(uint32_t line, uint32_t column, uint8_t color) {
    uint8_t *vga_memory = (uint8_t *) 0xA0000;
    uint32_t offset=0;

    offset=( (line*320) + column);

    vga_memory[offset]=color;
}


How to use it working in BIOS?


Top
 Profile  
 
 Post subject: Re: How to work with VGA video mod? How to encode pixels?
PostPosted: Mon Jul 22, 2019 11:19 am 
Offline
Member
Member

Joined: Sat Mar 10, 2018 10:16 am
Posts: 296
You must be in real mode and use assembler:

Code:
  mov ah, 0  ;BIOS VGA mode interrupt
  mov al, 0x13  ;320x200x8 bpp graphic mode
  int 0x10  ;call bios interrupt


And you are in graphic mode.

_________________
https://github.com/VendelinSlezak/BleskOS


Top
 Profile  
 
 Post subject: Re: How to work with VGA video mod? How to encode pixels?
PostPosted: Mon Jul 22, 2019 11:58 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 296
Klakap wrote:
You must be in real mode and use assembler


As far as I know, GRUB loads my kernel into protected mode right away. Is that right? How do I then use 320x200x8bpp graphic mode?


Top
 Profile  
 
 Post subject: Re: How to work with VGA video mod? How to encode pixels?
PostPosted: Tue Jul 23, 2019 12:52 am 
Offline

Joined: Sun Jul 14, 2019 4:27 pm
Posts: 22
You'd have to drop back to real mode. If you are using GRUB it can initialise the framebuffer for you.

Honestly all of the BIOS stuff is going away. You might be better off using UEFI if you plan to write your kernel in long mode.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], deblokc and 88 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group