Global sound for Ultima Online

Post Reply
User avatar
hifi
Posts: 19
Joined: Sun Oct 30, 2011 5:17 am

Global sound for Ultima Online

Post by hifi »

Ohai,

Just started on the shard yesterday and forgot how annoying UO can be when you minimize or alt-tab to a different window - the sounds stop.

A lot of people probably would appreciate having the game sounds played whatever you do so I made a patch including source.

The code itself is naturally very crappy as I made it quickly but the results are fine ;)

Just download uo-gsound.exe anywhare and drag your client.exe on top of it. It should patch it successfully, at least the UOSA client package client.exe and client_noenc.exe work fine. 3D client not tested, might work.

http://hifi.iki.fi/uo-gsound.exe (patcher)
http://hifi.iki.fi/uo-gsound.c (source)

For programmers etc.: the game uses DirectSound (naturally) and the secodary buffers it requests do not set DSBCAPS_GLOBALFOCUS flag. This patch adds it to the flags DWORD parameter by changing a single byte in the executable.

Code: Select all

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    char search[] = { 0xC7, 0x44, 0x24, 0x3C, 0xE0, 0x00, 0x01, 0x00 };
    char replace[] = { 0xC7, 0x44, 0x24, 0x3C, 0xE0, 0x80, 0x01, 0x00 };
    long int fsize;
    
    printf("hifi's UO 2D global sound patch <3\n");
    printf("==================================\n");
    
    if (argc < 2) {
        printf("Error: Need a file to patch, drag client.exe to this executable.\n");
        getchar();
        return 0;
    }
    
    printf("Opening %s...\n", argv[1]);
    FILE *fh = fopen(argv[1], "rb+");
    if (!fh) {
        perror("Failed to open file");
        getchar();
        return 0;
    }
    
    fseek(fh, 0, SEEK_END);
    fsize = ftell(fh);
    fseek(fh, 0, SEEK_SET);
    printf("Crawling %ld bytes...\n", fsize);
    
    char *file = malloc(fsize);
    if (fread(file, fsize, 1, fh) != 1) {
        perror("Failed to read file");
        getchar();
        return 0;     
    }
    
    long int i;
    for (i = 0; i < fsize - sizeof(search); i++) {
        if (memcmp(file + i, search, sizeof(search)) == 0) {
            fseek(fh, i, SEEK_SET);
            if (fwrite(replace, sizeof(replace), 1, fh) != 1) {
                perror("Failed to write file");
            } else {
                printf("Patched! You now have global sound enabled!\n");
            }
            fclose(fh);
            
            getchar();
            return 0;
        }
        if (memcmp(file + i, replace, sizeof(replace)) == 0) {
            fseek(fh, i, SEEK_SET);
            if (fwrite(search, sizeof(search), 1, fh) != 1) {
                perror("Failed to write file");
            } else {
                printf("Reverted! Global sound is removed.\n");
            }
            fclose(fh);
            
            getchar();
            return 0;
        }
    }
  
    fclose(fh);
    
    printf("Did not find g-spot :-(\n");
    
    getchar();
    return 0;
}
Last edited by Derrick on Wed Feb 08, 2012 8:16 pm, edited 1 time in total.
Reason: Added code to post from external link.

User avatar
Derrick
Posts: 9004
Joined: Thu Dec 13, 2007 7:49 pm
Location: Cove
Contact:

Re: Global sound for Ultima Online

Post by Derrick »

Welcome to Second Age!!

I think your reputation precedes you, unless I'm mistaking you with another hifi :)

Thanks much for this patch!
Image
"The text in this article or section may be incoherent or very hard to understand, and should be reworded if the intended meaning can be determined."

User avatar
Soma
UOSA Donor!!
UOSA Donor!!
Posts: 1023
Joined: Sun Nov 30, 2008 9:40 pm

Re: Global sound for Ultima Online

Post by Soma »

Image
Please choose a more appropriate signature.

jekkis
UOSA Subscriber!
UOSA Subscriber!
Posts: 463
Joined: Tue Aug 02, 2011 7:26 am
Location: Finland, Northeast Europe

Re: Global sound for Ultima Online

Post by jekkis »

It's beautiful. What else can I say?

I'm a very curious person though, and I'd like to know where does hifi get his reputation from? Obviously he is some demi-god programmer, but where can I find his other work/references? I honestly doubt I'll be needing any of it, just out of curiosity. It's always fun to see what people are capable of when they're passionate about something.

