VOGONS

Common searches


First post, by carlostex

User metadata
Rank l33t
Rank
l33t

Hi everyone.

I'm getting a rather weird issue on my system. I cannot get Wingo Commander Privateer to send MIDI messages to any port other than 330h. I have a Yamaha SW60XG configured for port 320h, i've run the install program accordingly.

The sound.cfg file sets the port number in decimal so 320h is 800 is present in the sound.cfg file. Install.exe sets the sound.cfg file accordingly to my selections. In any case, it doesn't matter MIDI messages are only sent via port 330h. So the game is ignoring the sound.cfg setting or it defaults back to 330h. My MT-32 which i have connected to my MPU-401 card on 330h always plays.

Anyone else ever encountered this problem? I don't like being limited to port 330h.

Reply 1 of 17, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

It is a known bug in Privateer that it blatantly ignores the "sound.cfg" settings for the music driver. (At least known to me, now known to you. 😀)

If you have the floppy disk version, you can open the file SOUND.TRE in a hex editor, search for the string "Roland MT-32" (yes, the game uses an MT-32 driver to play General MIDI music), and move to the position twelve bytes before the "R". The bytes should be "30 03", or 330h. Change these bytes to "20 03" (for 320h) and save SOUND.TRE. You have now changed the hard-coded I/O address.

If you have the CD-ROM version, you can just copy the giant .TRE files from the CD-ROM to hard disk, changing the paths in PRIV.CFG that previously pointed to the CD-ROM drive to your hard drive to which you just copied the giant .TRE files, and perform the same change to the giant .TRE file that way. If you don't want to do that, it is theoretically possible to create a .TRE file on the hard disk just for the modified sound driver and put that .TRE file as the first line in PRIV.CFG so it will be used instead of the file on the CD-ROM, but that is a bit more complicated, because you would have to first extract the sound driver from the giant .TRE file, modify it, then attach a new .TRE header.

Reply 2 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t

Thank you so much for that!

Yeah i took a look before with an hex editor, but i had found so many 30 03 references i had no idea which one was i supposed to patch. I didn't want to take an enourmous disassembly job, so i thought about asking first, and i'm glad i did.

I've been learning assembly language for a couple of months now, so i'll probably write a simple port changer for both game versions. It should be fun.

Reply 3 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t
carlostex wrote:

It should be fun.

It should be fun, if files to patch are smaller than 1MB... SInce i only just started in real mode, accessing and patching the CD versions is hardly trivial with a DOS application. I wrote most of the code already only to realize that a 0xa98f1e physical address can't be accessed.

Probably it is easier to code a TSR to redirect the 330h writes to other port.

Was Origin QA sleeping?

Reply 4 of 17, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

What exactly are you trying to do? You don't need to read an entire file into memory, change two bytes, then write back the entire file. All you need is to seek to the patch location and write the changed two bytes?

carloxtex wrote:

Probably it is easier to code a TSR to redirect the 330h writes to other port.

No, redirecting ports is among the most difficult things to do for a TSR. SoftMPU may be able to help, but Privateer uses Origin's own crazy DOS extender (called JEMM), which might interfere with its operation.

Reply 5 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t
NewRisingSun wrote:

What exactly are you trying to do? You don't need to read an entire file into memory, change two bytes, then write back the entire file. All you need is to seek to the patch location and write the changed two bytes?

I was trying to use AH=42h,INT 21h to put file pointer into the right offset and do a stosw. Probably a stosb, would be enough, just patch the high order byte. Any General MIDI cards that used ports lower than 300h?

I'm very unexperienced, so i couldn't find a way to do this. AH=42 INT 21h, requires CX:DX as a signed offset. So unless i'm misunderstanding how the function works (which is very likely), or there's another function i'm not aware of i don't see a way to do this with big files.

Reply 6 of 17, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

I am not sure why you need a signed offset. Here is how I would do it:

.model tiny

.data
filename byte "SOUND.TRE", 0
patchPosition dword 0A98F1Eh
patchData word 0320h

.code
.startup
mov ax, 3D02h ; open file for read/write access
mov dx, offset filename
int 21h
jc fail
mov bx, ax
mov ax, 4200h ; seek to absolute position in cx:dx
mov cx, word ptr [patchPosition +2] ; high word
mov dx, word ptr [patchPosition +0] ; low word
int 21h
mov ah, 40h
mov cx, sizeof patchData
mov dx, offset patchData
int 21h
mov ah, 3Eh
int 21h
fail: ret
end

Reply 7 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t

Hey so CX:DX can be an absolute address? I thought it had to be a signed offset since its what the function states:

CX:DX = (signed) offset from origin of new file position

and it kind of made sense since sometimes you might want to move the pointer back.

But hey if CX:DX can be the absolute address then its an easy job. I will keep writing the code.

Reply 9 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t

Ok so if anyone is interested i created a little GM port changer tool. The code is not brilliant but it gets the job done.

EDIT: Check below for a more refined patch tool, or better yet, just patch your .EXE's as per NewRisingSun's instructions.

Last edited by carlostex on 2019-08-03, 22:48. Edited 1 time in total.

Reply 11 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t
NewRisingSun wrote:

You have inspired me to put the task of patching the game's original executable itself to not ignore the setting in SOUND.CFG onto my ever-growing list of "things to do". 😎

The stuff you do!!

People like yourself, Jim Leonard, ripsaw8080, scali have really inspired me to learn assembly. Call me crazy but its my favorite language, i just love the low level nerdiness. 🤣

Reply 12 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t

Ok so i noticed there's no reason to have "Righteous Fire Floppy Version" option since apparently it uses the original game sound.tre file. I'll revise the program and will upload new version. BTW if anyone has another port that might be supported by some obscure card i'll add it in, or maybe i'll add a user input port entry instead if i'm in the mood for it.

Here's a revised version:

Filename
PRIVPORT.exe
File size
2.03 KiB
Downloads
79 downloads
File license
Fair use/fair dealing exception

Reply 14 of 17, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

I have succeeded at patching Privateer to no longer ignore the music device's port address. The patches are as follows:

For the original floppy disk version of Privateer:
PRIVATER.EXE, original CRC32 91FA6816
Change the three bytes of hexadecimal file offset 00071EB1 from 66 6A FF to FF 76 08.

For the original floppy disk version of Righteous Fire:
PRSO.EXE, original CRC32: 2993CCED
Change the three bytes of hexadecimal file offset 000727B3 from 66 6A FF to FF 76 08.

For the CD-ROM version:
PRCD.EXE, original CRC32: BA4C58AE
Change the three bytes of hexadecimal file offset 000727D3 from 66 6A FF to FF 76 08.

@carlostex: Please try this and tell me if it works as well for you as it worked for me.

Reply 15 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t

Bravo!!!

I only tested with CD version as of yet, but that did it!

I guess that i coded a utility that was useful for about 6 hours or so... 🤣 🤣 🤣 🤣

Reply 17 of 17, by carlostex

User metadata
Rank l33t
Rank
l33t
NewRisingSun wrote:

I am sorry about that. 😢

Don't worry it was good practice! 😎

Besides it still might be useful for some people who don't feel comfortable patching .EXE's.