The blue square.... IT LIVESSSgit add .!
This commit is contained in:
parent
be49deb44e
commit
c27c7cdb83
2 changed files with 66 additions and 28 deletions
69
gfx_util.asm
69
gfx_util.asm
|
@ -1,21 +1,70 @@
|
||||||
VMEM equ 0xA000
|
VMEM equ 0xA000
|
||||||
|
|
||||||
; di = y*320+x
|
; di = y*32+x
|
||||||
; ah = reserved
|
; ax = width
|
||||||
; al = color
|
; bl = height
|
||||||
; bx = width
|
; bh = color
|
||||||
; cx = height
|
|
||||||
gfx_rect:
|
; ax/bl = 0 is undefined behavior. Don't do it.
|
||||||
|
; (To be clear, in the current implementation it just halts)
|
||||||
|
|
||||||
|
_gfx_rect0:
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
; Set es to VMEM
|
|
||||||
push VMEM
|
push VMEM
|
||||||
pop es
|
pop es
|
||||||
|
|
||||||
.loop:
|
mov dl, 0 ; row counter
|
||||||
mov [es:di], al
|
|
||||||
|
|
||||||
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
|
popa
|
||||||
ret
|
ret
|
25
main.asm
25
main.asm
|
@ -21,31 +21,20 @@ main:
|
||||||
mov ax, 0x0013
|
mov ax, 0x0013
|
||||||
int 0x10
|
int 0x10
|
||||||
|
|
||||||
push es
|
mov cx, 50 ; x
|
||||||
push 0xa000
|
mov al, 50 ; y
|
||||||
pop es
|
mov dx, 100 ; w
|
||||||
|
mov bl, 100 ; h
|
||||||
|
mov bh, 0x01 ; color = Dark blue
|
||||||
|
|
||||||
mov di, 0
|
call gfx_rect
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
jmp $ ; Halt
|
jmp $ ; Halt
|
||||||
|
|
||||||
; Libs
|
; Libs
|
||||||
%include "print_util.asm"
|
%include "print_util.asm"
|
||||||
%include "time_util.asm"
|
%include "time_util.asm"
|
||||||
|
%include "gfx_util.asm"
|
||||||
|
|
||||||
; Data
|
; Data
|
||||||
HELLO_WORLD:
|
HELLO_WORLD:
|
||||||
|
|
Loading…
Add table
Reference in a new issue