Widescreen hack and some other fixes aka AiO Patch

Discuss Drakan: Order of the Flame with fellow players and post any technical problems here where an 'unofficial' support team will try and help you. Gameplay help questions can go here too.
Post Reply
UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

I've been looking at what calls game makes when it creates the surface for rendering and it doesn't appear to me that it marked any surface as texture. Either way, you can find reports online about applications and games failing to initialize at higher resolution that use older Direct3D APIs (7 and below).

I found a simple check in Microsoft's DLL that bails out on creating Direct3D device if either width or height are larger than 2048 pixels. Simply removing the check results in game being able to successfully initialize graphics subsystem and runs great at any high resolution desired. In this update, I have added a proxy DLL that scans Microsoft's DLL for the check and disables it when you start the game (d3dim.dll), so now you can run the game either through original Direct3D interfaces or through dgVoodoo2, both at any resolution you desire and your hardware can handle.

Also ported some of the relevant engine fixes over to Level Editor's 3D viewer and made some minor additions to borderless window code. Regarding Level Editor, one should setup Creative ALchemy to work with it as it seems that most sounds don't play in it unless 3D sound buffers are enabled in Riot Engine options and you don't get those buffers without ALchemy. It's also a good idea to use Compatibility Administrator and set it to use NoGDIHWAcceleration and VirtualRegistry fixes. First one resolves flickering noticeable in certain parts of UI, this is actually a bug since Windows 7 and it's very obvious in the old Pinball game that was bundled with Windows XP where it seems the ball just disappears at high speeds. The second fix resolves some of editor's settings being stored improperly in Windows registry, at least the list of recent files, otherwise, the next time you launch the editor, you notice eg. the last letter in file's extension is missing so you can't quickly open it by clicking on it.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

User avatar
Arokhs Twin
Site Admin
Posts: 1295
Joined: Wed Jul 18, 2001 9:36 pm
Location: United Kingdom
Contact:

Re: Widescreen hack and some other fixes aka AiO Patch

Post by Arokhs Twin »

Great, this is fantastic work. Will definitely be of use to level editors - most stopped making levels due to the inability of the game and editor to work properly on modern operating systems. Ill post this on the main site page later on.
By fire and by blood I join with thee in the Order of the Flame!
Webmaster of Arokh's Lair

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

Don't get too excited about the Level Editor, its 3D viewer engine variant (Engine.exe) uses different codepaths to do some things compared to the actual game version of the engine (Drakan.exe) so a majority of fixes aren't relevant for it so I only ported 3 of them, the patch for bump mapping crash bug, registry fixes and the fix for the glitch with texture filtering drop-down list. Code fixes for other glitches wouldn't make any difference since the same code I fixed in Drakan.exe isn't used in Engine.exe. This is why LOD feature doesn't seem present in there, you always get fully detailed models regardless of camera distance from them and the fogging is also done differently, it seems drawing distance is set very low, presumably because running the level editor with 3D view was very demanding for the hardware of that time.

I also thought maybe that bump mapping bug might have been overlooked because it was apparently a very fancy graphical feature for its time and only fancier hardware supported it so testers couldn't have spotted it if they played without it. But if that bug can be triggered when editing levels, it should be fixed now. Found some old article by Richard Rouse III and this caught my eye:

"One thing about proprietary tools in the gaming industry is that they're often riddled with bugs, and until the level designers learn to work around the crash-bugs their work will be severely hindered. Of course bugs that can't be worked around end up getting fixed. But why fix a particular problem if all the designers can just agree not to do whatever it is that causes the crash? The public, however, expects better quality software than professional game designers. Which is maybe backwards, if you think about it."

Source: http://www.paranoidproductions.com/gami ... g2_00.html

He didnt't mention anything bad about Drakan's Level Editor, but then again wasn't really involved in making of that game, at least not deeply. He was the lead designer of The Suffering and by that time, Surreal's tech was much improved. I've played The Suffering and there really isn't much to complain about, the only more serious glitch I've noticed is that if you saved the game during one boss fight and reloaded it if you died, the other guy in that room became immortal. Oh and I fell out of the map on the first level when randomly jumping around come chairs. Though we don't have Level Editor for The Suffering to compare.

