So, In my OS, I created a put pixel function. Im trying to make a draw line function with it.
here's my code:
org 0x7e00
[bits 16]
_start:
mov ah, 0x00 ; Set Video Mode
mov al, 0x03 ; Mode 3 (80x25 characters)
int 0x10 ; Call BIOS interrupt
mov ax,0x13
int 0x10
jmp EnterPM
%include "../src/system/include/gdt.asm"
EnterPM:
call EnableA20
cli
lgdt [gdt_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp codeseg:StartProtectedMode
EnableA20:
in al, 0x92
or al, 2
out 0x92, al
ret
[bits 32]
VIDEO_MEMORY equ 0xb8000
GRAPHICS_MEMORY equ 0x0A0000
WHITE_ON_BLACK equ 0x0f
PINK_ON_BLACK equ 0x3f
StartProtectedMode:
mov ax, dataseg
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
mov eax, 10
mov ecx, 0
mov ebx, PINK_ON_BLACK
mov edx, 70
call draw_line
jmp $
;------------------------------
; |
; put_pixel method |
; Plot a pixel on the screen|
; |
; Arguments: |
; eax - pos_x |
; ecx - pos_y |
; ebx - color |
; |
; kappetrov created |
;-----------------------------|
put_pixel:
; Calculate memory address of pixel
mov edi, GRAPHICS_MEMORY ; Base address of graphics memory
imul ecx, ecx, 320 ; Multiply pos_y by 320 (assuming 320 pixels per scanline)
add edi, ecx ; Add offset for y
add edi, eax ; Add offset for x
; Move color into memory
mov eax, ebx ; Move color value into eax for consistency
mov [edi], eax ; Store color value at calculated memory address
ret ; Return from function
; eax = pos x, ecx = pos y, edx = width, ebx = color
draw_line:
cmp edx, 0
je exit
call put_pixel
inc eax
dec edx
jmp draw_line
ret
exit:
ret
times 512-($-$$) db 0
dw 0xaa55
It's not actually drawing a line, sure, it's drawing 2 pixels indicating it's a line, but it doesnt actually draw the pixels between them.
i tried to draw a line, it did draw 2 pixels indicating a line, but doesnt draw the individual pixels between them.