Skip to content

Nenkai/OpenAdhoc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAdhoc

OpenAdhoc is an open-source re-implementation of the proprietary "Adhoc" scripting language used in Gran Turismo games. OpenAdhoc allows logic-based modding as seen on the GT6 Spec II Mod and GT4 Randomizer/Spec II, among other fan projects currently in development.

This repository contains compilable game scripts re-created from originally compiled ones. This allows source-code level editing for scripts that have been successfully reverse-engineered in Adhoc-based GT games.
GT4 Prologue, GT4, Tourist Trophy, GT HD, GT5 Prologue, GTPSP, GT5, GT6, GT Sport, and all games in between them are in the scope of OpenAdhoc.

Scripts operate nearly as the whole of game logic, while the executable mostly serves as the engine and exposes libraries to the script interface. The games use a system of "projects" to divide the major menu types. Each game mode is made out of a project folder containing the Adhoc logic script(s) (.adc), the UI definition script (.mproject), and assets: localization files, textures, models, and animations packaged into container files (.gpb).

Note

This code is licensed under GPL-v3. You are required to disclose source/changes including for mods.

Modified versions of OpenAdhoc for fan projects such as GT6 Spec II & GT5 Master Mod are required to be uploaded to a separate fork.

🎮 Games & Progress

Tip

Percentage/Progression is relative to the overall amount of lines that have been reversed.

[❌️] Demos & Misc. builds
GT4 Prologue Era
GT4 Prologue Subaru Version

No progress.

GT4 Prologue E3 2003

No progress.

GT4 Prius Trial Version

No progress.

GT Special Edition 2004 Geneva Edition

No progress.

GT Special Edition 2004 Toyota Demo

No progress.

GT4 Era
GT4 E3 2004

No progress.

GT4 BMW 1 Series Virtual Drive

No progress.

GT4 Tokyo Game Show 2004

No progress.

GT4 First Preview

No progress.

GT4 - Mazda MX-5 Edition Demo

No progress.

Tourist Trophy Era
Tourist Trophy Store Demo

No progress.

GT HD Era
GT HD E3 2006

No progress.

GT HD Tokyo Game Show 2006

No progress.

GT HD Premium Subaru Impreza Rally Car '99

No progress.

GT HD Le Mans 2007

No progress.

GT HD Nissan Xanavi Nismo Z

No progress.

GT HD "Wedding Version"

No progress.

GT5 Prologue Era
GT5P Games Convention 2007

No progress.

GT5P Tokyo Games Show 2007

No progress.

GT5P Tokyo Motor Show 2007

No progress.

GT5P Free Trial Version

No progress.

