mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
Merge pull request #5 from nanaian/items
match FindItem, RemoveItem, CountFortressKeys, RemoveFortressKeys
This commit is contained in:
commit
afc0415a2c
@ -1,24 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
|
||||
glabel CountFortessKeys
|
||||
/* 0FB5FC 802D6C4C 27BDFFE0 */ addiu $sp, $sp, -0x20
|
||||
/* 0FB600 802D6C50 AFB00010 */ sw $s0, 0x10($sp)
|
||||
/* 0FB604 802D6C54 0080802D */ daddu $s0, $a0, $zero
|
||||
/* 0FB608 802D6C58 AFBF0018 */ sw $ra, 0x18($sp)
|
||||
/* 0FB60C 802D6C5C AFB10014 */ sw $s1, 0x14($sp)
|
||||
/* 0FB610 802D6C60 8E02000C */ lw $v0, 0xc($s0)
|
||||
/* 0FB614 802D6C64 0C03A8F9 */ jal get_fortress_key_count
|
||||
/* 0FB618 802D6C68 8C510000 */ lw $s1, ($v0)
|
||||
/* 0FB61C 802D6C6C 0200202D */ daddu $a0, $s0, $zero
|
||||
/* 0FB620 802D6C70 0040302D */ daddu $a2, $v0, $zero
|
||||
/* 0FB624 802D6C74 0C0B2026 */ jal set_variable
|
||||
/* 0FB628 802D6C78 0220282D */ daddu $a1, $s1, $zero
|
||||
/* 0FB62C 802D6C7C 8FBF0018 */ lw $ra, 0x18($sp)
|
||||
/* 0FB630 802D6C80 8FB10014 */ lw $s1, 0x14($sp)
|
||||
/* 0FB634 802D6C84 8FB00010 */ lw $s0, 0x10($sp)
|
||||
/* 0FB638 802D6C88 24020002 */ addiu $v0, $zero, 2
|
||||
/* 0FB63C 802D6C8C 03E00008 */ jr $ra
|
||||
/* 0FB640 802D6C90 27BD0020 */ addiu $sp, $sp, 0x20
|
||||
|
@ -1,42 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
|
||||
glabel FindItem
|
||||
/* 0FB4C8 802D6B18 27BDFFE0 */ addiu $sp, $sp, -0x20
|
||||
/* 0FB4CC 802D6B1C AFB10014 */ sw $s1, 0x14($sp)
|
||||
/* 0FB4D0 802D6B20 0080882D */ daddu $s1, $a0, $zero
|
||||
/* 0FB4D4 802D6B24 AFBF0018 */ sw $ra, 0x18($sp)
|
||||
/* 0FB4D8 802D6B28 AFB00010 */ sw $s0, 0x10($sp)
|
||||
/* 0FB4DC 802D6B2C 8E30000C */ lw $s0, 0xc($s1)
|
||||
/* 0FB4E0 802D6B30 8E050000 */ lw $a1, ($s0)
|
||||
/* 0FB4E4 802D6B34 0C0B1EAF */ jal get_variable
|
||||
/* 0FB4E8 802D6B38 26100004 */ addiu $s0, $s0, 4
|
||||
/* 0FB4EC 802D6B3C 0040302D */ daddu $a2, $v0, $zero
|
||||
/* 0FB4F0 802D6B40 0000182D */ daddu $v1, $zero, $zero
|
||||
/* 0FB4F4 802D6B44 3C048011 */ lui $a0, 0x8011
|
||||
/* 0FB4F8 802D6B48 2484F290 */ addiu $a0, $a0, -0xd70
|
||||
/* 0FB4FC 802D6B4C 8E050000 */ lw $a1, ($s0)
|
||||
.L802D6B50:
|
||||
/* 0FB500 802D6B50 848201B4 */ lh $v0, 0x1b4($a0)
|
||||
/* 0FB504 802D6B54 10460006 */ beq $v0, $a2, .L802D6B70
|
||||
/* 0FB508 802D6B58 2402000A */ addiu $v0, $zero, 0xa
|
||||
/* 0FB50C 802D6B5C 24630001 */ addiu $v1, $v1, 1
|
||||
/* 0FB510 802D6B60 2862000A */ slti $v0, $v1, 0xa
|
||||
/* 0FB514 802D6B64 1440FFFA */ bnez $v0, .L802D6B50
|
||||
/* 0FB518 802D6B68 24840002 */ addiu $a0, $a0, 2
|
||||
/* 0FB51C 802D6B6C 2402000A */ addiu $v0, $zero, 0xa
|
||||
.L802D6B70:
|
||||
/* 0FB520 802D6B70 10620002 */ beq $v1, $v0, .L802D6B7C
|
||||
/* 0FB524 802D6B74 2406FFFF */ addiu $a2, $zero, -1
|
||||
/* 0FB528 802D6B78 0060302D */ daddu $a2, $v1, $zero
|
||||
.L802D6B7C:
|
||||
/* 0FB52C 802D6B7C 0C0B2026 */ jal set_variable
|
||||
/* 0FB530 802D6B80 0220202D */ daddu $a0, $s1, $zero
|
||||
/* 0FB534 802D6B84 8FBF0018 */ lw $ra, 0x18($sp)
|
||||
/* 0FB538 802D6B88 8FB10014 */ lw $s1, 0x14($sp)
|
||||
/* 0FB53C 802D6B8C 8FB00010 */ lw $s0, 0x10($sp)
|
||||
/* 0FB540 802D6B90 24020002 */ addiu $v0, $zero, 2
|
||||
/* 0FB544 802D6B94 03E00008 */ jr $ra
|
||||
/* 0FB548 802D6B98 27BD0020 */ addiu $sp, $sp, 0x20
|
||||
|
@ -1,17 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
|
||||
glabel RemoveFortressKeys
|
||||
/* 0FB644 802D6C94 27BDFFE8 */ addiu $sp, $sp, -0x18
|
||||
/* 0FB648 802D6C98 AFBF0010 */ sw $ra, 0x10($sp)
|
||||
/* 0FB64C 802D6C9C 8C82000C */ lw $v0, 0xc($a0)
|
||||
/* 0FB650 802D6CA0 0C0B1EAF */ jal get_variable
|
||||
/* 0FB654 802D6CA4 8C450000 */ lw $a1, ($v0)
|
||||
/* 0FB658 802D6CA8 0C03A8EE */ jal subtract_fortress_keys
|
||||
/* 0FB65C 802D6CAC 0040202D */ daddu $a0, $v0, $zero
|
||||
/* 0FB660 802D6CB0 8FBF0010 */ lw $ra, 0x10($sp)
|
||||
/* 0FB664 802D6CB4 24020002 */ addiu $v0, $zero, 2
|
||||
/* 0FB668 802D6CB8 03E00008 */ jr $ra
|
||||
/* 0FB66C 802D6CBC 27BD0018 */ addiu $sp, $sp, 0x18
|
||||
|
@ -1,54 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
|
||||
glabel RemoveItem
|
||||
/* 0FB54C 802D6B9C 27BDFFE0 */ addiu $sp, $sp, -0x20
|
||||
/* 0FB550 802D6BA0 AFB10014 */ sw $s1, 0x14($sp)
|
||||
/* 0FB554 802D6BA4 0080882D */ daddu $s1, $a0, $zero
|
||||
/* 0FB558 802D6BA8 AFBF001C */ sw $ra, 0x1c($sp)
|
||||
/* 0FB55C 802D6BAC AFB20018 */ sw $s2, 0x18($sp)
|
||||
/* 0FB560 802D6BB0 AFB00010 */ sw $s0, 0x10($sp)
|
||||
/* 0FB564 802D6BB4 8E30000C */ lw $s0, 0xc($s1)
|
||||
/* 0FB568 802D6BB8 8E050000 */ lw $a1, ($s0)
|
||||
/* 0FB56C 802D6BBC 0C0B1EAF */ jal get_variable
|
||||
/* 0FB570 802D6BC0 26100004 */ addiu $s0, $s0, 4
|
||||
/* 0FB574 802D6BC4 0040282D */ daddu $a1, $v0, $zero
|
||||
/* 0FB578 802D6BC8 0000182D */ daddu $v1, $zero, $zero
|
||||
/* 0FB57C 802D6BCC 3C068011 */ lui $a2, 0x8011
|
||||
/* 0FB580 802D6BD0 24C6F290 */ addiu $a2, $a2, -0xd70
|
||||
/* 0FB584 802D6BD4 00C0202D */ daddu $a0, $a2, $zero
|
||||
/* 0FB588 802D6BD8 8E120000 */ lw $s2, ($s0)
|
||||
.L802D6BDC:
|
||||
/* 0FB58C 802D6BDC 848201B4 */ lh $v0, 0x1b4($a0)
|
||||
/* 0FB590 802D6BE0 10450006 */ beq $v0, $a1, .L802D6BFC
|
||||
/* 0FB594 802D6BE4 2402000A */ addiu $v0, $zero, 0xa
|
||||
/* 0FB598 802D6BE8 24630001 */ addiu $v1, $v1, 1
|
||||
/* 0FB59C 802D6BEC 2862000A */ slti $v0, $v1, 0xa
|
||||
/* 0FB5A0 802D6BF0 1440FFFA */ bnez $v0, .L802D6BDC
|
||||
/* 0FB5A4 802D6BF4 24840002 */ addiu $a0, $a0, 2
|
||||
/* 0FB5A8 802D6BF8 2402000A */ addiu $v0, $zero, 0xa
|
||||
.L802D6BFC:
|
||||
/* 0FB5AC 802D6BFC 10620002 */ beq $v1, $v0, .L802D6C08
|
||||
/* 0FB5B0 802D6C00 2410FFFF */ addiu $s0, $zero, -1
|
||||
/* 0FB5B4 802D6C04 0060802D */ daddu $s0, $v1, $zero
|
||||
.L802D6C08:
|
||||
/* 0FB5B8 802D6C08 06000003 */ bltz $s0, .L802D6C18
|
||||
/* 0FB5BC 802D6C0C 00031040 */ sll $v0, $v1, 1
|
||||
/* 0FB5C0 802D6C10 00461021 */ addu $v0, $v0, $a2
|
||||
/* 0FB5C4 802D6C14 A44001B4 */ sh $zero, 0x1b4($v0)
|
||||
.L802D6C18:
|
||||
/* 0FB5C8 802D6C18 0C039DB3 */ jal sort_items
|
||||
/* 0FB5CC 802D6C1C 00000000 */ nop
|
||||
/* 0FB5D0 802D6C20 0220202D */ daddu $a0, $s1, $zero
|
||||
/* 0FB5D4 802D6C24 0240282D */ daddu $a1, $s2, $zero
|
||||
/* 0FB5D8 802D6C28 0C0B2026 */ jal set_variable
|
||||
/* 0FB5DC 802D6C2C 0200302D */ daddu $a2, $s0, $zero
|
||||
/* 0FB5E0 802D6C30 8FBF001C */ lw $ra, 0x1c($sp)
|
||||
/* 0FB5E4 802D6C34 8FB20018 */ lw $s2, 0x18($sp)
|
||||
/* 0FB5E8 802D6C38 8FB10014 */ lw $s1, 0x14($sp)
|
||||
/* 0FB5EC 802D6C3C 8FB00010 */ lw $s0, 0x10($sp)
|
||||
/* 0FB5F0 802D6C40 24020002 */ addiu $v0, $zero, 2
|
||||
/* 0FB5F4 802D6C44 03E00008 */ jr $ra
|
||||
/* 0FB5F8 802D6C48 27BD0020 */ addiu $sp, $sp, 0x20
|
||||
|
@ -192,13 +192,72 @@ s32 func_802D6AF0(script_context* script, s32 initialCall) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_fa4c0_len_3bf0, FindItem);
|
||||
s32 FindItem(script_context* script, s32 initialCall) {
|
||||
s32* ptrReadPos = script->ptrReadPos;
|
||||
s32 itemID = get_variable(script, *ptrReadPos++);
|
||||
s32 value = *ptrReadPos++;
|
||||
player_data* playerData = &gPlayerData;
|
||||
s32 i;
|
||||
s32 itemIndex;
|
||||
|
||||
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveItem);
|
||||
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
||||
if (playerData->invItems[i] == itemID) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_fa4c0_len_3bf0, CountFortessKeys);
|
||||
itemIndex = -1;
|
||||
if (i != ARRAY_COUNT(playerData->invItems)) {
|
||||
itemIndex = i;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_fa4c0_len_3bf0, RemoveFortressKeys);
|
||||
set_variable(script, value, itemIndex);
|
||||
return 2;
|
||||
}
|
||||
|
||||
s32 RemoveItem(script_context* script, s32 initialCall) {
|
||||
s32* ptrReadPos = script->ptrReadPos;
|
||||
s32 itemID = get_variable(script, *ptrReadPos++);
|
||||
s32 value = *ptrReadPos++;
|
||||
player_data* playerData = &gPlayerData;
|
||||
s32 i;
|
||||
s32 itemIndex;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
|
||||
if (playerData->invItems[i] == itemID) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
itemIndex = -1;
|
||||
if (i != ARRAY_COUNT(playerData->invItems)) {
|
||||
itemIndex = i;
|
||||
}
|
||||
|
||||
if (itemIndex >= 0) {
|
||||
// This is `playerData->invItems[i]`, but we have to do weird
|
||||
// pointer math to get the output asm to exactly match :/
|
||||
*(playerData->invItems + i) = 0;
|
||||
}
|
||||
sort_items();
|
||||
|
||||
set_variable(script, value, itemIndex);
|
||||
return 2;
|
||||
}
|
||||
|
||||
s32 CountFortressKeys(script_context* script, s32 initialCall) {
|
||||
s32 outVar = *script->ptrReadPos;
|
||||
|
||||
set_variable(script, outVar, get_fortress_key_count());
|
||||
return 2;
|
||||
}
|
||||
|
||||
s32 RemoveFortressKeys(script_context* script, s32 initialCall) {
|
||||
s32 num = get_variable(script, *script->ptrReadPos);
|
||||
|
||||
subtract_fortress_keys(num);
|
||||
return 2;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(code_fa4c0_len_3bf0, MakeItemEntity);
|
||||
|
||||
|
@ -2215,7 +2215,7 @@ labels:
|
||||
- [0x802D6A98, "AddItem"]
|
||||
- [0x802D6B18, "FindItem"]
|
||||
- [0x802D6B9C, "RemoveItem"]
|
||||
- [0x802D6C4C, "CountFortessKeys"]
|
||||
- [0x802D6C4C, "CountFortressKeys"]
|
||||
- [0x802D6C94, "RemoveFortressKeys"]
|
||||
- [0x802D6CC0, "MakeItemEntity"]
|
||||
- [0x802D6DC0, "DropItemEntity"]
|
||||
|
Loading…
Reference in New Issue
Block a user