I finally managed to draw a cyan pixel on the screen using the VESA BIOS Extensions (1920px * 1080px, 24bpp).
;esi = bytes per scan line;edx = physical address of linear framebuffer memory.;ebx = x coord * 3;ecx = y coordDrawPixel: push edx mov edx, 0 mov eax, 0 lea eax, [esi] ;mov ecx, 0 mul ecx add eax, ebx jmp drawdraw: pop edx add edx, eax mov ebx, 0x3296fa mov [edx], ebx ret
I tried to draw a cyan horizontal line on the screen using a "for loop" this way:
mov edi, 1920call drawLoopjmp $drawLoop: dec edi ;decrease edi cmp edi, 0 ;is edi equal to zero? jl doneLoop ;then return imul ebx, edi, 3 ;multiply edi by three and save the result in ebx mov ecx, 0 ;y = 0 mov esi, ModeInfoBlock + 10h mov edx, dword[ModeInfoBlock + 28h] call DrawPixel ;Draw it! jmp drawLoop ;run this againdoneLoop: ret
However, this doesn't work: it draws a green line instead.
When I try to draw a vertical line again with the draw/draw pixel code, it doesn't work either. It plots pixels with random colors everywhere. Here's how I use the DrawPixel
function to draw a vertical line:
%include "../kernel/Services/Display/display.asm"kernel: mov edi, 1080 call drawLoop jmp $drawLoop: dec edi cmp edi, 0 jl doneLoop mov ecx, edi mov ebx, 0 mov esi, ModeInfoBlock + 10h mov edx, dword[ModeInfoBlock + 28h] call DrawPixel jmp drawLoopdoneLoop: ret
Any way to solve these problems?