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 "dxr_atmf.h"
  7. #include "dxr_atm4.h"
  8. #include "fontatm2.h"
  9.  
  10. // vga like textmode (80x25)
  11.  
  12. static const int text0_ofs = 4*PAGE + 0x0;
  13. static const int text2_ofs = 4*PAGE + 0x800;
  14.  
  15. static void line_atm4_8(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font)
  16. {
  17.     for (unsigned x = 0; x < 640; x += 0x20)
  18.     {
  19.         unsigned p0 = *(unsigned*)(src + text0_ofs),
  20.                  a0 = *(unsigned*)(src + text2_ofs);
  21.         unsigned c, *tab;
  22.         tab = tab0 + ((a0 << 4) & 0xFF0);
  23.         c = font[p0 & 0xFF];
  24.         *(unsigned*)(dst+x+0x00) = tab[((c >> 4)  & 0xF)];
  25.         *(unsigned*)(dst+x+0x04) = tab[c & 0xF];
  26.  
  27.         tab = tab0 + ((a0 >> 4) & 0xFF0); c = font[(p0 >> 8) & 0xFF];
  28.         *(unsigned*)(dst+x+0x08) = tab[((c >> 4) & 0xF)];
  29.         *(unsigned*)(dst+x+0x0C) = tab[c & 0xF];
  30.  
  31.         tab = tab0 + ((a0 >> 12) & 0xFF0); c = font[(p0 >> 16) & 0xFF];
  32.         *(unsigned*)(dst+x+0x10) = tab[((c >> 4) & 0xF)];
  33.         *(unsigned*)(dst+x+0x14) = tab[c & 0xF];
  34.  
  35.         tab = tab0 + ((a0 >> 20) & 0xFF0); c = font[p0 >> 24];
  36.         *(unsigned*)(dst+x+0x18) = tab[((c >> 4) & 0xF)];
  37.         *(unsigned*)(dst+x+0x1C) = tab[c & 0xF];
  38.  
  39.         src += 4;
  40.     }
  41. }
  42.  
  43. static void line_atm4_16(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font)
  44. {
  45.     for (unsigned x = 0; x < 640*2; x += 0x40)
  46.     {
  47.         unsigned p0 = *(unsigned*)(src + text0_ofs),
  48.                  a0 = *(unsigned*)(src + text2_ofs);
  49.         unsigned c, *tab;
  50.         tab = tab0 + ((a0 << 2) & 0x3FC);
  51.         c = font[p0 & 0xFF];
  52.         *(unsigned*)(dst+x+0x00) = tab[((c >> 6)  & 0x03)];
  53.         *(unsigned*)(dst+x+0x04) = tab[((c >> 4)  & 0x03)];
  54.         *(unsigned*)(dst+x+0x08) = tab[((c >> 2)  & 0x03)];
  55.         *(unsigned*)(dst+x+0x0C) = tab[((c >> 0)  & 0x03)];
  56.  
  57.         tab = tab0 + ((a0 >> 6) & 0x3FC); c = font[(p0 >> 8) & 0xFF];
  58.         *(unsigned*)(dst+x+0x10) = tab[((c >> 6)  & 0x03)];
  59.         *(unsigned*)(dst+x+0x14) = tab[((c >> 4)  & 0x03)];
  60.         *(unsigned*)(dst+x+0x18) = tab[((c >> 2)  & 0x03)];
  61.         *(unsigned*)(dst+x+0x1C) = tab[((c >> 0)  & 0x03)];
  62.        
  63.         tab = tab0 + ((a0 >> 14) & 0x3FC); c = font[(p0 >> 16) & 0xFF];
  64.         *(unsigned*)(dst+x+0x20) = tab[((c >> 6)  & 0x03)];
  65.         *(unsigned*)(dst+x+0x24) = tab[((c >> 4)  & 0x03)];
  66.         *(unsigned*)(dst+x+0x28) = tab[((c >> 2)  & 0x03)];
  67.         *(unsigned*)(dst+x+0x2C) = tab[((c >> 0)  & 0x03)];
  68.  
  69.         tab = tab0 + ((a0 >> 22) & 0x3FC); c = font[p0 >> 24];
  70.         *(unsigned*)(dst+x+0x30) = tab[((c >> 6)  & 0x03)];
  71.         *(unsigned*)(dst+x+0x34) = tab[((c >> 4)  & 0x03)];
  72.         *(unsigned*)(dst+x+0x38) = tab[((c >> 2)  & 0x03)];
  73.         *(unsigned*)(dst+x+0x3C) = tab[((c >> 0)  & 0x03)];
  74.  
  75.         src += 4;
  76.     }
  77. }
  78.  
  79. static void line_atm4_32(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font)
  80. {
  81.    for (unsigned x = 0; x < 640*4; x += 0x40)
  82.    {
  83.       unsigned c, *tab;
  84.       tab = tab0 + src[text2_ofs]; c = font[src[text0_ofs]];
  85.       *(unsigned*)(dst+x+0x00) = tab[((c << 1) & 0x100)];
  86.       *(unsigned*)(dst+x+0x04) = tab[((c << 2) & 0x100)];
  87.       *(unsigned*)(dst+x+0x08) = tab[((c << 3) & 0x100)];
  88.       *(unsigned*)(dst+x+0x0C) = tab[((c << 4) & 0x100)];
  89.       *(unsigned*)(dst+x+0x10) = tab[((c << 5) & 0x100)];
  90.       *(unsigned*)(dst+x+0x14) = tab[((c << 6) & 0x100)];
  91.       *(unsigned*)(dst+x+0x18) = tab[((c << 7) & 0x100)];
  92.       *(unsigned*)(dst+x+0x1C) = tab[((c << 8) & 0x100)];
  93.  
  94.       tab = tab0 + src[text2_ofs + 1]; c = font[src[text0_ofs + 1]];
  95.       *(unsigned*)(dst+x+0x20) = tab[((c << 1) & 0x100)];
  96.       *(unsigned*)(dst+x+0x24) = tab[((c << 2) & 0x100)];
  97.       *(unsigned*)(dst+x+0x28) = tab[((c << 3) & 0x100)];
  98.       *(unsigned*)(dst+x+0x2C) = tab[((c << 4) & 0x100)];
  99.       *(unsigned*)(dst+x+0x30) = tab[((c << 5) & 0x100)];
  100.       *(unsigned*)(dst+x+0x34) = tab[((c << 6) & 0x100)];
  101.       *(unsigned*)(dst+x+0x38) = tab[((c << 7) & 0x100)];
  102.       *(unsigned*)(dst+x+0x3C) = tab[((c << 8) & 0x100)];
  103.  
  104.       src += 2;
  105.    }
  106. }
  107.  
  108. // Textmode
  109. void rend_atm4(unsigned char *dst, unsigned pitch, unsigned y)
  110. {
  111.    unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16;
  112.    if (temp.scy > 200)
  113.        dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
  114.  
  115.     int v = y%8;
  116.     int l = y/8;
  117.     if (conf.fast_sl)
  118.     {
  119.         dst2 += y*pitch;
  120.         switch(temp.obpp)
  121.         {
  122.         case 8:
  123.             line_atm4_8 (dst2, temp.base + l*80, t.zctab8 [0], fontatm2 + v*0x100);
  124.             break;
  125.         case 16:
  126.             line_atm4_16(dst2, temp.base + l*80, t.zctab16[0], fontatm2 + v*0x100);
  127.             break;
  128.         case 32:
  129.             line_atm4_32(dst2, temp.base + l*80, t.zctab32[0], fontatm2 + v*0x100);
  130.             break;
  131.         }
  132.     }
  133.     else
  134.     {
  135.         dst2 += 2*y*pitch;
  136.         switch(temp.obpp)
  137.         {
  138.         case 8:
  139.             line_atm4_8 (dst2, temp.base + l*80, t.zctab8 [0], fontatm2 + v*0x100);
  140.             dst2 += pitch;
  141.             line_atm4_8 (dst2, temp.base + l*80, t.zctab8 [1], fontatm2 + v*0x100);
  142.             break;
  143.         case 16:
  144.             line_atm4_16(dst2, temp.base + l*80, t.zctab16[0], fontatm2 + v*0x100);
  145.             dst2 += pitch;
  146.             line_atm4_16(dst2, temp.base + l*80, t.zctab16[1], fontatm2 + v*0x100);
  147.             break;
  148.         case 32:
  149.             line_atm4_32(dst2, temp.base + l*80, t.zctab32[0], fontatm2 + v*0x100);
  150.             dst2 += pitch;
  151.             line_atm4_32(dst2, temp.base + l*80, t.zctab32[1], fontatm2 + v*0x100);
  152.             break;
  153.         }
  154.     }
  155. }
  156.