Esempio n. 1
0
        public int ReadS16()
        {
            int offset = this.offset;

            this.offset += 0x02;
            return(JHI.SwapBytes(BitConverter.ToInt16(this.data, offset)));
        }
Esempio n. 2
0
File: HIO2.cs Progetto: magcius/mchi
        private void ProcessTags(ByteBuffer tagBuffer)
        {
            while (true)
            {
                if (tagBuffer.Data.Length < 0x08)
                {
                    // Not enough data...
                    return;
                }

                string           tagMagic  = Encoding.ASCII.GetString(tagBuffer.Data, 0x00, 0x04);
                IJHITagProcessor processor = tagDispatch[tagMagic];

                int tagSize = JHI.SwapBytes(BitConverter.ToInt32(tagBuffer.Data, 0x04));
                if (tagBuffer.Data.Length < 0x08 + tagSize)
                {
                    // Not enough data...
                    return;
                }

                // Tag is done!
                JHITag tag = new JHITag();
                tag.Magic = tagMagic;
                tag.Data  = tagBuffer.Data.AsSpan(0x08, tagSize).ToArray();
                tagBuffer.DoneReading(0x08 + tagSize);

                processor.ProcessTag(tag);
            }
        }
Esempio n. 3
0
        public uint ReadU32()
        {
            int offset = this.offset;

            this.offset += 0x04;
            return(JHI.SwapBytes(BitConverter.ToUInt32(this.data, offset)));
        }
Esempio n. 4
0
        public float ReadF32()
        {
            int offset = this.offset;

            this.offset += 0x04;
            return(BitConverter.ToSingle(JHI.SwapBytes(this.data.AsSpan(offset, 4).ToArray()), 0));
        }
Esempio n. 5
0
File: HIO2.cs Progetto: magcius/mchi
 public void WriteToDolphin(JHITag tag)
 {
     byte[] data       = new byte[0x08 + tag.Data.Length];
     byte[] magicBytes = Encoding.ASCII.GetBytes(tag.Magic);
     Array.Copy(magicBytes, 0x00, data, 0x00, 0x04);
     byte[] lengthBytes = BitConverter.GetBytes(JHI.SwapBytes(tag.Data.Length));
     Array.Copy(lengthBytes, 0x00, data, 0x04, 0x04);
     Array.Copy(tag.Data, 0x00, data, 0x08, tag.Data.Length);
     WriteToDolphin(data);
 }
Esempio n. 6
0
File: HIO2.cs Progetto: magcius/mchi
        private int WriteMessage(int dstOffs, byte[] src, int srcOffs, int size)
        {
            hio2.WriteBytes(dstOffs + 0x00, Encoding.ASCII.GetBytes(MAGIC_CODE));
            hio2.WriteBytes(dstOffs + 0x04, BitConverter.GetBytes(JHI.SwapBytes((ushort)size)));
            hio2.WriteBytes(dstOffs + 0x06, src, srcOffs, size);
            int fullSize         = GetFullMessageSize(size);
            int numZeroesToWrite = fullSize - (0x06 + size);

            byte[] zeroes = new byte[numZeroesToWrite];
            hio2.WriteBytes(dstOffs + 0x06 + size, zeroes);
            return(fullSize);
        }
Esempio n. 7
0
File: HIO2.cs Progetto: magcius/mchi
        private void ProcessChunks(ByteBuffer outBuffer, byte[] data)
        {
            int offs = 0;

            while (offs < data.Length)
            {
                Debug.Assert(JHI.StrEq(data, offs + 0x00, JHIMccBuf.MAGIC_CODE));

                int chunkSize = JHI.SwapBytes(BitConverter.ToInt16(data, offs + 0x04));
                offs += 0x06;

                outBuffer.Write(data, offs, chunkSize);
                offs += chunkSize;

                // Align to 0x20.
                offs = (offs + 0x1F) & ~0x1F;
            }
        }
Esempio n. 8
0
File: HIO2.cs Progetto: magcius/mchi
 public int ReadU32(int buf_idx)
 {
     return(JHI.SwapBytes(this.accessor.ReadInt32(buf_idx)));
 }
Esempio n. 9
0
File: HIO2.cs Progetto: magcius/mchi
 public void WriteU32(int buf_idx, int v)
 {
     WriteBytes(buf_idx, BitConverter.GetBytes(JHI.SwapBytes(v)));
 }
Esempio n. 10
0
 public void Write(ushort x)
 {
     Write(BitConverter.GetBytes(JHI.SwapBytes(x)));
 }
Esempio n. 11
0
 public void Write(float x)
 {
     Write(JHI.SwapBytes(BitConverter.GetBytes(x)));
 }