Jump to content
Yellowberry

Understanding .trk files

Recommended Posts

Yellowberry

Hello friends of RRU, it's been a hot minute since I've done anything on this website. I recently acquired a copy of Lego Stunt Rally, my favorite childhood game (I even went as Mr. X for Halloween once), and I've been slowly picking away at the game's files, specifically the track file format. 


I have so far figured out how to generate an entirely new track file, hex IDs for a good majority of the buildings, decorations, and track pieces, and how the tiles are structured in the file format.


I was quite surprised to find out that the track files are fixed in length at 65kb, no matter if you make a singleplayer or multiplayer track. Further digging revealed that there is a significant amount of nulled out data between the rows of tiles, meaning that theoretically if the game supported it, we could have even bigger maps.


Another interesting discovery is that the game will treat any value that doesn't match a particular scenery type as it's own type, but wrap back around to the city scenery. This /might/ mean that we could create new types of scenery packs eventually!


I'm currently writing a Python program to aid in track creation and tinkering, however in it's current state it is extremely buggy and I wouldn't want to release a broken tool to the public. But once I've stabilized it just a bit more so it doesn't crash every other time you try to make a track, I will release it.


If you have any more details on how the track files work, I'd love to know!

 

EDIT: I totally spaced it, but here is what I know about the hex stuff so far, not really organized due to the fact that it was originally just a private document. I've opened up commenting on the file, so anybody is welcome to leave specific things there if they have any additional incite. Here is the link to the Google Doc:

https://docs.google.com/document/d/1W8TvnOuQHVJPWumpz2AmZhxrYMDFgVP-vgKqvh1JkdI/edit?usp=sharing

 

 

 

Thanks for still being around,
Yellow

Edited by Yellowberry
Google Docs!

Share this post


Link to post
Share on other sites
JimbobJeffers

Thanks for the great documentation!

 

An external track editor sounds awesome, and I don't mean to devalue it here, but what are the perks of using it instead of the in-game one which already has a decent interface?

Share this post


Link to post
Share on other sites
Yellowberry

Benefits could include:

  • Faster track editing using hotkeys and other quality of life improvements
  • Maybe importable stamps?
  • Specific scenery bugging, such as kbios has shown here
  • Maybe custom tiles, if I can figure that out too

The possibilities are there, it's just a matter of getting to them.

Share this post


Link to post
Share on other sites
Yellowberry

Alright, thanks to kbios for telling me about how track pieces are cached and stored in the track format, I now know how to create tracks with multiple scenery items. I tinkered with adding a new track piece to MOTO.rtb, but all it does is crash my game no matter how hard I try. I'm gonna take a nap and then keep chipping away at whatever I can.

Share this post


Link to post
Share on other sites
kbios

Hey, these are my notes on the trk format (piece names are in italian, sorry haha)

 

Fixed-length file (65576 b)
***Little-endian values***
Header example:                                                                                                                                                                            
4C 45 47 4F 20 4D 4F 54 4F 00 00 00 05 00 00 00 28 00 01 00 01 00 00 00 02 00 00 00 00 00 00 00                                                                                    
                                                                                                                                                                                   
4C 45 47 4F 20 4D 4F 54 4F (bytes 1-9) magic number (LEGO MOTO)
00 00 00 05 00 00 00 (bytes 10-16) apparently fixed
28 00 01 00 (bytes 17-20) filesize (65576)                                                                                                                         
01 00 00 00 (bytes 21-24) map type (00 multi, 01 single)                                                                                                          
02 00 00 00 (bytes 25-28) ambiance (00 jungle, 01 ice, 02 desert, 03 city)                                                                                                      
00 00 00 00 (bytes 29-32) time (00 day, 01 night)                                                                                                                                         

Track description, starting from right side going down:                                      
An empty space is                                                                                                                                        
00 00 00 00 00 00 80 BF FF FF FF FF 00 00 00 00                                                                                                                                    
16 pieces, then 48 unusued blocks like                                                                                                                        
00 00 00 00 00 00 00 00 FF FF FF FF 00 00 00 00                                                                                                                                    
Multiplayer: 8 pieces and 56 unused blocks.
This for each row. After the last row the file is filled with unused blocks up to 64K.
Last 8 bytes are like                                                                                                                                                            
00 00 00 00 01 00 00 00                                                                                                                                                            
01 00 00 00 (bytes 5-8) open/finished track (00 open, 01 finished)

A piece (departure) is eg
00 00 00 00 00 00 80 BF 30 43 00 00 01 00 00 00

