home *** CD-ROM | disk | FTP | other *** search
- .286
- stack segment para stack
- ; db 64 dup(0)
- stack ends
- adatok segment para 'data'
- ;-SIN es COS tablazat (az ertek word es szamolas utan el kell osztani 128-al)-
- sintbl dw 0 , 2 , 4 , 7 , 9 , 11 , 13 , 16 , 18 , 20
- dw 22 , 24 , 27 , 29 , 31 , 33 , 35 , 37 , 40 , 42
- dw 44 , 46 , 48 , 50 , 52 , 54 , 56 , 58 , 60 , 62
- dw 64 , 66 , 68 , 70 , 72 , 73 , 75 , 77 , 79 , 81
- dw 82 , 84 , 86 , 87 , 89 , 91 , 92 , 94 , 95 , 97
- dw 98 , 99 , 101 , 102 , 104 , 105 , 106 , 107 , 109 , 110
- dw 111 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 119
- dw 120 , 121 , 122 , 122 , 123 , 124 , 124 , 125 , 125 , 126
- dw 126 , 126 , 127 , 127 , 127 , 128 , 128 , 128 , 128 , 128
- costbl dw 128 , 128 , 128 , 128 , 128 , 128 , 127 , 127 , 127 , 126
- dw 126 , 126 , 125 , 125 , 124 , 124 , 123 , 122 , 122 , 121
- dw 120 , 119 , 119 , 118 , 117 , 116 , 115 , 114 , 113 , 112
- dw 111 , 110 , 109 , 107 , 106 , 105 , 104 , 102 , 101 , 99
- dw 98 , 97 , 95 , 94 , 92 , 91 , 89 , 87 , 86 , 84
- dw 82 , 81 , 79 , 77 , 75 , 73 , 72 , 70 , 68 , 66
- dw 64 , 62 , 60 , 58 , 56 , 54 , 52 , 50 , 48 , 46
- dw 44 , 42 , 40 , 37 , 35 , 33 , 31 , 29 , 27 , 24
- dw 22 , 20 , 18 , 16 , 13 , 11 , 9 , 7 , 4 , 2
- dw -0 , -2 , -4 , -7 , -9 , -11 , -13 , -16 , -18 , -20
- dw -22 , -24 , -27 , -29 , -31 , -33 , -35 , -37 , -40 , -42
- dw -44 , -46 , -48 , -50 , -52 , -54 , -56 , -58 , -60 , -62
- dw -64 , -66 , -68 , -70 , -72 , -73 , -75 , -77 , -79 , -81
- dw -82 , -84 , -86 , -87 , -89 , -91 , -92 , -94 , -95 , -97
- dw -98 , -99 ,-101 ,-102 ,-104 ,-105 ,-106 ,-107 ,-109 ,-110
- dw -111 ,-112 ,-113 ,-114 ,-115 ,-116 ,-117 ,-118 ,-119 ,-119
- dw -120 ,-121 ,-122 ,-122 ,-123 ,-124 ,-124 ,-125 ,-125 ,-126
- dw -126 ,-126 ,-127 ,-127 ,-127 ,-128 ,-128 ,-128 ,-128 ,-128
- dw -128 ,-128 ,-128 ,-128 ,-128 ,-128 ,-127 ,-127 ,-127 ,-126
- dw -126 ,-126 ,-125 ,-125 ,-124 ,-124 ,-123 ,-122 ,-122 ,-121
- dw -120 ,-119 ,-119 ,-118 ,-117 ,-116 ,-115 ,-114 ,-113 ,-112
- dw -111 ,-110 ,-109 ,-107 ,-106 ,-105 ,-104 ,-102 ,-101 , -99
- dw -98 , -97 , -95 , -94 , -92 , -91 , -89 , -87 , -86 , -84
- dw -82 , -81 , -79 , -77 , -75 , -73 , -72 , -70 , -68 , -66
- dw -64 , -62 , -60 , -58 , -56 , -54 , -52 , -50 , -48 , -46
- dw -44 , -42 , -40 , -37 , -35 , -33 , -31 , -29 , -27 , -24
- dw -22 , -20 , -18 , -16 , -13 , -11 , -9 , -7 , -4 , -2
- dw 0 , 2 , 4 , 7 , 9 , 11 , 13 , 16 , 18 , 20
- dw 22 , 24 , 27 , 29 , 31 , 33 , 35 , 37 , 40 , 42
- dw 44 , 46 , 48 , 50 , 52 , 54 , 56 , 58 , 60 , 62
- dw 64 , 66 , 68 , 70 , 72 , 73 , 75 , 77 , 79 , 81
- dw 82 , 84 , 86 , 87 , 89 , 91 , 92 , 94 , 95 , 97
- dw 98 , 99 , 101 , 102 , 104 , 105 , 106 , 107 , 109 , 110
- dw 111 , 112 , 113 , 114 , 115 , 116 , 117 , 118 , 119 , 119
- dw 120 , 121 , 122 , 122 , 123 , 124 , 124 , 125 , 125 , 126
- dw 126 , 126 , 127 , 127 , 127 , 128 , 128 , 128 , 128 , 128
- ;------ A forgatashoz szukseges valtozok ------
- ralfa dw 00 ; az alfa forgatas szoge
- rbeta dw 00 ; az beta forgatas szoge
- rgamma dw 00 ; az gamma forgatas szoge
- rdalfa dw 2 ; az alfa szog valtozasanak erteke
- rdbeta dw 3 ; az beta szog valtozasanak erteke
- rdgamma dw 2 ; az gamma szog valtozasanak erteke
- rox dw 0d ; az elforgatando pont x kordinataja
- roy dw 0d ; az elforgatando pont y kordinataja
- roz dw 0d ; az elforgatando pont z kordinataja
- roxyze dw 0d ; segedvaltozo x-hez
- roye dw 0d ; segedvaltozo y-hoz
- roze dw 0d ; segedvaltozo z-hez
- ropontx dw 0d ; az elforgatott pont sikra valo lekepezesenek x kordinatja
- roponty dw 0d ; az elforgatott pont sikra valo lekepezesenek y kordinatja
- ropk dw 800d ; a lekepezes allitasa
- ropl dw 280d ; a lekepezes allitasa
- ;------ objektum adatai ------
- obnum dw 16 ; pontok szama
- obinc dw 0
- obx dw 20,-20,-20, 20, 20,-20,-20, 20, 0, 0, 0, 0,-99, 99
- oby dw 20, 20,-20,-20, 20, 20,-20,-20, 0, 0, 99,-99, 0, 0
- obz dw 20, 20, 20, 20,-20,-20,-20,-20, 99,-99, 0, 0, 0, 0
- obline dw 36
- oblinei dw 0
- kotmit dw 0,1,2,3,4,5,6,7,0,1,2,3, 0,1,2,3, 4,5,6,7
- dw 0, 1, 4, 5, 2, 3, 6, 7, 1, 2, 5, 6, 0, 3, 4, 7
- kotvel dw 1,2,3,0,5,6,7,4,4,5,6,7, 8,8,8,8, 9,9,9,9
- dw 10,10,10,10, 11,11,11,11, 12,12,12,12, 13,13,13,13
- obszx dw 16 dup (0h)
- obszy dw 16 dup (0h)
- ;------- A vonalhuzo rutin valtozoi --------
- lincolor db 9
- linemode db 00
- linx1 dw 0d
- linx2 dw 0
- liny1 dw 0d
- liny2 dw 0
- adatok ends
-
- begin segment para 'code'
- main proc far
- assume cs:begin,ds:adatok,ss:stack
- mov ax,adatok
- mov ds,ax
-
- ;*********** Fo torzs ***********
-
- mov ah,00h
- mov al,13h
- int 10h
- call forgat
- mov ah,00h
- mov al,03h
- int 10h
- jmp ki
-
- ;********** Fo torzs vege *******
-
- ;----- Forgatas ------
- forgat proc
- rotoda: call pontoksz ;Pontok kiszamolasa
- mov linemode,0 ;Rajzolasai mod beallitasa
- call waitraster ;Varakozas a kepernyofrissitesre
- call kitesz ;Vonalak kirajzolasa
- mov linemode,1 ;Torlesi mod beallitasa
- call waitraster ;Varakozas a kepernyofrissitesre
- call vaitraster
- call waitraster ;Varakozas a kepernyofrissitesre
- call kitesz ;Vonalak torlese
- call szoginc ;Szog ertekek novelese
- mov ah,0bh ;Billentyu leutes figyelese
- int 21h
- cmp al,00h
- je rotoda
- ret
- forgat endp
-
- ;------- A keprnyofrissitesre var ------
- waitraster proc
- mov dx,3dah
- raster: in ax,dx
- ror al,4
- jnc raster
- ret
- waitraster endp
-
- ;------- A keprnyofrissitesre var ------
- vaitraster proc
- mov dx,3dah
- vraster:in ax,dx
- ror al,4
- jc vraster
- ret
- vaitraster endp
-
- ;------- Vonalak Kirajzolasa -----------
- kitesz proc
- mov cx,0
- rotki: mov si,cx
- rol si,1
- mov ax,kotmit[si]
- mov si,ax
- rol si,1
- mov ax,obszx[si]
- mov linx1,ax
- mov ax,obszy[si]
- mov liny1,ax
-
- mov si,cx
- rol si,1
- mov ax,kotvel[si]
- mov si,ax
- rol si,1
- mov ax,obszx[si]
- mov linx2,ax
- mov ax,obszy[si]
- mov liny2,ax
- push cx
- call line
- pop cx
- inc cx
- cmp cx,obline
- jnz rotki
- ret
- kitesz endp
-
-
- ;------- Pontok kordinatainak kiszamitasa -------
- pontoksz proc
- mov obinc,0
- rotide: call kordolv
- call rotate
- mov ax,rox
- mov bx,roy
- mov si,obinc
- rol si,1
- mov obszx[si],ax
- mov obszy[si],bx
- inc obinc
- mov bx,obnum
- cmp obinc,bx
- jnz rotide
- ret
- pontoksz endp
-
- ;------- kordinata beallitas ------
- kordolv proc
- mov si,obinc
- rol si,1
- mov ax,obx[si]
- mov bx,oby[si]
- mov cx,obz[si]
- mov rox,ax
- mov roy,bx
- mov roz,cx
- ret
- kordolv endp
-
- ;-------- ALFA , BETA , GAMMA szogek novelese ------
- szoginc proc
- cmp rdalfa,0 ;{ha rdalfa>0 elugrik ide1 hoz}
- jg szogidea1
- mov ax,ralfa
- add ax,rdalfa
- cmp ax,0
- jge szogidea0 ;{ha ralfa>=0 akkor ide0-hoz}
- neg ax ;{kivonja 360-bol az uj szogerteket}
- mov bx,360
- sub bx,ax
- mov ax,bx
- szogidea0: mov ralfa,ax
- jmp szogbeta
- szogidea1: mov ax,ralfa
- add ax,rdalfa
- cmp ax,360
- jge szogidea2 ;{ha ralfa=<359 akkor ide0-hoz}
- mov ralfa,ax
- jmp szogbeta
- szogidea2: mov bx,360
- mov dx,0
- div bx
- mov ralfa,dx
- szogbeta: cmp rdbeta,0
- jg szogideb1
- mov ax,rbeta
- add ax,rdbeta
- cmp ax,0
- jge szogideb0
- neg ax
- mov bx,360
- sub bx,ax
- mov ax,bx
- szogideb0: mov rbeta,ax
- jmp szoggamma
- szogideb1: mov ax,rbeta
- add ax,rdbeta
- cmp ax,360
- jge szogideb2
- mov rbeta,ax
- jmp szoggamma
- szogideb2: mov bx,360
- mov dx,0
- div bx
- mov rbeta,dx
- szoggamma: cmp rdgamma,0
- jg szogideg1
- mov ax,rgamma
- add ax,rdgamma
- cmp ax,0
- jge szogideg0
- neg ax
- mov bx,360
- sub bx,ax
- mov ax,bx
- szogideg0: mov rgamma,ax
- jmp szogvege
- szogideg1: mov ax,rgamma
- add ax,rdgamma
- cmp ax,360
- jge szogideg2
- mov rgamma,ax
- jmp szogvege
- szogideg2: mov bx,360
- mov dx,0
- div bx
- mov rgamma,dx
- szogvege: ret
- szoginc endp
-
-
-
- deltabs proc
- cmp di,0 ;{lindeltx:=abs(lindeltx);}
- jg @lcser1
- neg di
- @lcser1:cmp bp,0 ;{lindelty:=abs(lindelty);}
- jg @lcser2
- neg bp
- @lcser2:ret
- deltabs endp
-
- putpont proc
- ;{--------- pont rajzolasa -------}
- cmp linemode,0
- jne @vonaltorol
- ;{mov dl,es:[bx] ;{XOR}
- ;{or dl,lincolor ;{XOR}
- ;mov dl,lincolor ;{NORMAL}
- mov es:[si],dl
- ret
- @vonaltorol: mov dh,es:[si]
- ;mov dh,0ffh
- xor dh,dl
- and dh,0
- mov es:[si],dh
- ret
- putpont endp
-
- lcsere proc
- mov cx,linx1 ;{x csere}
- mov dx,linx2
- mov linx1,dx
- mov linx2,cx
- mov cx,liny1 ;{y csere}
- mov dx,liny2
- mov liny1,dx
- mov liny2,cx
- ret
- lcsere endp
-
- line proc
- ;{ Hasznalt regiszterek :
- ;{ AX, BX, CX, DX, ES, SI, DI, BP }
- mov ax,0a000h
- mov es,ax
- mov di,linx2 ;{AX:=lindeltx:=linx2-linx1;}
- sub di,linx1
- mov bp,liny2 ;{BX:=lindelty:=liny2-liny1;}
- sub bp,liny1
- cmp di,0 ;{if (lindeltx<>0) and (lindelty<>0) then begin dolt; goto finish; end;}
- je @ln1
- cmp bp,0
- je @ln1
- jmp @ldolt
-
- @ln1: cmp bp,0 ;{if (lindelty<>0) then begin fuggoleges; goto finish; end;}
- je @ln2
- jmp @lfuggo
-
- @ln2: cmp di,0 ;{if (lindeltx<>0) then begin visszintes; goto finish; end;}
- je @ln3
- jmp @lvissz
-
- ;{------------------ Pont ------------------}
- @ln3: mov dx,liny1 ;{linxx1:=linx1; linyy1:=liny1;}
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
- mov dl,lincolor
- call putpont
- ret
-
- ;{-------------- Dolt vonalak ------------------}
- @ldolt: cmp di,0 ;{if (lindeltx<0) and (lindelty<0) then begin csere; eset1; goto vege; end;}
- jg @dolt1
- cmp bp,0
- jg @dolt1
- call lcsere
- jmp @eset1
- @dolt1: cmp di,0 ;{if (lindeltx<0) and (lindelty>0) then begin csere; eset2; goto vege; end;}
- jg @dolt2
- cmp bp,0
- jl @dolt2
- call lcsere
- jmp @eset2
- @dolt2: cmp bp,0 ;{if (lindelty>0) then begin eset1; goto vege; end;}
- jl @eset2
- jmp @eset1
-
- ;{---- Masodik eset ---}
- @eset2:
- call deltabs
- cmp di,bp
- jl @leset2a ;{if (lindeltx<lindelty) then goto eset2a;}
- mov cx,di ;{until linxx1=linx2;}
-
- mov dx,liny1
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
-
- mov ax,di
- sar ax,1
-
- mov dl,lincolor
- mov bx,0320d
- @leset20:call putpont
- add ax,bp ;{linyp:=linyp+lindelty;}
- cmp ax,di ;{if linyp>=lindeltx then begin linyp:=linyp-lindeltx; dec(linyy1); end;}
- jl @leset20a
- sub ax,di
- sub si,bx
- @leset20a:inc si
- loop @leset20
- ret
-
- @leset2a:
- mov cx,bp ;{until linyy1=liny2;}
-
- mov bx,bp
- sar bx,1
-
- mov dx,liny1
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
-
- mov dl,lincolor
- mov ax,0320d
- @leset2b:call putpont
- add bx,di ;{linxp:=linxp+lindeltx;}
- cmp bx,bp ;{if linxp>=lindelty then begin linxp:=linxp-lindelty; inc(linxx1); end;}
- jl @leset2c
- sub bx,bp
- inc si
- @leset2c:sub si,ax
- loop @leset2b
- ret
-
- ;{---- Elso eset ---}
- @eset1:
- call deltabs
- cmp di,bp
- jl @leset1a ;{if (lindeltx<lindelty) then goto eset1a;}
- mov cx,di ;{until linxx1=linx2;}
-
- mov dx,liny1
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
-
- mov ax,di
- sar ax,1
-
- mov dl,lincolor
- mov bx,0320d
- @leset0:call putpont
- add ax,bp ;{linyp:=linyp+lindelty;}
- cmp ax,di ;{if linyp>=lindeltx then begin linyp:=linyp-lindeltx; inc(linyy1); end;}
- jl @leset0a
- sub ax,di
- add si,bx
- @leset0a:inc si
- loop @leset0
- ret
-
- @leset1a:
- mov cx,bp ;{until linyy1=liny2;}
- mov bx,bp
- sar bx,1
-
- mov dx,liny1
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
-
- mov dl,lincolor
- mov ax,0320d
- @leset1b:call putpont
- add bx,di ;{linxp:=linxp+lindeltx;}
- cmp bx,bp ;{if linxp>=lindelty then begin linxp:=linxp-lindelty; inc(linxx1); end;}
- jl @leset1c
- sub bx,bp
- inc si
- @leset1c:add si,0320d
- loop @leset1b
- ret
-
- ;{------------- Fuggoleges vonal --------------}
- @lfuggo:
- cmp bp,0 ;{if lindelty<0 then csere;}
- jg @lnocs
- call lcsere
- neg bp
- @lnocs:mov dx,liny1 ;{linxx1:=linx1; linyy1:=liny1;}
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
- mov cx,bp ;{until linyy1=liny2;}
-
- mov dl,lincolor
- mov ax,0320d
- @lfis:call putpont
- add si,ax
- loop @lfis
- ret
-
- ;{------------- Visszintes vonal --------------}
- @lvissz:
- cmp di,0 ;{if lindeltx<0 then csere;}
- jg @lnoc
- call lcsere
- neg di
- @lnoc:mov dx,liny1 ;{linxx1:=linx1; linyy1:=liny1;}
- mov ax,0320d
- mul dx
- add ax,linx1
- mov si,ax
- mov cx,di ;{until linxx1=linx2;}
- mov dl,lincolor
- @lvis:call putpont
- inc si
- loop @lvis
- ret
- line endp
-
- ;------------ PONT FORGATASANAK KISZAMITASA ---------
- rotate proc
- ; xe:=x;
- ; x:=(sin(alfa)*y+(cos(alfa)*xe));
- mov ax,rox
- mov roxyze,ax
- mov si,ralfa
- rol si,1
- mov bx,sintbl[si]
- mov ax,roy
- imul bx
- mov bx,ax
- mov ax,costbl[si]
- mov dx,roxyze
- imul dx
- add ax,bx
- sar ax,7
- mov rox,ax
- ; y:=(cos(alfa)*y)-(sin(alfa)*xe);
- mov bx,costbl[si]
- mov ax,roy
- imul bx
- mov bx,ax
- mov ax,sintbl[si]
- mov dx,roxyze
- imul dx
- sub bx,ax
- sar bx,7
- mov roy,bx
- ;xe:=x;
- ;x:=(cos(beta)*xe)-(sin(beta)*z);
- mov ax,rox
- mov roxyze,ax
- mov si,rbeta
- rol si,1
- mov ax,costbl[si]
- mov dx,roxyze
- imul dx
- mov bx,ax
- mov ax,sintbl[si]
- push cx
- mov cx,roz
- imul cx
- sub bx,ax
- pop cx
- sar bx,7
- add bx,0160d
- mov rox,bx
- ;z:=(cos(beta)*z)+(sin(beta)*xe);
- mov bx,costbl[si]
- mov ax,roz
- imul bx
- mov bx,ax
- mov ax,sintbl[si]
- mov dx,roxyze
- imul dx
- add ax,bx
- sar ax,7
- mov roz,ax
- ;ye:=y;
- ;y:=(sin(gama)*z)+(cos(gama)*ye);
- mov ax,roy
- mov roxyze,ax
- mov si,rgamma
- rol si,1
- mov bx,sintbl[si]
- mov ax,roz
- imul bx
- mov bx,ax
- mov ax,costbl[si]
- mov dx,roxyze
- imul dx
- add ax,bx
- sar ax,7
- add ax,0100d
- mov roy,ax
- ;z:=(cos(gama)*z)-(sin(gama)*ye);
- mov bx,costbl[si]
- mov ax,roz
- imul bx
- mov bx,ax
- mov ax,sintbl[si]
- mov dx,roxyze
- imul dx
- sub bx,ax
- sar bx,7
- mov roz,bx
- ret
- rotate endp
-
- lekepez proc
- ;xx:=trunc(x*(pl-pk)/(pl-z));
- ;yy:=trunc(y*(pl-pk)/(pl-z));
- lekepez endp
-
- ki:
-
- mov ah,4ch ;EXIT DOS
- int 21h
- main endp
- begin ends
- end main
-
-