GT5P Spec-I (December '07 JP release)

No progress.

GT5P Spec II Nürburgring Special Edition 2008

No progress.

GT5P Games Convention 2008

No progress.

GT5P Special Event Version GT by Citroën

No progress.

GT5P DOME S102 '08

No progress.

GT5P Le Mans Special Edition '09

No progress.

GT PSP Era
GT PSP E3 2009

No progress.

GT PSP E3 2009

No progress.

GT PSP Gamescom 2009

No progress.

GT PSP Tokyo Games Show 2009

No progress.

GT5 Era
GT5 Gamescom 2009

No progress.

GT5 Tokyo Games Show 2009

No progress.

GT5 Tokyo Motor Show 2009

No progress.

GT5 Time Trial Challenge

No progress.

GT5 CES Demo

No progress.

GT5 SLS Demo

No progress.

GT5 Nür 2010 Demo

No progress.

GT5 24 Heures du Mans Demo

No progress.

GT5 E3 2010 Demo

No progress.

GT5 Kiosk Demo

No progress.

GT5 Gamescom 2010

No progress.

GT5 Tokyo Games Show 2010

No progress.

GT5 QA Build

No progress.

GT Academy 2012

No progress.

GT6 Era
GT Academy 2013

No progress.

GT E3 2013

No progress.

GT6 Gamescom 2013

No progress.

GT6 Tokyo Games Show 2013

No progress.

GT6 Toyota S-FR Build

No progress.

GT Sport Era
GT Sport E3 2016

No progress.

GT Sport Gamescom 2016

No progress.

GT Sport Essen Motorshow Demo

No progress.

GT Sport Closed Beta Test Version

No progress.

GT Sport Open Beta

No progress.

GT Sport MEGAWEB GR ZONE

No progress.

GT Sport TGS2017 VR Support

No progress.

[🚧] GT4 Prologue (40%)

GT4 Prologue

Adhoc Version: 5
5 of 11 projects are completed and can be compiled.
No progress has been made currently.

Name Completed Purpose
language ✔️ Language selection menu
memcard ✔️ Save file Load/Save, Load/Save replay, etc.
option ❌️ A hidden menu that contains advanced settings, primarily networking
option2 ✔️ Options menu
prize ❌️ Prize screen when unlocking a new car
prologue ❌️ School mode and its sub-menus
prologue_arcade ❌️ Arcade mode and its sub-menus
prologue_opening ❌️ Opening movie handler
quick ✔️ Pre-race menu for School mode
quick-arcade ❌️ Pre-race menu for Arcade mode
GT4Application ✔️ Initializer and Config Script loader / re-loader
[✅] GT4 (100%)

GT4

Adhoc Version: 7 (v5-7 compatible)
All 29 projects are completed and can be compiled.
There are 2 collections of shared scripts (share and quick-share) that multiple projects use.
There are 10 leftover projects from GT4P and retail GT4 that are not relevant.

Name Purpose
arcade Arcade mode and all of its sub-menus
boot Bootup, Language select, new game setup, initial intro movie
cursor Sets up cursor and dialog boxes
demo_movie Intro when idle at main menu, and any movie that plays after completing event
eyetoy Handles unlocking Nike Car when scanning GT Shirt with the Eyetoy accessory
gtmode Gran Turismo Mode and all of its sub-menus
labomode Photo lab, Replay Theater, Load & Save Replay, Delete Replay/Film/Photo
logger Replay Analyzer menu, accessed from various Pre-Race menus
message Online mode message menu
network (GT4 Online) Network Connection and Online mode login
network (GT4 Retail) Network Connection for LAN Battle mode. Returns to arcade project once established. Also contains some unused menu pages
online (GT4 Online) Online mode
option Game Options
photo_save Photo preview and save for Photo Drive
photo_shoot Photo mode camera menu, photo preview and save for Photo Travel
print Print menu, accessed from Photo Lab
quick-arcade Arcade mode Single Race Pre-Race menu
quick-championship GT Mode Championship Pre-Race menu
quick-event GT Mode Single Race, Practice, and Family Cup Pre-Race menu
quick-freerun GT Mode Photo Drive Pre-Race menu
quick-license GT Mode License test Pre-Race menu
quick-mission GT Mode Mission Pre-Race menu
quick-mt GT Mode Power & Speed Pre-Race menu
quick-online Online Mode Pre-Race menu
quick-practice GT Mode Track Meet Pre-Race menu
quick-tt Arcade Mode Time Trial Pre-Race menu
setting Car Setting menu and all of its sub-menus (Change parts and tuning sliders)
slide Slideshow mode
GT4Application Initializer and Config Script loader / re-loader
-------- ---- Stub projects: ----
event Unused project that appears to be a mode used on demo setups for public events. Seems non-functional.
ranking Online leaderboards, accessed from Event project
message (GT4 Retail) Message handler for the stub Online mode. (Compilable if GT4O_US_BETA define is absent in the YAML)
online (GT4 Retail) An earlier and unused implementation of online mode, works similarly to GT4 Online's version
language Leftover from GT4P's language select. Contains more language options, appears to be a dev version
list_box Leftover from GT4P's Save/Delete Replay menu. Possibly contains framework for an unused save icon customizer
memcard GT4P leftover
option2 GT4P leftover
option3 GT4P leftover
quick GT4P leftover
[❌️] Tourist Trophy

Tourist Trophy

Adhoc Version: 7
There are 22 projects.
There are 2 collections of shared scripts (share and quick-share) that multiple projects use.
No progress has been made currently.

Name Completed Purpose
arcade ❌️ Arcade mode and all of its sub-menus
bestshot ❌️
boot ❌️ Bootup, new game setup, initial intro movie
cursor ❌️ Sets up cursor and dialog boxes
demo_movie ❌️ Intro when idle at main menu, and any movie that plays after completing event
labomode ❌️ Photo lab, Replay Theater, Load & Save Replay, Delete Replay/Film/Photo
option ❌️ Game Options
photo_save ❌️ Photo mode
print ❌️
quick-arcade ❌️
quick-challenge ❌️
quick-championship ❌️
quick-event ❌️
quick-freerun ❌️
quick-license ❌️
quick-photo ❌️
quick-practice ❌️
quick-tt ❌️
setting ❌️ Bike Setting menu and all of its sub-menus (Change parts and tuning sliders)
slide ❌️ Slideshow mode
ttmode ❌️ Tourist Trophy mode and all of its sub-menus
GT4Application ❌️ Initializer and Config Script loader / re-loader
[❌️] GT HD

GT HD

Adhoc Version: 10 (v8-10 compatible)
There are 7 projects.
There are 2 collections of shared scripts (share and quick-share) that multiple projects use.
No progress has been made currently.

Name Completed Purpose
boot ❌️
cursor ❌️
demo_movie ❌️
option ❌️
quick-arcade ❌️
trial ❌️
GT4Application ❌️ Initializer and Config Script loader / re-loader
[❌️] GT5 Prologue

GT5 Prologue

Adhoc Version: 10
No progress has been made currently.

[✅] GT PSP (gt5m) (100%)

GT PSP (gt5m)

Adhoc Version: 12
All projects and scripts fully reversed by pez2k ✔️
Adhoc code is identical for all regions and revisions.

[🚧] GT5 (2.11) (>=40%)

GT5

Adhoc Version: 12
GT5 2.11 is prefered over 2.17 due to 2.12<->2.17 having no extra content, and mainly patches exploits/server use and other minor things.

Name Completed Purpose
main ✔️ Initial Bootstrap & Utils before boot
arcade ✔️ Arcade Mode
academy N/A
boot ✔️ Boot Project (logic is in bootstrap scripts)
concept N/A
config N/A
cursor N/A
demo_movie N/A
dialog N/A
gps_replay N/A
gtauto N/A
gtmode ✔️ GT Mode. Includes main screen, garage, a/bspec, & every single submenu starting from there.
gttop ✔️ Main Menu
gttv N/A
gttv2 N/A
leavedemo N/A
manual N/A
main (scripts) ✔️ Entrypoint and all util scripts used by ALL projects.
multimonitor N/A
museum N/A
news N/A
online N/A
online_bspec N/A
option N/A
photo N/A
play_movie N/A
race N/A
race_* N/A
ranking N/A
rcvtst N/A
setting N/A
ui_kit N/A
user_profile N/A
user_profile_driver N/A

[🔧] GT6 (1.22) (>=70%)

GT6

Adhoc Version: 12
26 of 49 projects are completed and can be compiled

Name Completed Purpose
main ✔️ Initial Bootstrap & Utils before boot
arcade ✔️ Arcade Mode
boot ✔️ Boot Process handling (Game Start to main project i.e gtmode or dev_runviewer
config ✔️ Game Save Nodes Creation
community ✔️ Community/Online Features Menu (Clubs, TimeLine, Bbs, etc)
cursor ✔️ Cursor handling & Top Menu
datalogger Car Data Logger Menu
dev_design_work ✔️ UI Showcasing (1.00)
dev_runviewer ✔️ Developer Tools
dev_sound ✔️ Sound Engineering Develop Tools
dev_test_sequence Unknown Dev Tools
develop ✔️ Cheat/QA Menu for gtmode
dialog UI Components for Dialogs
event_setting Settings Menu for Editing Lobby Options
garage ✔️ Garage Manager
gps_replay GPS Replay
gtmode ✔️ GT Mode. Everything before loading into an event/race.
gtauto ✔️ GT Auto
gttv Stub Leftover from GT5
leavedemo ✔️ Idle demonstration project
manual ✔️ Manual Menu & Credits
multimonitor ✔️ Multimonitor Handler Project
option ✔️ Game Settings Menu
photo ✔️ Photo Mode Handler
play_movie ✔️ Intro Movie Player Project
race ✔️ Main Race Project & Base
race_arcade_style Sierra Time Rally game mode plugin
race_course_edit Custom Track Test & Uploader game mode plugin
race_drag Left-over Drag game mode plugin
race_drift Drift game mode plugin
race_freerun ✔️ Free-Run game mode plugin
race_license ✔️ License game mode plugin
race_mission ✔️ Mission game mode plugin
race_online_drift Seasonal Drift Event game mode plugin
race_online_event Online Quickmatch Event game mode plugin
race_online_room ✔️ Online Lobby game mode plugin
race_online_single Seasonal Event game mode plugin
race_online_timeattack Seasonal Time Trial game mode plugin
race_single Event game mode plugin
race_split Split-Screen game mode plugin
race_tutorial Tutorial game mode plugin
race_timeattack ✔️ Time Trial game mode plugin
ranking Rankings/Leaderboard Handler Project
setting Car Parameters/Tuning Menu
ui_kit ✔️ Generic UI Components Project
ui_kit_sub Unknown
vision_gt Vision GT Menu
[❌] GT Sport (gt7sp)

GT Sport (gt7sp)

Adhoc Version: 12
Only the boot project (1.00) reversed.

[🛑] GT7

GT7

Out of scope. GT7 no longer uses Adhoc language and instead uses Swift (custom parser & compiler) which is then compiled to adhoc bytecode.

Note

Original bugs are left as is. You can find any that have been identified with the // BUG comments.

Matching notes are usually found starting with // NOTE or // COMPILER NOTE.

⚙️ Compilation

Adhoc Toolchain version 1.3.5 is required to compile game scripts. The tool itself is command line-based without a native GUI, however it does have a VS Code Extension, and a Python GUI wrapper for streamlined usage / workflow.

Tip

Adhoc Toolchain (i.e adhoc.exe) can be added to your PATH (Optional)

🔧 Compilation process:

  • adhoc build -i path:\to\.yaml\project\file -o path:\to\output\.adc\file
    or
  • adhoc build -i path:\to\.ad\source\file -o path:\to\output\.adc\file -v Adhoc Version (5,7,10,12, etc.)
    or
  • "Run Build Task (CTRL+SHIFT+B)" with the VS Code Adhoc Extension on any source file or project file.
    or
  • Use the Python wrapper script for a straightforward GUI to send commands to the program.

For more details refer to the Adhoc Page on the Modding Hub.

📋Contributing & Notes

1. Disassembly

  • To contribute to OpenAdhoc, the 1st step is to disassemble an original adhoc script (.adc), arriving at an intermediate translation of the bytecode that is understandable enough to convert into full source code.
  • The Adhoc toolchain allows disassembling scripts into an assembly-like text form. Most scripts contain symbols which are mandatory and thus allows reconstructing code back into source. Very rarely did syntax have to be made up to support specific adhoc features due to no original source reference, so the documentation is the code.
  • To disassemble a script, run the following command: adhoc path:\to\.adc\file

2. Learning & Decompilation

Translation

  • Understanding how to read the disassembly can be challenging at first.
  • Play around with adhoc first. Learn the basics, the language, and more. Compile basic code, investigate the disassembly, optionally have GT6 run your code using TinyWeb, through RPCS3
  • Refer to the repository for examples of matching code.
  • Translating by hand is a time-consuming and a somewhat steep process, but it is still far easier than decompiling matching assembly language.
  • Once you understand Adhoc well to the point where you know the bytecode, can reverse projects manually yourself and know general compilation process inside-out, you may train an AI model to translate the disassembly for you by having it help you edit code that's already translated, and attempt to have it decompile disassembly every so often. The key to training it is providing a lot of adhoc source code, and over many separate chats over time. It needs to learn the format of adhoc much moreso than the disassembly. This can take a very long time before it gets any good, but if it does it can make short work of even the largest scripts.
📝 Translation example (Expand to view)

Disassembly:

// 1st column is the hex location of the instruction in the binary file.
// 2nd column is the source line number.
// 3rd one is the instruction index for the current code frame.
// Rest is instruction contents.

// *FUNCTION_DEFINE is a new function declaration, equivalent to 'function onActivate(context) {
1A4E| 118| 30| FUNCTION_DEFINE - onActivate(context) '
> Instruction Count: 43 (1A7F)<br>
> Stack Size: 6 - Variable Heap Size: 7 - Variable Heap Size Static: =Variable Heap Size<br>

// Evaluating a module path. Equivalent to 'Slide::slide'
1A87| 109|  0| VARIABLE_PUSH: Slide,slide,`Slide::slide`, Static:2
1AB0| 109|  1| EVAL

// Accessing the isPlaying attribute of above path, so 'Slide::slide.isPlaying'
1AB5| 109|  2| ATTRIBUTE_PUSH: `isPlaying`<br>
1AC5| 109|  3| EVAL<br>

// Calling it. So we're making a call with 0 arguments, so we have: 'Slide::slide.isPlaying()'
1ACA| 109|  4| `CALL: ArgCount=0`<br>
1AD3| 109|  5| EVAL<br>

// This is a unary operator so we want to check if the above is false. Essentially this is 'if (!Slide::slide.isPlaying()) { ...'
// The JUMP_IF_FALSE index essentially is the end of the if block.
1AD8| 109|  6| UNARY_OPERATOR: ! (`!`)
1AE0| 109|  7| JUMP_IF_FALSE: Jump To Func Ins 39

// NOPs are used in earlier versions whenever a curly bracket was used in the original source code. This would have allowed a debugger to step through it.
1AE9| 110|  8| NOP

// Making yet another call, this time with one argument. Equivalent to 'main::sound.play("ok")'
1AEE| 111|  9| VARIABLE_PUSH: main,sound,main::sound, Static:3
1B15| 111| 10| EVAL<br>
1B1A| 111| 11| ATTRIBUTE_PUSH: play
1B25| 111| 12| EVAL<br>
1B2A| 111| 13| STRING_CONST: ok
1B33| 111| 14| CALL: ArgCount=1
1B3C| 111| 15| EVAL<br>
1B41| 111| 16| POP_OLD  // We aren't doing anything about the return value so it is being POP'ed.

// ...
// Skipping ahead, we reach the bottom of the function. SET_STATE is used as flow control, and in this case indicates a return to parent frame/function.
// (in particular, 2 is equal to EVENTRESULT_FILTER, which is a ui define for input control and whether to process other events).
// If a return was not manually specified, the compiler will always insert one (otherwise the function would never actually return).
1C46| 117| 39| INT_CONST: 2 (0x02)`<br>
1C4F| 117| 40| POP_OLD`<br>
1C54| 117| 41| SET_STATE_OLD: State=RETURN (1)`<br>

Translated:

function onActivate(context)
{
    if (!Slide::slide.isPlaying())
    {
        main::sound.play("ok");
        Slide::slide.doPlay();
        sensitive();
        SlideRoot.setFocus(Stop);
    }

    return EVENTRESULT_FILTER;
}

3. Decompilation/Contribution Guidelines

  • One golden rule before anything: Always, always, always make sure that you are running the latest version of the toolchain.
  • The 1st roadblock is squashing any mistakes in translating the disassembly if your translated code doesn't at least compile. You'll be on your own until you can get it to compile.
  • Once you successfully compile it, the next step is to revise the translated code to get it to completely match the original compiled code. To do so, disassemble both the original .adc and your new .adc. Use the included GTAdhocCompare.py script in the Toolchain's scripts folder to diff them. This will output an html file letting you view both disassemblies side-by-side. Red highlights indicate missing logic, and green highlights indicate added logic. Revise your translated code until all relevant red and green highlights from the comparison are eliminated.
  • Use the highlighted n link to navigate between differences, do not just scroll up or down to find mismatches. The n will jump to the next difference.
  • You should compare built scripts in multiple passes. For the first pass, ensure that most things match by comparing with GTAdhocCompare.py. Next, compare with GTAdhoCompare.py with the -j argument. This also allows comparing jump instruction indices to make sure branches match aswell.
  • The more passes the better. Human mistakes are expected such as typos, wrongly recognized branches, and so on. You can't expect to decompile correctly on the first try even if you are certain. You may still be left with dozens of mismatches you didn't pick up between passes.
  • Refer to below for things that can be omitted or not.

Things that must be preserved, aka, contribution guidelines

  • The logic should be perfectly matching. No typos, misnaming, anything that otherwise would make a script behave differently. Sometimes because of compiler differences it may not be possible, but the goal is to have the logic match nonetheless.
  • All code of any kind should be present in the scripts; bugs should NOT be fixed but should always be marked with a // BUG: <comment> block. An example of this is usage of undeclared variables, typos.
  • Usage of PROJECT and ROOT defines should be used everywhere to replace the current root name. Example: MyMenuRoot should be replaced with just ROOT (which should match the file name aswell).
  • Usage of other defines must be used when applicable such as EVENTRESULT and PAD defines (list here)
  • You should use preprocessor macros when the source code clearly shows use of one (i.e many statements on the same source line is a hint that a macro may've been used).
  • Comments to help understand code in general are not needed but appreciated.
  • GT4 and earlier - bool instructions did not exist, and are instead represented by a integer instruction instead. When applicable, try to recognize when bools are actually used (0 is false, 1 is true).

Things that are okay to discard

  • Following line numbers - attempting to follow line numbers for code that may be stripped from undefined original preprocessor directives or missing comment blocks can leave holes in the source, therefore prefered not to follow line numbers for better readability. Please make sure that the code is pretty much written in the same style as the projects already on this repository.
  • SOURCE_FILE instructions - These will be off due to path differences & the custom compiler emits them per file (on enter, and on exit to resume to the previous file). Earlier than GT5 had an issue in their compilers where SOURCE_FILE instructions were sometimes not emitted at the right spot.
  • Logic order - It is common that scripts were written using such pattern: nil != myObject or "Dog" == myString. For readability, literals should always be on the right-hand side such as myObject != nil.
  • LOGICAL_OR/LOGICAL_AND jump indices - The custom compiler may be slightly inaccurate when emitting these instructions. Namely the jump indices may look off (jumping to other LOGICAL_* rather than the end of a statement). This is okay to omit as the compiler does not implement short-circuit evaluation optimization like the original compiler does, but the way the instructions are executed will still produce the same result. However it does make it a little harder to make sure that the logic matches when both LOGICAL_AND and LOGICAL_OR's are used within the same statement, so make sure to review those instructions carefully!
  • For GT5 and above, LEAVE instructions may be emitted that essentially cleanups local variables used within a statement (one is emitted at the end of any block statement } that should be clearing some variables). These may throw the jump indices a little, but as long as the logic still matches, this is okay to omit. GTAdhocCompare will not show leaves by default. The -j argument will not show them either, but may show a difference in jump indices. Make sure to review them. You can also use the -l argument to include LEAVE in the compare output.

Once your translated code is fully matching (or at least as close as possible), fork the repo, add your files to your fork, then make a pull request. In the Pull request conversation, add any relevant information about your new files. If you have any mistakes that you are unable to correct, point them out for review and suggestions. Preferably your projects should be already matching and thus doesn't need verification. Otherwise open an issue.

Note

Since this is a custom compiler, some issues may pop up. Feel free to reach out on the GTAdhocToolchain repository. It should be capable of compiling most projects without issues, but it is not without issues. (Stack handling should be reworked eventually using GT7 compiler research. (as of 21/09/2025))

📜 History

  • August 2020 - Initial breakthrough in Adhoc, dissasembler built based on reverse-engineering
  • September 2020 - Master Mod release for GT5 with hex-edited script code edits
  • July 2021 - GT6 Spec II Mod release for GT6
  • December 2021 - Breakthrough. GT Sport Closed Beta build dump, contained a few scripts in source and compiled formats which allowed to figure most of the syntax to be similar to Javascript and Python. Stack understanding later came thanks to a random thought by ddm999 and the first custom "hello world" script compilation within the GT6 Web Server successfully ran to completion.
  • January 2022 - First fully recompiled project (boot).
  • February 2022 <-> December 2022 - Dozens of projects successfully recreated.
  • December 2022 - Source release.
  • September 2025 - GT4 and GT PSP reach 100% matching Adhoc decompilation.

Licensing

This project uses the GNU GENERAL PUBLIC LICENSE.

This project is not affiliated with "Polyphony Digital Inc." , "Gran Turismo", "GT", or any other projects by the aforementioned entities.

About

Open-source re-implementation of Gran Turismo Scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 6