How to set the screen resolution in the loader, which is on

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.
Post Reply
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

How to set the screen resolution in the loader, which is on

Post by mrjbom »

Hey.
I have a question about how to use not a fixed screen resolution in my loader, but depending on the size of the monitor.
My bootloader looks like this:

Code: Select all

bits 32

%define MULTIBOOT_MAGIC 0x1BADB002
%define MULTIBOOT_FLAGS (1<<0 | 1<<1 | 1<<2)

section .text
align 4
multiboot_header:
    dd MULTIBOOT_MAGIC
    dd MULTIBOOT_FLAGS
    dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 0
    dd 1280 ; width
    dd 1024 ; height
    dd 32 ; bbp

global start
extern main

start:
  cli
  mov esp, stack_space
  push ebx
  push eax
  call main
  hlt

section .bss
resb 8192
stack_space:
Can I do that? And how?
User avatar
zity
Member
Member
Posts: 99
Joined: Mon Jul 13, 2009 5:52 am
Location: Denmark

Re: How to set the screen resolution in the loader, which is

Post by zity »

As far as I know, this is not possible (please correct me if I am wrong).

However, you can set the resolution in the grub configuration file, such that you don't have to recompile the code to change the resolution.

Code: Select all

menuentry "Kernel" {
	multiboot /boot/kernel.bin
	set gfxpayload=1024x768x32
	boot
}
User avatar
mrjbom
Member
Member
Posts: 322
Joined: Sun Jul 21, 2019 7:34 am

Re: How to set the screen resolution in the loader, which is

Post by mrjbom »

How do I change the loader on the assembler in this case?
zity wrote:As far as I know, this is not possible (please correct me if I am wrong).

However, you can set the resolution in the grub configuration file, such that you don't have to recompile the code to change the resolution.

Code: Select all

menuentry "Kernel" {
	multiboot /boot/kernel.bin
	set gfxpayload=1024x768x32
	boot
}
GMorgan
Posts: 22
Joined: Sun Jul 14, 2019 4:27 pm

Re: How to set the screen resolution in the loader, which is

Post by GMorgan »

loonie
Posts: 7
Joined: Sat Jul 06, 2019 3:24 pm

Re: How to set the screen resolution in the loader, which is

Post by loonie »

One of the bios interrupts gives you info about monitor. I just don't remember which. Its something related to DDC (Display Data Channel). There used to be several pdf versions (on the google) of docs describing precise return format.
You should find what you need in ralf brown interrupt list.
Monitor size they give there is in millimeters or even centimeters - which means heavily rounded, but better than nothing.

However, for modern monitor + videocard you simply take highest resolution returned by VBE and that'll be native resolution. Instead, screen size is valuable mainly to calculate size of GUI elements.
Post Reply