public void WriteJump(byte style) { ulong source = (ulong)(Binary.Position + 2); Binary.WriteUInt8(style); Binary.WriteInt8(-2); // self-jump until set AddSource(Mapper.MapRomToRam(source - 1)); Binary.Position = (long)source; }
public static void WriteEncodedInt(this Stream s, int value) { uint num; for (num = (uint)value; num >= 128u; num >>= 7) { s.WriteInt8((byte)(num | 128u)); } s.WriteInt8((byte)num); }
public static void WriteEncodedInt(this Stream s, int value) { uint num = (uint)value; while (num >= 0x80) { s.WriteInt8((byte)(num | 0x80)); num = num >> 0x7; } s.WriteInt8((byte)num); }
protected virtual void Pack(Stream stream, CachedType ct, object obj) { if (obj == null) { stream.WriteInt8(0); return; } if (!ct.IsValueType) { stream.WriteInt8(1); } ct.WriteFunc(this, ct.Type, stream, obj); }
public override void Pack(Stream stream) { stream.WriteInt32(Time); stream.WriteBoolean(DayTime); stream.WriteInt8(MoonPhase); stream.WriteBoolean(BloodMoon); stream.WriteInt32(MaxTilesX); stream.WriteInt32(MaxTilesY); stream.WriteInt32(SpawnX); stream.WriteInt32(SpawnY); stream.WriteInt32(WorldSurface); stream.WriteInt32(RockLayer); stream.WriteInt32(WorldID); stream.WriteInt8((byte)WorldFlags); stream.WriteBytes(Encoding.ASCII.GetBytes(WorldName)); }
public byte OutputText(byte lastChar, int index, Stream s) { if (index == -1) { return(lastChar); } var bytes = new Stack <byte>(); while (index != -1) { var rec = Records[index]; bytes.Push(lastChar = rec.Character); index = rec.PreviousCharacter; if (bytes.Count > 0xFFF) { throw new OverflowException(); } } while (bytes.Count > 0) { s.WriteInt8(bytes.Pop()); } return(lastChar); }
public void Pack(Stream stream) { var flags = TileFlags.None; if (Active) { flags |= TileFlags.Active; } if (HasWall) { flags |= TileFlags.Wall; } if (HasLiquid) { flags |= TileFlags.Liquid; } if (Wire) { flags |= TileFlags.Wire; } stream.WriteInt8((byte)flags); if (Active) { stream.WriteInt8(Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) { stream.WriteInt8(Wall); } if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteBoolean(Lava); } }
public override void Pack(Stream stream) { stream.WriteInt32(Time); stream.WriteBoolean(DayTime); stream.WriteInt8(MoonPhase); stream.WriteBoolean(BloodMoon); stream.WriteBoolean(Eclipse); stream.WriteInt32(MaxTilesX); stream.WriteInt32(MaxTilesY); stream.WriteInt32(SpawnX); stream.WriteInt32(SpawnY); stream.WriteInt32(WorldSurface); stream.WriteInt32(RockLayer); stream.WriteInt32(WorldID); stream.WriteByte(MoonType); stream.WriteInt32(TreeX0); stream.WriteInt32(TreeX1); stream.WriteInt32(TreeX2); stream.WriteByte(TreeStyle0); stream.WriteByte(TreeStyle1); stream.WriteByte(TreeStyle2); stream.WriteByte(TreeStyle3); stream.WriteInt32(CaveBackX0); stream.WriteInt32(CaveBackX1); stream.WriteInt32(CaveBackX2); stream.WriteByte(CaveBackStyle0); stream.WriteByte(CaveBackStyle1); stream.WriteByte(CaveBackStyle2); stream.WriteByte(CaveBackStyle3); stream.WriteByte(SetBG0); stream.WriteByte(SetBG1); stream.WriteByte(SetBG2); stream.WriteByte(SetBG3); stream.WriteByte(SetBG4); stream.WriteByte(SetBG5); stream.WriteByte(SetBG6); stream.WriteByte(SetBG7); stream.WriteByte(IceBackStyle); stream.WriteByte(JungleBackStyle); stream.WriteByte(HellBackStyle); stream.WriteSingle(WindSpeed); stream.WriteByte(NumberOfClouds); stream.WriteInt8((byte)BossFlags); stream.WriteInt8((byte)BossFlags2); stream.WriteSingle(Rain); stream.WriteBytes(Encoding.UTF8.GetBytes(WorldName)); }
public void Pack(Stream stream) { stream.WriteInt8(Field6); stream.WriteInt16(Field7); stream.WriteInt32(Field8); stream.WriteBytes(Field9); stream.WriteString(Field10); }
public override void Pack(Stream stream) { stream.WriteInt8(PlayerIndex); stream.WriteInt16(TileX); stream.WriteInt16(TileY); stream.WriteInt32(RespawnTimer); stream.WriteByte((byte)PlayerSpawnContext); }
public void PackFull(Stream stream) { long start = stream.Position; stream.WriteInt16(0); stream.WriteInt8((byte) ID); Pack(stream); long end = stream.Position; stream.Position = start; stream.WriteInt16((short)end); stream.Position = end; }
public void PackFull(Stream stream) { long start = stream.Position; stream.WriteInt32(1); stream.WriteInt8((byte) ID); Pack(stream); long end = stream.Position; stream.Position = start; stream.WriteInt32((int) (end - start) - 4); stream.Position = end; }
public void PackFull(Stream stream) { long start = stream.Position; stream.WriteInt32(1); stream.WriteInt8((byte)ID); Pack(stream); long end = stream.Position; stream.Position = start; stream.WriteInt32((int)(end - start) - 4); stream.Position = end; }
public static void WriteInt(this Stream s, long num, BitUtils.Bitness bits, EndianUtils.Endianness endian) { switch (bits) { case BitUtils.Bitness.B8: s.WriteInt8((sbyte)num); return; case BitUtils.Bitness.B16: s.WriteInt16((short)num, endian); return; case BitUtils.Bitness.B32: s.WriteInt32((int)num, endian); return; case BitUtils.Bitness.B64: s.WriteInt64(num, endian); return; } throw new Exception("Writing int not implemented for bitness " + bits.ToString()); }
public static void WriteBoolean(this Stream s, bool value) { s.WriteInt8(value ? ((byte)0x1) : ((byte)0x0)); }
public static void Write(object obj, Stream stream) { stream.WriteInt8((byte)obj); }
public static void WriteBoolean(this Stream s, bool value) { s.WriteInt8((byte)(value ? 1 : 0)); }
public void Pack(Stream stream) { var bits = new BitsByte(); if ((Active) && (!Inactive)) bits[0] = true; if (HasWall) bits[2] = true; if (HasLiquid) bits[3] = true; if (Wire) bits[4] = true; if (IsHalf) bits[5] = true; if (IsActuator) bits[6] = true; if (Inactive) { bits[7] = true; } stream.WriteInt8((byte) bits); bits = new BitsByte(); if ((Wire2)) bits[0] = true; if (Wire3) bits[1] = true; if (HasColor) bits[2] = true; if (HasWallColor) bits[3] = true; if (Slope) bits[4] = true; if (Slope2) bits[5] = true; if (Slope3) bits[6] = true; stream.WriteInt8((byte)bits); if (HasColor) { stream.WriteByte(TileColor); } if (HasWallColor) { stream.WriteByte(WallColor); } if (Active) { stream.WriteInt16((short)Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) stream.WriteInt8(Wall); if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteInt8(LiquidType); } }
public static void WriteInt16(this Stream s, Int16 num) { s.WriteInt8((byte)(num & 0xff)); s.WriteInt8((byte)(num >> 8)); }
public override void Pack(Stream stream) { stream.WriteInt32(Time); stream.WriteBoolean(DayTime); stream.WriteInt8(MoonPhase); stream.WriteBoolean(BloodMoon); stream.WriteInt32(MaxTilesX); stream.WriteInt32(MaxTilesY); stream.WriteInt32(SpawnX); stream.WriteInt32(SpawnY); stream.WriteInt32(WorldSurface); stream.WriteInt32(RockLayer); stream.WriteInt32(WorldID); stream.WriteInt8((byte) WorldFlags); stream.WriteBytes(Encoding.UTF8.GetBytes(WorldName)); }
public void Pack(Stream stream) { var flags = TileFlags.None; if ((Active) && (!Inactive)) { flags |= TileFlags.Active; } if (Lighted) { flags |= TileFlags.Lighted; } if (HasWall) { flags |= TileFlags.Wall; } if (HasLiquid) { flags |= TileFlags.Liquid; } if (Wire) { flags |= TileFlags.Wire; } if (IsHalf) { flags |= TileFlags.HalfBrick; } if (IsActuator) { flags |= TileFlags.Actuator; } if (Inactive) { flags |= TileFlags.Inactive; } stream.WriteInt8((byte)flags); var flags2 = TileFlags2.None; if ((Wire2)) { flags2 |= TileFlags2.Wire2; } if (Wire3) { flags2 |= TileFlags2.Wire3; } if (HasColor) { flags2 |= TileFlags2.Color; } if (HasWallColor) { flags2 |= TileFlags2.WallColor; } if (Slope) { flags2 |= TileFlags2.Slope; } if (Slope2) { flags2 |= TileFlags2.Slope2; } stream.WriteInt8((byte)flags2); if (HasColor) { stream.WriteByte(TileColor); } if (HasWallColor) { stream.WriteByte(WallColor); } if (Active) { stream.WriteInt8(Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) { stream.WriteInt8(Wall); } if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteInt8(LiquidType); } }
public void Pack(Stream stream) { var flags = TileFlags.None; if ((Active) && (!Inactive)) flags |= TileFlags.Active; if (Lighted) flags |= TileFlags.Lighted; if (HasWall) flags |= TileFlags.Wall; if (HasLiquid) flags |= TileFlags.Liquid; if (Wire) flags |= TileFlags.Wire; if (IsHalf) flags |= TileFlags.HalfBrick; if (IsActuator) flags |= TileFlags.Actuator; if (Inactive) { flags |= TileFlags.Inactive; } stream.WriteInt8((byte) flags); var flags2 = TileFlags2.None; if ((Wire2)) flags2 |= TileFlags2.Wire2; if (Wire3) flags2 |= TileFlags2.Wire3; if (HasColor) flags2 |= TileFlags2.Color; if (HasWallColor) flags2 |= TileFlags2.WallColor; if (Slope) flags2 |= TileFlags2.Slope; if (Slope2) flags2 |= TileFlags2.Slope2; stream.WriteInt8((byte)flags2); if (HasColor) { stream.WriteByte(TileColor); } if (HasWallColor) { stream.WriteByte(WallColor); } if (Active) { stream.WriteInt8(Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) stream.WriteInt8(Wall); if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteInt8(LiquidType); } }
public byte OutputText(byte lastChar, int index, Stream s) { if (index == -1) return lastChar; var bytes = new Stack<byte>(); while (index != -1) { var rec = Records[index]; bytes.Push(lastChar = rec.Character); index = rec.PreviousCharacter; if (bytes.Count > 0xFFF) throw new OverflowException(); } while (bytes.Count > 0) s.WriteInt8(bytes.Pop()); return lastChar; }
public override void Pack(Stream stream) { stream.WriteInt8(PlayerIndex); stream.WriteInt32(TileX); stream.WriteInt32(TileY); }
public void Pack(Stream stream) { var flags = TileFlags.None; if (Active) flags |= TileFlags.Active; if (HasWall) flags |= TileFlags.Wall; if (HasLiquid) flags |= TileFlags.Liquid; if (Wire) flags |= TileFlags.Wire; stream.WriteInt8((byte) flags); if (Active) { stream.WriteInt8(Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) stream.WriteInt8(Wall); if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteBoolean(Lava); } }
public void Pack(Stream stream) { var bits = new BitsByte(); if ((Active) && (!Inactive)) { bits[0] = true; } if (HasWall) { bits[2] = true; } if (HasLiquid) { bits[3] = true; } if (Wire) { bits[4] = true; } if (IsHalf) { bits[5] = true; } if (IsActuator) { bits[6] = true; } if (Inactive) { bits[7] = true; } stream.WriteInt8((byte)bits); bits = new BitsByte(); if ((Wire2)) { bits[0] = true; } if (Wire3) { bits[1] = true; } if (HasColor) { bits[2] = true; } if (HasWallColor) { bits[3] = true; } if (Slope) { bits[4] = true; } if (Slope2) { bits[5] = true; } if (Slope3) { bits[6] = true; } stream.WriteInt8((byte)bits); if (HasColor) { stream.WriteByte(TileColor); } if (HasWallColor) { stream.WriteByte(WallColor); } if (Active) { stream.WriteInt16((short)Type); if (FrameImportant) { stream.WriteInt16(FrameX); stream.WriteInt16(FrameY); } } if (HasWall) { stream.WriteInt8(Wall); } if (HasLiquid) { stream.WriteInt8(Liquid); stream.WriteInt8(LiquidType); } }