Labels for Gen 5 Trainer Records (plus renamed flag) (#4362)

This commit is contained in:
Squid 2024-11-09 09:08:57 -06:00 committed by GitHub
parent 4bad2e3cdf
commit 62b58f78e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 170 additions and 56 deletions

View file

@ -16,7 +16,7 @@
0280 g Traded for Basculin
0315 g Received Larvesta Egg Gift
0352 t Battled Youngster Kyle
0355 t Battled Lass Dana
0355 t Can Battle Lass Dye
0339 g Purchased Magikarp
0347 g Traded for Emolga
0360 g Traded for Rotom

View file

@ -16,7 +16,7 @@
0280 g Intercambio por Basculin
0315 g Huevo Larvesta de regalo recibido
0352 t Luchado contra Joven Bertín
0355 t Luchado contra Chica Sara
0355 t Puede luchar contra Chica Geles
0339 g Magikarp comprado
0347 g Intercambio por Emolga
0360 g Intercambio por Rotom
@ -38,4 +38,4 @@
0769 r Captura/Derrota al Amoonguss de la Ruta 10
0770 r Captura/Derrota al Amoonguss de la Ruta 10
0771 r Captura/Derrota al Foongus de la Ruta 10
0772 r Captura/Derrota al Foongus de la Ruta 10
0772 r Captura/Derrota al Foongus de la Ruta 10

View file

@ -16,7 +16,7 @@
0280 g Traded for Basculin
0315 g Received Larvesta Egg Gift
0352 t Battled Youngster Kyle
0355 t Battled Lass Dana
0355 t Can battle Lass Anémone
0339 g Purchased Magikarp
0347 g Traded for Emolga
0360 g Traded for Rotom
@ -38,4 +38,4 @@
0769 r Route 10 Capture/Defeat Amoonguss
0770 r Route 10 Capture/Defeat Amoonguss
0771 r Route 10 Capture/Defeat Foongus
0772 r Route 10 Capture/Defeat Foongus
0772 r Route 10 Capture/Defeat Foongus

View file

@ -16,7 +16,7 @@
0280 g ホドモエシティでバスラオを交換した
0315 g 18番道路でメラルバのタマゴをもらった
0352 t たんぱんこぞうのナオキとバトルした
0355 t ミニスカートのリカとバトルした
0355 t ミニスカートのアヤとバトルできます
0339 g コイキングを買った
0347 g 7番道路でエモンガを交換した
0360 g 15番道路でロトムを交換した

View file

@ -16,7 +16,7 @@
0280 g Traded for Basculin
0315 g Received Larvesta Egg Gift
0352 t Battled Youngster Kyle
0355 t Battled Lass Dana
0355 t Can Battle Lass Dye
0339 g Purchased Magikarp
0347 g Traded for Emolga
0360 g Traded for Rotom

View file

@ -5,7 +5,14 @@ namespace PKHeX.Core;
public class Record5(SAV5 SAV, Memory<byte> raw) : SaveBlock<SAV5>(SAV, raw)
{
private Span<byte> DataRegion => Data[4..^4]; // 4..0x1DC
public const int Max32 = 999_999_999;
public const ushort Max16 = 65535;
public const byte Record32 = 68; // int32
public const byte Record16 = 100; // int16
private const byte Count = Record32 + Record16;
private Span<byte> DataRegion => Data[4..^4]; // 0..0x1DC
private uint CryptoSeed // 0x1DC
{
@ -29,77 +36,45 @@ public class Record5(SAV5 SAV, Memory<byte> raw) : SaveBlock<SAV5>(SAV, raw)
set => WriteUInt32LittleEndian(Data, value);
}
public const int Record32 = 68;
public const int Record16 = 100;
public static ushort GetMax16(int recordID) => Max16;
public static uint GetMax32(int recordID) => Max32;
public static int GetOffset(int recordID) => recordID switch
{
< Record32 => (recordID * sizeof(int)),
< Count => (Record32 * sizeof(int)) + ((recordID - Record32) * sizeof(ushort)),
_ => -1,
};
private const int Partition2 = Record32 * sizeof(uint);
private Span<byte> Record32Data => DataRegion[..Partition2];
private Span<byte> Record16Data => DataRegion[Partition2..];
private const uint Max32 = 999_999_999;
private const ushort Max16 = 9999;
public uint GetRecord32(int index)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record32);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, Record32);
EnsureDecrypted();
return ReadUInt32LittleEndian(Record32Data[(index * 4)..]);
}
public void SetRecord32(int index, uint value)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record32);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, Record32);
EnsureDecrypted();
WriteUInt32LittleEndian(Record32Data[(index * 4)..], Math.Min(Max32, value));
WriteUInt32LittleEndian(Record32Data[(index * 4)..], Math.Min(GetMax32(index), value));
}
public ushort GetRecord16(int index)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record16);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, Record16);
EnsureDecrypted();
return ReadUInt16LittleEndian(Record16Data[(index * 2)..]);
}
public void SetRecord16(int index, ushort value)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual<uint>((uint)index, Record16);
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual((uint)index, Record16);
EnsureDecrypted();
WriteUInt16LittleEndian(Record16Data[(index * 2)..], Math.Min(Max16, value));
}
public enum Record5Index
{
TimesSaved = 0,
StepsTaken = 1,
UsedBicycle = 2,
TotalBattles = 3,
WildBattles = 4,
TrainerBattles = 5,
Captured = 6,
CapturedFishing = 7,
EggsHatched = 8,
PokemonEvolved = 9,
TimesHealedPokeCenter = 10,
// ???
LinkTrades = 21,
LinkBattles = 22,
LinkBattleWins = 23,
LinkBattleLosses = 24,
// 00 - 0x110: start of u16 records
// 46 - 0x16C: Feeling Checks
// 47 - 0x16E: Musical
// 56 - 0x180: Battle Tests Attempted
// 57 - 0x182: Battle Test High Score
// 60 - 0x188: Customers
// 64 - 0x190: Movie Shoots
FirstU16 = Record32 + 00,
FeelingsChecked = Record32 + 46,
Musical = Record32 + 47,
BattleTestsAttempted = Record32 + 56,
BattleTestHighScore = Record32 + 57,
Customers = Record32 + 60,
MovieShoots = Record32 + 64,
WriteUInt16LittleEndian(Record16Data[(index * 2)..], Math.Min(GetMax16(index), value));
}
}

