Really early versions of TTO

Talk about the classic original version of Transport Tycoon.
User avatar
orudge
Administrator
Administrator
Posts: 23984
Joined: 26 Jan 2001 20:18
Skype: orudge
Location: Banchory, UK
Contact:

Re: Really early versions of TTO

Post by orudge » 24 Aug 2017 15:23

Very nice work, NCommander. I have, somewhere, an old Watcom C/C++ 10.6 CD. I may be wrong, but I think Phar Lap may have been included with that version - if not, then there could be stuff of use on it anyway perhaps. Failing that, I think I once came across an old version of Phar Lap online somewhere - it may well still be out there. Not sure if there's anything there that would be of any use, but you never know.

NCommander
Engineer
Engineer
Posts: 11
Joined: 15 Jul 2017 10:45

Re: Really early versions of TTO

Post by NCommander » 27 Aug 2017 16:30

Sorry for my inactivity on this on the last few days. My largest problem is just lack of time.

My largest problem with getting further on this is I can't quite seem to grasp how the binary file gets loaded into memory and I haven't found a decent way to examine the memory space so I can't get IDA to line up to allow me to trace string loading and such; that would make my job considerably easier.

I'll probably just end up downing Phar Lap SDK from one of the abandonware sites eventually and hope it's close enough to TT Demo that the debugger can work with it.

EDIT: So I took a look at the TTDPatch disassembles; it looks like they were working from a memory dump and not trying to disassemble the game binary directly. That's ... not an ideal way to do it, but I might get a saner dump if I do the same with the demo. I'm stuck on the laptop for at least a few hours which isn't setup to generate that kind of dump though ...

NCommander
Engineer
Engineer
Posts: 11
Joined: 15 Jul 2017 10:45

Re: Really early versions of TTO

Post by NCommander » 28 Aug 2017 22:29

I figure I should add some notes since I did make some fairly decent headway over the weekend.

Using the TTDPatch disassembles as a reference point, I found the master list of classes for vehicle and object behavior. TT's internal codebase is ... a bit weird to say with a lot of index referencing all over the place. This makes it annoyingly non-trivial to locate useful bits of code. It's also fairly annoying to hexedit the binary since the memory map doesn't line up to physical binary locations, but what can you do?

Serious props to the guys who disassembled TTDPatch; I think I would have gone mad without their work in this.

It also shows a lot of code more or less went from demo, to TTO, to TTD unchanged; most of the palette, and some of the window management code looks more or less identical. As far as I can tell, the major difference is the sound code was either stripped or ifdef'ed out of the codebase to build the demo.

Multiplayer code is there, and what little I looked at, at least seems partially complete; there's a TON of code dealing with serial communications; I'm not sure if network code is there are there. I may be able to re-enable this if I can figure out the correct jump locations.

As far as I can tell, the object classes (i.e., trains, RVs, etc) have a set of dispatch methods off them which allow things like "do X when Y is clicked". In TTD, the first method off the dispatch table is what popups up the windows to do construction, but this doesn't seem to be the case in the demo (unsure in TTO proper either). I tried to replace a call from trains to RV's Method0, and it simply crashed the game but I'm not convinced I hexedited in the right location.

For the toolbar itself, in TTD, each button is essentially connected to a jumptable which draws the menu. My guess is in TT-Demo, the jump table was simply disconnected which why the other code is there but I haven't found said table in the demo yet so no luck in re-connecting it. If I could get the game to crash when I try to do railroad construction, I can at least narrow down the possibilities.

NCommander
Engineer
Engineer
Posts: 11
Joined: 15 Jul 2017 10:45

Re: Really early versions of TTO

Post by NCommander » 29 Aug 2017 00:26

Image

I'm getting a better idea of how TT's code is laid out, and with some memory fiddling, got THIS to show up. Unfortunately, it doesn't work (yet). The tooltip says select airport size, but it won't actually switch the cursor to drop the airport down. I think the problem is I don't understand how CreateWindow actually works, but the second argument appears to be a class object, followed by flags I don't quite get. Obviously I'm not creating the window properly.

Trying to invoke RV causes error boxes to come up, and ships just leaves garbage data. I think all the bits are there I'm just not calling it properly.

I did find the toolbar stubs, and the expected retn. What annoys me is it looks like the call to actually CREATE the RV/Boat/Airport stuff was deleted which means I'm going to need to divine the right magic to patch it. That's made much harder due to Phar Lap. *sigh*. One bit at a time.

User avatar
Roman
Transport Coordinator
Transport Coordinator
Posts: 312
Joined: 12 Oct 2003 17:16
Location: Switzerland
Contact:

Re: Really early versions of TTO

Post by Roman » 30 Aug 2017 19:14

Very interesting work, keep it up!
Image

NCommander
Engineer
Engineer
Posts: 11
Joined: 15 Jul 2017 10:45

Re: Really early versions of TTO

Post by NCommander » 31 Aug 2017 06:57

Not much to add at this point.

I figured out how the toolbar GUI classes work. I was able to get the Road Vehicle button working again abet at the cost of disabling the rail button since I haven't found an enclave to put the new code in. They're essentially controlled by a single set of callbacks which hook into functions that create windows, which are then dispatched off a second table for each class of object in the game.

I was able to locate the bits of code that [try to] open the RV/Boats/Aircraft windows, and confirmed this by finding the code that cleans the "clicked" button on the toolbar. This leads to another ratsnest of pointers which try to call "CreateWindow" at which point TT-Demo corrupts the screen and things stop working.

I found the structures which define the window as well, but the format has changed in TTD but I haven't been able to divine the format as of yet. In TTD, they are essentially type, size, and an asset ID such as a sprite or text string in the GRF. I haven't however figured out how they're connected to object code. I theorize that the RV/boat window fails to dispatch because it's referencing invalid data in the GRF which also explains the screen corruption. The airport construction window displays because it's all text, but unclear at best why I can't plot an airport down. The assets themselves appear to be in the GRF.

Gurluas2000
Chief Executive
Chief Executive
Posts: 651
Joined: 31 May 2004 08:22

Re: Really early versions of TTO

Post by Gurluas2000 » 13 Apr 2018 09:17

NCommander wrote:Not much to add at this point.

I figured out how the toolbar GUI classes work. I was able to get the Road Vehicle button working again abet at the cost of disabling the rail button since I haven't found an enclave to put the new code in. They're essentially controlled by a single set of callbacks which hook into functions that create windows, which are then dispatched off a second table for each class of object in the game.

I was able to locate the bits of code that [try to] open the RV/Boats/Aircraft windows, and confirmed this by finding the code that cleans the "clicked" button on the toolbar. This leads to another ratsnest of pointers which try to call "CreateWindow" at which point TT-Demo corrupts the screen and things stop working.

I found the structures which define the window as well, but the format has changed in TTD but I haven't been able to divine the format as of yet. In TTD, they are essentially type, size, and an asset ID such as a sprite or text string in the GRF. I haven't however figured out how they're connected to object code. I theorize that the RV/boat window fails to dispatch because it's referencing invalid data in the GRF which also explains the screen corruption. The airport construction window displays because it's all text, but unclear at best why I can't plot an airport down. The assets themselves appear to be in the GRF.

This is amazing progress! :3
I really hope you can manage to unlock this early build!
Keep it up! I believe in you!

For the record, I'd be fine with just the date limitation removed, even if others vehicles aren't unlocked.

Post Reply

Return to “Transport Tycoon (Original)”

Who is online

Users browsing this forum: No registered users and 0 guests