Subversion Repositories pentevo

Rev

Rev 883 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #include "std.h"
  2.  
  3. #include "emul.h"
  4. #include "vars.h"
  5. #include "draw.h"
  6. #include "dx.h"
  7. #include "dxrframe.h"
  8. #include "dxrendch.h"
  9.  
  10. static RENDER_FUNC auto_ch = nullptr;
  11.  
  12. static void __fastcall _render_ch_ax(unsigned char *dst, unsigned pitch, RENDER_FUNC c2, RENDER_FUNC c4)
  13. {
  14.    if (conf.ch_size == 2) { c2(dst, pitch); return; }
  15.    if (conf.ch_size == 4) { c4(dst, pitch); return; }
  16.    static unsigned counter;
  17.    unsigned i; //Alone Coder 0.36.7
  18.    if (!auto_ch || needclr || !(++counter & 7)) {
  19.       unsigned char n[0x100];
  20.       for (/*unsigned*/ i = 0; i < 0x100; i++) n[i] = 0;
  21.       for (i = 0; i < 0x300; i++) n[temp.base[i+0x1800]] = 1;
  22.       unsigned max = 0;
  23.       for (i = 0; i < 0x100; i++) max += n[i];
  24.       auto_ch = (max > 3) ? c2 : c4;
  25.    }
  26.    auto_ch(dst, pitch);
  27. }
  28.  
  29. static void get_c2_32() {
  30.    unsigned char *base = temp.base;
  31.    unsigned char *attr = base + 0x1800;
  32.  
  33.    unsigned char *ptr = (unsigned char*)t.bs2h;
  34.    for (unsigned p = 0; p < 3; p++) {
  35.       for (unsigned y = 0; y < 8; y++) {
  36.          for (unsigned x = 0; x < 32; x++) {
  37.             unsigned *tab = t.c32tab[*attr++];
  38.             unsigned r =
  39.                 t.settab2[base[y*0x20+x]] +
  40.                 t.settab2[base[y*0x20+x+0x100]];
  41.             *(unsigned*)(ptr+16*x+0) = tab[r>>24];
  42.             *(unsigned*)(ptr+16*x+4) = tab[(r>>16)&0xFF];
  43.             *(unsigned*)(ptr+16*x+8) = tab[(r>>8)&0xFF];
  44.             *(unsigned*)(ptr+16*x+12) = tab[r&0xFF];
  45.             r = t.settab2[base[y*0x20+x+0x200]] +
  46.                 t.settab2[base[y*0x20+x+0x300]];
  47.             *(unsigned*)(ptr+16*x+129*4+0) = tab[r>>24];
  48.             *(unsigned*)(ptr+16*x+129*4+4) = tab[(r>>16)&0xFF];
  49.             *(unsigned*)(ptr+16*x+129*4+8) = tab[(r>>8)&0xFF];
  50.             *(unsigned*)(ptr+16*x+129*4+12) = tab[r&0xFF];
  51.             r = t.settab2[base[y*0x20+x+0x400]] +
  52.                 t.settab2[base[y*0x20+x+0x500]];
  53.             *(unsigned*)(ptr+16*x+129*8+0) = tab[r>>24];
  54.             *(unsigned*)(ptr+16*x+129*8+4) = tab[(r>>16)&0xFF];
  55.             *(unsigned*)(ptr+16*x+129*8+8) = tab[(r>>8)&0xFF];
  56.             *(unsigned*)(ptr+16*x+129*8+12) = tab[r&0xFF];
  57.             r = t.settab2[base[y*0x20+x+0x600]] +
  58.                 t.settab2[base[y*0x20+x+0x700]];
  59.             *(unsigned*)(ptr+16*x+129*12+0) = tab[r>>24];
  60.             *(unsigned*)(ptr+16*x+129*12+4) = tab[(r>>16)&0xFF];
  61.             *(unsigned*)(ptr+16*x+129*12+8) = tab[(r>>8)&0xFF];
  62.             *(unsigned*)(ptr+16*x+129*12+12) = tab[r&0xFF];
  63.          }
  64.          *(unsigned*)(ptr+512) = *(unsigned*)(ptr+512-4);
  65.          *(unsigned*)(ptr+512+129*4) = *(unsigned*)(ptr+512+129*4-4);
  66.          *(unsigned*)(ptr+512+129*8) = *(unsigned*)(ptr+512+129*8-4);
  67.          *(unsigned*)(ptr+512+129*12) = *(unsigned*)(ptr+512+129*12-4);
  68.          ptr += 129*16;
  69.       }
  70.       base += 2048;
  71.    }
  72. }
  73. static void get_c4_32() {
  74.    unsigned char *base = temp.base;
  75.    unsigned char *attr = base + 0x1800;
  76.  
  77.    unsigned char *ptr = (unsigned char*)t.bs4h;
  78.    for (unsigned p = 0; p < 3; p++) {
  79.       for (unsigned y = 0; y < 8; y++) {
  80.          for (unsigned x = 0; x < 32; x++) {
  81.             unsigned *tab = t.c32tab[*attr++];
  82.             unsigned r =
  83.                 t.settab[base[y*0x20+x]] +
  84.                 t.settab[base[y*0x20+x+0x100]] +
  85.                 t.settab[base[y*0x20+x+0x200]] +
  86.                 t.settab[base[y*0x20+x+0x300]];
  87.             *(unsigned*)(ptr+8*x+0) = tab[r >> 8];
  88.             *(unsigned*)(ptr+8*x+4) = tab[r & 0xFF];
  89.             r = t.settab[base[y*0x20+x+0x400]] +
  90.                 t.settab[base[y*0x20+x+0x500]] +
  91.                 t.settab[base[y*0x20+x+0x600]] +
  92.                 t.settab[base[y*0x20+x+0x700]];
  93.             *(unsigned*)(ptr+8*x+65*4+0) = tab[r >> 8];
  94.             *(unsigned*)(ptr+8*x+65*4+4) = tab[r & 0xFF];
  95.          }
  96.          *(unsigned*)(ptr+256) = *(unsigned*)(ptr+256-4);
  97.          *(unsigned*)(ptr+256+65*4) = *(unsigned*)(ptr+256+65*4-4);
  98.          ptr += 65*8;
  99.       }
  100.       base += 2048;
  101.    }
  102. }
  103.  
  104. static void __fastcall _render_c2x16(unsigned char *dst, unsigned pitch) {
  105.    get_c2_32();
  106.    if(!(temp.rflags & RF_128x96))
  107.    {
  108.        temp.rflags = ((temp.rflags & ~RF_64x48) | RF_128x96);
  109.        set_vidmode();
  110.    }
  111.    else
  112.    for (unsigned y = 0; y < 96; y++) {
  113.       for (unsigned x = 0; x < 128*4; x+=4)
  114.          *(unsigned*)(dst+x) = (*(unsigned*)((char*)t.bs2h[y]+2*x) & 0x0000FFFF) +
  115.                                (*(unsigned*)((char*)t.bs2h[y]+2*x+4) & 0xFFFF0000);
  116.       dst += pitch;
  117.    }
  118. }
  119. static void __fastcall _render_c4x16(unsigned char *dst, unsigned pitch) {
  120.    get_c4_32();
  121.    if(!(temp.rflags & RF_64x48))
  122.    {
  123.        temp.rflags = ((temp.rflags & ~RF_128x96) | RF_64x48);
  124.        set_vidmode();
  125.    }
  126.    else
  127.    for (unsigned y = 0; y < 48; y++) {
  128.       for (unsigned x = 0; x < 64*4; x+=4)
  129.          *(unsigned*)(dst+x) = (*(unsigned*)((char*)t.bs4h[y]+2*x) & 0x0000FFFF) +
  130.                                (*(unsigned*)((char*)t.bs4h[y]+2*x+4) & 0xFFFF0000);
  131.       dst += pitch;
  132.    }
  133. }
  134.  
  135. void __fastcall render_ch_ov(unsigned char *dst, unsigned pitch)
  136. {
  137.    _render_ch_ax(dst, pitch, _render_c2x16, _render_c4x16);
  138. }
  139.  
  140. static void _render_blt(unsigned char *dst, unsigned pitch, unsigned char *src, unsigned dp)
  141. {
  142.    for (unsigned y = 0; y < temp.oy; y++) {
  143.       for (unsigned x = 0; x < temp.ox; x++)
  144.          *(unsigned*)(dst+4*x) = *(unsigned*)(src+4*x);
  145.       dst += pitch; src += dp;
  146.    }
  147. }
  148.  
  149. static void __fastcall  _render_c2hw(unsigned char *dst, unsigned pitch)
  150. {
  151.    get_c2_32();
  152.    if(!(temp.rflags & RF_128x96))
  153.    {
  154.        temp.rflags = ((temp.rflags & ~RF_64x48) | RF_128x96);
  155.        set_vidmode();
  156.        return;
  157.    }
  158.    _render_blt(dst, pitch, (unsigned char*)t.bs2h, sizeof t.bs2h[0]);
  159. }
  160.  
  161. static void __fastcall  _render_c4hw(unsigned char *dst, unsigned pitch)
  162. {
  163.    get_c4_32();
  164.    if(!(temp.rflags & RF_64x48))
  165.    {
  166.        temp.rflags = ((temp.rflags & ~RF_128x96) | RF_64x48);
  167.        set_vidmode();
  168.        return;
  169.    }
  170.    _render_blt(dst, pitch, (unsigned char*)t.bs4h, sizeof t.bs4h[0]);
  171. }
  172.  
  173. void __fastcall render_ch_hw(unsigned char *dst, unsigned pitch)
  174. {
  175.    _render_ch_ax(dst, pitch, _render_c2hw, _render_c4hw);
  176. }
  177.  
  178. static void __fastcall  _render_c2x16b(unsigned char *dst, unsigned pitch)
  179. {
  180.    if (conf.updateb)
  181.    {
  182.        if (!conf.fast_sl) rend_frame_16d(dst, pitch);
  183.        else rend_frame_16d1(dst, pitch*2);
  184.    }
  185.  
  186.    get_c2_32();
  187.    dst += pitch * (temp.b_top*2) + temp.b_left*2*sizeof(WORD);
  188.  
  189.    unsigned ll[512*2];
  190.    unsigned y; //Alone Coder 0.36.7
  191.    unsigned x; //Alone Coder 0.36.7
  192.    for (/*unsigned*/ y = 0; y < 512*4; y += 4)
  193.       *(unsigned*)((unsigned char*)ll+y) = 0;
  194.    for (y = 0; y < 96; y++) {
  195.       unsigned *bp = t.bs2h[y];
  196.       for (/*unsigned*/ x = 0; x < 128; x++) {
  197.          unsigned *dst1 = ll + 512 + x*4;
  198.          unsigned b0 = bp[x] & 0xFCFCFC, b4 = bp[x+1] & 0xFCFCFC;
  199.          dst1[0] = bp[x];
  200.          dst1[1] = (3*b0+b4)/4;
  201.          dst1[2] = (b0+b4)/2;
  202.          dst1[3] = (b0+3*b4)/4;
  203.       }
  204.  
  205.       if (temp.hi15) {
  206. #define ps1(yy)                                                              \
  207.       for (x = 0; x < 512/2; x++) {                                          \
  208.          unsigned r1 = ll[2*x] & 0xFCFCFC, r2 = ll[512+2*x] & 0xFCFCFC;      \
  209.          unsigned r = (r2*yy + r1*(4-yy))/4;                                 \
  210.          r1 = ll[2*x+1] & 0xFCFCFC, r2 = ll[512+2*x+1] & 0xFCFCFC;           \
  211.          r2 = (r2*yy + r1*(4-yy))/4;                                         \
  212.          *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>6) & 0x03E0) + ((r>>9) & 0x7C00) + \
  213.             ((r2<<13) & 0x1F0000) + ((r2<<10) & 0x03E00000) + ((r2<<7) & 0x7C000000);      \
  214.       }                                                                      \
  215.       dst += pitch;
  216.          ps1(0); ps1(1); ps1(2); ps1(3);
  217. #undef ps1
  218.       } else {
  219. #define ps1(yy)                                                              \
  220.       for (x = 0; x < 512/2; x++) {                                          \
  221.          unsigned r1 = ll[2*x] & 0xFCFCFC, r2 = ll[512+2*x] & 0xFCFCFC;      \
  222.          unsigned r = (r2*yy + r1*(4-yy))/4;                                 \
  223.          r1 = ll[2*x+1] & 0xFCFCFC, r2 = ll[512+2*x+1] & 0xFCFCFC;           \
  224.          r2 = (r2*yy + r1*(4-yy))/4;                                         \
  225.          *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>5) & 0x07E0) + ((r>>8) & 0xF800) + \
  226.             ((r2<<13) & 0x1F0000) + ((r2<<11) & 0x07E00000) + ((r2<<8) & 0xF8000000);      \
  227.       }                                                                      \
  228.       dst += pitch;
  229.          ps1(0); ps1(1); ps1(2); ps1(3);
  230. #undef ps1
  231.       }
  232.       for (x = 0; x < 512; x++) ll[x] = ll[x+512];
  233.    }
  234. }
  235. static void __fastcall  _render_c2x16bl(unsigned char *dst, unsigned pitch)
  236. {
  237.    rend_frame16(dst, pitch);
  238.    get_c2_32();
  239.    dst += pitch * temp.b_top + temp.b_left*sizeof(WORD);
  240.  
  241.    unsigned ll[256*2];
  242.    unsigned y; //Alone Coder 0.36.7
  243.    unsigned x; //Alone Coder 0.36.7
  244.    for (/*unsigned*/ y = 0; y < 256*4; y += 4)
  245.       *(unsigned*)((unsigned char*)ll+y) = 0;
  246.    for (y = 0; y < 96; y++) {
  247.       unsigned *bp = t.bs2h[y];
  248.       for (/*unsigned*/ x = 0; x < 128; x++) {
  249.          unsigned *dst1 = ll + 256 + x*2;
  250.          unsigned b0 = bp[x] & 0xFEFEFE, b2 = bp[x+1] & 0xFEFEFE;
  251.          dst1[0] = bp[x];
  252.          dst1[1] = (b0+b2)/2;
  253.       }
  254.  
  255.       if (temp.hi15) {
  256. #define ps1(yy)                                                              \
  257.       for (x = 0; x < 256/2; x++) {                                          \
  258.          unsigned r1 = ll[2*x] & 0xFEFEFE, r2 = ll[512+2*x] & 0xFEFEFE;      \
  259.          unsigned r = (r2*yy + r1*(2-yy))/2;                                 \
  260.          r1 = ll[2*x+1] & 0xFEFEFE, r2 = ll[256+2*x+1] & 0xFEFEFE;           \
  261.          r2 = (r2*yy + r1*(2-yy))/2;                                         \
  262.          *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>6) & 0x03E0) + ((r>>9) & 0x7C00) + \
  263.             ((r2<<13) & 0x1F0000) + ((r2<<10) & 0x03E00000) + ((r2<<7) & 0x7C000000);      \
  264.       }                                                                      \
  265.       dst += pitch;
  266.          ps1(0); ps1(1);
  267. #undef ps1
  268.       } else {
  269. #define ps1(yy)                                                              \
  270.       for (x = 0; x < 256/2; x++) {                                          \
  271.          unsigned r1 = ll[2*x] & 0xFEFEFE, r2 = ll[256+2*x] & 0xFEFEFE;      \
  272.          unsigned r = (r2*yy + r1*(2-yy))/2;                                 \
  273.          r1 = ll[2*x+1] & 0xFEFEFE, r2 = ll[256+2*x+1] & 0xFEFEFE;           \
  274.          r2 = (r2*yy + r1*(2-yy))/2;                                         \
  275.          *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>5) & 0x07E0) + ((r>>8) & 0xF800) + \
  276.             ((r2<<13) & 0x1F0000) + ((r2<<11) & 0x07E00000) + ((r2<<8) & 0xF8000000);      \
  277.       }                                                                      \
  278.       dst += pitch;
  279.          ps1(0); ps1(1);
  280. #undef ps1
  281.       }
  282.       for (x = 0; x < 256; x++) ll[x] = ll[x+256];
  283.    }
  284. }
  285. static void __fastcall  _render_c4x16b(unsigned char *dst, unsigned pitch)
  286. {
  287.    if (conf.updateb)
  288.    {
  289.        if (!conf.fast_sl) rend_frame_16d(dst, pitch);
  290.        else rend_frame_16d1(dst, pitch*2);
  291.    }
  292.  
  293.    get_c4_32();
  294.    dst += pitch * (temp.b_top*2) + 2*temp.b_left*sizeof(WORD);
  295.  
  296.    unsigned ll[512*2];
  297.    unsigned y; //Alone Coder 0.36.7
  298.    unsigned x; //Alone Coder 0.36.7
  299.    for (/*unsigned*/ y = 0; y < 512*4; y += 4)
  300.       *(unsigned*)(((unsigned char*)ll)+y) = 0;
  301.    for (y = 0; y < 48; y++) {
  302.       unsigned *bp = t.bs4h[y];
  303.       for (/*unsigned*/ x = 0; x < 64; x++) {
  304.          unsigned *dst1 = ll + 512 + x*8;
  305.          unsigned b0 = bp[x] & 0xF8F8F8, b8 = bp[x+1] & 0xF8F8F8;
  306.          dst1[0] = bp[x];
  307.          dst1[1] = (7*b0+b8)/8;
  308.          dst1[2] = (3*b0+b8)/4;
  309.          dst1[3] = (5*b0+3*b8)/8;
  310.          dst1[4] = (b0+b8)/2;
  311.          dst1[5] = (3*b0+5*b8)/8;
  312.          dst1[6] = (b0+3*b8)/4;
  313.          dst1[7] = (b0+7*b8)/8;
  314.       }
  315.       if (temp.hi15) {
  316. #define ps1(yy)                                                            \
  317.          for (x = 0; x < 512/2; x++) {                                     \
  318.             unsigned r1 = ll[2*x] & 0xF8F8F8, r2 = ll[2*x+512] & 0xF8F8F8; \
  319.             unsigned r = (r2*yy + r1*(8-yy))/8;                            \
  320.             r1 = ll[2*x+1] & 0xF8F8F8, r2 = ll[2*x+1+512] & 0xF8F8F8;      \
  321.             r2 = ((r2*yy + r1*(8-yy))/8);                         \
  322.             *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>6) & 0x03E0) + ((r>>9) & 0x7C00) +\
  323.                ((r2<<13) & 0x1F0000) + ((r2<<10) & 0x03E00000) + ((r2<<7) & 0x7C000000);      \
  324.          }                                                                 \
  325.          dst += pitch;
  326.          ps1(0); ps1(1); ps1(2); ps1(3); ps1(4); ps1(5); ps1(6); ps1(7);
  327. #undef ps1
  328.       } else {
  329. #define ps1(yy)                                                            \
  330.          for (x = 0; x < 512/2; x++) {                                     \
  331.             unsigned r1 = ll[2*x] & 0xF8F8F8, r2 = ll[2*x+512] & 0xF8F8F8; \
  332.             unsigned r = (r2*yy + r1*(8-yy))/8;                            \
  333.             r1 = ll[2*x+1] & 0xF8F8F8, r2 = ll[2*x+1+512] & 0xF8F8F8;      \
  334.             r2 = ((r2*yy + r1*(8-yy))/8);                         \
  335.             *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>5) & 0x07E0) + ((r>>8) & 0xF800) + \
  336.                ((r2<<13) & 0x1F0000) + ((r2<<11) & 0x07E00000) + ((r2<<8) & 0xF8000000);      \
  337.          }                                                                 \
  338.          dst += pitch;
  339.       ps1(0); ps1(1); ps1(2); ps1(3); ps1(4); ps1(5); ps1(6); ps1(7);
  340. #undef ps1
  341.       }
  342.       for (x = 0; x < 512; x++) ll[x] = ll[x+512];
  343.    }
  344. }
  345. static void __fastcall  _render_c4x16bl(unsigned char *dst, unsigned pitch)
  346. {
  347.    rend_frame16(dst, pitch);
  348.    get_c4_32();
  349.    dst += pitch * temp.b_top + temp.b_left*sizeof(WORD);
  350.  
  351.    unsigned ll[256*2];
  352.    unsigned y; //Alone Coder 0.36.7
  353.    unsigned x; //Alone Coder 0.36.7
  354.    for (/*unsigned*/ y = 0; y < 256*4; y += 4)
  355.       *(unsigned*)(((unsigned char*)ll)+y) = 0;
  356.    for (y = 0; y < 48; y++) {
  357.       unsigned *bp = t.bs4h[y];
  358.       for (/*unsigned*/ x = 0; x < 64; x++) {
  359.          unsigned *dst1 = ll + 256 + x*4;
  360.          unsigned b0 = bp[x] & 0xFCFCFC, b4 = bp[x+1] & 0xFCFCFC;
  361.          dst1[0] = bp[x];
  362.          dst1[1] = (3*b0+b4)/4;
  363.          dst1[2] = (b0+b4)/2;
  364.          dst1[3] = (b0+3*b4)/4;
  365.       }
  366.       if (temp.hi15) {
  367. #define ps1(yy)                                                            \
  368.          for (x = 0; x < 256/2; x++) {                                     \
  369.             unsigned r1 = ll[2*x] & 0xFCFCFC, r2 = ll[2*x+256] & 0xFCFCFC; \
  370.             unsigned r = (r2*yy + r1*(4-yy))/4;                            \
  371.             r1 = ll[2*x+1] & 0xFCFCFC, r2 = ll[2*x+1+256] & 0xFCFCFC;      \
  372.             r2 = ((r2*yy + r1*(4-yy))/4);                         \
  373.             *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>6) & 0x03E0) + ((r>>9) & 0x7C00) +\
  374.                ((r2<<13) & 0x1F0000) + ((r2<<10) & 0x03E00000) + ((r2<<7) & 0x7C000000);      \
  375.          }                                                                 \
  376.          dst += pitch;
  377.          ps1(0); ps1(1); ps1(2); ps1(3);
  378. #undef ps1
  379.       } else {
  380. #define ps1(yy)                                                            \
  381.          for (x = 0; x < 256/2; x++) {                                     \
  382.             unsigned r1 = ll[2*x] & 0xFCFCFC, r2 = ll[2*x+256] & 0xFCFCFC; \
  383.             unsigned r = (r2*yy + r1*(4-yy))/4;                            \
  384.             r1 = ll[2*x+1] & 0xFCFCFC, r2 = ll[2*x+1+256] & 0xFCFCFC;      \
  385.             r2 = ((r2*yy + r1*(4-yy))/4);                         \
  386.             *(unsigned*)(dst+4*x) = ((r>>3) & 0x1F) + ((r>>5) & 0x07E0) + ((r>>8) & 0xF800) + \
  387.                ((r2<<13) & 0x1F0000) + ((r2<<11) & 0x07E00000) + ((r2<<8) & 0xF8000000);      \
  388.          }                                                                 \
  389.          dst += pitch;
  390.       ps1(0); ps1(1); ps1(2); ps1(3);
  391. #undef ps1
  392.       }
  393.       for (x = 0; x < 256; x++) ll[x] = ll[x+256];
  394.    }
  395. }
  396.  
  397. void __fastcall render_c16bl(unsigned char *dst, unsigned pitch)
  398. {
  399.    _render_ch_ax(dst, pitch, _render_c2x16bl, _render_c4x16bl);
  400. }
  401.  
  402. void __fastcall render_c16b(unsigned char *dst, unsigned pitch)
  403. {
  404.    _render_ch_ax(dst, pitch, _render_c2x16b, _render_c4x16b);
  405. }
  406.  
  407. void __fastcall render_c4x32b(unsigned char *dst, unsigned pitch)
  408. {
  409.    if (!conf.fast_sl) rend_frame_32d(dst, pitch);
  410.    else rend_frame_32d1(dst, pitch*2);
  411.  
  412.    get_c4_32();
  413.    dst += pitch * (temp.b_top*2) + 2*temp.b_left*sizeof(DWORD);
  414.  
  415.    unsigned ll[512*2];
  416.    unsigned y; //Alone Coder 0.36.7
  417.    unsigned x; //Alone Coder 0.36.7
  418.    for (/*unsigned*/ y = 0; y < 512*4; y += 4)
  419.       *(unsigned*)(((unsigned char*)ll)+y) = 0;
  420.    #define inter(a,b,c) ((unsigned char)((a*(8-c)+b*c)>>3))
  421.    for (y = 0; y < 48; y++) {
  422.       unsigned *bp = t.bs4h[y];
  423.       for (/*unsigned*/ x = 0; x < 64; x++) {
  424.          unsigned char *dst1 = (unsigned char*)ll + 512*4 + x*8*4;
  425.          unsigned char *src = (unsigned char*)&bp[x];
  426.          #define inter2(n) dst1[n*4]=inter(src[0],src[4],n); dst1[n*4+1]=inter(src[1],src[5],n); dst1[n*4+2]=inter(src[2],src[6],n);
  427.          inter2(0);inter2(1);inter2(2);inter2(3);
  428.          inter2(4);inter2(5);inter2(6);inter2(7);
  429.          #undef inter2
  430.       }
  431.       unsigned char *l1 = (unsigned char*)ll, *l2 = (unsigned char*)(ll+512);
  432.       #define ps1(yy)                                                   \
  433.         for (x = 0; x < 512; x++) {                                     \
  434.            dst[4*x+0] = inter(l1[4*x+0], l2[4*x+0], yy);                \
  435.            dst[4*x+1] = inter(l1[4*x+1], l2[4*x+1], yy);                \
  436.            dst[4*x+2] = inter(l1[4*x+2], l2[4*x+2], yy);                \
  437.         } dst += pitch;
  438.       ps1(0);ps1(1);ps1(2);ps1(3);ps1(4);ps1(5);ps1(6);ps1(7);
  439.       #undef ps1
  440.       for (x = 0; x < 512; x++) ll[x] = ll[x+512];
  441.    }
  442.    #undef inter
  443. }
  444.