There's also this, I'd have to learn how to use it to be better able to exploit the bugs and even then it would probably be difficult to fix because I'm just an amateur when it comes to programming and the lack of source code makes these things pretty much impossible. Randomly clicking stuff in the editor itself seems to work, and one crash that happens when you work in 3D can be bypassed by closing 3D view when you don't need it and then open it again. Or this scenario, load a level, open the sequences tab, play one of them, crash few seconds into it. Now repeat the same, but instead of clicking play again, click that first thing on the list on that tab, close 3D view, open it again, initiate playback and BAM, no crash. Some feedback on how to reproduce certain crashes would certainly be helpful, at least in case there was something very obviously wrong. It's not unusual for these things to crash in the middle of some complicated loop doing who knows what.

But on the more positive side, Drakan isn't exactly the worst when it comes to glitches. I still remember beating it on the old XP machine with GeForce4 MX 440 graphics card and the most frustrating thing were the crashes when Arokh got new crystal. At the time I was just a kid with not much knowledge about computer technical stuff, so I just kept retrying until it decided to let me continue. Had no idea I could go to options menu and turn off lens flares. Oh and this was before the game crashed on difficulty menu on just about any computer but the oldest ones, so that also helped.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

PaperJack2
Hatchling
Posts: 2
Joined: Thu Nov 22, 2012 7:40 am

Re: Widescreen hack and some other fixes aka AiO Patch

Post by PaperJack2 »

This patch causes drakan to crash on startup on my machine
Faulting application name: Drakan.exe, version: 1.0.0.1, time stamp: 0x38979d2d
Faulting module name: d3dim.dll, version: 6.1.7600.16385, time stamp: 0x4a5bd9aa
Exception code: 0xc0000005
Fault offset: 0x00004a8b
Faulting process id: 0xd38
Faulting application start time: 0x01d1c9a02d50a5a5
Faulting application path: C:\MY STUFF\Games\Drakan Gold Pack (2014)\drakan\Drakan.exe
Faulting module path: C:\Windows\system32\d3dim.dll
Report Id: 6cb9759f-3593-11e6-9320-3085a9ed0771

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

Try deleting d3dim.dll from Drakan folder. That file is supposed remove resolution limitation from Direct3D so it goes above 2048 pixels in each direction. Guess there is something different about Windows 7 version of original DLL...
Last edited by UCyborg on Sun Jun 19, 2016 3:32 pm, edited 1 time in total.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

I'll investigate later today and if I can't come up with something that works universally, remove it, or at least, write in Readme to use that file on one's own risk and place it separately in ZIP file.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

Just put Windows 7 on virtual machine and got the same crash as you. My d3dim.dll is the culprit. Now to see what gives...kinda funny that it works as intended on Windows 10 and Windows XP, but not on an OS in between.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

There we go, I think I've ran out of things I'm able to fix or improve:
  • Fixed Direct3D resolution limit remover so it doesn't crash the game anymore on some Windows versions.
  • Fixed the bug with quick-save not saving the correct track ID to the save file under certain circumstance.
  • Restored engine's original LOD feature, crash-free, with LOD factor configurable by the user.
  • Skip FOV calculations unless the aspect ratio is actually greater than 4:3.
  • Added compatibility database with some additional fixes for the game and the Level Editor.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

User avatar
Arokhs Twin
Site Admin
Posts: 1295
Joined: Wed Jul 18, 2001 9:36 pm
Location: United Kingdom
Contact:

Re: Widescreen hack and some other fixes aka AiO Patch

Post by Arokhs Twin »

Great - link updated on the main downloads page.
By fire and by blood I join with thee in the Order of the Flame!
Webmaster of Arokh's Lair

Guest

Re: Widescreen hack and some other fixes aka AiO Patch

