public int ReadS16() { int offset = this.offset; this.offset += 0x02; return(JHI.SwapBytes(BitConverter.ToInt16(this.data, offset))); }
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); } }
public uint ReadU32() { int offset = this.offset; this.offset += 0x04; return(JHI.SwapBytes(BitConverter.ToUInt32(this.data, offset))); }
public float ReadF32() { int offset = this.offset; this.offset += 0x04; return(BitConverter.ToSingle(JHI.SwapBytes(this.data.AsSpan(offset, 4).ToArray()), 0)); }
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); }
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); }
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; } }
public int ReadU32(int buf_idx) { return(JHI.SwapBytes(this.accessor.ReadInt32(buf_idx))); }
public void WriteU32(int buf_idx, int v) { WriteBytes(buf_idx, BitConverter.GetBytes(JHI.SwapBytes(v))); }
public void Write(ushort x) { Write(BitConverter.GetBytes(JHI.SwapBytes(x))); }
public void Write(float x) { Write(JHI.SwapBytes(BitConverter.GetBytes(x))); }