Subversion Repositories pentevo

Rev

Rev 716 | Blame | Last modification | View Log | Download | RSS feed

  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
  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 on/off) -> 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+pc-attribute -> 2 pixels
  51.          unsigned zctab16ad[2][2*0x100];// 1 bits data+pc-attribute -> 1 pixel (doubled)
  52.       };
  53.       struct {
  54.          unsigned zctab32[2][2*0x100];  // 1 bit  data+pc-attribute -> 1 pixel
  55.          unsigned zctab32ad[2][2*0x100];// 1 bit  data+pc-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.    struct {   // for AlCo-384
  82.       unsigned char *s, *a;
  83.    } alco[304][8];
  84.  
  85.    #ifdef MOD_VID_VD
  86.    __m64 vdtab[2][4][256];
  87.    #endif
  88.  
  89. };
  90.  
  91. struct videopoint
  92. {
  93.    unsigned next_t; // ╥ръЄ эрўрыр шыш ъюэЎр ёЄЁюъш
  94.  
  95.    // ╚ёяюы№чєхЄё  Єюы№ъю хёыш Єюўър - ъюэхЎ ёЄЁюъш
  96.    unsigned char *screen_ptr;
  97.    union {
  98.       unsigned nextvmode;  // for vmode=1, 0 - яЁшчэръ эрўрыр ёЄЁюъш
  99.       unsigned atr_offs;   // for vmode=2
  100.    };
  101.    unsigned scr_offs;
  102. };
  103.  
  104. struct AtmVideoController
  105. {
  106.     struct ScanLine
  107.     {
  108.         int Offset; // ёьх∙хэшх тэєЄЁш └╥╠ тшфхюёЄЁрэшЎ√
  109.         int VideoMode; // тшфхюЁхцшь фы  фрээющ ёърэышэшш
  110.     };
  111.     void PrepareFrameATM2(int VideoMode);
  112.     void PrepareFrameATM1(int VideoMode);
  113.  
  114.     ScanLine Scanlines[256]; // ярЁрьхЄЁ√ 56 эрфсюЁфхЁэ√ї ёърэышэшщ ш 200 ЁрёЄЁют√ї ёърэышэшщ
  115.  
  116.     // ┼ёыш шэъЁхьхэЄ√ тшфхюрфЁхёр яЁюшёїюф Є фю ЇръЄшўхёъющ юЄЁшёютъш ёърэышэшш -
  117.     // Єю юэш яЁшьхэ ■Єё  ъ х╕ эрўрыє ш ёюїЁрэ ■Єё  т ёююЄтхЄёЄтє■∙хь яюых .offset ¤Єющ ёърэышэшш.
  118.     //
  119.     // ┼ёыш шэъЁхьхэЄ√ тшфхюрфЁхёр яЁюшёїюф Є т ьюьхэЄ юЄЁшёютъш ЁрёЄЁр шыш ёЁрчє чр эшь -
  120.     // Єю юэш яЁшьхэ ■Єё  ъ ёыхфє■∙хщ ёърэышэшш.
  121.     // ╫Єюс√ тхёЄш єў╕Є эръюяыхэш  шэъЁхьхэЄют шёяюы№чє■Єё  ёыхфє■∙шх фтр яюы :
  122.     int CurrentRayLine; // эюьхЁ Єхъє∙хщ ёърэышэшш, эр ъюЄюЁющ яЁюшёїюфшЄ эръюяыхэшх шэъЁхьхэЄют
  123.     int IncCounter_InRaster; // ёў╕Єўшъ фы  эръюяыхэш  +64 шэъЁхьхэЄют, ёфхырээ√ї эр ЁрёЄЁх
  124.     int IncCounter_InBorder; // ёў╕Єўшъ фы  эръюяыхэш  +64 шэъЁхьхэЄют, ёфхырээ√ї эр сюЁф■Ёх
  125. };
  126.  
  127. extern AtmVideoController AtmVideoCtrl;
  128.  
  129. static const int rb2_offs = MAX_HEIGHT*MAX_WIDTH_P;
  130. static const int sizeof_rbuf = rb2_offs*(MAX_BUFFERS+2);
  131. // ┴єЇхЁ т ъюЄюЁ√щ ЁшёєхЄё  ърЁЄшэър т zx ЇюЁьрЄх (тъы■ўр  сюЁф■Ё),
  132. // рЄЁшсєЄ√ ъюэтхЁЄшЁє■Єё  т pc ЇюЁьрЄ ўхЁхч colortab
  133. // шч ¤Єюую сєЇхЁр ърЁЄшэър фрыхх ъюэтхЁЄшЁєхЄё  т pc ЇюЁьрЄ (эряЁшьхЁ rgb32) фы  т√тюфр эр ¤ъЁрэ
  134. #ifdef CACHE_ALIGNED
  135. extern CACHE_ALIGNED unsigned char rbuf[sizeof_rbuf];
  136. #else // __declspec(align) not available, force QWORD align with old method
  137. extern unsigned char * const rbuf;
  138. #endif
  139.  
  140. extern unsigned char * const save_buf;
  141. // map zx attributes to pc attributes
  142. // pc рЄЁшсєЄ (8сшЄ) шьххЄ ЇюЁьрЄ:
  143. // ёЄрЁ°шх 4 сшЄр: paper[3..0]
  144. // ьырф°шх 4 сшЄр: ink[3..0]
  145. // яЁш ¤Єюь єцх єўЄхэ√ тёх bright ш flash
  146. extern unsigned char colortab[0x100];
  147. // colortab shifted to 8 and 24
  148. extern unsigned colortab_s8[0x100];
  149. extern unsigned colortab_s24[0x100];
  150.  
  151. extern unsigned *atrtab;
  152. extern T t;
  153.  
  154. extern PALETTEENTRY pal0[0x100]; // emulator palette
  155. extern unsigned char * const rbuf_s; // frames to mix with noflic and resampler filters
  156. extern unsigned vmode;  // what are drawing: 0-not visible, 1-border, 2-screen
  157. extern videopoint *vcurr;
  158.  
  159. void set_video();
  160. void apply_video();
  161. void paint_scr(char alt); // alt=0/1 - main/alt screen, alt=2 - ray-painted
  162. void update_screen();
  163. void video_timing_tables();
  164. void pixel_tables();
  165. void video_color_tables();
  166. void video_permanent_tables();
  167. void init_frame();
  168. void flush_frame();
  169. void load_spec_colors();
  170.