Subversion Repositories spacemission

Rev

Rev 1 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 4
1
unit DXRender;
1
unit DXRender;
2
 
2
 
3
interface
3
interface
4
 
4
 
5
{$INCLUDE DelphiXcfg.inc}
5
{$INCLUDE DelphiXcfg.inc}
6
 
6
 
7
uses
7
uses
8
  Windows, DirectX;
8
  Windows,
-
 
9
{$IfDef StandardDX}
-
 
10
  DirectDraw,
-
 
11
  {$ifdef DX7}
-
 
12
  Direct3D;
-
 
13
  {$endif}
-
 
14
  {$IfDef DX9}
-
 
15
  Direct3D9, Direct3D, D3DX9, {Direct3D8,} DX7toDX8;
-
 
16
  {$EndIf}
-
 
17
{$Else}
-
 
18
  DirectX;
-
 
19
{$EndIf}
9
 
20
 
10
const
21
const
11
  DXR_MAXTEXTURE = 4;
22
  DXR_MAXTEXTURE = 4;
12
 
23
 
13
type
24
type
14
  TDXR_Value = Double;
25
  TDXR_Value = Double;
15
 
26
 
16
  TDXR_Color = DWORD;
27
  TDXR_Color = DWORD;
17
  TDXR_SurfaceColor = DWORD;
28
  TDXR_SurfaceColor = DWORD;
18
 
29
 
-
 
30
  {  TDXR_Option  }
-
 
31
 
-
 
32
  PDXR_Option = ^TDXR_Option;
-
 
33
  TDXR_Option = (
-
 
34
    DXR_OPTION_VERSION,
-
 
35
    DXR_OPTION_MMXENABLE,
-
 
36
    DXR_OPTION_RENDERPRIMITIVES
-
 
37
  );                            
-
 
38
 
19
  {  TDXR_ShadeMode  }
39
  {  TDXR_ShadeMode  }
20
 
40
 
21
  TDXR_ShadeMode = (
41
  TDXR_ShadeMode = (
22
    DXR_SHADEMODE_FLAT,
42
    DXR_SHADEMODE_FLAT,
23
    DXR_SHADEMODE_GOURAUD
43
    DXR_SHADEMODE_GOURAUD
24
  );
44
  );
25
 
45
 
26
  {  TDXR_Blend  }
46
  {  TDXR_Blend  }
27
 
47
 
28
  TDXR_Blend = (
48
  TDXR_Blend = (
29
    // for blending
49
    // for blending
30
    DXR_BLEND_ZERO,                        // r=0
50
    DXR_BLEND_ZERO,                        // r=0
31
    DXR_BLEND_ONE1,                        // r=c1
51
    DXR_BLEND_ONE1,                        // r=c1
32
    DXR_BLEND_ONE2,                        // r=c2
52
    DXR_BLEND_ONE2,                        // r=c2
33
    DXR_BLEND_ONE1_ADD_ONE2,               // r=c1+c2
53
    DXR_BLEND_ONE1_ADD_ONE2,               // r=c1+c2
34
    DXR_BLEND_ONE1_SUB_ONE2,               // r=c1-c2
54
    DXR_BLEND_ONE1_SUB_ONE2,               // r=c1-c2
35
    DXR_BLEND_ONE2_SUB_ONE1,               // r=c2-c1
55
    DXR_BLEND_ONE2_SUB_ONE1,               // r=c2-c1
36
    DXR_BLEND_ONE1_MUL_ONE2,               // r=c1*c2
56
    DXR_BLEND_ONE1_MUL_ONE2,               // r=c1*c2
37
 
-
 
38
    DXR_BLEND_SRCALPHA1,                   // r=c1*a1
57
    DXR_BLEND_SRCALPHA1,                   // r=c1*a1
39
    DXR_BLEND_SRCALPHA1_ADD_ONE2,          // r=c1*a1+c2
58
    DXR_BLEND_SRCALPHA1_ADD_ONE2,          // r=c1*a1+c2
40
    DXR_BLEND_ONE2_SUB_SRCALPHA1,          // r=c2-c1*a1
59
    DXR_BLEND_ONE2_SUB_SRCALPHA1,          // r=c2-c1*a1
41
    DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2,  // r=c1*a1+c2*(1-a2)
60
    DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2,  // r=c1*a1+c2*(1-a2)
42
    DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2,  // r=c1*(1-a1)+c2*a2
61
    DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2,  // r=c1*(1-a1)+c2*a2
43
    // for lighting
62
    // for lighting
-
 
63
    DXR_BLEND_DECAL,                       // r=c1
44
    DXR_BLEND_DECALALPHA,                  // r=c1    ra=a2
64
    DXR_BLEND_DECALALPHA,                  // r=c1    ra=a2
45
    DXR_BLEND_MODULATE,                    // r=c1*c2 ra=a2
65
    DXR_BLEND_MODULATE,                    // r=c1*c2 ra=a2
-
 
66
    DXR_BLEND_MODULATEALPHA,               // r=c1*c2
46
    DXR_BLEND_ADD                          // r=c1+c2 ra=a2
67
    DXR_BLEND_ADD                          // r=c1+c2 ra=a2
47
  );
68
  );
48
 
69
 
49
  {  TDXR_TextureFilter  }
70
  {  TDXR_TextureFilter  }
50
 
71
 
51
  TDXR_TextureFilter = (
72
  TDXR_TextureFilter = (
52
    DXR_TEXTUREFILTER_NEAREST,
73
    DXR_TEXTUREFILTER_NEAREST,
53
    DXR_TEXTUREFILTER_LINEAR
74
    DXR_TEXTUREFILTER_LINEAR,
-
 
75
    DXR_TEXTUREFILTER_MIPMAP_NEAREST,
-
 
76
    DXR_TEXTUREFILTER_MIPMAP_LINEAR
54
  );
77
  );
55
 
78
 
56
  {  TDXR_TextureAddress  }
79
  {  TDXR_TextureAddress  }
57
 
80
 
58
  TDXR_TextureAddress = (
81
  TDXR_TextureAddress = (
59
    DXR_TEXTUREADDRESS_TILE,           // tx=tx and WidthMask ty=ty and HeightMask
82
    DXR_TEXTUREADDRESS_TILE,           // tx=tx and WidthMask ty=ty and HeightMask
60
    DXR_TEXTUREADDRESS_DONOTCLIP       // tx=tx               ty=ty
83
    DXR_TEXTUREADDRESS_DONOTCLIP       // tx=tx               ty=ty
61
  );
84
  );
62
 
85
 
-
 
86
  {  TDXR_CmpFunc  }
-
 
87
 
-
 
88
  TDXR_CmpFunc = (
-
 
89
    DXR_CMPFUNC_NEVER,
-
 
90
    DXR_CMPFUNC_LESS,
-
 
91
    DXR_CMPFUNC_EQUAL,
-
 
92
    DXR_CMPFUNC_LESSEQUAL,
-
 
93
    DXR_CMPFUNC_GREATER,
-
 
94
    DXR_CMPFUNC_NOTEQUAL,
-
 
95
    DXR_CMPFUNC_GREATEREQUAL,
-
 
96
    DXR_CMPFUNC_ALWAYS
-
 
97
  );
-
 
98
 
63
  {  TDXR_ColorType  }
99
  {  TDXR_ColorType  }
64
 
100
 
65
  TDXR_ColorType = (
101
  TDXR_ColorType = (
66
    DXR_COLORTYPE_INDEXED,     // Palette indexed color
102
    DXR_COLORTYPE_INDEXED,     // Palette indexed color
67
    DXR_COLORTYPE_RGB          // RGB color
103
    DXR_COLORTYPE_RGB          // RGB color
68
  );
104
  );
69
 
105
 
70
  {  TDXR_ColorChannel  }
106
  {  TDXR_ColorChannel  }
71
 
107
 
72
  TDXR_ColorChannel = record
108
  TDXR_ColorChannel = record
73
    Mask: DWORD;                // Bit Mask
109
    Mask: DWORD;                // Bit Mask
74
    BitCount: DWORD;            // Number of bit
110
    BitCount: DWORD;            // Number of bit
75
    rshift: DWORD;
111
    rshift: DWORD;
76
    lshift: DWORD;
112
    lshift: DWORD;
77
  end;
113
  end;
78
 
114
 
79
  {  TDXR_Surface  }
115
  {  TDXR_Surface  }
80
 
116
 
81
  PDXR_Surface = ^TDXR_Surface;
117
  PDXR_Surface = ^TDXR_Surface;
82
  TDXR_Surface = record
118
  TDXR_Surface = record
83
    ColorType: TDXR_ColorType;   // Color type
119
    ColorType: TDXR_ColorType;   // Color type
84
    Width, Height: DWORD;        // Size of surface
120
    Width, Height: DWORD;        // Size of surface
85
    WidthBit, HeightBit: DWORD;  // Size of surface (Number of bit)
121
    WidthBit, HeightBit: DWORD;  // Size of surface (Number of bit)
86
    Width2, Height2: DWORD;      // 1 shl WidthBit, 1 shl HeightBit
122
    Width2, Height2: DWORD;      // 1 shl WidthBit, 1 shl HeightBit
87
    WidthMask, HeightMask: DWORD;// Bit Mask of size of surface
123
    WidthMask, HeightMask: DWORD;// Bit Mask of size of surface
88
    BitCount: DWORD;             // BitCount per Pixel(1, 2, 4, 8, 16, 24, 32 only)
124
    BitCount: DWORD;             // BitCount per Pixel(1, 2, 4, 8, 16, 24, 32 only)
89
    Bits: Pointer;               // Pointer to pixeldata(x:0 y:0)
125
    Bits: Pointer;               // Pointer to pixeldata(x:0 y:0)
90
    Pitch: Integer;              // Offset of next scanline
126
    Pitch: Integer;              // Offset of next scanline
91
    PitchBit: Integer;           // Offset of next scanline (Number of bit)
127
    PitchBit: Integer;           // Offset of next scanline (Number of bit)
-
 
128
    MipmapChain: PDXR_Surface;
92
    case Integer of
129
    case Integer of
93
      0: (
130
      0: (
94
        { Indexed color }
131
        { Indexed color }
95
        idx_index: TDXR_ColorChannel;  // Index channel
132
        idx_index: TDXR_ColorChannel;  // Index channel
96
        idx_alpha: TDXR_ColorChannel;  // Alpha channel
133
        idx_alpha: TDXR_ColorChannel;  // Alpha channel
97
        idx_palette: array[0..255] of TPaletteEntry;
134
        idx_palette: array[0..255] of TPaletteEntry;
98
                                       // Palette
135
                                       // Palette
99
      );
136
      );
100
      1: (
137
      1: (
101
        { RGB color }
138
        { RGB color }
102
        rgb_red: TDXR_ColorChannel;    // Red channel
139
        rgb_red: TDXR_ColorChannel;    // Red channel
103
        rgb_green: TDXR_ColorChannel;  // Green channel
140
        rgb_green: TDXR_ColorChannel;  // Green channel
104
        rgb_blue: TDXR_ColorChannel;   // Blue channel
141
        rgb_blue: TDXR_ColorChannel;   // Blue channel
105
        rgb_alpha: TDXR_ColorChannel;  // Alpha channel
142
        rgb_alpha: TDXR_ColorChannel;  // Alpha channel
106
      );
143
      );
107
  end;
144
  end;
108
 
145
 
109
  {  TDXR_Vertex  }
146
  {  TDXR_Vertex  }
110
 
147
 
111
  PDXR_Vertex = ^TDXR_Vertex;
148
  PDXR_Vertex = ^TDXR_Vertex;
112
  TDXR_Vertex = record
149
  TDXR_Vertex = record
113
    sx: TDXR_Value;            // Screen coordinates
150
    sx: TDXR_Value;            // Screen coordinates
114
    sy: TDXR_Value;
151
    sy: TDXR_Value;
115
    sz: TDXR_Value;
152
    sz: TDXR_Value;
-
 
153
    rhw: TDXR_Value;           // 1/sz
116
    color: TDXR_Color;
154
    color: TDXR_Color;
117
    specular: TDXR_Color;
155
    specular: TDXR_Color;
118
    tu, tv: array[0..DXR_MAXTEXTURE-1] of TDXR_Value;
156
    tu, tv: array[0..DXR_MAXTEXTURE-1] of TDXR_Value;
119
  end;
157
  end;
120
 
158
 
121
  PPDXR_Vertex = ^PDXR_Vertex;
159
  PPDXR_Vertex = ^PDXR_Vertex;
122
 
160
 
123
  {  TDXR_PrimitiveType  }
161
  {  TDXR_PrimitiveType  }
124
 
162
 
125
  TDXR_PrimitiveType = (
163
  TDXR_PrimitiveType = (
126
    DXR_PRIMITIVETYPE_TRIANGLELIST,
164
    DXR_PRIMITIVETYPE_TRIANGLELIST,
127
    DXR_PRIMITIVETYPE_TRIANGLESTRIP
165
    DXR_PRIMITIVETYPE_TRIANGLESTRIP
128
  );
166
  );
129
 
167
 
130
  {  TDXR_TextureLayerBlend  }
168
  {  TDXR_TextureLayerBlend  }
131
 
169
 
132
  TDXR_TextureLayerBlend = (
170
  TDXR_TextureLayerBlend = (
133
    DXR_TEXTURELAYERBLEND_TEXTURE,
171
    DXR_TEXTURELAYERBLEND_TEXTURE,
134
    DXR_TEXTURELAYERBLEND_LAST,
172
    DXR_TEXTURELAYERBLEND_LAST,
135
    DXR_TEXTURELAYERBLEND_NOBLEND
173
    DXR_TEXTURELAYERBLEND_NOBLEND
136
  );
174
  );
137
 
175
 
138
  {  TDXR_TextureLayer  }
176
  {  TDXR_TextureLayer  }
139
 
177
 
140
  PDXR_TextureLayer = ^TDXR_TextureLayer;
178
  PDXR_TextureLayer = ^TDXR_TextureLayer;
141
  TDXR_TextureLayer = record
179
  TDXR_TextureLayer = record
142
    Surface: PDXR_Surface;
180
    Surface: PDXR_Surface;
143
    LayerBlend: TDXR_TextureLayerBlend;
181
    LayerBlend: TDXR_TextureLayerBlend;
144
    Blend: TDXR_Blend;
182
    Blend: TDXR_Blend;
145
    ColorKeyEnable: Boolean;
183
    ColorKeyEnable: Boolean;
146
    ColorKey: TDXR_SurfaceColor;
184
    ColorKey: TDXR_SurfaceColor;
147
    TextureAddress: TDXR_TextureAddress;
185
    TextureAddress: TDXR_TextureAddress;
-
 
186
    BumpTexture: Integer;
148
  end;
187
  end;
149
 
188
 
150
  {  TDXR_Cull  }
189
  {  TDXR_Cull  }
151
 
190
 
152
  TDXR_Cull = (
191
  TDXR_Cull = (
153
    DXR_CULL_NONE,
192
    DXR_CULL_NONE,
154
    DXR_CULL_CW,
193
    DXR_CULL_CW,
155
    DXR_CULL_CCW
194
    DXR_CULL_CCW
156
  );
195
  );
157
 
196
 
158
  {  TDXR_RenderStates  }
197
  {  TDXR_RenderStates  }
159
 
198
 
160
  TDXR_RenderStates = record
199
  TDXR_RenderStates = record
161
    DitherEnable: Boolean;
200
    DitherEnable: Boolean;
162
    SpecularEnable: Boolean;
201
    SpecularEnable: Boolean;
163
    CullMode: TDXR_Cull;
202
    CullMode: TDXR_Cull;
164
    Shade: TDXR_ShadeMode;
203
    Shade: TDXR_ShadeMode;
165
    TexBlend: TDXR_Blend;
204
    TexBlend: TDXR_Blend;
166
    Blend: TDXR_Blend;
205
    Blend: TDXR_Blend;
167
    TextureEnable: Boolean;
206
    TextureEnable: Boolean;
168
    TextureList: array[0..DXR_MAXTEXTURE-1] of TDXR_TextureLayer;
207
    TextureList: array[0..DXR_MAXTEXTURE-1] of TDXR_TextureLayer;
169
    TextureFilter: TDXR_TextureFilter;
208
    TextureFilter: TDXR_TextureFilter;
-
 
209
    ZBuffer: PDXR_Surface;
-
 
210
    ZFunc: TDXR_CmpFunc;
-
 
211
    ZWriteEnable: Boolean;
170
    EnableDrawLine: DWORD;
212
    EnableDrawLine: Integer;
171
  end;
213
  end;
172
 
214
 
-
 
215
function dxrGetOption(Option: TDXR_Option): DWORD;
-
 
216
procedure dxrSetOption(Option: TDXR_Option; Value: DWORD);
-
 
217
 
173
procedure dxrMakeIndexedSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
218
procedure dxrMakeIndexedSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
174
  Bits: Pointer; pitch: Integer; idx_index, idx_alpha: DWORD);
219
  Bits: Pointer; pitch: Integer; idx_index, idx_alpha: DWORD);
175
procedure dxrMakeRGBSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
220
procedure dxrMakeRGBSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
176
  Bits: Pointer; pitch: Integer; rgb_red, rgb_green, rgb_blue, rgb_alpha: DWORD);
221
  Bits: Pointer; pitch: Integer; rgb_red, rgb_green, rgb_blue, rgb_alpha: DWORD);
177
function dxrScanLine(const Surface: TDXR_Surface; y: DWORD): Pointer;
222
function dxrScanLine(const Surface: TDXR_Surface; y: DWORD): Pointer;
-
 
223
procedure dxrZBufferClear(const Surface: TDXR_Surface);
178
 
224
 
179
function dxrDDSurfaceLock(DDSurface: IDirectDrawSurface; var Surface: TDXR_Surface): Boolean;
225
function dxrDDSurfaceLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var Surface: TDXR_Surface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
180
function dxrDDSurfaceLock2(DDSurface: IDirectDrawSurface; var ddsd: TDDSurfaceDesc;
226
function dxrDDSurfaceLock2(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
181
  var Surface: TDXR_Surface): Boolean;
227
  var Surface: TDXR_Surface): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
182
procedure dxrDDSurfaceUnLock(DDSurface: IDirectDrawSurface; const Surface: TDXR_Surface);
228
procedure dxrDDSurfaceUnLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; const Surface: TDXR_Surface); {$IFDEF VER9UP}inline;{$ENDIF}
183
 
229
 
184
procedure dxrDefRenderStates(var States: TDXR_RenderStates);
230
procedure dxrDefRenderStates(var States: TDXR_RenderStates);
185
 
231
 
186
procedure dxrDrawPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
232
procedure dxrDrawPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
187
  VertexList: PDXR_Vertex; VertexCount: DWORD);
233
  VertexList: PDXR_Vertex; VertexCount: DWORD);
188
procedure dxrDrawPointeredPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
234
procedure dxrDrawPointeredPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
189
  VertexList: PPDXR_Vertex; VertexCount: DWORD);
235
  VertexList: PPDXR_Vertex; VertexCount: DWORD);
190
procedure dxrDrawIndexedPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
236
procedure dxrDrawIndexedPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
191
  VertexList: PDXR_Vertex; VertexCount: DWORD; IndexList: PDWORD; IndexCount: DWORD);
237
  VertexList: PDXR_Vertex; VertexCount: DWORD; IndexList: PDWORD; IndexCount: DWORD);
192
 
238
 
193
procedure dxrCopyRectBlend(const Dest, Src: TDXR_Surface;
239
procedure dxrCopyRectBlend(const Dest, Src: TDXR_Surface;
194
  const DestRect, SrcRect: TRect; Blend: TDXR_Blend; Alpha: Integer;
240
  const DestRect, SrcRect: TRect; Blend: TDXR_Blend; Alpha: Integer;
195
  ColorKeyEnable: Boolean; ColorKey: DWORD);
241
  ColorKeyEnable: Boolean; ColorKey: DWORD);
196
 
242
 
197
procedure dxrFillRectColorBlend(const Dest: TDXR_Surface;
243
procedure dxrFillRectColorBlend(const Dest: TDXR_Surface;
198
  const DestRect: TRect; Blend: TDXR_Blend; Col: COLORREF);
244
  const DestRect: TRect; Blend: TDXR_Blend; Col: COLORREF);
199
 
245
 
200
procedure dxrDrawWaveXBlend(const Dest, Src: TDXR_Surface;
246
procedure dxrDrawWaveXBlend(const Dest, Src: TDXR_Surface;
201
  X, Y, Width, Height: Integer; const SrcRect: TRect; amp, Len, ph: Integer;
247
  X, Y, Width, Height: Integer; const SrcRect: TRect; amp, Len, ph: Integer;
202
  Blend: TDXR_Blend; Alpha: Integer;
248
  Blend: TDXR_Blend; Alpha: Integer;
203
  ColorKeyEnable: Boolean; ColorKey: DWORD);
249
  ColorKeyEnable: Boolean; ColorKey: DWORD);
204
 
250
 
205
procedure dxrDrawRotateBlend(const Dest, Src: TDXR_Surface;
251
procedure dxrDrawRotateBlend(const Dest, Src: TDXR_Surface;
206
  X, Y, Width, Height: Integer; const SrcRect: TRect; CenterX, CenterY: Double;
252
  X, Y, Width, Height: Integer; const SrcRect: TRect; CenterX, CenterY: Double;
207
  Angle: Integer; Blend: TDXR_Blend; Alpha: Integer;
253
  Angle: Integer; Blend: TDXR_Blend; Alpha: Integer;
208
  ColorKeyEnable: Boolean; ColorKey: DWORD);
254
  ColorKeyEnable: Boolean; ColorKey: DWORD);
209
 
255
 
210
implementation
256
implementation
211
 
257
 
212
const
258
const
213
  TextureAxisFloatBit = 16;
259
  TextureAxisFloatBit = 16;
214
  TextureAxisFloat = 1 shl TextureAxisFloatBit;
260
  TextureAxisFloat = 1 shl TextureAxisFloatBit;
215
 
261
 
216
  ColorFloatBit = 8;
262
  ColorFloatBit = 8;
217
  ColorFloat = 1 shl ColorFloatBit;
263
  ColorFloat = 1 shl ColorFloatBit;
218
 
264
               
219
type
265
type
220
 
266
 
221
  PInteger = ^Integer;
267
  PInteger = ^Integer;
222
 
268
 
223
  {  TDXR_CmpFunc  }
-
 
224
 
-
 
225
  TDXR_CmpFunc = (
-
 
226
    DXR_CMPFUNC_NEVER,
-
 
227
    DXR_CMPFUNC_LESS,
-
 
228
    DXR_CMPFUNC_EQUAL,
-
 
229
    DXR_CMPFUNC_LESSEQUAL,
-
 
230
    DXR_CMPFUNC_GREATER,
-
 
231
    DXR_CMPFUNC_NOTEQUAL,
-
 
232
    DXR_CMPFUNC_GREATEREQUAL,
-
 
233
    DXR_CMPFUNC_ALWAYS
-
 
234
  );
-
 
235
 
-
 
236
  {  TDXRMachine  }
269
  {  TDXRMachine  }
237
 
270
 
238
  TDXRMachine_TreeType = (
271
  TDXRMachine_TreeType = (
239
    DXR_TREETYPE_LOADBLACK,      // Load black color
272
    DXR_TREETYPE_LOADBLACK,      // Load black color
240
    DXR_TREETYPE_LOADCOLOR,      // Load vertex color
273
    DXR_TREETYPE_LOADCOLOR,      // Load vertex color
241
    DXR_TREETYPE_LOADCONSTCOLOR, // Load constant color
274
    DXR_TREETYPE_LOADCONSTCOLOR, // Load constant color
242
    DXR_TREETYPE_LOADTEXTURE,    // Load texel
275
    DXR_TREETYPE_LOADTEXTURE,    // Load texel
-
 
276
    DXR_TREETYPE_LOADBUMPTEXTURE,// Load texel with Bump mapping
-
 
277
                                 //   dx := nx + (BumpTexture[nx-1, ny]-BumpTexture[nx+1, ny]);
-
 
278
                                 //   dy := ny + (BumpTexture[nx, ny-1]-BumpTexture[nx, ny+1]);
243
    DXR_TREETYPE_LOADDESTPIXEL,  // Load dest pixel
279
    DXR_TREETYPE_LOADDESTPIXEL,  // Load dest pixel
244
    DXR_TREETYPE_BLEND           // Blend color
280
    DXR_TREETYPE_BLEND           // Blend color
245
  );
281
  );
246
 
282
 
247
  TDXRColorChannel = (chRed, chGreen, chBlue, chAlpha);
283
  TDXRColorChannel = (chRed, chGreen, chBlue, chAlpha);
248
  TDXRColorChannels = set of TDXRColorChannel;
284
  TDXRColorChannels = set of TDXRColorChannel;
249
 
285
 
250
  PDXRMachine_Color = ^TDXRMachine_Color;
286
  PDXRMachine_Color = ^TDXRMachine_Color;
251
  TDXRMachine_Color = packed record
287
  TDXRMachine_Color = packed record
252
    R, G, B, A: WORD;
288
    R, G, B, A: WORD;
253
  end;
289
  end;
254
 
290
 
255
  PDXRMachine_Axis = ^TDXRMachine_Axis;
291
  PDXRMachine_Axis = ^TDXRMachine_Axis;
256
  TDXRMachine_Axis = packed record
292
  TDXRMachine_Axis = packed record
257
    X, Y: Integer;
293
    X, Y: Integer;
258
  end;
294
  end;
259
 
295
 
260
  PDXRMachine_Int64 = ^TDXRMachine_Int64;
296
  PDXRMachine_Int64 = ^TDXRMachine_Int64;
261
  TDXRMachine_Int64 = Comp;
297
  TDXRMachine_Int64 = Comp;
262
 
298
 
263
  PDXRMachine_Reg_Color = ^TDXRMachine_Reg_Color;
299
  PDXRMachine_Reg_Color = ^TDXRMachine_Reg_Color;
264
  TDXRMachine_Reg_Color = record
300
  TDXRMachine_Reg_Color = record
265
    Enable: Boolean;
301
    Enable: Boolean;
266
    nColor: TDXRMachine_Color;
302
    nColor: TDXRMachine_Color;
267
    iColor: TDXRMachine_Color;
303
    iColor: TDXRMachine_Color;
268
    Gouraud: Boolean;
304
    Gouraud: Boolean;
269
    Channels: TDXRColorChannels;
305
    Channels: TDXRColorChannels;
270
  end;
306
  end;
271
 
307
 
272
  PDXRMachine_Reg_Texture = ^TDXRMachine_Reg_Texture;
308
  PDXRMachine_Reg_Texture = ^TDXRMachine_Reg_Texture;
273
  TDXRMachine_Reg_Texture = record
309
  TDXRMachine_Reg_Texture = record
274
    Enable: Boolean;
310
    Enable: Boolean;
275
    Surface: PDXR_Surface;
311
    Surface: PDXR_Surface;
276
    nAxis: TDXRMachine_Axis;
312
    nAxis: TDXRMachine_Axis;
277
    iAxis: TDXRMachine_Axis;
313
    iAxis: TDXRMachine_Axis;
278
    iAxisConstant: Boolean;
314
    iAxisConstant: Boolean;
279
    Filter: TDXR_TextureFilter;
315
    Filter: TDXR_TextureFilter;
280
    ColorKeyEnable: Boolean;
316
    ColorKeyEnable: Boolean;
281
    ColorKey: TDXR_SurfaceColor;
317
    ColorKey: TDXR_SurfaceColor;
282
    EnableChannels: TDXRColorChannels;
318
    EnableChannels: TDXRColorChannels;
283
    TextureAddress: TDXR_TextureAddress;
319
    TextureAddress: TDXR_TextureAddress;
284
    DefaultColor: TDXRMachine_Color;
320
    DefaultColor: TDXRMachine_Color;
285
  end;
321
  end;
286
 
322
 
-
 
323
  TDXRMachine_Reg_RHW = record
-
 
324
    Enable: Boolean;
-
 
325
    nRHW: TDXRMachine_Int64;
-
 
326
    iRHW: TDXRMachine_Int64;
-
 
327
  end;
-
 
328
 
287
  TDXRMachine_Reg_Dither = record
329
  TDXRMachine_Reg_Dither = record
288
    Enable: Boolean;
330
    Enable: Boolean;
289
  end;
331
  end;
290
 
332
 
-
 
333
  TDXRMachine_Reg_ZBuffer = record
-
 
334
    Enable: Boolean;
-
 
335
    Surface: PDXR_Surface;
-
 
336
    CmpFunc: TDXR_CmpFunc;
-
 
337
    WriteEnable: Boolean;
-
 
338
  end;
-
 
339
 
291
  TDXRMachine_Reg_Axis = record
340
  TDXRMachine_Reg_Axis = record
292
    Axis: TDXRMachine_Axis;
341
    Axis: TDXRMachine_Axis;
293
    IncEnable: Boolean;
342
    IncEnable: Boolean;
294
  end;
343
  end;
295
 
344
 
296
  PDXRMachine_Tree = ^TDXRMachine_Tree;
345
  PDXRMachine_Tree = ^TDXRMachine_Tree;
297
  TDXRMachine_Tree = record
346
  TDXRMachine_Tree = record
298
    Typ: TDXRMachine_TreeType;
347
    Typ: TDXRMachine_TreeType;
299
    Channels: TDXRColorChannels;
348
    Channels: TDXRColorChannels;
300
    case TDXRMachine_TreeType of
349
    case TDXRMachine_TreeType of
301
      DXR_TREETYPE_LOADBLACK: (
350
      DXR_TREETYPE_LOADBLACK: (
302
        );
351
        );
303
      DXR_TREETYPE_LOADCOLOR: (
352
      DXR_TREETYPE_LOADCOLOR: (
304
        Color: Integer
353
        Color: Integer
305
        );
354
        );
306
      DXR_TREETYPE_LOADCONSTCOLOR: (
355
      DXR_TREETYPE_LOADCONSTCOLOR: (
307
        ConstColor: TDXRMachine_Color;
356
        ConstColor: TDXRMachine_Color;
308
        );
357
        );
309
      DXR_TREETYPE_LOADTEXTURE: (
358
      DXR_TREETYPE_LOADTEXTURE: (
310
        Texture: Integer
359
        Texture: Integer
311
        );
360
        );
-
 
361
      DXR_TREETYPE_LOADBUMPTEXTURE: (
-
 
362
        _Texture: Integer;
-
 
363
        BumpTexture: Integer;
-
 
364
        );
312
      DXR_TREETYPE_LOADDESTPIXEL: (
365
      DXR_TREETYPE_LOADDESTPIXEL: (
313
        );
366
        );
314
      DXR_TREETYPE_BLEND: (
367
      DXR_TREETYPE_BLEND: (
315
        Blend: TDXR_Blend;
368
        Blend: TDXR_Blend;
316
        BlendTree1: PDXRMachine_Tree;
369
        BlendTree1: PDXRMachine_Tree;
317
        BlendTree2: PDXRMachine_Tree;
370
        BlendTree2: PDXRMachine_Tree;
318
        );
371
        );
319
  end;
372
  end;
320
 
373
 
321
  TDXRMachine = class
374
  TDXRMachine = class
322
  private
375
  private
323
    FBuf: Pointer;
376
    FBuf: Pointer;
324
    FCall: Pointer;
377
    FCall: Pointer;
325
    FCompiled: Boolean;
378
    FCompiled: Boolean;
326
    FTreeCount: Integer;
379
    FTreeCount: Integer;
327
    FTreeList: array[0..127] of TDXRMachine_Tree;
380
    FTreeList: array[0..127] of TDXRMachine_Tree;
328
    FMMXUsed: Boolean;
381
    FMMXUsed: Boolean;
-
 
382
    F_ZBuf: Pointer;
329
    F_BiLinearAxis: TDXRMachine_Axis;
383
    F_BiLinearAxis: TDXRMachine_Axis;
330
    F_BiLinearCol1: TDXRMachine_Color;
384
    F_BiLinearCol1: TDXRMachine_Color;
331
    F_BiLinearCol2: TDXRMachine_Color;
385
    F_BiLinearCol2: TDXRMachine_Color;
332
    F_BiLinearCol3: TDXRMachine_Color;
386
    F_BiLinearCol3: TDXRMachine_Color;
333
    F_BiLinearCol4: TDXRMachine_Color;
387
    F_BiLinearCol4: TDXRMachine_Color;
-
 
388
    F_BumpAxis: TDXRMachine_Axis;
-
 
389
    F_BumpAxis2: TDXRMachine_Axis;
-
 
390
    F_BumpTempCol: DWORD;
334
    FStack: array[0..255] of TDXRMachine_Color;
391
    FStack: array[0..255] of TDXRMachine_Color;
335
    procedure GenerateCode(var Code: Pointer; Tree: PDXRMachine_Tree);
392
    procedure GenerateCode(var Code: Pointer; Tree: PDXRMachine_Tree);
336
  public
393
  public
337
    Dest: PDXR_Surface;
394
    Dest: PDXR_Surface;
338
    ColorList: array[0..7] of TDXRMachine_Reg_Color;
395
    ColorList: array[0..7] of TDXRMachine_Reg_Color;
339
    ColorIndex: array[0..7] of Integer;
396
    ColorIndex: array[0..7] of Integer;
340
    ColorIndexCount: Integer;
397
    ColorIndexCount: Integer;
341
    TextureList: array[0..7] of TDXRMachine_Reg_Texture;
398
    TextureList: array[0..7] of TDXRMachine_Reg_Texture;
342
    TextureIndex: array[0..7] of Integer;
399
    TextureIndex: array[0..7] of Integer;
343
    TextureIndexCount: Integer;
400
    TextureIndexCount: Integer;
344
    Dither: TDXRMachine_Reg_Dither;
401
    Dither: TDXRMachine_Reg_Dither;
-
 
402
    ZBuffer: TDXRMachine_Reg_ZBuffer;
345
    Axis: TDXRMachine_Reg_Axis;
403
    Axis: TDXRMachine_Reg_Axis;
-
 
404
    RHW: TDXRMachine_Reg_RHW;
346
    constructor Create;
405
    constructor Create;
347
    destructor Destroy; override;
406
    destructor Destroy; override;
348
    function CreateTree: PDXRMachine_Tree;
407
    function CreateTree: PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
349
    function CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree;
408
    function CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
350
    function CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree;
409
    function CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
351
    function CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree;
410
    function CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
352
    function CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree;
411
    function CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
-
 
412
    function CreateTree_LoadBumpTexture(Texture, BumpTexture: DWORD): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
353
    function CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree;
413
    function CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree; {$IFDEF VER9UP}inline;{$ENDIF}
354
    procedure Initialize;
414
    procedure Initialize; {$IFDEF VER9UP}inline;{$ENDIF}
355
    procedure Compile(Tree: PDXRMachine_Tree);
415
    procedure Compile(Tree: PDXRMachine_Tree);
356
    procedure Run(Count: Integer);
416
    procedure Run(Count: Integer);
357
    property Compiled: Boolean read FCompiled write FCompiled;
417
    property Compiled: Boolean read FCompiled write FCompiled;
358
  end;
418
  end;
359
 
419
 
360
const
420
const
361
  CPUIDF_FPU  = 1 shl 0;  {  Floating-point unit on-chip  }
421
  CPUIDF_FPU  = 1 shl 0;  {  Floating-point unit on-chip  }
362
  CPUIDF_VME  = 1 shl 1;  {  Virtual Mode Extension  }
422
  CPUIDF_VME  = 1 shl 1;  {  Virtual Mode Extension  }
363
  CPUIDF_DE   = 1 shl 2;  {  Debugging Extension  }
423
  CPUIDF_DE   = 1 shl 2;  {  Debugging Extension  }
364
  CPUIDF_PSE  = 1 shl 3;  {  Page Size Extension  }
424
  CPUIDF_PSE  = 1 shl 3;  {  Page Size Extension  }
365
  CPUIDF_TSC  = 1 shl 4;  {  Time Stamp Counter  }
425
  CPUIDF_TSC  = 1 shl 4;  {  Time Stamp Counter  }
366
  CPUIDF_MSR  = 1 shl 5;  {  Mode Spacific Registers  }
426
  CPUIDF_MSR  = 1 shl 5;  {  Mode Spacific Registers  }
367
  CPUIDF_PAE  = 1 shl 6;  {  Physical Address Extension  }
427
  CPUIDF_PAE  = 1 shl 6;  {  Physical Address Extension  }
368
  CPUIDF_MCE  = 1 shl 7;  {  Machine Check Exception  }
428
  CPUIDF_MCE  = 1 shl 7;  {  Machine Check Exception  }
369
  CPUIDF_CX8  = 1 shl 8;  {  CMPXCHG8 Instruction Supported  }
429
  CPUIDF_CX8  = 1 shl 8;  {  CMPXCHG8 Instruction Supported  }
370
  CPUIDF_APIC = 1 shl 9;  {  On-chip APIC Hardware Supported }
430
  CPUIDF_APIC = 1 shl 9;  {  On-chip APIC Hardware Supported }
371
  CPUIDF_MTRR = 1 shl 12; {  Memory Type Range Registers  }
431
  CPUIDF_MTRR = 1 shl 12; {  Memory Type Range Registers  }
372
  CPUIDF_PGE  = 1 shl 13; {  Page Global Enable  }
432
  CPUIDF_PGE  = 1 shl 13; {  Page Global Enable  }
373
  CPUIDF_MCA  = 1 shl 14; {  Machine Check Architecture  }
433
  CPUIDF_MCA  = 1 shl 14; {  Machine Check Architecture  }
374
  CPUIDF_CMOV = 1 shl 15; {  Conditional Move Instruction Supported  }
434
  CPUIDF_CMOV = 1 shl 15; {  Conditional Move Instruction Supported  }
375
  CPUIDF_MMX  = 1 shl 23; {  Intel Architecture MMX Technology supported  }
435
  CPUIDF_MMX  = 1 shl 23; {  Intel Architecture MMX Technology supported  }
376
 
436
 
377
var
437
var
378
  CPUIDVendor: array[0..11] of Char;
438
  CPUIDVendor: array[0..11] of Char;
379
  CPUIDSignature: Integer;
439
  CPUIDSignature: Integer;
380
  CPUIDFeatures: Integer;
440
  CPUIDFeatures: Integer;
381
  UseMMX: Boolean;
441
  UseMMX: Boolean;
382
 
442
 
383
  RenderPrimitiveCount: Integer;
443
  RenderPrimitiveCount: Integer;
384
 
444
 
385
procedure ReadCPUID;
445
procedure ReadCPUID;
386
begin
446
begin
387
  asm
447
  asm
388
    push ebx
448
    push ebx
389
 
449
 
390
    pushfd
450
    pushfd
391
    pop eax
451
    pop eax
392
    mov ecx,eax
452
    mov ecx,eax
393
    xor eax,$200000
453
    xor eax,$200000
394
    push eax
454
    push eax
395
    popfd
455
    popfd
396
    pushfd
456
    pushfd
397
    pop eax
457
    pop eax
398
    xor eax,ecx
458
    xor eax,ecx
399
    jz @@exit
459
    jz @@exit
400
 
460
 
401
    mov eax,0
461
    mov eax,0
402
    db $0F,$A2                  ///cpuid
462
    db $0F,$A2                  ///cpuid
403
    cmp eax,1
463
    cmp eax,1
404
    jl @@exit
464
    jl @@exit
405
 
465
 
406
    {  Vendor ID  }
466
    {  Vendor ID  }
407
    mov eax,0
467
    mov eax,0
408
    db $0F,$A2                  ///cpuid
468
    db $0F,$A2                  ///cpuid
409
    mov dword ptr [CPUIDVendor], ebx
469
    mov dword ptr [CPUIDVendor], ebx
410
    mov dword ptr [CPUIDVendor+4], edx
470
    mov dword ptr [CPUIDVendor+4], edx
411
    mov dword ptr [CPUIDVendor+8], ecx
471
    mov dword ptr [CPUIDVendor+8], ecx
412
 
472
 
413
    {  Features, Signature  }
473
    {  Features, Signature  }
414
    mov eax,1
474
    mov eax,1
415
    db $0F,$A2                  ///cpuid
475
    db $0F,$A2                  ///cpuid
416
    mov CPUIDSignature,eax
476
    mov CPUIDSignature,eax
417
    mov CPUIDFeatures,edx
477
    mov CPUIDFeatures,edx
418
  @@exit:
478
  @@exit:
419
    pop ebx
479
    pop ebx
420
  end;
480
  end;
421
 
-
 
422
  UseMMX := CPUIDFeatures and CPUIDF_MMX<>0;
481
  UseMMX := CPUIDFeatures and CPUIDF_MMX<>0;
423
end;
482
end;
424
 
483
 
-
 
484
function dxrGetOption(Option: TDXR_Option): DWORD;
-
 
485
begin
-
 
486
  Result := 0;
-
 
487
  case Option of
-
 
488
    DXR_OPTION_VERSION:
-
 
489
        begin
-
 
490
          Result := 1*100 + 0;
-
 
491
        end;
-
 
492
    DXR_OPTION_MMXENABLE:
-
 
493
        begin
-
 
494
          Result := DWORD(LongBool(UseMMX));
-
 
495
        end;
-
 
496
    DXR_OPTION_RENDERPRIMITIVES:
-
 
497
        begin
-
 
498
          Result := RenderPrimitiveCount;
-
 
499
        end;
-
 
500
  end;
-
 
501
end;
-
 
502
 
-
 
503
procedure dxrSetOption(Option: TDXR_Option; Value: DWORD);
-
 
504
begin
-
 
505
  case Option of
-
 
506
    DXR_OPTION_MMXENABLE:
-
 
507
        begin
-
 
508
          UseMMX := LongBool(Value) and (CPUIDFeatures and CPUIDF_MMX<>0);
-
 
509
        end;
-
 
510
    DXR_OPTION_RENDERPRIMITIVES:
-
 
511
        begin
-
 
512
          RenderPrimitiveCount := Value;
-
 
513
        end;
-
 
514
  end;
-
 
515
end;
-
 
516
 
425
function GetBitCount(B: Integer): DWORD;
517
function GetBitCount(B: Integer): DWORD;
426
begin
518
begin
427
  Result := 31;
519
  Result := 31;
428
  while (Result>0) and (((1 shl Result) and B)=0) do Dec(Result);
520
  while (Result>0) and (((1 shl Result) and B)=0) do Dec(Result);
429
end;
521
end;
430
 
522
 
431
function GetFirstZeroBitCount(B: Integer): DWORD;
523
function GetFirstZeroBitCount(B: Integer): DWORD;
432
begin
524
begin
433
  Result := 0;
525
  Result := 0;
434
  while (Result<31) and (((1 shl Result) and B)=0) do Inc(Result);
526
  while (Result<31) and (((1 shl Result) and B)=0) do Inc(Result);
435
end;
527
end;
436
 
528
 
437
function GetOneBitCount(B: Integer): DWORD;
529
function GetOneBitCount(B: Integer): DWORD;
438
var
530
var
439
  i: Integer;
531
  i: Integer;
440
begin
532
begin
441
  Result := 0;
533
  Result := 0;
442
  for i:=0 to 31 do
534
  for i:=0 to 31 do
443
    Inc(Result, Ord(b and (1 shl i)<>0));
535
    Inc(Result, Ord(b and (1 shl i)<>0));
444
end;
536
end;
445
 
537
 
446
function dxrMakeColorChannel(Mask: DWORD; indexed: Boolean): TDXR_ColorChannel;
538
function dxrMakeColorChannel(Mask: DWORD; indexed: Boolean): TDXR_ColorChannel;
447
var
539
var
448
  i: Integer;
540
  i: Integer;
449
begin
541
begin
450
  Result.BitCount := GetOneBitCount(Mask shr (GetFirstZeroBitCount(Mask)));
542
  Result.BitCount := GetOneBitCount(Mask shr (GetFirstZeroBitCount(Mask)));
451
  Result.Mask := Mask;
543
  Result.Mask := Mask;
452
 
544
 
453
  if indexed then
545
  if indexed then
454
  begin
546
  begin
455
    Result.rshift := GetFirstZeroBitCount(Mask);
547
    Result.rshift := GetFirstZeroBitCount(Mask);
456
    Result.lshift := 0;
548
    Result.lshift := 0;
457
  end else
549
  end else
458
  begin
550
  begin
459
    i :=  GetFirstZeroBitCount(Mask)-(8-Result.BitCount);
551
    i :=  GetFirstZeroBitCount(Mask)-(8-Result.BitCount);
460
 
552
 
461
    if i<0 then
553
    if i<0 then
462
    begin
554
    begin
463
      Result.lshift := -i;
555
      Result.lshift := -i;
464
      Result.rshift := 0;
556
      Result.rshift := 0;
465
    end else
557
    end else
466
    begin
558
    begin
467
      Result.lshift := 0;
559
      Result.lshift := 0;
468
      Result.rshift := DWORD(i);
560
      Result.rshift := DWORD(i);
469
    end;
561
    end;
470
  end;
562
  end;
471
end;
563
end;
472
 
564
 
473
procedure dxrMakeIndexedSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
565
procedure dxrMakeIndexedSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
474
  Bits: Pointer; pitch: Integer; idx_index, idx_alpha: DWORD);
566
  Bits: Pointer; pitch: Integer; idx_index, idx_alpha: DWORD);
475
begin
567
begin
476
  FillChar(Surface, SizeOf(Surface), 0);
568
  FillChar(Surface, SizeOf(Surface), 0);
477
 
569
 
478
  Surface.ColorType := DXR_COLORTYPE_INDEXED;
570
  Surface.ColorType := DXR_COLORTYPE_INDEXED;
479
  Surface.Width := Width;
571
  Surface.Width := Width;
480
  Surface.Height := Height;
572
  Surface.Height := Height;
481
  Surface.WidthBit := GetBitCount(Width);
573
  Surface.WidthBit := GetBitCount(Width);
482
  Surface.HeightBit := GetBitCount(Height);
574
  Surface.HeightBit := GetBitCount(Height);
483
  Surface.Width2 := 1 shl Surface.WidthBit;
575
  Surface.Width2 := 1 shl Surface.WidthBit;
484
  Surface.Height2 := 1 shl Surface.HeightBit;
576
  Surface.Height2 := 1 shl Surface.HeightBit;
485
  Surface.WidthMask := Surface.Width-1;
577
  Surface.WidthMask := Surface.Width-1;
486
  Surface.HeightMask := Surface.Height2-1;
578
  Surface.HeightMask := Surface.Height2-1;
487
 
579
 
488
  Surface.BitCount := BitCount;
580
  Surface.BitCount := BitCount;
489
  Surface.Bits := Bits;
581
  Surface.Bits := Bits;
490
  Surface.Pitch := Pitch;
582
  Surface.Pitch := Pitch;
491
  Surface.PitchBit := GetBitCount(Abs(Pitch));
583
  Surface.PitchBit := GetBitCount(Abs(Pitch));
492
 
584
 
493
  Surface.idx_index := dxrMakeColorChannel(idx_index, True);
585
  Surface.idx_index := dxrMakeColorChannel(idx_index, True);
494
  Surface.idx_alpha := dxrMakeColorChannel(idx_alpha, False);
586
  Surface.idx_alpha := dxrMakeColorChannel(idx_alpha, False);
495
end;
587
end;
496
 
588
 
497
procedure dxrMakeRGBSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
589
procedure dxrMakeRGBSurface(var Surface: TDXR_Surface; Width, Height, BitCount: DWORD;
498
  Bits: Pointer; pitch: Integer; rgb_red, rgb_green, rgb_blue, rgb_alpha: DWORD);
590
  Bits: Pointer; pitch: Integer; rgb_red, rgb_green, rgb_blue, rgb_alpha: DWORD);
499
begin
591
begin
500
  FillChar(Surface, SizeOf(Surface), 0);
592
  FillChar(Surface, SizeOf(Surface), 0);
501
 
593
 
502
  Surface.ColorType := DXR_COLORTYPE_RGB;
594
  Surface.ColorType := DXR_COLORTYPE_RGB;
503
  Surface.Width := Width;
595
  Surface.Width := Width;
504
  Surface.Height := Height;
596
  Surface.Height := Height;
505
  Surface.WidthBit := GetBitCount(Width);
597
  Surface.WidthBit := GetBitCount(Width);
506
  Surface.HeightBit := GetBitCount(Height);
598
  Surface.HeightBit := GetBitCount(Height);
507
  Surface.Width2 := 1 shl Surface.WidthBit;
599
  Surface.Width2 := 1 shl Surface.WidthBit;
508
  Surface.Height2 := 1 shl Surface.HeightBit;
600
  Surface.Height2 := 1 shl Surface.HeightBit;
509
  Surface.WidthMask := Surface.Width-1;
601
  Surface.WidthMask := Surface.Width-1;
510
  Surface.HeightMask := Surface.Height2-1;
602
  Surface.HeightMask := Surface.Height2-1;
511
 
603
 
512
  Surface.BitCount := BitCount;
604
  Surface.BitCount := BitCount;
513
  Surface.Bits := Bits;
605
  Surface.Bits := Bits;
514
  Surface.Pitch := Pitch;
606
  Surface.Pitch := Pitch;
515
  Surface.PitchBit := GetBitCount(Abs(Pitch));
607
  Surface.PitchBit := GetBitCount(Abs(Pitch));
516
 
608
 
517
  Surface.rgb_red := dxrMakeColorChannel(rgb_red, False);
609
  Surface.rgb_red := dxrMakeColorChannel(rgb_red, False);
518
  Surface.rgb_green := dxrMakeColorChannel(rgb_green, False);
610
  Surface.rgb_green := dxrMakeColorChannel(rgb_green, False);
519
  Surface.rgb_blue := dxrMakeColorChannel(rgb_blue, False);
611
  Surface.rgb_blue := dxrMakeColorChannel(rgb_blue, False);
520
  Surface.rgb_alpha := dxrMakeColorChannel(rgb_alpha, False);
612
  Surface.rgb_alpha := dxrMakeColorChannel(rgb_alpha, False);
521
end;
613
end;
522
 
614
 
523
function dxrCompareSurface(const Surface1, Surface2: TDXR_Surface): Boolean;
615
function dxrCompareSurface(const Surface1, Surface2: TDXR_Surface): Boolean;
524
begin
616
begin
525
  if Surface1.ColorType=DXR_COLORTYPE_INDEXED then
617
  if Surface1.ColorType=DXR_COLORTYPE_INDEXED then
526
  begin
618
  begin
527
    Result := (Surface2.ColorType=DXR_COLORTYPE_INDEXED) and
619
    Result := (Surface2.ColorType=DXR_COLORTYPE_INDEXED) and
528
      (Surface1.idx_index.Mask=Surface2.idx_index.Mask) and
620
      (Surface1.idx_index.Mask=Surface2.idx_index.Mask) and
529
      (Surface1.idx_alpha.Mask=Surface2.idx_alpha.Mask);
621
      (Surface1.idx_alpha.Mask=Surface2.idx_alpha.Mask);
530
  end else if Surface1.ColorType=DXR_COLORTYPE_RGB then
622
  end else if Surface1.ColorType=DXR_COLORTYPE_RGB then
531
  begin
623
  begin
532
    Result := (Surface2.ColorType=DXR_COLORTYPE_RGB) and
624
    Result := (Surface2.ColorType=DXR_COLORTYPE_RGB) and
533
      (Surface1.rgb_red.Mask=Surface2.rgb_red.Mask) and
625
      (Surface1.rgb_red.Mask=Surface2.rgb_red.Mask) and
534
      (Surface1.rgb_green.Mask=Surface2.rgb_green.Mask) and
626
      (Surface1.rgb_green.Mask=Surface2.rgb_green.Mask) and
535
      (Surface1.rgb_blue.Mask=Surface2.rgb_blue.Mask) and
627
      (Surface1.rgb_blue.Mask=Surface2.rgb_blue.Mask) and
536
      (Surface1.rgb_alpha.Mask=Surface2.rgb_alpha.Mask);
628
      (Surface1.rgb_alpha.Mask=Surface2.rgb_alpha.Mask);
537
  end else
629
  end else
538
    Result := False;
630
    Result := False;
539
end;
631
end;
540
 
632
 
541
function dxrDDSurfaceLock(DDSurface: IDirectDrawSurface; var Surface: TDXR_Surface): Boolean;
633
function dxrDDSurfaceLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var Surface: TDXR_Surface): Boolean;
542
var
634
var
543
  ddsd: TDDSurfaceDesc;
635
  ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
544
begin
636
begin
545
  Result := dxrDDSurfaceLock2(DDSurface, ddsd, Surface);
637
  Result := dxrDDSurfaceLock2(DDSurface, ddsd, Surface);
546
end;
638
end;
547
 
639
                                                                                   
548
function dxrDDSurfaceLock2(DDSurface: IDirectDrawSurface; var ddsd: TDDSurfaceDesc;
640
function dxrDDSurfaceLock2(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; var ddsd: {$IFDEF D3D_deprecated}TDDSurfaceDesc{$ELSE}TDDSurfaceDesc2{$ENDIF};
549
  var Surface: TDXR_Surface): Boolean;
641
  var Surface: TDXR_Surface): Boolean;
550
const
642
const
551
  DDPF_PALETTEINDEXED = DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
643
  DDPF_PALETTEINDEXED = DDPF_PALETTEINDEXED1 or DDPF_PALETTEINDEXED2 or
552
    DDPF_PALETTEINDEXED4 or DDPF_PALETTEINDEXED8;
644
    DDPF_PALETTEINDEXED4 or DDPF_PALETTEINDEXED8;
553
begin
645
begin
554
  ddsd.dwSize := SizeOf(ddsd);
646
  ddsd.dwSize := SizeOf(ddsd);
555
  Result := DDSurface.Lock(nil, ddsd, DDLOCK_WAIT, 0)=DD_OK;
647
  Result := DDSurface.Lock(nil, ddsd, DDLOCK_WAIT, 0)=DD_OK;
556
  if Result then
648
  if Result then
557
  begin
649
  begin
558
    FillChar(Surface, SizeOf(Surface), 0);
650
    FillChar(Surface, SizeOf(Surface), 0);
559
    if ddsd.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED<>0 then
651
    if ddsd.ddpfPixelFormat.dwFlags and DDPF_PALETTEINDEXED<>0 then
560
    begin
652
    begin
561
      dxrMakeIndexedSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
653
      dxrMakeIndexedSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
562
        ddsd.lpSurface, ddsd.lPitch, (1 shl ddsd.ddpfPixelFormat.dwRGBBitCount)-1, 0);
654
        ddsd.lpSurface, ddsd.lPitch, (1 shl ddsd.ddpfPixelFormat.dwRGBBitCount)-1, 0);
563
    end else
655
    end else
564
    begin
656
    begin
565
      {if ddsd.ddpfPixelFormat.dwFlags and DDPF_ALPHAPIXELS<>0 then
657
      if ddsd.ddpfPixelFormat.dwFlags and DDPF_ALPHAPIXELS<>0 then
566
      begin
658
      begin
567
        dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
659
        dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
568
          ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
660
          ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
569
          ddsd.ddpfPixelFormat.dwBBitMask, ddsd.ddpfPixelFormat.dwRGBAlphaBitMask);
661
          ddsd.ddpfPixelFormat.dwBBitMask, ddsd.ddpfPixelFormat.dwRGBAlphaBitMask);
570
      end else}
662
      end else
571
      begin
663
      begin
572
        dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
664
        dxrMakeRGBSurface(Surface, ddsd.dwWidth, ddsd.dwHeight, ddsd.ddpfPixelFormat.dwRGBBitCount,
573
          ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
665
          ddsd.lpSurface, ddsd.lPitch, ddsd.ddpfPixelFormat.dwRBitMask, ddsd.ddpfPixelFormat.dwGBitMask,
574
          ddsd.ddpfPixelFormat.dwBBitMask, 0);
666
          ddsd.ddpfPixelFormat.dwBBitMask, 0);
575
      end;
667
      end;                          
576
    end;
668
    end;
577
  end;
669
  end;
578
end;
670
end;
579
 
671
 
580
procedure dxrDDSurfaceUnLock(DDSurface: IDirectDrawSurface; const Surface: TDXR_Surface);
672
procedure dxrDDSurfaceUnLock(DDSurface: {$IFDEF D3D_deprecated}IDirectDrawSurface{$ELSE}IDirectDrawSurface7{$ENDIF}; const Surface: TDXR_Surface);
581
begin
673
begin
582
  DDSurface.Unlock(Surface.Bits);
674
  DDSurface.Unlock(Surface.Bits);
583
end;
675
end;
584
 
676
 
585
function dxrScanLine(const Surface: TDXR_Surface; y: DWORD): Pointer;
677
function dxrScanLine(const Surface: TDXR_Surface; y: DWORD): Pointer;
586
begin
678
begin
587
  Result := Pointer(Integer(Surface.Bits)+Surface.Pitch*Integer(y));
679
  Result := Pointer(Integer(Surface.Bits)+Surface.Pitch*Integer(y));
588
end;
680
end;
589
 
681
 
-
 
682
procedure dxrZBufferClear(const Surface: TDXR_Surface);
-
 
683
var
-
 
684
  i: Integer;
-
 
685
begin
-
 
686
  for i:=0 to Surface.Height-1 do
-
 
687
    FillChar(dxrScanLine(Surface, i)^, Abs(Surface.Pitch), $FF);
-
 
688
end;
-
 
689
 
590
{  TDXRMachine  }
690
{  TDXRMachine  }
591
 
691
 
592
constructor TDXRMachine.Create;
692
constructor TDXRMachine.Create;
593
begin
693
begin
594
  inherited Create;
694
  inherited Create;
595
  FBuf := VirtualAlloc(nil, 2048, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
695
  FBuf := VirtualAlloc(nil, 2048, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
596
end;
696
end;
597
 
697
 
598
destructor TDXRMachine.Destroy;
698
destructor TDXRMachine.Destroy;
599
begin
699
begin
600
  VirtualFree(FBuf, 0, MEM_RELEASE);
700
  VirtualFree(FBuf, 0, MEM_RELEASE);
601
  inherited Destroy;
701
  inherited Destroy;
602
end;
702
end;
603
 
703
 
604
procedure TDXRMachine.Initialize;
704
procedure TDXRMachine.Initialize;
605
begin
705
begin
606
  FCall := nil;
706
  FCall := nil;
607
  ColorIndexCount := 0;
707
  ColorIndexCount := 0;
608
  TextureIndexCount := 0;
708
  TextureIndexCount := 0;
609
 
709
 
610
  FTreeCount := 0;
710
  FTreeCount := 0;
611
 
711
 
612
  Dest := nil;
712
  Dest := nil;
613
  FCompiled := False;
713
  FCompiled := False;
614
  FMMXUsed := False;
714
  FMMXUsed := False;
615
 
715
 
616
  FillChar(ColorList, SizeOf(ColorList), 0);
716
  FillChar(ColorList, SizeOf(ColorList), 0);
617
  FillChar(TextureList, SizeOf(TextureList), 0);
717
  FillChar(TextureList, SizeOf(TextureList), 0);
618
  FillChar(Dither, SizeOf(Dither), 0);
718
  FillChar(Dither, SizeOf(Dither), 0);
-
 
719
  FillChar(ZBuffer, SizeOf(ZBuffer), 0);
619
  FillChar(Axis, SizeOf(Axis), 0);
720
  FillChar(Axis, SizeOf(Axis), 0);
-
 
721
  FillChar(RHW, SizeOf(RHW), 0);
620
end;
722
end;
621
 
723
 
622
function TDXRMachine.CreateTree: PDXRMachine_Tree;
724
function TDXRMachine.CreateTree: PDXRMachine_Tree;
623
begin
725
begin
624
  Result := @FTreeList[FTreeCount];
726
  Result := @FTreeList[FTreeCount];
625
  FillChar(Result^, SizeOf(Result^), 0);
727
  FillChar(Result^, SizeOf(Result^), 0);
626
  Inc(FTreeCount);
728
  Inc(FTreeCount);
627
end;
729
end;
628
 
730
 
629
function TDXRMachine.CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree;
731
function TDXRMachine.CreateTree2(Typ: TDXRMachine_TreeType): PDXRMachine_Tree;
630
begin
732
begin
631
  Result := CreateTree;
733
  Result := CreateTree;
632
  Result.Typ := Typ;
734
  Result.Typ := Typ;
633
end;
735
end;
634
 
736
 
635
function TDXRMachine.CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree;
737
function TDXRMachine.CreateTree_LoadColor(Color: DWORD): PDXRMachine_Tree;
636
begin
738
begin
637
  Result := CreateTree;
739
  Result := CreateTree;
638
  Result.Typ := DXR_TREETYPE_LOADCOLOR;
740
  Result.Typ := DXR_TREETYPE_LOADCOLOR;
639
  Result.Color := Color;
741
  Result.Color := Color;
640
end;
742
end;
641
 
743
 
642
function TDXRMachine.CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree;
744
function TDXRMachine.CreateTree_LoadConstColor(R, G, B, A: Byte): PDXRMachine_Tree;
643
begin
745
begin
644
  Result := CreateTree;
746
  Result := CreateTree;
645
  Result.Typ := DXR_TREETYPE_LOADCONSTCOLOR;
747
  Result.Typ := DXR_TREETYPE_LOADCONSTCOLOR;
646
  Result.ConstColor.R := R shl 8;
748
  Result.ConstColor.R := R shl 8;
647
  Result.ConstColor.G := G shl 8;
749
  Result.ConstColor.G := G shl 8;
648
  Result.ConstColor.B := B shl 8;
750
  Result.ConstColor.B := B shl 8;
649
  Result.ConstColor.A := A shl 8;
751
  Result.ConstColor.A := A shl 8;
650
end;
752
end;
651
 
753
 
652
function TDXRMachine.CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree;
754
function TDXRMachine.CreateTree_LoadTexture(Texture: DWORD): PDXRMachine_Tree;
653
begin
755
begin
654
  Result := CreateTree;
756
  Result := CreateTree;
655
  Result.Typ := DXR_TREETYPE_LOADTEXTURE;
757
  Result.Typ := DXR_TREETYPE_LOADTEXTURE;
656
  Result.Texture := Texture;
758
  Result.Texture := Texture;
657
end;
759
end;
658
 
760
 
-
 
761
function TDXRMachine.CreateTree_LoadBumpTexture(Texture, BumpTexture: DWORD): PDXRMachine_Tree;
-
 
762
begin
-
 
763
  Result := CreateTree;
-
 
764
  Result.Typ := DXR_TREETYPE_LOADBUMPTEXTURE;
-
 
765
  Result.Texture := Texture;
-
 
766
  Result.BumpTexture := BumpTexture;
-
 
767
end;
-
 
768
 
659
function TDXRMachine.CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree;
769
function TDXRMachine.CreateTree_Blend(Blend: TDXR_Blend; BlendTree1, BlendTree2: PDXRMachine_Tree): PDXRMachine_Tree;
660
begin
770
begin
661
  Result := CreateTree;
771
  Result := CreateTree;
662
  Result.Typ := DXR_TREETYPE_BLEND;
772
  Result.Typ := DXR_TREETYPE_BLEND;
663
  Result.Blend := Blend;
773
  Result.Blend := Blend;
664
  Result.BlendTree1 := BlendTree1;
774
  Result.BlendTree1 := BlendTree1;
665
  Result.BlendTree2 := BlendTree2;
775
  Result.BlendTree2 := BlendTree2;
666
end;
776
end;
667
 
777
 
668
procedure TDXRMachine.Compile;
778
procedure TDXRMachine.Compile;
669
 
779
 
670
  function GetSurfaceChannels(const Surface: TDXR_Surface): TDXRColorChannels;
780
  function GetSurfaceChannels(const Surface: TDXR_Surface): TDXRColorChannels;
671
  begin
781
  begin
672
    Result := [];
782
    Result := [];
673
 
783
 
674
    if Surface.ColorType=DXR_COLORTYPE_INDEXED then
784
    if Surface.ColorType=DXR_COLORTYPE_INDEXED then
675
    begin
785
    begin
676
      if Surface.idx_index.Mask<>0 then Result := Result + [chRed, chGreen, chBlue];
786
      if Surface.idx_index.Mask<>0 then Result := Result + [chRed, chGreen, chBlue];
677
      if Surface.idx_alpha.Mask<>0 then Result := Result + [chAlpha];
787
      if Surface.idx_alpha.Mask<>0 then Result := Result + [chAlpha];
678
    end else
788
    end else
679
    begin
789
    begin
680
      if Surface.rgb_red.Mask<>0 then Result := Result + [chRed];
790
      if Surface.rgb_red.Mask<>0 then Result := Result + [chRed];
681
      if Surface.rgb_green.Mask<>0 then Result := Result + [chGreen];
791
      if Surface.rgb_green.Mask<>0 then Result := Result + [chGreen];
682
      if Surface.rgb_blue.Mask<>0 then Result := Result + [chBlue];
792
      if Surface.rgb_blue.Mask<>0 then Result := Result + [chBlue];
683
      if Surface.rgb_alpha.Mask<>0 then Result := Result + [chAlpha];
793
      if Surface.rgb_alpha.Mask<>0 then Result := Result + [chAlpha];
684
    end;
794
    end;
685
  end;
795
  end;
686
 
796
 
687
  procedure OptimizeTree(var Tree: PDXRMachine_Tree);
797
  procedure OptimizeTree(var Tree: PDXRMachine_Tree);
688
 
798
 
689
    procedure GetBlendChannels(Blend: TDXR_Blend; var Col1_1, Col1_2, Col2_1, Col2_2: TDXRColorChannels);
799
    procedure GetBlendChannels(Blend: TDXR_Blend; var Col1_1, Col1_2, Col2_1, Col2_2: TDXRColorChannels);
690
    begin
800
    begin
691
      case Blend of
801
      case Blend of
692
        DXR_BLEND_ZERO:
802
        DXR_BLEND_ZERO:
693
          begin
803
          begin
694
            Col1_1 := [];
804
            Col1_1 := [];
695
            Col1_2 := [];
805
            Col1_2 := [];
696
            Col2_1 := [];
806
            Col2_1 := [];
697
            Col2_2 := [];
807
            Col2_2 := [];
698
          end;
808
          end;
699
        DXR_BLEND_ONE1:
809
        DXR_BLEND_ONE1:
700
          begin
810
          begin
701
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
811
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
702
            Col1_2 := [];
812
            Col1_2 := [];
703
            Col2_1 := [];
813
            Col2_1 := [];
704
            Col2_2 := [];
814
            Col2_2 := [];
705
          end;
815
          end;
706
        DXR_BLEND_ONE2:
816
        DXR_BLEND_ONE2:
707
          begin
817
          begin
708
            Col1_1 := [];
818
            Col1_1 := [];
709
            Col1_2 := [];
819
            Col1_2 := [];
710
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
820
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
711
            Col2_2 := [];
821
            Col2_2 := [];
712
          end;
822
          end;
713
        DXR_BLEND_ONE1_ADD_ONE2,
823
        DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2:
-
 
824
          begin
-
 
825
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
714
        DXR_BLEND_ONE1_SUB_ONE2,
826
            Col1_2 := [];
-
 
827
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
715
        DXR_BLEND_ONE2_SUB_ONE1,
828
            Col2_2 := [];
-
 
829
          end;
716
        DXR_BLEND_ONE1_MUL_ONE2:
830
        DXR_BLEND_ONE2_SUB_ONE1, DXR_BLEND_ONE1_MUL_ONE2:
717
          begin
831
          begin
718
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
832
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
719
            Col1_2 := [];
833
            Col1_2 := [];
720
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
834
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
721
            Col2_2 := [];
835
            Col2_2 := [];
722
          end;
836
          end;
723
        DXR_BLEND_SRCALPHA1:
837
        DXR_BLEND_SRCALPHA1:
724
          begin
838
          begin
725
            Col1_1 := [chRed, chGreen, chBlue];
839
            Col1_1 := [chRed, chGreen, chBlue];
726
            Col1_2 := [chAlpha];
840
            Col1_2 := [chAlpha];
727
            Col2_1 := [];
841
            Col2_1 := [];
728
            Col2_2 := [];
842
            Col2_2 := [];
729
          end;
843
          end;
730
        DXR_BLEND_SRCALPHA1_ADD_ONE2:
844
        DXR_BLEND_SRCALPHA1_ADD_ONE2:
731
          begin
845
          begin
732
            Col1_1 := [chRed, chGreen, chBlue];
846
            Col1_1 := [chRed, chGreen, chBlue];
733
            Col1_2 := [chAlpha];
847
            Col1_2 := [chAlpha];
734
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
848
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
735
            Col2_2 := [];
849
            Col2_2 := [];
736
          end;
850
          end;
737
        DXR_BLEND_ONE2_SUB_SRCALPHA1:
851
        DXR_BLEND_ONE2_SUB_SRCALPHA1:
738
          begin
852
          begin
739
            Col1_1 := [chRed, chGreen, chBlue];
853
            Col1_1 := [chRed, chGreen, chBlue];
740
            Col1_2 := [chAlpha];
854
            Col1_2 := [chAlpha];
741
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
855
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
742
            Col2_2 := [];
856
            Col2_2 := [];
743
          end;
857
          end;
744
        DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2:
858
        DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2:
745
          begin
859
          begin
746
            Col1_1 := [chRed, chGreen, chBlue];
860
            Col1_1 := [chRed, chGreen, chBlue];
747
            Col1_2 := [chAlpha];
861
            Col1_2 := [chAlpha];
748
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
862
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
749
            Col2_2 := [];
863
            Col2_2 := [];
750
          end;
864
          end;
751
        DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2:
865
        DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2:
752
          begin
866
          begin
753
            Col1_1 := [chRed, chGreen, chBlue];
867
            Col1_1 := [chRed, chGreen, chBlue];
754
            Col1_2 := [chAlpha];
868
            Col1_2 := [chAlpha];
755
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
869
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
756
            Col2_2 := [];
870
            Col2_2 := [];
757
          end;
871
          end;
758
 
872
 
-
 
873
        DXR_BLEND_DECAL:
-
 
874
          begin
-
 
875
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
-
 
876
            Col1_2 := [];
-
 
877
            Col2_1 := [];
-
 
878
            Col2_2 := [];
-
 
879
          end;
759
        DXR_BLEND_DECALALPHA:
880
        DXR_BLEND_DECALALPHA:
760
          begin
881
          begin
761
            Col1_1 := [chRed, chGreen, chBlue];
882
            Col1_1 := [chRed, chGreen, chBlue];
762
            Col1_2 := [];
883
            Col1_2 := [];
763
            Col2_1 := [];
884
            Col2_1 := [];
764
            Col2_2 := [chAlpha];
885
            Col2_2 := [chAlpha];
765
          end;
886
          end;
766
        DXR_BLEND_MODULATE:
887
        DXR_BLEND_MODULATE:
767
          begin
888
          begin
-
 
889
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
-
 
890
            Col1_2 := [];
-
 
891
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
-
 
892
            Col2_2 := [];
-
 
893
          end;
-
 
894
        DXR_BLEND_MODULATEALPHA:
-
 
895
          begin
768
            Col1_1 := [chRed, chGreen, chBlue];
896
            Col1_1 := [chRed, chGreen, chBlue];
769
            Col1_2 := [chAlpha];
897
            Col1_2 := [chAlpha];
770
            Col2_1 := [chRed, chGreen, chBlue];
898
            Col2_1 := [chRed, chGreen, chBlue];
771
            Col2_2 := [chAlpha];
899
            Col2_2 := [chAlpha];
772
          end;
900
          end;
773
        DXR_BLEND_ADD:
901
        DXR_BLEND_ADD:
774
          begin
902
          begin
775
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
903
            Col1_1 := [chRed, chGreen, chBlue, chAlpha];
776
            Col1_2 := [];
904
            Col1_2 := [];
777
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
905
            Col2_1 := [chRed, chGreen, chBlue, chAlpha];
778
            Col2_2 := [];
906
            Col2_2 := [];
779
          end;
907
          end;
780
      end;
908
      end;
781
    end;
909
    end;
782
 
910
 
783
  var
911
  var
784
    c: TDXRColorChannels;
912
    c: TDXRColorChannels;
785
    Col1_1, Col1_2, Col2_1, Col2_2: TDXRColorChannels;
913
    Col1_1, Col1_2, Col2_1, Col2_2: TDXRColorChannels;
786
  begin
914
  begin
787
    case Tree.Typ of
915
    case Tree.Typ of
788
      DXR_TREETYPE_LOADBLACK:
916
      DXR_TREETYPE_LOADBLACK:
789
          begin
917
          begin
790
            // Load black color
918
            // Load black color
791
          end;
919
          end;
792
      DXR_TREETYPE_LOADCOLOR:
920
      DXR_TREETYPE_LOADCOLOR:
793
          begin
921
          begin
794
            // Load color
922
            // Load color
795
          end;
923
          end;
796
      DXR_TREETYPE_LOADTEXTURE:
924
      DXR_TREETYPE_LOADTEXTURE:
797
          begin
925
          begin
798
            // Load texel
926
            // Load texel
799
          end;
927
          end;
-
 
928
      DXR_TREETYPE_LOADBUMPTEXTURE:
-
 
929
          begin
-
 
930
            // Load texel with Bump mapping
-
 
931
          end;
800
      DXR_TREETYPE_LOADDESTPIXEL:
932
      DXR_TREETYPE_LOADDESTPIXEL:
801
          begin
933
          begin
802
            // Load dest pixel
934
            // Load dest pixel
803
          end;
935
          end;
804
      DXR_TREETYPE_BLEND:
936
      DXR_TREETYPE_BLEND:
805
          begin
937
          begin
806
            // Blend color
938
            // Blend color
807
            GetBlendChannels(Tree.Blend, Col1_1, Col1_2, Col2_1, Col2_2);
939
            GetBlendChannels(Tree.Blend, Col1_1, Col1_2, Col2_1, Col2_2);
808
 
940
 
809
            Tree.BlendTree1.Channels := Tree.Channels*Col1_1+Col1_2;
941
            Tree.BlendTree1.Channels := Tree.Channels*Col1_1+Col1_2;
810
            Tree.BlendTree2.Channels := Tree.Channels*Col2_1+Col2_2;
942
            Tree.BlendTree2.Channels := Tree.Channels*Col2_1+Col2_2;
811
 
943
 
812
            OptimizeTree(Tree.BlendTree1);
944
            OptimizeTree(Tree.BlendTree1);
813
            OptimizeTree(Tree.BlendTree2);
945
            OptimizeTree(Tree.BlendTree2);
814
 
946
 
815
            if (Tree.Blend=DXR_BLEND_ZERO) then
947
            if (Tree.Blend=DXR_BLEND_ZERO) then
816
            begin
948
            begin
817
              c := Tree.Channels; Tree^.Typ := DXR_TREETYPE_LOADBLACK; Tree.Channels := c;
949
              c := Tree.Channels; Tree^.Typ := DXR_TREETYPE_LOADBLACK; Tree.Channels := c;
818
            end else
950
            end else
819
            if (Tree.Blend in [DXR_BLEND_ONE1]) then
951
            if (Tree.Blend in [DXR_BLEND_ONE1, DXR_BLEND_DECAL]) then
820
            begin
952
            begin
821
              c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
953
              c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
822
            end else
954
            end else
823
            if (Tree.Blend=DXR_BLEND_ONE2) then
955
            if (Tree.Blend=DXR_BLEND_ONE2) then
824
            begin
956
            begin
825
              c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
957
              c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
826
            end else
958
            end else
827
            if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2]) and
959
            if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE2_SUB_ONE1]) and
828
              (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADBLACK) then
960
              (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADBLACK) then
829
            begin
961
            begin
830
              c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
962
              c := Tree.Channels; Tree := Tree.BlendTree1; Tree.Channels := c;
831
            end else
963
            end else
832
            if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE1_SUB_ONE2]) and
964
            if (Tree.Blend in [DXR_BLEND_ONE1_ADD_ONE2, DXR_BLEND_ONE2_SUB_ONE1]) and
833
              (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADBLACK) then
965
              (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADBLACK) then
834
            begin
966
            begin
835
              c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
967
              c := Tree.Channels; Tree := Tree.BlendTree2; Tree.Channels := c;
836
            end else
968
            end else
837
            begin
969
            begin
838
              if (Col1_1=[]) and (Col1_2=[]) then Tree.BlendTree1 := nil;
970
              if (Col1_1=[]) and (Col1_2=[]) then Tree.BlendTree1 := nil;
839
              if (Col2_1=[]) and (Col2_2=[]) then Tree.BlendTree2 := nil;
971
              if (Col2_1=[]) and (Col2_2=[]) then Tree.BlendTree2 := nil;
840
            end;
972
            end;
841
          end;
973
          end;
842
    end;
974
    end;
843
  end;
975
  end;
844
 
976
 
845
  procedure GetEnableChannels(Tree: PDXRMachine_Tree);
977
  procedure GetEnableChannels(Tree: PDXRMachine_Tree);
846
  begin
978
  begin
847
    case Tree.Typ of
979
    case Tree.Typ of
848
      DXR_TREETYPE_LOADBLACK:
980
      DXR_TREETYPE_LOADBLACK:
849
          begin
981
          begin
850
            // Load black color
982
            // Load black color
851
          end;
983
          end;
852
      DXR_TREETYPE_LOADCOLOR:
984
      DXR_TREETYPE_LOADCOLOR:
853
          begin
985
          begin
854
            // Load color
986
            // Load color
855
            ColorList[Tree.Color].Channels := ColorList[Tree.Color].Channels + Tree.Channels;
987
            ColorList[Tree.Color].Channels := ColorList[Tree.Color].Channels + Tree.Channels;
856
            ColorList[Tree.Color].Enable := ColorList[Tree.Color].Channels<>[];
988
            ColorList[Tree.Color].Enable := ColorList[Tree.Color].Channels<>[];
857
          end;
989
          end;
858
      DXR_TREETYPE_LOADTEXTURE:
990
      DXR_TREETYPE_LOADTEXTURE:
859
          begin
991
          begin
860
            // Load texel
992
            // Load texel
861
            TextureList[Tree.Texture].EnableChannels := TextureList[Tree.Texture].EnableChannels +
993
            TextureList[Tree.Texture].EnableChannels := TextureList[Tree.Texture].EnableChannels +
862
              Tree.Channels*GetSurfaceChannels(TextureList[Tree.Texture].Surface^);
994
              Tree.Channels*GetSurfaceChannels(TextureList[Tree.Texture].Surface^);
863
            TextureList[Tree.Texture].Enable := TextureList[Tree.Texture].EnableChannels<>[];
995
            TextureList[Tree.Texture].Enable := TextureList[Tree.Texture].EnableChannels<>[];
864
          end;
996
          end;
-
 
997
      DXR_TREETYPE_LOADBUMPTEXTURE:
-
 
998
          begin
-
 
999
            // Load texel with Bump mapping
-
 
1000
            TextureList[Tree.Texture].EnableChannels := TextureList[Tree.Texture].EnableChannels +
-
 
1001
              Tree.Channels*GetSurfaceChannels(TextureList[Tree.Texture].Surface^);
-
 
1002
            TextureList[Tree.Texture].Enable := TextureList[Tree.Texture].EnableChannels<>[];
-
 
1003
            TextureList[Tree.BumpTexture].Enable := True;
-
 
1004
          end;
865
      DXR_TREETYPE_LOADDESTPIXEL:
1005
      DXR_TREETYPE_LOADDESTPIXEL:
866
          begin
1006
          begin
867
            // Load dest pixel
1007
            // Load dest pixel
868
          end;
1008
          end;
869
      DXR_TREETYPE_BLEND:
1009
      DXR_TREETYPE_BLEND:
870
          begin
1010
          begin
871
            // Blend color
1011
            // Blend color
872
            if Tree.BlendTree1<>nil then GetEnableChannels(Tree.BlendTree1);
1012
            if Tree.BlendTree1<>nil then GetEnableChannels(Tree.BlendTree1);
873
            if Tree.BlendTree2<>nil then GetEnableChannels(Tree.BlendTree2);
1013
            if Tree.BlendTree2<>nil then GetEnableChannels(Tree.BlendTree2);
874
          end;
1014
          end;
875
    end;
1015
    end;
876
  end;
1016
  end;
877
 
1017
 
878
var
1018
var
879
  Code: Pointer;
1019
  Code: Pointer;
880
  i: Integer;
1020
  i: Integer;
881
begin
1021
begin
882
  {  Optimize tree  }
1022
  {  Optimize tree  }
883
  Tree.Channels := GetSurfaceChannels(Dest^);
1023
  Tree.Channels := GetSurfaceChannels(Dest^);
884
  OptimizeTree(Tree);
1024
  OptimizeTree(Tree);
885
 
1025
 
886
  {  Get enable channels  }
1026
  {  Get enable channels  }
887
  GetEnableChannels(Tree);
1027
  GetEnableChannels(Tree);
888
 
1028
 
889
  for i:=Low(ColorList) to High(ColorList) do
1029
  for i:=Low(ColorList) to High(ColorList) do
890
    if ColorList[i].Enable then
1030
    if ColorList[i].Enable then
891
    begin
1031
    begin
892
      ColorIndex[ColorIndexCount] := i;
1032
      ColorIndex[ColorIndexCount] := i;
893
      Inc(ColorIndexCount);
1033
      Inc(ColorIndexCount);
894
    end;
1034
    end;
895
 
1035
 
896
  for i:=Low(TextureList) to High(TextureList) do
1036
  for i:=Low(TextureList) to High(TextureList) do
897
    if TextureList[i].Enable then
1037
    if TextureList[i].Enable then
898
    begin
1038
    begin
899
      TextureIndex[TextureIndexCount] := i;
1039
      TextureIndex[TextureIndexCount] := i;
900
      Inc(TextureIndexCount);
1040
      Inc(TextureIndexCount);
901
    end;
1041
    end;
902
 
1042
 
-
 
1043
  ZBuffer.Enable := ZBuffer.Surface<>nil;
-
 
1044
 
-
 
1045
  RHW.Enable := ZBuffer.Enable;
903
  Axis.IncEnable := Dither.Enable;
1046
  Axis.IncEnable := Dither.Enable;
904
 
1047
 
905
  {  Generate X86 code  }
1048
  {  Generate X86 code  }
906
  Code := FBuf; GenerateCode(Code, Tree);
1049
  Code := FBuf; GenerateCode(Code, Tree);
907
 
1050
 
908
  FCompiled := True;
1051
  FCompiled := True;
909
end;
1052
end;
910
 
1053
 
911
const
1054
const
912
  Mask1: array[0..7] of DWORD= ($80, $40, $20, $10, $08, $04, $02, $01);
1055
  Mask1: array[0..7] of DWORD= ($80, $40, $20, $10, $08, $04, $02, $01);
913
  Mask2: array[0..3] of DWORD= ($C0, $30, $0C, $03);
1056
  Mask2: array[0..3] of DWORD= ($C0, $30, $0C, $03);
914
  Mask4: array[0..1] of DWORD= ($F0, $0F);
1057
  Mask4: array[0..1] of DWORD= ($F0, $0F);
915
 
1058
 
916
  Shift1: array[0..7] of DWORD= (7, 6, 5, 4, 3, 2, 1, 0);
1059
  Shift1: array[0..7] of DWORD= (7, 6, 5, 4, 3, 2, 1, 0);
917
  Shift2: array[0..3] of DWORD= (6, 4, 2, 0);
1060
  Shift2: array[0..3] of DWORD= (6, 4, 2, 0);
918
  Shift4: array[0..1] of DWORD= (4, 0);
1061
  Shift4: array[0..1] of DWORD= (4, 0);
919
 
1062
 
920
var
1063
var
921
  _null: Byte;
1064
  _null: Byte;
922
 
1065
 
923
  // Saturation addition table
1066
  // Saturation addition table
924
  //   Result := Min(n+j, 255)
1067
  //   Result := Min(n+j, 255)
925
  _AddTable: array[0..256*2-1] of Byte;
1068
  _AddTable: array[0..256*2-1] of Byte;
926
  _SubTable: array[-255..255] of Byte;
1069
  _SubTable: array[-255..255] of Byte;
927
 
1070
 
928
  // Byte to QWORD convert table
1071
  // Byte to QWORD convert table
929
  //   Result := (n shl 56)+(n shl 48)+(n shl 32)+(n shl 24)+(n shl 16)+(n shl 8)+n
1072
  //   Result := (n shl 56)+(n shl 48)+(n shl 32)+(n shl 24)+(n shl 16)+(n shl 8)+n
930
  _ByteToQWORDTable: array[0..255, 0..3] of WORD;
1073
  _ByteToQWORDTable: array[0..255, 0..3] of WORD;
931
 
1074
 
932
  _BlackColor: TDXRMachine_Color = (R: 0; G: 0; B: 0; A: 0);
1075
  _BlackColor: TDXRMachine_Color = (R: 0; G: 0; B: 0; A: 0);
933
 
1076
 
934
procedure Init;
1077
procedure Init;
935
var
1078
var
936
  i: Integer;
1079
  i: Integer;
937
begin
1080
begin
938
  for i:=Low(_AddTable) to High(_AddTable) do
1081
  for i:=Low(_AddTable) to High(_AddTable) do
939
  begin
1082
  begin
940
    if i>255 then
1083
    if i>255 then
941
      _AddTable[i] := 255
1084
      _AddTable[i] := 255
942
    else
1085
    else
943
      _AddTable[i] := i;
1086
      _AddTable[i] := i;
944
  end;
1087
  end;
945
 
1088
 
946
  for i:=Low(_SubTable) to High(_SubTable) do
1089
  for i:=Low(_SubTable) to High(_SubTable) do
947
  begin
1090
  begin
948
    if i<0 then
1091
    if i<0 then
949
      _SubTable[i] := 0
1092
      _SubTable[i] := 0
950
    else
1093
    else
951
      _SubTable[i] := i;
1094
      _SubTable[i] := i;
952
  end;
1095
  end;
953
 
1096
 
954
  for i:=0 to 255 do
1097
  for i:=0 to 255 do
955
  begin
1098
  begin
956
    _ByteToQWORDTable[i, 0] := i;
1099
    _ByteToQWORDTable[i, 0] := i;
957
    _ByteToQWORDTable[i, 1] := i;
1100
    _ByteToQWORDTable[i, 1] := i;
958
    _ByteToQWORDTable[i, 2] := i;
1101
    _ByteToQWORDTable[i, 2] := i;
959
    _ByteToQWORDTable[i, 3] := i;
1102
    _ByteToQWORDTable[i, 3] := i;
960
  end;
1103
  end;
961
end;
1104
end;
962
 
1105
 
963
procedure TDXRMachine.GenerateCode(var Code: Pointer; Tree: PDXRMachine_Tree);
1106
procedure TDXRMachine.GenerateCode(var Code: Pointer; Tree: PDXRMachine_Tree);
964
var
1107
var
965
  SkipAddress: Pointer;
1108
  SkipAddress: Pointer;
966
 
1109
 
967
  procedure genCmpFunc(var Code: Pointer; Func: TDXR_CmpFunc; JmpAdress: Pointer);
1110
  procedure genCmpFunc(var Code: Pointer; Func: TDXR_CmpFunc; JmpAdress: Pointer);
968
 
1111
 
969
    procedure genShortJmp(var Code: Pointer; JmpCode: Pointer; sC: Byte);
1112
    procedure genShortJmp(var Code: Pointer; JmpCode: Pointer; sC: Byte);
970
    type
1113
    type
971
      PShortJmp = ^TShortJmp;
1114
      PShortJmp = ^TShortJmp;
972
      TShortJmp = packed record
1115
      TShortJmp = packed record
973
        c: Byte;
1116
        c: Byte;
974
        A: ShortInt;
1117
        A: ShortInt;
975
      end;
1118
      end;
976
    begin
1119
    begin
977
      with PShortJmp(Code)^ do
1120
      with PShortJmp(Code)^ do
978
      begin
1121
      begin
979
        c := sC;
1122
        c := sC;
980
        A := Integer(JmpCode)-(Integer(Code)+2);
1123
        A := Integer(JmpCode)-(Integer(Code)+2);
981
      end;
1124
      end;
982
      Inc(Integer(Code), 2);
1125
      Inc(Integer(Code), 2);
983
    end;
1126
    end;
984
 
1127
 
985
    procedure genNearJmp(var Code: Pointer; JmpCode: Pointer; nC: Byte);
1128
    procedure genNearJmp(var Code: Pointer; JmpCode: Pointer; nC: Byte);
986
    type
1129
    type
987
      PNearJmp = ^TNearJmp;
1130
      PNearJmp = ^TNearJmp;
988
      TNearJmp = packed record
1131
      TNearJmp = packed record
989
        c: Byte;
1132
        c: Byte;
990
        A: Integer;
1133
        A: Integer;
991
      end;
1134
      end;
992
    begin
1135
    begin
993
      with PNearJmp(Code)^ do
1136
      with PNearJmp(Code)^ do
994
      begin
1137
      begin
995
        c := nC;
1138
        c := nC;
996
        A := Integer(JmpCode)-(Integer(Code)+5);
1139
        A := Integer(JmpCode)-(Integer(Code)+5);
997
      end;
1140
      end;
998
      Inc(Integer(Code), 5);
1141
      Inc(Integer(Code), 5);
999
    end;
1142
    end;
1000
 
1143
 
1001
    procedure genNearJmp2(var Code: Pointer; JmpCode: Pointer; nC1, nC2: Byte);
1144
    procedure genNearJmp2(var Code: Pointer; JmpCode: Pointer; nC1, nC2: Byte);
1002
    type
1145
    type
1003
      PNearJmp2 = ^TNearJmp2;
1146
      PNearJmp2 = ^TNearJmp2;
1004
      TNearJmp2 = packed record
1147
      TNearJmp2 = packed record
1005
        c1, c2: Byte;
1148
        c1, c2: Byte;
1006
        A: Integer;
1149
        A: Integer;
1007
      end;
1150
      end;
1008
    begin
1151
    begin
1009
      with PNearJmp2(Code)^ do
1152
      with PNearJmp2(Code)^ do
1010
      begin
1153
      begin
1011
        c1 := nC1;
1154
        c1 := nC1;
1012
        c2 := nC2;
1155
        c2 := nC2;
1013
        A := Integer(JmpCode)-(Integer(Code)+6);
1156
        A := Integer(JmpCode)-(Integer(Code)+6);
1014
      end;
1157
      end;
1015
      Inc(Integer(Code), 6);
1158
      Inc(Integer(Code), 6);
1016
    end;
1159
    end;
1017
 
1160
 
1018
    procedure genFlagJmp(var Code: Pointer; JmpCode: Pointer; sC, nC1, nC2: Byte);
1161
    procedure genFlagJmp(var Code: Pointer; JmpCode: Pointer; sC, nC1, nC2: Byte);
1019
    var
1162
    var
1020
      i: Integer;
1163
      i: Integer;
1021
    begin
1164
    begin
1022
      i := Integer(JmpCode)-(Integer(Code)+2);
1165
      i := Integer(JmpCode)-(Integer(Code)+2);
1023
      if abs(i)<128 then
1166
      if abs(i)<128 then
1024
        genShortJmp(Code, JmpCode, sC)
1167
        genShortJmp(Code, JmpCode, sC)
1025
      else
1168
      else
1026
        genNearJmp2(Code, JmpCode, nC1, nC2);
1169
        genNearJmp2(Code, JmpCode, nC1, nC2);
1027
    end;
1170
    end;
1028
 
1171
 
1029
    procedure genJmp(var Code: Pointer; JmpCode: Pointer);
1172
    procedure genJmp(var Code: Pointer; JmpCode: Pointer);
1030
    var
1173
    var
1031
      i: Integer;
1174
      i: Integer;
1032
    begin
1175
    begin
1033
      i := Integer(JmpCode)-(Integer(Code)+2);
1176
      i := Integer(JmpCode)-(Integer(Code)+2);
1034
      if abs(i)<128 then
1177
      if abs(i)<128 then
1035
        genShortJmp(Code, JmpCode, $EB)
1178
        genShortJmp(Code, JmpCode, $EB)
1036
      else
1179
      else
1037
        genNearJmp(Code, JmpCode, $E9);
1180
        genNearJmp(Code, JmpCode, $E9);
1038
    end;
1181
    end;
1039
 
1182
 
1040
  begin
1183
  begin
1041
    case Func of
1184
    case Func of
1042
      DXR_CMPFUNC_NEVER:
1185
      DXR_CMPFUNC_NEVER:
1043
          begin
1186
          begin
1044
            {  if (False) then Jump }
1187
            {  if (False) then Jump }
1045
          end;
1188
          end;
1046
      DXR_CMPFUNC_LESS:
1189
      DXR_CMPFUNC_LESS:
1047
          begin
1190
          begin
1048
            {  if (New<Old) then Jump  }
1191
            {  if (New<Old) then Jump  }
1049
            genFlagJmp(Code, JmpAdress, $7C, $0F, $8C);
1192
            genFlagJmp(Code, JmpAdress, $7C, $0F, $8C);
1050
          end;
1193
          end;
1051
      DXR_CMPFUNC_EQUAL:
1194
      DXR_CMPFUNC_EQUAL:
1052
          begin
1195
          begin
1053
            {  if (New=Old) then Jump  }
1196
            {  if (New=Old) then Jump  }
1054
            genFlagJmp(Code, JmpAdress, $74, $0F, $84);
1197
            genFlagJmp(Code, JmpAdress, $74, $0F, $84);
1055
          end;
1198
          end;
1056
      DXR_CMPFUNC_LESSEQUAL:
1199
      DXR_CMPFUNC_LESSEQUAL:
1057
          begin
1200
          begin
1058
            {  if (New<=Old) then Jump  }
1201
            {  if (New<=Old) then Jump  }
1059
            genFlagJmp(Code, JmpAdress, $7E, $0F, $8E);
1202
            genFlagJmp(Code, JmpAdress, $7E, $0F, $8E);
1060
          end;
1203
          end;
1061
      DXR_CMPFUNC_GREATER:
1204
      DXR_CMPFUNC_GREATER:
1062
          begin
1205
          begin
1063
            {  if (New>Old) then Jump  }
1206
            {  if (New>Old) then Jump  }
1064
            genFlagJmp(Code, JmpAdress, $7F, $0F, $8F);
1207
            genFlagJmp(Code, JmpAdress, $7F, $0F, $8F);
1065
          end;
1208
          end;
1066
      DXR_CMPFUNC_NOTEQUAL:
1209
      DXR_CMPFUNC_NOTEQUAL:
1067
          begin
1210
          begin
1068
            {  if (New<>Old) then Jump  }
1211
            {  if (New<>Old) then Jump  }
1069
            genFlagJmp(Code, JmpAdress, $75, $0F, $85);
1212
            genFlagJmp(Code, JmpAdress, $75, $0F, $85);
1070
          end;
1213
          end;
1071
      DXR_CMPFUNC_GREATEREQUAL:
1214
      DXR_CMPFUNC_GREATEREQUAL:
1072
          begin
1215
          begin
1073
            {  if (New>=Old) then Jump  }
1216
            {  if (New>=Old) then Jump  }
1074
            genFlagJmp(Code, JmpAdress, $7D, $0F, $8D);
1217
            genFlagJmp(Code, JmpAdress, $7D, $0F, $8D);
1075
          end;
1218
          end;
1076
      DXR_CMPFUNC_ALWAYS:
1219
      DXR_CMPFUNC_ALWAYS:
1077
          begin
1220
          begin
1078
            {  if (True) then Break }
1221
            {  if (True) then Break }
1079
            genJmp(Code, JmpAdress);
1222
            genJmp(Code, JmpAdress);
1080
          end;
1223
          end;
1081
    end;
1224
    end;
1082
  end;
1225
  end;
1083
 
1226
 
1084
  procedure genInitDestAddress(var Code: Pointer);
1227
  procedure genInitDestAddress(var Code: Pointer);
1085
  var
1228
  var
1086
    _Axis: Pointer;
1229
    _Axis: Pointer;
1087
    ByteCount, Pitch: DWORD;
1230
    ByteCount, Pitch: DWORD;
1088
    Bits: Pointer;
1231
    Bits: Pointer;
1089
  begin
1232
  begin
1090
    _Axis := @Axis.Axis;
1233
    _Axis := @Axis.Axis;
1091
 
1234
 
1092
    ByteCount := Dest.BitCount shr 3;
1235
    ByteCount := Dest.BitCount shr 3;
1093
    Pitch := Dest.pitch;
1236
    Pitch := Dest.pitch;
1094
    Bits := Dest.Bits;
1237
    Bits := Dest.Bits;
1095
 
1238
 
1096
    asm
1239
    asm
1097
      jmp @@EndCode
1240
      jmp @@EndCode
1098
    @@StartCode:
1241
    @@StartCode:
1099
      mov eax,dword ptr [offset _null]{}@@AxisX:
1242
      mov eax,dword ptr [offset _null]{}@@AxisX:
1100
      imul eax,$11{}        @@ByteCount: // Dest.BitCount div 8
1243
      imul eax,$11{}        @@ByteCount: // Dest.BitCount div 8
1101
      mov edi,dword ptr [offset _null]{}@@AxisY:
1244
      mov edi,dword ptr [offset _null]{}@@AxisY:
1102
      imul edi,$11111111{}  @@Pitch: // Dest.pitch
1245
      imul edi,$11111111{}  @@Pitch: // Dest.pitch
1103
      add edi,$11111111{}   @@Bits:  // Dest.Bits
1246
      add edi,$11111111{}   @@Bits:  // Dest.Bits
1104
      add edi,eax
1247
      add edi,eax
1105
    @@EndCode:
1248
    @@EndCode:
1106
      {$I DXRender.inc}
1249
      {$I DXRender.inc}
1107
      {  @@AxisX  }
1250
      {  @@AxisX  }
1108
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
1251
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
1109
      mov edx,offset @@AxisX-4
1252
      mov edx,offset @@AxisX-4
1110
      sub edx,offset @@StartCode
1253
      sub edx,offset @@StartCode
1111
      mov dword ptr [ecx+edx],eax
1254
      mov dword ptr [ecx+edx],eax
1112
 
1255
 
1113
      {  @@AxisY  }
1256
      {  @@AxisY  }
1114
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
1257
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
1115
      mov edx,offset @@AxisY-4
1258
      mov edx,offset @@AxisY-4
1116
      sub edx,offset @@StartCode
1259
      sub edx,offset @@StartCode
1117
      mov dword ptr [ecx+edx],eax
1260
      mov dword ptr [ecx+edx],eax
1118
 
1261
 
1119
      {  @@ByteCount  }
1262
      {  @@ByteCount  }
1120
      mov eax,ByteCount
1263
      mov eax,ByteCount
1121
      mov edx,offset @@ByteCount-1
1264
      mov edx,offset @@ByteCount-1
1122
      sub edx,offset @@StartCode
1265
      sub edx,offset @@StartCode
1123
      mov byte ptr [ecx+edx],al
1266
      mov byte ptr [ecx+edx],al
1124
 
1267
 
1125
      {  @@Pitch  }
1268
      {  @@Pitch  }
1126
      mov eax,Pitch
1269
      mov eax,Pitch
1127
      mov edx,offset @@Pitch-4
1270
      mov edx,offset @@Pitch-4
1128
      sub edx,offset @@StartCode
1271
      sub edx,offset @@StartCode
1129
      mov dword ptr [ecx+edx],eax
1272
      mov dword ptr [ecx+edx],eax
1130
 
1273
 
1131
      {  @@Bits  }
1274
      {  @@Bits  }
1132
      mov eax,Bits
1275
      mov eax,Bits
1133
      mov edx,offset @@Bits-4
1276
      mov edx,offset @@Bits-4
1134
      sub edx,offset @@StartCode
1277
      sub edx,offset @@StartCode
1135
      mov dword ptr [ecx+edx],eax
1278
      mov dword ptr [ecx+edx],eax
1136
    end;
1279
    end;
1137
  end;
1280
  end;
1138
 
1281
 
-
 
1282
  procedure genInitZBuffer(var Code: Pointer);
-
 
1283
  var
-
 
1284
    _Axis: Pointer;
-
 
1285
    ByteCount, Pitch: DWORD;
-
 
1286
    Bits, _ZBuf: Pointer;
-
 
1287
  begin
-
 
1288
    if not ZBuffer.Enable then Exit;
-
 
1289
 
-
 
1290
    _Axis := @Axis.Axis;
-
 
1291
 
-
 
1292
    ByteCount := ZBuffer.Surface.BitCount div 8;
-
 
1293
    Pitch := ZBuffer.Surface.Pitch;
-
 
1294
    Bits := ZBuffer.Surface.Bits;
-
 
1295
 
-
 
1296
    _ZBuf := @F_ZBuf;
-
 
1297
 
-
 
1298
    asm
-
 
1299
      jmp @@EndCode
-
 
1300
    @@StartCode:
-
 
1301
      mov edx,dword ptr [offset _null]{}@@AxisX:
-
 
1302
      imul edx,$11{}        @@ByteCount: // States.ZBuffer.BitCount div 8
-
 
1303
      mov eax,dword ptr [offset _null]{}@@AxisY:
-
 
1304
      imul eax,$11111111{}  @@Pitch: // States.ZBuffer.pitch
-
 
1305
      add eax,$11111111{}   @@Bits:  // States.ZBuffer.Bits
-
 
1306
      add eax,edx
-
 
1307
      mov dword ptr [offset _null],eax{}@@_ZBuf:
-
 
1308
    @@EndCode:
-
 
1309
      {$I DXRender.inc}
-
 
1310
      {  @@AxisX  }
-
 
1311
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
-
 
1312
      mov edx,offset @@AxisX-4
-
 
1313
      sub edx,offset @@StartCode
-
 
1314
      mov dword ptr [ecx+edx],eax
-
 
1315
 
-
 
1316
      {  @@AxisY  }
-
 
1317
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
-
 
1318
      mov edx,offset @@AxisY-4
-
 
1319
      sub edx,offset @@StartCode
-
 
1320
      mov dword ptr [ecx+edx],eax
-
 
1321
 
-
 
1322
      {  @@ByteCount  }
-
 
1323
      mov eax,ByteCount
-
 
1324
      mov edx,offset @@ByteCount-1
-
 
1325
      sub edx,offset @@StartCode
-
 
1326
      mov byte ptr [ecx+edx],al
-
 
1327
 
-
 
1328
      {  @@Pitch  }
-
 
1329
      mov eax,Pitch
-
 
1330
      mov edx,offset @@Pitch-4
-
 
1331
      sub edx,offset @@StartCode
-
 
1332
      mov dword ptr [ecx+edx],eax
-
 
1333
 
-
 
1334
      {  @@Bits  }
-
 
1335
      mov eax,Bits
-
 
1336
      mov edx,offset @@Bits-4
-
 
1337
      sub edx,offset @@StartCode
-
 
1338
      mov dword ptr [ecx+edx],eax
-
 
1339
 
-
 
1340
      {  @@_ZBuf  }
-
 
1341
      mov eax,_ZBuf
-
 
1342
      mov edx,offset @@_ZBuf-4
-
 
1343
      sub edx,offset @@StartCode
-
 
1344
      mov dword ptr [ecx+edx],eax
-
 
1345
    end;
-
 
1346
  end;
-
 
1347
 
-
 
1348
  procedure genZBufferTest(var Code: Pointer);
-
 
1349
  var
-
 
1350
    _ZBuf, _RHW: Pointer;
-
 
1351
  begin
-
 
1352
    if not ZBuffer.Enable then Exit;
-
 
1353
 
-
 
1354
    _ZBuf := @F_ZBuf;
-
 
1355
    _RHW := @RHW.nRHW;
-
 
1356
 
-
 
1357
    asm
-
 
1358
      jmp @@EndCode
-
 
1359
    @@StartCode:
-
 
1360
      mov edx,dword ptr [offset _null]{}@@_ZBuf:
-
 
1361
      mov ebx,dword ptr [offset _null]{}@@_RHW:
-
 
1362
    @@EndCode:
-
 
1363
      {$I DXRender.inc}
-
 
1364
      {  @@_ZBuf  }
-
 
1365
      mov eax,_ZBuf
-
 
1366
      mov edx,offset @@_ZBuf-4
-
 
1367
      sub edx,offset @@StartCode
-
 
1368
      mov dword ptr [ecx+edx],eax
-
 
1369
 
-
 
1370
      {  @@_RHW  }
-
 
1371
      mov eax,_RHW; add eax,4
-
 
1372
      mov edx,offset @@_RHW-4
-
 
1373
      sub edx,offset @@StartCode
-
 
1374
      mov dword ptr [ecx+edx],eax
-
 
1375
    end;
-
 
1376
 
-
 
1377
    if ZBuffer.CmpFunc<>DXR_CMPFUNC_ALWAYS then
-
 
1378
    begin
-
 
1379
      case ZBuffer.Surface.BitCount of
-
 
1380
        8: begin
-
 
1381
             asm
-
 
1382
               jmp @@EndCode
-
 
1383
             @@StartCode:
-
 
1384
               movzx eax,byte ptr [edx]
-
 
1385
             @@EndCode:
-
 
1386
               {$I DXRender.inc}
-
 
1387
             end;
-
 
1388
           end;
-
 
1389
       16: begin
-
 
1390
             asm
-
 
1391
               jmp @@EndCode
-
 
1392
             @@StartCode:
-
 
1393
               movzx eax,word ptr [edx]
-
 
1394
             @@EndCode:
-
 
1395
               {$I DXRender.inc}
-
 
1396
             end;
-
 
1397
           end;
-
 
1398
       24: begin
-
 
1399
             asm
-
 
1400
               jmp @@EndCode
-
 
1401
             @@StartCode:
-
 
1402
               movzx ax,byte ptr [edx+2]
-
 
1403
               shl eax,16
-
 
1404
               mov ax,word ptr [edx]
-
 
1405
             @@EndCode:
-
 
1406
               {$I DXRender.inc}
-
 
1407
             end;
-
 
1408
           end;
-
 
1409
       32: begin
-
 
1410
             asm
-
 
1411
               jmp @@EndCode
-
 
1412
             @@StartCode:
-
 
1413
               mov eax,dword ptr [edx]
-
 
1414
             @@EndCode:
-
 
1415
               {$I DXRender.inc}
-
 
1416
             end;
-
 
1417
           end;
-
 
1418
      end;
-
 
1419
 
-
 
1420
      asm
-
 
1421
        jmp @@EndCode
-
 
1422
      @@StartCode:
-
 
1423
        cmp eax,ebx
-
 
1424
      @@EndCode:
-
 
1425
        {$I DXRender.inc}
-
 
1426
      end;
-
 
1427
      genCmpFunc(Code, ZBuffer.CmpFunc, SkipAddress);
-
 
1428
    end;
-
 
1429
 
-
 
1430
    if ZBuffer.WriteEnable then
-
 
1431
    begin
-
 
1432
      case ZBuffer.Surface.BitCount of
-
 
1433
        8: begin
-
 
1434
             asm
-
 
1435
               jmp @@EndCode
-
 
1436
             @@StartCode:
-
 
1437
               mov byte ptr [edx],bl
-
 
1438
             @@EndCode:
-
 
1439
               {$I DXRender.inc}
-
 
1440
             end;
-
 
1441
           end;
-
 
1442
       16: begin
-
 
1443
             asm
-
 
1444
               jmp @@EndCode
-
 
1445
             @@StartCode:
-
 
1446
               mov word ptr [edx],bx
-
 
1447
             @@EndCode:
-
 
1448
               {$I DXRender.inc}
-
 
1449
             end;
-
 
1450
           end;
-
 
1451
       24: begin
-
 
1452
             asm
-
 
1453
               jmp @@EndCode
-
 
1454
             @@StartCode:
-
 
1455
               mov word ptr [edx],bx
-
 
1456
               bswap ebx
-
 
1457
               mov byte ptr [edx+2],bh
-
 
1458
             @@EndCode:
-
 
1459
               {$I DXRender.inc}
-
 
1460
             end;
-
 
1461
           end;
-
 
1462
       32: begin
-
 
1463
             asm
-
 
1464
               jmp @@EndCode
-
 
1465
             @@StartCode:
-
 
1466
               mov dword ptr [edx],ebx
-
 
1467
             @@EndCode:
-
 
1468
               {$I DXRender.inc}
-
 
1469
             end;
-
 
1470
           end;
-
 
1471
      end;
-
 
1472
    end;
-
 
1473
  end;
-
 
1474
 
-
 
1475
  procedure genUpdateZBufferAddress(var Code: Pointer);
-
 
1476
  var
-
 
1477
    ByteCount: DWORD;
-
 
1478
    _ZBuf: Pointer;
-
 
1479
  begin
-
 
1480
    if not ZBuffer.Enable then Exit;
-
 
1481
 
-
 
1482
    ByteCount := ZBuffer.Surface.BitCount shr 3;
-
 
1483
 
-
 
1484
    _ZBuf := @F_ZBuf;
-
 
1485
 
-
 
1486
    asm
-
 
1487
      jmp @@EndCode
-
 
1488
    @@StartCode:
-
 
1489
      add dword ptr [offset _null],$11{}@@_ZBuf:
-
 
1490
    @@EndCode:
-
 
1491
      {$I DXRender.inc}
-
 
1492
      {  @@_ZBuf  }
-
 
1493
      mov eax,ByteCount
-
 
1494
      mov edx,offset @@_ZBuf-1
-
 
1495
      sub edx,offset @@StartCode
-
 
1496
      mov byte ptr [ecx+edx],al
-
 
1497
 
-
 
1498
      {  @@_ZBuf  }
-
 
1499
      mov eax,_ZBuf
-
 
1500
      mov edx,offset @@_ZBuf-5
-
 
1501
      sub edx,offset @@StartCode
-
 
1502
      mov dword ptr [ecx+edx],eax
-
 
1503
    end;
-
 
1504
  end;
-
 
1505
 
1139
  procedure genReadDestPixel(var Code: Pointer);
1506
  procedure genReadDestPixel(var Code: Pointer);
1140
  begin
1507
  begin
1141
    case Dest.BitCount of
1508
    case Dest.BitCount of
1142
      8: begin
1509
      8: begin
1143
           asm
1510
           asm
1144
             jmp @@EndCode
1511
             jmp @@EndCode
1145
           @@StartCode:
1512
           @@StartCode:
1146
             movzx eax,byte ptr [edi]
1513
             movzx eax,byte ptr [edi]
1147
           @@EndCode:
1514
           @@EndCode:
1148
             {$I DXRender.inc}
1515
             {$I DXRender.inc}
1149
           end;
1516
           end;
1150
         end;
1517
         end;
1151
     16: begin
1518
     16: begin
1152
           asm
1519
           asm
1153
             jmp @@EndCode
1520
             jmp @@EndCode
1154
           @@StartCode:
1521
           @@StartCode:
1155
             movzx eax,word ptr [edi]
1522
             movzx eax,word ptr [edi]
1156
           @@EndCode:
1523
           @@EndCode:
1157
             {$I DXRender.inc}
1524
             {$I DXRender.inc}
1158
           end;
1525
           end;
1159
         end;
1526
         end;
1160
     24: begin
1527
     24: begin
1161
           asm
1528
           asm
1162
             jmp @@EndCode
1529
             jmp @@EndCode
1163
           @@StartCode:
1530
           @@StartCode:
1164
             movzx eax,byte ptr [edi+2]
1531
             movzx eax,byte ptr [edi+2]
1165
             shl eax,16
1532
             shl eax,16
1166
             mov ax,word ptr [edi]
1533
             mov ax,word ptr [edi]
1167
           @@EndCode:
1534
           @@EndCode:
1168
             {$I DXRender.inc}
1535
             {$I DXRender.inc}
1169
           end;
1536
           end;
1170
         end;
1537
         end;
1171
     32: begin
1538
     32: begin
1172
           asm
1539
           asm
1173
             jmp @@EndCode
1540
             jmp @@EndCode
1174
           @@StartCode:
1541
           @@StartCode:
1175
             mov eax,dword ptr [edi]
1542
             mov eax,dword ptr [edi]
1176
           @@EndCode:
1543
           @@EndCode:
1177
             {$I DXRender.inc}
1544
             {$I DXRender.inc}
1178
           end;
1545
           end;
1179
         end;
1546
         end;
1180
    end;
1547
    end;
1181
  end;
1548
  end;
1182
 
1549
 
1183
  procedure genWriteDestPixel(var Code: Pointer);
1550
  procedure genWriteDestPixel(var Code: Pointer);
1184
  begin
1551
  begin
1185
    case Dest.BitCount of
1552
    case Dest.BitCount of
1186
      8: begin
1553
      8: begin
1187
           asm
1554
           asm
1188
             jmp @@EndCode
1555
             jmp @@EndCode
1189
           @@StartCode:
1556
           @@StartCode:
1190
             mov byte ptr [edi],al
1557
             mov byte ptr [edi],al
1191
           @@EndCode:
1558
           @@EndCode:
1192
             {$I DXRender.inc}
1559
             {$I DXRender.inc}
1193
           end;
1560
           end;
1194
         end;
1561
         end;
1195
     16: begin
1562
     16: begin
1196
           asm
1563
           asm
1197
             jmp @@EndCode
1564
             jmp @@EndCode
1198
           @@StartCode:
1565
           @@StartCode:
1199
             mov word ptr [edi],ax
1566
             mov word ptr [edi],ax
1200
           @@EndCode:
1567
           @@EndCode:
1201
             {$I DXRender.inc}
1568
             {$I DXRender.inc}
1202
           end;
1569
           end;
1203
         end;
1570
         end;
1204
     24: begin
1571
     24: begin
1205
           asm
1572
           asm
1206
             jmp @@EndCode
1573
             jmp @@EndCode
1207
           @@StartCode:
1574
           @@StartCode:
1208
             mov word ptr [edi],ax
1575
             mov word ptr [edi],ax
1209
             bswap eax
1576
             bswap eax
1210
             mov byte ptr [edi+2],ah
1577
             mov byte ptr [edi+2],ah
1211
           @@EndCode:
1578
           @@EndCode:
1212
             {$I DXRender.inc}
1579
             {$I DXRender.inc}
1213
           end;
1580
           end;
1214
         end;
1581
         end;
1215
     32: begin
1582
     32: begin
1216
           asm
1583
           asm
1217
             jmp @@EndCode
1584
             jmp @@EndCode
1218
           @@StartCode:
1585
           @@StartCode:
1219
             mov dword ptr [edi],eax
1586
             mov dword ptr [edi],eax
1220
           @@EndCode:
1587
           @@EndCode:
1221
             {$I DXRender.inc}
1588
             {$I DXRender.inc}
1222
           end;
1589
           end;
1223
         end;
1590
         end;
1224
    end;
1591
    end;
1225
  end;
1592
  end;
1226
 
1593
 
1227
  procedure genUpdateDestAddress(var Code: Pointer);
1594
  procedure genUpdateDestAddress(var Code: Pointer);
1228
  var
1595
  var
1229
    ByteCount: DWORD;
1596
    ByteCount: DWORD;
1230
  begin
1597
  begin
1231
    ByteCount := Dest.BitCount shr 3;
1598
    ByteCount := Dest.BitCount shr 3;
1232
 
1599
 
1233
    if ByteCount=1 then
1600
    if ByteCount=1 then
1234
    begin
1601
    begin
1235
      asm
1602
      asm
1236
        jmp @@EndCode
1603
        jmp @@EndCode
1237
      @@StartCode:
1604
      @@StartCode:
1238
        inc edi
1605
        inc edi
1239
      @@EndCode:
1606
      @@EndCode:
1240
        {$I DXRender.inc}
1607
        {$I DXRender.inc}
1241
      end;
1608
      end;
1242
    end else
1609
    end else
1243
    begin
1610
    begin
1244
      asm
1611
      asm
1245
        jmp @@EndCode
1612
        jmp @@EndCode
1246
      @@StartCode:
1613
      @@StartCode:
1247
        add edi,$11{}@@ByteCount:    // Dest.BitCount div 8;
1614
        add edi,$11{}@@ByteCount:    // Dest.BitCount div 8;
1248
      @@EndCode:
1615
      @@EndCode:
1249
        {$I DXRender.inc}
1616
        {$I DXRender.inc}
1250
        {  @@ByteCount  }
1617
        {  @@ByteCount  }
1251
        mov eax,ByteCount
1618
        mov eax,ByteCount
1252
        mov edx,offset @@ByteCount-1
1619
        mov edx,offset @@ByteCount-1
1253
        sub edx,offset @@StartCode
1620
        sub edx,offset @@StartCode
1254
        mov byte ptr [ecx+edx],al
1621
        mov byte ptr [ecx+edx],al
1255
      end;
1622
      end;
1256
    end;
1623
    end;
1257
  end;
1624
  end;
1258
 
1625
 
1259
  procedure genReadSurfacePixel_Tile(var Code: Pointer; const Source: TDXR_Surface; Axis: PDXRMachine_Axis);
1626
  procedure genReadSurfacePixel_Tile(var Code: Pointer; const Source: TDXR_Surface; Axis: PDXRMachine_Axis);
1260
  begin
1627
  begin
1261
    case Source.BitCount of
1628
    case Source.BitCount of
1262
      1: begin
1629
      1: begin
1263
           asm
1630
           asm
1264
             jmp @@EndCode
1631
             jmp @@EndCode
1265
           @@StartCode:
1632
           @@StartCode:
1266
             mov esi,dword ptr [offset _null]{}//TexY
1633
             mov esi,dword ptr [offset _null]{}//TexY
1267
                                 @@TexY:
1634
                                 @@TexY:
1268
             shr esi,16
1635
             shr esi,16
1269
             and esi,$11111111{} @@MaskY:   // Source.HeightMask
1636
             and esi,$11111111{} @@MaskY:   // Source.HeightMask
1270
             imul esi,$11111111{}@@Pitch:   // Source.pitch
1637
             imul esi,$11111111{}@@Pitch:   // Source.pitch
1271
             mov edx,dword ptr [offset _null]{}//TexX
1638
             mov edx,dword ptr [offset _null]{}//TexX
1272
                                 @@TexX:
1639
                                 @@TexX:
1273
             shr edx,16
1640
             shr edx,16
1274
             and edx,$11111111{} @@MaskX:   // Source.WidthMask
1641
             and edx,$11111111{} @@MaskX:   // Source.WidthMask
1275
             mov ebx,edx
1642
             mov ebx,edx
1276
             shr edx,3
1643
             shr edx,3
1277
             and ebx,7
1644
             and ebx,7
1278
             movzx eax,byte ptr [esi+edx+$11111111]
1645
             movzx eax,byte ptr [esi+edx+$11111111]
1279
                                 @@Bits:   // Source.Bits
1646
                                 @@Bits:   // Source.Bits
1280
             and eax,dword ptr [offset Mask1+ebx*4]
1647
             and eax,dword ptr [offset Mask1+ebx*4]
1281
             push ecx
1648
             push ecx
1282
             mov ecx,dword ptr [offset Shift1+ebx*4]
1649
             mov ecx,dword ptr [offset Shift1+ebx*4]
1283
             shr eax,cl
1650
             shr eax,cl
1284
             pop ecx
1651
             pop ecx
1285
           @@EndCode:
1652
           @@EndCode:
1286
             {$I DXRender.inc}
1653
             {$I DXRender.inc}
1287
             {  @@TexX  }
1654
             {  @@TexX  }
1288
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1655
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1289
             mov edx,offset @@TexX-4
1656
             mov edx,offset @@TexX-4
1290
             sub edx,offset @@StartCode
1657
             sub edx,offset @@StartCode
1291
             mov dword ptr [ecx+edx],eax
1658
             mov dword ptr [ecx+edx],eax
1292
 
1659
 
1293
             {  @@TexY  }
1660
             {  @@TexY  }
1294
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1661
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1295
             mov edx,offset @@TexY-4
1662
             mov edx,offset @@TexY-4
1296
             sub edx,offset @@StartCode
1663
             sub edx,offset @@StartCode
1297
             mov dword ptr [ecx+edx],eax
1664
             mov dword ptr [ecx+edx],eax
1298
 
1665
 
1299
             {  @@MaskY  }
1666
             {  @@MaskY  }
1300
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1667
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1301
             mov edx,offset @@MaskY-4
1668
             mov edx,offset @@MaskY-4
1302
             sub edx,offset @@StartCode
1669
             sub edx,offset @@StartCode
1303
             mov dword ptr [ecx+edx],eax
1670
             mov dword ptr [ecx+edx],eax
1304
 
1671
 
1305
             {  @@Pitch  }
1672
             {  @@Pitch  }
1306
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1673
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1307
             mov edx,offset @@Pitch-4
1674
             mov edx,offset @@Pitch-4
1308
             sub edx,offset @@StartCode
1675
             sub edx,offset @@StartCode
1309
             mov dword ptr [ecx+edx],eax
1676
             mov dword ptr [ecx+edx],eax
1310
 
1677
 
1311
             {  @@MaskX  }
1678
             {  @@MaskX  }
1312
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1679
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1313
             mov edx,offset @@MaskX-4
1680
             mov edx,offset @@MaskX-4
1314
             sub edx,offset @@StartCode
1681
             sub edx,offset @@StartCode
1315
             mov dword ptr [ecx+edx],eax
1682
             mov dword ptr [ecx+edx],eax
1316
 
1683
 
1317
             {  @@Bits  }
1684
             {  @@Bits  }
1318
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1685
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1319
             mov edx,offset @@Bits-4
1686
             mov edx,offset @@Bits-4
1320
             sub edx,offset @@StartCode
1687
             sub edx,offset @@StartCode
1321
             mov dword ptr [ecx+edx],eax
1688
             mov dword ptr [ecx+edx],eax
1322
           end;
1689
           end;
1323
         end;
1690
         end;
1324
      2: begin
1691
      2: begin
1325
           asm
1692
           asm
1326
             jmp @@EndCode
1693
             jmp @@EndCode
1327
           @@StartCode:
1694
           @@StartCode:
1328
             mov esi,dword ptr [offset _null]{}//TexY
1695
             mov esi,dword ptr [offset _null]{}//TexY
1329
                                 @@TexY:
1696
                                 @@TexY:
1330
             shr esi,16
1697
             shr esi,16
1331
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
1698
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
1332
             imul esi,$11111111{}@@Pitch:  // Source.pitch
1699
             imul esi,$11111111{}@@Pitch:  // Source.pitch
1333
             mov edx,dword ptr [offset _null]{}//TexX
1700
             mov edx,dword ptr [offset _null]{}//TexX
1334
                                 @@TexX:
1701
                                 @@TexX:
1335
             shr edx,16
1702
             shr edx,16
1336
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
1703
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
1337
             mov ebx,edx
1704
             mov ebx,edx
1338
             shr edx,2
1705
             shr edx,2
1339
             and ebx,3
1706
             and ebx,3
1340
             movzx eax,byte ptr [esi+edx+$11111111]
1707
             movzx eax,byte ptr [esi+edx+$11111111]
1341
                                 @@Bits:   // Source.Bits
1708
                                 @@Bits:   // Source.Bits
1342
             and eax,dword ptr [offset Mask2+ebx*4]
1709
             and eax,dword ptr [offset Mask2+ebx*4]
1343
             push ecx
1710
             push ecx
1344
             mov ecx,dword ptr [offset Shift2+ebx*4]
1711
             mov ecx,dword ptr [offset Shift2+ebx*4]
1345
             shr eax,cl
1712
             shr eax,cl
1346
             pop ecx
1713
             pop ecx
1347
           @@EndCode:
1714
           @@EndCode:
1348
             {$I DXRender.inc}
1715
             {$I DXRender.inc}
1349
             {  @@TexX  }
1716
             {  @@TexX  }
1350
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1717
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1351
             mov edx,offset @@TexX-4
1718
             mov edx,offset @@TexX-4
1352
             sub edx,offset @@StartCode
1719
             sub edx,offset @@StartCode
1353
             mov dword ptr [ecx+edx],eax
1720
             mov dword ptr [ecx+edx],eax
1354
 
1721
 
1355
             {  @@TexY  }
1722
             {  @@TexY  }
1356
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1723
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1357
             mov edx,offset @@TexY-4
1724
             mov edx,offset @@TexY-4
1358
             sub edx,offset @@StartCode
1725
             sub edx,offset @@StartCode
1359
             mov dword ptr [ecx+edx],eax
1726
             mov dword ptr [ecx+edx],eax
1360
 
1727
 
1361
             {  @@MaskY  }
1728
             {  @@MaskY  }
1362
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1729
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1363
             mov edx,offset @@MaskY-4
1730
             mov edx,offset @@MaskY-4
1364
             sub edx,offset @@StartCode
1731
             sub edx,offset @@StartCode
1365
             mov dword ptr [ecx+edx],eax
1732
             mov dword ptr [ecx+edx],eax
1366
 
1733
 
1367
             {  @@Pitch  }
1734
             {  @@Pitch  }
1368
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1735
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1369
             mov edx,offset @@Pitch-4
1736
             mov edx,offset @@Pitch-4
1370
             sub edx,offset @@StartCode
1737
             sub edx,offset @@StartCode
1371
             mov dword ptr [ecx+edx],eax
1738
             mov dword ptr [ecx+edx],eax
1372
 
1739
 
1373
             {  @@MaskX  }
1740
             {  @@MaskX  }
1374
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1741
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1375
             mov edx,offset @@MaskX-4
1742
             mov edx,offset @@MaskX-4
1376
             sub edx,offset @@StartCode
1743
             sub edx,offset @@StartCode
1377
             mov dword ptr [ecx+edx],eax
1744
             mov dword ptr [ecx+edx],eax
1378
             {  @@Bits  }
1745
             {  @@Bits  }
1379
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1746
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1380
             mov edx,offset @@Bits-4
1747
             mov edx,offset @@Bits-4
1381
             sub edx,offset @@StartCode
1748
             sub edx,offset @@StartCode
1382
             mov dword ptr [ecx+edx],eax
1749
             mov dword ptr [ecx+edx],eax
1383
           end;
1750
           end;
1384
         end;
1751
         end;
1385
      4: begin
1752
      4: begin
1386
           asm
1753
           asm
1387
             jmp @@EndCode
1754
             jmp @@EndCode
1388
           @@StartCode:
1755
           @@StartCode:
1389
             mov esi,dword ptr [offset _null]{}//TexY
1756
             mov esi,dword ptr [offset _null]{}//TexY
1390
                                 @@TexY:
1757
                                 @@TexY:
1391
             shr esi,16
1758
             shr esi,16
1392
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
1759
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
1393
             imul esi,$11111111{}@@Pitch:  // Source.pitch
1760
             imul esi,$11111111{}@@Pitch:  // Source.pitch
1394
             mov edx,dword ptr [offset _null]{}//TexX
1761
             mov edx,dword ptr [offset _null]{}//TexX
1395
                                 @@TexX:
1762
                                 @@TexX:
1396
             shr edx,16
1763
             shr edx,16
1397
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
1764
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
1398
             mov ebx,edx
1765
             mov ebx,edx
1399
             shr edx,1
1766
             shr edx,1
1400
             and ebx,1
1767
             and ebx,1
1401
             movzx eax,byte ptr [esi+edx+$11111111]
1768
             movzx eax,byte ptr [esi+edx+$11111111]
1402
                                 @@Bits:   // Source.Bits
1769
                                 @@Bits:   // Source.Bits
1403
             and eax,dword ptr [offset Mask4+ebx*4]
1770
             and eax,dword ptr [offset Mask4+ebx*4]
1404
             push ecx
1771
             push ecx
1405
             mov ecx,dword ptr [offset Shift4+ebx*4]
1772
             mov ecx,dword ptr [offset Shift4+ebx*4]
1406
             shr eax,cl
1773
             shr eax,cl
1407
             pop ecx
1774
             pop ecx
1408
           @@EndCode:
1775
           @@EndCode:
1409
             {$I DXRender.inc}
1776
             {$I DXRender.inc}
1410
             {  @@TexX  }
1777
             {  @@TexX  }
1411
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1778
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1412
             mov edx,offset @@TexX-4
1779
             mov edx,offset @@TexX-4
1413
             sub edx,offset @@StartCode
1780
             sub edx,offset @@StartCode
1414
             mov dword ptr [ecx+edx],eax
1781
             mov dword ptr [ecx+edx],eax
1415
 
1782
 
1416
             {  @@TexY  }
1783
             {  @@TexY  }
1417
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1784
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1418
             mov edx,offset @@TexY-4
1785
             mov edx,offset @@TexY-4
1419
             sub edx,offset @@StartCode
1786
             sub edx,offset @@StartCode
1420
             mov dword ptr [ecx+edx],eax
1787
             mov dword ptr [ecx+edx],eax
1421
 
1788
 
1422
             {  @@MaskY  }
1789
             {  @@MaskY  }
1423
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1790
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1424
             mov edx,offset @@MaskY-4
1791
             mov edx,offset @@MaskY-4
1425
             sub edx,offset @@StartCode
1792
             sub edx,offset @@StartCode
1426
             mov dword ptr [ecx+edx],eax
1793
             mov dword ptr [ecx+edx],eax
1427
 
1794
 
1428
             {  @@Pitch  }
1795
             {  @@Pitch  }
1429
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1796
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1430
             mov edx,offset @@Pitch-4
1797
             mov edx,offset @@Pitch-4
1431
             sub edx,offset @@StartCode
1798
             sub edx,offset @@StartCode
1432
             mov dword ptr [ecx+edx],eax
1799
             mov dword ptr [ecx+edx],eax
1433
 
1800
 
1434
             {  @@MaskX  }
1801
             {  @@MaskX  }
1435
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1802
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1436
             mov edx,offset @@MaskX-4
1803
             mov edx,offset @@MaskX-4
1437
             sub edx,offset @@StartCode
1804
             sub edx,offset @@StartCode
1438
             mov dword ptr [ecx+edx],eax
1805
             mov dword ptr [ecx+edx],eax
1439
 
1806
 
1440
             {  @@Bits  }
1807
             {  @@Bits  }
1441
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1808
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1442
             mov edx,offset @@Bits-4
1809
             mov edx,offset @@Bits-4
1443
             sub edx,offset @@StartCode
1810
             sub edx,offset @@StartCode
1444
             mov dword ptr [ecx+edx],eax
1811
             mov dword ptr [ecx+edx],eax
1445
           end;
1812
           end;
1446
         end;
1813
         end;
1447
      8: begin
1814
      8: begin
1448
           if Source.pitch=(1 shl Source.PitchBit) then
1815
           if Source.pitch=(1 shl Source.PitchBit) then
1449
           begin
1816
           begin
1450
             asm
1817
             asm
1451
               jmp @@EndCode
1818
               jmp @@EndCode
1452
             @@StartCode:
1819
             @@StartCode:
1453
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1820
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1454
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1821
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1455
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1822
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1456
               shr edx,16
1823
               shr edx,16
1457
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1824
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1458
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1825
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1459
               movzx eax,byte ptr [$11111111+esi+edx]
1826
               movzx eax,byte ptr [$11111111+esi+edx]
1460
                                   @@Bits:   // Source.Bits
1827
                                   @@Bits:   // Source.Bits
1461
             @@EndCode:
1828
             @@EndCode:
1462
               {$I DXRender.inc}
1829
               {$I DXRender.inc}
1463
               {  @@TexX  }
1830
               {  @@TexX  }
1464
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1831
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1465
               mov edx,offset @@TexX-4
1832
               mov edx,offset @@TexX-4
1466
               sub edx,offset @@StartCode
1833
               sub edx,offset @@StartCode
1467
               mov dword ptr [ecx+edx],eax
1834
               mov dword ptr [ecx+edx],eax
1468
 
1835
 
1469
               {  @@TexY  }
1836
               {  @@TexY  }
1470
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1837
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1471
               mov edx,offset @@TexY-4
1838
               mov edx,offset @@TexY-4
1472
               sub edx,offset @@StartCode
1839
               sub edx,offset @@StartCode
1473
               mov dword ptr [ecx+edx],eax
1840
               mov dword ptr [ecx+edx],eax
1474
 
1841
 
1475
               {  @@YShift  }
1842
               {  @@YShift  }
1476
               push ebx
1843
               push ebx
1477
               mov eax,16
1844
               mov eax,16
1478
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1845
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1479
               pop ebx
1846
               pop ebx
1480
               mov edx,offset @@YShift-1
1847
               mov edx,offset @@YShift-1
1481
               sub edx,offset @@StartCode
1848
               sub edx,offset @@StartCode
1482
               mov byte ptr [ecx+edx],al
1849
               mov byte ptr [ecx+edx],al
1483
 
1850
 
1484
               {  @@MaskY  }
1851
               {  @@MaskY  }
1485
               push ecx
1852
               push ecx
1486
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1853
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1487
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1854
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1488
               shl eax,cl
1855
               shl eax,cl
1489
               pop ecx
1856
               pop ecx
1490
               mov edx,offset @@MaskY-4
1857
               mov edx,offset @@MaskY-4
1491
               sub edx,offset @@StartCode
1858
               sub edx,offset @@StartCode
1492
               mov dword ptr [ecx+edx],eax
1859
               mov dword ptr [ecx+edx],eax
1493
 
1860
 
1494
               {  @@MaskX  }
1861
               {  @@MaskX  }
1495
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1862
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1496
               mov edx,offset @@MaskX-4
1863
               mov edx,offset @@MaskX-4
1497
               sub edx,offset @@StartCode
1864
               sub edx,offset @@StartCode
1498
               mov dword ptr [ecx+edx],eax
1865
               mov dword ptr [ecx+edx],eax
1499
 
1866
 
1500
               {  @@Bits  }
1867
               {  @@Bits  }
1501
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1868
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1502
               mov edx,offset @@Bits-4
1869
               mov edx,offset @@Bits-4
1503
               sub edx,offset @@StartCode
1870
               sub edx,offset @@StartCode
1504
               mov dword ptr [ecx+edx],eax
1871
               mov dword ptr [ecx+edx],eax
1505
             end;
1872
             end;
1506
           end else
1873
           end else
1507
           if -Source.pitch=(1 shl Source.PitchBit) then
1874
           if -Source.pitch=(1 shl Source.PitchBit) then
1508
           begin
1875
           begin
1509
             asm
1876
             asm
1510
               jmp @@EndCode
1877
               jmp @@EndCode
1511
             @@StartCode:
1878
             @@StartCode:
1512
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1879
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1513
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1880
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1514
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1881
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1515
               shr edx,16
1882
               shr edx,16
1516
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1883
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1517
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1884
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1518
               neg esi
1885
               neg esi
1519
               movzx eax,byte ptr [$11111111+esi+edx]
1886
               movzx eax,byte ptr [$11111111+esi+edx]
1520
                                   @@Bits:   // Source.Bits
1887
                                   @@Bits:   // Source.Bits
1521
             @@EndCode:
1888
             @@EndCode:
1522
               {$I DXRender.inc}
1889
               {$I DXRender.inc}
1523
               {  @@TexX  }
1890
               {  @@TexX  }
1524
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1891
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1525
               mov edx,offset @@TexX-4
1892
               mov edx,offset @@TexX-4
1526
               sub edx,offset @@StartCode
1893
               sub edx,offset @@StartCode
1527
               mov dword ptr [ecx+edx],eax
1894
               mov dword ptr [ecx+edx],eax
1528
 
1895
 
1529
               {  @@TexY  }
1896
               {  @@TexY  }
1530
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1897
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1531
               mov edx,offset @@TexY-4
1898
               mov edx,offset @@TexY-4
1532
               sub edx,offset @@StartCode
1899
               sub edx,offset @@StartCode
1533
               mov dword ptr [ecx+edx],eax
1900
               mov dword ptr [ecx+edx],eax
1534
 
1901
 
1535
               {  @@YShift  }
1902
               {  @@YShift  }
1536
               push ebx
1903
               push ebx
1537
               mov eax,16
1904
               mov eax,16
1538
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1905
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1539
               pop ebx
1906
               pop ebx
1540
               mov edx,offset @@YShift-1
1907
               mov edx,offset @@YShift-1
1541
               sub edx,offset @@StartCode
1908
               sub edx,offset @@StartCode
1542
               mov byte ptr [ecx+edx],al
1909
               mov byte ptr [ecx+edx],al
1543
 
1910
 
1544
               {  @@MaskY  }
1911
               {  @@MaskY  }
1545
               push ecx
1912
               push ecx
1546
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1913
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1547
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1914
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1548
               shl eax,cl
1915
               shl eax,cl
1549
               pop ecx
1916
               pop ecx
1550
               mov edx,offset @@MaskY-4
1917
               mov edx,offset @@MaskY-4
1551
               sub edx,offset @@StartCode
1918
               sub edx,offset @@StartCode
1552
               mov dword ptr [ecx+edx],eax
1919
               mov dword ptr [ecx+edx],eax
1553
 
1920
 
1554
               {  @@MaskX  }
1921
               {  @@MaskX  }
1555
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1922
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1556
               mov edx,offset @@MaskX-4
1923
               mov edx,offset @@MaskX-4
1557
               sub edx,offset @@StartCode
1924
               sub edx,offset @@StartCode
1558
               mov dword ptr [ecx+edx],eax
1925
               mov dword ptr [ecx+edx],eax
1559
 
1926
 
1560
               {  @@Bits  }
1927
               {  @@Bits  }
1561
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1928
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1562
               mov edx,offset @@Bits-4
1929
               mov edx,offset @@Bits-4
1563
               sub edx,offset @@StartCode
1930
               sub edx,offset @@StartCode
1564
               mov dword ptr [ecx+edx],eax
1931
               mov dword ptr [ecx+edx],eax
1565
             end;
1932
             end;
1566
           end else
1933
           end else
1567
           begin
1934
           begin
1568
             asm
1935
             asm
1569
               jmp @@EndCode
1936
               jmp @@EndCode
1570
             @@StartCode:
1937
             @@StartCode:
1571
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1938
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1572
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1939
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1573
               shr esi,16
1940
               shr esi,16
1574
               shr edx,16
1941
               shr edx,16
1575
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
1942
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
1576
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1943
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1577
               imul esi,$11111111{}@@Pitch:  // Source.pitch
1944
               imul esi,$11111111{}@@Pitch:  // Source.pitch
1578
               movzx eax,byte ptr [esi+edx+$11111111]
1945
               movzx eax,byte ptr [esi+edx+$11111111]
1579
                                   @@Bits:   // Source.Bits
1946
                                   @@Bits:   // Source.Bits
1580
             @@EndCode:
1947
             @@EndCode:
1581
               {$I DXRender.inc}
1948
               {$I DXRender.inc}
1582
               {  @@TexX  }
1949
               {  @@TexX  }
1583
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1950
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1584
               mov edx,offset @@TexX-4
1951
               mov edx,offset @@TexX-4
1585
               sub edx,offset @@StartCode
1952
               sub edx,offset @@StartCode
1586
               mov dword ptr [ecx+edx],eax
1953
               mov dword ptr [ecx+edx],eax
1587
 
1954
 
1588
               {  @@TexY  }
1955
               {  @@TexY  }
1589
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1956
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1590
               mov edx,offset @@TexY-4
1957
               mov edx,offset @@TexY-4
1591
               sub edx,offset @@StartCode
1958
               sub edx,offset @@StartCode
1592
               mov dword ptr [ecx+edx],eax
1959
               mov dword ptr [ecx+edx],eax
1593
 
1960
 
1594
               {  @@MaskY  }
1961
               {  @@MaskY  }
1595
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1962
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1596
               mov edx,offset @@MaskY-4
1963
               mov edx,offset @@MaskY-4
1597
               sub edx,offset @@StartCode
1964
               sub edx,offset @@StartCode
1598
               mov dword ptr [ecx+edx],eax
1965
               mov dword ptr [ecx+edx],eax
1599
 
1966
 
1600
               {  @@Pitch  }
1967
               {  @@Pitch  }
1601
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1968
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1602
               mov edx,offset @@Pitch-4
1969
               mov edx,offset @@Pitch-4
1603
               sub edx,offset @@StartCode
1970
               sub edx,offset @@StartCode
1604
               mov dword ptr [ecx+edx],eax
1971
               mov dword ptr [ecx+edx],eax
1605
 
1972
 
1606
               {  @@MaskX  }
1973
               {  @@MaskX  }
1607
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1974
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1608
               mov edx,offset @@MaskX-4
1975
               mov edx,offset @@MaskX-4
1609
               sub edx,offset @@StartCode
1976
               sub edx,offset @@StartCode
1610
               mov dword ptr [ecx+edx],eax
1977
               mov dword ptr [ecx+edx],eax
1611
 
1978
 
1612
               {  @@Bits  }
1979
               {  @@Bits  }
1613
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1980
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1614
               mov edx,offset @@Bits-4
1981
               mov edx,offset @@Bits-4
1615
               sub edx,offset @@StartCode
1982
               sub edx,offset @@StartCode
1616
               mov dword ptr [ecx+edx],eax
1983
               mov dword ptr [ecx+edx],eax
1617
             end;
1984
             end;
1618
           end;
1985
           end;
1619
         end;
1986
         end;
1620
     16: begin
1987
     16: begin
1621
           if Source.pitch=(1 shl Source.PitchBit) then
1988
           if Source.pitch=(1 shl Source.PitchBit) then
1622
           begin
1989
           begin
1623
             asm
1990
             asm
1624
               jmp @@EndCode
1991
               jmp @@EndCode
1625
             @@StartCode:
1992
             @@StartCode:
1626
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1993
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1627
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1994
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1628
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1995
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1629
               shr edx,16
1996
               shr edx,16
1630
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1997
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1631
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1998
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1632
               movzx eax,word ptr [$11111111+esi+edx*2]
1999
               movzx eax,word ptr [$11111111+esi+edx*2]
1633
                                   @@Bits:   // Source.Bits
2000
                                   @@Bits:   // Source.Bits
1634
             @@EndCode:
2001
             @@EndCode:
1635
               {$I DXRender.inc}
2002
               {$I DXRender.inc}
1636
               {  @@TexX  }
2003
               {  @@TexX  }
1637
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2004
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1638
               mov edx,offset @@TexX-4
2005
               mov edx,offset @@TexX-4
1639
               sub edx,offset @@StartCode
2006
               sub edx,offset @@StartCode
1640
               mov dword ptr [ecx+edx],eax
2007
               mov dword ptr [ecx+edx],eax
1641
 
2008
 
1642
               {  @@TexY  }
2009
               {  @@TexY  }
1643
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2010
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1644
               mov edx,offset @@TexY-4
2011
               mov edx,offset @@TexY-4
1645
               sub edx,offset @@StartCode
2012
               sub edx,offset @@StartCode
1646
               mov dword ptr [ecx+edx],eax
2013
               mov dword ptr [ecx+edx],eax
1647
 
2014
 
1648
               {  @@YShift  }
2015
               {  @@YShift  }
1649
               push ebx
2016
               push ebx
1650
               mov eax,16
2017
               mov eax,16
1651
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
2018
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1652
               pop ebx
2019
               pop ebx
1653
               mov edx,offset @@YShift-1
2020
               mov edx,offset @@YShift-1
1654
               sub edx,offset @@StartCode
2021
               sub edx,offset @@StartCode
1655
               mov byte ptr [ecx+edx],al
2022
               mov byte ptr [ecx+edx],al
1656
 
2023
 
1657
               {  @@MaskY  }
2024
               {  @@MaskY  }
1658
               push ecx
2025
               push ecx
1659
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
2026
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1660
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2027
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1661
               shl eax,cl
2028
               shl eax,cl
1662
               pop ecx
2029
               pop ecx
1663
               mov edx,offset @@MaskY-4
2030
               mov edx,offset @@MaskY-4
1664
               sub edx,offset @@StartCode
2031
               sub edx,offset @@StartCode
1665
               mov dword ptr [ecx+edx],eax
2032
               mov dword ptr [ecx+edx],eax
1666
 
2033
 
1667
               {  @@MaskX  }
2034
               {  @@MaskX  }
1668
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2035
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1669
               mov edx,offset @@MaskX-4
2036
               mov edx,offset @@MaskX-4
1670
               sub edx,offset @@StartCode
2037
               sub edx,offset @@StartCode
1671
               mov dword ptr [ecx+edx],eax
2038
               mov dword ptr [ecx+edx],eax
1672
 
2039
 
1673
               {  @@Bits  }
2040
               {  @@Bits  }
1674
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2041
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1675
               mov edx,offset @@Bits-4
2042
               mov edx,offset @@Bits-4
1676
               sub edx,offset @@StartCode
2043
               sub edx,offset @@StartCode
1677
               mov dword ptr [ecx+edx],eax
2044
               mov dword ptr [ecx+edx],eax
1678
             end;
2045
             end;
1679
           end else
2046
           end else
1680
           if -Source.pitch=(1 shl Source.PitchBit) then
2047
           if -Source.pitch=(1 shl Source.PitchBit) then
1681
           begin
2048
           begin
1682
             asm
2049
             asm
1683
               jmp @@EndCode
2050
               jmp @@EndCode
1684
             @@StartCode:
2051
             @@StartCode:
1685
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2052
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1686
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2053
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1687
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
2054
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1688
               shr edx,16
2055
               shr edx,16
1689
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
2056
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1690
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
2057
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1691
               neg esi
2058
               neg esi
1692
               movzx eax,word ptr [$11111111+esi+edx*2]
2059
               movzx eax,word ptr [$11111111+esi+edx*2]
1693
                                   @@Bits:   // Source.Bits
2060
                                   @@Bits:   // Source.Bits
1694
             @@EndCode:
2061
             @@EndCode:
1695
               {$I DXRender.inc}
2062
               {$I DXRender.inc}
1696
               {  @@TexX  }
2063
               {  @@TexX  }
1697
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2064
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1698
               mov edx,offset @@TexX-4
2065
               mov edx,offset @@TexX-4
1699
               sub edx,offset @@StartCode
2066
               sub edx,offset @@StartCode
1700
               mov dword ptr [ecx+edx],eax
2067
               mov dword ptr [ecx+edx],eax
1701
 
2068
 
1702
               {  @@TexY  }
2069
               {  @@TexY  }
1703
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2070
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1704
               mov edx,offset @@TexY-4
2071
               mov edx,offset @@TexY-4
1705
               sub edx,offset @@StartCode
2072
               sub edx,offset @@StartCode
1706
               mov dword ptr [ecx+edx],eax
2073
               mov dword ptr [ecx+edx],eax
1707
 
2074
 
1708
               {  @@YShift  }
2075
               {  @@YShift  }
1709
               push ebx
2076
               push ebx
1710
               mov eax,16
2077
               mov eax,16
1711
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
2078
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1712
               pop ebx
2079
               pop ebx
1713
               mov edx,offset @@YShift-1
2080
               mov edx,offset @@YShift-1
1714
               sub edx,offset @@StartCode
2081
               sub edx,offset @@StartCode
1715
               mov byte ptr [ecx+edx],al
2082
               mov byte ptr [ecx+edx],al
1716
 
2083
 
1717
               {  @@MaskY  }
2084
               {  @@MaskY  }
1718
               push ecx
2085
               push ecx
1719
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
2086
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1720
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2087
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1721
               shl eax,cl
2088
               shl eax,cl
1722
               pop ecx
2089
               pop ecx
1723
               mov edx,offset @@MaskY-4
2090
               mov edx,offset @@MaskY-4
1724
               sub edx,offset @@StartCode
2091
               sub edx,offset @@StartCode
1725
               mov dword ptr [ecx+edx],eax
2092
               mov dword ptr [ecx+edx],eax
1726
 
2093
 
1727
               {  @@MaskX  }
2094
               {  @@MaskX  }
1728
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2095
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1729
               mov edx,offset @@MaskX-4
2096
               mov edx,offset @@MaskX-4
1730
               sub edx,offset @@StartCode
2097
               sub edx,offset @@StartCode
1731
               mov dword ptr [ecx+edx],eax
2098
               mov dword ptr [ecx+edx],eax
1732
 
2099
 
1733
               {  @@Bits  }
2100
               {  @@Bits  }
1734
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2101
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1735
               mov edx,offset @@Bits-4
2102
               mov edx,offset @@Bits-4
1736
               sub edx,offset @@StartCode
2103
               sub edx,offset @@StartCode
1737
               mov dword ptr [ecx+edx],eax
2104
               mov dword ptr [ecx+edx],eax
1738
             end;
2105
             end;
1739
           end else
2106
           end else
1740
           begin
2107
           begin
1741
             asm
2108
             asm
1742
               jmp @@EndCode
2109
               jmp @@EndCode
1743
             @@StartCode:
2110
             @@StartCode:
1744
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2111
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1745
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2112
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1746
               shr esi,16
2113
               shr esi,16
1747
               shr edx,16
2114
               shr edx,16
1748
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
2115
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
1749
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
2116
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1750
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2117
               imul esi,$11111111{}@@Pitch:  // Source.pitch
1751
               movzx eax,word ptr [esi+edx*2+$11111111]
2118
               movzx eax,word ptr [esi+edx*2+$11111111]
1752
                                   @@Bits:   // Source.Bits
2119
                                   @@Bits:   // Source.Bits
1753
             @@EndCode:
2120
             @@EndCode:
1754
               {$I DXRender.inc}
2121
               {$I DXRender.inc}
1755
               {  @@TexX  }
2122
               {  @@TexX  }
1756
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2123
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1757
               mov edx,offset @@TexX-4
2124
               mov edx,offset @@TexX-4
1758
               sub edx,offset @@StartCode
2125
               sub edx,offset @@StartCode
1759
               mov dword ptr [ecx+edx],eax
2126
               mov dword ptr [ecx+edx],eax
1760
 
2127
 
1761
               {  @@TexY  }
2128
               {  @@TexY  }
1762
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2129
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1763
               mov edx,offset @@TexY-4
2130
               mov edx,offset @@TexY-4
1764
               sub edx,offset @@StartCode
2131
               sub edx,offset @@StartCode
1765
               mov dword ptr [ecx+edx],eax
2132
               mov dword ptr [ecx+edx],eax
1766
 
2133
 
1767
               {  @@MaskY  }
2134
               {  @@MaskY  }
1768
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2135
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1769
               mov edx,offset @@MaskY-4
2136
               mov edx,offset @@MaskY-4
1770
               sub edx,offset @@StartCode
2137
               sub edx,offset @@StartCode
1771
               mov dword ptr [ecx+edx],eax
2138
               mov dword ptr [ecx+edx],eax
1772
 
2139
 
1773
               {  @@Pitch  }
2140
               {  @@Pitch  }
1774
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2141
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1775
               mov edx,offset @@Pitch-4
2142
               mov edx,offset @@Pitch-4
1776
               sub edx,offset @@StartCode
2143
               sub edx,offset @@StartCode
1777
               mov dword ptr [ecx+edx],eax
2144
               mov dword ptr [ecx+edx],eax
1778
 
2145
 
1779
               {  @@MaskX  }
2146
               {  @@MaskX  }
1780
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2147
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1781
               mov edx,offset @@MaskX-4
2148
               mov edx,offset @@MaskX-4
1782
               sub edx,offset @@StartCode
2149
               sub edx,offset @@StartCode
1783
               mov dword ptr [ecx+edx],eax
2150
               mov dword ptr [ecx+edx],eax
1784
 
2151
 
1785
               {  @@Bits  }
2152
               {  @@Bits  }
1786
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2153
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1787
               mov edx,offset @@Bits-4
2154
               mov edx,offset @@Bits-4
1788
               sub edx,offset @@StartCode
2155
               sub edx,offset @@StartCode
1789
               mov dword ptr [ecx+edx],eax
2156
               mov dword ptr [ecx+edx],eax
1790
             end;
2157
             end;
1791
           end;
2158
           end;
1792
         end;
2159
         end;
1793
     24: begin
2160
     24: begin
1794
           asm
2161
           asm
1795
             jmp @@EndCode
2162
             jmp @@EndCode
1796
           @@StartCode:
2163
           @@StartCode:
1797
             mov esi,dword ptr [offset _null]{}//TexY
2164
             mov esi,dword ptr [offset _null]{}//TexY
1798
                                 @@TexY:
2165
                                 @@TexY:
1799
             mov edx,dword ptr [offset _null]{}//TexX
2166
             mov edx,dword ptr [offset _null]{}//TexX
1800
                                 @@TexX:
2167
                                 @@TexX:
1801
             shr esi,16
2168
             shr esi,16
1802
             shr edx,16
2169
             shr edx,16
1803
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
2170
             and esi,$11111111{} @@MaskY:  // Source.HeightMask
1804
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
2171
             and edx,$11111111{} @@MaskX:  // Source.WidthMask
1805
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2172
             imul esi,$11111111{}@@Pitch:  // Source.pitch
1806
             lea edx,[edx+edx*2+$11111111] // Source.Bits
2173
             lea edx,[edx+edx*2+$11111111] // Source.Bits
1807
                                 @@Bits:
2174
                                 @@Bits:
1808
             movzx eax,byte ptr [esi+edx+2]
2175
             movzx eax,byte ptr [esi+edx+2]
1809
             shl eax,16
2176
             shl eax,16
1810
             mov ax,word ptr [esi+edx]
2177
             mov ax,word ptr [esi+edx]
1811
           @@EndCode:
2178
           @@EndCode:
1812
             {$I DXRender.inc}
2179
             {$I DXRender.inc}
1813
             {  @@TexX  }
2180
             {  @@TexX  }
1814
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2181
             mov eax,Axis; add eax,TDXRMachine_Axis.X
1815
             mov edx,offset @@TexX-4
2182
             mov edx,offset @@TexX-4
1816
             sub edx,offset @@StartCode
2183
             sub edx,offset @@StartCode
1817
             mov dword ptr [ecx+edx],eax
2184
             mov dword ptr [ecx+edx],eax
1818
 
2185
 
1819
             {  @@TexY  }
2186
             {  @@TexY  }
1820
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2187
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
1821
             mov edx,offset @@TexY-4
2188
             mov edx,offset @@TexY-4
1822
             sub edx,offset @@StartCode
2189
             sub edx,offset @@StartCode
1823
             mov dword ptr [ecx+edx],eax
2190
             mov dword ptr [ecx+edx],eax
1824
 
2191
 
1825
             {  @@MaskY  }
2192
             {  @@MaskY  }
1826
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2193
             mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1827
             mov edx,offset @@MaskY-4
2194
             mov edx,offset @@MaskY-4
1828
             sub edx,offset @@StartCode
2195
             sub edx,offset @@StartCode
1829
             mov dword ptr [ecx+edx],eax
2196
             mov dword ptr [ecx+edx],eax
1830
 
2197
 
1831
             {  @@Pitch  }
2198
             {  @@Pitch  }
1832
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2199
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
1833
             mov edx,offset @@Pitch-4
2200
             mov edx,offset @@Pitch-4
1834
             sub edx,offset @@StartCode
2201
             sub edx,offset @@StartCode
1835
             mov dword ptr [ecx+edx],eax
2202
             mov dword ptr [ecx+edx],eax
1836
 
2203
 
1837
             {  @@MaskX  }
2204
             {  @@MaskX  }
1838
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2205
             mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1839
             mov edx,offset @@MaskX-4
2206
             mov edx,offset @@MaskX-4
1840
             sub edx,offset @@StartCode
2207
             sub edx,offset @@StartCode
1841
             mov dword ptr [ecx+edx],eax
2208
             mov dword ptr [ecx+edx],eax
1842
 
2209
 
1843
             {  @@Bits  }
2210
             {  @@Bits  }
1844
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2211
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1845
             mov edx,offset @@Bits-4
2212
             mov edx,offset @@Bits-4
1846
             sub edx,offset @@StartCode
2213
             sub edx,offset @@StartCode
1847
             mov dword ptr [ecx+edx],eax
2214
             mov dword ptr [ecx+edx],eax
1848
           end;
2215
           end;
1849
         end;
2216
         end;
1850
     32: begin
2217
     32: begin
1851
           if Source.pitch=(1 shl Source.PitchBit) then
2218
           if Source.pitch=(1 shl Source.PitchBit) then
1852
           begin
2219
           begin
1853
             asm
2220
             asm
1854
               jmp @@EndCode
2221
               jmp @@EndCode
1855
             @@StartCode:
2222
             @@StartCode:
1856
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2223
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1857
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2224
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1858
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
2225
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1859
               shr edx,16
2226
               shr edx,16
1860
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
2227
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1861
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
2228
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1862
               mov eax,dword ptr [$11111111+esi+edx*4]
2229
               mov eax,dword ptr [$11111111+esi+edx*4]
1863
                                   @@Bits:   // Source.Bits
2230
                                   @@Bits:   // Source.Bits
1864
             @@EndCode:
2231
             @@EndCode:
1865
               {$I DXRender.inc}
2232
               {$I DXRender.inc}
1866
               {  @@TexX  }
2233
               {  @@TexX  }
1867
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2234
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1868
               mov edx,offset @@TexX-4
2235
               mov edx,offset @@TexX-4
1869
               sub edx,offset @@StartCode
2236
               sub edx,offset @@StartCode
1870
               mov dword ptr [ecx+edx],eax
2237
               mov dword ptr [ecx+edx],eax
1871
 
2238
 
1872
               {  @@TexY  }
2239
               {  @@TexY  }
1873
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2240
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1874
               mov edx,offset @@TexY-4
2241
               mov edx,offset @@TexY-4
1875
               sub edx,offset @@StartCode
2242
               sub edx,offset @@StartCode
1876
               mov dword ptr [ecx+edx],eax
2243
               mov dword ptr [ecx+edx],eax
1877
 
2244
 
1878
               {  @@YShift  }
2245
               {  @@YShift  }
1879
               push ebx
2246
               push ebx
1880
               mov eax,16
2247
               mov eax,16
1881
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
2248
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1882
               pop ebx
2249
               pop ebx
1883
               mov edx,offset @@YShift-1
2250
               mov edx,offset @@YShift-1
1884
               sub edx,offset @@StartCode
2251
               sub edx,offset @@StartCode
1885
               mov byte ptr [ecx+edx],al
2252
               mov byte ptr [ecx+edx],al
1886
 
2253
 
1887
               {  @@MaskY  }
2254
               {  @@MaskY  }
1888
               push ecx
2255
               push ecx
1889
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
2256
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1890
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2257
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1891
               shl eax,cl
2258
               shl eax,cl
1892
               pop ecx
2259
               pop ecx
1893
               mov edx,offset @@MaskY-4
2260
               mov edx,offset @@MaskY-4
1894
               sub edx,offset @@StartCode
2261
               sub edx,offset @@StartCode
1895
               mov dword ptr [ecx+edx],eax
2262
               mov dword ptr [ecx+edx],eax
1896
 
2263
 
1897
               {  @@MaskX  }
2264
               {  @@MaskX  }
1898
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2265
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1899
               mov edx,offset @@MaskX-4
2266
               mov edx,offset @@MaskX-4
1900
               sub edx,offset @@StartCode
2267
               sub edx,offset @@StartCode
1901
               mov dword ptr [ecx+edx],eax
2268
               mov dword ptr [ecx+edx],eax
1902
 
2269
 
1903
               {  @@Bits  }
2270
               {  @@Bits  }
1904
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2271
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1905
               mov edx,offset @@Bits-4
2272
               mov edx,offset @@Bits-4
1906
               sub edx,offset @@StartCode
2273
               sub edx,offset @@StartCode
1907
               mov dword ptr [ecx+edx],eax
2274
               mov dword ptr [ecx+edx],eax
1908
             end;
2275
             end;
1909
           end else
2276
           end else
1910
           if -Source.pitch=(1 shl Source.PitchBit) then
2277
           if -Source.pitch=(1 shl Source.PitchBit) then
1911
           begin
2278
           begin
1912
             asm
2279
             asm
1913
               jmp @@EndCode
2280
               jmp @@EndCode
1914
             @@StartCode:
2281
             @@StartCode:
1915
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2282
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1916
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2283
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1917
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
2284
               shr esi,$11{}       @@YShift: // 16-Source.PitchBit
1918
               shr edx,16
2285
               shr edx,16
1919
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
2286
               and esi,$11111111{} @@MaskY:  // Source.HeightMask shl Source.PitchBit
1920
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
2287
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1921
               neg esi
2288
               neg esi
1922
               mov eax,dword ptr [$11111111+esi+edx*4]
2289
               mov eax,dword ptr [$11111111+esi+edx*4]
1923
                                   @@Bits:   // Source.Bits
2290
                                   @@Bits:   // Source.Bits
1924
             @@EndCode:
2291
             @@EndCode:
1925
               {$I DXRender.inc}
2292
               {$I DXRender.inc}
1926
               {  @@TexX  }
2293
               {  @@TexX  }
1927
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2294
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1928
               mov edx,offset @@TexX-4
2295
               mov edx,offset @@TexX-4
1929
               sub edx,offset @@StartCode
2296
               sub edx,offset @@StartCode
1930
               mov dword ptr [ecx+edx],eax
2297
               mov dword ptr [ecx+edx],eax
1931
 
2298
 
1932
               {  @@TexY  }
2299
               {  @@TexY  }
1933
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2300
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1934
               mov edx,offset @@TexY-4
2301
               mov edx,offset @@TexY-4
1935
               sub edx,offset @@StartCode
2302
               sub edx,offset @@StartCode
1936
               mov dword ptr [ecx+edx],eax
2303
               mov dword ptr [ecx+edx],eax
1937
 
2304
 
1938
               {  @@YShift  }
2305
               {  @@YShift  }
1939
               push ebx
2306
               push ebx
1940
               mov eax,16
2307
               mov eax,16
1941
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
2308
               mov ebx,Source; sub eax,[ebx + TDXR_Surface.PitchBit]
1942
               pop ebx
2309
               pop ebx
1943
               mov edx,offset @@YShift-1
2310
               mov edx,offset @@YShift-1
1944
               sub edx,offset @@StartCode
2311
               sub edx,offset @@StartCode
1945
               mov byte ptr [ecx+edx],al
2312
               mov byte ptr [ecx+edx],al
1946
 
2313
 
1947
               {  @@MaskY  }
2314
               {  @@MaskY  }
1948
               push ecx
2315
               push ecx
1949
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
2316
               mov ecx,Source; mov ecx,[ecx + TDXR_Surface.PitchBit]
1950
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2317
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1951
               shl eax,cl
2318
               shl eax,cl
1952
               pop ecx
2319
               pop ecx
1953
               mov edx,offset @@MaskY-4
2320
               mov edx,offset @@MaskY-4
1954
               sub edx,offset @@StartCode
2321
               sub edx,offset @@StartCode
1955
               mov dword ptr [ecx+edx],eax
2322
               mov dword ptr [ecx+edx],eax
1956
 
2323
 
1957
               {  @@MaskX  }
2324
               {  @@MaskX  }
1958
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2325
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
1959
               mov edx,offset @@MaskX-4
2326
               mov edx,offset @@MaskX-4
1960
               sub edx,offset @@StartCode
2327
               sub edx,offset @@StartCode
1961
               mov dword ptr [ecx+edx],eax
2328
               mov dword ptr [ecx+edx],eax
1962
 
2329
 
1963
               {  @@Bits  }
2330
               {  @@Bits  }
1964
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2331
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
1965
               mov edx,offset @@Bits-4
2332
               mov edx,offset @@Bits-4
1966
               sub edx,offset @@StartCode
2333
               sub edx,offset @@StartCode
1967
               mov dword ptr [ecx+edx],eax
2334
               mov dword ptr [ecx+edx],eax
1968
             end;
2335
             end;
1969
           end else
2336
           end else
1970
           begin
2337
           begin
1971
             asm
2338
             asm
1972
               jmp @@EndCode
2339
               jmp @@EndCode
1973
             @@StartCode:
2340
             @@StartCode:
1974
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2341
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
1975
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2342
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
1976
               shr esi,16
2343
               shr esi,16
1977
               shr edx,16
2344
               shr edx,16
1978
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
2345
               and esi,$11111111{} @@MaskY:  // Source.HeightMask
1979
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
2346
               and edx,$11111111{} @@MaskX:  // Source.WidthMask
1980
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2347
               imul esi,$11111111{}@@Pitch:  // Source.pitch
1981
               mov eax,dword ptr [esi+edx*4+$11111111]
2348
               mov eax,dword ptr [esi+edx*4+$11111111]
1982
                                   @@Bits:   // Source.Bits
2349
                                   @@Bits:   // Source.Bits
1983
             @@EndCode:
2350
             @@EndCode:
1984
               {$I DXRender.inc}
2351
               {$I DXRender.inc}
1985
               {  @@TexX  }
2352
               {  @@TexX  }
1986
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2353
               mov eax,Axis; add eax,TDXRMachine_Axis.X
1987
               mov edx,offset @@TexX-4
2354
               mov edx,offset @@TexX-4
1988
               sub edx,offset @@StartCode
2355
               sub edx,offset @@StartCode
1989
               mov dword ptr [ecx+edx],eax
2356
               mov dword ptr [ecx+edx],eax
1990
 
2357
 
1991
               {  @@TexY  }
2358
               {  @@TexY  }
1992
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2359
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
1993
               mov edx,offset @@TexY-4
2360
               mov edx,offset @@TexY-4
1994
               sub edx,offset @@StartCode
2361
               sub edx,offset @@StartCode
1995
               mov dword ptr [ecx+edx],eax
2362
               mov dword ptr [ecx+edx],eax
1996
 
2363
 
1997
               {  @@MaskY  }
2364
               {  @@MaskY  }
1998
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
2365
               mov eax,Source; mov eax,[eax + TDXR_Surface.HeightMask]
1999
               mov edx,offset @@MaskY-4
2366
               mov edx,offset @@MaskY-4
2000
               sub edx,offset @@StartCode
2367
               sub edx,offset @@StartCode
2001
               mov dword ptr [ecx+edx],eax
2368
               mov dword ptr [ecx+edx],eax
2002
 
2369
 
2003
               {  @@Pitch  }
2370
               {  @@Pitch  }
2004
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2371
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2005
               mov edx,offset @@Pitch-4
2372
               mov edx,offset @@Pitch-4
2006
               sub edx,offset @@StartCode
2373
               sub edx,offset @@StartCode
2007
               mov dword ptr [ecx+edx],eax
2374
               mov dword ptr [ecx+edx],eax
2008
 
2375
 
2009
               {  @@MaskX  }
2376
               {  @@MaskX  }
2010
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2377
               mov eax,Source; mov eax,[eax + TDXR_Surface.WidthMask]
2011
               mov edx,offset @@MaskX-4
2378
               mov edx,offset @@MaskX-4
2012
               sub edx,offset @@StartCode
2379
               sub edx,offset @@StartCode
2013
               mov dword ptr [ecx+edx],eax
2380
               mov dword ptr [ecx+edx],eax
2014
 
2381
 
2015
               {  @@Bits  }
2382
               {  @@Bits  }
2016
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2383
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2017
               mov edx,offset @@Bits-4
2384
               mov edx,offset @@Bits-4
2018
               sub edx,offset @@StartCode
2385
               sub edx,offset @@StartCode
2019
               mov dword ptr [ecx+edx],eax
2386
               mov dword ptr [ecx+edx],eax
2020
             end;
2387
             end;
2021
           end;
2388
           end;
2022
         end;
2389
         end;
2023
    end;
2390
    end;
2024
  end;
2391
  end;
2025
 
2392
 
2026
  procedure genReadSurfacePixel_DoNotClip(var Code: Pointer; const Source: TDXR_Surface; Axis: PDXRMachine_Axis);
2393
  procedure genReadSurfacePixel_DoNotClip(var Code: Pointer; const Source: TDXR_Surface; Axis: PDXRMachine_Axis);
2027
  begin
2394
  begin
2028
    case Source.BitCount of
2395
    case Source.BitCount of
2029
      1: begin
2396
      1: begin
2030
           asm
2397
           asm
2031
             jmp @@EndCode
2398
             jmp @@EndCode
2032
           @@StartCode:
2399
           @@StartCode:
2033
             mov esi,dword ptr [offset _null]{}//TexY
2400
             mov esi,dword ptr [offset _null]{}//TexY
2034
                                 @@TexY:
2401
                                 @@TexY:
2035
             shr esi,16
2402
             shr esi,16
2036
             imul esi,$11111111{}@@Pitch:   // Source.pitch
2403
             imul esi,$11111111{}@@Pitch:   // Source.pitch
2037
             mov edx,dword ptr [offset _null]{}//TexX
2404
             mov edx,dword ptr [offset _null]{}//TexX
2038
                                 @@TexX:
2405
                                 @@TexX:
2039
             shr edx,16
2406
             shr edx,16
2040
             mov ebx,edx
2407
             mov ebx,edx
2041
             shr edx,3
2408
             shr edx,3
2042
             and ebx,7
2409
             and ebx,7
2043
             movzx eax,byte ptr [esi+edx+$11111111]
2410
             movzx eax,byte ptr [esi+edx+$11111111]
2044
                                 @@Bits:   // Source.Bits
2411
                                 @@Bits:   // Source.Bits
2045
             and eax,dword ptr [offset Mask1+ebx*4]
2412
             and eax,dword ptr [offset Mask1+ebx*4]
2046
             push ecx
2413
             push ecx
2047
             mov ecx,dword ptr [offset Shift1+ebx*4]
2414
             mov ecx,dword ptr [offset Shift1+ebx*4]
2048
             shr eax,cl
2415
             shr eax,cl
2049
             pop ecx
2416
             pop ecx
2050
           @@EndCode:
2417
           @@EndCode:
2051
             {$I DXRender.inc}
2418
             {$I DXRender.inc}
2052
             {  @@TexX  }
2419
             {  @@TexX  }
2053
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2420
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2054
             mov edx,offset @@TexX-4
2421
             mov edx,offset @@TexX-4
2055
             sub edx,offset @@StartCode
2422
             sub edx,offset @@StartCode
2056
             mov dword ptr [ecx+edx],eax
2423
             mov dword ptr [ecx+edx],eax
2057
 
2424
 
2058
             {  @@TexY  }
2425
             {  @@TexY  }
2059
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2426
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2060
             mov edx,offset @@TexY-4
2427
             mov edx,offset @@TexY-4
2061
             sub edx,offset @@StartCode
2428
             sub edx,offset @@StartCode
2062
             mov dword ptr [ecx+edx],eax
2429
             mov dword ptr [ecx+edx],eax
2063
 
2430
 
2064
             {  @@Pitch  }
2431
             {  @@Pitch  }
2065
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2432
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2066
             mov edx,offset @@Pitch-4
2433
             mov edx,offset @@Pitch-4
2067
             sub edx,offset @@StartCode
2434
             sub edx,offset @@StartCode
2068
             mov dword ptr [ecx+edx],eax
2435
             mov dword ptr [ecx+edx],eax
2069
 
2436
 
2070
             {  @@Bits  }
2437
             {  @@Bits  }
2071
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2438
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2072
             mov edx,offset @@Bits-4
2439
             mov edx,offset @@Bits-4
2073
             sub edx,offset @@StartCode
2440
             sub edx,offset @@StartCode
2074
             mov dword ptr [ecx+edx],eax
2441
             mov dword ptr [ecx+edx],eax
2075
           end;
2442
           end;
2076
         end;
2443
         end;
2077
      2: begin
2444
      2: begin
2078
           asm
2445
           asm
2079
             jmp @@EndCode
2446
             jmp @@EndCode
2080
           @@StartCode:
2447
           @@StartCode:
2081
             mov esi,dword ptr [offset _null]{}//TexY
2448
             mov esi,dword ptr [offset _null]{}//TexY
2082
                                 @@TexY:
2449
                                 @@TexY:
2083
             shr esi,16
2450
             shr esi,16
2084
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2451
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2085
             mov edx,dword ptr [offset _null]{}//TexX
2452
             mov edx,dword ptr [offset _null]{}//TexX
2086
                                 @@TexX:
2453
                                 @@TexX:
2087
             shr edx,16
2454
             shr edx,16
2088
             mov ebx,edx
2455
             mov ebx,edx
2089
             shr edx,2
2456
             shr edx,2
2090
             and ebx,3
2457
             and ebx,3
2091
             movzx eax,byte ptr [esi+edx+$11111111]
2458
             movzx eax,byte ptr [esi+edx+$11111111]
2092
                                 @@Bits:   // Source.Bits
2459
                                 @@Bits:   // Source.Bits
2093
             and eax,dword ptr [offset Mask2+ebx*4]
2460
             and eax,dword ptr [offset Mask2+ebx*4]
2094
             push ecx
2461
             push ecx
2095
             mov ecx,dword ptr [offset Shift2+ebx*4]
2462
             mov ecx,dword ptr [offset Shift2+ebx*4]
2096
             shr eax,cl
2463
             shr eax,cl
2097
             pop ecx
2464
             pop ecx
2098
           @@EndCode:
2465
           @@EndCode:
2099
             {$I DXRender.inc}
2466
             {$I DXRender.inc}
2100
             {  @@TexX  }
2467
             {  @@TexX  }
2101
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2468
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2102
             mov edx,offset @@TexX-4
2469
             mov edx,offset @@TexX-4
2103
             sub edx,offset @@StartCode
2470
             sub edx,offset @@StartCode
2104
             mov dword ptr [ecx+edx],eax
2471
             mov dword ptr [ecx+edx],eax
2105
 
2472
 
2106
             {  @@TexY  }
2473
             {  @@TexY  }
2107
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2474
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2108
             mov edx,offset @@TexY-4
2475
             mov edx,offset @@TexY-4
2109
             sub edx,offset @@StartCode
2476
             sub edx,offset @@StartCode
2110
             mov dword ptr [ecx+edx],eax
2477
             mov dword ptr [ecx+edx],eax
2111
 
2478
 
2112
             {  @@Pitch  }
2479
             {  @@Pitch  }
2113
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2480
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2114
             mov edx,offset @@Pitch-4
2481
             mov edx,offset @@Pitch-4
2115
             sub edx,offset @@StartCode
2482
             sub edx,offset @@StartCode
2116
             mov dword ptr [ecx+edx],eax
2483
             mov dword ptr [ecx+edx],eax
2117
 
2484
 
2118
             {  @@Bits  }
2485
             {  @@Bits  }
2119
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2486
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2120
             mov edx,offset @@Bits-4
2487
             mov edx,offset @@Bits-4
2121
             sub edx,offset @@StartCode
2488
             sub edx,offset @@StartCode
2122
             mov dword ptr [ecx+edx],eax
2489
             mov dword ptr [ecx+edx],eax
2123
           end;
2490
           end;
2124
         end;
2491
         end;
2125
      4: begin
2492
      4: begin
2126
           asm
2493
           asm
2127
             jmp @@EndCode
2494
             jmp @@EndCode
2128
           @@StartCode:
2495
           @@StartCode:
2129
             mov esi,dword ptr [offset _null]{}//TexY
2496
             mov esi,dword ptr [offset _null]{}//TexY
2130
                                 @@TexY:
2497
                                 @@TexY:
2131
             shr esi,16
2498
             shr esi,16
2132
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2499
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2133
             mov edx,dword ptr [offset _null]{}//TexX
2500
             mov edx,dword ptr [offset _null]{}//TexX
2134
                                 @@TexX:
2501
                                 @@TexX:
2135
             shr edx,16
2502
             shr edx,16
2136
             mov ebx,edx
2503
             mov ebx,edx
2137
             shr edx,1
2504
             shr edx,1
2138
             and ebx,1
2505
             and ebx,1
2139
             movzx eax,byte ptr [esi+edx+$11111111]
2506
             movzx eax,byte ptr [esi+edx+$11111111]
2140
                                 @@Bits:   // Source.Bits
2507
                                 @@Bits:   // Source.Bits
2141
             and eax,dword ptr [offset Mask4+ebx*4]
2508
             and eax,dword ptr [offset Mask4+ebx*4]
2142
             push ecx
2509
             push ecx
2143
             mov ecx,dword ptr [offset Shift4+ebx*4]
2510
             mov ecx,dword ptr [offset Shift4+ebx*4]
2144
             shr eax,cl
2511
             shr eax,cl
2145
             pop ecx
2512
             pop ecx
2146
           @@EndCode:
2513
           @@EndCode:
2147
             {$I DXRender.inc}
2514
             {$I DXRender.inc}
2148
             {  @@TexX  }
2515
             {  @@TexX  }
2149
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2516
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2150
             mov edx,offset @@TexX-4
2517
             mov edx,offset @@TexX-4
2151
             sub edx,offset @@StartCode
2518
             sub edx,offset @@StartCode
2152
             mov dword ptr [ecx+edx],eax
2519
             mov dword ptr [ecx+edx],eax
2153
 
2520
 
2154
             {  @@TexY  }
2521
             {  @@TexY  }
2155
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2522
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2156
             mov edx,offset @@TexY-4
2523
             mov edx,offset @@TexY-4
2157
             sub edx,offset @@StartCode
2524
             sub edx,offset @@StartCode
2158
             mov dword ptr [ecx+edx],eax
2525
             mov dword ptr [ecx+edx],eax
2159
 
2526
 
2160
             {  @@Pitch  }
2527
             {  @@Pitch  }
2161
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2528
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2162
             mov edx,offset @@Pitch-4
2529
             mov edx,offset @@Pitch-4
2163
             sub edx,offset @@StartCode
2530
             sub edx,offset @@StartCode
2164
             mov dword ptr [ecx+edx],eax
2531
             mov dword ptr [ecx+edx],eax
2165
 
2532
 
2166
             {  @@Bits  }
2533
             {  @@Bits  }
2167
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2534
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2168
             mov edx,offset @@Bits-4
2535
             mov edx,offset @@Bits-4
2169
             sub edx,offset @@StartCode
2536
             sub edx,offset @@StartCode
2170
             mov dword ptr [ecx+edx],eax
2537
             mov dword ptr [ecx+edx],eax
2171
           end;
2538
           end;
2172
         end;
2539
         end;
2173
      8: begin
2540
      8: begin
2174
           if Source.pitch=(1 shl Source.PitchBit) then
2541
           if Source.pitch=(1 shl Source.PitchBit) then
2175
           begin
2542
           begin
2176
             asm
2543
             asm
2177
               jmp @@EndCode
2544
               jmp @@EndCode
2178
             @@StartCode:
2545
             @@StartCode:
2179
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2546
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2180
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2547
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2181
               shr esi,16
2548
               shr esi,16
2182
               shr edx,16
2549
               shr edx,16
2183
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2550
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2184
               movzx eax,byte ptr [$11111111+esi+edx]
2551
               movzx eax,byte ptr [$11111111+esi+edx]
2185
                                   @@Bits:     // Source.Bits
2552
                                   @@Bits:     // Source.Bits
2186
             @@EndCode:
2553
             @@EndCode:
2187
               {$I DXRender.inc}
2554
               {$I DXRender.inc}
2188
               {  @@TexX  }
2555
               {  @@TexX  }
2189
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2556
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2190
               mov edx,offset @@TexX-4
2557
               mov edx,offset @@TexX-4
2191
               sub edx,offset @@StartCode
2558
               sub edx,offset @@StartCode
2192
               mov dword ptr [ecx+edx],eax
2559
               mov dword ptr [ecx+edx],eax
2193
 
2560
 
2194
               {  @@TexY  }
2561
               {  @@TexY  }
2195
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2562
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2196
               mov edx,offset @@TexY-4
2563
               mov edx,offset @@TexY-4
2197
               sub edx,offset @@StartCode
2564
               sub edx,offset @@StartCode
2198
               mov dword ptr [ecx+edx],eax
2565
               mov dword ptr [ecx+edx],eax
2199
 
2566
 
2200
               {  @@PitchBit  }
2567
               {  @@PitchBit  }
2201
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2568
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2202
               mov edx,offset @@PitchBit-1
2569
               mov edx,offset @@PitchBit-1
2203
               sub edx,offset @@StartCode
2570
               sub edx,offset @@StartCode
2204
               mov byte ptr [ecx+edx],al
2571
               mov byte ptr [ecx+edx],al
2205
 
2572
 
2206
               {  @@Bits  }
2573
               {  @@Bits  }
2207
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2574
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2208
               mov edx,offset @@Bits-4
2575
               mov edx,offset @@Bits-4
2209
               sub edx,offset @@StartCode
2576
               sub edx,offset @@StartCode
2210
               mov dword ptr [ecx+edx],eax
2577
               mov dword ptr [ecx+edx],eax
2211
             end;
2578
             end;
2212
           end else
2579
           end else
2213
           if -Source.pitch=(1 shl Source.PitchBit) then
2580
           if -Source.pitch=(1 shl Source.PitchBit) then
2214
           begin
2581
           begin
2215
             asm
2582
             asm
2216
               jmp @@EndCode
2583
               jmp @@EndCode
2217
             @@StartCode:
2584
             @@StartCode:
2218
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2585
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2219
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2586
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2220
               shr esi,16
2587
               shr esi,16
2221
               shr edx,16
2588
               shr edx,16
2222
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2589
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2223
               neg esi
2590
               neg esi
2224
               movzx eax,byte ptr [$11111111+esi+edx]
2591
               movzx eax,byte ptr [$11111111+esi+edx]
2225
                                   @@Bits:     // Source.Bits
2592
                                   @@Bits:     // Source.Bits
2226
             @@EndCode:
2593
             @@EndCode:
2227
               {$I DXRender.inc}
2594
               {$I DXRender.inc}
2228
               {  @@TexX  }
2595
               {  @@TexX  }
2229
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2596
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2230
               mov edx,offset @@TexX-4
2597
               mov edx,offset @@TexX-4
2231
               sub edx,offset @@StartCode
2598
               sub edx,offset @@StartCode
2232
               mov dword ptr [ecx+edx],eax
2599
               mov dword ptr [ecx+edx],eax
2233
 
2600
 
2234
               {  @@TexY  }
2601
               {  @@TexY  }
2235
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2602
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2236
               mov edx,offset @@TexY-4
2603
               mov edx,offset @@TexY-4
2237
               sub edx,offset @@StartCode
2604
               sub edx,offset @@StartCode
2238
               mov dword ptr [ecx+edx],eax
2605
               mov dword ptr [ecx+edx],eax
2239
 
2606
 
2240
               {  @@PitchBit  }
2607
               {  @@PitchBit  }
2241
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2608
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2242
               mov edx,offset @@PitchBit-1
2609
               mov edx,offset @@PitchBit-1
2243
               sub edx,offset @@StartCode
2610
               sub edx,offset @@StartCode
2244
               mov byte ptr [ecx+edx],al
2611
               mov byte ptr [ecx+edx],al
2245
 
2612
 
2246
               {  @@Bits  }
2613
               {  @@Bits  }
2247
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2614
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2248
               mov edx,offset @@Bits-4
2615
               mov edx,offset @@Bits-4
2249
               sub edx,offset @@StartCode
2616
               sub edx,offset @@StartCode
2250
               mov dword ptr [ecx+edx],eax
2617
               mov dword ptr [ecx+edx],eax
2251
             end;
2618
             end;
2252
           end else
2619
           end else
2253
           begin
2620
           begin
2254
             asm
2621
             asm
2255
               jmp @@EndCode
2622
               jmp @@EndCode
2256
             @@StartCode:
2623
             @@StartCode:
2257
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2624
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2258
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2625
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2259
               shr esi,16
2626
               shr esi,16
2260
               shr edx,16
2627
               shr edx,16
2261
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2628
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2262
               movzx eax,byte ptr [esi+edx+$11111111]
2629
               movzx eax,byte ptr [esi+edx+$11111111]
2263
                                   @@Bits:   // Source.Bits
2630
                                   @@Bits:   // Source.Bits
2264
             @@EndCode:
2631
             @@EndCode:
2265
               {$I DXRender.inc}
2632
               {$I DXRender.inc}
2266
               {  @@TexX  }
2633
               {  @@TexX  }
2267
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2634
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2268
               mov edx,offset @@TexX-4
2635
               mov edx,offset @@TexX-4
2269
               sub edx,offset @@StartCode
2636
               sub edx,offset @@StartCode
2270
               mov dword ptr [ecx+edx],eax
2637
               mov dword ptr [ecx+edx],eax
2271
 
2638
 
2272
               {  @@TexY  }
2639
               {  @@TexY  }
2273
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2640
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2274
               mov edx,offset @@TexY-4
2641
               mov edx,offset @@TexY-4
2275
               sub edx,offset @@StartCode
2642
               sub edx,offset @@StartCode
2276
               mov dword ptr [ecx+edx],eax
2643
               mov dword ptr [ecx+edx],eax
2277
 
2644
 
2278
               {  @@Pitch  }
2645
               {  @@Pitch  }
2279
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2646
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2280
               mov edx,offset @@Pitch-4
2647
               mov edx,offset @@Pitch-4
2281
               sub edx,offset @@StartCode
2648
               sub edx,offset @@StartCode
2282
               mov dword ptr [ecx+edx],eax
2649
               mov dword ptr [ecx+edx],eax
2283
 
2650
 
2284
               {  @@Bits  }
2651
               {  @@Bits  }
2285
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2652
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2286
               mov edx,offset @@Bits-4
2653
               mov edx,offset @@Bits-4
2287
               sub edx,offset @@StartCode
2654
               sub edx,offset @@StartCode
2288
               mov dword ptr [ecx+edx],eax
2655
               mov dword ptr [ecx+edx],eax
2289
             end;
2656
             end;
2290
           end;
2657
           end;
2291
         end;
2658
         end;
2292
     16: begin
2659
     16: begin
2293
           if Source.pitch=(1 shl Source.PitchBit) then
2660
           if Source.pitch=(1 shl Source.PitchBit) then
2294
           begin
2661
           begin
2295
             asm
2662
             asm
2296
               jmp @@EndCode
2663
               jmp @@EndCode
2297
             @@StartCode:
2664
             @@StartCode:
2298
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2665
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2299
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2666
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2300
               shr esi,16
2667
               shr esi,16
2301
               shr edx,16
2668
               shr edx,16
2302
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2669
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2303
               movzx eax,word ptr [$11111111+esi+edx*2]
2670
               movzx eax,word ptr [$11111111+esi+edx*2]
2304
                                   @@Bits:     // Source.Bits
2671
                                   @@Bits:     // Source.Bits
2305
             @@EndCode:
2672
             @@EndCode:
2306
               {$I DXRender.inc}
2673
               {$I DXRender.inc}
2307
               {  @@TexX  }
2674
               {  @@TexX  }
2308
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2675
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2309
               mov edx,offset @@TexX-4
2676
               mov edx,offset @@TexX-4
2310
               sub edx,offset @@StartCode
2677
               sub edx,offset @@StartCode
2311
               mov dword ptr [ecx+edx],eax
2678
               mov dword ptr [ecx+edx],eax
2312
 
2679
 
2313
               {  @@TexY  }
2680
               {  @@TexY  }
2314
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2681
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2315
               mov edx,offset @@TexY-4
2682
               mov edx,offset @@TexY-4
2316
               sub edx,offset @@StartCode
2683
               sub edx,offset @@StartCode
2317
               mov dword ptr [ecx+edx],eax
2684
               mov dword ptr [ecx+edx],eax
2318
 
2685
 
2319
               {  @@PitchBit  }
2686
               {  @@PitchBit  }
2320
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2687
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2321
               mov edx,offset @@PitchBit-1
2688
               mov edx,offset @@PitchBit-1
2322
               sub edx,offset @@StartCode
2689
               sub edx,offset @@StartCode
2323
               mov byte ptr [ecx+edx],al
2690
               mov byte ptr [ecx+edx],al
2324
 
2691
 
2325
               {  @@Bits  }
2692
               {  @@Bits  }
2326
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2693
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2327
               mov edx,offset @@Bits-4
2694
               mov edx,offset @@Bits-4
2328
               sub edx,offset @@StartCode
2695
               sub edx,offset @@StartCode
2329
               mov dword ptr [ecx+edx],eax
2696
               mov dword ptr [ecx+edx],eax
2330
             end;
2697
             end;
2331
           end else
2698
           end else
2332
           if -Source.pitch=(1 shl Source.PitchBit) then
2699
           if -Source.pitch=(1 shl Source.PitchBit) then
2333
           begin
2700
           begin
2334
             asm
2701
             asm
2335
               jmp @@EndCode
2702
               jmp @@EndCode
2336
             @@StartCode:
2703
             @@StartCode:
2337
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2704
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2338
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2705
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2339
               shr esi,16
2706
               shr esi,16
2340
               shr edx,16
2707
               shr edx,16
2341
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2708
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2342
               neg esi
2709
               neg esi
2343
               movzx eax,word ptr [$11111111+esi+edx*2]
2710
               movzx eax,word ptr [$11111111+esi+edx*2]
2344
                                   @@Bits:     // Source.Bits
2711
                                   @@Bits:     // Source.Bits
2345
             @@EndCode:
2712
             @@EndCode:
2346
               {$I DXRender.inc}
2713
               {$I DXRender.inc}
2347
               {  @@TexX  }
2714
               {  @@TexX  }
2348
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2715
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2349
               mov edx,offset @@TexX-4
2716
               mov edx,offset @@TexX-4
2350
               sub edx,offset @@StartCode
2717
               sub edx,offset @@StartCode
2351
               mov dword ptr [ecx+edx],eax
2718
               mov dword ptr [ecx+edx],eax
2352
 
2719
 
2353
               {  @@TexY  }
2720
               {  @@TexY  }
2354
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2721
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2355
               mov edx,offset @@TexY-4
2722
               mov edx,offset @@TexY-4
2356
               sub edx,offset @@StartCode
2723
               sub edx,offset @@StartCode
2357
               mov dword ptr [ecx+edx],eax
2724
               mov dword ptr [ecx+edx],eax
2358
 
2725
 
2359
               {  @@PitchBit  }
2726
               {  @@PitchBit  }
2360
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2727
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2361
               mov edx,offset @@PitchBit-1
2728
               mov edx,offset @@PitchBit-1
2362
               sub edx,offset @@StartCode
2729
               sub edx,offset @@StartCode
2363
               mov byte ptr [ecx+edx],al
2730
               mov byte ptr [ecx+edx],al
2364
 
2731
 
2365
               {  @@Bits  }
2732
               {  @@Bits  }
2366
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2733
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2367
               mov edx,offset @@Bits-4
2734
               mov edx,offset @@Bits-4
2368
               sub edx,offset @@StartCode
2735
               sub edx,offset @@StartCode
2369
               mov dword ptr [ecx+edx],eax
2736
               mov dword ptr [ecx+edx],eax
2370
             end;
2737
             end;
2371
           end else
2738
           end else
2372
           begin
2739
           begin
2373
             asm
2740
             asm
2374
               jmp @@EndCode
2741
               jmp @@EndCode
2375
             @@StartCode:
2742
             @@StartCode:
2376
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2743
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2377
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2744
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2378
               shr esi,16
2745
               shr esi,16
2379
               shr edx,16
2746
               shr edx,16
2380
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2747
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2381
               movzx eax,word ptr [esi+edx*2+$11111111]
2748
               movzx eax,word ptr [esi+edx*2+$11111111]
2382
                                   @@Bits:   // Source.Bits
2749
                                   @@Bits:   // Source.Bits
2383
             @@EndCode:
2750
             @@EndCode:
2384
               {$I DXRender.inc}
2751
               {$I DXRender.inc}
2385
               {  @@TexX  }
2752
               {  @@TexX  }
2386
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2753
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2387
               mov edx,offset @@TexX-4
2754
               mov edx,offset @@TexX-4
2388
               sub edx,offset @@StartCode
2755
               sub edx,offset @@StartCode
2389
               mov dword ptr [ecx+edx],eax
2756
               mov dword ptr [ecx+edx],eax
2390
 
2757
 
2391
               {  @@TexY  }
2758
               {  @@TexY  }
2392
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2759
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2393
               mov edx,offset @@TexY-4
2760
               mov edx,offset @@TexY-4
2394
               sub edx,offset @@StartCode
2761
               sub edx,offset @@StartCode
2395
               mov dword ptr [ecx+edx],eax
2762
               mov dword ptr [ecx+edx],eax
2396
 
2763
 
2397
               {  @@Pitch  }
2764
               {  @@Pitch  }
2398
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2765
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2399
               mov edx,offset @@Pitch-4
2766
               mov edx,offset @@Pitch-4
2400
               sub edx,offset @@StartCode
2767
               sub edx,offset @@StartCode
2401
               mov dword ptr [ecx+edx],eax
2768
               mov dword ptr [ecx+edx],eax
2402
 
2769
 
2403
               {  @@Bits  }
2770
               {  @@Bits  }
2404
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2771
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2405
               mov edx,offset @@Bits-4
2772
               mov edx,offset @@Bits-4
2406
               sub edx,offset @@StartCode
2773
               sub edx,offset @@StartCode
2407
               mov dword ptr [ecx+edx],eax
2774
               mov dword ptr [ecx+edx],eax
2408
             end;
2775
             end;
2409
           end;
2776
           end;
2410
         end;
2777
         end;
2411
     24: begin
2778
     24: begin
2412
           asm
2779
           asm
2413
             jmp @@EndCode
2780
             jmp @@EndCode
2414
           @@StartCode:
2781
           @@StartCode:
2415
             mov esi,dword ptr [offset _null]{}//TexY
2782
             mov esi,dword ptr [offset _null]{}//TexY
2416
                                 @@TexY:
2783
                                 @@TexY:
2417
             mov edx,dword ptr [offset _null]{}//TexX
2784
             mov edx,dword ptr [offset _null]{}//TexX
2418
                                 @@TexX:
2785
                                 @@TexX:
2419
             shr esi,16
2786
             shr esi,16
2420
             shr edx,16
2787
             shr edx,16
2421
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2788
             imul esi,$11111111{}@@Pitch:  // Source.pitch
2422
             lea edx,[edx+edx*2+$11111111] // Source.Bits
2789
             lea edx,[edx+edx*2+$11111111] // Source.Bits
2423
                                 @@Bits:
2790
                                 @@Bits:
2424
             movzx eax,byte ptr [esi+edx+2]
2791
             movzx eax,byte ptr [esi+edx+2]
2425
             shl eax,16
2792
             shl eax,16
2426
             mov ax,word ptr [esi+edx]
2793
             mov ax,word ptr [esi+edx]
2427
           @@EndCode:
2794
           @@EndCode:
2428
             {$I DXRender.inc}
2795
             {$I DXRender.inc}
2429
             {  @@TexX  }
2796
             {  @@TexX  }
2430
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2797
             mov eax,Axis; add eax,TDXRMachine_Axis.X
2431
             mov edx,offset @@TexX-4
2798
             mov edx,offset @@TexX-4
2432
             sub edx,offset @@StartCode
2799
             sub edx,offset @@StartCode
2433
             mov dword ptr [ecx+edx],eax
2800
             mov dword ptr [ecx+edx],eax
2434
 
2801
 
2435
             {  @@TexY  }
2802
             {  @@TexY  }
2436
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2803
             mov eax,Axis; add eax,TDXRMachine_Axis.Y
2437
             mov edx,offset @@TexY-4
2804
             mov edx,offset @@TexY-4
2438
             sub edx,offset @@StartCode
2805
             sub edx,offset @@StartCode
2439
             mov dword ptr [ecx+edx],eax
2806
             mov dword ptr [ecx+edx],eax
2440
 
2807
 
2441
             {  @@Pitch  }
2808
             {  @@Pitch  }
2442
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2809
             mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2443
             mov edx,offset @@Pitch-4
2810
             mov edx,offset @@Pitch-4
2444
             sub edx,offset @@StartCode
2811
             sub edx,offset @@StartCode
2445
             mov dword ptr [ecx+edx],eax
2812
             mov dword ptr [ecx+edx],eax
2446
 
2813
 
2447
             {  @@Bits  }
2814
             {  @@Bits  }
2448
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2815
             mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2449
             mov edx,offset @@Bits-4
2816
             mov edx,offset @@Bits-4
2450
             sub edx,offset @@StartCode
2817
             sub edx,offset @@StartCode
2451
             mov dword ptr [ecx+edx],eax
2818
             mov dword ptr [ecx+edx],eax
2452
           end;
2819
           end;
2453
         end;
2820
         end;
2454
     32: begin
2821
     32: begin
2455
           if Source.pitch=(1 shl Source.PitchBit) then
2822
           if Source.pitch=(1 shl Source.PitchBit) then
2456
           begin
2823
           begin
2457
             asm
2824
             asm
2458
               jmp @@EndCode
2825
               jmp @@EndCode
2459
             @@StartCode:
2826
             @@StartCode:
2460
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2827
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2461
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2828
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2462
               shr esi,16
2829
               shr esi,16
2463
               shr edx,16
2830
               shr edx,16
2464
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2831
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2465
               mov eax,dword ptr [$11111111+esi+edx*4]
2832
               mov eax,dword ptr [$11111111+esi+edx*4]
2466
                                   @@Bits:     // Source.Bits
2833
                                   @@Bits:     // Source.Bits
2467
             @@EndCode:
2834
             @@EndCode:
2468
               {$I DXRender.inc}
2835
               {$I DXRender.inc}
2469
               {  @@TexX  }
2836
               {  @@TexX  }
2470
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2837
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2471
               mov edx,offset @@TexX-4
2838
               mov edx,offset @@TexX-4
2472
               sub edx,offset @@StartCode
2839
               sub edx,offset @@StartCode
2473
               mov dword ptr [ecx+edx],eax
2840
               mov dword ptr [ecx+edx],eax
2474
 
2841
 
2475
               {  @@TexY  }
2842
               {  @@TexY  }
2476
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2843
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2477
               mov edx,offset @@TexY-4
2844
               mov edx,offset @@TexY-4
2478
               sub edx,offset @@StartCode
2845
               sub edx,offset @@StartCode
2479
               mov dword ptr [ecx+edx],eax
2846
               mov dword ptr [ecx+edx],eax
2480
 
2847
 
2481
               {  @@PitchBit  }
2848
               {  @@PitchBit  }
2482
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2849
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2483
               mov edx,offset @@PitchBit-1
2850
               mov edx,offset @@PitchBit-1
2484
               sub edx,offset @@StartCode
2851
               sub edx,offset @@StartCode
2485
               mov byte ptr [ecx+edx],al
2852
               mov byte ptr [ecx+edx],al
2486
 
2853
 
2487
               {  @@Bits  }
2854
               {  @@Bits  }
2488
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2855
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2489
               mov edx,offset @@Bits-4
2856
               mov edx,offset @@Bits-4
2490
               sub edx,offset @@StartCode
2857
               sub edx,offset @@StartCode
2491
               mov dword ptr [ecx+edx],eax
2858
               mov dword ptr [ecx+edx],eax
2492
             end;
2859
             end;
2493
           end else
2860
           end else
2494
           if -Source.pitch=(1 shl Source.PitchBit) then
2861
           if -Source.pitch=(1 shl Source.PitchBit) then
2495
           begin
2862
           begin
2496
             asm
2863
             asm
2497
               jmp @@EndCode
2864
               jmp @@EndCode
2498
             @@StartCode:
2865
             @@StartCode:
2499
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2866
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2500
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2867
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2501
               shr esi,16
2868
               shr esi,16
2502
               shr edx,16
2869
               shr edx,16
2503
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2870
               shl esi,$11{}       @@PitchBit: // Source.PitchBit
2504
               neg esi
2871
               neg esi
2505
               mov eax,dword ptr [$11111111+esi+edx*4]
2872
               mov eax,dword ptr [$11111111+esi+edx*4]
2506
                                   @@Bits:     // Source.Bits
2873
                                   @@Bits:     // Source.Bits
2507
             @@EndCode:
2874
             @@EndCode:
2508
               {$I DXRender.inc}
2875
               {$I DXRender.inc}
2509
               {  @@TexX  }
2876
               {  @@TexX  }
2510
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2877
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2511
               mov edx,offset @@TexX-4
2878
               mov edx,offset @@TexX-4
2512
               sub edx,offset @@StartCode
2879
               sub edx,offset @@StartCode
2513
               mov dword ptr [ecx+edx],eax
2880
               mov dword ptr [ecx+edx],eax
2514
 
2881
 
2515
               {  @@TexY  }
2882
               {  @@TexY  }
2516
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2883
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2517
               mov edx,offset @@TexY-4
2884
               mov edx,offset @@TexY-4
2518
               sub edx,offset @@StartCode
2885
               sub edx,offset @@StartCode
2519
               mov dword ptr [ecx+edx],eax
2886
               mov dword ptr [ecx+edx],eax
2520
 
2887
 
2521
               {  @@PitchBit  }
2888
               {  @@PitchBit  }
2522
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2889
               mov eax,Source; mov eax,[eax + TDXR_Surface.PitchBit]
2523
               mov edx,offset @@PitchBit-1
2890
               mov edx,offset @@PitchBit-1
2524
               sub edx,offset @@StartCode
2891
               sub edx,offset @@StartCode
2525
               mov byte ptr [ecx+edx],al
2892
               mov byte ptr [ecx+edx],al
2526
 
2893
 
2527
               {  @@Bits  }
2894
               {  @@Bits  }
2528
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2895
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2529
               mov edx,offset @@Bits-4
2896
               mov edx,offset @@Bits-4
2530
               sub edx,offset @@StartCode
2897
               sub edx,offset @@StartCode
2531
               mov dword ptr [ecx+edx],eax
2898
               mov dword ptr [ecx+edx],eax
2532
             end;
2899
             end;
2533
           end else
2900
           end else
2534
           begin
2901
           begin
2535
             asm
2902
             asm
2536
               jmp @@EndCode
2903
               jmp @@EndCode
2537
             @@StartCode:
2904
             @@StartCode:
2538
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2905
               mov esi,dword ptr [offset _null]{}@@TexY: //TexY
2539
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2906
               mov edx,dword ptr [offset _null]{}@@TexX: //TexX
2540
               shr esi,16
2907
               shr esi,16
2541
               shr edx,16
2908
               shr edx,16
2542
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2909
               imul esi,$11111111{}@@Pitch:  // Source.pitch
2543
               mov eax,dword ptr [esi+edx*4+$11111111]
2910
               mov eax,dword ptr [esi+edx*4+$11111111]
2544
                                   @@Bits:   // Source.Bits
2911
                                   @@Bits:   // Source.Bits
2545
             @@EndCode:
2912
             @@EndCode:
2546
               {$I DXRender.inc}
2913
               {$I DXRender.inc}
2547
               {  @@TexX  }
2914
               {  @@TexX  }
2548
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2915
               mov eax,Axis; add eax,TDXRMachine_Axis.X
2549
               mov edx,offset @@TexX-4
2916
               mov edx,offset @@TexX-4
2550
               sub edx,offset @@StartCode
2917
               sub edx,offset @@StartCode
2551
               mov dword ptr [ecx+edx],eax
2918
               mov dword ptr [ecx+edx],eax
2552
 
2919
 
2553
               {  @@TexY  }
2920
               {  @@TexY  }
2554
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2921
               mov eax,Axis; add eax,TDXRMachine_Axis.Y
2555
               mov edx,offset @@TexY-4
2922
               mov edx,offset @@TexY-4
2556
               sub edx,offset @@StartCode
2923
               sub edx,offset @@StartCode
2557
               mov dword ptr [ecx+edx],eax
2924
               mov dword ptr [ecx+edx],eax
2558
 
2925
 
2559
               {  @@Pitch  }
2926
               {  @@Pitch  }
2560
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2927
               mov eax,Source; mov eax,[eax + TDXR_Surface.Pitch]
2561
               mov edx,offset @@Pitch-4
2928
               mov edx,offset @@Pitch-4
2562
               sub edx,offset @@StartCode
2929
               sub edx,offset @@StartCode
2563
               mov dword ptr [ecx+edx],eax
2930
               mov dword ptr [ecx+edx],eax
2564
 
2931
 
2565
               {  @@Bits  }
2932
               {  @@Bits  }
2566
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2933
               mov eax,Source; mov eax,[eax + TDXR_Surface.Bits]
2567
               mov edx,offset @@Bits-4
2934
               mov edx,offset @@Bits-4
2568
               sub edx,offset @@StartCode
2935
               sub edx,offset @@StartCode
2569
               mov dword ptr [ecx+edx],eax
2936
               mov dword ptr [ecx+edx],eax
2570
             end;
2937
             end;
2571
           end;
2938
           end;
2572
         end;
2939
         end;
2573
    end;
2940
    end;
2574
  end;
2941
  end;
2575
 
2942
 
2576
  procedure genReadSurfacePixel(var Code: Pointer; const Texture: TDXRMachine_Reg_Texture; Axis: PDXRMachine_Axis);
2943
  procedure genReadSurfacePixel(var Code: Pointer; const Texture: TDXRMachine_Reg_Texture; Axis: PDXRMachine_Axis);
2577
  begin
2944
  begin
2578
    case Texture.TextureAddress of
2945
    case Texture.TextureAddress of
2579
      DXR_TEXTUREADDRESS_TILE     : genReadSurfacePixel_Tile(Code, Texture.Surface^, Axis);
2946
      DXR_TEXTUREADDRESS_TILE     : genReadSurfacePixel_Tile(Code, Texture.Surface^, Axis);
2580
      DXR_TEXTUREADDRESS_DONOTCLIP: genReadSurfacePixel_DoNotClip(Code, Texture.Surface^, Axis);
2947
      DXR_TEXTUREADDRESS_DONOTCLIP: genReadSurfacePixel_DoNotClip(Code, Texture.Surface^, Axis);
2581
    end;
2948
    end;
2582
  end;
2949
  end;
2583
 
2950
 
2584
  procedure genDecodeColor(var Code: Pointer; const Surface: TDXR_Surface; Dest: PDXRMachine_Color;
2951
  procedure genDecodeColor(var Code: Pointer; const Surface: TDXR_Surface; Dest: PDXRMachine_Color;
2585
    EnableChannels: TDXRColorChannels; DefaultColor: TDXRMachine_Color);
2952
    EnableChannels: TDXRColorChannels; DefaultColor: TDXRMachine_Color);
2586
  var
2953
  var
2587
    dcR, dcG, dcB, dcA: Word;
2954
    dcR, dcG, dcB, dcA: Word;
2588
  begin
2955
  begin
2589
    if EnableChannels=[] then Exit;
2956
    if EnableChannels=[] then Exit;
2590
 
2957
 
2591
    dcR := DefaultColor.R;
2958
    dcR := DefaultColor.R;
2592
    dcG := DefaultColor.G;
2959
    dcG := DefaultColor.G;
2593
    dcB := DefaultColor.B;
2960
    dcB := DefaultColor.B;
2594
    dcA := DefaultColor.A;
2961
    dcA := DefaultColor.A;
2595
 
2962
 
2596
    if Surface.ColorType=DXR_COLORTYPE_INDEXED then
2963
    if Surface.ColorType=DXR_COLORTYPE_INDEXED then
2597
    begin
2964
    begin
2598
      {  Index Channel  }
2965
      {  Index Channel  }
2599
      if EnableChannels*[chRed, chGreen, chBlue]<>[] then
2966
      if EnableChannels*[chRed, chGreen, chBlue]<>[] then
2600
      begin
2967
      begin
2601
        if Surface.idx_index.Mask<>0 then
2968
        if Surface.idx_index.Mask<>0 then
2602
        begin
2969
        begin
2603
          if (Surface.idx_index.rshift=0) and (Surface.idx_index.lshift=0) and
2970
          if (Surface.idx_index.rshift=0) and (Surface.idx_index.lshift=0) and
2604
            (Surface.idx_index.Mask=DWORD((1 shl Surface.BitCount)-1)) and (Surface.idx_alpha.Mask=0) then
2971
            (Surface.idx_index.Mask=DWORD((1 shl Surface.BitCount)-1)) and (Surface.idx_alpha.Mask=0) then
2605
          begin
2972
          begin
2606
            asm
2973
            asm
2607
              jmp @@EndCode
2974
              jmp @@EndCode
2608
            @@StartCode:
2975
            @@StartCode:
2609
              {  Index channel  }
2976
              {  Index channel  }
2610
              mov edx,dword ptr [eax*4+$11111111]
2977
              mov edx,dword ptr [eax*4+$11111111]
2611
                                  {}@@idx_indexPal:// @Surface.idx_palette
2978
                                  {}@@idx_indexPal:// @Surface.idx_palette
2612
 
2979
 
2613
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
2980
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
2614
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
2981
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
2615
              bswap edx
2982
              bswap edx
2616
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
2983
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
2617
            @@EndCode:
2984
            @@EndCode:
2618
              {$I DXRender.inc}
2985
              {$I DXRender.inc}
2619
              {  @@idx_indexPal  }
2986
              {  @@idx_indexPal  }
2620
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
2987
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
2621
              mov edx,offset @@idx_indexPal-4
2988
              mov edx,offset @@idx_indexPal-4
2622
              sub edx,offset @@StartCode
2989
              sub edx,offset @@StartCode
2623
              mov dword ptr [ecx+edx],eax
2990
              mov dword ptr [ecx+edx],eax
2624
 
2991
 
2625
              {  @@DestR  }
2992
              {  @@DestR  }
2626
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
2993
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
2627
              mov edx,offset @@DestR-4
2994
              mov edx,offset @@DestR-4
2628
              sub edx,offset @@StartCode
2995
              sub edx,offset @@StartCode
2629
              mov dword ptr [ecx+edx],eax
2996
              mov dword ptr [ecx+edx],eax
2630
 
2997
 
2631
              {  @@DestG  }
2998
              {  @@DestG  }
2632
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
2999
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
2633
              mov edx,offset @@DestG-4
3000
              mov edx,offset @@DestG-4
2634
              sub edx,offset @@StartCode
3001
              sub edx,offset @@StartCode
2635
              mov dword ptr [ecx+edx],eax
3002
              mov dword ptr [ecx+edx],eax
2636
 
3003
 
2637
              {  @@DestB  }
3004
              {  @@DestB  }
2638
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
3005
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
2639
              mov edx,offset @@DestB-4
3006
              mov edx,offset @@DestB-4
2640
              sub edx,offset @@StartCode
3007
              sub edx,offset @@StartCode
2641
              mov dword ptr [ecx+edx],eax
3008
              mov dword ptr [ecx+edx],eax
2642
            end;
3009
            end;
2643
          end else
3010
          end else
2644
          if Surface.idx_index.rshift<>0 then
3011
          if Surface.idx_index.rshift<>0 then
2645
          begin
3012
          begin
2646
            asm
3013
            asm
2647
              jmp @@EndCode
3014
              jmp @@EndCode
2648
            @@StartCode:
3015
            @@StartCode:
2649
              {  Index channel  }
3016
              {  Index channel  }
2650
              mov edx,eax
3017
              mov edx,eax
2651
              and edx,$11111111{}@@idx_indexMask:   // Surface.idx_index.Mask
3018
              and edx,$11111111{}@@idx_indexMask:   // Surface.idx_index.Mask
2652
              shr edx,$11      {}@@idx_indexRShift: // Surface.idx_index.rshift
3019
              shr edx,$11      {}@@idx_indexRShift: // Surface.idx_index.rshift
2653
              mov edx,dword ptr [edx*4+$11111111]
3020
              mov edx,dword ptr [edx*4+$11111111]
2654
                               {}@@idx_indexPal:    // @Surface.idx_palette
3021
                               {}@@idx_indexPal:    // @Surface.idx_palette
2655
 
3022
 
2656
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
3023
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
2657
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
3024
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
2658
              bswap edx
3025
              bswap edx
2659
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
3026
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
2660
            @@EndCode:
3027
            @@EndCode:
2661
              {$I DXRender.inc}
3028
              {$I DXRender.inc}
2662
              {  @@idx_indexMask  }
3029
              {  @@idx_indexMask  }
2663
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.Mask]
3030
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.Mask]
2664
              mov edx,offset @@idx_indexMask-4
3031
              mov edx,offset @@idx_indexMask-4
2665
              sub edx,offset @@StartCode
3032
              sub edx,offset @@StartCode
2666
              mov dword ptr [ecx+edx],eax
3033
              mov dword ptr [ecx+edx],eax
2667
 
3034
 
2668
              {  @@idx_indexRShift  }
3035
              {  @@idx_indexRShift  }
2669
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.rshift]
3036
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.rshift]
2670
              mov edx,offset @@idx_indexRShift-1
3037
              mov edx,offset @@idx_indexRShift-1
2671
              sub edx,offset @@StartCode
3038
              sub edx,offset @@StartCode
2672
              mov byte ptr [ecx+edx],al
3039
              mov byte ptr [ecx+edx],al
2673
 
3040
 
2674
              {  @@idx_indexPal  }
3041
              {  @@idx_indexPal  }
2675
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
3042
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
2676
              mov edx,offset @@idx_indexPal-4
3043
              mov edx,offset @@idx_indexPal-4
2677
              sub edx,offset @@StartCode
3044
              sub edx,offset @@StartCode
2678
              mov dword ptr [ecx+edx],eax
3045
              mov dword ptr [ecx+edx],eax
2679
 
3046
 
2680
              {  @@DestR  }
3047
              {  @@DestR  }
2681
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
3048
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
2682
              mov edx,offset @@DestR-4
3049
              mov edx,offset @@DestR-4
2683
              sub edx,offset @@StartCode
3050
              sub edx,offset @@StartCode
2684
              mov dword ptr [ecx+edx],eax
3051
              mov dword ptr [ecx+edx],eax
2685
 
3052
 
2686
              {  @@DestG  }
3053
              {  @@DestG  }
2687
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
3054
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
2688
              mov edx,offset @@DestG-4
3055
              mov edx,offset @@DestG-4
2689
              sub edx,offset @@StartCode
3056
              sub edx,offset @@StartCode
2690
              mov dword ptr [ecx+edx],eax
3057
              mov dword ptr [ecx+edx],eax
2691
 
3058
 
2692
              {  @@DestB  }
3059
              {  @@DestB  }
2693
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
3060
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
2694
              mov edx,offset @@DestB-4
3061
              mov edx,offset @@DestB-4
2695
              sub edx,offset @@StartCode
3062
              sub edx,offset @@StartCode
2696
              mov dword ptr [ecx+edx],eax
3063
              mov dword ptr [ecx+edx],eax
2697
            end;
3064
            end;
2698
          end else
3065
          end else
2699
          begin
3066
          begin
2700
            asm
3067
            asm
2701
              jmp @@EndCode
3068
              jmp @@EndCode
2702
            @@StartCode:
3069
            @@StartCode:
2703
              {  Index channel  }
3070
              {  Index channel  }
2704
              mov edx,eax
3071
              mov edx,eax
2705
              and edx,$11111111{}@@idx_indexMask:   // Surface.idx_index.Mask
3072
              and edx,$11111111{}@@idx_indexMask:   // Surface.idx_index.Mask
2706
              shl edx,$11      {}@@idx_indexLShift: // Surface.idx_index.lshift
3073
              shl edx,$11      {}@@idx_indexLShift: // Surface.idx_index.lshift
2707
              mov edx,dword ptr [edx*4+$11111111]
3074
              mov edx,dword ptr [edx*4+$11111111]
2708
                               {}@@idx_indexPal:    // @Surface.idx_palette
3075
                               {}@@idx_indexPal:    // @Surface.idx_palette
2709
 
3076
 
2710
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
3077
              mov byte ptr [offset _null],dl{}@@DestR:// @Dest.R
2711
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
3078
              mov byte ptr [offset _null],dh{}@@DestG:// @Dest.G
2712
              bswap edx
3079
              bswap edx
2713
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
3080
              mov byte ptr [offset _null],dh{}@@DestB:// @Dest.B
2714
            @@EndCode:
3081
            @@EndCode:
2715
              {$I DXRender.inc}
3082
              {$I DXRender.inc}
2716
              {  @@idx_indexMask  }
3083
              {  @@idx_indexMask  }
2717
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.Mask]
3084
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.Mask]
2718
              mov edx,offset @@idx_indexMask-4
3085
              mov edx,offset @@idx_indexMask-4
2719
              sub edx,offset @@StartCode
3086
              sub edx,offset @@StartCode
2720
              mov dword ptr [ecx+edx],eax
3087
              mov dword ptr [ecx+edx],eax
2721
 
3088
 
2722
              {  @@idx_indexLShift  }
3089
              {  @@idx_indexLShift  }
2723
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.lshift]
3090
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_index.lshift]
2724
              mov edx,offset @@idx_indexLShift-1
3091
              mov edx,offset @@idx_indexLShift-1
2725
              sub edx,offset @@StartCode
3092
              sub edx,offset @@StartCode
2726
              mov byte ptr [ecx+edx],al
3093
              mov byte ptr [ecx+edx],al
2727
 
3094
 
2728
              {  @@idx_indexPal  }
3095
              {  @@idx_indexPal  }
2729
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
3096
              mov eax,Surface; lea eax,dword ptr [eax + TDXR_Surface.idx_palette]
2730
              mov edx,offset @@idx_indexPal-4
3097
              mov edx,offset @@idx_indexPal-4
2731
              sub edx,offset @@StartCode
3098
              sub edx,offset @@StartCode
2732
              mov dword ptr [ecx+edx],eax
3099
              mov dword ptr [ecx+edx],eax
2733
 
3100
 
2734
              {  @@DestR  }
3101
              {  @@DestR  }
2735
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
3102
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
2736
              mov edx,offset @@DestR-4
3103
              mov edx,offset @@DestR-4
2737
              sub edx,offset @@StartCode
3104
              sub edx,offset @@StartCode
2738
              mov dword ptr [ecx+edx],eax
3105
              mov dword ptr [ecx+edx],eax
2739
 
3106
 
2740
              {  @@DestG  }
3107
              {  @@DestG  }
2741
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
3108
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
2742
              mov edx,offset @@DestG-4
3109
              mov edx,offset @@DestG-4
2743
              sub edx,offset @@StartCode
3110
              sub edx,offset @@StartCode
2744
              mov dword ptr [ecx+edx],eax
3111
              mov dword ptr [ecx+edx],eax
2745
 
3112
 
2746
              {  @@DestB  }
3113
              {  @@DestB  }
2747
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
3114
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
2748
              mov edx,offset @@DestB-4
3115
              mov edx,offset @@DestB-4
2749
              sub edx,offset @@StartCode
3116
              sub edx,offset @@StartCode
2750
              mov dword ptr [ecx+edx],eax
3117
              mov dword ptr [ecx+edx],eax
2751
            end;
3118
            end;
2752
          end;
3119
          end;
2753
        end else
3120
        end else
2754
        begin
3121
        begin
2755
          asm
3122
          asm
2756
            jmp @@EndCode
3123
            jmp @@EndCode
2757
          @@StartCode:
3124
          @@StartCode:
2758
            mov word ptr [offset _null],$1111{}@@DestR:// @Dest.R
3125
            mov word ptr [offset _null],$1111{}@@DestR:// @Dest.R
2759
            mov word ptr [offset _null],$1111{}@@DestG:// @Dest.G
3126
            mov word ptr [offset _null],$1111{}@@DestG:// @Dest.G
2760
            mov word ptr [offset _null],$1111{}@@DestB:// @Dest.B
3127
            mov word ptr [offset _null],$1111{}@@DestB:// @Dest.B
2761
          @@EndCode:
3128
          @@EndCode:
2762
            {$I DXRender.inc}
3129
            {$I DXRender.inc}
2763
            {  @@DestR  }
3130
            {  @@DestR  }
2764
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R)
3131
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R)
2765
            mov edx,offset @@DestR-6
3132
            mov edx,offset @@DestR-6
2766
            sub edx,offset @@StartCode
3133
            sub edx,offset @@StartCode
2767
            mov dword ptr [ecx+edx],eax
3134
            mov dword ptr [ecx+edx],eax
2768
 
3135
 
2769
            mov ax,dcR
3136
            mov ax,dcR
2770
            mov edx,offset @@DestR-2
3137
            mov edx,offset @@DestR-2
2771
            sub edx,offset @@StartCode
3138
            sub edx,offset @@StartCode
2772
            mov word ptr [ecx+edx],ax
3139
            mov word ptr [ecx+edx],ax
2773
 
3140
 
2774
            {  @@DestG  }
3141
            {  @@DestG  }
2775
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G)
3142
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G)
2776
            mov edx,offset @@DestG-6
3143
            mov edx,offset @@DestG-6
2777
            sub edx,offset @@StartCode
3144
            sub edx,offset @@StartCode
2778
            mov dword ptr [ecx+edx],eax
3145
            mov dword ptr [ecx+edx],eax
2779
 
3146
 
2780
            mov ax,dcG
3147
            mov ax,dcG
2781
            mov edx,offset @@DestG-2
3148
            mov edx,offset @@DestG-2
2782
            sub edx,offset @@StartCode
3149
            sub edx,offset @@StartCode
2783
            mov word ptr [ecx+edx],ax
3150
            mov word ptr [ecx+edx],ax
2784
 
3151
 
2785
            {  @@DestB  }
3152
            {  @@DestB  }
2786
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B)
3153
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B)
2787
            mov edx,offset @@DestB-6
3154
            mov edx,offset @@DestB-6
2788
            sub edx,offset @@StartCode
3155
            sub edx,offset @@StartCode
2789
            mov dword ptr [ecx+edx],eax
3156
            mov dword ptr [ecx+edx],eax
2790
 
3157
 
2791
            mov ax,dcB
3158
            mov ax,dcB
2792
            mov edx,offset @@DestB-2
3159
            mov edx,offset @@DestB-2
2793
            sub edx,offset @@StartCode
3160
            sub edx,offset @@StartCode
2794
            mov word ptr [ecx+edx],ax
3161
            mov word ptr [ecx+edx],ax
2795
          end;
3162
          end;
2796
        end;
3163
        end;
2797
      end;
3164
      end;
2798
 
3165
 
2799
      {  Alpha Channel  }
3166
      {  Alpha Channel  }
2800
      if chAlpha in EnableChannels then
3167
      if chAlpha in EnableChannels then
2801
      begin
3168
      begin
2802
        if Surface.idx_alpha.Mask<>0 then
3169
        if Surface.idx_alpha.Mask<>0 then
2803
        begin
3170
        begin
2804
          if Surface.idx_alpha.rshift<>0 then
3171
          if Surface.idx_alpha.rshift<>0 then
2805
          begin
3172
          begin
2806
            asm
3173
            asm
2807
              jmp @@EndCode
3174
              jmp @@EndCode
2808
            @@StartCode:
3175
            @@StartCode:
2809
              mov edx,eax
3176
              mov edx,eax
2810
              and edx,$11111111{}@@idx_alphaMask:   // Surface.idx_alpha.Mask
3177
              and edx,$11111111{}@@idx_alphaMask:   // Surface.idx_alpha.Mask
2811
              shr edx,$11      {}@@idx_alphaRShift: // Surface.idx_alpha.rshift
3178
              shr edx,$11      {}@@idx_alphaRShift: // Surface.idx_alpha.rshift
2812
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3179
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
2813
            @@EndCode:
3180
            @@EndCode:
2814
              {$I DXRender.inc}
3181
              {$I DXRender.inc}
2815
              {  @@idx_alphaMask  }
3182
              {  @@idx_alphaMask  }
2816
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.Mask]
3183
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.Mask]
2817
              mov edx,offset @@idx_alphaMask-4
3184
              mov edx,offset @@idx_alphaMask-4
2818
              sub edx,offset @@StartCode
3185
              sub edx,offset @@StartCode
2819
              mov dword ptr [ecx+edx],eax
3186
              mov dword ptr [ecx+edx],eax
2820
 
3187
 
2821
              {  @@idx_alphaRShift  }
3188
              {  @@idx_alphaRShift  }
2822
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.rshift]
3189
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.rshift]
2823
              mov edx,offset @@idx_alphaRShift-1
3190
              mov edx,offset @@idx_alphaRShift-1
2824
              sub edx,offset @@StartCode
3191
              sub edx,offset @@StartCode
2825
              mov byte ptr [ecx+edx],al
3192
              mov byte ptr [ecx+edx],al
2826
 
3193
 
2827
              {  @@Dest  }
3194
              {  @@Dest  }
2828
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
3195
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
2829
              mov edx,offset @@Dest-4
3196
              mov edx,offset @@Dest-4
2830
              sub edx,offset @@StartCode
3197
              sub edx,offset @@StartCode
2831
              mov dword ptr [ecx+edx],eax
3198
              mov dword ptr [ecx+edx],eax
2832
            end;
3199
            end;
2833
          end else
3200
          end else
2834
          begin
3201
          begin
2835
            asm
3202
            asm
2836
              jmp @@EndCode
3203
              jmp @@EndCode
2837
            @@StartCode:
3204
            @@StartCode:
2838
              mov edx,eax
3205
              mov edx,eax
2839
              and edx,$11111111{}@@idx_alphaMask:   // Surface.idx_alpha.Mask
3206
              and edx,$11111111{}@@idx_alphaMask:   // Surface.idx_alpha.Mask
2840
              shl edx,$11      {}@@idx_alphaLShift: // Surface.idx_alpha.lshift
3207
              shl edx,$11      {}@@idx_alphaLShift: // Surface.idx_alpha.lshift
2841
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3208
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
2842
            @@EndCode:
3209
            @@EndCode:
2843
              {$I DXRender.inc}
3210
              {$I DXRender.inc}
2844
              {  @@idx_alphaMask  }
3211
              {  @@idx_alphaMask  }
2845
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.Mask]
3212
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.Mask]
2846
              mov edx,offset @@idx_alphaMask-4
3213
              mov edx,offset @@idx_alphaMask-4
2847
              sub edx,offset @@StartCode
3214
              sub edx,offset @@StartCode
2848
              mov dword ptr [ecx+edx],eax
3215
              mov dword ptr [ecx+edx],eax
2849
 
3216
 
2850
              {  @@idx_alphaLShift  }
3217
              {  @@idx_alphaLShift  }
2851
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.lshift]
3218
              mov eax,Surface; mov eax,[eax + TDXR_Surface.idx_alpha.lshift]
2852
              mov edx,offset @@idx_alphaLShift-1
3219
              mov edx,offset @@idx_alphaLShift-1
2853
              sub edx,offset @@StartCode
3220
              sub edx,offset @@StartCode
2854
              mov byte ptr [ecx+edx],al
3221
              mov byte ptr [ecx+edx],al
2855
 
3222
 
2856
              {  @@Dest  }
3223
              {  @@Dest  }
2857
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
3224
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
2858
              mov edx,offset @@Dest-4
3225
              mov edx,offset @@Dest-4
2859
              sub edx,offset @@StartCode
3226
              sub edx,offset @@StartCode
2860
              mov dword ptr [ecx+edx],eax
3227
              mov dword ptr [ecx+edx],eax
2861
            end;
3228
            end;
2862
          end;
3229
          end;
2863
        end else
3230
        end else
2864
        begin
3231
        begin
2865
          asm
3232
          asm
2866
            jmp @@EndCode
3233
            jmp @@EndCode
2867
          @@StartCode:
3234
          @@StartCode:
2868
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.A
3235
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.A
2869
          @@EndCode:
3236
          @@EndCode:
2870
            {$I DXRender.inc}
3237
            {$I DXRender.inc}
2871
            {  @@Dest  }
3238
            {  @@Dest  }
2872
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A)
3239
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A)
2873
            mov edx,offset @@Dest-6
3240
            mov edx,offset @@Dest-6
2874
            sub edx,offset @@StartCode
3241
            sub edx,offset @@StartCode
2875
            mov dword ptr [ecx+edx],eax
3242
            mov dword ptr [ecx+edx],eax
2876
 
3243
 
2877
            mov ax,dcA
3244
            mov ax,dcA
2878
            mov edx,offset @@Dest-2
3245
            mov edx,offset @@Dest-2
2879
            sub edx,offset @@StartCode
3246
            sub edx,offset @@StartCode
2880
            mov word ptr [ecx+edx],ax
3247
            mov word ptr [ecx+edx],ax
2881
          end;
3248
          end;
2882
        end;
3249
        end;
2883
      end;
3250
      end;
2884
    end else if Surface.ColorType=DXR_COLORTYPE_RGB then
3251
    end else if Surface.ColorType=DXR_COLORTYPE_RGB then
2885
    begin
3252
    begin
2886
      {  Red Channel  }
3253
      {  Red Channel  }
2887
      if chRed in EnableChannels then
3254
      if chRed in EnableChannels then
2888
      begin
3255
      begin
2889
        if Surface.rgb_red.Mask<>0 then
3256
        if Surface.rgb_red.Mask<>0 then
2890
        begin
3257
        begin
2891
          if Surface.rgb_red.rshift<>0 then
3258
          if Surface.rgb_red.rshift<>0 then
2892
          begin
3259
          begin
2893
            asm
3260
            asm
2894
              jmp @@EndCode
3261
              jmp @@EndCode
2895
            @@StartCode:
3262
            @@StartCode:
2896
              mov edx,eax
3263
              mov edx,eax
2897
              and edx,$11111111{}@@Mask:    // Surface.rgb_red.Mask
3264
              and edx,$11111111{}@@Mask:    // Surface.rgb_red.Mask
2898
              shr edx,$11      {}@@RShift:  // Surface.rgb_red.rshift
3265
              shr edx,$11      {}@@RShift:  // Surface.rgb_red.rshift
2899
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.R
3266
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.R
2900
            @@EndCode:
3267
            @@EndCode:
2901
              {$I DXRender.inc}
3268
              {$I DXRender.inc}
2902
              {  @@Mask  }
3269
              {  @@Mask  }
2903
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3270
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
2904
              mov edx,offset @@Mask-4
3271
              mov edx,offset @@Mask-4
2905
              sub edx,offset @@StartCode
3272
              sub edx,offset @@StartCode
2906
              mov dword ptr [ecx+edx],eax
3273
              mov dword ptr [ecx+edx],eax
2907
 
3274
 
2908
              {  @@RShift  }
3275
              {  @@RShift  }
2909
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
3276
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
2910
              mov edx,offset @@RShift-1
3277
              mov edx,offset @@RShift-1
2911
              sub edx,offset @@StartCode
3278
              sub edx,offset @@StartCode
2912
              mov byte ptr [ecx+edx],al
3279
              mov byte ptr [ecx+edx],al
2913
 
3280
 
2914
              {  @@Dest  }
3281
              {  @@Dest  }
2915
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
3282
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
2916
              mov edx,offset @@Dest-4
3283
              mov edx,offset @@Dest-4
2917
              sub edx,offset @@StartCode
3284
              sub edx,offset @@StartCode
2918
              mov dword ptr [ecx+edx],eax
3285
              mov dword ptr [ecx+edx],eax
2919
            end;
3286
            end;
2920
          end else
3287
          end else
2921
          begin
3288
          begin
2922
            asm
3289
            asm
2923
              jmp @@EndCode
3290
              jmp @@EndCode
2924
            @@StartCode:
3291
            @@StartCode:
2925
              mov edx,eax
3292
              mov edx,eax
2926
              and edx,$11111111{}@@Mask:    // Surface.rgb_red.Mask
3293
              and edx,$11111111{}@@Mask:    // Surface.rgb_red.Mask
2927
              shl edx,$11      {}@@LShift:  // Surface.rgb_red.lshift
3294
              shl edx,$11      {}@@LShift:  // Surface.rgb_red.lshift
2928
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.R
3295
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.R
2929
            @@EndCode:
3296
            @@EndCode:
2930
              {$I DXRender.inc}
3297
              {$I DXRender.inc}
2931
              {  @@Mask  }
3298
              {  @@Mask  }
2932
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3299
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
2933
              mov edx,offset @@Mask-4
3300
              mov edx,offset @@Mask-4
2934
              sub edx,offset @@StartCode
3301
              sub edx,offset @@StartCode
2935
              mov dword ptr [ecx+edx],eax
3302
              mov dword ptr [ecx+edx],eax
2936
 
3303
 
2937
              {  @@LShift  }
3304
              {  @@LShift  }
2938
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
3305
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
2939
              mov edx,offset @@LShift-1
3306
              mov edx,offset @@LShift-1
2940
              sub edx,offset @@StartCode
3307
              sub edx,offset @@StartCode
2941
              mov byte ptr [ecx+edx],al
3308
              mov byte ptr [ecx+edx],al
2942
 
3309
 
2943
              {  @@Dest  }
3310
              {  @@Dest  }
2944
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
3311
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
2945
              mov edx,offset @@Dest-4
3312
              mov edx,offset @@Dest-4
2946
              sub edx,offset @@StartCode
3313
              sub edx,offset @@StartCode
2947
              mov dword ptr [ecx+edx],eax
3314
              mov dword ptr [ecx+edx],eax
2948
            end;
3315
            end;
2949
          end;
3316
          end;
2950
        end else
3317
        end else
2951
        begin
3318
        begin
2952
          asm
3319
          asm
2953
            jmp @@EndCode
3320
            jmp @@EndCode
2954
          @@StartCode:
3321
          @@StartCode:
2955
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.R
3322
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.R
2956
          @@EndCode:
3323
          @@EndCode:
2957
            {$I DXRender.inc}
3324
            {$I DXRender.inc}
2958
            {  @@Dest  }
3325
            {  @@Dest  }
2959
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R)
3326
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R)
2960
            mov edx,offset @@Dest-6
3327
            mov edx,offset @@Dest-6
2961
            sub edx,offset @@StartCode
3328
            sub edx,offset @@StartCode
2962
            mov dword ptr [ecx+edx],eax
3329
            mov dword ptr [ecx+edx],eax
2963
 
3330
 
2964
            mov ax,dcR
3331
            mov ax,dcR
2965
            mov edx,offset @@Dest-2
3332
            mov edx,offset @@Dest-2
2966
            sub edx,offset @@StartCode
3333
            sub edx,offset @@StartCode
2967
            mov word ptr [ecx+edx],ax
3334
            mov word ptr [ecx+edx],ax
2968
          end;
3335
          end;
2969
        end;
3336
        end;
2970
      end;
3337
      end;
2971
 
3338
 
2972
      {  Green Channel  }
3339
      {  Green Channel  }
2973
      if chGreen in EnableChannels then
3340
      if chGreen in EnableChannels then
2974
      begin
3341
      begin
2975
        if Surface.rgb_green.Mask<>0 then
3342
        if Surface.rgb_green.Mask<>0 then
2976
        begin
3343
        begin
2977
          if Surface.rgb_green.rshift<>0 then
3344
          if Surface.rgb_green.rshift<>0 then
2978
          begin
3345
          begin
2979
            asm
3346
            asm
2980
              jmp @@EndCode
3347
              jmp @@EndCode
2981
            @@StartCode:
3348
            @@StartCode:
2982
              mov edx,eax
3349
              mov edx,eax
2983
              and edx,$11111111{}@@Mask:    // Surface.rgb_green.Mask
3350
              and edx,$11111111{}@@Mask:    // Surface.rgb_green.Mask
2984
              shr edx,$11      {}@@RShift:  // Surface.rgb_green.rshift
3351
              shr edx,$11      {}@@RShift:  // Surface.rgb_green.rshift
2985
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.G
3352
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.G
2986
            @@EndCode:
3353
            @@EndCode:
2987
              {$I DXRender.inc}
3354
              {$I DXRender.inc}
2988
              {  @@Mask  }
3355
              {  @@Mask  }
2989
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3356
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
2990
              mov edx,offset @@Mask-4
3357
              mov edx,offset @@Mask-4
2991
              sub edx,offset @@StartCode
3358
              sub edx,offset @@StartCode
2992
              mov dword ptr [ecx+edx],eax
3359
              mov dword ptr [ecx+edx],eax
2993
 
3360
 
2994
              {  @@RShift  }
3361
              {  @@RShift  }
2995
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
3362
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
2996
              mov edx,offset @@RShift-1
3363
              mov edx,offset @@RShift-1
2997
              sub edx,offset @@StartCode
3364
              sub edx,offset @@StartCode
2998
              mov byte ptr [ecx+edx],al
3365
              mov byte ptr [ecx+edx],al
2999
 
3366
 
3000
              {  @@Dest  }
3367
              {  @@Dest  }
3001
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
3368
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
3002
              mov edx,offset @@Dest-4
3369
              mov edx,offset @@Dest-4
3003
              sub edx,offset @@StartCode
3370
              sub edx,offset @@StartCode
3004
              mov dword ptr [ecx+edx],eax
3371
              mov dword ptr [ecx+edx],eax
3005
            end;
3372
            end;
3006
          end else
3373
          end else
3007
          begin
3374
          begin
3008
            asm
3375
            asm
3009
              jmp @@EndCode
3376
              jmp @@EndCode
3010
            @@StartCode:
3377
            @@StartCode:
3011
              mov edx,eax
3378
              mov edx,eax
3012
              and edx,$11111111{}@@Mask:    // Surface.rgb_green.Mask
3379
              and edx,$11111111{}@@Mask:    // Surface.rgb_green.Mask
3013
              shl edx,$11      {}@@LShift:  // Surface.rgb_green.lshift
3380
              shl edx,$11      {}@@LShift:  // Surface.rgb_green.lshift
3014
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.G
3381
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.G
3015
            @@EndCode:
3382
            @@EndCode:
3016
              {$I DXRender.inc}
3383
              {$I DXRender.inc}
3017
              {  @@Mask  }
3384
              {  @@Mask  }
3018
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3385
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3019
              mov edx,offset @@Mask-4
3386
              mov edx,offset @@Mask-4
3020
              sub edx,offset @@StartCode
3387
              sub edx,offset @@StartCode
3021
              mov dword ptr [ecx+edx],eax
3388
              mov dword ptr [ecx+edx],eax
3022
 
3389
 
3023
              {  @@LShift  }
3390
              {  @@LShift  }
3024
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
3391
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
3025
              mov edx,offset @@LShift-1
3392
              mov edx,offset @@LShift-1
3026
              sub edx,offset @@StartCode
3393
              sub edx,offset @@StartCode
3027
              mov byte ptr [ecx+edx],al
3394
              mov byte ptr [ecx+edx],al
3028
 
3395
 
3029
              {  @@Dest  }
3396
              {  @@Dest  }
3030
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
3397
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
3031
              mov edx,offset @@Dest-4
3398
              mov edx,offset @@Dest-4
3032
              sub edx,offset @@StartCode
3399
              sub edx,offset @@StartCode
3033
              mov dword ptr [ecx+edx],eax
3400
              mov dword ptr [ecx+edx],eax
3034
            end;
3401
            end;
3035
          end;
3402
          end;
3036
        end else
3403
        end else
3037
        begin
3404
        begin
3038
          asm
3405
          asm
3039
            jmp @@EndCode
3406
            jmp @@EndCode
3040
          @@StartCode:
3407
          @@StartCode:
3041
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.G
3408
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.G
3042
          @@EndCode:
3409
          @@EndCode:
3043
            {$I DXRender.inc}
3410
            {$I DXRender.inc}
3044
            {  @@Dest  }
3411
            {  @@Dest  }
3045
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G)
3412
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G)
3046
            mov edx,offset @@Dest-6
3413
            mov edx,offset @@Dest-6
3047
            sub edx,offset @@StartCode
3414
            sub edx,offset @@StartCode
3048
            mov dword ptr [ecx+edx],eax
3415
            mov dword ptr [ecx+edx],eax
3049
 
3416
 
3050
            mov ax,dcG
3417
            mov ax,dcG
3051
            mov edx,offset @@Dest-2
3418
            mov edx,offset @@Dest-2
3052
            sub edx,offset @@StartCode
3419
            sub edx,offset @@StartCode
3053
            mov word ptr [ecx+edx],ax
3420
            mov word ptr [ecx+edx],ax
3054
          end;
3421
          end;
3055
        end;
3422
        end;
3056
      end;
3423
      end;
3057
 
3424
 
3058
      {  Blue Channel  }
3425
      {  Blue Channel  }
3059
      if chBlue in EnableChannels then
3426
      if chBlue in EnableChannels then
3060
      begin
3427
      begin
3061
        if Surface.rgb_blue.Mask<>0 then
3428
        if Surface.rgb_blue.Mask<>0 then
3062
        begin
3429
        begin
3063
          if Surface.rgb_blue.rshift<>0 then
3430
          if Surface.rgb_blue.rshift<>0 then
3064
          begin
3431
          begin
3065
            asm
3432
            asm
3066
              jmp @@EndCode
3433
              jmp @@EndCode
3067
            @@StartCode:
3434
            @@StartCode:
3068
              mov edx,eax
3435
              mov edx,eax
3069
              and edx,$11111111{}@@Mask:    // Surface.rgb_blue.Mask
3436
              and edx,$11111111{}@@Mask:    // Surface.rgb_blue.Mask
3070
              shr edx,$11      {}@@RShift:  // Surface.rgb_blue.rshift
3437
              shr edx,$11      {}@@RShift:  // Surface.rgb_blue.rshift
3071
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.B
3438
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.B
3072
            @@EndCode:
3439
            @@EndCode:
3073
              {$I DXRender.inc}
3440
              {$I DXRender.inc}
3074
              {  @@Mask  }
3441
              {  @@Mask  }
3075
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3442
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3076
              mov edx,offset @@Mask-4
3443
              mov edx,offset @@Mask-4
3077
              sub edx,offset @@StartCode
3444
              sub edx,offset @@StartCode
3078
              mov dword ptr [ecx+edx],eax
3445
              mov dword ptr [ecx+edx],eax
3079
 
3446
 
3080
              {  @@RShift  }
3447
              {  @@RShift  }
3081
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
3448
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
3082
              mov edx,offset @@RShift-1
3449
              mov edx,offset @@RShift-1
3083
              sub edx,offset @@StartCode
3450
              sub edx,offset @@StartCode
3084
              mov byte ptr [ecx+edx],al
3451
              mov byte ptr [ecx+edx],al
3085
 
3452
 
3086
              {  @@Dest  }
3453
              {  @@Dest  }
3087
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
3454
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
3088
              mov edx,offset @@Dest-4
3455
              mov edx,offset @@Dest-4
3089
              sub edx,offset @@StartCode
3456
              sub edx,offset @@StartCode
3090
              mov dword ptr [ecx+edx],eax
3457
              mov dword ptr [ecx+edx],eax
3091
            end;
3458
            end;
3092
          end else
3459
          end else
3093
          begin
3460
          begin
3094
            asm
3461
            asm
3095
              jmp @@EndCode
3462
              jmp @@EndCode
3096
            @@StartCode:
3463
            @@StartCode:
3097
              mov edx,eax
3464
              mov edx,eax
3098
              and edx,$11111111{}@@Mask:    // Surface.rgb_blue.Mask
3465
              and edx,$11111111{}@@Mask:    // Surface.rgb_blue.Mask
3099
              shl edx,$11      {}@@LShift:  // Surface.rgb_blue.lshift
3466
              shl edx,$11      {}@@LShift:  // Surface.rgb_blue.lshift
3100
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.B
3467
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.B
3101
            @@EndCode:
3468
            @@EndCode:
3102
              {$I DXRender.inc}
3469
              {$I DXRender.inc}
3103
              {  @@Mask  }
3470
              {  @@Mask  }
3104
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3471
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3105
              mov edx,offset @@Mask-4
3472
              mov edx,offset @@Mask-4
3106
              sub edx,offset @@StartCode
3473
              sub edx,offset @@StartCode
3107
              mov dword ptr [ecx+edx],eax
3474
              mov dword ptr [ecx+edx],eax
3108
 
3475
 
3109
              {  @@LShift  }
3476
              {  @@LShift  }
3110
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
3477
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
3111
              mov edx,offset @@LShift-1
3478
              mov edx,offset @@LShift-1
3112
              sub edx,offset @@StartCode
3479
              sub edx,offset @@StartCode
3113
              mov byte ptr [ecx+edx],al
3480
              mov byte ptr [ecx+edx],al
3114
 
3481
 
3115
              {  @@Dest  }
3482
              {  @@Dest  }
3116
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
3483
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
3117
              mov edx,offset @@Dest-4
3484
              mov edx,offset @@Dest-4
3118
              sub edx,offset @@StartCode
3485
              sub edx,offset @@StartCode
3119
              mov dword ptr [ecx+edx],eax
3486
              mov dword ptr [ecx+edx],eax
3120
            end;
3487
            end;
3121
          end;
3488
          end;
3122
        end else
3489
        end else
3123
        begin
3490
        begin
3124
          asm
3491
          asm
3125
            jmp @@EndCode
3492
            jmp @@EndCode
3126
          @@StartCode:
3493
          @@StartCode:
3127
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.B
3494
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.B
3128
          @@EndCode:
3495
          @@EndCode:
3129
            {$I DXRender.inc}
3496
            {$I DXRender.inc}
3130
            {  @@Dest  }
3497
            {  @@Dest  }
3131
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B)
3498
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B)
3132
            mov edx,offset @@Dest-6
3499
            mov edx,offset @@Dest-6
3133
            sub edx,offset @@StartCode
3500
            sub edx,offset @@StartCode
3134
            mov dword ptr [ecx+edx],eax
3501
            mov dword ptr [ecx+edx],eax
3135
 
3502
 
3136
            mov ax,dcB
3503
            mov ax,dcB
3137
            mov edx,offset @@Dest-2
3504
            mov edx,offset @@Dest-2
3138
            sub edx,offset @@StartCode
3505
            sub edx,offset @@StartCode
3139
            mov word ptr [ecx+edx],ax
3506
            mov word ptr [ecx+edx],ax
3140
          end;
3507
          end;
3141
        end;
3508
        end;
3142
      end;
3509
      end;
3143
 
3510
 
3144
      {  Alpha Channel  }
3511
      {  Alpha Channel  }
3145
      if chAlpha in EnableChannels then
3512
      if chAlpha in EnableChannels then
3146
      begin
3513
      begin
3147
        if Surface.rgb_alpha.Mask<>0 then
3514
        if Surface.rgb_alpha.Mask<>0 then
3148
        begin
3515
        begin
3149
          if Surface.rgb_alpha.rshift<>0 then
3516
          if Surface.rgb_alpha.rshift<>0 then
3150
          begin
3517
          begin
3151
            asm
3518
            asm
3152
              jmp @@EndCode
3519
              jmp @@EndCode
3153
            @@StartCode:
3520
            @@StartCode:
3154
              mov edx,eax
3521
              mov edx,eax
3155
              and edx,$11111111{}@@Mask:    // Surface.rgb_alpha.Mask
3522
              and edx,$11111111{}@@Mask:    // Surface.rgb_alpha.Mask
3156
              shr edx,$11      {}@@RShift:  // Surface.rgb_alpha.rshift
3523
              shr edx,$11      {}@@RShift:  // Surface.rgb_alpha.rshift
3157
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3524
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3158
            @@EndCode:
3525
            @@EndCode:
3159
              {$I DXRender.inc}
3526
              {$I DXRender.inc}
3160
              {  @@Mask  }
3527
              {  @@Mask  }
3161
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3528
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3162
              mov edx,offset @@Mask-4
3529
              mov edx,offset @@Mask-4
3163
              sub edx,offset @@StartCode
3530
              sub edx,offset @@StartCode
3164
              mov dword ptr [ecx+edx],eax
3531
              mov dword ptr [ecx+edx],eax
3165
 
3532
 
3166
              {  @@RShift  }
3533
              {  @@RShift  }
3167
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
3534
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
3168
              mov edx,offset @@RShift-1
3535
              mov edx,offset @@RShift-1
3169
              sub edx,offset @@StartCode
3536
              sub edx,offset @@StartCode
3170
              mov byte ptr [ecx+edx],al
3537
              mov byte ptr [ecx+edx],al
3171
 
3538
 
3172
              {  @@Dest  }
3539
              {  @@Dest  }
3173
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
3540
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
3174
              mov edx,offset @@Dest-4
3541
              mov edx,offset @@Dest-4
3175
              sub edx,offset @@StartCode
3542
              sub edx,offset @@StartCode
3176
              mov dword ptr [ecx+edx],eax
3543
              mov dword ptr [ecx+edx],eax
3177
            end;
3544
            end;
3178
          end else
3545
          end else
3179
          begin
3546
          begin
3180
            asm
3547
            asm
3181
              jmp @@EndCode
3548
              jmp @@EndCode
3182
            @@StartCode:
3549
            @@StartCode:
3183
              mov edx,eax
3550
              mov edx,eax
3184
              and edx,$11111111{}@@Mask:    // Surface.rgb_alpha.Mask
3551
              and edx,$11111111{}@@Mask:    // Surface.rgb_alpha.Mask
3185
              shl edx,$11      {}@@LShift:  // Surface.rgb_alpha.lshift
3552
              shl edx,$11      {}@@LShift:  // Surface.rgb_alpha.lshift
3186
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3553
              mov byte ptr [offset _null],dl{}@@Dest:// @Dest.A
3187
            @@EndCode:
3554
            @@EndCode:
3188
              {$I DXRender.inc}
3555
              {$I DXRender.inc}
3189
              {  @@Mask  }
3556
              {  @@Mask  }
3190
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3557
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3191
              mov edx,offset @@Mask-4
3558
              mov edx,offset @@Mask-4
3192
              sub edx,offset @@StartCode
3559
              sub edx,offset @@StartCode
3193
              mov dword ptr [ecx+edx],eax
3560
              mov dword ptr [ecx+edx],eax
3194
 
3561
 
3195
              {  @@LShift  }
3562
              {  @@LShift  }
3196
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
3563
              mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
3197
              mov edx,offset @@LShift-1
3564
              mov edx,offset @@LShift-1
3198
              sub edx,offset @@StartCode
3565
              sub edx,offset @@StartCode
3199
              mov byte ptr [ecx+edx],al
3566
              mov byte ptr [ecx+edx],al
3200
 
3567
 
3201
              {  @@Dest  }
3568
              {  @@Dest  }
3202
              mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
3569
              mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
3203
              mov edx,offset @@Dest-4
3570
              mov edx,offset @@Dest-4
3204
              sub edx,offset @@StartCode
3571
              sub edx,offset @@StartCode
3205
              mov dword ptr [ecx+edx],eax
3572
              mov dword ptr [ecx+edx],eax
3206
            end;
3573
            end;
3207
          end;
3574
          end;
3208
        end else
3575
        end else
3209
        begin
3576
        begin
3210
          asm
3577
          asm
3211
            jmp @@EndCode
3578
            jmp @@EndCode
3212
          @@StartCode:
3579
          @@StartCode:
3213
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.A
3580
            mov word ptr [offset _null],$1111{}@@Dest:// @Dest.A
3214
          @@EndCode:
3581
          @@EndCode:
3215
            {$I DXRender.inc}
3582
            {$I DXRender.inc}
3216
            {  @@Dest  }
3583
            {  @@Dest  }
3217
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A)
3584
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A)
3218
            mov edx,offset @@Dest-6
3585
            mov edx,offset @@Dest-6
3219
            sub edx,offset @@StartCode
3586
            sub edx,offset @@StartCode
3220
            mov dword ptr [ecx+edx],eax
3587
            mov dword ptr [ecx+edx],eax
3221
 
3588
 
3222
            mov ax,dcA
3589
            mov ax,dcA
3223
            mov edx,offset @@Dest-2
3590
            mov edx,offset @@Dest-2
3224
            sub edx,offset @@StartCode
3591
            sub edx,offset @@StartCode
3225
            mov word ptr [ecx+edx],ax
3592
            mov word ptr [ecx+edx],ax
3226
          end;
3593
          end;
3227
        end;
3594
        end;
3228
      end;
3595
      end;
3229
    end;
3596
    end;
3230
  end;
3597
  end;
3231
 
3598
 
3232
  procedure genEncodeColor(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color; EnableChannels: TDXRColorChannels);
3599
  procedure genEncodeColor(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color; EnableChannels: TDXRColorChannels);
3233
  begin
3600
  begin
3234
    asm
3601
    asm
3235
      jmp @@EndCode
3602
      jmp @@EndCode
3236
    @@StartCode:
3603
    @@StartCode:
3237
      xor eax,eax
3604
      xor eax,eax
3238
    @@EndCode:
3605
    @@EndCode:
3239
      {$I DXRender.inc}
3606
      {$I DXRender.inc}
3240
    end;
3607
    end;
3241
 
3608
 
3242
    {  Red channel  }
3609
    {  Red channel  }
3243
    if chRed in EnableChannels then
3610
    if chRed in EnableChannels then
3244
    begin
3611
    begin
3245
      if Surface.rgb_red.rshift<>0 then
3612
      if Surface.rgb_red.rshift<>0 then
3246
      begin
3613
      begin
3247
        asm
3614
        asm
3248
          jmp @@EndCode
3615
          jmp @@EndCode
3249
        @@StartCode:
3616
        @@StartCode:
3250
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3617
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3251
          shl edx,$11      {}@@rgb_redRShift:  // Surface.rgb_red.rshift
3618
          shl edx,$11      {}@@rgb_redRShift:  // Surface.rgb_red.rshift
3252
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3619
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3253
          or eax,edx
3620
          or eax,edx
3254
        @@EndCode:
3621
        @@EndCode:
3255
          {$I DXRender.inc}
3622
          {$I DXRender.inc}
3256
          {  @@Src  }
3623
          {  @@Src  }
3257
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
3624
          mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
3258
          mov edx,offset @@Src-4
3625
          mov edx,offset @@Src-4
3259
          sub edx,offset @@StartCode
3626
          sub edx,offset @@StartCode
3260
          mov dword ptr [ecx+edx],eax
3627
          mov dword ptr [ecx+edx],eax
3261
 
3628
 
3262
          {  @@rgb_redMask  }
3629
          {  @@rgb_redMask  }
3263
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3630
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3264
          mov edx,offset @@rgb_redMask-4
3631
          mov edx,offset @@rgb_redMask-4
3265
          sub edx,offset @@StartCode
3632
          sub edx,offset @@StartCode
3266
          mov dword ptr [ecx+edx],eax
3633
          mov dword ptr [ecx+edx],eax
3267
 
3634
 
3268
          {  @@rgb_redRShift  }
3635
          {  @@rgb_redRShift  }
3269
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
3636
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
3270
          mov edx,offset @@rgb_redRShift-1
3637
          mov edx,offset @@rgb_redRShift-1
3271
          sub edx,offset @@StartCode
3638
          sub edx,offset @@StartCode
3272
          mov byte ptr [ecx+edx],al
3639
          mov byte ptr [ecx+edx],al
3273
        end;
3640
        end;
3274
      end else
3641
      end else
3275
      begin
3642
      begin
3276
        asm
3643
        asm
3277
          jmp @@EndCode
3644
          jmp @@EndCode
3278
        @@StartCode:
3645
        @@StartCode:
3279
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3646
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3280
          shr edx,$11      {}@@rgb_redLShift:  // Surface.rgb_red.lshift
3647
          shr edx,$11      {}@@rgb_redLShift:  // Surface.rgb_red.lshift
3281
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3648
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3282
          or eax,edx
3649
          or eax,edx
3283
        @@EndCode:
3650
        @@EndCode:
3284
          {$I DXRender.inc}
3651
          {$I DXRender.inc}
3285
          {  @@Src  }
3652
          {  @@Src  }
3286
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
3653
          mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
3287
          mov edx,offset @@Src-4
3654
          mov edx,offset @@Src-4
3288
          sub edx,offset @@StartCode
3655
          sub edx,offset @@StartCode
3289
          mov dword ptr [ecx+edx],eax
3656
          mov dword ptr [ecx+edx],eax
3290
 
3657
 
3291
          {  @@rgb_redMask  }
3658
          {  @@rgb_redMask  }
3292
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3659
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3293
          mov edx,offset @@rgb_redMask-4
3660
          mov edx,offset @@rgb_redMask-4
3294
          sub edx,offset @@StartCode
3661
          sub edx,offset @@StartCode
3295
          mov dword ptr [ecx+edx],eax
3662
          mov dword ptr [ecx+edx],eax
3296
 
3663
 
3297
          {  @@rgb_redLShift  }
3664
          {  @@rgb_redLShift  }
3298
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
3665
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
3299
          mov edx,offset @@rgb_redLShift-1
3666
          mov edx,offset @@rgb_redLShift-1
3300
          sub edx,offset @@StartCode
3667
          sub edx,offset @@StartCode
3301
          mov byte ptr [ecx+edx],al
3668
          mov byte ptr [ecx+edx],al
3302
        end;
3669
        end;
3303
      end;
3670
      end;
3304
    end;
3671
    end;
3305
 
3672
 
3306
    {  Green channel  }
3673
    {  Green channel  }
3307
    if chGreen in EnableChannels then
3674
    if chGreen in EnableChannels then
3308
    begin
3675
    begin
3309
      if Surface.rgb_green.rshift<>0 then
3676
      if Surface.rgb_green.rshift<>0 then
3310
      begin
3677
      begin
3311
        asm
3678
        asm
3312
          jmp @@EndCode
3679
          jmp @@EndCode
3313
        @@StartCode:
3680
        @@StartCode:
3314
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3681
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3315
          shl edx,$11      {}@@rgb_greenRShift:  // Surface.rgb_green.rshift
3682
          shl edx,$11      {}@@rgb_greenRShift:  // Surface.rgb_green.rshift
3316
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3683
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3317
          or eax,edx
3684
          or eax,edx
3318
        @@EndCode:
3685
        @@EndCode:
3319
          {$I DXRender.inc}
3686
          {$I DXRender.inc}
3320
          {  @@Src  }
3687
          {  @@Src  }
3321
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
3688
          mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
3322
          mov edx,offset @@Src-4
3689
          mov edx,offset @@Src-4
3323
          sub edx,offset @@StartCode
3690
          sub edx,offset @@StartCode
3324
          mov dword ptr [ecx+edx],eax
3691
          mov dword ptr [ecx+edx],eax
3325
 
3692
 
3326
          {  @@rgb_greenMask  }
3693
          {  @@rgb_greenMask  }
3327
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3694
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3328
          mov edx,offset @@rgb_greenMask-4
3695
          mov edx,offset @@rgb_greenMask-4
3329
          sub edx,offset @@StartCode
3696
          sub edx,offset @@StartCode
3330
          mov dword ptr [ecx+edx],eax
3697
          mov dword ptr [ecx+edx],eax
3331
 
3698
 
3332
          {  @@rgb_greenRShift  }
3699
          {  @@rgb_greenRShift  }
3333
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
3700
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
3334
          mov edx,offset @@rgb_greenRShift-1
3701
          mov edx,offset @@rgb_greenRShift-1
3335
          sub edx,offset @@StartCode
3702
          sub edx,offset @@StartCode
3336
          mov byte ptr [ecx+edx],al
3703
          mov byte ptr [ecx+edx],al
3337
        end;
3704
        end;
3338
      end else
3705
      end else
3339
      begin
3706
      begin
3340
        asm
3707
        asm
3341
          jmp @@EndCode
3708
          jmp @@EndCode
3342
        @@StartCode:
3709
        @@StartCode:
3343
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3710
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3344
          shr edx,$11      {}@@rgb_greenLShift:  // Surface.rgb_green.lshift
3711
          shr edx,$11      {}@@rgb_greenLShift:  // Surface.rgb_green.lshift
3345
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3712
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3346
          or eax,edx
3713
          or eax,edx
3347
        @@EndCode:
3714
        @@EndCode:
3348
          {$I DXRender.inc}
3715
          {$I DXRender.inc}
3349
          {  @@Src  }
3716
          {  @@Src  }
3350
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
3717
          mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
3351
          mov edx,offset @@Src-4
3718
          mov edx,offset @@Src-4
3352
          sub edx,offset @@StartCode
3719
          sub edx,offset @@StartCode
3353
          mov dword ptr [ecx+edx],eax
3720
          mov dword ptr [ecx+edx],eax
3354
 
3721
 
3355
          {  @@rgb_greenMask  }
3722
          {  @@rgb_greenMask  }
3356
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3723
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3357
          mov edx,offset @@rgb_greenMask-4
3724
          mov edx,offset @@rgb_greenMask-4
3358
          sub edx,offset @@StartCode
3725
          sub edx,offset @@StartCode
3359
          mov dword ptr [ecx+edx],eax
3726
          mov dword ptr [ecx+edx],eax
3360
 
3727
 
3361
          {  @@rgb_greenLShift  }
3728
          {  @@rgb_greenLShift  }
3362
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
3729
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
3363
          mov edx,offset @@rgb_greenLShift-1
3730
          mov edx,offset @@rgb_greenLShift-1
3364
          sub edx,offset @@StartCode
3731
          sub edx,offset @@StartCode
3365
          mov byte ptr [ecx+edx],al
3732
          mov byte ptr [ecx+edx],al
3366
        end;
3733
        end;
3367
      end;
3734
      end;
3368
    end;
3735
    end;
3369
 
3736
 
3370
    {  Blue channel  }
3737
    {  Blue channel  }
3371
    if chBlue in EnableChannels then
3738
    if chBlue in EnableChannels then
3372
    begin
3739
    begin
3373
      if Surface.rgb_blue.rshift<>0 then
3740
      if Surface.rgb_blue.rshift<>0 then
3374
      begin
3741
      begin
3375
        asm
3742
        asm
3376
          jmp @@EndCode
3743
          jmp @@EndCode
3377
        @@StartCode:
3744
        @@StartCode:
3378
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
3745
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
3379
          shl edx,$11      {}@@rgb_blueRShift:  // Surface.rgb_blue.rshift
3746
          shl edx,$11      {}@@rgb_blueRShift:  // Surface.rgb_blue.rshift
3380
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3747
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3381
          or eax,edx
3748
          or eax,edx
3382
        @@EndCode:
3749
        @@EndCode:
3383
          {$I DXRender.inc}
3750
          {$I DXRender.inc}
3384
          {  @@Src  }
3751
          {  @@Src  }
3385
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
3752
          mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
3386
          mov edx,offset @@Src-4
3753
          mov edx,offset @@Src-4
3387
          sub edx,offset @@StartCode
3754
          sub edx,offset @@StartCode
3388
          mov dword ptr [ecx+edx],eax
3755
          mov dword ptr [ecx+edx],eax
3389
 
3756
 
3390
          {  @@rgb_blueMask  }
3757
          {  @@rgb_blueMask  }
3391
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3758
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3392
          mov edx,offset @@rgb_blueMask-4
3759
          mov edx,offset @@rgb_blueMask-4
3393
          sub edx,offset @@StartCode
3760
          sub edx,offset @@StartCode
3394
          mov dword ptr [ecx+edx],eax
3761
          mov dword ptr [ecx+edx],eax
3395
 
3762
 
3396
          {  @@rgb_blueRShift  }
3763
          {  @@rgb_blueRShift  }
3397
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
3764
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
3398
          mov edx,offset @@rgb_blueRShift-1
3765
          mov edx,offset @@rgb_blueRShift-1
3399
          sub edx,offset @@StartCode
3766
          sub edx,offset @@StartCode
3400
          mov byte ptr [ecx+edx],al
3767
          mov byte ptr [ecx+edx],al
3401
        end;
3768
        end;
3402
      end else
3769
      end else
3403
      begin
3770
      begin
3404
        asm
3771
        asm
3405
          jmp @@EndCode
3772
          jmp @@EndCode
3406
        @@StartCode:
3773
        @@StartCode:
3407
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
3774
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
3408
          shr edx,$11      {}@@rgb_blueLShift:  // Surface.rgb_blue.lshift
3775
          shr edx,$11      {}@@rgb_blueLShift:  // Surface.rgb_blue.lshift
3409
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3776
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3410
          or eax,edx
3777
          or eax,edx
3411
        @@EndCode:
3778
        @@EndCode:
3412
          {$I DXRender.inc}
3779
          {$I DXRender.inc}
3413
          {  @@Src  }
3780
          {  @@Src  }
3414
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
3781
          mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
3415
          mov edx,offset @@Src-4
3782
          mov edx,offset @@Src-4
3416
          sub edx,offset @@StartCode
3783
          sub edx,offset @@StartCode
3417
          mov dword ptr [ecx+edx],eax
3784
          mov dword ptr [ecx+edx],eax
3418
 
3785
 
3419
          {  @@rgb_blueMask  }
3786
          {  @@rgb_blueMask  }
3420
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3787
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3421
          mov edx,offset @@rgb_blueMask-4
3788
          mov edx,offset @@rgb_blueMask-4
3422
          sub edx,offset @@StartCode
3789
          sub edx,offset @@StartCode
3423
          mov dword ptr [ecx+edx],eax
3790
          mov dword ptr [ecx+edx],eax
3424
 
3791
 
3425
          {  @@rgb_blueLShift  }
3792
          {  @@rgb_blueLShift  }
3426
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
3793
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
3427
          mov edx,offset @@rgb_blueLShift-1
3794
          mov edx,offset @@rgb_blueLShift-1
3428
          sub edx,offset @@StartCode
3795
          sub edx,offset @@StartCode
3429
          mov byte ptr [ecx+edx],al
3796
          mov byte ptr [ecx+edx],al
3430
        end;
3797
        end;
3431
      end;
3798
      end;
3432
    end;
3799
    end;
3433
 
3800
 
3434
    {  Alpha channel  }
3801
    {  Alpha channel  }
3435
    if chAlpha in EnableChannels then
3802
    if chAlpha in EnableChannels then
3436
    begin
3803
    begin
3437
      if Surface.rgb_alpha.rshift<>0 then
3804
      if Surface.rgb_alpha.rshift<>0 then
3438
      begin
3805
      begin
3439
        asm
3806
        asm
3440
          jmp @@EndCode
3807
          jmp @@EndCode
3441
        @@StartCode:
3808
        @@StartCode:
3442
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.A
3809
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.A
3443
          shl edx,$11      {}@@rgb_alphaRShift: // Surface.rgb_alpha.rshift
3810
          shl edx,$11      {}@@rgb_alphaRShift: // Surface.rgb_alpha.rshift
3444
          and edx,$11111111{}@@rgb_alphaMask:   // Surface.rgb_alpha.Mask
3811
          and edx,$11111111{}@@rgb_alphaMask:   // Surface.rgb_alpha.Mask
3445
          or eax,edx
3812
          or eax,edx
3446
        @@EndCode:
3813
        @@EndCode:
3447
          {$I DXRender.inc}
3814
          {$I DXRender.inc}
3448
          {  @@Src  }
3815
          {  @@Src  }
3449
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
3816
          mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
3450
          mov edx,offset @@Src-4
3817
          mov edx,offset @@Src-4
3451
          sub edx,offset @@StartCode
3818
          sub edx,offset @@StartCode
3452
          mov dword ptr [ecx+edx],eax
3819
          mov dword ptr [ecx+edx],eax
3453
 
3820
 
3454
          {  @@rgb_alphaMask  }
3821
          {  @@rgb_alphaMask  }
3455
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3822
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3456
          mov edx,offset @@rgb_alphaMask-4
3823
          mov edx,offset @@rgb_alphaMask-4
3457
          sub edx,offset @@StartCode
3824
          sub edx,offset @@StartCode
3458
          mov dword ptr [ecx+edx],eax
3825
          mov dword ptr [ecx+edx],eax
3459
 
3826
 
3460
          {  @@rgb_alphaRShift  }
3827
          {  @@rgb_alphaRShift  }
3461
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
3828
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
3462
          mov edx,offset @@rgb_alphaRShift-1
3829
          mov edx,offset @@rgb_alphaRShift-1
3463
          sub edx,offset @@StartCode
3830
          sub edx,offset @@StartCode
3464
          mov byte ptr [ecx+edx],al
3831
          mov byte ptr [ecx+edx],al
3465
        end;
3832
        end;
3466
      end else
3833
      end else
3467
      begin
3834
      begin
3468
        asm
3835
        asm
3469
          jmp @@EndCode
3836
          jmp @@EndCode
3470
        @@StartCode:
3837
        @@StartCode:
3471
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.A
3838
          movzx edx,byte ptr [offset _null]{}@@Src:// @Src.A
3472
          shr edx,$11      {}@@rgb_alphaLShift: // Surface.rgb_alpha.lshift
3839
          shr edx,$11      {}@@rgb_alphaLShift: // Surface.rgb_alpha.lshift
3473
          and edx,$11111111{}@@rgb_alphaMask:   // Surface.rgb_alpha.Mask
3840
          and edx,$11111111{}@@rgb_alphaMask:   // Surface.rgb_alpha.Mask
3474
          or eax,edx
3841
          or eax,edx
3475
        @@EndCode:
3842
        @@EndCode:
3476
          {$I DXRender.inc}
3843
          {$I DXRender.inc}
3477
          {  @@Src  }
3844
          {  @@Src  }
3478
          mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
3845
          mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
3479
          mov edx,offset @@Src-4
3846
          mov edx,offset @@Src-4
3480
          sub edx,offset @@StartCode
3847
          sub edx,offset @@StartCode
3481
          mov dword ptr [ecx+edx],eax
3848
          mov dword ptr [ecx+edx],eax
3482
 
3849
 
3483
          {  @@rgb_alphaMask  }
3850
          {  @@rgb_alphaMask  }
3484
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3851
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3485
          mov edx,offset @@rgb_alphaMask-4
3852
          mov edx,offset @@rgb_alphaMask-4
3486
          sub edx,offset @@StartCode
3853
          sub edx,offset @@StartCode
3487
          mov dword ptr [ecx+edx],eax
3854
          mov dword ptr [ecx+edx],eax
3488
 
3855
 
3489
          {  @@rgb_alphaLShift  }
3856
          {  @@rgb_alphaLShift  }
3490
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
3857
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
3491
          mov edx,offset @@rgb_alphaLShift-1
3858
          mov edx,offset @@rgb_alphaLShift-1
3492
          sub edx,offset @@StartCode
3859
          sub edx,offset @@StartCode
3493
          mov byte ptr [ecx+edx],al
3860
          mov byte ptr [ecx+edx],al
3494
        end;
3861
        end;
3495
      end;
3862
      end;
3496
    end;
3863
    end;
3497
  end;
3864
  end;
3498
 
3865
 
3499
  procedure genEncodeColor_with_Dither(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color;
3866
  procedure genEncodeColor_with_Dither(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color;
3500
    Axis: PDXRMachine_Axis; EnableChannels: TDXRColorChannels);
3867
    Axis: PDXRMachine_Axis; EnableChannels: TDXRColorChannels);
3501
  const
3868
  const
3502
    m: array[0..3, 0..3] of Byte = ((0, 0, 0, 0), (1, 0, 0, 0), (1, 0, 0, 1), (1, 1, 1, 0));
3869
    m: array[0..3, 0..3] of Byte = ((0, 0, 0, 0), (1, 0, 0, 0), (1, 0, 0, 1), (1, 1, 1, 0));
3503
  begin
3870
  begin
3504
    asm
3871
    asm
3505
      jmp @@EndCode
3872
      jmp @@EndCode
3506
    @@StartCode:
3873
    @@StartCode:
3507
      xor eax,eax
3874
      xor eax,eax
3508
      movzx ebp,byte ptr [offset _null]{}@@AxisX:
3875
      movzx ebp,byte ptr [offset _null]{}@@AxisX:
3509
      movzx edx,byte ptr [offset _null]{}@@AxisY:
3876
      movzx edx,byte ptr [offset _null]{}@@AxisY:
3510
      and ebp,1
3877
      and ebp,1
3511
      and edx,1
3878
      and edx,1
3512
      lea ebp,[offset m+ebp*2+edx]
3879
      lea ebp,[offset m+ebp*2+edx]
3513
    @@EndCode:
3880
    @@EndCode:
3514
      {$I DXRender.inc}
3881
      {$I DXRender.inc}
3515
      {  @@AxisX  }
3882
      {  @@AxisX  }
3516
      mov eax,Axis; add eax,TDXRMachine_Axis.X
3883
      mov eax,Axis; add eax,TDXRMachine_Axis.X
3517
      mov edx,offset @@AxisX-4
3884
      mov edx,offset @@AxisX-4
3518
      sub edx,offset @@StartCode
3885
      sub edx,offset @@StartCode
3519
      mov dword ptr [ecx+edx],eax
3886
      mov dword ptr [ecx+edx],eax
3520
 
3887
 
3521
      {  @@AxisY  }
3888
      {  @@AxisY  }
3522
      mov eax,Axis; add eax,TDXRMachine_Axis.Y
3889
      mov eax,Axis; add eax,TDXRMachine_Axis.Y
3523
      mov edx,offset @@AxisY-4
3890
      mov edx,offset @@AxisY-4
3524
      sub edx,offset @@StartCode
3891
      sub edx,offset @@StartCode
3525
      mov dword ptr [ecx+edx],eax
3892
      mov dword ptr [ecx+edx],eax
3526
    end;
3893
    end;
3527
 
3894
 
3528
    {  Red channel  }
3895
    {  Red channel  }
3529
    if chRed in EnableChannels then
3896
    if chRed in EnableChannels then
3530
    begin
3897
    begin
3531
      asm
3898
      asm
3532
        jmp @@EndCode
3899
        jmp @@EndCode
3533
      @@StartCode:
3900
      @@StartCode:
3534
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3901
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3535
      @@EndCode:
3902
      @@EndCode:
3536
        {$I DXRender.inc}
3903
        {$I DXRender.inc}
3537
        {  @@Src  }
3904
        {  @@Src  }
3538
        mov eax,Src; add eax,BYTE(TDXRMachine_Color.R+1)
3905
        mov eax,Src; add eax,Byte(TDXRMachine_Color.R+1)
3539
        mov edx,offset @@Src-4
3906
        mov edx,offset @@Src-4
3540
        sub edx,offset @@StartCode
3907
        sub edx,offset @@StartCode
3541
        mov dword ptr [ecx+edx],eax
3908
        mov dword ptr [ecx+edx],eax
3542
      end;
3909
      end;
3543
 
3910
 
3544
      if Surface.rgb_red.Bitcount<7 then
3911
      if Surface.rgb_red.Bitcount<7 then
3545
      begin
3912
      begin
3546
        asm
3913
        asm
3547
          jmp @@EndCode
3914
          jmp @@EndCode
3548
        @@StartCode:
3915
        @@StartCode:
3549
          mov ebx,edx
3916
          mov ebx,edx
3550
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
3917
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
3551
          and ebx,3
3918
          and ebx,3
3552
          movzx ebx,byte ptr [ebp+ebx*4]
3919
          movzx ebx,byte ptr [ebp+ebx*4]
3553
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
3920
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
3554
          movzx edx,byte [offset (_AddTable+edx+ebx)]
3921
          movzx edx,byte [offset (_AddTable+edx+ebx)]
3555
        @@EndCode:
3922
        @@EndCode:
3556
          {$I DXRender.inc}
3923
          {$I DXRender.inc}
3557
          {  @@BitCount  }
3924
          {  @@BitCount  }
3558
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_red.Bitcount]
3925
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_red.Bitcount]
3559
          mov edx,offset @@BitCount-1
3926
          mov edx,offset @@BitCount-1
3560
          sub edx,offset @@StartCode
3927
          sub edx,offset @@StartCode
3561
          mov byte ptr [ecx+edx],al
3928
          mov byte ptr [ecx+edx],al
3562
 
3929
 
3563
          {  @@BitCount2  }
3930
          {  @@BitCount2  }
3564
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_red.Bitcount]
3931
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_red.Bitcount]
3565
          mov edx,offset @@BitCount2-1
3932
          mov edx,offset @@BitCount2-1
3566
          sub edx,offset @@StartCode
3933
          sub edx,offset @@StartCode
3567
          mov byte ptr [ecx+edx],al
3934
          mov byte ptr [ecx+edx],al
3568
        end;
3935
        end;
3569
      end;
3936
      end;
3570
 
3937
 
3571
      if Surface.rgb_red.rshift<>0 then
3938
      if Surface.rgb_red.rshift<>0 then
3572
      begin
3939
      begin
3573
        asm
3940
        asm
3574
          jmp @@EndCode
3941
          jmp @@EndCode
3575
        @@StartCode:
3942
        @@StartCode:
3576
          shl edx,$11      {}@@rgb_redRShift:  // Surface.rgb_red.rshift
3943
          shl edx,$11      {}@@rgb_redRShift:  // Surface.rgb_red.rshift
3577
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3944
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3578
          or eax,edx
3945
          or eax,edx
3579
        @@EndCode:
3946
        @@EndCode:
3580
          {$I DXRender.inc}
3947
          {$I DXRender.inc}
3581
          {  @@rgb_redMask  }
3948
          {  @@rgb_redMask  }
3582
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3949
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3583
          mov edx,offset @@rgb_redMask-4
3950
          mov edx,offset @@rgb_redMask-4
3584
          sub edx,offset @@StartCode
3951
          sub edx,offset @@StartCode
3585
          mov dword ptr [ecx+edx],eax
3952
          mov dword ptr [ecx+edx],eax
3586
 
3953
 
3587
          {  @@rgb_redRShift  }
3954
          {  @@rgb_redRShift  }
3588
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
3955
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.rshift]
3589
          mov edx,offset @@rgb_redRShift-1
3956
          mov edx,offset @@rgb_redRShift-1
3590
          sub edx,offset @@StartCode
3957
          sub edx,offset @@StartCode
3591
          mov byte ptr [ecx+edx],al
3958
          mov byte ptr [ecx+edx],al
3592
        end;
3959
        end;
3593
      end else
3960
      end else
3594
      begin
3961
      begin
3595
        asm
3962
        asm
3596
          jmp @@EndCode
3963
          jmp @@EndCode
3597
        @@StartCode:
3964
        @@StartCode:
3598
          shr edx,$11      {}@@rgb_redLShift:  // Surface.rgb_red.lshift
3965
          shr edx,$11      {}@@rgb_redLShift:  // Surface.rgb_red.lshift
3599
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3966
          and edx,$11111111{}@@rgb_redMask:    // Surface.rgb_red.Mask
3600
          or eax,edx
3967
          or eax,edx
3601
        @@EndCode:
3968
        @@EndCode:
3602
          {$I DXRender.inc}
3969
          {$I DXRender.inc}
3603
          {  @@rgb_redMask  }
3970
          {  @@rgb_redMask  }
3604
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3971
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.Mask]
3605
          mov edx,offset @@rgb_redMask-4
3972
          mov edx,offset @@rgb_redMask-4
3606
          sub edx,offset @@StartCode
3973
          sub edx,offset @@StartCode
3607
          mov dword ptr [ecx+edx],eax
3974
          mov dword ptr [ecx+edx],eax
3608
 
3975
 
3609
          {  @@rgb_redLShift  }
3976
          {  @@rgb_redLShift  }
3610
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
3977
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_red.lshift]
3611
          mov edx,offset @@rgb_redLShift-1
3978
          mov edx,offset @@rgb_redLShift-1
3612
          sub edx,offset @@StartCode
3979
          sub edx,offset @@StartCode
3613
          mov byte ptr [ecx+edx],al
3980
          mov byte ptr [ecx+edx],al
3614
        end;
3981
        end;
3615
      end;
3982
      end;
3616
    end;
3983
    end;
3617
 
3984
 
3618
    {  Green channel  }
3985
    {  Green channel  }
3619
    if chGreen in EnableChannels then
3986
    if chGreen in EnableChannels then
3620
    begin
3987
    begin
3621
      asm
3988
      asm
3622
        jmp @@EndCode
3989
        jmp @@EndCode
3623
      @@StartCode:
3990
      @@StartCode:
3624
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3991
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.G
3625
      @@EndCode:
3992
      @@EndCode:
3626
        {$I DXRender.inc}
3993
        {$I DXRender.inc}
3627
        {  @@Src  }
3994
        {  @@Src  }
3628
        mov eax,Src; add eax,BYTE(TDXRMachine_Color.G+1)
3995
        mov eax,Src; add eax,Byte(TDXRMachine_Color.G+1)
3629
        mov edx,offset @@Src-4
3996
        mov edx,offset @@Src-4
3630
        sub edx,offset @@StartCode
3997
        sub edx,offset @@StartCode
3631
        mov dword ptr [ecx+edx],eax
3998
        mov dword ptr [ecx+edx],eax
3632
      end;
3999
      end;
3633
 
4000
 
3634
      if Surface.rgb_green.Bitcount<7 then
4001
      if Surface.rgb_green.Bitcount<7 then
3635
      begin
4002
      begin
3636
        asm
4003
        asm
3637
          jmp @@EndCode
4004
          jmp @@EndCode
3638
        @@StartCode:
4005
        @@StartCode:
3639
          mov ebx,edx
4006
          mov ebx,edx
3640
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
4007
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
3641
          and ebx,3
4008
          and ebx,3
3642
          movzx ebx,byte ptr [ebp+ebx*4]
4009
          movzx ebx,byte ptr [ebp+ebx*4]
3643
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
4010
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
3644
          movzx edx,byte [offset (_AddTable+edx+ebx)]
4011
          movzx edx,byte [offset (_AddTable+edx+ebx)]
3645
        @@EndCode:
4012
        @@EndCode:
3646
          {$I DXRender.inc}
4013
          {$I DXRender.inc}
3647
          {  @@BitCount  }
4014
          {  @@BitCount  }
3648
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_green.Bitcount]
4015
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_green.Bitcount]
3649
          mov edx,offset @@BitCount-1
4016
          mov edx,offset @@BitCount-1
3650
          sub edx,offset @@StartCode
4017
          sub edx,offset @@StartCode
3651
          mov byte ptr [ecx+edx],al
4018
          mov byte ptr [ecx+edx],al
3652
 
4019
 
3653
          {  @@BitCount2  }
4020
          {  @@BitCount2  }
3654
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_green.Bitcount]
4021
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_green.Bitcount]
3655
          mov edx,offset @@BitCount2-1
4022
          mov edx,offset @@BitCount2-1
3656
          sub edx,offset @@StartCode
4023
          sub edx,offset @@StartCode
3657
          mov byte ptr [ecx+edx],al
4024
          mov byte ptr [ecx+edx],al
3658
        end;
4025
        end;
3659
      end;
4026
      end;
3660
 
4027
 
3661
      if Surface.rgb_green.rshift<>0 then
4028
      if Surface.rgb_green.rshift<>0 then
3662
      begin
4029
      begin
3663
        asm
4030
        asm
3664
          jmp @@EndCode
4031
          jmp @@EndCode
3665
        @@StartCode:
4032
        @@StartCode:
3666
          shl edx,$11      {}@@rgb_greenRShift:  // Surface.rgb_green.rshift
4033
          shl edx,$11      {}@@rgb_greenRShift:  // Surface.rgb_green.rshift
3667
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
4034
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3668
          or eax,edx
4035
          or eax,edx
3669
        @@EndCode:
4036
        @@EndCode:
3670
          {$I DXRender.inc}
4037
          {$I DXRender.inc}
3671
          {  @@rgb_greenMask  }
4038
          {  @@rgb_greenMask  }
3672
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
4039
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3673
          mov edx,offset @@rgb_greenMask-4
4040
          mov edx,offset @@rgb_greenMask-4
3674
          sub edx,offset @@StartCode
4041
          sub edx,offset @@StartCode
3675
          mov dword ptr [ecx+edx],eax
4042
          mov dword ptr [ecx+edx],eax
3676
 
4043
 
3677
          {  @@rgb_greenRShift  }
4044
          {  @@rgb_greenRShift  }
3678
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
4045
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.rshift]
3679
          mov edx,offset @@rgb_greenRShift-1
4046
          mov edx,offset @@rgb_greenRShift-1
3680
          sub edx,offset @@StartCode
4047
          sub edx,offset @@StartCode
3681
          mov byte ptr [ecx+edx],al
4048
          mov byte ptr [ecx+edx],al
3682
        end;
4049
        end;
3683
      end else
4050
      end else
3684
      begin
4051
      begin
3685
        asm
4052
        asm
3686
          jmp @@EndCode
4053
          jmp @@EndCode
3687
        @@StartCode:
4054
        @@StartCode:
3688
          shr edx,$11      {}@@rgb_greenLShift:  // Surface.rgb_green.lshift
4055
          shr edx,$11      {}@@rgb_greenLShift:  // Surface.rgb_green.lshift
3689
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
4056
          and edx,$11111111{}@@rgb_greenMask:    // Surface.rgb_green.Mask
3690
          or eax,edx
4057
          or eax,edx
3691
        @@EndCode:
4058
        @@EndCode:
3692
          {$I DXRender.inc}
4059
          {$I DXRender.inc}
3693
          {  @@rgb_greenMask  }
4060
          {  @@rgb_greenMask  }
3694
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
4061
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.Mask]
3695
          mov edx,offset @@rgb_greenMask-4
4062
          mov edx,offset @@rgb_greenMask-4
3696
          sub edx,offset @@StartCode
4063
          sub edx,offset @@StartCode
3697
          mov dword ptr [ecx+edx],eax
4064
          mov dword ptr [ecx+edx],eax
3698
 
4065
 
3699
          {  @@rgb_greenLShift  }
4066
          {  @@rgb_greenLShift  }
3700
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
4067
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_green.lshift]
3701
          mov edx,offset @@rgb_greenLShift-1
4068
          mov edx,offset @@rgb_greenLShift-1
3702
          sub edx,offset @@StartCode
4069
          sub edx,offset @@StartCode
3703
          mov byte ptr [ecx+edx],al
4070
          mov byte ptr [ecx+edx],al
3704
        end;
4071
        end;
3705
      end;
4072
      end;
3706
    end;
4073
    end;
3707
 
4074
 
3708
    {  Blue channel  }
4075
    {  Blue channel  }
3709
    if chBlue in EnableChannels then
4076
    if chBlue in EnableChannels then
3710
    begin
4077
    begin
3711
      asm
4078
      asm
3712
        jmp @@EndCode
4079
        jmp @@EndCode
3713
      @@StartCode:
4080
      @@StartCode:
3714
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
4081
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.B
3715
      @@EndCode:
4082
      @@EndCode:
3716
        {$I DXRender.inc}
4083
        {$I DXRender.inc}
3717
        {  @@Src  }
4084
        {  @@Src  }
3718
        mov eax,Src; add eax,BYTE(TDXRMachine_Color.B+1)
4085
        mov eax,Src; add eax,Byte(TDXRMachine_Color.B+1)
3719
        mov edx,offset @@Src-4
4086
        mov edx,offset @@Src-4
3720
        sub edx,offset @@StartCode
4087
        sub edx,offset @@StartCode
3721
        mov dword ptr [ecx+edx],eax
4088
        mov dword ptr [ecx+edx],eax
3722
      end;
4089
      end;
3723
 
4090
 
3724
      if Surface.rgb_blue.Bitcount<7 then
4091
      if Surface.rgb_blue.Bitcount<7 then
3725
      begin
4092
      begin
3726
        asm
4093
        asm
3727
          jmp @@EndCode
4094
          jmp @@EndCode
3728
        @@StartCode:
4095
        @@StartCode:
3729
          mov ebx,edx
4096
          mov ebx,edx
3730
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
4097
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
3731
          and ebx,3
4098
          and ebx,3
3732
          movzx ebx,byte ptr [ebp+ebx*4]
4099
          movzx ebx,byte ptr [ebp+ebx*4]
3733
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
4100
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
3734
          movzx edx,byte [offset (_AddTable+edx+ebx)]
4101
          movzx edx,byte [offset (_AddTable+edx+ebx)]
3735
        @@EndCode:
4102
        @@EndCode:
3736
          {$I DXRender.inc}
4103
          {$I DXRender.inc}
3737
          {  @@BitCount  }
4104
          {  @@BitCount  }
3738
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_blue.Bitcount]
4105
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_blue.Bitcount]
3739
          mov edx,offset @@BitCount-1
4106
          mov edx,offset @@BitCount-1
3740
          sub edx,offset @@StartCode
4107
          sub edx,offset @@StartCode
3741
          mov byte ptr [ecx+edx],al
4108
          mov byte ptr [ecx+edx],al
3742
 
4109
 
3743
          {  @@BitCount2  }
4110
          {  @@BitCount2  }
3744
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_blue.Bitcount]
4111
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_blue.Bitcount]
3745
          mov edx,offset @@BitCount2-1
4112
          mov edx,offset @@BitCount2-1
3746
          sub edx,offset @@StartCode
4113
          sub edx,offset @@StartCode
3747
          mov byte ptr [ecx+edx],al
4114
          mov byte ptr [ecx+edx],al
3748
        end;
4115
        end;
3749
      end;
4116
      end;
3750
 
4117
 
3751
      if Surface.rgb_blue.rshift<>0 then
4118
      if Surface.rgb_blue.rshift<>0 then
3752
      begin
4119
      begin
3753
        asm
4120
        asm
3754
          jmp @@EndCode
4121
          jmp @@EndCode
3755
        @@StartCode:
4122
        @@StartCode:
3756
          shl edx,$11      {}@@rgb_blueRShift:  // Surface.rgb_blue.rshift
4123
          shl edx,$11      {}@@rgb_blueRShift:  // Surface.rgb_blue.rshift
3757
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
4124
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3758
          or eax,edx
4125
          or eax,edx
3759
        @@EndCode:
4126
        @@EndCode:
3760
          {$I DXRender.inc}
4127
          {$I DXRender.inc}
3761
          {  @@rgb_blueMask  }
4128
          {  @@rgb_blueMask  }
3762
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
4129
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3763
          mov edx,offset @@rgb_blueMask-4
4130
          mov edx,offset @@rgb_blueMask-4
3764
          sub edx,offset @@StartCode
4131
          sub edx,offset @@StartCode
3765
          mov dword ptr [ecx+edx],eax
4132
          mov dword ptr [ecx+edx],eax
3766
 
4133
 
3767
          {  @@rgb_blueRShift  }
4134
          {  @@rgb_blueRShift  }
3768
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
4135
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.rshift]
3769
          mov edx,offset @@rgb_blueRShift-1
4136
          mov edx,offset @@rgb_blueRShift-1
3770
          sub edx,offset @@StartCode
4137
          sub edx,offset @@StartCode
3771
          mov byte ptr [ecx+edx],al
4138
          mov byte ptr [ecx+edx],al
3772
        end;
4139
        end;
3773
      end else
4140
      end else
3774
      begin
4141
      begin
3775
        asm
4142
        asm
3776
          jmp @@EndCode
4143
          jmp @@EndCode
3777
        @@StartCode:
4144
        @@StartCode:
3778
          shr edx,$11      {}@@rgb_blueLShift:  // Surface.rgb_blue.lshift
4145
          shr edx,$11      {}@@rgb_blueLShift:  // Surface.rgb_blue.lshift
3779
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
4146
          and edx,$11111111{}@@rgb_blueMask:    // Surface.rgb_blue.Mask
3780
          or eax,edx
4147
          or eax,edx
3781
        @@EndCode:
4148
        @@EndCode:
3782
          {$I DXRender.inc}
4149
          {$I DXRender.inc}
3783
          {  @@rgb_blueMask  }
4150
          {  @@rgb_blueMask  }
3784
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
4151
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.Mask]
3785
          mov edx,offset @@rgb_blueMask-4
4152
          mov edx,offset @@rgb_blueMask-4
3786
          sub edx,offset @@StartCode
4153
          sub edx,offset @@StartCode
3787
          mov dword ptr [ecx+edx],eax
4154
          mov dword ptr [ecx+edx],eax
3788
 
4155
 
3789
          {  @@rgb_blueLShift  }
4156
          {  @@rgb_blueLShift  }
3790
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
4157
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_blue.lshift]
3791
          mov edx,offset @@rgb_blueLShift-1
4158
          mov edx,offset @@rgb_blueLShift-1
3792
          sub edx,offset @@StartCode
4159
          sub edx,offset @@StartCode
3793
          mov byte ptr [ecx+edx],al
4160
          mov byte ptr [ecx+edx],al
3794
        end;
4161
        end;
3795
      end;
4162
      end;
3796
    end;
4163
    end;
3797
 
4164
 
3798
    {  Alpha channel  }
4165
    {  Alpha channel  }
3799
    if chAlpha in EnableChannels then
4166
    if chAlpha in EnableChannels then
3800
    begin
4167
    begin
3801
      asm
4168
      asm
3802
        jmp @@EndCode
4169
        jmp @@EndCode
3803
      @@StartCode:
4170
      @@StartCode:
3804
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
4171
        movzx edx,byte ptr [offset _null]{}@@Src:// @Src.R
3805
      @@EndCode:
4172
      @@EndCode:
3806
        {$I DXRender.inc}
4173
        {$I DXRender.inc}
3807
        {  @@Src  }
4174
        {  @@Src  }
3808
        mov eax,Src; add eax,BYTE(TDXRMachine_Color.A+1)
4175
        mov eax,Src; add eax,Byte(TDXRMachine_Color.A+1)
3809
        mov edx,offset @@Src-4
4176
        mov edx,offset @@Src-4
3810
        sub edx,offset @@StartCode
4177
        sub edx,offset @@StartCode
3811
        mov dword ptr [ecx+edx],eax
4178
        mov dword ptr [ecx+edx],eax
3812
      end;
4179
      end;
3813
 
4180
 
3814
      if Surface.rgb_alpha.Bitcount<7 then
4181
      if Surface.rgb_alpha.Bitcount<7 then
3815
      begin
4182
      begin
3816
        asm
4183
        asm
3817
          jmp @@EndCode
4184
          jmp @@EndCode
3818
        @@StartCode:
4185
        @@StartCode:
3819
          mov ebx,edx
4186
          mov ebx,edx
3820
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
4187
          shr ebx,$11       {}@@BitCount:  // 6-bitcount
3821
          and ebx,3
4188
          and ebx,3
3822
          movzx ebx,byte ptr [ebp+ebx]
4189
          movzx ebx,byte ptr [ebp+ebx]
3823
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
4190
          shl ebx,$11       {}@@BitCount2: // 8-bitcount
3824
          movzx edx,byte [offset (_AddTable+edx+ebx)]
4191
          movzx edx,byte [offset (_AddTable+edx+ebx)]
3825
        @@EndCode:
4192
        @@EndCode:
3826
          {$I DXRender.inc}
4193
          {$I DXRender.inc}
3827
          {  @@BitCount  }
4194
          {  @@BitCount  }
3828
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_alpha.Bitcount]
4195
          mov eax,6; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_alpha.Bitcount]
3829
          mov edx,offset @@BitCount-1
4196
          mov edx,offset @@BitCount-1
3830
          sub edx,offset @@StartCode
4197
          sub edx,offset @@StartCode
3831
          mov byte ptr [ecx+edx],al
4198
          mov byte ptr [ecx+edx],al
3832
 
4199
 
3833
          {  @@BitCount2  }
4200
          {  @@BitCount2  }
3834
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_alpha.Bitcount]
4201
          mov eax,8; mov edx,Surface; sub eax,[edx + TDXR_Surface.rgb_alpha.Bitcount]
3835
          mov edx,offset @@BitCount2-1
4202
          mov edx,offset @@BitCount2-1
3836
          sub edx,offset @@StartCode
4203
          sub edx,offset @@StartCode
3837
          mov byte ptr [ecx+edx],al
4204
          mov byte ptr [ecx+edx],al
3838
        end;
4205
        end;
3839
      end;
4206
      end;
3840
 
4207
 
3841
      if Surface.rgb_alpha.rshift<>0 then
4208
      if Surface.rgb_alpha.rshift<>0 then
3842
      begin
4209
      begin
3843
        asm
4210
        asm
3844
          jmp @@EndCode
4211
          jmp @@EndCode
3845
        @@StartCode:
4212
        @@StartCode:
3846
          shl edx,$11      {}@@rgb_alphaRShift:  // Surface.rgb_alpha.rshift
4213
          shl edx,$11      {}@@rgb_alphaRShift:  // Surface.rgb_alpha.rshift
3847
          and edx,$11111111{}@@rgb_alphaMask:    // Surface.rgb_alpha.Mask
4214
          and edx,$11111111{}@@rgb_alphaMask:    // Surface.rgb_alpha.Mask
3848
          or eax,edx
4215
          or eax,edx
3849
        @@EndCode:
4216
        @@EndCode:
3850
          {$I DXRender.inc}
4217
          {$I DXRender.inc}
3851
          {  @@rgb_alphaMask  }
4218
          {  @@rgb_alphaMask  }
3852
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
4219
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3853
          mov edx,offset @@rgb_alphaMask-4
4220
          mov edx,offset @@rgb_alphaMask-4
3854
          sub edx,offset @@StartCode
4221
          sub edx,offset @@StartCode
3855
          mov dword ptr [ecx+edx],eax
4222
          mov dword ptr [ecx+edx],eax
3856
 
4223
 
3857
          {  @@rgb_alphaRShift  }
4224
          {  @@rgb_alphaRShift  }
3858
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
4225
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.rshift]
3859
          mov edx,offset @@rgb_alphaRShift-1
4226
          mov edx,offset @@rgb_alphaRShift-1
3860
          sub edx,offset @@StartCode
4227
          sub edx,offset @@StartCode
3861
          mov byte ptr [ecx+edx],al
4228
          mov byte ptr [ecx+edx],al
3862
        end;
4229
        end;
3863
      end else
4230
      end else
3864
      begin
4231
      begin
3865
        asm
4232
        asm
3866
          jmp @@EndCode
4233
          jmp @@EndCode
3867
        @@StartCode:
4234
        @@StartCode:
3868
          shr edx,$11      {}@@rgb_alphaLShift:  // Surface.rgb_alpha.lshift
4235
          shr edx,$11      {}@@rgb_alphaLShift:  // Surface.rgb_alpha.lshift
3869
          and edx,$11111111{}@@rgb_alphaMask:    // Surface.rgb_alpha.Mask
4236
          and edx,$11111111{}@@rgb_alphaMask:    // Surface.rgb_alpha.Mask
3870
          or eax,edx
4237
          or eax,edx
3871
        @@EndCode:
4238
        @@EndCode:
3872
          {$I DXRender.inc}
4239
          {$I DXRender.inc}
3873
          {  @@rgb_alphaMask  }
4240
          {  @@rgb_alphaMask  }
3874
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
4241
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.Mask]
3875
          mov edx,offset @@rgb_alphaMask-4
4242
          mov edx,offset @@rgb_alphaMask-4
3876
          sub edx,offset @@StartCode
4243
          sub edx,offset @@StartCode
3877
          mov dword ptr [ecx+edx],eax
4244
          mov dword ptr [ecx+edx],eax
3878
 
4245
 
3879
          {  @@rgb_alphaLShift  }
4246
          {  @@rgb_alphaLShift  }
3880
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
4247
          mov eax,Surface; mov eax,[eax + TDXR_Surface.rgb_alpha.lshift]
3881
          mov edx,offset @@rgb_alphaLShift-1
4248
          mov edx,offset @@rgb_alphaLShift-1
3882
          sub edx,offset @@StartCode
4249
          sub edx,offset @@StartCode
3883
          mov byte ptr [ecx+edx],al
4250
          mov byte ptr [ecx+edx],al
3884
        end;
4251
        end;
3885
      end;
4252
      end;
3886
    end;
4253
    end;
3887
  end;
4254
  end;
3888
 
4255
 
3889
  procedure genEncodeColor2(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color; EnableChannels: TDXRColorChannels);
4256
  procedure genEncodeColor2(var Code: Pointer; const Surface: TDXR_Surface; Src: PDXRMachine_Color; EnableChannels: TDXRColorChannels);
3890
  begin
4257
  begin
3891
    if Dither.Enable then
4258
    if Dither.Enable then
-
 
4259
    begin
3892
      genEncodeColor_with_Dither(Code, Surface, Src, @Axis.Axis, EnableChannels)
4260
      genEncodeColor_with_Dither(Code, Surface, Src, @Axis.Axis, EnableChannels)
3893
    else
4261
    end else
-
 
4262
    begin
3894
      genEncodeColor(Code, Surface, Src, EnableChannels);
4263
      genEncodeColor(Code, Surface, Src, EnableChannels);
3895
  end;
4264
    end;
-
 
4265
  end;
3896
 
4266
 
3897
  procedure genColorKey(var Code: Pointer; const Texture: TDXRMachine_Reg_Texture);
4267
  procedure genColorKey(var Code: Pointer; const Texture: TDXRMachine_Reg_Texture);
3898
  var
4268
  var
3899
    TransparentMask, TransparentColor: DWORD;
4269
    TransparentMask, TransparentColor: DWORD;
3900
  begin
4270
  begin
3901
    if not Texture.ColorKeyEnable then Exit;
4271
    if not Texture.ColorKeyEnable then Exit;
3902
 
4272
 
3903
    if Texture.Surface.ColorType=DXR_COLORTYPE_INDEXED then
4273
    if Texture.Surface.ColorType=DXR_COLORTYPE_INDEXED then
3904
    begin
4274
    begin
3905
      TransparentMask := not Texture.Surface.idx_alpha.Mask;
4275
      TransparentMask := not Texture.Surface.idx_alpha.Mask;
3906
    end else if Texture.Surface.ColorType=DXR_COLORTYPE_RGB then
4276
    end else if Texture.Surface.ColorType=DXR_COLORTYPE_RGB then
3907
    begin
4277
    begin
3908
      TransparentMask := not Texture.Surface.rgb_alpha.Mask;
4278
      TransparentMask := not Texture.Surface.rgb_alpha.Mask;
3909
    end;
4279
    end;
3910
 
4280
 
3911
    TransparentColor := Texture.ColorKey;
4281
    TransparentColor := Texture.ColorKey;
3912
 
4282
 
3913
    if TransparentMask=$FFFFFFFF then
4283
    if TransparentMask=$FFFFFFFF then
3914
    begin
4284
    begin
3915
      if Texture.Surface.BitCount=32 then
4285
      if Texture.Surface.BitCount=32 then
3916
      begin
4286
      begin
3917
        if TransparentColor=0 then
4287
        if TransparentColor=0 then
3918
        begin
4288
        begin
3919
          asm
4289
          asm
3920
            jmp @@EndCode
4290
            jmp @@EndCode
3921
          @@StartCode:
4291
          @@StartCode:
3922
            and eax,$FFFFFF
4292
            and eax,$FFFFFF
3923
          @@EndCode:
4293
          @@EndCode:
3924
            {$I DXRender.inc}
4294
            {$I DXRender.inc}
3925
          end;
4295
          end;
3926
        end else
4296
        end else
3927
        begin
4297
        begin
3928
          asm
4298
          asm
3929
            jmp @@EndCode
4299
            jmp @@EndCode
3930
          @@StartCode:
4300
          @@StartCode:
3931
            and eax,$FFFFFF
4301
            and eax,$FFFFFF
3932
            cmp eax,$11111111{}@@TransColor: // Process.Texture.TransparentColor
4302
            cmp eax,$11111111{}@@TransColor: // Process.Texture.TransparentColor
3933
          @@EndCode:
4303
          @@EndCode:
3934
            {$I DXRender.inc}
4304
            {$I DXRender.inc}
3935
            {  @@TransColor  }
4305
            {  @@TransColor  }
3936
            mov eax,TransparentColor
4306
            mov eax,TransparentColor
3937
            mov edx,offset @@TransColor-4
4307
            mov edx,offset @@TransColor-4
3938
            sub edx,offset @@StartCode
4308
            sub edx,offset @@StartCode
3939
            mov dword ptr [ecx+edx],eax
4309
            mov dword ptr [ecx+edx],eax
3940
          end;
4310
          end;
3941
        end;
4311
        end;
3942
      end else
4312
      end else
3943
      begin
4313
      begin
3944
        if TransparentColor=0 then
4314
        if TransparentColor=0 then
3945
        begin
4315
        begin
3946
          asm
4316
          asm
3947
            jmp @@EndCode
4317
            jmp @@EndCode
3948
          @@StartCode:
4318
          @@StartCode:
3949
            test eax,eax
4319
            test eax,eax
3950
          @@EndCode:
4320
          @@EndCode:
3951
            {$I DXRender.inc}
4321
            {$I DXRender.inc}
3952
          end;
4322
          end;
3953
        end else
4323
        end else
3954
        begin
4324
        begin
3955
          asm
4325
          asm
3956
            jmp @@EndCode
4326
            jmp @@EndCode
3957
          @@StartCode:
4327
          @@StartCode:
3958
            cmp eax,$11111111{}@@TransColor: // Process.Texture.TransparentColor
4328
            cmp eax,$11111111{}@@TransColor: // Process.Texture.TransparentColor
3959
          @@EndCode:
4329
          @@EndCode:
3960
            {$I DXRender.inc}
4330
            {$I DXRender.inc}
3961
            {  @@TransColor  }
4331
            {  @@TransColor  }
3962
            mov eax,TransparentColor
4332
            mov eax,TransparentColor
3963
            mov edx,offset @@TransColor-4
4333
            mov edx,offset @@TransColor-4
3964
            sub edx,offset @@StartCode
4334
            sub edx,offset @@StartCode
3965
            mov dword ptr [ecx+edx],eax
4335
            mov dword ptr [ecx+edx],eax
3966
          end;
4336
          end;
3967
        end;
4337
        end;
3968
      end;
4338
      end;
3969
    end else
4339
    end else
3970
    begin
4340
    begin
3971
      if Texture.Surface.BitCount=32 then
4341
      if Texture.Surface.BitCount=32 then
3972
        TransparentMask := TransparentMask and $FFFFFF;
4342
        TransparentMask := TransparentMask and $FFFFFF;
3973
 
4343
 
3974
      asm
4344
      asm
3975
        jmp @@EndCode
4345
        jmp @@EndCode
3976
      @@StartCode:
4346
      @@StartCode:
3977
        mov edx,eax
4347
        mov edx,eax
3978
        and edx,$11111111{}@@TransMask:  // TransparentMask
4348
        and edx,$11111111{}@@TransMask:  // TransparentMask
3979
        cmp edx,$11111111{}@@TransColor: // Process.Texture.TransparentColor
4349
        cmp edx,$11111111{}@@TransColor: // Process.Texture.TransparentColor
3980
      @@EndCode:
4350
      @@EndCode:
3981
        {$I DXRender.inc}
4351
        {$I DXRender.inc}
3982
        {  @@TransMask  }
4352
        {  @@TransMask  }
3983
        mov eax,TransparentMask
4353
        mov eax,TransparentMask
3984
        mov edx,offset @@TransMask-4
4354
        mov edx,offset @@TransMask-4
3985
        sub edx,offset @@StartCode
4355
        sub edx,offset @@StartCode
3986
        mov dword ptr [ecx+edx],eax
4356
        mov dword ptr [ecx+edx],eax
3987
 
4357
 
3988
        {  @@TransColor  }
4358
        {  @@TransColor  }
3989
        mov eax,TransparentColor
4359
        mov eax,TransparentColor
3990
        mov edx,offset @@TransColor-4
4360
        mov edx,offset @@TransColor-4
3991
        sub edx,offset @@StartCode
4361
        sub edx,offset @@StartCode
3992
        mov dword ptr [ecx+edx],eax
4362
        mov dword ptr [ecx+edx],eax
3993
      end;
4363
      end;
3994
    end;
4364
    end;
3995
 
4365
 
3996
    genCmpFunc(Code, DXR_CMPFUNC_EQUAL, SkipAddress);
4366
    genCmpFunc(Code, DXR_CMPFUNC_EQUAL, SkipAddress);
3997
  end;
4367
  end;
3998
 
4368
 
3999
  procedure genReadTexture_Nearest(var Code: Pointer; Dest: PDXRMachine_Color;
4369
  procedure genReadTexture_Nearest(var Code: Pointer; Dest: PDXRMachine_Color;
4000
    const Texture: TDXRMachine_Reg_Texture; const Axis: TDXRMachine_Axis; EnableChannels: TDXRColorChannels);
4370
    const Texture: TDXRMachine_Reg_Texture; const Axis: TDXRMachine_Axis; EnableChannels: TDXRColorChannels);
4001
  begin
4371
  begin
4002
    if EnableChannels=[] then Exit;
4372
    if EnableChannels=[] then Exit;
4003
 
4373
 
4004
    genReadSurfacePixel(Code, Texture, @Axis);
4374
    genReadSurfacePixel(Code, Texture, @Axis);
4005
    genColorKey(Code, Texture);
4375
    genColorKey(Code, Texture);
4006
    genDecodeColor(Code, Texture.Surface^, Dest, EnableChannels, Texture.DefaultColor);
4376
    genDecodeColor(Code, Texture.Surface^, Dest, EnableChannels, Texture.DefaultColor);
4007
  end;
4377
  end;
4008
 
4378
 
4009
  procedure genReadTexture_BiLinear(var Code: Pointer; Dest: PDXRMachine_Color;
4379
  procedure genReadTexture_BiLinear(var Code: Pointer; Dest: PDXRMachine_Color;
4010
    const Texture: TDXRMachine_Reg_Texture; const Axis: TDXRMachine_Axis; EnableChannels: TDXRColorChannels);
4380
    const Texture: TDXRMachine_Reg_Texture; const Axis: TDXRMachine_Axis; EnableChannels: TDXRColorChannels);
4011
  var
4381
  var
4012
    _Axis, _BiLinearAxis, _BiLinearCol1, _BiLinearCol2, _BiLinearCol3, _BiLinearCol4: Pointer;
4382
    _Axis, _BiLinearAxis, _BiLinearCol1, _BiLinearCol2, _BiLinearCol3, _BiLinearCol4: Pointer;
4013
  begin
4383
  begin
4014
    if EnableChannels=[] then Exit;
4384
    if EnableChannels=[] then Exit;
4015
 
4385
 
4016
    _Axis := @Axis;
4386
    _Axis := @Axis;
4017
    _BiLinearAxis := @F_BiLinearAxis;
4387
    _BiLinearAxis := @F_BiLinearAxis;
4018
    _BiLinearCol1 := @F_BiLinearCol1;
4388
    _BiLinearCol1 := @F_BiLinearCol1;
4019
    _BiLinearCol2 := @F_BiLinearCol2;
4389
    _BiLinearCol2 := @F_BiLinearCol2;
4020
    _BiLinearCol3 := @F_BiLinearCol3;
4390
    _BiLinearCol3 := @F_BiLinearCol3;
4021
    _BiLinearCol4 := @F_BiLinearCol4;
4391
    _BiLinearCol4 := @F_BiLinearCol4;
4022
 
4392
 
4023
    genReadSurfacePixel(Code, Texture, _Axis);
4393
    genReadSurfacePixel(Code, Texture, _Axis);
4024
    genColorKey(Code, Texture);
4394
    genColorKey(Code, Texture);
4025
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol1, EnableChannels, Texture.DefaultColor);
4395
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol1, EnableChannels, Texture.DefaultColor);
4026
 
4396
 
4027
    asm
4397
    asm
4028
      jmp @@EndCode
4398
      jmp @@EndCode
4029
    @@StartCode:
4399
    @@StartCode:
4030
      mov eax,dword ptr [offset _null]{}@@TexX:
4400
      mov eax,dword ptr [offset _null]{}@@TexX:
4031
      mov edx,dword ptr [offset _null]{}@@TexY:
4401
      mov edx,dword ptr [offset _null]{}@@TexY:
4032
      add eax,65536
4402
      add eax,65536
4033
      mov dword ptr [offset _null],edx{}@@AxisY:
4403
      mov dword ptr [offset _null],edx{}@@AxisY:
4034
      mov dword ptr [offset _null],eax{}@@AxisX:
4404
      mov dword ptr [offset _null],eax{}@@AxisX:
4035
    @@EndCode:
4405
    @@EndCode:
4036
      {$I DXRender.inc}
4406
      {$I DXRender.inc}
4037
      {  @@TexX  }
4407
      {  @@TexX  }
4038
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
4408
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
4039
      mov edx,offset @@TexX-4
4409
      mov edx,offset @@TexX-4
4040
      sub edx,offset @@StartCode
4410
      sub edx,offset @@StartCode
4041
      mov dword ptr [ecx+edx],eax
4411
      mov dword ptr [ecx+edx],eax
4042
 
4412
 
4043
      {  @@TexY  }
4413
      {  @@TexY  }
4044
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
4414
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
4045
      mov edx,offset @@TexY-4
4415
      mov edx,offset @@TexY-4
4046
      sub edx,offset @@StartCode
4416
      sub edx,offset @@StartCode
4047
      mov dword ptr [ecx+edx],eax
4417
      mov dword ptr [ecx+edx],eax
4048
 
4418
 
4049
      {  @@AxisX  }
4419
      {  @@AxisX  }
4050
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.X
4420
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.X
4051
      mov edx,offset @@AxisX-4
4421
      mov edx,offset @@AxisX-4
4052
      sub edx,offset @@StartCode
4422
      sub edx,offset @@StartCode
4053
      mov dword ptr [ecx+edx],eax
4423
      mov dword ptr [ecx+edx],eax
4054
 
4424
 
4055
      {  @@AxisY  }
4425
      {  @@AxisY  }
4056
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.Y
4426
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.Y
4057
      mov edx,offset @@AxisY-4
4427
      mov edx,offset @@AxisY-4
4058
      sub edx,offset @@StartCode
4428
      sub edx,offset @@StartCode
4059
      mov dword ptr [ecx+edx],eax
4429
      mov dword ptr [ecx+edx],eax
4060
    end;
4430
    end;
4061
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4431
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4062
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol2, EnableChannels, Texture.DefaultColor);
4432
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol2, EnableChannels, Texture.DefaultColor);
4063
 
4433
 
4064
    asm
4434
    asm
4065
      jmp @@EndCode
4435
      jmp @@EndCode
4066
    @@StartCode:
4436
    @@StartCode:
4067
      add dword ptr [offset _null],65536{}@@AxisY:
4437
      add dword ptr [offset _null],65536{}@@AxisY:
4068
    @@EndCode:
4438
    @@EndCode:
4069
      {$I DXRender.inc}
4439
      {$I DXRender.inc}
4070
      {  @@AxisY  }
4440
      {  @@AxisY  }
4071
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.Y
4441
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.Y
4072
      mov edx,offset @@AxisY-8
4442
      mov edx,offset @@AxisY-8
4073
      sub edx,offset @@StartCode
4443
      sub edx,offset @@StartCode
4074
      mov dword ptr [ecx+edx],eax
4444
      mov dword ptr [ecx+edx],eax
4075
    end;
4445
    end;
4076
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4446
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4077
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol4, EnableChannels, Texture.DefaultColor);
4447
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol4, EnableChannels, Texture.DefaultColor);
4078
 
4448
 
4079
    asm
4449
    asm
4080
      jmp @@EndCode
4450
      jmp @@EndCode
4081
    @@StartCode:
4451
    @@StartCode:
4082
      sub dword ptr [offset _null],65536{}@@AxisX:
4452
      sub dword ptr [offset _null],65536{}@@AxisX:
4083
    @@EndCode:
4453
    @@EndCode:
4084
      {$I DXRender.inc}
4454
      {$I DXRender.inc}
4085
      {  @@AxisX  }
4455
      {  @@AxisX  }
4086
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.X
4456
      mov eax,_BiLinearAxis; add eax,TDXRMachine_Axis.X
4087
      mov edx,offset @@AxisX-8
4457
      mov edx,offset @@AxisX-8
4088
      sub edx,offset @@StartCode
4458
      sub edx,offset @@StartCode
4089
      mov dword ptr [ecx+edx],eax
4459
      mov dword ptr [ecx+edx],eax
4090
    end;
4460
    end;
4091
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4461
    genReadSurfacePixel(Code, Texture, _BiLinearAxis);
4092
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol3, EnableChannels, Texture.DefaultColor);
4462
    genDecodeColor(Code, Texture.Surface^, _BiLinearCol3, EnableChannels, Texture.DefaultColor);
4093
                 (*
4463
                 (*
4094
    if UseMMX then
4464
    if UseMMX then
4095
    begin
4465
    begin
4096
      asm
4466
      asm
4097
        jmp @@EndCode
4467
        jmp @@EndCode
4098
      @@StartCode:
4468
      @@StartCode:
4099
        movzx eax,byte ptr [offset _null]{}@@TexX:
4469
        movzx eax,byte ptr [offset _null]{}@@TexX:
4100
        movzx edx,byte ptr [offset _null]{}@@TexY:
4470
        movzx edx,byte ptr [offset _null]{}@@TexY:
4101
 
4471
 
4102
        db $0F,$6F,$1C,$C5,$11,$11,$11,$11///movq mm3,qword ptr [$11111111+eax*8]
4472
        db $0F,$6F,$1C,$C5,$11,$11,$11,$11///movq mm3,qword ptr [$11111111+eax*8]
4103
                               @@_ByteToQWORDTable1:
4473
                               @@_ByteToQWORDTable1:
4104
        xor eax,$FF
4474
        xor eax,$FF
4105
        db $0F,$6F,$24,$C5,$11,$11,$11,$11///movq mm4,qword ptr [$11111111+eax*8]
4475
        db $0F,$6F,$24,$C5,$11,$11,$11,$11///movq mm4,qword ptr [$11111111+eax*8]
4106
                               @@_ByteToQWORDTable2:
4476
                               @@_ByteToQWORDTable2:
4107
 
4477
 
4108
        db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
4478
        db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
4109
                               @@_BiLinearCol1:
4479
                               @@_BiLinearCol1:
4110
        db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
4480
        db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
4111
                               @@_BiLinearCol2:
4481
                               @@_BiLinearCol2:
4112
 
4482
 
4113
        db $0F,$D5,$C3        ///pmullw mm0,mm3
4483
        db $0F,$D5,$C3        ///pmullw mm0,mm3
4114
        db $0F,$D5,$CC        ///pmullw mm1,mm4
4484
        db $0F,$D5,$CC        ///pmullw mm1,mm4
4115
        db $0F,$FD,$C1        ///paddw mm0,mm1
4485
        db $0F,$FD,$C1        ///paddw mm0,mm1
4116
        db $0F,$71,$D0,$08    ///psrlw mm0,8
4486
        db $0F,$71,$D0,$08    ///psrlw mm0,8
4117
 
4487
 
4118
        db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
4488
        db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
4119
                               @@_BiLinearCol3:
4489
                               @@_BiLinearCol3:
4120
        db $0F,$6F,$15,$11,$11,$11,$11///movq mm2,qword ptr [$11111111]
4490
        db $0F,$6F,$15,$11,$11,$11,$11///movq mm2,qword ptr [$11111111]
4121
                               @@_BiLinearCol4:
4491
                               @@_BiLinearCol4:
4122
 
4492
 
4123
        db $0F,$D5,$CB        ///pmullw mm1,mm3
4493
        db $0F,$D5,$CB        ///pmullw mm1,mm3
4124
        db $0F,$D5,$D4        ///pmullw mm2,mm4
4494
        db $0F,$D5,$D4        ///pmullw mm2,mm4
4125
        db $0F,$FD,$CA        ///paddw mm1,mm2
4495
        db $0F,$FD,$CA        ///paddw mm1,mm2
4126
        db $0F,$71,$D1,$08    ///psrlw mm1,8
4496
        db $0F,$71,$D1,$08    ///psrlw mm1,8
4127
 
4497
 
4128
        db $0F,$D5,$04,$D5,$11,$11,$11,$11///pmullw mm0,qword ptr [$11111111+edx*8]
4498
        db $0F,$D5,$04,$D5,$11,$11,$11,$11///pmullw mm0,qword ptr [$11111111+edx*8]
4129
                               @@_ByteToQWORDTable3:
4499
                               @@_ByteToQWORDTable3:
4130
        xor edx,$FF
4500
        xor edx,$FF
4131
        db $0F,$D5,$0C,$D5,$11,$11,$11,$11///pmullw mm1,qword ptr [$11111111+edx*8]
4501
        db $0F,$D5,$0C,$D5,$11,$11,$11,$11///pmullw mm1,qword ptr [$11111111+edx*8]
4132
                               @@_ByteToQWORDTable4:
4502
                               @@_ByteToQWORDTable4:
4133
        db $0F,$FD,$C1        ///paddw mm0,mm1
4503
        db $0F,$FD,$C1        ///paddw mm0,mm1
4134
        db $0F,$71,$D0,$08    ///psrlw mm0,8
4504
        db $0F,$71,$D0,$08    ///psrlw mm0,8
4135
 
4505
 
4136
        db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
4506
        db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
4137
                               @@Dest:
4507
                               @@Dest:
4138
      @@EndCode:
4508
      @@EndCode:
4139
        {$I DXRender.inc}
4509
        {$I DXRender.inc}
4140
        {  @@TexX  }
4510
        {  @@TexX  }
4141
        mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4511
        mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4142
        mov edx,offset @@TexX-4
4512
        mov edx,offset @@TexX-4
4143
        sub edx,offset @@StartCode
4513
        sub edx,offset @@StartCode
4144
        mov dword ptr [ecx+edx],eax
4514
        mov dword ptr [ecx+edx],eax
4145
 
4515
 
4146
        {  @@TexY  }
4516
        {  @@TexY  }
4147
        mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4517
        mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4148
        mov edx,offset @@TexY-4
4518
        mov edx,offset @@TexY-4
4149
        sub edx,offset @@StartCode
4519
        sub edx,offset @@StartCode
4150
        mov dword ptr [ecx+edx],eax
4520
        mov dword ptr [ecx+edx],eax
4151
 
4521
 
4152
        {  @@_ByteToQWORDTable1  }
4522
        {  @@_ByteToQWORDTable1  }
4153
        mov eax,offset _ByteToQWORDTable
4523
        mov eax,offset _ByteToQWORDTable
4154
        mov edx,offset @@_ByteToQWORDTable1-4
4524
        mov edx,offset @@_ByteToQWORDTable1-4
4155
        sub edx,offset @@StartCode
4525
        sub edx,offset @@StartCode
4156
        mov dword ptr [ecx+edx],eax
4526
        mov dword ptr [ecx+edx],eax
4157
 
4527
 
4158
        {  @@_ByteToQWORDTable2  }
4528
        {  @@_ByteToQWORDTable2  }
4159
        mov eax,offset _ByteToQWORDTable
4529
        mov eax,offset _ByteToQWORDTable
4160
        mov edx,offset @@_ByteToQWORDTable2-4
4530
        mov edx,offset @@_ByteToQWORDTable2-4
4161
        sub edx,offset @@StartCode
4531
        sub edx,offset @@StartCode
4162
        mov dword ptr [ecx+edx],eax
4532
        mov dword ptr [ecx+edx],eax
4163
 
4533
 
4164
        {  @@_ByteToQWORDTable3  }
4534
        {  @@_ByteToQWORDTable3  }
4165
        mov eax,offset _ByteToQWORDTable
4535
        mov eax,offset _ByteToQWORDTable
4166
        mov edx,offset @@_ByteToQWORDTable3-4
4536
        mov edx,offset @@_ByteToQWORDTable3-4
4167
        sub edx,offset @@StartCode
4537
        sub edx,offset @@StartCode
4168
        mov dword ptr [ecx+edx],eax
4538
        mov dword ptr [ecx+edx],eax
4169
 
4539
 
4170
        {  @@_ByteToQWORDTable4  }
4540
        {  @@_ByteToQWORDTable4  }
4171
        mov eax,offset _ByteToQWORDTable
4541
        mov eax,offset _ByteToQWORDTable
4172
        mov edx,offset @@_ByteToQWORDTable4-4
4542
        mov edx,offset @@_ByteToQWORDTable4-4
4173
        sub edx,offset @@StartCode
4543
        sub edx,offset @@StartCode
4174
        mov dword ptr [ecx+edx],eax
4544
        mov dword ptr [ecx+edx],eax
4175
 
4545
 
4176
        {  @@_BiLinearCol1  }
4546
        {  @@_BiLinearCol1  }
4177
        mov eax,_BiLinearCol1
4547
        mov eax,_BiLinearCol1
4178
        mov edx,offset @@_BiLinearCol1-4
4548
        mov edx,offset @@_BiLinearCol1-4
4179
        sub edx,offset @@StartCode
4549
        sub edx,offset @@StartCode
4180
        mov dword ptr [ecx+edx],eax
4550
        mov dword ptr [ecx+edx],eax
4181
 
4551
 
4182
        {  @@_BiLinearCol2  }
4552
        {  @@_BiLinearCol2  }
4183
        mov eax,_BiLinearCol2
4553
        mov eax,_BiLinearCol2
4184
        mov edx,offset @@_BiLinearCol2-4
4554
        mov edx,offset @@_BiLinearCol2-4
4185
        sub edx,offset @@StartCode
4555
        sub edx,offset @@StartCode
4186
        mov dword ptr [ecx+edx],eax
4556
        mov dword ptr [ecx+edx],eax
4187
 
4557
 
4188
        {  @@_BiLinearCol3  }
4558
        {  @@_BiLinearCol3  }
4189
        mov eax,_BiLinearCol3
4559
        mov eax,_BiLinearCol3
4190
        mov edx,offset @@_BiLinearCol3-4
4560
        mov edx,offset @@_BiLinearCol3-4
4191
        sub edx,offset @@StartCode
4561
        sub edx,offset @@StartCode
4192
        mov dword ptr [ecx+edx],eax
4562
        mov dword ptr [ecx+edx],eax
4193
 
4563
 
4194
        {  @@_BiLinearCol4  }
4564
        {  @@_BiLinearCol4  }
4195
        mov eax,_BiLinearCol4
4565
        mov eax,_BiLinearCol4
4196
        mov edx,offset @@_BiLinearCol4-4
4566
        mov edx,offset @@_BiLinearCol4-4
4197
        sub edx,offset @@StartCode
4567
        sub edx,offset @@StartCode
4198
        mov dword ptr [ecx+edx],eax
4568
        mov dword ptr [ecx+edx],eax
4199
 
4569
 
4200
        {  @@Dest  }
4570
        {  @@Dest  }
4201
        mov eax,Dest
4571
        mov eax,Dest
4202
        mov edx,offset @@Dest-4
4572
        mov edx,offset @@Dest-4
4203
        sub edx,offset @@StartCode
4573
        sub edx,offset @@StartCode
4204
        mov dword ptr [ecx+edx],eax
4574
        mov dword ptr [ecx+edx],eax
4205
      end;
4575
      end;
4206
    end else       *)
4576
    end else       *)
4207
    begin
4577
    begin
4208
      {  Red Channel  }
4578
      {  Red Channel  }
4209
      if chRed in EnableChannels then
4579
      if chRed in EnableChannels then
4210
      begin
4580
      begin
4211
        asm
4581
        asm
4212
          jmp @@EndCode
4582
          jmp @@EndCode
4213
        @@StartCode:
4583
        @@StartCode:
4214
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4584
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4215
          movzx edx,byte ptr [offset _null]{}@@TexX:
4585
          movzx edx,byte ptr [offset _null]{}@@TexX:
4216
          imul eax,edx
4586
          imul eax,edx
4217
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4587
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4218
          xor edx,$FF
4588
          xor edx,$FF
4219
          imul ebx,edx
4589
          imul ebx,edx
4220
          add ebx,eax
4590
          add ebx,eax
4221
          xor edx,$FF
4591
          xor edx,$FF
4222
 
4592
 
4223
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4593
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4224
          imul eax,edx
4594
          imul eax,edx
4225
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4595
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4226
          xor edx,$FF
4596
          xor edx,$FF
4227
          imul ebp,edx
4597
          imul ebp,edx
4228
          add eax,ebp
4598
          add eax,ebp
4229
 
4599
 
4230
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4600
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4231
          imul eax,edx
4601
          imul eax,edx
4232
          xor edx,$FF
4602
          xor edx,$FF
4233
          imul ebx,edx
4603
          imul ebx,edx
4234
          add eax,ebx
4604
          add eax,ebx
4235
          shr eax,16
4605
          shr eax,16
4236
 
4606
 
4237
          mov byte ptr [offset _Null],al{}@@Dest:
4607
          mov byte ptr [offset _Null],al{}@@Dest:
4238
        @@EndCode:
4608
        @@EndCode:
4239
          {$I DXRender.inc}
4609
          {$I DXRender.inc}
4240
          {  @@_BiLinearCol1  }
4610
          {  @@_BiLinearCol1  }
4241
          mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.R+1)
4611
          mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.R+1)
4242
          mov edx,offset @@_BiLinearCol1-4
4612
          mov edx,offset @@_BiLinearCol1-4
4243
          sub edx,offset @@StartCode
4613
          sub edx,offset @@StartCode
4244
          mov dword ptr [ecx+edx],eax
4614
          mov dword ptr [ecx+edx],eax
4245
 
4615
 
4246
          {  @@_BiLinearCol2  }
4616
          {  @@_BiLinearCol2  }
4247
          mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.R+1)
4617
          mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.R+1)
4248
          mov edx,offset @@_BiLinearCol2-4
4618
          mov edx,offset @@_BiLinearCol2-4
4249
          sub edx,offset @@StartCode
4619
          sub edx,offset @@StartCode
4250
          mov dword ptr [ecx+edx],eax
4620
          mov dword ptr [ecx+edx],eax
4251
 
4621
 
4252
          {  @@_BiLinearCol3  }
4622
          {  @@_BiLinearCol3  }
4253
          mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.R+1)
4623
          mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.R+1)
4254
          mov edx,offset @@_BiLinearCol3-4
4624
          mov edx,offset @@_BiLinearCol3-4
4255
          sub edx,offset @@StartCode
4625
          sub edx,offset @@StartCode
4256
          mov dword ptr [ecx+edx],eax
4626
          mov dword ptr [ecx+edx],eax
4257
 
4627
 
4258
          {  @@_BiLinearCol4  }
4628
          {  @@_BiLinearCol4  }
4259
          mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.R+1)
4629
          mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.R+1)
4260
          mov edx,offset @@_BiLinearCol4-4
4630
          mov edx,offset @@_BiLinearCol4-4
4261
          sub edx,offset @@StartCode
4631
          sub edx,offset @@StartCode
4262
          mov dword ptr [ecx+edx],eax
4632
          mov dword ptr [ecx+edx],eax
4263
 
4633
 
4264
          {  @@TexX  }
4634
          {  @@TexX  }
4265
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4635
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4266
          mov edx,offset @@TexX-4
4636
          mov edx,offset @@TexX-4
4267
          sub edx,offset @@StartCode
4637
          sub edx,offset @@StartCode
4268
          mov dword ptr [ecx+edx],eax
4638
          mov dword ptr [ecx+edx],eax
4269
 
4639
 
4270
          {  @@TexY  }
4640
          {  @@TexY  }
4271
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4641
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4272
          mov edx,offset @@TexY-4
4642
          mov edx,offset @@TexY-4
4273
          sub edx,offset @@StartCode
4643
          sub edx,offset @@StartCode
4274
          mov dword ptr [ecx+edx],eax
4644
          mov dword ptr [ecx+edx],eax
4275
 
4645
 
4276
          {  @@Dest  }
4646
          {  @@Dest  }
4277
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
4647
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
4278
          mov edx,offset @@Dest-4
4648
          mov edx,offset @@Dest-4
4279
          sub edx,offset @@StartCode
4649
          sub edx,offset @@StartCode
4280
          mov dword ptr [ecx+edx],eax
4650
          mov dword ptr [ecx+edx],eax
4281
        end;
4651
        end;
4282
      end;
4652
      end;
4283
 
4653
 
4284
      {  Green Channel  }
4654
      {  Green Channel  }
4285
      if chGreen in EnableChannels then
4655
      if chGreen in EnableChannels then
4286
      begin
4656
      begin
4287
        asm
4657
        asm
4288
          jmp @@EndCode
4658
          jmp @@EndCode
4289
        @@StartCode:
4659
        @@StartCode:
4290
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4660
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4291
          movzx edx,byte ptr [offset _null]{}@@TexX:
4661
          movzx edx,byte ptr [offset _null]{}@@TexX:
4292
          imul eax,edx
4662
          imul eax,edx
4293
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4663
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4294
          xor edx,$FF
4664
          xor edx,$FF
4295
          imul ebx,edx
4665
          imul ebx,edx
4296
          add ebx,eax
4666
          add ebx,eax
4297
          xor edx,$FF
4667
          xor edx,$FF
4298
 
4668
 
4299
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4669
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4300
          imul eax,edx
4670
          imul eax,edx
4301
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4671
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4302
          xor edx,$FF
4672
          xor edx,$FF
4303
          imul ebp,edx
4673
          imul ebp,edx
4304
          add eax,ebp
4674
          add eax,ebp
4305
 
4675
 
4306
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4676
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4307
          imul eax,edx
4677
          imul eax,edx
4308
          xor edx,$FF
4678
          xor edx,$FF
4309
          imul ebx,edx
4679
          imul ebx,edx
4310
          add eax,ebx
4680
          add eax,ebx
4311
          shr eax,16
4681
          shr eax,16
4312
 
4682
 
4313
          mov byte ptr [offset _Null],al{}@@Dest:
4683
          mov byte ptr [offset _Null],al{}@@Dest:
4314
        @@EndCode:
4684
        @@EndCode:
4315
          {$I DXRender.inc}
4685
          {$I DXRender.inc}
4316
          {  @@_BiLinearCol1  }
4686
          {  @@_BiLinearCol1  }
4317
          mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.G+1)
4687
          mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.G+1)
4318
          mov edx,offset @@_BiLinearCol1-4
4688
          mov edx,offset @@_BiLinearCol1-4
4319
          sub edx,offset @@StartCode
4689
          sub edx,offset @@StartCode
4320
          mov dword ptr [ecx+edx],eax
4690
          mov dword ptr [ecx+edx],eax
4321
 
4691
 
4322
          {  @@_BiLinearCol2  }
4692
          {  @@_BiLinearCol2  }
4323
          mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.G+1)
4693
          mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.G+1)
4324
          mov edx,offset @@_BiLinearCol2-4
4694
          mov edx,offset @@_BiLinearCol2-4
4325
          sub edx,offset @@StartCode
4695
          sub edx,offset @@StartCode
4326
          mov dword ptr [ecx+edx],eax
4696
          mov dword ptr [ecx+edx],eax
4327
 
4697
 
4328
          {  @@_BiLinearCol3  }
4698
          {  @@_BiLinearCol3  }
4329
          mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.G+1)
4699
          mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.G+1)
4330
          mov edx,offset @@_BiLinearCol3-4
4700
          mov edx,offset @@_BiLinearCol3-4
4331
          sub edx,offset @@StartCode
4701
          sub edx,offset @@StartCode
4332
          mov dword ptr [ecx+edx],eax
4702
          mov dword ptr [ecx+edx],eax
4333
 
4703
 
4334
          {  @@_BiLinearCol4  }
4704
          {  @@_BiLinearCol4  }
4335
          mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.G+1)
4705
          mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.G+1)
4336
          mov edx,offset @@_BiLinearCol4-4
4706
          mov edx,offset @@_BiLinearCol4-4
4337
          sub edx,offset @@StartCode
4707
          sub edx,offset @@StartCode
4338
          mov dword ptr [ecx+edx],eax
4708
          mov dword ptr [ecx+edx],eax
4339
 
4709
 
4340
          {  @@TexX  }
4710
          {  @@TexX  }
4341
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4711
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4342
          mov edx,offset @@TexX-4
4712
          mov edx,offset @@TexX-4
4343
          sub edx,offset @@StartCode
4713
          sub edx,offset @@StartCode
4344
          mov dword ptr [ecx+edx],eax
4714
          mov dword ptr [ecx+edx],eax
4345
 
4715
 
4346
          {  @@TexY  }
4716
          {  @@TexY  }
4347
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4717
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4348
          mov edx,offset @@TexY-4
4718
          mov edx,offset @@TexY-4
4349
          sub edx,offset @@StartCode
4719
          sub edx,offset @@StartCode
4350
          mov dword ptr [ecx+edx],eax
4720
          mov dword ptr [ecx+edx],eax
4351
 
4721
 
4352
          {  @@Dest  }
4722
          {  @@Dest  }
4353
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
4723
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
4354
          mov edx,offset @@Dest-4
4724
          mov edx,offset @@Dest-4
4355
          sub edx,offset @@StartCode
4725
          sub edx,offset @@StartCode
4356
          mov dword ptr [ecx+edx],eax
4726
          mov dword ptr [ecx+edx],eax
4357
        end;
4727
        end;
4358
      end;
4728
      end;
4359
 
4729
 
4360
      {  Blue Channel  }
4730
      {  Blue Channel  }
4361
      if chBlue in EnableChannels then
4731
      if chBlue in EnableChannels then
4362
      begin
4732
      begin
4363
        asm
4733
        asm
4364
          jmp @@EndCode
4734
          jmp @@EndCode
4365
        @@StartCode:
4735
        @@StartCode:
4366
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4736
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4367
          movzx edx,byte ptr [offset _null]{}@@TexX:
4737
          movzx edx,byte ptr [offset _null]{}@@TexX:
4368
          imul eax,edx
4738
          imul eax,edx
4369
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4739
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4370
          xor edx,$FF
4740
          xor edx,$FF
4371
          imul ebx,edx
4741
          imul ebx,edx
4372
          add ebx,eax
4742
          add ebx,eax
4373
          xor edx,$FF
4743
          xor edx,$FF
4374
 
4744
 
4375
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4745
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4376
          imul eax,edx
4746
          imul eax,edx
4377
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4747
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4378
          xor edx,$FF
4748
          xor edx,$FF
4379
          imul ebp,edx
4749
          imul ebp,edx
4380
          add eax,ebp
4750
          add eax,ebp
4381
 
4751
 
4382
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4752
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4383
          imul eax,edx
4753
          imul eax,edx
4384
          xor edx,$FF
4754
          xor edx,$FF
4385
          imul ebx,edx
4755
          imul ebx,edx
4386
          add eax,ebx
4756
          add eax,ebx
4387
          shr eax,16
4757
          shr eax,16
4388
 
4758
 
4389
          mov byte ptr [offset _Null],al{}@@Dest:
4759
          mov byte ptr [offset _Null],al{}@@Dest:
4390
        @@EndCode:
4760
        @@EndCode:
4391
          {$I DXRender.inc}
4761
          {$I DXRender.inc}
4392
          {  @@_BiLinearCol1  }
4762
          {  @@_BiLinearCol1  }
4393
          mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.B+1)
4763
          mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.B+1)
4394
          mov edx,offset @@_BiLinearCol1-4
4764
          mov edx,offset @@_BiLinearCol1-4
4395
          sub edx,offset @@StartCode
4765
          sub edx,offset @@StartCode
4396
          mov dword ptr [ecx+edx],eax
4766
          mov dword ptr [ecx+edx],eax
4397
 
4767
 
4398
          {  @@_BiLinearCol2  }
4768
          {  @@_BiLinearCol2  }
4399
          mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.B+1)
4769
          mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.B+1)
4400
          mov edx,offset @@_BiLinearCol2-4
4770
          mov edx,offset @@_BiLinearCol2-4
4401
          sub edx,offset @@StartCode
4771
          sub edx,offset @@StartCode
4402
          mov dword ptr [ecx+edx],eax
4772
          mov dword ptr [ecx+edx],eax
4403
 
4773
 
4404
          {  @@_BiLinearCol3  }
4774
          {  @@_BiLinearCol3  }
4405
          mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.B+1)
4775
          mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.B+1)
4406
          mov edx,offset @@_BiLinearCol3-4
4776
          mov edx,offset @@_BiLinearCol3-4
4407
          sub edx,offset @@StartCode
4777
          sub edx,offset @@StartCode
4408
          mov dword ptr [ecx+edx],eax
4778
          mov dword ptr [ecx+edx],eax
4409
 
4779
 
4410
          {  @@_BiLinearCol4  }
4780
          {  @@_BiLinearCol4  }
4411
          mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.B+1)
4781
          mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.B+1)
4412
          mov edx,offset @@_BiLinearCol4-4
4782
          mov edx,offset @@_BiLinearCol4-4
4413
          sub edx,offset @@StartCode
4783
          sub edx,offset @@StartCode
4414
          mov dword ptr [ecx+edx],eax
4784
          mov dword ptr [ecx+edx],eax
4415
 
4785
 
4416
          {  @@TexX  }
4786
          {  @@TexX  }
4417
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4787
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4418
          mov edx,offset @@TexX-4
4788
          mov edx,offset @@TexX-4
4419
          sub edx,offset @@StartCode
4789
          sub edx,offset @@StartCode
4420
          mov dword ptr [ecx+edx],eax
4790
          mov dword ptr [ecx+edx],eax
4421
 
4791
 
4422
          {  @@TexY  }
4792
          {  @@TexY  }
4423
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4793
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4424
          mov edx,offset @@TexY-4
4794
          mov edx,offset @@TexY-4
4425
          sub edx,offset @@StartCode
4795
          sub edx,offset @@StartCode
4426
          mov dword ptr [ecx+edx],eax
4796
          mov dword ptr [ecx+edx],eax
4427
 
4797
 
4428
          {  @@Dest  }
4798
          {  @@Dest  }
4429
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
4799
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
4430
          mov edx,offset @@Dest-4
4800
          mov edx,offset @@Dest-4
4431
          sub edx,offset @@StartCode
4801
          sub edx,offset @@StartCode
4432
          mov dword ptr [ecx+edx],eax
4802
          mov dword ptr [ecx+edx],eax
4433
        end;
4803
        end;
4434
      end;
4804
      end;
4435
 
4805
 
4436
      {  Alpha Channel  }
4806
      {  Alpha Channel  }
4437
      if chAlpha in EnableChannels then
4807
      if chAlpha in EnableChannels then
4438
      begin
4808
      begin
4439
        asm
4809
        asm
4440
          jmp @@EndCode
4810
          jmp @@EndCode
4441
        @@StartCode:
4811
        @@StartCode:
4442
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4812
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol2:
4443
          movzx edx,byte ptr [offset _null]{}@@TexX:
4813
          movzx edx,byte ptr [offset _null]{}@@TexX:
4444
          imul eax,edx
4814
          imul eax,edx
4445
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4815
          movzx ebx,byte ptr [offset _null]{}@@_BiLinearCol1:
4446
          xor edx,$FF
4816
          xor edx,$FF
4447
          imul ebx,edx
4817
          imul ebx,edx
4448
          add ebx,eax
4818
          add ebx,eax
4449
          xor edx,$FF
4819
          xor edx,$FF
4450
 
4820
 
4451
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4821
          movzx eax,byte ptr [offset _null]{}@@_BiLinearCol4:
4452
          imul eax,edx
4822
          imul eax,edx
4453
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4823
          movzx ebp,byte ptr [offset _null]{}@@_BiLinearCol3:
4454
          xor edx,$FF
4824
          xor edx,$FF
4455
          imul ebp,edx
4825
          imul ebp,edx
4456
          add eax,ebp
4826
          add eax,ebp
4457
 
4827
 
4458
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4828
          movzx edx,byte ptr [offset _Null]{}@@TexY:
4459
          imul eax,edx
4829
          imul eax,edx
4460
          xor edx,$FF
4830
          xor edx,$FF
4461
          imul ebx,edx
4831
          imul ebx,edx
4462
          add eax,ebx
4832
          add eax,ebx
4463
          shr eax,16
4833
          shr eax,16
4464
 
4834
 
4465
          mov byte ptr [offset _Null],al{}@@Dest:
4835
          mov byte ptr [offset _Null],al{}@@Dest:
4466
        @@EndCode:
4836
        @@EndCode:
4467
          {$I DXRender.inc}
4837
          {$I DXRender.inc}
4468
          {  @@_BiLinearCol1  }
4838
          {  @@_BiLinearCol1  }
4469
          mov eax,_BiLinearCol1; add eax,BYTE(TDXRMachine_Color.A+1)
4839
          mov eax,_BiLinearCol1; add eax,Byte(TDXRMachine_Color.A+1)
4470
          mov edx,offset @@_BiLinearCol1-4
4840
          mov edx,offset @@_BiLinearCol1-4
4471
          sub edx,offset @@StartCode
4841
          sub edx,offset @@StartCode
4472
          mov dword ptr [ecx+edx],eax
4842
          mov dword ptr [ecx+edx],eax
4473
 
4843
 
4474
          {  @@_BiLinearCol2  }
4844
          {  @@_BiLinearCol2  }
4475
          mov eax,_BiLinearCol2; add eax,BYTE(TDXRMachine_Color.A+1)
4845
          mov eax,_BiLinearCol2; add eax,Byte(TDXRMachine_Color.A+1)
4476
          mov edx,offset @@_BiLinearCol2-4
4846
          mov edx,offset @@_BiLinearCol2-4
4477
          sub edx,offset @@StartCode
4847
          sub edx,offset @@StartCode
4478
          mov dword ptr [ecx+edx],eax
4848
          mov dword ptr [ecx+edx],eax
4479
 
4849
 
4480
          {  @@_BiLinearCol3  }
4850
          {  @@_BiLinearCol3  }
4481
          mov eax,_BiLinearCol3; add eax,BYTE(TDXRMachine_Color.A+1)
4851
          mov eax,_BiLinearCol3; add eax,Byte(TDXRMachine_Color.A+1)
4482
          mov edx,offset @@_BiLinearCol3-4
4852
          mov edx,offset @@_BiLinearCol3-4
4483
          sub edx,offset @@StartCode
4853
          sub edx,offset @@StartCode
4484
          mov dword ptr [ecx+edx],eax
4854
          mov dword ptr [ecx+edx],eax
4485
 
4855
 
4486
          {  @@_BiLinearCol4  }
4856
          {  @@_BiLinearCol4  }
4487
          mov eax,_BiLinearCol4; add eax,BYTE(TDXRMachine_Color.A+1)
4857
          mov eax,_BiLinearCol4; add eax,Byte(TDXRMachine_Color.A+1)
4488
          mov edx,offset @@_BiLinearCol4-4
4858
          mov edx,offset @@_BiLinearCol4-4
4489
          sub edx,offset @@StartCode
4859
          sub edx,offset @@StartCode
4490
          mov dword ptr [ecx+edx],eax
4860
          mov dword ptr [ecx+edx],eax
4491
 
4861
 
4492
          {  @@TexX  }
4862
          {  @@TexX  }
4493
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4863
          mov eax,_Axis; add eax,TDXRMachine_Axis.X+1
4494
          mov edx,offset @@TexX-4
4864
          mov edx,offset @@TexX-4
4495
          sub edx,offset @@StartCode
4865
          sub edx,offset @@StartCode
4496
          mov dword ptr [ecx+edx],eax
4866
          mov dword ptr [ecx+edx],eax
4497
 
4867
 
4498
          {  @@TexY  }
4868
          {  @@TexY  }
4499
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4869
          mov eax,_Axis; add eax,TDXRMachine_Axis.Y+1
4500
          mov edx,offset @@TexY-4
4870
          mov edx,offset @@TexY-4
4501
          sub edx,offset @@StartCode
4871
          sub edx,offset @@StartCode
4502
          mov dword ptr [ecx+edx],eax
4872
          mov dword ptr [ecx+edx],eax
4503
 
4873
 
4504
          {  @@Dest  }
4874
          {  @@Dest  }
4505
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
4875
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
4506
          mov edx,offset @@Dest-4
4876
          mov edx,offset @@Dest-4
4507
          sub edx,offset @@StartCode
4877
          sub edx,offset @@StartCode
4508
          mov dword ptr [ecx+edx],eax
4878
          mov dword ptr [ecx+edx],eax
4509
        end;
4879
        end;
4510
      end;
4880
      end;
4511
    end;
4881
    end;
4512
  end;
4882
  end;
4513
 
4883
 
4514
  procedure genReadTexture(var Code: Pointer; Dest: PDXRMachine_Color;
4884
  procedure genReadTexture(var Code: Pointer; Dest: PDXRMachine_Color;
4515
    const Texture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
4885
    const Texture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
4516
  begin
4886
  begin
4517
    if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR] then
4887
    if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
4518
      genReadTexture_BiLinear(Code, Dest, Texture, Texture.nAxis, EnableChannels)
4888
      genReadTexture_BiLinear(Code, Dest, Texture, Texture.nAxis, EnableChannels)
4519
    else
4889
    else
4520
      genReadTexture_Nearest(Code, Dest, Texture, Texture.nAxis, EnableChannels);
4890
      genReadTexture_Nearest(Code, Dest, Texture, Texture.nAxis, EnableChannels);
4521
  end;
4891
  end;
4522
 
4892
 
-
 
4893
  procedure genReadBumpTexture_Nearest(var Code: Pointer; Dest: PDXRMachine_Color;
-
 
4894
    const Texture, BumpTexture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
-
 
4895
  var
-
 
4896
    _Axis, _Axis2, _iAxis, _BumpAxis, _BumpAxis2: PDXRMachine_Axis;
-
 
4897
    _BumpTempCol: Pointer;
-
 
4898
  begin
-
 
4899
    if EnableChannels=[] then Exit;
-
 
4900
 
-
 
4901
    _Axis := @BumpTexture.nAxis;
-
 
4902
    _Axis2 := @Texture.nAxis;
-
 
4903
    _iAxis := @BumpTexture.iAxis;
-
 
4904
    _BumpAxis := @F_BumpAxis;
-
 
4905
    _BumpAxis2 := @F_BumpAxis2;
-
 
4906
    _BumpTempCol := @F_BumpTempCol;
-
 
4907
 
-
 
4908
    {  X  }
-
 
4909
    asm
-
 
4910
      jmp @@EndCode
-
 
4911
    @@StartCode:
-
 
4912
      mov eax,dword ptr [offset _null]{}@@TexX:
-
 
4913
      mov edx,dword ptr [offset _null]{}@@TexY:
-
 
4914
      sub eax,dword ptr [offset _null]{}@@iTexX:
-
 
4915
      mov dword ptr [offset _null],edx{}@@AxisY:
-
 
4916
      mov dword ptr [offset _null],eax{}@@AxisX:
-
 
4917
    @@EndCode:
-
 
4918
      {$I DXRender.inc}
-
 
4919
      {  @@TexX  }
-
 
4920
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
-
 
4921
      mov edx,offset @@TexX-4
-
 
4922
      sub edx,offset @@StartCode
-
 
4923
      mov dword ptr [ecx+edx],eax
-
 
4924
 
-
 
4925
      {  @@TexY  }
-
 
4926
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
-
 
4927
      mov edx,offset @@TexY-4
-
 
4928
      sub edx,offset @@StartCode
-
 
4929
      mov dword ptr [ecx+edx],eax
-
 
4930
 
-
 
4931
      {  @@iTexX  }
-
 
4932
      mov eax,_iAxis; add eax,TDXRMachine_Axis.X
-
 
4933
      mov edx,offset @@iTexX-4
-
 
4934
      sub edx,offset @@StartCode
-
 
4935
      mov dword ptr [ecx+edx],eax
-
 
4936
 
-
 
4937
      {  @@AxisX  }
-
 
4938
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
-
 
4939
      mov edx,offset @@AxisX-4
-
 
4940
      sub edx,offset @@StartCode
-
 
4941
      mov dword ptr [ecx+edx],eax
-
 
4942
 
-
 
4943
      {  @@AxisY  }
-
 
4944
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
-
 
4945
      mov edx,offset @@AxisY-4
-
 
4946
      sub edx,offset @@StartCode
-
 
4947
      mov dword ptr [ecx+edx],eax
-
 
4948
    end;
-
 
4949
    genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
-
 
4950
 
-
 
4951
    asm
-
 
4952
      jmp @@EndCode
-
 
4953
    @@StartCode:
-
 
4954
      mov dword ptr [offset _null],eax{}@@BumpTempCol:
-
 
4955
    @@EndCode:
-
 
4956
      {$I DXRender.inc}
-
 
4957
      {  @@BumpTempCol  }
-
 
4958
      mov eax,_BumpTempCol
-
 
4959
      mov edx,offset @@BumpTempCol-4
-
 
4960
      sub edx,offset @@StartCode
-
 
4961
      mov dword ptr [ecx+edx],eax
-
 
4962
    end;
-
 
4963
 
-
 
4964
    asm
-
 
4965
      jmp @@EndCode
-
 
4966
    @@StartCode:
-
 
4967
      mov edx,dword ptr [offset _null]{}@@iAxisX:
-
 
4968
      add dword ptr [offset _null],edx{}@@AxisX:
-
 
4969
    @@EndCode:
-
 
4970
      {$I DXRender.inc}
-
 
4971
      {  @@iAxisX  }
-
 
4972
      mov eax,_iAxis; add eax,TDXRMachine_Axis.X
-
 
4973
      mov edx,offset @@iAxisX-4
-
 
4974
      sub edx,offset @@StartCode
-
 
4975
      mov dword ptr [ecx+edx],eax
-
 
4976
 
-
 
4977
      {  @@AxisX  }
-
 
4978
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
-
 
4979
      mov edx,offset @@AxisX-4
-
 
4980
      sub edx,offset @@StartCode
-
 
4981
      mov dword ptr [ecx+edx],eax
-
 
4982
    end;
-
 
4983
 
-
 
4984
    genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
-
 
4985
 
-
 
4986
    asm
-
 
4987
      jmp @@EndCode
-
 
4988
    @@StartCode:
-
 
4989
      sub eax,dword ptr [offset _null]{}@@BumpTempCol:
-
 
4990
      sal eax,16
-
 
4991
      add eax,dword ptr [offset _null]{}@@TexX:
-
 
4992
      mov dword ptr [offset _null],eax{}@@AxisX:
-
 
4993
    @@EndCode:
-
 
4994
      {$I DXRender.inc}
-
 
4995
      {  @@BumpTempCol  }
-
 
4996
      mov eax,_BumpTempCol
-
 
4997
      mov edx,offset @@BumpTempCol-4
-
 
4998
      sub edx,offset @@StartCode
-
 
4999
      mov dword ptr [ecx+edx],eax
-
 
5000
 
-
 
5001
      {  @@TexX  }
-
 
5002
      mov eax,_Axis2; add eax,TDXRMachine_Axis.X
-
 
5003
      mov edx,offset @@TexX-4
-
 
5004
      sub edx,offset @@StartCode
-
 
5005
      mov dword ptr [ecx+edx],eax
-
 
5006
 
-
 
5007
      {  @@AxisX  }
-
 
5008
      mov eax,_BumpAxis2; add eax,TDXRMachine_Axis.X
-
 
5009
      mov edx,offset @@AxisX-4
-
 
5010
      sub edx,offset @@StartCode
-
 
5011
      mov dword ptr [ecx+edx],eax
-
 
5012
    end;
-
 
5013
 
-
 
5014
    {  Y  }
-
 
5015
    asm
-
 
5016
      jmp @@EndCode
-
 
5017
    @@StartCode:
-
 
5018
      mov eax,dword ptr [offset _null]{}@@TexX:
-
 
5019
      mov edx,dword ptr [offset _null]{}@@TexY:
-
 
5020
      sub edx,dword ptr [offset _null]{}@@iTexY:
-
 
5021
      mov dword ptr [offset _null],eax{}@@AxisX:
-
 
5022
      mov dword ptr [offset _null],edx{}@@AxisY:
-
 
5023
    @@EndCode:
-
 
5024
      {$I DXRender.inc}
-
 
5025
      {  @@TexX  }
-
 
5026
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
-
 
5027
      mov edx,offset @@TexX-4
-
 
5028
      sub edx,offset @@StartCode
-
 
5029
      mov dword ptr [ecx+edx],eax
-
 
5030
 
-
 
5031
      {  @@TexY  }
-
 
5032
      mov eax,_Axis; add eax,TDXRMachine_Axis.Y
-
 
5033
      mov edx,offset @@TexY-4
-
 
5034
      sub edx,offset @@StartCode
-
 
5035
      mov dword ptr [ecx+edx],eax
-
 
5036
 
-
 
5037
      {  @@iTexY  }
-
 
5038
      mov eax,_iAxis; add eax,TDXRMachine_Axis.Y
-
 
5039
      mov edx,offset @@iTexY-4
-
 
5040
      sub edx,offset @@StartCode
-
 
5041
      mov dword ptr [ecx+edx],eax
-
 
5042
 
-
 
5043
      {  @@AxisX  }
-
 
5044
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.X
-
 
5045
      mov edx,offset @@AxisX-4
-
 
5046
      sub edx,offset @@StartCode
-
 
5047
      mov dword ptr [ecx+edx],eax
-
 
5048
 
-
 
5049
      {  @@AxisY  }
-
 
5050
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
-
 
5051
      mov edx,offset @@AxisY-4
-
 
5052
      sub edx,offset @@StartCode
-
 
5053
      mov dword ptr [ecx+edx],eax
-
 
5054
    end;
-
 
5055
    genReadSurfacePixel(Code, BumpTexture, _BumpTempCol);
-
 
5056
 
-
 
5057
    asm
-
 
5058
      jmp @@EndCode
-
 
5059
    @@StartCode:
-
 
5060
      mov dword ptr [offset _null],eax{}@@BumpTempCol:
-
 
5061
    @@EndCode:
-
 
5062
      {$I DXRender.inc}
-
 
5063
      {  @@BumpTempCol  }
-
 
5064
      mov eax,_BumpTempCol
-
 
5065
      mov edx,offset @@BumpTempCol-4
-
 
5066
      sub edx,offset @@StartCode
-
 
5067
      mov dword ptr [ecx+edx],eax
-
 
5068
    end;
-
 
5069
 
-
 
5070
    asm
-
 
5071
      jmp @@EndCode
-
 
5072
    @@StartCode:
-
 
5073
      mov edx,dword ptr [offset _null]{}@@iAxisY:
-
 
5074
      sal edx,1
-
 
5075
      sub dword ptr [offset _null],edx{}@@AxisY:
-
 
5076
    @@EndCode:
-
 
5077
      {$I DXRender.inc}
-
 
5078
      {  @@iAxisY  }
-
 
5079
      mov eax,_iAxis; add eax,TDXRMachine_Axis.Y
-
 
5080
      mov edx,offset @@iAxisY-4
-
 
5081
      sub edx,offset @@StartCode
-
 
5082
      mov dword ptr [ecx+edx],eax
-
 
5083
 
-
 
5084
      {  @@AxisY  }
-
 
5085
      mov eax,_BumpAxis; add eax,TDXRMachine_Axis.Y
-
 
5086
      mov edx,offset @@AxisY-4
-
 
5087
      sub edx,offset @@StartCode
-
 
5088
      mov dword ptr [ecx+edx],eax
-
 
5089
    end;
-
 
5090
 
-
 
5091
    genReadSurfacePixel(Code, BumpTexture, _BumpAxis);
-
 
5092
 
-
 
5093
    asm
-
 
5094
      jmp @@EndCode
-
 
5095
    @@StartCode:
-
 
5096
      sub eax,dword ptr [offset _null]{}@@BumpTempCol:
-
 
5097
      sal eax,16
-
 
5098
      add eax,dword ptr [offset _null]{}@@TexY:
-
 
5099
      mov dword ptr [offset _null],eax{}@@AxisY:
-
 
5100
    @@EndCode:
-
 
5101
      {$I DXRender.inc}
-
 
5102
      {  @@BumpTempCol  }
-
 
5103
      mov eax,_BumpTempCol
-
 
5104
      mov edx,offset @@BumpTempCol-4
-
 
5105
      sub edx,offset @@StartCode
-
 
5106
      mov dword ptr [ecx+edx],eax
-
 
5107
 
-
 
5108
      {  @@TexX  }
-
 
5109
      mov eax,_Axis2; add eax,TDXRMachine_Axis.Y
-
 
5110
      mov edx,offset @@TexY-4
-
 
5111
      sub edx,offset @@StartCode
-
 
5112
      mov dword ptr [ecx+edx],eax
-
 
5113
 
-
 
5114
      {  @@AxisX  }
-
 
5115
      mov eax,_BumpAxis2; add eax,TDXRMachine_Axis.Y
-
 
5116
      mov edx,offset @@AxisY-4
-
 
5117
      sub edx,offset @@StartCode
-
 
5118
      mov dword ptr [ecx+edx],eax
-
 
5119
    end;
-
 
5120
 
-
 
5121
    genReadTexture_Nearest(Code, Dest, Texture, _BumpAxis2^, EnableChannels);
-
 
5122
  end;
-
 
5123
 
-
 
5124
  procedure genReadBumpTexture(var Code: Pointer; Dest: PDXRMachine_Color;
-
 
5125
    const Texture, BumpTexture: TDXRMachine_Reg_Texture; EnableChannels: TDXRColorChannels);
-
 
5126
  begin
-
 
5127
    {if Texture.Filter in [DXR_TEXTUREFILTER_LINEAR, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
-
 
5128
      genReadBumpTexture_BiLinear(Code, Dest, Texture, BumpTexture, EnableChannels)
-
 
5129
    else }
-
 
5130
      genReadBumpTexture_Nearest(Code, Dest, Texture, BumpTexture, EnableChannels);
-
 
5131
  end;
-
 
5132
 
4523
  procedure genUpdateAxis(var Code: Pointer);
5133
  procedure genUpdateAxis(var Code: Pointer);
4524
  var
5134
  var
4525
    _Axis: Pointer;
5135
    _Axis: Pointer;
4526
  begin
5136
  begin
4527
    if not Axis.IncEnable then Exit;
5137
    if not Axis.IncEnable then Exit;
4528
 
5138
 
4529
    _Axis := @Axis.Axis;
5139
    _Axis := @Axis.Axis;
-
 
5140
 
4530
    asm
5141
    asm
4531
      jmp @@EndCode
5142
      jmp @@EndCode
4532
    @@StartCode:
5143
    @@StartCode:
4533
      inc dword ptr [offset _null]{}@@AxisX:
5144
      inc dword ptr [offset _null]{}@@AxisX:
4534
    @@EndCode:
5145
    @@EndCode:
4535
      {$I DXRender.inc}
5146
      {$I DXRender.inc}
4536
      {  @@AxisX  }
5147
      {  @@AxisX  }
4537
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
5148
      mov eax,_Axis; add eax,TDXRMachine_Axis.X
4538
      mov edx,offset @@AxisX-4
5149
      mov edx,offset @@AxisX-4
4539
      sub edx,offset @@StartCode
5150
      sub edx,offset @@StartCode
4540
      mov dword ptr [ecx+edx],eax
5151
      mov dword ptr [ecx+edx],eax
4541
    end;
5152
    end;
4542
  end;
5153
  end;
4543
 
5154
 
4544
  procedure genUpdateColor(var Code: Pointer);
5155
  procedure genUpdateColor(var Code: Pointer);
4545
  var
5156
  var
4546
    i: Integer;
5157
    i: Integer;
4547
    Color: PDXRMachine_Reg_Color;
5158
    Color: PDXRMachine_Reg_Color;
4548
    nColor, iColor: Pointer;
5159
    nColor, iColor: Pointer;
4549
  begin
5160
  begin
4550
    for i:=0 to ColorIndexCount-1 do
5161
    for i:=0 to ColorIndexCount-1 do
4551
    begin
5162
    begin
4552
      Color := @ColorList[ColorIndex[i]];
5163
      Color := @ColorList[ColorIndex[i]];
4553
      if Color.Gouraud then
5164
      if Color.Gouraud then
4554
      begin
5165
      begin
4555
        nColor := @Color.nColor;
5166
        nColor := @Color.nColor;
4556
        iColor := @Color.iColor;
5167
        iColor := @Color.iColor;
4557
 
5168
 
4558
        if UseMMX then
5169
        if UseMMX then
4559
        begin
5170
        begin
4560
          FMMXUsed := True;
5171
          FMMXUsed := True;
4561
          asm
5172
          asm
4562
            jmp @@EndCode
5173
            jmp @@EndCode
4563
          @@StartCode:
5174
          @@StartCode:
4564
            db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5175
            db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
4565
                                   @@_nColor:
5176
                                   @@_nColor:
4566
            db $0F,$FD,$05,$11,$11,$11,$11/// paddw mm0,qword ptr [$11111111]
5177
            db $0F,$FD,$05,$11,$11,$11,$11///paddw mm0,qword ptr [$11111111]
4567
                                   @@_iColor:
5178
                                   @@_iColor:
4568
            db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5179
            db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
4569
                                   @@_nColor2:
5180
                                   @@_nColor2:
4570
          @@EndCode:
5181
          @@EndCode:
4571
            {$I DXRender.inc}
5182
            {$I DXRender.inc}
4572
            {  @@_nColor  }
5183
            {  @@_nColor  }
4573
            mov eax,nColor
5184
            mov eax,nColor
4574
            mov edx,offset @@_nColor-4
5185
            mov edx,offset @@_nColor-4
4575
            sub edx,offset @@StartCode
5186
            sub edx,offset @@StartCode
4576
            mov dword ptr [ecx+edx],eax
5187
            mov dword ptr [ecx+edx],eax
4577
 
5188
 
4578
            {  @@_iColor  }
5189
            {  @@_iColor  }
4579
            mov eax,iColor
5190
            mov eax,iColor
4580
            mov edx,offset @@_iColor-4
5191
            mov edx,offset @@_iColor-4
4581
            sub edx,offset @@StartCode
5192
            sub edx,offset @@StartCode
4582
            mov dword ptr [ecx+edx],eax
5193
            mov dword ptr [ecx+edx],eax
4583
 
5194
 
4584
            {  @@_nColor2  }
5195
            {  @@_nColor2  }
4585
            mov eax,nColor
5196
            mov eax,nColor
4586
            mov edx,offset @@_nColor2-4
5197
            mov edx,offset @@_nColor2-4
4587
            sub edx,offset @@StartCode
5198
            sub edx,offset @@StartCode
4588
            mov dword ptr [ecx+edx],eax
5199
            mov dword ptr [ecx+edx],eax
4589
          end;
5200
          end;
4590
        end else
5201
        end else
4591
        begin
5202
        begin
4592
          asm
5203
          asm
4593
            jmp @@EndCode
5204
            jmp @@EndCode
4594
          @@StartCode:
5205
          @@StartCode:
4595
            mov eax,dword ptr [offset _null]{}@@nColor11:
5206
            mov eax,dword ptr [offset _null]{}@@nColor11:
4596
            mov edx,dword ptr [offset _null]{}@@nColor12:
5207
            mov edx,dword ptr [offset _null]{}@@nColor12:
4597
            add eax,dword ptr [offset _null]{}@@iColor1:
5208
            add eax,dword ptr [offset _null]{}@@iColor1:
4598
            add edx,dword ptr [offset _null]{}@@iColor2:
5209
            add edx,dword ptr [offset _null]{}@@iColor2:
4599
            mov dword ptr [offset _null],eax{}@@nColor21:
5210
            mov dword ptr [offset _null],eax{}@@nColor21:
4600
            mov dword ptr [offset _null],edx{}@@nColor22:
5211
            mov dword ptr [offset _null],edx{}@@nColor22:
4601
          @@EndCode:
5212
          @@EndCode:
4602
            {$I DXRender.inc}
5213
            {$I DXRender.inc}
4603
 
5214
 
4604
            {  @@nColor11  }
5215
            {  @@nColor11  }
4605
            mov eax,nColor
5216
            mov eax,nColor
4606
            mov edx,offset @@nColor11-4
5217
            mov edx,offset @@nColor11-4
4607
            sub edx,offset @@StartCode
5218
            sub edx,offset @@StartCode
4608
            mov dword ptr [ecx+edx],eax
5219
            mov dword ptr [ecx+edx],eax
4609
 
5220
 
4610
            {  @@nColor12  }
5221
            {  @@nColor12  }
4611
            mov eax,nColor; add eax,4
5222
            mov eax,nColor; add eax,4
4612
            mov edx,offset @@nColor12-4
5223
            mov edx,offset @@nColor12-4
4613
            sub edx,offset @@StartCode
5224
            sub edx,offset @@StartCode
4614
            mov dword ptr [ecx+edx],eax
5225
            mov dword ptr [ecx+edx],eax
4615
 
5226
 
4616
            {  @@iColor1  }
5227
            {  @@iColor1  }
4617
            mov eax,iColor
5228
            mov eax,iColor
4618
            mov edx,offset @@iColor1-4
5229
            mov edx,offset @@iColor1-4
4619
            sub edx,offset @@StartCode
5230
            sub edx,offset @@StartCode
4620
            mov dword ptr [ecx+edx],eax
5231
            mov dword ptr [ecx+edx],eax
4621
 
5232
 
4622
            {  @@iColor2  }
5233
            {  @@iColor2  }
4623
            mov eax,iColor; add eax,4
5234
            mov eax,iColor; add eax,4
4624
            mov edx,offset @@iColor2-4
5235
            mov edx,offset @@iColor2-4
4625
            sub edx,offset @@StartCode
5236
            sub edx,offset @@StartCode
4626
            mov dword ptr [ecx+edx],eax
5237
            mov dword ptr [ecx+edx],eax
4627
 
5238
 
4628
            {  @@nColor21  }
5239
            {  @@nColor21  }
4629
            mov eax,nColor
5240
            mov eax,nColor
4630
            mov edx,offset @@nColor21-4
5241
            mov edx,offset @@nColor21-4
4631
            sub edx,offset @@StartCode
5242
            sub edx,offset @@StartCode
4632
            mov dword ptr [ecx+edx],eax
5243
            mov dword ptr [ecx+edx],eax
4633
 
5244
 
4634
            {  @@nColor22  }
5245
            {  @@nColor22  }
4635
            mov eax,nColor; add eax,4
5246
            mov eax,nColor; add eax,4
4636
            mov edx,offset @@nColor22-4
5247
            mov edx,offset @@nColor22-4
4637
            sub edx,offset @@StartCode
5248
            sub edx,offset @@StartCode
4638
            mov dword ptr [ecx+edx],eax
5249
            mov dword ptr [ecx+edx],eax
4639
          end;
5250
          end;
4640
        end;
5251
        end;
4641
      end;
5252
      end;
4642
    end;
5253
    end;
4643
  end;
5254
  end;
4644
 
5255
 
4645
  procedure genUpdateTextureAxis(var Code: Pointer);
5256
  procedure genUpdateTextureAxis(var Code: Pointer);
4646
  var
5257
  var
4647
    i: Integer;
5258
    i: Integer;
4648
    Texture: PDXRMachine_Reg_Texture;
5259
    Texture: PDXRMachine_Reg_Texture;
4649
    nTex, iTex: Pointer;
5260
    nTex, iTex: Pointer;
4650
  begin
5261
  begin
4651
    for i:=0 to TextureIndexCount-1 do
5262
    for i:=0 to TextureIndexCount-1 do
4652
    begin
5263
    begin
4653
      Texture := @TextureList[TextureIndex[i]];
5264
      Texture := @TextureList[TextureIndex[i]];
4654
 
5265
 
4655
      nTex := @Texture.nAxis;
5266
      nTex := @Texture.nAxis;
4656
      iTex := @Texture.iAxis;
5267
      iTex := @Texture.iAxis;
4657
 
5268
 
-
 
5269
      if UseMMX then
-
 
5270
      begin
-
 
5271
        FMMXUsed := True;
-
 
5272
        asm
-
 
5273
          jmp @@EndCode
-
 
5274
        @@StartCode:
-
 
5275
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
-
 
5276
                                 @@nTex:
-
 
5277
          db $0F,$FE,$05,$11,$11,$11,$11///paddd mm0,qword ptr [$11111111]
-
 
5278
                                 @@iTex:
-
 
5279
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
-
 
5280
                                 @@nTex2:
-
 
5281
        @@EndCode:
-
 
5282
          {$I DXRender.inc}
-
 
5283
          {  @@nTex  }
-
 
5284
          mov eax,nTex
-
 
5285
          mov edx,offset @@nTex-4
-
 
5286
          sub edx,offset @@StartCode
-
 
5287
          mov dword ptr [ecx+edx],eax
-
 
5288
 
-
 
5289
          {  @@nTex2  }
-
 
5290
          mov eax,nTex
-
 
5291
          mov edx,offset @@nTex2-4
-
 
5292
          sub edx,offset @@StartCode
-
 
5293
          mov dword ptr [ecx+edx],eax
-
 
5294
 
-
 
5295
          {  @@iTex  }
-
 
5296
          mov eax,iTex
-
 
5297
          mov edx,offset @@iTex-4
-
 
5298
          sub edx,offset @@StartCode
-
 
5299
          mov dword ptr [ecx+edx],eax
-
 
5300
        end;
-
 
5301
      end else
-
 
5302
      begin
4658
      if Texture.iAxisConstant then
5303
        if Texture.iAxisConstant then
4659
      begin
5304
        begin
4660
        if Texture.iAxis.X<>0 then
5305
          if Texture.iAxis.X<>0 then
4661
        begin
5306
          begin
4662
          asm
5307
            asm
4663
            jmp @@EndCode
5308
              jmp @@EndCode
4664
          @@StartCode:
5309
            @@StartCode:
4665
            add dword ptr [offset _Null],$11111111{}@@nTexX:
5310
              add dword ptr [offset _Null],$11111111{}@@nTexX:
4666
          @@EndCode:
5311
            @@EndCode:
4667
            {$I DXRender.inc}
5312
              {$I DXRender.inc}
4668
            {  @@nTexX  }
5313
              {  @@nTexX  }
4669
            mov eax,iTex; add eax,TDXRMachine_Axis.X; mov eax,dword ptr [eax]
5314
              mov eax,iTex; add eax,TDXRMachine_Axis.X; mov eax,dword ptr [eax]
4670
            mov edx,offset @@nTexX-4
5315
              mov edx,offset @@nTexX-4
4671
            sub edx,offset @@StartCode
5316
              sub edx,offset @@StartCode
4672
            mov dword ptr [ecx+edx],eax
5317
              mov dword ptr [ecx+edx],eax
4673
 
5318
 
4674
            mov eax,nTex; add eax,TDXRMachine_Axis.X
5319
              mov eax,nTex; add eax,TDXRMachine_Axis.X
4675
            mov edx,offset @@nTexX-8
5320
              mov edx,offset @@nTexX-8
4676
            sub edx,offset @@StartCode
5321
              sub edx,offset @@StartCode
4677
            mov dword ptr [ecx+edx],eax
5322
              mov dword ptr [ecx+edx],eax
4678
          end;
5323
            end;
4679
        end;
5324
          end;
4680
 
5325
 
4681
        if Texture.iAxis.Y<>0 then
5326
          if Texture.iAxis.Y<>0 then
4682
        begin
5327
          begin
4683
          asm
5328
            asm
4684
            jmp @@EndCode
5329
              jmp @@EndCode
4685
          @@StartCode:
5330
            @@StartCode:
4686
            add dword ptr [offset _Null],$11111111{}@@nTexY:
5331
              add dword ptr [offset _Null],$11111111{}@@nTexY:
4687
          @@EndCode:
5332
            @@EndCode:
4688
            {$I DXRender.inc}
5333
              {$I DXRender.inc}
4689
            {  @@nTexY  }
5334
              {  @@nTexY  }
4690
            mov eax,iTex; add eax,TDXRMachine_Axis.Y; mov eax,dword ptr [eax]
5335
              mov eax,iTex; add eax,TDXRMachine_Axis.Y; mov eax,dword ptr [eax]
4691
            mov edx,offset @@nTexY-4
5336
              mov edx,offset @@nTexY-4
4692
            sub edx,offset @@StartCode
5337
              sub edx,offset @@StartCode
4693
            mov dword ptr [ecx+edx],eax
5338
              mov dword ptr [ecx+edx],eax
4694
 
5339
                                         
4695
            mov eax,nTex; add eax,TDXRMachine_Axis.Y
5340
              mov eax,nTex; add eax,TDXRMachine_Axis.Y
4696
            mov edx,offset @@nTexY-8
5341
              mov edx,offset @@nTexY-8
4697
            sub edx,offset @@StartCode
5342
              sub edx,offset @@StartCode
4698
            mov dword ptr [ecx+edx],eax
5343
              mov dword ptr [ecx+edx],eax
4699
          end;
5344
            end;
4700
        end;
5345
          end;
4701
      end else
5346
        end else
4702
      begin
5347
        //begin
4703
        if UseMMX then
5348
         if UseMMX then
4704
        begin
5349
         begin
4705
          FMMXUsed := True;
5350
          FMMXUsed := True;
4706
          asm
5351
          asm
4707
            jmp @@EndCode
5352
            jmp @@EndCode
4708
          @@StartCode:
5353
          @@StartCode:
4709
            db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
5354
            db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
4710
                                   @@nTex:
5355
                                   @@nTex:
4711
            db $0F,$FE,$05,$11,$11,$11,$11///paddd mm0,qword ptr [$11111111]
5356
            db $0F,$FE,$05,$11,$11,$11,$11///paddd mm0,qword ptr [$11111111]
4712
                                   @@iTex:
5357
                                   @@iTex:
4713
            db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
5358
            db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
4714
                                   @@nTex2:
5359
                                   @@nTex2:
4715
          @@EndCode:
5360
          @@EndCode:
4716
            {$I DXRender.inc}
5361
            {$I DXRender.inc}
4717
            {  @@nTex  }
5362
            {  @@nTex  }
4718
            mov eax,nTex
5363
            mov eax,nTex
4719
            mov edx,offset @@nTex-4
5364
            mov edx,offset @@nTex-4
4720
            sub edx,offset @@StartCode
5365
            sub edx,offset @@StartCode
4721
            mov dword ptr [ecx+edx],eax
5366
            mov dword ptr [ecx+edx],eax
4722
 
5367
 
4723
            {  @@nTex2  }
5368
            {  @@nTex2  }
4724
            mov eax,nTex
5369
            mov eax,nTex
4725
            mov edx,offset @@nTex2-4
5370
            mov edx,offset @@nTex2-4
4726
            sub edx,offset @@StartCode
5371
            sub edx,offset @@StartCode
4727
            mov dword ptr [ecx+edx],eax
5372
            mov dword ptr [ecx+edx],eax
4728
 
5373
 
4729
            {  @@iTex  }
5374
            {  @@iTex  }
4730
            mov eax,iTex
5375
            mov eax,iTex
4731
            mov edx,offset @@iTex-4
5376
            mov edx,offset @@iTex-4
4732
            sub edx,offset @@StartCode
5377
            sub edx,offset @@StartCode
4733
            mov dword ptr [ecx+edx],eax
5378
            mov dword ptr [ecx+edx],eax
4734
          end;
5379
          end;
4735
        end else
5380
         end else
4736
        begin
5381
         begin
-
 
5382
 
4737
          asm
5383
          asm
4738
            jmp @@EndCode
5384
            jmp @@EndCode
4739
          @@StartCode:
5385
          @@StartCode:
4740
            mov eax,dword ptr [offset _Null]{}@@iTexX:
5386
            mov eax,dword ptr [offset _Null]{}@@iTexX:
4741
            mov edx,dword ptr [offset _Null]{}@@iTexY:
5387
            mov edx,dword ptr [offset _Null]{}@@iTexY:
4742
            add dword ptr [offset _Null],eax{}@@nTexX:
5388
            add dword ptr [offset _Null],eax{}@@nTexX:
4743
            add dword ptr [offset _Null],edx{}@@nTexY:
5389
            add dword ptr [offset _Null],edx{}@@nTexY:
4744
          @@EndCode:
5390
          @@EndCode:
4745
            {$I DXRender.inc}
5391
            {$I DXRender.inc}
4746
            {  @@iTexX  }
5392
            {  @@iTexX  }
4747
            mov eax,iTex; add eax,TDXRMachine_Axis.X
5393
            mov eax,iTex; add eax,TDXRMachine_Axis.X
4748
            mov edx,offset @@iTexX-4
5394
            mov edx,offset @@iTexX-4
4749
            sub edx,offset @@StartCode
5395
            sub edx,offset @@StartCode
4750
            mov dword ptr [ecx+edx],eax
5396
            mov dword ptr [ecx+edx],eax
4751
 
5397
 
4752
            {  @@iTexY  }
5398
            {  @@iTexY  }
4753
            mov eax,iTex; add eax,TDXRMachine_Axis.Y
5399
            mov eax,iTex; add eax,TDXRMachine_Axis.Y
4754
            mov edx,offset @@iTexY-4
5400
            mov edx,offset @@iTexY-4
4755
            sub edx,offset @@StartCode
5401
            sub edx,offset @@StartCode
4756
            mov dword ptr [ecx+edx],eax
5402
            mov dword ptr [ecx+edx],eax
4757
 
5403
 
4758
            {  @@nTexX  }
5404
            {  @@nTexX  }
4759
            mov eax,nTex; add eax,TDXRMachine_Axis.X
5405
            mov eax,nTex; add eax,TDXRMachine_Axis.X
4760
            mov edx,offset @@nTexX-4
5406
            mov edx,offset @@nTexX-4
4761
            sub edx,offset @@StartCode
5407
            sub edx,offset @@StartCode
4762
            mov dword ptr [ecx+edx],eax
5408
            mov dword ptr [ecx+edx],eax
4763
 
5409
 
4764
            {  @@nTexY  }
5410
            {  @@nTexY  }
4765
            mov eax,nTex; add eax,TDXRMachine_Axis.Y
5411
            mov eax,nTex; add eax,TDXRMachine_Axis.Y
4766
            mov edx,offset @@nTexY-4
5412
            mov edx,offset @@nTexY-4
4767
            sub edx,offset @@StartCode
5413
            sub edx,offset @@StartCode
4768
            mov dword ptr [ecx+edx],eax
5414
            mov dword ptr [ecx+edx],eax
4769
          end;
5415
          end;
4770
        end;
5416
        end;
4771
      end;
5417
      end;
4772
    end;
5418
    end;
4773
  end;
5419
  end;
4774
 
5420
 
-
 
5421
  procedure genUpdateRHW(var Code: Pointer);
-
 
5422
  var
-
 
5423
    nRHW, iRHW: Pointer;
-
 
5424
  begin
-
 
5425
    if not RHW.Enable then Exit;
-
 
5426
 
-
 
5427
    nRHW := @RHW.nRHW;
-
 
5428
    iRHW := @RHW.iRHW;
-
 
5429
 
-
 
5430
    asm
-
 
5431
      jmp @@EndCode
-
 
5432
    @@StartCode:
-
 
5433
      // 64 bit addition
-
 
5434
      mov eax,dword ptr [offset _null]{}@@iRHW:
-
 
5435
      mov edx,dword ptr [offset _null]{}@@iRHW2:
-
 
5436
      add dword ptr [offset _null],eax{}@@nRHW:
-
 
5437
      adc dword ptr [offset _null],edx{}@@nRHW2:
-
 
5438
    @@EndCode:
-
 
5439
      {$I DXRender.inc}
-
 
5440
      {  @@nRHW  }
-
 
5441
      mov eax,nRHW
-
 
5442
      mov edx,offset @@nRHW-4
-
 
5443
      sub edx,offset @@StartCode
-
 
5444
      mov dword ptr [ecx+edx],eax
-
 
5445
 
-
 
5446
      {  @@nRHW2  }
-
 
5447
      mov eax,nRHW; add eax,4
-
 
5448
      mov edx,offset @@nRHW2-4
-
 
5449
      sub edx,offset @@StartCode
-
 
5450
      mov dword ptr [ecx+edx],eax
-
 
5451
 
-
 
5452
      {  @@iRHW  }
-
 
5453
      mov eax,iRHW
-
 
5454
      mov edx,offset @@iRHW-4
-
 
5455
      sub edx,offset @@StartCode
-
 
5456
      mov dword ptr [ecx+edx],eax
-
 
5457
 
-
 
5458
      {  @@iRHW  }
-
 
5459
      mov eax,iRHW; add eax,4
-
 
5460
      mov edx,offset @@iRHW2-4
-
 
5461
      sub edx,offset @@StartCode
-
 
5462
      mov dword ptr [ecx+edx],eax
-
 
5463
    end;
-
 
5464
  end;
-
 
5465
 
4775
  procedure genBlend(var Code: Pointer; Blend: TDXR_Blend;
5466
  procedure genBlend(var Code: Pointer; Blend: TDXR_Blend;
4776
    Dest, Col1, Col2: PDXRMachine_Color; EnableChannels: TDXRColorChannels;
5467
    Dest, Col1, Col2: PDXRMachine_Color; EnableChannels: TDXRColorChannels;
4777
    ConstChannels1, ConstChannels2: TDXRColorChannels);
5468
    ConstChannels1, ConstChannels2: TDXRColorChannels);
4778
 
5469
 
4779
    procedure Func_col1_Add_col2(var Code: Pointer; Dest, col1, col2: PWord);
5470
    procedure Func_col1_Add_col2(var Code: Pointer; Dest, col1, col2: PWord);
4780
    begin
5471
    begin
4781
      asm
5472
      asm
4782
        jmp @@EndCode
5473
        jmp @@EndCode
4783
      @@StartCode:
5474
      @@StartCode:
4784
        movzx eax,byte ptr [offset _null]{}@@Col1:
5475
        movzx eax,byte ptr [offset _null]{}@@Col1:
4785
        movzx edx,byte ptr [offset _null]{}@@Col2:
5476
        movzx edx,byte ptr [offset _null]{}@@Col2:
4786
        mov al,byte ptr [offset (_AddTable + eax + edx)]
5477
        mov al,byte ptr [offset (_AddTable + eax + edx)]
4787
        mov byte ptr [offset _null],al{}@@Dest:
5478
        mov byte ptr [offset _null],al{}@@Dest:
4788
      @@EndCode:
5479
      @@EndCode:
4789
        {$I DXRender.inc}
5480
        {$I DXRender.inc}
4790
        {  @@Col1  }
5481
        {  @@Col1  }
4791
        mov eax,Col1; inc eax
5482
        mov eax,Col1; inc eax
4792
        mov edx,offset @@Col1-4
5483
        mov edx,offset @@Col1-4
4793
        sub edx,offset @@StartCode
5484
        sub edx,offset @@StartCode
4794
        mov dword ptr [ecx+edx],eax
5485
        mov dword ptr [ecx+edx],eax
4795
 
5486
 
4796
        {  @@Col2  }
5487
        {  @@Col2  }
4797
        mov eax,Col2; inc eax
5488
        mov eax,Col2; inc eax
4798
        mov edx,offset @@Col2-4
5489
        mov edx,offset @@Col2-4
4799
        sub edx,offset @@StartCode
5490
        sub edx,offset @@StartCode
4800
        mov dword ptr [ecx+edx],eax
5491
        mov dword ptr [ecx+edx],eax
4801
 
5492
 
4802
        {  @@Dest  }
5493
        {  @@Dest  }
4803
        mov eax,Dest; inc eax
5494
        mov eax,Dest; inc eax
4804
        mov edx,offset @@Dest-4
5495
        mov edx,offset @@Dest-4
4805
        sub edx,offset @@StartCode
5496
        sub edx,offset @@StartCode
4806
        mov dword ptr [ecx+edx],eax
5497
        mov dword ptr [ecx+edx],eax
4807
      end;
5498
      end;
4808
    end;
5499
    end;
4809
 
5500
 
4810
    procedure Func_col1_Add_const2(var Code: Pointer; Dest, col1, col2: PWord);
5501
    procedure Func_col1_Add_const2(var Code: Pointer; Dest, col1, col2: PWord);
4811
    begin
5502
    begin
4812
      asm
5503
      asm
4813
        jmp @@EndCode
5504
        jmp @@EndCode
4814
      @@StartCode:
5505
      @@StartCode:
4815
        movzx eax,byte ptr [offset _null]{}@@Col1:
5506
        movzx eax,byte ptr [offset _null]{}@@Col1:
4816
        mov al,byte ptr [$11111111 + eax]{}@@Col2:
5507
        mov al,byte ptr [$11111111 + eax]{}@@Col2:
4817
        mov byte ptr [offset _null],al{}@@Dest:
5508
        mov byte ptr [offset _null],al{}@@Dest:
4818
      @@EndCode:
5509
      @@EndCode:
4819
        {$I DXRender.inc}
5510
        {$I DXRender.inc}
4820
        {  @@Col1  }
5511
        {  @@Col1  }
4821
        mov eax,Col1; inc eax
5512
        mov eax,Col1; inc eax
4822
        mov edx,offset @@Col1-4
5513
        mov edx,offset @@Col1-4
4823
        sub edx,offset @@StartCode
5514
        sub edx,offset @@StartCode
4824
        mov dword ptr [ecx+edx],eax
5515
        mov dword ptr [ecx+edx],eax
4825
 
5516
 
4826
        {  @@Col2  }
5517
        {  @@Col2  }
4827
        mov eax,Col2; inc eax; movzx eax,byte ptr [eax]
5518
        mov eax,Col2; inc eax; movzx eax,byte ptr [eax]
4828
        add eax,offset _AddTable
5519
        add eax,offset _AddTable
4829
 
5520
 
4830
        mov edx,offset @@Col2-4
5521
        mov edx,offset @@Col2-4
4831
        sub edx,offset @@StartCode
5522
        sub edx,offset @@StartCode
4832
        mov dword ptr [ecx+edx],eax
5523
        mov dword ptr [ecx+edx],eax
4833
 
5524
 
4834
        {  @@Dest  }
5525
        {  @@Dest  }
4835
        mov eax,Dest; inc eax
5526
        mov eax,Dest; inc eax
4836
        mov edx,offset @@Dest-4
5527
        mov edx,offset @@Dest-4
4837
        sub edx,offset @@StartCode
5528
        sub edx,offset @@StartCode
4838
        mov dword ptr [ecx+edx],eax
5529
        mov dword ptr [ecx+edx],eax
4839
      end;
5530
      end;
4840
    end;
5531
    end;
4841
 
5532
 
4842
    procedure Func_col1_Sub_col2(var Code: Pointer; Dest, col1, col2: PWord);
5533
    procedure Func_col1_Sub_col2(var Code: Pointer; Dest, col1, col2: PWord);
4843
    begin
5534
    begin
4844
      asm
5535
      asm
4845
        jmp @@EndCode
5536
        jmp @@EndCode
4846
      @@StartCode:    
5537
      @@StartCode:    
4847
        movzx eax,byte ptr [offset _null]{}@@Col1:
5538
        movzx eax,byte ptr [offset _null]{}@@Col1:
4848
        movzx edx,byte ptr [offset _null]{}@@Col2:
5539
        movzx edx,byte ptr [offset _null]{}@@Col2:
4849
        sub eax,edx
5540
        sub eax,edx
4850
        mov al,byte ptr [offset (_SubTable + 255 + eax)]
5541
        mov al,byte ptr [offset (_SubTable + 255 + eax)]
4851
        mov byte ptr [offset _null],al{}@@Dest:
5542
        mov byte ptr [offset _null],al{}@@Dest:
4852
      @@EndCode:
5543
      @@EndCode:
4853
        {$I DXRender.inc}
5544
        {$I DXRender.inc}
4854
        {  @@Col1  }
5545
        {  @@Col1  }
4855
        mov eax,Col1; inc eax
5546
        mov eax,Col1; inc eax
4856
        mov edx,offset @@Col1-4
5547
        mov edx,offset @@Col1-4
4857
        sub edx,offset @@StartCode
5548
        sub edx,offset @@StartCode
4858
        mov dword ptr [ecx+edx],eax
5549
        mov dword ptr [ecx+edx],eax
4859
 
5550
 
4860
        {  @@Col2  }
5551
        {  @@Col2  }
4861
        mov eax,Col2; inc eax
5552
        mov eax,Col2; inc eax
4862
        mov edx,offset @@Col2-4
5553
        mov edx,offset @@Col2-4
4863
        sub edx,offset @@StartCode
5554
        sub edx,offset @@StartCode
4864
        mov dword ptr [ecx+edx],eax
5555
        mov dword ptr [ecx+edx],eax
4865
 
5556
 
4866
        {  @@Dest  }
5557
        {  @@Dest  }
4867
        mov eax,Dest; inc eax
5558
        mov eax,Dest; inc eax
4868
        mov edx,offset @@Dest-4
5559
        mov edx,offset @@Dest-4
4869
        sub edx,offset @@StartCode
5560
        sub edx,offset @@StartCode
4870
        mov dword ptr [ecx+edx],eax
5561
        mov dword ptr [ecx+edx],eax
4871
      end;
5562
      end;
4872
    end;
5563
    end;
4873
 
5564
 
4874
    procedure Func_const1_Sub_col2(var Code: Pointer; Dest, col1, col2: PWord);
5565
    procedure Func_const1_Sub_col2(var Code: Pointer; Dest, col1, col2: PWord);
4875
    begin
5566
    begin
4876
      asm
5567
      asm
4877
        jmp @@EndCode
5568
        jmp @@EndCode
4878
      @@StartCode:
5569
      @@StartCode:
4879
        mov eax,$11111111{}@@Col1:
5570
        mov eax,$11111111{}@@Col1:
4880
        movzx edx,byte ptr [offset _null]{}@@Col2:
5571
        movzx edx,byte ptr [offset _null]{}@@Col2:
4881
        sub eax,edx
5572
        sub eax,edx
4882
        mov al,byte ptr [offset (_SubTable + 255 + eax)]
5573
        mov al,byte ptr [offset (_SubTable + 255 + eax)]
4883
        mov byte ptr [offset _null],al{}@@Dest:
5574
        mov byte ptr [offset _null],al{}@@Dest:
4884
      @@EndCode:
5575
      @@EndCode:
4885
        {$I DXRender.inc}
5576
        {$I DXRender.inc}
4886
        {  @@Col1  }
5577
        {  @@Col1  }
4887
        mov eax,Col1; inc eax; movzx eax,byte ptr [eax]
5578
        mov eax,Col1; inc eax; movzx eax,byte ptr [eax]
4888
        mov edx,offset @@Col1-4
5579
        mov edx,offset @@Col1-4
4889
        sub edx,offset @@StartCode
5580
        sub edx,offset @@StartCode
4890
        mov dword ptr [ecx+edx],eax
5581
        mov dword ptr [ecx+edx],eax
4891
 
5582
 
4892
        {  @@Col2  }
5583
        {  @@Col2  }
4893
        mov eax,Col2; inc eax
5584
        mov eax,Col2; inc eax
4894
        mov edx,offset @@Col2-4
5585
        mov edx,offset @@Col2-4
4895
        sub edx,offset @@StartCode
5586
        sub edx,offset @@StartCode
4896
        mov dword ptr [ecx+edx],eax
5587
        mov dword ptr [ecx+edx],eax
4897
 
5588
 
4898
        {  @@Dest  }
5589
        {  @@Dest  }
4899
        mov eax,Dest; inc eax
5590
        mov eax,Dest; inc eax
4900
        mov edx,offset @@Dest-4
5591
        mov edx,offset @@Dest-4
4901
        sub edx,offset @@StartCode
5592
        sub edx,offset @@StartCode
4902
        mov dword ptr [ecx+edx],eax
5593
        mov dword ptr [ecx+edx],eax
4903
      end;
5594
      end;
4904
    end;
5595
    end;
4905
 
5596
 
4906
    procedure Func_col1_Sub_const2(var Code: Pointer; Dest, col1, col2: PWord);
5597
    procedure Func_col1_Sub_const2(var Code: Pointer; Dest, col1, col2: PWord);
4907
    begin
5598
    begin
4908
      asm
5599
      asm
4909
        jmp @@EndCode
5600
        jmp @@EndCode
4910
      @@StartCode:
5601
      @@StartCode:
4911
        movzx eax,byte ptr [offset _null]{}@@Col1:
5602
        movzx eax,byte ptr [offset _null]{}@@Col1:
4912
        mov al,byte ptr [$11111111 + eax]{}@@Col2:
5603
        mov al,byte ptr [$11111111 + eax]{}@@Col2:
4913
        mov byte ptr [offset _null],al{}@@Dest:
5604
        mov byte ptr [offset _null],al{}@@Dest:
4914
      @@EndCode:
5605
      @@EndCode:
4915
        {$I DXRender.inc}
5606
        {$I DXRender.inc}
4916
        {  @@Col1  }
5607
        {  @@Col1  }
4917
        mov eax,Col1; inc eax
5608
        mov eax,Col1; inc eax
4918
        mov edx,offset @@Col1-4
5609
        mov edx,offset @@Col1-4
4919
        sub edx,offset @@StartCode
5610
        sub edx,offset @@StartCode
4920
        mov dword ptr [ecx+edx],eax
5611
        mov dword ptr [ecx+edx],eax
4921
 
5612
 
4922
        {  @@Col2  }
5613
        {  @@Col2  }
4923
        mov eax,Col2; inc eax; movzx eax,byte ptr [eax]; neg eax
5614
        mov eax,Col2; inc eax; movzx eax,byte ptr [eax]; neg eax
4924
        add eax,offset _SubTable+255
5615
        add eax,offset _SubTable+255
4925
 
5616
 
4926
        mov edx,offset @@Col2-4
5617
        mov edx,offset @@Col2-4
4927
        sub edx,offset @@StartCode
5618
        sub edx,offset @@StartCode
4928
        mov dword ptr [ecx+edx],eax
5619
        mov dword ptr [ecx+edx],eax
4929
 
5620
 
4930
        {  @@Dest  }
5621
        {  @@Dest  }
4931
        mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
5622
        mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
4932
        mov edx,offset @@Dest-4
5623
        mov edx,offset @@Dest-4
4933
        sub edx,offset @@StartCode
5624
        sub edx,offset @@StartCode
4934
        mov dword ptr [ecx+edx],eax
5625
        mov dword ptr [ecx+edx],eax
4935
      end;
5626
      end;
4936
    end;
5627
    end;
4937
 
5628
 
4938
    procedure genBlend_ZERO(var Code: Pointer; Dest: PDXRMachine_Color);
5629
    procedure genBlend_ZERO(var Code: Pointer; Dest: PDXRMachine_Color);
4939
    begin
5630
    begin
4940
      asm                
5631
      asm
4941
        jmp @@EndCode
5632
        jmp @@EndCode
4942
      @@StartCode:
5633
      @@StartCode:
4943
        mov dword ptr [offset _null],0{}@@Dest:
5634
        mov dword ptr [offset _null],0{}@@Dest:
4944
        mov dword ptr [offset _null],0{}@@Dest2:
5635
        mov dword ptr [offset _null],0{}@@Dest2:
4945
      @@EndCode:
5636
      @@EndCode:
4946
        {$I DXRender.inc}
5637
        {$I DXRender.inc}
4947
        {  @@Dest  }
5638
        {  @@Dest  }
4948
        mov eax,Dest
5639
        mov eax,Dest
4949
        mov edx,offset @@Dest-8
5640
        mov edx,offset @@Dest-8
4950
        sub edx,offset @@StartCode
5641
        sub edx,offset @@StartCode
4951
        mov dword ptr [ecx+edx],eax
5642
        mov dword ptr [ecx+edx],eax
4952
 
5643
 
4953
        {  @@Dest2  }
5644
        {  @@Dest2  }
4954
        mov eax,Dest; add eax,4
5645
        mov eax,Dest; add eax,4
4955
        mov edx,offset @@Dest2-8
5646
        mov edx,offset @@Dest2-8
4956
        sub edx,offset @@StartCode
5647
        sub edx,offset @@StartCode
4957
        mov dword ptr [ecx+edx],eax
5648
        mov dword ptr [ecx+edx],eax
4958
      end;
5649
      end;
4959
    end;
5650
    end;
4960
 
5651
 
4961
    procedure genBlend_ONE1(var Code: Pointer; Dest, Col1: PDXRMachine_Color;
5652
    procedure genBlend_ONE1(var Code: Pointer; Dest, Col1: PDXRMachine_Color;
4962
      ConstChannels1: TDXRColorChannels);
5653
      ConstChannels1: TDXRColorChannels);
4963
    begin
5654
    begin
4964
      if Dest=Col1 then Exit;
5655
      if Dest=Col1 then Exit;
4965
 
5656
 
4966
      if UseMMX then
5657
      if UseMMX then //False then//UseMMX then
4967
      begin
5658
      begin
4968
        FMMXUsed := True;
5659
        FMMXUsed := True;
4969
        asm
5660
        asm
4970
          jmp @@EndCode
5661
          jmp @@EndCode
4971
        @@StartCode:
5662
        @@StartCode:
4972
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5663
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
4973
                                 @@Col:
5664
                                 @@Col:
4974
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5665
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
4975
                                 @@Dest:
5666
                                 @@Dest:
4976
        @@EndCode:
5667
        @@EndCode:
4977
          {$I DXRender.inc}
5668
          {$I DXRender.inc}
4978
          {  @@Col  }
5669
          {  @@Col  }
4979
          mov eax,Col1
5670
          mov eax,Col1
4980
          mov edx,offset @@Col-4
5671
          mov edx,offset @@Col-4
4981
          sub edx,offset @@StartCode
5672
          sub edx,offset @@StartCode
4982
          mov dword ptr [ecx+edx],eax
5673
          mov dword ptr [ecx+edx],eax
4983
 
5674
 
4984
          {  @@Dest  }
5675
          {  @@Dest  }
4985
          mov eax,Dest
5676
          mov eax,Dest
4986
          mov edx,offset @@Dest-4
5677
          mov edx,offset @@Dest-4
4987
          sub edx,offset @@StartCode
5678
          sub edx,offset @@StartCode
4988
          mov dword ptr [ecx+edx],eax
5679
          mov dword ptr [ecx+edx],eax
4989
        end;
5680
        end;
4990
      end else
5681
      end else
4991
      begin
5682
      begin
4992
        if ConstChannels1=[chRed, chGreen, chBlue, chAlpha] then
5683
        if ConstChannels1=[chRed, chGreen, chBlue, chAlpha] then
4993
        begin
5684
        begin
4994
          asm
5685
          asm
4995
            jmp @@EndCode
5686
            jmp @@EndCode
4996
          @@StartCode:
5687
          @@StartCode:
4997
            mov dword ptr [offset _null],$11111111{}@@Dest:
5688
            mov dword ptr [offset _null],$11111111{}@@Dest:
4998
            mov dword ptr [offset _null],$11111111{}@@Dest2:
5689
            mov dword ptr [offset _null],$11111111{}@@Dest2:
4999
          @@EndCode:
5690
          @@EndCode:
5000
            {$I DXRender.inc}
5691
            {$I DXRender.inc}
5001
            {  @@Dest  }
5692
            {  @@Dest  }
5002
            mov eax,Col1
5693
            mov eax,Col1
5003
            mov eax,dword ptr [eax]
5694
            mov eax,dword ptr [eax]
5004
            mov edx,offset @@Dest-4
5695
            mov edx,offset @@Dest-4
5005
            sub edx,offset @@StartCode
5696
            sub edx,offset @@StartCode
5006
            mov dword ptr [ecx+edx],eax
5697
            mov dword ptr [ecx+edx],eax
5007
 
5698
 
5008
            mov eax,Dest
5699
            mov eax,Dest
5009
            mov edx,offset @@Dest-8
5700
            mov edx,offset @@Dest-8
5010
            sub edx,offset @@StartCode
5701
            sub edx,offset @@StartCode
5011
            mov dword ptr [ecx+edx],eax
5702
            mov dword ptr [ecx+edx],eax
5012
 
5703
 
5013
            {  @@Dest2  }
5704
            {  @@Dest2  }
5014
            mov eax,Col1; add eax,4
5705
            mov eax,Col1; add eax,4
5015
            mov eax,dword ptr [eax]
5706
            mov eax,dword ptr [eax]
5016
            mov edx,offset @@Dest2-4
5707
            mov edx,offset @@Dest2-4
5017
            sub edx,offset @@StartCode
5708
            sub edx,offset @@StartCode
5018
            mov dword ptr [ecx+edx],eax
5709
            mov dword ptr [ecx+edx],eax
5019
 
5710
 
5020
            mov eax,Dest; add eax,8
5711
            mov eax,Dest; add eax,8
5021
            mov edx,offset @@Dest2-4
5712
            mov edx,offset @@Dest2-4
5022
            sub edx,offset @@StartCode
5713
            sub edx,offset @@StartCode
5023
            mov dword ptr [ecx+edx],eax
5714
            mov dword ptr [ecx+edx],eax
5024
          end;
5715
          end;
5025
        end else
5716
        end else
5026
        begin
5717
        begin
5027
          asm
5718
          asm
5028
            jmp @@EndCode
5719
            jmp @@EndCode
5029
          @@StartCode:
5720
          @@StartCode:
5030
            mov eax,dword ptr [offset _null]{}@@Col:
5721
            mov eax,dword ptr [offset _null]{}@@Col:
5031
            mov edx,dword ptr [offset _null]{}@@Col2:
5722
            mov edx,dword ptr [offset _null]{}@@Col2:
5032
            mov dword ptr [offset _null],eax{}@@Dest:
5723
            mov dword ptr [offset _null],eax{}@@Dest:
5033
            mov dword ptr [offset _null],edx{}@@Dest2:
5724
            mov dword ptr [offset _null],edx{}@@Dest2:
5034
          @@EndCode:
5725
          @@EndCode:
5035
            {$I DXRender.inc}
5726
            {$I DXRender.inc}
5036
            {  @@Col  }
5727
            {  @@Col  }
5037
            mov eax,Col1
5728
            mov eax,Col1
5038
            mov edx,offset @@Col-4
5729
            mov edx,offset @@Col-4
5039
            sub edx,offset @@StartCode
5730
            sub edx,offset @@StartCode
5040
            mov dword ptr [ecx+edx],eax
5731
            mov dword ptr [ecx+edx],eax
5041
 
5732
 
5042
            {  @@Col2  }
5733
            {  @@Col2  }
5043
            mov eax,Col1; add eax,4
5734
            mov eax,Col1; add eax,4
5044
            mov edx,offset @@Col2-4
5735
            mov edx,offset @@Col2-4
5045
            sub edx,offset @@StartCode
5736
            sub edx,offset @@StartCode
5046
            mov dword ptr [ecx+edx],eax
5737
            mov dword ptr [ecx+edx],eax
5047
 
5738
 
5048
            {  @@Dest  }
5739
            {  @@Dest  }
5049
            mov eax,Dest
5740
            mov eax,Dest
5050
            mov edx,offset @@Dest-4
5741
            mov edx,offset @@Dest-4
5051
            sub edx,offset @@StartCode
5742
            sub edx,offset @@StartCode
5052
            mov dword ptr [ecx+edx],eax
5743
            mov dword ptr [ecx+edx],eax
5053
 
5744
 
5054
            {  @@Dest2  }
5745
            {  @@Dest2  }
5055
            mov eax,Dest; add eax,4
5746
            mov eax,Dest; add eax,4
5056
            mov edx,offset @@Dest2-4
5747
            mov edx,offset @@Dest2-4
5057
            sub edx,offset @@StartCode
5748
            sub edx,offset @@StartCode
5058
            mov dword ptr [ecx+edx],eax
5749
            mov dword ptr [ecx+edx],eax
5059
          end;
5750
          end;
5060
        end;
5751
        end;
5061
      end;
5752
      end;
5062
    end;
5753
    end;
5063
 
5754
 
5064
    procedure genBlend_ONE1_ADD_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5755
    procedure genBlend_ONE1_ADD_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5065
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5756
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5066
    begin
5757
    begin
5067
      if UseMMX then
5758
      if UseMMX then
5068
      begin
5759
      begin
5069
        FMMXUsed := True;
5760
        FMMXUsed := True;
5070
        asm
5761
        asm
5071
          jmp @@EndCode
5762
          jmp @@EndCode
5072
        @@StartCode:
5763
        @@StartCode:
5073
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5764
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
5074
                                 @@Col1:
5765
                                 @@Col1:
5075
          db $0F,$DD,$05,$11,$11,$11,$11/// paddusw mm0,qword ptr [$11111111]
5766
          db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
5076
                                 @@Col2:
5767
                                 @@Col2:
-
 
5768
          db $0F,$DD,$C1      ///paddusw mm0,mm1
5077
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5769
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
5078
                                 @@Dest:
5770
                                 @@Dest:
5079
        @@EndCode:
5771
        @@EndCode:
5080
          {$I DXRender.inc}
5772
          {$I DXRender.inc}
5081
          {  @@Col1  }
5773
          {  @@Col1  }
5082
          mov eax,Col1
5774
          mov eax,Col1
5083
          mov edx,offset @@Col1-4
5775
          mov edx,offset @@Col1-4
5084
          sub edx,offset @@StartCode
5776
          sub edx,offset @@StartCode
5085
          mov dword ptr [ecx+edx],eax
5777
          mov dword ptr [ecx+edx],eax
5086
 
5778
 
5087
          {  @@Col2  }
5779
          {  @@Col2  }
5088
          mov eax,Col2
5780
          mov eax,Col2
5089
          mov edx,offset @@Col2-4
5781
          mov edx,offset @@Col2-4
5090
          sub edx,offset @@StartCode
5782
          sub edx,offset @@StartCode
5091
          mov dword ptr [ecx+edx],eax
5783
          mov dword ptr [ecx+edx],eax
5092
 
5784
 
5093
          {  @@Dest  }
5785
          {  @@Dest  }
5094
          mov eax,Dest
5786
          mov eax,Dest
5095
          mov edx,offset @@Dest-4
5787
          mov edx,offset @@Dest-4
5096
          sub edx,offset @@StartCode
5788
          sub edx,offset @@StartCode
5097
          mov dword ptr [ecx+edx],eax
5789
          mov dword ptr [ecx+edx],eax
5098
        end;
5790
        end;
5099
      end else
5791
      end else
5100
      begin
5792
      begin
5101
        { Red Channel }
5793
        { Red Channel }
5102
        if chRed in EnableChannels then
5794
        if chRed in EnableChannels then
5103
        begin
5795
        begin
5104
          if chRed in ConstChannels1 then
5796
          if chRed in ConstChannels1 then
5105
          begin
5797
          begin
5106
            Func_col1_Add_const2(Code, @Dest.R, @Col2.R, @Col1.R);
5798
            Func_col1_Add_const2(Code, @Dest.R, @Col2.R, @Col1.R);
5107
          end else
5799
          end else
5108
          if chRed in ConstChannels2 then
5800
          if chRed in ConstChannels2 then
5109
          begin
5801
          begin
5110
            Func_col1_Add_const2(Code, @Dest.R, @Col1.R, @Col2.R);
5802
            Func_col1_Add_const2(Code, @Dest.R, @Col1.R, @Col2.R);
5111
          end else
5803
          end else
5112
            Func_col1_Add_col2(Code, @Dest.R, @Col1.R, @Col2.R);
5804
            Func_col1_Add_col2(Code, @Dest.R, @Col1.R, @Col2.R);
5113
        end;
5805
        end;
5114
 
5806
 
5115
        { Green Channel }
5807
        { Green Channel }
5116
        if chGreen in EnableChannels then
5808
        if chGreen in EnableChannels then
5117
        begin
5809
        begin
5118
          if chRed in ConstChannels1 then
5810
          if chRed in ConstChannels1 then
5119
          begin
5811
          begin
5120
            Func_col1_Add_const2(Code, @Dest.G, @Col2.G, @Col1.G);
5812
            Func_col1_Add_const2(Code, @Dest.G, @Col2.G, @Col1.G);
5121
          end else
5813
          end else
5122
          if chRed in ConstChannels2 then
5814
          if chRed in ConstChannels2 then
5123
          begin
5815
          begin
5124
            Func_col1_Add_const2(Code, @Dest.G, @Col1.G, @Col2.G);
5816
            Func_col1_Add_const2(Code, @Dest.G, @Col1.G, @Col2.G);
5125
          end else
5817
          end else
5126
            Func_col1_Add_col2(Code, @Dest.G, @Col1.G, @Col2.G);
5818
            Func_col1_Add_col2(Code, @Dest.G, @Col1.G, @Col2.G);
5127
        end;
5819
        end;
5128
 
5820
 
5129
        { Blue Channel }
5821
        { Blue Channel }
5130
        if chBlue in EnableChannels then
5822
        if chBlue in EnableChannels then
5131
        begin
5823
        begin
5132
          if chRed in ConstChannels1 then
5824
          if chRed in ConstChannels1 then
5133
          begin
5825
          begin
5134
            Func_col1_Add_const2(Code, @Dest.B, @Col2.B, @Col1.B);
5826
            Func_col1_Add_const2(Code, @Dest.B, @Col2.B, @Col1.B);
5135
          end else
5827
          end else
5136
          if chRed in ConstChannels2 then
5828
          if chRed in ConstChannels2 then
5137
          begin
5829
          begin
5138
            Func_col1_Add_const2(Code, @Dest.B, @Col1.B, @Col2.B);
5830
            Func_col1_Add_const2(Code, @Dest.B, @Col1.B, @Col2.B);
5139
          end else
5831
          end else
5140
            Func_col1_Add_col2(Code, @Dest.B, @Col1.B, @Col2.B);
5832
            Func_col1_Add_col2(Code, @Dest.B, @Col1.B, @Col2.B);
5141
        end;
5833
        end;
5142
 
5834
 
5143
        { Alpha Channel }
5835
        { Alpha Channel }
5144
        if chAlpha in EnableChannels then
5836
        if chAlpha in EnableChannels then
5145
        begin
5837
        begin
5146
          if chRed in ConstChannels1 then
5838
          if chRed in ConstChannels1 then
5147
          begin
5839
          begin
5148
            Func_col1_Add_const2(Code, @Dest.A, @Col2.A, @Col1.A);
5840
            Func_col1_Add_const2(Code, @Dest.A, @Col2.A, @Col1.A);
5149
          end else
5841
          end else
5150
          if chRed in ConstChannels2 then
5842
          if chRed in ConstChannels2 then
5151
          begin
5843
          begin
5152
            Func_col1_Add_const2(Code, @Dest.A, @Col1.A, @Col2.A);
5844
            Func_col1_Add_const2(Code, @Dest.A, @Col1.A, @Col2.A);
5153
          end else
5845
          end else
5154
            Func_col1_Add_col2(Code, @Dest.A, @Col1.A, @Col2.A);
5846
            Func_col1_Add_col2(Code, @Dest.A, @Col1.A, @Col2.A);
5155
        end;
5847
        end;
5156
      end;
5848
      end;
5157
    end;
5849
    end;
5158
 
5850
 
-
 
5851
    procedure genBlend_ONE2_SUB_ONE1(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
-
 
5852
      ConstChannels1, ConstChannels12: TDXRColorChannels);
-
 
5853
    begin
-
 
5854
      if UseMMX then
-
 
5855
      begin
-
 
5856
        FMMXUsed := True;
-
 
5857
        asm
-
 
5858
          jmp @@EndCode
-
 
5859
        @@StartCode:
-
 
5860
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
-
 
5861
                                 @@Col1:
-
 
5862
          db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
-
 
5863
                                 @@Col2:
-
 
5864
          db $0F,$D9,$C8      ///psubusw mm1,mm0
-
 
5865
          db $0F,$7F,$0D,$11,$11,$11,$11///movq qword ptr [$11111111],mm1
-
 
5866
                                 @@Dest:
-
 
5867
        @@EndCode:
-
 
5868
          {$I DXRender.inc}
-
 
5869
          {  @@Col1  }
-
 
5870
          mov eax,Col1
-
 
5871
          mov edx,offset @@Col1-4
-
 
5872
          sub edx,offset @@StartCode
-
 
5873
          mov dword ptr [ecx+edx],eax
-
 
5874
 
-
 
5875
          {  @@Col2  }
-
 
5876
          mov eax,Col2
-
 
5877
          mov edx,offset @@Col2-4
-
 
5878
          sub edx,offset @@StartCode
-
 
5879
          mov dword ptr [ecx+edx],eax
-
 
5880
 
-
 
5881
          {  @@Dest  }
-
 
5882
          mov eax,Dest
-
 
5883
          mov edx,offset @@Dest-4
-
 
5884
          sub edx,offset @@StartCode
-
 
5885
          mov dword ptr [ecx+edx],eax
-
 
5886
        end;
-
 
5887
      end else
-
 
5888
      begin
-
 
5889
        { Red Channel }
-
 
5890
        if chRed in EnableChannels then
-
 
5891
        begin
-
 
5892
          if chRed in ConstChannels1 then
-
 
5893
          begin
-
 
5894
            Func_col1_Sub_const2(Code, @Dest.R, @Col2.R, @Col1.R);
-
 
5895
          end else
-
 
5896
          if chRed in ConstChannels2 then
-
 
5897
          begin
-
 
5898
            Func_const1_Sub_col2(Code, @Dest.R, @Col1.R, @Col2.R);
-
 
5899
          end else
-
 
5900
            Func_col1_Sub_col2(Code, @Dest.R, @Col2.R, @Col1.R);
-
 
5901
        end;
-
 
5902
 
-
 
5903
        { Green Channel }
-
 
5904
        if chRed in EnableChannels then
-
 
5905
        begin
-
 
5906
          if chRed in ConstChannels1 then
-
 
5907
          begin
-
 
5908
            Func_col1_Sub_const2(Code, @Dest.G, @Col2.G, @Col1.G);
-
 
5909
          end else
-
 
5910
          if chRed in ConstChannels2 then
-
 
5911
          begin
-
 
5912
            Func_const1_Sub_col2(Code, @Dest.G, @Col1.G, @Col2.G);
-
 
5913
          end else
-
 
5914
            Func_col1_Sub_col2(Code, @Dest.G, @Col2.G, @Col1.G);
-
 
5915
        end;
-
 
5916
 
-
 
5917
        { Blue Channel }
-
 
5918
        if chRed in EnableChannels then
-
 
5919
        begin
-
 
5920
          if chRed in ConstChannels1 then
-
 
5921
          begin
-
 
5922
            Func_col1_Sub_const2(Code, @Dest.B, @Col2.B, @Col1.B);
-
 
5923
          end else
-
 
5924
          if chRed in ConstChannels2 then
-
 
5925
          begin
-
 
5926
            Func_const1_Sub_col2(Code, @Dest.B, @Col1.B, @Col2.B);
-
 
5927
          end else
-
 
5928
            Func_col1_Sub_col2(Code, @Dest.B, @Col2.B, @Col1.B);
-
 
5929
        end;
-
 
5930
 
-
 
5931
        { Alpha Channel }
-
 
5932
        if chRed in EnableChannels then
-
 
5933
        begin
-
 
5934
          if chRed in ConstChannels1 then
-
 
5935
          begin
-
 
5936
            Func_col1_Sub_const2(Code, @Dest.A, @Col2.A, @Col1.A);
-
 
5937
          end else
-
 
5938
          if chRed in ConstChannels2 then
-
 
5939
          begin
-
 
5940
            Func_const1_Sub_col2(Code, @Dest.A, @Col1.A, @Col2.A);
-
 
5941
          end else
-
 
5942
            Func_col1_Sub_col2(Code, @Dest.A, @Col2.A, @Col1.A);
-
 
5943
        end;
-
 
5944
      end;
-
 
5945
    end;
-
 
5946
 
5159
    procedure genBlend_ONE1_SUB_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5947
    procedure genBlend_ONE1_SUB_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5160
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5948
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5161
    begin
5949
    begin
5162
      if UseMMX then
5950
      if UseMMX then
5163
      begin
5951
      begin
5164
        FMMXUsed := True;
5952
        FMMXUsed := True;
5165
        asm
5953
        asm
5166
          jmp @@EndCode
5954
          jmp @@EndCode
5167
        @@StartCode:
5955
        @@StartCode:
5168
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5956
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5169
                                 @@Col1:
5957
                                 @@Col1:
5170
          db $0F,$D9,$05,$11,$11,$11,$11/// psubusw mm0,qword ptr [$11111111]
5958
          db $0F,$D9,$05,$11,$11,$11,$11/// psubusw mm0,qword ptr [$11111111]
5171
                                 @@Col2:
5959
                                 @@Col2:
5172
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5960
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5173
                                 @@Dest:
5961
                                 @@Dest:
5174
        @@EndCode:
5962
        @@EndCode:
5175
          {$I DXRender.inc}
5963
          {$I DXRender.inc}
5176
          {  @@Col1  }
5964
          {  @@Col1  }
5177
          mov eax,Col1
5965
          mov eax,Col1
5178
          mov edx,offset @@Col1-4
5966
          mov edx,offset @@Col1-4
5179
          sub edx,offset @@StartCode
5967
          sub edx,offset @@StartCode
5180
          mov dword ptr [ecx+edx],eax
5968
          mov dword ptr [ecx+edx],eax
5181
 
5969
 
5182
          {  @@Col2  }
5970
          {  @@Col2  }
5183
          mov eax,Col2
5971
          mov eax,Col2
5184
          mov edx,offset @@Col2-4
5972
          mov edx,offset @@Col2-4
5185
          sub edx,offset @@StartCode
5973
          sub edx,offset @@StartCode
5186
          mov dword ptr [ecx+edx],eax
5974
          mov dword ptr [ecx+edx],eax
5187
 
5975
 
5188
          {  @@Dest  }
5976
          {  @@Dest  }
5189
          mov eax,Dest
5977
          mov eax,Dest
5190
          mov edx,offset @@Dest-4
5978
          mov edx,offset @@Dest-4
5191
          sub edx,offset @@StartCode
5979
          sub edx,offset @@StartCode
5192
          mov dword ptr [ecx+edx],eax
5980
          mov dword ptr [ecx+edx],eax
5193
        end;
5981
        end;
5194
      end else
5982
      end else
5195
      begin
5983
      begin
5196
        { Red Channel }
5984
        { Red Channel }
5197
        if chRed in EnableChannels then
5985
        if chRed in EnableChannels then
5198
        begin
5986
        begin
5199
          if chRed in ConstChannels1 then
5987
          if chRed in ConstChannels1 then
5200
          begin
5988
          begin
5201
            Func_col1_Sub_const2(Code, @Dest.R, @Col1.R, @Col2.R);
5989
            Func_col1_Sub_const2(Code, @Dest.R, @Col1.R, @Col2.R);
5202
          end else
5990
          end else
5203
          if chRed in ConstChannels2 then
5991
          if chRed in ConstChannels2 then
5204
          begin
5992
          begin
5205
            Func_const1_Sub_col2(Code, @Dest.R, @Col2.R, @Col1.R);
5993
            Func_const1_Sub_col2(Code, @Dest.R, @Col2.R, @Col1.R);
5206
          end else
5994
          end else
5207
            Func_col1_Sub_col2(Code, @Dest.R, @Col1.R, @Col2.R);
5995
            Func_col1_Sub_col2(Code, @Dest.R, @Col1.R, @Col2.R);
5208
        end;
5996
        end;
5209
 
5997
 
5210
        { Green Channel }
5998
        { Green Channel }
5211
        if chRed in EnableChannels then
5999
        if chRed in EnableChannels then
5212
        begin
6000
        begin
5213
          if chRed in ConstChannels1 then
6001
          if chRed in ConstChannels1 then
5214
          begin
6002
          begin
5215
            Func_col1_Sub_const2(Code, @Dest.G, @Col1.G, @Col2.G);
6003
            Func_col1_Sub_const2(Code, @Dest.G, @Col1.G, @Col2.G);
5216
          end else
6004
          end else
5217
          if chRed in ConstChannels2 then
6005
          if chRed in ConstChannels2 then
5218
          begin
6006
          begin
5219
            Func_const1_Sub_col2(Code, @Dest.G, @Col2.G, @Col1.G);
6007
            Func_const1_Sub_col2(Code, @Dest.G, @Col2.G, @Col1.G);
5220
          end else
6008
          end else
5221
            Func_col1_Sub_col2(Code, @Dest.G, @Col1.G, @Col2.G);
6009
            Func_col1_Sub_col2(Code, @Dest.G, @Col1.G, @Col2.G);
5222
        end;
6010
        end;
5223
 
6011
 
5224
        { Blue Channel }
6012
        { Blue Channel }
5225
        if chRed in EnableChannels then
6013
        if chRed in EnableChannels then
5226
        begin
6014
        begin
5227
          if chRed in ConstChannels1 then
6015
          if chRed in ConstChannels1 then
5228
          begin
6016
          begin
5229
            Func_col1_Sub_const2(Code, @Dest.B, @Col1.B, @Col2.B);
6017
            Func_col1_Sub_const2(Code, @Dest.B, @Col1.B, @Col2.B);
5230
          end else
6018
          end else
5231
          if chRed in ConstChannels2 then
6019
          if chRed in ConstChannels2 then
5232
          begin
6020
          begin
5233
            Func_const1_Sub_col2(Code, @Dest.B, @Col2.B, @Col1.B);
6021
            Func_const1_Sub_col2(Code, @Dest.B, @Col2.B, @Col1.B);
5234
          end else
6022
          end else
5235
            Func_col1_Sub_col2(Code, @Dest.B, @Col1.B, @Col2.B);
6023
            Func_col1_Sub_col2(Code, @Dest.B, @Col1.B, @Col2.B);
5236
        end;
6024
        end;
5237
 
6025
 
5238
        { Alpha Channel }
6026
        { Alpha Channel }
5239
        if chRed in EnableChannels then
6027
        if chRed in EnableChannels then
5240
        begin
6028
        begin
5241
          if chRed in ConstChannels1 then
6029
          if chRed in ConstChannels1 then
5242
          begin
6030
          begin
5243
            Func_col1_Sub_const2(Code, @Dest.A, @Col1.A, @Col2.A);
6031
            Func_col1_Sub_const2(Code, @Dest.A, @Col1.A, @Col2.A);
5244
          end else
6032
          end else
5245
          if chRed in ConstChannels2 then
6033
          if chRed in ConstChannels2 then
5246
          begin
6034
          begin
5247
            Func_const1_Sub_col2(Code, @Dest.A, @Col2.A, @Col1.A);
6035
            Func_const1_Sub_col2(Code, @Dest.A, @Col2.A, @Col1.A);
5248
          end else
6036
          end else
5249
            Func_col1_Sub_col2(Code, @Dest.A, @Col1.A, @Col2.A);
6037
            Func_col1_Sub_col2(Code, @Dest.A, @Col1.A, @Col2.A);
5250
        end;
6038
        end;
5251
      end;
6039
      end;
5252
    end;
6040
    end;
5253
 
6041
 
5254
    procedure genBlend_ONE1_MUL_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6042
    procedure genBlend_ONE1_MUL_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5255
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6043
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5256
    begin
6044
    begin
5257
      if UseMMX then
6045
      if UseMMX then
5258
      begin
6046
      begin
5259
        FMMXUsed := True;
6047
        FMMXUsed := True;
5260
        asm
6048
        asm
5261
          jmp @@EndCode
6049
          jmp @@EndCode
5262
        @@StartCode:
6050
        @@StartCode:
5263
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
6051
          db $0F,$6F,$05,$11,$11,$11,$11/// movq mm0,qword ptr [$11111111]
5264
                                 @@Col1:
6052
                                 @@Col1:
5265
          db $0F,$6F,$0D,$11,$11,$11,$11/// movq mm1,qword ptr [$11111111]
6053
          db $0F,$6F,$0D,$11,$11,$11,$11/// movq mm1,qword ptr [$11111111]
5266
                                 @@Col2:
6054
                                 @@Col2:
5267
          db $0F,$71,$D0,$01       /// psrlw mm0,1
6055
          db $0F,$71,$D0,$01       /// psrlw mm0,1
5268
          db $0F,$71,$D1,$01       /// psrlw mm1,1
6056
          db $0F,$71,$D1,$01       /// psrlw mm1,1
5269
          db $0F,$E5,$C1           /// pmulhw mm0,mm1
6057
          db $0F,$E5,$C1           /// pmulhw mm0,mm1
5270
          db $0F,$71,$F0,$02       /// psllw mm0,2
6058
          db $0F,$71,$F0,$02       /// psllw mm0,2
5271
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
6059
          db $0F,$7F,$05,$11,$11,$11,$11/// movq qword ptr [$11111111],mm0
5272
                                 @@Dest:
6060
                                 @@Dest:
5273
        @@EndCode:
6061
        @@EndCode:
5274
          {$I DXRender.inc}
6062
          {$I DXRender.inc}
5275
          {  @@Col1  }
6063
          {  @@Col1  }
5276
          mov eax,Col1
6064
          mov eax,Col1
5277
          mov edx,offset @@Col1-4
6065
          mov edx,offset @@Col1-4
5278
          sub edx,offset @@StartCode
6066
          sub edx,offset @@StartCode
5279
          mov dword ptr [ecx+edx],eax
6067
          mov dword ptr [ecx+edx],eax
5280
 
6068
 
5281
          {  @@Col2  }
6069
          {  @@Col2  }
5282
          mov eax,Col2
6070
          mov eax,Col2
5283
          mov edx,offset @@Col2-4
6071
          mov edx,offset @@Col2-4
5284
          sub edx,offset @@StartCode
6072
          sub edx,offset @@StartCode
5285
          mov dword ptr [ecx+edx],eax
6073
          mov dword ptr [ecx+edx],eax
5286
 
6074
 
5287
          {  @@Dest  }
6075
          {  @@Dest  }
5288
          mov eax,Dest
6076
          mov eax,Dest
5289
          mov edx,offset @@Dest-4
6077
          mov edx,offset @@Dest-4
5290
          sub edx,offset @@StartCode
6078
          sub edx,offset @@StartCode
5291
          mov dword ptr [ecx+edx],eax
6079
          mov dword ptr [ecx+edx],eax
5292
        end;
6080
        end;
5293
      end else
6081
      end else
5294
      begin
6082
      begin
5295
        if chRed in EnableChannels then
6083
        if chRed in EnableChannels then
5296
        begin
6084
        begin
5297
          asm
6085
          asm
5298
            jmp @@EndCode
6086
            jmp @@EndCode
5299
          @@StartCode:
6087
          @@StartCode:
5300
            mov al,byte ptr [offset offset _null]{}@@Col1:
6088
            mov al,byte ptr [offset offset _null]{}@@Col1:
5301
            mul byte ptr [offset offset _null]   {}@@Col2:
6089
            mul byte ptr [offset offset _null]   {}@@Col2:
5302
            mov byte ptr [offset offset _null],ah{}@@Dest:
6090
            mov byte ptr [offset offset _null],ah{}@@Dest:
5303
          @@EndCode:
6091
          @@EndCode:
5304
            {$I DXRender.inc}
6092
            {$I DXRender.inc}
5305
            {  @@Col1  }
6093
            {  @@Col1  }
5306
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6094
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
5307
            mov edx,offset @@Col1-4
6095
            mov edx,offset @@Col1-4
5308
            sub edx,offset @@StartCode
6096
            sub edx,offset @@StartCode
5309
            mov dword ptr [ecx+edx],eax
6097
            mov dword ptr [ecx+edx],eax
5310
 
6098
 
5311
            {  @@Col2  }
6099
            {  @@Col2  }
5312
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
6100
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
5313
            mov edx,offset @@Col2-4
6101
            mov edx,offset @@Col2-4
5314
            sub edx,offset @@StartCode
6102
            sub edx,offset @@StartCode
5315
            mov dword ptr [ecx+edx],eax
6103
            mov dword ptr [ecx+edx],eax
5316
 
6104
 
5317
            {  @@Dest  }
6105
            {  @@Dest  }
5318
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6106
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
5319
            mov edx,offset @@Dest-4
6107
            mov edx,offset @@Dest-4
5320
            sub edx,offset @@StartCode
6108
            sub edx,offset @@StartCode
5321
            mov dword ptr [ecx+edx],eax
6109
            mov dword ptr [ecx+edx],eax
5322
          end;
6110
          end;
5323
        end;
6111
        end;
5324
 
6112
 
5325
        if chGreen in EnableChannels then
6113
        if chGreen in EnableChannels then
5326
        begin
6114
        begin
5327
          asm
6115
          asm
5328
            jmp @@EndCode
6116
            jmp @@EndCode
5329
          @@StartCode:
6117
          @@StartCode:
5330
            mov al,byte ptr [offset offset _null]{}@@Col1:
6118
            mov al,byte ptr [offset offset _null]{}@@Col1:
5331
            mul byte ptr [offset offset _null]   {}@@Col2:
6119
            mul byte ptr [offset offset _null]   {}@@Col2:
5332
            mov byte ptr [offset offset _null],ah{}@@Dest:
6120
            mov byte ptr [offset offset _null],ah{}@@Dest:
5333
          @@EndCode:
6121
          @@EndCode:
5334
            {$I DXRender.inc}
6122
            {$I DXRender.inc}
5335
            {  @@Col1  }
6123
            {  @@Col1  }
5336
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
6124
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
5337
            mov edx,offset @@Col1-4
6125
            mov edx,offset @@Col1-4
5338
            sub edx,offset @@StartCode
6126
            sub edx,offset @@StartCode
5339
            mov dword ptr [ecx+edx],eax
6127
            mov dword ptr [ecx+edx],eax
5340
 
6128
 
5341
            {  @@Col2  }
6129
            {  @@Col2  }
5342
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
6130
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
5343
            mov edx,offset @@Col2-4
6131
            mov edx,offset @@Col2-4
5344
            sub edx,offset @@StartCode
6132
            sub edx,offset @@StartCode
5345
            mov dword ptr [ecx+edx],eax
6133
            mov dword ptr [ecx+edx],eax
5346
 
6134
 
5347
            {  @@Dest  }
6135
            {  @@Dest  }
5348
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
6136
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
5349
            mov edx,offset @@Dest-4
6137
            mov edx,offset @@Dest-4
5350
            sub edx,offset @@StartCode
6138
            sub edx,offset @@StartCode
5351
            mov dword ptr [ecx+edx],eax
6139
            mov dword ptr [ecx+edx],eax
5352
          end;
6140
          end;
5353
        end;
6141
        end;
5354
 
6142
 
5355
        if chBlue in EnableChannels then
6143
        if chBlue in EnableChannels then
5356
        begin
6144
        begin
5357
          asm
6145
          asm
5358
            jmp @@EndCode
6146
            jmp @@EndCode
5359
          @@StartCode:
6147
          @@StartCode:
5360
            mov al,byte ptr [offset offset _null]{}@@Col1:
6148
            mov al,byte ptr [offset offset _null]{}@@Col1:
5361
            mul byte ptr [offset offset _null]   {}@@Col2:
6149
            mul byte ptr [offset offset _null]   {}@@Col2:
5362
            mov byte ptr [offset offset _null],ah{}@@Dest:
6150
            mov byte ptr [offset offset _null],ah{}@@Dest:
5363
          @@EndCode:
6151
          @@EndCode:
5364
            {$I DXRender.inc}
6152
            {$I DXRender.inc}
5365
            {  @@Col1  }
6153
            {  @@Col1  }
5366
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
6154
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
5367
            mov edx,offset @@Col1-4
6155
            mov edx,offset @@Col1-4
5368
            sub edx,offset @@StartCode
6156
            sub edx,offset @@StartCode
5369
            mov dword ptr [ecx+edx],eax
6157
            mov dword ptr [ecx+edx],eax
5370
 
6158
 
5371
            {  @@Col2  }
6159
            {  @@Col2  }
5372
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
6160
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
5373
            mov edx,offset @@Col2-4
6161
            mov edx,offset @@Col2-4
5374
            sub edx,offset @@StartCode
6162
            sub edx,offset @@StartCode
5375
            mov dword ptr [ecx+edx],eax
6163
            mov dword ptr [ecx+edx],eax
5376
 
6164
 
5377
            {  @@Dest  }
6165
            {  @@Dest  }
5378
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
6166
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
5379
            mov edx,offset @@Dest-4
6167
            mov edx,offset @@Dest-4
5380
            sub edx,offset @@StartCode
6168
            sub edx,offset @@StartCode
5381
            mov dword ptr [ecx+edx],eax
6169
            mov dword ptr [ecx+edx],eax
5382
          end;
6170
          end;
5383
        end;
6171
        end;
5384
 
6172
 
5385
        if chAlpha in EnableChannels then
6173
        if chAlpha in EnableChannels then
5386
        begin
6174
        begin
5387
          asm
6175
          asm
5388
            jmp @@EndCode
6176
            jmp @@EndCode
5389
          @@StartCode:
6177
          @@StartCode:
5390
            mov al,byte ptr [offset offset _null]{}@@Col1:
6178
            mov al,byte ptr [offset offset _null]{}@@Col1:
5391
            mul byte ptr [offset offset _null]   {}@@Col2:
6179
            mul byte ptr [offset offset _null]   {}@@Col2:
5392
            mov byte ptr [offset offset _null],ah{}@@Dest:
6180
            mov byte ptr [offset offset _null],ah{}@@Dest:
5393
          @@EndCode:
6181
          @@EndCode:
5394
            {$I DXRender.inc}
6182
            {$I DXRender.inc}
5395
            {  @@Col1  }
6183
            {  @@Col1  }
5396
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6184
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5397
            mov edx,offset @@Col1-4
6185
            mov edx,offset @@Col1-4
5398
            sub edx,offset @@StartCode
6186
            sub edx,offset @@StartCode
5399
            mov dword ptr [ecx+edx],eax
6187
            mov dword ptr [ecx+edx],eax
5400
 
6188
 
5401
            {  @@Col2  }
6189
            {  @@Col2  }
5402
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
6190
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
5403
            mov edx,offset @@Col2-4
6191
            mov edx,offset @@Col2-4
5404
            sub edx,offset @@StartCode
6192
            sub edx,offset @@StartCode
5405
            mov dword ptr [ecx+edx],eax
6193
            mov dword ptr [ecx+edx],eax
5406
 
6194
 
5407
            {  @@Dest  }
6195
            {  @@Dest  }
5408
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
6196
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
5409
            mov edx,offset @@Dest-4
6197
            mov edx,offset @@Dest-4
5410
            sub edx,offset @@StartCode
6198
            sub edx,offset @@StartCode
5411
            mov dword ptr [ecx+edx],eax
6199
            mov dword ptr [ecx+edx],eax
5412
          end;
6200
          end;
5413
        end;
6201
        end;
5414
      end;
6202
      end;
5415
    end;
6203
    end;
5416
 
6204
 
5417
    procedure genBlend_SRCALPHA1(var Code: Pointer; Dest, Col1: PDXRMachine_Color;
6205
    procedure genBlend_SRCALPHA1(var Code: Pointer; Dest, Col1: PDXRMachine_Color;
5418
      ConstChannels1: TDXRColorChannels);
6206
      ConstChannels1: TDXRColorChannels);
5419
    begin
6207
    begin
5420
      asm
6208
      asm
5421
        jmp @@EndCode
6209
        jmp @@EndCode
5422
      @@StartCode:
6210
      @@StartCode:
5423
        movzx ebx,byte ptr [offset _null]{}@@Col1:
6211
        movzx ebx,byte ptr [offset _null]{}@@Col1:
5424
      @@EndCode:
6212
      @@EndCode:
5425
        {$I DXRender.inc}
6213
        {$I DXRender.inc}
5426
        {  @@Col1  }
6214
        {  @@Col1  }
5427
        mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6215
        mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5428
        mov edx,offset @@Col1-4
6216
        mov edx,offset @@Col1-4
5429
        sub edx,offset @@StartCode
6217
        sub edx,offset @@StartCode
5430
        mov dword ptr [ecx+edx],eax
6218
        mov dword ptr [ecx+edx],eax
5431
      end;
6219
      end;
5432
 
6220
 
5433
      if [chRed, chGreen]<=EnableChannels then
6221
      if [chRed, chGreen]<=EnableChannels then
5434
      begin
6222
      begin
5435
        asm
6223
        asm
5436
          jmp @@EndCode
6224
          jmp @@EndCode
5437
        @@StartCode:
6225
        @@StartCode:
5438
          mov eax,dword ptr [offset _null]{}@@Col1:
6226
          mov eax,dword ptr [offset _null]{}@@Col1:
5439
          shr eax,8
6227
          shr eax,8
5440
          and eax,$00FF00FF
6228
          and eax,$00FF00FF
5441
          imul eax,ebx
6229
          imul eax,ebx
5442
          mov dword ptr [offset _null],eax{}@@Dest:
6230
          mov dword ptr [offset _null],eax{}@@Dest:
5443
        @@EndCode:
6231
        @@EndCode:
5444
          {$I DXRender.inc}
6232
          {$I DXRender.inc}
5445
          {  @@Col1  }
6233
          {  @@Col1  }
5446
          mov eax,Col1
6234
          mov eax,Col1
5447
          mov edx,offset @@Col1-4
6235
          mov edx,offset @@Col1-4
5448
          sub edx,offset @@StartCode
6236
          sub edx,offset @@StartCode
5449
          mov dword ptr [ecx+edx],eax
6237
          mov dword ptr [ecx+edx],eax
5450
 
6238
 
5451
          {  @@Dest  }
6239
          {  @@Dest  }
5452
          mov eax,Dest
6240
          mov eax,Dest
5453
          mov edx,offset @@Dest-4
6241
          mov edx,offset @@Dest-4
5454
          sub edx,offset @@StartCode
6242
          sub edx,offset @@StartCode
5455
          mov dword ptr [ecx+edx],eax
6243
          mov dword ptr [ecx+edx],eax
5456
        end;
6244
        end;
5457
      end else
6245
      end else
5458
      begin
6246
      begin
5459
        if chRed in EnableChannels then
6247
        if chRed in EnableChannels then
5460
        begin
6248
        begin
5461
          asm
6249
          asm
5462
            jmp @@EndCode
6250
            jmp @@EndCode
5463
          @@StartCode:
6251
          @@StartCode:
5464
            movzx eax,byte ptr [offset _null]{}@@Col1:
6252
            movzx eax,byte ptr [offset _null]{}@@Col1:
5465
            imul eax,ebx
6253
            imul eax,ebx
5466
            mov byte ptr [offset _null],ah{}@@Dest:
6254
            mov byte ptr [offset _null],ah{}@@Dest:
5467
          @@EndCode:
6255
          @@EndCode:
5468
            {$I DXRender.inc}
6256
            {$I DXRender.inc}
5469
            {  @@Col1  }
6257
            {  @@Col1  }
5470
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6258
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
5471
            mov edx,offset @@Col1-4
6259
            mov edx,offset @@Col1-4
5472
            sub edx,offset @@StartCode
6260
            sub edx,offset @@StartCode
5473
            mov dword ptr [ecx+edx],eax
6261
            mov dword ptr [ecx+edx],eax
5474
 
6262
 
5475
            {  @@Dest  }
6263
            {  @@Dest  }
5476
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6264
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
5477
            mov edx,offset @@Dest-4
6265
            mov edx,offset @@Dest-4
5478
            sub edx,offset @@StartCode
6266
            sub edx,offset @@StartCode
5479
            mov dword ptr [ecx+edx],eax
6267
            mov dword ptr [ecx+edx],eax
5480
          end;
6268
          end;
5481
        end;
6269
        end;
5482
 
6270
 
5483
        if chGreen in EnableChannels then
6271
        if chGreen in EnableChannels then
5484
        begin
6272
        begin
5485
          asm
6273
          asm
5486
            jmp @@EndCode
6274
            jmp @@EndCode
5487
          @@StartCode:
6275
          @@StartCode:
5488
            movzx eax,byte ptr [offset _null]{}@@Col1:
6276
            movzx eax,byte ptr [offset _null]{}@@Col1:
5489
            imul eax,ebx
6277
            imul eax,ebx
5490
            mov byte ptr [offset _null],ah{}@@Dest:
6278
            mov byte ptr [offset _null],ah{}@@Dest:
5491
          @@EndCode:
6279
          @@EndCode:
5492
            {$I DXRender.inc}
6280
            {$I DXRender.inc}
5493
            {  @@Col1  }
6281
            {  @@Col1  }
5494
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
6282
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
5495
            mov edx,offset @@Col1-4
6283
            mov edx,offset @@Col1-4
5496
            sub edx,offset @@StartCode
6284
            sub edx,offset @@StartCode
5497
            mov dword ptr [ecx+edx],eax
6285
            mov dword ptr [ecx+edx],eax
5498
 
6286
 
5499
            {  @@Dest  }
6287
            {  @@Dest  }
5500
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
6288
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
5501
            mov edx,offset @@Dest-4
6289
            mov edx,offset @@Dest-4
5502
            sub edx,offset @@StartCode
6290
            sub edx,offset @@StartCode
5503
            mov dword ptr [ecx+edx],eax
6291
            mov dword ptr [ecx+edx],eax
5504
          end;
6292
          end;
5505
        end;
6293
        end;
5506
      end;
6294
      end;
5507
 
6295
 
5508
      if [chBlue, chAlpha]<=EnableChannels then
6296
      if [chBlue, chAlpha]<=EnableChannels then
5509
      begin
6297
      begin
5510
        asm
6298
        asm
5511
          jmp @@EndCode
6299
          jmp @@EndCode
5512
        @@StartCode:
6300
        @@StartCode:
5513
          mov eax,dword ptr [offset _null]{}@@Col1:
6301
          mov eax,dword ptr [offset _null]{}@@Col1:
5514
          shr eax,8
6302
          shr eax,8
5515
          and eax,$00FF00FF
6303
          and eax,$00FF00FF
5516
          imul eax,ebx
6304
          imul eax,ebx
5517
          mov dword ptr [offset _null],eax{}@@Dest:
6305
          mov dword ptr [offset _null],eax{}@@Dest:
5518
        @@EndCode:
6306
        @@EndCode:
5519
          {$I DXRender.inc}
6307
          {$I DXRender.inc}
5520
          {  @@Col1  }
6308
          {  @@Col1  }
5521
          mov eax,Col1; add eax,4
6309
          mov eax,Col1; add eax,4
5522
          mov edx,offset @@Col1-4
6310
          mov edx,offset @@Col1-4
5523
          sub edx,offset @@StartCode
6311
          sub edx,offset @@StartCode
5524
          mov dword ptr [ecx+edx],eax
6312
          mov dword ptr [ecx+edx],eax
5525
 
6313
 
5526
          {  @@Dest  }
6314
          {  @@Dest  }
5527
          mov eax,Dest; add eax,4
6315
          mov eax,Dest; add eax,4
5528
          mov edx,offset @@Dest-4
6316
          mov edx,offset @@Dest-4
5529
          sub edx,offset @@StartCode
6317
          sub edx,offset @@StartCode
5530
          mov dword ptr [ecx+edx],eax
6318
          mov dword ptr [ecx+edx],eax
5531
        end;
6319
        end;
5532
      end else
6320
      end else
5533
      begin
6321
      begin
5534
        if chBlue in EnableChannels then
6322
        if chBlue in EnableChannels then
5535
        begin
6323
        begin
5536
          asm
6324
          asm
5537
            jmp @@EndCode
6325
            jmp @@EndCode
5538
          @@StartCode:
6326
          @@StartCode:
5539
            movzx eax,byte ptr [offset _null]{}@@Col1:
6327
            movzx eax,byte ptr [offset _null]{}@@Col1:
5540
            imul eax,ebx
6328
            imul eax,ebx
5541
            mov byte ptr [offset _null],ah{}@@Dest:
6329
            mov byte ptr [offset _null],ah{}@@Dest:
5542
          @@EndCode:
6330
          @@EndCode:
5543
            {$I DXRender.inc}
6331
            {$I DXRender.inc}
5544
            {  @@Col1  }
6332
            {  @@Col1  }
5545
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
6333
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
5546
            mov edx,offset @@Col1-4
6334
            mov edx,offset @@Col1-4
5547
            sub edx,offset @@StartCode
6335
            sub edx,offset @@StartCode
5548
            mov dword ptr [ecx+edx],eax
6336
            mov dword ptr [ecx+edx],eax
5549
 
6337
 
5550
            {  @@Dest  }
6338
            {  @@Dest  }
5551
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
6339
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
5552
            mov edx,offset @@Dest-4
6340
            mov edx,offset @@Dest-4
5553
            sub edx,offset @@StartCode
6341
            sub edx,offset @@StartCode
5554
            mov dword ptr [ecx+edx],eax
6342
            mov dword ptr [ecx+edx],eax
5555
          end;
6343
          end;
5556
        end;
6344
        end;
5557
 
6345
 
5558
        if chAlpha in EnableChannels then
6346
        if chAlpha in EnableChannels then
5559
        begin
6347
        begin
5560
          asm
6348
          asm
5561
            jmp @@EndCode
6349
            jmp @@EndCode
5562
          @@StartCode:
6350
          @@StartCode:
5563
            movzx eax,byte ptr [offset _null]{}@@Col1:
6351
            movzx eax,byte ptr [offset _null]{}@@Col1:
5564
            imul eax,ebx
6352
            imul eax,ebx
5565
            mov byte ptr [offset _null],ah{}@@Dest:
6353
            mov byte ptr [offset _null],ah{}@@Dest:
5566
          @@EndCode:
6354
          @@EndCode:
5567
            {$I DXRender.inc}
6355
            {$I DXRender.inc}
5568
            {  @@Col1  }
6356
            {  @@Col1  }
5569
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6357
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5570
            mov edx,offset @@Col1-4
6358
            mov edx,offset @@Col1-4
5571
            sub edx,offset @@StartCode
6359
            sub edx,offset @@StartCode
5572
            mov dword ptr [ecx+edx],eax
6360
            mov dword ptr [ecx+edx],eax
5573
 
6361
 
5574
            {  @@Dest  }
6362
            {  @@Dest  }
5575
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
6363
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
5576
            mov edx,offset @@Dest-4
6364
            mov edx,offset @@Dest-4
5577
            sub edx,offset @@StartCode
6365
            sub edx,offset @@StartCode
5578
            mov dword ptr [ecx+edx],eax
6366
            mov dword ptr [ecx+edx],eax
5579
          end;
6367
          end;
5580
        end;
6368
        end;
5581
      end;
6369
      end;
5582
    end;
6370
    end;
5583
 
6371
 
5584
    procedure genBlend_SRCALPHA1_ADD_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6372
    procedure genBlend_SRCALPHA1_ADD_ONE2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5585
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6373
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5586
    begin
6374
    begin
5587
      asm
6375
      asm
5588
        jmp @@EndCode
6376
        jmp @@EndCode
5589
      @@StartCode:
6377
      @@StartCode:
5590
        movzx ebx,byte ptr [offset _null]{}@@Col1:
6378
        movzx ebx,byte ptr [offset _null]{}@@Col1:
5591
      @@EndCode:
6379
      @@EndCode:
5592
        {$I DXRender.inc}
6380
        {$I DXRender.inc}
5593
        {  @@Col1  }
6381
        {  @@Col1  }
5594
        mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6382
        mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5595
        mov edx,offset @@Col1-4
6383
        mov edx,offset @@Col1-4
5596
        sub edx,offset @@StartCode
6384
        sub edx,offset @@StartCode
5597
        mov dword ptr [ecx+edx],eax
6385
        mov dword ptr [ecx+edx],eax
5598
      end;
6386
      end;
5599
 
6387
 
5600
      if chRed in EnableChannels then
6388
      if chRed in EnableChannels then
5601
      begin
6389
      begin
5602
        asm
6390
        asm
5603
          jmp @@EndCode
6391
          jmp @@EndCode
5604
        @@StartCode:
6392
        @@StartCode:
5605
          movzx eax,byte ptr [offset _null]{}@@Col1:
6393
          movzx eax,byte ptr [offset _null]{}@@Col1:
5606
          movzx edx,byte ptr [offset _null]{}@@Col2:
6394
          movzx edx,byte ptr [offset _null]{}@@Col2:
5607
          imul eax,ebx
6395
          imul eax,ebx
5608
          shr eax,8
6396
          shr eax,8
5609
          mov al,byte ptr [offset (_AddTable + eax + edx)]
6397
          mov al,byte ptr [offset (_AddTable + eax + edx)]
5610
          mov byte ptr [offset _null],al{}@@Dest:
6398
          mov byte ptr [offset _null],al{}@@Dest:
5611
        @@EndCode:
6399
        @@EndCode:
5612
          {$I DXRender.inc}
6400
          {$I DXRender.inc}
5613
          {  @@Col1  }
6401
          {  @@Col1  }
5614
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6402
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
5615
          mov edx,offset @@Col1-4
6403
          mov edx,offset @@Col1-4
5616
          sub edx,offset @@StartCode
6404
          sub edx,offset @@StartCode
5617
          mov dword ptr [ecx+edx],eax
6405
          mov dword ptr [ecx+edx],eax
5618
 
6406
 
5619
          {  @@Col2  }
6407
          {  @@Col2  }
5620
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
6408
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
5621
          mov edx,offset @@Col2-4
6409
          mov edx,offset @@Col2-4
5622
          sub edx,offset @@StartCode
6410
          sub edx,offset @@StartCode
5623
          mov dword ptr [ecx+edx],eax
6411
          mov dword ptr [ecx+edx],eax
5624
 
6412
 
5625
          {  @@Dest  }
6413
          {  @@Dest  }
5626
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6414
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
5627
          mov edx,offset @@Dest-4
6415
          mov edx,offset @@Dest-4
5628
          sub edx,offset @@StartCode
6416
          sub edx,offset @@StartCode
5629
          mov dword ptr [ecx+edx],eax
6417
          mov dword ptr [ecx+edx],eax
5630
        end;
6418
        end;
5631
      end;
6419
      end;
5632
 
6420
 
5633
      if chGreen in EnableChannels then
6421
      if chGreen in EnableChannels then
5634
      begin
6422
      begin
5635
        asm
6423
        asm
5636
          jmp @@EndCode
6424
          jmp @@EndCode
5637
        @@StartCode:
6425
        @@StartCode:
5638
          movzx eax,byte ptr [offset _null]{}@@Col1:
6426
          movzx eax,byte ptr [offset _null]{}@@Col1:
5639
          movzx edx,byte ptr [offset _null]{}@@Col2:
6427
          movzx edx,byte ptr [offset _null]{}@@Col2:
5640
          imul eax,ebx
6428
          imul eax,ebx
5641
          shr eax,8
6429
          shr eax,8
5642
          mov al,byte ptr [offset (_AddTable + eax + edx)]
6430
          mov al,byte ptr [offset (_AddTable + eax + edx)]
5643
          mov byte ptr [offset _null],al{}@@Dest:
6431
          mov byte ptr [offset _null],al{}@@Dest:
5644
        @@EndCode:
6432
        @@EndCode:
5645
          {$I DXRender.inc}
6433
          {$I DXRender.inc}
5646
          {  @@Col1  }
6434
          {  @@Col1  }
5647
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
6435
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
5648
          mov edx,offset @@Col1-4
6436
          mov edx,offset @@Col1-4
5649
          sub edx,offset @@StartCode
6437
          sub edx,offset @@StartCode
5650
          mov dword ptr [ecx+edx],eax
6438
          mov dword ptr [ecx+edx],eax
5651
 
6439
 
5652
          {  @@Col2  }
6440
          {  @@Col2  }
5653
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
6441
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
5654
          mov edx,offset @@Col2-4
6442
          mov edx,offset @@Col2-4
5655
          sub edx,offset @@StartCode
6443
          sub edx,offset @@StartCode
5656
          mov dword ptr [ecx+edx],eax
6444
          mov dword ptr [ecx+edx],eax
5657
 
6445
 
5658
          {  @@Dest  }
6446
          {  @@Dest  }
5659
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
6447
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
5660
          mov edx,offset @@Dest-4
6448
          mov edx,offset @@Dest-4
5661
          sub edx,offset @@StartCode
6449
          sub edx,offset @@StartCode
5662
          mov dword ptr [ecx+edx],eax
6450
          mov dword ptr [ecx+edx],eax
5663
        end;
6451
        end;
5664
      end;
6452
      end;
5665
 
6453
 
5666
      if chBlue in EnableChannels then
6454
      if chBlue in EnableChannels then
5667
      begin
6455
      begin
5668
        asm
6456
        asm
5669
          jmp @@EndCode
6457
          jmp @@EndCode
5670
        @@StartCode:
6458
        @@StartCode:
5671
          movzx eax,byte ptr [offset _null]{}@@Col1:
6459
          movzx eax,byte ptr [offset _null]{}@@Col1:
5672
          movzx edx,byte ptr [offset _null]{}@@Col2:
6460
          movzx edx,byte ptr [offset _null]{}@@Col2:
5673
          imul eax,ebx
6461
          imul eax,ebx
5674
          shr eax,8
6462
          shr eax,8
5675
          mov al,byte ptr [offset (_AddTable + eax + edx)]
6463
          mov al,byte ptr [offset (_AddTable + eax + edx)]
5676
          mov byte ptr [offset _null],al{}@@Dest:
6464
          mov byte ptr [offset _null],al{}@@Dest:
5677
        @@EndCode:
6465
        @@EndCode:
5678
          {$I DXRender.inc}
6466
          {$I DXRender.inc}
5679
          {  @@Col1  }
6467
          {  @@Col1  }
5680
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
6468
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
5681
          mov edx,offset @@Col1-4
6469
          mov edx,offset @@Col1-4
5682
          sub edx,offset @@StartCode
6470
          sub edx,offset @@StartCode
5683
          mov dword ptr [ecx+edx],eax
6471
          mov dword ptr [ecx+edx],eax
5684
 
6472
 
5685
          {  @@Col2  }
6473
          {  @@Col2  }
5686
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
6474
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
5687
          mov edx,offset @@Col2-4
6475
          mov edx,offset @@Col2-4
5688
          sub edx,offset @@StartCode
6476
          sub edx,offset @@StartCode
5689
          mov dword ptr [ecx+edx],eax
6477
          mov dword ptr [ecx+edx],eax
5690
 
6478
 
5691
          {  @@Dest  }
6479
          {  @@Dest  }
5692
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
6480
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
5693
          mov edx,offset @@Dest-4
6481
          mov edx,offset @@Dest-4
5694
          sub edx,offset @@StartCode
6482
          sub edx,offset @@StartCode
5695
          mov dword ptr [ecx+edx],eax
6483
          mov dword ptr [ecx+edx],eax
5696
        end;
6484
        end;
5697
      end;
6485
      end;
5698
 
6486
 
5699
      if chAlpha in EnableChannels then
6487
      if chAlpha in EnableChannels then
5700
      begin
6488
      begin
5701
        asm
6489
        asm
5702
          jmp @@EndCode
6490
          jmp @@EndCode
5703
        @@StartCode:
6491
        @@StartCode:
5704
          movzx eax,byte ptr [offset _null]{}@@Col1:
6492
          movzx eax,byte ptr [offset _null]{}@@Col1:
5705
          movzx edx,byte ptr [offset _null]{}@@Col2:
6493
          movzx edx,byte ptr [offset _null]{}@@Col2:
5706
          imul eax,ebx
6494
          imul eax,ebx
5707
          shr eax,8
6495
          shr eax,8
5708
          mov al,byte ptr [offset (_AddTable + eax + edx)]
6496
          mov al,byte ptr [offset (_AddTable + eax + edx)]
5709
          mov byte ptr [offset _null],al{}@@Dest:
6497
          mov byte ptr [offset _null],al{}@@Dest:
5710
        @@EndCode:
6498
        @@EndCode:
5711
          {$I DXRender.inc}
6499
          {$I DXRender.inc}
5712
          {  @@Col1  }
6500
          {  @@Col1  }
5713
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6501
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5714
          mov edx,offset @@Col1-4
6502
          mov edx,offset @@Col1-4
5715
          sub edx,offset @@StartCode
6503
          sub edx,offset @@StartCode
5716
          mov dword ptr [ecx+edx],eax
6504
          mov dword ptr [ecx+edx],eax
5717
 
6505
 
5718
          {  @@Col2  }
6506
          {  @@Col2  }
5719
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
6507
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
5720
          mov edx,offset @@Col2-4
6508
          mov edx,offset @@Col2-4
5721
          sub edx,offset @@StartCode
6509
          sub edx,offset @@StartCode
5722
          mov dword ptr [ecx+edx],eax
6510
          mov dword ptr [ecx+edx],eax
5723
 
6511
 
5724
          {  @@Dest  }
6512
          {  @@Dest  }
5725
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
6513
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
5726
          mov edx,offset @@Dest-4
6514
          mov edx,offset @@Dest-4
5727
          sub edx,offset @@StartCode
6515
          sub edx,offset @@StartCode
5728
          mov dword ptr [ecx+edx],eax
6516
          mov dword ptr [ecx+edx],eax
5729
        end;
6517
        end;
5730
      end;
6518
      end;
5731
    end;
6519
    end;
5732
 
6520
 
5733
    procedure genBlend_ONE2_SUB_SRCALPHA1(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6521
    procedure genBlend_ONE2_SUB_SRCALPHA1(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5734
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6522
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5735
    begin
6523
    begin
5736
      asm
6524
      asm
5737
        jmp @@EndCode
6525
        jmp @@EndCode
5738
      @@StartCode:
6526
      @@StartCode:
5739
        movzx ebx,byte ptr [offset _null]{}@@Col1:
6527
        movzx ebx,byte ptr [offset _null]{}@@Col1:
5740
      @@EndCode:
6528
      @@EndCode:
5741
        {$I DXRender.inc}
6529
        {$I DXRender.inc}
5742
        {  @@Col1  }
6530
        {  @@Col1  }
5743
        mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6531
        mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5744
        mov edx,offset @@Col1-4
6532
        mov edx,offset @@Col1-4
5745
        sub edx,offset @@StartCode
6533
        sub edx,offset @@StartCode
5746
        mov dword ptr [ecx+edx],eax
6534
        mov dword ptr [ecx+edx],eax
5747
      end;
6535
      end;
5748
 
6536
 
5749
      if chRed in EnableChannels then
6537
      if chRed in EnableChannels then
5750
      begin
6538
      begin
5751
        asm
6539
        asm
5752
          jmp @@EndCode
6540
          jmp @@EndCode
5753
        @@StartCode:
6541
        @@StartCode:
5754
          movzx eax,byte ptr [offset _null]{}@@Col1:
6542
          movzx eax,byte ptr [offset _null]{}@@Col1:
5755
          movzx edx,byte ptr [offset _null]{}@@Col2:
6543
          movzx edx,byte ptr [offset _null]{}@@Col2:
5756
          imul eax,ebx
6544
          imul eax,ebx
5757
          shr eax,8
6545
          shr eax,8
5758
          sub edx,eax
6546
          sub edx,eax
5759
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
6547
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
5760
          mov byte ptr [offset _null],al{}@@Dest:
6548
          mov byte ptr [offset _null],al{}@@Dest:
5761
        @@EndCode:
6549
        @@EndCode:
5762
          {$I DXRender.inc}
6550
          {$I DXRender.inc}
5763
          {  @@Col1  }
6551
          {  @@Col1  }
5764
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6552
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
5765
          mov edx,offset @@Col1-4
6553
          mov edx,offset @@Col1-4
5766
          sub edx,offset @@StartCode
6554
          sub edx,offset @@StartCode
5767
          mov dword ptr [ecx+edx],eax
6555
          mov dword ptr [ecx+edx],eax
5768
 
6556
 
5769
          {  @@Col2  }
6557
          {  @@Col2  }
5770
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
6558
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
5771
          mov edx,offset @@Col2-4
6559
          mov edx,offset @@Col2-4
5772
          sub edx,offset @@StartCode
6560
          sub edx,offset @@StartCode
5773
          mov dword ptr [ecx+edx],eax
6561
          mov dword ptr [ecx+edx],eax
5774
 
6562
 
5775
          {  @@Dest  }
6563
          {  @@Dest  }
5776
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6564
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
5777
          mov edx,offset @@Dest-4
6565
          mov edx,offset @@Dest-4
5778
          sub edx,offset @@StartCode
6566
          sub edx,offset @@StartCode
5779
          mov dword ptr [ecx+edx],eax
6567
          mov dword ptr [ecx+edx],eax
5780
        end;
6568
        end;
5781
      end;
6569
      end;
5782
 
6570
 
5783
      if chGreen in EnableChannels then
6571
      if chGreen in EnableChannels then
5784
      begin
6572
      begin
5785
        asm
6573
        asm
5786
          jmp @@EndCode
6574
          jmp @@EndCode
5787
        @@StartCode:
6575
        @@StartCode:
5788
          movzx eax,byte ptr [offset _null]{}@@Col1:
6576
          movzx eax,byte ptr [offset _null]{}@@Col1:
5789
          movzx edx,byte ptr [offset _null]{}@@Col2:
6577
          movzx edx,byte ptr [offset _null]{}@@Col2:
5790
          imul eax,ebx
6578
          imul eax,ebx
5791
          shr eax,8
6579
          shr eax,8
5792
          sub edx,eax
6580
          sub edx,eax
5793
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
6581
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
5794
          mov byte ptr [offset _null],al{}@@Dest:
6582
          mov byte ptr [offset _null],al{}@@Dest:
5795
        @@EndCode:
6583
        @@EndCode:
5796
          {$I DXRender.inc}
6584
          {$I DXRender.inc}
5797
          {  @@Col1  }
6585
          {  @@Col1  }
5798
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
6586
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
5799
          mov edx,offset @@Col1-4
6587
          mov edx,offset @@Col1-4
5800
          sub edx,offset @@StartCode
6588
          sub edx,offset @@StartCode
5801
          mov dword ptr [ecx+edx],eax
6589
          mov dword ptr [ecx+edx],eax
5802
 
6590
 
5803
          {  @@Col2  }
6591
          {  @@Col2  }
5804
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
6592
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
5805
          mov edx,offset @@Col2-4
6593
          mov edx,offset @@Col2-4
5806
          sub edx,offset @@StartCode
6594
          sub edx,offset @@StartCode
5807
          mov dword ptr [ecx+edx],eax
6595
          mov dword ptr [ecx+edx],eax
5808
 
6596
 
5809
          {  @@Dest  }
6597
          {  @@Dest  }
5810
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
6598
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
5811
          mov edx,offset @@Dest-4
6599
          mov edx,offset @@Dest-4
5812
          sub edx,offset @@StartCode
6600
          sub edx,offset @@StartCode
5813
          mov dword ptr [ecx+edx],eax
6601
          mov dword ptr [ecx+edx],eax
5814
        end;
6602
        end;
5815
      end;
6603
      end;
5816
 
6604
 
5817
      if chBlue in EnableChannels then
6605
      if chBlue in EnableChannels then
5818
      begin
6606
      begin
5819
        asm
6607
        asm
5820
          jmp @@EndCode
6608
          jmp @@EndCode
5821
        @@StartCode:
6609
        @@StartCode:
5822
          movzx eax,byte ptr [offset _null]{}@@Col1:
6610
          movzx eax,byte ptr [offset _null]{}@@Col1:
5823
          movzx edx,byte ptr [offset _null]{}@@Col2:
6611
          movzx edx,byte ptr [offset _null]{}@@Col2:
5824
          imul eax,ebx
6612
          imul eax,ebx
5825
          shr eax,8
6613
          shr eax,8
5826
          sub edx,eax
6614
          sub edx,eax
5827
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
6615
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
5828
          mov byte ptr [offset _null],al{}@@Dest:
6616
          mov byte ptr [offset _null],al{}@@Dest:
5829
        @@EndCode:
6617
        @@EndCode:
5830
          {$I DXRender.inc}
6618
          {$I DXRender.inc}
5831
          {  @@Col1  }
6619
          {  @@Col1  }
5832
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
6620
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
5833
          mov edx,offset @@Col1-4
6621
          mov edx,offset @@Col1-4
5834
          sub edx,offset @@StartCode
6622
          sub edx,offset @@StartCode
5835
          mov dword ptr [ecx+edx],eax
6623
          mov dword ptr [ecx+edx],eax
5836
 
6624
 
5837
          {  @@Col2  }
6625
          {  @@Col2  }
5838
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
6626
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
5839
          mov edx,offset @@Col2-4
6627
          mov edx,offset @@Col2-4
5840
          sub edx,offset @@StartCode
6628
          sub edx,offset @@StartCode
5841
          mov dword ptr [ecx+edx],eax
6629
          mov dword ptr [ecx+edx],eax
5842
 
6630
 
5843
          {  @@Dest  }
6631
          {  @@Dest  }
5844
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
6632
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
5845
          mov edx,offset @@Dest-4
6633
          mov edx,offset @@Dest-4
5846
          sub edx,offset @@StartCode
6634
          sub edx,offset @@StartCode
5847
          mov dword ptr [ecx+edx],eax
6635
          mov dword ptr [ecx+edx],eax
5848
        end;
6636
        end;
5849
      end;
6637
      end;
5850
 
6638
 
5851
      if chAlpha in EnableChannels then
6639
      if chAlpha in EnableChannels then
5852
      begin
6640
      begin
5853
        asm
6641
        asm
5854
          jmp @@EndCode
6642
          jmp @@EndCode
5855
        @@StartCode:
6643
        @@StartCode:
5856
          movzx eax,byte ptr [offset _null]{}@@Col1:
6644
          movzx eax,byte ptr [offset _null]{}@@Col1:
5857
          movzx edx,byte ptr [offset _null]{}@@Col2:
6645
          movzx edx,byte ptr [offset _null]{}@@Col2:
5858
          imul eax,ebx
6646
          imul eax,ebx
5859
          shr eax,8
6647
          shr eax,8
5860
          sub edx,eax
6648
          sub edx,eax
5861
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
6649
          mov al,byte ptr [offset (_SubTable + 255 + edx)]
5862
          mov byte ptr [offset _null],al{}@@Dest:
6650
          mov byte ptr [offset _null],al{}@@Dest:
5863
        @@EndCode:
6651
        @@EndCode:
5864
          {$I DXRender.inc}
6652
          {$I DXRender.inc}
5865
          {  @@Col1  }
6653
          {  @@Col1  }
5866
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6654
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5867
          mov edx,offset @@Col1-4
6655
          mov edx,offset @@Col1-4
5868
          sub edx,offset @@StartCode
6656
          sub edx,offset @@StartCode
5869
          mov dword ptr [ecx+edx],eax
6657
          mov dword ptr [ecx+edx],eax
5870
 
6658
 
5871
          {  @@Col2  }
6659
          {  @@Col2  }
5872
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
6660
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
5873
          mov edx,offset @@Col2-4
6661
          mov edx,offset @@Col2-4
5874
          sub edx,offset @@StartCode
6662
          sub edx,offset @@StartCode
5875
          mov dword ptr [ecx+edx],eax
6663
          mov dword ptr [ecx+edx],eax
5876
 
6664
 
5877
          {  @@Dest  }
6665
          {  @@Dest  }
5878
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
6666
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
5879
          mov edx,offset @@Dest-4
6667
          mov edx,offset @@Dest-4
5880
          sub edx,offset @@StartCode
6668
          sub edx,offset @@StartCode
5881
          mov dword ptr [ecx+edx],eax
6669
          mov dword ptr [ecx+edx],eax
5882
        end;
6670
        end;
5883
      end;
6671
      end;
5884
    end;
6672
    end;
5885
 
6673
 
5886
    procedure genBlend_SRCALPHA1_ADD_INVSRCALPHA2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6674
    procedure genBlend_SRCALPHA1_ADD_INVSRCALPHA2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
5887
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6675
      ConstChannels1, ConstChannels12: TDXRColorChannels);
5888
    begin
6676
    begin
5889
      asm
6677
      asm
5890
        jmp @@EndCode
6678
        jmp @@EndCode
5891
      @@StartCode:
6679
      @@StartCode:
5892
        movzx ebx,byte ptr [offset _null]{}@@Col1:
6680
        movzx ebx,byte ptr [offset _null]{}@@Col1:
5893
        mov ebp,ebx
6681
        mov ebp,ebx
5894
        xor ebp,$FF
6682
        xor ebp,$FF
5895
      @@EndCode:
6683
      @@EndCode:
5896
        {$I DXRender.inc}
6684
        {$I DXRender.inc}
5897
        {  @@Col1  }
6685
        {  @@Col1  }
5898
        mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6686
        mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
5899
        mov edx,offset @@Col1-4
6687
        mov edx,offset @@Col1-4
5900
        sub edx,offset @@StartCode
6688
        sub edx,offset @@StartCode
5901
        mov dword ptr [ecx+edx],eax
6689
        mov dword ptr [ecx+edx],eax
5902
      end;
6690
      end;
5903
                       
6691
                       
5904
      if [chRed, chGreen]<=EnableChannels then
6692
      if [chRed, chGreen]<=EnableChannels then
5905
      begin
6693
      begin
5906
        asm
6694
        asm
5907
          jmp @@EndCode
6695
          jmp @@EndCode
5908
        @@StartCode:    
6696
        @@StartCode:    
5909
          mov eax,dword ptr [offset _null]{}@@Col1:
6697
          mov eax,dword ptr [offset _null]{}@@Col1:
5910
          mov edx,dword ptr [offset _null]{}@@Col2:
6698
          mov edx,dword ptr [offset _null]{}@@Col2:
5911
          shr eax,8
6699
          shr eax,8
5912
          shr edx,8
6700
          shr edx,8
5913
          and eax,$00FF00FF
6701
          and eax,$00FF00FF
5914
          and edx,$00FF00FF
6702
          and edx,$00FF00FF
5915
          imul eax,ebx
6703
          imul eax,ebx
5916
          imul edx,ebp
6704
          imul edx,ebp
5917
          add eax,edx
6705
          add eax,edx
5918
          mov dword ptr [offset _null],eax{}@@Dest:
6706
          mov dword ptr [offset _null],eax{}@@Dest:
5919
        @@EndCode:
6707
        @@EndCode:
5920
          {$I DXRender.inc}
6708
          {$I DXRender.inc}
5921
          {  @@Col1  }
6709
          {  @@Col1  }
5922
          mov eax,Col1
6710
          mov eax,Col1
5923
          mov edx,offset @@Col1-4
6711
          mov edx,offset @@Col1-4
5924
          sub edx,offset @@StartCode
6712
          sub edx,offset @@StartCode
5925
          mov dword ptr [ecx+edx],eax
6713
          mov dword ptr [ecx+edx],eax
5926
 
6714
 
5927
          {  @@Col2  }
6715
          {  @@Col2  }
5928
          mov eax,Col2
6716
          mov eax,Col2
5929
          mov edx,offset @@Col2-4
6717
          mov edx,offset @@Col2-4
5930
          sub edx,offset @@StartCode
6718
          sub edx,offset @@StartCode
5931
          mov dword ptr [ecx+edx],eax
6719
          mov dword ptr [ecx+edx],eax
5932
 
6720
 
5933
          {  @@Dest  }
6721
          {  @@Dest  }
5934
          mov eax,Dest
6722
          mov eax,Dest
5935
          mov edx,offset @@Dest-4
6723
          mov edx,offset @@Dest-4
5936
          sub edx,offset @@StartCode
6724
          sub edx,offset @@StartCode
5937
          mov dword ptr [ecx+edx],eax
6725
          mov dword ptr [ecx+edx],eax
5938
        end;
6726
        end;
5939
      end else
6727
      end else
5940
      begin
6728
      begin
5941
        if chRed in EnableChannels then
6729
        if chRed in EnableChannels then
5942
        begin
6730
        begin
5943
          asm
6731
          asm
5944
            jmp @@EndCode
6732
            jmp @@EndCode
5945
          @@StartCode:
6733
          @@StartCode:
5946
            movzx eax,byte ptr [offset _null]{}@@Col1:
6734
            movzx eax,byte ptr [offset _null]{}@@Col1:
5947
            movzx edx,byte ptr [offset _null]{}@@Col2:
6735
            movzx edx,byte ptr [offset _null]{}@@Col2:
5948
            sub eax,edx
6736
            sub eax,edx
5949
            imul eax,ebx
6737
            imul eax,ebx
5950
            shr eax,8
6738
            shr eax,8
5951
            add eax,edx
6739
            add eax,edx
5952
            mov byte ptr [offset _null],al{}@@Dest:
6740
            mov byte ptr [offset _null],al{}@@Dest:
5953
          @@EndCode:
6741
          @@EndCode:
5954
            {$I DXRender.inc}
6742
            {$I DXRender.inc}
5955
            {  @@Col1  }
6743
            {  @@Col1  }
5956
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6744
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
5957
            mov edx,offset @@Col1-4
6745
            mov edx,offset @@Col1-4
5958
            sub edx,offset @@StartCode
6746
            sub edx,offset @@StartCode
5959
            mov dword ptr [ecx+edx],eax
6747
            mov dword ptr [ecx+edx],eax
5960
 
6748
 
5961
            {  @@Col2  }
6749
            {  @@Col2  }
5962
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
6750
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
5963
            mov edx,offset @@Col2-4
6751
            mov edx,offset @@Col2-4
5964
            sub edx,offset @@StartCode
6752
            sub edx,offset @@StartCode
5965
            mov dword ptr [ecx+edx],eax
6753
            mov dword ptr [ecx+edx],eax
5966
 
6754
 
5967
            {  @@Dest  }
6755
            {  @@Dest  }
5968
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6756
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
5969
            mov edx,offset @@Dest-4
6757
            mov edx,offset @@Dest-4
5970
            sub edx,offset @@StartCode
6758
            sub edx,offset @@StartCode
5971
            mov dword ptr [ecx+edx],eax
6759
            mov dword ptr [ecx+edx],eax
5972
          end;
6760
          end;
5973
        end;
6761
        end;
5974
 
6762
 
5975
        if chGreen in EnableChannels then
6763
        if chGreen in EnableChannels then
5976
        begin
6764
        begin
5977
          asm
6765
          asm
5978
            jmp @@EndCode
6766
            jmp @@EndCode
5979
          @@StartCode:
6767
          @@StartCode:
5980
            movzx eax,byte ptr [offset _null]{}@@Col1:
6768
            movzx eax,byte ptr [offset _null]{}@@Col1:
5981
            movzx edx,byte ptr [offset _null]{}@@Col2:
6769
            movzx edx,byte ptr [offset _null]{}@@Col2:
5982
            sub eax,edx
6770
            sub eax,edx
5983
            imul eax,ebx
6771
            imul eax,ebx
5984
            shr eax,8
6772
            shr eax,8
5985
            add eax,edx
6773
            add eax,edx
5986
            mov byte ptr [offset _null],al{}@@Dest:
6774
            mov byte ptr [offset _null],al{}@@Dest:
5987
          @@EndCode:
6775
          @@EndCode:
5988
            {$I DXRender.inc}
6776
            {$I DXRender.inc}
5989
            {  @@Col1  }
6777
            {  @@Col1  }
5990
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
6778
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
5991
            mov edx,offset @@Col1-4
6779
            mov edx,offset @@Col1-4
5992
            sub edx,offset @@StartCode
6780
            sub edx,offset @@StartCode
5993
            mov dword ptr [ecx+edx],eax
6781
            mov dword ptr [ecx+edx],eax
5994
 
6782
 
5995
            {  @@Col2  }
6783
            {  @@Col2  }
5996
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
6784
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
5997
            mov edx,offset @@Col2-4
6785
            mov edx,offset @@Col2-4
5998
            sub edx,offset @@StartCode
6786
            sub edx,offset @@StartCode
5999
            mov dword ptr [ecx+edx],eax
6787
            mov dword ptr [ecx+edx],eax
6000
 
6788
 
6001
            {  @@Dest  }
6789
            {  @@Dest  }
6002
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
6790
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
6003
            mov edx,offset @@Dest-4
6791
            mov edx,offset @@Dest-4
6004
            sub edx,offset @@StartCode
6792
            sub edx,offset @@StartCode
6005
            mov dword ptr [ecx+edx],eax
6793
            mov dword ptr [ecx+edx],eax
6006
          end;
6794
          end;
6007
        end;
6795
        end;
6008
      end;
6796
      end;
6009
 
6797
 
6010
      if [chBlue, chAlpha]<=EnableChannels then
6798
      if [chBlue, chAlpha]<=EnableChannels then
6011
      begin
6799
      begin
6012
        asm
6800
        asm
6013
          jmp @@EndCode
6801
          jmp @@EndCode
6014
        @@StartCode:
6802
        @@StartCode:
6015
          mov eax,dword ptr [offset _null]{}@@Col1:
6803
          mov eax,dword ptr [offset _null]{}@@Col1:
6016
          mov edx,dword ptr [offset _null]{}@@Col2:
6804
          mov edx,dword ptr [offset _null]{}@@Col2:
6017
          shr eax,8
6805
          shr eax,8
6018
          shr edx,8
6806
          shr edx,8
6019
          and eax,$00FF00FF
6807
          and eax,$00FF00FF
6020
          and edx,$00FF00FF
6808
          and edx,$00FF00FF
6021
          imul eax,ebx
6809
          imul eax,ebx
6022
          imul edx,ebp
6810
          imul edx,ebp
6023
          add eax,edx
6811
          add eax,edx
6024
          mov dword ptr [offset _null],eax{}@@Dest:
6812
          mov dword ptr [offset _null],eax{}@@Dest:
6025
        @@EndCode:
6813
        @@EndCode:
6026
          {$I DXRender.inc}
6814
          {$I DXRender.inc}
6027
          {  @@Col1  }
6815
          {  @@Col1  }
6028
          mov eax,Col1; add eax,4
6816
          mov eax,Col1; add eax,4
6029
          mov edx,offset @@Col1-4
6817
          mov edx,offset @@Col1-4
6030
          sub edx,offset @@StartCode
6818
          sub edx,offset @@StartCode
6031
          mov dword ptr [ecx+edx],eax
6819
          mov dword ptr [ecx+edx],eax
6032
 
6820
 
6033
          {  @@Col2  }
6821
          {  @@Col2  }
6034
          mov eax,Col2; add eax,4
6822
          mov eax,Col2; add eax,4
6035
          mov edx,offset @@Col2-4
6823
          mov edx,offset @@Col2-4
6036
          sub edx,offset @@StartCode
6824
          sub edx,offset @@StartCode
6037
          mov dword ptr [ecx+edx],eax
6825
          mov dword ptr [ecx+edx],eax
6038
 
6826
 
6039
          {  @@Dest  }
6827
          {  @@Dest  }
6040
          mov eax,Dest; add eax,4
6828
          mov eax,Dest; add eax,4
6041
          mov edx,offset @@Dest-4
6829
          mov edx,offset @@Dest-4
6042
          sub edx,offset @@StartCode
6830
          sub edx,offset @@StartCode
6043
          mov dword ptr [ecx+edx],eax
6831
          mov dword ptr [ecx+edx],eax
6044
        end;
6832
        end;
6045
      end else
6833
      end else
6046
      begin
6834
      begin
6047
        if chBlue in EnableChannels then
6835
        if chBlue in EnableChannels then
6048
        begin
6836
        begin
6049
          asm
6837
          asm
6050
            jmp @@EndCode
6838
            jmp @@EndCode
6051
          @@StartCode:
6839
          @@StartCode:
6052
            movzx eax,byte ptr [offset _null]{}@@Col1:
6840
            movzx eax,byte ptr [offset _null]{}@@Col1:
6053
            movzx edx,byte ptr [offset _null]{}@@Col2:
6841
            movzx edx,byte ptr [offset _null]{}@@Col2:
6054
            sub eax,edx
6842
            sub eax,edx
6055
            imul eax,ebx
6843
            imul eax,ebx
6056
            shr eax,8
6844
            shr eax,8
6057
            add eax,edx
6845
            add eax,edx
6058
            mov byte ptr [offset _null],al{}@@Dest:
6846
            mov byte ptr [offset _null],al{}@@Dest:
6059
          @@EndCode:
6847
          @@EndCode:
6060
            {$I DXRender.inc}
6848
            {$I DXRender.inc}
6061
            {  @@Col1  }
6849
            {  @@Col1  }
6062
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
6850
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
6063
            mov edx,offset @@Col1-4
6851
            mov edx,offset @@Col1-4
6064
            sub edx,offset @@StartCode
6852
            sub edx,offset @@StartCode
6065
            mov dword ptr [ecx+edx],eax
6853
            mov dword ptr [ecx+edx],eax
6066
 
6854
 
6067
            {  @@Col2  }
6855
            {  @@Col2  }
6068
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
6856
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
6069
            mov edx,offset @@Col2-4
6857
            mov edx,offset @@Col2-4
6070
            sub edx,offset @@StartCode
6858
            sub edx,offset @@StartCode
6071
            mov dword ptr [ecx+edx],eax
6859
            mov dword ptr [ecx+edx],eax
6072
 
6860
 
6073
            {  @@Dest  }
6861
            {  @@Dest  }
6074
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
6862
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
6075
            mov edx,offset @@Dest-4
6863
            mov edx,offset @@Dest-4
6076
            sub edx,offset @@StartCode
6864
            sub edx,offset @@StartCode
6077
            mov dword ptr [ecx+edx],eax
6865
            mov dword ptr [ecx+edx],eax
6078
          end;
6866
          end;
6079
        end;
6867
        end;
6080
 
6868
 
6081
        if chAlpha in EnableChannels then
6869
        if chAlpha in EnableChannels then
6082
        begin
6870
        begin
6083
          asm
6871
          asm
6084
            jmp @@EndCode
6872
            jmp @@EndCode
6085
          @@StartCode:
6873
          @@StartCode:
6086
            movzx eax,byte ptr [offset _null]{}@@Col1:
6874
            movzx eax,byte ptr [offset _null]{}@@Col1:
6087
            movzx edx,byte ptr [offset _null]{}@@Col2:
6875
            movzx edx,byte ptr [offset _null]{}@@Col2:
6088
            sub eax,edx
6876
            sub eax,edx
6089
            imul eax,ebx
6877
            imul eax,ebx
6090
            shr eax,8
6878
            shr eax,8
6091
            add eax,edx
6879
            add eax,edx
6092
            mov byte ptr [offset _null],al{}@@Dest:
6880
            mov byte ptr [offset _null],al{}@@Dest:
6093
          @@EndCode:
6881
          @@EndCode:
6094
            {$I DXRender.inc}
6882
            {$I DXRender.inc}
6095
            {  @@Col1  }
6883
            {  @@Col1  }
6096
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6884
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
6097
            mov edx,offset @@Col1-4
6885
            mov edx,offset @@Col1-4
6098
            sub edx,offset @@StartCode
6886
            sub edx,offset @@StartCode
6099
            mov dword ptr [ecx+edx],eax
6887
            mov dword ptr [ecx+edx],eax
6100
 
6888
 
6101
            {  @@Col2  }
6889
            {  @@Col2  }
6102
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
6890
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
6103
            mov edx,offset @@Col2-4
6891
            mov edx,offset @@Col2-4
6104
            sub edx,offset @@StartCode
6892
            sub edx,offset @@StartCode
6105
            mov dword ptr [ecx+edx],eax
6893
            mov dword ptr [ecx+edx],eax
6106
 
6894
 
6107
            {  @@Dest  }
6895
            {  @@Dest  }
6108
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
6896
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
6109
            mov edx,offset @@Dest-4
6897
            mov edx,offset @@Dest-4
6110
            sub edx,offset @@StartCode
6898
            sub edx,offset @@StartCode
6111
            mov dword ptr [ecx+edx],eax
6899
            mov dword ptr [ecx+edx],eax
6112
          end;
6900
          end;
6113
        end;
6901
        end;
6114
      end;
6902
      end;
6115
    end;
6903
    end;
6116
 
6904
 
6117
    procedure genBlend_INVSRCALPHA1_ADD_SRCALPHA2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6905
    procedure genBlend_INVSRCALPHA1_ADD_SRCALPHA2(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6118
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6906
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6119
    begin
6907
    begin
6120
      asm
6908
      asm
6121
        jmp @@EndCode
6909
        jmp @@EndCode
6122
      @@StartCode:
6910
      @@StartCode:
6123
        movzx ebp,byte ptr [offset _null]{}@@Col1A:
6911
        movzx ebp,byte ptr [offset _null]{}@@Col1A:
6124
        mov ebx,ebp
6912
        mov ebx,ebp
6125
        xor ebx,$FF
6913
        xor ebx,$FF
6126
      @@EndCode:
6914
      @@EndCode:
6127
        {$I DXRender.inc}
6915
        {$I DXRender.inc}
6128
        {  @@Col1A  }
6916
        {  @@Col1A  }
6129
        mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
6917
        mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
6130
        mov edx,offset @@Col1A-4
6918
        mov edx,offset @@Col1A-4
6131
        sub edx,offset @@StartCode
6919
        sub edx,offset @@StartCode
6132
        mov dword ptr [ecx+edx],eax
6920
        mov dword ptr [ecx+edx],eax
6133
      end;
6921
      end;
6134
 
6922
 
6135
      if [chRed, chGreen]<=EnableChannels then
6923
      if [chRed, chGreen]<=EnableChannels then
6136
      begin
6924
      begin
6137
        asm
6925
        asm
6138
          jmp @@EndCode
6926
          jmp @@EndCode
6139
        @@StartCode:
6927
        @@StartCode:
6140
          mov eax,dword ptr [offset _null]{}@@Col1:
6928
          mov eax,dword ptr [offset _null]{}@@Col1:
6141
          mov edx,dword ptr [offset _null]{}@@Col2:
6929
          mov edx,dword ptr [offset _null]{}@@Col2:
6142
          shr eax,8
6930
          shr eax,8
6143
          shr edx,8
6931
          shr edx,8
6144
          and eax,$00FF00FF
6932
          and eax,$00FF00FF
6145
          and edx,$00FF00FF
6933
          and edx,$00FF00FF
6146
          imul eax,ebx
6934
          imul eax,ebx
6147
          imul edx,ebp
6935
          imul edx,ebp
6148
          add eax,edx
6936
          add eax,edx
6149
          mov dword ptr [offset _null],eax{}@@Dest:
6937
          mov dword ptr [offset _null],eax{}@@Dest:
6150
        @@EndCode:
6938
        @@EndCode:
6151
          {$I DXRender.inc}
6939
          {$I DXRender.inc}
6152
          {  @@Col1  }
6940
          {  @@Col1  }
6153
          mov eax,Col1
6941
          mov eax,Col1
6154
          mov edx,offset @@Col1-4
6942
          mov edx,offset @@Col1-4
6155
          sub edx,offset @@StartCode
6943
          sub edx,offset @@StartCode
6156
          mov dword ptr [ecx+edx],eax
6944
          mov dword ptr [ecx+edx],eax
6157
 
6945
 
6158
          {  @@Col2  }
6946
          {  @@Col2  }
6159
          mov eax,Col2
6947
          mov eax,Col2
6160
          mov edx,offset @@Col2-4
6948
          mov edx,offset @@Col2-4
6161
          sub edx,offset @@StartCode
6949
          sub edx,offset @@StartCode
6162
          mov dword ptr [ecx+edx],eax
6950
          mov dword ptr [ecx+edx],eax
6163
 
6951
 
6164
          {  @@Dest  }
6952
          {  @@Dest  }
6165
          mov eax,Dest
6953
          mov eax,Dest
6166
          mov edx,offset @@Dest-4
6954
          mov edx,offset @@Dest-4
6167
          sub edx,offset @@StartCode
6955
          sub edx,offset @@StartCode
6168
          mov dword ptr [ecx+edx],eax
6956
          mov dword ptr [ecx+edx],eax
6169
        end;
6957
        end;
6170
      end else
6958
      end else
6171
      begin
6959
      begin
6172
        if chRed in EnableChannels then
6960
        if chRed in EnableChannels then
6173
        begin
6961
        begin
6174
          asm
6962
          asm
6175
            jmp @@EndCode
6963
            jmp @@EndCode
6176
          @@StartCode:
6964
          @@StartCode:
6177
            movzx eax,byte ptr [offset _null]{}@@Col1:
6965
            movzx eax,byte ptr [offset _null]{}@@Col1:
6178
            movzx edx,byte ptr [offset _null]{}@@Col2:
6966
            movzx edx,byte ptr [offset _null]{}@@Col2:
6179
            sub eax,edx
6967
            sub eax,edx
6180
            imul eax,ebx
6968
            imul eax,ebx
6181
            shr eax,8
6969
            shr eax,8
6182
            add eax,edx
6970
            add eax,edx
6183
            mov byte ptr [offset _null],al{}@@Dest:
6971
            mov byte ptr [offset _null],al{}@@Dest:
6184
          @@EndCode:
6972
          @@EndCode:
6185
            {$I DXRender.inc}
6973
            {$I DXRender.inc}
6186
            {  @@Col1  }
6974
            {  @@Col1  }
6187
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
6975
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
6188
            mov edx,offset @@Col1-4
6976
            mov edx,offset @@Col1-4
6189
            sub edx,offset @@StartCode
6977
            sub edx,offset @@StartCode
6190
            mov dword ptr [ecx+edx],eax
6978
            mov dword ptr [ecx+edx],eax
6191
 
6979
 
6192
            {  @@Col2  }
6980
            {  @@Col2  }
6193
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
6981
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
6194
            mov edx,offset @@Col2-4
6982
            mov edx,offset @@Col2-4
6195
            sub edx,offset @@StartCode
6983
            sub edx,offset @@StartCode
6196
            mov dword ptr [ecx+edx],eax
6984
            mov dword ptr [ecx+edx],eax
6197
 
6985
 
6198
            {  @@Dest  }
6986
            {  @@Dest  }
6199
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
6987
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
6200
            mov edx,offset @@Dest-4
6988
            mov edx,offset @@Dest-4
6201
            sub edx,offset @@StartCode
6989
            sub edx,offset @@StartCode
6202
            mov dword ptr [ecx+edx],eax
6990
            mov dword ptr [ecx+edx],eax
6203
          end;
6991
          end;
6204
        end;
6992
        end;
6205
 
6993
 
6206
        if chGreen in EnableChannels then
6994
        if chGreen in EnableChannels then
6207
        begin
6995
        begin
6208
          asm
6996
          asm
6209
            jmp @@EndCode
6997
            jmp @@EndCode
6210
          @@StartCode:
6998
          @@StartCode:
6211
            movzx eax,byte ptr [offset _null]{}@@Col1:
6999
            movzx eax,byte ptr [offset _null]{}@@Col1:
6212
            movzx edx,byte ptr [offset _null]{}@@Col2:
7000
            movzx edx,byte ptr [offset _null]{}@@Col2:
6213
            sub eax,edx
7001
            sub eax,edx
6214
            imul eax,ebx
7002
            imul eax,ebx
6215
            shr eax,8
7003
            shr eax,8
6216
            add eax,edx
7004
            add eax,edx
6217
            mov byte ptr [offset _null],al{}@@Dest:
7005
            mov byte ptr [offset _null],al{}@@Dest:
6218
          @@EndCode:
7006
          @@EndCode:
6219
            {$I DXRender.inc}
7007
            {$I DXRender.inc}
6220
            {  @@Col1  }
7008
            {  @@Col1  }
6221
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
7009
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
6222
            mov edx,offset @@Col1-4
7010
            mov edx,offset @@Col1-4
6223
            sub edx,offset @@StartCode
7011
            sub edx,offset @@StartCode
6224
            mov dword ptr [ecx+edx],eax
7012
            mov dword ptr [ecx+edx],eax
6225
 
7013
 
6226
            {  @@Col2  }
7014
            {  @@Col2  }
6227
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
7015
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
6228
            mov edx,offset @@Col2-4
7016
            mov edx,offset @@Col2-4
6229
            sub edx,offset @@StartCode
7017
            sub edx,offset @@StartCode
6230
            mov dword ptr [ecx+edx],eax
7018
            mov dword ptr [ecx+edx],eax
6231
 
7019
 
6232
            {  @@Dest  }
7020
            {  @@Dest  }
6233
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
7021
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
6234
            mov edx,offset @@Dest-4
7022
            mov edx,offset @@Dest-4
6235
            sub edx,offset @@StartCode
7023
            sub edx,offset @@StartCode
6236
            mov dword ptr [ecx+edx],eax
7024
            mov dword ptr [ecx+edx],eax
6237
          end;
7025
          end;
6238
        end;
7026
        end;
6239
      end;
7027
      end;
6240
 
7028
 
6241
      if [chBlue, chAlpha]<=EnableChannels then
7029
      if [chBlue, chAlpha]<=EnableChannels then
6242
      begin
7030
      begin
6243
        asm
7031
        asm
6244
          jmp @@EndCode
7032
          jmp @@EndCode
6245
        @@StartCode:
7033
        @@StartCode:
6246
          mov eax,dword ptr [offset _null]{}@@Col1:
7034
          mov eax,dword ptr [offset _null]{}@@Col1:
6247
          mov edx,dword ptr [offset _null]{}@@Col2:
7035
          mov edx,dword ptr [offset _null]{}@@Col2:
6248
          shr eax,8
7036
          shr eax,8
6249
          shr edx,8
7037
          shr edx,8
6250
          and eax,$00FF00FF
7038
          and eax,$00FF00FF
6251
          and edx,$00FF00FF
7039
          and edx,$00FF00FF
6252
          imul eax,ebx
7040
          imul eax,ebx
6253
          imul edx,ebp
7041
          imul edx,ebp
6254
          add eax,edx
7042
          add eax,edx
6255
          mov dword ptr [offset _null],eax{}@@Dest:
7043
          mov dword ptr [offset _null],eax{}@@Dest:
6256
        @@EndCode:
7044
        @@EndCode:
6257
          {$I DXRender.inc}
7045
          {$I DXRender.inc}
6258
          {  @@Col1  }
7046
          {  @@Col1  }
6259
          mov eax,Col1; add eax,4
7047
          mov eax,Col1; add eax,4
6260
          mov edx,offset @@Col1-4
7048
          mov edx,offset @@Col1-4
6261
          sub edx,offset @@StartCode
7049
          sub edx,offset @@StartCode
6262
          mov dword ptr [ecx+edx],eax
7050
          mov dword ptr [ecx+edx],eax
6263
 
7051
 
6264
          {  @@Col2  }
7052
          {  @@Col2  }
6265
          mov eax,Col2; add eax,4
7053
          mov eax,Col2; add eax,4
6266
          mov edx,offset @@Col2-4
7054
          mov edx,offset @@Col2-4
6267
          sub edx,offset @@StartCode
7055
          sub edx,offset @@StartCode
6268
          mov dword ptr [ecx+edx],eax
7056
          mov dword ptr [ecx+edx],eax
6269
 
7057
 
6270
          {  @@Dest  }
7058
          {  @@Dest  }
6271
          mov eax,Dest; add eax,4
7059
          mov eax,Dest; add eax,4
6272
          mov edx,offset @@Dest-4
7060
          mov edx,offset @@Dest-4
6273
          sub edx,offset @@StartCode
7061
          sub edx,offset @@StartCode
6274
          mov dword ptr [ecx+edx],eax
7062
          mov dword ptr [ecx+edx],eax
6275
        end;
7063
        end;
6276
      end else
7064
      end else
6277
      begin
7065
      begin
6278
        if chBlue in EnableChannels then
7066
        if chBlue in EnableChannels then
6279
        begin
7067
        begin
6280
          asm
7068
          asm
6281
            jmp @@EndCode
7069
            jmp @@EndCode
6282
          @@StartCode:
7070
          @@StartCode:
6283
            movzx eax,byte ptr [offset _null]{}@@Col1:
7071
            movzx eax,byte ptr [offset _null]{}@@Col1:
6284
            movzx edx,byte ptr [offset _null]{}@@Col2:
7072
            movzx edx,byte ptr [offset _null]{}@@Col2:
6285
            sub eax,edx
7073
            sub eax,edx
6286
            imul eax,ebx
7074
            imul eax,ebx
6287
            shr eax,8
7075
            shr eax,8
6288
            add eax,edx
7076
            add eax,edx
6289
            mov byte ptr [offset _null],al{}@@Dest:
7077
            mov byte ptr [offset _null],al{}@@Dest:
6290
          @@EndCode:
7078
          @@EndCode:
6291
            {$I DXRender.inc}
7079
            {$I DXRender.inc}
6292
            {  @@Col1  }
7080
            {  @@Col1  }
6293
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
7081
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
6294
            mov edx,offset @@Col1-4
7082
            mov edx,offset @@Col1-4
6295
            sub edx,offset @@StartCode
7083
            sub edx,offset @@StartCode
6296
            mov dword ptr [ecx+edx],eax
7084
            mov dword ptr [ecx+edx],eax
6297
 
7085
 
6298
            {  @@Col2  }
7086
            {  @@Col2  }
6299
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
7087
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
6300
            mov edx,offset @@Col2-4
7088
            mov edx,offset @@Col2-4
6301
            sub edx,offset @@StartCode
7089
            sub edx,offset @@StartCode
6302
            mov dword ptr [ecx+edx],eax
7090
            mov dword ptr [ecx+edx],eax
6303
 
7091
 
6304
            {  @@Dest  }
7092
            {  @@Dest  }
6305
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
7093
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
6306
            mov edx,offset @@Dest-4
7094
            mov edx,offset @@Dest-4
6307
            sub edx,offset @@StartCode
7095
            sub edx,offset @@StartCode
6308
            mov dword ptr [ecx+edx],eax
7096
            mov dword ptr [ecx+edx],eax
6309
          end;
7097
          end;
6310
        end;
7098
        end;
6311
 
7099
 
6312
        if chAlpha in EnableChannels then
7100
        if chAlpha in EnableChannels then
6313
        begin
7101
        begin
6314
          asm
7102
          asm
6315
            jmp @@EndCode
7103
            jmp @@EndCode
6316
          @@StartCode:
7104
          @@StartCode:
6317
            movzx eax,byte ptr [offset _null]{}@@Col1:
7105
            movzx eax,byte ptr [offset _null]{}@@Col1:
6318
            movzx edx,byte ptr [offset _null]{}@@Col2:
7106
            movzx edx,byte ptr [offset _null]{}@@Col2:
6319
            sub eax,edx
7107
            sub eax,edx
6320
            imul eax,ebx
7108
            imul eax,ebx
6321
            shr eax,8
7109
            shr eax,8
6322
            add eax,edx
7110
            add eax,edx
6323
            mov byte ptr [offset _null],al{}@@Dest:
7111
            mov byte ptr [offset _null],al{}@@Dest:
6324
          @@EndCode:
7112
          @@EndCode:
6325
            {$I DXRender.inc}
7113
            {$I DXRender.inc}
6326
            {  @@Col1  }
7114
            {  @@Col1  }
6327
            mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
7115
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
6328
            mov edx,offset @@Col1-4
7116
            mov edx,offset @@Col1-4
6329
            sub edx,offset @@StartCode
7117
            sub edx,offset @@StartCode
6330
            mov dword ptr [ecx+edx],eax
7118
            mov dword ptr [ecx+edx],eax
6331
 
7119
 
6332
            {  @@Col2  }
7120
            {  @@Col2  }
6333
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
7121
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
6334
            mov edx,offset @@Col2-4
7122
            mov edx,offset @@Col2-4
6335
            sub edx,offset @@StartCode
7123
            sub edx,offset @@StartCode
6336
            mov dword ptr [ecx+edx],eax
7124
            mov dword ptr [ecx+edx],eax
6337
 
7125
 
6338
            {  @@Dest  }
7126
            {  @@Dest  }
6339
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
7127
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
6340
            mov edx,offset @@Dest-4
7128
            mov edx,offset @@Dest-4
6341
            sub edx,offset @@StartCode
7129
            sub edx,offset @@StartCode
6342
            mov dword ptr [ecx+edx],eax
7130
            mov dword ptr [ecx+edx],eax
6343
          end;
7131
          end;
6344
        end;
7132
        end;
6345
      end;
7133
      end;
6346
    end;
7134
    end;
6347
 
7135
 
6348
    procedure genBlend_DECALALPHA(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
7136
    procedure genBlend_DECALALPHA(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6349
      ConstChannels1, ConstChannels12: TDXRColorChannels);
7137
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6350
    begin
7138
    begin
6351
      if ([chRed, chGreen, chBlue]<=EnableChannels) and (Dest<>Col1) then
7139
      if ([chRed, chGreen, chBlue]<=EnableChannels) and (Dest<>Col1) then
6352
      begin
7140
      begin
6353
        if UseMMX then
7141
        if UseMMX then
6354
        begin
7142
        begin
6355
          FMMXUsed := True;
7143
          FMMXUsed := True;
6356
          asm
7144
          asm
6357
            jmp @@EndCode
7145
            jmp @@EndCode
6358
          @@StartCode:
7146
          @@StartCode:
6359
            db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
7147
            db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
6360
                                   @@Col1:
7148
                                   @@Col1:
6361
            db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
7149
            db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
6362
                                   @@Dest:
7150
                                   @@Dest:
6363
          @@EndCode:
7151
          @@EndCode:
6364
            {$I DXRender.inc}
7152
            {$I DXRender.inc}
6365
            {  @@Col1  }
7153
            {  @@Col1  }
6366
            mov eax,Col1
7154
            mov eax,Col1
6367
            mov edx,offset @@Col1-4
7155
            mov edx,offset @@Col1-4
6368
            sub edx,offset @@StartCode
7156
            sub edx,offset @@StartCode
6369
            mov dword ptr [ecx+edx],eax
7157
            mov dword ptr [ecx+edx],eax
6370
 
7158
 
6371
            {  @@Dest  }
7159
            {  @@Dest  }
6372
            mov eax,Dest
7160
            mov eax,Dest
6373
            mov edx,offset @@Dest-4
7161
            mov edx,offset @@Dest-4
6374
            sub edx,offset @@StartCode
7162
            sub edx,offset @@StartCode
6375
            mov dword ptr [ecx+edx],eax
7163
            mov dword ptr [ecx+edx],eax
6376
          end;
7164
          end;
6377
        end else
7165
        end else
6378
        begin
7166
        begin
6379
          asm
7167
          asm
6380
            jmp @@EndCode
7168
            jmp @@EndCode
6381
          @@StartCode:
7169
          @@StartCode:
6382
            mov eax,dword ptr [offset _null]{}@@Col1:
7170
            mov eax,dword ptr [offset _null]{}@@Col1:
6383
            mov edx,dword ptr [offset _null]{}@@Col1_2:
7171
            mov edx,dword ptr [offset _null]{}@@Col1_2:
6384
            mov dword ptr [offset _null],eax{}@@Dest:
7172
            mov dword ptr [offset _null],eax{}@@Dest:
6385
            mov dword ptr [offset _null],edx{}@@Dest2:
7173
            mov dword ptr [offset _null],edx{}@@Dest2:
6386
          @@EndCode:
7174
          @@EndCode:
6387
            {$I DXRender.inc}
7175
            {$I DXRender.inc}
6388
            {  @@Col1  }
7176
            {  @@Col1  }
6389
            mov eax,Col1
7177
            mov eax,Col1
6390
            mov edx,offset @@Col1-4
7178
            mov edx,offset @@Col1-4
6391
            sub edx,offset @@StartCode
7179
            sub edx,offset @@StartCode
6392
            mov dword ptr [ecx+edx],eax
7180
            mov dword ptr [ecx+edx],eax
6393
 
7181
 
6394
            {  @@Col1_2  }
7182
            {  @@Col1_2  }
6395
            mov eax,Col1; add eax,4
7183
            mov eax,Col1; add eax,4
6396
            mov edx,offset @@Col1_2-4
7184
            mov edx,offset @@Col1_2-4
6397
            sub edx,offset @@StartCode
7185
            sub edx,offset @@StartCode
6398
            mov dword ptr [ecx+edx],eax
7186
            mov dword ptr [ecx+edx],eax
6399
 
7187
 
6400
            {  @@Dest  }
7188
            {  @@Dest  }
6401
            mov eax,Dest
7189
            mov eax,Dest
6402
            mov edx,offset @@Dest-4
7190
            mov edx,offset @@Dest-4
6403
            sub edx,offset @@StartCode
7191
            sub edx,offset @@StartCode
6404
            mov dword ptr [ecx+edx],eax
7192
            mov dword ptr [ecx+edx],eax
6405
 
7193
 
6406
            {  @@Dest2  }
7194
            {  @@Dest2  }
6407
            mov eax,Dest; add eax,4
7195
            mov eax,Dest; add eax,4
6408
            mov edx,offset @@Dest2-4
7196
            mov edx,offset @@Dest2-4
6409
            sub edx,offset @@StartCode
7197
            sub edx,offset @@StartCode
6410
            mov dword ptr [ecx+edx],eax
7198
            mov dword ptr [ecx+edx],eax
6411
          end;
7199
          end;
6412
        end;
7200
        end;
6413
      end;
7201
      end;
6414
 
7202
 
6415
      if chAlpha in EnableChannels then
7203
      if chAlpha in EnableChannels then
6416
      begin
7204
      begin
6417
        asm
7205
        asm
6418
          jmp @@EndCode
7206
          jmp @@EndCode
6419
        @@StartCode:
7207
        @@StartCode:
6420
          mov al,byte ptr [offset _null]{}@@Col2:
7208
          mov al,byte ptr [offset _null]{}@@Col2:
6421
          mov byte ptr [offset _null],al{}@@Dest:
7209
          mov byte ptr [offset _null],al{}@@Dest:
6422
        @@EndCode:
7210
        @@EndCode:
6423
          {$I DXRender.inc}
7211
          {$I DXRender.inc}
6424
          {  @@Col2  }
7212
          {  @@Col2  }
6425
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
7213
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
6426
          mov edx,offset @@Col2-4
7214
          mov edx,offset @@Col2-4
6427
          sub edx,offset @@StartCode
7215
          sub edx,offset @@StartCode
6428
          mov dword ptr [ecx+edx],eax
7216
          mov dword ptr [ecx+edx],eax
6429
 
7217
 
6430
          {  @@Dest  }
7218
          {  @@Dest  }
6431
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
7219
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
6432
          mov edx,offset @@Dest-4
7220
          mov edx,offset @@Dest-4
6433
          sub edx,offset @@StartCode
7221
          sub edx,offset @@StartCode
6434
          mov dword ptr [ecx+edx],eax
7222
          mov dword ptr [ecx+edx],eax
6435
        end;
7223
        end;
6436
      end;
7224
      end;
6437
    end;
7225
    end;
6438
 
7226
 
6439
    procedure genBlend_MODULATE_RGBONLY(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
7227
    procedure genBlend_MODULATE(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6440
      ConstChannels1, ConstChannels12: TDXRColorChannels);
7228
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6441
    begin
7229
    begin
6442
      if chRed in EnableChannels then
7230
      if chRed in EnableChannels then
6443
      begin
7231
      begin
6444
        asm
7232
        asm
6445
          jmp @@EndCode
7233
          jmp @@EndCode
6446
        @@StartCode:
7234
        @@StartCode:
6447
          mov al,byte ptr [offset offset _null]{}@@Col1:
7235
          mov al,byte ptr [offset offset _null]{}@@Col1:
6448
          mul byte ptr [offset offset _null]   {}@@Col2:
7236
          mul byte ptr [offset offset _null]   {}@@Col2:
6449
          mov byte ptr [offset offset _null],ah{}@@Dest:
7237
          mov byte ptr [offset offset _null],ah{}@@Dest:
6450
        @@EndCode:
7238
        @@EndCode:
6451
          {$I DXRender.inc}
7239
          {$I DXRender.inc}
6452
          {  @@Col1  }
7240
          {  @@Col1  }
6453
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.R+1)
7241
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
6454
          mov edx,offset @@Col1-4
7242
          mov edx,offset @@Col1-4
6455
          sub edx,offset @@StartCode
7243
          sub edx,offset @@StartCode
6456
          mov dword ptr [ecx+edx],eax
7244
          mov dword ptr [ecx+edx],eax
6457
 
7245
 
6458
          {  @@Col2  }
7246
          {  @@Col2  }
6459
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.R+1)
7247
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
6460
          mov edx,offset @@Col2-4
7248
          mov edx,offset @@Col2-4
6461
          sub edx,offset @@StartCode
7249
          sub edx,offset @@StartCode
6462
          mov dword ptr [ecx+edx],eax
7250
          mov dword ptr [ecx+edx],eax
6463
 
7251
 
6464
          {  @@Dest  }
7252
          {  @@Dest  }
6465
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.R+1)
7253
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
6466
          mov edx,offset @@Dest-4
7254
          mov edx,offset @@Dest-4
6467
          sub edx,offset @@StartCode
7255
          sub edx,offset @@StartCode
6468
          mov dword ptr [ecx+edx],eax
7256
          mov dword ptr [ecx+edx],eax
6469
        end;
7257
        end;
6470
      end;
7258
      end;
6471
 
7259
 
6472
      if chGreen in EnableChannels then
7260
      if chGreen in EnableChannels then
6473
      begin
7261
      begin
6474
        asm
7262
        asm
6475
          jmp @@EndCode
7263
          jmp @@EndCode
6476
        @@StartCode:
7264
        @@StartCode:
6477
          mov al,byte ptr [offset offset _null]{}@@Col1:
7265
          mov al,byte ptr [offset offset _null]{}@@Col1:
6478
          mul byte ptr [offset offset _null]   {}@@Col2:
7266
          mul byte ptr [offset offset _null]   {}@@Col2:
6479
          mov byte ptr [offset offset _null],ah{}@@Dest:
7267
          mov byte ptr [offset offset _null],ah{}@@Dest:
6480
        @@EndCode:
7268
        @@EndCode:
6481
          {$I DXRender.inc}
7269
          {$I DXRender.inc}
6482
          {  @@Col1  }
7270
          {  @@Col1  }
6483
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.G+1)
7271
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
6484
          mov edx,offset @@Col1-4
7272
          mov edx,offset @@Col1-4
6485
          sub edx,offset @@StartCode
7273
          sub edx,offset @@StartCode
6486
          mov dword ptr [ecx+edx],eax
7274
          mov dword ptr [ecx+edx],eax
6487
 
7275
 
6488
          {  @@Col2  }
7276
          {  @@Col2  }
6489
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.G+1)
7277
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
6490
          mov edx,offset @@Col2-4
7278
          mov edx,offset @@Col2-4
6491
          sub edx,offset @@StartCode
7279
          sub edx,offset @@StartCode
6492
          mov dword ptr [ecx+edx],eax
7280
          mov dword ptr [ecx+edx],eax
6493
 
7281
 
6494
          {  @@Dest  }
7282
          {  @@Dest  }
6495
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.G+1)
7283
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
6496
          mov edx,offset @@Dest-4
7284
          mov edx,offset @@Dest-4
6497
          sub edx,offset @@StartCode
7285
          sub edx,offset @@StartCode
6498
          mov dword ptr [ecx+edx],eax
7286
          mov dword ptr [ecx+edx],eax
6499
        end;
7287
        end;
6500
      end;
7288
      end;
6501
 
7289
 
6502
      if chBlue in EnableChannels then
7290
      if chBlue in EnableChannels then
6503
      begin
7291
      begin
6504
        asm
7292
        asm
6505
          jmp @@EndCode
7293
          jmp @@EndCode
6506
        @@StartCode:
7294
        @@StartCode:
6507
          mov al,byte ptr [offset offset _null]{}@@Col1:
7295
          mov al,byte ptr [offset offset _null]{}@@Col1:
6508
          mul byte ptr [offset offset _null]   {}@@Col2:
7296
          mul byte ptr [offset offset _null]   {}@@Col2:
6509
          mov byte ptr [offset offset _null],ah{}@@Dest:
7297
          mov byte ptr [offset offset _null],ah{}@@Dest:
6510
        @@EndCode:
7298
        @@EndCode:
6511
          {$I DXRender.inc}
7299
          {$I DXRender.inc}
6512
          {  @@Col1  }
7300
          {  @@Col1  }
6513
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.B+1)
7301
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
6514
          mov edx,offset @@Col1-4
7302
          mov edx,offset @@Col1-4
6515
          sub edx,offset @@StartCode
7303
          sub edx,offset @@StartCode
6516
          mov dword ptr [ecx+edx],eax
7304
          mov dword ptr [ecx+edx],eax
6517
 
7305
 
6518
          {  @@Col2  }
7306
          {  @@Col2  }
6519
          mov eax,Col2; add eax,BYTE(TDXRMachine_Color.B+1)
7307
          mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
6520
          mov edx,offset @@Col2-4
7308
          mov edx,offset @@Col2-4
6521
          sub edx,offset @@StartCode
7309
          sub edx,offset @@StartCode
6522
          mov dword ptr [ecx+edx],eax
7310
          mov dword ptr [ecx+edx],eax
6523
 
7311
 
6524
          {  @@Dest  }
7312
          {  @@Dest  }
6525
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.B+1)
7313
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
6526
          mov edx,offset @@Dest-4
7314
          mov edx,offset @@Dest-4
6527
          sub edx,offset @@StartCode
7315
          sub edx,offset @@StartCode
6528
          mov dword ptr [ecx+edx],eax
7316
          mov dword ptr [ecx+edx],eax
6529
        end;
7317
        end;
6530
      end;
7318
      end;
6531
 
7319
 
6532
      if (chAlpha in EnableChannels) or (Dest<>Col1) then
7320
      if (chAlpha in EnableChannels) or (Dest<>Col1) then
6533
      begin
7321
      begin
6534
        asm
7322
        asm
6535
          jmp @@EndCode
7323
          jmp @@EndCode
6536
        @@StartCode:
7324
        @@StartCode:
6537
          mov al,byte ptr [offset _null]{}@@Col1:
7325
          mov al,byte ptr [offset _null]{}@@Col1:
6538
          mov byte ptr [offset _null],al{}@@Dest:
7326
          mov byte ptr [offset _null],al{}@@Dest:
6539
        @@EndCode:
7327
        @@EndCode:
6540
          {$I DXRender.inc}
7328
          {$I DXRender.inc}
6541
          {  @@Col1  }
7329
          {  @@Col1  }
6542
          mov eax,Col1; add eax,BYTE(TDXRMachine_Color.A+1)
7330
          mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
-
 
7331
          mov edx,offset @@Col1-4
-
 
7332
          sub edx,offset @@StartCode
-
 
7333
          mov dword ptr [ecx+edx],eax
-
 
7334
 
-
 
7335
          {  @@Dest  }
-
 
7336
          mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
-
 
7337
          mov edx,offset @@Dest-4
-
 
7338
          sub edx,offset @@StartCode
-
 
7339
          mov dword ptr [ecx+edx],eax
-
 
7340
        end;
-
 
7341
      end;
-
 
7342
    end;
-
 
7343
 
-
 
7344
    procedure genBlend_MODULATEALPHA(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
-
 
7345
      ConstChannels1, ConstChannels12: TDXRColorChannels);
-
 
7346
    begin
-
 
7347
      if UseMMX then
-
 
7348
      begin
-
 
7349
        FMMXUsed := True;
-
 
7350
        asm
-
 
7351
          jmp @@EndCode
-
 
7352
        @@StartCode:
-
 
7353
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
-
 
7354
                                 @@Col1:
-
 
7355
          db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
-
 
7356
                                 @@Col2:
-
 
7357
          db $0F,$E5,$C1      ///pmulhw mm0,mm1
-
 
7358
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
-
 
7359
                                 @@Dest:
-
 
7360
        @@EndCode:
-
 
7361
          {$I DXRender.inc}
-
 
7362
          {  @@Col1  }
-
 
7363
          mov eax,Col1
-
 
7364
          mov edx,offset @@Col1-4
-
 
7365
          sub edx,offset @@StartCode
-
 
7366
          mov dword ptr [ecx+edx],eax
-
 
7367
 
-
 
7368
          {  @@Col2  }
-
 
7369
          mov eax,Col2
-
 
7370
          mov edx,offset @@Col2-4
-
 
7371
          sub edx,offset @@StartCode
-
 
7372
          mov dword ptr [ecx+edx],eax
-
 
7373
 
-
 
7374
          {  @@Dest  }
-
 
7375
          mov eax,offset Dest
-
 
7376
          mov edx,offset @@Dest-4
-
 
7377
          sub edx,offset @@StartCode
-
 
7378
          mov dword ptr [ecx+edx],eax
-
 
7379
        end;
-
 
7380
      end else
-
 
7381
      begin
-
 
7382
        if chRed in EnableChannels then
-
 
7383
        begin
-
 
7384
          asm
-
 
7385
            jmp @@EndCode
-
 
7386
          @@StartCode:
-
 
7387
            mov al,byte ptr [offset offset _null]{}@@Col1:
-
 
7388
            mul byte ptr [offset offset _null]   {}@@Col2:
-
 
7389
            mov byte ptr [offset offset _null],ah{}@@Dest:
-
 
7390
          @@EndCode:
-
 
7391
            {$I DXRender.inc}
-
 
7392
            {  @@Col1  }
-
 
7393
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.R+1)
-
 
7394
            mov edx,offset @@Col1-4
-
 
7395
            sub edx,offset @@StartCode
-
 
7396
            mov dword ptr [ecx+edx],eax
-
 
7397
 
-
 
7398
            {  @@Col2  }
-
 
7399
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.R+1)
-
 
7400
            mov edx,offset @@Col2-4
-
 
7401
            sub edx,offset @@StartCode
-
 
7402
            mov dword ptr [ecx+edx],eax
-
 
7403
 
-
 
7404
            {  @@Dest  }
-
 
7405
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.R+1)
-
 
7406
            mov edx,offset @@Dest-4
-
 
7407
            sub edx,offset @@StartCode
-
 
7408
            mov dword ptr [ecx+edx],eax
-
 
7409
          end;
-
 
7410
        end;
-
 
7411
 
-
 
7412
        if chGreen in EnableChannels then
-
 
7413
        begin
-
 
7414
          asm
-
 
7415
            jmp @@EndCode
-
 
7416
          @@StartCode:
-
 
7417
            mov al,byte ptr [offset offset _null]{}@@Col1:
-
 
7418
            mul byte ptr [offset offset _null]   {}@@Col2:
-
 
7419
            mov byte ptr [offset offset _null],ah{}@@Dest:
-
 
7420
          @@EndCode:
-
 
7421
            {$I DXRender.inc}
-
 
7422
            {  @@Col1  }
-
 
7423
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.G+1)
-
 
7424
            mov edx,offset @@Col1-4
-
 
7425
            sub edx,offset @@StartCode
-
 
7426
            mov dword ptr [ecx+edx],eax
-
 
7427
 
-
 
7428
            {  @@Col2  }
-
 
7429
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.G+1)
-
 
7430
            mov edx,offset @@Col2-4
-
 
7431
            sub edx,offset @@StartCode
-
 
7432
            mov dword ptr [ecx+edx],eax
-
 
7433
 
-
 
7434
            {  @@Dest  }
-
 
7435
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.G+1)
-
 
7436
            mov edx,offset @@Dest-4
-
 
7437
            sub edx,offset @@StartCode
-
 
7438
            mov dword ptr [ecx+edx],eax
-
 
7439
          end;
-
 
7440
        end;
-
 
7441
 
-
 
7442
        if chBlue in EnableChannels then
-
 
7443
        begin
-
 
7444
          asm
-
 
7445
            jmp @@EndCode
-
 
7446
          @@StartCode:
-
 
7447
            mov al,byte ptr [offset offset _null]{}@@Col1:
-
 
7448
            mul byte ptr [offset offset _null]   {}@@Col2:
-
 
7449
            mov byte ptr [offset offset _null],ah{}@@Dest:
-
 
7450
          @@EndCode:
-
 
7451
            {$I DXRender.inc}
-
 
7452
            {  @@Col1  }
-
 
7453
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.B+1)
6543
          mov edx,offset @@Col1-4
7454
            mov edx,offset @@Col1-4
6544
          sub edx,offset @@StartCode
7455
            sub edx,offset @@StartCode
6545
          mov dword ptr [ecx+edx],eax
7456
            mov dword ptr [ecx+edx],eax
6546
 
7457
 
-
 
7458
            {  @@Col2  }
-
 
7459
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.B+1)
-
 
7460
            mov edx,offset @@Col2-4
-
 
7461
            sub edx,offset @@StartCode
-
 
7462
            mov dword ptr [ecx+edx],eax
-
 
7463
 
6547
          {  @@Dest  }
7464
            {  @@Dest  }
6548
          mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
7465
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.B+1)
6549
          mov edx,offset @@Dest-4
7466
            mov edx,offset @@Dest-4
6550
          sub edx,offset @@StartCode
7467
            sub edx,offset @@StartCode
6551
          mov dword ptr [ecx+edx],eax
7468
            mov dword ptr [ecx+edx],eax
6552
        end;
7469
          end;
6553
      end;
7470
        end;
-
 
7471
 
-
 
7472
        if chAlpha in EnableChannels then
-
 
7473
        begin
-
 
7474
          asm
-
 
7475
            jmp @@EndCode
-
 
7476
          @@StartCode:
-
 
7477
            mov al,byte ptr [offset offset _null]{}@@Col1:
-
 
7478
            mul byte ptr [offset offset _null]   {}@@Col2:
-
 
7479
            mov byte ptr [offset offset _null],ah{}@@Dest:
-
 
7480
          @@EndCode:
-
 
7481
            {$I DXRender.inc}
-
 
7482
            {  @@Col1  }
-
 
7483
            mov eax,Col1; add eax,Byte(TDXRMachine_Color.A+1)
-
 
7484
            mov edx,offset @@Col1-4
-
 
7485
            sub edx,offset @@StartCode
-
 
7486
            mov dword ptr [ecx+edx],eax
-
 
7487
 
-
 
7488
            {  @@Col2  }
-
 
7489
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
-
 
7490
            mov edx,offset @@Col2-4
-
 
7491
            sub edx,offset @@StartCode
-
 
7492
            mov dword ptr [ecx+edx],eax
-
 
7493
 
-
 
7494
            {  @@Dest  }
-
 
7495
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
-
 
7496
            mov edx,offset @@Dest-4
-
 
7497
            sub edx,offset @@StartCode
-
 
7498
            mov dword ptr [ecx+edx],eax
-
 
7499
          end;
-
 
7500
        end;
-
 
7501
      end;
6554
    end;
7502
    end;
6555
 
7503
 
6556
    procedure genBlend_ADD(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
7504
    procedure genBlend_ADD(var Code: Pointer; Dest, Col1, Col2: PDXRMachine_Color;
6557
      ConstChannels1, ConstChannels12: TDXRColorChannels);
7505
      ConstChannels1, ConstChannels12: TDXRColorChannels);
6558
    begin
7506
    begin
6559
      if UseMMX then
7507
      if UseMMX then
6560
      begin
7508
      begin
6561
        FMMXUsed := True;
7509
        FMMXUsed := True;
6562
        asm
7510
        asm
6563
          jmp @@EndCode
7511
          jmp @@EndCode
6564
        @@StartCode:
7512
        @@StartCode:
6565
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
7513
          db $0F,$6F,$05,$11,$11,$11,$11///movq mm0,qword ptr [$11111111]
6566
                                 @@Col1:
7514
                                 @@Col1:
6567
          db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
7515
          db $0F,$6F,$0D,$11,$11,$11,$11///movq mm1,qword ptr [$11111111]
6568
                                 @@Col2:
7516
                                 @@Col2:
6569
          db $0F,$DD,$C1      ///paddusw mm0,mm1
7517
          db $0F,$DD,$C1      ///paddusw mm0,mm1
6570
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
7518
          db $0F,$7F,$05,$11,$11,$11,$11///movq qword ptr [$11111111],mm0
6571
                                 @@Dest:
7519
                                 @@Dest:
6572
        @@EndCode:
7520
        @@EndCode:
6573
          {$I DXRender.inc}
7521
          {$I DXRender.inc}
6574
          {  @@Col1  }
7522
          {  @@Col1  }
6575
          mov eax,Col1
7523
          mov eax,Col1
6576
          mov edx,offset @@Col1-4
7524
          mov edx,offset @@Col1-4
6577
          sub edx,offset @@StartCode
7525
          sub edx,offset @@StartCode
6578
          mov dword ptr [ecx+edx],eax
7526
          mov dword ptr [ecx+edx],eax
6579
 
7527
 
6580
          {  @@Col2  }
7528
          {  @@Col2  }
6581
          mov eax,Col2
7529
          mov eax,Col2
6582
          mov edx,offset @@Col2-4
7530
          mov edx,offset @@Col2-4
6583
          sub edx,offset @@StartCode
7531
          sub edx,offset @@StartCode
6584
          mov dword ptr [ecx+edx],eax
7532
          mov dword ptr [ecx+edx],eax
6585
 
7533
 
6586
          {  @@Dest  }
7534
          {  @@Dest  }
6587
          mov eax,Dest
7535
          mov eax,Dest
6588
          mov edx,offset @@Dest-4
7536
          mov edx,offset @@Dest-4
6589
          sub edx,offset @@StartCode
7537
          sub edx,offset @@StartCode
6590
          mov dword ptr [ecx+edx],eax
7538
          mov dword ptr [ecx+edx],eax
6591
        end;
7539
        end;
6592
 
7540
 
6593
        {  Alpha Channel  }
7541
        {  Alpha Channel  }
6594
        if chAlpha in EnableChannels then
7542
        if chAlpha in EnableChannels then
6595
        begin
7543
        begin
6596
          asm
7544
          asm
6597
            jmp @@EndCode
7545
            jmp @@EndCode
6598
          @@StartCode:
7546
          @@StartCode:
6599
            mov al,byte ptr [offset _null]{}@@Col2:
7547
            mov al,byte ptr [offset _null]{}@@Col2:
6600
            mov byte ptr [offset _null],al{}@@Dest:
7548
            mov byte ptr [offset _null],al{}@@Dest:
6601
          @@EndCode:
7549
          @@EndCode:
6602
            {$I DXRender.inc}
7550
            {$I DXRender.inc}
6603
            {  @@Col2  }
7551
            {  @@Col2  }
6604
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
7552
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
6605
            mov edx,offset @@Col2-4
7553
            mov edx,offset @@Col2-4
6606
            sub edx,offset @@StartCode
7554
            sub edx,offset @@StartCode
6607
            mov dword ptr [ecx+edx],eax
7555
            mov dword ptr [ecx+edx],eax
6608
 
7556
 
6609
            {  @@Dest  }
7557
            {  @@Dest  }
6610
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
7558
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
6611
            mov edx,offset @@Dest-4
7559
            mov edx,offset @@Dest-4
6612
            sub edx,offset @@StartCode
7560
            sub edx,offset @@StartCode
6613
            mov dword ptr [ecx+edx],eax
7561
            mov dword ptr [ecx+edx],eax
6614
          end;
7562
          end;
6615
        end;
7563
        end;
6616
      end else
7564
      end else
6617
      begin
7565
      begin
6618
        { Red Channel }
7566
        { Red Channel }
6619
        if chRed in EnableChannels then
7567
        if chRed in EnableChannels then
6620
        begin
7568
        begin
6621
          if chRed in ConstChannels1 then
7569
          if chRed in ConstChannels1 then
6622
          begin
7570
          begin
6623
            Func_col1_Add_const2(Code, @Dest.R, @Col2.R, @Col1.R);
7571
            Func_col1_Add_const2(Code, @Dest.R, @Col2.R, @Col1.R);
6624
          end else
7572
          end else
6625
          if chRed in ConstChannels2 then
7573
          if chRed in ConstChannels2 then
6626
          begin
7574
          begin
6627
            Func_col1_Add_const2(Code, @Dest.R, @Col1.R, @Col2.R);
7575
            Func_col1_Add_const2(Code, @Dest.R, @Col1.R, @Col2.R);
6628
          end else
7576
          end else
6629
            Func_col1_Add_col2(Code, @Dest.R, @Col1.R, @Col2.R);
7577
            Func_col1_Add_col2(Code, @Dest.R, @Col1.R, @Col2.R);
6630
        end;
7578
        end;
6631
 
7579
 
6632
        { Green Channel }
7580
        { Green Channel }
6633
        if chGreen in EnableChannels then
7581
        if chGreen in EnableChannels then
6634
        begin
7582
        begin
6635
          if chRed in ConstChannels1 then
7583
          if chRed in ConstChannels1 then
6636
          begin
7584
          begin
6637
            Func_col1_Add_const2(Code, @Dest.G, @Col2.G, @Col1.G);
7585
            Func_col1_Add_const2(Code, @Dest.G, @Col2.G, @Col1.G);
6638
          end else
7586
          end else
6639
          if chRed in ConstChannels2 then
7587
          if chRed in ConstChannels2 then
6640
          begin
7588
          begin
6641
            Func_col1_Add_const2(Code, @Dest.G, @Col1.G, @Col2.G);
7589
            Func_col1_Add_const2(Code, @Dest.G, @Col1.G, @Col2.G);
6642
          end else
7590
          end else
6643
            Func_col1_Add_col2(Code, @Dest.G, @Col1.G, @Col2.G);
7591
            Func_col1_Add_col2(Code, @Dest.G, @Col1.G, @Col2.G);
6644
        end;
7592
        end;
6645
 
7593
 
6646
        { Blue Channel }
7594
        { Blue Channel }
6647
        if chBlue in EnableChannels then
7595
        if chBlue in EnableChannels then
6648
        begin
7596
        begin
6649
          if chRed in ConstChannels1 then
7597
          if chRed in ConstChannels1 then
6650
          begin
7598
          begin
6651
            Func_col1_Add_const2(Code, @Dest.B, @Col2.B, @Col1.B);
7599
            Func_col1_Add_const2(Code, @Dest.B, @Col2.B, @Col1.B);
6652
          end else
7600
          end else
6653
          if chRed in ConstChannels2 then
7601
          if chRed in ConstChannels2 then
6654
          begin
7602
          begin
6655
            Func_col1_Add_const2(Code, @Dest.B, @Col1.B, @Col2.B);
7603
            Func_col1_Add_const2(Code, @Dest.B, @Col1.B, @Col2.B);
6656
          end else
7604
          end else
6657
            Func_col1_Add_col2(Code, @Dest.B, @Col1.B, @Col2.B);
7605
            Func_col1_Add_col2(Code, @Dest.B, @Col1.B, @Col2.B);
6658
        end;
7606
        end;
6659
 
7607
 
6660
        {  Alpha Channel  }
7608
        {  Alpha Channel  }
6661
        if (chAlpha in EnableChannels) and (Col2<>Dest) then
7609
        if (chAlpha in EnableChannels) and (Col2<>Dest) then
6662
        begin
7610
        begin
6663
          asm
7611
          asm
6664
            jmp @@EndCode
7612
            jmp @@EndCode
6665
          @@StartCode:
7613
          @@StartCode:
6666
            mov al,byte ptr [offset _null]{}@@Col2:
7614
            mov al,byte ptr [offset _null]{}@@Col2:
6667
            mov byte ptr [offset _null],al{}@@Dest:
7615
            mov byte ptr [offset _null],al{}@@Dest:
6668
          @@EndCode:
7616
          @@EndCode:
6669
            {$I DXRender.inc}
7617
            {$I DXRender.inc}
6670
            {  @@Col2  }
7618
            {  @@Col2  }
6671
            mov eax,Col2; add eax,BYTE(TDXRMachine_Color.A+1)
7619
            mov eax,Col2; add eax,Byte(TDXRMachine_Color.A+1)
6672
            mov edx,offset @@Col2-4
7620
            mov edx,offset @@Col2-4
6673
            sub edx,offset @@StartCode
7621
            sub edx,offset @@StartCode
6674
            mov dword ptr [ecx+edx],eax
7622
            mov dword ptr [ecx+edx],eax
6675
 
7623
 
6676
            {  @@Dest  }
7624
            {  @@Dest  }
6677
            mov eax,Dest; add eax,BYTE(TDXRMachine_Color.A+1)
7625
            mov eax,Dest; add eax,Byte(TDXRMachine_Color.A+1)
6678
            mov edx,offset @@Dest-4
7626
            mov edx,offset @@Dest-4
6679
            sub edx,offset @@StartCode
7627
            sub edx,offset @@StartCode
6680
            mov dword ptr [ecx+edx],eax
7628
            mov dword ptr [ecx+edx],eax
6681
          end;
7629
          end;
6682
        end;
7630
        end;
6683
      end;
7631
      end;
6684
    end;
7632
    end;
6685
 
7633
 
6686
  begin
7634
  begin
6687
    if EnableChannels=[] then Exit;
7635
    if EnableChannels=[] then Exit;
6688
 
7636
                             
6689
    case Blend of
7637
    case Blend of
6690
      DXR_BLEND_ZERO                      : genBlend_ZERO(Code, Dest);
7638
      DXR_BLEND_ZERO                      : genBlend_ZERO(Code, Dest);
6691
      DXR_BLEND_ONE1                      : genBlend_ONE1(Code, Dest, Col1, ConstChannels1);
7639
      DXR_BLEND_ONE1                      : genBlend_ONE1(Code, Dest, Col1, ConstChannels1);
6692
      DXR_BLEND_ONE2                      : genBlend_ONE1(Code, Dest, Col2, ConstChannels2);
7640
      DXR_BLEND_ONE2                      : genBlend_ONE1(Code, Dest, Col2, ConstChannels2);
6693
      DXR_BLEND_ONE1_ADD_ONE2             : genBlend_ONE1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7641
      DXR_BLEND_ONE1_ADD_ONE2             : genBlend_ONE1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6694
      DXR_BLEND_ONE1_SUB_ONE2             : genBlend_ONE1_SUB_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7642
      DXR_BLEND_ONE1_SUB_ONE2             : genBlend_ONE1_SUB_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6695
      DXR_BLEND_ONE2_SUB_ONE1             : genBlend_ONE1_SUB_ONE2(Code, Dest, Col2, Col1, ConstChannels2, ConstChannels1);
7643
      DXR_BLEND_ONE2_SUB_ONE1             : genBlend_ONE2_SUB_ONE1(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6696
      DXR_BLEND_ONE1_MUL_ONE2             : genBlend_ONE1_MUL_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7644
      DXR_BLEND_ONE1_MUL_ONE2             : genBlend_ONE1_MUL_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6697
      DXR_BLEND_SRCALPHA1                 : genBlend_SRCALPHA1(Code, Dest, Col1, ConstChannels1);
7645
      DXR_BLEND_SRCALPHA1                 : genBlend_SRCALPHA1(Code, Dest, Col1, ConstChannels1);
6698
      DXR_BLEND_SRCALPHA1_ADD_ONE2        : genBlend_SRCALPHA1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7646
      DXR_BLEND_SRCALPHA1_ADD_ONE2        : genBlend_SRCALPHA1_ADD_ONE2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6699
      DXR_BLEND_ONE2_SUB_SRCALPHA1        : genBlend_ONE2_SUB_SRCALPHA1(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7647
      DXR_BLEND_ONE2_SUB_SRCALPHA1        : genBlend_ONE2_SUB_SRCALPHA1(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6700
      DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2: genBlend_SRCALPHA1_ADD_INVSRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7648
      DXR_BLEND_SRCALPHA1_ADD_INVSRCALPHA2: genBlend_SRCALPHA1_ADD_INVSRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6701
      DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2: genBlend_INVSRCALPHA1_ADD_SRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7649
      DXR_BLEND_INVSRCALPHA1_ADD_SRCALPHA2: genBlend_INVSRCALPHA1_ADD_SRCALPHA2(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
-
 
7650
      DXR_BLEND_DECAL                     : genBlend_ONE1(Code, Dest, Col1, ConstChannels1);
6702
      DXR_BLEND_DECALALPHA                : genBlend_DECALALPHA(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7651
      DXR_BLEND_DECALALPHA                : genBlend_DECALALPHA(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6703
      DXR_BLEND_MODULATE                  : genBlend_MODULATE_RGBONLY(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7652
      DXR_BLEND_MODULATE                  : genBlend_MODULATE(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
-
 
7653
      DXR_BLEND_MODULATEALPHA             : genBlend_MODULATEALPHA(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6704
      DXR_BLEND_ADD                       : genBlend_ADD(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
7654
      DXR_BLEND_ADD                       : genBlend_ADD(Code, Dest, Col1, Col2, ConstChannels1, ConstChannels2);
6705
    end;
7655
    end;                                                                                                      
6706
  end;
7656
  end;
6707
 
7657
 
6708
var
7658
var
6709
  StackPoint: Integer;
7659
  StackPoint: Integer;
6710
 
7660
 
6711
  function NewWorkColor: PDXRMachine_Color;
7661
  function NewWorkColor: PDXRMachine_Color;
6712
  begin
7662
  begin
6713
    Result := @FStack[StackPoint]; Inc(StackPoint);
7663
    Result := @FStack[StackPoint]; Inc(StackPoint);
6714
  end;
7664
  end;
6715
 
7665
 
6716
  function GenerateCode2(var Code: Pointer; Tree: PDXRMachine_Tree): PDXRMachine_Color;
7666
  function GenerateCode2(var Code: Pointer; Tree: PDXRMachine_Tree): PDXRMachine_Color;
6717
  var
7667
  var
6718
    Col1, Col2: PDXRMachine_Color;
7668
    Col1, Col2: PDXRMachine_Color;
6719
    ConstChannels1, ConstChannels2: TDXRColorChannels;
7669
    ConstChannels1, ConstChannels2: TDXRColorChannels;
6720
    ch: TDXRColorChannels;
7670
    ch: TDXRColorChannels;
6721
  begin
7671
  begin
6722
    Result := NewWorkColor;
7672
    Result := NewWorkColor;
6723
    case Tree.Typ of
7673
    case Tree.Typ of
6724
      DXR_TREETYPE_LOADBLACK:
7674
      DXR_TREETYPE_LOADBLACK:
6725
          begin
7675
          begin
6726
            genBlend(Code, DXR_BLEND_ZERO, Result, nil, nil, Tree.Channels, [], []);
7676
            genBlend(Code, DXR_BLEND_ZERO, Result, nil, nil, Tree.Channels, [], []);
6727
          end;
7677
          end;
6728
      DXR_TREETYPE_LOADCOLOR:
7678
      DXR_TREETYPE_LOADCOLOR:
6729
          begin
7679
          begin
6730
            genBlend(Code, DXR_BLEND_ONE1, Result, @ColorList[Tree.Color].nColor, nil, Tree.Channels, [], []);
7680
            genBlend(Code, DXR_BLEND_ONE1, Result, @ColorList[Tree.Color].nColor, nil, Tree.Channels, [], []);
6731
          end;
7681
          end;
6732
      DXR_TREETYPE_LOADCONSTCOLOR:
7682
      DXR_TREETYPE_LOADCONSTCOLOR:
6733
          begin
7683
          begin
6734
            genBlend(Code, DXR_BLEND_ONE1, Result, @Tree.ConstColor, nil, Tree.Channels,
7684
            genBlend(Code, DXR_BLEND_ONE1, Result, @Tree.ConstColor, nil, Tree.Channels,
6735
              [chRed, chGreen, chBlue, chAlpha], []);
7685
              [chRed, chGreen, chBlue, chAlpha], []);
6736
          end;
7686
          end;
6737
      DXR_TREETYPE_LOADTEXTURE:
7687
      DXR_TREETYPE_LOADTEXTURE:
6738
          begin
7688
          begin
6739
            genReadTexture(Code, Result, TextureList[Tree.Texture], Tree.Channels);
7689
            genReadTexture(Code, Result, TextureList[Tree.Texture], Tree.Channels);
6740
          end;
7690
          end;
-
 
7691
      DXR_TREETYPE_LOADBUMPTEXTURE:
-
 
7692
          begin
-
 
7693
            genReadBumpTexture(Code, Result, TextureList[Tree.Texture], TextureList[Tree.BumpTexture], Tree.Channels);
-
 
7694
          end;
6741
      DXR_TREETYPE_LOADDESTPIXEL:
7695
      DXR_TREETYPE_LOADDESTPIXEL:
6742
          begin
7696
          begin
6743
            genReadDestPixel(Code);
7697
            genReadDestPixel(Code);
6744
            genDecodeColor(Code, Dest^, Result, Tree.Channels, _BlackColor);
7698
            genDecodeColor(Code, Dest^, Result, Tree.Channels, _BlackColor);
6745
          end;
7699
          end;
6746
      DXR_TREETYPE_BLEND:
7700
      DXR_TREETYPE_BLEND:
6747
          begin
7701
          begin
6748
            // Blend color
7702
            // Blend color
6749
            Col1 := nil;
7703
            Col1 := nil;
6750
            Col2 := nil;
7704
            Col2 := nil;
6751
 
7705
 
6752
            ConstChannels1 := [];
7706
            ConstChannels1 := [];
6753
            ConstChannels2 := [];
7707
            ConstChannels2 := [];
6754
 
7708
 
6755
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADBLACK) then
7709
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADBLACK) then
6756
            begin
7710
            begin
6757
              Col1 := @_BlackColor;
7711
              Col1 := @_BlackColor;
6758
            end else
7712
            end else
6759
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADCOLOR) then
7713
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADCOLOR) then
6760
            begin
7714
            begin
6761
              Col1 := @ColorList[Tree.BlendTree1.Color].nColor;
7715
              Col1 := @ColorList[Tree.BlendTree1.Color].nColor;
6762
            end else
7716
            end else
6763
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADCONSTCOLOR) then
7717
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADCONSTCOLOR) then
6764
            begin
7718
            begin
6765
              Col1 := @Tree.BlendTree1.ConstColor;
7719
              Col1 := @Tree.BlendTree1.ConstColor;
6766
              ConstChannels1 := [chRed, chGreen, chBlue, chAlpha];
7720
              ConstChannels1 := [chRed, chGreen, chBlue, chAlpha];
6767
            end else
7721
            end else
6768
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADTEXTURE) then
7722
            if (Tree.BlendTree1<>nil) and (Tree.BlendTree1.Typ=DXR_TREETYPE_LOADTEXTURE) then
6769
            begin
7723
            begin
6770
              ch := TextureList[Tree.BlendTree1.Texture].EnableChannels;
7724
              ch := TextureList[Tree.BlendTree1.Texture].EnableChannels;
6771
 
7725
 
6772
              if (chRed in Tree.BlendTree1.Channels) and (not (chRed in ch)) then
7726
              if (chRed in Tree.BlendTree1.Channels) and (not (chRed in ch)) then
6773
              begin
7727
              begin
6774
                ConstChannels1 := ConstChannels1 + [chRed];
7728
                ConstChannels1 := ConstChannels1 + [chRed];
6775
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chRed];
7729
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chRed];
6776
              end;
7730
              end;
6777
 
7731
 
6778
              if (chGreen in Tree.BlendTree1.Channels) and (not (chGreen in ch)) then
7732
              if (chGreen in Tree.BlendTree1.Channels) and (not (chGreen in ch)) then
6779
              begin
7733
              begin
6780
                ConstChannels1 := ConstChannels1 + [chGreen];
7734
                ConstChannels1 := ConstChannels1 + [chGreen];
6781
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chGreen];
7735
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chGreen];
6782
              end;
7736
              end;
6783
 
7737
 
6784
              if (chBlue in Tree.BlendTree1.Channels) and (not (chBlue in ch)) then
7738
              if (chBlue in Tree.BlendTree1.Channels) and (not (chBlue in ch)) then
6785
              begin
7739
              begin
6786
                ConstChannels1 := ConstChannels1 + [chBlue];
7740
                ConstChannels1 := ConstChannels1 + [chBlue];
6787
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chBlue];
7741
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chBlue];
6788
              end;
7742
              end;
6789
 
7743
 
6790
              if (chAlpha in Tree.BlendTree1.Channels) and (not (chAlpha in ch)) then
7744
              if (chAlpha in Tree.BlendTree1.Channels) and (not (chAlpha in ch)) then
6791
              begin
7745
              begin
6792
                ConstChannels1 := ConstChannels1 + [chAlpha];
7746
                ConstChannels1 := ConstChannels1 + [chAlpha];
6793
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chAlpha];
7747
                Tree.BlendTree1.Channels := Tree.BlendTree1.Channels - [chAlpha];
6794
              end;
7748
              end;
6795
 
7749
 
6796
              Col1 := GenerateCode2(Code, Tree.BlendTree1);
7750
              Col1 := GenerateCode2(Code, Tree.BlendTree1);
6797
 
7751
 
6798
              if chRed in ConstChannels1 then
7752
              if chRed in ConstChannels1 then
6799
                Col1.R := TextureList[Tree.BlendTree1.Texture].DefaultColor.R;
7753
                Col1.R := TextureList[Tree.BlendTree1.Texture].DefaultColor.R;
6800
 
7754
 
6801
              if chGreen in ConstChannels1 then
7755
              if chGreen in ConstChannels1 then
6802
                Col1.G := TextureList[Tree.BlendTree1.Texture].DefaultColor.G;
7756
                Col1.G := TextureList[Tree.BlendTree1.Texture].DefaultColor.G;
6803
 
7757
 
6804
              if chBlue in ConstChannels1 then
7758
              if chBlue in ConstChannels1 then
6805
                Col1.B := TextureList[Tree.BlendTree1.Texture].DefaultColor.B;
7759
                Col1.B := TextureList[Tree.BlendTree1.Texture].DefaultColor.B;
6806
 
7760
               
6807
              if chAlpha in ConstChannels1 then
7761
              if chAlpha in ConstChannels1 then
6808
                Col1.A := TextureList[Tree.BlendTree1.Texture].DefaultColor.A;
7762
                Col1.A := TextureList[Tree.BlendTree1.Texture].DefaultColor.A;
6809
            end else
7763
            end else
6810
            if Tree.BlendTree1<>nil then
7764
            if Tree.BlendTree1<>nil then
6811
            begin
7765
            begin
6812
              Col1 := GenerateCode2(Code, Tree.BlendTree1);
7766
              Col1 := GenerateCode2(Code, Tree.BlendTree1);
6813
            end;
7767
            end;
6814
 
7768
 
6815
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADBLACK) then
7769
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADBLACK) then
6816
            begin
7770
            begin
6817
              Col2 := @_BlackColor;
7771
              Col2 := @_BlackColor;
6818
            end else
7772
            end else
6819
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADCOLOR) then
7773
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADCOLOR) then
6820
            begin
7774
            begin
6821
              Col2 := @ColorList[Tree.BlendTree2.Color].nColor;
7775
              Col2 := @ColorList[Tree.BlendTree2.Color].nColor;
6822
            end else
7776
            end else
6823
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADCONSTCOLOR) then
7777
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADCONSTCOLOR) then
6824
            begin
7778
            begin
6825
              Col2 := @Tree.BlendTree2.ConstColor;
7779
              Col2 := @Tree.BlendTree2.ConstColor;
6826
              ConstChannels2 := [chRed, chGreen, chBlue, chAlpha];
7780
              ConstChannels2 := [chRed, chGreen, chBlue, chAlpha];
6827
            end else
7781
            end else
6828
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADTEXTURE) then
7782
            if (Tree.BlendTree2<>nil) and (Tree.BlendTree2.Typ=DXR_TREETYPE_LOADTEXTURE) then
6829
            begin
7783
            begin
6830
              ch := TextureList[Tree.BlendTree2.Texture].EnableChannels;
7784
              ch := TextureList[Tree.BlendTree2.Texture].EnableChannels;
6831
             
7785
             
6832
              if (chRed in Tree.BlendTree2.Channels) and (not (chRed in ch)) then
7786
              if (chRed in Tree.BlendTree2.Channels) and (not (chRed in ch)) then
6833
              begin
7787
              begin
6834
                ConstChannels2 := ConstChannels2 + [chRed];
7788
                ConstChannels2 := ConstChannels2 + [chRed];
6835
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chRed];
7789
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chRed];
6836
              end;
7790
              end;
6837
 
7791
 
6838
              if (chGreen in Tree.BlendTree2.Channels) and (not (chGreen in ch)) then
7792
              if (chGreen in Tree.BlendTree2.Channels) and (not (chGreen in ch)) then
6839
              begin
7793
              begin
6840
                ConstChannels2 := ConstChannels2 + [chGreen];
7794
                ConstChannels2 := ConstChannels2 + [chGreen];
6841
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chGreen];
7795
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chGreen];
6842
              end;
7796
              end;
6843
 
7797
 
6844
              if (chBlue in Tree.BlendTree2.Channels) and (not (chBlue in ch)) then
7798
              if (chBlue in Tree.BlendTree2.Channels) and (not (chBlue in ch)) then
6845
              begin
7799
              begin
6846
                ConstChannels2 := ConstChannels2 + [chBlue];
7800
                ConstChannels2 := ConstChannels2 + [chBlue];
6847
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chBlue];
7801
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chBlue];
6848
              end;
7802
              end;
6849
 
7803
 
6850
              if (chAlpha in Tree.BlendTree2.Channels) and (not (chAlpha in ch)) then
7804
              if (chAlpha in Tree.BlendTree2.Channels) and (not (chAlpha in ch)) then
6851
              begin
7805
              begin
6852
                ConstChannels2 := ConstChannels2 + [chAlpha];
7806
                ConstChannels2 := ConstChannels2 + [chAlpha];
6853
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chAlpha];
7807
                Tree.BlendTree2.Channels := Tree.BlendTree2.Channels - [chAlpha];
6854
              end;
7808
              end;
6855
 
7809
 
6856
              Col2 := GenerateCode2(Code, Tree.BlendTree2);
7810
              Col2 := GenerateCode2(Code, Tree.BlendTree2);
6857
 
7811
 
6858
              if chRed in ConstChannels2 then
7812
              if chRed in ConstChannels2 then
6859
                Col2.R := TextureList[Tree.BlendTree2.Texture].DefaultColor.R;
7813
                Col2.R := TextureList[Tree.BlendTree2.Texture].DefaultColor.R;
6860
 
7814
 
6861
              if chGreen in ConstChannels2 then
7815
              if chGreen in ConstChannels2 then
6862
                Col2.G := TextureList[Tree.BlendTree2.Texture].DefaultColor.G;
7816
                Col2.G := TextureList[Tree.BlendTree2.Texture].DefaultColor.G;
6863
 
7817
 
6864
              if chBlue in ConstChannels2 then
7818
              if chBlue in ConstChannels2 then
6865
                Col2.B := TextureList[Tree.BlendTree2.Texture].DefaultColor.B;
7819
                Col2.B := TextureList[Tree.BlendTree2.Texture].DefaultColor.B;
6866
 
7820
 
6867
              if chAlpha in ConstChannels2 then
7821
              if chAlpha in ConstChannels2 then
6868
                Col2.A := TextureList[Tree.BlendTree2.Texture].DefaultColor.A;
7822
                Col2.A := TextureList[Tree.BlendTree2.Texture].DefaultColor.A;
6869
            end else
7823
            end else
6870
            if Tree.BlendTree2<>nil then
7824
            if Tree.BlendTree2<>nil then
6871
            begin
7825
            begin
6872
              Col2 := GenerateCode2(Code, Tree.BlendTree2);
7826
              Col2 := GenerateCode2(Code, Tree.BlendTree2);
6873
            end;
7827
            end;
6874
 
7828
 
6875
            genBlend(Code, Tree.Blend, Result, Col1, Col2, Tree.Channels,
7829
            genBlend(Code, Tree.Blend, Result, Col1, Col2, Tree.Channels,
6876
              ConstChannels1, ConstChannels2);
7830
              ConstChannels1, ConstChannels2);
6877
          end;
7831
          end;
6878
    end;
7832
    end;
6879
  end;
7833
  end;
6880
 
7834
 
6881
var
7835
var
6882
  ExitAddress, MainCode: Pointer;
7836
  ExitAddress, MainCode: Pointer;
6883
  Col: PDXRMachine_Color;
7837
  Col: PDXRMachine_Color;
6884
begin
7838
begin
6885
  if (Tree.Typ=DXR_TREETYPE_LOADCOLOR) and (not ColorList[Tree.Color].Gouraud) and
7839
  if (Tree.Typ=DXR_TREETYPE_LOADCOLOR) and (not ColorList[Tree.Color].Gouraud) and
6886
    (not Dither.Enable) and (Dest.BitCount in [16, 32]) then
7840
    (not ZBuffer.Enable) and (not Dither.Enable) and (Dest.BitCount in [16, 32]) then
6887
  begin
7841
  begin
6888
    FCall := Code;
7842
    FCall := Code;
6889
    genInitDestAddress(Code);
7843
    genInitDestAddress(Code);
6890
    genEncodeColor(Code, Dest^, @ColorList[Tree.Color].nColor, Tree.Channels);
7844
    genEncodeColor(Code, Dest^, @ColorList[Tree.Color].nColor, Tree.Channels);
6891
 
7845
 
6892
    case Dest.BitCount of
7846
    case Dest.BitCount of
6893
      16: begin
7847
      16: begin
6894
            asm
7848
            asm
6895
              jmp @@EndCode
7849
              jmp @@EndCode
6896
            @@StartCode:
7850
            @@StartCode:
6897
              mov edx,eax
7851
              mov edx,eax
6898
              rol eax,16
7852
              rol eax,16
6899
              mov ax,dx
7853
              mov ax,dx
6900
 
7854
 
6901
              {  DWORD arrangement  }
7855
              {  DWORD arrangement  }
6902
              mov edx,edi
7856
              mov edx,edi
6903
              and edx,3
7857
              and edx,3
6904
              shr edx,1
7858
              shr edx,1
6905
              jz @@dwordarray_skip
7859
              jz @@dwordarray_skip
6906
 
7860
 
6907
            @@dwordarray_loop:
7861
            @@dwordarray_loop:
6908
              mov word ptr [edi],ax
7862
              mov word ptr [edi],ax
6909
              add edi,2
7863
              add edi,2
6910
              dec ecx
7864
              dec ecx
6911
              jz @@Exit
7865
              jz @@Exit
6912
              dec edx
7866
              dec edx
6913
              jmp @@dwordarray_loop
7867
              jmp @@dwordarray_loop
6914
            @@dwordarray_skip:
7868
            @@dwordarray_skip:
6915
 
7869
 
6916
              {  DWORD  }
7870
              {  DWORD  }
6917
              mov edx,ecx
7871
              mov edx,ecx
6918
              shr edx,1
7872
              shr edx,1
6919
              jz @@dword_skip
7873
              jz @@dword_skip
6920
            @@dword_loop:
7874
            @@dword_loop:
6921
              mov dword ptr [edi],eax
7875
              mov dword ptr [edi],eax
6922
              add edi,4
7876
              add edi,4
6923
              dec edx
7877
              dec edx
6924
              jnz @@dword_loop
7878
              jnz @@dword_loop
6925
 
7879
 
6926
              and ecx,1
7880
              and ecx,1
6927
              jz @@Exit
7881
              jz @@Exit
6928
            @@dword_skip:
7882
            @@dword_skip:
6929
 
7883
 
6930
              {  WORD  }
7884
              {  WORD  }
6931
              mov word ptr [edi],ax
7885
              mov word ptr [edi],ax
6932
            @@Exit:
7886
            @@Exit:
6933
              ret
7887
              ret
6934
            @@EndCode:
7888
            @@EndCode:
6935
              {$I DXRender.inc}
7889
              {$I DXRender.inc}
6936
            end;
7890
            end;
6937
          end;
7891
          end;
6938
      32: begin
7892
      32: begin
6939
            asm
7893
            asm
6940
              jmp @@EndCode
7894
              jmp @@EndCode
6941
            @@StartCode:
7895
            @@StartCode:
6942
              {  DWORD  }
7896
              {  DWORD  }
6943
              dec ecx
7897
              dec ecx
6944
            @@loop:
7898
            @@loop:
6945
              mov dword ptr [edi+ecx*4],eax
7899
              mov dword ptr [edi+ecx*4],eax
6946
              dec ecx
7900
              dec ecx
6947
              jnl @@loop
7901
              jnl @@loop
6948
              ret
7902
              ret
6949
            @@EndCode:
7903
            @@EndCode:
6950
              {$I DXRender.inc}
7904
              {$I DXRender.inc}
6951
            end;
7905
            end;
6952
          end;
7906
          end;
6953
    end;
7907
    end;
6954
 
7908
 
6955
    Exit;
7909
    Exit;
6956
  end;
7910
  end;
6957
 
7911
 
6958
  {  -----------  Exit  -----------  }
7912
  {  -----------  Exit  -----------  }
6959
  ExitAddress := Code;
7913
  ExitAddress := Code;
6960
 
7914
 
6961
  asm
7915
  asm
6962
    jmp @@EndCode
7916
    jmp @@EndCode
6963
  @@StartCode:
7917
  @@StartCode:
6964
    ret
7918
    ret
6965
  @@EndCode:
7919
  @@EndCode:
6966
    {$I DXRender.inc}
7920
    {$I DXRender.inc}
6967
  end;
7921
  end;
6968
 
7922
 
6969
  {  -----------  Loop  -----------  }
7923
  {  -----------  Loop  -----------  }
6970
  SkipAddress := Code;
7924
  SkipAddress := Code;
6971
 
7925
 
6972
  genUpdateAxis(Code);
7926
  genUpdateAxis(Code);
6973
  genUpdateColor(Code);
7927
  genUpdateColor(Code);
6974
  genUpdateTextureAxis(Code);
7928
  genUpdateTextureAxis(Code);
-
 
7929
  genUpdateRHW(Code);
6975
  genUpdateDestAddress(Code);
7930
  genUpdateDestAddress(Code);
-
 
7931
  genUpdateZBufferAddress(Code);
6976
 
7932
 
6977
  asm
7933
  asm
6978
    jmp @@EndCode
7934
    jmp @@EndCode
6979
  @@StartCode:
7935
  @@StartCode:
6980
    dec ecx
7936
    dec ecx
6981
  @@EndCode:
7937
  @@EndCode:
6982
    {$I DXRender.inc}
7938
    {$I DXRender.inc}
6983
  end;
7939
  end;
6984
  genCmpFunc(Code, DXR_CMPFUNC_LESSEQUAL, ExitAddress);
7940
  genCmpFunc(Code, DXR_CMPFUNC_LESSEQUAL, ExitAddress);
6985
 
7941
 
6986
  {  -----------  Main  -----------  }
7942
  {  -----------  Main  -----------  }
6987
  MainCode := Code;
7943
  MainCode := Code;
6988
 
7944
 
-
 
7945
  genZBufferTest(Code);
-
 
7946
 
6989
  if Tree.Typ=DXR_TREETYPE_LOADCOLOR then
7947
  if Tree.Typ=DXR_TREETYPE_LOADCOLOR then
6990
  begin
7948
  begin
6991
    genEncodeColor2(Code, Dest^, @ColorList[Tree.Color].nColor, Tree.Channels);
7949
    genEncodeColor2(Code, Dest^, @ColorList[Tree.Color].nColor, Tree.Channels);
6992
    genWriteDestPixel(Code);
7950
    genWriteDestPixel(Code);
6993
  end else
7951
  end else
6994
  if (Tree.Typ=DXR_TREETYPE_LOADTEXTURE) and (not Dither.Enable) and
7952
  if (Tree.Typ=DXR_TREETYPE_LOADTEXTURE) and (not Dither.Enable) and
6995
    (TextureList[Tree.Texture].Filter in [DXR_TEXTUREFILTER_NEAREST]) and
7953
    (TextureList[Tree.Texture].Filter in [DXR_TEXTUREFILTER_NEAREST, DXR_TEXTUREFILTER_MIPMAP_NEAREST]) and
6996
    (dxrCompareSurface(Dest^, TextureList[Tree.Texture].Surface^)) then
7954
    (dxrCompareSurface(Dest^, TextureList[Tree.Texture].Surface^)) then
6997
  begin
7955
  begin
6998
    genReadSurfacePixel(Code, TextureList[Tree.Texture], @TextureList[Tree.Texture].nAxis);
7956
    genReadSurfacePixel(Code, TextureList[Tree.Texture], @TextureList[Tree.Texture].nAxis);
6999
    genColorKey(Code, TextureList[Tree.Texture]);
7957
    genColorKey(Code, TextureList[Tree.Texture]);
7000
    genWriteDestPixel(Code);
7958
    genWriteDestPixel(Code);
7001
  end else
7959
  end else
7002
  begin
7960
  begin
7003
    StackPoint := 0; Col := GenerateCode2(Code, Tree);
7961
    StackPoint := 0; Col := GenerateCode2(Code, Tree);
7004
    genEncodeColor2(Code, Dest^, Col, Tree.Channels);
7962
    genEncodeColor2(Code, Dest^, Col, Tree.Channels);
7005
    genWriteDestPixel(Code);
7963
    genWriteDestPixel(Code);
7006
  end;
7964
  end;
7007
 
7965
 
7008
  genCmpFunc(Code, DXR_CMPFUNC_ALWAYS, SkipAddress);
7966
  genCmpFunc(Code, DXR_CMPFUNC_ALWAYS, SkipAddress);
7009
 
7967
 
7010
  {  -----------  Initialize  -----------  }
7968
  {  -----------  Initialize  -----------  }
7011
  FCall := Code;
7969
  FCall := Code;
7012
 
7970
 
7013
  genInitDestAddress(Code);
7971
  genInitDestAddress(Code);
-
 
7972
  genInitZBuffer(Code);
7014
 
7973
 
7015
  genCmpFunc(Code, DXR_CMPFUNC_ALWAYS, MainCode);
7974
  genCmpFunc(Code, DXR_CMPFUNC_ALWAYS, MainCode);
7016
end;
7975
end;
7017
 
7976
 
7018
procedure TDXRMachine.Run(Count: Integer);
7977
procedure TDXRMachine.Run(Count: Integer);
7019
var
7978
var
7020
  P: Pointer;
7979
  P: Pointer;
7021
begin
7980
begin
7022
  if Count<=0 then Exit;
7981
  if Count<=0 then Exit;
7023
  if FCall=nil then Exit;
7982
  if FCall=nil then Exit;
7024
 
7983
 
7025
  P := FCall;
7984
  P := FCall;
7026
 
7985
 
7027
  asm
7986
  asm
7028
    push edi
7987
    push edi
7029
    push esi
7988
    push esi
7030
    push ebx
7989
    push ebx
7031
    push ebp
7990
    push ebp
7032
    push eax
7991
    push eax
7033
    push edx
7992
    push edx
7034
    mov ecx,Count
7993
    mov ecx,Count
7035
    mov eax,P
7994
    mov eax,P
7036
    call eax
7995
    call eax
7037
    pop edx
7996
    pop edx
7038
    pop eax
7997
    pop eax
7039
    pop ebp
7998
    pop ebp
7040
    pop ebx
7999
    pop ebx
7041
    pop esi
8000
    pop esi
7042
    pop edi
8001
    pop edi
7043
  end;
8002
  end;
7044
 
8003
 
7045
  if FMMXUsed then
8004
  if FMMXUsed then
7046
  begin
8005
  begin
7047
    asm
8006
    asm
7048
      db $0F,$77                    ///emms
8007
      db $0F,$77                    ///emms
7049
    end;
8008
    end;
7050
  end;
8009
  end;
7051
end;
8010
end;
7052
 
8011
 
7053
var
8012
var
7054
  FDXRMachine: TDXRMachine;
8013
  FDXRMachine: TDXRMachine;
7055
 
8014
 
7056
function DXRMachine: TDXRMachine;
8015
function DXRMachine: TDXRMachine;
7057
begin
8016
begin
7058
  if FDXRMachine=nil then
8017
  if FDXRMachine=nil then
7059
    FDXRMachine := TDXRMachine.Create;
8018
    FDXRMachine := TDXRMachine.Create;
7060
  Result := FDXRMachine;
8019
  Result := FDXRMachine;
7061
end;
8020
end;
7062
 
8021
 
7063
procedure dxrDefRenderStates(var States: TDXR_RenderStates);
8022
procedure dxrDefRenderStates(var States: TDXR_RenderStates);
7064
var
8023
var
7065
  i: Integer;
8024
  i: Integer;
7066
begin
8025
begin
7067
  FillChar(States, SizeOf(States), 0);
8026
  FillChar(States, SizeOf(States), 0);
7068
 
8027
 
7069
  with States do
8028
  with States do
7070
  begin
8029
  begin
7071
    DitherEnable := False;
8030
    DitherEnable := False;
7072
    SpecularEnable := True;
8031
    SpecularEnable := True;
7073
    CullMode := DXR_CULL_CCW;
8032
    CullMode := DXR_CULL_CCW;
7074
    Shade := DXR_SHADEMODE_GOURAUD;
8033
    Shade := DXR_SHADEMODE_GOURAUD;
7075
    TexBlend := DXR_BLEND_MODULATE;
8034
    TexBlend := DXR_BLEND_MODULATE;
7076
    Blend := DXR_BLEND_ONE1;
8035
    Blend := DXR_BLEND_ONE1;
7077
    TextureFilter := DXR_TEXTUREFILTER_NEAREST;
8036
    TextureFilter := DXR_TEXTUREFILTER_NEAREST;
-
 
8037
    ZBuffer := nil;
-
 
8038
    ZFunc := DXR_CMPFUNC_LESSEQUAL;
-
 
8039
    ZWriteEnable := True;
7078
    EnableDrawLine := $FFFFFFFF;
8040
    EnableDrawLine := 0;
7079
  end;                
8041
  end;
7080
 
8042
 
7081
  for i:=0 to DXR_MAXTEXTURE-1 do
8043
  for i:=0 to DXR_MAXTEXTURE-1 do
7082
    with States.TextureList[i] do
8044
    with States.TextureList[i] do
7083
    begin
8045
    begin
7084
      LayerBlend := DXR_TEXTURELAYERBLEND_TEXTURE;
8046
      LayerBlend := DXR_TEXTURELAYERBLEND_TEXTURE;
7085
      Blend := DXR_BLEND_ONE1;
8047
      Blend := DXR_BLEND_ONE1;
7086
      Surface := nil;
8048
      Surface := nil;
7087
      ColorKeyEnable := False;
8049
      ColorKeyEnable := False;
7088
      ColorKey := 0;
8050
      ColorKey := 0;
7089
      TextureAddress := DXR_TEXTUREADDRESS_TILE;
8051
      TextureAddress := DXR_TEXTUREADDRESS_TILE;
-
 
8052
      BumpTexture := -1;
7090
    end;
8053
    end;
7091
end;
8054
end;
7092
 
8055
 
7093
{  Draw primitive  }
8056
{  Draw primitive  }
7094
 
8057
 
7095
type
8058
type
7096
  PArrayDXR_Vertex = ^TArrayDXR_Vertex;
8059
  PArrayDXR_Vertex = ^TArrayDXR_Vertex;
7097
  TArrayDXR_Vertex = array[0..0] of TDXR_Vertex;
8060
  TArrayDXR_Vertex = array[0..0] of TDXR_Vertex;
7098
 
8061
 
7099
  PArrayPDXR_Vertex = ^TArrayPDXR_Vertex;
8062
  PArrayPDXR_Vertex = ^TArrayPDXR_Vertex;
7100
  TArrayPDXR_Vertex = array[0..0] of PDXR_Vertex;
8063
  TArrayPDXR_Vertex = array[0..0] of PDXR_Vertex;
7101
 
8064
 
7102
  TDXR_Triangle = array[0..2] of PDXR_Vertex;
8065
  TDXR_Triangle = array[0..2] of PDXR_Vertex;
7103
 
8066
 
7104
  PArrayDWORD = ^TArrayDWORD;
8067
  PArrayDWORD = ^TArrayDWORD;
7105
  TArrayDWORD = array[0..2] of DWORD;
8068
  TArrayDWORD = array[0..2] of DWORD;
7106
 
8069
 
7107
procedure dxrDrawTriangle(const Dest: TDXR_Surface; const States: TDXR_RenderStates; const Tri: TDXR_Triangle);
8070
procedure dxrDrawTriangle(const Dest: TDXR_Surface; const States: TDXR_RenderStates; const Tri: TDXR_Triangle);
7108
 
8071
 
7109
  function InitGenerator_MakeTree_LoadTexture(Texture: Integer): PDXRMachine_Tree;
8072
  function InitGenerator_MakeTree_LoadTexture(Texture: Integer): PDXRMachine_Tree;
7110
  begin
8073
  begin
-
 
8074
    if States.TextureList[Texture].BumpTexture>=0 then
-
 
8075
      Result := DXRMachine.CreateTree_LoadBumpTexture(Texture, States.TextureList[Texture].BumpTexture)
-
 
8076
    else
7111
    Result := DXRMachine.CreateTree_LoadTexture(Texture);
8077
      Result := DXRMachine.CreateTree_LoadTexture(Texture);
7112
  end;
8078
  end;
7113
 
8079
 
7114
  function InitGenerator_MakeTree: PDXRMachine_Tree;
8080
  function InitGenerator_MakeTree: PDXRMachine_Tree;
7115
  var
8081
  var
7116
    i: Integer;
8082
    i: Integer;
7117
    Layer: PDXR_TextureLayer;
8083
    Layer: PDXR_TextureLayer;
7118
  begin
8084
  begin
7119
    if States.TextureEnable then
8085
    if States.TextureEnable then
7120
    begin
8086
    begin
7121
      {  Load texel  }
8087
      {  Load texel  }
7122
      Result := DXRMachine.CreateTree2(DXR_TREETYPE_LOADBLACK);
8088
      Result := DXRMachine.CreateTree2(DXR_TREETYPE_LOADBLACK);
7123
 
8089
 
7124
      if States.TextureEnable then
8090
      if States.TextureEnable then
7125
        for i:=Low(States.TextureList) to High(States.TextureList) do
8091
        for i:=Low(States.TextureList) to High(States.TextureList) do
7126
        begin
8092
        begin
7127
          Layer := @States.TextureList[i];
8093
          Layer := @States.TextureList[i];
7128
          if (Layer.Surface<>nil) and (Layer.LayerBlend=DXR_TEXTURELAYERBLEND_TEXTURE) then
8094
          if (Layer.Surface<>nil) and (Layer.LayerBlend=DXR_TEXTURELAYERBLEND_TEXTURE) then
7129
          begin
8095
          begin
7130
            Result := DXRMachine.CreateTree_Blend(Layer.Blend, InitGenerator_MakeTree_LoadTexture(i), Result);
8096
            Result := DXRMachine.CreateTree_Blend(Layer.Blend, InitGenerator_MakeTree_LoadTexture(i), Result);
7131
          end;
8097
          end;
7132
        end;
8098
        end;
7133
 
8099
 
7134
      {  Lighting  }
8100
      {  Lighting  }
7135
      Result := DXRMachine.CreateTree_Blend(States.TexBlend, Result, DXRMachine.CreateTree_LoadColor(0));
8101
      Result := DXRMachine.CreateTree_Blend(States.TexBlend, Result, DXRMachine.CreateTree_LoadColor(0));
7136
 
8102
 
7137
      {  Blend after lighting is given  }
8103
      {  Blend after lighting is given  }
7138
      for i:=Low(States.TextureList) to High(States.TextureList) do
8104
      for i:=Low(States.TextureList) to High(States.TextureList) do
7139
      begin
8105
      begin
7140
        Layer := @States.TextureList[i];
8106
        Layer := @States.TextureList[i];
7141
        if (Layer.Surface<>nil) and (Layer.LayerBlend=DXR_TEXTURELAYERBLEND_LAST) then
8107
        if (Layer.Surface<>nil) and (Layer.LayerBlend=DXR_TEXTURELAYERBLEND_LAST) then
7142
        begin
8108
        begin
7143
          Result := DXRMachine.CreateTree_Blend(Layer.Blend, InitGenerator_MakeTree_LoadTexture(i), Result);
8109
          Result := DXRMachine.CreateTree_Blend(Layer.Blend, InitGenerator_MakeTree_LoadTexture(i), Result);
7144
        end;
8110
        end;
7145
      end;
8111
      end;
7146
    end else
8112
    end else
7147
    begin
8113
    begin
7148
      Result := DXRMachine.CreateTree_LoadColor(0);
8114
      Result := DXRMachine.CreateTree_LoadColor(0);
7149
    end;
8115
    end;
7150
 
8116
 
7151
    {  Blend with Dest pixel   }
8117
    {  Blend with Dest pixel   }
7152
    Result := DXRMachine.CreateTree_Blend(States.Blend, Result, DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
8118
    Result := DXRMachine.CreateTree_Blend(States.Blend, Result, DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
7153
 
8119
 
7154
    {  Specular generation  }
8120
    {  Specular generation  }
7155
    if States.SpecularEnable then
8121
    if States.SpecularEnable then
7156
    begin
8122
    begin
7157
      Result := DXRMachine.CreateTree_Blend(DXR_BLEND_ONE1_ADD_ONE2, Result, DXRMachine.CreateTree_LoadColor(1));
8123
      Result := DXRMachine.CreateTree_Blend(DXR_BLEND_ONE1_ADD_ONE2, Result, DXRMachine.CreateTree_LoadColor(1));
7158
    end;
8124
    end;
7159
  end;
8125
  end;
7160
 
8126
 
7161
  procedure InitGenerator;
8127
  procedure InitGenerator;
7162
 
8128
 
7163
    function Hypot(X, Y: Extended): Extended;
8129
    function Hypot(X, Y: Extended): Extended;
7164
    begin
8130
    begin
7165
      Result := Sqrt(X*X + Y*Y);
8131
      Result := Sqrt(X*X + Y*Y);
7166
    end;
8132
    end;
7167
 
8133
 
7168
  var
8134
  var
7169
    i: Integer;
8135
    i: Integer;
7170
    Layer: PDXR_TextureLayer;
8136
    Layer: PDXR_TextureLayer;
-
 
8137
    Mipmap1, Mipmap2, Mipmap3: Integer;
-
 
8138
    TmpSurface2: PDXR_Surface;
7171
  begin
8139
  begin
7172
    DXRMachine.Initialize;
8140
    DXRMachine.Initialize;
7173
 
8141
 
7174
    {  Parameter setting  }
8142
    {  Parameter setting  }
7175
    DXRMachine.Dest := @Dest;
8143
    DXRMachine.Dest := @Dest;
-
 
8144
    DXRMachine.ZBuffer.Enable := States.ZBuffer<>nil;
-
 
8145
    DXRMachine.ZBuffer.Surface := States.ZBuffer;
-
 
8146
    DXRMachine.ZBuffer.CmpFunc := States.ZFunc;
-
 
8147
    DXRMachine.ZBuffer.WriteEnable := States.ZWriteEnable;
7176
    DXRMachine.Dither.Enable := States.DitherEnable;
8148
    DXRMachine.Dither.Enable := States.DitherEnable;
7177
 
8149
 
7178
    DXRMachine.ColorList[0].Gouraud := States.Shade=DXR_SHADEMODE_GOURAUD;
8150
    DXRMachine.ColorList[0].Gouraud := States.Shade=DXR_SHADEMODE_GOURAUD;
7179
    DXRMachine.ColorList[1].Gouraud := States.Shade=DXR_SHADEMODE_GOURAUD;
8151
    DXRMachine.ColorList[1].Gouraud := States.Shade=DXR_SHADEMODE_GOURAUD;
7180
 
8152
 
7181
    if States.TextureEnable then
8153
    if States.TextureEnable then
7182
      for i:=Low(States.TextureList) to High(States.TextureList) do
8154
      for i:=Low(States.TextureList) to High(States.TextureList) do
7183
      begin
8155
      begin
7184
        Layer := @States.TextureList[i];
8156
        Layer := @States.TextureList[i];
7185
 
8157
 
7186
        if States.TextureList[i].Surface<>nil then
8158
        if States.TextureList[i].Surface<>nil then
7187
        begin
8159
        begin
7188
          with DXRMachine.TextureList[i] do
8160
          with DXRMachine.TextureList[i] do
7189
          begin
8161
          begin
7190
            ColorKeyEnable := Layer.ColorKeyEnable;
8162
            ColorKeyEnable := Layer.ColorKeyEnable;
7191
            ColorKey := Layer.ColorKey;
8163
            ColorKey := Layer.ColorKey;
7192
            Surface := Layer.Surface;
8164
            Surface := Layer.Surface;
7193
            Filter := States.TextureFilter;
8165
            Filter := States.TextureFilter;
7194
            TextureAddress := Layer.TextureAddress;
8166
            TextureAddress := Layer.TextureAddress;
-
 
8167
 
-
 
8168
            if (Filter in [DXR_TEXTUREFILTER_MIPMAP_NEAREST, DXR_TEXTUREFILTER_MIPMAP_LINEAR]) and
-
 
8169
              (Surface.MipmapChain<>nil) then
-
 
8170
            begin
-
 
8171
              {  Mipmap  }
-
 
8172
              Mipmap1 := MaxInt;
-
 
8173
              Mipmap3 := Trunc(Abs(Hypot(Tri[2].sx-Tri[1].sx, Tri[2].sy-Tri[1].sy))*
-
 
8174
                Abs(Hypot(Tri[1].sx-Tri[0].sx, Tri[1].sy-Tri[0].sy))*
-
 
8175
                Abs(Hypot(Tri[2].sx-Tri[0].sx, Tri[2].sy-Tri[0].sy))/9);
-
 
8176
 
-
 
8177
              TmpSurface2 := Surface;
-
 
8178
 
-
 
8179
              while TmpSurface2<>nil do
-
 
8180
              begin
-
 
8181
                Mipmap2 := TmpSurface2.Width2*TmpSurface2.Height2;
-
 
8182
 
-
 
8183
                if (Abs(Mipmap3-Mipmap2)<Abs(Mipmap3-Mipmap1)) then
-
 
8184
                begin
-
 
8185
                  Surface := TmpSurface2;
-
 
8186
                  Mipmap1 := Mipmap2;
-
 
8187
                end;
-
 
8188
 
-
 
8189
                TmpSurface2 := TmpSurface2.MipmapChain;
-
 
8190
              end;
-
 
8191
            end;
7195
          end;
8192
          end;
7196
        end;
8193
        end;
7197
      end;
8194
      end;
7198
 
8195
 
7199
    {  Tree making  }
8196
    {  Tree making  }
7200
    DXRMachine.Compile(InitGenerator_MakeTree);
8197
    DXRMachine.Compile(InitGenerator_MakeTree);
7201
  end;
8198
  end;
7202
 
8199
 
7203
type
8200
type
7204
  TCol64Array = array[0..1] of TDXRMachine_Color;
8201
  TCol64Array = array[0..1] of TDXRMachine_Color;
7205
  T2DAxis64Array = array[0..DXR_MAXTEXTURE-1] of TDXRMachine_Axis;
8202
  T2DAxis64Array = array[0..DXR_MAXTEXTURE-1] of TDXRMachine_Axis;
7206
 
8203
 
7207
const
8204
const
7208
  Int32Value = 65536.0*65536.0;
8205
  Int32Value = 65536.0*65536.0;
7209
 
8206
 
7210
var
8207
var
7211
  TexXFloat, TexYFloat: array[0..DXR_MAXTEXTURE-1] of DWORD;
8208
  TexXFloat, TexYFloat: array[0..DXR_MAXTEXTURE-1] of DWORD;
7212
 
8209
 
7213
  function Comp2DWORD(c: Comp): DWORD;
8210
  function Comp2DWORD(c: Comp): DWORD;
7214
  begin
8211
  begin
7215
    Result := PDWORD(@c)^;
8212
    Result := PDWORD(@c)^;
7216
  end;
8213
  end;
7217
 
8214
 
7218
  function FloatToIntFloat(d: Extended): Comp;
8215
  function FloatToIntFloat(d: Extended): Comp;
7219
  begin
8216
  begin
7220
    Result := d*Int32Value;
8217
    Result := d*Int32Value;
7221
  end;
8218
  end;
7222
 
8219
 
7223
  function FloatToColorFloat(d: Extended): Word;
8220
  function FloatToColorFloat(d: Extended): Word;
7224
  begin
8221
  begin
7225
    Result := Trunc(d*255);
8222
    Result := Trunc(d*255);
7226
  end;
8223
  end;
7227
 
8224
 
7228
  function FloatToTextureFloatX(i: Integer; d: Extended): DWORD;
8225
  function FloatToTextureFloatX(i: Integer; d: Extended): DWORD;
7229
  begin
8226
  begin
7230
    Result := Comp2DWORD(d*TexXFloat[i]);
8227
    Result := Comp2DWORD(d*TexXFloat[i]);
7231
  end;
8228
  end;
7232
 
8229
 
7233
  function FloatToTextureFloatY(i: Integer; d: Double): DWORD;
8230
  function FloatToTextureFloatY(i: Integer; d: Double): DWORD;
7234
  begin
8231
  begin
7235
    Result := Comp2DWORD(d*TexYFloat[i]);
8232
    Result := Comp2DWORD(d*TexYFloat[i]);
7236
  end;
8233
  end;
7237
 
8234
 
-
 
8235
  function FloatToRHWFloat(d: Extended): Comp;
-
 
8236
  begin
-
 
8237
    Result := d*Int32Value;
-
 
8238
  end;
-
 
8239
 
7238
  procedure drawline(x1, x2, y: Integer;
8240
  procedure drawline(x1, x2, y: Integer;
7239
    const x_ntex1, x_ntex2: T2DAxis64Array;
8241
    const x_ntex1, x_ntex2: T2DAxis64Array;
7240
    const x_nc1, x_nc2: TCol64Array);
8242
    const x_nc1, x_nc2: TCol64Array;
-
 
8243
    const x_nRHW1, x_nRHW2: Comp);
7241
  var
8244
  var
7242
    i, xcount, xcount2, ofs: Integer;
8245
    i, xcount, xcount2, ofs: Integer;
7243
  begin
8246
  begin
7244
    xcount := x2-x1;
8247
    xcount := x2-x1;
7245
    xcount2 := xcount;
8248
    xcount2 := xcount;
7246
 
8249
 
7247
    {  Clipping  }
8250
    {  Clipping  }
7248
    ofs := 0;
8251
    ofs := 0;
7249
 
8252
 
7250
    if x1<0 then
8253
    if x1<0 then
7251
    begin
8254
    begin
7252
      i := -x1;
8255
      i := -x1;
7253
      Inc(ofs, i);
8256
      Inc(ofs, i);
7254
      Inc(x1, i);
8257
      Inc(x1, i);
7255
      Dec(xcount2, i);
8258
      Dec(xcount2, i);
7256
    end;
8259
    end;
7257
 
8260
 
7258
    if x1+xcount2>=Integer(Dest.Width) then
8261
    if x1+xcount2>=Integer(Dest.Width) then
7259
    begin
8262
    begin
7260
      i := (x1+xcount2)-Integer(Dest.Width);
8263
      i := (x1+xcount2)-Integer(Dest.Width);
7261
      Dec(xcount2, i);
8264
      Dec(xcount2, i);
7262
    end;
8265
    end;
7263
 
8266
 
7264
    if xcount2<=0 then Exit;
8267
    if xcount2<=0 then Exit;
7265
 
8268
 
7266
    DXRMachine.Axis.Axis.X := x1;
8269
    DXRMachine.Axis.Axis.X := x1;
7267
    DXRMachine.Axis.Axis.Y := y;
8270
    DXRMachine.Axis.Axis.Y := y;
7268
 
8271
 
7269
    for i:=0 to DXRMachine.TextureIndexCount-1 do
8272
    for i:=0 to DXRMachine.TextureIndexCount-1 do
7270
      with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
8273
      with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
7271
      begin
8274
      begin
7272
        nAxis := x_ntex1[i];
8275
        nAxis := x_ntex1[i];
7273
        iAxis.X := Integer(x_ntex2[i].X-x_ntex1[i].X) div xcount;
8276
        iAxis.X := Integer(x_ntex2[i].X-x_ntex1[i].X) div xcount;
7274
        iAxis.Y := Integer(x_ntex2[i].Y-x_ntex1[i].Y) div xcount;
8277
        iAxis.Y := Integer(x_ntex2[i].Y-x_ntex1[i].Y) div xcount;
7275
 
8278
 
7276
        if TextureAddress=DXR_TEXTUREADDRESS_DONOTCLIP then
8279
        if TextureAddress=DXR_TEXTUREADDRESS_DONOTCLIP then
7277
        begin
8280
        begin
7278
          if (DWORD(nAxis.X) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Width) or
8281
          if (DWORD(nAxis.X) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Width) or
7279
            (DWORD(nAxis.Y) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Height) then Exit;
8282
            (DWORD(nAxis.Y) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Height) then Exit;
7280
 
8283
 
7281
          if ((DWORD(nAxis.X+iAxis.X*(xcount)-1)) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Width) or
8284
          if ((DWORD(nAxis.X+iAxis.X*(xcount)-1)) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Width) or
7282
            ((DWORD(nAxis.Y+iAxis.Y*(xcount)-1)) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Height) then Exit;
8285
            ((DWORD(nAxis.Y+iAxis.Y*(xcount)-1)) shr 16>DXRMachine.TextureList[DXRMachine.TextureIndex[i]].Surface.Height) then Exit;
7283
        end;
8286
        end;
7284
 
8287
 
7285
        if ofs<>0 then
8288
        if ofs<>0 then
7286
        begin
8289
        begin
7287
          nAxis.X := nAxis.X + iAxis.X*ofs;
8290
          nAxis.X := nAxis.X + iAxis.X*ofs;
7288
          nAxis.Y := nAxis.Y + iAxis.Y*ofs;
8291
          nAxis.Y := nAxis.Y + iAxis.Y*ofs;
7289
        end;
8292
        end;
7290
      end;
8293
      end;
7291
 
8294
 
7292
    for i:=0 to DXRMachine.ColorIndexCount-1 do
8295
    for i:=0 to DXRMachine.ColorIndexCount-1 do
7293
      with DXRMachine.ColorList[DXRMachine.ColorIndex[i]] do
8296
      with DXRMachine.ColorList[DXRMachine.ColorIndex[i]] do
7294
      begin
8297
      begin
7295
        if Gouraud then
8298
        if Gouraud then
7296
        begin
8299
        begin
7297
          nColor := x_nc1[i];
8300
          nColor := x_nc1[i];
7298
 
8301
 
7299
          iColor.R := Integer(x_nc2[i].R-x_nc1[i].R) div xcount;
8302
          iColor.R := Integer(x_nc2[i].R-x_nc1[i].R) div xcount;
7300
          iColor.G := Integer(x_nc2[i].G-x_nc1[i].G) div xcount;
8303
          iColor.G := Integer(x_nc2[i].G-x_nc1[i].G) div xcount;
7301
          iColor.B := Integer(x_nc2[i].B-x_nc1[i].B) div xcount;
8304
          iColor.B := Integer(x_nc2[i].B-x_nc1[i].B) div xcount;
7302
          iColor.A := Integer(x_nc2[i].A-x_nc1[i].A) div xcount;
8305
          iColor.A := Integer(x_nc2[i].A-x_nc1[i].A) div xcount;
7303
 
8306
 
7304
          if ofs<>0 then
8307
          if ofs<>0 then
7305
          begin
8308
          begin
7306
            nColor.R := nColor.R + iColor.R*ofs;
8309
            nColor.R := nColor.R + iColor.R*ofs;
7307
            nColor.G := nColor.G + iColor.G*ofs;
8310
            nColor.G := nColor.G + iColor.G*ofs;
7308
            nColor.B := nColor.B + iColor.B*ofs;
8311
            nColor.B := nColor.B + iColor.B*ofs;
7309
            nColor.A := nColor.A + iColor.A*ofs;
8312
            nColor.A := nColor.A + iColor.A*ofs;
7310
          end;
8313
          end;
7311
        end;
8314
        end;
7312
      end;
8315
      end;
7313
 
8316
 
-
 
8317
    with DXRMachine.RHW do
-
 
8318
    begin
-
 
8319
      if Enable then
-
 
8320
      begin
-
 
8321
        nRHW := x_nRHW1;
-
 
8322
        iRHW := (x_nRHW2-x_nRHW1) / xcount;
-
 
8323
        if ofs<>0 then
-
 
8324
          nRHW := nRHW + iRHW*ofs;
-
 
8325
      end;
-
 
8326
    end;
-
 
8327
 
7314
    DXRMachine.Run(xcount2);
8328
    DXRMachine.Run(xcount2);
7315
  end;
8329
  end;
7316
 
8330
 
7317
  procedure draw(p1, pt1, p2, pt2: PDXR_Vertex; starty, ycount, y1, y2, ofs1, ofs2: Integer);
8331
  procedure draw(p1, pt1, p2, pt2: PDXR_Vertex; starty, ycount, y1, y2, ofs1, ofs2: Integer);
7318
  var
8332
  var
7319
    i, j, y: Integer;
8333
    i, j, y: Integer;
7320
    c1, c2, c2_1, c2_2: TDXR_Color;
8334
    c1, c2, c2_1, c2_2: TDXR_Color;
7321
    y_nx1, y_nx2, y_ix1, y_ix2: Comp;
8335
    y_nx1, y_nx2, y_ix1, y_ix2: Comp;
7322
    y_ntex1, y_ntex2, y_itex1, y_itex2: T2DAxis64Array;
8336
    y_ntex1, y_ntex2, y_itex1, y_itex2: T2DAxis64Array;
7323
    y_nc1, y_nc2, y_ic1, y_ic2: TCol64Array;
8337
    y_nc1, y_nc2, y_ic1, y_ic2: TCol64Array;
-
 
8338
    y_nRHW1, y_nRHW2, y_iRHW1, y_iRHW2: Comp;
7324
  begin
8339
  begin
7325
    if ycount<=0 then Exit;
8340
    if ycount<=0 then Exit;
7326
    if y1=0 then Exit;
8341
    if y1=0 then Exit;
7327
    if y2=0 then Exit;
8342
    if y2=0 then Exit;
7328
 
8343
 
7329
    {  Clipping  }
8344
    {  Clipping  }
7330
    if starty<0 then
8345
    if starty<0 then
7331
    begin
8346
    begin
7332
      i := -starty;
8347
      i := -starty;
7333
 
8348
 
7334
      Inc(ofs1, i);
8349
      Inc(ofs1, i);
7335
      Inc(ofs2, i);
8350
      Inc(ofs2, i);
7336
 
8351
 
7337
      Inc(starty, i);
8352
      Inc(starty, i);
7338
      Dec(ycount, i);
8353
      Dec(ycount, i);
7339
    end;
8354
    end;
7340
 
8355
 
7341
    if starty+ycount>=Integer(Dest.Height) then
8356
    if starty+ycount>=Integer(Dest.Height) then
7342
    begin
8357
    begin
7343
      i := (starty+ycount)-Integer(Dest.Height);
8358
      i := (starty+ycount)-Integer(Dest.Height);
7344
      Dec(ycount, i);
8359
      Dec(ycount, i);
7345
    end;
8360
    end;
7346
 
8361
 
7347
    if ycount<=0 then Exit;
8362
    if ycount<=0 then Exit;
7348
 
8363
 
7349
    y_nx1 := FloatToIntFloat(Trunc(p1.sx));
8364
    y_nx1 := FloatToIntFloat(Trunc(p1.sx));
7350
    y_nx2 := FloatToIntFloat(Trunc(p2.sx));
8365
    y_nx2 := FloatToIntFloat(Trunc(p2.sx));
7351
    y_ix1 := FloatToIntFloat((Trunc(pt1.sx)-Trunc(p1.sx))/y1);
8366
    y_ix1 := FloatToIntFloat((Trunc(pt1.sx)-Trunc(p1.sx))/y1);
7352
    y_ix2 := FloatToIntFloat((Trunc(pt2.sx)-Trunc(p2.sx))/y2);
8367
    y_ix2 := FloatToIntFloat((Trunc(pt2.sx)-Trunc(p2.sx))/y2);
7353
 
8368
 
7354
    if ofs1<>0 then
8369
    if ofs1<>0 then
7355
      y_nx1 := y_nx1 + y_ix1*ofs1;
8370
      y_nx1 := y_nx1 + y_ix1*ofs1;
7356
 
8371
 
7357
    if ofs2<>0 then
8372
    if ofs2<>0 then
7358
      y_nx2 := y_nx2 + y_ix2*ofs2;
8373
      y_nx2 := y_nx2 + y_ix2*ofs2;
7359
 
8374
 
7360
    for i:=0 to DXRMachine.TextureIndexCount-1 do
8375
    for i:=0 to DXRMachine.TextureIndexCount-1 do
7361
    begin
8376
    begin
7362
      j := DXRMachine.TextureIndex[i];
8377
      j := DXRMachine.TextureIndex[i];
7363
 
8378
 
7364
      y_itex1[i].X := FloatToTextureFloatX(i, (pt1.tu[j]-p1.tu[j])/y1);
8379
      y_itex1[i].X := FloatToTextureFloatX(i, (pt1.tu[j]-p1.tu[j])/y1);
7365
      y_itex1[i].Y := FloatToTextureFloatY(i, (pt1.tv[j]-p1.tv[j])/y1);
8380
      y_itex1[i].Y := FloatToTextureFloatY(i, (pt1.tv[j]-p1.tv[j])/y1);
7366
      y_itex2[i].X := FloatToTextureFloatX(i, (pt2.tu[j]-p2.tu[j])/y2);
8381
      y_itex2[i].X := FloatToTextureFloatX(i, (pt2.tu[j]-p2.tu[j])/y2);
7367
      y_itex2[i].Y := FloatToTextureFloatY(i, (pt2.tv[j]-p2.tv[j])/y2);
8382
      y_itex2[i].Y := FloatToTextureFloatY(i, (pt2.tv[j]-p2.tv[j])/y2);
7368
 
8383
 
7369
      y_ntex1[i].X := FloatToTextureFloatX(i, p1.tu[j]);
8384
      y_ntex1[i].X := FloatToTextureFloatX(i, p1.tu[j]);
7370
      y_ntex1[i].Y := FloatToTextureFloatY(i, p1.tv[j]);
8385
      y_ntex1[i].Y := FloatToTextureFloatY(i, p1.tv[j]);
7371
      y_ntex2[i].X := FloatToTextureFloatX(i, p2.tu[j]);
8386
      y_ntex2[i].X := FloatToTextureFloatX(i, p2.tu[j]);
7372
      y_ntex2[i].Y := FloatToTextureFloatY(i, p2.tv[j]);
8387
      y_ntex2[i].Y := FloatToTextureFloatY(i, p2.tv[j]);
7373
 
8388
 
7374
      if ofs1<>0 then
8389
      if ofs1<>0 then
7375
      begin
8390
      begin
7376
        y_ntex1[i].X := y_ntex1[i].X + y_itex1[i].X*ofs1;
8391
        y_ntex1[i].X := y_ntex1[i].X + y_itex1[i].X*ofs1;
7377
        y_ntex1[i].Y := y_ntex1[i].Y + y_itex1[i].Y*ofs1;
8392
        y_ntex1[i].Y := y_ntex1[i].Y + y_itex1[i].Y*ofs1;
7378
      end;
8393
      end;
7379
 
8394
 
7380
      if ofs2<>0 then
8395
      if ofs2<>0 then
7381
      begin
8396
      begin
7382
        y_ntex2[i].X := y_ntex2[i].X + y_itex2[i].X*ofs2;
8397
        y_ntex2[i].X := y_ntex2[i].X + y_itex2[i].X*ofs2;
7383
        y_ntex2[i].Y := y_ntex2[i].Y + y_itex2[i].Y*ofs2;
8398
        y_ntex2[i].Y := y_ntex2[i].Y + y_itex2[i].Y*ofs2;
7384
      end;
8399
      end;
7385
    end;
8400
    end;
7386
 
8401
 
7387
    for i:=0 to DXRMachine.ColorIndexCount-1 do
8402
    for i:=0 to DXRMachine.ColorIndexCount-1 do
7388
      if DXRMachine.ColorList[i].Gouraud then
8403
      if DXRMachine.ColorList[i].Gouraud then
7389
      begin
8404
      begin
7390
        if DXRMachine.ColorIndex[i]=0 then
8405
        if DXRMachine.ColorIndex[i]=0 then
7391
        begin
8406
        begin
7392
          c1 := p1.color;
8407
          c1 := p1.color;
7393
          c2 := p2.color;
8408
          c2 := p2.color;
7394
          c2_1 := pt1.color;
8409
          c2_1 := pt1.color;
7395
          c2_2 := pt2.color;
8410
          c2_2 := pt2.color;
7396
        end else
8411
        end else
7397
        begin
8412
        begin
7398
          c1 := p1.specular;
8413
          c1 := p1.specular;
7399
          c2 := p2.specular;
8414
          c2 := p2.specular;
7400
          c2_1 := pt1.specular;
8415
          c2_1 := pt1.specular;
7401
          c2_2 := pt2.specular;
8416
          c2_2 := pt2.specular;
7402
        end;
8417
        end;
7403
 
8418
 
7404
        y_nc1[i].R := FloatToColorFloat(RGBA_GETRED(c1));
8419
        y_nc1[i].R := FloatToColorFloat(RGBA_GETRED(c1));
7405
        y_nc1[i].G := FloatToColorFloat(RGBA_GETGREEN(c1));
8420
        y_nc1[i].G := FloatToColorFloat(RGBA_GETGREEN(c1));
7406
        y_nc1[i].B := FloatToColorFloat(RGBA_GETBLUE(c1));
8421
        y_nc1[i].B := FloatToColorFloat(RGBA_GETBLUE(c1));
7407
        y_nc1[i].A := FloatToColorFloat(RGBA_GETALPHA(c1));
8422
        y_nc1[i].A := FloatToColorFloat(RGBA_GETALPHA(c1));
7408
        y_nc2[i].R := FloatToColorFloat(RGBA_GETRED(c2));
8423
        y_nc2[i].R := FloatToColorFloat(RGBA_GETRED(c2));
7409
        y_nc2[i].G := FloatToColorFloat(RGBA_GETGREEN(c2));
8424
        y_nc2[i].G := FloatToColorFloat(RGBA_GETGREEN(c2));
7410
        y_nc2[i].B := FloatToColorFloat(RGBA_GETBLUE(c2));
8425
        y_nc2[i].B := FloatToColorFloat(RGBA_GETBLUE(c2));
7411
        y_nc2[i].A := FloatToColorFloat(RGBA_GETALPHA(c2));
8426
        y_nc2[i].A := FloatToColorFloat(RGBA_GETALPHA(c2));
7412
 
8427
 
7413
        y_ic1[i].R := FloatToColorFloat((RGBA_GETRED(c2_1)-RGBA_GETRED(c1))/y1);
8428
        y_ic1[i].R := FloatToColorFloat((RGBA_GETRED(c2_1)-RGBA_GETRED(c1))/y1);
7414
        y_ic1[i].G := FloatToColorFloat((RGBA_GETGREEN(c2_1)-RGBA_GETGREEN(c1))/y1);
8429
        y_ic1[i].G := FloatToColorFloat((RGBA_GETGREEN(c2_1)-RGBA_GETGREEN(c1))/y1);
7415
        y_ic1[i].B := FloatToColorFloat((RGBA_GETBLUE(c2_1)-RGBA_GETBLUE(c1))/y1);
8430
        y_ic1[i].B := FloatToColorFloat((RGBA_GETBLUE(c2_1)-RGBA_GETBLUE(c1))/y1);
7416
        y_ic1[i].A := FloatToColorFloat((RGBA_GETALPHA(c2_1)-RGBA_GETALPHA(c1))/y1);
8431
        y_ic1[i].A := FloatToColorFloat((RGBA_GETALPHA(c2_1)-RGBA_GETALPHA(c1))/y1);
7417
        y_ic2[i].R := FloatToColorFloat((RGBA_GETRED(c2_2)-RGBA_GETRED(c2))/y2);
8432
        y_ic2[i].R := FloatToColorFloat((RGBA_GETRED(c2_2)-RGBA_GETRED(c2))/y2);
7418
        y_ic2[i].G := FloatToColorFloat((RGBA_GETGREEN(c2_2)-RGBA_GETGREEN(c2))/y2);
8433
        y_ic2[i].G := FloatToColorFloat((RGBA_GETGREEN(c2_2)-RGBA_GETGREEN(c2))/y2);
7419
        y_ic2[i].B := FloatToColorFloat((RGBA_GETBLUE(c2_2)-RGBA_GETBLUE(c2))/y2);
8434
        y_ic2[i].B := FloatToColorFloat((RGBA_GETBLUE(c2_2)-RGBA_GETBLUE(c2))/y2);
7420
        y_ic2[i].A := FloatToColorFloat((RGBA_GETALPHA(c2_2)-RGBA_GETALPHA(c2))/y2);
8435
        y_ic2[i].A := FloatToColorFloat((RGBA_GETALPHA(c2_2)-RGBA_GETALPHA(c2))/y2);
7421
 
8436
 
7422
        if ofs1<>0 then
8437
        if ofs1<>0 then
7423
        begin
8438
        begin
7424
          y_nc1[i].R := y_nc1[i].R + y_ic1[i].R*ofs1;
8439
          y_nc1[i].R := y_nc1[i].R + y_ic1[i].R*ofs1;
7425
          y_nc1[i].G := y_nc1[i].G + y_ic1[i].G*ofs1;
8440
          y_nc1[i].G := y_nc1[i].G + y_ic1[i].G*ofs1;
7426
          y_nc1[i].B := y_nc1[i].B + y_ic1[i].B*ofs1;
8441
          y_nc1[i].B := y_nc1[i].B + y_ic1[i].B*ofs1;
7427
          y_nc1[i].A := y_nc1[i].A + y_ic1[i].A*ofs1;
8442
          y_nc1[i].A := y_nc1[i].A + y_ic1[i].A*ofs1;
7428
        end;
8443
        end;
7429
 
8444
 
7430
        if ofs2<>0 then
8445
        if ofs2<>0 then
7431
        begin
8446
        begin
7432
          y_nc2[i].R := y_nc2[i].R + y_ic2[i].R*ofs2;
8447
          y_nc2[i].R := y_nc2[i].R + y_ic2[i].R*ofs2;
7433
          y_nc2[i].G := y_nc2[i].G + y_ic2[i].G*ofs2;
8448
          y_nc2[i].G := y_nc2[i].G + y_ic2[i].G*ofs2;
7434
          y_nc2[i].B := y_nc2[i].B + y_ic2[i].B*ofs2;
8449
          y_nc2[i].B := y_nc2[i].B + y_ic2[i].B*ofs2;
7435
          y_nc2[i].A := y_nc2[i].A + y_ic2[i].A*ofs2;
8450
          y_nc2[i].A := y_nc2[i].A + y_ic2[i].A*ofs2;
7436
        end;
8451
        end;
7437
      end;
8452
      end;
7438
 
8453
 
-
 
8454
    if DXRMachine.RHW.Enable then
-
 
8455
    begin
-
 
8456
      y_nRHW1 := FloatToRHWFloat(p1.rhw);
-
 
8457
      y_nRHW2 := FloatToRHWFloat(p2.rhw);
-
 
8458
      y_iRHW1 := FloatToRHWFloat((pt1.rhw-p1.rhw)/y1);
-
 
8459
      y_iRHW2 := FloatToRHWFloat((pt2.rhw-p2.rhw)/y2);
-
 
8460
 
-
 
8461
      if ofs1<>0 then
-
 
8462
      begin
-
 
8463
        y_nRHW1 := y_nRHW1 + y_iRHW1*ofs1;
-
 
8464
      end;
-
 
8465
 
-
 
8466
      if ofs2<>0 then
-
 
8467
      begin
-
 
8468
        y_nRHW2 := y_nRHW2 + y_iRHW2*ofs2;
-
 
8469
      end;
-
 
8470
    end else
-
 
8471
    begin
-
 
8472
      y_nRHW1 := 0;
-
 
8473
      y_nRHW2 := 0;
-
 
8474
      y_iRHW1 := 0;
-
 
8475
      y_iRHW2 := 0;
-
 
8476
    end;
-
 
8477
 
7439
    for y:=starty to starty+ycount-1 do
8478
    for y:=starty to starty+ycount-1 do
7440
    begin
8479
    begin
7441
      if States.EnableDrawLine and (1 shl (y and 31))<>0 then
8480
      if (States.EnableDrawLine=0) or ((States.EnableDrawLine-1)=y mod 2) then
7442
        if PInteger(Integer(@y_nx1)+4)^<PInteger(Integer(@y_nx2)+4)^ then
8481
        if PInteger(Integer(@y_nx1)+4)^<PInteger(Integer(@y_nx2)+4)^ then
7443
        begin
8482
        begin
7444
          drawline(
8483
          drawline(
7445
            PInteger(Integer(@y_nx1)+4)^, PInteger(Integer(@y_nx2)+4)^, y,
8484
            PInteger(Integer(@y_nx1)+4)^, PInteger(Integer(@y_nx2)+4)^, y,
7446
            y_ntex1, y_ntex2,
8485
            y_ntex1, y_ntex2,
7447
            y_nc1, y_nc2
8486
            y_nc1, y_nc2,
-
 
8487
            y_nRHW1, y_nRHW2
7448
          );
8488
          );
7449
        end else if PInteger(Integer(@y_nx1)+4)^>PInteger(Integer(@y_nx2)+4)^ then
8489
        end else if PInteger(Integer(@y_nx1)+4)^>PInteger(Integer(@y_nx2)+4)^ then
7450
        begin
8490
        begin
7451
          drawline(
8491
          drawline(
7452
            PInteger(Integer(@y_nx2)+4)^, PInteger(Integer(@y_nx1)+4)^, y,
8492
            PInteger(Integer(@y_nx2)+4)^, PInteger(Integer(@y_nx1)+4)^, y,
7453
            y_ntex2, y_ntex1,
8493
            y_ntex2, y_ntex1,
7454
            y_nc2, y_nc1
8494
            y_nc2, y_nc1,
-
 
8495
            y_nRHW2, y_nRHW1
7455
          );
8496
          );
7456
        end;
8497
        end;
7457
 
8498
 
7458
      y_nx1 := y_nx1 + y_ix1;
8499
      y_nx1 := y_nx1 + y_ix1;
7459
      y_nx2 := y_nx2 + y_ix2;
8500
      y_nx2 := y_nx2 + y_ix2;
7460
 
8501
 
7461
      for i:=0 to DXRMachine.TextureIndexCount-1 do
8502
      for i:=0 to DXRMachine.TextureIndexCount-1 do
7462
        with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
8503
        with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
7463
        begin
8504
        begin
7464
          y_ntex1[i].X := y_ntex1[i].X + y_itex1[i].X;
8505
          y_ntex1[i].X := y_ntex1[i].X + y_itex1[i].X;
7465
          y_ntex1[i].Y := y_ntex1[i].Y + y_itex1[i].Y;
8506
          y_ntex1[i].Y := y_ntex1[i].Y + y_itex1[i].Y;
7466
          y_ntex2[i].X := y_ntex2[i].X + y_itex2[i].X;
8507
          y_ntex2[i].X := y_ntex2[i].X + y_itex2[i].X;
7467
          y_ntex2[i].Y := y_ntex2[i].Y + y_itex2[i].Y;
8508
          y_ntex2[i].Y := y_ntex2[i].Y + y_itex2[i].Y;
7468
        end;
8509
        end;
7469
 
8510
 
7470
      for i:=0 to DXRMachine.ColorIndexCount-1 do
8511
      for i:=0 to DXRMachine.ColorIndexCount-1 do
7471
        with DXRMachine.ColorList[DXRMachine.ColorIndex[i]] do
8512
        with DXRMachine.ColorList[DXRMachine.ColorIndex[i]] do
7472
        begin
8513
        begin
7473
          if Gouraud then
8514
          if Gouraud then
7474
          begin
8515
          begin
7475
            y_nc1[i].R := y_nc1[i].R + y_ic1[i].R;
8516
            y_nc1[i].R := y_nc1[i].R + y_ic1[i].R;
7476
            y_nc1[i].G := y_nc1[i].G + y_ic1[i].G;
8517
            y_nc1[i].G := y_nc1[i].G + y_ic1[i].G;
7477
            y_nc1[i].B := y_nc1[i].B + y_ic1[i].B;
8518
            y_nc1[i].B := y_nc1[i].B + y_ic1[i].B;
7478
            y_nc1[i].A := y_nc1[i].A + y_ic1[i].A;
8519
            y_nc1[i].A := y_nc1[i].A + y_ic1[i].A;
7479
            y_nc2[i].R := y_nc2[i].R + y_ic2[i].R;
8520
            y_nc2[i].R := y_nc2[i].R + y_ic2[i].R;
7480
            y_nc2[i].G := y_nc2[i].G + y_ic2[i].G;
8521
            y_nc2[i].G := y_nc2[i].G + y_ic2[i].G;
7481
            y_nc2[i].B := y_nc2[i].B + y_ic2[i].B;
8522
            y_nc2[i].B := y_nc2[i].B + y_ic2[i].B;
7482
            y_nc2[i].A := y_nc2[i].A + y_ic2[i].A;
8523
            y_nc2[i].A := y_nc2[i].A + y_ic2[i].A;
7483
          end;
8524
          end;
7484
        end;
8525
        end;
-
 
8526
 
-
 
8527
      if DXRMachine.RHW.Enable then
-
 
8528
      begin
-
 
8529
        y_nRHW1 := y_nRHW1 + y_iRHW1;
-
 
8530
        y_nRHW2 := y_nRHW2 + y_iRHW2;
-
 
8531
      end;
7485
    end;
8532
    end;
7486
  end;
8533
  end;
7487
 
8534
 
7488
var
8535
var
7489
  p: array[0..2] of PDXR_Vertex;
8536
  p: array[0..2] of PDXR_Vertex;
7490
  tmp: Pointer;
8537
  tmp: Pointer;
7491
  y1, y2, y3, i: Integer;
8538
  y1, y2, y3, i: Integer;
7492
begin
8539
begin
7493
  {  Cull  }
8540
  {  Cull  }
7494
  case States.CullMode of
8541
  case States.CullMode of
7495
    DXR_CULL_NONE:
8542
    DXR_CULL_NONE:
7496
        begin
8543
        begin
7497
        end;
8544
        end;
7498
    DXR_CULL_CW:
8545
    DXR_CULL_CW:
7499
        begin
8546
        begin
7500
          if (Tri[1].sx-Tri[0].sx)*(Tri[2].sy-Tri[0].sy)-(Tri[1].sy-Tri[0].sy)*(Tri[2].sx-Tri[0].sx)>0 then Exit;
8547
          if (Tri[1].sx-Tri[0].sx)*(Tri[2].sy-Tri[0].sy)-(Tri[1].sy-Tri[0].sy)*(Tri[2].sx-Tri[0].sx)>0 then Exit;
7501
        end;
8548
        end;
7502
    DXR_CULL_CCW:
8549
    DXR_CULL_CCW:
7503
        begin
8550
        begin
7504
          if (Tri[1].sx-Tri[0].sx)*(Tri[2].sy-Tri[0].sy)-(Tri[1].sy-Tri[0].sy)*(Tri[2].sx-Tri[0].sx)<0 then Exit;
8551
          if (Tri[1].sx-Tri[0].sx)*(Tri[2].sy-Tri[0].sy)-(Tri[1].sy-Tri[0].sy)*(Tri[2].sx-Tri[0].sx)<0 then Exit;
7505
        end;
8552
        end;
7506
  end;
8553
  end;
7507
 
8554
 
7508
  Inc(RenderPrimitiveCount);
8555
  Inc(RenderPrimitiveCount);
7509
 
8556
 
7510
  { p[0]=Top vertex of Y axis }
8557
  { p[0]=Top vertex of Y axis }
7511
  { p[1]=Center vertex of Y axis }
8558
  { p[1]=Center vertex of Y axis }
7512
  { p[2]=Bottom vertex of Y axis }
8559
  { p[2]=Bottom vertex of Y axis }
7513
  p[0]:=Tri[0]; p[1]:=Tri[1]; p[2]:=Tri[2];
8560
  p[0]:=Tri[0]; p[1]:=Tri[1]; p[2]:=Tri[2];
7514
  if p[0].sy>p[1].sy then begin tmp:=p[0]; p[0]:=p[1]; p[1]:=tmp end;
8561
  if p[0].sy>p[1].sy then begin tmp:=p[0]; p[0]:=p[1]; p[1]:=tmp end;
7515
  if p[0].sy>p[2].sy then begin tmp:=p[0]; p[0]:=p[2]; p[2]:=tmp end;
8562
  if p[0].sy>p[2].sy then begin tmp:=p[0]; p[0]:=p[2]; p[2]:=tmp end;
7516
  if p[1].sy>p[2].sy then begin tmp:=p[1]; p[1]:=p[2]; p[2]:=tmp end;
8563
  if p[1].sy>p[2].sy then begin tmp:=p[1]; p[1]:=p[2]; p[2]:=tmp end;
7517
 
8564
 
7518
  if (p[2].sy<=p[0].sy) then Exit;
8565
  if (p[2].sy<=p[0].sy) then Exit;
7519
  if (p[2].sy<=0) or (p[0].sy>=Dest.Height) then Exit;
8566
  if (p[2].sy<=0) or (p[0].sy>=Dest.Height) then Exit;
7520
  if (p[0].sx<0) and (p[1].sx<0) and (p[2].sx<0) then Exit;
8567
  if (p[0].sx<0) and (p[1].sx<0) and (p[2].sx<0) then Exit;
7521
  if (p[0].sx>=Dest.Width) and (p[1].sx>=Dest.Width) and (p[2].sx>=Dest.Width) then Exit;
8568
  if (p[0].sx>=Dest.Width) and (p[1].sx>=Dest.Width) and (p[2].sx>=Dest.Width) then Exit;
7522
 
8569
 
7523
  {  Generate code  }
8570
  {  Generate code  }
-
 
8571
  if States.TextureFilter in [DXR_TEXTUREFILTER_MIPMAP_NEAREST, DXR_TEXTUREFILTER_MIPMAP_LINEAR] then
-
 
8572
    DXRMachine.Compiled := False;
-
 
8573
 
7524
  if not DXRMachine.Compiled then
8574
  if not DXRMachine.Compiled then
7525
    InitGenerator;
8575
    InitGenerator;
7526
 
8576
 
7527
  y1 := Trunc(p[1].sy)-Trunc(p[0].sy);
8577
  y1 := Trunc(p[1].sy)-Trunc(p[0].sy);
7528
  y2 := Trunc(p[2].sy)-Trunc(p[1].sy);
8578
  y2 := Trunc(p[2].sy)-Trunc(p[1].sy);
7529
  y3 := Trunc(p[2].sy)-Trunc(p[0].sy);
8579
  y3 := Trunc(p[2].sy)-Trunc(p[0].sy);
7530
 
8580
 
7531
  for i:=0 to DXRMachine.TextureIndexCount-1 do
8581
  for i:=0 to DXRMachine.TextureIndexCount-1 do
7532
    with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
8582
    with DXRMachine.TextureList[DXRMachine.TextureIndex[i]] do
7533
    begin
8583
    begin
7534
      case TextureAddress of
8584
      case TextureAddress of
7535
        DXR_TEXTUREADDRESS_TILE:
8585
        DXR_TEXTUREADDRESS_TILE:
7536
            begin
8586
            begin
7537
              TexXFloat[i] := Surface.Width2 * TextureAxisFloat;
8587
              TexXFloat[i] := Surface.Width2 * TextureAxisFloat;
7538
              TexYFloat[i] := Surface.Height2 * TextureAxisFloat;
8588
              TexYFloat[i] := Surface.Height2 * TextureAxisFloat;
7539
            end;
8589
            end;
7540
        DXR_TEXTUREADDRESS_DONOTCLIP:
8590
        DXR_TEXTUREADDRESS_DONOTCLIP:
7541
            begin
8591
            begin
7542
              TexXFloat[i] := (Surface.Width-1) * TextureAxisFloat;
8592
              TexXFloat[i] := (Surface.Width-1) * TextureAxisFloat;
7543
              TexYFloat[i] := (Surface.Height-1) * TextureAxisFloat;
8593
              TexYFloat[i] := (Surface.Height-1) * TextureAxisFloat;
7544
            end;
8594
            end;
7545
      end;
8595
      end;
7546
    end;
8596
    end;
7547
 
8597
 
7548
  with DXRMachine.ColorList[0] do
8598
  with DXRMachine.ColorList[0] do
7549
    if Enable and (not Gouraud) then
8599
    if Enable and (not Gouraud) then
7550
    begin
8600
    begin
7551
      nColor.R := RGBA_GETRED(Tri[0].color)*ColorFloat;
8601
      nColor.R := RGBA_GETRED(Tri[0].color)*ColorFloat;
7552
      nColor.G := RGBA_GETGREEN(Tri[0].color)*ColorFloat;
8602
      nColor.G := RGBA_GETGREEN(Tri[0].color)*ColorFloat;
7553
      nColor.B := RGBA_GETBLUE(Tri[0].color)*ColorFloat;
8603
      nColor.B := RGBA_GETBLUE(Tri[0].color)*ColorFloat;
7554
      nColor.A := RGBA_GETALPHA(Tri[0].color)*ColorFloat;
8604
      nColor.A := RGBA_GETALPHA(Tri[0].color)*ColorFloat;
7555
    end;
8605
    end;
7556
 
8606
 
7557
  with DXRMachine.ColorList[1] do
8607
  with DXRMachine.ColorList[1] do
7558
    if Enable and (not Gouraud) then
8608
    if Enable and (not Gouraud) then
7559
    begin
8609
    begin
7560
      nColor.R := RGBA_GETRED(Tri[0].specular)*ColorFloat;
8610
      nColor.R := RGBA_GETRED(Tri[0].specular)*ColorFloat;
7561
      nColor.G := RGBA_GETGREEN(Tri[0].specular)*ColorFloat;
8611
      nColor.G := RGBA_GETGREEN(Tri[0].specular)*ColorFloat;
7562
      nColor.B := RGBA_GETBLUE(Tri[0].specular)*ColorFloat;
8612
      nColor.B := RGBA_GETBLUE(Tri[0].specular)*ColorFloat;
7563
      nColor.A := RGBA_GETALPHA(Tri[0].specular)*ColorFloat;
8613
      nColor.A := RGBA_GETALPHA(Tri[0].specular)*ColorFloat;
7564
    end;
8614
    end;
7565
 
8615
 
7566
  { p[0] - p[1] }
8616
  { p[0] - p[1] }
7567
  draw(p[0], p[1], p[0], p[2], Trunc(p[0].sy), y1, y1, y3, 0, 0);
8617
  draw(p[0], p[1], p[0], p[2], Trunc(p[0].sy), y1, y1, y3, 0, 0);
7568
 
8618
 
7569
  { p[1] - p[2] }
8619
  { p[1] - p[2] }
7570
  draw(p[1], p[2], p[0], p[2], Trunc(p[1].sy), y2, y2, y3, 0, y1);
8620
  draw(p[1], p[2], p[0], p[2], Trunc(p[1].sy), y2, y2, y3, 0, y1);
7571
end;
8621
end;
7572
 
8622
 
7573
procedure dxrDrawPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
8623
procedure dxrDrawPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
7574
  VertexList: PDXR_Vertex; VertexCount: DWORD);
8624
  VertexList: PDXR_Vertex; VertexCount: DWORD);
7575
var
8625
var
7576
  i: Integer;
8626
  i: Integer;
7577
  Tri: TDXR_Triangle;
8627
  Tri: TDXR_Triangle;
7578
begin
8628
begin
7579
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
8629
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
7580
 
8630
 
7581
  DXRMachine.Compiled := False;
8631
  DXRMachine.Compiled := False;
7582
 
8632
 
7583
  case PrimitiveType of
8633
  case PrimitiveType of
7584
    DXR_PRIMITIVETYPE_TRIANGLELIST:
8634
    DXR_PRIMITIVETYPE_TRIANGLELIST:
7585
        begin
8635
        begin
7586
          for i:=0 to VertexCount div 3-1 do
8636
          for i:=0 to VertexCount div 3-1 do
7587
          begin
8637
          begin
7588
            Tri[0] := @PArrayDXR_Vertex(VertexList)[i*3];
8638
            Tri[0] := @PArrayDXR_Vertex(VertexList)[i*3];
7589
            Tri[1] := @PArrayDXR_Vertex(VertexList)[i*3+1];
8639
            Tri[1] := @PArrayDXR_Vertex(VertexList)[i*3+1];
7590
            Tri[2] := @PArrayDXR_Vertex(VertexList)[i*3+2];
8640
            Tri[2] := @PArrayDXR_Vertex(VertexList)[i*3+2];
7591
            dxrDrawTriangle(Dest, States, Tri);
8641
            dxrDrawTriangle(Dest, States, Tri);
7592
          end;
8642
          end;
7593
        end;
8643
        end;
7594
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
8644
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
7595
        begin
8645
        begin
7596
          for i:=2 to VertexCount-1 do
8646
          for i:=2 to VertexCount-1 do
7597
          begin
8647
          begin
7598
            Tri[0] := @PArrayDXR_Vertex(VertexList)[i-2];
8648
            Tri[0] := @PArrayDXR_Vertex(VertexList)[i-2];
7599
            Tri[1] := @PArrayDXR_Vertex(VertexList)[i-1];
8649
            Tri[1] := @PArrayDXR_Vertex(VertexList)[i-1];
7600
            Tri[2] := @PArrayDXR_Vertex(VertexList)[i];
8650
            Tri[2] := @PArrayDXR_Vertex(VertexList)[i];
7601
            dxrDrawTriangle(Dest, States, Tri);
8651
            dxrDrawTriangle(Dest, States, Tri);
7602
          end;
8652
          end;
7603
        end;
8653
        end;
7604
  end;
8654
  end;
7605
end;
8655
end;
7606
 
8656
 
7607
procedure dxrDrawPointeredPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
8657
procedure dxrDrawPointeredPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
7608
  VertexList: PPDXR_Vertex; VertexCount: DWORD);
8658
  VertexList: PPDXR_Vertex; VertexCount: DWORD);
7609
var
8659
var
7610
  i: Integer;
8660
  i: Integer;
7611
  Tri: TDXR_Triangle;
8661
  Tri: TDXR_Triangle;
7612
begin
8662
begin
7613
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
8663
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
7614
 
8664
 
7615
  DXRMachine.Compiled := False;
8665
  DXRMachine.Compiled := False;
7616
 
8666
 
7617
  case PrimitiveType of
8667
  case PrimitiveType of
7618
    DXR_PRIMITIVETYPE_TRIANGLELIST:
8668
    DXR_PRIMITIVETYPE_TRIANGLELIST:
7619
        begin
8669
        begin
7620
          for i:=0 to VertexCount div 3-1 do
8670
          for i:=0 to VertexCount div 3-1 do
7621
          begin
8671
          begin
7622
            Tri[0] := PArrayPDXR_Vertex(VertexList)[i*3];
8672
            Tri[0] := PArrayPDXR_Vertex(VertexList)[i*3];
7623
            Tri[1] := PArrayPDXR_Vertex(VertexList)[i*3+1];
8673
            Tri[1] := PArrayPDXR_Vertex(VertexList)[i*3+1];
7624
            Tri[2] := PArrayPDXR_Vertex(VertexList)[i*3+2];
8674
            Tri[2] := PArrayPDXR_Vertex(VertexList)[i*3+2];
7625
            dxrDrawTriangle(Dest, States, Tri);
8675
            dxrDrawTriangle(Dest, States, Tri);
7626
          end;
8676
          end;
7627
        end;
8677
        end;
7628
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
8678
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
7629
        begin
8679
        begin
7630
          for i:=2 to VertexCount-1 do
8680
          for i:=2 to VertexCount-1 do
7631
          begin
8681
          begin
7632
            Tri[0] := PArrayPDXR_Vertex(VertexList)[i-2];
8682
            Tri[0] := PArrayPDXR_Vertex(VertexList)[i-2];
7633
            Tri[1] := PArrayPDXR_Vertex(VertexList)[i-1];
8683
            Tri[1] := PArrayPDXR_Vertex(VertexList)[i-1];
7634
            Tri[2] := PArrayPDXR_Vertex(VertexList)[i];
8684
            Tri[2] := PArrayPDXR_Vertex(VertexList)[i];
7635
            dxrDrawTriangle(Dest, States, Tri);
8685
            dxrDrawTriangle(Dest, States, Tri);
7636
          end;
8686
          end;
7637
        end;
8687
        end;
7638
  end;
8688
  end;
7639
end;
8689
end;
7640
 
8690
 
7641
procedure dxrDrawIndexedPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
8691
procedure dxrDrawIndexedPrimitive(const Dest: TDXR_Surface; const States: TDXR_RenderStates; PrimitiveType: TDXR_PrimitiveType;
7642
  VertexList: PDXR_Vertex; VertexCount: DWORD; IndexList: PDWORD; IndexCount: DWORD);
8692
  VertexList: PDXR_Vertex; VertexCount: DWORD; IndexList: PDWORD; IndexCount: DWORD);
7643
var
8693
var
7644
  i: Integer;
8694
  i: Integer;
7645
  Tri: TDXR_Triangle;
8695
  Tri: TDXR_Triangle;
7646
begin
8696
begin
7647
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
8697
  if not (PrimitiveType in [DXR_PRIMITIVETYPE_TRIANGLELIST, DXR_PRIMITIVETYPE_TRIANGLESTRIP]) then Exit;
7648
 
8698
 
7649
  DXRMachine.Compiled := False;
8699
  DXRMachine.Compiled := False;
7650
 
8700
 
7651
  case PrimitiveType of
8701
  case PrimitiveType of
7652
    DXR_PRIMITIVETYPE_TRIANGLELIST:
8702
    DXR_PRIMITIVETYPE_TRIANGLELIST:
7653
        begin
8703
        begin
7654
          for i:=0 to IndexCount div 3-1 do
8704
          for i:=0 to IndexCount div 3-1 do
7655
          begin
8705
          begin
7656
            Tri[0] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3]];
8706
            Tri[0] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3]];
7657
            Tri[1] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3+1]];
8707
            Tri[1] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3+1]];
7658
            Tri[2] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3+2]];
8708
            Tri[2] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i*3+2]];
7659
            dxrDrawTriangle(Dest, States, Tri);
8709
            dxrDrawTriangle(Dest, States, Tri);
7660
          end;
8710
          end;
7661
        end;
8711
        end;
7662
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
8712
    DXR_PRIMITIVETYPE_TRIANGLESTRIP:
7663
        begin
8713
        begin
7664
          for i:=2 to IndexCount-1 do
8714
          for i:=2 to IndexCount-1 do
7665
          begin
8715
          begin
7666
            Tri[0] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i-2]];
8716
            Tri[0] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i-2]];
7667
            Tri[1] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i-1]];
8717
            Tri[1] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i-1]];
7668
            Tri[2] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i]];
8718
            Tri[2] := @PArrayDXR_Vertex(VertexList)[PArrayDWORD(IndexList)[i]];
7669
            dxrDrawTriangle(Dest, States, Tri);
8719
            dxrDrawTriangle(Dest, States, Tri);
7670
          end;
8720
          end;
7671
        end;
8721
        end;
7672
  end;
8722
  end;
7673
end;
8723
end;
7674
 
8724
 
7675
function MulDiv64(a, b, c: Integer): Integer; assembler;
8725
function MulDiv64(a, b, c: Integer): Integer; assembler;
7676
asm
8726
asm
7677
  mov eax, a
8727
  mov eax, a
7678
  imul b
8728
  imul b
7679
  idiv c
8729
  idiv c
7680
end;
8730
end;
7681
 
8731
 
7682
function Max(B1, B2: Integer): Integer;
8732
function Max(B1, B2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
7683
begin
8733
begin
7684
  if B1>=B2 then Result := B1 else Result := B2;
8734
  if B1>=B2 then Result := B1 else Result := B2;
7685
end;
8735
end;
7686
 
8736
 
7687
function Min(B1, B2: Integer): Integer;
8737
function Min(B1, B2: Integer): Integer; {$IFDEF VER9UP}inline;{$ENDIF}
7688
begin
8738
begin
7689
  if B1<=B2 then Result := B1 else Result := B2;
8739
  if B1<=B2 then Result := B1 else Result := B2;
7690
end;
8740
end;
7691
 
8741
 
7692
function BltClipX(const Dest, Src: TDXR_Surface;
8742
function BltClipX(const Dest, Src: TDXR_Surface;
7693
  var StartX, EndX, StartSrcX: Integer): Boolean;
8743
  var StartX, EndX, StartSrcX: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
7694
begin
8744
begin
7695
  if StartX<0 then
8745
  if StartX<0 then
7696
  begin
8746
  begin
7697
    StartSrcX := StartSrcX-StartX;
8747
    StartSrcX := StartSrcX-StartX;
7698
    StartX := 0;
8748
    StartX := 0;
7699
  end;
8749
  end;
7700
 
8750
 
7701
  EndX := Min(EndX, Dest.Width);
8751
  EndX := Min(EndX, Dest.Width);
7702
 
8752
 
7703
  Result := (EndX>0) and (EndX-StartX>0);
8753
  Result := (EndX>0) and (EndX-StartX>0);
7704
end;
8754
end;
7705
 
8755
 
7706
function BltClipY(const Dest, Src: TDXR_Surface;
8756
function BltClipY(const Dest, Src: TDXR_Surface;
7707
  var StartY, EndY, StartSrcY: Integer): Boolean;
8757
  var StartY, EndY, StartSrcY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
7708
begin
8758
begin
7709
  if StartY<0 then
8759
  if StartY<0 then
7710
  begin
8760
  begin
7711
    StartSrcY := StartSrcY-StartY;
8761
    StartSrcY := StartSrcY-StartY;
7712
    StartY := 0;
8762
    StartY := 0;
7713
  end;
8763
  end;
7714
 
8764
 
7715
  EndY := Min(EndY, Dest.Height);
8765
  EndY := Min(EndY, Dest.Height);
7716
 
8766
 
7717
  Result := (EndY>0) and (EndY-StartY>0);
8767
  Result := (EndY>0) and (EndY-StartY>0);
7718
end;
8768
end;
7719
 
8769
 
7720
function BltClip(const Dest, Src: TDXR_Surface;
8770
function BltClip(const Dest, Src: TDXR_Surface;
7721
  var StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer): Boolean;
8771
  var StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
7722
begin
8772
begin
7723
  Result := BltClipX(Dest, Src, StartX, EndX, StartSrcX) and
8773
  Result := BltClipX(Dest, Src, StartX, EndX, StartSrcX) and
7724
    BltClipY(Dest, Src, StartY, EndY, StartSrcY);
8774
    BltClipY(Dest, Src, StartY, EndY, StartSrcY);
7725
end;
8775
end;
7726
 
8776
 
7727
function FillClip(const Dest: TDXR_Surface;
8777
function FillClip(const Dest: TDXR_Surface;
7728
  var StartX, StartY, EndX, EndY: Integer): Boolean;
8778
  var StartX, StartY, EndX, EndY: Integer): Boolean; {$IFDEF VER9UP}inline;{$ENDIF}
7729
begin
8779
begin
7730
  StartX := Max(StartX, 0);
8780
  StartX := Max(StartX, 0);
7731
  StartY := Max(StartY, 0);
8781
  StartY := Max(StartY, 0);
7732
  EndX := Min(EndX, Dest.Width);
8782
  EndX := Min(EndX, Dest.Width);
7733
  EndY := Min(EndY, Dest.Height);
8783
  EndY := Min(EndY, Dest.Height);
7734
 
8784
 
7735
  Result := (StartX<EndX) and (StartY<EndY);
8785
  Result := (StartX<EndX) and (StartY<EndY);
7736
end;
8786
end;
7737
 
8787
 
7738
var
8788
var
7739
  CosinTable: array[0..255] of Double;
8789
  CosinTable: array[0..255] of Double;
7740
 
8790
 
7741
procedure InitCosinTable;
8791
procedure InitCosinTable; {$IFDEF VER9UP}inline;{$ENDIF}
7742
var
8792
var
7743
  i: Integer;
8793
  i: Integer;
7744
begin
8794
begin
7745
  for i:=Low(CosinTable) to High(CosinTable) do
8795
  for i:=Low(CosinTable) to High(CosinTable) do
7746
    CosinTable[i] := Cos((i/256)*2*PI);
8796
    CosinTable[i] := Cos((i/256)*2*PI);
7747
end;
8797
end;
7748
 
8798
 
7749
function Cos256(i: Integer): Double;
8799
function Cos256(i: Integer): Double; {$IFDEF VER9UP}inline;{$ENDIF}
7750
begin
8800
begin
7751
  Result := CosinTable[i and 255];
8801
  Result := CosinTable[i and 255];
7752
end;
8802
end;
7753
 
8803
 
7754
function Sin256(i: Integer): Double;
8804
function Sin256(i: Integer): Double; {$IFDEF VER9UP}inline;{$ENDIF}
7755
begin
8805
begin
7756
  Result := CosinTable[(i+192) and 255];
8806
  Result := CosinTable[(i+192) and 255];
7757
end;
8807
end;
7758
 
8808
 
7759
function RotationClip(const Dest, Src: TDXR_Surface;
8809
function RotationClip(const Dest, Src: TDXR_Surface;
7760
  X, Y, Width, Height: Integer; CenterX, CenterY: Double; Angle: Integer;
8810
  X, Y, Width, Height: Integer; CenterX, CenterY: Double; Angle: Integer;
7761
  var StartX, StartY, EndX, EndY: Integer): Boolean;
8811
  var StartX, StartY, EndX, EndY: Integer): Boolean;
7762
 
8812
 
7763
  function RotatePoint(ax, ay: Integer): TPoint;
8813
  function RotatePoint(ax, ay: Integer): TPoint;
7764
  var
8814
  var
7765
    c, s: Double;
8815
    c, s: Double;
7766
  begin
8816
  begin
7767
    ax := Trunc(ax - Width*CenterX);
8817
    ax := Trunc(ax - Width*CenterX);
7768
    ay := Trunc(ay - Height*CenterY);
8818
    ay := Trunc(ay - Height*CenterY);
7769
    c := Cos256(Angle);
8819
    c := Cos256(Angle);
7770
    s := Sin256(Angle);
8820
    s := Sin256(Angle);
7771
    Result.X := X+Trunc(ax * c - ay * s);
8821
    Result.X := X+Trunc(ax * c - ay * s);
7772
    Result.Y := Y+Trunc(ax * s + ay * c);
8822
    Result.Y := Y+Trunc(ax * s + ay * c);
7773
  end;
8823
  end;
7774
                     
8824
                     
7775
var
8825
var
7776
  i: Integer;
8826
  i: Integer;
7777
  Points: array[0..3] of TPoint;
8827
  Points: array[0..3] of TPoint;
7778
begin                      
8828
begin                      
7779
  Points[0] := RotatePoint(0, 0);
8829
  Points[0] := RotatePoint(0, 0);
7780
  Points[1] := RotatePoint(Width, 0);
8830
  Points[1] := RotatePoint(Width, 0);
7781
  Points[2] := RotatePoint(0, Height);
8831
  Points[2] := RotatePoint(0, Height);
7782
  Points[3] := RotatePoint(Width, Height);
8832
  Points[3] := RotatePoint(Width, Height);
7783
 
8833
 
7784
  StartX := Points[0].X;
8834
  StartX := Points[0].X;
7785
  StartY := Points[0].Y;
8835
  StartY := Points[0].Y;
7786
  EndX := StartX;
8836
  EndX := StartX;
7787
  EndY := StartY;
8837
  EndY := StartY;
7788
 
8838
 
7789
  for i:=1 to 3 do
8839
  for i:=1 to 3 do
7790
    with Points[i] do
8840
    with Points[i] do
7791
    begin
8841
    begin
7792
      StartX := Min(StartX, X);
8842
      StartX := Min(StartX, X);
7793
      StartY := Min(StartY, Y);
8843
      StartY := Min(StartY, Y);
7794
      EndX := Max(EndX, X);
8844
      EndX := Max(EndX, X);
7795
      EndY := Max(EndY, Y);
8845
      EndY := Max(EndY, Y);
7796
    end;
8846
    end;
7797
 
8847
 
7798
  StartX := Max(StartX, 0);
8848
  StartX := Max(StartX, 0);
7799
  StartY := Max(StartY, 0);
8849
  StartY := Max(StartY, 0);
7800
  EndX := Min(EndX, Dest.Width);
8850
  EndX := Min(EndX, Dest.Width);
7801
  EndY := Min(EndY, Dest.Height);
8851
  EndY := Min(EndY, Dest.Height);
7802
 
8852
 
7803
  Result := (StartX<=Integer(Dest.Width)) and (EndX>0) and (EndX-StartX>0) and
8853
  Result := (StartX<=Integer(Dest.Width)) and (EndX>0) and (EndX-StartX>0) and
7804
    (StartY<=Integer(Dest.Height)) and (EndY>0) and (EndY-StartY>0);
8854
    (StartY<=Integer(Dest.Height)) and (EndY>0) and (EndY-StartY>0);
7805
end;
8855
end;
7806
 
8856
 
7807
procedure CopyXLineInitialize(const Dest, Src: TDXR_Surface;
8857
procedure CopyXLineInitialize(const Dest, Src: TDXR_Surface;
7808
  const Blend: TDXR_Blend; Alpha: Integer;
8858
  const Blend: TDXR_Blend; Alpha: Integer;
7809
  IncX, IncY: Integer;
8859
  IncX, IncY: Integer;
7810
  ColorKeyEnable: Boolean; ColorKey: DWORD);
8860
  ColorKeyEnable: Boolean; ColorKey: DWORD);
7811
var
8861
var
7812
  Tree: PDXRMachine_Tree;
8862
  Tree: PDXRMachine_Tree;
7813
begin
8863
begin
7814
  DXRMachine.Initialize;
8864
  DXRMachine.Initialize;
7815
 
8865
 
7816
  {  Parameter setting  }
8866
  {  Parameter setting  }
7817
  DXRMachine.Dest := @Dest;
8867
  DXRMachine.Dest := @Dest;
7818
  DXRMachine.TextureList[0].ColorKeyEnable := ColorKeyEnable;
8868
  DXRMachine.TextureList[0].ColorKeyEnable := ColorKeyEnable;
7819
  DXRMachine.TextureList[0].ColorKey := ColorKey;
8869
  DXRMachine.TextureList[0].ColorKey := ColorKey;
7820
  DXRMachine.TextureList[0].Surface := @Src;
8870
  DXRMachine.TextureList[0].Surface := @Src;
7821
  DXRMachine.TextureList[0].TextureAddress := DXR_TEXTUREADDRESS_DONOTCLIP;
8871
  DXRMachine.TextureList[0].TextureAddress := DXR_TEXTUREADDRESS_DONOTCLIP;
7822
  DXRMachine.TextureList[0].iAxis.X := IncX;
8872
  DXRMachine.TextureList[0].iAxis.X := IncX;
7823
  DXRMachine.TextureList[0].iAxis.Y := IncY;
8873
  DXRMachine.TextureList[0].iAxis.Y := IncY;
7824
  DXRMachine.TextureList[0].iAxisConstant := True;
8874
  DXRMachine.TextureList[0].iAxisConstant := True;
7825
  DXRMachine.TextureList[0].DefaultColor.R := Alpha*ColorFloat;
8875
  DXRMachine.TextureList[0].DefaultColor.R := Alpha*ColorFloat;
7826
  DXRMachine.TextureList[0].DefaultColor.G := Alpha*ColorFloat;
8876
  DXRMachine.TextureList[0].DefaultColor.G := Alpha*ColorFloat;
7827
  DXRMachine.TextureList[0].DefaultColor.B := Alpha*ColorFloat;
8877
  DXRMachine.TextureList[0].DefaultColor.B := Alpha*ColorFloat;
7828
  DXRMachine.TextureList[0].DefaultColor.A := Alpha*ColorFloat;
8878
  DXRMachine.TextureList[0].DefaultColor.A := Alpha*ColorFloat;
7829
 
8879
 
7830
  {  Tree making  }
8880
  {  Tree making  }
7831
  Tree := DXRMachine.CreateTree_Blend(Blend, DXRMachine.CreateTree_LoadTexture(0), DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
8881
  Tree := DXRMachine.CreateTree_Blend(Blend, DXRMachine.CreateTree_LoadTexture(0), DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
7832
 
8882
 
7833
  DXRMachine.Compile(Tree);
8883
  DXRMachine.Compile(Tree);
7834
end;
8884
end;
7835
 
8885
 
7836
procedure dxrCopyRectBlend(const Dest, Src: TDXR_Surface;
8886
procedure dxrCopyRectBlend(const Dest, Src: TDXR_Surface;
7837
  const DestRect, SrcRect: TRect; Blend: TDXR_Blend; Alpha: Integer;
8887
  const DestRect, SrcRect: TRect; Blend: TDXR_Blend; Alpha: Integer;
7838
  ColorKeyEnable: Boolean; ColorKey: DWORD);
8888
  ColorKeyEnable: Boolean; ColorKey: DWORD);
7839
var
8889
var
7840
  StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer;
8890
  StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer;
7841
  dy, sx, sy: Integer;
8891
  dy, sx, sy: Integer;
7842
  IncX, IncY: Integer;
8892
  IncX, IncY: Integer;
7843
begin
8893
begin
7844
  {  Clipping  }
8894
  {  Clipping  }
7845
  if (DestRect.Left>=DestRect.Right) or (DestRect.Top>=DestRect.Bottom) then Exit;
8895
  if (DestRect.Left>=DestRect.Right) or (DestRect.Top>=DestRect.Bottom) then Exit;
7846
 
8896
 
7847
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
8897
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
7848
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
8898
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
7849
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
8899
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
7850
 
8900
 
7851
  StartX := DestRect.Left;
8901
  StartX := DestRect.Left;
7852
  StartY := DestRect.Top;
8902
  StartY := DestRect.Top;
7853
  EndX := DestRect.Right;
8903
  EndX := DestRect.Right;
7854
  EndY := DestRect.Bottom;
8904
  EndY := DestRect.Bottom;
7855
  StartSrcX := 0;
8905
  StartSrcX := 0;
7856
  StartSrcY := 0;
8906
  StartSrcY := 0;
7857
  if not BltClip(Dest, Src, StartX, StartY, EndX, EndY, StartSrcX, StartSrcY) then Exit;
8907
  if not BltClip(Dest, Src, StartX, StartY, EndX, EndY, StartSrcX, StartSrcY) then Exit;
7858
 
8908
 
7859
  IncX := MulDiv64(SrcRect.Right-SrcRect.Left, TextureAxisFloat, DestRect.Right-DestRect.Left);
8909
  IncX := MulDiv64(SrcRect.Right-SrcRect.Left, TextureAxisFloat, DestRect.Right-DestRect.Left);
7860
  IncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, TextureAxisFloat, DestRect.Bottom-DestRect.Top);
8910
  IncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, TextureAxisFloat, DestRect.Bottom-DestRect.Top);
7861
 
8911
                                                       
7862
  sx := StartSrcX * IncX + SrcRect.Left*TextureAxisFloat;
8912
  sx := StartSrcX * IncX + SrcRect.Left*TextureAxisFloat;
7863
  sy := StartSrcY * IncY + SrcRect.Top*TextureAxisFloat;
8913
  sy := StartSrcY * IncY + SrcRect.Top*TextureAxisFloat;
7864
 
8914
 
7865
  if (sx<0) or (sy<0) or ((sx+(EndX-StartX)*IncX) shr 16>Integer(Src.Width)) or
8915
  if (sx<0) or (sy<0) or ((sx+(EndX-StartX)*IncX) shr 16>Integer(Src.Width)) or
7866
    ((sy+(EndY-StartY)*IncY) shr 16>Integer(Src.Height)) then Exit;
8916
    ((sy+(EndY-StartY)*IncY) shr 16>Integer(Src.Height)) then Exit;
7867
 
8917
 
7868
  {  Compile  }
8918
  {  Compile  }
7869
  CopyXLineInitialize(Dest, Src, Blend, Alpha, IncX, 0, ColorKeyEnable, ColorKey);
8919
  CopyXLineInitialize(Dest, Src, Blend, Alpha, IncX, 0, ColorKeyEnable, ColorKey);
7870
 
8920
 
7871
  {  Run  }
8921
  {  Run  }
7872
  for dy:=StartY to EndY-1 do
8922
  for dy:=StartY to EndY-1 do
7873
  begin
8923
  begin
7874
    DXRMachine.Axis.Axis.X := StartX;
8924
    DXRMachine.Axis.Axis.X := StartX;
7875
    DXRMachine.Axis.Axis.Y := dy;
8925
    DXRMachine.Axis.Axis.Y := dy;
7876
    DXRMachine.TextureList[0].nAxis.X := sx;
8926
    DXRMachine.TextureList[0].nAxis.X := sx;
7877
    DXRMachine.TextureList[0].nAxis.Y := sy;
8927
    DXRMachine.TextureList[0].nAxis.Y := sy;
7878
    DXRMachine.Run(EndX-StartX);
8928
    DXRMachine.Run(EndX-StartX);
7879
    Inc(sy, IncY);
8929
    Inc(sy, IncY);
7880
  end;
8930
  end;
7881
end;
8931
end;
7882
 
8932
 
7883
procedure dxrFillRectColorBlend(const Dest: TDXR_Surface;
8933
procedure dxrFillRectColorBlend(const Dest: TDXR_Surface;
7884
  const DestRect: TRect; Blend: TDXR_Blend; Col: COLORREF);
8934
  const DestRect: TRect; Blend: TDXR_Blend; Col: COLORREF);
7885
var
8935
var
7886
  dy, StartX, StartY, EndX, EndY: Integer;
8936
  dy, StartX, StartY, EndX, EndY: Integer;
7887
  Tree: PDXRMachine_Tree;
8937
  Tree: PDXRMachine_Tree;
7888
begin
8938
begin
7889
  {  Clipping  }
8939
  {  Clipping  }
7890
  if (DestRect.Left>=DestRect.Right) or (DestRect.Top>=DestRect.Bottom) then Exit;
8940
  if (DestRect.Left>=DestRect.Right) or (DestRect.Top>=DestRect.Bottom) then Exit;
7891
 
8941
 
7892
  StartX := DestRect.Left;
8942
  StartX := DestRect.Left;
7893
  StartY := DestRect.Top;
8943
  StartY := DestRect.Top;
7894
  EndX := DestRect.Right;
8944
  EndX := DestRect.Right;
7895
  EndY := DestRect.Bottom;
8945
  EndY := DestRect.Bottom;
7896
  if not FillClip(Dest, StartX, StartY, EndX, EndY) then Exit;
8946
  if not FillClip(Dest, StartX, StartY, EndX, EndY) then Exit;
7897
 
8947
 
7898
  {  Compile  }
8948
  {  Compile  }
7899
  DXRMachine.Initialize;
8949
  DXRMachine.Initialize;
7900
  DXRMachine.Dest := @Dest;
8950
  DXRMachine.Dest := @Dest;
7901
  Tree := DXRMachine.CreateTree_Blend(Blend,
8951
  Tree := DXRMachine.CreateTree_Blend(Blend,
7902
    DXRMachine.CreateTree_LoadConstColor(Byte(Col), Byte(Col shr 8), Byte(Col shr 16), Byte(Col shr 24)),
8952
    DXRMachine.CreateTree_LoadConstColor(Byte(Col), Byte(Col shr 8), Byte(Col shr 16), Byte(Col shr 24)),
7903
    DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
8953
    DXRMachine.CreateTree2(DXR_TREETYPE_LOADDESTPIXEL));
7904
  DXRMachine.Compile(Tree);    
8954
  DXRMachine.Compile(Tree);    
7905
   
8955
   
7906
  {  Run  }
8956
  {  Run  }
7907
  for dy:=StartY to EndY-1 do
8957
  for dy:=StartY to EndY-1 do
7908
  begin
8958
  begin
7909
    DXRMachine.Axis.Axis.X := StartX;
8959
    DXRMachine.Axis.Axis.X := StartX;
7910
    DXRMachine.Axis.Axis.Y := dy;
8960
    DXRMachine.Axis.Axis.Y := dy;
7911
    DXRMachine.Run(EndX-StartX);
8961
    DXRMachine.Run(EndX-StartX);
7912
  end;
8962
  end;
7913
end;
8963
end;
7914
 
8964
 
7915
procedure dxrDrawWaveXBlend(const Dest, Src: TDXR_Surface;
8965
procedure dxrDrawWaveXBlend(const Dest, Src: TDXR_Surface;
7916
  X, Y, Width, Height: Integer; const SrcRect: TRect; amp, Len, ph: Integer;
8966
  X, Y, Width, Height: Integer; const SrcRect: TRect; amp, Len, ph: Integer;
7917
  Blend: TDXR_Blend; Alpha: Integer;
8967
  Blend: TDXR_Blend; Alpha: Integer;
7918
  ColorKeyEnable: Boolean; ColorKey: DWORD);
8968
  ColorKeyEnable: Boolean; ColorKey: DWORD);
7919
var
8969
var
7920
  StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer;
8970
  StartX, StartY, EndX, EndY, StartSrcX, StartSrcY: Integer;
7921
  sx, sy: Integer;
8971
  sx, sy: Integer;
7922
  dy, IncX, IncY, i, IncPh: Integer;
8972
  dy, IncX, IncY, i, IncPh: Integer;
7923
begin
8973
begin
7924
  {  Clipping  }
8974
  {  Clipping  }
7925
  if (Width=0) or (Height=0) then Exit;
8975
  if (Width=0) or (Height=0) then Exit;
7926
 
8976
 
7927
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
8977
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
7928
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
8978
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
7929
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
8979
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
7930
 
8980
 
7931
  StartY := Y;
8981
  StartY := Y;
7932
  EndY := Y+Height;
8982
  EndY := Y+Height;
7933
  StartSrcY := 0;
8983
  StartSrcY := 0;
7934
  if not BltClipY(Dest, Src, StartY, EndY, StartSrcY) then Exit;
8984
  if not BltClipY(Dest, Src, StartY, EndY, StartSrcY) then Exit;
7935
 
8985
 
7936
  IncX := MulDiv64(SrcRect.Right-SrcRect.Left, TextureAxisFloat, Width);
8986
  IncX := MulDiv64(SrcRect.Right-SrcRect.Left, TextureAxisFloat, Width);
7937
  IncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, TextureAxisFloat, Height);
8987
  IncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, TextureAxisFloat, Height);
7938
 
8988
 
7939
  if Len=0 then
8989
  if Len=0 then
7940
  begin
8990
  begin
7941
    IncPh := 0;
8991
    IncPh := 0;
7942
  end else
8992
  end else
7943
    IncPh := MulDiv64(256, 65536, Len);
8993
    IncPh := MulDiv64(256, 65536, Len);
7944
  i := ph*65536+StartSrcY*IncPh;
8994
  i := ph*65536+StartSrcY*IncPh;
7945
             
8995
             
7946
  sy := StartSrcY * IncY + SrcRect.Top*TextureAxisFloat;
8996
  sy := StartSrcY * IncY + SrcRect.Top*TextureAxisFloat;
7947
 
8997
 
7948
  if ((sy+(EndY-StartY)*IncY) shr 16>Integer(Src.Height)) then Exit;
8998
  if ((sy+(EndY-StartY)*IncY) shr 16>Integer(Src.Height)) then Exit;
7949
 
8999
 
7950
  {  Compile  }
9000
  {  Compile  }
7951
  CopyXLineInitialize(Dest, Src, Blend, Alpha, IncX, 0, ColorKeyEnable, ColorKey);
9001
  CopyXLineInitialize(Dest, Src, Blend, Alpha, IncX, 0, ColorKeyEnable, ColorKey);
7952
 
9002
 
7953
  {  Run  }
9003
  {  Run  }
7954
  for dy:=StartY to EndY-1 do
9004
  for dy:=StartY to EndY-1 do
7955
  begin
9005
  begin
7956
    {  X clipping  }
9006
    {  X clipping  }
7957
    StartX := X+Round(Sin256(i div 65536)*amp);
9007
    StartX := X+Round(Sin256(i div 65536)*amp);
7958
    EndX := StartX+Width;
9008
    EndX := StartX+Width;
7959
    StartSrcX := 0;
9009
    StartSrcX := 0;
7960
 
9010
 
7961
    if BltClipX(Dest, Src, StartX, EndX, StartSrcX) then
9011
    if BltClipX(Dest, Src, StartX, EndX, StartSrcX) then
7962
    begin
9012
    begin
7963
      sx := StartSrcX * IncX + SrcRect.Left*TextureAxisFloat;
9013
      sx := StartSrcX * IncX + SrcRect.Left*TextureAxisFloat;
7964
      if (sx<0) or (sy<0) or ((sx+(EndX-StartX)*IncX) shr 16>Integer(Src.Width)) then Exit;
9014
      if (sx<0) or (sy<0) or ((sx+(EndX-StartX)*IncX) shr 16>Integer(Src.Width)) then Exit;
7965
      DXRMachine.Axis.Axis.X := StartX;
9015
      DXRMachine.Axis.Axis.X := StartX;
7966
      DXRMachine.Axis.Axis.Y := dy;
9016
      DXRMachine.Axis.Axis.Y := dy;
7967
      DXRMachine.TextureList[0].nAxis.X := sx;
9017
      DXRMachine.TextureList[0].nAxis.X := sx;
7968
      DXRMachine.TextureList[0].nAxis.Y := sy;
9018
      DXRMachine.TextureList[0].nAxis.Y := sy;
7969
      DXRMachine.Run(EndX-StartX);
9019
      DXRMachine.Run(EndX-StartX);
7970
    end;
9020
    end;
7971
 
9021
 
7972
    Inc(i, IncPh);
9022
    Inc(i, IncPh);
7973
    Inc(sy, IncY);
9023
    Inc(sy, IncY);
7974
  end;
9024
  end;
7975
end;
9025
end;
7976
 
9026
 
7977
procedure dxrDrawRotateBlend(const Dest, Src: TDXR_Surface;
9027
procedure dxrDrawRotateBlend(const Dest, Src: TDXR_Surface;
7978
  X, Y, Width, Height: Integer; const SrcRect: TRect; CenterX, CenterY: Double;
9028
  X, Y, Width, Height: Integer; const SrcRect: TRect; CenterX, CenterY: Double;
7979
  Angle: Integer; Blend: TDXR_Blend; Alpha: Integer;
9029
  Angle: Integer; Blend: TDXR_Blend; Alpha: Integer;
7980
  ColorKeyEnable: Boolean; ColorKey: DWORD);
9030
  ColorKeyEnable: Boolean; ColorKey: DWORD);
7981
var
9031
var
7982
  StartX, EndX, StartY, EndY: Integer;
9032
  StartX, EndX, StartY, EndY: Integer;
7983
  dy, sx, sy: Integer;
9033
  dy, sx, sy: Integer;
7984
  c, s, xIncX, xIncY, yIncX, yIncY: Integer;
9034
  c, s, xIncX, xIncY, yIncX, yIncY: Integer;
7985
  pSkip, pCount: Integer;
9035
  pSkip, pCount: Integer;
7986
  gStartX, gStartY: Integer;
9036
  gStartX, gStartY: Integer;
7987
begin
9037
begin
7988
  {  Clipping  }
9038
  {  Clipping  }
7989
  if (Width=0) or (Height=0) then Exit;
9039
  if (Width=0) or (Height=0) then Exit;
7990
 
9040
 
7991
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
9041
  if (SrcRect.Left<0) or (SrcRect.Top<0) or
7992
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
9042
    (SrcRect.Right>Integer(Src.Width)) or (SrcRect.Bottom>Integer(Src.Height)) or
7993
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
9043
    (SrcRect.Left>=SrcRect.Right) or (SrcRect.Top>=SrcRect.Bottom) then Exit;
7994
 
9044
 
7995
  if not RotationClip(Dest, Src, X, Y, Width, Height, CenterX, CenterY, Angle,
9045
  if not RotationClip(Dest, Src, X, Y, Width, Height, CenterX, CenterY, Angle,
7996
    StartX, StartY, EndX, EndY) then Exit;
9046
    StartX, StartY, EndX, EndY) then Exit;
7997
 
9047
 
7998
  c := Trunc(Cos256(-Angle)*TextureAxisFloat);
9048
  c := Trunc(Cos256(-Angle)*TextureAxisFloat);
7999
  s := Trunc(Sin256(-Angle)*TextureAxisFloat);
9049
  s := Trunc(Sin256(-Angle)*TextureAxisFloat);
8000
 
9050
 
8001
  xIncX := MulDiv64(SrcRect.Right-SrcRect.Left, c, Width);
9051
  xIncX := MulDiv64(SrcRect.Right-SrcRect.Left, c, Width);
8002
  xIncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, s, Height);
9052
  xIncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, s, Height);
8003
 
9053
 
8004
  yIncX := MulDiv64(SrcRect.Right-SrcRect.Left, s, Width);
9054
  yIncX := MulDiv64(SrcRect.Right-SrcRect.Left, s, Width);
8005
  yIncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, c, Height);
9055
  yIncY := MulDiv64(SrcRect.Bottom-SrcRect.Top, c, Height);
8006
 
9056
 
8007
  sx := (-X+StartX) * xIncX + (Y-StartY) * yIncX + Trunc((SrcRect.Right-SrcRect.Left)*CenterX*TextureAxisFloat) + SrcRect.Left*TextureAxisFloat;
9057
  sx := (-X+StartX) * xIncX + (Y-StartY) * yIncX + Trunc((SrcRect.Right-SrcRect.Left)*CenterX*TextureAxisFloat) + SrcRect.Left*TextureAxisFloat;
8008
  sy := (-X+StartX) * xIncY - (Y-StartY) * yIncY + Trunc((SrcRect.Bottom-SrcRect.Top)*CenterY*TextureAxisFloat) + SrcRect.Top*TextureAxisFloat;
9058
  sy := (-X+StartX) * xIncY - (Y-StartY) * yIncY + Trunc((SrcRect.Bottom-SrcRect.Top)*CenterY*TextureAxisFloat) + SrcRect.Top*TextureAxisFloat;
8009
 
9059
 
8010
  {  Compile  }
9060
  {  Compile  }
8011
  CopyXLineInitialize(Dest, Src, Blend, Alpha, xIncX, xIncY, ColorKeyEnable, ColorKey);
9061
  CopyXLineInitialize(Dest, Src, Blend, Alpha, xIncX, xIncY, ColorKeyEnable, ColorKey);
8012
 
9062
 
8013
  {  Run  }
9063
  {  Run  }
8014
  for dy := StartY to EndY-1 do
9064
  for dy := StartY to EndY-1 do
8015
  begin
9065
  begin
8016
    gStartX := sx;
9066
    gStartX := sx;
8017
    gStartY := sy;
9067
    gStartY := sy;
8018
 
9068
 
8019
    {  X clipping  }
9069
    {  X clipping  }
8020
    pSkip := 0;
9070
    pSkip := 0;
8021
    if xIncX>0 then
9071
    if xIncX>0 then
8022
    begin
9072
    begin
8023
      if gStartX<SrcRect.Left*TextureAxisFloat then
9073
      if gStartX<SrcRect.Left*TextureAxisFloat then
8024
        pSkip := (SrcRect.Left*TextureAxisFloat-gStartX+xIncX-1) div xIncX;
9074
        pSkip := (SrcRect.Left*TextureAxisFloat-gStartX+xIncX-1) div xIncX;
8025
    end else if xIncX<0 then
9075
    end else if xIncX<0 then
8026
    begin
9076
    begin
8027
      if gStartX>=SrcRect.Right*TextureAxisFloat then
9077
      if gStartX>=SrcRect.Right*TextureAxisFloat then
8028
        pSkip := (SrcRect.Right*TextureAxisFloat-gStartX+xIncX) div xIncX;
9078
        pSkip := (SrcRect.Right*TextureAxisFloat-gStartX+xIncX) div xIncX;
8029
    end;
9079
    end;
8030
 
9080
 
8031
    if xIncY>0 then
9081
    if xIncY>0 then
8032
    begin
9082
    begin
8033
      if gStartY<SrcRect.Top*TextureAxisFloat then
9083
      if gStartY<SrcRect.Top*TextureAxisFloat then
8034
        pSkip := Max((SrcRect.Top*TextureAxisFloat-gStartY+xIncY-1) div xIncY, pSkip);
9084
        pSkip := Max((SrcRect.Top*TextureAxisFloat-gStartY+xIncY-1) div xIncY, pSkip);
8035
    end else if xIncY<0 then
9085
    end else if xIncY<0 then
8036
    begin
9086
    begin
8037
      if gStartY>=SrcRect.Bottom*TextureAxisFloat then
9087
      if gStartY>=SrcRect.Bottom*TextureAxisFloat then
8038
        pSkip := Max((SrcRect.Bottom*TextureAxisFloat-gStartY+xIncY) div xIncY, pSkip);
9088
        pSkip := Max((SrcRect.Bottom*TextureAxisFloat-gStartY+xIncY) div xIncY, pSkip);
8039
    end;
9089
    end;
8040
 
9090
 
8041
    gStartX := gStartX + pSkip*xIncX;
9091
    gStartX := gStartX + pSkip*xIncX;
8042
    gStartY := gStartY + pSkip*xIncY;
9092
    gStartY := gStartY + pSkip*xIncY;
8043
 
9093
 
8044
    {  X clipping  }
9094
    {  X clipping  }
8045
    if xIncX>=0 then
9095
    if xIncX>=0 then
8046
    begin
9096
    begin
8047
      pCount := (SrcRect.Right*TextureAxisFloat-gStartX) div Max(xIncX, 1);
9097
      pCount := (SrcRect.Right*TextureAxisFloat-gStartX) div Max(xIncX, 1);
8048
    end else
9098
    end else
8049
    begin
9099
    begin
8050
      pCount := (gStartX-SrcRect.Left*TextureAxisFloat) div (-xIncX);
9100
      pCount := (gStartX-SrcRect.Left*TextureAxisFloat) div (-xIncX);
8051
    end;
9101
    end;
8052
 
9102
 
8053
    if xIncY>=0 then
9103
    if xIncY>=0 then
8054
    begin
9104
    begin
8055
      pCount := Min((SrcRect.Bottom*TextureAxisFloat-gStartY) div Max(xIncY, 1), pCount);
9105
      pCount := Min((SrcRect.Bottom*TextureAxisFloat-gStartY) div Max(xIncY, 1), pCount);
8056
    end else
9106
    end else
8057
    begin
9107
    begin
8058
      pCount := Min((gStartY-SrcRect.Top*TextureAxisFloat) div (-xIncY), pCount);
9108
      pCount := Min((gStartY-SrcRect.Top*TextureAxisFloat) div (-xIncY), pCount);
8059
    end;
9109
    end;
8060
 
9110
 
8061
    pCount := Min(Integer(Dest.Width)-(StartX+pSkip), pCount);
9111
    pCount := Min(Integer(Dest.Width)-(StartX+pSkip), pCount);
8062
 
9112
 
8063
    {  Run  }
9113
    {  Run  }
8064
    DXRMachine.Axis.Axis.X := StartX + pSkip;
9114
    DXRMachine.Axis.Axis.X := StartX + pSkip;
8065
    DXRMachine.Axis.Axis.Y := dy;
9115
    DXRMachine.Axis.Axis.Y := dy;
8066
    DXRMachine.TextureList[0].nAxis.X := gStartX;
9116
    DXRMachine.TextureList[0].nAxis.X := gStartX;
8067
    DXRMachine.TextureList[0].nAxis.Y := gStartY;
9117
    DXRMachine.TextureList[0].nAxis.Y := gStartY;
8068
    DXRMachine.Run(pCount);
9118
    DXRMachine.Run(pCount);
8069
 
9119
 
8070
    sx := sx - yIncX;
9120
    sx := sx - yIncX;
8071
    sy := sy + yIncY;
9121
    sy := sy + yIncY;
8072
  end;
9122
  end;
8073
end;
9123
end;
8074
 
9124
 
-
 
9125
//var TextureSurface, DestSurface: TDXR_Surface; RenderStates: TDXR_RenderStates;
-
 
9126
//
-
 
9127
//dxrDefRenderStates(RenderStates);
-
 
9128
//if dxrDDSurfaceLock(Surf.ISurface, DestSurface then begin
-
 
9129
//  dxrDDSurfaceLock(TextureSurface as IDirectDrawSurface, TextureSurface);
-
 
9130
//  RenderStates.TextureList<0>.Surface:=@TextureSurface;
-
 
9131
//  dxrDrawPrimitive(DestSurface, RenderStates, DXR_PRIMITIVETYPE_TRIANGLELIST, @VertexList, 36);
-
 
9132
//  dxrDDSurfaceUnlock(SurfaceTexture as IDirectDrawSurface, TextureSurface);
-
 
9133
//  dxrDDSurfaceUnlock(Surf.ISurface, DestSurface);
-
 
9134
//end;
-
 
9135
 
8075
initialization
9136
initialization
8076
  ReadCPUID;
9137
  ReadCPUID;
8077
  Init;
9138
  Init;
8078
  InitCosinTable;
9139
  InitCosinTable;
-
 
9140
 
-
 
9141
  dxrSetOption(DXR_OPTION_MMXENABLE, 1);
8079
finalization
9142
finalization
8080
  FDXRMachine.Free;
9143
  FDXRMachine.Free;
8081
end.
9144
end.
8082
 
-