The blue square.... IT LIVESSSgit add .!

This commit is contained in:
maelstrom 2024-07-25 21:01:07 +03:00
parent be49deb44e
commit c27c7cdb83
2 changed files with 66 additions and 28 deletions

View file

@ -1,21 +1,70 @@
VMEM equ 0xA000
; di = y*320+x
; ah = reserved
; al = color
; bx = width
; cx = height
gfx_rect:
; 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:
pusha
; Set es to VMEM
push VMEM
pop es
.loop:
mov [es:di], al
mov dl, 0 ; row counter
jmp .loop
.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
call _gfx_rect0
popa
ret

View file

@ -21,31 +21,20 @@ main:
mov ax, 0x0013
int 0x10
push es
push 0xa000
pop es
mov cx, 50 ; x
mov al, 50 ; y
mov dx, 100 ; w
mov bl, 100 ; h
mov bh, 0x01 ; color = Dark blue
mov di, 0
mov bx, 0
.r:
add bx, 1
.f:
mov byte [es:di], bl
add di, 1
mod di, 320
cmp dx, 0
jnz .f
cmp bx, 200
jnz .r
pop es
call gfx_rect
jmp $ ; Halt
; Libs
%include "print_util.asm"
%include "time_util.asm"
%include "gfx_util.asm"
; Data
HELLO_WORLD: