diff --git a/asm/nonmatchings/code_1A5830/SetTargetOffset.s b/asm/nonmatchings/code_1A5830/SetTargetOffset.s deleted file mode 100644 index 05538cceb0..0000000000 --- a/asm/nonmatchings/code_1A5830/SetTargetOffset.s +++ /dev/null @@ -1,50 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel SetTargetOffset -/* 1ABC60 8027D380 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 1ABC64 8027D384 AFB3001C */ sw $s3, 0x1c($sp) -/* 1ABC68 8027D388 0080982D */ daddu $s3, $a0, $zero -/* 1ABC6C 8027D38C AFBF0020 */ sw $ra, 0x20($sp) -/* 1ABC70 8027D390 AFB20018 */ sw $s2, 0x18($sp) -/* 1ABC74 8027D394 AFB10014 */ sw $s1, 0x14($sp) -/* 1ABC78 8027D398 AFB00010 */ sw $s0, 0x10($sp) -/* 1ABC7C 8027D39C 8E72000C */ lw $s2, 0xc($s3) -/* 1ABC80 8027D3A0 8E450000 */ lw $a1, ($s2) -/* 1ABC84 8027D3A4 0C0B1EAF */ jal get_variable -/* 1ABC88 8027D3A8 26520004 */ addiu $s2, $s2, 4 -/* 1ABC8C 8027D3AC 0040802D */ daddu $s0, $v0, $zero -/* 1ABC90 8027D3B0 2402FF81 */ addiu $v0, $zero, -0x7f -/* 1ABC94 8027D3B4 16020002 */ bne $s0, $v0, .L8027D3C0 -/* 1ABC98 8027D3B8 00000000 */ nop -/* 1ABC9C 8027D3BC 8E700148 */ lw $s0, 0x148($s3) -.L8027D3C0: -/* 1ABCA0 8027D3C0 8E450000 */ lw $a1, ($s2) -/* 1ABCA4 8027D3C4 26520004 */ addiu $s2, $s2, 4 -/* 1ABCA8 8027D3C8 0C0B1EAF */ jal get_variable -/* 1ABCAC 8027D3CC 0260202D */ daddu $a0, $s3, $zero -/* 1ABCB0 8027D3D0 0200202D */ daddu $a0, $s0, $zero -/* 1ABCB4 8027D3D4 0C09A75B */ jal get_actor -/* 1ABCB8 8027D3D8 0040802D */ daddu $s0, $v0, $zero -/* 1ABCBC 8027D3DC 0040202D */ daddu $a0, $v0, $zero -/* 1ABCC0 8027D3E0 0C099117 */ jal get_actor_part -/* 1ABCC4 8027D3E4 0200282D */ daddu $a1, $s0, $zero -/* 1ABCC8 8027D3E8 8E450000 */ lw $a1, ($s2) -/* 1ABCCC 8027D3EC 26520004 */ addiu $s2, $s2, 4 -/* 1ABCD0 8027D3F0 0260202D */ daddu $a0, $s3, $zero -/* 1ABCD4 8027D3F4 0C0B1EAF */ jal get_variable -/* 1ABCD8 8027D3F8 0040882D */ daddu $s1, $v0, $zero -/* 1ABCDC 8027D3FC 0260202D */ daddu $a0, $s3, $zero -/* 1ABCE0 8027D400 8E450000 */ lw $a1, ($s2) -/* 1ABCE4 8027D404 0C0B1EAF */ jal get_variable -/* 1ABCE8 8027D408 0040802D */ daddu $s0, $v0, $zero -/* 1ABCEC 8027D40C A622006E */ sh $v0, 0x6e($s1) -/* 1ABCF0 8027D410 A630006C */ sh $s0, 0x6c($s1) -/* 1ABCF4 8027D414 8FBF0020 */ lw $ra, 0x20($sp) -/* 1ABCF8 8027D418 8FB3001C */ lw $s3, 0x1c($sp) -/* 1ABCFC 8027D41C 8FB20018 */ lw $s2, 0x18($sp) -/* 1ABD00 8027D420 8FB10014 */ lw $s1, 0x14($sp) -/* 1ABD04 8027D424 8FB00010 */ lw $s0, 0x10($sp) -/* 1ABD08 8027D428 24020002 */ addiu $v0, $zero, 2 -/* 1ABD0C 8027D42C 03E00008 */ jr $ra -/* 1ABD10 8027D430 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/asm/nonmatchings/code_1A5830/WasStatusInflicted.s b/asm/nonmatchings/code_1A5830/WasStatusInflicted.s deleted file mode 100644 index 5ced25630e..0000000000 --- a/asm/nonmatchings/code_1A5830/WasStatusInflicted.s +++ /dev/null @@ -1,25 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel WasStatusInflicted -/* 1AC548 8027DC68 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 1AC54C 8027DC6C AFB10014 */ sw $s1, 0x14($sp) -/* 1AC550 8027DC70 0080882D */ daddu $s1, $a0, $zero -/* 1AC554 8027DC74 AFBF0018 */ sw $ra, 0x18($sp) -/* 1AC558 8027DC78 AFB00010 */ sw $s0, 0x10($sp) -/* 1AC55C 8027DC7C 8E30000C */ lw $s0, 0xc($s1) -/* 1AC560 8027DC80 8E050000 */ lw $a1, ($s0) -/* 1AC564 8027DC84 0C0B1EAF */ jal get_variable -/* 1AC568 8027DC88 26100004 */ addiu $s0, $s0, 4 -/* 1AC56C 8027DC8C 3C02800E */ lui $v0, %hi(gBattleStatus) -/* 1AC570 8027DC90 2442C070 */ addiu $v0, $v0, %lo(gBattleStatus) -/* 1AC574 8027DC94 8E050000 */ lw $a1, ($s0) -/* 1AC578 8027DC98 80460199 */ lb $a2, 0x199($v0) -/* 1AC57C 8027DC9C 0C0B2026 */ jal set_variable -/* 1AC580 8027DCA0 0220202D */ daddu $a0, $s1, $zero -/* 1AC584 8027DCA4 8FBF0018 */ lw $ra, 0x18($sp) -/* 1AC588 8027DCA8 8FB10014 */ lw $s1, 0x14($sp) -/* 1AC58C 8027DCAC 8FB00010 */ lw $s0, 0x10($sp) -/* 1AC590 8027DCB0 24020002 */ addiu $v0, $zero, 2 -/* 1AC594 8027DCB4 03E00008 */ jr $ra -/* 1AC598 8027DCB8 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_1A5830/func_8027D4C8.s b/asm/nonmatchings/code_1A5830/func_8027D4C8.s deleted file mode 100644 index 2518b24209..0000000000 --- a/asm/nonmatchings/code_1A5830/func_8027D4C8.s +++ /dev/null @@ -1,50 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel func_8027D4C8 -/* 1ABDA8 8027D4C8 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 1ABDAC 8027D4CC AFB3001C */ sw $s3, 0x1c($sp) -/* 1ABDB0 8027D4D0 0080982D */ daddu $s3, $a0, $zero -/* 1ABDB4 8027D4D4 AFBF0020 */ sw $ra, 0x20($sp) -/* 1ABDB8 8027D4D8 AFB20018 */ sw $s2, 0x18($sp) -/* 1ABDBC 8027D4DC AFB10014 */ sw $s1, 0x14($sp) -/* 1ABDC0 8027D4E0 AFB00010 */ sw $s0, 0x10($sp) -/* 1ABDC4 8027D4E4 8E72000C */ lw $s2, 0xc($s3) -/* 1ABDC8 8027D4E8 8E450000 */ lw $a1, ($s2) -/* 1ABDCC 8027D4EC 0C0B1EAF */ jal get_variable -/* 1ABDD0 8027D4F0 26520004 */ addiu $s2, $s2, 4 -/* 1ABDD4 8027D4F4 0040802D */ daddu $s0, $v0, $zero -/* 1ABDD8 8027D4F8 2402FF81 */ addiu $v0, $zero, -0x7f -/* 1ABDDC 8027D4FC 16020002 */ bne $s0, $v0, .L8027D508 -/* 1ABDE0 8027D500 00000000 */ nop -/* 1ABDE4 8027D504 8E700148 */ lw $s0, 0x148($s3) -.L8027D508: -/* 1ABDE8 8027D508 8E450000 */ lw $a1, ($s2) -/* 1ABDEC 8027D50C 26520004 */ addiu $s2, $s2, 4 -/* 1ABDF0 8027D510 0C0B1EAF */ jal get_variable -/* 1ABDF4 8027D514 0260202D */ daddu $a0, $s3, $zero -/* 1ABDF8 8027D518 0200202D */ daddu $a0, $s0, $zero -/* 1ABDFC 8027D51C 0C09A75B */ jal get_actor -/* 1ABE00 8027D520 0040802D */ daddu $s0, $v0, $zero -/* 1ABE04 8027D524 0040202D */ daddu $a0, $v0, $zero -/* 1ABE08 8027D528 0C099117 */ jal get_actor_part -/* 1ABE0C 8027D52C 0200282D */ daddu $a1, $s0, $zero -/* 1ABE10 8027D530 8E450000 */ lw $a1, ($s2) -/* 1ABE14 8027D534 26520004 */ addiu $s2, $s2, 4 -/* 1ABE18 8027D538 0260202D */ daddu $a0, $s3, $zero -/* 1ABE1C 8027D53C 0C0B1EAF */ jal get_variable -/* 1ABE20 8027D540 0040882D */ daddu $s1, $v0, $zero -/* 1ABE24 8027D544 0260202D */ daddu $a0, $s3, $zero -/* 1ABE28 8027D548 8E450000 */ lw $a1, ($s2) -/* 1ABE2C 8027D54C 0C0B1EAF */ jal get_variable -/* 1ABE30 8027D550 0040802D */ daddu $s0, $v0, $zero -/* 1ABE34 8027D554 A2220076 */ sb $v0, 0x76($s1) -/* 1ABE38 8027D558 A2300075 */ sb $s0, 0x75($s1) -/* 1ABE3C 8027D55C 8FBF0020 */ lw $ra, 0x20($sp) -/* 1ABE40 8027D560 8FB3001C */ lw $s3, 0x1c($sp) -/* 1ABE44 8027D564 8FB20018 */ lw $s2, 0x18($sp) -/* 1ABE48 8027D568 8FB10014 */ lw $s1, 0x14($sp) -/* 1ABE4C 8027D56C 8FB00010 */ lw $s0, 0x10($sp) -/* 1ABE50 8027D570 24020002 */ addiu $v0, $zero, 2 -/* 1ABE54 8027D574 03E00008 */ jr $ra -/* 1ABE58 8027D578 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/include/common_structs.h b/include/common_structs.h index 6b91843409..386644c345 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1093,7 +1093,9 @@ typedef struct ActorPart { /* 0x70 */ s16 unk_70; /* 0x72 */ u8 size[2]; /* 0x74 */ u8 verticalStretch; - /* 0x75 */ char unk_75[3]; + /* 0x75 */ s8 unk_75; + /* 0x76 */ s8 unk_76; + /* 0x77 */ char unk_77[1]; /* 0x78 */ u32* defenseTable; /* 0x7C */ s32 eventFlags; /* 0x80 */ s32 partFlags3; diff --git a/src/code_1A5830.c b/src/code_1A5830.c index 29ffdf7a7a..80085ba50d 100644 --- a/src/code_1A5830.c +++ b/src/code_1A5830.c @@ -232,7 +232,38 @@ ApiStatus SetTargetActor(ScriptInstance* script, s32 isInitialCall) { INCLUDE_ASM(s32, "code_1A5830", SetEnemyHP); +#ifdef NON_MATCHING +ApiStatus GetActorHP(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + PlayerData* playerData = PLAYER_DATA; + ActorID actorID = get_variable(script, *args++); + Actor* actor; + s32 outVar; + s32 outVal; + + if (actorID == ActorID_SELF) { + actorID = script->owner1.actorID; + } + outVar = *args++; + + actor = get_actor(actorID); + + if (actorID & 0x700) { + if (actorID == ActorID_PARTNER) { + outVal = 99; + } else { + outVal = actor->currentHP; + } + } else { + outVal = playerData->curHP; + } + + set_variable(script, outVar, outVal); + return ApiStatus_DONE2; +} +#else INCLUDE_ASM(s32, "code_1A5830", GetActorHP); +#endif ApiStatus GetEnemyMaxHP(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -379,7 +410,29 @@ ApiStatus func_8027D32C(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "code_1A5830", SetTargetOffset); +ApiStatus SetTargetOffset(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + ActorID actorID = get_variable(script, *args++); + s32 partIndex; + ActorPart* part; + s32 x; + s32 y; + + if (actorID == ActorID_SELF) { + actorID = script->owner1.actorID; + } + + partIndex = get_variable(script, *args++); + part = get_actor_part(get_actor(actorID), partIndex); + + x = get_variable(script, *args++); + y = get_variable(script, *args++); + + part->targetOffset.x = x; + part->targetOffset.y = y; + + return ApiStatus_DONE2; +} ApiStatus func_8027D434(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -397,7 +450,29 @@ ApiStatus func_8027D434(ScriptInstance* script, s32 isInitialCall) { return ApiStatus_DONE2; } -INCLUDE_ASM(s32, "code_1A5830", func_8027D4C8); +ApiStatus func_8027D4C8(ScriptInstance* script, s32 isInitialCall) { + Bytecode* args = script->ptrReadPos; + ActorID actorID = get_variable(script, *args++); + s32 partIndex; + ActorPart* part; + s32 temp; + s32 temp2; + + if (actorID == ActorID_SELF) { + actorID = script->owner1.actorID; + } + + partIndex = get_variable(script, *args++); + part = get_actor_part(get_actor(actorID), partIndex); + + temp = get_variable(script, *args++); + temp2 = get_variable(script, *args++); + + part->unk_75 = temp; + part->unk_76 = temp2; + + return ApiStatus_DONE2; +} ApiStatus EnableActorBlur(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; @@ -520,19 +595,22 @@ ApiStatus GetLastDamage(ScriptInstance* script, s32 isInitialCall) { INCLUDE_ASM(s32, "code_1A5830", EnableActorGlow); -// Cannot get gBattleStatus to load via lui+addiu no matter what I do -#ifdef NON_MATCHING ApiStatus WasStatusInflicted(ScriptInstance* script, s32 isInitialCall) { Bytecode* args = script->ptrReadPos; + BattleStatus* battleStatus = BATTLE_STATUS; + s32 outVal; get_variable(script, *args++); - set_variable(script, *args++, gBattleStatus.wasStatusInflicted); + + if (script) { // can be args or script but not 1 or do while 0, nor does else work after + outVal = battleStatus->wasStatusInflicted; + } + outVal = battleStatus->wasStatusInflicted; + + set_variable(script, *args++, outVal); return ApiStatus_DONE2; } -#else -INCLUDE_ASM(s32, "code_1A5830", WasStatusInflicted); -#endif INCLUDE_ASM(s32, "code_1A5830", CopyStatusEffects);