Modding resources and documentation.

Discussion in 'Automobilista 2 - Modding' started by jota.191, Aug 24, 2023.

Tags:
  1. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Can we please have documentation of what do hex files contain? Or at least an official statement from the staff on why that is not doable/desirable.

    Context: I have never modded any sim, I entered the simracing world 3 years ago and I haven't had the time. I dedicated some time to learn how it works in AMS2 in the past days and while I have many things to learn, I get what must be done. (btw I am a computer scientist working in compilers, so it is not the first time I run emacs in hexl-mode to understand what is going on).

    Given my background it is very tempting to make my own compiler to generate the hex files from plain text. This would be doable after some hours of development but there is a catch: There are some chunks of the hex files that apparently anybody knows what they do.

    So my question in the first paragraph. I could understand if Reiza does not want us to interpret the binaries, but since they are not encrypted, and Reiza endorse modding, apparently they are ok with that. The reason could be they don't have the time to document things, it is ok. In that case we should do it as a community. Perhaps a thread here could be a start.

    Edit: I start. Here AMS2 modding docs is the best resource I know. Any other documentation is welcomed.
     
    • Like Like x 5
  2. Racinglegend1234

    Racinglegend1234 AMS2 wiki founder AMS2 Club Member

    Joined:
    Jul 28, 2022
    Messages:
    5,254
    Likes Received:
    1,784
    Any addition of modding info to the wiki is appreciated. I personally don’t know how to mod, but those who can could maybe post some things to the wiki
     
    • Like Like x 1
    • Agree Agree x 1
  3. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    That is definitely a good place to collect the information, I thought about it already :). But we need to gather the information first. Any insights are welcome.
     
    • Agree Agree x 1
  4. gvse

    gvse Active Member AMS2 Club Member

    Joined:
    May 15, 2020
    Messages:
    97
    Likes Received:
    153
    You could make a proof of concept compiler based on the small gearbox file. I think its translation is compete as it hasn't changed since S2U.

    As far as I know Reiza work with XML files which are then binarized in their tool pipeline.
    Access to these xmls would be highly appreciated.
    If you could then make a compiler, it would make modders' life so much easier.
     
    • Like Like x 2
    • Informative Informative x 1
  5. macbtz

    macbtz Member

    Joined:
    Sep 28, 2016
    Messages:
    35
    Likes Received:
    17
    Hi Guys, I am very interested in this matter.
    I don't know anything about hex editing but I would like to be able to edit the physics.
    I am attaching a file that I found as samples in case this works for you. If so, I can provide you with more or tell you where there is more documentation about it. I am not sure if it is allowed to put links to other websites here.
     

    Attached Files:

    • Like Like x 1
  6. Racinglegend1234

    Racinglegend1234 AMS2 wiki founder AMS2 Club Member

    Joined:
    Jul 28, 2022
    Messages:
    5,254
    Likes Received:
    1,784
    AFAIK there is no clear documentation, but I would love for it to be added to the wiki
     
  7. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Tomorrow is Independence day in Uruguay. I guess now I have a project to nerd about in the long weekend...
     
    • Like Like x 3
  8. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Well, basically I got it. I have a CLI utility that can compile a gearbox from plain text, and decompile an existing gearbox hex file to plain text. I must do some further testing. I'll publish the code later.

    This should scale to the other hex files. My next step will be actually refactor what I have a little bit to save time later.

    However, more than ever it should be handy to have a better specification of hex files. For now I think what I will do is having the possibility to insert hex chunks in the plain text with a special field. For instance something like the following:

    <field1> = 0.0
    blob = 0xca 0xfe 0xca 0xfe
    <field 2> = 14

    could compile into <field 1 compiled> CAFECAFE <field2 compiled>.

    This implies my text files are sensible to the ordering in their fields. I wanted a more declarative approach but it is not easy to combine with those bin chunks (also, I have not studied all the hex formats yet, perhaps even there is a fundamental quirk that makes the declarative approach non-doable anyways..)

    EDIT: For instance if I decompile the hex file for the Clio Cup adaptation from PC2 of Thunderflash, I get:

    ratio = (15,34)
    ratio = (18,31)
    ratio = (16,22)
    ratio = (14,16)
    ratio = (50,48)
    ratio = (18,15)
    bevel = (1,1)
    finalDrive = (10,38)


    If I compile this again (or anything similar modulo whitespaces/comments) I get the original hex file bit by bit.
     
    Last edited: Aug 26, 2023
    • Like Like x 5
    • Informative Informative x 1
  9. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Update: It worked well in most tests I've done.
    vrc_chevrette.gdfbin does not decompile, though. the hex file format is not exaclty as documented in AMS2 modding docs...
     
    • Like Like x 1
  10. gvse

    gvse Active Member AMS2 Club Member

    Joined:
    May 15, 2020
    Messages:
    97
    Likes Received:
    153
    It's because I used
    Code:
    24 9D 58 F9 64 A2
    , which is followed by float, float. It's then much easier to define ratios.
    My docs guide lists examples of hex code endings here: chassis - AMS2 modding docs
    but there may be more which are unaccounted for.

    Anyways, good progress so far, and thanks a lot for working on this!
    Maybe we should tag @CrimsonEminence to bring this to devs' attention, and perhaps get some feedback on the possibility of getting access to sample xmls with physics files. ;)
    Hope I'm not being too forward.
     
    • Like Like x 3
    • Winner Winner x 2
    • Informative Informative x 1
    • Friendly Friendly x 1
  11. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Oh I realize you are behind many things :p Thank you! What I've done is small and would be imposible without the documentation. I'll keep working on this.

    So, A2 is float,float. Is 02 (without the documented prefixes) byte,byte?
     
  12. gvse

    gvse Active Member AMS2 Club Member

    Joined:
    May 15, 2020
    Messages:
    97
    Likes Received:
    153
    Can you give me the specific key and the file in which I can find it? Then I should be able to figure it out.
     
    • Like Like x 1
  13. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    Hi! Sorry for the delay in answering. During the week I have been busy with work.

    To find gear ratios I parsed: 24 9D 58 F9 64 02 X Y with X and Y as bytes.
    In the chevrette we have instead 24 9D 58 F9 64 A2 X Y where X and Y are floats (If I remember correctly) (of course note that X, Y are no longer bytes so this chunk is longer).

    A2 means the following values must be interpreted as floats, my question is if the 02 in 24 9D 58 F9 64 02 means that the two values following are just bytes. I see in your documentation that 03 02, 23 02, 83 02 and A3 02 mean things, but not 02.

    Is it safe to state that 24 9D 58 F9 64 means there is a gear ratio value where the next byte indicates the format it is stored? (02 means two bytes (int8s), A2 means two floats).
     
    • Like Like x 1
  14. gvse

    gvse Active Member AMS2 Club Member

    Joined:
    May 15, 2020
    Messages:
    97
    Likes Received:
    153
    Yes, I guess it's safe to assume that. Unless there are two bytes, which indicates a different format, as in the examples you have given.
    You also need to look at the start of the keys. The most obvious example is `28`, which means the key is empty. The chassis translation should give you a better idea.
     
    • Like Like x 1
    • Informative Informative x 1
  15. paoloambrosio

    paoloambrosio New Member AMS2 Club Member

    Joined:
    Feb 6, 2021
    Messages:
    9
    Likes Received:
    10
    Given the lack of engagement by Reiza in this thread, I'm not sure why I bother, but here it is...

    Thanks to some great reverse engineering job by the modding community, the structure of *fbin files is pretty easy to understand. I am having troubles with mrdf and vdfm files. Except for the different sections, both have the same structure. What puzzles me are the red sections below, and I hope someone can tell me what they are:
    • The second 8 bytes (0x08-0x0F) seem to change for every car and I wasn't able to find a pattern.
    • The last 16 bytes (or really 12 plus 4 trailing zeros) that make up the last section are almost always "01 00 00 00 49 89 07 FB 0E 00 00 00" for mrdf files and "01 00 00 00 5F B5 28 EF 0F 00 00 00" for vdfm (and exception that I found was Mcl650sGT3.mrdf, but that might be incorrect as the last 4 bytes are not zero either).

    *.mrdf
    upload_2023-9-1_7-52-23.png

    *.vdfm
    upload_2023-9-1_7-52-46.png
     
    • Like Like x 3
    • Winner Winner x 2
  16. jota.191

    jota.191 (I'm Lando Garlando in AMS2 lobbies) AMS2 Club Member

    Joined:
    Jul 3, 2022
    Messages:
    491
    Likes Received:
    314
    I am slowly doing things in the time I find, I have basically rewritten the project to make it scalable now that I understand better the format of binaries. The idea is to parse unknown records with the proper hex code as its name, I show an example in the attachment. That way I can de-compile any physics file to text, sometimes with some awkward named key-value pairs, and recompiling it getting the very same original file (eventually doing changes, that is of course the point). I hope I can release it soon (Reiza time ;)), hopefully by putting some de-compiled examples someone else can figure out some more fields to make it more complete...


    There is a question I have and I think you could have the answer since you wrote that auriel file.

    There is a sort of table at the end of the engine file (entries start with 24 51 5F 5E 83 86 AA). What does it mean? I scrapped some AMS2 cars and I also find some tables, for instance starting with "24 04 45 49 29". There is no documentation of those from PC2 afaik :(

    Edit: Play the game: the screenshot shows a bug...
     

    Attached Files:

    Last edited: Oct 8, 2023
    • Like Like x 2
    • Informative Informative x 1
  17. gvse

    gvse Active Member AMS2 Club Member

    Joined:
    May 15, 2020
    Messages:
    97
    Likes Received:
    153
    Code:
    24 51 5F 5E 83 86 AA
    that the start of turbo. It's followed by
    Code:
    24 51 5F 5E 83 96 AA
    where the integer is RPM and the floats are boost at throttle positions.
    The other table you mention has been added by Reiza, and it would be great to get some feedback from the devs on what it does and how to use it.
    Either way, it's not required for mod cars to work.
     
    • Informative Informative x 3
    • Agree Agree x 1
  18. ZeldaACFan17

    ZeldaACFan17 New Member

    Joined:
    Jan 8, 2024
    Messages:
    1
    Likes Received:
    0
    Hey there. I'm new to AMS2 modding (And other Madness engine games like PCars), but I noticed that the gearbox files have a different set of hex code values for the final drive to PCars2... the 02 in [24 9D 58 F9 64 02] is replaced by a 42 instead, and after that section, the two values for what I think are the gear cogs (the [64 18]? Or maybe it's the values after the last 64, [18 01]) don't really match what I have for the main gears
    upload_2024-1-8_9-45-25.png
     
    Last edited: Jan 8, 2024

Share This Page