Page 1 of 2

1.06 features in TM?

Posted: Fri Sep 04, 2009 4:46 pm
by nedfumpkin
So here I am all curious as a cat trying to figure out the 1.06 source code. It comes with the patch.

Does anyone know how to read this stuff? I suspect there is a gold mine of useful information in there that could well be useful with TM.

I don't have a problem with making the changes I want to make manually, but alas, I have no idea what this scripting means...perhaps someone could enlighten me. For example,

.586
.model flat, c

.code

org 462275h
cmp eax, 0Bh ; bump whistle limit up by one

org 5CA392h
db 'whistle_twotone.wav',0

org 5F3AACh
dd 5CA392h ; offset 10

end
-------------------------

If someone can decipher this, perhaps I could figure the rest of it out. What does org refer to? I can't seem to find those as addresses in the exe file.

Any help would be appreciated.

Re: 1.06 features in TM?

Posted: Sat Sep 05, 2009 1:49 pm
by Grandma Ruth
You really need to talk to milo, he did all the programming, I think. He's not been around for a bit but he does surface from time to time - maybe you should send him a PM?

Re: 1.06 features in TM?

Posted: Sat Sep 05, 2009 3:36 pm
by nedfumpkin
I sent Milo a pm, waiting for a reply, he;s not been around for a while.

PS...welcome back from Prague, hope you had a good time.

Re: 1.06 features in TM?

Posted: Sat Sep 05, 2009 9:57 pm
by Hawk
I think I have his email address. Let me see if I can get in touch with him. I think I also have his phone number.
Give me a day or two. I just got back from out of town and it's going to be a bit hectic for me tomorrow.

Re: 1.06 features in TM?

Posted: Sat Sep 05, 2009 10:46 pm
by nedfumpkin
Take your time, it's a long weekend and you're supposed to relax.

BTW...nice to see that you apologized to Badger for whatever wrong you committed and she let you back home. ^**lylgh

Re: 1.06 features in TM?

Posted: Sat Sep 05, 2009 11:16 pm
by Hawk
Actually, the Badger was with me the whole time. ;-)
We were both out huntin' solitude. Things have been a bit crazy and debilitating for us lately. :evil:
We rode around in the mountains for a couple of days then went and paid a visit to a friend then went to my sister's for a couple of days.

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 8:38 am
by nedfumpkin
Good for you. It's nice to get away for a while.

If Milo could answer a few questions about the source code for !.06 so that I can try to make some changes manually to the RT3.exe file for TM, then it would be most appreciated. It would be so much easier than trying to learn programming in whatever language it is.

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 9:23 am
by Hawk
If I get in touch with him I'll tell him to contact you either via a PM or - I guess it would be OK to give him your email address. :?:

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 10:07 am
by nedfumpkin
Sure that would be fine. There's not real rush because I am going to finish up with the CA01 map, and I am currently working on creating stake cars to haul hemp, waste, and possibly corn and pulpwood. So this will take me a few minutes. ^**lylgh

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 10:27 am
by Hawk
I got home to find a new map to add to the site for RT3, 2 new files to add to the site in the MSTS section, plus 2 new files to add to the file library at my Railworks America site.
Along with that my wife and I have a dentists office to clean today (one of our H&H Cleaning Services customers).

Busy day for me today. *!*!*!

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 10:30 am
by nedfumpkin
Now if you would just embrace communism then you would be required to not work on Labour Day weekend, and instead you would be shouting out for equality among the masses, and free healthcare for all, etc. ^**lylgh

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 10:43 am
by Hawk
You do have a warped sense of humor, don't you? ^**lylgh

I just sent Milo an email. If I, or you, don't hear back from him in a few days I'll try to call him.
If he does contact you, please let me know so I don't bother him on the phone.
BTW! I did suggest he contact you via PM. Y'all can swap email addresses after that, if y'all are so inclined. ;-)

Re: 1.06 features in TM?

Posted: Sun Sep 06, 2009 2:39 pm
by Mish Mish
nedfumpkin wrote:Now if you would just embrace communism then you would be required to not work on Labour Day weekend, and instead you would be shouting out for equality among the masses, and free healthcare for all, etc. ^**lylgh
Perhaps we need a cheat code called "worker's paradise" that converts all locomotives to QJ class steam engines?

Hmmm...or another called "glorious October revolution" that would convert all the AI companies to human control?

**!!!**

Re: 1.06 features in TM?

Posted: Mon Sep 07, 2009 7:49 am
by Grandma Ruth
Hawk wrote:You do have a warped sense of humor, don't you? ^**lylgh
And what's warped about our Hawk embracing communism? ^**lylgh Seems a perfectly reasonable idea to me! ^**lylgh

BTW, thanks for the welcome back, Ned - Prague was great, as ever, lots of ex-communists there!

Re: 1.06 features in TM?

Posted: Mon Sep 07, 2009 8:54 am
by Hawk
Why's everybody always pickin' on me? **!!!** ^**lylgh

Re: 1.06 features in TM?

