Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
palfade.c
Go to the documentation of this file.
1/*
2 * Fades a viewport palette towards a colour.
3 *
4 * Retail object 0x453820-0x453A6F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8#pragma function(memset)
9/* Function start: 0x453820 */
11 unsigned short colour,
12 short enabled)
13{
14 unsigned char *indices;
15 short slot;
16 short used;
17 unsigned short targetColour[3];
18 short *goalPalette;
19 short *workPalette;
20
21 if (g_nSpacePaletteFadeMode == 0x13) {
22 indices = AllocateTaggedMemory(256, 0);
23 if (indices == 0)
24 return;
25 memset(indices, 0, 256);
26 used = CollectActivePaletteIndices(viewport, indices, 256);
27 workPalette = AllocateTaggedMemory(
28 (unsigned int)(used * 6), 0);
29 if (workPalette == 0) {
30 ReleasePacketHandle(indices);
31 return;
32 }
33 memset(workPalette, 0,
34 (unsigned int)(used * 6));
35 goalPalette = AllocateTaggedMemory(
36 (unsigned int)(used * 6), 0);
37 if (goalPalette == 0) {
38 ReleasePacketHandle(indices);
39 ReleasePacketHandle(workPalette);
40 return;
41 }
42 memset(goalPalette, 0,
43 (unsigned int)(used * 6));
44 GetPaletteEntry((short)colour, targetColour);
45 for (slot = 0; slot < used; slot++) {
47 (short)indices[slot],
48 (unsigned short *)&workPalette[slot * 3]);
49 memcpy(&goalPalette[slot * 3], targetColour, 6);
50 }
52 workPalette, goalPalette,
53 (short)(used * 3)) != 0) {
54 if (enabled != 0) {
55 slot = enabled;
56 while (slot-- != 0)
58 }
59 for (slot = 0; slot < used; slot++) {
60 SetPaletteEntry((short)indices[slot],
61 &workPalette[slot * 3]);
62 }
63 }
64 ReleasePacketHandle(goalPalette);
65 ReleasePacketHandle(workPalette);
66 ReleasePacketHandle(indices);
67 }
68}
void FadeViewportPaletteToColour(Viewport *viewport, unsigned short colour, short enabled)
Definition palfade.c:10
short StepPaletteTransition(short *current, const short *target, short componentCount)
Definition fade.c:12
void SetPaletteEntry(short index, short *rgb)
Definition gr.c:676
short CollectActivePaletteIndices(Viewport *viewport, unsigned char *indices, short capacity)
Definition usedcols.c:11
void * AllocateTaggedMemory(unsigned int size, short flags)
Definition memapi.c:92
void WaitForVerticalBlankThunk(void)
Definition eventmgr.c:189
void GetPaletteEntry(short index, unsigned short *rgb)
Definition gr.c:670
void ReleasePacketHandle(void *handle)
Definition memapi.c:108
Shared Win32 declarations, types and library interfaces.
short g_nSpacePaletteFadeMode
Definition palalloc.c:8