Page 1 of 3

XWA.Exe Patches

Posted: Tue Feb 10, 2015 9:36 pm
by JeremyaFr
Here is a list of patches for XWINGALLIANCE.EXE that were dispersed throughout the forum.

DISCLAIMER
Never apply a patch if you are not sure of what it does.
It is recommended to make a backup of XWingAlliance.exe.

To make it easy to apply patches, I've create a GUI tool:
XwaExePatcher.png
download link:
https://github.com/JeremyAnsel/XwaExePa ... ses/latest

The patches are defined in an xml file "patcher.xml". The format of this file is defined in "patcher.xsd".

patcher.xsd:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="ArrayOfPatch">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Patch">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="Item">
                <xs:complexType>
                  <xs:attribute name="Offset" type="xs:string" use="required" />
                  <xs:attribute name="From" type="xs:string" use="required" />
                  <xs:attribute name="To" type="xs:string" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="Name" type="xs:string" use="required" />
            <xs:attribute name="Description" type="xs:string" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
patcher.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfPatch>
  <Patch Name="[Recommended] triangling to infinity" Description="Fix the 'triangling to infinity' glitch.">
    <Item Offset="193C4A" From="750C" To="9090" />
    <Item Offset="193C53" From="02" To="08" />
  </Patch>
  <Patch Name="[Recommended] disable briefing wireframe overlay" Description="Disable the briefing wireframe overlay.">
    <Item Offset="07E09C" From="7D" To="EB"/>
    <Item Offset="07E12E" From="7D" To="EB"/>
    <Item Offset="07E1B9" From="47" To="90"/>
  </Patch>
  <Patch Name="remove joystick check" Description="Remove the joystick check.">
    <Item Offset="138CB4" From="754E" To="EB4E" />
  </Patch>
  <Patch Name="show framerate" Description="Show in-flight framerate">
    <Item Offset="05A3EA" From="85C07405" To="90909090" />
    <Item Offset="0F165A" From="85C07405" To="90909090" />
    <Item Offset="07978B" From="746F" To="EB6F" />
  </Patch>
  <Patch Name="show framerate, vertices, triangles" Description="Show in-flight framerate, SceneNumVerts, SceneNumTris, SceneNumTexChanges, SceneNumStateChanges">
    <Item Offset="05A3EA" From="85C07405" To="90909090" />
    <Item Offset="0F165A" From="85C07405" To="90909090" />
    <Item Offset="07978B" From="746F" To="EB36" />
  </Patch>
  <Patch Name="show framerate, video memory" Description="Show in-flight framerate, TexThrash, TotalTex">
    <Item Offset="05A3EA" From="85C07405" To="90909090" />
    <Item Offset="0F165A" From="85C07405" To="90909090" />
    <Item Offset="07978B" From="746F" To="EB0A" />
  </Patch>
  <Patch Name="crafts count per region" Description="Replace the craft count per region from 96 to 192.">
    <Item Offset="14C2E" From="60000000C1E305" To="C0000000C1E306"/>
  </Patch>
  <Patch Name ="backdrop scaling factor from 256.0f to 512.0f">
    <Item Offset="1A83AC" From="00008043" To="00000044"/>
  </Patch>
  <Patch Name ="backdrop scaling factor from 256.0f to 128.0f">
    <Item Offset="1A83AC" From="00008043" To="00000043"/>
  </Patch>
  <Patch Name ="backdrop scaling factor from 256.0f to 64.0f">
    <Item Offset="1A83AC" From="00008043" To="00008042"/>
  </Patch>
  <Patch Name ="backdrop scaling factor from 256.0f to 32.0f">
    <Item Offset="1A83AC" From="00008043" To="00000042"/>
  </Patch>
  <Patch Name="remove textures size limit" Description="Remove the 256x256 texture size limit.">
    <Item Offset="19564A" From="81790C000100007717" To="909090909090909090" />
    <Item Offset="1956C2" From="817A10000100007717" To="909090909090909090" />
  </Patch>
  <Patch Name="opt textures count limit from 200 to 1024">
    <Item Offset="0CC432" From="2003" To="0010" />
    <Item Offset="0CC43A" From="2803" To="0810" />
    <Item Offset="0CC445" From="2C03" To="0C10" />
    <Item Offset="0CC44C" From="2003" To="0010" />
    <Item Offset="0CC466" From="C800" To="0004" />
    <Item Offset="0CC497" From="3003" To="1010" />
    <Item Offset="0CC4C9" From="3003" To="1010" />
    <Item Offset="0CC4E6" From="3003" To="1010" />
    <Item Offset="0CC4EE" From="2003" To="0010" />
  </Patch>
  <Patch Name="[Fix] 32-bit bmp screenshot" Description="Fix misaligned flightscreen*.bmp screenshots.">
    <Item Offset="136CDA" From="740140" To="909090"/>
    <Item Offset="136D00" From="18" To="20"/>
    <Item Offset="136B2E" From="03" To="04"/>
    <Item Offset="136B35" From="0F8C50FFFFFFF6C3017445" To="9090909090909090909090"/>
    <Item Offset="136B56" From="6A0056E8C237FFFF0FBFC083C408" To="8B44245C3BD80F8C29FFFFFFEB21"/>
    <Item Offset="136C3B" From="03" To="04"/>
    <Item Offset="136C43" From="7C8CF6C3017447" To="90909090909090"/>
    <Item Offset="136C60" From="6A0056E8B836FFFF0FBFC083C408" To="8B44245C3BD80F8C65FFFFFFEB23"/>
  </Patch>
  <Patch Name="[Fix] disable a3d" Description="Disable the creation of an A3D device.">
    <Item Offset="1A7CA1" From="558BEC83EC20C745" To="B8FFFFFFFFC20C00"/>
  </Patch>
  <Patch Name="[Experimental] replace malloc with calloc">
    <Item Offset="19BCE0" From="A1B81E7B008B4C24045051E810000000" To="8B4C2404516A0190909090E8C0000000" />
  </Patch>
