Page 1 of 1

Global sound for Ultima Online

Posted: Sun Oct 30, 2011 5:30 am
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;
}

Re: Global sound for Ultima Online

Posted: Mon Oct 31, 2011 9:02 am
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!

Re: Global sound for Ultima Online

Posted: Wed Nov 02, 2011 7:33 am
by Soma
Image

Re: Global sound for Ultima Online

Posted: Wed Nov 02, 2011 10:44 am
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.

Re: Global sound for Ultima Online

Posted: Wed Nov 02, 2011 10:55 am
by Stuck
*Looks at an x86 opcode reference to see what changed.*

Re: Global sound for Ultima Online

Posted: Wed Nov 02, 2011 1:00 pm
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? -_-

Re: Global sound for Ultima Online

Posted: Wed Nov 02, 2011 1:13 pm
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. =/

Re: Global sound for Ultima Online

Posted: Sat Feb 18, 2012 11:22 am
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.

Re: Global sound for Ultima Online

Posted: Tue Apr 03, 2012 1:02 am
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?

Re: Global sound for Ultima Online

Posted: Sat Apr 07, 2012 3:45 pm
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.

Re: Global sound for Ultima Online

Posted: Sat Apr 07, 2012 11:06 pm
by UsualSuspect
I love this man. That drove me nuts. On the downside now even the non-hardcore dweebs will run 3 clients.

Re: Global sound for Ultima Online

Posted: Mon Apr 09, 2012 6:55 am
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!

Re: Global sound for Ultima Online

Posted: Thu Nov 01, 2012 1:44 pm
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.