home *** CD-ROM | disk | FTP | other *** search
/ WarCraft 2000 - Nuclear Epidemic / W2000.nrg / SOURCE.War2000 / Fastdraw.cpp < prev    next >
C/C++ Source or Header  |  1998-09-25  |  42KB  |  2,235 lines

  1. /*               Fast raster graphics routine
  2.  *  
  3.  *  This module presents several useful procedures for fast output,
  4.  * using RLC graphics format (see the discription below). Before the
  5.  * wor you must call SetRlcWindow to set properly the screen 
  6.  * capabilities.After this you mast call SetScreenPtr to set the
  7.  * output distanation. Uou can use LoadRLC to load the set of RLC
  8.  * pictures into the RLCTable structure. Then you can draw the 
  9.  * picture on the screen wit the procedure ShowRLCItem 
  10.  */
  11. #include "ddini.h"
  12. #include "ResFile.h"
  13. #include "mode.h"
  14. extern int SCRSizeX;
  15. extern int SCRSizeY;
  16. extern int RSCRSizeX;
  17. extern int RSCRSizeY;
  18. extern int COPYSizeX;
  19. byte PAL1[256];
  20. byte PAL2[256];
  21. byte PAL3[256];
  22. byte PAL4[256];
  23. byte PAL5[256];
  24. byte PAL6[256];
  25. byte PAL7[256];
  26. extern void* offScreenPtr;
  27. struct RLCHeader
  28. {
  29. short    SizeX;
  30. short    SizeY;
  31. };
  32.  
  33. typedef RLCHeader* lpRLCHeader;
  34. struct xRLCTable
  35. {
  36. int sign;
  37. int    SCount;
  38. int OfsTable[400];
  39. };
  40. typedef xRLCTable* RLCTable; 
  41. typedef RLCTable* lpRLCTable;
  42. struct RLCFont
  43. {
  44. int    FirstSymbol;
  45. int LastSymbol;
  46. RLCTable RLC;
  47. };
  48. typedef RLCFont* lpRLCFont;
  49. //Window parameters
  50. int WindX=0; 
  51. int WindY=0;
  52. int WindLx;
  53. int WindLy;
  54. int WindX1;
  55. int WindY1; 
  56. int ScrWidth;
  57. int ScrHeight;
  58. int BytesPerPixel=1;
  59. void* ScreenPtr=NULL;
  60. void* RealScreenPtr=NULL;
  61. void InitRLCWindows(){
  62.     WindLx=SCRSizeX;
  63.     WindLy=SCRSizeY;
  64.     WindX1=SCRSizeX-1;
  65.     WindY1=SCRSizeY-1; 
  66.     ScrWidth=SCRSizeX;
  67.     ScrHeight=SCRSizeY;
  68. };
  69. /*  Creating window
  70.  */
  71. bool ProcessMessages();
  72. static int cntr;
  73. static bool InCycle;
  74. extern int RealLx;
  75. extern int RealLy;
  76. void SetRLCWindow(int x,int y,int lx,int ly,int slx)
  77. {
  78.     WindX=x;
  79.     WindY=y;
  80.     WindX1=x+lx-1;
  81.     WindY1=y+ly-1;
  82.     ScrWidth=slx;
  83.     if(WindX<0)WindX=0;
  84.     if(WindY<0)WindY=0;
  85.     if(WindX1>=RealLx)WindX1=RealLx-1;
  86.     if(WindY1>=RealLy)WindY1=RealLy-1;
  87.     WindLx=WindX1-WindX+1;
  88.     WindLy=WindY1-WindY+1;
  89. }
  90. //  Setting proper value of the screen pointer
  91. void SetScreenPtr(void)
  92. {
  93. #ifdef COPYSCR
  94.     ScreenPtr=offScreenPtr;
  95.     RealScreenPtr=ddsd.lpSurface;
  96. #else
  97.     ScreenPtr=ddsd.lpSurface;
  98. #endif
  99. }
  100.  
  101. void ClearScreen()
  102. {
  103.     if(DDError) return;
  104.     int sz=ScrWidth*ScrHeight*BytesPerPixel/4;
  105.     __asm
  106.     {
  107.         push    edi
  108.         push    esi
  109.         mov        edi,ScreenPtr
  110.         xor        eax,eax
  111.         cld
  112.         mov        ecx,sz
  113.         rep        stosd
  114.         pop        esi
  115.         pop        edi
  116.     }
  117. }
  118. //Showing RLC image with clipping
  119. void ShowRLC(int x,int y,void* PicPtr)
  120. {
  121.     byte precomp[256];
  122.     //for(int i=0;i<256;i++) precomp[i]=i;
  123.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  124.     int addofs=0;
  125.     int subline=0;
  126.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  127.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  128.     if ((y+PLY-1<WindY)|(y>WindY1)||
  129.         ((x+PLX<=WindX)||(x>WindX1)||!PLY)) return;
  130.     if (y<WindY) 
  131.     {
  132.         __asm    
  133.         {    
  134.             mov        edx,PicPtr
  135.             add        edx,4
  136.             xor        eax,eax
  137.             mov        ecx,WindY
  138.             sub        ecx,y
  139.             xor        eax,eax
  140.             xor        ebx,ebx
  141. Loop1xx1:    mov        al,[edx]
  142.             inc        edx
  143.             or        eax,eax
  144.             jz        Loop1xx3
  145. Loop1xx2:    mov        bl,[edx+1]
  146.             add        edx,ebx
  147.             add        edx,2
  148.             dec        eax
  149.             jnz        Loop1xx2
  150. Loop1xx3:    dec        cx
  151.             jnz        Loop1xx1
  152.             sub        edx,PicPtr
  153.             sub        edx,4
  154.             mov        addofs,edx
  155.         }
  156.         subline=WindY-y;
  157.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  158.     }
  159.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  160.     addofs+=4;
  161.     PLY-=subline;
  162.     if(PLY>0){
  163.         if(x<WindX){
  164.             int roff=WindX-x;
  165.             __asm{
  166.                 push    esi
  167.                 push    edi
  168.                 mov        edi,ScrOfst
  169.                 mov        esi,PicPtr
  170.                 add        esi,addofs
  171.                 xor        ecx,ecx
  172.                 xor        eax,eax
  173.                 cld
  174. ScanLineLoop1:
  175.                 cmp        PLY,0
  176.                 je        ScanLineLoopEnd1
  177.                 push    edi
  178.                 mov        bl,[esi]
  179.                 inc        esi
  180.                 or        bl,bl
  181.                 jz        NextLine1
  182.                 mov        bh,byte ptr roff
  183. BeginLine1:        mov        cl,[esi]
  184.                 sub        bh,cl
  185.                 add        edi,ecx
  186.                 mov        cl,[esi+1]
  187.                 //sub        bh,cl
  188.                 add        esi,2
  189.                 //clipping left code
  190.                 cmp        bh,0
  191.                 jle        ok1
  192.                 cmp        bh,cl
  193.                 jl        hdraw1
  194.                 //nothing to draw
  195.                 sub        bh,cl
  196.                 add        esi,ecx
  197.                 add        edi,ecx
  198.                 dec        bl
  199.                 jnz        BeginLine1
  200.                 pop        edi
  201.                 add        edi,ScrWidth
  202.                 dec     PLY
  203.                 jmp        ScanLineLoop1
  204. hdraw1:            //draw only small part of line
  205.                 sub        cl,bh
  206.                 mov        al,bh
  207.                 xor        bh,bh
  208.                 add        esi,eax
  209.                 add        edi,eax
  210. ok1:
  211.                 mov        eax,ecx
  212.                 shr        ecx,2
  213.                 //jcxz    Lx11
  214.                 rep        movsd
  215.                 mov        ecx,eax
  216.                 and        ecx,3
  217.                 //jcxz    Lx21
  218.                 rep        movsb
  219. Lx21:            dec        bl
  220.                 jnz        BeginLine1
  221. NextLine1:        pop        edi
  222.                 add        edi,ScrWidth
  223.                 dec     PLY
  224.                 jmp        ScanLineLoop1
  225. ScanLineLoopEnd1:
  226.                 pop        edi
  227.                 pop        esi
  228.             };
  229.         }else if(x+PLX>=WindX1){
  230.             int roff=WindX1-x+1;
  231.             int part;
  232.             __asm{
  233.                 push    esi
  234.                 push    edi
  235.                 mov        edi,ScrOfst
  236.                 mov        esi,PicPtr
  237.                 add        esi,addofs
  238.                 xor        ecx,ecx
  239.                 xor        eax,eax
  240.                 cld
  241. ScanLineLoop2:
  242.                 cmp        PLY,0
  243.                 je        ScanLineLoopEnd2
  244.                 push    edi
  245.                 mov        bl,[esi]
  246.                 inc        esi
  247.                 or        bl,bl
  248.                 jz        NextLine2
  249.                 mov        bh,byte ptr roff
  250. BeginLine2:        mov        cl,[esi]
  251.                 sub        bh,cl
  252.                 add        edi,ecx
  253.                 mov        cl,[esi+1]
  254.                 add        esi,2
  255.                 //clipping right code
  256.                 cmp        bh,cl
  257.                 jge        ok2
  258.                 //clipping
  259.                 cmp        bh,0
  260.                 jle        ntd2
  261.                 //partial drawing
  262.                 sub        cl,bh
  263.                 mov        part,ecx
  264.                 mov        cl,bh
  265.                 mov        eax,ecx
  266.                 shr        ecx,2
  267.                 //jcxz    Lx11_1
  268.                 rep        movsd
  269.                 mov        ecx,eax
  270.                 and        ecx,3
  271.                 //jcxz    Lx2
  272.                 rep        movsb
  273.                 add        esi,part
  274.                 jmp        ntd4
  275. ntd2:            //scanning to the next line
  276.                 add        esi,ecx
  277. ntd4:            dec        bl
  278.                 jz        NextLine2
  279. ntd22:            mov        cl,[esi+1]
  280.                 add        esi,2
  281.                 add        esi,ecx
  282.                 dec        bl
  283.                 jnz        ntd22
  284.                 jmp        NextLine2
  285. ok2:            sub        bh,cl
  286.                 mov        eax,ecx
  287.                 shr        ecx,2
  288.                 //jcxz    Lx11
  289.                 rep        movsd
  290. Lx11:            mov        ecx,eax
  291.                 and        ecx,3
  292.                 //jcxz    Lx22
  293.                 rep        movsb
  294. Lx22:            dec        bl
  295.                 jnz        BeginLine2
  296. NextLine2:        pop        edi
  297.                 add        edi,ScrWidth
  298.                 dec     PLY
  299.                 jmp        ScanLineLoop2
  300. ScanLineLoopEnd2:
  301.                 pop        edi
  302.                 pop        esi
  303.             };
  304.         }else
  305.         __asm
  306.         {
  307.             push    esi
  308.             push    edi
  309.             mov        edi,ScrOfst
  310.             mov        esi,PicPtr
  311.             add        esi,addofs
  312.             xor        ecx,ecx
  313.             xor        ebx,ebx
  314.             cld
  315. ScanLineLoop:
  316.             cmp        PLY,0
  317.             je        ScanLineLoopEnd
  318.             push    edi
  319.             mov        bl,[esi]
  320.             inc        esi
  321.             or        bl,bl
  322.             jz        NextLine
  323. BeginLine:    mov        cl,[esi]
  324.             add        edi,ecx
  325.             mov        cl,[esi+1]
  326.             add        esi,2
  327.             mov        eax,ecx
  328.             shr        ecx,2
  329.             jcxz    Lx1
  330.             rep        movsd
  331. Lx1:        mov        ecx,eax
  332.             and        ecx,3
  333.             jcxz    Lx2
  334.             rep        movsb
  335. //            xor        eax,eax
  336. //rrr:        lodsb
  337. //            mov        al,[precomp+eax]
  338. //            stosb
  339. //            loop    rrr
  340. //            rep        movsb
  341. Lx2:        dec        ebx
  342.             jnz        BeginLine
  343. NextLine:    pop        edi
  344.             add        edi,ScrWidth
  345.             dec     PLY
  346.             jmp        ScanLineLoop
  347. ScanLineLoopEnd:
  348.             pop        edi
  349.             pop        esi
  350.         }
  351.     }
  352. }
  353. //End of RLC with clipping
  354. //Showing inverse RLC image with clipping
  355. void ShowRLCi(int x,int y,void* PicPtr)
  356. {
  357.     byte precomp[256];
  358.     //for(int i=0;i<256;i++) precomp[i]=i;
  359.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  360.     int addofs=0;
  361.     int subline=0;
  362.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  363.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  364.     if ((y+PLY-1<WindY)|(y>WindY1)||
  365.         ((x<WindX)||(x-PLX+1>=WindX1)||!PLY)) return;
  366.     if (y<WindY) 
  367.     {
  368.         __asm    
  369.         {    
  370.             mov        edx,PicPtr
  371.             add        edx,4
  372.             xor        eax,eax
  373.             mov        ecx,WindY
  374.             sub        ecx,y
  375.             xor        eax,eax
  376.             xor        ebx,ebx
  377. Loop1xx1:    mov        al,[edx]
  378.             inc        edx
  379.             or        eax,eax
  380.             jz        Loop1xx3
  381. Loop1xx2:    mov        bl,[edx+1]
  382.             add        edx,ebx
  383.             add        edx,2
  384.             dec        eax
  385.             jnz        Loop1xx2
  386. Loop1xx3:    dec        cx
  387.             jnz        Loop1xx1
  388.             sub        edx,PicPtr
  389.             sub        edx,4
  390.             mov        addofs,edx
  391.         }
  392.         subline=WindY-y;
  393.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  394.     }
  395.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  396.     addofs+=4;
  397.     PLY-=subline;
  398.     if(PLY>0){
  399.         if(x>WindX1){
  400.             int roff=x-WindX1;
  401.             __asm{
  402.                 push    esi
  403.                 push    edi
  404.                 mov        edi,ScrOfst
  405.                 mov        esi,PicPtr
  406.                 add        esi,addofs
  407.                 xor        ecx,ecx
  408.                 xor        eax,eax
  409.                 cld
  410. ScanLineLoop1:
  411.                 cmp        PLY,0
  412.                 je        ScanLineLoopEnd1
  413.                 push    edi
  414.                 mov        bl,[esi]
  415.                 inc        esi
  416.                 or        bl,bl
  417.                 jz        NextLine1
  418.                 mov        bh,byte ptr roff
  419. BeginLine1:        mov        cl,[esi]
  420.                 sub        bh,cl
  421.                 sub        edi,ecx
  422.                 mov        cl,[esi+1]
  423.                 //sub        bh,cl
  424.                 add        esi,2
  425.                 //clipping left code
  426.                 cmp        bh,0
  427.                 jle        ok1
  428.                 cmp        bh,cl
  429.                 jl        hdraw1
  430.                 //nothing to draw
  431.                 sub        bh,cl
  432.                 add        esi,ecx
  433.                 sub        edi,ecx
  434.                 dec        bl
  435.                 jnz        BeginLine1
  436.                 pop        edi
  437.                 add        edi,ScrWidth
  438.                 dec     PLY
  439.                 jmp        ScanLineLoop1
  440. hdraw1:            //draw only small part of line
  441.                 sub        cl,bh
  442.                 mov        al,bh
  443.                 xor        bh,bh
  444.                 add        esi,eax
  445.                 sub        edi,eax
  446. ok1:
  447.                 movsb
  448.                 sub        edi,2
  449.                 dec        cl
  450.                 jnz        ok1
  451. Lx21:            dec        bl
  452.                 jnz        BeginLine1
  453. NextLine1:        pop        edi
  454.                 add        edi,ScrWidth
  455.                 dec     PLY
  456.                 jmp        ScanLineLoop1
  457. ScanLineLoopEnd1:
  458.                 pop        edi
  459.                 pop        esi
  460.             };
  461.         }else if(x-PLX+1<WindX){
  462.             int roff=x-WindX+1;
  463.             int part;
  464.             __asm{
  465.                 push    esi
  466.                 push    edi
  467.                 mov        edi,ScrOfst
  468.                 mov        esi,PicPtr
  469.                 add        esi,addofs
  470.                 xor        ecx,ecx
  471.                 xor        eax,eax
  472.                 cld
  473. ScanLineLoop2:
  474.                 cmp        PLY,0
  475.                 je        ScanLineLoopEnd2
  476.                 push    edi
  477.                 mov        bl,[esi]
  478.                 inc        esi
  479.                 or        bl,bl
  480.                 jz        NextLine2
  481.                 mov        bh,byte ptr roff
  482. BeginLine2:        mov        cl,[esi]
  483.                 sub        bh,cl
  484.                 sub        edi,ecx
  485.                 mov        cl,[esi+1]
  486.                 add        esi,2
  487.                 //clipping right code
  488.                 cmp        bh,cl
  489.                 jge        ok2
  490.                 //clipping
  491.                 cmp        bh,0
  492.                 jle        ntd2
  493.                 //partial drawing
  494.                 sub        cl,bh
  495.                 mov        part,ecx
  496.                 mov        cl,bh
  497. lxsd1:            movsb
  498.                 sub        edi,2
  499.                 dec        cl
  500.                 jnz        lxsd1
  501.                 add        esi,part
  502.                 jmp        ntd4
  503. ntd2:            //scanning to the next line
  504.                 add        esi,ecx
  505. ntd4:            dec        bl
  506.                 jz        NextLine2
  507. ntd22:            mov        cl,[esi+1]
  508.                 add        esi,2
  509.                 add        esi,ecx
  510.                 dec        bl
  511.                 jnz        ntd22
  512.                 jmp        NextLine2
  513. ok2:            sub        bh,cl
  514. lkfr1:            movsb
  515.                 sub        edi,2
  516.                 dec        cl
  517.                 jnz        lkfr1
  518. Lx22:            dec        bl
  519.                 jnz        BeginLine2
  520. NextLine2:        pop        edi
  521.                 add        edi,ScrWidth
  522.                 dec     PLY
  523.                 jmp        ScanLineLoop2
  524. ScanLineLoopEnd2:
  525.                 pop        edi
  526.                 pop        esi
  527.             };
  528.         }else
  529.         __asm
  530.         {
  531.             push    esi
  532.             push    edi
  533.             mov        edi,ScrOfst
  534.             mov        esi,PicPtr
  535.             add        esi,addofs
  536.             xor        ecx,ecx
  537.             xor        ebx,ebx
  538.             cld
  539. ScanLineLoop:
  540.             cmp        PLY,0
  541.             je        ScanLineLoopEnd
  542.             push    edi
  543.             mov        bl,[esi]
  544.             inc        esi
  545.             or        bl,bl
  546.             jz        NextLine
  547. BeginLine:    mov        cl,[esi]
  548.             sub        edi,ecx
  549.             mov        cl,[esi+1]
  550.             add        esi,2
  551. ghte:        movsb
  552.             sub        edi,2
  553.             dec        cl
  554.             jnz        ghte
  555. Lx2:        dec        ebx
  556.             jnz        BeginLine
  557. NextLine:    pop        edi
  558.             add        edi,ScrWidth
  559.             dec     PLY
  560.             jmp        ScanLineLoop
  561. ScanLineLoopEnd:
  562.             pop        edi
  563.             pop        esi
  564.         }
  565.     }
  566. }
  567. //End of RLC with clipping & with palette
  568. void ShowRLCpal(int x,int y,void* PicPtr,byte* pal)
  569. {
  570.     byte precomp[256];
  571.     //for(int i=0;i<256;i++) precomp[i]=i;
  572.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  573.     int addofs=0;
  574.     int subline=0;
  575.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  576.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  577.     if ((y+PLY-1<WindY)|(y>WindY1)||
  578.         ((x+PLX<=WindX)||(x>WindX1)||!PLY)) return;
  579.     if (y<WindY) 
  580.     {
  581.         __asm    
  582.         {    
  583.             mov        edx,PicPtr
  584.             add        edx,4
  585.             xor        eax,eax
  586.             mov        ecx,WindY
  587.             sub        ecx,y
  588.             xor        eax,eax
  589.             xor        ebx,ebx
  590. Loop1xx1:    mov        al,[edx]
  591.             inc        edx
  592.             or        eax,eax
  593.             jz        Loop1xx3
  594. Loop1xx2:    mov        bl,[edx+1]
  595.             add        edx,ebx
  596.             add        edx,2
  597.             dec        eax
  598.             jnz        Loop1xx2
  599. Loop1xx3:    dec        cx
  600.             jnz        Loop1xx1
  601.             sub        edx,PicPtr
  602.             sub        edx,4
  603.             mov        addofs,edx
  604.         }
  605.         subline=WindY-y;
  606.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  607.     }
  608.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  609.     addofs+=4;
  610.     PLY-=subline;
  611.     if(PLY>0){
  612.         if(x<WindX){
  613.             int roff=WindX-x;
  614.             __asm{
  615.                 push    esi
  616.                 push    edi
  617.                 mov        edi,ScrOfst
  618.                 mov        esi,PicPtr
  619.                 add        esi,addofs
  620.                 xor        ecx,ecx
  621.                 xor        eax,eax
  622.                 mov        ebx,pal
  623.                 cld
  624. ScanLineLoop1:
  625.                 cmp        PLY,0
  626.                 je        ScanLineLoopEnd1
  627.                 push    edi
  628.                 mov        dl,[esi]
  629.                 inc        esi
  630.                 or        dl,dl
  631.                 jz        NextLine1
  632.                 mov        dh,byte ptr roff
  633. BeginLine1:        mov        cl,[esi]
  634.                 sub        dh,cl
  635.                 add        edi,ecx
  636.                 mov        cl,[esi+1]
  637.                 //sub        bh,cl
  638.                 add        esi,2
  639.                 //clipping left code
  640.                 cmp        dh,0
  641.                 jle        ok1
  642.                 cmp        dh,cl
  643.                 jl        hdraw1
  644.                 //nothing to draw
  645.                 sub        dh,cl
  646.                 add        esi,ecx
  647.                 add        edi,ecx
  648.                 dec        dl
  649.                 jnz        BeginLine1
  650.                 pop        edi
  651.                 add        edi,ScrWidth
  652.                 dec     PLY
  653.                 jmp        ScanLineLoop1
  654. hdraw1:            //draw only small part of line
  655.                 sub        cl,dh
  656.                 mov        al,dh
  657.                 xor        dh,dh
  658.                 add        esi,eax
  659.                 add        edi,eax
  660. ok1:
  661.                 lodsb
  662.                 mov        al,[ebx+eax]
  663.                 stosb
  664.                 dec        cl
  665.                 jnz        ok1
  666. Lx21:            dec        dl
  667.                 jnz        BeginLine1
  668. NextLine1:        pop        edi
  669.                 add        edi,ScrWidth
  670.                 dec     PLY
  671.                 jmp        ScanLineLoop1
  672. ScanLineLoopEnd1:
  673.                 pop        edi
  674.                 pop        esi
  675.             };
  676.         }else if(x+PLX>=WindX1){
  677.             int roff=WindX1-x+1;
  678.             int part;
  679.             __asm{
  680.                 push    esi
  681.                 push    edi
  682.                 mov        edi,ScrOfst
  683.                 mov        esi,PicPtr
  684.                 add        esi,addofs
  685.                 xor        ecx,ecx
  686.                 xor        eax,eax
  687.                 mov        ebx,pal
  688.                 cld
  689. ScanLineLoop2:
  690.                 cmp        PLY,0
  691.                 je        ScanLineLoopEnd2
  692.                 push    edi
  693.                 mov        dl,[esi]
  694.                 inc        esi
  695.                 or        dl,dl
  696.                 jz        NextLine2
  697.                 mov        dh,byte ptr roff
  698. BeginLine2:        mov        cl,[esi]
  699.                 sub        dh,cl
  700.                 add        edi,ecx
  701.                 mov        cl,[esi+1]
  702.                 add        esi,2
  703.                 //clipping right code
  704.                 cmp        dh,cl
  705.                 jge        ok2
  706.                 //clipping
  707.                 cmp        dh,0
  708.                 jle        ntd2
  709.                 //partial drawing
  710.                 sub        cl,dh
  711.                 mov        part,ecx
  712.                 mov        cl,dh
  713. kkj1:            lodsb    
  714.                 mov        al,[ebx+eax]
  715.                 stosb
  716.                 dec        cl
  717.                 jnz        kkj1
  718.                 add        esi,part
  719.                 jmp        ntd4
  720. ntd2:            //scanning to the next line
  721.                 add        esi,ecx
  722. ntd4:            dec        dl
  723.                 jz        NextLine2
  724. ntd22:            mov        cl,[esi+1]
  725.                 add        esi,2
  726.                 add        esi,ecx
  727.                 dec        dl
  728.                 jnz        ntd22
  729.                 jmp        NextLine2
  730. ok2:            sub        dh,cl
  731. kkj2:            lodsb    
  732.                 mov        al,[ebx+eax]
  733.                 stosb
  734.                 dec        cl
  735.                 jnz        kkj2
  736. Lx22:            dec        dl
  737.                 jnz        BeginLine2
  738. NextLine2:        pop        edi
  739.                 add        edi,ScrWidth
  740.                 dec     PLY
  741.                 jmp        ScanLineLoop2
  742. ScanLineLoopEnd2:
  743.                 pop        edi
  744.                 pop        esi
  745.             };
  746.         }else
  747.         __asm
  748.         {
  749.             push    esi
  750.             push    edi
  751.             mov        edi,ScrOfst
  752.             mov        esi,PicPtr
  753.             add        esi,addofs
  754.             xor        ecx,ecx
  755.             xor        ebx,ebx
  756.             xor        eax,eax
  757.             mov        ebx,pal
  758.             cld
  759. ScanLineLoop:
  760.             cmp        PLY,0
  761.             je        ScanLineLoopEnd
  762.             push    edi
  763.             mov        dl,[esi]
  764.             inc        esi
  765.             or        dl,dl
  766.             jz        NextLine
  767. BeginLine:    mov        cl,[esi]
  768.             add        edi,ecx
  769.             mov        cl,[esi+1]
  770.             add        esi,2
  771. hgaw:        lodsb
  772.             mov        al,[ebx+eax]
  773.             stosb
  774.             dec        cl
  775.             jnz        hgaw
  776. Lx2:        dec        dl
  777.             jnz        BeginLine
  778. NextLine:    pop        edi
  779.             add        edi,ScrWidth
  780.             dec     PLY
  781.             jmp        ScanLineLoop
  782. ScanLineLoopEnd:
  783.             pop        edi
  784.             pop        esi
  785.         }
  786.     }
  787. }
  788. //End of RLC with clipping & encoding
  789. //Showing inverse RLC image with clipping & encodint
  790. void ShowRLCipal(int x,int y,void* PicPtr,byte* pal)
  791. {
  792.     byte precomp[256];
  793.     //for(int i=0;i<256;i++) precomp[i]=i;
  794.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  795.     int addofs=0;
  796.     int subline=0;
  797.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  798.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  799.     if ((y+PLY-1<WindY)|(y>WindY1)||
  800.         ((x<WindX)||(x-PLX+1>=WindX1)||!PLY)) return;
  801.     if (y<WindY) 
  802.     {
  803.         __asm    
  804.         {    
  805.             mov        edx,PicPtr
  806.             add        edx,4
  807.             xor        eax,eax
  808.             mov        ecx,WindY
  809.             sub        ecx,y
  810.             xor        eax,eax
  811.             xor        ebx,ebx
  812. Loop1xx1:    mov        al,[edx]
  813.             inc        edx
  814.             or        eax,eax
  815.             jz        Loop1xx3
  816. Loop1xx2:    mov        bl,[edx+1]
  817.             add        edx,ebx
  818.             add        edx,2
  819.             dec        eax
  820.             jnz        Loop1xx2
  821. Loop1xx3:    dec        cx
  822.             jnz        Loop1xx1
  823.             sub        edx,PicPtr
  824.             sub        edx,4
  825.             mov        addofs,edx
  826.         }
  827.         subline=WindY-y;
  828.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  829.     }
  830.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  831.     addofs+=4;
  832.     PLY-=subline;
  833.     if(PLY>0){
  834.         if(x>WindX1){
  835.             int roff=x-WindX1;
  836.             __asm{
  837.                 push    esi
  838.                 push    edi
  839.                 mov        edi,ScrOfst
  840.                 mov        esi,PicPtr
  841.                 add        esi,addofs
  842.                 xor        ecx,ecx
  843.                 xor        eax,eax
  844.                 mov        ebx,pal
  845.                 cld
  846. ScanLineLoop1:
  847.                 cmp        PLY,0
  848.                 je        ScanLineLoopEnd1
  849.                 push    edi
  850.                 mov        dl,[esi]
  851.                 inc        esi
  852.                 or        dl,dl
  853.                 jz        NextLine1
  854.                 mov        dh,byte ptr roff
  855. BeginLine1:        mov        cl,[esi]
  856.                 sub        dh,cl
  857.                 sub        edi,ecx
  858.                 mov        cl,[esi+1]
  859.                 //sub        bh,cl
  860.                 add        esi,2
  861.                 //clipping left code
  862.                 cmp        dh,0
  863.                 jle        ok1
  864.                 cmp        dh,cl
  865.                 jl        hdraw1
  866.                 //nothing to draw
  867.                 sub        dh,cl
  868.                 add        esi,ecx
  869.                 sub        edi,ecx
  870.                 dec        dl
  871.                 jnz        BeginLine1
  872.                 pop        edi
  873.                 add        edi,ScrWidth
  874.                 dec     PLY
  875.                 jmp        ScanLineLoop1
  876. hdraw1:            //draw only small part of line
  877.                 sub        cl,dh
  878.                 mov        al,dh
  879.                 xor        dh,dh
  880.                 add        esi,eax
  881.                 sub        edi,eax
  882. ok1:            lodsb
  883.                 mov        al,[ebx+eax]
  884.                 mov        [edi],al
  885.                 dec        edi
  886.                 dec        cl
  887.                 jnz        ok1
  888. Lx21:            dec        dl
  889.                 jnz        BeginLine1
  890. NextLine1:        pop        edi
  891.                 add        edi,ScrWidth
  892.                 dec     PLY
  893.                 jmp        ScanLineLoop1
  894. ScanLineLoopEnd1:
  895.                 pop        edi
  896.                 pop        esi
  897.             };
  898.         }else if(x-PLX+1<WindX){
  899.             int roff=x-WindX+1;
  900.             int part;
  901.             __asm{
  902.                 push    esi
  903.                 push    edi
  904.                 mov        edi,ScrOfst
  905.                 mov        esi,PicPtr
  906.                 add        esi,addofs
  907.                 xor        ecx,ecx
  908.                 xor        eax,eax
  909.                 mov        ebx,pal
  910.                 cld
  911. ScanLineLoop2:
  912.                 cmp        PLY,0
  913.                 je        ScanLineLoopEnd2
  914.                 push    edi
  915.                 mov        dl,[esi]
  916.                 inc        esi
  917.                 or        dl,dl
  918.                 jz        NextLine2
  919.                 mov        dh,byte ptr roff
  920. BeginLine2:        mov        cl,[esi]
  921.                 sub        dh,cl
  922.                 sub        edi,ecx
  923.                 mov        cl,[esi+1]
  924.                 add        esi,2
  925.                 //clipping right code
  926.                 cmp        dh,cl
  927.                 jge        ok2
  928.                 //clipping
  929.                 cmp        dh,0
  930.                 jle        ntd2
  931.                 //partial drawing
  932.                 sub        cl,dh
  933.                 mov        part,ecx
  934.                 mov        cl,dh
  935. lxsd1:            lodsb
  936.                 mov        al,[ebx+eax]
  937.                 mov        [edi],al
  938.                 dec        edi
  939.                 dec        cl
  940.                 jnz        lxsd1
  941.                 add        esi,part
  942.                 jmp        ntd4
  943. ntd2:            //scanning to the next line
  944.                 add        esi,ecx
  945. ntd4:            dec        dl
  946.                 jz        NextLine2
  947. ntd22:            mov        cl,[esi+1]
  948.                 add        esi,2
  949.                 add        esi,ecx
  950.                 dec        dl
  951.                 jnz        ntd22
  952.                 jmp        NextLine2
  953. ok2:            sub        dh,cl
  954. lkfr1:            lodsb
  955.                 mov        al,[ebx+eax]
  956.                 mov        [edi],al
  957.                 dec        edi
  958.                 dec        cl
  959.                 jnz        lkfr1
  960. Lx22:            dec        dl
  961.                 jnz        BeginLine2
  962. NextLine2:        pop        edi
  963.                 add        edi,ScrWidth
  964.                 dec     PLY
  965.                 jmp        ScanLineLoop2
  966. ScanLineLoopEnd2:
  967.                 pop        edi
  968.                 pop        esi
  969.             };
  970.         }else
  971.         __asm
  972.         {
  973.             push    esi
  974.             push    edi
  975.             mov        edi,ScrOfst
  976.             mov        esi,PicPtr
  977.             add        esi,addofs
  978.             xor        ecx,ecx
  979.             xor        ebx,ebx
  980.             xor        eax,eax
  981.             mov        ebx,pal
  982.             cld
  983. ScanLineLoop:
  984.             cmp        PLY,0
  985.             je        ScanLineLoopEnd
  986.             push    edi
  987.             mov        dl,[esi]
  988.             inc        esi
  989.             or        dl,dl
  990.             jz        NextLine
  991. BeginLine:    mov        cl,[esi]
  992.             sub        edi,ecx
  993.             mov        cl,[esi+1]
  994.             add        esi,2
  995. ghte:        lodsb
  996.             mov        al,[eax+ebx]
  997.             mov        [edi],al
  998.             dec        edi
  999.             dec        cl
  1000.             jnz        ghte
  1001. Lx2:        dec        dl
  1002.             jnz        BeginLine
  1003. NextLine:    pop        edi
  1004.             add        edi,ScrWidth
  1005.             dec     PLY
  1006.             jmp        ScanLineLoop
  1007. ScanLineLoopEnd:
  1008.             pop        edi
  1009.             pop        esi
  1010.         }
  1011.     }
  1012. }
  1013. //End of inverted RLC with clipping & encoding
  1014.  
  1015. //End of RLC with clipping & with palette->fon
  1016. void ShowRLCfonpal(int x,int y,void* PicPtr,byte* pal)
  1017. {
  1018.     byte precomp[256];
  1019.     //for(int i=0;i<256;i++) precomp[i]=i;
  1020.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  1021.     int addofs=0;
  1022.     int subline=0;
  1023.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  1024.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  1025.     if ((y+PLY-1<WindY)|(y>WindY1)||
  1026.         ((x+PLX<=WindX)||(x>WindX1)||!PLY)) return;
  1027.     if (y<WindY) 
  1028.     {
  1029.         __asm    
  1030.         {    
  1031.             mov        edx,PicPtr
  1032.             add        edx,4
  1033.             xor        eax,eax
  1034.             mov        ecx,WindY
  1035.             sub        ecx,y
  1036.             xor        eax,eax
  1037.             xor        ebx,ebx
  1038. Loop1xx1:    mov        al,[edx]
  1039.             inc        edx
  1040.             or        eax,eax
  1041.             jz        Loop1xx3
  1042. Loop1xx2:    mov        bl,[edx+1]
  1043.             add        edx,ebx
  1044.             add        edx,2
  1045.             dec        eax
  1046.             jnz        Loop1xx2
  1047. Loop1xx3:    dec        cx
  1048.             jnz        Loop1xx1
  1049.             sub        edx,PicPtr
  1050.             sub        edx,4
  1051.             mov        addofs,edx
  1052.         }
  1053.         subline=WindY-y;
  1054.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  1055.     }
  1056.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  1057.     addofs+=4;
  1058.     PLY-=subline;
  1059.     if(PLY>0){
  1060.         if(x<WindX){
  1061.             int roff=WindX-x;
  1062.             __asm{
  1063.                 push    esi
  1064.                 push    edi
  1065.                 mov        edi,ScrOfst
  1066.                 mov        esi,PicPtr
  1067.                 add        esi,addofs
  1068.                 xor        ecx,ecx
  1069.                 xor        eax,eax
  1070.                 mov        ebx,pal
  1071.                 cld
  1072. ScanLineLoop1:
  1073.                 cmp        PLY,0
  1074.                 je        ScanLineLoopEnd1
  1075.                 push    edi
  1076.                 mov        dl,[esi]
  1077.                 inc        esi
  1078.                 or        dl,dl
  1079.                 jz        NextLine1
  1080.                 mov        dh,byte ptr roff
  1081. BeginLine1:        mov        cl,[esi]
  1082.                 sub        dh,cl
  1083.                 add        edi,ecx
  1084.                 mov        cl,[esi+1]
  1085.                 //sub        bh,cl
  1086.                 add        esi,2
  1087.                 //clipping left code
  1088.                 cmp        dh,0
  1089.                 jle        okk1
  1090.                 cmp        dh,cl
  1091.                 jl        hdraw1
  1092.                 //nothing to draw
  1093.                 sub        dh,cl
  1094.                 add        esi,ecx
  1095.                 add        edi,ecx
  1096.                 dec        dl
  1097.                 jnz        BeginLine1
  1098.                 pop        edi
  1099.                 add        edi,ScrWidth
  1100.                 dec     PLY
  1101.                 jmp        ScanLineLoop1
  1102. hdraw1:            //draw only small part of line
  1103.                 sub        cl,dh
  1104.                 mov        al,dh
  1105.                 xor        dh,dh
  1106.                 add        esi,eax
  1107.                 add        edi,eax
  1108. okk1:            add        esi,ecx
  1109. ok1:            mov        al,[edi]
  1110.                 mov        al,[ebx+eax]
  1111.                 stosb
  1112.                 dec        cl
  1113.                 jnz        ok1
  1114. Lx21:            dec        dl
  1115.                 jnz        BeginLine1
  1116. NextLine1:        pop        edi
  1117.                 add        edi,ScrWidth
  1118.                 dec     PLY
  1119.                 jmp        ScanLineLoop1
  1120. ScanLineLoopEnd1:
  1121.                 pop        edi
  1122.                 pop        esi
  1123.             };
  1124.         }else if(x+PLX>=WindX1){
  1125.             int roff=WindX1-x+1;
  1126.             int part;
  1127.             __asm{
  1128.                 push    esi
  1129.                 push    edi
  1130.                 mov        edi,ScrOfst
  1131.                 mov        esi,PicPtr
  1132.                 add        esi,addofs
  1133.                 xor        ecx,ecx
  1134.                 xor        eax,eax
  1135.                 mov        ebx,pal
  1136.                 cld
  1137. ScanLineLoop2:
  1138.                 cmp        PLY,0
  1139.                 je        ScanLineLoopEnd2
  1140.                 push    edi
  1141.                 mov        dl,[esi]
  1142.                 inc        esi
  1143.                 or        dl,dl
  1144.                 jz        NextLine2
  1145.                 mov        dh,byte ptr roff
  1146. BeginLine2:        mov        cl,[esi]
  1147.                 sub        dh,cl
  1148.                 add        edi,ecx
  1149.                 mov        cl,[esi+1]
  1150.                 add        esi,2
  1151.                 //clipping right code
  1152.                 cmp        dh,cl
  1153.                 jge        ok2
  1154.                 //clipping
  1155.                 cmp        dh,0
  1156.                 jle        ntd2
  1157.                 //partial drawing
  1158.                 sub        cl,dh
  1159.                 mov        part,ecx
  1160.                 mov        cl,dh
  1161.                 add        esi,ecx
  1162. kkj1:            mov        al,[edi]
  1163.                 mov        al,[ebx+eax]
  1164.                 stosb
  1165.                 dec        cl
  1166.                 jnz        kkj1
  1167.                 add        esi,part
  1168.                 jmp        ntd4
  1169. ntd2:            //scanning to the next line
  1170.                 add        esi,ecx
  1171. ntd4:            dec        dl
  1172.                 jz        NextLine2
  1173. ntd22:            mov        cl,[esi+1]
  1174.                 add        esi,2
  1175.                 add        esi,ecx
  1176.                 dec        dl
  1177.                 jnz        ntd22
  1178.                 jmp        NextLine2
  1179. ok2:            sub        dh,cl
  1180.                 add        esi,ecx
  1181. kkj3:            mov        al,[edi]
  1182.                 mov        al,[ebx+eax]
  1183.                 stosb
  1184.                 dec        cl
  1185.                 jnz        kkj3
  1186. Lx22:            dec        dl
  1187.                 jnz        BeginLine2
  1188. NextLine2:        pop        edi
  1189.                 add        edi,ScrWidth
  1190.                 dec     PLY
  1191.                 jmp        ScanLineLoop2
  1192. ScanLineLoopEnd2:
  1193.                 pop        edi
  1194.                 pop        esi
  1195.             };
  1196.         }else
  1197.         __asm
  1198.         {
  1199.             push    esi
  1200.             push    edi
  1201.             mov        edi,ScrOfst
  1202.             mov        esi,PicPtr
  1203.             add        esi,addofs
  1204.             xor        ecx,ecx
  1205.             xor        ebx,ebx
  1206.             xor        eax,eax
  1207.             mov        ebx,pal
  1208.             cld
  1209. ScanLineLoop:
  1210.             cmp        PLY,0
  1211.             je        ScanLineLoopEnd
  1212.             push    edi
  1213.             mov        dl,[esi]
  1214.             inc        esi
  1215.             or        dl,dl
  1216.             jz        NextLine
  1217. BeginLine:    mov        cl,[esi]
  1218.             add        edi,ecx
  1219.             mov        cl,[esi+1]
  1220.             add        esi,2
  1221.             add        esi,ecx
  1222. hgaw:        mov        al,[edi]
  1223.             mov        al,[ebx+eax]
  1224.             stosb
  1225.             dec        cl
  1226.             jnz        hgaw
  1227. Lx2:        dec        dl
  1228.             jnz        BeginLine
  1229. NextLine:    pop        edi
  1230.             add        edi,ScrWidth
  1231.             dec     PLY
  1232.             jmp        ScanLineLoop
  1233. ScanLineLoopEnd:
  1234.             pop        edi
  1235.             pop        esi
  1236.         }
  1237.     }
  1238. }
  1239. //End of RLC with clipping & encoding
  1240. //Showing inverse RLC image with clipping & encodint
  1241. void ShowRLCifonpal(int x,int y,void* PicPtr,byte* pal)
  1242. {
  1243.     byte precomp[256];
  1244.     //for(int i=0;i<256;i++) precomp[i]=i;
  1245.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  1246.     int addofs=0;
  1247.     int subline=0;
  1248.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  1249.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  1250.     if ((y+PLY-1<WindY)|(y>WindY1)||
  1251.         ((x<WindX)||(x-PLX+1>=WindX1)||!PLY)) return;
  1252.     if (y<WindY) 
  1253.     {
  1254.         __asm    
  1255.         {    
  1256.             mov        edx,PicPtr
  1257.             add        edx,4
  1258.             xor        eax,eax
  1259.             mov        ecx,WindY
  1260.             sub        ecx,y
  1261.             xor        eax,eax
  1262.             xor        ebx,ebx
  1263. Loop1xx1:    mov        al,[edx]
  1264.             inc        edx
  1265.             or        eax,eax
  1266.             jz        Loop1xx3
  1267. Loop1xx2:    mov        bl,[edx+1]
  1268.             add        edx,ebx
  1269.             add        edx,2
  1270.             dec        eax
  1271.             jnz        Loop1xx2
  1272. Loop1xx3:    dec        cx
  1273.             jnz        Loop1xx1
  1274.             sub        edx,PicPtr
  1275.             sub        edx,4
  1276.             mov        addofs,edx
  1277.         }
  1278.         subline=WindY-y;
  1279.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  1280.     }
  1281.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  1282.     addofs+=4;
  1283.     PLY-=subline;
  1284.     if(PLY>0){
  1285.         if(x>WindX1){
  1286.             int roff=x-WindX1;
  1287.             __asm{
  1288.                 push    esi
  1289.                 push    edi
  1290.                 mov        edi,ScrOfst
  1291.                 mov        esi,PicPtr
  1292.                 add        esi,addofs
  1293.                 xor        ecx,ecx
  1294.                 xor        eax,eax
  1295.                 mov        ebx,pal
  1296.                 cld
  1297. ScanLineLoop1:
  1298.                 cmp        PLY,0
  1299.                 je        ScanLineLoopEnd1
  1300.                 push    edi
  1301.                 mov        dl,[esi]
  1302.                 inc        esi
  1303.                 or        dl,dl
  1304.                 jz        NextLine1
  1305.                 mov        dh,byte ptr roff
  1306. BeginLine1:        mov        cl,[esi]
  1307.                 sub        dh,cl
  1308.                 sub        edi,ecx
  1309.                 mov        cl,[esi+1]
  1310.                 //sub        bh,cl
  1311.                 add        esi,2
  1312.                 //clipping left code
  1313.                 cmp        dh,0
  1314.                 jle        okk1
  1315.                 cmp        dh,cl
  1316.                 jl        hdraw1
  1317.                 //nothing to draw
  1318.                 sub        dh,cl
  1319.                 add        esi,ecx
  1320.                 sub        edi,ecx
  1321.                 dec        dl
  1322.                 jnz        BeginLine1
  1323.                 pop        edi
  1324.                 add        edi,ScrWidth
  1325.                 dec     PLY
  1326.                 jmp        ScanLineLoop1
  1327. hdraw1:            //draw only small part of line
  1328.                 sub        cl,dh
  1329.                 mov        al,dh
  1330.                 xor        dh,dh
  1331.                 add        esi,eax
  1332.                 sub        edi,eax
  1333. okk1:            add        esi,ecx
  1334.                 //or        cl,cl
  1335.                 //jz        Lx21
  1336. ok1:            mov        al,[edi]
  1337.                 mov        al,[ebx+eax]
  1338.                 mov        [edi],al
  1339.                 dec        edi
  1340.                 dec        cl
  1341.                 jnz        ok1
  1342. Lx21:            dec        dl
  1343.                 jnz        BeginLine1
  1344. NextLine1:        pop        edi
  1345.                 add        edi,ScrWidth
  1346.                 dec     PLY
  1347.                 jmp        ScanLineLoop1
  1348. ScanLineLoopEnd1:
  1349.                 pop        edi
  1350.                 pop        esi
  1351.             };
  1352.         }else if(x-PLX+1<WindX){
  1353.             int roff=x-WindX+1;
  1354.             int part;
  1355.             __asm{
  1356.                 push    esi
  1357.                 push    edi
  1358.                 mov        edi,ScrOfst
  1359.                 mov        esi,PicPtr
  1360.                 add        esi,addofs
  1361.                 xor        ecx,ecx
  1362.                 xor        eax,eax
  1363.                 mov        ebx,pal
  1364.                 cld
  1365. ScanLineLoop2:
  1366.                 cmp        PLY,0
  1367.                 je        ScanLineLoopEnd2
  1368.                 push    edi
  1369.                 mov        dl,[esi]
  1370.                 inc        esi
  1371.                 or        dl,dl
  1372.                 jz        NextLine2
  1373.                 mov        dh,byte ptr roff
  1374. BeginLine2:        mov        cl,[esi]
  1375.                 sub        dh,cl
  1376.                 sub        edi,ecx
  1377.                 mov        cl,[esi+1]
  1378.                 add        esi,2
  1379.                 //clipping right code
  1380.                 cmp        dh,cl
  1381.                 jge        ok2
  1382.                 //clipping
  1383.                 cmp        dh,0
  1384.                 jle        ntd2
  1385.                 //partial drawing
  1386.                 sub        cl,dh
  1387.                 mov        part,ecx
  1388.                 mov        cl,dh
  1389.                 add        esi,ecx
  1390. lxsd1:            mov        al,[edi]
  1391.                 mov        al,[ebx+eax]
  1392.                 mov        [edi],al
  1393.                 dec        edi
  1394.                 dec        cl
  1395.                 jnz        lxsd1
  1396.                 add        esi,part
  1397.                 jmp        ntd4
  1398. ntd2:            //scanning to the next line
  1399.                 add        esi,ecx
  1400. ntd4:            dec        dl
  1401.                 jz        NextLine2
  1402. ntd22:            mov        cl,[esi+1]
  1403.                 add        esi,2
  1404.                 add        esi,ecx
  1405.                 dec        dl
  1406.                 jnz        ntd22
  1407.                 jmp        NextLine2
  1408. ok2:            sub        dh,cl
  1409.                 add        esi,ecx
  1410. lkfr1:            mov        al,[edi]
  1411.                 mov        al,[ebx+eax]
  1412.                 mov        [edi],al
  1413.                 dec        edi
  1414.                 dec        cl
  1415.                 jnz        lkfr1
  1416. Lx22:            dec        dl
  1417.                 jnz        BeginLine2
  1418. NextLine2:        pop        edi
  1419.                 add        edi,ScrWidth
  1420.                 dec     PLY
  1421.                 jmp        ScanLineLoop2
  1422. ScanLineLoopEnd2:
  1423.                 pop        edi
  1424.                 pop        esi
  1425.             };
  1426.         }else
  1427.         __asm
  1428.         {
  1429.             push    esi
  1430.             push    edi
  1431.             mov        edi,ScrOfst
  1432.             mov        esi,PicPtr
  1433.             add        esi,addofs
  1434.             xor        ecx,ecx
  1435.             xor        ebx,ebx
  1436.             xor        eax,eax
  1437.             mov        ebx,pal
  1438.             cld
  1439. ScanLineLoop:
  1440.             cmp        PLY,0
  1441.             je        ScanLineLoopEnd
  1442.             push    edi
  1443.             mov        dl,[esi]
  1444.             inc        esi
  1445.             or        dl,dl
  1446.             jz        NextLine
  1447. BeginLine:    mov        cl,[esi]
  1448.             sub        edi,ecx
  1449.             mov        cl,[esi+1]
  1450.             add        esi,2
  1451.             add        esi,ecx
  1452. ghte:        mov        al,[edi]
  1453.             mov        al,[eax+ebx]
  1454.             mov        [edi],al
  1455.             dec        edi
  1456.             dec        cl
  1457.             jnz        ghte
  1458. Lx2:        dec        dl
  1459.             jnz        BeginLine
  1460. NextLine:    pop        edi
  1461.             add        edi,ScrWidth
  1462.             dec     PLY
  1463.             jmp        ScanLineLoop
  1464. ScanLineLoopEnd:
  1465.             pop        edi
  1466.             pop        esi
  1467.         }
  1468.     }
  1469. }
  1470. //End of inverted RLC with clipping & encoding->fon
  1471.  
  1472.  
  1473. //End of RLC with clipping & with palette(half-transparent fog)
  1474. void ShowRLChtpal(int x,int y,void* PicPtr,byte* pal)
  1475. {
  1476.     byte precomp[256];
  1477.     //for(int i=0;i<256;i++) precomp[i]=i;
  1478.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  1479.     int addofs=0;
  1480.     int subline=0;
  1481.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  1482.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  1483.     if ((y+PLY-1<WindY)|(y>WindY1)||
  1484.         ((x+PLX<=WindX)||(x>WindX1)||!PLY)) return;
  1485.     if (y<WindY) 
  1486.     {
  1487.         __asm    
  1488.         {    
  1489.             mov        edx,PicPtr
  1490.             add        edx,4
  1491.             xor        eax,eax
  1492.             mov        ecx,WindY
  1493.             sub        ecx,y
  1494.             xor        eax,eax
  1495.             xor        ebx,ebx
  1496. Loop1xx1:    mov        al,[edx]
  1497.             inc        edx
  1498.             or        eax,eax
  1499.             jz        Loop1xx3
  1500. Loop1xx2:    mov        bl,[edx+1]
  1501.             add        edx,ebx
  1502.             add        edx,2
  1503.             dec        eax
  1504.             jnz        Loop1xx2
  1505. Loop1xx3:    dec        cx
  1506.             jnz        Loop1xx1
  1507.             sub        edx,PicPtr
  1508.             sub        edx,4
  1509.             mov        addofs,edx
  1510.         }
  1511.         subline=WindY-y;
  1512.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  1513.     }
  1514.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  1515.     addofs+=4;
  1516.     PLY-=subline;
  1517.     if(PLY>0){
  1518.         if(x<WindX){
  1519.             int roff=WindX-x;
  1520.             __asm{
  1521.                 push    esi
  1522.                 push    edi
  1523.                 mov        edi,ScrOfst
  1524.                 mov        esi,PicPtr
  1525.                 add        esi,addofs
  1526.                 xor        ecx,ecx
  1527.                 xor        eax,eax
  1528.                 mov        ebx,pal
  1529.                 cld
  1530. ScanLineLoop1:
  1531.                 cmp        PLY,0
  1532.                 je        ScanLineLoopEnd1
  1533.                 push    edi
  1534.                 mov        dl,[esi]
  1535.                 inc        esi
  1536.                 or        dl,dl
  1537.                 jz        NextLine1
  1538.                 mov        dh,byte ptr roff
  1539. BeginLine1:        mov        cl,[esi]
  1540.                 sub        dh,cl
  1541.                 add        edi,ecx
  1542.                 mov        cl,[esi+1]
  1543.                 //sub        bh,cl
  1544.                 add        esi,2
  1545.                 //clipping left code
  1546.                 cmp        dh,0
  1547.                 jle        ok1
  1548.                 cmp        dh,cl
  1549.                 jl        hdraw1
  1550.                 //nothing to draw
  1551.                 sub        dh,cl
  1552.                 add        esi,ecx
  1553.                 add        edi,ecx
  1554.                 dec        dl
  1555.                 jnz        BeginLine1
  1556.                 pop        edi
  1557.                 add        edi,ScrWidth
  1558.                 dec     PLY
  1559.                 jmp        ScanLineLoop1
  1560. hdraw1:            //draw only small part of line
  1561.                 sub        cl,dh
  1562.                 xor        eax,eax
  1563.                 mov        al,dh
  1564.                 xor        dh,dh
  1565.                 add        esi,eax
  1566.                 add        edi,eax
  1567. ok1:
  1568.                 mov        ah,[esi]
  1569.                 inc        esi
  1570.                 mov        al,[edi]
  1571.                 mov        al,[ebx+eax]
  1572.                 stosb
  1573.                 dec        cl
  1574.                 jnz        ok1
  1575. Lx21:            dec        dl
  1576.                 jnz        BeginLine1
  1577. NextLine1:        pop        edi
  1578.                 add        edi,ScrWidth
  1579.                 dec     PLY
  1580.                 jmp        ScanLineLoop1
  1581. ScanLineLoopEnd1:
  1582.                 pop        edi
  1583.                 pop        esi
  1584.             };
  1585.         }else if(x+PLX>=WindX1){
  1586.             int roff=WindX1-x+1;
  1587.             int part;
  1588.             __asm{
  1589.                 push    esi
  1590.                 push    edi
  1591.                 mov        edi,ScrOfst
  1592.                 mov        esi,PicPtr
  1593.                 add        esi,addofs
  1594.                 xor        ecx,ecx
  1595.                 xor        eax,eax
  1596.                 mov        ebx,pal
  1597.                 cld
  1598. ScanLineLoop2:
  1599.                 cmp        PLY,0
  1600.                 je        ScanLineLoopEnd2
  1601.                 push    edi
  1602.                 mov        dl,[esi]
  1603.                 inc        esi
  1604.                 or        dl,dl
  1605.                 jz        NextLine2
  1606.                 mov        dh,byte ptr roff
  1607. BeginLine2:        mov        cl,[esi]
  1608.                 sub        dh,cl
  1609.                 add        edi,ecx
  1610.                 mov        cl,[esi+1]
  1611.                 add        esi,2
  1612.                 //clipping right code
  1613.                 cmp        dh,cl
  1614.                 jge        ok2
  1615.                 //clipping
  1616.                 cmp        dh,0
  1617.                 jle        ntd2
  1618.                 //partial drawing
  1619.                 sub        cl,dh
  1620.                 mov        part,ecx
  1621.                 mov        cl,dh
  1622. kkj1:            mov        ah,[esi]
  1623.                 inc        esi
  1624.                 mov        al,[edi]    
  1625.                 mov        al,[ebx+eax]
  1626.                 stosb
  1627.                 dec        cl
  1628.                 jnz        kkj1
  1629.                 add        esi,part
  1630.                 jmp        ntd4
  1631. ntd2:            //scanning to the next line
  1632.                 add        esi,ecx
  1633. ntd4:            dec        dl
  1634.                 jz        NextLine2
  1635. ntd22:            mov        cl,[esi+1]
  1636.                 add        esi,2
  1637.                 add        esi,ecx
  1638.                 dec        dl
  1639.                 jnz        ntd22
  1640.                 jmp        NextLine2
  1641. ok2:            sub        dh,cl
  1642. kkj4:            mov        ah,[esi]
  1643.                 inc        esi
  1644.                 mov        al,[edi]    
  1645.                 mov        al,[ebx+eax]
  1646.                 stosb
  1647.                 dec        cl
  1648.                 jnz        kkj4
  1649. Lx22:            dec        dl
  1650.                 jnz        BeginLine2
  1651. NextLine2:        pop        edi
  1652.                 add        edi,ScrWidth
  1653.                 dec     PLY
  1654.                 jmp        ScanLineLoop2
  1655. ScanLineLoopEnd2:
  1656.                 pop        edi
  1657.                 pop        esi
  1658.             };
  1659.         }else
  1660.         __asm
  1661.         {
  1662.             push    esi
  1663.             push    edi
  1664.             mov        edi,ScrOfst
  1665.             mov        esi,PicPtr
  1666.             add        esi,addofs
  1667.             xor        ecx,ecx
  1668.             xor        ebx,ebx
  1669.             xor        eax,eax
  1670.             mov        ebx,pal
  1671.             cld
  1672. ScanLineLoop:
  1673.             cmp        PLY,0
  1674.             je        ScanLineLoopEnd
  1675.             push    edi
  1676.             mov        dl,[esi]
  1677.             inc        esi
  1678.             or        dl,dl
  1679.             jz        NextLine
  1680. BeginLine:    mov        cl,[esi]
  1681.             add        edi,ecx
  1682.             mov        cl,[esi+1]
  1683.             add        esi,2
  1684. hgaw:        mov        ah,[esi]
  1685.             inc        esi
  1686.             mov        al,[edi]
  1687.             mov        al,[ebx+eax]
  1688.             stosb
  1689.             dec        cl
  1690.             jnz        hgaw
  1691. Lx2:        dec        dl
  1692.             jnz        BeginLine
  1693. NextLine:    pop        edi
  1694.             add        edi,ScrWidth
  1695.             dec     PLY
  1696.             jmp        ScanLineLoop
  1697. ScanLineLoopEnd:
  1698.             pop        edi
  1699.             pop        esi
  1700.         }
  1701.     }
  1702. }
  1703. //End of RLC with clipping & encoding
  1704. //Showing inverse RLC image with clipping & encodint(half-transparent fog)
  1705. void ShowRLCihtpal(int x,int y,void* PicPtr,byte* pal)
  1706. {
  1707.     byte precomp[256];
  1708.     //for(int i=0;i<256;i++) precomp[i]=i;
  1709.     int ScrOfst=int(ScreenPtr)+y*ScrWidth+x;
  1710.     int addofs=0;
  1711.     int subline=0;
  1712.     int PLY=(lpRLCHeader(PicPtr)->SizeY)&65535;
  1713.     int PLX=(lpRLCHeader(PicPtr)->SizeX)&65535;
  1714.     if ((y+PLY-1<WindY)|(y>WindY1)||
  1715.         ((x<WindX)||(x-PLX+1>=WindX1)||!PLY)) return;
  1716.     if (y<WindY) 
  1717.     {
  1718.         __asm    
  1719.         {    
  1720.             mov        edx,PicPtr
  1721.             add        edx,4
  1722.             xor        eax,eax
  1723.             mov        ecx,WindY
  1724.             sub        ecx,y
  1725.             xor        eax,eax
  1726.             xor        ebx,ebx
  1727. Loop1xx1:    mov        al,[edx]
  1728.             inc        edx
  1729.             or        eax,eax
  1730.             jz        Loop1xx3
  1731. Loop1xx2:    mov        bl,[edx+1]
  1732.             add        edx,ebx
  1733.             add        edx,2
  1734.             dec        eax
  1735.             jnz        Loop1xx2
  1736. Loop1xx3:    dec        cx
  1737.             jnz        Loop1xx1
  1738.             sub        edx,PicPtr
  1739.             sub        edx,4
  1740.             mov        addofs,edx
  1741.         }
  1742.         subline=WindY-y;
  1743.         ScrOfst=int(ScreenPtr)+WindY*ScrWidth+x;
  1744.     }
  1745.     if (WindY1<y+PLY-1) subline+=y+PLY-1-WindY1;
  1746.     addofs+=4;
  1747.     PLY-=subline;
  1748.     if(PLY>0){
  1749.         if(x>WindX1){
  1750.             int roff=x-WindX1;
  1751.             __asm{
  1752.                 push    esi
  1753.                 push    edi
  1754.                 mov        edi,ScrOfst
  1755.                 mov        esi,PicPtr
  1756.                 add        esi,addofs
  1757.                 xor        ecx,ecx
  1758.                 xor        eax,eax
  1759.                 mov        ebx,pal
  1760.                 cld
  1761. ScanLineLoop1:
  1762.                 cmp        PLY,0
  1763.                 je        ScanLineLoopEnd1
  1764.                 push    edi
  1765.                 mov        dl,[esi]
  1766.                 inc        esi
  1767.                 or        dl,dl
  1768.                 jz        NextLine1
  1769.                 mov        dh,byte ptr roff
  1770. BeginLine1:        mov        cl,[esi]
  1771.                 sub        dh,cl
  1772.                 sub        edi,ecx
  1773.                 mov        cl,[esi+1]
  1774.                 //sub        bh,cl
  1775.                 add        esi,2
  1776.                 //clipping left code
  1777.                 cmp        dh,0
  1778.                 jle        ok1
  1779.                 cmp        dh,cl
  1780.                 jl        hdraw1
  1781.                 //nothing to draw
  1782.                 sub        dh,cl
  1783.                 add        esi,ecx
  1784.                 sub        edi,ecx
  1785.                 dec        dl
  1786.                 jnz        BeginLine1
  1787.                 pop        edi
  1788.                 add        edi,ScrWidth
  1789.                 dec     PLY
  1790.                 jmp        ScanLineLoop1
  1791. hdraw1:            //draw only small part of line
  1792.                 xor        eax,eax
  1793.                 sub        cl,dh
  1794.                 mov        al,dh
  1795.                 xor        dh,dh
  1796.                 add        esi,eax
  1797.                 sub        edi,eax
  1798. ok1:            mov        ah,[esi]
  1799.                 inc        esi
  1800.                 mov        al,[edi]
  1801.                 mov        al,[ebx+eax]
  1802.                 mov        [edi],al
  1803.                 dec        edi
  1804.                 dec        cl
  1805.                 jnz        ok1
  1806. Lx21:            dec        dl
  1807.                 jnz        BeginLine1
  1808. NextLine1:        pop        edi
  1809.                 add        edi,ScrWidth
  1810.                 dec     PLY
  1811.                 jmp        ScanLineLoop1
  1812. ScanLineLoopEnd1:
  1813.                 pop        edi
  1814.                 pop        esi
  1815.             };
  1816.         }else if(x-PLX+1<WindX){
  1817.             int roff=x-WindX+1;
  1818.             int part;
  1819.             __asm{
  1820.                 push    esi
  1821.                 push    edi
  1822.                 mov        edi,ScrOfst
  1823.                 mov        esi,PicPtr
  1824.                 add        esi,addofs
  1825.                 xor        ecx,ecx
  1826.                 xor        eax,eax
  1827.                 mov        ebx,pal
  1828.                 cld
  1829. ScanLineLoop2:
  1830.                 cmp        PLY,0
  1831.                 je        ScanLineLoopEnd2
  1832.                 push    edi
  1833.                 mov        dl,[esi]
  1834.                 inc        esi
  1835.                 or        dl,dl
  1836.                 jz        NextLine2
  1837.                 mov        dh,byte ptr roff
  1838. BeginLine2:        mov        cl,[esi]
  1839.                 sub        dh,cl
  1840.                 sub        edi,ecx
  1841.                 mov        cl,[esi+1]
  1842.                 add        esi,2
  1843.                 //clipping right code
  1844.                 cmp        dh,cl
  1845.                 jge        ok2
  1846.                 //clipping
  1847.                 cmp        dh,0
  1848.                 jle        ntd2
  1849.                 //partial drawing
  1850.                 sub        cl,dh
  1851.                 mov        part,ecx
  1852.                 mov        cl,dh
  1853. lxsd1:            mov        ah,[esi]
  1854.                 inc        esi
  1855.                 mov        al,[edi]
  1856.                 mov        al,[ebx+eax]
  1857.                 mov        [edi],al
  1858.                 dec        edi
  1859.                 dec        cl
  1860.                 jnz        lxsd1
  1861.                 add        esi,part
  1862.                 jmp        ntd4
  1863. ntd2:            //scanning to the next line
  1864.                 add        esi,ecx
  1865. ntd4:            dec        dl
  1866.                 jz        NextLine2
  1867. ntd22:            mov        cl,[esi+1]
  1868.                 add        esi,2
  1869.                 add        esi,ecx
  1870.                 dec        dl
  1871.                 jnz        ntd22
  1872.                 jmp        NextLine2
  1873. ok2:            sub        dh,cl
  1874. lkfr1:            mov        ah,[esi]
  1875.                 inc        esi
  1876.                 mov        al,[edi]
  1877.                 mov        al,[ebx+eax]
  1878.                 mov        [edi],al
  1879.                 dec        edi
  1880.                 dec        cl
  1881.                 jnz        lkfr1
  1882. Lx22:            dec        dl
  1883.                 jnz        BeginLine2
  1884. NextLine2:        pop        edi
  1885.                 add        edi,ScrWidth
  1886.                 dec     PLY
  1887.                 jmp        ScanLineLoop2
  1888. ScanLineLoopEnd2:
  1889.                 pop        edi
  1890.                 pop        esi
  1891.             };
  1892.         }else
  1893.         __asm
  1894.         {
  1895.             push    esi
  1896.             push    edi
  1897.             mov        edi,ScrOfst
  1898.             mov        esi,PicPtr
  1899.             add        esi,addofs
  1900.             xor        ecx,ecx
  1901.             xor        ebx,ebx
  1902.             xor        eax,eax
  1903.             mov        ebx,pal
  1904.             cld
  1905. ScanLineLoop:
  1906.             cmp        PLY,0
  1907.             je        ScanLineLoopEnd
  1908.             push    edi
  1909.             mov        dl,[esi]
  1910.             inc        esi
  1911.             or        dl,dl
  1912.             jz        NextLine
  1913. BeginLine:    mov        cl,[esi]
  1914.             sub        edi,ecx
  1915.             mov        cl,[esi+1]
  1916.             add        esi,2
  1917. ghte:        mov        ah,[esi]
  1918.             inc        esi
  1919.             mov        al,[edi]
  1920.             mov        al,[eax+ebx]
  1921.             mov        [edi],al
  1922.             dec        edi
  1923.             dec        cl
  1924.             jnz        ghte
  1925. Lx2:        dec        dl
  1926.             jnz        BeginLine
  1927. NextLine:    pop        edi
  1928.             add        edi,ScrWidth
  1929.             dec     PLY
  1930.             jmp        ScanLineLoop
  1931. ScanLineLoopEnd:
  1932.             pop        edi
  1933.             pop        esi
  1934.         }
  1935.     }
  1936. }
  1937. //End of inverted RLC with clipping & encoding(half-transparent fog)
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958. void ShowRLCp1(int x,int y,void* PicPtr)
  1959. {
  1960.     ShowRLCpal(x,y,PicPtr,PAL1);
  1961. }
  1962. void ShowRLCp2(int x,int y,void* PicPtr)
  1963. {
  1964.     ShowRLCpal(x,y,PicPtr,PAL2);
  1965. }
  1966. void ShowRLCp3(int x,int y,void* PicPtr)
  1967. {
  1968.     ShowRLCpal(x,y,PicPtr,PAL3);
  1969. }
  1970. void ShowRLCp4(int x,int y,void* PicPtr)
  1971. {
  1972.     ShowRLCpal(x,y,PicPtr,PAL4);
  1973. }
  1974. void ShowRLCp5(int x,int y,void* PicPtr)
  1975. {
  1976.     ShowRLCpal(x,y,PicPtr,PAL5);
  1977. }
  1978. void ShowRLCp6(int x,int y,void* PicPtr)
  1979. {
  1980.     ShowRLCpal(x,y,PicPtr,PAL6);
  1981. }
  1982. void ShowRLCp7(int x,int y,void* PicPtr)
  1983. {
  1984.     ShowRLCpal(x,y,PicPtr,PAL7);
  1985. }
  1986. void ShowRLCip1(int x,int y,void* PicPtr)
  1987. {
  1988.     ShowRLCipal(x,y,PicPtr,PAL1);
  1989. }
  1990. void ShowRLCip2(int x,int y,void* PicPtr)
  1991. {
  1992.     ShowRLCipal(x,y,PicPtr,PAL2);
  1993. }
  1994. void ShowRLCip3(int x,int y,void* PicPtr)
  1995. {
  1996.     ShowRLCipal(x,y,PicPtr,PAL3);
  1997. }
  1998. void ShowRLCip4(int x,int y,void* PicPtr)
  1999. {
  2000.     ShowRLCipal(x,y,PicPtr,PAL4);
  2001. }
  2002. void ShowRLCip5(int x,int y,void* PicPtr)
  2003. {
  2004.     ShowRLCipal(x,y,PicPtr,PAL5);
  2005. }
  2006. void ShowRLCip6(int x,int y,void* PicPtr)
  2007. {
  2008.     ShowRLCipal(x,y,PicPtr,PAL6);
  2009. }
  2010. void ShowRLCip7(int x,int y,void* PicPtr)
  2011. {
  2012.     ShowRLCipal(x,y,PicPtr,PAL7);
  2013. }
  2014. extern byte fog[8192+1024];
  2015. extern byte wfog[8192];
  2016. extern byte yfog[8192];
  2017. extern byte rfog[8192];
  2018. void ShowRLCShadow(int x,int y,void* PicPtr)
  2019. {
  2020.     ShowRLCfonpal(x,y,PicPtr,fog+1024+2048);
  2021. }
  2022. void ShowRLCiShadow(int x,int y,void* PicPtr)
  2023. {
  2024.     ShowRLCifonpal(x,y,PicPtr,fog+1024+2048);
  2025. }
  2026. void ShowRLCWhite(int x,int y,void* PicPtr)
  2027. {
  2028.     ShowRLCfonpal(x,y,PicPtr,wfog+1024);
  2029. }
  2030. void ShowRLCWFog(int x,int y,void* PicPtr)
  2031. {
  2032.     ShowRLChtpal(x,y,PicPtr,wfog);
  2033. }
  2034. void ShowRLCiWhite(int x,int y,void* PicPtr)
  2035. {
  2036.     ShowRLCifonpal(x,y,PicPtr,wfog+1024);
  2037. }
  2038. void ShowRLCiWFog(int x,int y,void* PicPtr)
  2039. {
  2040.     ShowRLCihtpal(x,y,PicPtr,wfog);
  2041. }
  2042. void ShowRLCFire(int x,int y,void* PicPtr)
  2043. {
  2044.     ShowRLCfonpal(x,y,PicPtr,yfog+4096);
  2045. }
  2046. void ShowRLCiFire(int x,int y,void* PicPtr)
  2047. {
  2048.     ShowRLCifonpal(x,y,PicPtr,yfog+4096);
  2049. }
  2050.  
  2051. //          Loading RLC file
  2052. bool LoadRLC(LPCSTR lpFileName,RLCTable *RLCtbl)
  2053. {
  2054.     ResFile f1=RReset(lpFileName);
  2055.     int xxx=IOresult();
  2056.     if (!xxx) 
  2057.     {
  2058.         DWORD fsz=RFileSize(f1);
  2059.         *RLCtbl=(RLCTable)malloc(fsz);
  2060.         RBlockRead(f1,*RLCtbl,fsz);
  2061.         //if (IOresult)
  2062.         {
  2063.             int shft=int(*RLCtbl);
  2064.             int cnt=((*RLCtbl)->SCount&65535);
  2065.             for(int i=0;i<cnt;i++) (*RLCtbl)->OfsTable[i]+=shft;
  2066.             return true;
  2067.         }
  2068.         free(*RLCtbl);
  2069.         return false;
  2070.     }
  2071.     return false;
  2072. //       Showing RLC item
  2073. void ShowRLCItem(int x,int y,lpRLCTable lprt,int n,byte nt)
  2074. {
  2075.     cntr++;
  2076.     if(cntr>64&&!InCycle){
  2077.         InCycle=true;
  2078.         ProcessMessages();
  2079.         InCycle=false;
  2080.         cntr=0;
  2081.     };
  2082.     if(n<4096){
  2083.         switch(nt){
  2084.         case 1:
  2085.             ShowRLCp1(x,y,(void*)((*lprt)->OfsTable[n]));
  2086.             break;
  2087.         case 2:
  2088.             ShowRLCp2(x,y,(void*)((*lprt)->OfsTable[n]));
  2089.             break;
  2090.         case 3:
  2091.             ShowRLCp3(x,y,(void*)((*lprt)->OfsTable[n]));
  2092.             break;
  2093.         case 4:
  2094.             ShowRLCp4(x,y,(void*)((*lprt)->OfsTable[n]));
  2095.             break;
  2096.         case 5:
  2097.             ShowRLCp5(x,y,(void*)((*lprt)->OfsTable[n]));
  2098.             break;
  2099.         case 6:
  2100.             ShowRLCp6(x,y,(void*)((*lprt)->OfsTable[n]));
  2101.             break;
  2102.         case 7:
  2103.             ShowRLCp7(x,y,(void*)((*lprt)->OfsTable[n]));
  2104.             break;
  2105.         default:
  2106.             ShowRLC(x,y,(void*)((*lprt)->OfsTable[n]));
  2107.         };
  2108.     }else{
  2109.         switch(nt){
  2110.         case 1:
  2111.             ShowRLCip1(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2112.             break;
  2113.         case 2:
  2114.             ShowRLCip2(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2115.             break;
  2116.         case 3:
  2117.             ShowRLCip3(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2118.             break;
  2119.         case 4:
  2120.             ShowRLCip4(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2121.             break;
  2122.         case 5:
  2123.             ShowRLCip5(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2124.             break;
  2125.         case 6:
  2126.             ShowRLCip6(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2127.             break;
  2128.         case 7:
  2129.             ShowRLCip7(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2130.             break;
  2131.         default:
  2132.             ShowRLCi(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2133.         };
  2134.     };
  2135. };
  2136. void ShowRLCItemShadow(int x,int y,lpRLCTable lprt,int n)
  2137. {
  2138.     if(n<4096){
  2139.         ShowRLCShadow(x,y,(void*)((*lprt)->OfsTable[n]));
  2140.     }else{
  2141.         ShowRLCiShadow(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2142.     };
  2143. };
  2144. void ShowRLCItemMutno(int x,int y,lpRLCTable lprt,int n)
  2145. {
  2146.     if(n<4096){
  2147.         ShowRLCWFog(x,y,(void*)((*lprt)->OfsTable[n]));
  2148.     }else{
  2149.         ShowRLCiWFog(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2150.     };
  2151. };
  2152. void ShowRLCItemFired(int x,int y,lpRLCTable lprt,int n)
  2153. {
  2154.     if(n<4096){
  2155.         ShowRLCFire(x,y,(void*)((*lprt)->OfsTable[n]));
  2156.     }else{
  2157.         ShowRLCiFire(x,y,(void*)((*lprt)->OfsTable[n-4096]));
  2158.     };
  2159. };
  2160. int GetRLCWidth(RLCTable lpr,byte n)
  2161. {
  2162.     if (n<lpr->SCount) return (*((lpRLCHeader)((void*)(lpr->OfsTable[n])))).SizeX;
  2163.     else return 0;
  2164. }
  2165. int GetRLCHeight(RLCTable lpr,byte n)
  2166. {
  2167.     if (n<lpr->SCount) return (*((lpRLCHeader)((void*)(lpr->OfsTable[n])))).SizeY;
  2168.     else return 0;
  2169. }
  2170. void RegisterRLCFont(lpRLCFont lrf,RLCTable lpr,int fir)
  2171. {
  2172.     lrf->FirstSymbol=fir;
  2173.     lrf->LastSymbol=lpr->SCount+fir-1;
  2174.     lrf->RLC=lpr;
  2175. }
  2176. void ShowString(int x,int y,LPCSTR lps,lpRLCFont lpf)
  2177. {
  2178.     if (lps==NULL) return;
  2179.     byte    ch;
  2180.     int        i=0;
  2181.     do 
  2182.     {
  2183.         ch=lps[i];
  2184.         if(ch!=0) 
  2185.         {
  2186.             ShowRLCItem(x,y,&(lpf->RLC),lpf->FirstSymbol+ch,0);
  2187.             x+=GetRLCWidth(lpf->RLC,lpf->FirstSymbol+ch);
  2188.         }
  2189.         i++;
  2190.     }
  2191.     while(ch-0);
  2192. }
  2193. void ShowShadString(int x,int y,LPCSTR lps,lpRLCFont lpf)
  2194. {
  2195.     if (lps==NULL) return;
  2196.     byte    ch;
  2197.     int        i=0;
  2198.     do 
  2199.     {
  2200.         ch=lps[i];
  2201.         if(ch!=0) 
  2202.         {
  2203.             ShowRLCItemShadow(x+2,y+2,&(lpf->RLC),lpf->FirstSymbol+ch);
  2204.             ShowRLCItem(x,y,&(lpf->RLC),lpf->FirstSymbol+ch,0);
  2205.             x+=GetRLCWidth(lpf->RLC,lpf->FirstSymbol+ch);
  2206.         }
  2207.         i++;
  2208.     }
  2209.     while(ch-0);
  2210. }
  2211. void LoadPalettes(){
  2212.     ResFile f1=RReset("pal1.dat");
  2213.     RBlockRead(f1,PAL1,256);
  2214.     RClose(f1);
  2215.     f1=RReset("pal2.dat");
  2216.     RBlockRead(f1,PAL2,256);
  2217.     RClose(f1);
  2218.     f1=RReset("pal3.dat");
  2219.     RBlockRead(f1,PAL3,256);
  2220.     RClose(f1);
  2221.     f1=RReset("pal4.dat");
  2222.     RBlockRead(f1,PAL4,256);
  2223.     RClose(f1);
  2224.     f1=RReset("pal5.dat");
  2225.     RBlockRead(f1,PAL5,256);
  2226.     RClose(f1);
  2227.     f1=RReset("pal6.dat");
  2228.     RBlockRead(f1,PAL6,256);
  2229.     RClose(f1);
  2230.     f1=RReset("pal7.dat");
  2231.     RBlockRead(f1,PAL7,256);
  2232.     RClose(f1);
  2233. };
  2234. /* End of Graphics routine */