Esempio n. 1
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            sz_str = reader.ReadUInt16();
            str    = new Reference <String>(reader, resolve: true, onPreRead: (s) => { s.length = sz_str; });
        }
Esempio n. 2
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            sz_str = reader.ReadUInt16();
            str    = new Reference <String>(reader, resolve: true, onPreRead: (s) => { s.length = sz_str; s.isBytes = true; });
            //l.print(sz_str + " - " + string.Join(", ", str.Value.bytes));
        }
Esempio n. 3
0
        public Reference <T> Resolve(Reader reader, Action <T> onPreRead = null)
        {
            R2ROMLoader l     = MapLoader.Loader as R2ROMLoader;
            ushort      index = forceFix ? (ushort)(this.index | (ushort)FATEntry.Flag.Fix) : this.index;

            Value = l.GetOrRead(reader, index, onPreRead: onPreRead);
            return(this);
        }
Esempio n. 4
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            strings = new Reference <BinaryStringRef> [length];
            for (ushort i = 0; i < length; i++)
            {
                strings[i] = new Reference <BinaryStringRef>(reader, true);
            }
        }
Esempio n. 5
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            refs = new Reference <TextureInfoRef> [length];
            for (int i = 0; i < length; i++)
            {
                refs[i] = new Reference <TextureInfoRef>(reader, true);
            }
        }
Esempio n. 6
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            vmTex = new VisualMaterialTexture[length];
            for (int i = 0; i < vmTex.Length; i++)
            {
                vmTex[i].texRef = new Reference <TextureInfoRef>(reader, true);
                vmTex[i].time   = reader.ReadUInt16();
            }
        }
Esempio n. 7
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            elements = new GeometricElementListEntry[length];
            for (ushort i = 0; i < length; i++)
            {
                elements[i].element = new GenericReference(reader, true);
                elements[i].unk0    = reader.ReadUInt16();
                elements[i].unk1    = reader.ReadUInt16();
            }
        }
Esempio n. 8
0
 public void ReadData(ushort index)
 {
     if (index != 0xFFFF && index < length)
     {
         R2ROMLoader l            = MapLoader.Loader as R2ROMLoader;
         ushort      currentIndex = index;
         while (currentIndex != 0xFFFF)
         {
             l.romAnims[currentIndex].ReadData();
             currentIndex = entries[currentIndex].nextAnim;
         }
     }
 }
Esempio n. 9
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            textTable       = new Reference <StringRefArray>(reader);
            num_txtTable    = reader.ReadUInt16();
            binaryTable     = new Reference <BinaryStringRefArray>(reader);
            num_binaryTable = reader.ReadUInt16();
            unk_08          = reader.ReadUInt16();
            name            = reader.ReadString(0x12);

            // Resolve unresolved references
            textTable.Resolve(reader, (tt) => { tt.length = num_txtTable; });
            binaryTable.Resolve(reader, (tt) => { tt.length = num_binaryTable; });
        }
Esempio n. 10
0
        private void ParseMatrixAndVector()
        {
            R2ROMLoader l  = MapLoader.Loader as R2ROMLoader;
            LevelHeader lh = l.Get <LevelHeader>((ushort)(l.CurrentLevel | (ushort)FATEntry.Flag.Fix));

            if (lh != null)
            {
                Short3Array  indices = lh.indices.Value;
                Vector3Array vectors = lh.vectors.Value;
                matrix = ROMTransform.ROMMatrix.Get(matrixIndex, indices, vectors);
                if (vectorIndex != 0xFFFF && vectorIndex < vectors.length)
                {
                    vector = vectors.vectors[vectorIndex];
                }
            }
        }
Esempio n. 11
0
        public async Task Read(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            l.loadingState = "Loading language tables";
            await MapLoader.WaitIfNecessary();

            NumLanguages numLanguages = l.GetOrRead <NumLanguages>(reader, 0);

            l.print("Number of languages: " + numLanguages.num_languages);
            languageTables = new LanguageTable[numLanguages.num_languages];
            for (ushort i = 0; i < numLanguages.num_languages; i++)
            {
                l.loadingState = "Loading language table " + (i + 1) + "/" + numLanguages.num_languages;
                await MapLoader.WaitIfNecessary();

                languageTables[i] = l.GetOrRead <LanguageTable>(reader, i);
                if (languageTables[i] != null)
                {
                    l.print(languageTables[i].name);
                }
            }
        }
