diff --git a/asm/code_8046CE4.s b/asm/code_8046CE4.s index 8a64cc722..a4d5ce0ba 100644 --- a/asm/code_8046CE4.s +++ b/asm/code_8046CE4.s @@ -421,7 +421,7 @@ _08047462: bl sub_80522F4 mov r0, r9 adds r1, r4, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg lsls r0, 24 lsrs r2, r0, 24 movs r1, 0 @@ -927,7 +927,7 @@ _0804786E: bl sub_80522F4 ldr r0, [sp, 0x10] adds r1, r5, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg lsls r0, 24 lsrs r2, r0, 24 movs r1, 0 diff --git a/asm/code_80521D0.s b/asm/code_80521D0.s index 2f67b2b7c..bbdaf8c08 100644 --- a/asm/code_80521D0.s +++ b/asm/code_80521D0.s @@ -2827,7 +2827,7 @@ _08053A4C: bl sub_806A1E8 adds r0, r7, 0 adds r1, r5, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg movs r4, 0 adds r0, r7, 0 mov r1, r8 diff --git a/asm/code_8066D04.s b/asm/code_8066D04.s index ee46e283c..3efc80e78 100644 --- a/asm/code_8066D04.s +++ b/asm/code_8066D04.s @@ -958,7 +958,7 @@ _080675C0: bl sub_8084778 adds r0, r6, 0 adds r1, r5, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg adds r0, r5, 0 bl sub_8070BC0 lsls r0, 24 diff --git a/asm/code_806CD90.s b/asm/code_806CD90.s index 667abd2a4..fe8989ed7 100644 --- a/asm/code_806CD90.s +++ b/asm/code_806CD90.s @@ -632,7 +632,7 @@ _0806D4FE: ldr r3, _0806D524 adds r0, r4, 0 movs r2, 0xC - bl sub_806F324 + bl DealDamageToEntity _0806D514: add sp, 0x1C pop {r3-r5} @@ -677,7 +677,7 @@ _0806D55C: ldr r6, [r7, 0x70] mov r0, r9 adds r1, r7, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg mov r0, r9 adds r1, r7, 0 bl SetShopkeeperAggression diff --git a/asm/code_806E8B0.s b/asm/code_806E8B0.s index c826785f0..7eb951411 100644 --- a/asm/code_806E8B0.s +++ b/asm/code_806E8B0.s @@ -1000,8 +1000,8 @@ _0806F2DE: _0806F320: .4byte 0x000003e7 thumb_func_end sub_806F2BC - thumb_func_start sub_806F324 -sub_806F324: + thumb_func_start DealDamageToEntity +DealDamageToEntity: push {r4-r6,lr} mov r6, r8 push {r6} @@ -1037,7 +1037,7 @@ sub_806F324: pop {r4-r6} pop {r0} bx r0 - thumb_func_end sub_806F324 + thumb_func_end DealDamageToEntity thumb_func_start sub_806F370 sub_806F370: diff --git a/asm/code_807CD9C.s b/asm/code_807CD9C.s index 51eb85325..298700ef7 100644 --- a/asm/code_807CD9C.s +++ b/asm/code_807CD9C.s @@ -237,7 +237,7 @@ _0807CF4E: bne _0807CF9E mov r0, r9 ldr r1, [sp, 0x28] - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg ldr r0, _0807D050 movs r1, 0 ldrsh r2, [r0, r1] @@ -529,7 +529,7 @@ _0807D1DC: bl sub_80522F4 adds r0, r5, 0 adds r1, r5, 0 - bl sub_807A96C + bl TrySendImmobilizeSleepEndMsg mov r0, r8 adds r1, r5, 0 bl sub_80421AC diff --git a/include/code_8077274_1.h b/include/code_8077274_1.h index 73c2d590a..6c2d689f1 100644 --- a/include/code_8077274_1.h +++ b/include/code_8077274_1.h @@ -44,7 +44,7 @@ void SendMoveEndMessage(Entity * pokemon, Entity * target); void SendTransformEndMessage(Entity * pokemon, Entity *target); void SendEyesightEndMessage(Entity * pokemon,Entity * target); void SendMuzzledEndMessage(Entity * pokemon, Entity * target); -void sub_807A96C(Entity *pokemon, Entity *target); +bool8 TrySendImmobilizeSleepEndMsg(Entity *pokemon, Entity *target); void WakeUpPokemon(Entity * pokemon); void SendThawedMessage(Entity *pokemon, Entity *target); void sub_807AA30(void); diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index a453dfd7b..570d021d9 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -36,7 +36,7 @@ extern bool8 sub_8044B28(void); extern void sub_8075708(Entity *entity); extern void sub_80526D0(u8 r0); -extern void sub_806F324(Entity *, s32, u32, u32); +extern void DealDamageToEntity(Entity *, s32, u32, u32); extern void sub_8067110(Entity *); extern void sub_80671A0(Entity *); extern void sub_8073D14(Entity *); @@ -375,8 +375,8 @@ void sub_8074094(Entity *entity) if (gDungeon->unk679 == 3) str = gUnknown_80FD628, sound = FALSE; - sub_807A96C(entity, entity); - sub_806F324(entity, 1, 0xE, 0x211); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, 1, 0xE, 0x211); entityInfo->unk146 = 1; if (FixedPointToInt(entityInfo->belly) != 0) str = NULL; @@ -398,12 +398,12 @@ void sub_8074094(Entity *entity) if (gDungeon->weather.weatherDamageCounter == 0) { if (GetApparentWeather(entity) == WEATHER_HAIL) { if (!MonsterIsType(entity, TYPE_ICE)) { - sub_806F324(entity, gUnknown_80F4F8E, 0x12, 0x220); + DealDamageToEntity(entity, gUnknown_80F4F8E, 0x12, 0x220); } } else if (GetApparentWeather(entity) == WEATHER_SANDSTORM) { if (!MonsterIsType(entity, TYPE_GROUND) && !MonsterIsType(entity, TYPE_ROCK) && !MonsterIsType(entity, TYPE_STEEL)) { - sub_806F324(entity, gUnknown_80F4F8E, 0x12, 0x220); + DealDamageToEntity(entity, gUnknown_80F4F8E, 0x12, 0x220); } } if (!EntityExists(entity) || sub_8044B28()) @@ -440,8 +440,8 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; entityInfo->nonVolatile.nonVolatileStatusDamageCountdown = gUnknown_80F4F32; - sub_807A96C(entity, entity); - sub_806F324(entity, gUnknown_80F4F70, 1, 0x208); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, gUnknown_80F4F70, 1, 0x208); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -453,8 +453,8 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; entityInfo->nonVolatile.nonVolatileStatusDamageCountdown = gUnknown_80F4F34; - sub_807A96C(entity, entity); - sub_806F324(entity, gUnknown_80F4F72, 3, 0x20A); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, gUnknown_80F4F72, 3, 0x20A); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -472,8 +472,8 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; - sub_807A96C(entity, entity); - sub_806F324(entity, gUnknown_80F4FC8[turns], 3, 0x20A); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, gUnknown_80F4FC8[turns], 3, 0x20A); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -485,9 +485,9 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; entityInfo->immobilize.immobilizeStatusDamageCountdown = gUnknown_80F4F38; - sub_807A96C(entity, entity); + TrySendImmobilizeSleepEndMsg(entity, entity); sub_8041C4C(entity, entityInfo->immobilize.unk4); - sub_806F324(entity, gUnknown_80F4F74, 2, 0x209); + DealDamageToEntity(entity, gUnknown_80F4F74, 2, 0x209); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -498,8 +498,8 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; entityInfo->immobilize.immobilizeStatusDamageCountdown = gUnknown_80F4F3A; - sub_807A96C(entity, entity); - sub_806F324(entity, gUnknown_80F4F76, 5, 0x20B); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, gUnknown_80F4F76, 5, 0x20B); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -524,8 +524,8 @@ void sub_8074094(Entity *entity) if (!EntityExists(entity) || sub_8044B28()) return; - sub_807A96C(entity, entity); - sub_806F324(entity, dmg, 7, 0x20C); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, dmg, 7, 0x20C); } if (!EntityExists(entity) || sub_8044B28()) return; @@ -553,11 +553,11 @@ void sub_8074094(Entity *entity) return; if (entityInfo->immobilize.immobilizeStatus != STATUS_FROZEN) { - sub_807A96C(entity, entity); - sub_806F324(entity, hp, 9, 0x20D); + TrySendImmobilizeSleepEndMsg(entity, entity); + DealDamageToEntity(entity, hp, 9, 0x20D); if (dmgUser) { - sub_807A96C(target, target); - sub_806F324(target, hp, 0xD, 0x1FA); + TrySendImmobilizeSleepEndMsg(target, target); + DealDamageToEntity(target, hp, 0xD, 0x1FA); } else { HealTargetHP(target, target, hp, 0, TRUE); @@ -578,12 +578,12 @@ void sub_8074094(Entity *entity) return; SetMessageArgument(gUnknown_202DFE8, entity, 0); SendMessage(entity, gUnknown_80FEB30); - sub_807A96C(entity, entity); + TrySendImmobilizeSleepEndMsg(entity, entity); if (entityInfo->protection.protectionStatus == STATUS_PROTECT) { SendMessage(entity, gPtrProtectSavedItMessage); } else { - sub_806F324(entity, 0x270F, 0xB, 0x20E); + DealDamageToEntity(entity, 0x270F, 0xB, 0x20E); } if (!EntityExists(entity) || sub_8044B28()) return; diff --git a/src/code_8077274_1.c b/src/code_8077274_1.c index b014f9c3c..bd7ba939a 100644 --- a/src/code_8077274_1.c +++ b/src/code_8077274_1.c @@ -176,7 +176,7 @@ extern void sub_807EC28(bool8); extern s32 sub_8069F54(Entity *param_1, s16 param_2); extern void sub_806A898(Entity *, u32, u32); extern void HealTargetHP(Entity *pokemon, Entity *r1, s16, s16, u32); -extern void sub_806F324(Entity *, s16, u32, u32); +extern void DealDamageToEntity(Entity *, s16, u32, u32); extern void sub_806BFC0(EntityInfo *, u32); extern void sub_80420C8(Entity *r0); extern void nullsub_68(Entity *); @@ -1190,7 +1190,7 @@ void SendSleepEndMessage(Entity * pokemon, Entity * target, bool8 param_3, bool8 isAsleep = TRUE; sub_80522F4(pokemon,target,*gUnknown_80FA70C); if (param_4) { - sub_806F324(target,gUnknown_80F4F78,8,0x20f); + DealDamageToEntity(target,gUnknown_80F4F78,8,0x20f); } break; case STATUS_NAPPING: @@ -1570,65 +1570,22 @@ void SendMuzzledEndMessage(Entity * pokemon, Entity * target) EntityUpdateStatusSprites(target); } -/* - * https://decomp.me/scratch/kEFOw (97.58 % matching, Seth) - - bool8 sub_807A96C(Entity * pokemon, Entity * target) - { - EntityInfo *entityInfo; - bool8 flag; - - entityInfo = target->info; - flag = FALSE; - if (entityInfo->immobilize.immobilizeStatus == 6) { - SendImmobilizeEndMessage(pokemon, target); - flag = TRUE; - } - - if (entityInfo->sleep.sleep == 1 && entityInfo->sleep.sleepTurns == 0x7f) { - SendSleepEndMessage(pokemon,target,0,1); - flag = TRUE; - } - return flag; - } -*/ -NAKED -void sub_807A96C(Entity *pokemon, Entity *target) +bool8 TrySendImmobilizeSleepEndMsg(Entity * pokemon, Entity * target) { - asm_unified( - "\tpush {r4-r6,lr}\n" - "\tadds r6, r0, 0\n" - "\tadds r4, r1, 0\n" - "\tldr r0, [r4, 0x70]\n" - "\tadds r5, r0, 0\n" - "\tmovs r2, 0\n" - "\tadds r0, 0xB0\n" - "\tldrb r0, [r0]\n" - "\tcmp r0, 0x6\n" - "\tbne _0807A988\n" - "\tadds r0, r6, 0\n" - "\tbl SendImmobilizeEndMessage\n" - "\tmovs r2, 0x1\n" -"_0807A988:\n" - "\tadds r0, r5, 0\n" - "\tadds r0, 0xA8\n" - "\tldrh r1, [r0]\n" - "\tldr r0, _0807A9AC\n" - "\tcmp r1, r0\n" - "\tbne _0807A9A2\n" - "\tadds r0, r6, 0\n" - "\tadds r1, r4, 0\n" - "\tmovs r2, 0\n" - "\tmovs r3, 0x1\n" - "\tbl SendSleepEndMessage\n" - "\tmovs r2, 0x1\n" -"_0807A9A2:\n" - "\tadds r0, r2, 0\n" - "\tpop {r4-r6}\n" - "\tpop {r1}\n" - "\tbx r1\n" - "\t.align 2, 0\n" -"_0807A9AC: .4byte 0x00007f01"); + // entityInfoMatch needed to match + EntityInfo *entityInfoMatch = target->info; + EntityInfo *entityInfo = entityInfoMatch; + bool32 msg = FALSE; + + if (entityInfo->immobilize.immobilizeStatus == STATUS_PETRIFIED) { + SendImmobilizeEndMessage(pokemon, target); + msg = TRUE; + } + if (entityInfo->sleep.sleep == STATUS_SLEEP && entityInfo->sleep.sleepTurns == 0x7f) { + SendSleepEndMessage(pokemon,target, FALSE, TRUE); + msg = TRUE; + } + return msg; } void WakeUpPokemon(Entity * pokemon) diff --git a/src/move_actions.c b/src/move_actions.c index bc64a6da4..c555bc91f 100644 --- a/src/move_actions.c +++ b/src/move_actions.c @@ -222,7 +222,7 @@ extern void sub_806F370(Entity *r0, Entity *r1, u32, u32, u8 *, u8, s32, u32, u3 extern u32 sub_8055640(Entity *, Entity *, Move *, u32, u32); u8 sub_8057620(u32 param_1); extern s16 sub_8094828(u16, u8); -extern void sub_806F324(Entity *, s32, u32, u32); +extern void DealDamageToEntity(Entity *, s32, u32, u32); extern s16 gUnknown_80F4DB4; extern u32 gUnknown_8106A4C; @@ -1198,7 +1198,7 @@ bool8 sub_80586DC(Entity * pokemon, Entity * target, Move * move, u32 param_4) entityInfo->unkFB = TRUE; } if (hasLiquidOoze) { - sub_806F324(pokemon, newHP, 0xd, 0x1fa); + DealDamageToEntity(pokemon, newHP, 0xd, 0x1fa); } else { HealTargetHP(pokemon, pokemon, newHP, 0, TRUE); @@ -1771,7 +1771,7 @@ bool8 sub_80591E4(Entity *pokemon, Entity *target, Move *move, s32 param_4) } if (sub_8057308(pokemon,0)) { if (hasLiquidOoze) { - sub_806F324(pokemon,iVar4,0xd,0x1fa); + DealDamageToEntity(pokemon,iVar4,0xd,0x1fa); } else { HealTargetHP(pokemon,pokemon,iVar4,0,1); diff --git a/src/status_actions.c b/src/status_actions.c index 02a7cb300..d60ca77f7 100644 --- a/src/status_actions.c +++ b/src/status_actions.c @@ -80,7 +80,7 @@ extern void WrapTarget(Entity *, Entity *); extern void SqueezedStatusTarget(Entity *, Entity *, s32, bool32); extern void sub_8075C58(Entity *, Entity *, s32, s32); -extern void sub_806F324(Entity *, s32, u32, u32); +extern void DealDamageToEntity(Entity *, s32, u32, u32); extern bool8 sub_805755C(Entity* pokemon,u16 moveID); extern void sub_80783C4(Entity *, Entity *, u32); extern void sub_807CD9C(Entity *, Entity *, u32 direction); @@ -558,7 +558,7 @@ bool8 sub_805B668(Entity * pokemon, Entity * target, Move *move, s32 param_4) } if (sub_8057308(pokemon,0) != 0) { if (hasLiquidOoze) { - sub_806F324(pokemon,newHP,0xd,0x1fa); + DealDamageToEntity(pokemon,newHP,0xd,0x1fa); } else { HealTargetHP(pokemon,pokemon,newHP,0,TRUE); diff --git a/src/trap.c b/src/trap.c index b85585b8e..f5c58711c 100644 --- a/src/trap.c +++ b/src/trap.c @@ -76,7 +76,7 @@ void sub_8068FE0(Entity *, u32, Entity *); void sub_805239C(Entity *, u8 *); void sub_8045C28(Item *, u8 , u8); void sub_8045BF8(u8 *, Item *); -void sub_806F324(Entity *,s16,u32,u32); +void DealDamageToEntity(Entity *,s16,u32,u32); void sub_806F480(Entity *, u32); extern void sub_80421C0(Entity *, u32); void sub_804225C(Entity *, Position *, u8); @@ -349,7 +349,7 @@ void sub_807FE9C(Entity *pokemon, Position *pos, int param_3, char param_4) break; case TRAP_CHESTNUT_TRAP: if (target != NULL) { - sub_806F324(target,gUnknown_80F4F86,0xf,0x213); + DealDamageToEntity(target,gUnknown_80F4F86,0xf,0x213); } break; case TRAP_WONDER_TILE: @@ -361,7 +361,7 @@ void sub_807FE9C(Entity *pokemon, Position *pos, int param_3, char param_4) break; case TRAP_SPIKE_TRAP: if (target != NULL) { - sub_806F324(target,gUnknown_80F4F84,10,0x206); + DealDamageToEntity(target,gUnknown_80F4F84,10,0x206); } } if (EntityExists(target)) { @@ -560,7 +560,7 @@ void HandlePitfallTrap(Entity *pokemon, Entity *target, Tile *tile) info->unk15C = 1; info->unk15E = 1; sub_803E708(0x28,0x4b); - sub_806F324(target,gUnknown_80F4F8A,0x11,0x215); + DealDamageToEntity(target,gUnknown_80F4F8A,0x11,0x215); gDungeon->unk2 = 2; return; }