</ArrayOfPatch>

Re: XWA.Exe Patches

Posted: Tue Feb 10, 2015 11:32 pm
by Darksaber
Thanks Jeremy :D

Just a couple of questions I understand all of them apart from the last two, I don't think you've published these offsets before

Replace malloc with calloc, what is it and what does it do?
Disable a3d = Disable the creation of a A3D device, but what exactly is an A3D device and what does it do?

Thanks

Re: XWA.Exe Patches

Posted: Wed Feb 11, 2015 12:26 am
by Rasalas
Darksaber wrote:Disable a3d = Disable the creation of a A3D device, but what exactly is an A3D device and what does it do?
That's the Aureal 3D sound engine: http://en.wikipedia.org/wiki/A3D
Jeremy, does using this patch have any benefits compared to disabling A3D in XWA's sound menue?

Re: XWA.Exe Patches

Posted: Wed Feb 11, 2015 12:37 am
by JeremyaFr
Darksaber wrote:Disable a3d = Disable the creation of a A3D device, but what exactly is an A3D device and what does it do?
From Update202.rtf:
Aureal A3D Interactive(TM) sound support: Provides hardware accelerated 3d positional audio. To enable this support go to the sound options menu in the game, and select on for 3d sound enabled. If you have an Aureal supported sound card it will default to A3D support.

Improvements to Direct Sound 3D support: We have made adjustments to our sound system to create a more fulfilling experience for users with Direct Sound 3D supported soundcards.
On a system where an Aureal sound card was present and the a3d dlls are still installed, XWA may crash when 3D sound is enabled. Disabling the A3D device fix that crash.
Darksaber wrote:Replace malloc with calloc, what is it and what does it do?
malloc allocates memory without initializing it.
calloc allocates memory and fills it with 0.
I do not recommend to use this patch. I have made it for debugging purposes.

Re: XWA.Exe Patches

Posted: Wed Feb 11, 2015 4:39 pm
by Forceflow
Great work!
Maybe you should add a 'Not recommended' to the settings you deem unsafe to use or have a 'recommended' setting for the patches.

Re: XWA.Exe Patches

Posted: Thu Feb 12, 2015 11:06 pm
by JeremyaFr
UPDATE:
I've added Recommended, Fix, Experimental tags to the patches.

Re: XWA.Exe Patches

Posted: Fri Feb 13, 2015 5:28 pm
by Trevor
Hi Jeremya.

None of your stuff load in 98.
I wanted to try the hangar stuff but the patcher requires net4.

