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 "dxr_atmf.h"
  7. #include "dxr_atm2.h"
  8.  
  9. const int atmh0_ofs = 0;
  10. const int atmh1_ofs = 0x2000;
  11. const int atmh2_ofs = -4*int(PAGE);
  12. const int atmh3_ofs = -4*int(PAGE)+0x2000;
  13.  
  14.  
  15. static void line_atm2_8(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset)
  16. {
  17.     for (unsigned x = 0; x < 640; x += 0x40) {
  18.         src_offset &= 0x1FFF;
  19.         unsigned s  = *(unsigned*)(src+atmh0_ofs+src_offset);
  20.         unsigned t  = *(unsigned*)(src+atmh1_ofs+src_offset);
  21.         unsigned as = *(unsigned*)(src+atmh2_ofs+src_offset);
  22.         unsigned at = *(unsigned*)(src+atmh3_ofs+src_offset);
  23.         unsigned *tab = tab0 + ((as << 4) & 0xFF0);
  24.         *(unsigned*)(dst+x+0x00) = tab[((s >> 4)  & 0xF)];
  25.         *(unsigned*)(dst+x+0x04) = tab[((s >> 0)  & 0xF)];
  26.         tab = tab0 + ((at << 4) & 0xFF0);
  27.         *(unsigned*)(dst+x+0x08) = tab[((t >> 4)  & 0xF)];
  28.         *(unsigned*)(dst+x+0x0C) = tab[((t >> 0)  & 0xF)];
  29.         tab = tab0 + ((as >> 4) & 0xFF0);
  30.         *(unsigned*)(dst+x+0x10) = tab[((s >> 12) & 0xF)];
  31.         *(unsigned*)(dst+x+0x14) = tab[((s >> 8)  & 0xF)];
  32.         tab = tab0 + ((at >> 4) & 0xFF0);
  33.         *(unsigned*)(dst+x+0x18) = tab[((t >> 12) & 0xF)];
  34.         *(unsigned*)(dst+x+0x1C) = tab[((t >> 8)  & 0xF)];
  35.         tab = tab0 + ((as >> 12) & 0xFF0);
  36.         *(unsigned*)(dst+x+0x20) = tab[((s >> 20) & 0xF)];
  37.         *(unsigned*)(dst+x+0x24) = tab[((s >> 16) & 0xF)];
  38.         tab = tab0 + ((at >> 12) & 0xFF0);
  39.         *(unsigned*)(dst+x+0x28) = tab[((t >> 20) & 0xF)];
  40.         *(unsigned*)(dst+x+0x2C) = tab[((t >> 16) & 0xF)];
  41.         tab = tab0 + ((as >> 20) & 0xFF0);
  42.         *(unsigned*)(dst+x+0x30) = tab[((s >> 28) & 0xF)];
  43.         *(unsigned*)(dst+x+0x34) = tab[((s >> 24) & 0xF)];
  44.         tab = tab0 + ((at >> 20) & 0xFF0);
  45.         *(unsigned*)(dst+x+0x38) = tab[((t >> 28) & 0xF)];
  46.         *(unsigned*)(dst+x+0x3C) = tab[((t >> 24) & 0xF)];
  47.         src_offset+=4;
  48.     }
  49. }
  50.  
  51. static void line_atm2_16(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset)
  52. {
  53.     for (unsigned x = 0; x < 640*2; x += 0x80) {
  54.         src_offset &= 0x1FFF;
  55.         unsigned s  = *(unsigned*)(src+atmh0_ofs+src_offset);
  56.         unsigned t  = *(unsigned*)(src+atmh1_ofs+src_offset);
  57.         unsigned as = *(unsigned*)(src+atmh2_ofs+src_offset);
  58.         unsigned at = *(unsigned*)(src+atmh3_ofs+src_offset);
  59.         unsigned *tab = tab0 + ((as << 2) & 0x3FC);
  60.         *(unsigned*)(dst+x+0x00) = tab[((s >> 6)  & 3)];
  61.         *(unsigned*)(dst+x+0x04) = tab[((s >> 4)  & 3)];
  62.         *(unsigned*)(dst+x+0x08) = tab[((s >> 2)  & 3)];
  63.         *(unsigned*)(dst+x+0x0C) = tab[((s >> 0)  & 3)];
  64.         tab = tab0 + ((at << 2) & 0x3FC);
  65.         *(unsigned*)(dst+x+0x10) = tab[((t >> 6)  & 3)];
  66.         *(unsigned*)(dst+x+0x14) = tab[((t >> 4)  & 3)];
  67.         *(unsigned*)(dst+x+0x18) = tab[((t >> 2)  & 3)];
  68.         *(unsigned*)(dst+x+0x1C) = tab[((t >> 0)  & 3)];
  69.         tab = tab0 + ((as >> 6) & 0x3FC);
  70.         *(unsigned*)(dst+x+0x20) = tab[((s >>14)  & 3)];
  71.         *(unsigned*)(dst+x+0x24) = tab[((s >>12)  & 3)];
  72.         *(unsigned*)(dst+x+0x28) = tab[((s >>10)  & 3)];
  73.         *(unsigned*)(dst+x+0x2C) = tab[((s >> 8)  & 3)];
  74.         tab = tab0 + ((at >> 6) & 0x3FC);
  75.         *(unsigned*)(dst+x+0x30) = tab[((t >>14)  & 3)];
  76.         *(unsigned*)(dst+x+0x34) = tab[((t >>12)  & 3)];
  77.         *(unsigned*)(dst+x+0x38) = tab[((t >>10)  & 3)];
  78.         *(unsigned*)(dst+x+0x3C) = tab[((t >> 8)  & 3)];
  79.         tab = tab0 + ((as >> 14) & 0x3FC);
  80.         *(unsigned*)(dst+x+0x40) = tab[((s >>22)  & 3)];
  81.         *(unsigned*)(dst+x+0x44) = tab[((s >>20)  & 3)];
  82.         *(unsigned*)(dst+x+0x48) = tab[((s >>18)  & 3)];
  83.         *(unsigned*)(dst+x+0x4C) = tab[((s >>16)  & 3)];
  84.         tab = tab0 + ((at >> 14) & 0x3FC);
  85.         *(unsigned*)(dst+x+0x50) = tab[((t >>22)  & 3)];
  86.         *(unsigned*)(dst+x+0x54) = tab[((t >>20)  & 3)];
  87.         *(unsigned*)(dst+x+0x58) = tab[((t >>18)  & 3)];
  88.         *(unsigned*)(dst+x+0x5C) = tab[((t >>16)  & 3)];
  89.         tab = tab0 + ((as >> 22) & 0x3FC);
  90.         *(unsigned*)(dst+x+0x60) = tab[((s >>30)  & 3)];
  91.         *(unsigned*)(dst+x+0x64) = tab[((s >>28)  & 3)];
  92.         *(unsigned*)(dst+x+0x68) = tab[((s >>26)  & 3)];
  93.         *(unsigned*)(dst+x+0x6C) = tab[((s >>24)  & 3)];
  94.         tab = tab0 + ((at >> 22) & 0x3FC);
  95.         *(unsigned*)(dst+x+0x70) = tab[((t >>30)  & 3)];
  96.         *(unsigned*)(dst+x+0x74) = tab[((t >>28)  & 3)];
  97.         *(unsigned*)(dst+x+0x78) = tab[((t >>26)  & 3)];
  98.         *(unsigned*)(dst+x+0x7C) = tab[((t >>24)  & 3)];
  99.         src_offset+=4;
  100.     }
  101. }
  102.  
  103. static void line_atm2_32(unsigned char *dst, unsigned char *src, unsigned *tab0, int src_offset)
  104. {
  105.     unsigned *tab; unsigned c;
  106.     for (unsigned x = 0; x < 640*4; x += 0x40) {
  107.         src_offset &= 0x1FFF;
  108.  
  109.         tab = tab0 + src[atmh2_ofs+src_offset];
  110.         c = src[atmh0_ofs+src_offset];
  111.         *(unsigned*)(dst+x+0x00) = tab[((c << 1) & 0x100)];
  112.         *(unsigned*)(dst+x+0x04) = tab[((c << 2) & 0x100)];
  113.         *(unsigned*)(dst+x+0x08) = tab[((c << 3) & 0x100)];
  114.         *(unsigned*)(dst+x+0x0C) = tab[((c << 4) & 0x100)];
  115.         *(unsigned*)(dst+x+0x10) = tab[((c << 5) & 0x100)];
  116.         *(unsigned*)(dst+x+0x14) = tab[((c << 6) & 0x100)];
  117.         *(unsigned*)(dst+x+0x18) = tab[((c << 7) & 0x100)];
  118.         *(unsigned*)(dst+x+0x1C) = tab[((c << 8) & 0x100)];
  119.  
  120.         tab = tab0 + src[atmh3_ofs+src_offset];
  121.         c = src[atmh1_ofs+src_offset];
  122.         *(unsigned*)(dst+x+0x20) = tab[((c << 1) & 0x100)];
  123.         *(unsigned*)(dst+x+0x24) = tab[((c << 2) & 0x100)];
  124.         *(unsigned*)(dst+x+0x28) = tab[((c << 3) & 0x100)];
  125.         *(unsigned*)(dst+x+0x2C) = tab[((c << 4) & 0x100)];
  126.         *(unsigned*)(dst+x+0x30) = tab[((c << 5) & 0x100)];
  127.         *(unsigned*)(dst+x+0x34) = tab[((c << 6) & 0x100)];
  128.         *(unsigned*)(dst+x+0x38) = tab[((c << 7) & 0x100)];
  129.         *(unsigned*)(dst+x+0x3C) = tab[((c << 8) & 0x100)];
  130.  
  131.         ++src_offset;
  132.     }
  133. }
  134.  
  135. // Hardware Multicolor
  136. void rend_atm2(unsigned char *dst, unsigned pitch, unsigned y, int Offset)
  137. {
  138.     unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16;
  139.     if (temp.scy > 200)
  140.         dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
  141.  
  142.     if (conf.fast_sl) {
  143.         dst2 += y*pitch;
  144.         switch (temp.obpp)
  145.         {
  146.         case 8:
  147.             line_atm2_8 (dst2, temp.base, t.zctab8 [0], Offset);
  148.             break;
  149.         case 16:
  150.             line_atm2_16(dst2, temp.base, t.zctab16[0], Offset);
  151.             break;
  152.         case 32:
  153.             line_atm2_32(dst2, temp.base, t.zctab32[0],  Offset);
  154.             break;
  155.         }
  156.     } else {
  157.         dst2 += 2*y*pitch;
  158.         switch (temp.obpp)
  159.         {
  160.         case 8:
  161.             line_atm2_8 (dst2, temp.base, t.zctab8 [0], Offset);
  162.             dst2 += pitch;
  163.             line_atm2_8 (dst2, temp.base, t.zctab8 [1], Offset);
  164.             break;
  165.         case 16:
  166.             line_atm2_16(dst2, temp.base, t.zctab16[0], Offset);
  167.             dst2 += pitch;
  168.             line_atm2_16(dst2, temp.base, t.zctab16[1], Offset);
  169.             break;
  170.         case 32:
  171.             line_atm2_32(dst2, temp.base, t.zctab32[0], Offset);
  172.             dst2 += pitch;
  173.             line_atm2_32(dst2, temp.base, t.zctab32[1], Offset);
  174.             break;
  175.         }
  176.     }
  177. }
  178.