Advertisement
Guest User

Untitled

a guest
Jun 5th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IDEAL
  2. MODEL small
  3. STACK 100h
  4. DATASEG
  5. ; --------------------------
  6. ; Your variables here
  7. ; --------------------------
  8.  
  9. wid dw ?
  10. hei dw ?
  11. widr db ?
  12. heir db ?
  13. startd dw ?
  14. startc dw ?
  15. destx dw ?
  16. desty dw ?
  17. len dw ?
  18.  
  19. CODESEG
  20. start:
  21.     mov ax, @data
  22.     mov ds, ax
  23. ; --------------------------
  24.     mov ax, 0000h
  25.     int 33h ; Enables mouse
  26.    
  27.     ;mov ax, 0002h
  28.     ;int 33h
  29.    
  30.     mov ah, 00h
  31.     mov al, 13h
  32.     int 10h ;SETS GRAPHICS MODE
  33.  
  34.     mov al, 0fh
  35.     xor cx, cx
  36.     xor dx, dx
  37.     loop1:
  38.     pop di
  39.     pop si
  40.     push ax
  41.     mov ax, 0003h
  42.     int 33h
  43.     pop ax
  44.     shr cx, 1
  45.     push cx
  46.     push dx
  47.     push bx
  48.     and bx, 010b
  49.     cmp bx, 010b
  50.     je exit
  51.     pop bx
  52.     push bx
  53.     and bx, 0100b
  54.     cmp bx, 0100b
  55.     jne cmpleft
  56.     inc ax
  57.     cmpleft:
  58.     pop bx
  59.     and bx, 01b
  60.     cmp bx, 01b
  61.     jne loop1
  62.     call drawline
  63.     jmp loop1
  64.    
  65. exit:
  66.     mov ax, 4c00h
  67.     int 21h
  68.  
  69. proc drawpix ;Draws a single pixel at point (cx,dx) of color = al
  70.     mov ah, 0ch
  71.     int 10h
  72.     ret
  73. endp drawpix
  74.    
  75. proc drawline ;Draws a line. Starting point (cx, dx) ending point (si,di)
  76.     cmp si, cx
  77.     jg startdrawline
  78.     push si
  79.     push cx
  80.     pop si
  81.     pop cx
  82.     push di
  83.     push dx
  84.     pop di
  85.     pop dx
  86.    
  87.     startdrawline:
  88.     mov [destx], si
  89.     mov [desty], di
  90.     sub si, cx
  91.     sub di, dx
  92.     cmp si, 00h
  93.     jne noflat
  94.     call drawflatlinev
  95.     jmp finishdrawline
  96.     noflat:
  97.     cmp di, 00h
  98.     jne noflat2
  99.     call drawflatlineh
  100.     jmp finishdrawline
  101.     noflat2:
  102.     cmp si, di
  103.     jl vert
  104.     hor:
  105.     call drawhorline
  106.     jmp finishdrawline
  107.     vert:
  108.     call drawvertline
  109.    
  110.     finishdrawline:
  111.     ret
  112. endp drawline
  113.  
  114. proc drawhorline ; Draws horizontal line from (cx, dx) with x length si, y length di
  115.     cmp di, 0
  116.     mov bx, 1
  117.     jg next1
  118.     neg bx
  119.     neg di
  120.  
  121.     next1:
  122.     push ax
  123.     mov ax, si
  124.     push dx
  125.     xor dx, dx
  126.     div di
  127.     mov si, ax
  128.     mov [len], si
  129.     pop dx
  130.     pop ax
  131.  
  132.     drawh:
  133.     call drawpix
  134.     inc cx
  135.     dec si
  136.     cmp cx, [destx]
  137.     je finishh
  138.     cmp si, 0
  139.     jge drawh
  140.     mov si, [len]
  141.     add dx, bx
  142.     jmp drawh
  143.     finishh:
  144.     ret
  145. endp drawhorline
  146.  
  147. proc drawvertline ; Draws vertical line from (cx, dx) with x length si, y length di
  148.     cmp si, 0
  149.     mov bx, 1
  150.     jg next2
  151.     neg bx
  152.     neg si
  153.  
  154.     next2:
  155.     push ax
  156.     mov ax, di
  157.     push dx
  158.     xor dx, dx
  159.     div si
  160.     mov di, ax
  161.     mov [len], di
  162.     pop dx
  163.     pop ax
  164.  
  165.     drawv:
  166.     call drawpix
  167.     inc dx
  168.     dec di
  169.     cmp dx, [desty]
  170.     je finishv
  171.     cmp di, 0
  172.     jge drawv
  173.     mov di, [len]
  174.     add cx, bx
  175.     jmp drawv
  176.     finishv:
  177.     ret
  178. endp drawvertline
  179.  
  180. proc drawflatlineh
  181.     drawfh:
  182.     call drawpix
  183.     inc cx
  184.     cmp cx, [destx]
  185.     jle drawfh
  186.     ret
  187. endp drawflatlineh
  188.  
  189. proc drawflatlinev
  190.     drawfv:
  191.     call drawpix
  192.     inc dx
  193.     cmp dx, [desty]
  194.     jle drawfv
  195.     ret
  196. endp drawflatlinev
  197.  
  198. END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement