Skip to content

Instantly share code, notes, and snippets.

@SharpMan
Created December 28, 2015 17:27
Show Gist options
  • Save SharpMan/134e3114c4d5274c7eed to your computer and use it in GitHub Desktop.
Save SharpMan/134e3114c4d5274c7eed to your computer and use it in GitHub Desktop.
public function writeVarShort(param1:int) : void
{
var _loc5_:* = 0;
if(param1 > SHORT_MAX_VALUE || param1 < SHORT_MIN_VALUE)
{
throw new Error("Forbidden value");
}
var _loc2_:ByteArray = new ByteArray();
if(param1 >= 0 && param1 <= MASK_01111111)
{
_loc2_.writeByte(param1);
this._data.writeBytes(_loc2_);
return;
}
var _loc3_:* = param1 & 65535;
var _loc4_:ByteArray = new ByteArray();
while(_loc3_ != 0)
{
_loc4_.writeByte(_loc3_ & MASK_01111111);
_loc4_.position = _loc4_.length - 1;
_loc5_ = _loc4_.readByte();
_loc3_ = _loc3_ >>> CHUNCK_BIT_SIZE;
if(_loc3_ > 0)
{
_loc5_ = _loc5_ | MASK_10000000;
}
_loc2_.writeByte(_loc5_);
}
this._data.writeBytes(_loc2_);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment