Advertisement
Guest User

Untitled

a guest
Jul 18th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. public polydr
  3. code segment para use16
  4. assume cs:code
  5. start:
  6. polydr proc near
  7. arg data_buf:dword,n:word,Point_mas:dword =  Param_size
  8. ;arg data_buf:dword = Param_size
  9. psz EQU 5
  10. coll    EQU word ptr ds:[bx+12+16+4+2*0]
  11. colr    EQU word ptr ds:[bx+12+16+4+2*1]
  12. dcoll   EQU word ptr ds:[bx+12+16+4+2*2]
  13. dcolr   EQU word ptr ds:[bx+12+16+4+2*3]
  14. const5757 EQU ds:[bx+12+16+4+2*4]
  15. public polydr
  16.        push bp
  17.        mov bp,sp
  18.        push ds
  19.        lgs di,point_mas
  20.        lds bx,Data_buf
  21.        mov word ptr const5757,5757
  22.        mov ax,ds:[bx+0];segA000
  23.        mov es,ax
  24.        mov ds:[bx+0],di
  25.        mov si,n
  26.        dec si                   ;because mas [0..n-1]
  27.        imul si,si,psz           ; *psz:structure "point" need psz bytes.
  28.        ;shl si,2
  29.        ;add si,
  30.        add si,di
  31.        mov ds:[bx+1*2],si
  32.        xor cx,cx
  33.        mov ax,-32000
  34.        mov dx,+32000
  35. c1:    cmp cx,n                 ;for cx:= 0 to n-1 do ...
  36.        je endc1
  37.        cmp ax,gs:[di+2]
  38.        jge l1_in_c1
  39.        mov ax,gs:[di+2]
  40.        mov si,di
  41. l1_in_c1:
  42.        cmp dx,gs:[di+2]
  43.        jle l2_in_c1
  44.        mov dx,gs:[di+2]
  45. l2_in_c1:
  46.        add di,psz
  47.        inc cx
  48.        jmp c1
  49. endc1:
  50. IF 1
  51.        cmp ax,dx                ;if ymax = ymin, then goto enddr
  52.        je enddr
  53.        mov di,si                ;"save"  si in di. si == index of ymax in point_mas.
  54. c2:    cmp gs:[si+2],ax         ;ax = ymax now.
  55.        jne endc2
  56.        cmp si,ds:[bx+1*2]
  57.        je l1_c2
  58.        add si,psz
  59.        jmp short  l2_c2
  60. l1_c2: mov si,ds:[bx+0]
  61. l2_c2: jmp short c2
  62. endc2: mov ds:[bx+2*2],si       ;si == il
  63.        mov si,di                ;index of ymax was saved in di
  64. c3:    cmp gs:[si+2],ax         ;ax == ymax now.
  65.        jne endc3
  66.        cmp si,ds:[bx+0*2]
  67.        je l1_c3
  68.        sub si,psz
  69.        jmp short  l2_c3
  70. l1_c3: mov si,ds:[bx+1*2]
  71. l2_c3: jmp short c3
  72. endc3: mov ds:[bx+3*2],si       ;si == ir
  73.        mov ds:[bx+4*2],ax       ;ytec:=ymax
  74. ENDIF
  75.        mov ds:[bx+5*2],dx       ;ymin
  76. if 1
  77.        mov si,ds:[bx+2*2]       ;si:= il
  78.        cmp si,ds:[bx+0*2]
  79.        je l1
  80.        sub si,psz
  81.        jmp short l2
  82. l1:    mov si,ds:[bx+1*2]
  83. l2:    mov ax,gs:[si+0]         ;ax := int(xl)
  84.        shl eax,16
  85.        mov ds:[bx+12+0*4],eax   ;xl
  86.        xor ax,ax
  87.        mov ah,gs:[si+4]
  88.        mov coll,ax
  89.        mov si,ds:[bx+3*2]       ;SI := ir
  90.        cmp si,ds:[bx+1*2]
  91.        je l3
  92.        add si,psz
  93.        jmp short l4
  94. l3:    mov si,ds:[bx+0*2]
  95. l4:    mov ax,gs:[si+0]
  96.        shl eax,16
  97.        mov ds:[bx+12 + 1*4],eax         ;xr
  98.        xor ax,ax
  99.        mov ah,gs:[si+4]
  100.        mov colr,ax
  101. ;Count dxl:
  102.        mov si,ds:[bx+2*2]               ;si := il
  103.        mov ax,gs:[si+0]                 ;ax:= round(x[il])
  104.        shl eax,16
  105.        sub eax,ds:[bx+12+0*4]           ;x[il]-xl
  106.        xor ecx,ecx                      ;ecx := 0
  107.        mov cx,[bx+4*2]                  ;cx:=ytec
  108.        sub cx,gs:[si+2]                 ;cx:= ytec - y[il]
  109.        cdq                      ;(edx:eax)/ecx
  110.        idiv ecx                 ;(edx:eax)/ecx
  111.        mov ds:[bx+12+2*4],eax   ;dxl
  112.        xor ax,ax
  113.        mov ah,gs:[si+4]
  114.        sub ax,coll
  115.        cwd
  116.        idiv cx
  117.        mov dcoll,ax
  118.  
  119. ;Count dxr:
  120.        mov si,ds:[bx+3*2]               ;si := ir
  121.        mov ax,gs:[si+0]                 ;ax:= x[ir]
  122.        shl eax,16
  123.        sub eax,ds:[bx+12+1*4]           ;x[ir]-xr
  124.        xor ecx,ecx                      ;ecx := 0
  125.        mov cx,[bx+4*2]                  ;cx:=ytec
  126.        sub cx,gs:[si+2]                 ;ytec - y[ir]
  127.        cdq                      ;(edx:eax)/ecx
  128.        idiv ecx                 ;(edx:eax)/ecx
  129.        mov ds:[bx+12+3*4],eax   ;dxr
  130.        xor ax,ax
  131.        mov ah,gs:[si+4]
  132.        sub ax,colr
  133.        cwd
  134.        idiv cx
  135.        mov dcolr,ax
  136. ;count adress of sreen line start
  137.        mov ax,ds:[bx+4*2]
  138.        mov cx,320
  139.        mul cx
  140.        mov ds:[bx+12+16+0*2],ax ;line start
  141. endif
  142. if 1
  143. BIG_c: ;Line:
  144.        mov ecx,ds:[bx+12+1*4]   ;ecx := xr
  145.        mov eax,ds:[bx+12+0*4]   ;eax := xl
  146.        rol ecx,16
  147.        rol eax,16
  148.        sub cx,ax
  149.        jl enddr
  150.        jcxz eppix
  151.        mov di,ds:[bx+12+16+0*2]
  152.        add di,ax
  153.        mov ax,colr
  154.        sub ax,coll
  155.        cwd
  156.        idiv cx
  157.        mov dx,ax
  158.        mov ax,coll
  159. ppix:  mov es:[di],ah
  160.        add ax,dx
  161.        inc di
  162.        loop ppix
  163. eppix:
  164.        ;mov al,c
  165. ;   rep stosb
  166.        mov dx,ds:[bx+4*2]      ;dx:= ytec
  167.        cmp dx,ds:[bx+5*2]      ;cmp ytec,ymin
  168.        jle enddr
  169. ;Redefine xr and xl:
  170.        mov si,ds:[bx+2*2]       ;si:= il
  171.        mov ax,gs:[si+2]
  172.        cmp ax,dx                ;cmp y[il],ytec
  173.        jne end_def_xl
  174.        mov cx,gs:[si+0]
  175.        shl ecx,16
  176.        mov ds:[bx+12+0*4],ecx
  177.        xor cx,cx
  178.        mov ch,gs:[si+4]
  179.        mov coll,cx
  180. c1bc:  cmp ax,dx
  181.        jne endc1bc
  182.        cmp si,ds:[bx+1*2]
  183.        je l1c1bc
  184.        add si,psz
  185.        jmp short l2c1bc
  186. l1c1bc:mov si,ds:[bx+0*2]
  187. l2c1bc:mov ax,gs:[si+2]
  188.        jmp c1bc
  189. endc1bc:
  190.        mov ax,gs:[si+0]                 ;ax:= x[il]
  191.        shl eax,16
  192.        sub eax,ds:[bx+12+0*4]           ;x[il]-xl
  193.        xor ecx,ecx                      ;ecx := 0
  194.        mov cx,[bx+4*2]                  ;cx:=ytec
  195.        sub cx,gs:[si+2]                 ;ytec - y[il]
  196.        cdq                      ;(edx:eax)/ecx
  197.        idiv ecx                 ;(edx:eax)/ecx
  198.        mov ds:[bx+2*2],si       ;il
  199.        mov ds:[bx+12+2*4],eax   ;dxl
  200.        xor ax,ax
  201.        mov ah,gs:[si+4]
  202.        sub ax,coll
  203.        cwd
  204.        idiv cx
  205.        mov dcoll,ax
  206. end_def_xl:
  207.        mov dx,ds:[bx+4*2]      ;dx:= ytec
  208.        mov si,ds:[bx+3*2]       ;si:= ir
  209.        mov ax,gs:[si+2]         ;ax:= y[ir]
  210.        cmp ax,dx                ;cmp y[ir],ytec
  211.        jne end_def_xr
  212.        mov cx,gs:[si+0]
  213.        shl ecx,16
  214.        mov ds:[bx+12+1*4],ecx
  215.        xor cx,cx
  216.        mov ch,gs:[si+4]
  217.        mov colr,cx
  218. c2bc:  cmp ax,dx
  219.        jne endc2bc
  220.        cmp si,ds:[bx+0*2]
  221.        je l1c2bc
  222.        sub si,psz
  223.        jmp short l2c2bc
  224. l1c2bc:mov si,ds:[bx+1*2]
  225. l2c2bc:mov ax,gs:[si+2]
  226.        jmp c2bc
  227. endc2bc:
  228.        mov ax,gs:[si+0]                 ;ax:= x[ir]
  229.        shl eax,16
  230.        sub eax,ds:[bx+12+1*4]           ;x[ir]-xr
  231.        xor ecx,ecx                      ;ecx := 0
  232.        mov cx,[bx+4*2]                  ;cx:=ytec
  233.        sub cx,gs:[si+2]                 ;ytec - y[ir]
  234.        cdq                      ;(edx:eax)/ecx
  235.        idiv ecx                 ;(edx:eax)/ecx
  236.        mov ds:[bx+3*2],si
  237.        mov ds:[bx+12+3*4],eax   ;dxr
  238. ;       xor eax,eax
  239. ;       mov ah,gs:[si+4]
  240. ;       sub ax,colr
  241. ;      div cx
  242. ;       mov dcolr,ax
  243.        xor ax,ax
  244.        mov ah,gs:[si+4]
  245.        sub ax,colr
  246.        cwd
  247.        idiv cx
  248.        mov dcolr,ax
  249. end_def_xr:
  250.        ;Incs:
  251.        mov ax,coll
  252.        add ax,dcoll
  253.        mov coll,ax
  254.        mov ax,colr
  255.        add ax,dcolr
  256.        mov colr,ax
  257.        mov eax,ds:[bx+12+0*4]
  258.        add eax,ds:[bx+12+2*4]
  259.        mov ds:[bx+12+0*4],eax
  260.        mov eax,ds:[bx+12+1*4]
  261.        add eax,ds:[bx+12+3*4]
  262.        mov ds:[bx+12+1*4],eax
  263.        sub word ptr ds:[bx+12+16+0*2],320
  264.        dec word ptr ds:[bx+4*2]
  265.        jmp BIG_c
  266. ENDIF
  267. enddr:
  268.  
  269.        pop ds
  270.        pop bp
  271.        ret  Param_size
  272. polydr endp
  273. code ends
  274. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement