Skip to content

Commit

Permalink
Add Adventure Start editing
Browse files Browse the repository at this point in the history
Seconds Since 1/1/2000; can go negative (more than 32 bits, but we can't
ever realistically do that).
  • Loading branch information
kwsch committed Jan 23, 2016
1 parent ea000cc commit 808e4b6
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 19 deletions.
10 changes: 8 additions & 2 deletions Misc/SAV6.cs
Expand Up @@ -84,6 +84,7 @@ public void getSAVOffsets()
Puff = 0x00000;
Item = 0x00400;
Items = new Inventory(Item, 0);
AdventureInfo = 0x01200;
Trainer1 = 0x1400;
Trainer2 = 0x4200;
PCLayout = 0x4400;
Expand Down Expand Up @@ -126,6 +127,7 @@ public void getSAVOffsets()
Puff = 0x00000; // Confirmed
Item = 0x00400; // Confirmed
Items = new Inventory(Item, 1);
AdventureInfo = 0x01200;
Trainer1 = 0x01400; // Confirmed
Trainer2 = 0x04200; // Confirmed
PCLayout = 0x04400; // Confirmed
Expand Down Expand Up @@ -183,7 +185,7 @@ public Inventory(int Offset, int Game)
}
public Inventory Items = new Inventory(0, -1);
public int BattleBox, GTS, Daycare, EonTicket,
Fused, SUBE, Puff, Item, Trainer1, Trainer2, SuperTrain, PSSStats, MaisonStats, SecretBase, BoxWallpapers, LastViewedBox,
Fused, SUBE, Puff, Item, AdventureInfo, Trainer1, Trainer2, SuperTrain, PSSStats, MaisonStats, SecretBase, BoxWallpapers, LastViewedBox,
PCLayout, PCBackgrounds, PCFlags, WondercardFlags, WondercardData, BerryField, OPower, EventConst, EventFlag, EventAsh, PlayTime, Accessories,
PokeDex, PokeDexLanguageFlags, Spinda, EncounterCount, HoF, PSS, JPEG;
public int TrainerCard = 0x14000;
Expand Down Expand Up @@ -439,7 +441,11 @@ public int PlayedSeconds
public uint LastSaved { get { return BitConverter.ToUInt32(Data, PlayTime + 0x4); } set { BitConverter.GetBytes(value).CopyTo(Data, PlayTime + 0x4); } }
public int LastSavedYear { get { return (int)(LastSaved & 0xFFF); } set { LastSaved = LastSaved & 0xFFFFF000 | (uint)value; } }
public int LastSavedMonth { get { return (int)(LastSaved >> 12 & 0xF); } set { LastSaved = LastSaved & 0xFFFF0FFF | ((uint)value & 0xF) << 12; } }
public int LastSavedDay { get { return (int)(LastSaved >> 16 & 0xF); } set { LastSaved = LastSaved & 0xFFE0FFFF | ((uint)value & 0x1F) << 16; } }
public int LastSavedDay { get { return (int)(LastSaved >> 16 & 0x1F); } set { LastSaved = LastSaved & 0xFFE0FFFF | ((uint)value & 0x1F) << 16; } }
public int LastSavedHour { get { return (int)(LastSaved >> 21 & 0x1F); } set { LastSaved = LastSaved & 0xFC1FFFFF | ((uint)value & 0x1F) << 21; } }
public int LastSavedMinute { get { return (int)(LastSaved >> 26 & 0x3F); } set { LastSaved = LastSaved & 0x03FFFFFF | ((uint)value & 0x3F) << 26; } }
public int SecondsToStart { get { return BitConverter.ToInt32(Data, AdventureInfo + 0x18); } set { BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x18); } }
public int SecondsToFame { get { return BitConverter.ToInt32(Data, AdventureInfo + 0x20); } set { BitConverter.GetBytes(value).CopyTo(Data, AdventureInfo + 0x20); } }

public uint getPSSStat(int index) { return BitConverter.ToUInt32(Data, PSSStats + 4*index); }
public void setPSSStat(int index, uint value) { BitConverter.GetBytes(value).CopyTo(Data, PSSStats + 4*index); }
Expand Down
84 changes: 71 additions & 13 deletions SAV/SAV_Trainer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions SAV/SAV_Trainer.cs
Expand Up @@ -438,7 +438,10 @@ private void getTextBoxes()
}

CB_Vivillon.SelectedIndex = SAV.Vivillon;
CAL_LastSaved.Value = new DateTime(SAV.LastSavedYear, SAV.LastSavedMonth, SAV.LastSavedDay);
CAL_LastSavedDate.Value = new DateTime(SAV.LastSavedYear, SAV.LastSavedMonth, SAV.LastSavedDay);
CAL_LastSavedTime.Value = new DateTime(2000, 1, 1, SAV.LastSavedHour, SAV.LastSavedMinute, 0);
CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart% 86400);
}
private void save()
{
Expand Down Expand Up @@ -519,9 +522,14 @@ private void save()

// Vivillon
SAV.Vivillon = CB_Vivillon.SelectedIndex;
SAV.LastSavedYear = CAL_LastSaved.Value.Year;
SAV.LastSavedMonth = CAL_LastSaved.Value.Month;
SAV.LastSavedDay = CAL_LastSaved.Value.Day;

SAV.SecondsToStart = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds;

SAV.LastSavedYear = CAL_LastSavedDate.Value.Year;
SAV.LastSavedMonth = CAL_LastSavedDate.Value.Month;
SAV.LastSavedDay = CAL_LastSavedDate.Value.Day;
SAV.LastSavedHour = CAL_LastSavedTime.Value.Hour;
SAV.LastSavedMinute = CAL_LastSavedTime.Value.Minute;
}

private void clickOT(object sender, MouseEventArgs e)
Expand Down

0 comments on commit 808e4b6

Please sign in to comment.