From 67b516d3d24d6e6a564dbe141d155146a0686ebb Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Fri, 16 Oct 2020 18:23:52 -0400 Subject: [PATCH] :arrow: --- .../code_190B20/add_actor_decoration.s | 41 ---- asm/nonmatchings/code_190B20/get_defense.s | 155 ------------- .../code_190B20/remove_player_buffs.s | 217 ------------------ include/common_structs.h | 39 +++- src/code_190B20.c | 163 ++++++++++++- 5 files changed, 188 insertions(+), 427 deletions(-) delete mode 100644 asm/nonmatchings/code_190B20/add_actor_decoration.s delete mode 100644 asm/nonmatchings/code_190B20/get_defense.s delete mode 100644 asm/nonmatchings/code_190B20/remove_player_buffs.s diff --git a/asm/nonmatchings/code_190B20/add_actor_decoration.s b/asm/nonmatchings/code_190B20/add_actor_decoration.s deleted file mode 100644 index 7a09ec251a..0000000000 --- a/asm/nonmatchings/code_190B20/add_actor_decoration.s +++ /dev/null @@ -1,41 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel add_actor_decoration -/* 195A70 80267190 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 195A74 80267194 AFB20018 */ sw $s2, 0x18($sp) -/* 195A78 80267198 00A0902D */ daddu $s2, $a1, $zero -/* 195A7C 8026719C AFBF0020 */ sw $ra, 0x20($sp) -/* 195A80 802671A0 AFB3001C */ sw $s3, 0x1c($sp) -/* 195A84 802671A4 AFB10014 */ sw $s1, 0x14($sp) -/* 195A88 802671A8 AFB00010 */ sw $s0, 0x10($sp) -/* 195A8C 802671AC 8C9001F4 */ lw $s0, 0x1f4($a0) -/* 195A90 802671B0 12000012 */ beqz $s0, .L802671FC -/* 195A94 802671B4 00C0982D */ daddu $s3, $a2, $zero -/* 195A98 802671B8 3C110010 */ lui $s1, 0x10 -/* 195A9C 802671BC 36310001 */ ori $s1, $s1, 1 -.L802671C0: -/* 195AA0 802671C0 8E030000 */ lw $v1, ($s0) -/* 195AA4 802671C4 00711024 */ and $v0, $v1, $s1 -/* 195AA8 802671C8 14400009 */ bnez $v0, .L802671F0 -/* 195AAC 802671CC 00000000 */ nop -/* 195AB0 802671D0 8E020094 */ lw $v0, 0x94($s0) -/* 195AB4 802671D4 10400006 */ beqz $v0, .L802671F0 -/* 195AB8 802671D8 30620002 */ andi $v0, $v1, 2 -/* 195ABC 802671DC 14400004 */ bnez $v0, .L802671F0 -/* 195AC0 802671E0 0200202D */ daddu $a0, $s0, $zero -/* 195AC4 802671E4 0240282D */ daddu $a1, $s2, $zero -/* 195AC8 802671E8 0C099C45 */ jal add_part_decoration -/* 195ACC 802671EC 0260302D */ daddu $a2, $s3, $zero -.L802671F0: -/* 195AD0 802671F0 8E10000C */ lw $s0, 0xc($s0) -/* 195AD4 802671F4 1600FFF2 */ bnez $s0, .L802671C0 -/* 195AD8 802671F8 00000000 */ nop -.L802671FC: -/* 195ADC 802671FC 8FBF0020 */ lw $ra, 0x20($sp) -/* 195AE0 80267200 8FB3001C */ lw $s3, 0x1c($sp) -/* 195AE4 80267204 8FB20018 */ lw $s2, 0x18($sp) -/* 195AE8 80267208 8FB10014 */ lw $s1, 0x14($sp) -/* 195AEC 8026720C 8FB00010 */ lw $s0, 0x10($sp) -/* 195AF0 80267210 03E00008 */ jr $ra -/* 195AF4 80267214 27BD0028 */ addiu $sp, $sp, 0x28 diff --git a/asm/nonmatchings/code_190B20/get_defense.s b/asm/nonmatchings/code_190B20/get_defense.s deleted file mode 100644 index 07590070a6..0000000000 --- a/asm/nonmatchings/code_190B20/get_defense.s +++ /dev/null @@ -1,155 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel get_defense -/* 194B9C 802662BC 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 194BA0 802662C0 AFB10014 */ sw $s1, 0x14($sp) -/* 194BA4 802662C4 00A0882D */ daddu $s1, $a1, $zero -/* 194BA8 802662C8 AFB20018 */ sw $s2, 0x18($sp) -/* 194BAC 802662CC 00C0902D */ daddu $s2, $a2, $zero -/* 194BB0 802662D0 AFB00010 */ sw $s0, 0x10($sp) -/* 194BB4 802662D4 241000FF */ addiu $s0, $zero, 0xff -/* 194BB8 802662D8 12200065 */ beqz $s1, .L80266470 -/* 194BBC 802662DC AFBF001C */ sw $ra, 0x1c($sp) -/* 194BC0 802662E0 32420002 */ andi $v0, $s2, 2 -/* 194BC4 802662E4 10400007 */ beqz $v0, .L80266304 -/* 194BC8 802662E8 0220202D */ daddu $a0, $s1, $zero -/* 194BCC 802662EC 0C099791 */ jal lookup_defense -/* 194BD0 802662F0 24050002 */ addiu $a1, $zero, 2 -/* 194BD4 802662F4 0040182D */ daddu $v1, $v0, $zero -/* 194BD8 802662F8 0070102A */ slt $v0, $v1, $s0 -/* 194BDC 802662FC 54400001 */ bnel $v0, $zero, .L80266304 -/* 194BE0 80266300 0060802D */ daddu $s0, $v1, $zero -.L80266304: -/* 194BE4 80266304 32420004 */ andi $v0, $s2, 4 -/* 194BE8 80266308 10400007 */ beqz $v0, .L80266328 -/* 194BEC 8026630C 0220202D */ daddu $a0, $s1, $zero -/* 194BF0 80266310 0C099791 */ jal lookup_defense -/* 194BF4 80266314 24050003 */ addiu $a1, $zero, 3 -/* 194BF8 80266318 0040182D */ daddu $v1, $v0, $zero -/* 194BFC 8026631C 0070102A */ slt $v0, $v1, $s0 -/* 194C00 80266320 54400001 */ bnel $v0, $zero, .L80266328 -/* 194C04 80266324 0060802D */ daddu $s0, $v1, $zero -.L80266328: -/* 194C08 80266328 32420008 */ andi $v0, $s2, 8 -/* 194C0C 8026632C 10400007 */ beqz $v0, .L8026634C -/* 194C10 80266330 0220202D */ daddu $a0, $s1, $zero -/* 194C14 80266334 0C099791 */ jal lookup_defense -/* 194C18 80266338 24050004 */ addiu $a1, $zero, 4 -/* 194C1C 8026633C 0040182D */ daddu $v1, $v0, $zero -/* 194C20 80266340 0070102A */ slt $v0, $v1, $s0 -/* 194C24 80266344 54400001 */ bnel $v0, $zero, .L8026634C -/* 194C28 80266348 0060802D */ daddu $s0, $v1, $zero -.L8026634C: -/* 194C2C 8026634C 32420010 */ andi $v0, $s2, 0x10 -/* 194C30 80266350 10400007 */ beqz $v0, .L80266370 -/* 194C34 80266354 0220202D */ daddu $a0, $s1, $zero -/* 194C38 80266358 0C099791 */ jal lookup_defense -/* 194C3C 8026635C 24050007 */ addiu $a1, $zero, 7 -/* 194C40 80266360 0040182D */ daddu $v1, $v0, $zero -/* 194C44 80266364 0070102A */ slt $v0, $v1, $s0 -/* 194C48 80266368 54400001 */ bnel $v0, $zero, .L80266370 -/* 194C4C 8026636C 0060802D */ daddu $s0, $v1, $zero -.L80266370: -/* 194C50 80266370 32420040 */ andi $v0, $s2, 0x40 -/* 194C54 80266374 10400007 */ beqz $v0, .L80266394 -/* 194C58 80266378 0220202D */ daddu $a0, $s1, $zero -/* 194C5C 8026637C 0C099791 */ jal lookup_defense -/* 194C60 80266380 24050008 */ addiu $a1, $zero, 8 -/* 194C64 80266384 0040182D */ daddu $v1, $v0, $zero -/* 194C68 80266388 0070102A */ slt $v0, $v1, $s0 -/* 194C6C 8026638C 54400001 */ bnel $v0, $zero, .L80266394 -/* 194C70 80266390 0060802D */ daddu $s0, $v1, $zero -.L80266394: -/* 194C74 80266394 32420080 */ andi $v0, $s2, 0x80 -/* 194C78 80266398 10400007 */ beqz $v0, .L802663B8 -/* 194C7C 8026639C 0220202D */ daddu $a0, $s1, $zero -/* 194C80 802663A0 0C099791 */ jal lookup_defense -/* 194C84 802663A4 24050009 */ addiu $a1, $zero, 9 -/* 194C88 802663A8 0040182D */ daddu $v1, $v0, $zero -/* 194C8C 802663AC 0070102A */ slt $v0, $v1, $s0 -/* 194C90 802663B0 54400001 */ bnel $v0, $zero, .L802663B8 -/* 194C94 802663B4 0060802D */ daddu $s0, $v1, $zero -.L802663B8: -/* 194C98 802663B8 32420100 */ andi $v0, $s2, 0x100 -/* 194C9C 802663BC 10400007 */ beqz $v0, .L802663DC -/* 194CA0 802663C0 0220202D */ daddu $a0, $s1, $zero -/* 194CA4 802663C4 0C099791 */ jal lookup_defense -/* 194CA8 802663C8 2405000A */ addiu $a1, $zero, 0xa -/* 194CAC 802663CC 0040182D */ daddu $v1, $v0, $zero -/* 194CB0 802663D0 0070102A */ slt $v0, $v1, $s0 -/* 194CB4 802663D4 54400001 */ bnel $v0, $zero, .L802663DC -/* 194CB8 802663D8 0060802D */ daddu $s0, $v1, $zero -.L802663DC: -/* 194CBC 802663DC 32420200 */ andi $v0, $s2, 0x200 -/* 194CC0 802663E0 10400007 */ beqz $v0, .L80266400 -/* 194CC4 802663E4 0220202D */ daddu $a0, $s1, $zero -/* 194CC8 802663E8 0C099791 */ jal lookup_defense -/* 194CCC 802663EC 2405000B */ addiu $a1, $zero, 0xb -/* 194CD0 802663F0 0040182D */ daddu $v1, $v0, $zero -/* 194CD4 802663F4 0070102A */ slt $v0, $v1, $s0 -/* 194CD8 802663F8 54400001 */ bnel $v0, $zero, .L80266400 -/* 194CDC 802663FC 0060802D */ daddu $s0, $v1, $zero -.L80266400: -/* 194CE0 80266400 32420020 */ andi $v0, $s2, 0x20 -/* 194CE4 80266404 10400007 */ beqz $v0, .L80266424 -/* 194CE8 80266408 0220202D */ daddu $a0, $s1, $zero -/* 194CEC 8026640C 0C099791 */ jal lookup_defense -/* 194CF0 80266410 2405000C */ addiu $a1, $zero, 0xc -/* 194CF4 80266414 0040182D */ daddu $v1, $v0, $zero -/* 194CF8 80266418 0070102A */ slt $v0, $v1, $s0 -/* 194CFC 8026641C 54400001 */ bnel $v0, $zero, .L80266424 -/* 194D00 80266420 0060802D */ daddu $s0, $v1, $zero -.L80266424: -/* 194D04 80266424 32420800 */ andi $v0, $s2, 0x800 -/* 194D08 80266428 10400007 */ beqz $v0, .L80266448 -/* 194D0C 8026642C 0220202D */ daddu $a0, $s1, $zero -/* 194D10 80266430 0C099791 */ jal lookup_defense -/* 194D14 80266434 2405000D */ addiu $a1, $zero, 0xd -/* 194D18 80266438 0040182D */ daddu $v1, $v0, $zero -/* 194D1C 8026643C 0070102A */ slt $v0, $v1, $s0 -/* 194D20 80266440 54400001 */ bnel $v0, $zero, .L80266448 -/* 194D24 80266444 0060802D */ daddu $s0, $v1, $zero -.L80266448: -/* 194D28 80266448 3C020004 */ lui $v0, 4 -/* 194D2C 8026644C 02421024 */ and $v0, $s2, $v0 -/* 194D30 80266450 10400007 */ beqz $v0, .L80266470 -/* 194D34 80266454 0220202D */ daddu $a0, $s1, $zero -/* 194D38 80266458 0C099791 */ jal lookup_defense -/* 194D3C 8026645C 2405000F */ addiu $a1, $zero, 0xf -/* 194D40 80266460 0040182D */ daddu $v1, $v0, $zero -/* 194D44 80266464 0070102A */ slt $v0, $v1, $s0 -/* 194D48 80266468 54400001 */ bnel $v0, $zero, .L80266470 -/* 194D4C 8026646C 0060802D */ daddu $s0, $v1, $zero -.L80266470: -/* 194D50 80266470 240200FF */ addiu $v0, $zero, 0xff -/* 194D54 80266474 16020009 */ bne $s0, $v0, .L8026649C -/* 194D58 80266478 3C020800 */ lui $v0, 0x800 -/* 194D5C 8026647C 0220202D */ daddu $a0, $s1, $zero -/* 194D60 80266480 0C099791 */ jal lookup_defense -/* 194D64 80266484 24050001 */ addiu $a1, $zero, 1 -/* 194D68 80266488 0040182D */ daddu $v1, $v0, $zero -/* 194D6C 8026648C 286200FF */ slti $v0, $v1, 0xff -/* 194D70 80266490 54400001 */ bnel $v0, $zero, .L80266498 -/* 194D74 80266494 0060802D */ daddu $s0, $v1, $zero -.L80266498: -/* 194D78 80266498 3C020800 */ lui $v0, 0x800 -.L8026649C: -/* 194D7C 8026649C 02421024 */ and $v0, $s2, $v0 -/* 194D80 802664A0 10400007 */ beqz $v0, .L802664C0 -/* 194D84 802664A4 24020063 */ addiu $v0, $zero, 0x63 -/* 194D88 802664A8 16020003 */ bne $s0, $v0, .L802664B8 -/* 194D8C 802664AC 00000000 */ nop -/* 194D90 802664B0 08099930 */ j .L802664C0 -/* 194D94 802664B4 241003E7 */ addiu $s0, $zero, 0x3e7 -.L802664B8: -/* 194D98 802664B8 5E000001 */ bgtzl $s0, .L802664C0 -/* 194D9C 802664BC 0000802D */ daddu $s0, $zero, $zero -.L802664C0: -/* 194DA0 802664C0 0200102D */ daddu $v0, $s0, $zero -/* 194DA4 802664C4 8FBF001C */ lw $ra, 0x1c($sp) -/* 194DA8 802664C8 8FB20018 */ lw $s2, 0x18($sp) -/* 194DAC 802664CC 8FB10014 */ lw $s1, 0x14($sp) -/* 194DB0 802664D0 8FB00010 */ lw $s0, 0x10($sp) -/* 194DB4 802664D4 03E00008 */ jr $ra -/* 194DB8 802664D8 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/nonmatchings/code_190B20/remove_player_buffs.s b/asm/nonmatchings/code_190B20/remove_player_buffs.s deleted file mode 100644 index bc7d22feaf..0000000000 --- a/asm/nonmatchings/code_190B20/remove_player_buffs.s +++ /dev/null @@ -1,217 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel remove_player_buffs -/* 195D34 80267454 27BDFFB8 */ addiu $sp, $sp, -0x48 -/* 195D38 80267458 AFB30024 */ sw $s3, 0x24($sp) -/* 195D3C 8026745C 0080982D */ daddu $s3, $a0, $zero -/* 195D40 80267460 AFB20020 */ sw $s2, 0x20($sp) -/* 195D44 80267464 3C12800E */ lui $s2, %hi(gBattleStatus) -/* 195D48 80267468 2652C070 */ addiu $s2, $s2, %lo(gBattleStatus) -/* 195D4C 8026746C 32620001 */ andi $v0, $s3, 1 -/* 195D50 80267470 AFBF002C */ sw $ra, 0x2c($sp) -/* 195D54 80267474 AFB40028 */ sw $s4, 0x28($sp) -/* 195D58 80267478 AFB1001C */ sw $s1, 0x1c($sp) -/* 195D5C 8026747C AFB00018 */ sw $s0, 0x18($sp) -/* 195D60 80267480 F7B80040 */ sdc1 $f24, 0x40($sp) -/* 195D64 80267484 F7B60038 */ sdc1 $f22, 0x38($sp) -/* 195D68 80267488 F7B40030 */ sdc1 $f20, 0x30($sp) -/* 195D6C 8026748C 8E5100D8 */ lw $s1, 0xd8($s2) -/* 195D70 80267490 8E5400DC */ lw $s4, 0xdc($s2) -/* 195D74 80267494 8E3001F4 */ lw $s0, 0x1f4($s1) -/* 195D78 80267498 10400006 */ beqz $v0, .L802674B4 -/* 195D7C 8026749C 3C03DFFF */ lui $v1, 0xdfff -/* 195D80 802674A0 8E420000 */ lw $v0, ($s2) -/* 195D84 802674A4 3463FFFF */ ori $v1, $v1, 0xffff -/* 195D88 802674A8 A2400097 */ sb $zero, 0x97($s2) -/* 195D8C 802674AC 00431024 */ and $v0, $v0, $v1 -/* 195D90 802674B0 AE420000 */ sw $v0, ($s2) -.L802674B4: -/* 195D94 802674B4 32620002 */ andi $v0, $s3, 2 -/* 195D98 802674B8 10400006 */ beqz $v0, .L802674D4 -/* 195D9C 802674BC 3C03EFFF */ lui $v1, 0xefff -/* 195DA0 802674C0 8E420000 */ lw $v0, ($s2) -/* 195DA4 802674C4 3463FFFF */ ori $v1, $v1, 0xffff -/* 195DA8 802674C8 A2400096 */ sb $zero, 0x96($s2) -/* 195DAC 802674CC 00431024 */ and $v0, $v0, $v1 -/* 195DB0 802674D0 AE420000 */ sw $v0, ($s2) -.L802674D4: -/* 195DB4 802674D4 32620008 */ andi $v0, $s3, 8 -/* 195DB8 802674D8 10400003 */ beqz $v0, .L802674E8 -/* 195DBC 802674DC 32620010 */ andi $v0, $s3, 0x10 -/* 195DC0 802674E0 A2200215 */ sb $zero, 0x215($s1) -/* 195DC4 802674E4 A2200214 */ sb $zero, 0x214($s1) -.L802674E8: -/* 195DC8 802674E8 10400006 */ beqz $v0, .L80267504 -/* 195DCC 802674EC 3C03FBFF */ lui $v1, 0xfbff -/* 195DD0 802674F0 8E420000 */ lw $v0, ($s2) -/* 195DD4 802674F4 3463FFFF */ ori $v1, $v1, 0xffff -/* 195DD8 802674F8 A240008B */ sb $zero, 0x8b($s2) -/* 195DDC 802674FC 00431024 */ and $v0, $v0, $v1 -/* 195DE0 80267500 AE420000 */ sw $v0, ($s2) -.L80267504: -/* 195DE4 80267504 32620020 */ andi $v0, $s3, 0x20 -/* 195DE8 80267508 10400009 */ beqz $v0, .L80267530 -/* 195DEC 8026750C 32620040 */ andi $v0, $s3, 0x40 -/* 195DF0 80267510 82220212 */ lb $v0, 0x212($s1) -/* 195DF4 80267514 10400006 */ beqz $v0, .L80267530 -/* 195DF8 80267518 32620040 */ andi $v0, $s3, 0x40 -/* 195DFC 8026751C 86240436 */ lh $a0, 0x436($s1) -/* 195E00 80267520 A2200213 */ sb $zero, 0x213($s1) -/* 195E04 80267524 0C011E68 */ jal func_800479A0 -/* 195E08 80267528 A2200212 */ sb $zero, 0x212($s1) -/* 195E0C 8026752C 32620040 */ andi $v0, $s3, 0x40 -.L80267530: -/* 195E10 80267530 1040000C */ beqz $v0, .L80267564 -/* 195E14 80267534 32620200 */ andi $v0, $s3, 0x200 -/* 195E18 80267538 82220218 */ lb $v0, 0x218($s1) -/* 195E1C 8026753C 10400008 */ beqz $v0, .L80267560 -/* 195E20 80267540 2403FEFF */ addiu $v1, $zero, -0x101 -/* 195E24 80267544 A2200219 */ sb $zero, 0x219($s1) -/* 195E28 80267548 A2200218 */ sb $zero, 0x218($s1) -/* 195E2C 8026754C 8E020000 */ lw $v0, ($s0) -/* 195E30 80267550 00431024 */ and $v0, $v0, $v1 -/* 195E34 80267554 AE020000 */ sw $v0, ($s0) -/* 195E38 80267558 0C011EAA */ jal func_80047AA8 -/* 195E3C 8026755C 86240436 */ lh $a0, 0x436($s1) -.L80267560: -/* 195E40 80267560 32620200 */ andi $v0, $s3, 0x200 -.L80267564: -/* 195E44 80267564 10400058 */ beqz $v0, .L802676C8 -/* 195E48 80267568 32620100 */ andi $v0, $s3, 0x100 -/* 195E4C 8026756C 8242009D */ lb $v0, 0x9d($s2) -/* 195E50 80267570 10400055 */ beqz $v0, .L802676C8 -/* 195E54 80267574 32620100 */ andi $v0, $s3, 0x100 -/* 195E58 80267578 8E42043C */ lw $v0, 0x43c($s2) -/* 195E5C 8026757C 3C013FC0 */ lui $at, 0x3fc0 -/* 195E60 80267580 44811000 */ mtc1 $at, $f2 -/* 195E64 80267584 A240009D */ sb $zero, 0x9d($s2) -/* 195E68 80267588 8C42000C */ lw $v0, 0xc($v0) -/* 195E6C 8026758C A4400010 */ sh $zero, 0x10($v0) -/* 195E70 80267590 8E4300A0 */ lw $v1, 0xa0($s2) -/* 195E74 80267594 3C014190 */ lui $at, 0x4190 -/* 195E78 80267598 44810000 */ mtc1 $at, $f0 -/* 195E7C 8026759C 8C620000 */ lw $v0, ($v1) -/* 195E80 802675A0 3C0140A0 */ lui $at, 0x40a0 -/* 195E84 802675A4 4481A000 */ mtc1 $at, $f20 -/* 195E88 802675A8 34420010 */ ori $v0, $v0, 0x10 -/* 195E8C 802675AC AC620000 */ sw $v0, ($v1) -/* 195E90 802675B0 2402000A */ addiu $v0, $zero, 0xa -/* 195E94 802675B4 C6240148 */ lwc1 $f4, 0x148($s1) -/* 195E98 802675B8 C626014C */ lwc1 $f6, 0x14c($s1) -/* 195E9C 802675BC 46002100 */ add.s $f4, $f4, $f0 -/* 195EA0 802675C0 E7A20010 */ swc1 $f2, 0x10($sp) -/* 195EA4 802675C4 AFA20014 */ sw $v0, 0x14($sp) -/* 195EA8 802675C8 46143180 */ add.s $f6, $f6, $f20 -/* 195EAC 802675CC 8E250144 */ lw $a1, 0x144($s1) -/* 195EB0 802675D0 44062000 */ mfc1 $a2, $f4 -/* 195EB4 802675D4 44073000 */ mfc1 $a3, $f6 -/* 195EB8 802675D8 0C01C694 */ jal func_80071A50 -/* 195EBC 802675DC 24040001 */ addiu $a0, $zero, 1 -/* 195EC0 802675E0 C6220144 */ lwc1 $f2, 0x144($s1) -/* 195EC4 802675E4 3C014120 */ lui $at, 0x4120 -/* 195EC8 802675E8 44810000 */ mtc1 $at, $f0 -/* 195ECC 802675EC 00000000 */ nop -/* 195ED0 802675F0 46001081 */ sub.s $f2, $f2, $f0 -/* 195ED4 802675F4 C6200148 */ lwc1 $f0, 0x148($s1) -/* 195ED8 802675F8 46140000 */ add.s $f0, $f0, $f20 -/* 195EDC 802675FC 44060000 */ mfc1 $a2, $f0 -/* 195EE0 80267600 C620014C */ lwc1 $f0, 0x14c($s1) -/* 195EE4 80267604 0000202D */ daddu $a0, $zero, $zero -/* 195EE8 80267608 46140000 */ add.s $f0, $f0, $f20 -/* 195EEC 8026760C 3C013F80 */ lui $at, 0x3f80 -/* 195EF0 80267610 4481B000 */ mtc1 $at, $f22 -/* 195EF4 80267614 44051000 */ mfc1 $a1, $f2 -/* 195EF8 80267618 44070000 */ mfc1 $a3, $f0 -/* 195EFC 8026761C 24100018 */ addiu $s0, $zero, 0x18 -/* 195F00 80267620 E7B60010 */ swc1 $f22, 0x10($sp) -/* 195F04 80267624 0C01C70C */ jal func_80071C30 -/* 195F08 80267628 AFB00014 */ sw $s0, 0x14($sp) -/* 195F0C 8026762C C6200144 */ lwc1 $f0, 0x144($s1) -/* 195F10 80267630 3C014170 */ lui $at, 0x4170 -/* 195F14 80267634 4481C000 */ mtc1 $at, $f24 -/* 195F18 80267638 00000000 */ nop -/* 195F1C 8026763C 46180001 */ sub.s $f0, $f0, $f24 -/* 195F20 80267640 C6220148 */ lwc1 $f2, 0x148($s1) -/* 195F24 80267644 44050000 */ mfc1 $a1, $f0 -/* 195F28 80267648 3C014200 */ lui $at, 0x4200 -/* 195F2C 8026764C 44810000 */ mtc1 $at, $f0 -/* 195F30 80267650 00000000 */ nop -/* 195F34 80267654 46001080 */ add.s $f2, $f2, $f0 -/* 195F38 80267658 C620014C */ lwc1 $f0, 0x14c($s1) -/* 195F3C 8026765C 46140000 */ add.s $f0, $f0, $f20 -/* 195F40 80267660 44061000 */ mfc1 $a2, $f2 -/* 195F44 80267664 44070000 */ mfc1 $a3, $f0 -/* 195F48 80267668 0000202D */ daddu $a0, $zero, $zero -/* 195F4C 8026766C E7B60010 */ swc1 $f22, 0x10($sp) -/* 195F50 80267670 0C01C70C */ jal func_80071C30 -/* 195F54 80267674 AFB00014 */ sw $s0, 0x14($sp) -/* 195F58 80267678 C6200144 */ lwc1 $f0, 0x144($s1) -/* 195F5C 8026767C 46180000 */ add.s $f0, $f0, $f24 -/* 195F60 80267680 C6220148 */ lwc1 $f2, 0x148($s1) -/* 195F64 80267684 44050000 */ mfc1 $a1, $f0 -/* 195F68 80267688 3C0141B0 */ lui $at, 0x41b0 -/* 195F6C 8026768C 44810000 */ mtc1 $at, $f0 -/* 195F70 80267690 00000000 */ nop -/* 195F74 80267694 46001080 */ add.s $f2, $f2, $f0 -/* 195F78 80267698 C620014C */ lwc1 $f0, 0x14c($s1) -/* 195F7C 8026769C 46140000 */ add.s $f0, $f0, $f20 -/* 195F80 802676A0 44061000 */ mfc1 $a2, $f2 -/* 195F84 802676A4 44070000 */ mfc1 $a3, $f0 -/* 195F88 802676A8 24040001 */ addiu $a0, $zero, 1 -/* 195F8C 802676AC E7B60010 */ swc1 $f22, 0x10($sp) -/* 195F90 802676B0 0C01C70C */ jal func_80071C30 -/* 195F94 802676B4 AFB00014 */ sw $s0, 0x14($sp) -/* 195F98 802676B8 24040299 */ addiu $a0, $zero, 0x299 -/* 195F9C 802676BC 0C05272D */ jal play_sound -/* 195FA0 802676C0 AE4000A0 */ sw $zero, 0xa0($s2) -/* 195FA4 802676C4 32620100 */ andi $v0, $s3, 0x100 -.L802676C8: -/* 195FA8 802676C8 10400009 */ beqz $v0, .L802676F0 -/* 195FAC 802676CC 32620080 */ andi $v0, $s3, 0x80 -/* 195FB0 802676D0 8242009B */ lb $v0, 0x9b($s2) -/* 195FB4 802676D4 10400006 */ beqz $v0, .L802676F0 -/* 195FB8 802676D8 32620080 */ andi $v0, $s3, 0x80 -/* 195FBC 802676DC 8E42043C */ lw $v0, 0x43c($s2) -/* 195FC0 802676E0 A240009B */ sb $zero, 0x9b($s2) -/* 195FC4 802676E4 8C42000C */ lw $v0, 0xc($v0) -/* 195FC8 802676E8 A4400024 */ sh $zero, 0x24($v0) -/* 195FCC 802676EC 32620080 */ andi $v0, $s3, 0x80 -.L802676F0: -/* 195FD0 802676F0 1040000B */ beqz $v0, .L80267720 -/* 195FD4 802676F4 00000000 */ nop -/* 195FD8 802676F8 824200A4 */ lb $v0, 0xa4($s2) -/* 195FDC 802676FC 10400008 */ beqz $v0, .L80267720 -/* 195FE0 80267700 00000000 */ nop -/* 195FE4 80267704 8E42043C */ lw $v0, 0x43c($s2) -/* 195FE8 80267708 A24000A4 */ sb $zero, 0xa4($s2) -/* 195FEC 8026770C 8C42000C */ lw $v0, 0xc($v0) -/* 195FF0 80267710 A440001A */ sh $zero, 0x1a($v0) -/* 195FF4 80267714 0C016914 */ jal remove_effect -/* 195FF8 80267718 8E4400A8 */ lw $a0, 0xa8($s2) -/* 195FFC 8026771C AE4000A8 */ sw $zero, 0xa8($s2) -.L80267720: -/* 196000 80267720 1280000B */ beqz $s4, .L80267750 -/* 196004 80267724 3C020001 */ lui $v0, 1 -/* 196008 80267728 02621024 */ and $v0, $s3, $v0 -/* 19600C 8026772C 10400008 */ beqz $v0, .L80267750 -/* 196010 80267730 3C04BFFF */ lui $a0, 0xbfff -/* 196014 80267734 3C03800E */ lui $v1, %hi(gBattleStatus) -/* 196018 80267738 2463C070 */ addiu $v1, $v1, %lo(gBattleStatus) -/* 19601C 8026773C A2800220 */ sb $zero, 0x220($s4) -/* 196020 80267740 8C620000 */ lw $v0, ($v1) -/* 196024 80267744 3484FFFF */ ori $a0, $a0, 0xffff -/* 196028 80267748 00441024 */ and $v0, $v0, $a0 -/* 19602C 8026774C AC620000 */ sw $v0, ($v1) -.L80267750: -/* 196030 80267750 8FBF002C */ lw $ra, 0x2c($sp) -/* 196034 80267754 8FB40028 */ lw $s4, 0x28($sp) -/* 196038 80267758 8FB30024 */ lw $s3, 0x24($sp) -/* 19603C 8026775C 8FB20020 */ lw $s2, 0x20($sp) -/* 196040 80267760 8FB1001C */ lw $s1, 0x1c($sp) -/* 196044 80267764 8FB00018 */ lw $s0, 0x18($sp) -/* 196048 80267768 D7B80040 */ ldc1 $f24, 0x40($sp) -/* 19604C 8026776C D7B60038 */ ldc1 $f22, 0x38($sp) -/* 196050 80267770 D7B40030 */ ldc1 $f20, 0x30($sp) -/* 196054 80267774 03E00008 */ jr $ra -/* 196058 80267778 27BD0048 */ addiu $sp, $sp, 0x48 diff --git a/include/common_structs.h b/include/common_structs.h index 99de498391..0a5f3aba8e 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -524,6 +524,20 @@ typedef struct Camera { /* 0x538 */ char unk_538[32]; } Camera; // size = 0x558 +typedef struct BattleStatusUnkInner { + /* 0x00 */ char unk_00[0x10]; + /* 0x10 */ s16 unk_10; + /* 0x12 */ char unk_12[8]; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ char unk_1C[8]; + /* 0x24 */ s16 unk_24; +} BattleStatusUnkInner; // size = unknown + +typedef struct BattleStatusUnk { + /* 0x00 */ char unk_00[0xC]; + /* 0x0C */ BattleStatusUnkInner* unk_0C; +} BattleStatusUnk; // size = unknown + typedef struct BattleStatus { /* 0x000 */ s32 flags1; /* 0x004 */ s32 flags2; @@ -552,17 +566,18 @@ typedef struct BattleStatus { /* 0x08C */ char unk_8C[2]; /* 0x08E */ u8 initialEnemyCount; /* used for SP award bonus */ /* 0x08F */ char unk_8F[7]; - /* 0x096 */ u8 hammerCharge; - /* 0x097 */ u8 jumpCharge; + /* 0x096 */ s8 hammerCharge; + /* 0x097 */ s8 jumpCharge; /* 0x098 */ char unk_98; /* 0x099 */ u8 dangerFlags; /* 1 = danger, 2 = peril */ /* 0x09A */ u8 outtaSightActive; - /* 0x09B */ u8 turboChargeTurnsLeft; + /* 0x09B */ s8 turboChargeTurnsLeft; /* 0x09C */ u8 turboChargeAmount; /* unused? */ - /* 0x09D */ u8 waterBlockTurnsLeft; + /* 0x09D */ s8 waterBlockTurnsLeft; /* 0x09E */ u8 waterBlockAmount; /* unused? */ - /* 0x09F */ char unk_9F[5]; - /* 0x0A4 */ u8 cloudNineTurnsLeft; + /* 0x09F */ char unk_9F; + /* 0x0A0 */ s32* unk_A0; + /* 0x0A4 */ s8 cloudNineTurnsLeft; /* 0x0A5 */ u8 cloudNineDodgeChance; /* = 50% */ /* 0x0A6 */ char unk_A6[2]; /* 0x0A8 */ s32 cloudNineEffect; @@ -631,7 +646,7 @@ typedef struct BattleStatus { /* 0x432 */ char unk_432[2]; /* 0x434 */ s32 unk_434; /* 0x438 */ s32* foregroundModelList; - /* 0x43C */ UNK_PTR turboChargeCounter; + /* 0x43C */ BattleStatusUnk* unk_43C; /* 0x440 */ u8 tattleFlags[27]; /* 0x45B */ char unk_45B[17]; /* 0x46C */ s32 battleState; /* 0 = load assets, 1 = create actors, 4 = start scripts, 7 & 8 = unk */ @@ -1286,20 +1301,20 @@ typedef struct Actor { /* 0x20C */ u32* statusTable; /* 0x210 */ u8 debuff; /* 0x211 */ u8 debuffDuration; - /* 0x212 */ u8 staticStatus; /* 0B = yes */ + /* 0x212 */ s8 staticStatus; /* 0B = yes */ /* 0x213 */ u8 staticDuration; /* 0x214 */ s8 stoneStatus; /* 0C = yes */ /* 0x215 */ u8 stoneDuration; /* 0x216 */ u8 koStatus; /* 0D = yes */ /* 0x217 */ u8 koDuration; - /* 0x218 */ u8 transStatus; /* 0E = yes */ + /* 0x218 */ s8 transStatus; /* 0E = yes */ /* 0x219 */ u8 transDuration; /* 0x21A */ char unk_21A[2]; /* 0x21C */ u8 status; /* 0x21D */ char unk_21D[3]; - /* 0x220 */ u8 bGlowing; + /* 0x220 */ u8 isGlowing; /* 0x221 */ u8 attackBoost; - /* 0x222 */ u8 defenseBoost; + /* 0x222 */ s8 defenseBoost; /* 0x223 */ u8 chillOutAmount; /* attack reduction */ /* 0x224 */ u8 chillOutTurns; /* 0x225 */ char unk_225[7]; @@ -1314,7 +1329,7 @@ typedef struct Actor { /* 0x42C */ struct Shadow* shadow; /* might be shadow ID */ /* 0x430 */ f32 shadowScale; /* = actor size / 24.0 */ /* 0x434 */ s16 renderMode; /* initially 0xD, set to 0x22 if any part is transparent */ - /* 0x436 */ char unk_436[2]; + /* 0x436 */ s16 unk_436; /* 0x438 */ s32 x[2]; /* ??? see FUN_80253974 */ /* 0x440 */ struct MenuIcon* ptrDefuffIcon; } Actor; // size = 0x444 diff --git a/src/code_190B20.c b/src/code_190B20.c index 00bc7a4fa9..e9d58cd707 100644 --- a/src/code_190B20.c +++ b/src/code_190B20.c @@ -83,6 +83,7 @@ typedef struct { Element element; s32 defense; } DefenseTableEntry; + s32 lookup_defense(DefenseTableEntry* defenseTable, Element elementKey) { DefenseTableEntry* row; s32 normalDefense = 0; @@ -112,7 +113,99 @@ INCLUDE_ASM(s32, "code_190B20", inflict_status); INCLUDE_ASM(s32, "code_190B20", inflict_partner_ko); -INCLUDE_ASM(s32, "code_190B20", get_defense); +s32 get_defense(Actor* actor, s32* defenseTable, s32 elementFlags) { + s32 defense; + s32 minDefense = 0xFF; + + if (defenseTable != NULL) { + if (elementFlags & 2) { + defense = lookup_defense(defenseTable, Element_FIRE); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 4) { + defense = lookup_defense(defenseTable, Element_WATER); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 8) { + defense = lookup_defense(defenseTable, Element_ICE); + if (defense < minDefense) { + minDefense = defense; + } + } + // Element_MYSTERY missing? + if (elementFlags & 0x10) { + defense = lookup_defense(defenseTable, Element_MAGIC); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x40) { + defense = lookup_defense(defenseTable, Element_HAMMER); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x80) { + defense = lookup_defense(defenseTable, Element_JUMP); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x100) { + defense = lookup_defense(defenseTable, Element_COSMIC); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x200) { + defense = lookup_defense(defenseTable, Element_BLAST); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x20) { + defense = lookup_defense(defenseTable, Element_SHOCK); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x800) { + defense = lookup_defense(defenseTable, Element_QUAKE); + if (defense < minDefense) { + minDefense = defense; + } + } + if (elementFlags & 0x40000) { + defense = lookup_defense(defenseTable, Element_THROW); + if (defense < minDefense) { + minDefense = defense; + } + } + } + + // If no element flags were set, fall back to normal defense. + if (minDefense == 0xFF) { + defense = lookup_defense(defenseTable, Element_NORMAL); + if (defense < 0xFF) { + minDefense = defense; + } + } + + if (elementFlags & 0x8000000) { // "ignore defense" flag + if (minDefense == 99) { + // Immune + minDefense = 999; + } else if (minDefense > 0) { + minDefense = 0; + } + } + + return minDefense; +} INCLUDE_ASM(s32, "code_190B20", func_802664DC); @@ -241,7 +334,73 @@ void create_part_shadow_by_ptr(UNK_TYPE arg0, ActorPart* part) { part->shadowScale = part->size[0] / 24.0; } -INCLUDE_ASM(s32, "code_190B20", remove_player_buffs); +void func_80071A50(s32, f32 x, f32 y, f32 z, f32 scale /* maybe */, s32); +void func_80071C30(s32, f32 x, f32 y, f32 z, f32 scale /* maybe */, s32); + +void remove_player_buffs(PlayerBuff buffs) { + BattleStatus* battleStatus = &gBattleStatus; + Actor* player = battleStatus->playerActor; + Actor* partner = battleStatus->partnerActor; + ActorPart* playerPartsTable = player->partsTable; + + if (buffs & 1) { + battleStatus->jumpCharge = 0; + battleStatus->flags1 &= ~0x20000000; + } + if (buffs & 2) { + battleStatus->hammerCharge = 0; + battleStatus->flags1 &= ~0x10000000; + } + if (buffs & 8) { + player->stoneDuration = 0; + player->stoneStatus = 0; + } + if (buffs & 0x10) { + battleStatus->hustleTurns = 0; + battleStatus->flags1 &= ~0x04000000; + } + if ((buffs & 0x20) && (player->staticStatus != 0)) { + player->staticDuration = 0; + player->staticStatus = 0; + func_800479A0(player->unk_436); + } + if ((buffs & 0x40) && (player->transStatus != 0)) { + player->transDuration = 0; + player->transStatus = 0; + playerPartsTable->flags &= ~0x100; + func_80047AA8(player->unk_436); + } + if ((buffs & 0x200) && (battleStatus->waterBlockTurnsLeft != 0)) { + battleStatus->waterBlockTurnsLeft = 0; + battleStatus->unk_43C->unk_0C->unk_10 = 0; + battleStatus->unk_A0[0] |= 0x10; + + func_80071A50(1, player->currentPos.x, player->currentPos.y + 18.0f, player->currentPos.z + 5.0f, 1.5f, 0xA); + func_80071C30(0, player->currentPos.x - 10.0f, player->currentPos.y + 5.0f, player->currentPos.z + 5.0f, 1.0f, 0x18); + func_80071C30(0, player->currentPos.x - 15.0f, player->currentPos.y + 32.0f, player->currentPos.z + 5.0f, 1.0f, 0x18); + func_80071C30(1, player->currentPos.x + 15.0f, player->currentPos.y + 22.0f, player->currentPos.z + 5.0f, 1.0f, 0x18); + + battleStatus->unk_A0 = NULL; + play_sound(0x299); + } + if ((buffs & 0x100) && (battleStatus->turboChargeTurnsLeft != 0)) { + battleStatus->turboChargeTurnsLeft = 0; + battleStatus->unk_43C->unk_0C->unk_24 = 0; + } + if ((buffs & 0x80) && (battleStatus->cloudNineTurnsLeft != 0)) { + battleStatus->cloudNineTurnsLeft = 0; + battleStatus->unk_43C->unk_0C->unk_1A = 0; + remove_effect(battleStatus->cloudNineEffect); + battleStatus->cloudNineEffect = 0; + } + + if ((partner != NULL) && (buffs & 0x10000)) { + BattleStatus* bs = &gBattleStatus; + + partner->isGlowing = FALSE; + bs->flags1 &= ~0x40000000; + } +} INCLUDE_ASM(s32, "code_190B20", func_8026777C);