Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
gr.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup graphics
4 * @brief Rasteriser primitives, screen-space effects and the music streamer's
5 * wrappers.
6 *
7 * Address range 4408a0-44269f. The routines print some of their names:
8 * shadow_draw, fizzle_fade and snow_viewport.
9 */
10#include <stdio.h>
11#include "wc1.h"
12
13/* 0x00470678 */
14static unsigned char abPaletteTranslation[256] = {
15 0, 1, 2, 3, 4, 5, 6, 7,
16 8, 9, 10, 11, 12, 13, 14, 15,
17 16, 17, 18, 19, 20, 21, 22, 23,
18 24, 25, 26, 27, 28, 29, 30, 31,
19 32, 33, 34, 35, 36, 37, 38, 39,
20 40, 41, 42, 43, 44, 45, 46, 47,
21 48, 49, 50, 51, 52, 53, 54, 55,
22 56, 57, 58, 59, 60, 61, 62, 63,
23 64, 65, 66, 67, 68, 69, 70, 71,
24 72, 73, 74, 75, 76, 77, 78, 79,
25 80, 81, 82, 83, 84, 85, 86, 87,
26 88, 89, 90, 91, 92, 93, 94, 95,
27 96, 97, 98, 99, 100, 101, 102, 103,
28 104, 105, 106, 107, 108, 109, 110, 111,
29 112, 113, 114, 115, 116, 117, 118, 119,
30 120, 121, 122, 123, 124, 125, 126, 127,
31 128, 129, 130, 131, 132, 133, 134, 135,
32 136, 137, 138, 139, 140, 141, 142, 143,
33 144, 145, 146, 147, 148, 149, 150, 151,
34 152, 153, 154, 155, 156, 157, 158, 159,
35 160, 161, 162, 163, 164, 165, 166, 167,
36 168, 169, 170, 171, 172, 173, 174, 175,
37 176, 177, 178, 179, 180, 181, 182, 183,
38 184, 185, 186, 187, 188, 189, 190, 191,
39 192, 193, 194, 195, 196, 197, 198, 199,
40 200, 201, 202, 203, 204, 205, 206, 207,
41 208, 209, 210, 211, 212, 213, 214, 215,
42 216, 217, 218, 219, 220, 221, 222, 223,
43 224, 225, 226, 227, 228, 229, 230, 231,
44 232, 233, 234, 235, 236, 237, 238, 239,
45 240, 241, 242, 243, 244, 245, 246, 247,
46 248, 249, 250, 251, 252, 253, 254, 255
47};
48/* 0x00470778 */
49/* Absolute cosine row, then the sine row at 0x00470a48, indexed by angle in
50 * degrees. One table keeps the unit's symbol count. */
51static unsigned short aawAbsoluteTrig[2][360] = {
52 {
53 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 252, 251,
54 250, 250, 248, 247, 246, 245, 243, 242, 241, 239, 237, 236,
55 234, 232, 230, 228, 226, 224, 221, 219, 217, 215, 212, 210,
56 207, 204, 202, 198, 196, 193, 190, 187, 184, 181, 178, 175,
57 171, 168, 165, 161, 158, 154, 150, 147, 143, 139, 136, 131,
58 128, 124, 120, 116, 112, 108, 104, 100, 96, 92, 88, 83,
59 79, 74, 71, 66, 62, 58, 53, 49, 45, 40, 36, 31,
60 27, 22, 18, 13, 9, 4, 0, 4, 9, 13, 18, 22,
61 27, 31, 36, 40, 45, 49, 53, 58, 62, 66, 71, 75,
62 79, 83, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124,
63 128, 131, 136, 139, 143, 147, 150, 154, 158, 161, 165, 168,
64 171, 175, 178, 181, 184, 187, 190, 193, 196, 198, 202, 204,
65 207, 210, 212, 215, 217, 219, 221, 224, 226, 228, 230, 232,
66 234, 236, 237, 239, 241, 242, 243, 245, 246, 247, 248, 250,
67 250, 251, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255,
68 255, 255, 255, 255, 255, 255, 255, 254, 254, 253, 252, 251,
69 250, 250, 248, 247, 246, 245, 243, 242, 241, 239, 237, 236,
70 234, 232, 230, 228, 226, 224, 221, 219, 217, 215, 212, 210,
71 207, 204, 202, 198, 196, 193, 190, 187, 184, 181, 178, 175,
72 171, 168, 165, 161, 158, 154, 150, 147, 143, 139, 136, 131,
73 128, 124, 120, 116, 112, 108, 104, 100, 96, 92, 88, 83,
74 79, 74, 71, 66, 62, 58, 53, 49, 45, 40, 36, 31,
75 27, 22, 18, 13, 9, 4, 0, 4, 9, 13, 18, 22,
76 27, 31, 36, 40, 45, 49, 53, 58, 62, 66, 71, 75,
77 79, 83, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124,
78 128, 131, 136, 139, 143, 147, 150, 154, 158, 161, 165, 168,
79 171, 175, 178, 181, 184, 187, 190, 193, 196, 198, 202, 204,
80 207, 210, 212, 215, 217, 219, 221, 224, 226, 228, 230, 232,
81 234, 236, 237, 239, 241, 242, 243, 245, 246, 247, 248, 250,
82 250, 251, 252, 253, 254, 254, 255, 255, 255, 255, 255, 255
83 },
84 {
85 0, 4, 9, 13, 18, 22, 27, 31, 36, 40, 45, 49,
86 53, 58, 62, 66, 71, 75, 79, 83, 88, 92, 96, 100,
87 104, 108, 112, 116, 120, 124, 128, 131, 136, 139, 143, 147,
88 150, 154, 158, 161, 165, 168, 171, 175, 178, 181, 184, 187,
89 190, 193, 196, 198, 202, 204, 207, 210, 212, 215, 217, 219,
90 221, 224, 226, 228, 230, 232, 234, 236, 237, 239, 241, 242,
91 243, 245, 246, 247, 248, 250, 250, 251, 252, 253, 254, 254,
92 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
93 255, 254, 254, 253, 252, 251, 250, 250, 248, 247, 246, 245,
94 243, 242, 241, 239, 237, 236, 234, 232, 230, 228, 226, 224,
95 221, 219, 217, 215, 212, 210, 207, 204, 202, 198, 196, 193,
96 190, 187, 184, 181, 178, 175, 171, 168, 165, 161, 158, 154,
97 150, 147, 143, 139, 136, 131, 128, 124, 120, 116, 112, 108,
98 104, 100, 96, 92, 88, 83, 79, 74, 71, 66, 62, 58,
99 53, 49, 45, 40, 36, 31, 27, 22, 18, 13, 9, 4,
100 0, 4, 9, 13, 18, 22, 27, 31, 36, 40, 45, 49,
101 53, 58, 62, 66, 71, 75, 79, 83, 88, 92, 96, 100,
102 104, 108, 112, 116, 120, 124, 128, 131, 136, 139, 143, 147,
103 150, 154, 158, 161, 165, 168, 171, 175, 178, 181, 184, 187,
104 190, 193, 196, 198, 202, 204, 207, 210, 212, 215, 217, 219,
105 221, 224, 226, 228, 230, 232, 234, 236, 237, 239, 241, 242,
106 243, 245, 246, 247, 248, 250, 250, 251, 252, 253, 254, 254,
107 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
108 255, 254, 254, 253, 252, 251, 250, 250, 248, 247, 246, 245,
109 243, 242, 241, 239, 237, 236, 234, 232, 230, 228, 226, 224,
110 221, 219, 217, 215, 212, 210, 207, 204, 202, 198, 196, 193,
111 190, 187, 184, 181, 178, 175, 171, 168, 165, 161, 158, 154,
112 150, 147, 143, 139, 136, 131, 128, 124, 120, 116, 112, 108,
113 104, 100, 96, 92, 88, 83, 79, 74, 71, 66, 62, 58,
114 53, 49, 45, 40, 36, 31, 27, 22, 18, 13, 9, 4
115 }
116};
117
118/* The raster, shape, streamer and registry definitions below are declared
119 * near their first users, in address order, and the linker commons at the end
120 * of the unit. CL places static .bss storage by identifier hash, so this
121 * changes no address. */
122
123/* Function start: 0x4408A0 */
125{
126 /* Expression statement rather than if: same code, one label fewer. */
127 ((struct TaggedAllocationHeader *)shape)[-1].signature != 0x6666656a &&
128 (exit_squadron("not jefftep"), 0);
129}
130
131/* Function start: 0x4408C0 */
132struct RLEShape *GetPreparedShapeData(struct Shape *shape)
133{
134 return ((struct TaggedAllocationHeader *)shape)[-1].preparedShape;
135}
136
137/* Function start: 0x4408D0 */
138short __stdcall GetShapeFrameCount(struct Shape *shape)
139{
141 return (short)((*(unsigned short *)&shape->frameOffsets[0] >> 2) - 1);
142}
143
144/* Function start: 0x4408F0 */
145void GetShapeFrameExtents(struct Shape *shape, short frame,
146 short *width, short *height,
147 short *leftExtent, short *topExtent)
148{
149 int rightExtent;
150 int bottom;
151 int frameOffset;
152 int left;
153 int top;
154 short *frameHeader;
155
156 frameOffset = (int)(short)(frame * 4 + 4);
157 /* One expression statement, like CheckHeapBlockSignature's test: CL 4.20
158 * gives it no label, which keeps DecodeShapeFrame's symbol context.
159 * Walk the contiguous extent words: the original retains two cursor
160 * increments even after loading all four values. */
161 frameOffset < (int)(unsigned short)shape->frameOffsets[0] &&
162 (frameHeader = &((struct ShapeFrame *)((unsigned char *)shape +
163 *(int *)((unsigned char *)shape + frameOffset)))->right,
164 rightExtent = *frameHeader++,
165 left = *frameHeader++,
166 top = *frameHeader++,
167 bottom = *frameHeader,
168 *width = (short)(left + rightExtent + 1),
169 *height = (short)(top + bottom + 1),
170 *leftExtent = (short)left,
171 *topExtent = (short)top);
172}
173
174/* Function start: 0x440960 */
175void DecodeShapeFrame(struct Shape *shape, short frame,
176 unsigned char *bitmap, int width, int height,
177 int leftExtent, int topExtent)
178{
179 int y;
180 unsigned short rowCode;
181 int x;
182 short maximumY;
183 short maximumX;
184 short sourceY;
185 unsigned char code;
186 unsigned char *destination;
187 unsigned char colour;
188 int frameOffset;
189 int skip;
190 unsigned short runLength;
191 unsigned char *commands;
192 short sourceX;
193 short rowCopyLength;
194 short runCopyLength;
195 int rowRight;
196 int runRight;
197
198 if (shape == 0 || frame < 0)
199 return;
200 frameOffset = (int)(short)(frame * 4 + 4);
201 if (frameOffset >= (int)(unsigned short)shape->frameOffsets[0])
202 return;
203
204 maximumX = (short)(width - 1);
205 maximumY = (short)(height - 1);
206 commands = (unsigned char *)shape +
207 *(int *)((unsigned char *)shape + frameOffset) + sizeof(struct ShapeFrame);
208 rowCode = *(unsigned short *)commands;
209 commands += 2;
210 while (rowCode != 0) {
211 sourceX = *(short *)commands;
212 commands += 2;
213 sourceY = *(short *)commands;
214 commands += 2;
215 x = leftExtent + sourceX;
216 y = topExtent + sourceY;
217 destination = bitmap + y * width + x;
218 if ((rowCode & 1) != 0) {
219 rowCode >>= 1;
220 while (rowCode != 0) {
221 code = *commands;
222 commands++;
223 if ((code & 1) != 0) {
224 code >>= 1;
225 colour = *commands;
226 commands++;
227 runLength = code;
228 rowCode = (unsigned short)(rowCode - runLength);
229 if (y >= 0 && y <= maximumY) {
230 runRight = x + runLength - 1;
231 if (x <= maximumX && runRight >= 0) {
232 skip = 0;
233 runCopyLength = (short)runLength;
234 if (x < 0) {
235 runCopyLength =
236 (short)(runCopyLength + (short)x);
237 skip = -x;
238 }
239 if (maximumX < runRight)
240 runCopyLength =
241 (short)(runCopyLength - runRight + maximumX);
242 memset(destination + skip, colour,
243 (short)runCopyLength);
244 }
245 }
246 x += runLength;
247 destination += runLength;
248 } else {
249 code >>= 1;
250 runLength = code;
251 rowCode = (unsigned short)(rowCode - runLength);
252 if (y >= 0 && y <= maximumY) {
253 runRight = x + runLength - 1;
254 if (x <= maximumX && runRight >= 0) {
255 skip = 0;
256 runCopyLength = (short)runLength;
257 if (x < 0) {
258 runCopyLength =
259 (short)(runCopyLength + (short)x);
260 skip = -x;
261 }
262 if (maximumX < runRight)
263 runCopyLength =
264 (short)(runCopyLength - runRight + maximumX);
265 memcpy(destination + skip, commands + skip,
266 (short)runCopyLength);
267 }
268 }
269 commands += runLength;
270 x += runLength;
271 destination += runLength;
272 }
273 }
274 } else {
275 rowCode >>= 1;
276 if (y >= 0 && y <= maximumY) {
277 rowRight = x + rowCode - 1;
278 if (x <= maximumX && rowRight >= 0) {
279 skip = 0;
280 rowCopyLength = (short)rowCode;
281 if (x < 0) {
282 rowCopyLength = (short)(rowCopyLength + (short)x);
283 skip = -x;
284 }
285 if (maximumX < rowRight)
286 rowCopyLength =
287 (short)(rowCopyLength - rowRight + maximumX);
288 memcpy(destination + skip, commands + skip,
289 (short)rowCopyLength);
290 }
291 }
292 commands += rowCode;
293 }
294 rowCode = *(unsigned short *)commands;
295 commands += 2;
296 }
297}
298
299/* Function start: 0x440BE0 */
300int SignExtendClipCoord(volatile short v)
301{
302 if ((unsigned short)v < 0xfdc0)
303 return (unsigned short)v;
304 return (int)(short)v;
305}
306/* Function start: 0x440C00 */
308 RasterClip *clip)
309{
310 int topOffset;
311 int nextOffset;
312 int rowStrideOffset;
313 int allocation;
314
315 if (viewport->pixels != stScreenView.pixels) {
316 for (allocation = 0; allocation < nViewAllocTotal; allocation++) {
317 if (apViewportAllocations[allocation] ==
318 viewport->pixels)
319 break;
320 }
321 if (allocation >= nViewAllocTotal)
322 exit_squadron("bad vport");
323 }
324 if (viewport->pixels == stScreenView.pixels)
325 DIBslam();
326 topOffset = SignExtendClipCoord(viewport->rowOffsets[viewport->top]);
327 nextOffset = SignExtendClipCoord(
328 viewport->rowOffsets[viewport->top + 1]);
329 rowStrideOffset = SignExtendClipCoord(
330 viewport->rowOffsets[viewport->top]);
331 surface->pixels = viewport->pixels + viewport->left + topOffset;
332 surface->maximumX = nextOffset - rowStrideOffset - 1;
333 surface->maximumY = viewport->bottom - viewport->top;
334 surface->field_C = 0;
335 surface->field_10 = 0;
336 clip->surface = surface;
337 clip->left = 0;
338 clip->top = 0;
339 clip->right = viewport->right - viewport->left;
340 clip->bottom = viewport->bottom - viewport->top;
341}
342
343static RasterSurface stRasterTarget; /* 0x004875a8 */
344static unsigned char abShapeTransformPixels[0xfa00]; /* 0x004875c0 */
345static RasterClip stRasterClip; /* 0x00496fc0 */
346/* Nothing in the shipped executable references this table. */
347static unsigned char abUnusedGrTable[0x670]; /* 0x00496fd8 */
348
349/* Function start: 0x440CF0 */
351{
353 &stRasterClip);
354}
355
356static unsigned char abSolidColourLookup[256]; /* 0x00497648 */
357
358/* Function start: 0x440D10 */
359void SetSolidColourTranslation(unsigned char colour)
360{
361 memset(abSolidColourLookup, colour, 255);
362 abSolidColourLookup[255] = 0xff;
364}
365
366static unsigned char abShapeRLEBuffer[0x100000]; /* 0x00497748 */
367
368/* Function start: 0x440D50 */
369void PrepareShapeRLEData(struct Shape *shape)
370{
371 void (*getExtents)(struct Shape *, short index,
372 short *width, short *height,
373 short *left, short *top) = GetShapeFrameExtents;
374 void (*decodeFrame)(struct Shape *, short, unsigned char *,
375 int, int, int, int) = DecodeShapeFrame;
376 unsigned char *bitmap;
377 unsigned char *pixel;
378 unsigned char *output;
379 int *frameOffset;
380 int frameCount;
381 short topExtent;
382 short height;
383 short leftExtent;
384 short width;
385 int frame;
386 int row;
387 int remaining;
388 int runLength;
389 int frameLeft;
390 int frameTop;
391 int frameRight;
392 int frameBottom;
393
395 if (GetPreparedShapeData(shape) != 0)
396 return;
397
398 *(int *)abShapeRLEBuffer =
399 *(const int *)"1.00";
400 frameCount = GetShapeFrameCount(shape);
401 memcpy(abShapeRLEBuffer + 4, &frameCount, sizeof(frameCount));
402 frameOffset = (int *)(abShapeRLEBuffer + 8);
403 memset(frameOffset, 0, frameCount * 8);
404 output = abShapeRLEBuffer + 8 + (frameCount << 3);
405
406 for (frame = 0; frame < frameCount; frame++) {
407 int frameStart = (int)(output - abShapeRLEBuffer);
408
409 memcpy(frameOffset, &frameStart, sizeof(frameStart));
410 frameOffset += 2;
411 getExtents(shape, (short)frame, &width, &height,
412 &leftExtent, &topExtent);
413 memcpy(output, &height, sizeof(height));
414 output += sizeof(height);
415 memcpy(output, &width, sizeof(width));
416 output += sizeof(width);
417 memcpy(output, &topExtent, sizeof(topExtent));
418 output += sizeof(topExtent);
419 memcpy(output, &leftExtent, sizeof(leftExtent));
420 output += sizeof(leftExtent);
421 frameLeft = -leftExtent;
422 frameTop = -topExtent;
423 frameRight = width - leftExtent - 1;
424 frameBottom = height - topExtent - 1;
425 memcpy(output, &frameLeft, sizeof(frameLeft));
426 output += sizeof(frameLeft);
427 memcpy(output, &frameTop, sizeof(frameTop));
428 output += sizeof(frameTop);
429 memcpy(output, &frameRight, sizeof(frameRight));
430 output += sizeof(frameRight);
431 memcpy(output, &frameBottom, sizeof(frameBottom));
432 output += sizeof(frameBottom);
433
434 bitmap = AllocateTaggedMemory(
435 (unsigned int)((int)width * height), 0);
436 pixel = bitmap;
437 memset(bitmap, 0xff, (unsigned int)((int)width * height));
438 decodeFrame(shape, (short)frame, bitmap, width, height,
439 leftExtent, topExtent);
440 for (row = 0; row < height; row++) {
441 remaining = width;
442 while (remaining > 0) {
443 if (*pixel != 0xff) {
444 unsigned char *runCode;
445
446 runCode = output++;
447 runLength = 0;
448 while (remaining != 0 && runLength < 0x7f &&
449 *pixel != 0xff) {
450 *output = *pixel;
451 runLength++;
452 remaining--;
453 output++;
454 pixel++;
455 }
456 *runCode = (unsigned char)(runLength * 2 + 1);
457 continue;
458 }
459 runLength = 0;
460 while (remaining != 0 && runLength < 0xff &&
461 *pixel == 0xff) {
462 runLength++;
463 remaining--;
464 pixel++;
465 }
466 *output++ = 1;
467 *output++ = (unsigned char)runLength;
468 }
469 *output++ = 0;
470 }
471 ReleasePacketHandle(bitmap);
472 }
473
474 if ((int)(output - abShapeRLEBuffer) > (int)sizeof(abShapeRLEBuffer))
475 exit_squadron("qq copy overflow");
476 {
477 struct RLEShape *preparedShape;
478
479 preparedShape = AllocateTaggedMemory(
480 (int)(output - abShapeRLEBuffer), 0);
481 memcpy(preparedShape, abShapeRLEBuffer,
482 (int)(output - abShapeRLEBuffer));
483 memcpy(&((struct TaggedAllocationHeader *)shape)[-1].preparedShape,
484 &preparedShape, sizeof(preparedShape));
485 }
486}
487
488/* Function start: 0x440FE0 */
489void DrawSpriteTransformed(Viewport *viewport, int x, int y,
490 struct Shape *shape, int frame,
491 int angle, int scaleX, int scaleY,
492 int flip, int blendMode)
493{
494 if (shape == 0 || frame < 0 || viewport->pixels == 0 ||
495 viewport->rowOffsets == 0 || frame >= GetShapeFrameCount(shape))
496 return;
497 PrepareShapeRLEData(shape);
498 ClipViewportToScreen(viewport);
499 if (flip != 0) {
500 if (flip == 0x10) {
501 scaleX = -scaleX;
502 } else if (flip == 0x20) {
503 scaleY = -scaleY;
504 } else if (flip == 0x30) {
505 scaleX = -scaleX;
506 scaleY = -scaleY;
507 } else {
508 exit_squadron("bad flip");
509 }
510 }
511 if (blendMode != 0) {
513 GetPreparedShapeData(shape), frame,
514 x - viewport->left, y - viewport->top,
516 angle * 10, scaleX * 256, scaleY * 256, 1);
517 } else {
519 GetPreparedShapeData(shape), frame,
520 x - viewport->left, y - viewport->top,
522 angle * 10, scaleX * 256, scaleY * 256, 0);
523 }
524}
525
526/* Function start: 0x441140 */
527void RasterLineHook(const void *marker)
528{
529 (void)marker;
530}
531
532/* Function start: 0x441150 */
533void DrawFontGlyph(char character, TextContext *context, int height,
534 int width, int y)
535{
536 int row;
537 unsigned char background;
538 unsigned char *characterData;
539 unsigned char *destination;
540 unsigned char fontBackground;
541 unsigned char colour;
542 unsigned char fontColour;
543 unsigned char *source;
544 Viewport *viewport;
545 int column;
546 unsigned char translated;
547 short characterIndex;
548
549 row = y;
550 viewport = context->viewport;
551 colour = context->colour;
552 background = context->backgroundColour;
553 characterData = context->font;
554 fontColour = characterData[2];
555 fontBackground = characterData[3];
556
557 abPaletteTranslation[fontColour] = colour;
558 abPaletteTranslation[fontBackground] = background;
559 characterIndex = (short)(signed char)character;
560 if (characterIndex != 0x81 && characterIndex != 0x84 &&
561 characterIndex != 0x8e && characterIndex != 0x94 &&
562 characterIndex != 0x99 && characterIndex != 0x9a &&
563 characterIndex != 0xe1) {
564 characterData = context->font + characterIndex;
565 source = context->font +
566 (((unsigned int)characterData[0x204] << 8) +
567 characterData[0x104]);
568 if (fontColour == colour && fontBackground == background) {
569 for (; height-- != 0; row++) {
570 if (viewport->top == row) {
571 if ((viewport->rowOffsets[row] & 0x8000) != 0)
572 destination = context->cursorX + viewport->pixels;
573 else
574 destination = viewport->rowOffsets[row] +
575 context->cursorX + viewport->pixels;
576 } else {
577 destination = viewport->rowOffsets[row] +
578 context->cursorX + viewport->pixels;
579 }
580 for (column = width; column-- != 0;) {
581 if (*source != 0xff)
582 *destination = *source;
583 source++;
584 destination++;
585 }
586 }
587 context->cursorX += context->font[4 + characterIndex];
588 } else {
589 unsigned char *translatedDestination;
590
591 for (; height-- != 0; row++) {
592 int isTopRow = viewport->top == row;
593
594 if (isTopRow) {
595 if ((viewport->rowOffsets[row] & 0x8000) != 0)
596 translatedDestination =
597 context->cursorX + viewport->pixels;
598 else
599 translatedDestination = viewport->rowOffsets[row] +
600 context->cursorX + viewport->pixels;
601 } else {
602 translatedDestination = viewport->rowOffsets[row] +
603 context->cursorX + viewport->pixels;
604 }
605 for (column = width; column-- != 0;) {
606 translated = abPaletteTranslation[*source];
607 if (translated != 0xff)
608 *translatedDestination = translated;
609 source++;
610 translatedDestination++;
611 }
612 }
613 context->cursorX += context->font[4 + characterIndex];
614 }
615 abPaletteTranslation[fontColour] = fontColour;
616 abPaletteTranslation[fontBackground] = fontBackground;
617 }
618}
619
620/* Function start: 0x441350 */
621void __copyline(void)
622{
623 RasterLineHook("__copyline");
624}
625
626/* Function start: 0x441360 */
627void __wipeline(void)
628{
629 RasterLineHook("__wipeline");
630}
631
632/* Function start: 0x441370 */
633void __stdcall MarkActivePaletteEntries(Viewport *viewport,
634 unsigned char *active)
635{
636 short rgb[3];
637 int index;
638
639 (void)viewport;
640 for (index = 0; index < 256; index++) {
641 GetPaletteEntry((short)index, rgb);
642 if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
643 active[index] = 1;
644 }
645}
646
647/* Function start: 0x4413C0 */
648void __stdcall GetPaletteEntry(short index, short *rgb)
649{
650 GetPaletteEntryAsWords(index, rgb);
651}
652
653/* Function start: 0x4413E0 */
654void __stdcall SetPaletteEntry(short index, short *rgb)
655{
656 DIBsetPalette(index, rgb);
657}
658
659/* Function start: 0x441400 */
660void DrawSpriteDefault(Viewport *viewport, short x, short y,
661 struct Shape *shape, short frame)
662{
663 if (shape != 0 && frame >= 0)
664 DrawSpriteTransformed(viewport, x, y, shape, frame,
665 0, 0x100, 0x100, 0, 0);
666}
667
668/* Function start: 0x441450 */
669void CaptureSpriteBackground(Viewport *viewport, unsigned char *background,
670 short x, short y, struct Shape *shape,
671 short frame)
672{
673 short copyLength;
674 unsigned char *commands;
675 unsigned char *save;
676 unsigned char *screen;
677 int runRight;
678 unsigned char *pixels;
679 unsigned char code;
680 unsigned char colour;
681 unsigned short rowCode;
682 short xOffset;
683 short yOffset;
684 short minimumX;
685 short maximumX;
686 short minimumY;
687 short maximumY;
688 int drawX;
689 int drawY;
690 int skip;
691
692 save = background;
693 if (save == 0)
694 return;
695 if (shape == 0)
696 return;
697 if (frame < 0)
698 return;
699 frame++;
700 frame <<= 2;
701 if ((unsigned short)shape->frameOffsets[0] > frame) {
702 minimumX = viewport->left;
703 maximumX = viewport->right;
704 minimumY = viewport->top;
705 maximumY = viewport->bottom;
706 commands = (unsigned char *)shape +
707 *(int *)(frame + (unsigned char *)shape);
708 commands += sizeof(struct ShapeFrame);
709 pixels = viewport->pixels;
710 rowCode = *(unsigned short *)commands;
711 commands += 2;
712 while (rowCode != 0) {
713 xOffset = *(short *)commands;
714 commands += 2;
715 yOffset = *(short *)commands;
716 commands += 2;
717 drawX = x + xOffset;
718 drawY = y + yOffset;
719 screen = SPRITE_ROW_OFFSET(viewport, drawY) + drawX + pixels;
720 if ((rowCode & 1) != 0) {
721 rowCode >>= 1;
722 while (rowCode > 0) {
723 code = *commands;
724 commands++;
725 if ((code & 1) != 0) {
726 code >>= 1;
727 rowCode = (unsigned short)(rowCode - code);
728 colour = *commands;
729 commands++;
730 if (minimumY <= drawY && maximumY >= drawY) {
731 runRight = code + drawX - 1;
732 if (maximumX >= drawX &&
733 minimumX <= runRight) {
734 copyLength = code;
735 skip = 0;
736 if (minimumX > drawX) {
737 copyLength -= minimumX - drawX;
738 skip += minimumX - drawX;
739 }
740 if (maximumX < runRight)
741 copyLength -= runRight - maximumX;
742 memcpy(save, skip + screen, copyLength);
743 save += copyLength;
744 }
745 }
746 screen += code;
747 drawX += code;
748 } else {
749 code >>= 1;
750 rowCode = (unsigned short)(rowCode - code);
751 if (minimumY <= drawY && maximumY >= drawY) {
752 runRight = code + drawX - 1;
753 if (maximumX >= drawX &&
754 minimumX <= runRight) {
755 copyLength = code;
756 skip = 0;
757 if (minimumX > drawX) {
758 copyLength -= minimumX - drawX;
759 skip += minimumX - drawX;
760 }
761 if (maximumX < runRight)
762 copyLength -= runRight - maximumX;
763 memcpy(save, skip + screen, copyLength);
764 save += copyLength;
765 }
766 }
767 commands += code;
768 screen += code;
769 drawX += code;
770 }
771 }
772 } else {
773 rowCode >>= 1;
774 if (minimumY <= drawY && maximumY >= drawY) {
775 runRight = rowCode + drawX - 1;
776 if (maximumX >= drawX && minimumX <= runRight) {
777 copyLength = rowCode;
778 skip = 0;
779 if (minimumX > drawX) {
780 copyLength -= minimumX - drawX;
781 skip += minimumX - drawX;
782 }
783 if (maximumX < runRight)
784 copyLength -= runRight - maximumX;
785 memcpy(save, skip + screen, copyLength);
786 save += copyLength;
787 }
788 }
789 commands += rowCode;
790 }
791 rowCode = *(unsigned short *)commands;
792 commands += 2;
793 }
794 }
795 (void)colour;
796}
797
798/* Function start: 0x441740 */
799void RestoreSpriteBackground(Viewport *viewport, unsigned char *background,
800 short x, short y, struct Shape *shape,
801 short frame)
802{
803 short copyLength;
804 unsigned int runRight;
805 unsigned char colour;
806 short minimumX;
807 int drawY;
808 int skip;
809 unsigned char *pixels;
810 short xOffset;
811 short maximumX;
812 short maximumY;
813 unsigned char *save;
814 short yOffset;
815 short minimumY;
816 unsigned short rowCode;
817 unsigned char code;
818 unsigned char *screen;
819 unsigned char *commands;
820 int drawX;
821
822 save = background;
823 if (save == 0)
824 return;
825 if (shape == 0)
826 return;
827 if (frame < 0)
828 return;
829 frame++;
830 frame <<= 2;
831 if ((unsigned short)shape->frameOffsets[0] <= frame)
832 goto refreshScreen;
833 minimumX = viewport->left;
834 maximumX = viewport->right;
835 minimumY = viewport->top;
836 maximumY = viewport->bottom;
837 commands = (unsigned char *)shape +
838 *(int *)(frame + (unsigned char *)shape);
839 commands += sizeof(struct ShapeFrame);
840 pixels = viewport->pixels;
841 rowCode = *(unsigned short *)commands;
842 commands += 2;
843 while (rowCode != 0) {
844 xOffset = *(short *)commands;
845 commands += 2;
846 yOffset = *(short *)commands;
847 commands += 2;
848 drawX = x + xOffset;
849 drawY = y + yOffset;
850 screen = SPRITE_ROW_OFFSET(viewport, drawY) + drawX + pixels;
851 if ((rowCode & 1) != 0) {
852 rowCode >>= 1;
853 while (rowCode > 0) {
854 code = *commands;
855 commands++;
856 if ((code & 1) != 0) {
857 code >>= 1;
858 rowCode = (unsigned short)(rowCode - code);
859 colour = *commands;
860 commands++;
861 if (minimumY <= drawY && maximumY >= drawY) {
862 skip = code + drawX - 1;
863 if (maximumX >= drawX &&
864 minimumX <= skip) {
865 copyLength = code;
866 runRight = skip;
867 skip = 0;
868 if (minimumX > drawX) {
869 copyLength -= minimumX - drawX;
870 skip += minimumX - drawX;
871 }
872 if (maximumX < (int)runRight)
873 copyLength -= (int)runRight - maximumX;
874 memcpy(skip + screen, save, copyLength);
875 save += copyLength;
876 }
877 }
878 screen += code;
879 drawX += code;
880 } else {
881 code >>= 1;
882 rowCode = (unsigned short)(rowCode - code);
883 if (minimumY <= drawY && maximumY >= drawY) {
884 skip = code + drawX - 1;
885 if (maximumX >= drawX &&
886 minimumX <= skip) {
887 copyLength = code;
888 runRight = skip;
889 skip = 0;
890 if (minimumX > drawX) {
891 copyLength -= minimumX - drawX;
892 skip += minimumX - drawX;
893 }
894 if (maximumX < (int)runRight)
895 copyLength -= (int)runRight - maximumX;
896 memcpy(skip + screen, save, copyLength);
897 save += copyLength;
898 }
899 }
900 commands += code;
901 screen += code;
902 drawX += code;
903 }
904 }
905 } else {
906 rowCode >>= 1;
907 if (minimumY <= drawY && maximumY >= drawY) {
908 skip = rowCode + drawX - 1;
909 if (maximumX >= drawX && minimumX <= skip) {
910 copyLength = rowCode;
911 runRight = skip;
912 skip = 0;
913 if (minimumX > drawX) {
914 copyLength -= minimumX - drawX;
915 skip += minimumX - drawX;
916 }
917 if (maximumX < (int)runRight)
918 copyLength -= (int)runRight - maximumX;
919 memcpy(skip + screen, save, copyLength);
920 save += copyLength;
921 }
922 }
923 commands += rowCode;
924 }
925 rowCode = *(unsigned short *)commands;
926 commands += 2;
927 }
928refreshScreen:
929 if (viewport->pixels == stScreenView.pixels)
930 DIBslam();
931 (void)colour;
932}
933
934/* Function start: 0x441A40 */
935void DrawSolidColourSprite(Viewport *viewport, short x, short y,
936 struct Shape *shape, short frame,
937 short colour)
938{
939 SetSolidColourTranslation((unsigned char)colour);
940 DrawSpriteTransformed(viewport, x, y, shape, frame, 0,
941 0x100, 0x100, 0, 1);
942}
943
944/* Function start: 0x441A90 */
945void CopyViewportContents(Viewport *source, Viewport *destination)
946{
947 RasterSurface sourceSurface;
948 RasterClip destinationClip;
949 int blitResult;
950 RasterClip sourceClip;
951 RasterSurface destinationSurface;
952
953 ValidateViewportBounds(source, &sourceSurface, &sourceClip);
954 ValidateViewportBounds(destination, &destinationSurface,
955 &destinationClip);
956 blitResult = BlitRasterClip(
957 &sourceClip, 0, 0, &destinationClip, 0, 0, 0xffffffff);
958 if (blitResult != 0)
959 abs(blitResult);
960}
961
962/* Function start: 0x441AE0 */
963void ClearViewport(Viewport *viewport, short colour)
964{
965 if (viewport->pixels != 0 && viewport->rowOffsets != 0) {
966 ClipViewportToScreen(viewport);
968 }
969 if (viewport == &stScreenView) {
970 DIBslam();
971 DIBslamReal();
972 }
973}
974
975/* Function start: 0x441B20 */
976void DrawViewportPixel(Viewport *viewport, short x, short y,
977 short colour)
978{
979 ClipViewportToScreen(viewport);
981 (int)x - viewport->left,
982 (int)y - viewport->top, colour);
983}
984
985/* Function start: 0x441B60 */
986int GetViewportPixel(Viewport *viewport, short x, short y)
987{
988 ClipViewportToScreen(viewport);
990 (int)x - viewport->left,
991 (int)y - viewport->top);
992}
993
994/* Function start: 0x441BA0 */
995void DrawViewportLine(Viewport *viewport, short x1, short y1,
996 short x2, short y2, short colour)
997{
998 ClipViewportToScreen(viewport);
1000 x1 - viewport->left, y1 - viewport->top,
1001 x2 - viewport->left, y2 - viewport->top,
1002 0, colour);
1003}
1004
1005/* Function start: 0x441BF0 */
1006void DrawViewportPolygonHook(Viewport *viewport, const ShortPoint *points,
1007 int count, int colour)
1008{
1009 (void)viewport;
1010 (void)points;
1011 (void)count;
1012 (void)colour;
1013}
1014
1015/* Function start: 0x441C00 */
1016void triangle(Viewport *viewport, const ShortPoint *points, int colour)
1017{
1018 DrawViewportPolygonHook(viewport, points, 3, colour);
1019 if (viewport->pixels == stScreenView.pixels)
1020 DIBslam();
1021 RasterLineHook("triangle");
1022}
1023
1024/* Function start: 0x441C40 */
1026{
1027 if (viewport->pixels == stScreenView.pixels)
1028 DIBslam();
1029 RasterLineHook("shaded_triangle");
1030}
1031
1032/* Function start: 0x441C70 */
1033void DrawFilledViewportRect(Viewport *viewport, short left, short top,
1034 short right, short bottom, short colour)
1035{
1036 int row;
1037 int height;
1038
1039 height = bottom - top;
1040 ClipViewportToScreen(viewport);
1041 for (row = 0; row <= height; row++) {
1043 left - viewport->left,
1044 row + top - viewport->top,
1045 right - viewport->left,
1046 row + top - viewport->top,
1047 0, colour);
1048 }
1049}
1050
1051/* Function start: 0x441CF0 */
1052void DrawViewportBorder(Viewport *viewport, short left, short top,
1053 short right, short bottom, short colour)
1054{
1055 ClipViewportToScreen(viewport);
1057 left - viewport->left, top - viewport->top,
1058 right - viewport->left, top - viewport->top,
1059 0, colour);
1061 left - viewport->left, bottom - viewport->top,
1062 right - viewport->left, bottom - viewport->top,
1063 0, colour);
1065 left - viewport->left, top - viewport->top,
1066 left - viewport->left, bottom - viewport->top,
1067 0, colour);
1069 right - viewport->left, top - viewport->top,
1070 right - viewport->left, bottom - viewport->top,
1071 0, colour);
1072}
1073
1074/* Function start: 0x441DD0 */
1075void DrawViewportEllipse(Viewport *viewport, short x, short y,
1076 short verticalRadius, short horizontalRadius,
1077 short colour)
1078{
1079 ClipViewportToScreen(viewport);
1081 horizontalRadius, verticalRadius, colour);
1082 if (viewport->pixels == stScreenView.pixels)
1083 DIBslam();
1084}
1085
1086/* Function start: 0x441E20 */
1087void FillViewportEllipse(Viewport *viewport, short x, short y,
1088 short verticalRadius, short horizontalRadius,
1089 short colour)
1090{
1091 ClipViewportToScreen(viewport);
1093 horizontalRadius, verticalRadius, colour);
1094 if (viewport->pixels == stScreenView.pixels)
1095 DIBslam();
1096}
1097
1098/* Function start: 0x441E70 */
1099void DrawViewportEllipseShadow(Viewport *viewport, short x, short y,
1100 short verticalRadius,
1101 short horizontalRadius, short colour)
1102{
1103 ClipViewportToScreen(viewport);
1105 horizontalRadius, verticalRadius, colour);
1106 if (viewport->pixels == stScreenView.pixels)
1107 DIBslam();
1108}
1109
1110/* Function start: 0x441EC0 */
1111void shadow_draw(Viewport *viewport)
1112{
1113 if (viewport->pixels == stScreenView.pixels)
1114 DIBslam();
1115 RasterLineHook("shadow_draw");
1116}
1117
1118/* Function start: 0x441EF0 */
1119void DrawShapeFrameScaled(Viewport *viewport, struct Shape *shape,
1120 int frame, int x, int y, int angle, int scale)
1121{
1122 if (shape != 0 && frame >= 0)
1123 DrawSpriteTransformed(viewport, x, y, shape, frame,
1124 angle, scale, scale, 0, 0);
1125}
1126
1127/* The original packet frame begins with these four signed extents. */
1134
1135/* Function start: 0x441F30 */
1136void GetShapeFrameCorners(unsigned char *shape, int frame, int x, int y,
1137 ShortPoint *corners, int *cornerCount)
1138{
1139 int frameOffset;
1140
1141 *cornerCount = 0;
1142 CheckHeapBlockSignature((struct Shape *)shape);
1143 frame++;
1144 frame <<= 2;
1145 frameOffset = frame;
1146 if ((int)*(unsigned short *)(shape + 4) >= frameOffset) {
1147 ShapeFrameExtents *extents;
1148 int left;
1149 int top;
1150 int right;
1151 int bottom;
1152
1153 shape += *(int *)(shape + frameOffset);
1154 extents = (ShapeFrameExtents *)shape;
1155 left = extents->left;
1156 left += x;
1157 right = extents->right;
1158 right += x;
1159 top = extents->top;
1160 top += y;
1161 bottom = extents->bottom;
1162 bottom += y;
1163 corners[0].x = (short)left;
1164 corners[0].y = (short)top;
1165 corners[1].x = (short)left;
1166 corners[1].y = (short)bottom;
1167 corners[2].x = (short)right;
1168 corners[2].y = (short)bottom;
1169 corners[3].x = (short)right;
1170 corners[3].y = (short)top;
1171 *cornerCount = 4;
1172 }
1173}
1174
1175/* Function start: 0x441FC0 */
1176void DrawSpriteScaled(Viewport *viewport, short x, short y,
1177 struct Shape *shape, short frame, short angle,
1178 short scale, short flip)
1179{
1180 DrawSpriteTransformed(viewport, x, y, shape, frame, angle,
1181 scale, scale, flip, 0);
1182}
1183
1184/* Function start: 0x442000 */
1185void DrawSolidColourSpriteScaled(Viewport *viewport, short x, short y,
1186 struct Shape *shape, short frame,
1187 short angle, short scale, short flip,
1188 short colour)
1189{
1190 SetSolidColourTranslation((unsigned char)colour);
1191 DrawSpriteTransformed(viewport, x, y, shape, frame, angle,
1192 scale, scale, flip, 1);
1193}
1194
1195/* Function start: 0x442050 */
1196short GetTransformedShapeBounds(Viewport *viewport, short x, short y,
1197 struct Shape *shape, short frame,
1198 short angle, short scale, short flip,
1199 ShortRect *bounds)
1200{
1201 struct ShapeFrame *cursor;
1202 int frameOffset;
1203 int frameLeft;
1204 int frameRight;
1205 int frameTop;
1206 int frameBottom;
1207 int extentX;
1208 int extentY;
1209 int cosine;
1210 int topEdge;
1211 int sine;
1212 int transformedHeight;
1213 int transformedWidth;
1214 int leftEdge;
1215 short left;
1216 short top;
1217 short right;
1218 short bottom;
1219 int inside;
1220
1221 inside = 0;
1222 if (shape == 0) {
1223 if (viewport->left > x || viewport->right < x ||
1224 viewport->top > y || viewport->bottom < y)
1225 inside = 0;
1226 else
1227 inside = 1;
1228 return (short)inside;
1229 }
1231 frameOffset = frame;
1232 cursor = (struct ShapeFrame *)shape;
1233 frameOffset++;
1234 frameOffset <<= 2;
1235 if ((unsigned short)shape->frameOffsets[0] >= frameOffset) {
1236 cursor = (struct ShapeFrame *)((unsigned char *)cursor +
1237 *(int *)(frameOffset + (unsigned char *)cursor));
1238 frameRight = cursor->left;
1239 frameLeft = cursor->right;
1240 frameTop = cursor->top;
1241 frameBottom = cursor->bottom;
1242 cosine = aawAbsoluteTrig[0][angle] * scale;
1243 cosine >>= 8;
1244 sine = aawAbsoluteTrig[1][angle] * scale;
1245 sine >>= 8;
1246 if (cosine == 0)
1247 cosine++;
1248 if (sine == 0)
1249 sine++;
1250 extentX = frameLeft + frameRight;
1251 extentY = frameBottom + frameTop;
1252 transformedHeight = sine * extentX + cosine * extentY;
1253 if ((char)transformedHeight != 0)
1254 transformedHeight += 0x100;
1255 transformedHeight >>= 8;
1256 transformedWidth = sine * extentY + cosine * extentX;
1257 if ((char)transformedWidth != 0)
1258 transformedWidth += 0x100;
1259 transformedWidth >>= 8;
1260 if (cosine == 0)
1261 cosine = 1;
1262 if (sine == 0)
1263 sine = 1;
1264 leftEdge = (sine * frameTop >> 8) + x - (cosine * frameRight >> 8);
1265 topEdge = y - (cosine * frameTop >> 8) - (sine * frameRight >> 8);
1266 top = (short)topEdge;
1267 bottom = (short)(top + transformedHeight);
1268 extentY = sine * extentY;
1269 extentY >>= 8;
1270 extentY++;
1271 extentY = leftEdge - extentY;
1272 left = (short)extentY;
1273 right = (short)(extentY + transformedWidth);
1274 if (viewport->left > right || viewport->right < left ||
1275 viewport->top > bottom || top > viewport->bottom) {
1276 inside = 0;
1277 } else {
1278 bounds->left = left;
1279 bounds->right = right;
1280 bounds->top = top;
1281 bounds->bottom = bottom;
1282 inside = 1;
1283 }
1284 }
1285 (void)flip;
1286 return (short)inside;
1287}
1288
1289/* Function start: 0x442200 */
1290void BlitViewportScanlineRuns(Viewport *source, Viewport *destination,
1291 const ScreenViewportGeometry *geometry)
1292{
1293 const short *run;
1294 unsigned char *sourcePixels;
1295 unsigned char *destinationPixels;
1296 unsigned short width;
1297 short sourceLeft;
1298 short sourceTop;
1299 short destinationX;
1300 short sourceY;
1301
1302 if (source->pixels != 0 && destination->pixels != 0) {
1303 run = &geometry->originX;
1304 sourceLeft = *run++;
1305 sourceTop = *run++;
1306 while ((destinationX = *run++) != -1) {
1307 sourceY = *run++;
1308 width = (unsigned short)*run++;
1309 sourcePixels = source->pixels +
1310 source->rowOffsets[sourceY - sourceTop] - sourceLeft +
1311 destinationX;
1312 destinationPixels = destination->pixels +
1313 destination->rowOffsets[sourceY] + destinationX;
1314 memcpy(destinationPixels, sourcePixels, width);
1315 }
1316 if (destination->pixels == stScreenView.pixels)
1317 DIBslam();
1318 }
1319}
1320
1321/* Function start: 0x4422D0 */
1322void fizzle_fade(Viewport *source, Viewport *destination)
1323{
1324 if (destination->pixels == stScreenView.pixels)
1325 DIBslam();
1326 RasterLineHook("fizzle_fade");
1327 (void)source;
1328}
1329
1330/* Function start: 0x442300 */
1331void snow_viewport(Viewport *viewport, int effect, unsigned short colour)
1332{
1333 (void)effect;
1334 (void)colour;
1335 if (viewport->pixels == stScreenView.pixels)
1336 DIBslam();
1337 RasterLineHook("snow_viewport");
1338}
1339
1340/* Function start: 0x442330 */
1342{
1343 if (bIxAudioEnabled != 0)
1345 (dwIxStreamerStatus & 4) == 0;
1346}
1347
1348/* Function start: 0x442350 */
1350{
1351 if (bIxAudioEnabled != 0)
1353}
1354
1355/* Function start: 0x442370 */
1357{
1358 if (bIxAudioEnabled != 0) {
1359 ix_streamer_configure(3, (void *)1);
1360 ix_streamer_configure(0, window);
1363 }
1364}
1365
1366static int bStreamerAudioRunning; /* 0x00597748 */
1367static char szStreamerPathBuffer[128]; /* 0x00597750 */
1368
1369/* Function start: 0x4423B0 */
1370void Streamer_open(const char *streamName)
1371{
1372 char *streamsDirectory;
1373
1374 if (bIxAudioEnabled != 0) {
1375 streamsDirectory = LocateStreamsDirOnDisc();
1376 if (streamsDirectory == 0) {
1377 ShowNoticeMessageBox("Unable to locate streamed music.\n");
1378 exit_squadron("");
1379 }
1380 sprintf(szStreamerPathBuffer, "%s%s",
1381 streamsDirectory, streamName);
1382 SoundDebugPrintf("Streamer_open %s", szStreamerPathBuffer);
1385 }
1386}
1387
1388/* Function start: 0x442430 */
1390{
1391 if (bIxAudioEnabled != 0 &&
1392 bStreamerAudioRunning == 0) {
1394 SoundDebugPrintf("Streamer_play");
1396 }
1397}
1398
1399/* Function start: 0x442460 */
1401{
1402 if (bIxAudioEnabled != 0 &&
1403 bStreamerAudioRunning != 0) {
1404 SoundDebugPrintf("Streamer_stop");
1407 }
1408}
1409
1410/* Function start: 0x442490 */
1412{
1413 if (bIxAudioEnabled == 0)
1414 return 0;
1415 return ix_streamer_get_trigger();
1416}
1417
1418/* Function start: 0x4424B0 */
1420{
1421 if (bIxAudioEnabled != 0)
1423}
1424
1425/* Function start: 0x4424D0 */
1426void Streamer_trigger(int trigger)
1427{
1428 if (bIxAudioEnabled != 0) {
1429 if (bStreamerAudioRunning == 0) {
1430 ForceStreamerTrigger(trigger);
1431 return;
1432 }
1433 SoundDebugPrintf("Streamer_trigger %d", trigger);
1434 if (trigger >= 0)
1435 ix_streamer_set_trigger((char)trigger);
1436 if (bStreamerAudioRunning == 0)
1437 Streamer_play();
1438 }
1439}
1440
1441/* Function start: 0x442520 */
1442void SetStreamerIntensity(unsigned char intensity)
1443{
1444 if (bIxAudioEnabled != 0) {
1445 ix_streamer_set_intensity(intensity);
1446 if (bStreamerAudioRunning == 0)
1447 Streamer_play();
1448 }
1449}
1450
1451/* Function start: 0x442550 */
1452void ForceStreamerTrigger(int trigger)
1453{
1454 if (bIxAudioEnabled != 0) {
1455 SoundDebugPrintf("FORCE");
1456 if (trigger >= 0)
1457 ix_streamer_force_trigger((char)trigger);
1458 if (bStreamerAudioRunning == 0)
1459 Streamer_play();
1460 }
1461}
1462
1463/* Function start: 0x442590 */
1464void SetMusicStreamVolume(unsigned short volume)
1465{
1466 if (bIxAudioEnabled != 0)
1467 ix_streamer_set_volume(volume);
1468}
1469
1470/* Function start: 0x4425B0 */
1471unsigned int GetMusicStreamVolume(void)
1472{
1473 if (bIxAudioEnabled == 0)
1474 return 0;
1475 return ix_streamer_get_volume();
1476}
1477
1478/* Function start: 0x4425D0 */
1480{
1481 if (bIxAudioEnabled != 0) {
1482 SoundDebugPrintf("Streamer_close");
1484 }
1485}
1486
1487/* Function start: 0x4425F0 */
1489{
1490 if (bIxAudioEnabled != 0)
1492}
1493
1494const char szGameRegistryKey[42] =
1495 "Software\\Origin Systems\\WC: Kilrathi Saga"; /* 0x004631c8 */
1496const char szCheaterRegistryValue[8] = "Cheater"; /* 0x004631f8 */
1497
1498/* Function start: 0x442600 */
1500{
1501 HKEY key;
1502 DWORD type;
1503 DWORD size;
1504 int enabled = 0;
1505
1506 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1508 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) {
1509 type = REG_DWORD;
1510 size = sizeof(int);
1511 RegQueryValueExA(key, szCheaterRegistryValue, 0, &type,
1512 (LPBYTE)&enabled, &size);
1513 RegCloseKey(key);
1514 }
1515 if (enabled != 0)
1516 OutputDebugStringA("reg cheating\n");
1517 else
1518 OutputDebugStringA("reg not cheating\n");
1519 return enabled;
1520}
1521
1522/* Linker commons defined here; LINK orders them by identifier hash. */
1523int nUnusedFlightProfileTicksA; /* 0x00598888 */
1524int nUnusedFlightProfileTicksB; /* 0x0059888c */
1525int nUnusedFlightProfileTicksC; /* 0x00598890 */
1527short nSavedRoomCtrlX; /* 0x005988b4 */
1528unsigned char *pRecRoomRoster; /* 0x005988b8 */
1529unsigned char *pMissionCampaignInfo; /* 0x005988bc */
1530struct Shape *apRecRoomFigureShapes[3]; /* 0x005988c0 */
1531PilotRecord aPilotEntriesList[9]; /* 0x005988d0 */
void(__cdecl *pIxFree)(void *)
int nUnusedFlightProfileTicksB
Definition gr.c:1524
Viewport stRoomScreenViewport
Definition gr.c:1526
ConstellationObjectDefinition * pConstellationDefinitionsPtr
Definition gr.c:1532
int nUnusedFlightProfileTicksC
Definition gr.c:1525
short nMusicTrackComplete
Definition music.c:17
int nViewAllocTotal
Definition gameflow.c:25
Viewport stScreenView
Definition launch.c:50
int nUnusedFlightProfileTicksA
Definition gr.c:1523
PilotRecord * apWingmanPilotsList[8]
Definition gr.c:1533
unsigned int dwIxStreamerStatus
Definition ix.h:521
short nSavedRoomCtrlX
Definition gr.c:1527
unsigned char * apViewportAllocations[128]
Definition gameflow.c:26
int bIxAudioEnabled
Definition winmain.c:30
unsigned char * pMissionCampaignInfo
Definition gr.c:1529
unsigned char * pRecRoomRoster
Definition gr.c:1528
PilotRecord aPilotEntriesList[9]
Definition gr.c:1531
struct Shape * apRecRoomFigureShapes[3]
Definition gr.c:1530
static RasterSurface stRasterTarget
Definition gr.c:343
static unsigned char abSolidColourLookup[256]
Definition gr.c:356
static unsigned char abShapeTransformPixels[0xfa00]
Definition gr.c:344
static unsigned char abPaletteTranslation[256]
Definition gr.c:14
static unsigned char abShapeRLEBuffer[0x100000]
Definition gr.c:366
static RasterClip stRasterClip
Definition gr.c:345
static char szStreamerPathBuffer[128]
Definition gr.c:1367
const char szGameRegistryKey[42]
Definition gr.c:1494
static unsigned short aawAbsoluteTrig[2][360]
Definition gr.c:51
static int bStreamerAudioRunning
Definition gr.c:1366
const char szCheaterRegistryValue[8]
Definition gr.c:1496
static unsigned char abUnusedGrTable[0x670]
Definition gr.c:347
int right
Definition wc1base.h:168
RasterSurface * surface
Definition wc1base.h:165
int bottom
Definition wc1base.h:169
unsigned char * pixels
Definition wc1base.h:157
short bottom
Definition gr.c:1132
short right
Definition gr.c:1129
short bottom
Definition wc1base.h:180
short top
Definition wc1base.h:179
short left
Definition wc1base.h:178
short right
Definition wc1base.h:177
int frameOffsets[1]
Definition wc1base.h:92
short y
Definition wcdata.h:416
short x
Definition wcdata.h:415
short top
Definition wcdata.h:441
short left
Definition wcdata.h:440
short right
Definition wcdata.h:442
short bottom
Definition wcdata.h:443
unsigned int signature
Definition wc1base.h:330
unsigned char colour
Definition wc1base.h:240
unsigned char * font
Definition wc1base.h:239
unsigned char backgroundColour
Definition wc1base.h:241
short cursorX
Definition wc1base.h:237
Viewport * viewport
Definition wc1base.h:236
unsigned char * pixels
Definition wc1base.h:74
short right
Definition wc1base.h:78
short bottom
Definition wc1base.h:79
unsigned short * rowOffsets
Definition wc1base.h:75
short left
Definition wc1base.h:76
short top
Definition wc1base.h:77
Umbrella header for the game core.
void SoundDebugPrintf(const char *fmt,...)
Definition mono.c:382
#define SPRITE_ROW_OFFSET(viewport, row)
Definition wc1base.h:83
int FillRasterClip(RasterClip *clip, int colour)
void ForceStreamerTrigger(int trigger)
Definition gr.c:1452
void * AllocateTaggedMemory(int size, unsigned short flags)
Definition ending.c:31
void DrawViewportLine(Viewport *viewport, short x1, short y1, short x2, short y2, short colour)
Definition gr.c:995
void DrawViewportEllipseShadow(Viewport *viewport, short x, short y, short verticalRadius, short horizontalRadius, short colour)
Definition gr.c:1099
short GetTransformedShapeBounds(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short angle, short scale, short flip, ShortRect *bounds)
Definition gr.c:1196
void DIBslam(void)
Definition dib.c:513
void ClearStreamerTrigger(void)
Definition gr.c:1419
void snow_viewport(Viewport *viewport, int effect, unsigned short colour)
Definition gr.c:1331
void CheckHeapBlockSignature(struct Shape *shape)
Definition gr.c:124
void SetMusicStreamVolume(unsigned short volume)
Definition gr.c:1464
int GetStreamerTrigger(void)
Definition gr.c:1411
int ReadRasterClipPixel(RasterClip *clip, int x, int y)
void __stdcall MarkActivePaletteEntries(Viewport *viewport, unsigned char *active)
Definition gr.c:633
unsigned int SetRasterClipPixel(RasterClip *clip, int x, int y, int colour)
void ix_streamer_set_intensity(unsigned char intensity)
Definition streamer.cpp:386
unsigned int DrawClippedLine(RasterClip *clip, int x1, int y1, int x2, int y2, int mode, int colour)
void __copyline(void)
Definition gr.c:621
void __stdcall GetPaletteEntry(short index, short *rgb)
Definition gr.c:648
void SetStreamerIntensity(unsigned char intensity)
Definition gr.c:1442
void PrepareShapeRLEData(struct Shape *shape)
Definition gr.c:369
void DrawShapeFrameScaled(Viewport *viewport, struct Shape *shape, int frame, int x, int y, int angle, int scale)
Definition gr.c:1119
void InitializeAudioStreamer(HWND window)
Definition gr.c:1356
void DrawViewportPixel(Viewport *viewport, short x, short y, short colour)
Definition gr.c:976
void DrawSpriteScaled(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short angle, short scale, short flip)
Definition gr.c:1176
void GetShapeFrameCorners(unsigned char *shape, int frame, int x, int y, ShortPoint *corners, int *cornerCount)
Definition gr.c:1136
int ReadCheaterFlagFromRegistry(void)
Definition gr.c:1499
void SetSolidColourTranslation(unsigned char colour)
Definition gr.c:359
void DrawSpriteDefault(Viewport *viewport, short x, short y, struct Shape *shape, short frame)
Definition gr.c:660
unsigned int DrawRasterEllipse(RasterClip *clip, int x, int y, int horizontalRadius, int verticalRadius, int colour)
void ix_streamer_configure(int option, void *value)
Definition streamer.cpp:102
void __stdcall SetPaletteEntry(short index, short *rgb)
Definition gr.c:654
struct RLEShape * GetPreparedShapeData(struct Shape *shape)
Definition gr.c:132
void DIBslamReal(void)
Definition dib.c:519
void ValidateViewportBounds(Viewport *viewport, RasterSurface *surface, RasterClip *clip)
Definition gr.c:307
void Streamer_close(void)
Definition gr.c:1479
void ix_streamer_audio_play(void)
Definition streamer.cpp:336
int GetViewportPixel(Viewport *viewport, short x, short y)
Definition gr.c:986
void DIBsetPalette(short index, short *rgb)
Definition dib.c:794
void BlitViewportScanlineRuns(Viewport *source, Viewport *destination, const ScreenViewportGeometry *geometry)
Definition gr.c:1290
void Streamer_open(const char *streamName)
Definition gr.c:1370
void DrawFilledViewportRect(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition gr.c:1033
int SignExtendClipCoord(volatile short v)
Definition gr.c:300
short __stdcall GetShapeFrameCount(struct Shape *shape)
Definition gr.c:138
int RotateRLEImage(RasterClip *clip, struct RLEShape *shape, int frame, int x, int y, unsigned char *scratch, unsigned int angleTenths, int scaleX, int scaleY, unsigned int flags)
int ix_streamer_open_stream_file(char *path)
Definition streamer.cpp:123
unsigned int GetMusicStreamVolume(void)
Definition gr.c:1471
void shadow_draw(Viewport *viewport)
Definition gr.c:1111
void ClipViewportToScreen(Viewport *viewport)
Definition gr.c:350
char * LocateStreamsDirOnDisc(void)
Definition winsys.c:188
void RestoreSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, struct Shape *shape, short frame)
Definition gr.c:799
void ix_streamer_set_trigger(char trigger)
Definition streamer.cpp:402
char ix_streamer_get_trigger(void)
Definition streamer.cpp:417
void DrawSolidColourSprite(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short colour)
Definition gr.c:935
void ix_streamer_destroy(void)
Definition streamer.cpp:81
void DrawViewportPolygonHook(Viewport *viewport, const ShortPoint *points, int count, int colour)
Definition gr.c:1006
void DrawViewportEllipse(Viewport *viewport, short x, short y, short verticalRadius, short horizontalRadius, short colour)
Definition gr.c:1075
void ShutdownAudioStreamer(void)
Definition gr.c:1488
void UpdateStreamerStoppedFlag(void)
Definition gr.c:1341
void DrawViewportBorder(Viewport *viewport, short left, short top, short right, short bottom, short colour)
Definition gr.c:1052
void SetPaletteTranslationTable(const unsigned char *translation)
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:963
void exit_squadron(const char *msg)
Definition main.c:122
unsigned short ix_streamer_get_volume(void)
Definition streamer.cpp:491
void triangle(Viewport *viewport, const ShortPoint *points, int colour)
Definition gr.c:1016
void __wipeline(void)
Definition gr.c:627
void RasterLineHook(const void *marker)
Definition gr.c:527
unsigned int FillRasterEllipse(RasterClip *clip, int x, int y, int horizontalRadius, int verticalRadius, int colour)
void SignalAudioMixerWakeEvent(void)
Definition gr.c:1349
void DrawSolidColourSpriteScaled(Viewport *viewport, short x, short y, struct Shape *shape, short frame, short angle, short scale, short flip, short colour)
Definition gr.c:1185
void Streamer_play(void)
Definition gr.c:1389
int ix_streamer_init(void)
Definition streamer.cpp:51
void CaptureSpriteBackground(Viewport *viewport, unsigned char *background, short x, short y, struct Shape *shape, short frame)
Definition gr.c:669
void GetPaletteEntryAsWords(short i, short *rgb)
Definition dib.c:831
void ReleasePacketHandle(void *handle)
Definition ending.c:50
void DrawFontGlyph(char character, TextContext *context, int height, int width, int y)
Definition gr.c:533
void ShowNoticeMessageBox(const char *text)
Definition winmain.c:657
void ix_streamer_force_trigger(char trigger)
Definition streamer.cpp:423
void fizzle_fade(Viewport *source, Viewport *destination)
Definition gr.c:1322
void shaded_triangle(Viewport *viewport)
Definition gr.c:1025
void ix_streamer_audio_stop(void)
Definition streamer.cpp:349
void ix_streamer_close_stream_file(void)
Definition streamer.cpp:297
void ix_streamer_set_volume(unsigned short volume)
Definition streamer.cpp:475
void DrawSpriteTransformed(Viewport *viewport, int x, int y, struct Shape *shape, int frame, int angle, int scaleX, int scaleY, int flip, int blendMode)
Definition gr.c:489
void DecodeShapeFrame(struct Shape *shape, short frame, unsigned char *bitmap, int width, int height, int leftExtent, int topExtent)
Definition gr.c:175
void Streamer_trigger(int trigger)
Definition gr.c:1426
void GetShapeFrameExtents(struct Shape *shape, short frame, short *width, short *height, short *leftExtent, short *topExtent)
Definition gr.c:145
void CopyViewportContents(Viewport *source, Viewport *destination)
Definition gr.c:945
int BlitRasterClip(RasterClip *source, int sourceX, int sourceY, RasterClip *destination, int destinationX, int destinationY, unsigned int colour)
void Streamer_stop(void)
Definition gr.c:1400
void FillViewportEllipse(Viewport *viewport, short x, short y, short verticalRadius, short horizontalRadius, short colour)
Definition gr.c:1087