Wing Commander
Reconstructed Win32 source (1996)
Toggle main menu visibility
Loading...
Searching...
No Matches
fade.c
Go to the documentation of this file.
1
/**
2
* @file
3
* @ingroup graphics
4
* @brief Incremental palette transitions, and the DOS string-append shim
5
* beside them.
6
*
7
* Address range 41c510-41c75f. The initialization flag follows the barracks
8
* literal pool. Which unit owned DosStrcat is provisional.
9
*/
10
#include "
wc1.h
"
11
12
#include <sys/types.h>
13
14
short
nPaletteTransitionInitialise
= 1;
/* 0x00469640 */
15
short
*
pPaletteTransDirection
;
/* 0x005a7d88 */
16
short
*
pPaletteTransitionDelta
;
/* 0x005a7d8c */
17
short
nPaletteTransMaxDelta
;
/* 0x005a7d90 */
18
short
*
pPaletteTransitionAccumulatorPtr
;
/* 0x005a7d94 */
19
short
nPaletteTransitionCountdown
;
/* 0x005a7d98 */
20
21
/* Function start: 0x41C510 */
22
unsigned
short
__stdcall
StepPaletteTransition
(
short
*current,
23
const
short
*target,
24
short
componentCount)
25
{
26
short
index;
27
short
difference;
28
29
if
(
nPaletteTransitionInitialise
!= 0) {
30
pPaletteTransitionAccumulatorPtr
=
31
AllocateTaggedMemory
(componentCount * 2, 0);
32
pPaletteTransitionDelta
=
33
AllocateTaggedMemory
(componentCount * 2, 0);
34
pPaletteTransDirection
=
35
AllocateTaggedMemory
(componentCount * 2, 0);
36
if
(
pPaletteTransitionAccumulatorPtr
== 0 ||
37
pPaletteTransitionDelta
== 0 ||
38
pPaletteTransDirection
== 0) {
39
if
(
pPaletteTransitionAccumulatorPtr
!= 0)
40
ReleasePacketHandle
(
pPaletteTransitionAccumulatorPtr
);
41
if
(
pPaletteTransitionDelta
!= 0)
42
ReleasePacketHandle
(
pPaletteTransitionDelta
);
43
if
(
pPaletteTransDirection
!= 0)
44
ReleasePacketHandle
(
pPaletteTransDirection
);
45
return
0;
46
}
47
48
nPaletteTransMaxDelta
= 0;
49
for
(index = 0; index < componentCount; index++) {
50
difference = current[index] - target[index];
51
if
(difference < 0) {
52
difference = -difference;
53
pPaletteTransDirection
[index] = 4;
54
}
else
{
55
pPaletteTransDirection
[index] = -4;
56
}
57
pPaletteTransitionDelta
[index] = difference;
58
if
(
nPaletteTransMaxDelta
< difference)
59
nPaletteTransMaxDelta
= difference;
60
}
61
62
difference =
nPaletteTransMaxDelta
/ 4;
63
for
(index = 0; index < componentCount; index++) {
64
pPaletteTransitionAccumulatorPtr
[index] = difference;
65
}
66
nPaletteTransitionInitialise
= 0;
67
nPaletteTransitionCountdown
=
68
nPaletteTransMaxDelta
/ 4;
69
}
70
71
if
(
nPaletteTransitionCountdown
-- == 0) {
72
ReleasePacketHandle
(
pPaletteTransitionAccumulatorPtr
);
73
ReleasePacketHandle
(
pPaletteTransitionDelta
);
74
ReleasePacketHandle
(
pPaletteTransDirection
);
75
nPaletteTransitionInitialise
= 1;
76
return
0;
77
}
78
79
for
(index = 0; index < componentCount; index++) {
80
if
((
pPaletteTransitionAccumulatorPtr
[index] +=
81
pPaletteTransitionDelta
[index]) >
82
nPaletteTransMaxDelta
) {
83
pPaletteTransitionAccumulatorPtr
[index] -=
84
nPaletteTransMaxDelta
;
85
current[index] +=
pPaletteTransDirection
[index];
86
}
87
}
88
return
1;
89
}
90
91
/* Function start: 0x41C740 */
92
char
*__stdcall
DosStrcat
(
char
*destination,
const
char
*source)
93
{
94
char
*end;
95
96
end =
DosStrchr
(destination, 0);
97
DosStrcpy
(end, source);
98
return
destination;
99
}
pPaletteTransitionDelta
short * pPaletteTransitionDelta
Definition
fade.c:16
pPaletteTransitionAccumulatorPtr
short * pPaletteTransitionAccumulatorPtr
Definition
fade.c:18
pPaletteTransDirection
short * pPaletteTransDirection
Definition
fade.c:15
nPaletteTransMaxDelta
short nPaletteTransMaxDelta
Definition
fade.c:17
nPaletteTransitionInitialise
short nPaletteTransitionInitialise
Definition
fade.c:14
nPaletteTransitionCountdown
short nPaletteTransitionCountdown
Definition
fade.c:19
wc1.h
Umbrella header for the game core.
AllocateTaggedMemory
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition
ending.c:31
DosStrchr
char *__stdcall DosStrchr(const char *s, short c)
Definition
strdos.c:43
StepPaletteTransition
unsigned short __stdcall StepPaletteTransition(short *current, const short *target, short componentCount)
Definition
fade.c:22
DosStrcat
char *__stdcall DosStrcat(char *destination, const char *source)
Definition
fade.c:92
DosStrcpy
char *__stdcall DosStrcpy(char *dst, const char *src)
Definition
strdos.c:49
ReleasePacketHandle
void ReleasePacketHandle(void *handle)
Definition
ending.c:50
src
fade.c
Generated by
1.18.0