Merge pull request #21 from JoshW-7/master

Mostly more script functions
This commit is contained in:
Ethan Roseman 2020-08-15 21:52:10 -04:00 committed by GitHub
commit 458cab2a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 136 additions and 204 deletions

View File

@ -1,22 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel DeleteNpc
/* 0F25CC 802CDC1C 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F25D0 802CDC20 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F25D4 802CDC24 8C82000C */ lw $v0, 0xc($a0)
/* 0F25D8 802CDC28 0C0B1EAF */ jal get_variable
/* 0F25DC 802CDC2C 8C450000 */ lw $a1, ($v0)
/* 0F25E0 802CDC30 0C00EABB */ jal get_npc_unsafe
/* 0F25E4 802CDC34 0040202D */ daddu $a0, $v0, $zero
/* 0F25E8 802CDC38 50400004 */ beql $v0, $zero, .L802CDC4C
/* 0F25EC 802CDC3C 24020002 */ addiu $v0, $zero, 2
/* 0F25F0 802CDC40 0C00E273 */ jal free_npc
/* 0F25F4 802CDC44 0040202D */ daddu $a0, $v0, $zero
/* 0F25F8 802CDC48 24020002 */ addiu $v0, $zero, 2
.L802CDC4C:
/* 0F25FC 802CDC4C 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F2600 802CDC50 03E00008 */ jr $ra
/* 0F2604 802CDC54 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel GetNpcPointer
/* 0F2608 802CDC58 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0F260C 802CDC5C AFB10014 */ sw $s1, 0x14($sp)
/* 0F2610 802CDC60 0080882D */ daddu $s1, $a0, $zero
/* 0F2614 802CDC64 AFBF0018 */ sw $ra, 0x18($sp)
/* 0F2618 802CDC68 AFB00010 */ sw $s0, 0x10($sp)
/* 0F261C 802CDC6C 8E30000C */ lw $s0, 0xc($s1)
/* 0F2620 802CDC70 8E050000 */ lw $a1, ($s0)
/* 0F2624 802CDC74 0C0B1EAF */ jal get_variable
/* 0F2628 802CDC78 26100004 */ addiu $s0, $s0, 4
/* 0F262C 802CDC7C 8E100000 */ lw $s0, ($s0)
/* 0F2630 802CDC80 0C00EAD2 */ jal get_npc_safe
/* 0F2634 802CDC84 0040202D */ daddu $a0, $v0, $zero
/* 0F2638 802CDC88 0220202D */ daddu $a0, $s1, $zero
/* 0F263C 802CDC8C 0040302D */ daddu $a2, $v0, $zero
/* 0F2640 802CDC90 0C0B2026 */ jal set_variable
/* 0F2644 802CDC94 0200282D */ daddu $a1, $s0, $zero
/* 0F2648 802CDC98 8FBF0018 */ lw $ra, 0x18($sp)
/* 0F264C 802CDC9C 8FB10014 */ lw $s1, 0x14($sp)
/* 0F2650 802CDCA0 8FB00010 */ lw $s0, 0x10($sp)
/* 0F2654 802CDCA4 24020002 */ addiu $v0, $zero, 2
/* 0F2658 802CDCA8 03E00008 */ jr $ra
/* 0F265C 802CDCAC 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel CancelMessage
/* 0F55D0 802D0C20 3C04802E */ lui $a0, 0x802e
/* 0F55D4 802D0C24 8C84B260 */ lw $a0, -0x4da0($a0)
/* 0F55D8 802D0C28 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F55DC 802D0C2C AFBF0010 */ sw $ra, 0x10($sp)
/* 0F55E0 802D0C30 0C0496C2 */ jal cancel_message
/* 0F55E4 802D0C34 00000000 */ nop
/* 0F55E8 802D0C38 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F55EC 802D0C3C 24020002 */ addiu $v0, $zero, 2
/* 0F55F0 802D0C40 03E00008 */ jr $ra
/* 0F55F4 802D0C44 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel CancelMessageAndBlock
/* 0F55F8 802D0C48 3C04802E */ lui $a0, 0x802e
/* 0F55FC 802D0C4C 8C84B260 */ lw $a0, -0x4da0($a0)
/* 0F5600 802D0C50 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F5604 802D0C54 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F5608 802D0C58 0C0496C2 */ jal cancel_message
/* 0F560C 802D0C5C 00000000 */ nop
/* 0F5610 802D0C60 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F5614 802D0C64 0000102D */ daddu $v0, $zero, $zero
/* 0F5618 802D0C68 03E00008 */ jr $ra
/* 0F561C 802D0C6C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,16 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel CloseChoice
/* 0F55A8 802D0BF8 3C04802E */ lui $a0, 0x802e
/* 0F55AC 802D0BFC 8C84B268 */ lw $a0, -0x4d98($a0)
/* 0F55B0 802D0C00 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F55B4 802D0C04 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F55B8 802D0C08 0C04971C */ jal close_message
/* 0F55BC 802D0C0C 00000000 */ nop
/* 0F55C0 802D0C10 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F55C4 802D0C14 24020001 */ addiu $v0, $zero, 1
/* 0F55C8 802D0C18 03E00008 */ jr $ra
/* 0F55CC 802D0C1C 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,13 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel EndSpeech
/* 0F4C7C 802D02CC 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F4C80 802D02D0 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F4C84 802D02D4 0C0B40C8 */ jal _show_message
/* 0F4C88 802D02D8 24060001 */ addiu $a2, $zero, 1
/* 0F4C8C 802D02DC 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F4C90 802D02E0 03E00008 */ jr $ra
/* 0F4C94 802D02E4 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,41 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SetMessageImages
/* 0F5620 802D0C70 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F5624 802D0C74 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F5628 802D0C78 8C82000C */ lw $v0, 0xc($a0)
/* 0F562C 802D0C7C 0C0496CB */ jal set_message_images
/* 0F5630 802D0C80 8C440000 */ lw $a0, ($v0)
/* 0F5634 802D0C84 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F5638 802D0C88 24020002 */ addiu $v0, $zero, 2
/* 0F563C 802D0C8C 03E00008 */ jr $ra
/* 0F5640 802D0C90 27BD0018 */ addiu $sp, $sp, 0x18
/* 0F5644 802D0C94 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F5648 802D0C98 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F564C 802D0C9C 8C82000C */ lw $v0, 0xc($a0)
/* 0F5650 802D0CA0 0C0B1EAF */ jal get_variable
/* 0F5654 802D0CA4 8C450000 */ lw $a1, ($v0)
/* 0F5658 802D0CA8 14400007 */ bnez $v0, .L802D0CC8
/* 0F565C 802D0CAC 2404FFEF */ addiu $a0, $zero, -0x11
/* 0F5660 802D0CB0 3C03800A */ lui $v1, 0x800a
/* 0F5664 802D0CB4 2463A650 */ addiu $v1, $v1, -0x59b0
/* 0F5668 802D0CB8 8C620000 */ lw $v0, ($v1)
/* 0F566C 802D0CBC 34420010 */ ori $v0, $v0, 0x10
/* 0F5670 802D0CC0 080B4337 */ j .L802D0CDC
/* 0F5674 802D0CC4 AC620000 */ sw $v0, ($v1)
.L802D0CC8:
/* 0F5678 802D0CC8 3C02800A */ lui $v0, 0x800a
/* 0F567C 802D0CCC 2442A650 */ addiu $v0, $v0, -0x59b0
/* 0F5680 802D0CD0 8C430000 */ lw $v1, ($v0)
/* 0F5684 802D0CD4 00641824 */ and $v1, $v1, $a0
/* 0F5688 802D0CD8 AC430000 */ sw $v1, ($v0)
.L802D0CDC:
/* 0F568C 802D0CDC 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F5690 802D0CE0 24020002 */ addiu $v0, $zero, 2
/* 0F5694 802D0CE4 03E00008 */ jr $ra
/* 0F5698 802D0CE8 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -1,28 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SetMessageString
/* 0F569C 802D0CEC 27BDFFE0 */ addiu $sp, $sp, -0x20
/* 0F56A0 802D0CF0 AFB10014 */ sw $s1, 0x14($sp)
/* 0F56A4 802D0CF4 0080882D */ daddu $s1, $a0, $zero
/* 0F56A8 802D0CF8 AFBF0018 */ sw $ra, 0x18($sp)
/* 0F56AC 802D0CFC AFB00010 */ sw $s0, 0x10($sp)
/* 0F56B0 802D0D00 8E30000C */ lw $s0, 0xc($s1)
/* 0F56B4 802D0D04 8E050000 */ lw $a1, ($s0)
/* 0F56B8 802D0D08 0C0B1EAF */ jal get_variable
/* 0F56BC 802D0D0C 26100004 */ addiu $s0, $s0, 4
/* 0F56C0 802D0D10 0220202D */ daddu $a0, $s1, $zero
/* 0F56C4 802D0D14 8E050000 */ lw $a1, ($s0)
/* 0F56C8 802D0D18 0C0B1EAF */ jal get_variable
/* 0F56CC 802D0D1C 0040802D */ daddu $s0, $v0, $zero
/* 0F56D0 802D0D20 0200202D */ daddu $a0, $s0, $zero
/* 0F56D4 802D0D24 0C0496CF */ jal set_message_string
/* 0F56D8 802D0D28 0040282D */ daddu $a1, $v0, $zero
/* 0F56DC 802D0D2C 8FBF0018 */ lw $ra, 0x18($sp)
/* 0F56E0 802D0D30 8FB10014 */ lw $s1, 0x14($sp)
/* 0F56E4 802D0D34 8FB00010 */ lw $s0, 0x10($sp)
/* 0F56E8 802D0D38 24020002 */ addiu $v0, $zero, 2
/* 0F56EC 802D0D3C 03E00008 */ jr $ra
/* 0F56F0 802D0D40 27BD0020 */ addiu $sp, $sp, 0x20