Ill try patching manually and then test the dlls

Edit:
Ok, its confirmed that none of these new features will work in 9x based systems.

Those of us using 9x to play this game are stuck with the official stuff except for the Opts and Texture stuff

The last version of MSVC that I know works in 9x is MSVCR90.dll (MSVC 2008)
It doesnt work in Vanilla 98 but with Kex it does.

trev

Re: XWA.Exe Patches

Posted: Wed Mar 04, 2015 11:26 pm
by JeremyaFr
Hello Trevor,
I have no plan to support systems older than Windows XP.

Re: XWA.Exe Patches

Posted: Mon Apr 13, 2015 12:46 pm
by Atx
As a former staunch supporter of win98 I agree its no longer worth supporting. Now if someone has Win98 still using it as a Dosbox (sheepishly looks away) then I advise you get KernelEx and all its numerous add ons.
Add ons are still being made for it by the community I believe.
http://kernelex.sourceforge.net/

Nice work on breaking the features ;)

JeremyFr - thanks for all your EXE insights and a huge thanks for all the neat tools. I know it's a lot of hard work (and a lot of your free time) but it is truly appreciated by the community here. :D

Re: XWA.Exe Patches

Posted: Sat Apr 25, 2015 6:15 am
by DTM
Great work as always!
What are the patches already included into the XWAU Craft Pack?

Re: XWA.Exe Patches

Posted: Sat Apr 25, 2015 8:22 am
by Darksaber
Using Disc and Gog versions
[Recommended] triangling to infinity
[Recommended] disable briefing wireframe overlay
crafts count per region
backdrop scaling factor from 256.0f to 128.0f
remove textures size limit
opt textures count limit from 200 to 1024
[Fix] 32-bit bmp screenshot
[Fix] disable a3d
To setup the dinput hook
To call the hook that selects the hangar type
To call the hook that selects the inside animation
To call the hook that selects the hangar model index
To call the hook that loads hangar opt
To remove the opt filter
To call the hook that sets the hangar camera
To call the hook that sets the hangar map
To call the hook that sets the family hangar map
To call the hook that remove D3DInfos count limit

If using Gog version (Only)
Removed
Force 800 mode
Fixed Z Clear
32 bit Mode
No CD Check

Reapplied
Correct No CD Check

XWA.Exe Patches

Posted: Sat Apr 14, 2018 10:47 pm
by Bman
Hi Jeremy, just wanted to confirm... these general patches are Not already part of your recent runtime .dll files? My understanding is these offset patches are included in the installers and applied through XWAUCP or DSUCP packs, correct ?

Re: XWA.Exe Patches

Posted: Sun Apr 15, 2018 11:56 am
by JeremyaFr
Hi Bman,
These general patches are not part of the hook DLLs. They are included in the craft packs (see the above list except the hook patches).

Re: XWA.Exe Patches

Posted: Sun Apr 15, 2018 12:22 pm
by JeremyaFr
Hello,
I've added "disable gun turret random rotation" patch to XwaExePatcher.
It will disable the gun turret rotation when there is no targetted craft.
See viewtopic.php?p=153940#p153940

Re: XWA.Exe Patches

Posted: Sun Apr 15, 2018 5:24 pm
by Bman
Awesome. I will test it in near future. Thank you!

EDIT: Hi Jeremy, I just noticed in the patcher.xml file for XWA.Exe patches, should we remove the following script lines ?

Code: Select all

  </Patch>
  <Patch Name="disable S-Foil model filter">
    <Item Offset="0FB86E" From="7419" To="EB19"/>
  </Patch>
Because this is already included in the hook_sfoils.dll file? I was wondering if it was redundant.

Re: XWA.Exe Patches

Posted: Thu Apr 26, 2018 3:38 pm
by JeremyaFr
Hello,
Yes, it is redundant since this patch is included in the sfoils hook.

XWA.Exe Patches

Posted: Sun May 06, 2018 12:10 am
by Bman
Hi Jeremy, I was wondering if the below could be added to your patcher.xml file for enhancing quality of sounds by using superior .wav samples. I know the game engine is limited to 2 channels (stereo) 8 bit or 16 bit, (maybe 24 bit PCM ?) The secondary buffers feed the primary buffers. But maybe replace the primary buffers which are currently capped at 22,050 kHz for .wav file content with optional 44.100 kHz, 48.000 kHz, 88.200 kHz, and 96.000 kHz.

