From e6bcfee6680bd29c15ef5084665a05e5a2ae5a4e Mon Sep 17 00:00:00 2001 From: ProjectRevoTPP Date: Mon, 27 Nov 2017 15:20:10 -0500 Subject: [PATCH] Encyprtion --- asm/link.s | 8 ++++---- asm/rom4.s | 8 ++++---- src/item.c | 10 +++++----- src/load_save.c | 32 ++++++++++++++++---------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/asm/link.s b/asm/link.s index d2dc05630e..b291bf5a99 100644 --- a/asm/link.s +++ b/asm/link.s @@ -52672,8 +52672,8 @@ SetBerryPowder: @ 802467C .pool thumb_func_end SetBerryPowder - thumb_func_start ApplyNewEncyprtionKeyToBerryPowder -ApplyNewEncyprtionKeyToBerryPowder: @ 8024690 + thumb_func_start ApplyNewEncryptionKeyToBerryPowder +ApplyNewEncryptionKeyToBerryPowder: @ 8024690 push {lr} adds r1, r0, 0 ldr r0, =gSaveBlock2Ptr @@ -52681,11 +52681,11 @@ ApplyNewEncyprtionKeyToBerryPowder: @ 8024690 movs r2, 0xFA lsls r2, 1 adds r0, r2 - bl ApplyNewEncyprtionKeyToWord + bl ApplyNewEncryptionKeyToWord pop {r0} bx r0 .pool - thumb_func_end ApplyNewEncyprtionKeyToBerryPowder + thumb_func_end ApplyNewEncryptionKeyToBerryPowder thumb_func_start sub_80246AC sub_80246AC: @ 80246AC diff --git a/asm/rom4.s b/asm/rom4.s index 8b7dec1ae8..ea03b8a8d4 100644 --- a/asm/rom4.s +++ b/asm/rom4.s @@ -238,8 +238,8 @@ _08084854: .pool thumb_func_end sav12_xor_set - thumb_func_start ApplyNewEncyprtionKeyToGameStats -ApplyNewEncyprtionKeyToGameStats: @ 8084864 + thumb_func_start ApplyNewEncryptionKeyToGameStats +ApplyNewEncryptionKeyToGameStats: @ 8084864 push {r4-r6,lr} adds r5, r0, 0 movs r4, 0 @@ -251,7 +251,7 @@ _0808486C: ldr r0, [r6] adds r0, r1 adds r1, r5, 0 - bl ApplyNewEncyprtionKeyToWord + bl ApplyNewEncryptionKeyToWord adds r0, r4, 0x1 lsls r0, 24 lsrs r4, r0, 24 @@ -261,7 +261,7 @@ _0808486C: pop {r0} bx r0 .pool - thumb_func_end ApplyNewEncyprtionKeyToGameStats + thumb_func_end ApplyNewEncryptionKeyToGameStats thumb_func_start CopyFieldObjectTemplatesToSav1 @ void CopyFieldObjectTemplatesToSav1() diff --git a/src/item.c b/src/item.c index 32347623e6..5cf9edf6c6 100644 --- a/src/item.c +++ b/src/item.c @@ -5,7 +5,7 @@ #include "text.h" #include "event_data.h" -extern void ApplyNewEncyprtionKeyToHword(u16* hword, u32 newKey); +extern void ApplyNewEncryptionKeyToHword(u16* hword, u32 newKey); extern bool8 InBattlePyramid(void); extern const u8 gText_PokeBalls[]; @@ -45,19 +45,19 @@ void SetBagItemId(u16* slot, u16 newItemId) *slot = newItemId; } -void ApplyNewEncyprtionKeyToBagItems(u32 newKey) +void ApplyNewEncryptionKeyToBagItems(u32 newKey) { u32 pocket, item; for (pocket = 0; pocket < 5; pocket++) { for (item = 0; item < gBagPockets[pocket].capacity; item++) - ApplyNewEncyprtionKeyToHword(&(gBagPockets[pocket].itemSlots[item].quantity), newKey); + ApplyNewEncryptionKeyToHword(&(gBagPockets[pocket].itemSlots[item].quantity), newKey); } } -void ApplyNewEncyprtionKeyToBagItems_(u32 newKey) // really GF? +void ApplyNewEncryptionKeyToBagItems_(u32 newKey) // really GF? { - ApplyNewEncyprtionKeyToBagItems(newKey); + ApplyNewEncryptionKeyToBagItems(newKey); } // TODO: move those max values to defines diff --git a/src/load_save.c b/src/load_save.c index 5eb160e5a7..1d78bda502 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -10,10 +10,10 @@ extern void* gUnknown_0203CF5C; extern bool16 IdentifyFlash(void); extern void SetBagItemsPointers(void); extern void SetDecorationInventoriesPointers(void); -extern void ApplyNewEncyprtionKeyToGameStats(u32 key); -extern void ApplyNewEncyprtionKeyToBagItems(u32 newKey); -extern void ApplyNewEncyprtionKeyToBagItems_(u32 key); -extern void ApplyNewEncyprtionKeyToBerryPowder(u32 key); +extern void ApplyNewEncryptionKeyToGameStats(u32 key); +extern void ApplyNewEncryptionKeyToBagItems(u32 newKey); +extern void ApplyNewEncryptionKeyToBagItems_(u32 key); +extern void ApplyNewEncryptionKeyToBerryPowder(u32 key); extern void sub_8084FAC(int unused); // this is probably wrong or misleading due to it being used in ResetHeap... @@ -43,7 +43,7 @@ EWRAM_DATA u8 gSaveblock3_DMA[SAVEBLOCK_MOVE_RANGE] = {0}; EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0}; EWRAM_DATA u32 gLastEncryptionKey = {0}; -void ApplyNewEncyprtionKeyToAllEncryptedData(u32 encryptionKey); +void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey); void CheckForFlashMemory(void) { @@ -150,7 +150,7 @@ void MoveSaveBlocks_ResetHeap(void) // create a new encryption key encryptionKey = (Random() << 0x10) + (Random()); - ApplyNewEncyprtionKeyToAllEncryptedData(encryptionKey); + ApplyNewEncryptionKeyToAllEncryptedData(encryptionKey); gSaveBlock2Ptr->encryptionKey = encryptionKey; } #else @@ -235,7 +235,7 @@ void MoveSaveBlocks_ResetHeap(void) lsrs r0, 16\n\ adds r4, r0\n\ adds r0, r4, 0\n\ - bl ApplyNewEncyprtionKeyToAllEncryptedData\n\ + bl ApplyNewEncryptionKeyToAllEncryptedData\n\ ldr r1, =gSaveBlock2Ptr\n\ ldr r0, [r1]\n\ adds r0, 0xAC\n\ @@ -389,27 +389,27 @@ void copy_bags_and_unk_data_to_save_blocks(void) encryptionKeyBackup = gSaveBlock2Ptr->encryptionKey; gSaveBlock2Ptr->encryptionKey = gLastEncryptionKey; - ApplyNewEncyprtionKeyToBagItems(encryptionKeyBackup); + ApplyNewEncryptionKeyToBagItems(encryptionKeyBackup); gSaveBlock2Ptr->encryptionKey = encryptionKeyBackup; // updated twice? } -void ApplyNewEncyprtionKeyToHword(u16 *hWord, u32 newKey) +void ApplyNewEncryptionKeyToHword(u16 *hWord, u32 newKey) { *hWord ^= gSaveBlock2Ptr->encryptionKey; *hWord ^= newKey; } -void ApplyNewEncyprtionKeyToWord(u32 *word, u32 newKey) +void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey) { *word ^= gSaveBlock2Ptr->encryptionKey; *word ^= newKey; } -void ApplyNewEncyprtionKeyToAllEncryptedData(u32 encryptionKey) +void ApplyNewEncryptionKeyToAllEncryptedData(u32 encryptionKey) { - ApplyNewEncyprtionKeyToGameStats(encryptionKey); - ApplyNewEncyprtionKeyToBagItems_(encryptionKey); - ApplyNewEncyprtionKeyToBerryPowder(encryptionKey); - ApplyNewEncyprtionKeyToWord(&gSaveBlock1Ptr->money, encryptionKey); - ApplyNewEncyprtionKeyToHword(&gSaveBlock1Ptr->coins, encryptionKey); + ApplyNewEncryptionKeyToGameStats(encryptionKey); + ApplyNewEncryptionKeyToBagItems_(encryptionKey); + ApplyNewEncryptionKeyToBerryPowder(encryptionKey); + ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->money, encryptionKey); + ApplyNewEncryptionKeyToHword(&gSaveBlock1Ptr->coins, encryptionKey); }