View File

@ -1,13 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel SpeakToPlayer
/* 0F4C60 802D02B0 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0F4C64 802D02B4 AFBF0010 */ sw $ra, 0x10($sp)
/* 0F4C68 802D02B8 0C0B40C8 */ jal _show_message
/* 0F4C6C 802D02BC 0000302D */ daddu $a2, $zero, $zero
/* 0F4C70 802D02C0 8FBF0010 */ lw $ra, 0x10($sp)
/* 0F4C74 802D02C4 03E00008 */ jr $ra
/* 0F4C78 802D02C8 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -4,6 +4,12 @@
#include "ultra64.h"
#include "types.h"
typedef struct vec3f {
/* 0x00 */ f32 x;
/* 0x04 */ f32 y;
/* 0x08 */ f32 z;
} vec3f; // size = 0x0C
typedef struct matrix4f {
/* 0x00 */ f32 mtx[4][4];
} matrix4f; // size = 0x40
@ -671,6 +677,42 @@ typedef struct npc_blur_data {
/* 0xA4 */ f32 zpos[20];
} npc_blur_data; // size = 0xF4
typedef struct npc {
/* 0x000 */ s32 flags;
/* 0x004 */ UNK_PTR onUpdate; /* run before anything else for this npc in the npc update step */
/* 0x008 */ UNK_PTR onRender; /* run after the display list for this npc is built */
/* 0x00C */ f32 yaw;
/* 0x010 */ f32 planarFlyDist; /* also used for speech, temp0? */
/* 0x014 */ f32 jumpScale; /* also used for speech, temp1? */
/* 0x018 */ f32 moveSpeed;
/* 0x01C */ f32 jumpVelocity;
/* 0x020 */ struct npc_blur_data* blurData; /* related to movement somehow... */
/* 0x024 */ char unk_24[4];
/* 0x028 */ u32 currentAnim;
/* 0x02C */ char unk_2C[12];
/* 0x038 */ struct vec3f pos;
/* 0x044 */ struct vec3f rotation;
/* 0x050 */ char unk_50[4];
/* 0x054 */ struct vec3f scale;
/* 0x060 */ struct vec3f moveToPos;
/* 0x06C */ struct vec3f colliderPos; /* used during collision with player */
/* 0x078 */ s32 shadowIndex;
/* 0x07C */ f32 shadowScale;
/* 0x080 */ char unk_80[8];
/* 0x088 */ s16 isFacingAway;
/* 0x08A */ s16 yawCamOffset;
/* 0x08C */ char unk_8C[2];
/* 0x08E */ s16 duration; /* formerly interp_counter */
/* 0x090 */ s16 homePos[3];
/* 0x096 */ char unk_96[14];
/* 0x0A4 */ u8 npcID;
/* 0x0A5 */ char unk_A5;
/* 0x0A6 */ s16 collisionRadius;
/* 0x0A8 */ s16 collisionHeight;
/* 0x0AA */ u8 renderMode;
/* 0x0AB */ char unk_AB[661];
} npc; // size = 0x340
typedef struct collider_aabb {
/* 0x00 */ f32 min[3];
/* 0x0C */ f32 max[3];

View File

@ -27,6 +27,9 @@ extern char gSunnyFlowerFieldsBg[]; // "flb_bg"
extern bg_header gBackgroundImage;
extern s8 D_8014F12F;
extern print_context* gCurrentPrintContext;
extern print_context* D_802DB268;
// Triggers
/* 0x80151334 */ extern s16 gTriggerCount;
/* 0x80159190 */ extern trigger gTriggerList1[64];

View File

@ -4,9 +4,25 @@ INCLUDE_ASM(code_f2470_len_27f0, func_802CDAC0);
INCLUDE_ASM(code_f2470_len_27f0, set_npc_animation);
INCLUDE_ASM(code_f2470_len_27f0, DeleteNpc);
s32 DeleteNpc(script_context* script, s32 initialCall) {
bytecode* ptrReadPos = script->ptrReadPos;
npc* npcPtr = get_npc_unsafe(get_variable(script, *ptrReadPos++));
INCLUDE_ASM(code_f2470_len_27f0, GetNpcPointer);
if (npcPtr) {
free_npc(npcPtr);
return 2;
}
return 2;
}
s32 GetNpcPointer(script_context* script, s32 initialCall) {
bytecode* ptrReadPos = script->ptrReadPos;
bytecode npcID = get_variable(script, *ptrReadPos++);
bytecode varNPC = *ptrReadPos++;
set_variable(script, varNPC, get_npc_safe(npcID));
return 2;
}
INCLUDE_ASM(code_f2470_len_27f0, SetNpcPos);
@ -17,6 +33,20 @@ INCLUDE_ASM(code_f2470_len_27f0, SetNpcScale);
INCLUDE_ASM(code_f2470_len_27f0, SetNpcCollisionSize);
INCLUDE_ASM(code_f2470_len_27f0, SetNpcSpeed);
// TODO: Fix issue with BNEZL vs BNEZ
/*
s32 SetNpcSpeed(script_context* script, s32 initialCall) {
bytecode* ptrReadPos = script->ptrReadPos;
bytecode npcID = get_variable(script, *ptrReadPos++);
f32 speed = get_float_variable(script, *ptrReadPos);
npc* npcPtr = resolve_npc(script, npcID);
npcPtr->moveSpeed = speed;
if(npcPtr != NULL) {
return 2;
}
}
*/
INCLUDE_ASM(code_f2470_len_27f0, SetNpcJumpscale);

View File

@ -1,12 +1,20 @@
#include "common.h"
INCLUDE_ASM(code_f4c60_len_4300, SpeakToPlayer);
s32 SpeakToPlayer(script_context* script, s32 initialCall) {
return _show_message(script, initialCall, 0);
}
INCLUDE_ASM(code_f4c60_len_4300, EndSpeech);
s32 EndSpeech(script_context* script, s32 initialCall) {
return _show_message(script, initialCall, 1);
}
INCLUDE_ASM(code_f4c60_len_4300, ContinueSpeech);
s32 ContinueSpeech(script_context* script, s32 initialCall) {
return _show_message(script, initialCall, 2);
}
INCLUDE_ASM(code_f4c60_len_4300, SpeakToNpc);
s32 SpeakToNpc(script_context* script, s32 initialCall) {
return _show_message(script, initialCall, 3);
}
INCLUDE_ASM(code_f4c60_len_4300, _show_message);
@ -20,17 +28,57 @@ INCLUDE_ASM(code_f4c60_len_4300, SwitchMessage);
INCLUDE_ASM(code_f4c60_len_4300, ShowChoice);
INCLUDE_ASM(code_f4c60_len_4300, CloseChoice);
s32 CloseChoice(script_context* script, s32 initialCall) {
close_message(D_802DB268);
return 1;
}
INCLUDE_ASM(code_f4c60_len_4300, CancelMessage);
s32 CancelMessage(script_context* script, s32 initialCall) {
cancel_message(gCurrentPrintContext);
return 2;
}
INCLUDE_ASM(code_f4c60_len_4300, CancelMessageAndBlock);
s32 CancelMessageAndBlock(script_context* script, s32 initialCall) {
cancel_message(gCurrentPrintContext);
return 0;
}
INCLUDE_ASM(code_f4c60_len_4300, SetMessageImages);
s32 SetMessageImages(script_context* script, s32 initialCall) {
set_message_images(*script->ptrReadPos);
return 2;
}
INCLUDE_ASM(code_f4c60_len_4300, SetMessageString);
s32 func_802D0C94(script_context* script, s32 initialCall) {
if (get_variable(script, *script->ptrReadPos) == 0) {
D_8009A650[0] |= 0x10;
} else {
D_8009A650[0] &= ~0x10;
}
return 2;
}
s32 SetMessageString(script_context* script, s32 initialCall) {
bytecode* ptrReadPos = script->ptrReadPos;
bytecode string = get_variable(script, *ptrReadPos++);
bytecode index = get_variable(script, *ptrReadPos++);
set_message_string(string, index);
return 2;
}
INCLUDE_ASM(code_f4c60_len_4300, SetMessageValue);
// TODO: Figure out why there's an extra NOP after this function
// It's probably because of a file split issue
/*
s32 SetMessageValue(script_context* script, s32 initialCall) {
bytecode* ptrReadPos = script->ptrReadPos;
bytecode value = get_variable(script, *ptrReadPos++);
bytecode index = get_variable(script, *ptrReadPos);
set_message_value(value, index);
return 2;
}
*/
INCLUDE_ASM(code_f4c60_len_4300, HidePlayerShadow);

View File

@ -43,6 +43,8 @@ D_8010F6D0 = 0x8010F6D0;
gBackgroundImage = 0x80200000;
D_802C3000 = 0x802C3000;
D_802DBD40 = 0x802DBD40;
gCurrentPrintContext = 0x802DB260;
D_802DB268 = 0x802DB268;
D_802E0D90 = 0x802E0D90;
D_802EB3D0 = 0x802EB3D0;