diff options
author | jiangzhengwenjz <jiangzhengwenjzw@qq.com> | 2019-07-13 11:25:45 +0800 |
---|---|---|
committer | jiangzhengwenjz <jiangzhengwenjzw@qq.com> | 2019-07-13 11:25:45 +0800 |
commit | 2b09d272ebb31c3aac555139a1b79e55b51a7def (patch) | |
tree | bed6918a020cee13d921d5931f58630b74313101 | |
parent | 64957876846c5892fde62ffd9ab32e6c88ec0e83 (diff) |
OakSpeechNidoranFSetup() NONMATCHING
-rw-r--r-- | asm/pokemon_3.s | 44 | ||||
-rw-r--r-- | src/pokemon.c | 112 | ||||
-rw-r--r-- | sym_ewram.txt | 2 |
3 files changed, 129 insertions, 29 deletions
diff --git a/asm/pokemon_3.s b/asm/pokemon_3.s index 4e6cd6ed2..788415285 100644 --- a/asm/pokemon_3.s +++ b/asm/pokemon_3.s @@ -796,7 +796,7 @@ OakSpeechNidoranFSetup: @ 8044AF0 lsrs r5, r1, 24 movs r0, 0 mov r8, r0 - ldr r4, _08044B34 @ =sOakTutNidoranResources + ldr r4, _08044B34 @ =sOakSpeechNidoranResources ldr r1, [r4] cmp r1, 0 beq _08044B1E @@ -810,7 +810,7 @@ OakSpeechNidoranFSetup: @ 8044AF0 mov r1, r8 str r1, [r4] _08044B1E: - ldr r4, _08044B34 @ =sOakTutNidoranResources + ldr r4, _08044B34 @ =sOakSpeechNidoranResources movs r0, 0x18 bl AllocZeroed adds r2, r0, 0 @@ -821,7 +821,7 @@ _08044B2E: movs r0, 0 b _08044D70 .align 2, 0 -_08044B34: .4byte sOakTutNidoranResources +_08044B34: .4byte sOakSpeechNidoranResources _08044B38: cmp r5, 0 beq _08044B94 @@ -862,7 +862,7 @@ _08044B64: _08044B7C: orrs r0, r1 strb r0, [r2] - ldr r2, _08044B90 @ =sOakTutNidoranResources + ldr r2, _08044B90 @ =sOakSpeechNidoranResources ldr r1, [r2] movs r0, 0x4 strb r0, [r1, 0x1] @@ -871,7 +871,7 @@ _08044B7C: strb r0, [r1, 0x3] b _08044BD0 .align 2, 0 -_08044B90: .4byte sOakTutNidoranResources +_08044B90: .4byte sOakSpeechNidoranResources _08044B94: cmp r6, 0 bne _08044B9A @@ -881,7 +881,7 @@ _08044B9A: bls _08044BA0 movs r6, 0x8 _08044BA0: - ldr r4, _08044C10 @ =sOakTutNidoranResources + ldr r4, _08044C10 @ =sOakSpeechNidoranResources ldr r3, [r4] movs r0, 0xF adds r1, r6, 0 @@ -906,7 +906,7 @@ _08044BA0: ldr r0, [r4] strb r2, [r0, 0x3] _08044BD0: - ldr r5, _08044C10 @ =sOakTutNidoranResources + ldr r5, _08044C10 @ =sOakSpeechNidoranResources ldr r0, [r5] ldrb r1, [r0, 0x1] lsls r1, 11 @@ -937,7 +937,7 @@ _08044C04: mov r8, r1 b _08044C44 .align 2, 0 -_08044C10: .4byte sOakTutNidoranResources +_08044C10: .4byte sOakSpeechNidoranResources _08044C14: ldrb r0, [r1] lsls r0, 28 @@ -965,7 +965,7 @@ _08044C20: cmp r4, r0 blt _08044C20 _08044C44: - ldr r5, _08044C8C @ =sOakTutNidoranResources + ldr r5, _08044C8C @ =sOakSpeechNidoranResources ldr r0, [r5] ldrb r1, [r0] lsls r1, 28 @@ -1000,7 +1000,7 @@ _08044C7C: mov r8, r0 b _08044CE2 .align 2, 0 -_08044C8C: .4byte sOakTutNidoranResources +_08044C8C: .4byte sOakSpeechNidoranResources _08044C90: movs r4, 0 ldrb r0, [r1, 0x1] @@ -1041,7 +1041,7 @@ _08044CC6: bl OakSpeechNidoranFSetupTemplate b _08044CE2 _08044CDA: - ldr r0, _08044D60 @ =sOakTutNidoranResources + ldr r0, _08044D60 @ =sOakSpeechNidoranResources ldr r0, [r0] bl OakSpeechNidoranFSetupTemplateDummy _08044CE2: @@ -1050,7 +1050,7 @@ _08044CE2: ands r0, r1 cmp r0, 0 beq _08044D12 - ldr r4, _08044D60 @ =sOakTutNidoranResources + ldr r4, _08044D60 @ =sOakSpeechNidoranResources ldr r0, [r4] ldr r0, [r0, 0x14] cmp r0, 0 @@ -1074,7 +1074,7 @@ _08044D12: ands r0, r1 cmp r0, 0 beq _08044D42 - ldr r4, _08044D60 @ =sOakTutNidoranResources + ldr r4, _08044D60 @ =sOakSpeechNidoranResources ldr r0, [r4] ldr r0, [r0, 0xC] cmp r0, 0 @@ -1096,7 +1096,7 @@ _08044D42: mov r0, r8 cmp r0, 0 beq _08044D64 - ldr r4, _08044D60 @ =sOakTutNidoranResources + ldr r4, _08044D60 @ =sOakSpeechNidoranResources ldr r0, [r4] movs r1, 0 movs r2, 0x18 @@ -1107,14 +1107,14 @@ _08044D42: str r0, [r4] b _08044D6C .align 2, 0 -_08044D60: .4byte sOakTutNidoranResources +_08044D60: .4byte sOakSpeechNidoranResources _08044D64: - ldr r0, _08044D7C @ =sOakTutNidoranResources + ldr r0, _08044D7C @ =sOakSpeechNidoranResources ldr r1, [r0] movs r0, 0xA3 strb r0, [r1, 0x2] _08044D6C: - ldr r0, _08044D7C @ =sOakTutNidoranResources + ldr r0, _08044D7C @ =sOakSpeechNidoranResources ldr r0, [r0] _08044D70: pop {r3} @@ -1123,13 +1123,13 @@ _08044D70: pop {r1} bx r1 .align 2, 0 -_08044D7C: .4byte sOakTutNidoranResources +_08044D7C: .4byte sOakSpeechNidoranResources thumb_func_end OakSpeechNidoranFSetup */ thumb_func_start OakSpeechNidoranFFreeResources OakSpeechNidoranFFreeResources: @ 8044D80 push {r4,lr} - ldr r4, _08044D9C @ =sOakTutNidoranResources + ldr r4, _08044D9C @ =sOakSpeechNidoranResources ldr r1, [r4] cmp r1, 0 beq _08044DFA @@ -1142,7 +1142,7 @@ OakSpeechNidoranFFreeResources: @ 8044D80 bl memset b _08044DF6 .align 2, 0 -_08044D9C: .4byte sOakTutNidoranResources +_08044D9C: .4byte sOakSpeechNidoranResources _08044DA0: ldr r0, [r1, 0x14] cmp r0, 0 @@ -1199,7 +1199,7 @@ OakSpeechNidoranFGetBuffer: @ 8044E00 push {lr} lsls r0, 24 lsrs r1, r0, 24 - ldr r0, _08044E14 @ =sOakTutNidoranResources + ldr r0, _08044E14 @ =sOakSpeechNidoranResources ldr r2, [r0] ldrb r0, [r2, 0x2] cmp r0, 0xA3 @@ -1207,7 +1207,7 @@ OakSpeechNidoranFGetBuffer: @ 8044E00 movs r0, 0 b _08044E2C .align 2, 0 -_08044E14: .4byte sOakTutNidoranResources +_08044E14: .4byte sOakSpeechNidoranResources _08044E18: ldrb r0, [r2] lsls r0, 28 diff --git a/src/pokemon.c b/src/pokemon.c index 6d40ebafa..39ccbc2d3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -52,7 +52,7 @@ struct OakSpeechNidoranFStruct }; // External symbols -extern struct OakSpeechNidoranFStruct *sOakTutNidoranResources; +extern struct OakSpeechNidoranFStruct *sOakSpeechNidoranResources; extern struct SpriteTemplate gUnknown_825DEF0[]; extern struct SpriteTemplate gUnknown_825DF50[]; extern const union AnimCmd *const *const gTrainerBackAnimsPtrTable[]; @@ -1143,12 +1143,12 @@ void SetMultiuseSpriteTemplateToPokemon(u16 speciesTag, u8 battlerPosition) } else { - if(sOakTutNidoranResources) + if(sOakSpeechNidoranResources) { - if(battlerPosition >= (s8)sOakTutNidoranResources->battlePosition) // why a cast?!? changing the unk0_2 type to s8 causes extra shifts, but a cast is the correct fix. why, compiler? + if(battlerPosition >= (s8)sOakSpeechNidoranResources->battlePosition) // why a cast?!? changing the unk0_2 type to s8 causes extra shifts, but a cast is the correct fix. why, compiler? battlerPosition = 0; - gMultiuseSpriteTemplate = sOakTutNidoranResources->templates[battlerPosition]; + gMultiuseSpriteTemplate = sOakSpeechNidoranResources->templates[battlerPosition]; } else { @@ -5842,7 +5842,7 @@ void OakSpeechNidoranFSetupTemplateDummy(struct OakSpeechNidoranFStruct *structP structPtr->templates[i] = gUnknown_825E05C; for (j = 0; j < structPtr->frameCount; ++j) structPtr->frameImages[i * structPtr->spriteCount + j].data = &structPtr->bufferPtrs[i][j * 0x800]; - structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->spriteCount]; // Bug here, it should be frameCount logically + structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->spriteCount]; // should be frameCount logically structPtr->templates[i].anims = gUnknown_82349BC; structPtr->templates[i].paletteTag = i; } @@ -5850,5 +5850,105 @@ void OakSpeechNidoranFSetupTemplateDummy(struct OakSpeechNidoranFStruct *structP struct OakSpeechNidoranFStruct *OakSpeechNidoranFSetup(u8 battlePosition, bool8 enable) { + s32 size; + u8 i, flags = 0; -}
\ No newline at end of file + if (sOakSpeechNidoranResources != NULL) + { + if (sOakSpeechNidoranResources->enable == 0xA3) + return NULL; + memset(sOakSpeechNidoranResources, 0, sizeof(struct OakSpeechNidoranFStruct)); + sOakSpeechNidoranResources = NULL; + } + sOakSpeechNidoranResources = AllocZeroed(0x18); + if (sOakSpeechNidoranResources == NULL) + return NULL; + switch (enable) + { + case TRUE: + if (battlePosition == 4) + { + sOakSpeechNidoranResources->spriteCount = 4; + sOakSpeechNidoranResources->battlePosition = 4; + } + else + { + if (battlePosition > 4) + battlePosition = 0; + sOakSpeechNidoranResources->spriteCount = 1; + sOakSpeechNidoranResources->battlePosition = 1; + } + sOakSpeechNidoranResources->frameCount = 4; + sOakSpeechNidoranResources->enable2 = TRUE; + break; + case FALSE: + default: + if (!battlePosition) + battlePosition = 1; + if (battlePosition > 8) + battlePosition = 8; + sOakSpeechNidoranResources->spriteCount = battlePosition; + sOakSpeechNidoranResources->battlePosition = battlePosition; + sOakSpeechNidoranResources->frameCount = 4; + sOakSpeechNidoranResources->enable2 = FALSE; + break; + } + size = sOakSpeechNidoranResources->frameCount * 0x800; + sOakSpeechNidoranResources->sizePerSprite = size; + sOakSpeechNidoranResources->dataBuffer = AllocZeroed(sOakSpeechNidoranResources->spriteCount * size); + sOakSpeechNidoranResources->bufferPtrs = AllocZeroed(sOakSpeechNidoranResources->spriteCount * 0x20); + if (sOakSpeechNidoranResources->dataBuffer == NULL || sOakSpeechNidoranResources->bufferPtrs == NULL) + { + flags |= 1; + } + else + { + for (i = 0; i < (s8)sOakSpeechNidoranResources->spriteCount; ++i) + sOakSpeechNidoranResources->bufferPtrs[i] = &sOakSpeechNidoranResources->dataBuffer[sOakSpeechNidoranResources->sizePerSprite * i]; + } + sOakSpeechNidoranResources->templates = AllocZeroed(sizeof(struct SpriteTemplate) * sOakSpeechNidoranResources->spriteCount); + sOakSpeechNidoranResources->frameImages = AllocZeroed(sOakSpeechNidoranResources->spriteCount * sizeof(struct SpriteFrameImage) * sOakSpeechNidoranResources->frameCount); + if (sOakSpeechNidoranResources->templates == NULL || sOakSpeechNidoranResources->frameImages == NULL) + { + flags |= 2; + } + else + { + for (i = 0; i < sOakSpeechNidoranResources->frameCount * sOakSpeechNidoranResources->spriteCount; ++i) + sOakSpeechNidoranResources->frameImages[i].size = 0x800; + switch (sOakSpeechNidoranResources->enable2) + { + case TRUE: + OakSpeechNidoranFSetupTemplate(sOakSpeechNidoranResources, battlePosition); + break; + case FALSE: + default: + OakSpeechNidoranFSetupTemplateDummy(sOakSpeechNidoranResources); + break; + } + } + if (flags & 2) + { + if (sOakSpeechNidoranResources->frameImages != NULL) + FREE_AND_SET_NULL(sOakSpeechNidoranResources->frameImages); + if (sOakSpeechNidoranResources->templates != NULL) + FREE_AND_SET_NULL(sOakSpeechNidoranResources->templates); + } + if (flags & 1) + { + if (sOakSpeechNidoranResources->bufferPtrs != NULL) + FREE_AND_SET_NULL(sOakSpeechNidoranResources->bufferPtrs); + if (sOakSpeechNidoranResources->dataBuffer != NULL) + FREE_AND_SET_NULL(sOakSpeechNidoranResources->dataBuffer); + } + if (flags) + { + memset(sOakSpeechNidoranResources, 0, sizeof(struct OakSpeechNidoranFStruct)); + FREE_AND_SET_NULL(sOakSpeechNidoranResources); + } + else + { + sOakSpeechNidoranResources->enable = 0xA3; + } + return sOakSpeechNidoranResources; +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 889b5491c..cca185dd8 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -490,7 +490,7 @@ gUnknown_2024478: @ 2024478 gMultiuseSpriteTemplate: @ 20244DC .space 0x18 -sOakTutNidoranResources: @ 20244F4 +sOakSpeechNidoranResources: @ 20244F4 .space 0x4 .align 2 |