View file

@ -56,6 +56,145 @@ public static class Records
public static class RecordLists
{
public static readonly Dictionary<int, string> RecordList_5 = new()
{
{000, "Steps Taken"},
{001, "Times Saved"},
{002, "Storyline Completed Time"},
{003, "Times Bicycled"},
{004, "Total Battles"},
{005, "Wild Pokémon Battles"},
{006, "Trainer Battles"},
{007, "Pokemon Caught"},
{008, "Times fished"},
{009, "Eggs Hatched"},
{010, "Pokémon Evolved"},
{011, "Times Healed at Pokémon Centers"},
{012, "Link Trades"},
{013, "Link Battles"},
{014, "Link Battle Wins"},
{015, "Link Battle Losses"},
{016, "WiFi Trades"},
{017, "WiFi Battles"},
{018, "WiFi Battle Wins"},
{019, "WiFi Battle Losses"},
{020, "Times Shopped"},
{021, "Money Spent"},
{022, "TVs Watched"},
{023, "Pokemon deposited in Daycare"},
{024, "Pokemon Defeated"},
{025, "EXP Earned (highest)"},
{026, "EXP Earned (today)"},
{027, "GTS Used"},
{028, "Mail Sent"},
{029, "Nicknames Given"},
{030, "Premier Balls earned"},
{031, "Nimbasa Stadium Battles"},
{032, "BP Earned"},
{033, "BP Spent"},
{034, "???"},
{035, "IR Trades"},
{036, "IR Battles"},
{037, "IR Wins"},
{038, "IR Losses"},
{039, "???"},
{040, "???"},
{041, "Times used Fly"},
{042, "Trash Cans Checked"},
{043, "Hidden Items Found"},
{044, "Pass Powers Used"},
{045, "Pokemon Caught in Entralink"},
{046, "Super Effective Moves Used"},
{047, "Times Challenged Battle Subway"},
{048, "Tower/Treehollow Trainers Defeated"},
{049, "Balloon Game Tottal Points"},
{050, "Highest Box Office Gross"},
{051, "Total Box Office Gross"},
{052, "???"},
{053, "???"},
{054, "???"},
{055, "???"},
{056, "???"},
{057, "???"},
{058, "???"},
{059, "???"},
{060, "???"},
{061, "???"},
{062, "???"},
{063, "???"},
{064, "???"},
{065, "???"},
{066, "???"},
{067, "???"},
{068, "???"},
{069, "???"},
{070, "???"},
{071, "Champion Beaten"},
{072, "Healed with Mom"},
{073, "Used Splash"},
{074, "Used Struggle"},
{075, "Noneffective move used on you"},
{076, "Own Pokemon Attacked"},
{077, "Own Pokemon Fainted"},
{078, "Failed to Run"},
{079, "Pokemon Fled"},
{080, "Failed Fishing"},
{081, "Pokemon defeated (highest)"},
{082, "Pokemon defeated (today)"},
{083, "Trainers defeated (highest)"},
{084, "Trainers defeated (today)"},
{085, "Pokemon evolved (highest)"},
{086, "Pokemon evolved (today)"},
{087, "Fossils Restored"},
{088, "Spin Trade"},
{089, "???"},
{090, "???"},
{091, "???"},
{092, "???"},
{093, "???"},
{094, "???"},
{095, "???"},
{096, "???"},
{097, "???"},
{098, "???"},
{099, "???"},
{100, "???"},
{101, "???"},
{102, "???"},
{103, "???"},
{104, "???"},
{105, "???"},
{106, "???"},
{107, "???"},
{108, "???"},
{109, "???"},
{110, "Disturbed Tile Encounters"},
{111, "Feeling Check"},
{112, "Musicals Participated In"},
{113, "Musicals Won"},
{114, "Musicals with Friends"},
{115, "Musicals with Friends Won"},
{116, "Musical Fame Score"},
{117, "Pokemon Tucked In"},
{118, "Poketransfer Minigame Played"},
{119, "Battle Institute Attempts"},
{120, "???"},
{121, "Battle Institute Max Rank reached"},
{122, "Battle Test High Score"},
{123, "Vending Machines Used"},
{124, "Rode Royal Unova"},
{125, "Passers-by Guided"},
{126, "Shops Created"},
{127, "Xtransciever minigames Played"},
{128, "Souvenirs Collected"},
{129, "Movie Shoots"},
};
public static readonly Dictionary<int, string> RecordList_6 = new()
{
{000, "Steps Taken"},