private void decode(Default317Buffer stream) { for (int instrument = 0; instrument < 10; instrument++) { int active = stream.getUnsignedByte(); if (active != 0) { stream.position--; instruments[instrument] = new Instrument(); instruments[instrument].decode(stream); } } loopStart = stream.getUnsignedLEShort(); loopEnd = stream.getUnsignedLEShort(); }
public static void load(Default317Buffer stream) { _output = new byte[0x6baa8]; output = new Default317Buffer(_output); Instrument.initialise(); do { int effect = stream.getUnsignedLEShort(); if (effect == 65535) { return; } effects[effect] = new Effect(); effects[effect].decode(stream); effectDelays[effect] = effects[effect].getDelay(); } while (true); }
public Skins(Default317Buffer buffer) { int count = buffer.getUnsignedByte(); opcodes = new int[count]; skinList = new int[count][]; for (int opcode = 0; opcode < count; opcode++) { opcodes[opcode] = buffer.getUnsignedByte(); } for (int skin = 0; skin < count; skin++) { int subSkinAmount = buffer.getUnsignedByte(); skinList[skin] = new int[subSkinAmount]; for (int subSkin = 0; subSkin < subSkinAmount; subSkin++) { skinList[skin][subSkin] = buffer.getUnsignedByte(); } } }
public static void method529(byte[] data) { Default317Buffer buffer = new Default317Buffer(data); buffer.position = data.Length - 8; int attributesOffset = buffer.getUnsignedLEShort(); int transformationOffset = buffer.getUnsignedLEShort(); int durationOffset = buffer.getUnsignedLEShort(); int baseOffset = buffer.getUnsignedLEShort(); int offset = 0; Default317Buffer headerBuffer = new Default317Buffer(data); headerBuffer.position = offset; offset += attributesOffset + 2; Default317Buffer attributeBuffer = new Default317Buffer(data); attributeBuffer.position = offset; offset += transformationOffset; Default317Buffer transformationBuffer = new Default317Buffer(data); transformationBuffer.position = offset; offset += durationOffset; Default317Buffer durationBuffer = new Default317Buffer(data); durationBuffer.position = offset; offset += baseOffset; Default317Buffer baseBuffer = new Default317Buffer(data); baseBuffer.position = offset; Skins @base = new Skins(baseBuffer); int count = headerBuffer.getUnsignedLEShort(); int[] transformationIndices = new int[500]; int[] transformX = new int[500]; int[] transformY = new int[500]; int[] transformZ = new int[500]; for (int i = 0; i < count; i++) { int id = headerBuffer.getUnsignedLEShort(); Animation anim = animations[id] = new Animation(); anim.displayLength = durationBuffer.getUnsignedByte(); anim.animationSkins = @base; int transformationCount = headerBuffer.getUnsignedByte(); int highestIndex = -1; int transformation = 0; for (int index = 0; index < transformationCount; index++) { int attribute = attributeBuffer.getUnsignedByte(); if (attribute > 0) { if (@base.opcodes[index] != 0) { for (int next = index - 1; next > highestIndex; next--) { if (@base.opcodes[next] != 0) { continue; } transformationIndices[transformation] = next; transformX[transformation] = 0; transformY[transformation] = 0; transformZ[transformation] = 0; transformation++; break; } } transformationIndices[transformation] = index; int standard = @base.opcodes[index] == 3 ? 128 : 0; if ((attribute & 1) != 0) { transformX[transformation] = transformationBuffer.getSmartA(); } else { transformX[transformation] = standard; } if ((attribute & 2) != 0) { transformY[transformation] = transformationBuffer.getSmartA(); } else { transformY[transformation] = standard; } if ((attribute & 4) != 0) { transformZ[transformation] = transformationBuffer.getSmartA(); } else { transformZ[transformation] = standard; } highestIndex = index; transformation++; if (@base.opcodes[index] == 5) { opaque[id] = false; } } } anim.frameCount = transformation; anim.opcodeTable = new int[transformation]; anim.transformationX = new int[transformation]; anim.transformationY = new int[transformation]; anim.transformationZ = new int[transformation]; for (int t = 0; t < transformation; t++) { anim.opcodeTable[t] = transformationIndices[t]; anim.transformationX[t] = transformX[t]; anim.transformationY[t] = transformY[t]; anim.transformationZ[t] = transformZ[t]; } } }