Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Mon Jun 25, 2018 5:24 pm

All times are UTC




Post new topic  Reply to topic  [ 167 posts ]  Go to page Previous 15 6 7 8 9
Author Message
PostPosted: Thu Aug 24, 2017 3:23 pm 
Offline
Administrator
Administrator
User avatar

Joined: Fri Jan 26, 2001 8:18 pm
Posts: 23861
Skype: orudge
Location: Banchory, UK
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.

_________________
Owen Rudge
owenrudge.net | Owen's Transport Tycoon Station | Owen's Locomotion Depot | The Transport Tycoon Wiki


Top
   
PostPosted: Sun Aug 27, 2017 4:30 pm 
Offline
Engineer
Engineer

Joined: Sat Jul 15, 2017 10:45 am
Posts: 11
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 ...


Top
   
PostPosted: Mon Aug 28, 2017 10:29 pm 
Offline
Engineer
Engineer

Joined: Sat Jul 15, 2017 10:45 am
Posts: 11
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.


Top
   
PostPosted: Tue Aug 29, 2017 12:26 am 
Offline
Engineer
Engineer

Joined: Sat Jul 15, 2017 10:45 am
Posts: 11
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.


Top
   
PostPosted: Wed Aug 30, 2017 7:14 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Sun Oct 12, 2003 5:16 pm
Posts: 312
Location: Switzerland
Very interesting work, keep it up!

_________________
Image


Top
   
PostPosted: Thu Aug 31, 2017 6:57 am 
Offline
Engineer
Engineer

Joined: Sat Jul 15, 2017 10:45 am
Posts: 11
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.


Top
   
PostPosted: Fri Apr 13, 2018 9:17 am 
Offline
Chief Executive
Chief Executive
User avatar

Joined: Mon May 31, 2004 8:22 am
Posts: 651
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 167 posts ]  Go to page Previous 15 6 7 8 9

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.