home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PINBSRC.ZIP / _VIDEO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-02-02  |  9KB  |  513 lines

  1. procedure video_mode(mode:byte);
  2. begin
  3.       asm
  4.         mov  AH,00
  5.         mov  AL,mode
  6.         int  10h
  7.       end;
  8. end;
  9.  
  10.  
  11. procedure vga320x400Overscan; assembler;
  12. asm
  13.   mov ax,0013h     { mode 13h, 320x200x256x1 }
  14.   int 10h
  15.   mov dx,03c4h
  16.   mov ax,0604h     { unchain stuff: 320x200x256x4 }
  17.   out dx,ax
  18.   mov ax,0f02h
  19.   out dx,ax
  20.  
  21.   mov cx,320*200
  22.   mov es,vseg
  23.   xor ax,ax
  24.   mov di,ax
  25.   rep stosw
  26.   mov dx,03d4h
  27.  
  28. { set 'overscan' mode here! }
  29.   cmp overscan,0
  30.   jz @@weiter1
  31.     mov dx,03c2h
  32.     mov al,10100011b
  33.     out dx,al
  34.   @@weiter1:
  35.  
  36.   mov dx,03d4h
  37.  
  38.   cmp highres,0
  39.   jz @@weiter2
  40.     mov ax,4009h
  41.     out dx,ax
  42.   @@weiter2:
  43.  
  44.   mov ax,0014h
  45.   out dx,ax
  46.   mov ax,0e317h
  47.   out dx,ax{}
  48. end;
  49.  
  50. procedure Set_RGB_color(co,r,g,b:byte); assembler;
  51. asm
  52.   mov dx,$3c8
  53.   mov al, co
  54.   out dx,al
  55.  
  56.   mov dx,$3c9
  57.  
  58.   mov al, r
  59.   out dx,al
  60.  
  61.   mov al, g
  62.   out dx,al
  63.  
  64.   mov al, b
  65.   out dx,al
  66. end;
  67.  
  68. procedure retrace; assembler;
  69. asm
  70.   mov dx,3dah
  71.  @vert1:
  72.   in al,dx
  73.   test al,8
  74.   jz @vert1
  75.  @vert2:
  76.   in al,dx
  77.   test al,8
  78.   jnz @vert2
  79. end;
  80.  
  81. procedure setaddress(ad:word); assembler;
  82. asm
  83.   mov dx,3d4h
  84.   mov al,0ch
  85.   mov ah,[byte(ad)+1]
  86.   out dx,ax
  87.   mov al,0dh
  88.   mov ah,[byte(ad)]
  89.   out dx,ax
  90. end;
  91.  
  92. procedure setlinecomp(ad:word); assembler;
  93. asm
  94.   mov dx,3d4h
  95.   mov al,18h
  96.   mov ah,[byte(ad)]
  97.   out dx,ax
  98.   mov al,7
  99.   out dx,al
  100.   inc dx
  101.   in al,dx
  102.   dec dx
  103.   mov ah,[byte(ad)+1]
  104.   and ah,00000001b
  105.   shl ah,4
  106.   and al,11101111b
  107.   or al,ah
  108.   mov ah,al
  109.   mov al,7
  110.   out dx,ax
  111.   mov al,9
  112.   out dx,al
  113.   inc dx
  114.   in al,dx
  115.   dec dx
  116.   mov ah,[byte(ad)+1]
  117.   and ah,00000010b
  118.   shl ah,5
  119.   and al,10111111b
  120.   or al,ah
  121.   mov ah,al
  122.   mov al,9
  123.   out dx,ax
  124. end;
  125.  
  126. procedure Getfont;
  127.  
  128. begin
  129.   FSeg := Seg(Font);
  130.   FOfs := Ofs(Font);
  131. end;
  132.  
  133. procedure cls; assembler; asm
  134.   mov es,vseg; mov di,0; mov cx,8000; mov dx,3c4h
  135.   mov ax,0f02h; out dx,ax; xor ax,ax; rep stosw;
  136. end;
  137.  
  138. procedure clsvir; assembler; asm
  139.   mov es,vseg; mov di,0; mov cx,8000; mov dx,3c4h
  140.   mov ax,0f02h; out dx,ax; xor ax,ax; rep stosw;
  141. end;
  142.  
  143. procedure flip(src,dst:word); assembler; asm { copy virt scr to visual scr }
  144.   push ds; mov es,[dst]; mov ds,[src]; xor si,si
  145.   xor di,di; mov cx,32000; rep movsw; pop ds;
  146. end;
  147.  
  148. procedure flip_led_1;
  149. var z:byte;
  150.     z1,z2:word;
  151. begin
  152.   for z:=0 to 22 do
  153.   begin
  154.     z1:=z*80;
  155.     z2:=z*160;
  156.     asm
  157.       push si
  158.       push di
  159.       push ds
  160.       push es
  161.       push cx
  162.       push dx
  163.  
  164.       mov dx,03c4h
  165.       mov ax,258
  166.       out dx,ax
  167.       mov es,[vseg]   {ES:DI}
  168.       mov ds,[ledseg] {DS:SI}
  169.       mov si,z1
  170.       mov di,z2
  171.       mov cx,40
  172.       rep movsw {}
  173.  
  174.       pop dx
  175.       pop cx
  176.       pop es
  177.       pop ds
  178.       pop di
  179.       pop si
  180.     end;
  181.   end;
  182. end;
  183.  
  184. procedure flip_led_2;
  185. var z:byte;
  186.     z1,z2:word;
  187. begin
  188.   for z:=0 to 22 do
  189.   begin
  190.     z1:=z*80+1920;
  191.     z2:=z*160;
  192.     asm
  193.       push si
  194.       push di
  195.       push ds
  196.       push es
  197.       push cx
  198.       push dx
  199.  
  200.       mov dx,03c4h
  201.       mov ax,1026
  202.       out dx,ax
  203.       mov es,[vseg]   {ES:DI}
  204.       mov ds,[ledseg] {DS:SI}
  205.       mov si,z1
  206.       mov di,z2
  207.       mov cx,40
  208.       rep movsw {}
  209.  
  210.       pop dx
  211.       pop cx
  212.       pop es
  213.       pop ds
  214.       pop di
  215.       pop si
  216.     end;
  217.   end;
  218. end;
  219.  
  220. procedure FLIP_LED;
  221. begin
  222.  flip_led_1;
  223.  flip_led_2;
  224.  led_status:=0;
  225. end;
  226.  
  227. procedure set_sprite(x,y:word;breite:word;hoehe, spriteseg, spriteoffs:word);
  228. var  addr1,addr2:word;
  229.      loop:byte;
  230.      yact,SpriteOffsAct:word;
  231.      VGAOffs:word;
  232.      LaengeAct:word;
  233.      xdiv4:word;
  234.      yphoehem1:word;
  235. begin
  236.   inc(y,49);
  237.   LaengeAct:=Breite div 8;
  238.   XDIV4:=x div 4;
  239.   SpriteOffsAct:=SpriteOffs;
  240.   yphoehem1:=y+hoehe;
  241.   for loop:=x mod 4 to (x mod 4)+3 do
  242.   begin
  243.     addr1:=SetSprite_VGAADR[loop];
  244.     asm
  245.       push ax
  246.       push si
  247.       push di
  248.       push es
  249.       push cx
  250.       push dx
  251.  
  252.       mov dx,03c4h  {1 Durchgang}
  253.       mov ax,addr1
  254.       out dx,ax
  255.  
  256.       mov ax,y
  257.       mov yact,ax
  258.       @fortodo:
  259.         push ds
  260.         mov ax,yact
  261.         mov cx,80
  262.         mul cx
  263.         add ax,XDIV4
  264.         mov VGAOffs,ax
  265.  
  266.         mov al,loop
  267.         cmp al,3
  268.         jng @l1
  269.           inc VGAOffs
  270.         @l1:
  271.         mov es,[vseg]
  272.         mov di,[VGAOffs]
  273.         mov ds,[SpriteSeg]
  274.         mov si,[SpriteOffsAct]
  275.         mov cx,[LaengeAct]
  276.         rep movsw
  277.         mov [SpriteOffsAct],si
  278.         pop ds
  279.         inc yact
  280.         mov ax,yact
  281.         cmp ax,yphoehem1
  282.       jnz @ForToDo
  283.       pop dx
  284.       pop cx
  285.       pop es
  286.       pop di
  287.       pop si
  288.       pop ax
  289.     end;
  290.   end;
  291. end;
  292.  
  293. procedure get_sprite(x,y:word;breite:byte;hoehe, spriteseg, spriteoffs:word);
  294. var  addr1,addr2:word;
  295.      loop:byte;
  296.      yact,SpriteOffsAct:word;
  297.      VGAOffs:word;
  298.      LaengeAct:word;
  299.      xdiv4:word;
  300.      yphoehem1:word;
  301. begin
  302.   inc(y,49);
  303.   LaengeAct:=Breite div 8;
  304.   XDIV4:=x div 4;
  305.   SpriteOffsAct:=SpriteOffs;
  306.   yphoehem1:=y+hoehe;
  307.   for loop:=x mod 4 to (x mod 4)+3 do
  308.   begin
  309.     addr1:=GetSprite_VGAADR[loop];
  310.     asm
  311.       push ax
  312.       push si
  313.       push di
  314.       push es
  315.       push cx
  316.       push dx
  317.  
  318.       mov dx,03ceh
  319.       mov ax,addr1
  320.       out dx,ax
  321.  
  322.       mov ax,y
  323.       mov yact,ax
  324.       @fortodo:
  325.  
  326.         push ds
  327.         mov ax,yact
  328.         mov cx,80
  329.         mul cx
  330.         add ax,XDIV4
  331.         mov VGAOffs,ax
  332.  
  333.         mov al,loop
  334.         cmp al,3
  335.         jng @l1
  336.           inc VGAOffs
  337.         @l1:
  338.  
  339.         mov ds,[vseg]
  340.         mov si,[VGAOffs]
  341.         mov es,[SpriteSeg]
  342.         mov di,[SpriteOffsAct]
  343.         mov cx,[LaengeAct]
  344.         rep movsw
  345.         mov [SpriteOffsAct],di
  346.         pop ds
  347.         inc yact
  348.         mov ax,yact
  349.         cmp ax,yphoehem1
  350.       jnz @ForToDo
  351.       pop dx
  352.       pop cx
  353.       pop es
  354.       pop di
  355.       pop si
  356.       pop ax
  357.     end;
  358.   end;
  359. end;
  360.  
  361. procedure draw_Arm_links_msk;
  362. var z1,z2,z5:word;
  363.     z6,z7:word;
  364.     x,y:longint;
  365.     z8,z9,z10:word;
  366. begin
  367.   z8:=ArmBreiteLinks*ArmHoeheLinks;
  368.   z9:=ArmBreiteLinks div 8 * 2;
  369.   z10:=ArmHoeheLinks div 2;
  370.   z5:=(arm_links_status-1)*z8;
  371.   z6:=seg(tableground3^);
  372.   z7:=seg(arm_links_msk^);
  373.  
  374.   for x:=0 to ArmBreiteLinks-1 do
  375.     asm
  376.      mov ax,word(x)
  377.      add ax,ArmXLinks
  378.      mov cx,200
  379.      mul cx
  380.      add ax,ArmYLinks
  381.      Sub ax,399
  382.      mov z1,ax
  383.  
  384.      mov ax,word(x)
  385.      mul ArmHoeheLinks
  386.      add ax,z5
  387.      mov z2,ax
  388.  
  389.       push ds
  390.       mov es,z6 {ES:DI DESTINATION}
  391.       mov di,z1
  392.       mov ds,z7 {DS:SI SOURCE}
  393.       mov si,z2
  394.       mov cx,z10
  395.       rep movsw
  396.       pop ds
  397.     end;
  398. end;
  399.  
  400. procedure draw_Arm_Rechts_msk;
  401. var z1,z2,z5:word;
  402.     z6,z7:word;
  403.     x,y:word;
  404.     z8,z9,z10:word;
  405. begin
  406.   z8:=ArmBreiteRechts*ArmHoeheRechts;
  407.   z9:=ArmBreiteRechts div 8 * 2;
  408.   z10:=ArmHoeheRechts div 2;
  409.   z5:=(arm_Rechts_status-1)*z8;
  410.   z6:=seg(tableground3^);
  411.   z7:=seg(arm_Rechts_msk^);
  412.  
  413.   for x:=0 to ArmBreiteRechts-1 do
  414.     asm
  415.      mov ax,word(x)
  416.      add ax,ArmXRechts
  417.      mov cx,200
  418.      mul cx
  419.      add ax,ArmYRechts
  420.      Sub ax,399
  421.      mov z1,ax
  422.  
  423.      mov ax,word(x)
  424.      mul ArmHoeheRechts
  425.      add ax,z5
  426.      mov z2,ax
  427.  
  428.       push ds
  429.       mov es,z6 {ES:DI DESTINATION}
  430.       mov di,z1
  431.       mov ds,z7 {DS:SI SOURCE}
  432.       mov si,z2
  433.       mov cx,z10
  434.       rep movsw
  435.       pop ds
  436.     end;
  437. end;
  438.  
  439. procedure draw_ARM_LINKS;
  440. var SpriteOffs:word;
  441. begin
  442.   SpriteOffs:=(Arm_links_status-1)*ArmBreiteLinks*ArmHoeheLinks;
  443.   Set_Sprite(ArmXLinks,ArmYLinks,ArmBreiteLinks,ArmHoeheLinks,ArmLinksSeg,SpriteOffs);
  444.   draw_arm_links_msk;
  445. end;
  446.  
  447. procedure draw_ARM_Rechts;
  448. var SpriteOffs:word;
  449. begin
  450.   SpriteOffs:=(Arm_Rechts_status-1)*ArmBreiteRechts*ArmHoeheRechts;
  451.   Set_Sprite(ArmXRechts,ArmYRechts,ArmBreiteRechts,ArmHoeheRechts,ArmRechtsSeg,SpriteOffs);
  452.   draw_arm_Rechts_msk;
  453. end;
  454.  
  455. procedure put_pixel(x,y:word; col:byte); assembler;
  456. asm
  457.   mov dx,03c4h
  458.   mov al,2
  459.   mov cx,[x]
  460.   and cx,3
  461.   mov ah,1
  462.   shl ah,cl
  463.   out dx,ax
  464.   mov es,vseg
  465.   mov ax,[y]
  466.   shl ax,4
  467.   mov di,ax
  468.   shl ax,2
  469.   add di,ax
  470.   mov dx,[x]
  471.   shr dx,2
  472.   add di,dx
  473.   mov al,[col]
  474.   mov [es:di],al
  475. end;
  476.  
  477. function get_pixel(x,y:word):byte;
  478. var addr1:word;
  479. begin
  480.   addr1:=GetSprite_VGAADR[x mod 4];
  481.   asm
  482.     push ax
  483.     push dx
  484.     mov dx,03ceh
  485.     mov ax,addr1
  486.     out dx,ax
  487.     pop dx
  488.     pop ax
  489.   end;
  490.   get_pixel:=mem[$a000:y*80+x div 4];
  491. end;
  492.  
  493. procedure put_pixel_led(x,y:word; color:byte);
  494. begin
  495.   MEM[ledseg: (x div 2) + ((x and 1)*1920)+y*80]:=color;
  496. end;
  497.  
  498. procedure set_feder;
  499. var x,y,z:word;
  500. begin
  501.   z:=0;
  502.   for y:=400+205 to 400+205+startpow div 5 do begin
  503.     for x:=federx to federx+federbreite-1 do begin
  504.       put_pixel(x,y,0);
  505.     end;
  506.   end;
  507.   for y:=federy to federy+federhoehe do begin
  508.     for x:=federx to federx+federbreite-1 do begin
  509.       put_pixel(x,y,mem[federseg:z]);
  510.       inc(z);
  511.     end;
  512.   end;
  513. end;