Posted: Mon Sep 07, 2009 9:22 am
by nedfumpkin
I have boxcars to make so I am not getting any further into this than I have to.....Comrade Hawk. :)

Re: 1.06 features in TM?

Posted: Wed Sep 09, 2009 1:56 am
by milo
nedfumpkin wrote:So here I am all curious as a cat trying to figure out the 1.06 source code. It comes with the patch.

Does anyone know how to read this stuff? I suspect there is a gold mine of useful information in there that could well be useful with TM.
It's a bit of a mess, and worse, I think it's incomplete. For each change in the 1.05A patch, I looked for a Dr. Watson crash report, figured out the minimum changes to the binary to keep the crash from happening, and added a PatchEntry to patch105a.c to replace the necessary bytes in RT3.EXE. It wasn't until halfway through developing 1.06 that I figured out I could use a macroassembler (MASM) to do some of the dirty work.

The .ASM files are x86 assembly language. Each of them describes new code that replaces part of the old binary. I used MASM to convert them into object files, dumped those out in hexadecimal format, and then used a quick-n-dirty Python script (proclisting.py, if I remembered to include it with the RT3 1.06 source) to convert a hexadecimal dump into a new PatchEntry.

Stuff beginning with a semicolon below is a comment. If a number ends in an h, it means it's hexadecimal - base 16.
.586 ; assume a 586 (Pentium) or better when assembling
.model flat, c ; use a 0:32 addressing model instead of an old-style segmented model

.code ; stuff following this goes into the executable portion of the binary

org 462275h ; assembler directive: start assembling at address 462275
cmp eax, 0Bh ; compare contents of extended-AX register to 11
The code near 462275h reads a numeric field from the locomotive description file and uses it to look up a record in a locomotive noise table. In 1.05, this table has 10 entries, and as a safety check, the executable makes sure the field specifies a number no larger than 10: 'cmp eax, 0Ah'. It turns out there's enough room for an eleventh entry, but to use it, I had to bump up the limit in the safety check from 10 to 11.
org 5CA392h ; start at address 5CA392h
db 'whistle_twotone.wav',0 ; define bytes corresponding to the null-terminated string 'whistle_twotone.wav'

org 5F3AACh ; start at address 5F3AACh
dd 5CA392h ; point to the 'whistle_twotone.wav' string at address 5CA392h
The locomotive noise table lives at address 5F3A80h and consists of an array of four-byte pointers to strings. This adds an eleventh entry to the table, at address 5F3AACh, that points to the string 'whistle_twotone.wav'. Now one can set the whistle field in a .LCO file to 11, and the game will play Bombardiere's two-tone British whistle.
end ; all MASM files have to end with this directive
In patch106.c, the code above was processed into four PatchEntries:
/* Add Bombardiere's British Rail two-tone whistle. */
{ 0x62275, 3,
"\x83\xf8\x0a",
"\x83\xf8\x0b" },
{ 0x1ca392, 16,
"\x61\x73\x73\x34\x36\x30\x4c\x00\x00\x00\x7a\x65\x70\x68\x79\x72",
"\x77\x68\x69\x73\x74\x6c\x65\x5f\x74\x77\x6f\x74\x6f\x6e\x65\x2e" },
{ 0x1ca3a2, 4,
"\x6c\x00\x75\x31",
"\x77\x61\x76\x00" },
{ 0x1f3aac, 4,
"\x00\x00\x00\x00",
"\x92\xa3\x5c\x00" },
The code segment in RT3.EXE is set up to load at address 400000, so the byte at file offset 62275h in RT3.EXE gets stored at memory address 462275h. In this case, the first PatchEntry says that at file offset 62275h, the patcher should replace the three bytes '83 F8 0A' (which correspond to 'cmp eax, 0Ah') with the three bytes '83 F8 0B' (which correspond to 'cmp eax, 0Bh'). The next two PatchEntries replace some unused space at offset 1CA392h ('org 5CA392h') with the ASCII string 'whistle_twotone.wav', and the final PatchEntry writes the four bytes 92 A3 5C 00 ('dd 5CA392h') into offset 1F3AACh ('org 5F3AACh').

Not sure if this really helps you much.

Re: 1.06 features in TM?

Posted: Wed Sep 09, 2009 6:26 am
by nedfumpkin
I helps a lot, but I still have to figure it out. The addresses is the part that is really getting me confused since I can't find those addresses in the exe file. Perhaps I am looking at it the wrong way.

Re: 1.06 features in TM?

Posted: Thu Sep 10, 2009 4:51 pm
by Sugus
As a professional programmer (these days better spelled as 'software engineer', but I'm simply a 59 years old mathematician lurking around by means of PCs) I would like to "figure out the 1.06 source code". Is there really any RT3 source code available (I know I'm stupid, but: in which programming language and development envrionment) or is it only MODding?

In five years I'll going to retire. Means: lot of time: so, what's better than to help making better an old good game?

Re: 1.06 features in TM?

Posted: Thu Sep 10, 2009 6:08 pm
by JayGould
The 'source code' for the 1.06 patch are the instructions used to modify the executable file. I am very impressed by the great effort it took to work out the changes.