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_atm6.h"
  8. #include "fontatm2.h"
  9. /*
  10. const int text0_ofs = 0x01C0;
  11. const int text1_ofs = 0x21C0;
  12. const int text2_ofs = -4*PAGE+0x01C1;
  13. const int text3_ofs = -4*PAGE+0x21C0;
  14. */
  15.  
  16. const int text0_ofs = 0x0;
  17. const int text1_ofs = 0x2000;
  18. const int text2_ofs = -4*int(PAGE)+1;
  19. const int text3_ofs = -4*int(PAGE)+0x2000;
  20.  
  21.  
  22. static void line_atm6_8(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
  23. {
  24.     for (unsigned x = 0; x < 640; x += 0x40) {
  25.         src_offset &= 0x1FFF;
  26.         unsigned p0 = *(unsigned*)(src + src_offset + text0_ofs),
  27.                  p1 = *(unsigned*)(src + src_offset + text1_ofs),
  28.                  a0 = *(unsigned*)(src + src_offset + text2_ofs),
  29.                  a1 = *(unsigned*)(src + src_offset + text3_ofs);
  30.         unsigned c, *tab;
  31.         tab = tab0 + ((a1 << 4) & 0xFF0);
  32.         c = font[p0 & 0xFF];
  33.         *(unsigned*)(dst+x+0x00) = tab[((c >> 4)  & 0xF)];
  34.         *(unsigned*)(dst+x+0x04) = tab[c & 0xF];
  35.         tab = tab0 + ((a0 << 4) & 0xFF0); c = font[p1 & 0xFF];
  36.         *(unsigned*)(dst+x+0x08) = tab[((c >> 4)  & 0xF)];
  37.         *(unsigned*)(dst+x+0x0C) = tab[c & 0xF];
  38.         tab = tab0 + ((a1 >> 4) & 0xFF0); c = font[(p0 >> 8) & 0xFF];
  39.         *(unsigned*)(dst+x+0x10) = tab[((c >> 4) & 0xF)];
  40.         *(unsigned*)(dst+x+0x14) = tab[c & 0xF];
  41.         tab = tab0 + ((a0 >> 4) & 0xFF0); c = font[(p1 >> 8) & 0xFF];
  42.         *(unsigned*)(dst+x+0x18) = tab[((c >> 4) & 0xF)];
  43.         *(unsigned*)(dst+x+0x1C) = tab[c & 0xF];
  44.         tab = tab0 + ((a1 >> 12) & 0xFF0); c = font[(p0 >> 16) & 0xFF];
  45.         *(unsigned*)(dst+x+0x20) = tab[((c >> 4) & 0xF)];
  46.         *(unsigned*)(dst+x+0x24) = tab[c & 0xF];
  47.         tab = tab0 + ((a0 >> 12) & 0xFF0); c = font[(p1 >> 16) & 0xFF];
  48.         *(unsigned*)(dst+x+0x28) = tab[((c >> 4) & 0xF)];
  49.         *(unsigned*)(dst+x+0x2C) = tab[c & 0xF];
  50.         tab = tab0 + ((a1 >> 20) & 0xFF0); c = font[p0 >> 24];
  51.         *(unsigned*)(dst+x+0x30) = tab[((c >> 4) & 0xF)];
  52.         *(unsigned*)(dst+x+0x34) = tab[c & 0xF];
  53.         tab = tab0 + ((a0 >> 20) & 0xFF0); c = font[p1 >> 24];
  54.         *(unsigned*)(dst+x+0x38) = tab[((c >> 4) & 0xF)];
  55.         *(unsigned*)(dst+x+0x3C) = tab[c & 0xF];
  56.         src_offset += 4;
  57.     }
  58. }
  59.  
  60. static void line_atm6_16(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
  61. {
  62.     for (unsigned x = 0; x < 640*2; x += 0x80) {
  63.         src_offset &= 0x1FFF;
  64.         unsigned p0 = *(unsigned*)(src + src_offset + text0_ofs),
  65.                  p1 = *(unsigned*)(src + src_offset + text1_ofs),
  66.                  a0 = *(unsigned*)(src + src_offset + text2_ofs),
  67.                  a1 = *(unsigned*)(src + src_offset + text3_ofs);
  68.         unsigned c, *tab;
  69.         tab = tab0 + ((a1 << 2) & 0x3FC);
  70.         c = font[p0 & 0xFF];
  71.         *(unsigned*)(dst+x+0x00) = tab[((c >> 6)  & 0x03)];
  72.         *(unsigned*)(dst+x+0x04) = tab[((c >> 4)  & 0x03)];
  73.         *(unsigned*)(dst+x+0x08) = tab[((c >> 2)  & 0x03)];
  74.         *(unsigned*)(dst+x+0x0C) = tab[((c >> 0)  & 0x03)];
  75.         tab = tab0 + ((a0 << 2) & 0x3FC); c = font[p1 & 0xFF];
  76.         *(unsigned*)(dst+x+0x10) = tab[((c >> 6)  & 0x03)];
  77.         *(unsigned*)(dst+x+0x14) = tab[((c >> 4)  & 0x03)];
  78.         *(unsigned*)(dst+x+0x18) = tab[((c >> 2)  & 0x03)];
  79.         *(unsigned*)(dst+x+0x1C) = tab[((c >> 0)  & 0x03)];
  80.         tab = tab0 + ((a1 >> 6) & 0x3FC); c = font[(p0 >> 8) & 0xFF];
  81.         *(unsigned*)(dst+x+0x20) = tab[((c >> 6)  & 0x03)];
  82.         *(unsigned*)(dst+x+0x24) = tab[((c >> 4)  & 0x03)];
  83.         *(unsigned*)(dst+x+0x28) = tab[((c >> 2)  & 0x03)];
  84.         *(unsigned*)(dst+x+0x2C) = tab[((c >> 0)  & 0x03)];
  85.         tab = tab0 + ((a0 >> 6) & 0x3FC); c = font[(p1 >> 8) & 0xFF];
  86.         *(unsigned*)(dst+x+0x30) = tab[((c >> 6)  & 0x03)];
  87.         *(unsigned*)(dst+x+0x34) = tab[((c >> 4)  & 0x03)];
  88.         *(unsigned*)(dst+x+0x38) = tab[((c >> 2)  & 0x03)];
  89.         *(unsigned*)(dst+x+0x3C) = tab[((c >> 0)  & 0x03)];
  90.         tab = tab0 + ((a1 >> 14) & 0x3FC); c = font[(p0 >> 16) & 0xFF];
  91.         *(unsigned*)(dst+x+0x40) = tab[((c >> 6)  & 0x03)];
  92.         *(unsigned*)(dst+x+0x44) = tab[((c >> 4)  & 0x03)];
  93.         *(unsigned*)(dst+x+0x48) = tab[((c >> 2)  & 0x03)];
  94.         *(unsigned*)(dst+x+0x4C) = tab[((c >> 0)  & 0x03)];
  95.         tab = tab0 + ((a0 >> 14) & 0x3FC); c = font[(p1 >> 16) & 0xFF];
  96.         *(unsigned*)(dst+x+0x50) = tab[((c >> 6)  & 0x03)];
  97.         *(unsigned*)(dst+x+0x54) = tab[((c >> 4)  & 0x03)];
  98.         *(unsigned*)(dst+x+0x58) = tab[((c >> 2)  & 0x03)];
  99.         *(unsigned*)(dst+x+0x5C) = tab[((c >> 0)  & 0x03)];
  100.         tab = tab0 + ((a1 >> 22) & 0x3FC); c = font[p0 >> 24];
  101.         *(unsigned*)(dst+x+0x60) = tab[((c >> 6)  & 0x03)];
  102.         *(unsigned*)(dst+x+0x64) = tab[((c >> 4)  & 0x03)];
  103.         *(unsigned*)(dst+x+0x68) = tab[((c >> 2)  & 0x03)];
  104.         *(unsigned*)(dst+x+0x6C) = tab[((c >> 0)  & 0x03)];
  105.         tab = tab0 + ((a0 >> 22) & 0x3FC); c = font[p1 >> 24];
  106.         *(unsigned*)(dst+x+0x70) = tab[((c >> 6)  & 0x03)];
  107.         *(unsigned*)(dst+x+0x74) = tab[((c >> 4)  & 0x03)];
  108.         *(unsigned*)(dst+x+0x78) = tab[((c >> 2)  & 0x03)];
  109.         *(unsigned*)(dst+x+0x7C) = tab[((c >> 0)  & 0x03)];
  110.         src_offset += 4;
  111.     }
  112. }
  113.  
  114. static void line_atm6_32(unsigned char *dst, unsigned char *src, unsigned *tab0, unsigned char *font, int src_offset)
  115. {
  116.    for (unsigned x = 0; x < 640*4; x += 0x80) {
  117.       unsigned c, *tab;
  118.       src_offset &= 0x1FFF;
  119.       tab = tab0 + src[src_offset + text3_ofs];
  120.       c = font[src[src_offset + text0_ofs]];
  121.       *(unsigned*)(dst+x+0x00) = tab[((c << 1) & 0x100)];
  122.       *(unsigned*)(dst+x+0x04) = tab[((c << 2) & 0x100)];
  123.       *(unsigned*)(dst+x+0x08) = tab[((c << 3) & 0x100)];
  124.       *(unsigned*)(dst+x+0x0C) = tab[((c << 4) & 0x100)];
  125.       *(unsigned*)(dst+x+0x10) = tab[((c << 5) & 0x100)];
  126.       *(unsigned*)(dst+x+0x14) = tab[((c << 6) & 0x100)];
  127.       *(unsigned*)(dst+x+0x18) = tab[((c << 7) & 0x100)];
  128.       *(unsigned*)(dst+x+0x1C) = tab[((c << 8) & 0x100)];
  129.  
  130.       tab = tab0 + src[src_offset + text2_ofs];
  131.       c = font[src[src_offset + text1_ofs]];
  132.       *(unsigned*)(dst+x+0x20) = tab[((c << 1) & 0x100)];
  133.       *(unsigned*)(dst+x+0x24) = tab[((c << 2) & 0x100)];
  134.       *(unsigned*)(dst+x+0x28) = tab[((c << 3) & 0x100)];
  135.       *(unsigned*)(dst+x+0x2C) = tab[((c << 4) & 0x100)];
  136.       *(unsigned*)(dst+x+0x30) = tab[((c << 5) & 0x100)];
  137.       *(unsigned*)(dst+x+0x34) = tab[((c << 6) & 0x100)];
  138.       *(unsigned*)(dst+x+0x38) = tab[((c << 7) & 0x100)];
  139.       *(unsigned*)(dst+x+0x3C) = tab[((c << 8) & 0x100)];
  140.  
  141.       tab = tab0 + src[src_offset + text3_ofs+1];
  142.       c = font[src[src_offset + text0_ofs+1]];
  143.       *(unsigned*)(dst+x+0x40) = tab[((c << 1) & 0x100)];
  144.       *(unsigned*)(dst+x+0x44) = tab[((c << 2) & 0x100)];
  145.       *(unsigned*)(dst+x+0x48) = tab[((c << 3) & 0x100)];
  146.       *(unsigned*)(dst+x+0x4C) = tab[((c << 4) & 0x100)];
  147.       *(unsigned*)(dst+x+0x50) = tab[((c << 5) & 0x100)];
  148.       *(unsigned*)(dst+x+0x54) = tab[((c << 6) & 0x100)];
  149.       *(unsigned*)(dst+x+0x58) = tab[((c << 7) & 0x100)];
  150.       *(unsigned*)(dst+x+0x5C) = tab[((c << 8) & 0x100)];
  151.  
  152.       tab = tab0 + src[src_offset + text2_ofs+1];
  153.       c = font[src[src_offset + text1_ofs+1]];
  154.       *(unsigned*)(dst+x+0x60) = tab[((c << 1) & 0x100)];
  155.       *(unsigned*)(dst+x+0x64) = tab[((c << 2) & 0x100)];
  156.       *(unsigned*)(dst+x+0x68) = tab[((c << 3) & 0x100)];
  157.       *(unsigned*)(dst+x+0x6C) = tab[((c << 4) & 0x100)];
  158.       *(unsigned*)(dst+x+0x70) = tab[((c << 5) & 0x100)];
  159.       *(unsigned*)(dst+x+0x74) = tab[((c << 6) & 0x100)];
  160.       *(unsigned*)(dst+x+0x78) = tab[((c << 7) & 0x100)];
  161.       *(unsigned*)(dst+x+0x7C) = tab[((c << 8) & 0x100)];
  162.  
  163.       src_offset += 2;
  164.    }
  165. }
  166.  
  167. // Textmode
  168. void rend_atm6(unsigned char *dst, unsigned pitch, unsigned y, int Offset)
  169. {
  170.    unsigned char *dst2 = dst + (temp.ox-640)*temp.obpp/16;
  171.    if (temp.scy > 200)
  172.        dst2 += (temp.scy-200)/2*pitch * ((temp.oy > temp.scy)?2:1);
  173.  
  174.     int v = y%8;
  175.     if (conf.fast_sl) {
  176.         dst2 += y*pitch;
  177.         switch(temp.obpp)
  178.         {
  179.         case 8:
  180.             line_atm6_8 (dst2, temp.base, t.zctab8 [0], fontatm2 + v*0x100, Offset);
  181.             break;
  182.         case 16:
  183.             line_atm6_16(dst2, temp.base, t.zctab16[0], fontatm2 + v*0x100, Offset);
  184.             break;
  185.         case 32:
  186.             line_atm6_32(dst2, temp.base, t.zctab32[0], fontatm2 + v*0x100, Offset);
  187.             break;
  188.         }
  189.     } else {
  190.         dst2 += 2*y*pitch;
  191.         switch(temp.obpp)
  192.         {
  193.         case 8:
  194.             line_atm6_8 (dst2, temp.base, t.zctab8 [0], fontatm2 + v*0x100, Offset);
  195.             dst2 += pitch;
  196.             line_atm6_8 (dst2, temp.base, t.zctab8 [1], fontatm2 + v*0x100, Offset);
  197.             break;
  198.         case 16:
  199.             line_atm6_16(dst2, temp.base, t.zctab16[0], fontatm2 + v*0x100, Offset);
  200.             dst2 += pitch;
  201.             line_atm6_16(dst2, temp.base, t.zctab16[1], fontatm2 + v*0x100, Offset);
  202.             break;
  203.         case 32:
  204.             line_atm6_32(dst2, temp.base, t.zctab32[0], fontatm2 + v*0x100, Offset);
  205.             dst2 += pitch;
  206.             line_atm6_32(dst2, temp.base, t.zctab32[1], fontatm2 + v*0x100, Offset);
  207.             break;
  208.         }
  209.     }
  210. }
  211.