00 00 00 00 (bytes 1-4) unknown (can be 00, 01, 02, 03), doesn't seem to have any effect
00 00 80 BF (bytes 5-8) height as a ***floating point number***
30 (byte 9) piece type
43 (byte 10) piece ambiance (43 city, 47 desert, 3B jungle, 3F ice)
00 00 together with the preceding two bytes forms the asset id
01 00 00 00 (bytes 13-16) clockwise rotation (00, 01, 02, 03)

Pieces occupying more than one space are marked only in one place, the one around which they rotate

Pieces (city, desert, jungle, ice):
Partenza:               30 1D 65 48
Rettilineo semplice:    31 19 61 49
Rettilineo camion:      32 1A 62 4A
Curva semplice:         33 1B 63 4B
Curva larga semplice:   34 1C 64 4C

Rettilineo parapetto:   36 1E 66 4E
Rettilineo lungo:       37 1F 67 4F
Curva parapetto:        38 20 68 50
Curva larga parapetto:  39 21 69 51

Rettilineo dosso:       3B 23 6B 53
Salita parapetto:       3C 24 6C 54

Paravalanghe:           40 28 70 58
Chicane:                41 29 71 59
Ventola:                42 2A 72 5A
Pantano:                43 2B 73 5B
Salto:                  44 2C 74 5C
Giro della morte:       45 2D 75 5D
Salita accelerazione:   46 2E 76 5E
Piastra:                47 2F 77 5F
Nastro:                 48 30 78 60
Incrocio:               49 31 79 61
Rettilineo fumo:        4A 32 7A 62
Rettilineo griglia:     4B 33 7B 63
Rettilineo casse:       4C 34 7C 64
Cannone:                4D 35 7D 65

Rettilineo semafori:    51 39 81 69

Salita semplice:        53 3B 83 6B

Pot. supersterzo:       58 40 88 70
Potenziatore turbo:     59 41 89 71
Pot. a sorpresa:        5A 42 8A 72
Pot. autoscontro:       5B 43 8B 73
Pot. oggetti insidiosi: 5C 44 8C 74
Fabbrica:               5D 45 8D 75
Edificio 1:             5E 46 8E 76
Pot. raggio paralizz.:  5F 47 8F 77
Edificio 2:             60 48 90 78
Edificio 3:             61 49 91 79
Edificio 4:             62 4A 92 7A
Edificio 5:             63 4B 93 7B
Edificio 6:             64 4C 94 7C

Aeroporto:              67 4F 97 7F

Statua:                 6C 54 9C 84
Angolo:                 6D 55 9D 85
Schermo:                6E 56 9E 86
Parcheggio 1:           6F 57 9F 87
Aiuola:                 70 58 A0 88
Laghetto:               71 59 A1 89
Pini:                   72 5A A2 8A

Cespugli:               74 5C A4 8C
Parcheggio 2:           75 5D A5 8D
Casse:                  77 5F A7 8F
Lampione:               78 60 A8 90

Lago:                   7A 62 AA 92

Salita cespugli:        7C 64 AC 94
Astronave:              7D 65 AD 95
Albero:                 7E 66 AE 96
Buca:                   7F 67 AF 97

Rettilineo luce:        8D 75 BD A5

 

Share this post


Link to post
Share on other sites
Yellowberry

Very useful, thank you very much! I will add this new information to my document and now I believe I have enough info to start work on an external track editor. Stay tuned for progress on that.

 

NOTE: If anyone has topdown images of all of the pieces, I would appreciate those, as they would help create a better looking editor. Unless I go the route of actually loading the 3D models and stuff, but that seems like too much work for what it's worth at this stage.

 

Thank you all again for all the help!

Share this post


Link to post
Share on other sites
Yellowberry

Hey, sorry, I kinda died. Life's been crazy, but I haven't forgotten about this project! I hope I can post proof-of-concept dealio within the next month or so...

Share this post


Link to post
Share on other sites
Yellowberry

Alright, so I got a sudden surge of motivation, and last night I finished a few basic tools I've been working on. I've written them in Python 3, however I plan on also rewriting them in C# soon.

I've created a GitHub repository for my code, MIT licensed for your use. Do whatever with it, my code is always a gift to the world.
https://github.com/YellowberryHN/srtools

Currently included are gentrack, a tool to generate a track file from scratch, readtrack, a tool to get basic info about a track, including about specific pieces, and lsrutil, a few basic things to help both tools function as needed.

Here's a preview of what gentrack can do:

gentrack.png

And here's what readtrack can do:

readtrack.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.