Subversion Repositories pentevo

Rev

Rev 796 | 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 "dxrframe.h"
  7. #include "dxrcopy.h"
  8. #include "dxr_prof.h"
  9.  
  10. static void line8_prof(unsigned char *dst, unsigned char *src, unsigned *tab0)
  11. {
  12.    for (unsigned x = 0; x < 512; x += 64)
  13.    {
  14.       unsigned s = *(unsigned*)(src+0x2000);
  15.       unsigned t = *(unsigned*)src;
  16.       unsigned as, at;
  17.       if(conf.profi_monochrome)
  18.       {
  19.           as = (comp.border_attr | ((~comp.border_attr)<<3)) & 0x3F;
  20.           at = as = as | (as<<8) | (as<<16) | (as<<24);
  21.       }
  22.       else
  23.       {
  24.           as = *(unsigned*)(src + 0x2000 + 0x34*PAGE);
  25.           at = *(unsigned*)(src + 0x34*PAGE);
  26.       }
  27.       unsigned *tab = tab0 + ((as << 4) & 0xFF0);
  28.       *(unsigned*)(dst+x)    = tab[((s >> 4)  & 0xF)];
  29.       *(unsigned*)(dst+x+4)  = tab[((s >> 0)  & 0xF)];
  30.       tab = tab0 + ((at << 4) & 0xFF0);
  31.       *(unsigned*)(dst+x+8)  = tab[((t >> 4)  & 0xF)];
  32.       *(unsigned*)(dst+x+12) = tab[((t >> 0)  & 0xF)];
  33.       tab = tab0 + ((as >> 4) & 0xFF0);
  34.       *(unsigned*)(dst+x+16) = tab[((s >> 12) & 0xF)];
  35.       *(unsigned*)(dst+x+20) = tab[((s >> 8)  & 0xF)];
  36.       tab = tab0 + ((at >> 4) & 0xFF0);
  37.       *(unsigned*)(dst+x+24) = tab[((t >> 12) & 0xF)];
  38.       *(unsigned*)(dst+x+28) = tab[((t >> 8)  & 0xF)];
  39.       tab = tab0 + ((as >> 12) & 0xFF0);
  40.       *(unsigned*)(dst+x+32) = tab[((s >> 20) & 0xF)];
  41.       *(unsigned*)(dst+x+36) = tab[((s >> 16) & 0xF)];
  42.       tab = tab0 + ((at >> 12) & 0xFF0);
  43.       *(unsigned*)(dst+x+40) = tab[((t >> 20) & 0xF)];
  44.       *(unsigned*)(dst+x+44) = tab[((t >> 16) & 0xF)];
  45.       tab = tab0 + ((as >> 20) & 0xFF0);
  46.       *(unsigned*)(dst+x+48) = tab[((s >> 28) & 0xF)];
  47.       *(unsigned*)(dst+x+52) = tab[((s >> 24) & 0xF)];
  48.       tab = tab0 + ((at >> 20) & 0xFF0);
  49.       *(unsigned*)(dst+x+56) = tab[((t >> 28) & 0xF)];
  50.       *(unsigned*)(dst+x+60) = tab[((t >> 24) & 0xF)];
  51.       src += 4;
  52.    }
  53. }
  54.  
  55. static void line16_prof(unsigned char *dst, unsigned char *src, unsigned *tab0)
  56. {
  57.    for (unsigned x = 0; x < 1024; x += 128)
  58.    {
  59.       unsigned s = *(unsigned*)(src+0x2000);
  60.       unsigned t = *(unsigned*)src;
  61.       unsigned as, at;
  62.       if(conf.profi_monochrome)
  63.       {
  64.           as = (comp.border_attr | ((~comp.border_attr)<<3)) & 0x3F;
  65.           at = as = as | (as<<8) | (as<<16) | (as<<24);
  66.       }
  67.       else
  68.       {
  69.           as = *(unsigned*)(src + 0x2000 + 0x34*PAGE);
  70.           at = *(unsigned*)(src + 0x34*PAGE);
  71.       }
  72.       unsigned *tab = tab0 + ((as << 2) & 0x3FC);
  73.       *(unsigned*)(dst+x+0x00) = tab[((s >> 6)  & 0x03)];
  74.       *(unsigned*)(dst+x+0x04) = tab[((s >> 4)  & 0x03)];
  75.       *(unsigned*)(dst+x+0x08) = tab[((s >> 2)  & 0x03)];
  76.       *(unsigned*)(dst+x+0x0C) = tab[((s >> 0)  & 0x03)];
  77.       tab = tab0 + ((at << 2) & 0x3FC);
  78.       *(unsigned*)(dst+x+0x10) = tab[((t >> 6)  & 0x03)];
  79.       *(unsigned*)(dst+x+0x14) = tab[((t >> 4)  & 0x03)];
  80.       *(unsigned*)(dst+x+0x18) = tab[((t >> 2)  & 0x03)];
  81.       *(unsigned*)(dst+x+0x1C) = tab[((t >> 0)  & 0x03)];
  82.       tab = tab0 + ((as >> 6) & 0x3FC);
  83.       *(unsigned*)(dst+x+0x20) = tab[((s >> 14) & 0x03)];
  84.       *(unsigned*)(dst+x+0x24) = tab[((s >> 12) & 0x03)];
  85.       *(unsigned*)(dst+x+0x28) = tab[((s >> 10) & 0x03)];
  86.       *(unsigned*)(dst+x+0x2C) = tab[((s >> 8)  & 0x03)];
  87.       tab = tab0 + ((at >> 6) & 0x3FC);
  88.       *(unsigned*)(dst+x+0x30) = tab[((t >> 14) & 0x03)];
  89.       *(unsigned*)(dst+x+0x34) = tab[((t >> 12) & 0x03)];
  90.       *(unsigned*)(dst+x+0x38) = tab[((t >> 10) & 0x03)];
  91.       *(unsigned*)(dst+x+0x3C) = tab[((t >> 8)  & 0x03)];
  92.       tab = tab0 + ((as >> 14) & 0x3FC);
  93.       *(unsigned*)(dst+x+0x40) = tab[((s >> 22) & 0x03)];
  94.       *(unsigned*)(dst+x+0x44) = tab[((s >> 20) & 0x03)];
  95.       *(unsigned*)(dst+x+0x48) = tab[((s >> 18) & 0x03)];
  96.       *(unsigned*)(dst+x+0x4C) = tab[((s >> 16) & 0x03)];
  97.       tab = tab0 + ((at >> 14) & 0x3FC);
  98.       *(unsigned*)(dst+x+0x50) = tab[((t >> 22) & 0x03)];
  99.       *(unsigned*)(dst+x+0x54) = tab[((t >> 20) & 0x03)];
  100.       *(unsigned*)(dst+x+0x58) = tab[((t >> 18) & 0x03)];
  101.       *(unsigned*)(dst+x+0x5C) = tab[((t >> 16) & 0x03)];
  102.       tab = tab0 + ((as >> 22) & 0x3FC);
  103.       *(unsigned*)(dst+x+0x60) = tab[((s >> 30) & 0x03)];
  104.       *(unsigned*)(dst+x+0x64) = tab[((s >> 28) & 0x03)];
  105.       *(unsigned*)(dst+x+0x68) = tab[((s >> 26) & 0x03)];
  106.       *(unsigned*)(dst+x+0x6C) = tab[((s >> 24) & 0x03)];
  107.       tab = tab0 + ((at >> 22) & 0x3FC);
  108.       *(unsigned*)(dst+x+0x70) = tab[((t >> 30) & 0x03)];
  109.       *(unsigned*)(dst+x+0x74) = tab[((t >> 28) & 0x03)];
  110.       *(unsigned*)(dst+x+0x78) = tab[((t >> 26) & 0x03)];
  111.       *(unsigned*)(dst+x+0x7C) = tab[((t >> 24) & 0x03)];
  112.       src += 4;
  113.    }
  114. }
  115.  
  116. static void line32_prof(unsigned char *dst, unsigned char *src, unsigned *tab0)
  117. {
  118.    for (unsigned x = 0; x < 512*4; x += 64)
  119.    {
  120.       unsigned s = src[0x2000];
  121.       unsigned char as, at;
  122.       if(conf.profi_monochrome)
  123.       {
  124.           at = as = (comp.border_attr | ((~comp.border_attr)<<3)) & 0x3F;
  125.       }
  126.       else
  127.       {
  128.           as = src[0x2000 + 0x34*PAGE];
  129.           at = src[0x34*PAGE];
  130.       }
  131.       unsigned *tab = tab0 + as;
  132.       *(unsigned*)(dst+x)    = tab[((s << 1) & 0x100)];
  133.       *(unsigned*)(dst+x+4)  = tab[((s << 2) & 0x100)];
  134.       *(unsigned*)(dst+x+8)  = tab[((s << 3) & 0x100)];
  135.       *(unsigned*)(dst+x+12) = tab[((s << 4) & 0x100)];
  136.       *(unsigned*)(dst+x+16) = tab[((s << 5) & 0x100)];
  137.       *(unsigned*)(dst+x+20) = tab[((s << 6) & 0x100)];
  138.       *(unsigned*)(dst+x+24) = tab[((s << 7) & 0x100)];
  139.       *(unsigned*)(dst+x+28) = tab[((s << 8) & 0x100)];
  140.       s = src[0];
  141.       tab = tab0 + at;
  142.       *(unsigned*)(dst+x+32) = tab[((s << 1) & 0x100)];
  143.       *(unsigned*)(dst+x+36) = tab[((s << 2) & 0x100)];
  144.       *(unsigned*)(dst+x+40) = tab[((s << 3) & 0x100)];
  145.       *(unsigned*)(dst+x+44) = tab[((s << 4) & 0x100)];
  146.       *(unsigned*)(dst+x+48) = tab[((s << 5) & 0x100)];
  147.       *(unsigned*)(dst+x+52) = tab[((s << 6) & 0x100)];
  148.       *(unsigned*)(dst+x+56) = tab[((s << 7) & 0x100)];
  149.       *(unsigned*)(dst+x+60) = tab[((s << 8) & 0x100)];
  150.       src++;
  151.    }
  152. }
  153.  
  154. static void r_profi_8(unsigned char *dst, unsigned pitch, unsigned char *base)
  155. {
  156.    unsigned max = min(240U, temp.scy);
  157.    for (unsigned y = 0; y < max; y++)
  158.    {
  159.       line8_prof(dst, base+t.scrtab[y], t.zctab8[0]);
  160.       dst += pitch;
  161.    }
  162. }
  163.  
  164. static void r_profi_8d(unsigned char *dst, unsigned pitch, unsigned char *base)
  165. {
  166.    unsigned max = min(240U, temp.scy);
  167.    for (unsigned y = 0; y < max; y++)
  168.    {
  169.       line8_prof(dst, base+t.scrtab[y], t.zctab8[0]); dst += pitch;
  170.       line8_prof(dst, base+t.scrtab[y], t.zctab8[1]); dst += pitch;
  171.    }
  172. }
  173.  
  174. static void r_profi_16(unsigned char *dst, unsigned pitch, unsigned char *base)
  175. {
  176.    unsigned max = min(240U, temp.scy);
  177.    for (unsigned y = 0; y < max; y++)
  178.    {
  179.       line16_prof(dst, base+t.scrtab[y], t.zctab16[0]);
  180.       dst += pitch;
  181.    }
  182. }
  183.  
  184. static void r_profi_16d(unsigned char *dst, unsigned pitch, unsigned char *base)
  185. {
  186.    unsigned max = min(240U, temp.scy);
  187.    for (unsigned y = 0; y < max; y++)
  188.    {
  189.       line16_prof(dst, base+t.scrtab[y], t.zctab16[0]); dst += pitch;
  190.       line16_prof(dst, base+t.scrtab[y], t.zctab16[1]); dst += pitch;
  191.    }
  192. }
  193.  
  194. static void r_profi_32(unsigned char *dst, unsigned pitch, unsigned char *base)
  195. {
  196.    unsigned max = min(240U, temp.scy);
  197.    for (unsigned y = 0; y < max; y++)
  198.    {
  199.       line32_prof(dst, base+t.scrtab[y], t.zctab32[0]);
  200.       dst += pitch;
  201.    }
  202. }
  203.  
  204. static void r_profi_32d(unsigned char *dst, unsigned pitch, unsigned char *base)
  205. {
  206.    unsigned max = min(240U, temp.scy);
  207.    for (unsigned y = 0; y < max; y++)
  208.    {
  209.       line32_prof(dst, base+t.scrtab[y], t.zctab32[0]); dst += pitch;
  210.       line32_prof(dst, base+t.scrtab[y], t.zctab32[1]); dst += pitch;
  211.    }
  212. }
  213.  
  214. void rend_profi(unsigned char *dst, unsigned pitch)
  215. {
  216.    static unsigned char dffd = u8(-1U);
  217.    if ((comp.pDFFD ^ dffd) & 0x80)
  218.    {
  219.       video_color_tables();
  220.       dffd = comp.pDFFD;
  221.       needclr = 2;
  222.    }
  223.  
  224.    if (temp.comp_pal_changed)
  225.    {
  226.       pixel_tables();
  227.       temp.comp_pal_changed = 0;
  228.    }
  229.  
  230.    unsigned char *dst2 = dst + (temp.ox-512)*temp.obpp/16;
  231.    if (temp.scy > 240)
  232.        dst2 += (temp.scy-240)/2*pitch * ((temp.oy > temp.scy)?2:1);
  233.    if (temp.oy > temp.scy && conf.fast_sl)
  234.        pitch *= 2;
  235.  
  236.    unsigned char *base = memory + ((comp.p7FFD & 0x08) ? 6 * PAGE : 4 * PAGE);
  237.    if (temp.obpp == 8)
  238.    {
  239.        if (conf.fast_sl)
  240.            r_profi_8 (dst2, pitch, base);
  241.        else
  242.            r_profi_8d (dst2, pitch, base);
  243.        return;
  244.    }
  245.    if (temp.obpp == 16)
  246.    {
  247.        if (conf.fast_sl)
  248.            r_profi_16(dst2, pitch, base);
  249.        else
  250.            r_profi_16d(dst2, pitch, base);
  251.        return;
  252.    }
  253.    if (temp.obpp == 32)
  254.    {
  255.        if (conf.fast_sl)
  256.            r_profi_32(dst2, pitch, base);
  257.        else
  258.            r_profi_32d(dst2, pitch, base);
  259.        return;
  260.    }
  261. }
  262.