private void SaveMain() { SAV.Coin = (uint)NUD_Coin.Value; uint valFly = ReadUInt32LittleEndian(SAV.General.AsSpan(ofsFly)); for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { if (FlyDestC[i] < 32) { if (CLB_FlyDest.GetItemChecked(i)) { valFly |= (uint)1 << FlyDestC[i]; } else { valFly &= ~((uint)1 << FlyDestC[i]); } } else { var o = ofsFly + (FlyDestC[i] >> 3); SAV.General[o] = (byte)((SAV.General[o] & ~(1 << (FlyDestC[i] & 7))) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0)); } } WriteUInt32LittleEndian(SAV.General.AsSpan(ofsFly), valFly); WriteUInt16LittleEndian(SAV.General.AsSpan(ofsBP), (ushort)NUD_BP.Value); if (SAV is SAV4Sinnoh sinnoh) { SavePoketch(sinnoh); } if (SAV is SAV4HGSS hgss) { SaveWalker(hgss); } if (ofsUGFlagCount > 0) { var current = ReadUInt32LittleEndian(SAV.General.AsSpan(ofsUGFlagCount)) & ~0xFFFFFu; var update = current | (uint)NUD_UGFlags.Value; WriteUInt32LittleEndian(SAV.General.AsSpan(ofsUGFlagCount), update); } if (ofsMap > 0) { int valMap = CB_UpgradeMap.SelectedIndex; if (valMap >= 0) { SAV.General[ofsMap] = (byte)((SAV.General[ofsMap] & 0xE7) | valMap << 3); } } }
private void saveMain() { int GBO = SAV.getGBO; if (GB_Poketch.Visible) { savePoketch(); } if (GB_FlyDest.Visible) { uint val = BitConverter.ToUInt32(SAV.Data, ofsFly); for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { if (FlyDestC[i] < 32) { if (CLB_FlyDest.GetItemChecked(i)) { val |= (uint)1 << FlyDestC[i]; } else { val &= ~((uint)1 << FlyDestC[i]); } } else { SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] - (FlyDestC[i] >> 3 << 3))) | ((CLB_FlyDest.GetItemChecked(i) ? 1 : 0) << (FlyDestC[i] - (FlyDestC[i] >> 3 << 3)))); } } BitConverter.GetBytes(val).CopyTo(SAV.Data, ofsFly); } if (NUD_BP.Visible) { BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP); } if (CHK_UpgradeTC.Visible) { SAV.Data[GBO + 0x11F0] = (byte)(SAV.Data[GBO + 0x11F0] & 0xEF | (CHK_UpgradeTC.Checked ? 0x10 : 0)); } if (CB_UpgradeMap.Visible) { int val = CB_UpgradeMap.SelectedIndex; if (val >= 0) { SAV.Data[GBO + 0xBAE7] = (byte)(SAV.Data[GBO + 0xBAE7] & 0xE7 | val << 3); } } }
private void SaveMain() { SAV.Coin = (uint)NUD_Coin.Value; uint valFly = BitConverter.ToUInt32(SAV.General, ofsFly); for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { if (FlyDestC[i] < 32) { if (CLB_FlyDest.GetItemChecked(i)) { valFly |= (uint)1 << FlyDestC[i]; } else { valFly &= ~((uint)1 << FlyDestC[i]); } } else { var o = ofsFly + (FlyDestC[i] >> 3); SAV.General[o] = (byte)((SAV.General[o] & ~(1 << (FlyDestC[i] & 7))) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0)); } } BitConverter.GetBytes(valFly).CopyTo(SAV.General, ofsFly); BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.General, ofsBP); if (SAV is SAV4Sinnoh sinnoh) { SavePoketch(sinnoh); } if (SAV is SAV4HGSS hgss) { SaveWalker(hgss); } if (ofsUGFlagCount > 0) { BitConverter.GetBytes((BitConverter.ToUInt32(SAV.General, ofsUGFlagCount) & ~0xFFFFFu) | (uint)NUD_UGFlags.Value).CopyTo(SAV.General, ofsUGFlagCount); } if (ofsMap > 0) { int valMap = CB_UpgradeMap.SelectedIndex; if (valMap >= 0) { SAV.General[ofsMap] = (byte)((SAV.General[ofsMap] & 0xE7) | valMap << 3); } } }
private void SaveMain() { SAV.Coin = (uint)NUD_Coin.Value; uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly); for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { if (FlyDestC[i] < 32) { if (CLB_FlyDest.GetItemChecked(i)) { valFly |= (uint)1 << FlyDestC[i]; } else { valFly &= ~((uint)1 << FlyDestC[i]); } } else { SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] & 7)) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0)); } } BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly); BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP); if (ofsPoketch > 0) { SavePoketch(); } if (ofsUGFlagCount > 0) { BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsUGFlagCount) & ~(uint)0xFFFFF | (uint)NUD_UGFlags.Value).CopyTo(SAV.Data, ofsUGFlagCount); } if (ofsMap > 0) { int valMap = CB_UpgradeMap.SelectedIndex; if (valMap >= 0) { SAV.Data[ofsMap] = (byte)(SAV.Data[ofsMap] & 0xE7 | valMap << 3); } } }
private void SaveFlags() { SAV.Stamps = GetBits(LB_Stamps); SAV.SetEventFlag(333, CHK_UnlockSuperSingles.Checked); SAV.SetEventFlag(334, CHK_UnlockSuperDoubles.Checked); SAV.SetEventFlag(335, CHK_UnlockSuperMulti.Checked); SAV.MegaUnlocked = CHK_UnlockMega.Checked; SAV.ZMoveUnlocked = CHK_UnlockZMove.Checked; for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { SAV.SetEventFlag(SkipFlag + FlyDestFlagOfs[i], CLB_FlyDest.GetItemChecked(i)); } for (int i = 0; i < CLB_MapUnmask.Items.Count; i++) { SAV.SetEventFlag(SkipFlag + MapUnmaskFlagOfs[i], CLB_MapUnmask.GetItemChecked(i)); } }
private void SaveMain() { uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly); for (int i = 0; i < CLB_FlyDest.Items.Count; i++) { if (FlyDestC[i] < 32) { if (CLB_FlyDest.GetItemChecked(i)) { valFly |= (uint)1 << FlyDestC[i]; } else { valFly &= ~((uint)1 << FlyDestC[i]); } } else { var ofs = ofsFly + (FlyDestC[i] >> 3); SAV.Data[ofs] = (byte)((SAV.Data[ofs] & ~(1 << (FlyDestC[i] & 7))) | ((CLB_FlyDest.GetItemChecked(i) ? 1 : 0) << (FlyDestC[i] & 7))); } } BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly); if (SAV is SAV5BW) { // Roamer for (int i = 0; i < cbr.Length; i++) { int c = SAV.Data[ofsRoamer + 0x2E + i]; var d = (int)cbr[i].SelectedValue; if (c == d) { continue; } SAV.Data[ofsRoamer + 0x2E + i] = (byte)d; if (c != 1) { continue; } new byte[14].CopyTo(SAV.Data, ofsRoamer + 4 + (i * 0x14)); SAV.Data[ofsRoamer + 0x2C + i] = 0; } // LibertyPass if (CHK_LibertyPass.Checked ^ bLibPass) { BitConverter.GetBytes(bLibPass ? 0 : valLibPass).CopyTo(SAV.Data, ofsLibPass); } } else if (SAV is SAV5B2W2) { // KeySystem for (int i = 0; i < CLB_KeySystem.Items.Count; i++) { if (CLB_KeySystem.GetItemChecked(i) ^ bKS[i]) { BitConverter.GetBytes(bKS[i] ? 0 : valKS[i]).CopyTo(SAV.Data, ofsKS + (i << 2)); } } } }