Esempio n. 12
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            if (Settings.s.platform == Settings.Platform.N64)
            {
                r = reader.ReadByte();
                g = reader.ReadByte();
                b = reader.ReadByte();
                a = reader.ReadByte();
            }
            else
            {
                diffuseCoef = reader.ReadUInt16();
                ambientCoef = reader.ReadUInt16();
            }
            scrollSpeedX     = reader.ReadSingle();
            scrollSpeedY     = reader.ReadSingle();
            textures         = new Reference <VisualMaterialTextures>(reader);
            num_textures     = reader.ReadUInt16();
            num_animTextures = reader.ReadUInt16();
            flags            = reader.ReadUInt16();
            textures.Resolve(reader, (vmt) => { vmt.length = num_textures; });
        }
Esempio n. 13
0
        public ROMTransform(ushort index)
        {
            if (index == 0xFFFF)
            {
                return;
            }
            R2ROMLoader l  = MapLoader.Loader as R2ROMLoader;
            LevelHeader lh = l.Get <LevelHeader>((ushort)(l.CurrentLevel | (ushort)FATEntry.Flag.Fix));

            if (lh != null)
            {
                Short3Array          indices = lh.indices.Value;
                Vector3Array         vectors = lh.vectors.Value;
                Short3Array.Triangle tri     = lh.indices.Value.triangles[index];
                rotationMatrix = ROMMatrix.Get(tri.v1, indices, vectors);
                scaleMatrix    = ROMMatrix.Get(tri.v2, indices, vectors);
                if (tri.v3 != 0xFFFF && tri.v3 < vectors.length)
                {
                    //MapLoader.Loader.print(tri.v3);
                    position = vectors.vectors[tri.v3];
                    //MapLoader.Loader.print(transform.position);
                }
            }
        }