Code: Select all

WAVEFORMATEX wf;
    wf.wFormatTag = WAVE_FORMAT_PCM;
    wf.nChannels = 2;
    wf.nSamplesPerSec = 22050;
    wf.nAvgBytesPerSec = 88200;
    wf.nBlockAlign = 4;
    wf.wBitsPerSample = 16;
For example, to replace the default wf.nSamplesPerSec = 22.050 with 44.100:

Code: Select all

  </Patch>
  <Patch Name="To Allow higher kHz Sound samples beyond 22kHz" Description="From 22,050 kHz to 44,100 kHz">
    <Item Offset="1379E9" From="22560000" To="44AC0000" />
    <Item Offset="1379FF" From="88580100" To="10B10200" />
    <Item Offset="1376D2" From="22560000" To="44AC0000" />
    <Item Offset="1376E8" From="88580100" To="10B10200" />
  </Patch>
I'm not sure what the values would be for 48.000 kHz, 88.200 kHz, and 96.000 kHz. Too bad wf.nChannels can't be greater than 2. Hope this helps. Thanks.

Re: XWA.Exe Patches

Posted: Sun May 06, 2018 12:29 pm
by JeremyaFr
Hello,

The game engine sets the primary wave format to 22050 Hz.

Wav data are loaded into secondary buffers. The format of a secondary buffer matches the format of the wav data.
When the sound is played, its format is converted to the format of the primary buffer.
MSDN Library wrote: DirectSound Playback Objects

Primary buffer:
Mixes and plays sounds from secondary buffers, and controls global 3D parameters.

Secondary buffer:
Manages a static or streaming sound and plays it into the primary buffer.
The wave format is defined as this:

Code: Select all

WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 2;
wf.nSamplesPerSec = 22050;
wf.nAvgBytesPerSec = 88200;
wf.nBlockAlign = 4;
wf.wBitsPerSample = 16;
The game engine works with 2 sound channels.

Code: Select all

nBlockAlign = nChannels * (wBitsPerSample / 8)
nAvgBytesPerSec = nSamplesPerSec * nBlockAlign
The following modifications will replace nSamplesPerSec and nAvgBytesPerSec:

Code: Select all

# sound format from 22050 Hz to 44100 Hz
At offset 1379E9, replace 22560000 with 44AC0000.
At offset 1379FF, replace 88580100 with 10B10200.
At offset 1376D2, replace 22560000 with 44AC0000.
At offset 1376E8, replace 88580100 with 10B10200.

# sound format from 22050 Hz to 48000 Hz
At offset 1379E9, replace 22560000 with 80BB0000.
At offset 1379FF, replace 88580100 with 00EE0200.
At offset 1376D2, replace 22560000 with 80BB0000.
At offset 1376E8, replace 88580100 with 00EE0200.

# sound format from 22050 Hz to 88200 Hz
At offset 1379E9, replace 22560000 with 88580100.
At offset 1379FF, replace 88580100 with 20620500.
At offset 1376D2, replace 22560000 with 88580100.
At offset 1376E8, replace 88580100 with 20620500.

# sound format from 22050 Hz to 96000 Hz
At offset 1379E9, replace 22560000 with 00770100.
At offset 1379FF, replace 88580100 with 00DC0500.
At offset 1376D2, replace 22560000 with 00770100.
At offset 1376E8, replace 88580100 with 00DC0500.

Re: XWA.Exe Patches

Posted: Sun May 06, 2018 12:34 pm
by JeremyaFr
UPDATE:
I've updated XwaExePatcher.
Here is the changelog:
  • Remove disable S-Foil model filter. It is included in hook_sfoils.
  • Add remove warhead count limit.
  • Add sound format. You can choose between 22050 Hz, 44100 Hz, 48000 Hz, 88200 Hz and 96000 Hz.

Re: XWA.Exe Patches

Posted: Sun May 06, 2018 5:19 pm
by Bman
Awesome. Thank you!

Re: XWA.Exe Patches

Posted: Fri Aug 31, 2018 7:41 pm
by JeremyaFr
UPDATE

