ibis-os/gfx_util.asm

124 lines
1.7 KiB
NASM
Raw Normal View History

2024-07-25 18:20:57 +00:00
; Constants
2024-07-25 17:28:01 +00:00
VMEM equ 0xA000
2024-07-25 18:20:57 +00:00
; Initializes 320x200 8-bit/256-color (13h) video graphics mode
gfx_init_vga13:
push ax
mov ax, 0x0013
int 0x10
pop ax
ret
; di = y*32+x
; ax = width
; bl = height
; bh = color
; ax/bl = 0 is undefined behavior. Don't do it.
; (To be clear, in the current implementation it just halts)
_gfx_rect0:
2024-07-25 17:28:01 +00:00
pusha
push VMEM
pop es
mov dl, 0 ; row counter
.row:
add dl, 1
mov cx, 0 ; col counter
.col:
add cx, 1
mov [es:di], bh
add di, 1
cmp cx, ax
jnz .col
sub di, ax ; di - width + 320. == x=x1; y++
add di, 320
cmp dl, bl
jnz .row
popa
ret
; cx = x
; al = y
; dx = width
; bl = height
; bh = color
gfx_rect:
pusha
; Set di to y*320+x
push bx
push dx ; Don't forget, mul clobbers dx!
mov ah, 0
mov bx, 320
mul bx
add ax, cx
mov di, ax
pop dx
pop bx
; AX CLOBBERED
mov ax, dx
2024-07-25 17:28:01 +00:00
call _gfx_rect0
2024-07-25 17:28:01 +00:00
2024-07-25 18:20:57 +00:00
popa
ret
2024-07-26 09:15:20 +00:00
; di = y*320+x
2024-07-25 18:20:57 +00:00
; si = source color data
; ax = width
; bl = height
; ax/bl = 0 is undefined behavior. Don't do it.
; (To be clear, in the current implementation it just halts)
_gfx_blit0:
pusha
push VMEM
pop es
mov dl, 0 ; row counter
.row:
add dl, 1
mov cx, 0 ; col counter
.col:
add cx, 1
mov dh, [si]
2024-07-26 09:15:20 +00:00
cmp dh, 0xFF
jz .ncp
2024-07-25 18:20:57 +00:00
mov [es:di], dh
2024-07-26 09:15:20 +00:00
.ncp:
2024-07-25 18:20:57 +00:00
add di, 1
add si, 1
cmp cx, ax
jnz .col
sub di, ax ; di - width + 320. == x=x1; y++
add di, 320
cmp dl, bl
jnz .row
2024-07-25 17:28:01 +00:00
popa
ret