mirror of
https://github.com/pmret/papermario.git
synced 2024-09-07 18:19:48 +02:00
Implemented kkj_19_5_baking_GetItemNameRaw for pal (#1066)
* Implemented kkj_19_5_baking_GetItemNameRaw for pal * Usage of decimals instead of hexadecimals * Implemented mgm_01_2_npc SetMsgVars_BlocksRemaining * Implemented mgm_02_0_header.c * Removed .s file I'm such an idiot for forgetting this * removed implemented methods * optimized decomp * found the value for the hex number thanks to @marijnvdwerf and @Brotenko * Fixed args indexing Co-authored-by: Ethan Roseman <ethteck@gmail.com> * Added empty line after definitions * Apply suggestions from code review Co-authored-by: Marijn van der Werf <marijn.vanderwerf@gmail.com> Co-authored-by: Ethan Roseman <ethteck@gmail.com> * adjusted format (fixed compiler warning) * made review changes * removed duplicated code * namespaced pal_var --------- Co-authored-by: Ethan Roseman <ethteck@gmail.com> Co-authored-by: Marijn van der Werf <marijn.vanderwerf@gmail.com>
This commit is contained in:
parent
d65dce43df
commit
f0a9274c01
@ -193,10 +193,55 @@ API_CALLABLE(N(AwaitPlayerPressATimer)) {
|
||||
return ApiStatus_BLOCK;
|
||||
}
|
||||
|
||||
#if VERSION_PAL
|
||||
typedef struct BakingIngredient {
|
||||
s32 itemID;
|
||||
s32 nameID;
|
||||
} BakingIngredient;
|
||||
struct BakingIngredient N(BakingIngredientsNames)[] = {
|
||||
{ITEM_BAKING_FLOUR, MSG_Menus_BakingFlour},
|
||||
{ITEM_BAKING_SUGAR, MSG_Menus_BakingSugar},
|
||||
{ITEM_BAKING_SALT, MSG_Menus_BakingSalt},
|
||||
{ITEM_BAKING_EGG, MSG_Menus_BakingEgg},
|
||||
{ITEM_BAKING_MILK, MSG_Menus_BakingMilk},
|
||||
{ITEM_BAKING_STRAWBERRY, MSG_Menus_BakingStrawberry},
|
||||
{ITEM_BAKING_CREAM, MSG_Menus_BakingCream},
|
||||
{ITEM_BAKING_BUTTER, MSG_Menus_BakingButter},
|
||||
{ITEM_BAKING_CLEANSER, MSG_Menus_BakingCleanser},
|
||||
{ITEM_BAKING_WATER, MSG_Menus_BakingWater},
|
||||
};
|
||||
#endif
|
||||
|
||||
s32 N(BakingIngredientsList)[] = {
|
||||
ITEM_BAKING_SUGAR,
|
||||
ITEM_BAKING_SALT,
|
||||
ITEM_BAKING_EGG,
|
||||
ITEM_BAKING_STRAWBERRY,
|
||||
ITEM_BAKING_CREAM,
|
||||
ITEM_BAKING_BUTTER,
|
||||
ITEM_BAKING_CLEANSER,
|
||||
ITEM_BAKING_WATER,
|
||||
ITEM_BAKING_FLOUR,
|
||||
ITEM_BAKING_MILK,
|
||||
};
|
||||
|
||||
// unlike the common import, does not mask out 0xF0000 from itemID
|
||||
#if VERSION_PAL
|
||||
API_CALLABLE(N(GetItemNameRaw));
|
||||
INCLUDE_ASM(ApiResult, "world/area_kkj/kkj_19/kkj_19_5_baking", kkj_19_GetItemNameRaw);
|
||||
|
||||
API_CALLABLE(N(GetItemNameRaw)) {
|
||||
Bytecode* args = script->ptrReadPos;
|
||||
s32 inOutVar = *args++;
|
||||
s32 itemID = evt_get_variable(script, inOutVar);
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(N(BakingIngredientsNames)); i++) {
|
||||
if (itemID == N(BakingIngredientsNames)[i].itemID) {
|
||||
evt_set_variable(script, inOutVar, N(BakingIngredientsNames)[i].nameID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
#else
|
||||
API_CALLABLE(N(GetItemNameRaw)) {
|
||||
Bytecode* args = script->ptrReadPos;
|
||||
@ -254,34 +299,6 @@ API_CALLABLE(N(FadeScreenFromBlack)) {
|
||||
return ApiStatus_BLOCK;
|
||||
}
|
||||
|
||||
#if VERSION_PAL
|
||||
s32 N(BakingIngredientsNames)[] = {
|
||||
ITEM_BAKING_FLOUR, MSG_Menus_BakingFlour,
|
||||
ITEM_BAKING_SUGAR, MSG_Menus_BakingSugar,
|
||||
ITEM_BAKING_SALT, MSG_Menus_BakingSalt,
|
||||
ITEM_BAKING_EGG, MSG_Menus_BakingEgg,
|
||||
ITEM_BAKING_MILK, MSG_Menus_BakingMilk,
|
||||
ITEM_BAKING_STRAWBERRY, MSG_Menus_BakingStrawberry,
|
||||
ITEM_BAKING_CREAM, MSG_Menus_BakingCream,
|
||||
ITEM_BAKING_BUTTER, MSG_Menus_BakingButter,
|
||||
ITEM_BAKING_CLEANSER, MSG_Menus_BakingCleanser,
|
||||
ITEM_BAKING_WATER, MSG_Menus_BakingWater,
|
||||
};
|
||||
#endif
|
||||
|
||||
s32 N(BakingIngredientsList)[] = {
|
||||
ITEM_BAKING_SUGAR,
|
||||
ITEM_BAKING_SALT,
|
||||
ITEM_BAKING_EGG,
|
||||
ITEM_BAKING_STRAWBERRY,
|
||||
ITEM_BAKING_CREAM,
|
||||
ITEM_BAKING_BUTTER,
|
||||
ITEM_BAKING_CLEANSER,
|
||||
ITEM_BAKING_WATER,
|
||||
ITEM_BAKING_FLOUR,
|
||||
ITEM_BAKING_MILK,
|
||||
};
|
||||
|
||||
EvtScript N(EVS_SetCookwareOnTable) = {
|
||||
EVT_SWITCH(AB_KKJ_CompletedBakeStep)
|
||||
EVT_CASE_EQ(CAKE_TYPE_NONE)
|
||||
|
@ -656,20 +656,19 @@ API_CALLABLE(N(GetCoinCount)) {
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
|
||||
#if VERSION_PAL
|
||||
API_CALLABLE(N(SetMsgVars_BlocksRemaining));
|
||||
INCLUDE_ASM(ApiStatus, "world/area_mgm/mgm_01/mgm_01_2_npc", mgm_01_SetMsgVars_BlocksRemaining)
|
||||
#else
|
||||
API_CALLABLE(N(SetMsgVars_BlocksRemaining)) {
|
||||
Enemy* scorekeeper = get_enemy(SCOREKEEPER_ENEMY_IDX);
|
||||
s32 remaining = (scorekeeper->varTable[TOTAL_BLOCKS_VAR_IDX] - scorekeeper->varTable[BROKEN_BLOCKS_VAR_IDX]) + 1;
|
||||
|
||||
set_message_value(remaining, 0);
|
||||
#if VERSION_PAL
|
||||
evt_set_variable(script, LVarD, remaining);
|
||||
#else
|
||||
set_message_msg((remaining == 1) ? (s32)&MessageSingular : (s32)&MessagePlural, 1);
|
||||
#endif
|
||||
|
||||
return ApiStatus_DONE2;
|
||||
}
|
||||
#endif
|
||||
|
||||
API_CALLABLE(N(HideCoinCounter)) {
|
||||
hide_coin_counter_immediately();
|
||||
|
@ -1,8 +1,14 @@
|
||||
#include "mgm_02.h"
|
||||
|
||||
#if VERSION_PAL
|
||||
s32 N(get_tattle)(void);
|
||||
INCLUDE_ASM(void, "world/area_mgm/mgm_02/mgm_02_0_header", mgm_02_get_tattle);
|
||||
extern s32 N(pal_variable);
|
||||
s32 N(get_tattle)(void) {
|
||||
s32 msgID = MSG_MapTattle_mgm_02;
|
||||
if (N(pal_variable) != 0) {
|
||||
msgID = MSG_NONE;
|
||||
}
|
||||
return msgID;
|
||||
}
|
||||
#endif
|
||||
|
||||
EntryList N(Entrances) = {
|
||||
|
@ -1,40 +0,0 @@
|
||||
.set noat /* allow manual use of $at */
|
||||
.set noreorder /* don't insert nops after branches */
|
||||
|
||||
/* Generated by spimdisasm 1.11.1 */
|
||||
|
||||
glabel kkj_19_GetItemNameRaw
|
||||
/* B6435C 80240B8C 27BDFFE0 */ addiu $sp, $sp, -0x20
|
||||
/* B64360 80240B90 AFB10014 */ sw $s1, 0x14($sp)
|
||||
/* B64364 80240B94 0080882D */ daddu $s1, $a0, $zero
|
||||
/* B64368 80240B98 AFBF0018 */ sw $ra, 0x18($sp)
|
||||
/* B6436C 80240B9C AFB00010 */ sw $s0, 0x10($sp)
|
||||
/* B64370 80240BA0 8E22000C */ lw $v0, 0xC($s1)
|
||||
/* B64374 80240BA4 8C500000 */ lw $s0, 0x0($v0)
|
||||
/* B64378 80240BA8 0C0B2AAF */ jal evt_get_variable
|
||||
/* B6437C 80240BAC 0200282D */ daddu $a1, $s0, $zero
|
||||
/* B64380 80240BB0 0040282D */ daddu $a1, $v0, $zero
|
||||
/* B64384 80240BB4 0000202D */ daddu $a0, $zero, $zero
|
||||
/* B64388 80240BB8 3C038024 */ lui $v1, %hi(kkj_19_BakingIngredientsNames)
|
||||
/* B6438C 80240BBC 24631E50 */ addiu $v1, $v1, %lo(kkj_19_BakingIngredientsNames)
|
||||
.LPAL_80240BC0:
|
||||
/* B64390 80240BC0 8C620000 */ lw $v0, 0x0($v1)
|
||||
/* B64394 80240BC4 14A20007 */ bne $a1, $v0, .LPAL_80240BE4
|
||||
/* B64398 80240BC8 24840001 */ addiu $a0, $a0, 0x1
|
||||
/* B6439C 80240BCC 0220202D */ daddu $a0, $s1, $zero
|
||||
/* B643A0 80240BD0 8C660004 */ lw $a2, 0x4($v1)
|
||||
/* B643A4 80240BD4 0C0B2C26 */ jal evt_set_variable
|
||||
/* B643A8 80240BD8 0200282D */ daddu $a1, $s0, $zero
|
||||
/* B643AC 80240BDC 080902FC */ j .LPAL_80240BF0
|
||||
/* B643B0 80240BE0 00000000 */ nop
|
||||
.LPAL_80240BE4:
|
||||
/* B643B4 80240BE4 2882000A */ slti $v0, $a0, 0xA
|
||||
/* B643B8 80240BE8 1440FFF5 */ bnez $v0, .LPAL_80240BC0
|
||||
/* B643BC 80240BEC 24630008 */ addiu $v1, $v1, 0x8
|
||||
.LPAL_80240BF0:
|
||||
/* B643C0 80240BF0 8FBF0018 */ lw $ra, 0x18($sp)
|
||||
/* B643C4 80240BF4 8FB10014 */ lw $s1, 0x14($sp)
|
||||
/* B643C8 80240BF8 8FB00010 */ lw $s0, 0x10($sp)
|
||||
/* B643CC 80240BFC 24020002 */ addiu $v0, $zero, 0x2
|
||||
/* B643D0 80240C00 03E00008 */ jr $ra
|
||||
/* B643D4 80240C04 27BD0020 */ addiu $sp, $sp, 0x20
|
@ -1,31 +0,0 @@
|
||||
.set noat /* allow manual use of $at */
|
||||
.set noreorder /* don't insert nops after branches */
|
||||
|
||||
/* Generated by spimdisasm 1.11.1 */
|
||||
|
||||
glabel func_PAL_802416F8
|
||||
/* E80888 802416F8 27BDFFE0 */ addiu $sp, $sp, -0x20
|
||||
/* E8088C 802416FC AFB10014 */ sw $s1, 0x14($sp)
|
||||
/* E80890 80241700 0080882D */ daddu $s1, $a0, $zero
|
||||
/* E80894 80241704 0000202D */ daddu $a0, $zero, $zero
|
||||
/* E80898 80241708 AFBF0018 */ sw $ra, 0x18($sp)
|
||||
/* E8089C 8024170C 0C00FC76 */ jal get_enemy
|
||||
/* E808A0 80241710 AFB00010 */ sw $s0, 0x10($sp)
|
||||
/* E808A4 80241714 8C50007C */ lw $s0, 0x7C($v0)
|
||||
/* E808A8 80241718 8C420074 */ lw $v0, 0x74($v0)
|
||||
/* E808AC 8024171C 0000282D */ daddu $a1, $zero, $zero
|
||||
/* E808B0 80241720 02028023 */ subu $s0, $s0, $v0
|
||||
/* E808B4 80241724 26100001 */ addiu $s0, $s0, 0x1
|
||||
/* E808B8 80241728 0C0491C2 */ jal set_message_value
|
||||
/* E808BC 8024172C 0200202D */ daddu $a0, $s0, $zero
|
||||
/* E808C0 80241730 0220202D */ daddu $a0, $s1, $zero
|
||||
/* E808C4 80241734 3C05FE36 */ lui $a1, (0xFE363C8D >> 16)
|
||||
/* E808C8 80241738 34A53C8D */ ori $a1, $a1, (0xFE363C8D & 0xFFFF)
|
||||
/* E808CC 8024173C 0C0B2C26 */ jal evt_set_variable
|
||||
/* E808D0 80241740 0200302D */ daddu $a2, $s0, $zero
|
||||
/* E808D4 80241744 8FBF0018 */ lw $ra, 0x18($sp)
|
||||
/* E808D8 80241748 8FB10014 */ lw $s1, 0x14($sp)
|
||||
/* E808DC 8024174C 8FB00010 */ lw $s0, 0x10($sp)
|
||||
/* E808E0 80241750 24020002 */ addiu $v0, $zero, 0x2
|
||||
/* E808E4 80241754 03E00008 */ jr $ra
|
||||
/* E808E8 80241758 27BD0020 */ addiu $sp, $sp, 0x20
|
@ -1,15 +0,0 @@
|
||||
.set noat /* allow manual use of $at */
|
||||
.set noreorder /* don't insert nops after branches */
|
||||
|
||||
/* Generated by spimdisasm 1.11.1 */
|
||||
|
||||
glabel mgm_02_get_tattle
|
||||
/* E827F0 80240000 3C030019 */ lui $v1, (0x190008 >> 16)
|
||||
/* E827F4 80240004 3C028024 */ lui $v0, %hi(mgm_02_pal_variable)
|
||||
/* E827F8 80240008 8C422A50 */ lw $v0, %lo(mgm_02_pal_variable)($v0)
|
||||
/* E827FC 8024000C 10400002 */ beqz $v0, .Lmgm_02_80240018
|
||||
/* E82800 80240010 34630008 */ ori $v1, $v1, (0x190008 & 0xFFFF)
|
||||
/* E82804 80240014 0000182D */ daddu $v1, $zero, $zero
|
||||
.Lmgm_02_80240018:
|
||||
/* E82808 80240018 03E00008 */ jr $ra
|
||||
/* E8280C 8024001C 0060102D */ daddu $v0, $v1, $zero
|
Loading…
Reference in New Issue
Block a user