Subversion Repositories pentevo

Rev

Rev 796 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #pragma once
  2.  
  3. #define MAX_WIDTH 512
  4. #define MAX_WIDTH_P (((MAX_WIDTH)*2)/8) // ╠ръёшьры№эюх чэръюьхёЄ ё pc-рЄЁшсєЄрьш т юфэющ ёЄЁюъх
  5. #define MAX_HEIGHT 304
  6. #define MAX_BUFFERS 8
  7.  
  8. #define MAX_FONT_TABLES 0x62000
  9. static const int sc2lines_width = MAX_WIDTH*2;
  10.  
  11. CACHE_ALIGNED struct T
  12. {
  13.    struct { // switch palette/color values
  14.       // 8bit
  15.       unsigned sctab8[2][16*0x100];  //4 bits data+pc-attribute -> 4 palette pixels
  16.       unsigned sctab8d[2][4*0x100];  //2 bits data+pc-attribute -> 2 palette pixels (doubled)
  17.       unsigned sctab8q[2*0x100];     //1 bit  data+pc-attribute -> 1 palette pixel (quad)
  18.       // 16bit & 32bit
  19.       unsigned sctab16[2][4*0x100];  //2 bits data+pc-attribute -> 2 pixels
  20.       unsigned sctab16d[2][2*0x100]; //1 bit  data+pc-attribute -> 1 pixel (doubled)
  21.       unsigned sctab32[2][2*0x100];  //1 bit  data+pc-attribute -> 1 pixel (sctab32[0] = {pix_off=paper[0..0xFF], pix_on=ink[0x100..0x1FF]})
  22.    };
  23.  
  24.    union { // switch chunks/noflic
  25.       unsigned c32tab[0x100][32]; // for chunks 16/32: n_pixels+attr -> chunk color
  26.       struct {
  27.          unsigned sctab16_nf[2][4*0x100];  //2 bits data+pc-attribute -> 2 pixels
  28.          unsigned sctab16d_nf[2][2*0x100]; //1 bit  data+pc-attribute -> 2 pixels
  29.          unsigned sctab32_nf[2][2*0x100];  //1 bit  data+pc-attribute -> 1 pixel
  30.       };
  31.    };
  32.  
  33.    unsigned char attrtab[0x200]; // pc attribute + bit (pixel off[0..0xFF]/on[0x100..0x1FF]) -> palette index
  34.  
  35.    CACHE_ALIGNED union {
  36.       unsigned p4bpp8[2][0x100];   // ATM EGA screen. EGA byte -> raw video data: 2 pixels (doubled) (p2p2p1p1)
  37.       unsigned p4bpp16[2][2*0x100];// ATM EGA screen. EGA byte -> raw video data: 2 pixels (doubled)
  38.       unsigned p4bpp32[2][2*0x100];// ATM EGA screen. EGA byte -> raw video data: 2 pixels
  39.    };
  40.    CACHE_ALIGNED union {
  41.       unsigned p4bpp16_nf[2][2*0x100];// ATM EGA screen. EGA byte -> raw video data: 2 pixels (doubled)
  42.       unsigned p4bpp32_nf[2][2*0x100];// ATM EGA screen. EGA byte -> raw video data: 2 pixels
  43.    };
  44.    CACHE_ALIGNED union {
  45.       struct {
  46.          unsigned zctab8[2][16*0x100];  // 4 bits data+zx-attribute -> 4 palette pixels
  47.          unsigned zctab8ad[2][4*0x100]; // 2 bits data+zx-attribute -> 2 palette pixels (doubled)
  48.       };
  49.       struct {
  50.          unsigned zctab16[2][4*0x100];  // 2 bits data+zx-attribute -> 2 pixels
  51.          unsigned zctab16ad[2][2*0x100];// 1 bits data+zx-attribute -> 1 pixel (doubled)
  52.       };
  53.       struct {
  54.          unsigned zctab32[2][2*0x100];  // 1 bit  data+zx-attribute -> 1 pixel
  55.          unsigned zctab32ad[2][2*0x100];// 1 bit  data+zx-attribute -> 1 pixel
  56.       };
  57.    };
  58.  
  59.    union {
  60.       struct { // 8bpp
  61.          CACHE_ALIGNED unsigned char scale2buf[8][sc2lines_width];    // temp buffer for scale2x,3x filter
  62.          CACHE_ALIGNED unsigned char scale4buf[8][sc2lines_width];    // temp buffer for scale4x filter
  63.       };
  64.       struct // 32 bpp
  65.       {
  66.          CACHE_ALIGNED u32 scale2buf32[8][sc2lines_width];    // temp buffer for scale2x,3x filter
  67.          CACHE_ALIGNED u32 scale4buf32[8][sc2lines_width];    // temp buffer for scale4x filter
  68.       };
  69.       unsigned bs2h[96][129];      // temp buffer for chunks 2x2 flt
  70.       unsigned bs4h[48][65];       // temp buffer for chunks 4x4 flt
  71.       void* font_tables[MAX_FONT_TABLES / sizeof(void*)]; // for anti-text64
  72.    };
  73.    // pre-calculated
  74.    unsigned settab[0x100];         // for chunks 4x4
  75.    unsigned settab2[0x100];        // for chunks 2x2
  76.    unsigned dbl[0x100]; // reverse and double pixels (for scaling renderer)
  77.    unsigned scrtab[256]; // offset to start of line
  78.    unsigned atrtab[256]; // offset to start of attribute line
  79.    unsigned atrtab_hwmc[256]; // attribute for HWMC
  80.    unsigned atm_pal_map[0x100]; // atm palette port value -> palette index
  81.    unsigned profi_pal_map[0x100]; // profi palette port value -> palette index
  82.  
  83.    struct {   // for AlCo-384
  84.       unsigned char *s, *a;
  85.    } alco[304][8];
  86.  
  87.    #ifdef MOD_VID_VD
  88.    __m64 vdtab[2][4][256];
  89.    #endif
  90.  
  91. };
  92.  
  93. struct videopoint
  94. {
  95.    unsigned next_t; // ╥ръЄ эрўрыр шыш ъюэЎр ёЄЁюъш
  96.  
  97.    // ╚ёяюы№чєхЄё  Єюы№ъю хёыш Єюўър - ъюэхЎ ёЄЁюъш
  98.    unsigned char *screen_ptr;
  99.    union {
  100.       unsigned nextvmode;  // for vmode=1, 0 - яЁшчэръ эрўрыр ёЄЁюъш
  101.       unsigned atr_offs;   // for vmode=2
  102.    };
  103.    unsigned scr_offs;
  104. };
  105.  
  106. struct AtmVideoController
  107. {
  108.     struct ScanLine
  109.     {
  110.         int Offset; // ёьх∙хэшх тэєЄЁш └╥╠ тшфхюёЄЁрэшЎ√
  111.         int VideoMode; // тшфхюЁхцшь фы  фрээющ ёърэышэшш
  112.     };
  113.     void PrepareFrameATM2(int VideoMode);
  114.     void PrepareFrameATM1(int VideoMode);
  115.  
  116.     ScanLine Scanlines[256]; // ярЁрьхЄЁ√ 56 эрфсюЁфхЁэ√ї ёърэышэшщ ш 200 ЁрёЄЁют√ї ёърэышэшщ
  117.  
  118.     // ┼ёыш шэъЁхьхэЄ√ тшфхюрфЁхёр яЁюшёїюф Є фю ЇръЄшўхёъющ юЄЁшёютъш ёърэышэшш -
  119.     // Єю юэш яЁшьхэ ■Єё  ъ х╕ эрўрыє ш ёюїЁрэ ■Єё  т ёююЄтхЄёЄтє■∙хь яюых .offset ¤Єющ ёърэышэшш.
  120.     //
  121.     // ┼ёыш шэъЁхьхэЄ√ тшфхюрфЁхёр яЁюшёїюф Є т ьюьхэЄ юЄЁшёютъш ЁрёЄЁр шыш ёЁрчє чр эшь -
  122.     // Єю юэш яЁшьхэ ■Єё  ъ ёыхфє■∙хщ ёърэышэшш.
  123.     // ╫Єюс√ тхёЄш єў╕Є эръюяыхэш  шэъЁхьхэЄют шёяюы№чє■Єё  ёыхфє■∙шх фтр яюы :
  124.     int CurrentRayLine; // эюьхЁ Єхъє∙хщ ёърэышэшш, эр ъюЄюЁющ яЁюшёїюфшЄ эръюяыхэшх шэъЁхьхэЄют
  125.     int IncCounter_InRaster; // ёў╕Єўшъ фы  эръюяыхэш  +64 шэъЁхьхэЄют, ёфхырээ√ї эр ЁрёЄЁх
  126.     int IncCounter_InBorder; // ёў╕Єўшъ фы  эръюяыхэш  +64 шэъЁхьхэЄют, ёфхырээ√ї эр сюЁф■Ёх
  127. };
  128.  
  129. extern AtmVideoController AtmVideoCtrl;
  130.  
  131. static const int rb2_offs = MAX_HEIGHT*MAX_WIDTH_P;
  132. static const int sizeof_rbuf = rb2_offs*(MAX_BUFFERS+2);
  133. // ┴єЇхЁ т ъюЄюЁ√щ ЁшёєхЄё  ърЁЄшэър т zx ЇюЁьрЄх (тъы■ўр  сюЁф■Ё),
  134. // рЄЁшсєЄ√ ъюэтхЁЄшЁє■Єё  т pc ЇюЁьрЄ ўхЁхч colortab
  135. // шч ¤Єюую сєЇхЁр ърЁЄшэър фрыхх ъюэтхЁЄшЁєхЄё  т pc ЇюЁьрЄ (эряЁшьхЁ rgb32) фы  т√тюфр эр ¤ъЁрэ
  136. // ╘юЁьрЄ сєЇхЁр: pix(8bit), attrs(8bit), ...
  137. // └ЄЁшсєЄ√ т ЇюЁьрЄх 8x1 (эр ърцф√х 8x1 Єюўхъ 1 рЄЁшсєЄ)
  138. #ifdef CACHE_ALIGNED
  139. extern CACHE_ALIGNED unsigned char rbuf[sizeof_rbuf];
  140. #else // __declspec(align) not available, force QWORD align with old method
  141. extern unsigned char * const rbuf;
  142. #endif
  143.  
  144. extern unsigned char * const save_buf;
  145. // map zx attributes to pc attributes
  146. // pc рЄЁшсєЄ (8сшЄ) шьххЄ ЇюЁьрЄ:
  147. // ёЄрЁ°шх 4 сшЄр: paper[3..0]  (шёяюы№чєхЄё , хёыш pix_off)
  148. // ьырф°шх 4 сшЄр: ink[3..0] (шёяюы№чєхЄё , хёыш pix_on)
  149. // яЁш ¤Єюь єцх єўЄхэ√ тёх bright ш flash
  150. extern unsigned char colortab[0x100];
  151. // colortab shifted to 8 and 24
  152. extern unsigned colortab_s8[0x100];
  153. extern unsigned colortab_s24[0x100];
  154.  
  155. extern unsigned *atrtab;
  156. extern T t;
  157.  
  158. extern PALETTEENTRY pal0[0x100]; // emulator palette
  159. extern unsigned char * const rbuf_s; // frames to mix with noflic and resampler filters
  160. extern unsigned vmode;  // what are drawing: 0-not visible, 1-border, 2-screen
  161. extern videopoint *vcurr;
  162.  
  163. void set_video();
  164. void apply_video();
  165. void paint_scr(char alt); // alt=0/1 - main/alt screen, alt=2 - ray-painted
  166. void update_screen();
  167. void video_timing_tables();
  168. void pixel_tables();
  169. void video_color_tables();
  170. void video_permanent_tables();
  171. void init_frame();
  172. void flush_frame();
  173. void load_spec_colors();
  174.