Changeset 705
- Timestamp:
- Mar 19, 2013, 4:00:23 PM (12 years ago)
- Location:
- Daodan
- Files:
-
- 2 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/makefile
r692 r705 17 17 OUT = build/binkw32.dll 18 18 19 SRC = src/Daodan.c src/Daodan_BSL.c src/Daodan_Character.c src/Daodan_Cheater.c src/Daodan_Console.c src/Daodan_GL.c src/Daodan_Patch.c src/Daodan_Persistence.c src/Daodan_Utility.c src/Daodan_Win32.c src/ Daodan_WindowHack.c src/Inifile_Reader.c src/_DLLInfo.rc19 SRC = src/Daodan.c src/Daodan_BSL.c src/Daodan_Character.c src/Daodan_Cheater.c src/Daodan_Console.c src/Daodan_GL.c src/Daodan_Patch.c src/Daodan_Persistence.c src/Daodan_Utility.c src/Daodan_Win32.c src/Inifile_Reader.c src/_DLLInfo.rc 20 20 DEST = $(patsubst src/%.rc,build/%.o,$(patsubst src/%.c,build/%.o,$(SRC))) 21 21 -
Daodan/src/BFW_Motoko_Draw.h
r694 r705 2 2 #define BFW_MOTOKO_DRAW_H 3 3 4 typedef struct 4 typedef struct M3tDisplayMode 5 5 { 6 6 unsigned short Width; … … 8 8 unsigned short Depth; 9 9 unsigned short __unused; 10 } M3tDisplayMode; 10 } M3tDisplayMode; // 0x0010: (size). 11 11 12 typedef struct 12 typedef struct M3tDisplayDevice 13 13 { 14 int Type; 15 char Name[64]; 16 char a[64]; 17 int b, c, d; 18 short DisplayModeCount; 19 M3tDisplayMode DisplayModes[12]; 20 char e[990]; 21 } M3tDrawEngineCaps; 14 unsigned int __unknown; // 15 unsigned short NumModes; // 0x0004: number of valid display modes on this device. 16 M3tDisplayMode Modes[16]; // 0x0006: list of supported display modes. 17 unsigned short __padding; // 0x0086: padding (not used). 18 } M3tDisplayDevice; // 0x0088: (size). 19 20 typedef struct M3tDrawEngineCaps 21 { 22 int Type; // 0x0000: 23 char Name[64]; // 0x0004: draw engine name (eg. "OpenGL"). 24 char Driver[64]; // 0x0044: driver name (always NULL string). 25 unsigned int Version; // 0x0084: draw engine version (1 for OpenGL). 26 unsigned int NumDevices; // 0x0088: number of valid DisplayDevice-s. 27 M3tDisplayDevice DisplayDevices[8]; // 0x008c: 1 or more display devices. 28 int __unknown; // 0x04cc: 29 } M3tDrawEngineCaps; // 0x04d0: (size). 22 30 23 31 typedef struct -
Daodan/src/BFW_ScriptLang.h
r692 r705 19 19 char* value_str32; 20 20 float value_float; 21 boolvalue_bool;21 char value_bool; 22 22 } val; 23 23 } sl_arg; -
Daodan/src/Daodan.c
r694 r705 10 10 #include "Daodan_BSL.h" 11 11 #include "Daodan_Console.h" 12 #include "Daodan_WindowHack.h"13 12 14 13 #include "Oni.h" … … 42 41 bool patch_optionsvisible = true; 43 42 43 bool patch_binkplay = true; 44 44 bool patch_safeprintf = true; 45 45 bool patch_daodandisplayenum = true; 46 46 bool patch_usegettickcount = true; 47 47 bool patch_cheatsenabled = true; 48 bool patch_usedaodangl = false;49 bool patch_ windowhack= true;48 bool patch_usedaodangl = true; 49 bool patch_clipcursor = true; 50 50 bool patch_daodaninit = true; 51 51 bool patch_bsl = true; … … 55 55 bool opt_border = true; 56 56 bool opt_topmost = false; 57 58 typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI); 59 bool patch_chinese = false; 60 61 62 63 void ONICALL DDrShowResumeButton(int window, int visibility) 57 bool opt_gamma = true; 58 59 typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); 60 bool patch_chinese = true; 61 62 63 // Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma 64 // slider in windowed mode. 65 static void ONICALL DD_ONiOGU_GammaSlider_SetRange(WMtWindow* window, int min_value, int max_value) 66 { 67 WMrWindow_SetEnabled(window, M3gResolutionSwitch && opt_gamma); 68 WMrSlider_SetRange(window, min_value, max_value); 69 } 70 71 void ONICALL DDrShowResumeButton(WMtWindow* window, int visibility) 64 72 { 65 73 if (visibility) … … 70 78 71 79 /* Options always visible patch */ 72 void ONICALL DDrShowOptionsButton( intwindow, int visibility)80 void ONICALL DDrShowOptionsButton(WMtWindow* window, int visibility) 73 81 { 74 82 WMrWindow_SetVisible(window, 1); … … 255 263 if(patch_chinese) 256 264 { 257 DDrStartupMessage("Loading chinese DLL"); 258 HMODULE dll = LoadLibrary("xfhsm_oni.dll"); 259 DWORD err = GetLastError(); 260 DDrStartupMessage(" - Module loading returned error %i", err); 265 HMODULE dll; 266 DWORD err; 267 268 DDrStartupMessage("Loading chinese DLL"); 269 dll = LoadLibrary("xfhsm_oni.dll"); 270 err = GetLastError(); 261 271 if( dll ) 262 272 { … … 266 276 ((CHINESEPROC)proc)(GetCurrentThreadId()); 267 277 } 278 } else { 279 char msg[100]; 280 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL); 281 DDrStartupMessage(" - Module loading failed with error %i: %s", err, msg); 268 282 } 269 283 } … … 311 325 DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton); 312 326 } 327 328 // Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting 329 // instead of DirectDraw; patch ONiRunGame to use the same method to play 330 // outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the 331 // latter has problems on WINE). 332 if (patch_binkplay) 333 { 334 // push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION. 335 DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02); 336 // call ONrMovie_Play_Hardware -> call ONrMovie_Play 337 DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play); 338 } 339 340 // Patch a gamma slider in Options dialog (unconditionally). 341 // ONiOGU_Options_InitDialog: replace WMrSlider_SetRange(gammaSliderWindow, ...) 342 // call with our hook function. 343 DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange); 313 344 314 345 return true; … … 360 391 else if (!_stricmp(name, "switch")) 361 392 M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true"); 393 else if (!_stricmp(name, "gamma")) 394 opt_gamma = !_stricmp(inifile_cleanstr(value), "true"); 362 395 else 363 396 DDrStartupMessage("unrecognised option \"%s\"", name); … … 410 443 else if (!_stricmp(name, "usedaodangl")) 411 444 patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true"); 412 else if (!_stricmp(name, " windowhack"))413 patch_ windowhack= !_stricmp(inifile_cleanstr(value), "true");445 else if (!_stricmp(name, "clipcursor")) 446 patch_clipcursor = !_stricmp(inifile_cleanstr(value), "true"); 414 447 else if (!_stricmp(name, "daodaninit")) 415 448 patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true"); … … 422 455 else if (!_stricmp(name, "optionsvisible")) 423 456 patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true"); 457 else if (!_stricmp(name, "binkplay")) 458 patch_binkplay = !_stricmp(inifile_cleanstr(value), "true"); 424 459 else 425 460 DDrStartupMessage("unrecognised patch \"%s\"", name); … … 666 701 // Daodan device mode enumeration function 667 702 if (patch_daodandisplayenum) 668 DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*) daodan_enumerate_valid_display_modes);703 DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes); 669 704 670 705 // Performance patch … … 680 715 DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame); 681 716 682 // Windowed mode717 // DaodanGL with windowed mode support. 683 718 if (patch_usedaodangl) 684 719 { 685 DDrPatch_NOOP((char*)(OniExe + 0x000032B7), 6); 686 DDrPatch_MakeCall((void*)(OniExe + 0x000032B7), (void*)LIiP_SetCursorPosHook); 687 688 DDrPatch_NOOP((char*)(OniExe + 0x00003349), 6); 689 DDrPatch_MakeCall((void*)(OniExe + 0x00003349), (void*)LIiP_SetCursorPosHook); 690 DDrPatch_MakeJump((void*)ONrPlatform_Initialize, (void*)DDrPlatform_Initialize); 691 DDrPatch_MakeJump((void*)gl_platform_initialize, (void*)daodangl_platform_initialize); 692 } 693 // Hacked windowed mode (for when daodangl isn't working properly) 694 else if (patch_windowhack) 695 DDrWindowHack_Install(); 720 // LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect. 721 DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6); 722 DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect); 723 724 // UUrWindow_GetSize: GetWindowRect -> GetClientRect. 725 DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6); 726 DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect); 727 728 // LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates. 729 DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6); 730 DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos); 731 732 // LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates. 733 DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6); 734 DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos); 735 736 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 737 DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6); 738 DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos); 739 740 // LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates. 741 DDrPatch_NOOP((char*) OniExe + 0x00003349, 6); 742 DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos); 743 744 // Replace ONrPlatformInitialize. 745 DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize); 746 747 // Replace gl_platform_initialize. 748 DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize); 749 750 // Replace gl_platform_dispose. 751 DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose); 752 } 753 754 if (patch_clipcursor) 755 { 756 // LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook. 757 DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set); 758 759 // LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook. 760 DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set); 761 762 // LIrTermiante: replace LIrPlatform_Terminate call with our hook. 763 DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate); 764 } 765 696 766 697 767 if (patch_daodaninit) … … 714 784 DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning); 715 785 716 786 ONiMain(argc, argv); 717 787 } 718 788 /* -
Daodan/src/Daodan.h
r692 r705 3 3 4 4 #include <windows.h> 5 #include <assert.h> 5 6 #include "stdint.h" 6 7 7 8 #define ONICALL __fastcall 9 #define UUmType(t) typedef struct t t; 10 11 #define DDmAssert(expr) assert(expr); 12 13 typedef unsigned char UUtBool; 14 #define UUcTrue ((UUtBool) 1) 15 #define UUcFalse ((UUtBool) 0) 16 17 typedef unsigned short UUtError; 18 #define UUcError_None ((UUtError) 0) 8 19 9 20 extern HMODULE DDrDLLModule; … … 12 23 extern bool opt_border; 13 24 extern bool opt_topmost; 25 extern bool opt_gamma; 14 26 15 27 #endif -
Daodan/src/Daodan_BSL.c
r692 r705 764 764 uint16_t ONICALL cinematic_start_patch(sl_callinfo* callinfo, unsigned int numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) 765 765 { 766 args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl _eng->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl_eng->DisplayMode.Height));766 args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl->DisplayMode.Height)); 767 767 return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret); 768 768 } -
Daodan/src/Daodan_GL.c
r694 r705 11 11 #include "Oni_GL.h" 12 12 13 #define max_modes (104) // Dirty hack to add more resolutions, it really should only be 16 ^_^ 14 #define builtin_modes (sizeof(daodan_reslist) / sizeof(M3tDisplayMode)) 15 #define builtin_depths (sizeof(daodan_resdepths) / sizeof(short)) 16 17 bool daodan_testmode(M3tDisplayMode mode); 18 19 const M3tDisplayMode daodan_reslist[] = { 20 { 720 , 480, 0, 0 }, 21 { 720 , 576, 0, 0 }, 22 { 768 , 480, 0, 0 }, 23 { 800 , 480, 0, 0 }, 24 { 800 , 600, 0, 0 }, 25 { 852 , 480, 0, 0 }, 26 { 856 , 480, 0, 0 }, 27 { 960 , 540, 0, 0 }, 28 { 960 , 720, 0, 0 }, 13 static const M3tDisplayMode daodan_reslist[] = 14 { 15 { 640, 480, 0, 0 }, 16 { 720, 480, 0, 0 }, 17 { 720, 576, 0, 0 }, 18 { 768, 480, 0, 0 }, 19 { 800, 480, 0, 0 }, 20 { 800, 600, 0, 0 }, 21 { 852, 480, 0, 0 }, 22 { 856, 480, 0, 0 }, 23 { 960, 540, 0, 0 }, 24 { 960, 720, 0, 0 }, 29 25 { 1024, 576, 0, 0 }, 30 26 { 1024, 600, 0, 0 }, … … 47 43 { 1920, 1440, 0, 0 }, 48 44 }; 49 //Just going to always use 32 bits for now... 50 //short daodan_resdepths[] = { 16, 32 }; 51 short daodan_resdepths[] = { 32 }; 52 DEVMODE orig_devmode, cur_devmode, new_devmode; 53 54 /* Never called 55 void init_daodan_gl() 56 { 57 DDrStartupMessage("initalizing daodan gl"); 58 59 memset(&orig_devmode, 0, sizeof(orig_devmode)); 60 orig_devmode.dmSize = sizeof(orig_devmode); 61 62 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &orig_devmode)) 63 { 64 orig_devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 65 orig_devmode.dmBitsPerPel = 32; 66 orig_devmode.dmPelsWidth = GetSystemMetrics(SM_CXSCREEN); 67 orig_devmode.dmPelsHeight = GetSystemMetrics(SM_CYSCREEN); 68 } 69 70 memcpy(&cur_devmode, &orig_devmode, sizeof(orig_devmode)); 71 memcpy(&new_devmode, &orig_devmode, sizeof(orig_devmode)); 72 } 73 */ 74 75 void update_cdmode() 76 { 77 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_devmode)) 78 { 79 cur_devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 80 cur_devmode.dmBitsPerPel = 32; 81 cur_devmode.dmPelsWidth = GetSystemMetrics(SM_CXSCREEN); 82 cur_devmode.dmPelsHeight = GetSystemMetrics(SM_CYSCREEN); 83 } 84 } 85 86 unsigned int ONICALL daodan_enumerate_valid_display_modes(M3tDisplayMode modes[max_modes]) 45 46 static DWORD window_style, window_exstyle; 47 48 // HACK: use additional device entries to store display modes. It would give us 49 // 67 mode slots total (far more than enough). I absolutely have no idea where 50 // Rossy got his 104 (it would take up to 0x660 bytes while the whole GL state 51 // is only 0x63c bytes). Maybe it was just octal (67 + 1). 52 // This hack would break (crash!) "m3_display_list" script command. 53 #define DD_MAX_MODES ((offsetof(M3tDrawEngineCaps,__unknown) - \ 54 offsetof(M3tDrawEngineCaps,DisplayDevices) - \ 55 offsetof(M3tDisplayDevice,Modes)) / sizeof(M3tDisplayMode)) 56 57 // Former daodan_resdepths. 58 #define DD_MIN_DEPTH 16 59 60 unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes) 87 61 { 88 62 unsigned int vmodes = 0; … … 90 64 unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN); 91 65 92 uint16_t i, j; 66 unsigned int i; 67 signed int j; 93 68 94 69 DDrStartupMessage("listing display modes"); 95 /* 96 if (!M3gResolutionSwitch) 97 daodan_resdepths[0] = orig_devmode.dmBitsPerPel; 98 */ 99 for (i = 0; i < builtin_depths; i ++) 100 { 101 bool scrInsert = false; 70 71 memset(modes, 0, sizeof(M3tDisplayMode) * DD_MAX_MODES); 72 73 if (M3gResolutionSwitch) 74 { 75 // Enumerate in -switch mode. "67 slots ought to be enough for anybody". 76 77 DEVMODE dm; 78 79 dm.dmSize = sizeof(dm); 80 dm.dmDriverExtra = 0; 81 82 for (i = 0; EnumDisplaySettings(NULL, i, &dm); ++i) 83 { 84 if (dm.dmBitsPerPel < DD_MIN_DEPTH || dm.dmPelsWidth < 640 || dm.dmPelsHeight < 480) 85 continue; 86 87 // Already exists? Search backwards as modes are sorted most of the times 88 for (j = vmodes - 1; j >= 0; --j) 89 if (modes[j].Width == dm.dmPelsWidth && modes[j].Height == dm.dmPelsHeight && 90 modes[j].Depth == dm.dmBitsPerPel) 91 break; 92 93 if (j >= 0) 94 continue; // We've found a match. 95 96 modes[vmodes].Width = dm.dmPelsWidth; 97 modes[vmodes].Height = dm.dmPelsHeight; 98 modes[vmodes].Depth = dm.dmBitsPerPel; 99 100 if (++vmodes >= DD_MAX_MODES) 101 break; 102 } 103 } 104 else 105 { 106 // In -noswtich we put predefined window sizes which don't overlap 107 // deskbar(s) plus one "native" fullscreen mode. 108 109 unsigned int workarea_width, workarea_height, frame_width, frame_height; 110 DWORD style, exstyle; 111 RECT rc; 112 113 if (SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0)) 114 { 115 workarea_width = rc.right - rc.left; 116 workarea_height = rc.bottom - rc.top; 117 } 118 else 119 { 120 workarea_width = screen_x; 121 workarea_height = screen_y; 122 } 123 124 style = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE); 125 exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE); 126 127 // Calculate additional width and height for window borders. Don't 128 // bother with system metrics. Let Windows calculate this. 129 rc.left = rc.top = 0; 130 rc.right = rc.bottom = 300; 131 132 if (AdjustWindowRectEx(&rc, style, FALSE, exstyle)) 133 { 134 frame_width = rc.right - rc.left - 300; 135 frame_height = rc.bottom - rc.top - 300; 136 } 137 else 138 { 139 frame_width = 0; 140 frame_height = 0; 141 } 142 143 for (i = 0; i < sizeof(daodan_reslist) / sizeof(daodan_reslist[0]); ++i) 144 { 145 // Don't check the mode which has the same rect as screen. We would 146 // add it later as a special case. 147 if (daodan_reslist[i].Width == screen_x && daodan_reslist[i].Height == screen_y) 148 continue; 149 150 if (daodan_reslist[i].Width + frame_width <= workarea_width && 151 daodan_reslist[i].Height + frame_height <= workarea_height) 152 { 153 modes[vmodes] = daodan_reslist[i]; 154 modes[vmodes].Depth = GLgInitialMode.dmBitsPerPel; 155 156 if (++vmodes >= DD_MAX_MODES) 157 { 158 --vmodes; // Remove the last mode to make room for "fullscreen" mode. 159 break; 160 } 161 } 162 } 163 164 modes[vmodes].Width = GLgInitialMode.dmPelsWidth; 165 modes[vmodes].Height = GLgInitialMode.dmPelsHeight; 166 modes[vmodes].Depth = GLgInitialMode.dmBitsPerPel; 167 ++vmodes; 168 } 169 170 DDrStartupMessage("%u modes available:", vmodes); 171 for (i = 0; i < vmodes; ++i) 172 DDrStartupMessage(" %ux%ux%u", modes[i].Width, modes[i].Height, modes[i].Depth); 173 174 return vmodes; 175 } 176 177 // Sets a new display mode (if it is somehow different from a current mode). 178 // NOTE: signature for this function was changed to simplify code. 179 UUtBool DD_GLrPlatform_SetDisplayMode(M3tDisplayMode* mode) 180 { 181 if (mode->Height < 480) 182 return UUcFalse; 183 184 if (M3gResolutionSwitch) 185 { 186 DEVMODE new_mode, cur_mode; 187 188 cur_mode.dmSize = sizeof(cur_mode); 189 cur_mode.dmDriverExtra = 0; 190 191 // We don't need this check. Windows does this too (see CDS_RESET). 192 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_mode) || 193 cur_mode.dmPelsWidth != mode->Width || cur_mode.dmPelsHeight != mode->Height || 194 cur_mode.dmBitsPerPel != mode->Depth) 195 { 196 new_mode.dmSize = sizeof(new_mode); 197 new_mode.dmFields = DM_BITSPERPEL | DM_PELSHEIGHT | DM_PELSWIDTH; 198 new_mode.dmPelsWidth = mode->Width; 199 new_mode.dmPelsHeight = mode->Height; 200 new_mode.dmBitsPerPel = mode->Depth; 201 202 if (ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) 203 return UUcFalse; 204 } 102 205 103 modes[vmodes].Width = 640; 104 modes[vmodes].Height = 480; 105 modes[vmodes].Depth = daodan_resdepths[i]; 206 // We didn't change window size in DD_GLrPlatform_Initialize so we need 207 // to change it here. 208 SetWindowPos(ONgPlatformData.Window, NULL, 0, 0, mode->Width, mode->Height, 209 SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER); 210 211 return UUcTrue; 212 } 213 else 214 { 215 unsigned screen_x, screen_y; 216 DWORD style, exstyle, new_style, new_exstyle; 217 DWORD flags; 218 RECT rc, workarea_rc; 219 POINT pt; 220 221 screen_x = GetSystemMetrics(SM_CXSCREEN); 222 screen_y = GetSystemMetrics(SM_CYSCREEN); 223 224 GetClientRect(ONgPlatformData.Window, &rc); 106 225 107 if (++vmodes == max_modes - builtin_modes + i) 108 goto modesfull; 226 // Don't do anything if the mode was not changed. 227 if (rc.right == mode->Width && rc.bottom == mode->Height) 228 return UUcTrue; 229 230 style = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE); 231 exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE); 232 flags = SWP_NOACTIVATE | SWP_NOZORDER; 233 234 // Remember initial window style to correctly restore from fullscreen. 235 if (window_style == 0) 236 { 237 window_style = style; 238 window_exstyle = exstyle; 239 } 240 241 if (mode->Width == screen_x && mode->Height == screen_y) 242 { 243 // "Fullscreen" mode. 244 new_exstyle = exstyle & ~(WS_EX_CLIENTEDGE | WS_EX_DLGMODALFRAME | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE); 245 new_style = style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_DLGFRAME); 246 new_style = new_style | WS_POPUP; 247 rc.left = 0; 248 rc.top = 0; 249 rc.right = mode->Width; 250 rc.bottom = mode->Height; 251 } 252 else 253 { 254 if (opt_border) 255 { 256 pt.x = rc.left; 257 pt.y = rc.top; 258 ClientToScreen(ONgPlatformData.Window, &pt); 259 } 260 else 261 { 262 pt.x = screen_x / 2 - mode->Width / 2; 263 pt.y = screen_y / 2 - mode->Height / 2; 264 } 265 266 new_exstyle = window_exstyle; 267 new_style = window_style; 268 rc.left = pt.x; 269 rc.top = pt.y; 270 rc.right = rc.left + mode->Width; 271 rc.bottom = rc.top + mode->Height; 272 273 AdjustWindowRectEx(&rc, new_style, FALSE, new_exstyle); 274 275 // Convert to width and height. 276 rc.right -= rc.left; 277 rc.bottom -= rc.top; 278 279 if (SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea_rc, 0)) 280 { 281 // We try to keep window position, but we should prevent window 282 // from going off screen. 283 284 if (rc.left + rc.right > workarea_rc.right) 285 rc.left = workarea_rc.right - rc.right; 286 if (rc.top + rc.bottom > workarea_rc.bottom) 287 rc.top = workarea_rc.bottom - rc.bottom; 288 289 // Titlebar should always be visible. 290 291 if (rc.left < workarea_rc.left) 292 rc.left = workarea_rc.left; 293 if (rc.top < workarea_rc.top) 294 rc.top = workarea_rc.top; 295 } 296 } 297 298 if (new_style != style) 299 { 300 SetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE, (LONG_PTR) new_style); 301 flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME; 302 } 303 304 if (new_exstyle != exstyle) 305 { 306 SetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE, (LONG_PTR) new_exstyle); 307 flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME; 308 } 309 310 SetWindowPos(ONgPlatformData.Window, NULL, rc.left, rc.top, rc.right, rc.bottom, flags); 311 return UUcTrue; 312 } 313 } 314 315 static void ONICALL DD_GLiGamma_Restore(void) 316 { 317 if (opt_gamma) 318 { 319 if (gl_api->wglSetDeviceGammaRamp3DFX) 320 gl_api->wglSetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp); 321 else 322 SetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp); 323 } 324 } 325 326 static void ONICALL DD_GLiGamma_Initialize(void) 327 { 328 if (opt_gamma) 329 { 330 if (gl_api->wglSetDeviceGammaRamp3DFX) 331 { 332 UUrStartupMessage("Using 3dfx gamma adjustment"); 333 GLgGammaRampValid = gl_api->wglGetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp); 334 } 335 else 336 { 337 UUrStartupMessage("Using Windows gamma adjustment"); 338 GLgGammaRampValid = GetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp); 339 } 340 341 M3rSetGamma(ONrPersist_GetGamma()); 342 } 343 else 344 { 345 GLgGammaRampValid = FALSE; 346 } 347 } 348 349 // Disposes OpenGL engine. Called once. 350 void ONICALL DD_GLrPlatform_Dispose(void) 351 { 352 DEVMODE dm; 353 354 DD_GLiGamma_Restore(); 355 356 gl_api->wglMakeCurrent(NULL, NULL); 357 gl_api->wglDeleteContext(gl->hGLRC); 358 ReleaseDC(ONgPlatformData.Window, gl->hDC); 359 360 // Restore initial display mode if it does not match current mode. 361 362 dm.dmSize = sizeof(dm); 363 dm.dmDriverExtra = 0; 364 365 if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) || 366 dm.dmPelsWidth != GLgInitialMode.dmPelsWidth || 367 dm.dmPelsHeight != GLgInitialMode.dmPelsHeight || 368 dm.dmBitsPerPel != GLgInitialMode.dmBitsPerPel) 369 { 370 ChangeDisplaySettings(&GLgInitialMode, 0); 371 } 372 373 // (skipping SetWindowPos as it only adds flickering) 374 gl_unload_library(); 375 } 376 377 // Initializes (and re-initializes) OpenGL. 378 UUtBool ONICALL DD_GLrPlatform_Initialize(void) 379 { 380 static const M3tDisplayMode FallbackMode = { 640, 480, 16, 0 }; 381 382 if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode)) 383 { 384 gl->DisplayMode = FallbackMode; 109 385 110 for (j = 0; j < builtin_modes; j ++) 111 if (!(daodan_reslist[j].Width == 640 && daodan_reslist[j].Height == 480) && !(daodan_reslist[j].Width == screen_x && daodan_reslist[j].Height == screen_y) && 112 ((daodan_reslist[j].Width < screen_x && daodan_reslist[j].Height < screen_y) || (M3gResolutionSwitch && daodan_testmode(daodan_reslist[j])))) 113 { 114 if (!scrInsert && (daodan_reslist[j].Width > screen_x || (daodan_reslist[j].Width == screen_x && daodan_reslist[j].Height > screen_y))) 115 { 116 modes[vmodes].Width = screen_x; 117 modes[vmodes].Height = screen_y; 118 modes[vmodes].Depth = daodan_resdepths[i]; 119 120 if (++vmodes == max_modes - builtin_modes + i) 121 goto modesfull; 122 123 scrInsert = true; 124 } 125 126 modes[vmodes].Width = daodan_reslist[j].Width; 127 modes[vmodes].Height = daodan_reslist[j].Height; 128 modes[vmodes].Depth = daodan_resdepths[i]; 129 130 if (++vmodes == max_modes - builtin_modes + i) 131 goto modesfull; 132 } 133 134 if (!scrInsert) 135 { 136 modes[vmodes].Width = screen_x; 137 modes[vmodes].Height = screen_y; 138 modes[vmodes].Depth = daodan_resdepths[i]; 139 140 if (++vmodes == max_modes - builtin_modes + i) 141 goto modesfull; 142 } 143 144 if (!M3gResolutionSwitch) 145 goto modesfull; 146 } 147 148 modesfull: 149 DDrStartupMessage("%d modes available", vmodes); 150 return vmodes; 151 } 152 153 bool daodan_testmode(M3tDisplayMode mode) 154 { 155 DEVMODE devmode; 156 memset(&devmode, 0, sizeof(devmode)); 157 158 devmode.dmSize = sizeof(devmode); 159 devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; 160 devmode.dmBitsPerPel = mode.Depth; 161 devmode.dmPelsWidth = mode.Width; 162 devmode.dmPelsHeight = mode.Height; 163 164 return (ChangeDisplaySettings(&devmode, CDS_TEST | CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL); 165 } 166 167 int daodan_set_display_mode(short width, short height, short depth) 168 { 169 if (M3gResolutionSwitch) 170 { 171 DEVMODE new_devmode; 172 new_devmode.dmSize = sizeof(new_devmode); 173 new_devmode.dmFields = DM_BITSPERPEL | DM_PELSHEIGHT | DM_PELSWIDTH; 174 new_devmode.dmPelsWidth = width; 175 new_devmode.dmPelsHeight = height; 176 new_devmode.dmBitsPerPel = depth; 177 178 if (ChangeDisplaySettings(&new_devmode, CDS_TEST) != DISP_CHANGE_SUCCESSFUL) 179 return 0; 180 181 if (ChangeDisplaySettings(&new_devmode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) 182 return 0; 183 184 update_cdmode(); 185 gl_eng->DisplayMode.Width = cur_devmode.dmPelsWidth; 186 gl_eng->DisplayMode.Height = cur_devmode.dmPelsHeight; 187 if (cur_devmode.dmBitsPerPel > (unsigned short)depth) 188 gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel; 189 } 190 else 191 { 192 update_cdmode(); 193 if (cur_devmode.dmBitsPerPel > (unsigned short)depth) 194 gl_eng->DisplayMode.Depth = cur_devmode.dmBitsPerPel; 195 } 196 return 1; 197 } 198 int ONICALL daodangl_platform_initialize() 199 { 200 static M3tDisplayMode lastmode = {0, 0, 0, 0}; 201 202 if (lastmode.Width != gl_eng->DisplayMode.Width || lastmode.Height != gl_eng->DisplayMode.Height || lastmode.Depth != gl_eng->DisplayMode.Depth) 203 if (!daodan_set_display_mode(gl_eng->DisplayMode.Width, gl_eng->DisplayMode.Height, gl_eng->DisplayMode.Depth)) 204 if (gl_eng->DisplayMode.Width != 640 || gl_eng->DisplayMode.Height != 480 || gl_eng->DisplayMode.Depth != 16) 205 { 206 gl_eng->DisplayMode.Width = 640; 207 gl_eng->DisplayMode.Height = 480; 208 if (!daodan_set_display_mode(640, 480, 16)) 209 goto exit_err; 210 } 211 212 if (lastmode.Width != gl_eng->DisplayMode.Width || lastmode.Height != gl_eng->DisplayMode.Height) 213 { 214 RECT Rect; 215 Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (gl_eng->DisplayMode.Width / 2); 216 Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (gl_eng->DisplayMode.Height / 2); 217 Rect.right = Rect.left + gl_eng->DisplayMode.Width; 218 Rect.bottom = Rect.top + gl_eng->DisplayMode.Height; 219 AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_CAPTION |WS_TILEDWINDOW , FALSE); 220 221 SetWindowPos(ONgPlatformData.Window, NULL, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, SWP_NOACTIVATE | SWP_NOZORDER); 222 } 223 224 if (gl_eng->HDC == NULL) 225 if ((gl_eng->HDC = GetDC(ONgPlatformData.Window)) == NULL) 386 if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode)) 387 { 226 388 goto exit_err; 227 228 if (gl_api->wglGetDeviceGammaRamp3DFX != NULL)229 { 230 DDrStartupMessage("Using 3DFX gamma adjustment");231 232 if (gl_api->wglGetDeviceGammaRamp3DFX(gl_eng->HDC, gl_gamma_ramp))233 gl_gamma_ramp_valid = 1;234 }235 else236 { 237 DDrStartupMessage("Using standard Windows gamma adjustment");238 239 if (GetDeviceGammaRamp(gl_eng->HDC, gl_gamma_ramp))240 gl_gamma_ramp_valid = 1;241 } 242 243 /*if (gl_gamma_ramp_valid)244 daodan_set_gamma(ONrPersist_GetGamma()); 245 else*/246 DDrStartupMessage("gamma adjustment not supported");247 248 if (!gl_platform_set_pixel_format(gl_eng->HDC))249 if (gl_eng->DisplayMode.Depth != 16)250 {251 if (! daodan_set_display_mode(gl_eng->DisplayMode.Width, gl_eng->DisplayMode.Height, 16))389 } 390 } 391 392 // (DD_GLrPlatform_SetDisplayMode updates a window rectangle for us) 393 394 if (!gl->hDC && !(gl->hDC = GetDC(ONgPlatformData.Window))) 395 { 396 goto exit_err; 397 } 398 399 if (!M3gResolutionSwitch && opt_gamma) 400 { 401 UUrStartupMessage("Ignoring gamma setting for a windowed mode"); 402 opt_gamma = false; 403 } 404 405 DD_GLiGamma_Initialize(); 406 407 // This creates a rendering context too. 408 if (!gl_platform_set_pixel_format(gl->hDC)) 409 { 410 if (gl->DisplayMode.Depth != 16) 411 { 412 gl->DisplayMode.Depth = 16; 413 if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode)) 252 414 goto exit_err; 253 415 254 if (!gl_platform_set_pixel_format(gl _eng->HDC))416 if (!gl_platform_set_pixel_format(gl->hDC)) 255 417 goto exit_err; 256 418 } 257 258 lastmode.Width = gl_eng->DisplayMode.Width; 259 lastmode.Height = gl_eng->DisplayMode.Height; 260 lastmode.Depth = gl_eng->DisplayMode.Depth; 261 return 1; 419 } 420 421 return UUcTrue; 262 422 263 423 exit_err: -
Daodan/src/Daodan_GL.h
r692 r705 5 5 #include "BFW_Motoko_Draw.h" 6 6 7 unsigned int ONICALL daodan_enumerate_valid_display_modes(M3tDisplayMode modes[16]); 8 int ONICALL daodangl_platform_initialize(); 7 unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes); 8 UUtBool ONICALL DD_GLrPlatform_Initialize(void); 9 void ONICALL DD_GLrPlatform_Dispose(void); 9 10 10 11 #endif -
Daodan/src/Daodan_Win32.c
r692 r705 4 4 #include "Daodan_Win32.h" 5 5 6 #include "BFW_Utility.h" 6 7 #include "Oni.h" 7 8 8 extern HWND onihwnd;9 9 10 short ONICALL DDrPlatform_Initialize(ONtPlatformData *PlatformData) 10 // LIrPlatform_Terminate wrapper. Removes any cursor clipping we've done. Doing 11 // this is required for Windows 98 :-D 12 void ONICALL DD_LIrPlatform_Terminate(void) 11 13 { 12 WNDCLASSEX WndClass; 13 RECT Rect; 14 const int Width = 640, Height = 480; 15 HINSTANCE temp_Instance = PlatformData->Instance; 14 ClipCursor(NULL); 15 LIrPlatform_Terminate(); 16 } 16 17 17 PlatformData->Instance = g_Instance; 18 // LIrPlatform_Mode_Set wrapper. Clips cursor to window bounds to 19 // prevent loosing focus (mostly on Linux). 20 void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode) 21 { 22 DDmAssert(ONgPlatformData.Window); 18 23 19 WndClass.cbSize = sizeof(WndClass); 20 WndClass.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC; 21 WndClass.cbClsExtra = 0; 22 WndClass.cbWndExtra = 0; 23 WndClass.hInstance = PlatformData->Instance; 24 WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); 25 WndClass.hIcon = LoadIcon(g_Instance, MAKEINTRESOURCE(103) ); 26 WndClass.hIconSm = LoadIcon(g_Instance, MAKEINTRESOURCE(103)); 24 if (active_mode) 25 { 26 RECT rc; 27 POINT pt; 28 29 pt.x = 0; 30 pt.y = 0; 31 32 if (GetClientRect(ONgPlatformData.Window, &rc) && 33 ClientToScreen(ONgPlatformData.Window, &pt)) 34 { 35 rc.left += pt.x; 36 rc.top += pt.y; 37 rc.right += pt.x; 38 rc.bottom += pt.y; 39 40 ClipCursor(&rc); 41 } 42 } 43 else 44 { 45 ClipCursor(NULL); 46 } 47 48 LIrPlatform_Mode_Set(active_mode); 49 } 50 51 BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint) 52 { 53 DDmAssert(ONgPlatformData.Window); 54 55 return GetCursorPos(lpPoint) && ScreenToClient(ONgPlatformData.Window, lpPoint); 56 } 57 58 BOOL WINAPI DD_SetCursorPos(int X, int Y) 59 { 60 POINT pt; 61 pt.x = X; 62 pt.y = Y; 63 64 DDmAssert(ONgPlatformData.Window); 65 66 return ClientToScreen(ONgPlatformData.Window, &pt) && SetCursorPos(pt.x, pt.y); 67 } 68 69 static LRESULT CALLBACK DD_ONrPlatform_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 70 { 71 switch (uMsg) 72 { 73 case WM_SYSCOMMAND: 74 if (wParam == SC_SCREENSAVE) 75 { 76 // Prevent screen saver from starting when Oni has focus. 77 return 0; 78 } 79 break; 80 81 case WM_PAINT: 82 { 83 PAINTSTRUCT ps; 84 BeginPaint(hWnd, &ps); 85 // Oni does a useless PatBlt here. 86 EndPaint(hWnd, &ps); 87 return 0; 88 } 89 90 case WM_CLOSE: 91 // There's no way to reliably terminate a modal dialog. 92 // The following condition is (almost) always true. 93 if (WMgActive) 94 exit(0); 95 96 ONgTerminateGame = UUcTrue; 97 return 0; 98 99 case WM_SETCURSOR: 100 // If a mouse is inside our client area, we hide cursor (always), 101 // otherwise we ask DefWindowProc to set an appropriate arrow for us. 102 if (LOWORD(lParam) == HTCLIENT) 103 { 104 SetCursor(NULL); 105 return TRUE; 106 } 107 108 break; 109 } 110 111 return ONrPlatform_WindowProc(hWnd, uMsg, wParam, lParam); 112 } 113 114 115 UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData) 116 { 117 WNDCLASSEX WndClass; 118 RECT Rect; 119 const int Width = 640, Height = 480; 120 DWORD window_style, window_style_ex; 121 122 PlatformData->Instance = ONgInstance; 123 PlatformData->Window = NULL; 124 125 if (FindWindow("ONI ", "ONI ")) 126 { 127 AUrMessageBox(1, "There is already an instance of the game running."); 128 exit(0); 129 } 130 131 WndClass.cbSize = sizeof(WndClass); 132 WndClass.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC; 133 WndClass.cbClsExtra = 0; 134 WndClass.cbWndExtra = 0; 135 WndClass.hInstance = PlatformData->Instance; 136 WndClass.hCursor = NULL; // To debug: LoadCursor(NULL, IDC_ARROW); 137 WndClass.hIcon = LoadIcon(ONgInstance, MAKEINTRESOURCE(103)); 138 WndClass.hIconSm = LoadIcon(ONgInstance, MAKEINTRESOURCE(103)); 27 139 WndClass.hbrBackground = GetStockObject(BLACK_BRUSH); 28 140 WndClass.lpszMenuName = NULL; 29 WndClass.lpszClassName = "ONI "; 30 WndClass.lpfnWndProc = ONrPlatform_WindowProc; 141 WndClass.lpszMenuName = NULL; 142 WndClass.lpszClassName = "ONI "; 143 WndClass.lpfnWndProc = DD_ONrPlatform_WindowProc; 144 145 RegisterClassEx(&WndClass); 146 147 if (M3gResolutionSwitch) 148 { 149 // Do not allow border and topmost flag for a fullscreen window. 150 window_style = WS_POPUP; 151 window_style_ex = 0; 152 } 153 else 154 { 155 window_style = (opt_border) ? WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_DLGFRAME | WS_MINIMIZEBOX : WS_POPUP; 156 window_style_ex = (opt_topmost) ? WS_EX_TOPMOST : 0; 157 } 158 159 Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (Width / 2); 160 Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (Height / 2); 161 Rect.right = Rect.left + Width; 162 Rect.bottom = Rect.top + Height; 163 AdjustWindowRectEx(&Rect, window_style, FALSE, window_style_ex); 164 165 PlatformData->Window = CreateWindowEx(window_style_ex, WndClass.lpszClassName, "ONI ", window_style, 166 Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, 167 NULL, NULL, PlatformData->Instance, NULL); 168 169 ShowWindow(PlatformData->Window, SW_SHOWNORMAL); 170 UpdateWindow(PlatformData->Window); 171 172 return UUcError_None; 173 } 31 174 32 RegisterClassEx(&WndClass);33 34 Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (Width / 2);35 Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (Height / 2);36 Rect.right = Rect.left + Width;37 Rect.bottom = Rect.top + Height;38 AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW , FALSE);39 PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ", WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);40 onihwnd = PlatformData->Window;41 ShowWindow(PlatformData->Window, SW_SHOWNORMAL);42 UpdateWindow(PlatformData->Window);43 44 ShowCursor(FALSE);45 46 // I dont know why this is needed but Oni doesn't init without it.47 ONgPlatformData.Window = PlatformData->Window;48 ONgPlatformData.Instance = PlatformData->Instance;49 50 return 0;51 }52 -
Daodan/src/Daodan_Win32.h
r692 r705 5 5 #include "Oni.h" 6 6 7 short ONICALL DDrPlatform_Initialize(ONtPlatformData *PlatformData); 7 UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData); 8 BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint); 9 BOOL WINAPI DD_SetCursorPos(int X, int Y); 10 void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode); 11 void ONICALL DD_LIrPlatform_Terminate(void); 8 12 9 13 #endif -
Daodan/src/Oni.h
r692 r705 8 8 9 9 typedef unsigned char onibool; 10 11 #define WMcMessage_Quit 0x39 // WM_QUIT equivalent. 10 12 11 13 typedef struct { … … 20 22 void** PointerList, //Where the found pointers go 21 23 int* FoundCount //Where the number of pointers found go. 22 ); 24 ); 25 26 UUmType(WMtWindow); 23 27 24 28 #include "Oni_Symbols.h" -
Daodan/src/Oni_GL.h
r694 r705 58 58 int f_0624; 59 59 char *TextureBuffer; 60 HDC HDC;61 HGLRC HGLRC;60 HDC hDC; 61 HGLRC hGLRC; 62 62 char vsync; 63 63 char f_0635[3]; -
Daodan/src/Oni_Symbols.h
r694 r705 32 32 #define COgFadeTimeValue (*((uint32_t*)0x00533f68)) 33 33 34 // Some kind of graphics context? 35 #define g_Instance (*((HINSTANCE*)0x0061F9E4)) 36 37 // OpenGL Gamma related 38 #define gl_gamma_ramp (((M3tWin32GammaRamp*)0x0055fdfc)) 39 40 // OpenGL Gamma related 41 #define gl_gamma_ramp_valid (*((int*)0x005603fc)) 34 // Game termination flag (ONiRunGame loops on it). 35 #define ONgTerminateGame (*((UUtBool*)0x00630ffd)) 36 37 // Window manager is running (drawing and updating windows). 38 #define WMgActive (*((UUtBool*)0x005e99a0)) 39 40 // Set by WinMain, used by UUrPlatform_Initialize and ONrPlatform_Initialize, 41 // which copies it into ONgPlatformData. 42 #define ONgInstance (*((HINSTANCE*)0x0061f9e4)) 43 44 // Keeps initial gamma ramp value (before any change). 45 #define GLgInitialGammaRamp (((M3tWin32GammaRamp*)0x0055fdfc)) 46 47 // Nonzero when gamma ramp was successfully read into GLgInitialGammaRamp. 48 #define GLgGammaRampValid (*((int*)0x005603fc)) 42 49 43 50 // OpenGL: list of pointers to opengl32.dll functions (and a few functions from GL extensions) … … 45 52 46 53 // OpenGL render engine descriptor (resolutions, flags, context methods) 47 #define gl_eng (*((gl_engine_t**)0x00560600)) 48 49 // Value of -switch/-noswitch? 54 #define gl (*((gl_engine_t**)0x00560600)) 55 56 // Initial display mode (saved by gl_library_is_loaded). 57 #define GLgInitialMode (*((DEVMODE*)0x0055fd60)) 58 59 // False to prevent Oni from changing display settings (however Bink 60 // player does not respect this setting). 50 61 #define M3gResolutionSwitch (*((char*)0x00531634)) 51 62 … … 57 68 58 69 // Current ONtPlatformData 59 #define ONgPlatformData (*((ONtPlatformData*)0x00 53100c))70 #define ONgPlatformData (*((ONtPlatformData*)0x00631008)) 60 71 61 72 // Load non levelX_final-files yes/no … … 104 115 DefFunc(int, gl_platform_set_pixel_format, ONICALL, (HDC hdc), 0x00407b50); 105 116 106 // Original graphics initialization method patched to use "daodangl_platform_initialize" instead if daodangl is used 107 DefFunc(int, gl_platform_initialize, ONICALL, (), 0x00407da0); 117 // Original graphics initialization/cleanup functions patched to use 118 // DD_GLrPlatform_Initialize/DD_GLrPlatform_Dispoose instead if daodangl is used. 119 DefFunc(UUtBool, gl_platform_initialize, ONICALL, (void), 0x00407da0); 120 DefFunc(void, gl_platform_dispose, ONICALL, (void), 0x408210); 108 121 109 122 // Retrieve gamma value from settings … … 199 212 200 213 // Make a dialog element (in)visible and change its position 201 DefFunc(void, WMrWindow_SetVisible, ONICALL, (int window, int visibility), 0x00475a10); 202 DefFunc(void, WMrWindow_SetLocation, ONICALL, (int window, int x, int y), 0x004756d0); 214 DefFunc(void, WMrWindow_SetVisible, ONICALL, (WMtWindow* window, int visibility), 0x00475a10); 215 DefFunc(void, WMrWindow_SetLocation, ONICALL, (WMtWindow* window, int x, int y), 0x004756d0); 216 217 // Plays movie using Bink blitting method (ie., non-OpenGL blitting). 218 DefFunc(void, ONrMovie_Play, ONICALL, (const char* movie, int unknown), 0x004d5580); 219 220 // Sets minimum and maximum values for a slider control. 221 DefFunc(void, WMrSlider_SetRange, ONICALL, (WMtWindow* window, int min_value, int max_value), 0x00472650); 222 223 // Enables or disables window. 224 DefFunc(void, WMrWindow_SetEnabled, ONICALL, (WMtWindow* window, UUtBool enabled), 0x00475580); 225 226 // Sets gamma to specified factor (0.0 .. 1.0). 227 DefFunc(void, M3rSetGamma, ONICALL, (float factor), 0x00407a60); 228 229 // Resets gl_api pointers, unloads OPENGL32.DLL. 230 DefFunc(void, gl_unload_library, ONICALL, (void), 0x0040ac40); 231 232 // Notifies platform-specific local input implementation about internal (ie., 233 // real) input mode change. 234 DefFunc(void, LIrPlatform_Mode_Set, ONICALL, (unsigned int active_mode), 0x00402cf0); 235 236 // Terminates platform-specific local-input. 237 DefFunc(void, LIrPlatform_Terminate, ONICALL, (void), 0x00403620); 203 238 204 239 #undef DefFunc
Note:
See TracChangeset
for help on using the changeset viewer.