Wing COmmander Privateer and General MIDI

Getting old DOS games working on modern hardware. (DOSBox topics belong in DOSBox areas below, not here).

Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-02 @ 19:42

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.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-02 @ 20:02

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.
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-02 @ 21:37

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.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 00:31

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?
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 08:39

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.
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 09:32

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.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 10:03

I am not sure why you need a signed offset. Here is how I would do it:
Code: Select all
.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
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 10:48

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.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 10:51

If AL is 00, then CX:DX is "a signed offset from the start of the file", or in other words, an absolute offset. :)
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 13:00

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-8-03 @ 22:48, edited 1 time in total.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 13:44

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". :cool:
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 13:52

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". :cool:


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. :lol:
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 16:08

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:
PRIVPORT.exe
(2.03 KiB) Downloaded 3 times
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby jesolo » 2019-8-03 @ 18:25

Great work. Thank you for putting in the effort.
User avatar
jesolo
Oldbie
 
Posts: 1683
Joined: 2014-6-24 @ 19:04
Location: South Africa

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 20:06

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.
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 22:05

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... :lol: :lol: :lol: :lol:
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal

Re: Wing COmmander Privateer and General MIDI

Postby NewRisingSun » 2019-8-03 @ 22:11

I am sorry about that. :depressed:
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Wing COmmander Privateer and General MIDI

Postby carlostex » 2019-8-03 @ 22:46

NewRisingSun wrote:I am sorry about that. :depressed:

Don't worry it was good practice! :cool:

Besides it still might be useful for some people who don't feel comfortable patching .EXE's.
User avatar
carlostex
l33t
 
Posts: 2096
Joined: 2010-4-03 @ 21:39
Location: Portugal


Return to DOS

Who is online

Users browsing this forum: No registered users and 2 guests