31 return (
short)(rand() % (int)n);
39 srand((
unsigned int)time(0));
45 return (
unsigned short)rand();
55 return lo + rand() % (span + 1);
61 if (n != -1 && n != 0)
62 return (
short)(rand() % (n + 1));
69 double leftValue = (double)left * (1.0 / 256.0);
70 double rightValue = (double)right * (1.0 / 256.0);
72 return (
long)(leftValue * rightValue * 256.0);
78 float numeratorValue = (float)((
double)numerator * (1.0 / 256.0));
79 float denominatorValue;
82 denominatorValue = (float)((
double)denominator * (1.0 / 256.0));
84 denominatorValue = 1.0f;
85 return (
long)(numeratorValue / denominatorValue * 256.0);
103 return (
long)(asin(value * 0.00390625f) *
110 return (
long)(acos(value * 0.00390625f) *
117 return (
long)(sqrt(value * 0.00390625f) * 256.0);
123 double scaledX = (double)x * (1.0 / 256.0);
124 double scaledY = (double)y * (1.0 / 256.0);
128 return (
long)(sqrt(scaledX + scaledY) * 256.0);
134 double x = (double)vector->
x * (1.0 / 256.0);
135 double y = (double)vector->
y * (1.0 / 256.0);
136 double z = (double)vector->
z * (1.0 / 256.0);
141 return (
long)(sqrt(x + y + z) * 256.0);
180 return *(
const unsigned short *)p;
196 struct Shape *shape,
short frame)
198 short frameTableOffset;
201 frameTableOffset = (short)(frame * 4);
202 if ((
int)frameTableOffset < (
int)(
unsigned short)shape->
frameOffsets[0]) {
203 frameTableOffset = (short)(frameTableOffset + 4);
204 shape = (
struct Shape *)((
unsigned char *)shape +
205 *(
unsigned short *)((
unsigned char *)shape + frameTableOffset));
207 bounds[2] = (short)(frameData->
right + x);
208 bounds[0] = (short)(x - frameData->
left);
209 bounds[1] = (short)(y - frameData->
top);
210 bounds[3] = (short)(frameData->
bottom + y);
219 if (rect[0] <= x && x <= rect[2] &&
220 rect[1] <= y && y <= rect[3])
235 const char *lineStart;
248 while (*cursor ==
' ')
252 while (lineWidth <
right) {
255 if (value ==
'\n' || value ==
'\r')
263 if (lineWidth >=
right) {
269 if (*cursor !=
' ') {
270 while (*cursor !=
' ' && cursor > text) {
276 if (cursor <= text) {
278 "FATAL : INVALID STRING '%s'n", text);
296 while (lineStart < cursor) {
309 }
while (finished == 0);
318 unsigned int glyphWidth;
321 if (character ==
'\n') {
327 }
else if (character ==
'\r') {
330 }
else if (character != 0) {
332 fontHeight = *(
short *)font;
333 glyphWidth = font[4 + (int)(
signed char)character];
336 DrawFontGlyph(character, context, fontHeight, glyphWidth, cursorY);
352 unsigned short rowLength;
353 unsigned char command;
354 int frameTableOffset;
358 if (shape != 0 && frame >= 0) {
359 frameTableOffset = frame * 4 + 4;
360 if (frameTableOffset < (
unsigned short)shape->
frameOffsets[0]) {
361 run = (
unsigned char *)shape +
362 *(
int *)((
unsigned char *)shape + frameTableOffset) +
364 rowLength = *(
unsigned short *)run;
366 while (rowLength != 0) {
368 if ((rowLength & 1) != 0) {
370 while (rowLength != 0) {
373 if ((command & 1) != 0) {
377 (
unsigned short)(rowLength - command);
382 (
unsigned short)(rowLength - command);
392 rowLength = *(
unsigned short *)run;
unsigned char bEscapePressedFlag
short nViewportOriginPositionX
int nMouseCursorDamageRight
int nEventMousePointerDamageBottom
int bMouseCursorDamagePending
TextContext * pCurTextContext
short nPacketDecompressPending
short nViewportOriginPositionY
int nMousePointerDamageTopValue
short nCurrentPacketDecompressScratchSegment
unsigned short wPacketDecompressInputSize
int nMouseCursorDamageLeft
volatile int bFrameTickPendingFlag
int nSavedDosInterruptVector
Umbrella header for the game core.
#define DEGREES_TO_RADIANS
void SystemDebugPrintf(const char *fmt,...)
void __stdcall DrawTextCharacter(char character)
short __stdcall IsPointInRect(short x, short y, const short *rect)
unsigned short __stdcall GetFontCharWidth(char i)
long MultiplyFixed(int left, int right)
char PumpMessagesDuringWait(void)
void __stdcall SetWholePaletteFromTriplets(unsigned char *palette)
void __stdcall SplitPackedPoint(ShortPoint point, short *p)
long Vector_magnitude(const FixedVector *vector)
void __stdcall SetTextCursor(unsigned short a, unsigned short b)
void *__stdcall IdentityHandle(void *v)
void __stdcall SeedRandomFromClock(int seed)
long SinFixed(short degrees)
void __stdcall SetTextContext(TextContext *context)
long PlanarMagnitude(int x, int y)
void ResetTextCursor(void)
void ReleaseVideoResourcesHook(void)
void WaitForVerticalBlankThunk(void)
void ClearDebugPauseFlags(void)
long CosFixed(short degrees)
void __stdcall DrawTextString(const char *text)
long DivideFixed(int numerator, int denominator)
short RandomBelow(short n)
unsigned short __stdcall FontHeight(const void *p)
long Magnitude(int value)
void DIBwholePaletteFromTriplets(unsigned char *palette)
short __stdcall GetShapeFrameBounds(short *bounds, short x, short y, struct Shape *shape, short frame)
void DrawFontGlyph(char character, TextContext *context, int height, int width, int y)
void DIBwaitForVerticalBlank(void)
void __stdcall AppendTextCharacter(char character)
int __stdcall MeasureShapeFrameStorage(struct Shape *shape, short frame)
short __stdcall RandomInRange(short lo, short hi)
unsigned short RandomWord(void)
short RandomBelowOrEqual(short n)