Post by Guest »

I disagree with usefulness of
Game settings that get stored in registry are now stored under local user's registry key instead of system-wide key (HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE).
I'm aware of why this is implemented but it just creates problems because, for example, my program searches for "regular" key in HKLM. This is not found if I never run plain 445 version. So it's a problem for me. I have to implement two checks, one for regular 445 version, one for 447 version.
Also, what's the point of this - if someone wants to play Drakan from, for example, "Program Files" then it should run it as admin anyway so why, why "fixing" this with redirection to HKCU....the point is - this is workaround, not fix...also a not a good one. Simple rule is - if you want to play Drakan - run it as admin. Period. And leave that registry where it was. If you not agreeing with me, then can you please point me to HEX offset where I can revert that change in Drakan? Thanks in advance, fantastic work on this btw! :) Regards.

P.S. With newest nVidia drivers and Windows 10 build 1511 x64 game will "stuck" on alt-tab and exit when run as fullscreen..tried multiple times, same results. CTRL+ALT+DEL and ESC fixes this...

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

While I do think "never run user programs as admin" is a good rule, that fact alone was not the main reason this was changed. Newer Windows versions have this feature that redirect registry and directory writes to user specific locations if the user doesn't have permissions to write there (HKLM key, anywhere under Program Files). The thing is, from my past experience, because of some bug in Windows, game would sometimes fail to read back its registry settings unless the game's key was deleted and let the game recreate it. I remember it happened consistently on Windows 8.1 after performing full shutdown or just restarting computer. After reboot, game would show graphics options dialog again.

Directory redirection however seems to work fine. This also gives you the possibility, if you have multiple users on a computer, everyone can have their own config and save files, one user won't see others' saves etc. Run it as admin, and you get the classic behavior. But even that is not necessary. You can just change Drakan's folder permissions, and assign group Users Full control permission. It's what Steam does for its own folder so games can write in their own folder (those permissions are inheritable, this is how everything under Program Files get same restrictions by default) even if you have only one Steam library at default location. And just for the info, game editing tools do save their stuff under HKCU out of the box.

You could open the game in the debugger and look for calls to RegCreateKeyExA and RegOpenKeyA. I use OllyDbg 2.01. You simply open the .exe, hit CTRL + N, then right-click on each function and Find references. The value 80000002 means HKLM. This patch is meant as a drop-in replacement for the old 445 version. It gets buggier and buggier with older versions. I'm also curious about what your program does with game's graphics config.

I'm aware of the issue that happens with nVidia drivers, got the same problem here. I'm guessing the same thing also causes the game's screenshot feature to break. I hope they fix it in later versions, quality of their drivers seems to have degraded recently, looking at GeForce forums. Also played some Max Payne 3 a while back, I tabbed out on an occasion, got back, the game was frozen and later, I see that the driver crashed in the event log. You also have an option to run the game through dgVoodoo 2 wrapper, it basically makes the game run under DirectX 11.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

User avatar
mage150
Dragon
Posts: 173
Joined: Sun Aug 12, 2001 3:05 pm
Location: USA
Contact:

Re: Widescreen hack and some other fixes aka AiO Patch

Post by mage150 »

Good news - I finally got the game to run with the latest version of AiO.

Bad news - I have no key binds. When I try to set options my game crashes.

CPU: AMD Phenom II X6 1090t
RAM: 8 GB
GPU: NVIDIA GeForce GTX 770
GPU driver version: 368.39
OS: Windows 7

Let me know what I can do to help you debug.
Moderator Of Arokh's Lair.

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

I think it's a good idea if we make sure all your game files pass integrity check. I'm attaching a file which you can use to check if your files are OK:
  1. Extract the file Drakan.md5 from the attachment to your Drakan installation directory.
  2. Download Md5Checker from here and unzip it to anywhere you want it and launch it. It's a free portable program for file integrity checking and won't leave any traces on your computer.
  3. Inside the program, click button Add and then point the program to the CHECKSUM.md5 file, which you extracted to your Drakan dir earlier.
  4. Your files will be checked and any file that don't pass the test will be marked with X sign in the file list. Missing files are marked with exclamation mark. You can use those buttons just above the file list to show only bad files (Failed), missing files (N/A) etc.