Esempio n. 14
0
        protected override void ReadInternal(Reader reader)
        {
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            if (Settings.s.platform == Settings.Platform._3DS)
            {
                wExponent    = reader.ReadByte();
                hExponent    = reader.ReadByte();
                flags        = reader.ReadUInt16();
                flags2       = reader.ReadUInt16();
                color_size   = reader.ReadUInt16();
                bpp          = reader.ReadUInt16();
                name         = reader.ReadString(200);
                off_texture  = Pointer.Current(reader);
                textureBytes = reader.ReadBytes(color_size);                 // max size: 0x10000
                Texture2D rawTex = new ETC(textureBytes, 1 << wExponent, 1 << hExponent, bpp == 32).texture;
                if (l.exportTextures)
                {
                    if (!File.Exists(l.gameDataBinFolder + "/textures/" + Path.GetDirectoryName(name) + "/" + Path.GetFileNameWithoutExtension(name) + ".png"))
                    {
                        Util.ByteArrayToFile(l.gameDataBinFolder + "/textures/" + Path.GetDirectoryName(name) + "/" + Path.GetFileNameWithoutExtension(name) + ".png", rawTex.EncodeToPNG());
                    }
                }
                Texture = rawTex;
            }
            else if (Settings.s.platform == Settings.Platform.DS || Settings.s.platform == Settings.Platform.N64)
            {
                texture_index = reader.ReadUInt16();
                palette_index = reader.ReadUInt16();
                alpha_index   = reader.ReadUInt16();
                wExponent     = reader.ReadByte();
                hExponent     = reader.ReadByte();
                flags         = reader.ReadUInt16();
                color_size    = reader.ReadUInt16();
                if (Settings.s.platform == Settings.Platform.DS)
                {
                    palette_num_colors = reader.ReadUInt16();
                }
                else
                {
                    palette_num_colors = 16;
                }
                ushort      ind_texture = 0xFFFF;
                bool        rgba16      = alpha_index != 0xFFFF && texture_index != 0xFFFF;
                GF64.Format format      = GF64.Format.I4;
                if ((flags & 1) != 0)
                {
                    ind_texture = (ushort)((texture_index + l.ind_textureTable_i4) & 0xFFFF);
                }
                else if ((flags & 2) != 0)
                {
                    format      = GF64.Format.I8;
                    ind_texture = (ushort)((texture_index + l.ind_textureTable_i8) & 0xFFFF);
                    if (Settings.s.platform == Settings.Platform.N64)
                    {
                        palette_num_colors = 256;
                    }
                }
                else if ((flags & 4) != 0)
                {
                    format      = GF64.Format.RGBA;
                    ind_texture = (ushort)((texture_index + l.ind_textureTable_rgba) & 0xFFFF);
                }
                if (ind_texture != 0xFFFF)
                {
                    off_texture = l.texturesTable[ind_texture];
                    if (l.texturesTableSeen != null)
                    {
                        l.texturesTableSeen[ind_texture] = true;
                    }
                }
                if (alpha_index != 0xFFFF)
                {
                    off_alpha = l.texturesTable[alpha_index];
                    if (l.texturesTableSeen != null)
                    {
                        l.texturesTableSeen[alpha_index] = true;
                    }
                }
                off_palette = null;

                /*if (Settings.s.platform == Settings.Platform.DS) {
                 *      format = rgba16 ? GF64.Format.RGBA : (palette_num_colors == 16 ? GF64.Format.I4 : GF64.Format.I8);
                 * }*/
                if (palette_index != 0xFFFF)
                {
                    if (Settings.s.platform == Settings.Platform.DS)
                    {
                        off_palette = l.palettesTable[palette_index & 0x7FFF];
                        if (l.palettesTableSeen != null)
                        {
                            l.palettesTableSeen[palette_index & 0x7FFF] = true;
                        }
                    }
                    else
                    {
                        off_palette = l.GetStructPtr(FATEntry.Type.Palette, palette_index, global: true);
                    }
                }

                /*l.print(((1 << hExponent) * (1 << wExponent)) + "\t"
                 + (1 << wExponent) + "\t" + (1 << hExponent) + "\t"
                 + (texture_index == 0xFFFF ? "-" : texture_index.ToString()) + "\t"
                 + (alpha_index == 0xFFFF ? "-" : alpha_index.ToString()) + "\t"
                 + (palette_index == 0xFFFF ? "-" : (palette_index & 0x7FFF).ToString()) + "\t"
                 + String.Format("{0:X4}", flags) + "\t"
                 + color_size + "\t"
                 + palette_num_colors + "\t"
                 + off_texture + "\t"
                 + off_alpha + "\t"
                 + off_palette + "\t");*/
                if (off_texture != null)
                {
                    mainTex = new GF64(reader,
                                       off_texture,
                                       (1 << wExponent),
                                       (1 << hExponent),
                                       format,
                                       off_palette,
                                       palette_num_colors);
                }
                if (off_alpha != null)
                {
                    alphaTex = new GF64(reader,
                                        off_alpha,
                                        (1 << wExponent),
                                        (1 << hExponent),
                                        GF64.Format.I4Alpha,
                                        null,
                                        palette_num_colors);
                    if (mainTex != null)
                    {
                        mainTex.LoadAlphaTexture(alphaTex);
                    }
                }
                Texture2D rawTex = mainTex != null ? mainTex.texture : alphaTex?.texture;
                if (l.exportTextures)
                {
                    if (rawTex != null)
                    {
                        string palette = (palette_index != 0xFFFF ? "_P" + (palette_index & 0x7FFF) : "");
                        string alpha   = (alpha_index != 0xFFFF ? "_A" + (alpha_index & 0x7FFF) : "");
                        string main    = (texture_index != 0xFFFF ? "_T" + (texture_index & 0x7FFF) : "");
                        if (!File.Exists(l.gameDataBinFolder + "/textures/" + format + main + alpha + palette + ".png"))
                        {
                            Util.ByteArrayToFile(l.gameDataBinFolder + "/textures/" + format + main + alpha + palette + ".png", rawTex.EncodeToPNG());
                        }
                    }
                    else
                    {
                        Debug.LogWarning("No mainTex or alphaTex for tex " + Offset);
                    }
                }
                Texture = rawTex;
            }
        }
