Add RTC reset, allows game to define on continue

Closes #2273 , thanks @SatoMew !
This commit is contained in:
Kurt
2019-03-30 12:34:51 -07:00
parent bb8cf5d3d8
commit e1a3c8edb3
4 changed files with 31 additions and 3 deletions

View File

@@ -663,6 +663,11 @@ private ushort GetResetKey()
return (ushort)(val + tr);
}
/// <summary>
/// Sets the "Time Not Set" flag to the RTC Flag list.
/// </summary>
public void ResetRTC() => Data[Offsets.RTCFlags] |= 0x80;
public void UnlockAllDecorations()
{
for (int i = 676; i <= 721; i++)

View File

@@ -1,4 +1,6 @@
namespace PKHeX.Core
using System;
namespace PKHeX.Core
{
internal class SAV2Offsets
{
@@ -17,6 +19,8 @@ public SAV2Offsets(SAV2 sav)
EventConst = EventFlag - 0x100;
}
public int RTCFlags { get; private set; } = -1;
public int Options { get; }
public int Trainer1 { get; }
@@ -35,7 +39,7 @@ public SAV2Offsets(SAV2 sav)
public int Gender { get; private set; } = -1;
public int AccumulatedChecksumEnd { get; private set; } = -1;
public int OverallChecksumPosition { get; private set; } = -1;
public int EventFlag { get; private set; }= -1;
public int EventFlag { get; private set; } = -1;
public int EventConst { get; }
public int Daycare { get; }
@@ -47,6 +51,8 @@ public SAV2Offsets(SAV2 sav)
private void LoadOffsetsInternational(GameVersion Version)
{
RTCFlags = 0x0C60;
DaylightSavings = 0x2042;
OtherCurrentBox = 0x284C;
switch (Version)
@@ -99,6 +105,9 @@ private void LoadOffsetsInternational(GameVersion Version)
EventFlag = 0x2600;
break;
default:
throw new ArgumentException(nameof(Version));
}
}
@@ -113,6 +122,8 @@ private void LoadOffsetsJapanese(GameVersion Version)
switch (Version)
{
case GameVersion.GS:
RTCFlags = 0x1000;
Money = 0x23BC;
JohtoBadges = 0x23C5;
CurrentBoxIndex = 0x2705;
@@ -134,6 +145,8 @@ private void LoadOffsetsJapanese(GameVersion Version)
EventFlag = CurrentBoxIndex - 0x105;
break;
case GameVersion.C:
RTCFlags = 0x0C80;
Money = 0x23BE;
JohtoBadges = 0x23C7;
CurrentBoxIndex = 0x26E2;
@@ -154,6 +167,9 @@ private void LoadOffsetsJapanese(GameVersion Version)
EventFlag = 0x1800;
break;
default:
throw new ArgumentException(nameof(Version));
}
}
@@ -161,6 +177,8 @@ private void LoadOffsetsJapanese(GameVersion Version)
private void LoadOffsetsKorean()
{
RTCFlags = 0x1060;
// No Crystal Version
DaylightSavings = 0x2042;
OtherCurrentBox = 0x284C;

View File

@@ -183,6 +183,7 @@ public static class MessageStrings
public static string MsgSaveGen6FriendSafari { get; set; } = "No editing support for Friend Safari :(";
public static string MsgSaveGen6FriendSafariCheatDesc { get; set; } = "Unlock all 3 slots for each friend?";
public static string MsgSaveGen2RTCResetPassword { get; set; } = "RTC Reset Password: {0:00000}";
public static string MsgSaveGen2RTCResetBitflag { get; set; } = "Would you like to reset the RTC?";
public static string MsgSaveJPEGExportFail { get; set; } = "No picture data found in the save file!";
public static string MsgSaveChecksumFailEdited { get; set; } = "Save has been edited. Cannot integrity check.";

View File

@@ -636,7 +636,11 @@ private void B_OpenRTCEditor_Click(object sender, EventArgs e)
switch (SAV.Generation)
{
case 2:
WinFormsUtil.Alert(string.Format(MsgSaveGen2RTCResetPassword, ((SAV2) SAV).ResetKey)); break;
var sav2 = ((SAV2) SAV);
var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, string.Format(MsgSaveGen2RTCResetPassword, sav2.ResetKey), MsgSaveGen2RTCResetBitflag);
if (dr == DialogResult.Yes)
sav2.ResetRTC();
break;
case 3:
new SAV_RTC3(SAV).ShowDialog(); break;
}