34 0xd7b70ee0, 0x4340, 0x11cf,
35 { 0xb0, 0x63, 0x00, 0x20, 0xaf, 0xc2, 0xcd, 0x35 }
38 0x593817a0, 0x7db3, 0x11cf,
39 { 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56 }
42 0x6c14db80, 0xa733, 0x11ce,
43 { 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
46 0xb3a6f3e0, 0x2b43, 0x11cf,
47 { 0xa2, 0xde, 0x00, 0xaa, 0x00, 0xb9, 0x33, 0x56 }
50 0x6c14db81, 0xa733, 0x11ce,
51 { 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
54 0x57805885, 0x6eec, 0x11cf,
55 { 0x94, 0x41, 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27 }
58 0x6c14db84, 0xa733, 0x11ce,
59 { 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
62 0x6c14db85, 0xa733, 0x11ce,
63 { 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60 }
158 frameRate += adjustment;
165 "Space Flight Max FPS : %.1f",
204 errorFile = fopen(
"direct.err",
"wt+");
229 IDirectDraw2_SetCooperativeLevel(
232 DIBerror(
"DIBreInstall DIBcascade Failure", err);
243 LPDIRECTDRAW directDraw;
248 result = DirectDrawCreate(0, &directDraw, 0);
250 DIBerror(
"DIBInstall Create", result);
252 result = IDirectDraw_QueryInterface(
256 DIBerror(
"DIBInstall Unable to acquire DirectDraw2 interface", result);
259 result = IDirectDraw2_SetCooperativeLevel(
262 result = IDirectDraw2_SetCooperativeLevel(
265 DIBerror(
"DIBmakeInstall SetCooperativeLevel", result);
269 if (cascadeResult == 0)
270 DIBerror(
"DIBinstall DIBcascade Failure", result);
288 DDSURFACEDESC surface;
303 if (reportedResult != 0)
304 *reportedResult = result;
305 if (result != DD_OK) {
310 OutputDebugStringA(
"320x200 achieved...testing\n");
315 if (reportedResult != 0)
316 *reportedResult = result;
317 if (result != DD_OK) {
322 OutputDebugStringA(
"640x400 achieved...testing\n");
327 if (reportedResult != 0)
328 *reportedResult = result;
329 if (result != DD_OK) {
334 OutputDebugStringA(
"640x480 achieved...testing\n");
342 result = IDirectDrawSurface_Restore(
344 if (reportedResult != 0)
345 *reportedResult = result;
347 DIBerror(
"DIBcascade Unable to restore surface (secondary)",
351 result = IDirectDrawSurface_Restore(
353 if (reportedResult != 0)
354 *reportedResult = result;
356 DIBerror(
"DIBcascade Unable to restore surface", result);
358 result = IDirectDrawSurface_SetPalette(
362 DIBerror(
"DIBcascade CreatePalette", result);
366 OutputDebugStringA(
" acquiring surface:");
367 memset(&surface, 0,
sizeof(surface));
368 surface.dwSize =
sizeof(surface);
369 surface.dwFlags = DDSD_CAPS;
370 surface.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
371 result = IDirectDraw2_CreateSurface(
374 if (reportedResult != 0)
375 *reportedResult = result;
376 if (result != DD_OK) {
377 OutputDebugStringA(
" failed\n");
384 OutputDebugStringA(
" successful\n locking surface:");
385 result = IDirectDrawSurface_Lock(
388 if (reportedResult != 0)
389 *reportedResult = result;
390 if (result != DD_OK) {
391 OutputDebugStringA(
" failed\n");
399 IDirectDrawSurface_Unlock(
401 IDirectDrawSurface_Release(
404 OutputDebugStringA(
" successful\n");
424 DDSURFACEDESC surface;
425 unsigned char entries[0x400];
429 memset(&surface, 0,
sizeof(surface));
430 surface.dwSize =
sizeof(surface);
431 surface.dwFlags = DDSD_CAPS;
432 surface.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_MODEX;
433 result = IDirectDraw2_CreateSurface(
437 DIBerror(
"DIBmakeDIB CreateSurface (primary)", result);
445 entries[offset + 3] = 0;
447 }
while (offset < 0x400);
449 result = IDirectDraw2_CreatePalette(
453 DIBerror(
"DIBmakeDIB CreatePalette", result);
455 result = IDirectDrawSurface_SetPalette(
459 DIBerror(
"DIBmakeDIB CreatePalette", result);
462 memset(&surface, 0,
sizeof(surface));
463 surface.dwSize =
sizeof(surface);
464 surface.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
465 surface.dwWidth = 320;
466 surface.dwHeight = 200;
467 surface.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
468 result = IDirectDraw2_CreateSurface(
472 DIBerror(
"DIBmakeDIB CreateSurface (secondary)", result);
496 DIBerror(
"DIBdestroyDIB secondary->Release", result);
502 DIBerror(
"DIBdestroyDIB primary->Release", result);
521 DDSURFACEDESC surface;
522 unsigned char *destination;
523 unsigned char *source;
524 RECT destinationRect;
532 memset(&surface, 0,
sizeof(surface));
533 surface.dwSize =
sizeof(surface);
542 result = IDirectDrawSurface_Lock(
544 0, &surface, DDLOCK_WAIT, 0);
546 result = IDirectDrawSurface_Lock(
548 0, &surface, DDLOCK_WAIT, 0);
550 if (result != DD_OK) {
551 if (result == DDERR_SURFACELOST) {
553 result = IDirectDrawSurface_Restore(
556 DIBerror(
"DIBslamReal Unable to restore surface (secondary)",
559 result = IDirectDrawSurface_Restore(
562 DIBerror(
"DIBslamReal Unable to restore surface (primary)",
566 result = IDirectDrawSurface_Lock(
568 0, &surface, DDLOCK_WAIT, 0);
570 result = IDirectDrawSurface_Lock(
572 0, &surface, DDLOCK_WAIT, 0);
575 DIBerror(
"DIBslamReal Unable to lock restored surface",
578 IDirectDrawSurface_Unlock(
580 DIBerror(
"DIBslamReal secondary->Lock", result);
584 destination = surface.lpSurface;
587 IDirectDraw2_WaitForVerticalBlank(
594 destination += surface.lPitch;
601 IDirectDrawSurface_Unlock(
604 IDirectDrawSurface_Unlock(
613 destinationRect.left = 0;
614 destinationRect.top = 0;
615 destinationRect.right = 639;
616 destinationRect.bottom = 399;
619 sourceRect.right = 319;
620 sourceRect.bottom = 199;
622 destinationRect.top = 40;
623 destinationRect.bottom = 439;
626 result = IDirectDrawSurface_Blt(
630 if (result != DD_OK) {
631 if (result == DDERR_SURFACELOST) {
632 result = IDirectDrawSurface_Restore(
635 DIBerror(
"DIBslamReal (BLIT) Unable to restore surface (primary)",
637 result = IDirectDrawSurface_Restore(
640 DIBerror(
"DIBslamReal (BLIT) Unable to restore surface (secondary)",
642 result = IDirectDrawSurface_Blt(
647 DIBerror(
"DIBslamReal (BLIT) Unable to blit to restored surface (primary)",
650 DIBerror(
"DIBslamReal primary->Blt", result);
667 unsigned char *destination;
668 unsigned char *source;
669 DDSURFACEDESC surface;
673 int destinationOffset;
695 width = right - left + 1;
696 height = bottom - top + 1;
697 memset(&surface, 0,
sizeof(surface));
698 surface.dwSize =
sizeof(surface);
699 result = IDirectDrawSurface_Lock(
702 if (result != DD_OK) {
703 IDirectDrawSurface_Unlock(
705 DIBerror(
"DIBupdate primary->Lock", result);
708 destinationOffset = surface.lPitch * top;
709 destinationOffset += left;
710 destination = (
unsigned char *)surface.lpSurface + destinationOffset;
712 sourceOffset += left;
714 IDirectDraw2_WaitForVerticalBlank(
717 memcpy(destination, source, width);
718 destination += surface.lPitch;
722 IDirectDrawSurface_Unlock(
774 unsigned char entries[0x400];
782 entries[offset + 3] = 0;
784 }
while (offset < 0x400);
786 result = IDirectDrawPalette_SetEntries(
788 (LPPALETTEENTRY)entries);
790 DIBerror(
"DIBramPalette SetEntries", result);
817 result = IDirectDrawPalette_SetEntries(
820 DIBerror(
"DIBsetPalette SetEntries", result);
822 result = IDirectDrawSurface_SetPalette(
826 DIBerror(
"DIBmakeDIB CreatePalette", result);
843 unsigned char entries[0x400];
847 IDirectDraw2_WaitForVerticalBlank(
850 unsigned char value = palette[0];
852 palette = palette + 3;
854 entries[offset] = value;
857 entries[offset + 1] = value;
860 entries[offset + 2] = value;
861 entries[offset + 3] = 0;
864 }
while (offset < 0x400);
866 error = IDirectDrawPalette_SetEntries(
868 (LPPALETTEENTRY)entries);
870 DIBerror(
"DIBsetWholePalette SetEntries", error);
872 error = IDirectDrawSurface_SetPalette(
875 DIBerror(
"DIBmakeDIB CreatePalette", error);
881 unsigned char entries[0x400];
885 IDirectDraw2_WaitForVerticalBlank(
888 unsigned char value = (
unsigned char)palette[0];
890 palette = palette + 3;
892 entries[offset] = value;
893 value = (
unsigned char)palette[-2];
895 entries[offset + 1] = value;
896 value = (
unsigned char)palette[-1];
898 entries[offset + 2] = value;
899 entries[offset + 3] = 0;
902 }
while (offset < 0x400);
904 error = IDirectDrawPalette_SetEntries(
906 (LPPALETTEENTRY)entries);
908 DIBerror(
"DIBsetWholePalette SetEntries", error);
910 error = IDirectDrawSurface_SetPalette(
913 DIBerror(
"DIBmakeDIB CreatePalette", error);
919 IDirectDraw2_WaitForVerticalBlank(
927 case DDERR_ALREADYINITIALIZED:
928 return "DDERR_ALREADYINITIALIZED";
929 case DDERR_CANNOTATTACHSURFACE:
930 return "DDERR_CANNOTATTACHSURFACE";
931 case DDERR_CANNOTDETACHSURFACE:
932 return "DDERR_CANNOTDETACHSURFACE";
933 case DDERR_CURRENTLYNOTAVAIL:
934 return "DDERR_CURRENTLYNOTAVAIL";
935 case DDERR_EXCEPTION:
936 return "DDERR_EXCEPTION";
938 return "DDERR_GENERIC";
939 case DDERR_HEIGHTALIGN:
940 return "DDERR_HEIGHTALIGN";
941 case DDERR_INCOMPATIBLEPRIMARY:
942 return "DDERR_INCOMPATIBLEPRIMARY";
943 case DDERR_INVALIDCAPS:
944 return "DDERR_INVALIDCAPS";
945 case DDERR_INVALIDCLIPLIST:
946 return "DDERR_INVALIDCLIPLIST";
947 case DDERR_INVALIDMODE:
948 return "DDERR_INVALIDMODE";
949 case DDERR_INVALIDOBJECT:
950 return "DDERR_INVALIDOBJECT";
951 case DDERR_INVALIDPARAMS:
952 return "DDERR_INVALIDPARAMS";
953 case DDERR_INVALIDPIXELFORMAT:
954 return "DDERR_INVALIDPIXELFORMAT";
955 case DDERR_INVALIDRECT:
956 return "DDERR_INVALIDRECT";
957 case DDERR_LOCKEDSURFACES:
958 return "DDERR_LOCKEDSURFACES";
961 case DDERR_NOALPHAHW:
962 return "DDERR_NOALPHAHW";
963 case DDERR_NOCLIPLIST:
964 return "DDERR_NOCLIPLIST";
965 case DDERR_NOCOLORCONVHW:
966 return "DDERR_NOCOLORCONVHW";
967 case DDERR_NOCOOPERATIVELEVELSET:
968 return "DDERR_NOCOOPERATIVELEVELSET";
969 case DDERR_NOCOLORKEY:
970 return "DDERR_NOCOLORKEY";
971 case DDERR_NOCOLORKEYHW:
972 return "DDERR_NOCOLORKEYHW";
973 case DDERR_NODIRECTDRAWSUPPORT:
974 return "DDERR_NODIRECTDRAWSUPPORT";
975 case DDERR_NOEXCLUSIVEMODE:
976 return "DDERR_NOEXCLUSIVEMODE";
978 return "DDERR_NOFLIPHW";
980 return "DDERR_NOGDI";
981 case DDERR_NOMIRRORHW:
982 return "DDERR_NOMIRRORHW";
984 return "DDERR_NOTFOUND";
985 case DDERR_NOOVERLAYHW:
986 return "DDERR_NOOVERLAYHW";
987 case DDERR_NORASTEROPHW:
988 return "DDERR_NORASTEROPHW";
989 case DDERR_NOROTATIONHW:
990 return "DDERR_NOROTATIONHW";
991 case DDERR_NOSTRETCHHW:
992 return "DDERR_NOSTRETCHHW";
993 case DDERR_NOT4BITCOLOR:
994 return "DDERR_NOT4BITCOLOR";
995 case DDERR_NOT4BITCOLORINDEX:
996 return "DDERR_NOT4BITCOLORINDEX";
997 case DDERR_NOT8BITCOLOR:
998 return "DDERR_NOT8BITCOLOR";
999 case DDERR_NOTEXTUREHW:
1000 return "DDERR_NOTEXTUREHW";
1001 case DDERR_NOVSYNCHW:
1002 return "DDERR_NOVSYNCHW";
1003 case DDERR_NOZBUFFERHW:
1004 return "DDERR_NOZBUFFERHW";
1005 case DDERR_NOZOVERLAYHW:
1006 return "DDERR_NOZOVERLAYHW";
1007 case DDERR_OUTOFCAPS:
1008 return "DDERR_OUTOFCAPS";
1009 case DDERR_OUTOFMEMORY:
1010 return "DDERR_OUTOFMEMORY";
1011 case DDERR_OUTOFVIDEOMEMORY:
1012 return "DDERR_OUTOFVIDEOMEMORY";
1013 case DDERR_OVERLAYCANTCLIP:
1014 return "DDERR_OVERLAYCANTCLIP";
1015 case DDERR_OVERLAYCOLORKEYONLYONEACTIVE:
1016 return "DDERR_OVERLAYCOLORKEYONLYONEACTIVE";
1017 case DDERR_PALETTEBUSY:
1018 return "DDERR_PALETTEBUSY";
1019 case DDERR_COLORKEYNOTSET:
1020 return "DDERR_COLORKEYNOTSET";
1021 case DDERR_SURFACEALREADYATTACHED:
1022 return "DDERR_SURFACEALREADYATTACHED";
1023 case DDERR_SURFACEALREADYDEPENDENT:
1024 return "DDERR_SURFACEALREADYDEPENDENT";
1025 case DDERR_SURFACEBUSY:
1026 return "DDERR_SURFACEBUSY";
1027 case DDERR_CANTLOCKSURFACE:
1028 return "DDERR_CANTLOCKSURFACE";
1029 case DDERR_SURFACEISOBSCURED:
1030 return "DDERR_SURFACEISOBSCURED";
1031 case DDERR_SURFACELOST:
1032 return "DDERR_SURFACELOST";
1033 case DDERR_SURFACENOTATTACHED:
1034 return "DDERR_SURFACENOTATTACHED";
1035 case DDERR_TOOBIGHEIGHT:
1036 return "DDERR_TOOBIGHEIGHT";
1037 case DDERR_TOOBIGSIZE:
1038 return "DDERR_TOOBIGSIZE";
1039 case DDERR_TOOBIGWIDTH:
1040 return "DDERR_TOOBIGWIDTH";
1041 case DDERR_UNSUPPORTED:
1042 return "DDERR_UNSUPPORTED";
1043 case DDERR_UNSUPPORTEDFORMAT:
1044 return "DDERR_UNSUPPORTEDFORMAT";
1045 case DDERR_UNSUPPORTEDMASK:
1046 return "DDERR_UNSUPPORTEDMASK";
1047 case DDERR_VERTICALBLANKINPROGRESS:
1048 return "DDERR_VERTICALBLANKINPROGRESS";
1049 case DDERR_WASSTILLDRAWING:
1050 return "DDERR_WASSTILLDRAWING";
1052 return "DDERR_XALIGN";
1053 case DDERR_INVALIDDIRECTDRAWGUID:
1054 return "DDERR_INVALIDDIRECTDRAWGUID";
1055 case DDERR_DIRECTDRAWALREADYCREATED:
1056 return "DDERR_DIRECTDRAWALREADYCREATED";
1057 case DDERR_NODIRECTDRAWHW:
1058 return "DDERR_NODIRECTDRAWHW";
1059 case DDERR_PRIMARYSURFACEALREADYEXISTS:
1060 return "DDERR_PRIMARYSURFACEALREADYEXISTS";
1061 case DDERR_NOEMULATION:
1062 return "DDERR_NOEMULATION";
1063 case DDERR_REGIONTOOSMALL:
1064 return "DDERR_REGIONTOOSMALL";
1065 case DDERR_CLIPPERISUSINGHWND:
1066 return "DDERR_CLIPPERISUSINGHWND";
1067 case DDERR_NOCLIPPERATTACHED:
1068 return "DDERR_NOCLIPPERATTACHED";
1070 return "DDERR_NOHWND";
1071 case DDERR_HWNDSUBCLASSED:
1072 return "DDERR_HWNDSUBCLASSED";
1073 case DDERR_HWNDALREADYSET:
1074 return "DDERR_HWNDALREADYSET";
1075 case DDERR_NOPALETTEATTACHED:
1076 return "DDERR_NOPALETTEATTACHED";
1077 case DDERR_NOPALETTEHW:
1078 return "DDERR_NOPALETTEHW";
1079 case DDERR_BLTFASTCANTCLIP:
1080 return "DDERR_BLTFASTCANTCLIP";
1082 return "DDERR_NOBLTHW";
1083 case DDERR_NODDROPSHW:
1084 return "DDERR_NODDROPSHW";
1085 case DDERR_OVERLAYNOTVISIBLE:
1086 return "DDERR_OVERLAYNOTVISIBLE";
1087 case DDERR_NOOVERLAYDEST:
1088 return "DDERR_NOOVERLAYDEST";
1089 case DDERR_INVALIDPOSITION:
1090 return "DDERR_INVALIDPOSITION";
1091 case DDERR_NOTAOVERLAYSURFACE:
1092 return "DDERR_NOTAOVERLAYSURFACE";
1093 case DDERR_EXCLUSIVEMODEALREADYSET:
1094 return "DDERR_EXCLUSIVEMODEALREADYSET";
1095 case DDERR_NOTFLIPPABLE:
1096 return "DDERR_NOTFLIPPABLE";
1097 case DDERR_CANTDUPLICATE:
1098 return "DDERR_CANTDUPLICATE";
1099 case DDERR_NOTLOCKED:
1100 return "DDERR_NOTLOCKED";
1101 case DDERR_CANTCREATEDC:
1102 return "DDERR_CANTCREATEDC";
1104 return "DDERR_NODC";
1105 case DDERR_WRONGMODE:
1106 return "DDERR_WRONGMODE";
1107 case DDERR_IMPLICITLYCREATED:
1108 return "DDERR_IMPLICITLYCREATED";
1109 case DDERR_NOTPALETTIZED:
1110 return "DDERR_NOTPALETTIZED";
1111 case DDERR_UNSUPPORTEDMODE:
1112 return "DDERR_UNSUPPORTEDMODE";
1113 case DDERR_NOMIPMAPHW:
1114 return "DDERR_NOMIPMAPHW";
1115 case DDERR_INVALIDSURFACETYPE:
1116 return "DDERR_INVALIDSURFACETYPE";
1117 case DDERR_DCALREADYCREATED:
1118 return "DDERR_DCALREADYCREATED";
1119 case DDERR_CANTPAGELOCK:
1120 return "DDERR_CANTPAGELOCK";
1121 case DDERR_CANTPAGEUNLOCK:
1122 return "DDERR_CANTPAGEUNLOCK";
1123 case DDERR_NOTPAGELOCKED:
1124 return "DDERR_NOTPAGELOCKED";
1126 return "<undefined>";
static unsigned char abDIBPixelBackup[0xfa00]
static unsigned int DAT_00476640
void DIBpixelBufferHook(void)
static HWND hDIBParentWindow
static int nUnusedDIBValue
const GUID IID_IDirectDrawSurface2
static unsigned char * pDIBImage
static int nFrameDeadlineMs
static unsigned int nDIBFrameHeight
static LPDIRECTDRAWSURFACE pPrimarySurface
static char szDIBFailureString[0x98]
const GUID IID_IDirectDrawPalette
static unsigned int nDIBFrameWidth
static unsigned char abDIBPaletteQuads[1024]
static unsigned int DAT_00476644
static LPDIRECTDRAW2 pDirectDraw2
const GUID IID_IDirectDrawClipper
static unsigned char szFrameRateLabel[32]
static int bPendingDIBSlam
static int nUnusedDIBLevel
static int nDIBCascadeLevel
unsigned int GetDIBWidth(void)
static unsigned char abUnusedDIBRect[8]
static int nPreviousFrameTimeMs
const GUID IID_IDirectDraw
static LPDIRECTDRAWPALETTE pDirectDrawPalette
static int bSpaceFlightFrameTiming
static char szSpaceFlightFpsCapMessage[0x80]
const GUID CLSID_DirectDraw
static LPDIRECTDRAWSURFACE pSecondarySurface
const GUID CLSID_DirectDrawClipper
static unsigned char abUnusedDIBArea[12]
const GUID IID_IDirectDrawSurface
static float fCinematicFrameRate
static int nUnusedDIBData
unsigned int GetDIBHeight(void)
static float fSpaceFlightFrameRate
short asObjScreenScalesArray[SPACE_OBJECT_COUNT]
signed char acViableTargetList[16]
signed char aShipWeaponsTable[10][0x47]
const GUID guidDirectDraw2
short asObjAfterburnerVelocities[SPACE_OBJECT_COUNT]
MouseCursorState stMouseCursorState
int bDirectDrawModeCascadeEnabled
short nEyeRollTargetValue
short awPaletteRgbWordsList[0x300]
CampaignState stCampaignState
short asObjectFlipArray[SPACE_OBJECT_COUNT]
signed char acPreviousAttackers[16]
short nCurrentHazardFieldTotal
signed char cCurrentNavPtIdx
FixedVector vPreviousStarFieldMotion
unsigned char * allocation
Umbrella header for the game core.
#define COM_RELEASE(surface)
void RefreshMouseCursorDisplay(void)
void DIBwholePaletteFromWords(short *palette)
HWND GetDIBWindowHandle(void)
void RestoreMouseCursorBackground(void)
void SetSpaceFlightFrameTiming(void)
void ReportSpaceFlightMaxFps(float adjustment)
void ThrottleFrameAndDrawFps(HDC dc)
void DIBinstall(HWND window)
void DIBpositionWindow(void)
char * DirectDrawResultToText(int result)
void DrawMouseCursor(void)
void DIBsetPalette(short index, short *rgb)
int DIBcascade(int mode, int *reportedResult)
void CaptureMouseCursorBackground(void)
void ServiceSoundSystem(void)
unsigned char * GetDIBPixelBuffer(void)
void UpdateStreamerStoppedFlag(void)
void CachePaletteEntryFromWords(short index, short *rgb)
void DIBwholePaletteFromTriplets(unsigned char *palette)
void SetHudMessageText(char *text, unsigned short colour, unsigned short duration)
void GetPaletteEntryAsWords(short i, short *rgb)
void DIBupdate(int left, int top, int right, int bottom)
void DIBwaitForVerticalBlank(void)
void DIBerror(const char *tag, int hr)
void SetCinematicFrameTiming(void)
#define SPACE_OBJECT_COUNT