Example #1
0
        //Utility
        private int GetTypeCount(int type, BPE_SubEntry subEntry)
        {
            switch (type)
            {
            case 0:
                return(subEntry.Type0.Count());

            case 1:
                return(subEntry.Type1.Count());

            case 2:
                return(subEntry.Type2.Count());

            case 3:
                return(subEntry.Type3.Count());

            case 4:
                return(subEntry.Type4.Count());

            case 5:
                return(subEntry.Type5.Count());

            case 6:
                return(subEntry.Type6.Count());

            case 7:
                return(subEntry.Type7.Count());

            case 8:
                return(subEntry.Type8.Count());

            case 9:
                return(subEntry.Type9.Count());

            default:
                return(0);
            }
        }
Example #2
0
        private void ParseBpe()
        {
            int count       = BitConverter.ToInt16(rawBytes, 18);
            int offset      = BitConverter.ToInt32(rawBytes, 20);
            int actualIndex = 0;

            if (count > 0)
            {
                bpeFile.Entries = new List <BPE_Entry>();

                for (int i = 0; i < count; i++)
                {
                    int entryOffset = BitConverter.ToInt32(rawBytes, offset);

                    if (entryOffset != 0)
                    {
                        bpeFile.Entries.Add(new BPE_Entry()
                        {
                            Index = i.ToString(),
                            I_00  = BitConverter.ToInt32(rawBytes, entryOffset + 0),
                            I_04  = BitConverter.ToUInt16(rawBytes, entryOffset + 4),
                            I_06  = BitConverter.ToUInt16(rawBytes, entryOffset + 6),
                            I_08  = BitConverter.ToUInt16(rawBytes, entryOffset + 8),
                        });

                        //SubEntries
                        int subEntryCount  = BitConverter.ToInt16(rawBytes, entryOffset + 10);
                        int subEntryOffset = BitConverter.ToInt32(rawBytes, entryOffset + 12) + entryOffset;

                        if (subEntryCount > 0)
                        {
                            bpeFile.Entries[actualIndex].SubEntries = new List <BPE_SubEntry>();

                            for (int a = 0; a < subEntryCount; a++)
                            {
                                bpeFile.Entries[actualIndex].SubEntries.Add(new BPE_SubEntry()
                                {
                                    I_00 = BPE_SubEntry.GetBpeType(BitConverter.ToInt32(rawBytes, subEntryOffset + 0)),
                                    I_04 = BitConverter.ToUInt16(rawBytes, subEntryOffset + 4),
                                    I_06 = BitConverter.ToUInt16(rawBytes, subEntryOffset + 6),
                                    I_08 = BitConverter.ToUInt16(rawBytes, subEntryOffset + 8),
                                    I_10 = BitConverter.ToUInt16(rawBytes, subEntryOffset + 10),
                                    F_12 = BitConverter.ToSingle(rawBytes, subEntryOffset + 12),
                                    F_16 = BitConverter.ToSingle(rawBytes, subEntryOffset + 16),
                                    F_20 = BitConverter.ToSingle(rawBytes, subEntryOffset + 20),
                                    F_24 = BitConverter.ToSingle(rawBytes, subEntryOffset + 24),
                                    F_28 = BitConverter.ToSingle(rawBytes, subEntryOffset + 28),
                                    F_32 = BitConverter.ToSingle(rawBytes, subEntryOffset + 32),
                                    I_36 = BitConverter.ToInt32(rawBytes, subEntryOffset + 36),
                                    I_40 = BitConverter.ToUInt16(rawBytes, subEntryOffset + 40),
                                });

                                //Types
                                int type       = BitConverter.ToInt32(rawBytes, subEntryOffset + 0);
                                int typeCount  = BitConverter.ToInt16(rawBytes, subEntryOffset + 42);
                                int typeOffset = BitConverter.ToInt32(rawBytes, subEntryOffset + 44) + subEntryOffset;

                                switch (type)
                                {
                                case 0:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type0 = ParseType0(typeOffset, typeCount);
                                    break;

                                case 1:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type1 = ParseType1(typeOffset, typeCount);
                                    break;

                                case 2:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type2 = ParseType2(typeOffset, typeCount);
                                    break;

                                case 3:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type3 = ParseType3(typeOffset, typeCount);
                                    break;

                                case 4:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type4 = ParseType4(typeOffset, typeCount);
                                    break;

                                case 5:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type5 = ParseType5(typeOffset, typeCount);
                                    break;

                                case 6:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type6 = ParseType6(typeOffset, typeCount);
                                    break;

                                case 7:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type7 = ParseType7(typeOffset, typeCount);
                                    break;

                                case 8:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type8 = ParseType8(typeOffset, typeCount);
                                    break;

                                case 9:
                                    bpeFile.Entries[actualIndex].SubEntries[a].Type9 = ParseType9(typeOffset, typeCount);
                                    break;
                                }

                                subEntryOffset += 48;
                            }
                        }

                        actualIndex++;
                    }

                    offset += 4;
                }
            }
        }
Example #3
0
        private void TypeValidation(BPE_SubEntry subEntry, BPE_Entry entry)
        {
            switch (subEntry.GetBpeType())
            {
            case 0:
                if (subEntry.Type0 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 1:
                if (subEntry.Type1 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 2:
                if (subEntry.Type2 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 3:
                if (subEntry.Type3 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 4:
                if (subEntry.Type4 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 5:
                if (subEntry.Type5 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 6:
                if (subEntry.Type6 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 7:
                if (subEntry.Type7 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 8:
                if (subEntry.Type8 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            case 9:
                if (subEntry.Type9 == null)
                {
                    TypeDoesntExist(entry, subEntry.I_00);
                }
                break;

            default:
                Console.WriteLine(String.Format("{0} is not a valid BPE_Type (BPE_Entry: Index = {1})", subEntry.I_00, entry.Index));
                Utils.WaitForInputThenQuit();
                break;
            }
        }