Hello,
I've included the 'triangling to infinity' path to the opt limit hook. So you no longer have to apply it. The patch will be applied by the hook.

Re: XWA.Exe Patches

Posted: Fri Aug 31, 2018 9:04 pm
by DTM
I've just updated all Hooks. There is a problem, I think with the Hook_Opt_Limit.dll file.
This message is shown at game's launch:

xwa_hook_main (Dinput.dll)
"triangling to infinity patch" is not correctly initialized.

In game S-Foils don't work (your craft does not have S-Foils)
If i restore the old Hook_Opt_Limit.dll file, everything is ok.

EDIT:
:doh: ...I must disable "triangling to infinity" patch !

Re: XWA.Exe Patches

Posted: Sat Nov 24, 2018 7:50 pm
by JeremyaFr
UPDATE
Hello,
I've removed the Recommended tag for the 'triangling to infinity' patch and I've indicated that this patch is included in the opt limit hook.

Re: XWA.Exe Patches

Posted: Fri Jan 11, 2019 4:28 pm
by JeremyaFr
UPDATE
Hello,
I've added a new patch.

Code: Select all

  <Patch Name ="disable starfield rendering">
    <Item Offset="0DCFF0" From="A0AA6F7B00" To="C390909090" />
    <Item Offset="059980" From="E8EB2A0B00E866360800E811310B00" To="909090909090909090909090909090" />
    <Item Offset="0EF4AC" From="E8BFCF0100E83ADBFEFFE8E5D50100" To="909090909090909090909090909090" />
  </Patch>
This patch disables the starfield rendering. Rendering the starfield is not needed when you use DTM's backdrops.

Re: XWA.Exe Patches

Posted: Fri Jan 11, 2019 9:10 pm
by Darksaber
Thanks Jeremy the disable starfield rendering works a treat, it's weird if you replace the planet.dat with the original version,

BLACK SPACE :)

Just a questions regarding some of the patch offsets

Could these be added to one of the hooks or is there a reason why they are not included in a hook

Code: Select all

  <Patch Name="[Recommended] disable briefing wireframe overlay" Description="Disable the briefing wireframe overlay.">
    <Item Offset="07E09C" From="7D" To="EB"/>
    <Item Offset="07E12E" From="7D" To="EB"/>
    <Item Offset="07E1B9" From="47" To="90"/>
  </Patch>
  <Patch Name="[Recommended] disable XwaConfig.screenres reset" Description="Prevent the game from resetting the user resolution choice by using the resolution width">
    <Item Offset="10A431" From="A134AD9100" To="E9AE000000" />
  </Patch>
  <Patch Name="remove textures size limit" Description="Remove the 256x256 texture size limit.">
    <Item Offset="19564A" From="81790C000100007717" To="909090909090909090" />
    <Item Offset="1956C2" From="817A10000100007717" To="909090909090909090" />
  </Patch>
  <Patch Name="opt textures count limit from 200 to 1024">
    <Item Offset="0CC432" From="2003" To="0010" />
    <Item Offset="0CC43A" From="2803" To="0810" />
    <Item Offset="0CC445" From="2C03" To="0C10" />
    <Item Offset="0CC44C" From="2003" To="0010" />
    <Item Offset="0CC466" From="C800" To="0004" />
    <Item Offset="0CC497" From="3003" To="1010" />
    <Item Offset="0CC4C9" From="3003" To="1010" />
    <Item Offset="0CC4E6" From="3003" To="1010" />
    <Item Offset="0CC4EE" From="2003" To="0010" />
  </Patch>
I understand why the backdrop scaling factor isn't included, but the disable briefing wireframe overlay patch stops the game crashing so it's necessary. And I would have thought remove textures size limit and opt textures count limit from 200 to 1024 where also a necessity therefore should be in a hook as standard. unless you have a specific reason why they are not.

I'm not sure if the disable XwaConfig.screenres reset should be included in a Hook or not, it is [Recommend] so perhaps should be

Also this the craft per region should be included in a Hook as it's also Recommended

Code: Select all

  <Patch Name="[Recommended] crafts count per region" Description="Replace the craft count per region from 96 to 192.">
    <Item Offset="14C2E" From="60000000C1E305" To="C0000000C1E306"/>
  </Patch>
Thanks :)