Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
vpalloc.c
Go to the documentation of this file.
1/*
2 * Viewport buffer allocation.
3 *
4 * Retail object 0x45CA50-0x45CCAF (link order; see docs/ORDER.md). The
5 * DOS release's vpalloc module holds the size and allocation routines;
6 * the Win32 port puts its display-mode diagnostic in front of them.
7 */
8#include "game.h"
9
10/* Function start: 0x45CA50 */
11void LogDisplayMode(const char *mode)
12{
13 SystemDebugPrintf("display_mode == '%s'\n", mode);
16 exit(1);
17}
18
19short AllocateViewport(Viewport *viewport, short clearColour, short flags);
20void ClearViewport(Viewport *viewport, short colour);
21
22/* Function start: 0x45CA80 */
23short CalcRectangleArea(const Viewport *viewport)
24{
25 if (g_nSpacePaletteFadeMode != 0x13)
26 LogDisplayMode("not MCGA");
27 return (short)((viewport->bottom - viewport->top + 1) *
28 (viewport->right - viewport->left + 1));
29}
30
31/* Function start: 0x45CAD2 */
32short AllocateViewport(Viewport *viewport,
33 short clearColour, short flags)
34{
35 unsigned short y;
36 unsigned short height;
37 unsigned short pixelOffset;
38 unsigned char *buffer;
39 unsigned short firstRow;
40 unsigned short width;
41 unsigned short left;
42
43 height = viewport->bottom - viewport->top + 1;
44 width = viewport->right - viewport->left + 1;
45 left = viewport->left;
46 firstRow = viewport->top;
48 if (g_nSpacePaletteFadeMode != 0x13)
49 LogDisplayMode("not MCGA");
51 width * height, (unsigned short)(flags + 2));
54 buffer = viewport->allocation;
55 if (buffer == 0)
56 return 0;
57 viewport->pixels = buffer;
58 pixelOffset = 0;
59
61 (firstRow + height + 2) * 2, 0);
62 if (viewport->rowOffsets == 0) {
63 if (g_nSpacePaletteFadeMode != 0x13)
65 return 0;
66 }
67
68 for (y = 0; y < height + 2; y++) {
69 (&viewport->rowOffsets[firstRow])[y] = pixelOffset - left;
70 pixelOffset += width;
71 }
72 if (clearColour != -1)
73 ClearViewport(viewport, clearColour);
74 return 1;
75}
76
77/* Linker commons defined here. LINK lays a unit's commons out by the
78 * identifiers' hash keys, so these spellings follow the original addresses. */
79int g_nAllocateViewportCalls; /* 0x005c8dc4 */
char PumpMessagesDuringWait(void)
Definition console.cpp:46
short AllocateViewport(Viewport *viewport, short clearColour, short flags)
Definition vpalloc.c:32
void * AllocateTaggedMemory(unsigned int size, short flags)
Definition memapi.c:92
void ClearDebugPauseFlags(void)
Definition console.cpp:82
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:1027
void ReleasePacketHandle(void *handle)
Definition memapi.c:108
void LogDisplayMode(const char *mode)
Definition vpalloc.c:11
void SystemDebugPrintf(const char *format,...)
Definition console.cpp:30
short CalcRectangleArea(const Viewport *viewport)
Definition vpalloc.c:23
Shared Win32 declarations, types and library interfaces.
int g_nAllocateViewportCalls
Definition vpalloc.c:79
unsigned char * g_apViewportAllocations[128]
Definition vpfree.c:52
short g_nSpacePaletteFadeMode
Definition palalloc.c:8
int g_nViewportAllocationCount
Definition vpfree.c:51
unsigned char * pixels
Definition game.h:150
short right
Definition game.h:154
short bottom
Definition game.h:155
unsigned char * allocation
Definition game.h:156
unsigned short * rowOffsets
Definition game.h:151
short left
Definition game.h:152
short top
Definition game.h:153