kernel/src/framebuffer.asm

75 lines
902 B
NASM
Raw Normal View History

;; x, y, r, g, b
putpixel:
push ebp
mov ebp, esp
push eax
push ebx
push ecx
push edi
; Destination
std
mov edi, [mbootinfo.fb_addr]
mov eax, [mbootinfo.fb_pitch]
mul dword [ebp+12] ;y
add edi, eax
mov eax, [ebp+8] ;x
mul byte [mbootinfo.fb_bytespp]
dec eax
add edi, eax
movzx eax, [mbootinfo.fb_bytespp]
dec eax
add edi, eax
; Blue
mov ebx, [ebp + 24]
mov cl, [mbootinfo.fb_bpos]
shl ebx, cl
or eax, ebx
; Green
mov ebx, [ebp + 20]
mov cl, [mbootinfo.fb_gpos]
shl ebx, cl
or eax, ebx
; Red
mov ebx, [ebp + 16]
mov cl, [mbootinfo.fb_rpos]
shl ebx, cl
or eax, ebx
cmp [mbootinfo.fb_bpp], 24
je .24bpp
jne .32bpp
.done:
pop edi
pop ecx
pop ebx
pop eax
pop ebp
ret
.32bpp:
stosb
shr eax, 8
stosb
shr eax, 8
stosb
shr eax, 8
stosb
jmp .done
.24bpp:
;shr eax, 8
stosb
shr eax, 8
stosb
shr eax, 8
stosb
jmp .done
.msg db 10, ":D", 10, 0