Stuck
UOSA Donor!!
UOSA Donor!!
Posts: 324
Joined: Mon Aug 10, 2009 9:25 pm

Re: Global sound for Ultima Online

Post by Stuck »

*Looks at an x86 opcode reference to see what changed.*

User avatar
hifi
Posts: 19
Joined: Sun Oct 30, 2011 5:17 am

Re: Global sound for Ultima Online

Post by hifi »

jekkis wrote:It's beautiful. What else can I say?

I'm a very curious person though, and I'd like to know where does hifi get his reputation from? Obviously he is some demi-god programmer, but where can I find his other work/references? I honestly doubt I'll be needing any of it, just out of curiosity. It's always fun to see what people are capable of when they're passionate about something.
http://cncnet.org/
http://hifi.iki.fi/cnc-ddraw/
http://hifi.iki.fi/ra95-hires/
Stuck wrote:*Looks at an x86 opcode reference to see what changed.*
Maybe the thing I described in the last paragraph of the post? -_-

Stuck
UOSA Donor!!
UOSA Donor!!
Posts: 324
Joined: Mon Aug 10, 2009 9:25 pm

Re: Global sound for Ultima Online

Post by Stuck »

hifi wrote:Maybe the thing I described in the last paragraph of the post? -_-
Yeah, I didn't read that, I just kind of looked at the code. The joke being, that single byte wipes your entire disk or something equally malicious. I guess it fell flat. =/

rwuser
Posts: 72
Joined: Tue Feb 14, 2012 4:51 pm

Re: Global sound for Ultima Online

Post by rwuser »

I told derrick about hifi's work on other oldschool games and showed off some of his stuff to him (Oldschool gamers/devs are a close knit group generally).

Hifi was quite interested in helping out with any issues here for a while, but he seemed to of lost interest quite quickly :P , it seems GOG.com caught wind of his stuff and are interested in using his skills for increasing compatibility with official releases.

Some of us in the *background* do continually contemplate ideas about how to help derrick/etc and find ways to make the experience on this shard more O/S and client/server friendly.

On that note: UO never had the problem of being left behind, client exe wise because of the continued support other games wern't afforded. But when support is dropped/etc, people like hifi/etc will be around to pick up the pieces.

Mirage
UOSA Donor!!
UOSA Donor!!
Posts: 1764
Joined: Thu Sep 25, 2008 3:28 pm
Location: North Brit

Re: Global sound for Ultima Online

Post by Mirage »

I'm having an issue with my sound. When I go to my volume mixed, I keep trying to readjust my volume levels for my client, but everytime I increase it, it keeps my bar at 25%, an ideas?
Image
Syntax of the Wolfpack (TW) - PVP Since 97'

User avatar
Chaos
UOSA Donor!!
UOSA Donor!!
Posts: 1456
Joined: Thu Mar 12, 2009 5:24 pm

Re: Global sound for Ultima Online

Post by Chaos »

Hello hifi and welcome. Glad to see your already posting in support. People willing to take part in the support forums is always much needed and welcomed.

Again Welcome to UOSA if you have questions feel free to ask in public or pm me.
Image

[21:27] <@Derrick> UOSA is a tribute to the feasibility of anarchy

UsualSuspect
Posts: 415
Joined: Sat Feb 18, 2012 10:24 pm

Re: Global sound for Ultima Online

Post by UsualSuspect »

I love this man. That drove me nuts. On the downside now even the non-hardcore dweebs will run 3 clients.

xenoglyph
Posts: 23
Joined: Thu Mar 22, 2012 7:49 am

Re: Global sound for Ultima Online

Post by xenoglyph »

Here's same patch for 6.x+ clients:

C7 44 24 28 E0 00 01 00 ->
C7 44 24 28 E0 80 01 00

Cheers!

User avatar
hifi
Posts: 19
Joined: Sun Oct 30, 2011 5:17 am

Re: Global sound for Ultima Online

Post by hifi »

Hello again,

I actually made a generic patch later that proxies the call to DirectSound. This works for almost any game (not necessarily DRM protected, also note that anticheats might get triggered so use at your own risk).

Just drop this in your game directory and it should work.

http://hifi.iki.fi/dsound.dll

Unfortunately, I apparently lost the code so you just need to trust me on this one. I'll redo it some day with sources.

Post Reply