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