Wing Commander II
Reconstructed Win32 source (1996)
Toggle main menu visibility
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
8
short
g_nSpacePaletteFadeMode
= -1;
/* 0x004901e8 */
9
10
/* Function start: 0x401840 */
11
void
ConfigureDefaultSpacePalette
(
short
mode)
12
{
13
(
void
)mode;
14
g_nSpacePaletteFadeMode
= 0x13;
15
ApplySpacePaletteModeHook
();
16
}
17
18
/* Function start: 0x401859 */
19
short
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 */
46
void
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 */
57
void
PrintPaletteAllocationMap
(
void
)
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. */
76
short
g_awPaletteEntryAllocation
[256];
/* 0x005d4050 */
void
void(__cdecl *g_pIxFree)(void *)
ReleaseContiguousPaletteEntries
void ReleaseContiguousPaletteEntries(short firstEntry)
Definition
palalloc.c:46
ApplySpacePaletteModeHook
void ApplySpacePaletteModeHook(void)
Definition
eventmgr.c:222
ConfigureDefaultSpacePalette
void ConfigureDefaultSpacePalette(short mode)
Definition
palalloc.c:11
ReserveContiguousPaletteEntries
short ReserveContiguousPaletteEntries(short entryCount)
Definition
palalloc.c:19
PrintPaletteAllocationMap
void PrintPaletteAllocationMap(void)
Definition
palalloc.c:57
game.h
Shared Win32 declarations, types and library interfaces.
g_nSpacePaletteFadeMode
short g_nSpacePaletteFadeMode
Definition
palalloc.c:8
g_awPaletteEntryAllocation
short g_awPaletteEntryAllocation[256]
Definition
palalloc.c:76
src
palalloc.c
Generated by
1.18.0