kernel/src/framebuffer.asm

45 lines
578 B
NASM
Raw Normal View History

;; x, y, brightness
putpixel:
push ebp
mov ebp, esp
push eax
push ebx
push ecx
push edi
; check pixel is in screen
mov ebx, [ebp+12] ;y
cmp ebx, [mbootinfo.fb_height]
jge .done
mov ecx, [ebp+8] ;x
cmp ecx, [mbootinfo.fb_width]
jge .done
; Destination
mov edi, [mbootinfo.fb_addr]
mov eax, [mbootinfo.fb_pitch]
mul dword ebx ;y
add edi, eax
mov eax, ecx ;x
movzx ecx, byte [mbootinfo.fb_bytespp]
mul ecx
add edi, eax
; Brightness
mov eax, [ebp + 16]
; Poke videomemory
cld
rep stosb
.done:
pop edi
pop ecx
pop ebx
pop eax
pop ebp
ret