Subversion Repositories pentevo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
716 lvd 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();