Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- public polydr
- code segment para use16
- assume cs:code
- start:
- polydr proc near
- arg data_buf:dword,n:word,Point_mas:dword = Param_size
- ;arg data_buf:dword = Param_size
- psz EQU 5
- coll EQU word ptr ds:[bx+12+16+4+2*0]
- colr EQU word ptr ds:[bx+12+16+4+2*1]
- dcoll EQU word ptr ds:[bx+12+16+4+2*2]
- dcolr EQU word ptr ds:[bx+12+16+4+2*3]
- const5757 EQU ds:[bx+12+16+4+2*4]
- public polydr
- push bp
- mov bp,sp
- push ds
- lgs di,point_mas
- lds bx,Data_buf
- mov word ptr const5757,5757
- mov ax,ds:[bx+0];segA000
- mov es,ax
- mov ds:[bx+0],di
- mov si,n
- dec si ;because mas [0..n-1]
- imul si,si,psz ; *psz:structure "point" need psz bytes.
- ;shl si,2
- ;add si,
- add si,di
- mov ds:[bx+1*2],si
- xor cx,cx
- mov ax,-32000
- mov dx,+32000
- c1: cmp cx,n ;for cx:= 0 to n-1 do ...
- je endc1
- cmp ax,gs:[di+2]
- jge l1_in_c1
- mov ax,gs:[di+2]
- mov si,di
- l1_in_c1:
- cmp dx,gs:[di+2]
- jle l2_in_c1
- mov dx,gs:[di+2]
- l2_in_c1:
- add di,psz
- inc cx
- jmp c1
- endc1:
- IF 1
- cmp ax,dx ;if ymax = ymin, then goto enddr
- je enddr
- mov di,si ;"save" si in di. si == index of ymax in point_mas.
- c2: cmp gs:[si+2],ax ;ax = ymax now.
- jne endc2
- cmp si,ds:[bx+1*2]
- je l1_c2
- add si,psz
- jmp short l2_c2
- l1_c2: mov si,ds:[bx+0]
- l2_c2: jmp short c2
- endc2: mov ds:[bx+2*2],si ;si == il
- mov si,di ;index of ymax was saved in di
- c3: cmp gs:[si+2],ax ;ax == ymax now.
- jne endc3
- cmp si,ds:[bx+0*2]
- je l1_c3
- sub si,psz
- jmp short l2_c3
- l1_c3: mov si,ds:[bx+1*2]
- l2_c3: jmp short c3
- endc3: mov ds:[bx+3*2],si ;si == ir
- mov ds:[bx+4*2],ax ;ytec:=ymax
- ENDIF
- mov ds:[bx+5*2],dx ;ymin
- if 1
- mov si,ds:[bx+2*2] ;si:= il
- cmp si,ds:[bx+0*2]
- je l1
- sub si,psz
- jmp short l2
- l1: mov si,ds:[bx+1*2]
- l2: mov ax,gs:[si+0] ;ax := int(xl)
- shl eax,16
- mov ds:[bx+12+0*4],eax ;xl
- xor ax,ax
- mov ah,gs:[si+4]
- mov coll,ax
- mov si,ds:[bx+3*2] ;SI := ir
- cmp si,ds:[bx+1*2]
- je l3
- add si,psz
- jmp short l4
- l3: mov si,ds:[bx+0*2]
- l4: mov ax,gs:[si+0]
- shl eax,16
- mov ds:[bx+12 + 1*4],eax ;xr
- xor ax,ax
- mov ah,gs:[si+4]
- mov colr,ax
- ;Count dxl:
- mov si,ds:[bx+2*2] ;si := il
- mov ax,gs:[si+0] ;ax:= round(x[il])
- shl eax,16
- sub eax,ds:[bx+12+0*4] ;x[il]-xl
- xor ecx,ecx ;ecx := 0
- mov cx,[bx+4*2] ;cx:=ytec
- sub cx,gs:[si+2] ;cx:= ytec - y[il]
- cdq ;(edx:eax)/ecx
- idiv ecx ;(edx:eax)/ecx
- mov ds:[bx+12+2*4],eax ;dxl
- xor ax,ax
- mov ah,gs:[si+4]
- sub ax,coll
- cwd
- idiv cx
- mov dcoll,ax
- ;Count dxr:
- mov si,ds:[bx+3*2] ;si := ir
- mov ax,gs:[si+0] ;ax:= x[ir]
- shl eax,16
- sub eax,ds:[bx+12+1*4] ;x[ir]-xr
- xor ecx,ecx ;ecx := 0
- mov cx,[bx+4*2] ;cx:=ytec
- sub cx,gs:[si+2] ;ytec - y[ir]
- cdq ;(edx:eax)/ecx
- idiv ecx ;(edx:eax)/ecx
- mov ds:[bx+12+3*4],eax ;dxr
- xor ax,ax
- mov ah,gs:[si+4]
- sub ax,colr
- cwd
- idiv cx
- mov dcolr,ax
- ;count adress of sreen line start
- mov ax,ds:[bx+4*2]
- mov cx,320
- mul cx
- mov ds:[bx+12+16+0*2],ax ;line start
- endif
- if 1
- BIG_c: ;Line:
- mov ecx,ds:[bx+12+1*4] ;ecx := xr
- mov eax,ds:[bx+12+0*4] ;eax := xl
- rol ecx,16
- rol eax,16
- sub cx,ax
- jl enddr
- jcxz eppix
- mov di,ds:[bx+12+16+0*2]
- add di,ax
- mov ax,colr
- sub ax,coll
- cwd
- idiv cx
- mov dx,ax
- mov ax,coll
- ppix: mov es:[di],ah
- add ax,dx
- inc di
- loop ppix
- eppix:
- ;mov al,c
- ; rep stosb
- mov dx,ds:[bx+4*2] ;dx:= ytec
- cmp dx,ds:[bx+5*2] ;cmp ytec,ymin
- jle enddr
- ;Redefine xr and xl:
- mov si,ds:[bx+2*2] ;si:= il
- mov ax,gs:[si+2]
- cmp ax,dx ;cmp y[il],ytec
- jne end_def_xl
- mov cx,gs:[si+0]
- shl ecx,16
- mov ds:[bx+12+0*4],ecx
- xor cx,cx
- mov ch,gs:[si+4]
- mov coll,cx
- c1bc: cmp ax,dx
- jne endc1bc
- cmp si,ds:[bx+1*2]
- je l1c1bc
- add si,psz
- jmp short l2c1bc
- l1c1bc:mov si,ds:[bx+0*2]
- l2c1bc:mov ax,gs:[si+2]
- jmp c1bc
- endc1bc:
- mov ax,gs:[si+0] ;ax:= x[il]
- shl eax,16
- sub eax,ds:[bx+12+0*4] ;x[il]-xl
- xor ecx,ecx ;ecx := 0
- mov cx,[bx+4*2] ;cx:=ytec
- sub cx,gs:[si+2] ;ytec - y[il]
- cdq ;(edx:eax)/ecx
- idiv ecx ;(edx:eax)/ecx
- mov ds:[bx+2*2],si ;il
- mov ds:[bx+12+2*4],eax ;dxl
- xor ax,ax
- mov ah,gs:[si+4]
- sub ax,coll
- cwd
- idiv cx
- mov dcoll,ax
- end_def_xl:
- mov dx,ds:[bx+4*2] ;dx:= ytec
- mov si,ds:[bx+3*2] ;si:= ir
- mov ax,gs:[si+2] ;ax:= y[ir]
- cmp ax,dx ;cmp y[ir],ytec
- jne end_def_xr
- mov cx,gs:[si+0]
- shl ecx,16
- mov ds:[bx+12+1*4],ecx
- xor cx,cx
- mov ch,gs:[si+4]
- mov colr,cx
- c2bc: cmp ax,dx
- jne endc2bc
- cmp si,ds:[bx+0*2]
- je l1c2bc
- sub si,psz
- jmp short l2c2bc
- l1c2bc:mov si,ds:[bx+1*2]
- l2c2bc:mov ax,gs:[si+2]
- jmp c2bc
- endc2bc:
- mov ax,gs:[si+0] ;ax:= x[ir]
- shl eax,16
- sub eax,ds:[bx+12+1*4] ;x[ir]-xr
- xor ecx,ecx ;ecx := 0
- mov cx,[bx+4*2] ;cx:=ytec
- sub cx,gs:[si+2] ;ytec - y[ir]
- cdq ;(edx:eax)/ecx
- idiv ecx ;(edx:eax)/ecx
- mov ds:[bx+3*2],si
- mov ds:[bx+12+3*4],eax ;dxr
- ; xor eax,eax
- ; mov ah,gs:[si+4]
- ; sub ax,colr
- ; div cx
- ; mov dcolr,ax
- xor ax,ax
- mov ah,gs:[si+4]
- sub ax,colr
- cwd
- idiv cx
- mov dcolr,ax
- end_def_xr:
- ;Incs:
- mov ax,coll
- add ax,dcoll
- mov coll,ax
- mov ax,colr
- add ax,dcolr
- mov colr,ax
- mov eax,ds:[bx+12+0*4]
- add eax,ds:[bx+12+2*4]
- mov ds:[bx+12+0*4],eax
- mov eax,ds:[bx+12+1*4]
- add eax,ds:[bx+12+3*4]
- mov ds:[bx+12+1*4],eax
- sub word ptr ds:[bx+12+16+0*2],320
- dec word ptr ds:[bx+4*2]
- jmp BIG_c
- ENDIF
- enddr:
- pop ds
- pop bp
- ret Param_size
- polydr endp
- code ends
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement