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 "dxr_512.h"
  8.  
  9. static void line8_512(unsigned char *dst, unsigned char *src, unsigned *tab)
  10. {
  11.    for (unsigned x = 0; x < 512; x += 64) {
  12.       unsigned s = *(unsigned*)src;
  13.       unsigned t = *(unsigned*)(src+0x2000);
  14.       *(unsigned*)(dst+x)    = tab[((s >> 4)  & 0xF)];
  15.       *(unsigned*)(dst+x+4)  = tab[((s >> 0)  & 0xF)];
  16.       *(unsigned*)(dst+x+8)  = tab[((t >> 4)  & 0xF)];
  17.       *(unsigned*)(dst+x+12) = tab[((t >> 0)  & 0xF)];
  18.       *(unsigned*)(dst+x+16) = tab[((s >> 12) & 0xF)];
  19.       *(unsigned*)(dst+x+20) = tab[((s >> 8)  & 0xF)];
  20.       *(unsigned*)(dst+x+24) = tab[((t >> 12) & 0xF)];
  21.       *(unsigned*)(dst+x+28) = tab[((t >> 8)  & 0xF)];
  22.       *(unsigned*)(dst+x+32) = tab[((s >> 20) & 0xF)];
  23.       *(unsigned*)(dst+x+36) = tab[((s >> 16) & 0xF)];
  24.       *(unsigned*)(dst+x+40) = tab[((t >> 20) & 0xF)];
  25.       *(unsigned*)(dst+x+44) = tab[((t >> 16) & 0xF)];
  26.       *(unsigned*)(dst+x+48) = tab[((s >> 28) & 0xF)];
  27.       *(unsigned*)(dst+x+52) = tab[((s >> 24) & 0xF)];
  28.       *(unsigned*)(dst+x+56) = tab[((t >> 28) & 0xF)];
  29.       *(unsigned*)(dst+x+60) = tab[((t >> 24) & 0xF)];
  30.       src += 4;
  31.    }
  32. }
  33. static void line16_512(unsigned char *dst, unsigned char *src, unsigned *tab)
  34. {
  35.    for (unsigned x = 0; x < 1024; x += 128) {
  36.       unsigned s = *(unsigned*)src;
  37.       unsigned t = *(unsigned*)(src+0x2000);
  38.       *(unsigned*)(dst+x+0x00) = tab[((s >> 6)  & 0x03)];
  39.       *(unsigned*)(dst+x+0x04) = tab[((s >> 4)  & 0x03)];
  40.       *(unsigned*)(dst+x+0x08) = tab[((s >> 2)  & 0x03)];
  41.       *(unsigned*)(dst+x+0x0C) = tab[((s >> 0)  & 0x03)];
  42.       *(unsigned*)(dst+x+0x10) = tab[((t >> 6)  & 0x03)];
  43.       *(unsigned*)(dst+x+0x14) = tab[((t >> 4)  & 0x03)];
  44.       *(unsigned*)(dst+x+0x18) = tab[((t >> 2)  & 0x03)];
  45.       *(unsigned*)(dst+x+0x1C) = tab[((t >> 0)  & 0x03)];
  46.       *(unsigned*)(dst+x+0x20) = tab[((s >> 14) & 0x03)];
  47.       *(unsigned*)(dst+x+0x24) = tab[((s >> 12) & 0x03)];
  48.       *(unsigned*)(dst+x+0x28) = tab[((s >> 10) & 0x03)];
  49.       *(unsigned*)(dst+x+0x2C) = tab[((s >> 8)  & 0x03)];
  50.       *(unsigned*)(dst+x+0x30) = tab[((t >> 14) & 0x03)];
  51.       *(unsigned*)(dst+x+0x34) = tab[((t >> 12) & 0x03)];
  52.       *(unsigned*)(dst+x+0x38) = tab[((t >> 10) & 0x03)];
  53.       *(unsigned*)(dst+x+0x3C) = tab[((t >> 8)  & 0x03)];
  54.       *(unsigned*)(dst+x+0x40) = tab[((s >> 22) & 0x03)];
  55.       *(unsigned*)(dst+x+0x44) = tab[((s >> 20) & 0x03)];
  56.       *(unsigned*)(dst+x+0x48) = tab[((s >> 18) & 0x03)];
  57.       *(unsigned*)(dst+x+0x4C) = tab[((s >> 16) & 0x03)];
  58.       *(unsigned*)(dst+x+0x50) = tab[((t >> 22) & 0x03)];
  59.       *(unsigned*)(dst+x+0x54) = tab[((t >> 20) & 0x03)];
  60.       *(unsigned*)(dst+x+0x58) = tab[((t >> 18) & 0x03)];
  61.       *(unsigned*)(dst+x+0x5C) = tab[((t >> 16) & 0x03)];
  62.       *(unsigned*)(dst+x+0x60) = tab[((s >> 30) & 0x03)];
  63.       *(unsigned*)(dst+x+0x64) = tab[((s >> 28) & 0x03)];
  64.       *(unsigned*)(dst+x+0x68) = tab[((s >> 26) & 0x03)];
  65.       *(unsigned*)(dst+x+0x6C) = tab[((s >> 24) & 0x03)];
  66.       *(unsigned*)(dst+x+0x70) = tab[((t >> 30) & 0x03)];
  67.       *(unsigned*)(dst+x+0x74) = tab[((t >> 28) & 0x03)];
  68.       *(unsigned*)(dst+x+0x78) = tab[((t >> 26) & 0x03)];
  69.       *(unsigned*)(dst+x+0x7C) = tab[((t >> 24) & 0x03)];
  70.       src += 4;
  71.    }
  72. }
  73. static void line32_512(unsigned char *dst, unsigned char *src, unsigned *tab)
  74. {
  75.    for (unsigned x = 0; x < 512*4; x += 64) {
  76.       unsigned s = src[0];
  77.       *(unsigned*)(dst+x)    = tab[((s << 1) & 0x100)];
  78.       *(unsigned*)(dst+x+4)  = tab[((s << 2) & 0x100)];
  79.       *(unsigned*)(dst+x+8)  = tab[((s << 3) & 0x100)];
  80.       *(unsigned*)(dst+x+12) = tab[((s << 4) & 0x100)];
  81.       *(unsigned*)(dst+x+16) = tab[((s << 5) & 0x100)];
  82.       *(unsigned*)(dst+x+20) = tab[((s << 6) & 0x100)];
  83.       *(unsigned*)(dst+x+24) = tab[((s << 7) & 0x100)];
  84.       *(unsigned*)(dst+x+28) = tab[((s << 8) & 0x100)];
  85.       s = src[0x2000];
  86.       *(unsigned*)(dst+x+32) = tab[((s << 1) & 0x100)];
  87.       *(unsigned*)(dst+x+36) = tab[((s << 2) & 0x100)];
  88.       *(unsigned*)(dst+x+40) = tab[((s << 3) & 0x100)];
  89.       *(unsigned*)(dst+x+44) = tab[((s << 4) & 0x100)];
  90.       *(unsigned*)(dst+x+48) = tab[((s << 5) & 0x100)];
  91.       *(unsigned*)(dst+x+52) = tab[((s << 6) & 0x100)];
  92.       *(unsigned*)(dst+x+56) = tab[((s << 7) & 0x100)];
  93.       *(unsigned*)(dst+x+60) = tab[((s << 8) & 0x100)];
  94.       src++;
  95.    }
  96. }
  97.  
  98. #define ATTR_512 0x07
  99. static void r512_8s(unsigned char *dst, unsigned pitch)
  100. {
  101.    for (unsigned y = 0; y < 192; y++) {
  102.       line8_512(dst, temp.base+t.scrtab[y], t.sctab8[0]+ATTR_512*0x10);
  103.       dst += pitch;
  104.    }
  105. }
  106. static void r512_8d(unsigned char *dst, unsigned pitch)
  107. {
  108.    for (unsigned y = 0; y < 192; y++) {
  109.       line8_512(dst, temp.base+t.scrtab[y], t.sctab8[0]+ATTR_512*0x10); dst += pitch;
  110.       line8_512(dst, temp.base+t.scrtab[y], t.sctab8[1]+ATTR_512*0x10); dst += pitch;
  111.    }
  112. }
  113. static void r512_16s(unsigned char *dst, unsigned pitch)
  114. {
  115.    for (unsigned y = 0; y < 192; y++) {
  116.       line16_512(dst, temp.base+t.scrtab[y], t.sctab16[0]+ATTR_512*4);
  117.       dst += pitch;
  118.    }
  119. }
  120. static void r512_16d(unsigned char *dst, unsigned pitch)
  121. {
  122.    for (unsigned y = 0; y < 192; y++) {
  123.       line16_512(dst, temp.base+t.scrtab[y], t.sctab16[0]+ATTR_512*4); dst += pitch;
  124.       line16_512(dst, temp.base+t.scrtab[y], t.sctab16[1]+ATTR_512*4); dst += pitch;
  125.    }
  126. }
  127. static void r512_32s(unsigned char *dst, unsigned pitch)
  128. {
  129.    for (unsigned y = 0; y < 192; y++) {
  130.       line32_512(dst, temp.base+t.scrtab[y], t.sctab32[0]+ATTR_512);
  131.       dst += pitch;
  132.    }
  133. }
  134. static void r512_32d(unsigned char *dst, unsigned pitch)
  135. {
  136.    for (unsigned y = 0; y < 192; y++) {
  137.       line32_512(dst, temp.base+t.scrtab[y], t.sctab32[0]+ATTR_512); dst += pitch;
  138.       line32_512(dst, temp.base+t.scrtab[y], t.sctab32[1]+ATTR_512); dst += pitch;
  139.    }
  140. }
  141.  
  142. void rend_512(unsigned char *dst, unsigned pitch)
  143. {
  144.     unsigned char *dst2 = dst + temp.b_left*temp.obpp / 4 + temp.b_top*pitch * ((temp.oy > temp.scy) ? 2 : 1);
  145.     if(temp.oy > temp.scy && conf.fast_sl)
  146.     {
  147.         pitch *= 2;
  148.     }
  149.  
  150.     if(temp.obpp == 8)
  151.     {
  152.         if(conf.fast_sl)
  153.         {
  154.             rend_frame_8d1(dst, pitch);
  155.             r512_8s(dst2, pitch);
  156.         }
  157.         else
  158.         {
  159.             rend_frame_8d(dst, pitch);
  160.             r512_8d(dst2, pitch);
  161.         }
  162.         return;
  163.     }
  164.     if(temp.obpp == 16)
  165.     {
  166.         if(conf.fast_sl)
  167.         {
  168.             rend_frame_16d1(dst, pitch);
  169.             r512_16s(dst2, pitch);
  170.         }
  171.         else
  172.         {
  173.             rend_frame_16d(dst, pitch);
  174.             r512_16d(dst2, pitch);
  175.         }
  176.         return;
  177.     }
  178.     if(temp.obpp == 32)
  179.     {
  180.         if(conf.fast_sl)
  181.         {
  182.             rend_frame_32d1(dst, pitch);
  183.             r512_32s(dst2, pitch);
  184.         }
  185.         else
  186.         {
  187.             rend_frame_32d(dst, pitch);
  188.             r512_32d(dst2, pitch);
  189.         }
  190.         return;
  191.     }
  192. }
  193.  
  194.