# Decompile

As previously mentioned, [**AtlusScriptCompiler**](https://docs.shrinefox.com/flowscript/atlusscriptcompiler) can [**decompile**](https://docs.shrinefox.com/flowscript/atlusscriptcompiler/run-via-commandline/decompile) `.BF` and `.BMD` into `.FLOW` and `.MSG` respectively. This allows us to view scripts in plain text and edit to our liking.

## 1. Specifying the Input File <a href="#id-1-specifying-the-input-file" id="id-1-specifying-the-input-file"></a>

First, you must tell the program what file we're working with. \
For [decompiling](https://docs.shrinefox.com/flowscript/atlusscriptcompiler/run-via-commandline/decompile), this must be a `.BF` or `.BMD` file.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd"
```

{% hint style="info" %}
You can simply **drag** `AtlusScriptCompiler.exe` and then `input.bmd` onto the [command prompt window](https://docs.shrinefox.com/flowscript/atlusscriptcompiler/run-via-commandline). \
This will automatically wrap each paths in quotes, which keeps arguments separate in case your paths contain spaces.‌
{% endhint %}

## 2. Specify that you are Decompiling

Now, let's tell the program what to do with that file. \
Add `-Decompile`, separated by a space.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile
```

## 2. Specifying the Library <a href="#id-2-specifying-the-library" id="id-2-specifying-the-library"></a>

A **Flowscript Library** instructs the compiler on function names and parameters.\
In order to work with the input file, you have to tell the compiler which Library to use with `-Library`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile -Library P5
```

### Included Libraries <a href="#included-libraries" id="included-libraries"></a>

|         Library Name | Usage                 |
| -------------------: | --------------------- |
| **DigitalDevilSaga** | `-Library`**`DDS`**   |
|         **Nocturne** | `-Library`**`SMT3`**  |
|         **Persona3** | `-Library`**`P3`**    |
|      **Persona3FES** | `-Library`**`P3FES`** |
| **Persona3Portable** | `-Library`**`P3P`**   |
|         **Persona4** | `-Library`**`P4`**    |
|   **Persona4Golden** | `-Library`**`P4G`**   |
|         **Persona5** | `-Library`**`P5`**    |
|    **Persona5Royal** | `-Library`**`P5R`**   |
|        **PersonaQ2** | `-Library`**`PQ2`**   |

{% hint style="warning" %}
**Not all games** have libraries available. Knowledge of reverse engineering game executables is required to generate a library, as you'll have to find the offsets of function signatures yourself. A sample script for dumping that data from P3/P4 (PS2) can be seen [here](https://github.com/TGEnigma/Atlus-Script-Tools/blob/master/Scripts/ScriptInterpreterCOMMTableToJson_P3P4.py).‌‌
{% endhint %}

## 3. Specifying Encoding <a href="#id-4-specifying-encoding" id="id-4-specifying-encoding"></a>

‌An **Encoding** can be specified using `-Encoding`. \
It lets the compiler know what set of characters to use.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" =Decompile -Library P5 -Encoding P5
```

### Encodings <a href="#encodings" id="encodings"></a>

|                                                                    Game Name | Usage                       |
| ---------------------------------------------------------------------------: | --------------------------- |
|                                                                **Persona 5** | `-Encoding`**`P5`**         |
|                                                                **Persona 4** | `-Encoding`**`P4`**         |
|                                                          **Persona 3 (FES)** | `-Encoding`**`P3`**         |
| <p><strong>PersonaQ(2)</strong><br>or any game using <br>Shift-JIS/CP932</p> | `-Encoding`**`SJ`**&#x200C; |

## 5. Specifying the Output File <a href="#id-5-specifying-the-output-file" id="id-5-specifying-the-output-file"></a>

‌Finally, you can name the **Output File** using `-Out`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile -Library P5 -Encoding P5 -Out "C:\Path\To\output.msg"
```

If `-Out` is **not specified,** it will default to the input filename and folder, but with the output filetype appended. In this case, that would be `C:\Path\To\input.bmd.msg`.‌

## Conclusion

At this point, you can press **`Enter`**&#x74;o begin decompiling.

To learn how to put a new or edited script back in the game, keep reading.

{% content-ref url="compile" %}
[compile](https://docs.shrinefox.com/flowscript/atlusscriptcompiler/run-via-commandline/compile)
{% endcontent-ref %}
