More Generic VBE Modes - Amateur OS Dev (C/x86 asm)

More Generic VBE Modes - Amateur OS Dev (C/x86 asm)

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=mU3EhiC1tns



Duration: 2:38:42
905 views
30


Changing the video mode/graphics info, printing, and drawing to be more generic, so no more hardcoded values for 1920x1080. Then making a change foreground/background color command, and lastly getting user input from the bootloader to set the VBE graphics mode for a given x/y resolution and bpp.
The OS now supports most qemu/bochs available VBE modes for 8/15/16/24/32bpp! You can do 640x480 8bpp or 1920x1200 32bpp, or whatever your system supports.
Unfortunately text scrolling and other things are a lot slower now, especially for higher resolutions. I'm researching double buffering and other ways to increase performance. There'll probably be some memcpy function(s) in the near future.

Update: I found a workaround for the slow text scrolling, mainly by copying data from scroll2 to scroll1 with 32bit pointers (I made small memcpy and 32bit memcpy functions). It is close to if not as fast as it was before now, definitely fast enough for lower resolutions & bpp. Small refactors and less lines of code for print_char as well. These changes may be on the next video, depending on how long it is.

!! Disclaimer: Before trying to run on any actual hardware, make sure you know what is supported by your graphics card, monitor and general setup, using unsupported modes may damage your hardware !!

OS Dev playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqajsw8Xh7SP9KJwjfpP8TNX

Source code as of the end of this video:
https://git.sr.ht/~queso_fuego/amateur_os_video_sources/tree/master/item/36_generic_vbe_modes

Git repos for this OS:
Sourcehut: https://git.sr.ht/~queso_fuego/quesos
Github mirror: https://github.com/queso-fuego/amateuros

Notes:
Not shown in this video, but you could make a small program on boot that will list the available VBE modes if you want to see what is available, by using bios int 10h AX 4F00h & 4F01h, but not setting a mode with 4F02h. Only going through the mode list until it ends and printing the width/height/bpp values for each mode that is found.

Next video ideas:
Making font printing more generic, not 8x16 hardcoding, with font width/height values in the .fnt files, and a change fonts command;
Or Software & hardware interrupts with IDT, and PIC, maybe going into syscalls if enough time.

- Let me know if there's anything specific you'd like to see

Outline:
0:00 - Copy VBE mode info struct from bootloader to 2d_gfx.h
6:18 - Consolidate print files into 1 print_types file
14:23 - Replace hardcoded values with gfx_mode values
24:28 - Change printing to work with uint8_t values, not uint32_t
47:12 - convert_color() function
1:06:47 - Fix fill_ functions for drawing pixels
1:14:37 - Fix text scrolling
1:17:50 - Change clear_screen & cursor functions for uint8_t framebuffer
1:27:15 - user_gfx_info struct, use new foreground/background colors
1:41:56 - chgColors command
2:00:07 - Change bootloader to get vbe mode values from user
2:21:01 - Fix bootloader/other misc changes
2:26:46 - Change hardcoded line numbers to fix text scrolling (again)
2:37:07 - Coming up/outro

Software used:
VMware Workstation Player - https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html
openBSD - https://www.openbsd.org/
qemu - https://www.qemu.org/
vim - https://www.vim.org/
clang - https://clang.llvm.org/
davinci resolve - https://www.blackmagicdesign.com/products/davinciresolve/
OBS Studio - https://obsproject.com/

Peripherals:
Camera: Sony ZV-1, Elgato Camlink 4k
Microphone: Shure SM7B, Cloudlifter CL-1, Focusrite Scarlett Solo
Keyboard: HHKB Pro Hybrid Type S, white/blank keycaps
Mouse: Logitech M590

Contact:
email - fuegoqueso@gmail.com
twitter - @Queso_Fuego
twitch - https://www.twitch.tv/queso_fuego

Thoughts/Notes/Suggestions/Other - Drop a message in the video comments, twitter, or email

Updates for these videos and other things will be on twitter, if I remember. Maybe the YouTube channel community tab, or mailing lists

Credits:
Music from https://incompetech.com:
"Your Call" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
http://creativecommons.org/licenses/by/4.0/

#osdev #programming #videomodes







Tags:
vbe
programming
low level
osdev
os dev
graphics modes
colors
qemu
vim
queso fuego