home *** CD-ROM | disk | FTP | other *** search
/ CD-X 1 / cdx_01.iso / demodisc / tyrant / morph / morph2.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-03-17  |  9.3 KB  |  598 lines

  1. { Ez csak az elv miatt van itt, de ennĂ©l lehet 10-szer jobbat csinalni!
  2.                                          by TyRaNT / MurmidoneS }
  3. Const dots = 1800;
  4.       Mdb  = 32;
  5.       P1X  = 160;
  6.       P1Y  = 110;
  7.       P2X  = 160;
  8.       P2Y  = 110;
  9.  
  10.  
  11. Var     X,Y : Word;
  12.  
  13.         Ok  : Byte;
  14.  
  15.         Px1  : Array[0..dots] of Integer;
  16.         Py1  : Array[0..dots] of Integer;
  17.         Px2  : Array[0..dots] of Integer;
  18.         Py2  : Array[0..dots] of Integer;
  19.         Pa   : Array[0..dots] of Longint;
  20.         Pb   : Array[0..dots] of Longint;
  21.         Ps1  : Array[0..dots] of Longint;
  22.         Ps2  : Array[0..dots] of Longint;
  23.  
  24. procedure vblank; assembler;
  25. asm
  26.         push    ax
  27.         push    dx
  28.     MOV    DX,03DAh
  29. @VBL0:
  30.     IN    AL,DX
  31.     TEST    AL,8
  32.     JZ    @VBL0
  33. @VBL1:
  34.     IN    AL,DX
  35.     TEST    AL,8
  36.     JNZ    @VBL1
  37.         pop     dx
  38.         pop     ax
  39. end;
  40.  
  41. Procedure MORPH; External; {$L MORPH.Obj}
  42. Procedure Pcx_Tomorito; Assembler;
  43. ASM
  44.         PUSH DS;
  45.         push cs
  46.         pop  ds
  47.         push 09000h
  48.         pop  es
  49.         lea si,MORPH
  50.         ADD SI,127
  51.         XOR DI,DI;
  52.         XOR BX,BX;
  53.         XOR CX,CX;
  54. @DataIn:  XOR BX,BX;
  55.           LODSB;
  56.           TEST AL,128;
  57.           JE @@AzAs1;
  58.           INC BX;
  59. @@AzAs1:  TEST AL,64;
  60.           JE @@AzAs2;
  61.           INC BX;
  62. @@AzAs2:  CMP BX,2;
  63.           JE @@Duplazas;
  64.           STOSB;
  65.           CMP DI,5*320;
  66.           JA @@AzAs3;
  67.           JMP @DataIn;
  68. @@AzAs3:  CMP DI,64000;
  69.           JA @@DispEnd;
  70.           JMP @DataIn;
  71. @@Duplazas: AND AL,63;
  72.             XOR AH,AH;
  73.             MOV CX,AX;
  74.             CMP CX,$0;
  75.             JNE @@Mehtt;
  76.             INC CX;
  77. @@Mehtt:    LODSB;
  78.             REPNZ STOSB;
  79.             CMP DI,64000;
  80.             JA @@DispEnd;
  81.             JMP @DataIn;
  82. @@DispEnd:  POP DS;
  83. End;
  84.  
  85. Procedure Pontki; assembler;
  86. asm
  87. mov ax,09000h
  88. mov es,ax
  89. mov di,x
  90. mov ax,y
  91.  
  92.     push di
  93.     push bx
  94.     push ax
  95.     mov bx,80
  96.     mul bx
  97.     mov bx,di
  98.     shr di,3
  99.     add di,ax
  100.     mov al,010000000b
  101.     shr bx,1
  102.     jnc  @t1
  103.     shr al,1
  104. @t1:
  105.     shr bx,1
  106.     jnc  @t2
  107.     shr al,2
  108. @t2:
  109.     shr bx,1
  110.     jnc  @t3
  111.     shr al,4
  112. @t3:
  113.     or es:[di],al
  114.     pop ax
  115.     pop bx
  116.     pop di
  117. end;
  118.  
  119. Procedure Pontbe; assembler;
  120. asm
  121. mov di,x
  122. mov ax,y
  123.  
  124.     push di
  125.     push bx
  126.     push ax
  127.     push cx
  128.     mov bx,80
  129.     mul bx
  130.     mov cx,di
  131.     shr di,3
  132.     mov bx,di
  133.     add di,ax
  134.     mov al,es:[di];
  135.     shl bx,3
  136.     sub cx,bx
  137.     mov bx,000000010000000b
  138.     shr bx,cl
  139.     test al,bl
  140.     mov  ok,0
  141.     jz @z
  142.     inc  ok
  143. @z:
  144. {A zero flag 1 lesz ha egyenlo}
  145.     pop cx
  146.     pop ax
  147.     pop bx
  148.     pop di
  149. end;
  150.  
  151. Begin
  152. asm
  153.    call Pcx_tomorito;
  154.  
  155.         mov cs:word ptr @AK,0;
  156. @C1:
  157.         mov cs:word ptr @AJ,0;
  158. @C2:
  159.         mov cs:word ptr @AI,0;
  160. @C3:
  161.         mov ax,word ptr @AI;
  162.         mov X,ax
  163.         mov ax,word ptr @AJ;
  164.         mov Y,ax
  165.         call pontbe;
  166.  
  167.         cmp ok,0
  168.         je @to
  169.  
  170.         mov si,offset Px1;
  171.         mov di,cs:word ptr @AK;
  172.         shl di,1
  173.         add si,di
  174.         mov bx,cs:word ptr @AI;
  175.         add bx,P1X
  176.         mov [si],bx
  177.  
  178.         mov si,offset Py1;
  179.         mov di,cs:word ptr @AK;
  180.         shl di,1
  181.         add si,di
  182.         mov bx,cs:word ptr @AJ;
  183.         add bx,P1Y
  184.         mov [si],bx
  185.  
  186.         inc cs:word ptr @AK
  187. @to:
  188.         inc cs:word ptr @AI
  189.         cmp cs:word ptr @AK,dots;
  190.         ja @to2
  191.         cmp cs:word ptr @AI,639;
  192.         ja @to2
  193.         jmp @c3
  194. @to2:
  195.         inc cs:word ptr @AJ
  196.         cmp cs:word ptr @AK,dots;
  197.         ja @to3
  198.         cmp cs:word ptr @AJ,31;
  199.         ja @to3
  200.         jmp @c2
  201. @to3:
  202.         cmp cs:word ptr @AK,dots;
  203.         ja @to4
  204.         jmp @c1
  205. @to4:
  206.  
  207. jmp @quit
  208. @AI: dw 0
  209. @AJ: dw 0
  210. @AK: dw 0
  211. @Quit:
  212. end;
  213.  
  214. asm
  215.         mov cs:word ptr @AK,0
  216. @C1:
  217.         mov cs:word ptr @AJ,0
  218. @C2:
  219.         mov cs:word ptr @AI,0
  220. @C3:
  221.         mov ax,word ptr @AI;
  222.         mov X,ax
  223.         mov ax,word ptr @AJ;
  224.         add ax,32               {Y kord +}
  225.         mov Y,ax
  226.         call pontbe;
  227.  
  228.         cmp ok,0
  229.         je @to
  230.  
  231.         mov si,offset Px2;
  232.         mov di,cs:word ptr @AK;
  233.         shl di,1
  234.         add si,di
  235.         mov bx,cs:word ptr @AI;
  236.         add bx,P2X
  237.         mov [si],bx
  238.  
  239.         mov si,offset Py2;
  240.         mov di,cs:word ptr @AK;
  241.         shl di,1
  242.         add si,di
  243.         mov bx,cs:word ptr @AJ;
  244.         add bx,P2Y
  245.         mov [si],bx
  246.  
  247.         inc cs:word ptr @AK
  248. @to:
  249.         inc cs:word ptr @AI
  250.         cmp cs:word ptr @AK,dots;
  251.         ja @to2
  252.         cmp cs:word ptr @AI,639
  253.         je @to2
  254.         jmp @c3
  255. @to2:
  256.         inc cs:word ptr @AJ
  257.         cmp cs:word ptr @AK,dots;
  258.         ja @to3
  259.         cmp cs:word ptr @AJ,32
  260.         je @to3
  261.         jmp @c2
  262. @to3:
  263.         cmp cs:word ptr @AK,dots;
  264.         ja @to4
  265.         jmp @c1
  266. @to4:
  267.  
  268. jmp @quit
  269. @AI: dw 0
  270. @AJ: dw 0
  271. @AK: dw 0
  272. @Quit:
  273. end;
  274.  
  275. asm
  276. mov ax,010h;
  277. int 10h;
  278. push 09000h
  279. pop es
  280. xor di,di
  281. xor ax,ax
  282. mov cx,32000
  283. rep stosw;
  284. end;
  285.  
  286. asm
  287.         mov cs:word ptr @AK,0
  288.  
  289.         mov ax,dots
  290.         shl ax,2
  291.         mov cs:word ptr @dots2,ax
  292.  
  293. @C1:
  294. db $66
  295.         xor ax,ax
  296.         mov di,cs:word ptr @AK
  297.         add di,offset ps1
  298. db $66
  299.         mov [di],ax
  300.         mov di,cs:word ptr @AK
  301.         add di,offset ps2
  302. db $66
  303.         mov [di],ax
  304.  
  305.  
  306.         mov di,cs:word ptr @AK
  307.         shr di,1
  308.         add di,offset px1
  309. {db $66}
  310.         mov ax,[di]
  311.  
  312.         mov si,cs:word ptr @AK
  313.         shr si,1
  314.         add si,offset px2
  315. {db $66}
  316.         mov bx,[si]
  317.  
  318. db $66
  319.         shl ax,16
  320. db $66
  321.         shl bx,16
  322.  
  323. db $66
  324.         cmp ax,bx
  325.         jae @nz1
  326.  
  327. db $66
  328.         sub bx,ax
  329. db $66
  330.         mov ax,bx
  331. db $66
  332.         shr ax,5
  333. db $66
  334.         neg ax
  335.  
  336.         jmp @nz2
  337. @nz1:
  338.  
  339. db $66
  340.         sub ax,bx
  341. db $66
  342.         shr ax,5
  343.  
  344. @nz2:
  345.  
  346.         mov di,cs:word ptr @AK
  347.         add di,offset pa
  348. db $66
  349.         mov [di],ax
  350.  
  351.  
  352.         mov di,cs:word ptr @AK
  353.         shr di,1
  354.         add di,offset py1
  355. {db $66}
  356.         mov ax,[di]
  357.  
  358.         mov si,cs:word ptr @AK
  359.         shr si,1
  360.         add si,offset py2
  361. {db $66}
  362.         mov bx,[si]
  363.  
  364. db $66
  365.         shl ax,16
  366. db $66
  367.         shl bx,16
  368.  
  369. db $66
  370.         cmp ax,bx
  371.         jae @nz3
  372.  
  373. db $66
  374.         sub bx,ax
  375. db $66
  376.         mov ax,bx
  377. db $66
  378.         shr ax,5
  379. db $66
  380.         neg ax
  381.  
  382.         jmp @nz4
  383. @nz3:
  384.  
  385. db $66
  386.         sub ax,bx
  387. db $66
  388.         shr ax,5
  389.  
  390. @nz4:
  391.  
  392.         mov di,cs:word ptr @AK
  393.         add di,offset pb
  394. db $66
  395.         mov [di],ax
  396.  
  397.  
  398.         add cs:word ptr @AK,4
  399.         mov ax,cs:word ptr @dots2;
  400.         cmp cs:word ptr @AK,ax
  401.         jbe @c1
  402.  
  403. jmp @quit
  404. @AK: dw 0
  405. @dots2: dw 0
  406. @Quit:
  407. end;
  408.  
  409.  
  410.  
  411. asm
  412.  
  413. mov cx,mdb
  414. @sel1:
  415. push cx
  416.  
  417.         mov cs:word ptr @AK,0
  418.  
  419.         mov ax,dots
  420.         shl ax,2
  421.         mov cs:word ptr @dots2,ax
  422.  
  423. @C1:
  424.  
  425.         mov di,cs:word ptr @AK
  426.         add di,offset ps1
  427. db $66
  428.         mov ax,[di]
  429. db $66
  430.         shr ax,16
  431.  
  432.         mov si,cs:word ptr @AK
  433.         shr si,1
  434.         add si,offset px1
  435.         mov bx,[si]
  436.         sub bx,ax
  437.         mov x,bx
  438.  
  439.         mov di,cs:word ptr @AK
  440.         add di,offset ps2
  441. db $66
  442.         mov ax,[di]
  443. db $66
  444.         shr ax,16
  445.  
  446.         mov si,cs:word ptr @AK
  447.         shr si,1
  448.         add si,offset py1
  449.         mov bx,[si]
  450.         sub bx,ax
  451.         mov y,bx
  452.  
  453.         call pontki
  454.  
  455.  
  456.         mov di,cs:word ptr @AK
  457.         add di,offset pa
  458. db $66
  459.         mov ax,[di]
  460.         mov di,cs:word ptr @AK
  461.         add di,offset ps1
  462. db $66
  463.         add [di],ax
  464.  
  465.         mov di,cs:word ptr @AK
  466.         add di,offset pb
  467. db $66
  468.         mov ax,[di]
  469.         mov di,cs:word ptr @AK
  470.         add di,offset ps2
  471. db $66
  472.         add [di],ax
  473.  
  474.  
  475.         add cs:word ptr @AK,4
  476.         mov ax,cs:word ptr @dots2;
  477.         cmp cs:word ptr @AK,ax
  478.         jbe @c1
  479.  
  480. jmp @quit
  481. @AK: dw 0
  482. @dots2: dw 0
  483. @Quit:
  484.  
  485. push ds
  486. push 09000h
  487. pop  ds
  488. push 0a000h
  489. pop  es
  490. xor di,di
  491. xor si,si
  492. mov cx,20*350
  493. db $66
  494. rep movsw
  495. push 09000h;
  496. pop  es
  497. xor di,di
  498. db $66
  499. xor ax,ax
  500. mov cx,20*350
  501. db $66
  502. rep stosw
  503. pop  ds
  504. call vblank
  505. pop cx
  506. cmp cx,mdb
  507. jne @tv
  508. @tv2:
  509. in al,060h
  510. cmp al,1
  511. jne @Tv2
  512. @tv:
  513. dec cx
  514. cmp cx,0
  515. jnl @sel1
  516. @tv3:
  517. in al,060h
  518. cmp al,1
  519. jne @Tv3
  520. End;
  521. End.
  522.  
  523. {
  524. K:=0;
  525. Repeat
  526. J:=0;
  527. repeat
  528. I:=0;
  529. repeat
  530. X:=I;
  531. Y:=J;
  532. Pontbe;
  533. If Ok=1 Then Begin
  534.              Px1[K]:=I+P1X;
  535.              Py1[K]:=J+P1Y;
  536.              Inc(K);
  537.              End;
  538. Inc(I);
  539. Until (I>639) Or (K>dots);
  540. Inc(J);
  541. Until (J>31) Or (K>dots);
  542. Until K>dots;
  543. }
  544. {
  545. E:=True;
  546. K:=0;
  547. Repeat
  548. J:=0;
  549. repeat
  550. I:=639;
  551. repeat
  552. If E Then Begin
  553.           E:=False;
  554.           I:=230;
  555.           End;
  556. X:=I;
  557. Y:=J+32;
  558. Pontbe;
  559. If Ok=1 Then Begin
  560.              Px2[K]:=I+P2X;
  561.              Py2[K]:=J+P2Y;
  562.              Inc(K);
  563.              End;
  564. dec(I);
  565. Until (I<0) Or (K>dots);
  566. Inc(J);
  567. Until (J>31) Or (K>dots);
  568. Until K>dots;
  569. }
  570.  
  571. {for k:=0 to dots do
  572. begin
  573. x:=px1[k];
  574. y:=py1[k]+100;
  575. pontki;
  576. end;
  577. for k:=0 to dots do
  578. begin
  579. x:=px2[k];
  580. y:=py2[k]+100;
  581. pontki;
  582. end;}
  583.  
  584. {For k:=0 to Dots do
  585. begin
  586. Pa[k]:=((Px1[k]*65535-Px2[K]*65536) Div 16);
  587. Pb[k]:=((Py1[k]*65535-Py2[K]*65535) Div 16);
  588. end;}
  589.  
  590. {For K:=0 To dots do
  591. Begin
  592. X:=Round(Px1[k]-Ps1[k] Div 65535);
  593. Y:=Round(Py1[k]-Ps2[k] Div 65535);
  594. Pontki;
  595. Ps1[k]:=Ps1[k]+Pa[k];
  596. Ps2[k]:=Ps2[k]+Pb[k];
  597. end;}
  598.