Only the file drakan.tln under System directory can fail since it depends on the Drakan version, which you started from. I don't think any of the files in that directory is even used by the game though, so it doesn't really matter. Everything else, with exception of level list files (.lfl), should pass the test.

This doesn't usually happen under normal circumstances, but sometimes, the game's settings in registry get corrupted somehow. When that happened on my machine, frame-rate would be lower than usual, and hitting CTRL + ALT + DEL would result in a crash, with a crashpoint located in graphics driver DLL. They can be reset by running regedit, navigating to HKEY_CURRENT_USER\SOFTWARE\Surreal\Riot Engine and deleting Settings101 and Settings100 things in the right pane. Settings100 appear only if you've ran a dedicated server before.

But, make sure your files are OK first before we start blaming Windows, drivers, the game itself etc. You're the first one to report that issue and random crashes like that are likely to occur if some of the files are corrupted. Debugging is easiest when I'm able to reproduce the crash. While a bug or two did occur during the development of AiO Patch, those have been ironed out. Windows also logs some basic information about the crash in the event log. if you start the Event Viewer, you can usually find it under Custom Views->Administrative Events.
Attachments
DrakanMD5.zip
(6.02 KiB) Downloaded 4327 times
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

User avatar
mage150
Dragon
Posts: 173
Joined: Sun Aug 12, 2001 3:05 pm
Location: USA
Contact:

Re: Widescreen hack and some other fixes aka AiO Patch

Post by mage150 »

Thanks for the reply. It's awesome seeing there is still someone so dedicated to this game. Where were you back when I was making Joaxin's relic ;) Anyways I do have my original disk which I did a clean install from, however I just realized that I added a whole lot of different db and level files. I might have mixed stuff up.

Let me go ahead and delete my installed Drakan folder and do a fresh install from my Disk, then I will put the AiO patch. If it still does not work I will go ahead and troubleshoot using your suggestions.

I will have an update for you later tonight!

Again thank you so much!
Moderator Of Arokh's Lair.

UCyborg
Dragon
Posts: 433
Joined: Sun Jul 07, 2013 7:24 pm
Location: Slovenia

Re: Widescreen hack and some other fixes aka AiO Patch

Post by UCyborg »

Only added 2 minor fixes for the Level Editor 3D Viewer I forgot about last time, on modern Windows, there is a strange glitch with windowed mode, window sort of flashes every once in a while and when it loses focus, for some reason Windows considers it non-responsive after 5 seconds. Workaround is disabling window ghosting feature. Already took care of that for the game with Windows 8 update of the patch so it's only fair we do the same for 3D Viewer. The second fix is identical to the one that resolves crashing on difficulty screen in the game, probably doesn't do much for the 3D view, but that code is nevertheless executed and it might as well be there, if only for consistency.

Interestingly, the glitch related to the windowed mode (in which 3D view works as well) does not occur when we run the game through dgVoodoo. But dgVoodoo still needs some work done with its fast video memory access option, which, when the author succeeds and makes it work perfectly, should make Drakan run through it perfectly (no slower mouse response and degraded performance with debug messages enabled in developer options). It also doesn't work with Level Editor yet, probably because of mixed DirectDraw + GDI usage.

When I thought the game somehow corrupted its settings that time, it was actually dgVoodoo and enabled debug messages. No wonder resetting settings and NOT turning on those messages fixed it...

mage150, hope you managed to get your game running, couple of nights have passed by now. ;) I'm surprised myself about how many issues have been taken care of by randomly hacking inside game executables.
"When a human being takes his life in depression, this is a natural death of spiritual causes. The modern barbarity of 'saving' the suicidal is based on a hair-raising misapprehension of the nature of existence." - Peter Wessel Zapffe

Post Reply