Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IDEAL
- MODEL small
- STACK 100h
- DATASEG
- ; --------------------------
- ; Your variables here
- ; --------------------------
- wid dw ?
- hei dw ?
- widr db ?
- heir db ?
- startd dw ?
- startc dw ?
- destx dw ?
- desty dw ?
- len dw ?
- CODESEG
- start:
- mov ax, @data
- mov ds, ax
- ; --------------------------
- mov ax, 0000h
- int 33h ; Enables mouse
- ;mov ax, 0002h
- ;int 33h
- mov ah, 00h
- mov al, 13h
- int 10h ;SETS GRAPHICS MODE
- mov al, 0fh
- xor cx, cx
- xor dx, dx
- loop1:
- pop di
- pop si
- push ax
- mov ax, 0003h
- int 33h
- pop ax
- shr cx, 1
- push cx
- push dx
- push bx
- and bx, 010b
- cmp bx, 010b
- je exit
- pop bx
- push bx
- and bx, 0100b
- cmp bx, 0100b
- jne cmpleft
- inc ax
- cmpleft:
- pop bx
- and bx, 01b
- cmp bx, 01b
- jne loop1
- call drawline
- jmp loop1
- exit:
- mov ax, 4c00h
- int 21h
- proc drawpix ;Draws a single pixel at point (cx,dx) of color = al
- mov ah, 0ch
- int 10h
- ret
- endp drawpix
- proc drawline ;Draws a line. Starting point (cx, dx) ending point (si,di)
- cmp si, cx
- jg startdrawline
- push si
- push cx
- pop si
- pop cx
- push di
- push dx
- pop di
- pop dx
- startdrawline:
- mov [destx], si
- mov [desty], di
- sub si, cx
- sub di, dx
- cmp si, 00h
- jne noflat
- call drawflatlinev
- jmp finishdrawline
- noflat:
- cmp di, 00h
- jne noflat2
- call drawflatlineh
- jmp finishdrawline
- noflat2:
- cmp si, di
- jl vert
- hor:
- call drawhorline
- jmp finishdrawline
- vert:
- call drawvertline
- finishdrawline:
- ret
- endp drawline
- proc drawhorline ; Draws horizontal line from (cx, dx) with x length si, y length di
- cmp di, 0
- mov bx, 1
- jg next1
- neg bx
- neg di
- next1:
- push ax
- mov ax, si
- push dx
- xor dx, dx
- div di
- mov si, ax
- mov [len], si
- pop dx
- pop ax
- drawh:
- call drawpix
- inc cx
- dec si
- cmp cx, [destx]
- je finishh
- cmp si, 0
- jge drawh
- mov si, [len]
- add dx, bx
- jmp drawh
- finishh:
- ret
- endp drawhorline
- proc drawvertline ; Draws vertical line from (cx, dx) with x length si, y length di
- cmp si, 0
- mov bx, 1
- jg next2
- neg bx
- neg si
- next2:
- push ax
- mov ax, di
- push dx
- xor dx, dx
- div si
- mov di, ax
- mov [len], di
- pop dx
- pop ax
- drawv:
- call drawpix
- inc dx
- dec di
- cmp dx, [desty]
- je finishv
- cmp di, 0
- jge drawv
- mov di, [len]
- add cx, bx
- jmp drawv
- finishv:
- ret
- endp drawvertline
- proc drawflatlineh
- drawfh:
- call drawpix
- inc cx
- cmp cx, [destx]
- jle drawfh
- ret
- endp drawflatlineh
- proc drawflatlinev
- drawfv:
- call drawpix
- inc dx
- cmp dx, [desty]
- jle drawfv
- ret
- endp drawflatlinev
- END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement