I've set the video mode 12 (640x480x8) with GRUB as follows:
Code: Select all
MBALIGN equ 1 << 0 ; align loaded modules on page boundaries
MEMINFO equ 1 << 1 ; provide memory map
VIDINFO equ 1 << 2
FLAGS equ MBALIGN | MEMINFO | VIDINFO ; this is the Multiboot 'flag' field
MAGIC equ 0x1BADB002 ; 'magic number' lets bootloader find the header
CHECKSUM equ -(MAGIC + FLAGS) ; checksum of above, to prove we are multiboot
section .multiboot
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
dd 0,0,0,0,0
dd 0
dd 640, 480, 8
section .bss
align 16
stack_bottom:
resb 16384 ; 16 KiB
stack_top:
; The linker script specifies _start as the entry point to the kernel and the
; bootloader will jump to this position once the kernel has been loaded. It
; doesn't make sense to return from this function as the bootloader is gone.
; Declare _start as a function symbol with the given symbol size.
section .text
global _start:function (_start.end - _start)
_start:
mov esp, stack_top
cli
push ebx
extern kmain
call kmain
cli
.hang: hlt
jmp .hang
.end:
Code: Select all
void putpixel(int color, int x , int y) {
unsigned int *pixel = (unsigned int*) 0xA0000 + y * 640 + x;
*pixel = color;
}
void cls_graph() {
for (int r = 0; r < 480; r++) {
for (int c = 0; c < 640; c++) {
putpixel (BLUE, c, r);
}
}
}
but my screen became like this photo:
I've tried also with an unsigned char* framebuffer, and the screen became like this:
Then, with an uint16_t framebuffer:
What am I doing wrong?