home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / VGAGRAPH.ZIP / GRAPH10.C < prev    next >
C/C++ Source or Header  |  1993-03-26  |  31KB  |  1,752 lines

  1. #include <dos.h>
  2. #include <string.h>
  3. #include <mem.h>
  4. #include <stdio.h>
  5. #include <io.h>
  6. #include <fcntl.h>
  7. #include <dir.h>
  8. #include <stdlib.h>
  9. #include <alloc.h>
  10. #include "low.h"
  11.  
  12.  
  13. extern char byte_tabXL[4];
  14. extern char byte_tabXR[4];
  15. extern char char_tab[16];
  16. extern char byte_tab[8];
  17. extern char pln_tab[4];
  18.  
  19. extern unsigned int BytesPerLine,FastPlace;
  20.  
  21. typedef
  22.      struct {
  23.        unsigned int dx,dy,type;
  24.        unsigned int p[4];
  25.        } Image;
  26.  
  27. void setscrline10(unsigned int w)
  28. {
  29.      w=w*BytesPerLine;
  30.      asm{
  31.       mov ax,3D4h
  32.       mov dx,ax
  33.       }
  34. waitstart:asm{
  35.       in  al,dx
  36.       test al,8
  37.       je waitstart
  38.       }
  39.       outportb(0x03D4,12);outportb(0x03D5,w>>8);
  40.       outportb(0x03D4,13);outportb(0x03D5,w);
  41.      asm{
  42.       mov ax,3D4h
  43.       mov dx,ax
  44.       }
  45. waitend:  asm{
  46.       in  al,dx
  47.       test al,1
  48.       je waitend
  49.       }
  50. }
  51. void putpixel10(int x,int y,char color)
  52. {
  53.       asm{
  54.     mov     ax,y
  55.     mov     bx,x
  56.     mov     cl,bl
  57.     push    dx
  58.     mov     dx,BytesPerLine
  59.     mul     dx
  60.     pop     dx
  61.     shr     bx,1
  62.     shr     bx,1
  63.     shr     bx,1
  64.     add     bx,ax
  65.     mov     ax,0A000h
  66.     mov     es,ax
  67.     and     cl,7
  68.     xor     cl,7
  69.     mov     ah,1
  70.     shl     ah,cl
  71.     mov     dx,3CEh
  72.     mov     al,8
  73.     out     dx,ax
  74.     mov     ax,0005h
  75.     out     dx,ax
  76.     mov     ah,0     /* Bit logic */
  77.     mov     al,3
  78.     out     dx,ax
  79.     mov     ah,color
  80.     mov     al,00h
  81.     out     dx,ax
  82.     mov     ax,0F01h
  83.     out     dx,ax
  84.     or      es:[bx],al
  85.     mov     ax,0FF08h
  86.     out     dx,ax
  87.     mov     ax,0005
  88.     out     dx,ax
  89.     mov     ax,0003
  90.     out     dx,ax
  91.     mov     ax,0001
  92.     out     dx,ax
  93.     mov     ax,0000h
  94.     out     dx,ax
  95.     }
  96. }
  97. char getpixel10(int x,int y)
  98. {
  99. char b;
  100.      asm{
  101.         mov     ax,y
  102.     mov     bx,x
  103.         mov     cl,bl
  104.         push    dx
  105.     mov     dx,BytesPerLine
  106.         mul     dx
  107.         pop     dx
  108.         shr     bx,1
  109.         shr     bx,1
  110.         shr     bx,1
  111.         add     bx,ax
  112.         mov     ax,0A000h
  113.         mov     es,ax
  114.         and     cl,7
  115.         xor     cl,7
  116.         mov     ah,1
  117.     mov     ch,ah
  118.         shl     ch,cl
  119.         mov     si,bx
  120.     xor     bl,bl
  121.     mov     dx,3CEh
  122.     mov     ax,304h
  123.     }
  124. L:
  125.     asm{
  126.     out     dx,ax
  127.     mov     bh,es:[si]
  128.     and     bh,ch
  129.     neg     bh
  130.     rol     bx,1
  131.     dec     ah
  132.     jge     L
  133.     mov     b,bl
  134.     mov     ax,0004h
  135.     out     dx,ax
  136.     }
  137.       return(b);
  138. }
  139. void clearscr10(char color)
  140. {
  141. void far *Screen;
  142.  
  143.     outport(0x03CE,color << 8);
  144.     outport(0x03CE,0x0F01);
  145.     outport(0x03CE,0x0003);
  146.     outport(0x03CE,0x0003);
  147.     Screen=MK_FP(0xA000, 0);
  148.     setmem(Screen,0xFFFF,0);
  149.     outport(0x03CE,0x0000);
  150.     outport(0x03CE,0x0001);
  151. }
  152. void line10(int x1,int y1,int x2,int y2,char color)
  153. {
  154. unsigned int VertIncr,Incr1,Incr2,Routine;
  155.  
  156.     asm{
  157.     cld
  158.     mov    dx,3CEh
  159.     mov     ax,0005h
  160.     out     dx,ax
  161.     mov     ah,color
  162.     xor    al,al
  163.     out    dx,ax
  164.     mov    ax,0F01h
  165.     out    dx,ax
  166.     mov     ah,0  /* bit logic */
  167.     mov    al,3
  168.     out    dx,ax
  169.     mov    si,BytesPerLine
  170.     mov     cx,x2
  171.     sub     cx,x1
  172.     jns    L01
  173.     neg    cx
  174.     mov     bx,x2
  175.     xchg    bx,x1
  176.     mov     x2,bx
  177.     mov     bx,y2
  178.     xchg    bx,y1
  179.     mov     y2,bx
  180.     }
  181. L01:
  182.     asm{
  183.     mov     bx,y2
  184.     sub     bx,y1
  185.     jns    L03
  186.     neg    bx
  187.     neg    si
  188.     }
  189. L03:
  190.     asm{
  191.     mov     VertIncr,si
  192.     mov     Routine,0
  193.     cmp    bx,cx
  194.     jle    L04
  195.     mov     Routine,1
  196.     xchg    bx,cx
  197.     }
  198. L04:
  199.     asm{
  200.     shl    bx,1
  201.     mov     Incr1,bx
  202.     sub    bx,cx
  203.     mov    si,bx
  204.     sub    bx,cx
  205.     mov     Incr2,bx
  206.     push    cx
  207.     mov     ax,y1
  208.     mov     bx,x1
  209.     mov     cl,bl
  210.     push    dx
  211.     mov     dx,BytesPerLine
  212.     mul     dx
  213.     pop     dx
  214.     shr     bx,1
  215.     shr     bx,1
  216.     shr     bx,1
  217.     add     bx,ax
  218.     mov     ax,0A000h
  219.     mov     es,ax
  220.     and     cl,7
  221.     xor     cl,7
  222.     mov     ah,1
  223.     mov    di,bx
  224.     shl    ah,cl
  225.     mov    bl,ah
  226.     mov    al,8
  227.     pop    cx
  228.     inc    cx
  229.     }
  230.     if (Routine!=0) goto HiSlopeLine10;
  231. LL10:
  232.     asm{
  233.     mov    ah,bl
  234.     }
  235. LL11:
  236.     asm{
  237.     or    ah,bl
  238.     ror    bl,1
  239.     jc    LL14
  240.     or    si,si
  241.     jns    LL12
  242.     add     si,Incr1
  243.     loop    LL11
  244.     out    dx,ax
  245.     or    es:[di],al
  246.     jmp     Lexit_line
  247.     }
  248. LL12:
  249.     asm{
  250.     add     si,Incr2
  251.     out    dx,ax
  252.     or    es:[di],al
  253.     add     di,VertIncr
  254.     loop     LL10
  255.     jmp     Lexit_line
  256.     }
  257. LL14:
  258.     asm{
  259.     out    dx,ax
  260.     or    es:[di],al
  261.     inc    di
  262.     or    si,si
  263.     jns    LL15
  264.     add     si,Incr1
  265.     loop    LL10
  266.     jmp     Lexit_line
  267.     }
  268. LL15:
  269.     asm{
  270.     add     si,Incr2
  271.     add     di,VertIncr
  272.     loop    LL10
  273.     jmp     Lexit_line
  274.     }
  275. HiSlopeLine10:
  276.     asm{
  277.     mov     bx,VertIncr
  278.     }
  279. LL21:
  280.     asm{
  281.     out    dx,ax
  282.     or    es:[di],al
  283.     add    di,bx
  284.     }
  285. LL22:
  286.     asm{
  287.     or    si,si
  288.     jns    LL23
  289.     add     si,Incr1
  290.     loop    LL21
  291.     jmp     Lexit_line
  292.     }
  293. LL23:
  294.     asm{
  295.     add     si,Incr2
  296.     ror    ah,1
  297.     adc    di,0
  298.     loop    LL21
  299.     }
  300. Lexit_line:
  301.     asm{
  302.     xor    ax,ax
  303.     out    dx,ax
  304.     inc    ax
  305.     out    dx,ax
  306.     mov    ax,0FF08h
  307.     out    dx,ax
  308.     mov     ax,0003h
  309.     out     dx,ax
  310.     mov     ax,0000h
  311.     out     dx,ax
  312.     mov     ax,0001h
  313.     out     dx,ax
  314.     }
  315.  
  316. }
  317. void bar10(int x,int y,int dx,int dy,int color)
  318. {
  319. unsigned int Bytes=BytesPerLine;
  320. unsigned int lx=dx;
  321. unsigned int StartOffset,i,yoff;
  322.  
  323.       asm{
  324.     mov     ax,0A000h
  325.     mov     es,ax
  326.     mov     ax,y
  327.     mul     Bytes
  328.     mov     yoff,ax
  329.     mov     dx,03CEh
  330.     mov     ax,0005h
  331.     out     dx,ax
  332.     mov     ah,0      /* bit logic */
  333.     mov     al,03h
  334.     out     dx,ax
  335.     mov     ax,0FF08h
  336.     out     dx,ax
  337.     mov     ax,0F01h
  338.     out     dx,ax
  339.     mov     ax,color
  340.     shl     ax,8
  341.     out     dx,ax
  342.     mov     bx,x
  343.         shr     bx,3
  344.         mov     si,bx
  345.         add     si,yoff
  346.         mov     bx,lx
  347.         shr     bx,3
  348.         mov     cx,dy
  349.     }
  350. L2:
  351.     asm{
  352.     push    cx
  353.     mov     cx,bx
  354.     mov     di,si
  355.     }
  356. L1:
  357.     asm{
  358.     or      es:[di],al
  359.     inc     di
  360.     loop    L1
  361.     add     si,Bytes
  362.     pop     cx
  363.     loop    L2
  364.     mov     ax,0005h
  365.     out     dx,ax
  366.     mov     ax,0003h
  367.     out     dx,ax
  368.     mov     ax,0001h
  369.     out     dx,ax
  370.     }
  371. }
  372. void bars10(int x,int y,int dx,int dy,char color)
  373. {
  374. unsigned int x2,add1,add2,row_to_adjust,count,yoff;
  375. unsigned int Bytes=BytesPerLine;
  376. unsigned int i=dy;
  377. char byte_tab1[8];
  378.  
  379.        memmove(byte_tab1,byte_tab,8);
  380.        x2=x+dx;
  381.        asm{
  382.      cld
  383.      inc    i
  384.      mov    dx,03CEh
  385.      mov    ax,0205h
  386.      out    dx,ax
  387.      mov    ah,0    /* bit logic */
  388.      mov    al,03h
  389.      out    dx,ax
  390.      mov    ax,y
  391.      mul    Bytes
  392.      mov    yoff,ax
  393.      mov    si,x
  394.      and    si,7
  395.      mov    dh,byte ptr byte_tab1[si]
  396.      mov    si,x2
  397.      inc    si
  398.      and    si,7
  399.      mov    dl,byte ptr byte_tab1[si]
  400.      not    dl
  401.      mov    si,x
  402.      mov    cl,3
  403.      shr    si,cl
  404.      mov    add1,si
  405.      mov    si,x2
  406.      inc    si
  407.      shr    si,cl
  408.      mov    add2,si
  409.      mov    ax,0A000h
  410.      mov    es,ax
  411.      mov    bx,Bytes
  412.      cmp    si,add1
  413.      jnz    More_Byte
  414.      mov    si,add1
  415.      add    si,yoff
  416.      mov    ah,8
  417.      mov    al,dl
  418.      and    al,dh
  419.      xchg   al,ah
  420.      mov    dx,03CEh
  421.      out    dx,ax
  422.      xchg   al,ah
  423.      mov    al,color
  424.      mov    cx,i
  425.      }
  426. L1:
  427.      asm{
  428.      mov    ah,es:[si]
  429.      mov    es:[si],al
  430.      add     si,bx
  431.      loop   L1
  432.      jmp    FILL_EXIT
  433.      }
  434. More_Byte:
  435.      asm{
  436.      dec    si
  437.      cmp    si,add1
  438.      jnz    More_Two_Byte
  439.      dec    bx
  440.      mov    row_to_adjust,bx
  441.      mov    bx,dx
  442.      mov    si,add1
  443.      add    si,yoff
  444.      mov    dx,03CEh
  445.      mov    al,8
  446.      out    dx,al
  447.      inc    dx
  448.      mov    ah,color
  449.      mov    cx,i
  450.      }
  451. L2:
  452.      asm{
  453.      mov    al,bh
  454.      out    dx,al
  455.      test   ch,es:[si]
  456.      mov    es:[si],ah
  457.      mov    al,bl
  458.      out    dx,al
  459.      inc    si
  460.      test   ch,es:[si]
  461.      mov    es:[si],ah
  462.      add    si,row_to_adjust
  463.      loop   L2
  464.      jmp    FILL_EXIT
  465.      }
  466. More_Two_Byte:
  467.      asm{
  468.      sub    bx,add2
  469.      mov    di,add1
  470.      add    bx,di
  471.      mov    row_to_adjust,bx
  472.      mov    bx,add2
  473.      sub    bx,di
  474.      dec    bx
  475.      mov    count,bx
  476.      mov    bx,dx
  477.      mov    dx,03CEh
  478.      mov    al,8
  479.      out    dx,al
  480.      inc    dx
  481.      mov    ah,color
  482.      add    di,yoff
  483.      cld
  484.      }
  485. L3:
  486.      asm{
  487.      mov    al,bh
  488.      out    dx,al
  489.      test   ch,es:[di]
  490.      mov    es:[di],ah
  491.      inc    di
  492.      mov    cx,count
  493.      mov    al,0FFh
  494.      out    dx,al
  495.      mov    al,ah
  496.      }
  497. L4:
  498.      asm{
  499.      test   ch,es:[di]
  500.      stosb
  501.      loop   L4
  502.      mov    al,bl
  503.      out    dx,al
  504.      test   ch,es:[di]
  505.      mov    es:[di],ah
  506.      add    di,row_to_adjust
  507.      dec    i
  508.      cmp    i,0
  509.      jne    L3
  510.      }
  511. FILL_EXIT:
  512.      asm{
  513.      dec    dx
  514.      mov    ax,0005h
  515.      out    dx,ax
  516.      mov    ax,0003h
  517.      out    dx,ax
  518.      mov    ax,0FF08h
  519.      out    dx,ax
  520.      }
  521. }
  522. void barpat10(int x,int y,int dx,int dy,char colorb1,char colorb2)
  523. {
  524. char BitMask = 0x55;
  525. unsigned int add1,add2,add3,yoff,i,lx;
  526. unsigned int l=dx;
  527. unsigned int Bytes=BytesPerLine;
  528.  
  529.        asm{
  530.          cld
  531.          push   ds
  532.          mov    ax,y
  533.          mul    Bytes
  534.          mov    yoff,ax
  535.          mov    ax,x
  536.          shr    ax,3
  537.          add    ax,yoff
  538.          mov    add1,ax
  539.          add    ax,Bytes
  540.          mov    add2,ax
  541.          mov    ax,0A000h
  542.      mov    es,ax
  543.          mov    si,add1
  544.      mov    cx,l
  545.          shr    cx,3
  546.          mov    lx,cx
  547.          mov    dx,03CEh
  548.      mov    ah,0       /* bit logic */
  549.      mov    al,03h
  550.      out    dx,ax
  551.      mov    cx,2
  552.      }
  553. L2:
  554.      asm{
  555.      push   cx
  556.      mov    ax,0205h
  557.          out    dx,ax
  558.          mov    ah,BitMask
  559.          mov    al,08h
  560.          out    dx,ax
  561.          mov    al,colorb1
  562.      mov    ah,es:[si]
  563.          mov    es:[si],al
  564.  
  565.          not    BitMask
  566.          mov    ah,BitMask
  567.          mov    al,08h
  568.          out    dx,ax
  569.          mov    al,colorb2
  570.          mov    ah,es:[si]
  571.          mov    es:[si],al
  572.  
  573.          mov    cx,lx
  574.          dec    cx
  575.          mov    ax,0105h
  576.      out    dx,ax
  577.      cmp    cx,00h
  578.      je     L5
  579.      mov    di,si
  580.      inc    si
  581.      }
  582. L1:
  583.      asm{
  584.      mov    al,es:[di]
  585.      mov    es:[si],al
  586.      inc    si
  587.      loop   L1
  588.      }
  589. L5:
  590.      asm{
  591.      mov    si,add2
  592.      pop    cx
  593.      loop   L2
  594.  
  595.      mov    cx,dy
  596.      sub    cx,01h
  597.      cmp    cx,00h
  598.      je     Fill_Exit
  599.  
  600.      mov    si,add1
  601.      add    si,Bytes
  602.      mov    bx,si
  603.      add    si,Bytes
  604.      mov    di,si
  605.      mov    si,add1
  606.      }
  607. L3:
  608.      asm{
  609.      push   cx
  610.      push   di
  611.      mov    cx,lx
  612.      }
  613. L4:
  614.      asm{
  615.      mov    al,es:[si]
  616.      mov    es:[di],al
  617.      inc    di
  618.      loop   L4
  619.      xchg   si,bx
  620.      pop    di
  621.      add    di,Bytes
  622.      pop    cx
  623.      loop   L3
  624.      }
  625. Fill_Exit:
  626.      asm{
  627.      mov    ax,0005h
  628.      out    dx,ax
  629.      mov    ax,0003h
  630.      out    dx,ax
  631.      mov    ax,0FF08h
  632.      out    dx,ax
  633.      pop    ds
  634.      }
  635. }
  636. void displaychar10(int x,int y,char s,char colorf,char colorb,char flag)
  637. {
  638. unsigned int Bytes,yoff,CellOff,dssave;
  639. char ln,Shift_C,Left_Mask,Right_Mask,ScanLine;
  640. char byte_tab1[8];
  641.  
  642.        memmove(byte_tab1,byte_tab,8);
  643.        ln=1;
  644.        asm{
  645.          cld
  646.          mov    dssave,ds
  647.      mov    dx,03CEh
  648.      mov    ah,0       /* Bit logic */
  649.      mov    al,03h
  650.      out    dx,ax
  651.      mov    ax,0205h
  652.      out    dx,ax
  653.      mov    ax,BytesPerLine
  654.      mov    Bytes,ax
  655.      mov    ax,40h
  656.      mov    ds,ax
  657.      mov    al,ds:[85h]
  658.      mov    ScanLine,al
  659.      mul    Bytes
  660.      dec    ax
  661.      mov    CellOff,ax
  662.      xor    ax,ax
  663.      mov    ds,ax
  664.      mov    bx,010Ch
  665.      lds    si,ds:[bx]
  666.      mov    ax,0A000h
  667.      mov    es,ax
  668.      mov    ax,Bytes
  669.      mul    y
  670.      mov    yoff,ax
  671.      mov    ax,x
  672.      shr    ax,3
  673.      add    yoff,ax
  674.      mov    bx,01h
  675.      mov    dx,03CEh
  676.      mov    di,x
  677.      and    di,7
  678.      jz     Byte_A
  679.      jmp    NByte_A
  680.      }
  681. Byte_A:
  682.      asm{
  683.      mov    al,8
  684.      out    dx,al
  685.      inc    dx
  686.      xor    cx,cx
  687.      mov    cl,ln
  688.      mov    di,yoff
  689.      cmp    flag,1
  690.      je     L_1
  691.      }
  692. L1:
  693.      asm{
  694.      push   cx
  695.      push   si
  696.      xchg   di,bx
  697.      mov    al,s
  698.      mul    byte  ptr  ScanLine
  699.      add    si,ax
  700.      xchg   di,bx
  701.      inc    bx
  702.      mov    cl,ScanLine
  703.      }
  704. L11:
  705.      asm{
  706.      lodsb
  707.      out    dx,al
  708.      mov    ah,colorf
  709.          cmp    ah,es:[di]
  710.          mov    es:[di],ah
  711.          add    di,Bytes
  712.          loop   L11
  713.          sub    di,CellOff
  714.          pop    si
  715.          pop    cx
  716.          loop   L1
  717.      jmp    STR_OUT
  718.      }
  719. L_1:
  720.      asm{
  721.      push   cx
  722.      push   si
  723.      xchg   di,bx
  724.      mov    al,s
  725.      mul    byte  ptr  ScanLine
  726.      add    si,ax
  727.      xchg   di,bx
  728.      inc    bx
  729.      mov    cl,ScanLine
  730.      }
  731. L_11:
  732.      asm{
  733.      lodsb
  734.      out    dx,al
  735.      mov    ah,colorf
  736.      test   ah,es:[di]
  737.      mov    es:[di],ah
  738.      not    al
  739.      out    dx,al
  740.      mov    ah,colorb
  741.      test   ah,es:[di]
  742.      mov    es:[di],ah
  743.      add    di,Bytes
  744.      loop   L_11
  745.      sub    di,CellOff
  746.      pop    si
  747.      pop    cx
  748.      loop   L_1
  749.      jmp    STR_OUT
  750.      }
  751. NByte_A:
  752.      asm{
  753.      mov   ax,di
  754.      mov   Shift_C,al
  755.      push  ds
  756.      mov   ax,dssave
  757.      mov   ds,ax
  758.      mov   al,byte ptr byte_tab1[di]
  759.      pop   ds
  760.      mov   Left_Mask,al
  761.      not   al
  762.      mov   Right_Mask,al
  763.      mov   al,8
  764.      out   dx,al
  765.      inc   dx
  766.      xor   cx,cx
  767.      mov   cl,ln
  768.      mov   di,yoff
  769.      cmp   flag,01h
  770.      je    L_2
  771.      }
  772. L2:
  773.      asm{
  774.      push  cx
  775.      push  si
  776.      xchg  di,bx
  777.      mov   al,s
  778.      mul   ScanLine
  779.      add   si,ax
  780.      xchg  di,bx
  781.      inc   bx
  782.      mov   cl,ScanLine
  783.      }
  784. L22:
  785.      asm{
  786.      push  cx
  787.      mov   al,ds:[si]
  788.      mov   cl,Shift_C
  789.      ror   al,cl
  790.      and   al,Left_Mask
  791.      out   dx,al
  792.      mov   ah,es:[di]
  793.      mov   ah,colorf
  794.      mov   es:[di],ah
  795.      mov   al,ds:[si]
  796.      ror   al,cl
  797.      and   al,Right_Mask
  798.      out   dx,al
  799.      mov   ah,es:[di+1]
  800.      mov   ah,colorf
  801.      mov   es:[di+1],ah
  802.      inc   si
  803.      add   di,Bytes
  804.      pop   cx
  805.      loop  L22
  806.      sub   di,CellOff
  807.      pop   si
  808.      pop   cx
  809.      loop  L2
  810.      jmp   STR_OUT
  811.      }
  812. L_2:
  813.      asm{
  814.      push  cx
  815.      push  si
  816.      xchg  di,bx
  817.      mov   al,s
  818.      mul   ScanLine
  819.      add   si,ax
  820.      xchg  di,bx
  821.      inc   bx
  822.      mov   cl,ScanLine
  823.      }
  824. L_22:
  825.      asm{
  826.      push  cx
  827.      mov   al,ds:[si]
  828.      mov   cl,Shift_C
  829.      ror   al,cl
  830.      and   al,Left_Mask
  831.      out   dx,al
  832.      mov   ah,es:[di]
  833.      mov   ah,colorf
  834.      mov   es:[di],ah
  835.      not   al
  836.      and   al,Left_Mask
  837.      out   dx,al
  838.      mov   ah,es:[di]
  839.      mov   ah,colorb
  840.      mov   es:[di],ah
  841.      mov   al,ds:[si]
  842.      ror   al,cl
  843.      and   al,Right_Mask
  844.      out   dx,al
  845.      mov   ah,es:[di+1]
  846.      mov   ah,colorf
  847.      mov   es:[di+1],ah
  848.      not   al
  849.      and   al,Right_Mask
  850.      out   dx,al
  851.      mov   ah,es:[di+1]
  852.      mov   ah,colorb
  853.      mov   es:[di+1],ah
  854.      inc   si
  855.      add   di,Bytes
  856.      pop   cx
  857.      loop  L_22
  858.      sub   di,CellOff
  859.      pop   si
  860.      pop   cx
  861.      loop  L_2
  862.      }
  863. STR_OUT:
  864.      asm{
  865.      mov   dx,03CEh
  866.      mov   ax,0005h
  867.      out   dx,ax
  868.      mov   ax,0003h
  869.      out   dx,ax
  870.      mov   ax,0FF08h
  871.      out   dx,ax
  872.      mov   ds,dssave
  873.      }
  874. }
  875.  
  876. void lineh10(int x,int y,int dx,char color1,char color2)
  877. {
  878. char BIT_MASK = 0x55,b;
  879. unsigned int yoff,x2,add1,add2;
  880. unsigned int l=dx;
  881. char byte_tab1[8];
  882.  
  883.        if ((y%2)==0){b=color1;color1=color2;color2=b;}
  884.        memmove(byte_tab1,byte_tab,8);
  885.        asm{
  886.      cld
  887.      mov   ax,x
  888.      add   ax,l
  889.      mov   x2,ax
  890.      mov   ax,y
  891.      mul   BytesPerLine
  892.      mov   yoff,ax
  893.      mov   dx,03CEh
  894.      mov   ah,0     /* Bit logic */
  895.      mov   al,03h
  896.      out   dx,ax
  897.      mov   ax,0205h
  898.      out   dx,ax
  899.  
  900.      mov    si,x
  901.      and    si,7
  902.      mov    bh,byte ptr byte_tab1[si]
  903.      mov    si,x2
  904.      inc    si
  905.          and    si,7
  906.      mov    bl,byte ptr byte_tab1[si]
  907.      not    bl
  908.      mov    si,x
  909.      shr    si,3
  910.      add    si,yoff
  911.      mov    add1,si
  912.      mov    si,x2
  913.      inc    si
  914.      shr    si,3
  915.      add    si,yoff
  916.      mov    add2,si
  917.      mov    ax,0A000h
  918.      mov    es,ax
  919.      cmp    si,add1
  920.      jnz    More_Byte
  921.          mov    si,add1
  922.          mov    ah,bh
  923.          and    ah,bl
  924.          and    ah,BIT_MASK
  925.          mov    al,08h
  926.          out    dx,ax
  927.          mov    ah,color1
  928.          test   al,es:[si]
  929.          mov    es:[si],ah
  930.          not    BIT_MASK
  931.          mov    ah,bh
  932.          and    ah,bl
  933.          and    ah,BIT_MASK
  934.          out    dx,ax
  935.      mov    ah,color2
  936.          test   al,es:[si]
  937.      mov    es:[si],ah
  938.          not    BIT_MASK
  939.      jmp    LINE_END
  940.      }
  941. More_Byte:
  942.      asm{
  943.      dec    si
  944.          cmp    si,add1
  945.          jnz    More_Two_Byte
  946.          mov    al,08h
  947.      mov    cx,02h
  948.      }
  949. L__:
  950.      asm{
  951.      mov    ah,bh
  952.      and    ah,BIT_MASK
  953.      out    dx,ax
  954.      mov    ah,color1
  955.      test   al,es:[si]
  956.      mov    es:[si],ah
  957.      not    BIT_MASK
  958.      mov    ah,bh
  959.      and    ah,BIT_MASK
  960.      out    dx,ax
  961.      mov    ah,color2
  962.      test   al,es:[si]
  963.      mov    es:[si],ah
  964.      inc    si
  965.          not    BIT_MASK
  966.          xchg   bh,bl
  967.          loop   L__
  968.          not    BIT_MASK
  969.      jmp    LINE_END
  970.      }
  971. More_Two_Byte:
  972.      asm{
  973.      mov    si,add1
  974.          mov    al,08h
  975.      mov    ah,bh
  976.          and    ah,BIT_MASK
  977.      out    dx,ax
  978.          mov    ah,color1
  979.          test   al,es:[si]
  980.          mov    es:[si],ah
  981.          mov    ah,bh
  982.          not    BIT_MASK
  983.          and    ah,BIT_MASK
  984.          out    dx,ax
  985.          mov    ah,color2
  986.          test   al,es:[si]
  987.          mov    es:[si],ah
  988.          not    BIT_MASK
  989.          mov    si,add2
  990.          mov    al,08h
  991.          mov    ah,bl
  992.      and    ah,BIT_MASK
  993.          out    dx,ax
  994.          mov    ah,color1
  995.      test   al,es:[si]
  996.          mov    es:[si],ah
  997.      mov    ah,bl
  998.          not    BIT_MASK
  999.          and    ah,BIT_MASK
  1000.          out    dx,ax
  1001.      mov    ah,color2
  1002.      test   al,es:[si]
  1003.      mov    es:[si],ah
  1004.      not    BIT_MASK
  1005.      mov    si,add1
  1006.      inc    si
  1007.      mov    ah,BIT_MASK
  1008.      out    dx,ax
  1009.      mov    ah,color1
  1010.      test   al,es:[si]
  1011.      mov    es:[si],ah
  1012.          not    BIT_MASK
  1013.          mov    ah,BIT_MASK
  1014.          out    dx,ax
  1015.      mov    ah,color2
  1016.          test   al,es:[si]
  1017.      mov    es:[si],ah
  1018.          mov    ax,0105h
  1019.          out    dx,ax
  1020.          inc    si
  1021.      cmp    si,add2
  1022.      je     LINE_END
  1023.      push   ds
  1024.      mov    ax,0A000h
  1025.      mov    ds,ax
  1026.      mov    di,si
  1027.      dec    si
  1028.      }
  1029. L_1:
  1030.      asm{
  1031.      movsb
  1032.      cmp    di,add2
  1033.      jnz    L_1
  1034.      pop    ds
  1035.      }
  1036. LINE_END:
  1037.      asm{
  1038.      mov    ax,0005h
  1039.          out    dx,ax
  1040.          mov    ax,0FF08h
  1041.          out    dx,ax
  1042.          mov    ax,0003h
  1043.          out    dx,ax
  1044.      }
  1045. }
  1046. void linev10(int x,int y,int dy,char color1,char color2)
  1047. {
  1048.        asm{
  1049.          mov    cx,x
  1050.          shr    cx,3
  1051.          mov    ax,y
  1052.          mul    BytesPerLine
  1053.          add    ax,cx
  1054.          mov    si,ax
  1055.      mov    cl,byte ptr x
  1056.          and    cl,7
  1057.      xor    cl,7
  1058.          mov    bh,01h
  1059.          shl    bh,cl
  1060.          mov    cx,dy
  1061.          inc    cx
  1062.          mov    ax,0A000h
  1063.          mov    es,ax
  1064.          mov    dx,03CEh
  1065.          mov    ax,0205h
  1066.          out    dx,ax
  1067.          mov    al,03h
  1068.      mov    ah,0      /* Bit logic */
  1069.      out    dx,ax
  1070.          mov    al,08h
  1071.          mov    ah,bh
  1072.          out    dx,ax
  1073.          mov    bh,color1
  1074.      mov    bl,color2
  1075.      }
  1076. L1:
  1077.      asm{
  1078.      test   al,es:[si]
  1079.          mov    es:[si],bh
  1080.          xchg   bh,bl
  1081.          add    si,BytesPerLine
  1082.          loop   L1
  1083.          mov    ax,0005h
  1084.          out    dx,ax
  1085.          mov    ah,0003h
  1086.      out    dx,ax
  1087.          mov    ax,0FF08h
  1088.          out    dx,ax
  1089.      }
  1090. }
  1091. void  barpats10(int x,int y,int dx,int dy,char color1,char color2)
  1092. {
  1093. char  BIT_MASK = 0x55;
  1094. unsigned int l=dx;
  1095. unsigned int x2,yoff,add1,add2,add0,lx;
  1096. char Mask1,Mask2,MaskL1,MaskL2,MaskR1,MaskR2,i;
  1097. char byte_tab1[8];
  1098.  
  1099.        memmove(byte_tab1,byte_tab,8);
  1100.        asm{
  1101.      mov   lx,01h
  1102.      mov   i,0
  1103.      mov   ax,x
  1104.      add   ax,l
  1105.          mov   x2,ax
  1106.      mov   ax,y
  1107.          mul   BytesPerLine
  1108.          mov   yoff,ax
  1109.          mov   dx,03CEh
  1110.          mov   ax,0205h
  1111.      out   dx,ax
  1112.      mov   ah,0  /* bit logic */
  1113.      mov   al,03h
  1114.      out   dx,ax
  1115.      mov    si,x
  1116.      and    si,7
  1117.      mov    bh,byte ptr byte_tab1[si]
  1118.      mov    si,x2
  1119.      inc    si
  1120.      and    si,7
  1121.      mov    bl,byte ptr byte_tab1[si]
  1122.      not    bl
  1123.      mov    si,x
  1124.          shr    si,3
  1125.      add    si,yoff
  1126.      mov    add1,si
  1127.          mov    si,x2
  1128.          inc    si
  1129.          shr    si,3
  1130.      add    si,yoff
  1131.      mov    add2,si
  1132.          mov    ax,0A000h
  1133.      mov    es,ax
  1134.      cmp    si,add1
  1135.      jnz    More_Byte
  1136.      mov    si,add1
  1137.      mov    ah,bh
  1138.      and    ah,bl
  1139.      mov    bh,ah
  1140.      and    bh,BIT_MASK
  1141.      not    BIT_MASK
  1142.      and    ah,BIT_MASK
  1143.          mov    bl,ah
  1144.          mov    cx,dy
  1145.          mov    al,08h
  1146.      mov    ah,bh
  1147.          out    dx,ax
  1148.          mov    al,color1
  1149.      mov    ah,color2
  1150.      }
  1151. L1:
  1152.      asm{
  1153.      test   al,es:[si]
  1154.      mov    es:[si],al
  1155.      add    si,BytesPerLine
  1156.      xchg   al,ah
  1157.          loop   L1
  1158.      mov    si,add1
  1159.          mov    al,08h
  1160.      mov    ah,bl
  1161.      out    dx,ax
  1162.          mov    cx,dy
  1163.          mov    al,color2
  1164.      mov    ah,color1
  1165.      }
  1166. L2:
  1167.      asm{
  1168.      test   al,es:[si]
  1169.      mov    es:[si],al
  1170.      add    si,BytesPerLine
  1171.      xchg   al,ah
  1172.      loop   L2
  1173.      jmp    FILL_END
  1174.      }
  1175. More_Byte:
  1176.      asm{
  1177.      mov    ah,bh
  1178.      and    ah,BIT_MASK
  1179.      mov    MaskL1,ah
  1180.      mov    ah,bh
  1181.      not    BIT_MASK
  1182.      and    ah,BIT_MASK
  1183.      mov    MaskL2,ah
  1184.      mov    ah,bl
  1185.      and    ah,BIT_MASK
  1186.      mov    MaskR2,ah
  1187.      mov    ah,bl
  1188.      not    BIT_MASK
  1189.      and    ah,BIT_MASK
  1190.      mov    MaskR1,ah
  1191.      mov    Mask1,ah
  1192.      mov    ah,MaskR2
  1193.      mov    Mask2,ah
  1194.      mov    si,add2
  1195.      mov    add0,si
  1196.      }
  1197. L__1:
  1198.      asm{
  1199.      mov    cx,dy
  1200.      inc    cx
  1201.      mov    al,08h
  1202.      mov    ah,Mask1
  1203.      out    dx,ax
  1204.      mov    al,color1
  1205.      mov    ah,color2
  1206.      }
  1207. L_1:
  1208.      asm{
  1209.      test   al,es:[si]
  1210.      mov    es:[si],al
  1211.      add    si,BytesPerLine
  1212.      xchg   al,ah
  1213.      loop   L_1
  1214.  
  1215.      mov    si,add0
  1216.      mov    cx,dy
  1217.      inc    cx
  1218.      mov    al,08h
  1219.      mov    ah,Mask2
  1220.      out    dx,ax
  1221.      mov    al,color2
  1222.      mov    ah,color1
  1223.      }
  1224. L_2:
  1225.      asm{
  1226.      test   al,es:[si]
  1227.      mov    es:[si],al
  1228.      add    si,BytesPerLine
  1229.      xchg   al,ah
  1230.      loop   L_2
  1231.      inc    i
  1232.      cmp    i,02h
  1233.      je     L__C
  1234.      mov    ah,MaskL1
  1235.      mov    Mask1,ah
  1236.      mov    ah,MaskL2
  1237.      mov    Mask2,ah
  1238.      mov    si,add1
  1239.      mov    add0,si
  1240.      jmp    L__1
  1241.      }
  1242. L__C:
  1243.      asm{
  1244.      mov    si,add1
  1245.      inc    si
  1246.      cmp    si,add2
  1247.          je     FILL_END
  1248.          mov    ah,BIT_MASK
  1249.      mov    al,08h
  1250.          out    dx,ax
  1251.      mov    ah,color1
  1252.          test   es:[si],al
  1253.          mov    es:[si],ah
  1254.          not    BIT_MASK
  1255.      mov    ah,BIT_MASK
  1256.          out    dx,ax
  1257.          mov    ah,color2
  1258.      test   al,es:[si]
  1259.          mov    es:[si],ah
  1260.      add    si,BytesPerLine
  1261.      mov    ah,BIT_MASK
  1262.          mov    al,08h
  1263.          out    dx,ax
  1264.      mov    ah,color1
  1265.      test   es:[si],al
  1266.      mov    es:[si],ah
  1267.          not    BIT_MASK
  1268.          mov    ah,BIT_MASK
  1269.      out    dx,ax
  1270.          mov    ah,color2
  1271.      test   al,es:[si]
  1272.          mov    es:[si],ah
  1273.          mov    ax,0105h
  1274.          out    dx,ax
  1275.  
  1276.      mov    si,add1
  1277.          inc    si
  1278.      mov    di,si
  1279.          inc    di
  1280.      cmp    di,add2
  1281.      je     LC
  1282.      }
  1283. L___1:
  1284.      asm{
  1285.      mov    al,es:[si]
  1286.      mov    es:[di],al
  1287.      inc    di
  1288.      cmp    di,add2
  1289.          jnz    L___1
  1290.      mov    add0,di
  1291.      sub    di,si
  1292.          mov    lx,di
  1293.      mov    di,add0
  1294.      add    di,BytesPerLine
  1295.      mov    add0,di
  1296.      add    si,BytesPerLine
  1297.          mov    di,si
  1298.      inc    di
  1299.      }
  1300. L___2:
  1301.      asm{
  1302.      mov    al,es:[si]
  1303.      mov    es:[di],al
  1304.      inc    di
  1305.      cmp    di,add0
  1306.      jnz    L___2
  1307.      }
  1308. LC:
  1309.      asm{
  1310.      cmp    dy,02h
  1311.      je     FILL_END
  1312.      mov    cx,dy
  1313.      sub    cx,01h
  1314.      mov    si,add1
  1315.      inc    si
  1316.      add    si,BytesPerLine
  1317.      mov    add0,si
  1318.      mov    di,si
  1319.      add    di,BytesPerLine
  1320.      mov    si,add1
  1321.      inc    si
  1322.      mov    bx,add0
  1323.      }
  1324. L___:
  1325.      asm{
  1326.      push   cx
  1327.      push   di
  1328.      mov    cx,lx
  1329.      }
  1330. L_I:
  1331.      asm{
  1332.      mov    al,es:[si]
  1333.      mov    es:[di],al
  1334.      inc    di
  1335.      loop   L_I
  1336.      xchg   si,bx
  1337.      pop    di
  1338.      add    di,BytesPerLine
  1339.      pop    cx
  1340.      loop   L___
  1341.      }
  1342. FILL_END:
  1343.      asm{
  1344.      mov    ax,0005h
  1345.      out    dx,ax
  1346.      mov    ax,0003h
  1347.      out    dx,ax
  1348.      mov    ax,0FF08h
  1349.      out    dx,ax
  1350.      }
  1351. }
  1352. void setcol10(char colorf,char colorb,unsigned int place)
  1353. {
  1354.  
  1355.       FastPlace=place;
  1356.       asm{
  1357.     push    ds
  1358.     mov     ax,FastPlace
  1359.         push    ax
  1360.         mov     ax,40h
  1361.         mov     ds,ax
  1362.         mov     cx,ds:[85h]
  1363.         xor     ax,ax
  1364.         mov     ds,ax
  1365.         mov     bx,43h*4
  1366.     lds     si,ds:[bx]
  1367.         mov     ax,0A000h
  1368.         mov     es,ax
  1369.         pop     ax
  1370.         mov     di,ax
  1371.         mov     al,0h
  1372.     mov     ah,1
  1373.         mul     cx
  1374.         mov     cx,ax
  1375.     mov     bl,colorf
  1376.         mov     bh,colorb
  1377.         mov     dx,3CEh
  1378.         mov     ax,0A05h
  1379.         out     dx,ax
  1380.         mov     ax,0003h
  1381.         out     dx,ax
  1382.         mov     ax,0007
  1383.         out     dx,ax
  1384.     mov     al,8
  1385.     }
  1386. L1:
  1387.     asm{
  1388.     mov     ah,ds:[si]
  1389.         out     dx,ax
  1390.         and     es:[di],bl
  1391.         not     ah
  1392.     out     dx,ax
  1393.         and     es:[di],bh
  1394.         inc     di
  1395.     inc     si
  1396.         loop    L1
  1397.         mov     ax,0FF08h
  1398.         out     dx,ax
  1399.         mov     ax,0005
  1400.         out     dx,ax
  1401.         mov     ax,0003
  1402.         out     dx,ax
  1403.         mov     ax,0F07h
  1404.         out     dx,ax
  1405.         pop     ds
  1406.     }
  1407. }
  1408. void fasttext10(int x,int y,char *s)
  1409. {
  1410. char *strs;
  1411. char b,i;
  1412. unsigned int w,ScanLine,wd;
  1413.  
  1414.        w=BytesPerLine;
  1415.        strcpy(strs,s);
  1416.        asm{
  1417.     cld
  1418.     push    ds
  1419.     mov     ax,FastPlace
  1420.     push    ax
  1421.     mov     dx,3CEh
  1422.     mov     ax,0105h
  1423.     out     dx,ax
  1424.     mov     ax,0003h
  1425.     out     dx,ax
  1426.     mov     ax,40h
  1427.     mov     ds,ax
  1428.     mov     ax,ds:[85h]
  1429.     mov     ScanLine,ax
  1430.     mov     ax,0A000h
  1431.     mov     es,ax
  1432.     mov     bx,x
  1433.     mov     ax,y
  1434.     shr     bx,1
  1435.     shr     bx,1
  1436.     shr     bx,1
  1437.     mov     dx,w
  1438.     mul     dx
  1439.     add     ax,bx
  1440.     mov     di,ax
  1441.     mov     dx,ax
  1442.     mov     bx,w
  1443.     mov     wd,dx
  1444.     }
  1445.       for (i=0;i<strlen(strs);i++)
  1446.       {
  1447.        b=strs[i];
  1448.        asm{
  1449.     mov     dx,wd
  1450.     mov     ax,0A000h
  1451.     mov     es,ax
  1452.     mov     ax,0A000h
  1453.     mov     ds,ax
  1454.     pop     ax
  1455.     mov     si,ax
  1456.     push    ax
  1457.     mov     al,b
  1458.         mov     cx,ScanLine
  1459.         mul     cl
  1460.     add     si,ax
  1461.     mov     di,dx
  1462.     }
  1463. L1:
  1464.     asm{
  1465.     movsb
  1466.     dec     di
  1467.     add     di,w
  1468.     loop    L1
  1469.     inc     dx
  1470.     mov     wd,dx
  1471.     }
  1472.       }
  1473.        asm{
  1474.     mov     dx,03CEh
  1475.     mov     ax,0005h
  1476.     out     dx,ax
  1477.     pop     ax
  1478.     pop     ds
  1479.     }
  1480. }
  1481. void UnLockEGA()
  1482. {
  1483.     outport(0x03CE,0x0000);
  1484.     outport(0x03CE,0x0001);
  1485.     outport(0x03CE,0x0002);
  1486.     outport(0x03CE,0x0003);
  1487.     outport(0x03CE,0x0004);
  1488.     outport(0x03CE,0x0805);
  1489.     outport(0x03CE,0x0506);
  1490.     outport(0x03CE,0x0f07);
  1491.     outport(0x03CE,0xff08);
  1492.     outportb(0x03C4,0x02);
  1493. }
  1494. void LockEGA()
  1495. {
  1496.     outport(0x03CE,0x0003);
  1497.     outport(0x03CE,0x0004);
  1498.     outport(0x03CE,0x0005);
  1499.     outport(0x03CE,0x0506);
  1500.     outport(0x03CE,0x0f07);
  1501.     outport(0x03CE,0xff08);
  1502.     outport(0x03C4,0x0f02);
  1503. }
  1504. char getimageram10(unsigned int x,unsigned int y,unsigned int dx,
  1505.            unsigned int dy,Image *W)
  1506. {
  1507. unsigned int i,j,k,scrofs,xend;
  1508. long t,l;
  1509. char s[20];
  1510.     xend=x+dx;
  1511.     x=x >> 3;
  1512.     if (xend % 8 != 0) xend=((xend >> 3) << 3)+8;
  1513.     dx=xend-x;
  1514.     W->dx=dx >> 3;
  1515.     W->dy=dy;
  1516.     t=coreleft();
  1517.  
  1518.     l=(W->dy+1)*(W->dx)*(long)(4);
  1519.     t=l-t+10000;
  1520.     if (t>0) return(1);
  1521.  
  1522.     for (i=0;i<=3;i++)
  1523.     t=allocmem(((W->dx)*(W->dy+1))/16+1,&W->p[i]);
  1524.  
  1525.     outport(0x03CE,0x0005);
  1526.     outportb(0x03CE,4);
  1527.     k=y*BytesPerLine+x;
  1528.  
  1529.     for (i=0;i<=3;i++){
  1530.         scrofs=k;
  1531.         outportb(0x03CF,i);
  1532.     for (j=0;j<=W->dy;j++){
  1533.         move(0xA000,scrofs,W->p[i],j*W->dx,W->dx);
  1534.         scrofs=scrofs+BytesPerLine;
  1535.         }
  1536.         }
  1537.     W->type=0;
  1538.     return(0);
  1539. }
  1540. void putimageram10(unsigned int x,unsigned int y,Image W,char Restore)
  1541. {
  1542. unsigned int  i,j,scrofs;
  1543.  
  1544.     scrofs=y*BytesPerLine+(x >> 3);
  1545.     UnLockEGA();
  1546.     for (i=0;i<=W.dy;i++)
  1547.         {
  1548.     for (j=0;j<=3;j++)
  1549.         {
  1550.         outportb(0x03C5,1 << j);
  1551.         move(W.p[j],i*W.dx,0xA000,scrofs,W.dx);
  1552.         }
  1553.         scrofs=scrofs+BytesPerLine;
  1554.         }
  1555.     LockEGA();
  1556.     if (Restore==0) for (i=0;i<=3;i++) freemem(W.p[i]);
  1557.  
  1558. }
  1559. char getimagedisk10(unsigned int x,unsigned int y,unsigned int dx,unsigned int dy,
  1560.            Image *W)
  1561. {
  1562. unsigned int  k,i,j,n,bufsize,xend,Buff,scrofs;
  1563. long t0,ll,l;
  1564. int   f;
  1565. struct dfree free;
  1566. long avail;
  1567. int drive;
  1568. char Name[12];
  1569. void far *buff;
  1570. char *buffer;
  1571.  
  1572.     xend=x+dx;
  1573.     x=x >> 3;
  1574.     if (xend % 8 != 0) xend=((xend >> 3) << 3)+8;
  1575.     dx=xend-x;
  1576.     W->dx=dx >> 3;
  1577.     W->dy=dy;
  1578.     l=(W->dy+1)*(W->dx)*(long)(4);
  1579.  
  1580.  
  1581.     drive = getdisk()+1;
  1582.     getdfree(drive, &free);
  1583.     if (free.df_sclus == 0xFFFF) return(1);
  1584.     avail =  (long)free.df_avail*(long)free.df_bsec*(long)free.df_sclus;
  1585.  
  1586.     l=avail-l;
  1587.     if (l<10000) return(1);
  1588.     randomize();
  1589.     W->p[0]=rand();
  1590.  
  1591.     itoa(W->p[0],Name,10);
  1592.     _fmode=O_BINARY;
  1593.     if ((f=creat(Name,0x0100 | 0x0080))==NULL) return(1);
  1594.     l=coreleft();
  1595.     if (l>0xFFF0) bufsize=0xFFF0; else bufsize=l;
  1596.     bufsize=(bufsize-(bufsize % (W->dx*4)));
  1597.     if (l>80) t0=allocmem(bufsize/16+1,&Buff); else return(1);
  1598.     //if (t0!=-1) return(1);
  1599.  
  1600.     buff=MK_FP(Buff,0);
  1601.     scrofs=y*BytesPerLine+x;
  1602.     outport(0x03CE,0x0005);
  1603.     outportb(0x03CE,4);
  1604.  
  1605.     k=0;
  1606.     for (i=0;i<=W->dy;i++)
  1607.         {
  1608.     for (j=0;j<=3;j++)
  1609.         {
  1610.         outportb(0x03CF,j);
  1611.         move(0xA000,scrofs,Buff,k,W->dx);
  1612.         k=k+W->dx;
  1613.         }
  1614.         if (k==bufsize)
  1615.            {
  1616.            write(f,buff,bufsize);
  1617.            k=0;
  1618.            }
  1619.            scrofs=scrofs+BytesPerLine;
  1620.         }
  1621.         if (k!=0) write(f,buff,k);
  1622.         freemem(Buff);
  1623.         close(f);
  1624.         W->type=1;
  1625.         return(0);
  1626. }
  1627. void putimagedisk10(unsigned int x,unsigned int y,Image W,char Restore)
  1628. {
  1629. unsigned int  k,i,j,bufsize,scrofs,Buff;
  1630. long t0,l;
  1631. int  f,b;
  1632. char Name[12];
  1633. void far *buff;
  1634.  
  1635.        itoa(W.p[0],Name,10);
  1636.        _fmode=O_BINARY;
  1637.        if ((f=open(Name,0x0100 | 0x0080))==NULL) exit(0);
  1638.        l= coreleft();
  1639.        if (l>0xFFF0) bufsize=0xFFF0; else bufsize=l;
  1640.        bufsize=(bufsize-(bufsize % (W.dx*4)));
  1641.        if (l>80) t0=allocmem(bufsize/16+1,&Buff); else exit(0);
  1642.        if (t0!=-1) exit(0);
  1643.        buff=MK_FP(Buff,0);
  1644.        scrofs=y*BytesPerLine+(x >> 3);
  1645.        read(f,buff,bufsize);
  1646.        k=0;
  1647.        UnLockEGA();
  1648.        for (i=0;i<=W.dy;i++)
  1649.            {
  1650.        for (j=0;j<=3;j++)
  1651.            {
  1652.            outportb(0x03C5,1 << j);
  1653.            move(Buff,k,0xA000,scrofs,W.dx);
  1654.            k=k+W.dx;
  1655.            }
  1656.            if (k==bufsize)
  1657.           {
  1658.            read(f,buff,bufsize);
  1659.            k=0;
  1660.            }
  1661.            scrofs=scrofs+BytesPerLine;
  1662.            }
  1663.          LockEGA();
  1664.          freemem(Buff);
  1665.          close(f);
  1666.          if (Restore==0) remove(Name);
  1667. }
  1668. char getimage10(unsigned int x,unsigned int y,unsigned int dx,unsigned int dy,Image *W)
  1669. {
  1670.     if (getimageram10(x,y,dx,dy,W)==0) return(0);
  1671.     return(getimagedisk10(x,y,dx,dy,W));
  1672. }
  1673. void putimage10(unsigned int x,unsigned int y,Image W,char Restore)
  1674. {
  1675.      if (W.type==0) putimageram10(x,y,W,Restore);
  1676.      if (W.type==1) putimagedisk10(x,y,W,Restore);
  1677. }
  1678. void windowshadow10(int x,int y,int dx,int dy)
  1679. {
  1680. unsigned int i,k,j,x1,y1,ofsp,ofspp;
  1681. char b;
  1682.  
  1683.       x=(x >> 3) << 3;
  1684.       dx=(dx >> 3) << 3;
  1685.       x1=x+dx;
  1686.       y1=y+dy;
  1687.       x=x+10;
  1688.       y=y+10;
  1689.       ofsp=y*BytesPerLine+(x1 >> 3);
  1690.       outport(0x03CE,0x0005);
  1691.       outport(0x03CE,0x0007);
  1692.       outport(0x03CE,0x0003);
  1693.       for (i=1;i<=dy;i++)
  1694.       {
  1695.       outport(0x03CE,0x0005);
  1696.       outport(0x03CE,0x0304);
  1697.       b=peekb(0xA000,ofsp);
  1698.       outport(0x03CE,0x0A05);
  1699.       outportb(0x03CE,0x08);
  1700.       outportb(0x03CF,b);
  1701.       pokeb(0xA000,ofsp,peekb(0xA000,ofsp) & 7);
  1702.       outportb(0x03CE,0x08);
  1703.       outportb(0x03CF,~b);
  1704.       pokeb(0xA000,ofsp,peekb(0xA000,ofsp) & 8);
  1705.       ofsp=ofsp+BytesPerLine;
  1706.       }
  1707.       ofsp=(y1+1)*BytesPerLine+(x >> 3);
  1708.       ofspp=ofsp;
  1709.       outport(0x03CE,0x0005);
  1710.       outport(0x03CE,0x0007);
  1711.       outport(0x03CE,0x0003);
  1712.       dx=(dx >> 3)-1;
  1713.       for (i=1;i<=9;i++)
  1714.       {
  1715.       for (j=1;j<=dx;j++)
  1716.       {
  1717.       outport(0x03CE,0x0005);
  1718.       outport(0x03CE,0x0304);
  1719.       b=peekb(0xA000,ofsp);
  1720.       outport(0x03CE,0x0A05);
  1721.       outportb(0x03CE,0x08);
  1722.       outportb(0x03CF,b);
  1723.       pokeb(0xA000,ofsp,peekb(0xA000,ofsp) & 7);
  1724.       outportb(0x03CE,0x08);
  1725.       outportb(0x03CF,~b);
  1726.       pokeb(0xA000,ofsp,peekb(0xA000,ofsp) & 8);
  1727.       ofsp=ofsp+1;
  1728.       }
  1729.       ofspp=ofspp+BytesPerLine;
  1730.       ofsp=ofspp;
  1731.       }
  1732.       LockEGA();
  1733. }
  1734.  
  1735. void screentoscreen10(int x,int y,int dx,int dy,int x1,int y1)
  1736. {
  1737. unsigned int ofsp,ofsp1,i,j;
  1738.  
  1739.      outport(0x03CE,0x0105);
  1740.      x=x >> 3;
  1741.      x1=x1 >> 3;
  1742.      dx=dx >> 3;
  1743.      ofsp=y*BytesPerLine+x;
  1744.      ofsp1=y1*BytesPerLine+x1;
  1745.      for (i=y;i<=(y+dy);i++)
  1746.      {
  1747.      move(0xA000,ofsp,0xA000,ofsp1,dx);
  1748.      ofsp=ofsp+BytesPerLine;
  1749.      ofsp1=ofsp1+BytesPerLine;
  1750.      }
  1751.     outport(0x03CE,0x0005);
  1752. }