Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
palalloc.c
Go to the documentation of this file.
1/*
2 * Space palette layout and contiguous palette-entry reservation.
3 *
4 * Retail object 0x401840-0x401A0F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8short g_nSpacePaletteFadeMode = -1; /* 0x004901e8 */
9
10/* Function start: 0x401840 */
12{
13 (void)mode;
16}
17
18/* Function start: 0x401859 */
19short ReserveContiguousPaletteEntries(short entryCount)
20{
21 short entry;
22 short firstFree;
23 short freeEntries;
24
25 firstFree = 0;
26 freeEntries = firstFree;
27 for (entry = freeEntries; entry < 256; entry++) {
28 if (g_awPaletteEntryAllocation[entry] != 0) {
29 freeEntries = 0;
30 firstFree = (short)(entry + 1);
31 } else {
32 freeEntries++;
33 }
34 if (entryCount == freeEntries) {
35 for (entry = 0; entry < entryCount; entry++) {
36 g_awPaletteEntryAllocation[entry + firstFree] =
37 entryCount;
38 }
39 return firstFree;
40 }
41 }
42 return -1;
43}
44
45/* Function start: 0x401922 */
46void ReleaseContiguousPaletteEntries(short firstEntry)
47{
48 short entry;
49 short count;
50
51 count = g_awPaletteEntryAllocation[firstEntry];
52 for (entry = 0; count > entry; entry++)
53 g_awPaletteEntryAllocation[entry + firstEntry] = 0;
54}
55
56/* Function start: 0x401978 */
58{
59 short x;
60 short y;
61 short entry;
62
63 entry = 0;
64 for (y = entry; y < 4; y++) {
65 for (x = 0; x < 0x40; x++) {
66 printf("%c",
67 g_awPaletteEntryAllocation[entry++] == 0 ?
68 '_' : '.');
69 }
70 printf("\n");
71 }
72}
73
74/* Linker commons defined here. LINK lays a unit's commons out by the
75 * identifiers' hash keys, so these spellings follow the original addresses. */
76short g_awPaletteEntryAllocation[256]; /* 0x005d4050 */
void(__cdecl *g_pIxFree)(void *)
void ReleaseContiguousPaletteEntries(short firstEntry)
Definition palalloc.c:46
void ApplySpacePaletteModeHook(void)
Definition eventmgr.c:222
void ConfigureDefaultSpacePalette(short mode)
Definition palalloc.c:11
short ReserveContiguousPaletteEntries(short entryCount)
Definition palalloc.c:19
void PrintPaletteAllocationMap(void)
Definition palalloc.c:57
Shared Win32 declarations, types and library interfaces.
short g_nSpacePaletteFadeMode
Definition palalloc.c:8
short g_awPaletteEntryAllocation[256]
Definition palalloc.c:76