From 7f1827767c27c6b696a9cd1a8c15b2b31a125b78 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Wed, 9 Sep 2020 16:05:22 -0400 Subject: [PATCH] Document size field of unknown struct --- include/pokemon.h | 6 +++--- src/pokedex.c | 10 ++++------ src/pokemon.c | 10 +++++----- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 94353bea27..81c17f545b 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -126,9 +126,9 @@ struct Unknown_806F160_Struct u32 field_0_0:4; u32 field_0_1:4; u32 field_1:8; - u32 magic:8; - u32 field_3_0:4; - u32 field_3_1:4; + u16 magic:8; + u32 size:4; + u16 field_3_1:4; void *bytes; u8 **byteArrays; struct SpriteTemplate *templates; diff --git a/src/pokedex.c b/src/pokedex.c index e499118919..edc324b6ec 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -5453,8 +5453,8 @@ static void PrintSearchParameterText(u8 taskId) const struct SearchOptionText *texts = sSearchOptions[gTasks[taskId].tMenuItem].texts; const u16 *cursorPos = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataCursorPos]; const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataScrollOffset]; - u16 i; - u16 j; + + u16 i, j; ClearSearchParameterBoxText(); @@ -5543,8 +5543,7 @@ static bool8 SearchParamCantScrollUp(u8 taskId) if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset != 0) return FALSE; - else - return TRUE; + return TRUE; } static bool8 SearchParamCantScrollDown(u8 taskId) @@ -5555,8 +5554,7 @@ static bool8 SearchParamCantScrollDown(u8 taskId) if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset < lastOption - MAX_SEARCH_PARAM_CURSOR_POS) return FALSE; - else - return TRUE; + return TRUE; } #define sTaskId data[0] diff --git a/src/pokemon.c b/src/pokemon.c index 813c327e39..a0e655d1e6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6858,7 +6858,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) structPtr->field_0_0 = 7; structPtr->field_0_1 = 7; structPtr->field_1 = 4; - structPtr->field_3_0 = 1; + structPtr->size = 1; structPtr->field_3_1 = 2; break; case 0: @@ -6866,12 +6866,12 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) structPtr->field_0_0 = 4; structPtr->field_0_1 = 4; structPtr->field_1 = 4; - structPtr->field_3_0 = 1; + structPtr->size = 1; structPtr->field_3_1 = 0; break; } - structPtr->bytes = AllocZeroed(structPtr->field_3_0 * 0x800 * 4 * structPtr->field_0_0); + structPtr->bytes = AllocZeroed(structPtr->size * 0x800 * 4 * structPtr->field_0_0); structPtr->byteArrays = AllocZeroed(structPtr->field_0_0 * 32); if (structPtr->bytes == NULL || structPtr->byteArrays == NULL) { @@ -6880,7 +6880,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) else { for (i = 0; i < structPtr->field_0_0; i++) - structPtr->byteArrays[i] = structPtr->bytes + (structPtr->field_3_0 * (i << 0xD)); + structPtr->byteArrays[i] = structPtr->bytes + (structPtr->size * (i << 0xD)); } structPtr->templates = AllocZeroed(sizeof(struct SpriteTemplate) * structPtr->field_0_0); @@ -6899,8 +6899,8 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) case 2: sub_806F1FC(structPtr); break; - case 0: case 1: + case 0: default: sub_806F160(structPtr); break;