public void Assemble(ref int offset) { if (index >= 0x0800) { Bits.SetShort(rom, 0x37E000 + index * 2, (ushort)(offset - 4)); } else { Bits.SetShort(rom, 0x37E000 + index * 2, (ushort)(offset - 8)); } int dlgOffset = 0; // Select bank to save to if (index >= 0x0C00) { dlgOffset = offset + 0x240000; } else if (index >= 0x0800) { dlgOffset = offset + 0x230000; } else { dlgOffset = offset + 0x220000; } Bits.SetChars(rom, dlgOffset, text); offset += text.Length; }
public void Assemble() { Bits.SetChars(rom, 0x3959F4 + (index * 13), name); // int offset = (index * 4) + 0x391226; rom[offset] = attackLevel; Bits.SetBit(rom, offset, 3, instantDeath); Bits.SetBit(rom, offset, 4, noDamageA); Bits.SetBit(rom, offset, 5, hideDigits); Bits.SetBit(rom, offset++, 6, noDamageB); // rom[offset++] = hitRate; Bits.SetBit(rom, offset, 0, effectMute); Bits.SetBit(rom, offset, 1, effectSleep); Bits.SetBit(rom, offset, 2, effectPoison); Bits.SetBit(rom, offset, 3, effectFear); Bits.SetBit(rom, offset, 5, effectMushroom); Bits.SetBit(rom, offset, 6, effectScarecrow); Bits.SetBit(rom, offset++, 7, effectInvincible); // Bits.SetBit(rom, offset, 3, upMagicAttack); Bits.SetBit(rom, offset, 4, upAttack); Bits.SetBit(rom, offset, 5, upMagicDefense); Bits.SetBit(rom, offset, 6, upDefense); }
public void Assemble(ref int offset) { Bits.SetShort(rom, pointerOffset + index * 2, offset); this.offset = offset + baseOffset; // Bits.SetChars(rom, this.offset, text); offset += text.Length; }
public void Assemble(ref int pointer) { Bits.SetShort(rom, 0x249000 + index * 2, pointer); int offset = pointer + 0x249100; char[] raw = new char[text.Length + 1]; text.CopyTo(raw, 0); Bits.SetChars(rom, offset, raw); pointer += raw.Length; }
public static byte[] BRRToWAV(byte[] inBrr, int rate, int loopStart) { if (inBrr == null) { inBrr = new byte[9]; } p1 = 0; p2 = 0; short[] samples = new short[0]; byte[] BRR = new byte[9]; int size = (int)inBrr.Length; //if (size % 9 != 0) //{ // MessageBox.Show("Error : BRR file isn't a multiple of 9 bytes or is too big."); // return null; //} int blockamount = size / 9; int offset = 0; size = 0; for (int i = 0; i < blockamount; i++) { BRR = Bits.GetBytes(inBrr, offset, 9); offset += 9; samples = append(samples, DecodeBRR(BRR)); //Append 16 BRR samples to existing array size += 16; } // int position = loopStart / 9 * 16; if (position >= size) { position = 0; } size -= position; // byte[] outWav = new byte[(size << 1) + 44]; offset = 0; Bits.SetChars(outWav, offset, "RIFF".ToCharArray()); offset += 4; Bits.SetInt32(outWav, offset, (size << 1) + 36); offset += 4; Bits.SetChars(outWav, offset, "WAVEfmt ".ToCharArray()); offset += 8; Bits.SetInt32(outWav, offset, 16); offset += 4; Bits.SetShort(outWav, offset, 1); offset += 2; Bits.SetShort(outWav, offset, 1); offset += 2; Bits.SetInt32(outWav, offset, rate); offset += 4; Bits.SetInt32(outWav, offset, rate * 2); offset += 4; Bits.SetShort(outWav, offset, 2); offset += 2; Bits.SetShort(outWav, offset, 16); offset += 2; Bits.SetChars(outWav, offset, "data".ToCharArray()); offset += 4; Bits.SetInt32(outWav, offset, size << 1); offset += 4; // for (int i = position; i < size + position; i++) { Bits.SetShort(outWav, offset, samples[i]); offset += 2; } return(outWav); }
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() { int offset = 0; byte[] temp = new byte[0x700]; MenuTexts lastMenuText = null; foreach (MenuTexts menuText in Model.MenuTexts) { if (lastMenuText != null && menuText.Length != 0 && Bits.Compare(menuText.Text, lastMenuText.Text)) { Bits.SetShort(Model.ROM, menuText.Index * 2 + 0x3EEF00, lastMenuText.Offset); menuText.Offset = lastMenuText.Offset; continue; } if (offset + menuText.Length + 1 >= 0x700) { MessageBox.Show("Menu texts exceed allotted ROM space. Stopped saving at index " + menuText.Index + "."); break; } menuText.Offset = offset; lastMenuText = menuText; // Bits.SetShort(Model.ROM, menuText.Index * 2 + 0x3EEF00, offset); Bits.SetChars(temp, offset, menuText.Text); offset += menuText.Length; temp[offset++] = 0; switch (menuText.Index) { case 14: Bits.SetByteBits(Model.ROM, 0x03328E, (byte)(menuText.X * 2), 0x3F); break; case 15: Bits.SetByteBits(Model.ROM, 0x03327E, (byte)(menuText.X * 2), 0x3F); break; case 16: Bits.SetByteBits(Model.ROM, 0x033282, (byte)(menuText.X * 2), 0x3F); break; case 17: Bits.SetByteBits(Model.ROM, 0x033286, (byte)(menuText.X * 2), 0x3F); break; case 18: Bits.SetByteBits(Model.ROM, 0x03328A, (byte)(menuText.X * 2), 0x3F); break; case 19: Bits.SetByteBits(Model.ROM, 0x03327A, (byte)(menuText.X * 2), 0x3F); break; } } Bits.SetBytes(Model.ROM, 0x3EF000, temp); //Bits.SetShort(Model.Data, 0x3EF600, 0x344F); menus.Assemble(); menus.Modified = false; this.Modified = false; }
private void AssembleLocationTexts() { char[][] pointNames = new char[56][]; char[] tempB; int[] duplicates = new int[56]; // the point it is a duplicate of int[] levels = new int[56]; // the location within the point it is a duplicate of bool[] isdup = new bool[56]; // if is a duplicate of something // set duplicates for (int i = 0; i < locations.Length; i++) { pointNames[i] = locations[i].Name; // the name we'll be comparing everything to if (!isdup[i]) { for (int a = 0; a < locations.Length; a++) { if (a != i && !isdup[a]) // last condition checks if it already has duplicate { tempB = locations[a].Name; // the name that might be a duplicate of tempA for (int b = 0; b < pointNames[i].Length; b++) { if (tempB.Length == pointNames[i].Length - b) { if (Bits.Compare(pointNames[i], tempB, b, 0)) // if tempB is a duplicate of tempA at location b of tempA { levels[a] = b; duplicates[a] = i; isdup[a] = true; break; } } else if (tempB.Length > pointNames[i].Length - b) { break; } } } } } } // assemble ushort[] pointers = new ushort[56]; int pOffset = 0x3EFD00; int dOffset = 0x3EFD80; ushort pointer = 0; // set all of the ones that aren't duplicates first (so we'll have pointers to use) for (int i = 0; i < locations.Length; i++) { if (!isdup[i]) { pointers[i] = pointer; Bits.SetShort(Model.ROM, i * 2 + pOffset, pointers[i]); Bits.SetChars(Model.ROM, dOffset, pointNames[i]); dOffset += pointNames[i].Length; pointer += (ushort)pointNames[i].Length; Model.ROM[dOffset] = 6; dOffset++; pointer++; if (i != locations.Length - 1 && !isdup[i + 1] && dOffset > 0x3EFF1F) { MessageBox.Show("The total compressed size of all location names is too large. Some data might not have been saved correctly. Please reduce the length of one or more location names.", "LAZY SHELL"); } } } // set duplicates pOffset = 0x3EFD00; pointer = 0; for (int i = 0; i < locations.Length; i++) { if (isdup[i]) { pointers[i] = (ushort)(pointers[duplicates[i]] + levels[i]); Bits.SetShort(Model.ROM, i * 2 + pOffset, pointers[i]); } } }
public void Assemble(ref int psychopathOffset) { // name Bits.SetChars(rom, 0x3992d1 + (index * 13), name); // psychopath int length = 0; Bits.SetShort(rom, 0x399FD1 + index * 2, psychopathOffset); if (this.psychopathError) { MessageBox.Show("There was a problem saving monster #" + this.index + "'s psychopath message."); } else { length = psychopath.Length; Bits.SetChars(rom, 0x390000 + psychopathOffset, psychopath); } psychopathOffset += length; // stats int offset = Bits.GetShort(rom, 0x390026 + index * 2) + 0x390000; // B0 Bits.SetShort(rom, offset, hp); offset += 2; // B1-8 rom[offset++] = speed; rom[offset++] = attack; rom[offset++] = defense; rom[offset++] = magicAttack; rom[offset++] = magicDefense; rom[offset++] = fp; rom[offset++] = evade; rom[offset++] = magicEvade; // B9 Bits.SetBit(rom, offset, 0, disableAutoDeath); Bits.SetBit(rom, offset++, 1, palette2bpp); // B10 rom[offset] = (byte)((strikeSound << 4) + (morphSuccess << 2)); Bits.SetBit(rom, offset, 0, invincible); Bits.SetBit(rom, offset++, 1, mortalityProtection); // B11 Bits.SetBit(rom, offset, 4, elemNullIce); Bits.SetBit(rom, offset, 5, elemNullThunder); Bits.SetBit(rom, offset, 6, elemNullFire); Bits.SetBit(rom, offset++, 7, elemNullJump); // B12 rom[offset] = otherSound; Bits.SetBit(rom, offset, 4, elemWeakIce); Bits.SetBit(rom, offset, 5, elemWeakThunder); Bits.SetBit(rom, offset, 6, elemWeakFire); Bits.SetBit(rom, offset++, 7, elemWeakJump); // B13 Bits.SetBit(rom, offset, 0, effectNullMute); Bits.SetBit(rom, offset, 1, effectNullSleep); Bits.SetBit(rom, offset, 2, effectNullPoison); Bits.SetBit(rom, offset, 3, effectNullFear); Bits.SetBit(rom, offset, 5, effectNullMushroom); Bits.SetBit(rom, offset, 6, effectNullScarecrow); Bits.SetBit(rom, offset++, 7, effectNullInvincible); // B14 rom[offset] = (byte)(entranceStyle + (elevation << 4) + (coinSize << 6)); // rewards offset = Bits.GetShort(rom, 0x39142a + index * 2) + 0x390000; Bits.SetShort(rom, offset, experience); offset += 2; rom[offset++] = coins; rom[offset++] = yoshiCookie; rom[offset++] = itemWinA; rom[offset++] = itemWinB; // flower bonus offset = index + 0x39BB44; rom[offset] = (byte)(flowerBonus + (flowerOdds << 4)); // death animation offset = index * 2 + 0x350202; switch (spriteBehavior) // DEATH ANIMATION { case 0: Bits.SetShort(rom, offset, 0x058A); break; // no movement for "Escape" case 1: Bits.SetShort(rom, offset, 0x0596); break; // slide backward when hit case 2: Bits.SetShort(rom, offset, 0x05A2); break; // etc... case 3: Bits.SetShort(rom, offset, 0x05AE); break; case 4: Bits.SetShort(rom, offset, 0x05BA); break; case 5: Bits.SetShort(rom, offset, 0x0898); break; case 6: Bits.SetShort(rom, offset, 0x0985); break; case 7: Bits.SetShort(rom, offset, 0x0991); break; case 8: Bits.SetShort(rom, offset, 0x0AD3); break; case 9: Bits.SetShort(rom, offset, 0x0ADF); break; case 10: Bits.SetShort(rom, offset, 0x0AEB); break; case 11: Bits.SetShort(rom, offset, 0x0CF2); break; case 12: Bits.SetShort(rom, offset, 0x0CFE); break; case 13: Bits.SetShort(rom, offset, 0x0D0A); break; case 14: Bits.SetShort(rom, offset, 0x0D16); break; case 15: Bits.SetShort(rom, offset, 0x0E60); break; case 16: Bits.SetShort(rom, offset, 0x0E6C); break; case 17: Bits.SetShort(rom, offset, 0x0E78); break; } // cursor rom[0x39B944 + index] = (byte)(cursorX << 4); rom[0x39B944 + index] |= cursorY; }
public void Assemble(ref int descriptionOffset) { int offset = 0x3A46EF + (index * 15); Bits.SetChars(rom, offset, name); this.baseOffsetName = offset; // description int length = 0; if (index <= 0xB0) { Bits.SetShort(rom, 0x3A2F20 + index * 2, descriptionOffset); if (this.descriptionError) { MessageBox.Show("Unable to save item #" + this.index + "'s description."); } else { length = (ushort)description.Length; Bits.SetChars(rom, 0x3A0000 + descriptionOffset, description); // Write the actual description } } descriptionOffset += length; // price Bits.SetShort(rom, (index * 2) + 0x3A40F2, price); this.baseOffsetPrice = offset; // stats offset = (index * 18) + 0x3A014D; this.baseOffsetStats = offset; rom[offset] = itemType; Bits.SetBit(rom, offset, 3, usageBattleMenu); Bits.SetBit(rom, offset, 4, usageOverworldMenu); Bits.SetBit(rom, offset, 5, usageReusable); Bits.SetBit(rom, offset++, 7, usageInstantDeath); // switch (attackType) { case 0: rom[offset] = 0x02; break; case 1: rom[offset] = 0x01; break; case 2: rom[offset] = 0x04; break; case 3: rom[offset] = 0x00; break; } // cursor if (cursorBehavior == 1) { Bits.SetBit(rom, offset, 5, true); } Bits.SetBit(rom, offset, 6, restoreFP); Bits.SetBit(rom, offset++, 7, restoreHP); // Bits.SetBit(rom, offset, 0, equipMario); Bits.SetBit(rom, offset, 1, equipToadstool); Bits.SetBit(rom, offset, 2, equipBowser); Bits.SetBit(rom, offset, 3, equipGeno); Bits.SetBit(rom, offset++, 4, equipMallow); // Bits.SetBit(rom, offset, 1, targetLiveAlly); Bits.SetBit(rom, offset, 2, targetEnemy); Bits.SetBit(rom, offset, 4, targetAll); Bits.SetBit(rom, offset, 5, targetWoundedOnly); Bits.SetBit(rom, offset, 6, targetOnePartyOnly); Bits.SetBit(rom, offset++, 7, targetNotSelf); // switch (elemAttack) { case 0: rom[offset++] = 0x10; break; // Ice case 1: rom[offset++] = 0x20; break; // Thunder case 2: rom[offset++] = 0x40; break; // Fire case 3: rom[offset++] = 0x80; break; // Earth case 4: rom[offset++] = 0x00; break; } // elemental attributes: nullify Bits.SetBit(rom, offset, 4, elemNullIce); Bits.SetBit(rom, offset, 5, elemNullThunder); Bits.SetBit(rom, offset, 6, elemNullFire); Bits.SetBit(rom, offset++, 7, elemNullJump); // elemental attributes: weakness Bits.SetBit(rom, offset, 4, elemWeakIce); Bits.SetBit(rom, offset, 5, elemWeakThunder); Bits.SetBit(rom, offset, 6, elemWeakFire); Bits.SetBit(rom, offset++, 7, elemWeakJump); // status effect Bits.SetBit(rom, offset, 0, effectMute); Bits.SetBit(rom, offset, 1, effectSleep); Bits.SetBit(rom, offset, 2, effectPoison); Bits.SetBit(rom, offset, 3, effectFear); Bits.SetBit(rom, offset, 5, effectMushroom); Bits.SetBit(rom, offset, 6, effectScarecrow); Bits.SetBit(rom, offset++, 7, effectInvincible); // status change Bits.SetBit(rom, offset, 3, changeMagicAttack); Bits.SetBit(rom, offset, 4, changeAttack); Bits.SetBit(rom, offset, 5, changeMagicDefense); Bits.SetBit(rom, offset++, 6, changeDefense); // rom[offset++] = (byte)speed; rom[offset++] = (byte)attack; rom[offset++] = (byte)defense; rom[offset++] = (byte)magicAttack; rom[offset++] = (byte)magicDefense; rom[offset++] = attackRange; rom[offset++] = inflictionAmount; // inflict function switch (inflictFunction) { case 0: rom[offset++] = 0x00; break; case 1: rom[offset++] = 0x01; break; // Revive case 2: rom[offset++] = 0x02; break; // Recover FP case 3: rom[offset++] = 0x03; break; // etc... case 4: rom[offset++] = 0x04; break; case 5: rom[offset++] = 0x05; break; case 6: rom[offset++] = 0x06; break; case 7: rom[offset++] = 0x07; break; case 8: rom[offset++] = 0xFF; break; } Bits.SetBit(rom, offset, 2, hideDigits); // timing if (index < 37) { offset = (index * 4) + 0x3A438A; rom[offset++] = weaponStartLevel1; rom[offset++] = weaponStartLevel2; rom[offset++] = weaponEndLevel2; rom[offset++] = weaponEndLevel1; } }
public void Assemble(ref int descriptionOffset) { Bits.SetChars(rom, 0x3A137F + (index * 15), name); // description int length = 0; if (index <= 0x1A) { Bits.SetShort(rom, 0x3A2B80 + index * 2, descriptionOffset); if (this.descriptionError) { MessageBox.Show("Unable to save spell #" + this.index + "'s description."); } else { length = description.Length; Bits.SetChars(rom, 0x3A0000 + descriptionOffset, description); // Write the actual description } } descriptionOffset += length; // stats int offset = (index * 12) + 0x3A20F1; Bits.SetBit(rom, offset, 0, checkStats); Bits.SetBit(rom, offset, 1, ignoreDefense); Bits.SetBit(rom, offset, 5, checkMortality); Bits.SetBit(rom, offset++, 7, usableOverworld); // rom[offset] = attackType; if (effectType == 0) // Inflict { Bits.SetBit(rom, offset, 1, true); Bits.SetBit(rom, offset, 2, false); } else if (effectType == 1) // Nullify { Bits.SetBit(rom, offset, 1, false); Bits.SetBit(rom, offset, 2, true); } else if (effectType == 2) // {NONE} { Bits.SetBit(rom, offset, 1, false); Bits.SetBit(rom, offset, 2, false); } Bits.SetBit(rom, offset++, 3, maxAttack); // rom[offset++] = fpCost; Bits.SetBit(rom, offset, 1, targetLiveAlly); Bits.SetBit(rom, offset, 2, targetEnemy); Bits.SetBit(rom, offset, 4, targetAll); Bits.SetBit(rom, offset, 5, targetWoundedOnly); Bits.SetBit(rom, offset, 6, targetOnePartyOnly); Bits.SetBit(rom, offset++, 7, targetNotSelf); // switch (inflictElement) { case 0: rom[offset] = 0x10; break; case 1: rom[offset] = 0x20; break; case 2: rom[offset] = 0x40; break; case 3: rom[offset] = 0x80; break; case 4: rom[offset] = 0x00; break; } offset++; // rom[offset++] = magicPower; rom[offset++] = hitRate; Bits.SetBit(rom, offset, 0, effectMute); Bits.SetBit(rom, offset, 1, effectSleep); Bits.SetBit(rom, offset, 2, effectPoison); Bits.SetBit(rom, offset, 3, effectFear); Bits.SetBit(rom, offset, 5, effectMushroom); Bits.SetBit(rom, offset, 6, effectScarecrow); Bits.SetBit(rom, offset++, 7, effectInvincible); // Bits.SetBit(rom, offset, 3, changeMagicAttack); Bits.SetBit(rom, offset, 4, changeAttack); Bits.SetBit(rom, offset, 5, changeMagicDefense); Bits.SetBit(rom, offset, 6, changeDefense); offset += 2; // switch (inflictFunction) { case 0: rom[offset] = 0x00; break; case 1: rom[offset] = 0x01; break; case 2: rom[offset] = 0x02; break; case 3: rom[offset] = 0x03; break; case 4: rom[offset] = 0x04; break; default: rom[offset] = 0xFF; break; } offset++; if (hideDigits == true) { rom[offset] = 0x04; } else { rom[offset] = 0x00; } // timing if (index < 32) { // timing + damage pointers offset = index * 2 + 0x02CACE; Bits.SetShort(rom, offset, timingPointer); offset = index * 2 + 0x02D05B; Bits.SetShort(rom, offset, damagePointer); } }