Esempio n. 15
0
        public Type Resolve(Reader reader)
        {
            if (this.type == 0xFFFF)
            {
                return(null);
            }
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;

            FATEntry.Type entryType = FATEntry.GetEntryType(this.type);
            System.Type   type      = null;
            foreach (KeyValuePair <System.Type, FATEntry.Type> typePair in FATEntry.types)
            {
                if (typePair.Value == entryType)
                {
                    type = typePair.Key;
                    break;
                }
            }
            ushort index = forceFix ? (ushort)(this.index | (ushort)FATEntry.Flag.Fix) : this.index;

            switch (entryType)
            {
            case FATEntry.Type.GeometricElementTriangles:
                Value = l.GetOrRead <GeometricObjectElementTriangles>(reader, index);
                break;

            case FATEntry.Type.GeometricElementSprites:
                Value = l.GetOrRead <GeometricObjectElementSprites>(reader, index);
                break;

            case FATEntry.Type.VisualMaterial:
                Value = l.GetOrRead <VisualMaterial>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideTriangles:
                Value = l.GetOrRead <GeometricObjectElementCollideTriangles>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideAlignedBoxes:
                Value = l.GetOrRead <GeometricObjectElementCollideAlignedBoxes>(reader, index);
                break;

            case FATEntry.Type.GeometricElementCollideSpheres:
                Value = l.GetOrRead <GeometricObjectElementCollideSpheres>(reader, index);
                break;

            case FATEntry.Type.GameMaterial:
                Value = l.GetOrRead <GameMaterial>(reader, index);
                break;

            case FATEntry.Type.PhysicalObject:
                Value = l.GetOrRead <PhysicalObject>(reader, index);
                break;

            case FATEntry.Type.Sector:
                Value = l.GetOrRead <Sector>(reader, index);
                break;

            default:
                UnityEngine.Debug.LogWarning("GenericReference: Unsupported struct with type " + entryType + "(" + this.type + ")");
                break;
            }
            return(type);
        }
Esempio n. 16
0
    private List <string> FindFiles()
    {
        // Create the output
        var output = new List <string>();

        // If the directory does not exist, return the empty list
        if (!Directory.Exists(directory))
        {
            return(output);
        }

        // Add the found files containing the correct file extension
        string extension = null;

        switch (Settings.s.platform)
        {
        case Settings.Platform.PC:
        case Settings.Platform.iOS:
        case Settings.Platform.GC:
        case Settings.Platform.Xbox:
        case Settings.Platform.Xbox360:
            if (Settings.s.engineVersion < Settings.EngineVersion.R3)
            {
                extension = "*.sna";
            }
            else
            {
                extension = "*.lvl";
            }
            break;

        case Settings.Platform.DC: extension = "*.DAT"; break;

        case Settings.Platform.PS2:
            if (Settings.s.engineVersion < Settings.EngineVersion.R3)
            {
                extension = "*.lv2";
            }
            else
            {
                extension = "*.lvl";
            }
            break;

        case Settings.Platform.DS:
        case Settings.Platform.N64:
        case Settings.Platform._3DS:
            MapLoader.Reset();
            R2ROMLoader l = MapLoader.Loader as R2ROMLoader;
            l.gameDataBinFolder = directory;
            string[] levels = l.LoadLevelList();
            MapLoader.Reset();
            output.AddRange(levels);
            break;
        }
        if (extension != null)
        {
            output.AddRange(
                from file in Directory.EnumerateFiles(directory, extension, SearchOption.AllDirectories)
                let filename = Path.GetFileNameWithoutExtension(file)
                               where ((!filterPaths.Contains(filename.ToLower())) &&
                                      new DirectoryInfo(file).Parent.Name.ToLower() == filename.ToLower())
                               select filename

                );
        }

        // Return the output
        return(output);
    }
