Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1c196c59
Commit
1c196c59
authored
May 31, 2005
by
Christian Costa
Committed by
Alexandre Julliard
May 31, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged convert.c, struct_convert.c and helper.c into ddraw_utils.c.
parent
5bc90f25
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
283 additions
and
340 deletions
+283
-340
Makefile.in
dlls/ddraw/Makefile.in
+2
-4
convert.c
dlls/ddraw/convert.c
+0
-278
ddraw_utils.c
dlls/ddraw/ddraw_utils.c
+281
-12
struct_convert.c
dlls/ddraw/struct_convert.c
+0
-46
No files found.
dlls/ddraw/Makefile.in
View file @
1c196c59
...
...
@@ -24,8 +24,8 @@ OPENGLFILES = \
C_SRCS
=
\
@OPENGLFILES@
\
convert.c
\
dclipper/main.c
\
ddraw_utils.c
\
ddraw/hal.c
\
ddraw/main.c
\
ddraw/thunks.c
\
...
...
@@ -40,10 +40,8 @@ C_SRCS = \
dsurface/thunks.c
\
dsurface/user.c
\
dsurface/wndproc.c
\
helper.c
\
main.c
\
regsvr.c
\
struct_convert.c
regsvr.c
RC_SRCS
=
version.rc
...
...
dlls/ddraw/convert.c
deleted
100644 → 0
View file @
5bc90f25
/*
* Copyright 2000 Marcus Meissner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
ddraw
);
/* *************************************
16 / 15 bpp to palettized 8 bpp
************************************* */
static
void
pixel_convert_16_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
#if defined(__i386__) && defined(__GNUC__)
/* gcc generates slightly inefficient code for the the copy/lookup,
* it generates one excess memory access (to pal) per pixel. Since
* we know that pal is not modified by the memory write we can
* put it into a register and reduce the number of memory accesses
* from 4 to 3 pp. There are two xor eax,eax to avoid pipeline
* stalls. (This is not guaranteed to be the fastest method.)
*/
__asm__
__volatile__
(
"xor %%eax,%%eax
\n
"
"1:
\n
"
" lodsb
\n
"
" movw (%%edx,%%eax,4),%%ax
\n
"
" stosw
\n
"
" xor %%eax,%%eax
\n
"
" loop 1b
\n
"
:
"=S"
(
c_src
),
"=D"
(
c_dst
)
:
"S"
(
c_src
),
"D"
(
c_dst
)
,
"c"
(
width
),
"d"
(
pal
)
:
"eax"
,
"cc"
,
"memory"
);
c_src
+=
(
pitch
-
width
);
#else
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
*
c_dst
++
=
pal
[
*
c_src
++
];
c_src
+=
(
pitch
-
width
);
#endif
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
2
);
}
}
static
void
palette_convert_16_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
(((((
unsigned
short
)
palent
[
i
].
peRed
)
&
0xF8
)
<<
8
)
|
((((
unsigned
short
)
palent
[
i
].
peBlue
)
&
0xF8
)
>>
3
)
|
((((
unsigned
short
)
palent
[
i
].
peGreen
)
&
0xFC
)
<<
3
));
}
static
void
palette_convert_15_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
(((((
unsigned
short
)
palent
[
i
].
peRed
)
&
0xF8
)
<<
7
)
|
((((
unsigned
short
)
palent
[
i
].
peBlue
)
&
0xF8
)
>>
3
)
|
((((
unsigned
short
)
palent
[
i
].
peGreen
)
&
0xF8
)
<<
2
));
}
/* *************************************
24 to palettized 8 bpp
************************************* */
static
void
pixel_convert_24_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
char
*
c_dst
=
(
unsigned
char
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
register
long
pixel
=
pal
[
*
c_src
++
];
*
c_dst
++
=
pixel
;
*
c_dst
++
=
pixel
>>
8
;
*
c_dst
++
=
pixel
>>
16
;
}
c_src
+=
(
pitch
-
width
);
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
3
);
}
}
/* *************************************
32 bpp to palettized 8 bpp
************************************* */
static
void
pixel_convert_32_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
#if defined(__i386__) && defined(__GNUC__)
/* See comment in pixel_convert_16_to_8 */
__asm__
__volatile__
(
"xor %%eax,%%eax
\n
"
"1:
\n
"
" lodsb
\n
"
" movl (%%edx,%%eax,4),%%eax
\n
"
" stosl
\n
"
" xor %%eax,%%eax
\n
"
" loop 1b
\n
"
:
"=S"
(
c_src
),
"=D"
(
c_dst
)
:
"S"
(
c_src
),
"D"
(
c_dst
)
,
"c"
(
width
),
"d"
(
pal
)
:
"eax"
,
"cc"
,
"memory"
);
c_src
+=
(
pitch
-
width
);
#else
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
*
c_dst
++
=
pal
[
*
c_src
++
];
c_src
+=
(
pitch
-
width
);
#endif
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
4
);
}
}
static
void
palette_convert_24_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
((((
unsigned
int
)
palent
[
i
].
peRed
)
<<
16
)
|
(((
unsigned
int
)
palent
[
i
].
peGreen
)
<<
8
)
|
((
unsigned
int
)
palent
[
i
].
peBlue
));
}
/* *************************************
16 bpp to 15 bpp
************************************* */
static
void
pixel_convert_15_to_16
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
short
*
c_src
=
(
unsigned
short
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
short
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
unsigned
short
val
=
*
c_src
++
;
*
c_dst
++=
((
val
&
0xFFC0
)
>>
1
)
|
(
val
&
0x001f
);
}
c_src
+=
((
pitch
/
2
)
-
width
);
}
}
/* *************************************
32 bpp to 16 bpp
************************************* */
static
void
pixel_convert_32_to_16
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
short
*
c_src
=
(
unsigned
short
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
short
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
*
c_dst
++
=
(((
*
c_src
&
0xF800
)
<<
8
)
|
((
*
c_src
&
0x07E0
)
<<
5
)
|
((
*
c_src
&
0x001F
)
<<
3
));
c_src
++
;
}
c_src
+=
((
pitch
/
2
)
-
width
);
}
}
/* *************************************
32 bpp to 24 bpp
************************************* */
static
void
pixel_convert_32_to_24
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
char
*
srclineend
=
c_src
+
width
*
3
;
while
(
c_src
<
srclineend
)
{
/* FIXME: wrong for big endian */
memcpy
(
c_dst
,
c_src
,
3
);
c_src
+=
3
;
c_dst
++
;
}
c_src
+=
pitch
-
width
*
3
;
}
}
/* *************************************
16 bpp to 32 bpp
************************************* */
static
void
pixel_convert_16_to_32
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
int
*
c_src
=
(
unsigned
int
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
int
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
*
c_dst
++
=
(((
*
c_src
&
0xF80000
)
>>
8
)
|
((
*
c_src
&
0x00FC00
)
>>
5
)
|
((
*
c_src
&
0x0000F8
)
>>
3
));
c_src
++
;
}
c_src
+=
((
pitch
/
4
)
-
width
);
}
}
Convert
ModeEmulations
[
8
]
=
{
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
24
,
24
,
0xFF0000
,
0x00FF00
,
0x0000FF
},
{
pixel_convert_32_to_24
,
NULL
}
},
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
pixel_convert_32_to_16
,
NULL
}
},
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_32_to_8
,
palette_convert_24_to_8
}
},
{
{
24
,
24
,
0xFF0000
,
0x00FF00
,
0x0000FF
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_24_to_8
,
palette_convert_24_to_8
}
},
{
{
16
,
15
,
0x7C00
,
0x03E0
,
0x001F
},
{
16
,
16
,
0xf800
,
0x07e0
,
0x001f
},
{
pixel_convert_15_to_16
,
NULL
}
},
{
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_16_to_8
,
palette_convert_16_to_8
}
},
{
{
16
,
15
,
0x7C00
,
0x03E0
,
0x001F
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_16_to_8
,
palette_convert_15_to_8
}
},
{
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
pixel_convert_16_to_32
,
NULL
}
}
};
dlls/ddraw/
helper
.c
→
dlls/ddraw/
ddraw_utils
.c
View file @
1c196c59
/* DirectDraw Base F
unctions
/*
* DirectDraw helper f
unctions
*
* Copyright 1997-
1999
Marcus Meissner
* Copyright 1997-
2000
Marcus Meissner
* Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
* Copyright 2000 TransGaming Technologies Inc.
*
...
...
@@ -20,29 +20,298 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "wine/debug.h"
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "d3d.h"
#include "ddraw.h"
#include "winerror.h"
#include "wine/exception.h"
#include "ddraw_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
ddraw
);
/* *************************************
16 / 15 bpp to palettized 8 bpp
************************************* */
static
void
pixel_convert_16_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
#if defined(__i386__) && defined(__GNUC__)
/* gcc generates slightly inefficient code for the the copy/lookup,
* it generates one excess memory access (to pal) per pixel. Since
* we know that pal is not modified by the memory write we can
* put it into a register and reduce the number of memory accesses
* from 4 to 3 pp. There are two xor eax,eax to avoid pipeline
* stalls. (This is not guaranteed to be the fastest method.)
*/
__asm__
__volatile__
(
"xor %%eax,%%eax
\n
"
"1:
\n
"
" lodsb
\n
"
" movw (%%edx,%%eax,4),%%ax
\n
"
" stosw
\n
"
" xor %%eax,%%eax
\n
"
" loop 1b
\n
"
:
"=S"
(
c_src
),
"=D"
(
c_dst
)
:
"S"
(
c_src
),
"D"
(
c_dst
)
,
"c"
(
width
),
"d"
(
pal
)
:
"eax"
,
"cc"
,
"memory"
);
c_src
+=
(
pitch
-
width
);
#else
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
*
c_dst
++
=
pal
[
*
c_src
++
];
c_src
+=
(
pitch
-
width
);
#endif
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
2
);
}
}
static
void
palette_convert_16_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
(((((
unsigned
short
)
palent
[
i
].
peRed
)
&
0xF8
)
<<
8
)
|
((((
unsigned
short
)
palent
[
i
].
peBlue
)
&
0xF8
)
>>
3
)
|
((((
unsigned
short
)
palent
[
i
].
peGreen
)
&
0xFC
)
<<
3
));
}
static
void
palette_convert_15_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
(((((
unsigned
short
)
palent
[
i
].
peRed
)
&
0xF8
)
<<
7
)
|
((((
unsigned
short
)
palent
[
i
].
peBlue
)
&
0xF8
)
>>
3
)
|
((((
unsigned
short
)
palent
[
i
].
peGreen
)
&
0xF8
)
<<
2
));
}
/* *************************************
24 to palettized 8 bpp
************************************* */
static
void
pixel_convert_24_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
char
*
c_dst
=
(
unsigned
char
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
register
long
pixel
=
pal
[
*
c_src
++
];
*
c_dst
++
=
pixel
;
*
c_dst
++
=
pixel
>>
8
;
*
c_dst
++
=
pixel
>>
16
;
}
c_src
+=
(
pitch
-
width
);
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
3
);
}
}
/* *************************************
32 bpp to palettized 8 bpp
************************************* */
static
void
pixel_convert_32_to_8
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
if
(
palette
!=
NULL
)
{
const
unsigned
int
*
pal
=
(
unsigned
int
*
)
palette
->
screen_palents
;
for
(
y
=
height
;
y
--
;
)
{
#if defined(__i386__) && defined(__GNUC__)
/* See comment in pixel_convert_16_to_8 */
__asm__
__volatile__
(
"xor %%eax,%%eax
\n
"
"1:
\n
"
" lodsb
\n
"
" movl (%%edx,%%eax,4),%%eax
\n
"
" stosl
\n
"
" xor %%eax,%%eax
\n
"
" loop 1b
\n
"
:
"=S"
(
c_src
),
"=D"
(
c_dst
)
:
"S"
(
c_src
),
"D"
(
c_dst
)
,
"c"
(
width
),
"d"
(
pal
)
:
"eax"
,
"cc"
,
"memory"
);
c_src
+=
(
pitch
-
width
);
#else
unsigned
char
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
*
c_dst
++
=
pal
[
*
c_src
++
];
c_src
+=
(
pitch
-
width
);
#endif
}
}
else
{
FIXME
(
"No palette set...
\n
"
);
memset
(
dst
,
0
,
width
*
height
*
4
);
}
}
static
void
palette_convert_24_to_8
(
LPPALETTEENTRY
palent
,
void
*
screen_palette
,
DWORD
start
,
DWORD
count
)
{
unsigned
int
i
;
unsigned
int
*
pal
=
(
unsigned
int
*
)
screen_palette
;
for
(
i
=
0
;
i
<
count
;
i
++
)
pal
[
start
+
i
]
=
((((
unsigned
int
)
palent
[
i
].
peRed
)
<<
16
)
|
(((
unsigned
int
)
palent
[
i
].
peGreen
)
<<
8
)
|
((
unsigned
int
)
palent
[
i
].
peBlue
));
}
/* *************************************
16 bpp to 15 bpp
************************************* */
static
void
pixel_convert_15_to_16
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
short
*
c_src
=
(
unsigned
short
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
short
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
unsigned
short
val
=
*
c_src
++
;
*
c_dst
++=
((
val
&
0xFFC0
)
>>
1
)
|
(
val
&
0x001f
);
}
c_src
+=
((
pitch
/
2
)
-
width
);
}
}
/* *************************************
32 bpp to 16 bpp
************************************* */
static
void
pixel_convert_32_to_16
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
short
*
c_src
=
(
unsigned
short
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
short
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
*
c_dst
++
=
(((
*
c_src
&
0xF800
)
<<
8
)
|
((
*
c_src
&
0x07E0
)
<<
5
)
|
((
*
c_src
&
0x001F
)
<<
3
));
c_src
++
;
}
c_src
+=
((
pitch
/
2
)
-
width
);
}
}
/* *************************************
32 bpp to 24 bpp
************************************* */
static
void
pixel_convert_32_to_24
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
char
*
c_src
=
(
unsigned
char
*
)
src
;
unsigned
int
*
c_dst
=
(
unsigned
int
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
char
*
srclineend
=
c_src
+
width
*
3
;
while
(
c_src
<
srclineend
)
{
/* FIXME: wrong for big endian */
memcpy
(
c_dst
,
c_src
,
3
);
c_src
+=
3
;
c_dst
++
;
}
c_src
+=
pitch
-
width
*
3
;
}
}
/* *************************************
16 bpp to 32 bpp
************************************* */
static
void
pixel_convert_16_to_32
(
void
*
src
,
void
*
dst
,
DWORD
width
,
DWORD
height
,
LONG
pitch
,
IDirectDrawPaletteImpl
*
palette
)
{
unsigned
int
*
c_src
=
(
unsigned
int
*
)
src
;
unsigned
short
*
c_dst
=
(
unsigned
short
*
)
dst
;
int
y
;
for
(
y
=
height
;
y
--
;
)
{
unsigned
int
*
srclineend
=
c_src
+
width
;
while
(
c_src
<
srclineend
)
{
*
c_dst
++
=
(((
*
c_src
&
0xF80000
)
>>
8
)
|
((
*
c_src
&
0x00FC00
)
>>
5
)
|
((
*
c_src
&
0x0000F8
)
>>
3
));
c_src
++
;
}
c_src
+=
((
pitch
/
4
)
-
width
);
}
}
Convert
ModeEmulations
[
8
]
=
{
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
24
,
24
,
0xFF0000
,
0x00FF00
,
0x0000FF
},
{
pixel_convert_32_to_24
,
NULL
}
},
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
pixel_convert_32_to_16
,
NULL
}
},
{
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_32_to_8
,
palette_convert_24_to_8
}
},
{
{
24
,
24
,
0xFF0000
,
0x00FF00
,
0x0000FF
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_24_to_8
,
palette_convert_24_to_8
}
},
{
{
16
,
15
,
0x7C00
,
0x03E0
,
0x001F
},
{
16
,
16
,
0xf800
,
0x07e0
,
0x001f
},
{
pixel_convert_15_to_16
,
NULL
}
},
{
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_16_to_8
,
palette_convert_16_to_8
}
},
{
{
16
,
15
,
0x7C00
,
0x03E0
,
0x001F
},
{
8
,
8
,
0x00
,
0x00
,
0x00
},
{
pixel_convert_16_to_8
,
palette_convert_15_to_8
}
},
{
{
16
,
16
,
0xF800
,
0x07E0
,
0x001F
},
{
32
,
24
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
},
{
pixel_convert_16_to_32
,
NULL
}
}
};
void
DDRAW_Convert_DDSCAPS_1_To_2
(
const
DDSCAPS
*
pIn
,
DDSCAPS2
*
pOut
)
{
/* 2 adds three additional caps fields to the end. Both versions
* are unversioned. */
pOut
->
dwCaps
=
pIn
->
dwCaps
;
pOut
->
dwCaps2
=
0
;
pOut
->
dwCaps3
=
0
;
pOut
->
dwCaps4
=
0
;
}
void
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1
(
const
DDDEVICEIDENTIFIER2
*
pIn
,
DDDEVICEIDENTIFIER
*
pOut
)
{
/* 2 adds a dwWHQLLevel field to the end. Both structures are
* unversioned. */
memcpy
(
pOut
,
pIn
,
sizeof
(
*
pOut
));
}
/******************************************************************************
* debug output functions
*/
...
...
dlls/ddraw/struct_convert.c
deleted
100644 → 0
View file @
5bc90f25
/* ddraw/d3d structure version conversion
*
* Copyright 2000 TransGaming Technologies Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddraw.h"
#include "ddraw_private.h"
void
DDRAW_Convert_DDSCAPS_1_To_2
(
const
DDSCAPS
*
pIn
,
DDSCAPS2
*
pOut
)
{
/* 2 adds three additional caps fields to the end. Both versions
* are unversioned. */
pOut
->
dwCaps
=
pIn
->
dwCaps
;
pOut
->
dwCaps2
=
0
;
pOut
->
dwCaps3
=
0
;
pOut
->
dwCaps4
=
0
;
}
void
DDRAW_Convert_DDDEVICEIDENTIFIER_2_To_1
(
const
DDDEVICEIDENTIFIER2
*
pIn
,
DDDEVICEIDENTIFIER
*
pOut
)
{
/* 2 adds a dwWHQLLevel field to the end. Both structures are
* unversioned. */
memcpy
(
pOut
,
pIn
,
sizeof
(
*
pOut
));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment