示例#1
0
        protected override void loadBlo1(aBinaryReader reader)
        {
            base.loadBlo1(reader);

            var finder = bloResourceFinder.getFinder();

            int numparams = reader.Read8();

            mFont = finder.find <bloResFont>(reader, "font");

            mTopColor    = new bloColor(reader.Read32());
            mBottomColor = new bloColor(reader.Read32());

            int binding = reader.Read8();

            mHBinding = (bloTextboxHBinding)((binding >> 2) & 3);
            mVBinding = (bloTextboxVBinding)((binding >> 0) & 3);

            mFontSpacing = reader.ReadS16();
            mFontLeading = reader.ReadS16();
            mFontWidth   = reader.Read16();
            mFontHeight  = reader.Read16();

            int strlen = reader.Read16();

            setString(reader.Read8s(strlen));

            numparams -= 10;

            if (numparams > 0)
            {
                if (reader.Read8() != 0)
                {
                    setConnectParent(true);
                }
                --numparams;
            }

            if (numparams > 0)
            {
                mFromColor = new bloColor(reader.Read32());
                --numparams;
            }
            else
            {
                mFromColor = new bloColor(bloColor.cZero);
            }

            if (numparams > 0)
            {
                mToColor = new bloColor(reader.Read32());
                --numparams;
            }
            else
            {
                mToColor = new bloColor(bloColor.cOne);
            }

            reader.Skip(4);
        }
示例#2
0
        void LoadFmtBlock(int size)
        {
            var format = mReader.ReadS16();

            if (format != 1)
            {
                mareep.WriteError("WAV: only LPCM is supported.");
            }

            mChannelCount = mReader.Read16();

            if (mChannelCount < 1 || mChannelCount > 2)
            {
                mareep.WriteError("WAV: only mono or stereo is supported.");
            }

            mSampleRate = mReader.ReadS32();
            mByteRate   = mReader.ReadS32();
            mBlockAlign = mReader.Read16();
            mBitDepth   = mReader.Read16();

            if (mBitDepth != 8 && mBitDepth != 16)
            {
                mareep.WriteError("WAV: only bit-depths of 8 and 16 are supported.");
            }
        }
示例#3
0
        public override void load(Stream stream)
        {
            aBinaryReader reader = new aBinaryReader(stream, Endianness.Big);

            mFormat       = (gxTextureFormat)reader.Read8(); // 0000
            mTransparency = reader.Read8();                  // 0001
            mWidth        = reader.Read16();                 // 0002
            mHeight       = reader.Read16();                 // 0004
            mWrapS        = (gxWrapMode)reader.Read8();      // 0006
            mWrapT        = (gxWrapMode)reader.Read8();      // 0007
            reader.Step(1);                                  // 0008 (0001)
            mTlutFormat = (gxTlutFormat)reader.Read8();      // 0009
            int  tlutentrycount = reader.Read16();           // 000A
            long tlutoffset     = reader.Read32();           // 000C

            mMipMap     = (reader.Read8() != 0);             // 0010
            mEdgeLOD    = (reader.Read8() != 0);             // 0011
            mBiasClamp  = (reader.Read8() != 0);             // 0012
            mMaxAniso   = (gxAnisotropy)reader.Read8();      // 0013
            mMinFilter  = (gxTextureFilter)reader.Read8();   // 0014
            mMagFilter  = (gxTextureFilter)reader.Read8();   // 0015
            mMinLod     = reader.ReadS8();                   // 0016
            mMaxLod     = reader.ReadS8();                   // 0017
            mImageCount = reader.Read8();                    // 0018 (0001)
            mLodBias    = reader.ReadS16();                  // 001A
            long texoffset = reader.Read32();                // 001C

            loadImageData(reader, texoffset);
            if (tlutentrycount > 0)
            {
                loadPaletteData(reader, tlutentrycount, tlutoffset);
            }
        }
示例#4
0
        static aRGBA[] loadRGB5A3(aBinaryReader reader, int width, int height)
        {
            var       data = new aRGBA[width * height];
            const int cBlockWidth = 4, cBlockHeight = 4;

            for (var y = 0; y < height; y += cBlockHeight)
            {
                for (var x = 0; x < width; x += cBlockWidth)
                {
                    for (var by = 0; by < cBlockHeight; ++by)
                    {
                        for (var bx = 0; bx < cBlockWidth; ++bx)
                        {
                            var color = reader.Read16();
                            if ((bx + x) >= width || (by + y) >= height)
                            {
                                continue;
                            }
                            data[(width * (y + by)) + (x + bx)] = (
                                (color & 0x8000) != 0 ?
                                aRGBA.FromRGB5(color) :
                                aRGBA.FromRGB4A3(color)
                                );
                        }
                    }
                }
            }
            return(data);
        }
示例#5
0
        static short[] loadCI14X2(aBinaryReader reader, int width, int height)
        {
            var       data = new short[width * height];
            const int cBlockWidth = 4, cBlockHeight = 4;

            for (var y = 0; y < height; y += cBlockHeight)
            {
                for (var x = 0; x < width; x += cBlockWidth)
                {
                    for (var by = 0; by < cBlockHeight; ++by)
                    {
                        for (var bx = 0; bx < cBlockWidth; ++bx)
                        {
                            var ci14x2 = reader.Read16();
                            if ((bx + x) >= width || (by + y) >= height)
                            {
                                continue;
                            }
                            data[width * (y + by) + (x + bx)] = (short)(ci14x2 & 0x3FFF);
                        }
                    }
                }
            }
            return(data);
        }
示例#6
0
        protected override void loadCompact(aBinaryReader reader)
        {
            base.loadCompact(reader);

            var finder = bloResourceFinder.getFinder();

            mFont = finder.find <bloResFont>(reader, "font");

            mTopColor    = new bloColor(reader.Read32());
            mBottomColor = new bloColor(reader.Read32());

            int hbinding = reader.Read8();

            mHBinding = (bloTextboxHBinding)(hbinding & 127);
            mVBinding = (bloTextboxVBinding)reader.Read8();

            if ((hbinding & 0x80) != 0)
            {
                mFontSpacing = reader.ReadS16();
                mFontLeading = reader.ReadS16();
                mFontWidth   = reader.Read16();
                mFontHeight  = reader.Read16();
            }
            else if (mFont != null)
            {
                mFontSpacing = 0;
                mFontLeading = mFont.getLeading();
                mFontWidth   = mFont.getWidth();
                mFontHeight  = mFont.getHeight();
            }
            else
            {
                mFontSpacing = 0;
                mFontLeading = 0;
                mFontWidth   = 0;
                mFontHeight  = 0;
            }

            int strlen = reader.Read16();

            setString(reader.Read8s(strlen));

            mFromColor = new bloColor(bloColor.cZero);
            mToColor   = new bloColor(bloColor.cOne);

            reader.Skip(4);
        }
示例#7
0
 void loadPaletteDataRGB565(aBinaryReader reader)
 {
     for (int i = 0; i < mEntryCount; ++i)
     {
         var rgb565 = reader.Read16();
         mData[i] = aRGBA.FromRGB565(rgb565);
     }
 }
示例#8
0
        public override void load(Stream stream)
        {
            var reader = new aBinaryReader(stream, Endianness.Big);

            reader.PushAnchor();
            mFormat       = (gxTlutFormat)reader.Read8();
            mTransparency = reader.Read8();
            mEntryCount   = reader.Read16();
            reader.Goto(0x20);
            loadPaletteData(reader);
        }
示例#9
0
 void loadPaletteDataRGB5A3(aBinaryReader reader)
 {
     for (int i = 0; i < mEntryCount; ++i)
     {
         var rgb5a3 = reader.Read16();
         mData[i] = (
             (rgb5a3 & 0x8000) != 0 ?
             aRGBA.FromRGB5(rgb5a3) :
             aRGBA.FromRGB4A3(rgb5a3)
             );
     }
 }
示例#10
0
        static aRGBA[] loadRGBA8(aBinaryReader reader, int width, int height)
        {
            var       data = new aRGBA[width * height];
            const int cBlockWidth = 4, cBlockHeight = 4;
            var       colors = new uint[16];

            for (var y = 0; y < height; y += cBlockHeight)
            {
                for (var x = 0; x < width; x += cBlockWidth)
                {
                    for (var by = 0; by < cBlockHeight && (y + by) < height; ++by)                       // AR
                    {
                        for (var bx = 0; bx < cBlockWidth && (x + bx) < width; ++bx)
                        {
                            colors[(cBlockWidth * by) + bx] = (uint)(reader.Read16() << 16);
                        }
                    }
                    for (var by = 0; by < cBlockHeight && (y + by) < height; ++by)                       // GB
                    {
                        for (var bx = 0; bx < cBlockWidth && (x + bx) < width; ++bx)
                        {
                            colors[(cBlockWidth * by) + bx] |= reader.Read16();
                        }
                    }
                    for (var by = 0; by < cBlockHeight; ++by)
                    {
                        for (var bx = 0; bx < cBlockWidth; ++bx)
                        {
                            if ((x + bx) >= width || (y + by) >= height)
                            {
                                continue;
                            }
                            data[width * (y + by) + (x + bx)] = aRGBA.FromARGB8(colors[(cBlockWidth * by) + bx]);
                        }
                    }
                }
            }
            return(data);
        }
示例#11
0
            public GlyphBlock(aBinaryReader reader)
            {
                firstCode   = reader.Read16();                  // 0008
                lastCode    = reader.Read16();                  // 000A
                cellWidth   = reader.Read16();                  // 000C
                cellHeight  = reader.Read16();                  // 000E
                sheetSize   = reader.ReadS32();                 // 0010
                sheetFormat = (gxTextureFormat)reader.Read16(); // 0014
                sheetRow    = reader.Read16();                  // 0016
                sheetColumn = reader.Read16();                  // 0018
                sheetWidth  = reader.Read16();                  // 001A
                sheetHeight = reader.Read16();                  // 001C
                reader.Step(2);                                 // 001E

                // we have to manually calculate how many sheets there are
                int sheetCount = (((lastCode - firstCode) / (sheetRow * sheetColumn)) + 1);

                sheets = aCollection.Initialize(sheetCount, () => reader.Read8s(sheetSize));
            }
示例#12
0
        protected override void loadCompact(aBinaryReader reader)
        {
            base.loadCompact(reader);

            var finder = bloResourceFinder.getFinder();

            int x      = reader.Read16();
            int y      = reader.Read16();
            int width  = reader.Read16();
            int height = reader.Read16();

            mContentRect.set(x, y, (x + width), (y + height));

            for (int i = 0; i < 4; ++i)
            {
                mTextures[i].texture = finder.find <bloTexture>(reader, "timg");
            }
            mPalette = finder.find <bloPalette>(reader, "tlut");

            int bits = reader.Read8();

            for (int i = 0; i < 4; ++i)
            {
                mTextures[i].mirror = (bloMirror)((bits >> (6 - (i * 2))) & 3);
            }

            for (int i = 0; i < 4; ++i)
            {
                mTextures[i].color = new bloColor(reader.Read32());
            }

            mContentTexture = null;
            mFromColor.rgba = bloColor.cZero;
            mToColor.rgba   = bloColor.cOne;

            reader.Skip(4);
            initializeMinSize();
        }
示例#13
0
 public InfoBlock(aBinaryReader reader)
 {
     fontType  = (bloFontType)reader.Read16();
     ascent    = reader.Read16();
     descent   = reader.Read16();
     width     = reader.Read16();
     leading   = reader.Read16();
     invalChar = reader.Read16();
 }
示例#14
0
        void PerformStreamToWav(Stream instream, Stream outstream)
        {
            var reader = new aBinaryReader(instream, Endianness.Big);
            var writer = new aBinaryWriter(outstream, Endianness.Little);

            var streamDataSize = reader.ReadS32();
            var sampleCount    = reader.ReadS32();
            var sampleRate     = reader.Read16();
            var dataSize       = (sampleCount * 4);
            var format         = (StreamFormat)reader.Read16();

            writer.WriteString("RIFF");
            writer.WriteS32(36 + dataSize);
            writer.WriteString("WAVE");
            writer.WriteString("fmt ");
            writer.WriteS32(16);
            writer.WriteS16(1);              // format
            writer.Write16(2);               // channel count
            writer.WriteS32(sampleRate);
            writer.WriteS32(sampleRate * 4); // byte rate
            writer.Write16(4);               // block align
            writer.Write16(16);              // bit depth
            writer.WriteString("data");
            writer.WriteS32(dataSize);

            reader.Goto(32);

            switch (format)
            {
            case StreamFormat.Pcm: DecodeStreamPcm(reader, writer, sampleCount); break;

            case StreamFormat.Adpcm: DecodeStreamAdpcm(reader, writer, sampleCount); break;

            default: mareep.WriteError("AFC: Unknown format '{0}' in header.", (int)format); break;
            }
        }
示例#15
0
        public void load(aBinaryReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            reader.PushAnchor();
            var entryCount  = reader.ReadS32();
            var fieldCount  = reader.ReadS32();
            var entryOffset = reader.Read32();
            var entrySize   = reader.ReadS32();

            mFields = new jmpField[fieldCount];
            for (var i = 0; i < fieldCount; ++i)
            {
                mFields[i].hash    = reader.Read32();
                mFields[i].bitmask = reader.Read32();
                mFields[i].start   = reader.Read16();
                mFields[i].shift   = reader.Read8();
                mFields[i].type    = (jmpValueType)reader.Read8();
            }
            mEntries = new jmpValue[entryCount, fieldCount];
            for (var entry = 0; entry < entryCount; ++entry)
            {
                for (var field = 0; field < fieldCount; ++field)
                {
                    reader.Goto(entryOffset + (entrySize * entry) + mFields[field].start);
                    switch (mFields[field].type)
                    {
                    case jmpValueType.INTEGER: mEntries[entry, field] = (int)((reader.ReadS32() & mFields[field].bitmask) >> mFields[field].shift); break;

                    case jmpValueType.FLOAT: mEntries[entry, field] = reader.ReadF32(); break;

                    case jmpValueType.STRING: mEntries[entry, field] = reader.ReadString <aCSTR>(0x20); break;
                    }
                }
            }
            reader.PopAnchor();
        }
示例#16
0
 public MapBlock(aBinaryReader reader)
 {
     mapType   = (MapType)reader.Read16();
     firstChar = reader.Read16();
     lastChar  = reader.Read16();
     dataCount = reader.Read16();
     if (mapType == MapType.MapMap)
     {
         data = new ushort[dataCount];
         code = new ushort[dataCount];
         for (int i = 0; i < dataCount; ++i)
         {
             data[i] = reader.Read16();
             code[i] = reader.Read16();
         }
     }
     else
     {
         data = reader.Read16s(dataCount);
     }
 }
示例#17
0
        protected virtual void loadBlo1(aBinaryReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            int numparams = reader.Read8();

            mVisible = (reader.Read8() != 0);
            reader.Step(2);

            mName = reader.Read32();

            int left   = reader.ReadS16();
            int top    = reader.ReadS16();
            int width  = reader.ReadS16();
            int height = reader.ReadS16();

            mRect.set(left, top, (left + width), (top + height));

            numparams -= 6;

            if (numparams > 0)
            {
                mAngle = reader.Read16();
                --numparams;
            }
            else
            {
                mAngle = 0.0d;
            }

            if (numparams > 0)
            {
                mAnchor = (bloAnchor)reader.Read8();
                --numparams;
            }
            else
            {
                mAnchor = bloAnchor.TopLeft;
            }

            if (numparams > 0)
            {
                mAlpha = reader.Read8();
                --numparams;
            }
            else
            {
                mAlpha = 255;
            }

            if (numparams > 0)
            {
                mInheritAlpha = (reader.Read8() != 0);
                --numparams;
            }
            else
            {
                mInheritAlpha = true;
            }

            reader.Skip(4);
        }
示例#18
0
        static bool loadCompact(bloPane parent, aBinaryReader reader)
        {
            bloPane lastPane = parent;

            for (;;)
            {
                long   start  = reader.Position;
                ushort typeID = reader.Read16();                 // this is actually a peek in SMS, but f**k that

                switch (typeID)
                {
                default: {
                    Console.WriteLine(">>> Unknown '{0:X4}' section at 0x{1:X6}", typeID, start);
                    return(false);
                }

                case cExitID: {
                    return(true);
                }

                case cEndID: {
                    reader.Step(2);
                    return(true);
                }

                case cBeginID: {
                    reader.Step(2);
                    if (!loadCompact(lastPane, reader))
                    {
                        return(false);
                    }
                    break;
                }

                case cPaneID: {
                    lastPane = new bloPane();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    if (parent is bloScreen)
                    {
                        var oldrect = lastPane.getRectangle();
                        var newrect = new bloRectangle(0, 0, oldrect.width, oldrect.height);
                        parent.setRectangle(newrect);
                    }
                    break;
                }

                case cWindowID: {
                    lastPane = new bloWindow();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }

                case cPictureID: {
                    lastPane = new bloPicture();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }

                case cTextboxID: {
                    lastPane = new bloTextbox();
                    lastPane.load(parent, reader, bloFormat.Compact);
                    break;
                }
                }
            }
        }
示例#19
0
 public WidthBlock(aBinaryReader reader)
 {
     firstCode = reader.Read16();
     lastCode  = reader.Read16();
     entries   = aCollection.Initialize((lastCode - firstCode), () => new WidthEntry(reader));
 }
示例#20
0
文件: string.cs 项目: arookas/arookas
 public override string Read(aBinaryReader reader)
 {
     var length = reader.Read16();
     var value = reader.ReadString(length);
     return value;
 }