Esempio n. 17
0
            public string ToString(Perso perso, TranslatedROMScript.TranslationSettings ts, bool advanced = false)
            {
                R2ROMLoader l    = Loader;
                short       mask = 0;

                AITypes aiTypes = Settings.s.aiTypes;

                Vector3 vector3 = new Vector3 {
                    x = 0, y = 0, z = 0
                };

                switch (nodeType)
                {
                case NodeType.KeyWord:     // KeyWordFunctionPtr
                    if (param < aiTypes.keywordTable.Length)
                    {
                        if (ts.exportMode)
                        {
                            if (aiTypes.keywordTable[param] == "Me")
                            {
                                return("this");
                            }
                            if (aiTypes.keywordTable[param] == "MainActor")
                            {
                                return("Controller.MainActor");
                            }
                            if (aiTypes.keywordTable[param] == "Nobody" || aiTypes.keywordTable[param] == "NoInput" || aiTypes.keywordTable[param] == "Nowhere" || aiTypes.keywordTable[param] == "NoGraph" || aiTypes.keywordTable[param] == "NoAction" || aiTypes.keywordTable[param] == "CapsNull")
                            {
                                return("null");
                            }
                        }

                        return(aiTypes.keywordTable[param]);
                    }
                    return("UnknownKeyword_" + param);

                case NodeType.Condition:     // GetConditionFunctionPtr
                    if (param < aiTypes.conditionTable.Length)
                    {
                        return(aiTypes.conditionTable[param]);
                    }
                    return("UnknownCondition_" + param);

                case NodeType.Operator:     // GetOperatorFunctionPtr
                    if (advanced)
                    {
                        if (param < aiTypes.operatorTable.Length)
                        {
                            return(aiTypes.operatorTable[param] + " (" + param + ")");
                        }
                    }
                    if (param < aiTypes.operatorTable.Length)
                    {
                        return(aiTypes.operatorTable[param]);
                    }
                    return("UnknownOperator_" + param);

                case NodeType.Function:     // GetFunctionFunctionPtr
                    if (param < aiTypes.functionTable.Length)
                    {
                        return(aiTypes.functionTable[param]);
                    }
                    return("UnknownFunction_" + param);

                case NodeType.Procedure:     // ProcedureFunctionReturn
                    if (param < aiTypes.procedureTable.Length)
                    {
                        return(aiTypes.procedureTable[param]);
                    }
                    return("UnknownProcedure_" + param);

                case NodeType.MetaAction:     // meta action
                    if (param < aiTypes.metaActionTable.Length)
                    {
                        return(aiTypes.metaActionTable[param]);
                    }
                    return("UnknownMetaAction_" + param);

                case NodeType.BeginMacro:
                    return("BeginMacro");

                case NodeType.EndMacro:
                    return("EndMacro");

                case NodeType.Field:
                    if (param < aiTypes.fieldTable.Length)
                    {
                        return(aiTypes.fieldTable[param]);
                    }
                    return("UnknownField_" + param);

                case NodeType.DsgVarRef:     // Dsg Var
                    /*if (perso != null && perso.brain != null && perso.brain.mind != null) {
                     *  Mind mind = perso.brain.mind;
                     *  if (mind.dsgMem != null && mind.dsgMem.dsgVar != null) {
                     *      if (param < mind.dsgMem.dsgVar.dsgVarInfos.Length) {
                     *          return mind.dsgMem.dsgVar.dsgVarInfos[param].NiceVariableName;
                     *      }
                     *  } else if (mind.AI_model != null && mind.AI_model.dsgVar != null) {
                     *      if (param < mind.AI_model.dsgVar.dsgVarInfos.Length) {
                     *          return mind.AI_model.dsgVar.dsgVarInfos[param].NiceVariableName;
                     *      }
                     *  }
                     * }*/
                    return("dsgVar_" + param);

                case NodeType.Constant:
                    if (advanced)
                    {
                        return("Constant: " + paramInt.Value?.value);
                    }
                    return(paramInt.Value?.value + "");

                case NodeType.Real:
                    NumberFormatInfo nfi = new NumberFormatInfo()
                    {
                        NumberDecimalSeparator = "."
                    };
                    return(paramFloat.Value?.value.ToString(nfi) + "f");

                case NodeType.Button:     // Button/entryaction
                    EntryAction ea = paramButton.Value;

                    if (ea == null)
                    {
                        return("ERR_ENTRYACTION_NOTFOUND");
                    }

                    string eaName = (advanced ? ea.ToString() : ea.ToScriptString());
                    if (advanced)
                    {
                        return("Button: " + eaName + "(" + ea.Offset + ")");
                    }

                    if (!ts.expandEntryActions && ea != null)
                    {
                        return("\"" + eaName + "\"");
                    }
                    return(eaName);

                case NodeType.ConstantVector:
                    return("Constant Vector: " + paramVector3.Value?.value.ToString());

                case NodeType.Vector:
                    return("new Vector3");    // TODO: same

                case NodeType.Mask:
                    mask = (short)param;     // TODO: as short
                    if (advanced)
                    {
                        return("Mask: " + (mask).ToString("x4"));
                    }
                    if (ts.exportMode)
                    {
                        return("\"" + (mask).ToString("x4") + "\"");
                    }
                    return("Mask(" + (mask).ToString("x4") + ")");

                case NodeType.ModuleRef:
                    if (advanced)
                    {
                        return("ModuleRef: " + "0x" + (param).ToString("x8"));
                    }
                    return("GetModule(" + (int)param + ")");

                case NodeType.DsgVarId:
                    if (advanced)
                    {
                        return("DsgVarId: " + "0x" + (param).ToString("x8"));
                    }
                    return("DsgVarId(" + param + ")");

                case NodeType.String:
                    return(paramString.Value.ToString());

                case NodeType.LipsSynchroRef:
                    return("LipsSynchroRef: " + param);

                case NodeType.FamilyRef:

                    return("Family.FromIndex(" + ParamString + ")");

                case NodeType.PersoRef:
                    return("Perso.FromIndex(" + ParamString + ")");

                case NodeType.ActionRef:
                    return("GetAction(" + ParamString + ")");

                case NodeType.SuperObjectRef:
                    return("SuperObject.FromIndex(" + ParamString + ")");

                case NodeType.WayPointRef:
                    return("WayPoint.FromIndex(" + ParamString + ")");

                case NodeType.TextRef:
                    if (param == 0xFFFF || l.localizationROM == null)
                    {
                        return("TextRef.Null");
                    }

                    /*if (advanced) return "TextRef: " + param + " (" + l.localizationROM.GetTextForHandleAndLanguageID((int)param, 0) + ")";
                     * if (ts.expandStrings) {
                     *  return "\"" + l.localizationROM[0].GetTextForHandleAndLanguageID((int)param, 0) + "\""; // Preview in english
                     * } else {
                     *  return "new TextReference(" + (int)param + ")";
                     * }*/
                    int    txtIndex = param;
                    string result   = l.localizationROM.Lookup(txtIndex);
                    if (result != null)
                    {
                        return("\"" + result + "\"");
                    }
                    else
                    {
                        return("TextRef_" + param);
                    }

                case NodeType.ComportRef:

                    return("Comport.FromIndex(" + ParamString + ")");

                case NodeType.SoundEventRef:
                    if (advanced)
                    {
                        return("SoundEventRef: " + (int)param);
                    }
                    return("SoundEvent.FromID(0x" + ((int)param).ToString("X8") + ")");

                case NodeType.ObjectTableRef:


                    return("ObjectTable.FromIndex(" + ParamString + ")");

                case NodeType.GameMaterialRef:

                    return("GameMaterial.FromIndex(" + ParamString + ")");

                case NodeType.ParticleGenerator:
                    return("ParticleGenerator: " + "0x" + (param).ToString("x8"));

                case NodeType.VisualMaterial:
                    return("VisualMaterial.FromIndex(" + ParamString + ")");

                case NodeType.ModelRef:     // ModelCast

                    return("AIModel.FromIndex(" + ParamString + ")");

                case NodeType.DataType42:
                    if (advanced)
                    {
                        return("EvalDataType42: " + "0x" + (param).ToString("x8"));
                    }
                    return("EvalDataType42(" + "0x" + (param).ToString("x8") + ")");

                case NodeType.CustomBits:
                    if (advanced)
                    {
                        return("CustomBits: " + "0x" + (param).ToString("x8"));
                    }
                    if (ts.exportMode)
                    {
                        return("0x" + (param).ToString("x8"));
                    }
                    return("CustomBits(" + "0x" + (param).ToString("x8") + ")");

                case NodeType.Caps:
                    if (advanced)
                    {
                        return("Caps: " + "0x" + (param).ToString("x8"));
                    }
                    if (ts.exportMode)
                    {
                        return("0x" + (param).ToString("x8"));
                    }
                    return("Caps(" + "0x" + (param).ToString("x8") + ")");

                case NodeType.SubRoutine:
                    string macroString = "/* Subroutine */";
                    macroString += Environment.NewLine;
                    TranslatedROMScript macroScript = new TranslatedROMScript(paramScript.Value, perso);
                    macroString += macroScript.ToString();
                    macroString += Environment.NewLine + "/* End Subroutine */";
                    return(macroString);

                case NodeType.Null:
                    return("null");

                case NodeType.GraphRef:
                    if (advanced)
                    {
                        return("Graph: " + "0x" + (param).ToString("x8"));
                    }
                    return("Graph.FromIndex(" + ParamString + ")");
                }

                return("unknown");
            }