// universal functions public void Assemble() { int offset = ((index - 2) * 2) + 0x3A1AFF; if (owner == 0) { Bits.SetShort(rom, offset, expNeeded); } // offset = (owner * 3) + ((index - 2) * 15) + 0x3A1B39; Bits.SetByte(rom, offset, hpPlus); offset++; Bits.SetByte(rom, offset, (byte)((attackPlus << 4) + defensePlus)); offset++; Bits.SetByte(rom, offset, (byte)((mgAttackPlus << 4) + mgDefensePlus)); offset++; // offset = (owner * 3) + ((index - 2) * 15) + 0x3A1CEC; Bits.SetByte(rom, offset, hpPlusBonus); offset++; Bits.SetByte(rom, offset, (byte)((attackPlusBonus << 4) + defensePlusBonus)); offset++; Bits.SetByte(rom, offset, (byte)((mgAttackPlusBonus << 4) + mgDefensePlusBonus)); offset++; // if (spellLearned == 0x20) { rom[owner + ((index - 2) * 5) + 0x3A42F5] = 0xFF; } else { rom[owner + ((index - 2) * 5) + 0x3A42F5] = spellLearned; } }
public void Assemble() { int offset = (index * 20) + 0x3A002C; // rom[offset++] = startingLevel; Bits.SetShort(rom, offset, startingCurrentHP); offset += 2; Bits.SetShort(rom, offset, startingMaxHP); offset += 2; rom[offset++] = startingSpeed; rom[offset++] = startingAttack; rom[offset++] = startingDefense; rom[offset++] = startingMgAttack; rom[offset++] = startingMgDefense; Bits.SetShort(rom, offset, startingExperience); offset += 2; rom[offset++] = startingWeapon; rom[offset++] = startingArmor; Bits.SetByte(rom, offset, startingAccessory); offset += 2; // int a = 0; for (int o = 0; o < 4; o++, offset++) { for (int i = 0; i < 8; i++) { Bits.SetBit(rom, offset, i, startingMagic[a++]); } } // foreach (LevelUp l in levels) { if (l != null) { l.Assemble(); } } if (index == 0) { Bits.SetShort(rom, 0x3A00DB, startingCoins); rom[0x3A00DD] = startingCurrentFP; rom[0x3A00DE] = startingMaximumFP; Bits.SetShort(rom, 0x3A00DF, startingFrogCoins); // rom[0x02C9B3] = defenseStartL1; rom[0x02C9B9] = defenseStartL2; rom[0x02C9BF] = defenseEndL2; rom[0x02C9C5] = defenseEndL1; } Bits.SetChars(rom, 0x3a134d + (index * 10), name); }
private void Assemble() { effect.Assemble(); animation.Assemble(); int i = 0; int pointer = 0x252C00; int offset = 0x330000; for (; i < 39 && offset < 0x33FFFF; i++, pointer += 3) { if (animations[i].BUFFER.Length + offset > 0x33FFFF) { break; } Bits.SetShort(Model.ROM, pointer, (ushort)offset); Bits.SetByte(Model.ROM, pointer + 2, (byte)((offset >> 16) + 0xC0)); Bits.SetBytes(Model.ROM, offset, animations[i].BUFFER); offset += animations[i].BUFFER.Length; } if (i < 39) { MessageBox.Show("The available space for animation data in bank 0x330000 has exceeded the alotted space.\nAnimation #'s " + i.ToString() + " through 38 will not saved. Please make sure the available animation bytes is not negative.", "LAZY SHELL"); } offset = 0x340000; for (; i < 64 && offset < 0x34CFFF; i++, pointer += 3) { if (animations[i].BUFFER.Length + offset > 0x34CFFF) { break; } Bits.SetShort(Model.ROM, pointer, (ushort)offset); Bits.SetByte(Model.ROM, pointer + 2, (byte)((offset >> 16) + 0xC0)); Bits.SetBytes(Model.ROM, offset, animations[i].BUFFER); offset += animations[i].BUFFER.Length; } if (i < 64) { MessageBox.Show("The available space for animation data in bank 0x340000 has exceeded the alotted space.\nAnimation #'s " + i.ToString() + " through 63 will not saved. Please make sure the available animation bytes is not negative.", "LAZY SHELL"); } molds.Modified = false; sequences.Modified = false; this.Modified = false; }
public void Assemble() { // set sm to new byte with largest possible size byte[] temp = new byte[0x10000]; // now start writing dynamic data temp[6] = (byte)sequences.Count; temp[7] = (byte)molds.Count; temp[8] = (byte)(vramAllocation >> 8); // Sequences int offset = 12; // where sequences begin Bits.SetShort(temp, 2, (ushort)0x0C); int fOffset = sequences.Count * 2 + 2; // offset of first frame packet foreach (Sequence s in sequences) { if (s.Frames.Count != 0 && s.Active) { Bits.SetShort(temp, offset, (ushort)(fOffset + offset)); fOffset += s.Frames.Count * 2 - 1; } else if (s.Active) { Bits.SetShort(temp, offset, (ushort)(fOffset + offset)); fOffset -= 1; } else { Bits.SetShort(temp, offset, 0xFFFF); fOffset -= 2; } offset += 2; } Bits.SetShort(temp, offset, 0); offset += 2; foreach (Sequence s in sequences) { foreach (Sequence.Frame f in s.Frames) { Bits.SetByte(temp, offset++, f.Duration); Bits.SetByte(temp, offset++, f.Mold); } if (s.Active) { Bits.SetByte(temp, offset++, 0); } } // Molds Bits.SetShort(temp, 4, (ushort)offset); int mOffset = molds.Count * 2 + 2; // offset of first mold tilemap foreach (Mold m in molds) { if (index == 162 && mOffset == 0x132) { index = 162; } if (m.Tiles.Count != 0) { if (m.Gridplane) { Bits.SetShort(temp, offset, (ushort)(mOffset + offset + 0x8000)); Mold.Tile tile = m.Tiles[0]; if (tile.Subtile_bytes != null) { mOffset += tile.Length - 2; } } else { Bits.SetShort(temp, offset, (ushort)(mOffset + offset)); mOffset += m.Recompress(mOffset + offset, molds).Length - 1; } } else { Bits.SetShort(temp, offset, (ushort)0xFFFF); mOffset -= 2; } offset += 2; } Bits.SetShort(temp, offset += 2, 0); foreach (Mold m in molds) { if (m.Tiles.Count == 0) { continue; } if (m.Gridplane) { Mold.Tile tile = m.Tiles[0]; if (tile.Subtile_bytes == null) { continue; } temp[offset] = (byte)(tile.Format & 3); Bits.SetBit(temp, offset, 3, tile.Is16bit); Bits.SetBit(temp, offset, 4, tile.YPlusOne == 1); Bits.SetBit(temp, offset, 5, tile.YMinusOne == 1); Bits.SetBit(temp, offset, 6, tile.Mirror); Bits.SetBit(temp, offset++, 7, tile.Invert); int size = tile.Is16bit ? tile.Length - 3 : tile.Length - 1; // set bits for tiles that are 16bit if (tile.Is16bit) { for (int i = 0; i < size; i++) { Bits.SetBit(temp, offset, i, tile.Subtile_bytes[i] >= 0x100); } offset += 2; } for (int i = 0; i < size; i++) { temp[offset++] = (byte)tile.Subtile_bytes[i]; } } else { byte[] mold = m.Recompress(offset, molds); mold.CopyTo(temp, offset); offset += mold.Length; temp[offset++] = 0; } } // finally, set the animation length Bits.SetShort(temp, 0, (ushort)offset); buffer = new byte[offset]; Bits.SetBytes(buffer, 0, temp); }
public int Assemble() { int size = this.buffer.Length; // set sm to new byte with largest possible size byte[] temp = new byte[0x10000]; // not dynamic, can set before others temp[12] = width; temp[13] = height; Bits.SetShort(temp, 14, codec); // now start writing dynamic data int offset = 18; // Graphics Bits.SetShort(temp, 2, 0x12); Buffer.BlockCopy(graphicSet, 0, temp, 18, graphicSetLength); offset += graphicSetLength; // Palettes Bits.SetShort(temp, 4, (ushort)offset); paletteSet.Assemble(temp, offset); offset += paletteSetLength; // Tileset Bits.SetShort(temp, 16, (ushort)offset); int tilesetoffset = offset; foreach (Tile t in tileset_tiles.Tileset) { if (t.Index >= tilesetLength / 8) { break; } if (t.Index > 0 && t.Index % 8 == 0) { offset += 32; } for (int i = 0; i < 4; i++) { Bits.SetShort(temp, offset, (byte)t.Subtiles[i].Index); offset++; Bits.SetBit(temp, offset, 5, t.Subtiles[i].Priority1); Bits.SetBit(temp, offset, 6, t.Subtiles[i].Mirror); Bits.SetBit(temp, offset, 7, t.Subtiles[i].Invert); if (i % 2 == 0) { offset++; } else if (i == 1) { offset += 29; } else if (i == 3) { offset -= 31; } } } Buffer.BlockCopy(temp, tilesetoffset, tileset_bytes, 0, tileset_bytes.Length); // offset += 32; Bits.SetShort(temp, offset, 0xFFFF); offset += 2; // Sequences Bits.SetShort(temp, 6, (ushort)offset); int fOffset = sequences.Count * 2 + 2; // offset of first frame packet foreach (E_Sequence s in sequences) { if (s.Frames.Count != 0) { Bits.SetShort(temp, offset, (ushort)(fOffset + offset)); fOffset += s.Frames.Count * 2 + 1; } else { Bits.SetShort(temp, offset, 0xFFFF); } offset += 2; } Bits.SetShort(temp, offset, 0); offset += 2; foreach (E_Sequence s in sequences) { foreach (E_Sequence.Frame f in s.Frames) { Bits.SetByte(temp, offset, f.Duration); offset++; Bits.SetByte(temp, offset, f.Mold); offset++; } Bits.SetByte(temp, offset, 0); offset++; } // Molds Bits.SetShort(temp, 8, (ushort)offset); int mOffset = molds.Count * 2 + 2; // offset of first mold tilemap foreach (E_Mold m in molds) { if (!m.Empty) { Bits.SetShort(temp, offset, (ushort)(mOffset + offset)); mOffset += m.Recompress(m.Mold, width, height).Length - 2; } else { Bits.SetShort(temp, offset, 0xFFFF); } offset += 2; } Bits.SetShort(temp, offset, 0); offset += 2; foreach (E_Mold m in molds) { if (!m.Empty) { byte[] mold = m.Recompress(m.Mold, width, height); Buffer.BlockCopy(mold, 0, temp, offset, mold.Length); offset += mold.Length; } } // finally, set the animation length Bits.SetShort(temp, 0, (ushort)offset); this.buffer = new byte[offset]; Bits.SetBytes(this.buffer, 0, temp); //Do.Export(sm, "test.bin"); return(size - this.buffer.Length); }