Wing Commander
Reconstructed Win32 source (1996)
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
14short nPaletteTransitionInitialise = 1; /* 0x00469640 */
15short *pPaletteTransDirection; /* 0x005a7d88 */
16short *pPaletteTransitionDelta; /* 0x005a7d8c */
17short nPaletteTransMaxDelta; /* 0x005a7d90 */
18short *pPaletteTransitionAccumulatorPtr; /* 0x005a7d94 */
19short nPaletteTransitionCountdown; /* 0x005a7d98 */
20
21/* Function start: 0x41C510 */
22unsigned short __stdcall StepPaletteTransition(short *current,
23 const short *target,
24 short componentCount)
25{
26 short index;
27 short difference;
28
31 AllocateTaggedMemory(componentCount * 2, 0);
33 AllocateTaggedMemory(componentCount * 2, 0);
35 AllocateTaggedMemory(componentCount * 2, 0);
45 return 0;
46 }
47
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 }
69 }
70
71 if (nPaletteTransitionCountdown-- == 0) {
76 return 0;
77 }
78
79 for (index = 0; index < componentCount; index++) {
85 current[index] += pPaletteTransDirection[index];
86 }
87 }
88 return 1;
89}
90
91/* Function start: 0x41C740 */
92char *__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}
short * pPaletteTransitionDelta
Definition fade.c:16
short * pPaletteTransitionAccumulatorPtr
Definition fade.c:18
short * pPaletteTransDirection
Definition fade.c:15
short nPaletteTransMaxDelta
Definition fade.c:17
short nPaletteTransitionInitialise
Definition fade.c:14
short nPaletteTransitionCountdown
Definition fade.c:19
Umbrella header for the game core.
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
char *__stdcall DosStrchr(const char *s, short c)
Definition strdos.c:43
unsigned short __stdcall StepPaletteTransition(short *current, const short *target, short componentCount)
Definition fade.c:22
char *__stdcall DosStrcat(char *destination, const char *source)
Definition fade.c:92
char *__stdcall DosStrcpy(char *dst, const char *src)
Definition strdos.c:49
void ReleasePacketHandle(void *handle)
Definition ending.c:50