Merge pull request #26 from notyouraveragehooman/master

keese.c, input.c
This commit is contained in:
notyouraveragehooman 2020-07-15 20:52:03 -07:00 committed by GitHub
commit e7ae99c1fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 127 additions and 222 deletions

View File

@ -1,74 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start sub_08021F24
sub_08021F24: @ 0x08021F24
push {r4, lr}
adds r4, r0, #0
adds r0, #0x78
ldrh r0, [r0]
cmp r0, #0
bne _08021F48
movs r0, #2
strb r0, [r4, #0xc]
bl Random
ldr r2, _08021F44 @ =gUnk_080CB6F6
movs r1, #0xf
ands r1, r0
adds r1, r1, r2
ldrb r0, [r1]
b _08021F6E
.align 2, 0
_08021F44: .4byte gUnk_080CB6F6
_08021F48:
adds r0, r4, #0
adds r0, #0x7a
ldrh r0, [r0]
cmp r0, #0
bne _08021F80
ldr r0, _08021F7C @ =gLinkEntity
movs r2, #0x2e
ldrsh r1, [r0, r2]
movs r3, #0x32
ldrsh r2, [r0, r3]
adds r0, r4, #0
movs r3, #0x70
bl sub_0806FCB8
cmp r0, #0
bne _08021F80
movs r0, #3
strb r0, [r4, #0xc]
movs r0, #0x1e
_08021F6E:
strb r0, [r4, #0xe]
adds r0, r4, #0
movs r1, #1
bl InitializeAnimation
b _08021FA4
.align 2, 0
_08021F7C: .4byte gLinkEntity
_08021F80:
adds r0, r4, #0
bl sub_08049FA0
cmp r0, #0
beq _08021F94
bl Random
movs r1, #0x1f
ands r0, r1
b _08021F9A
_08021F94:
adds r0, r4, #0
bl sub_08049EE4
_08021F9A:
strb r0, [r4, #0x15]
adds r0, r4, #0
movs r1, #0
bl InitializeAnimation
_08021FA4:
pop {r4, pc}
.align 2, 0

View File

@ -1,54 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start ReadKeyInput
ReadKeyInput: @ 0x0801D6C0
push {lr}
ldr r0, _0801D6D4 @ =0x04000130
ldrh r0, [r0]
ldr r1, _0801D6D8 @ =0x000003FF
bics r1, r0
ldr r0, _0801D6DC @ =gUnk_03000FF0
bl sub_0801D6E0
pop {pc}
.align 2, 0
_0801D6D4: .4byte 0x04000130
_0801D6D8: .4byte 0x000003FF
_0801D6DC: .4byte gUnk_03000FF0
thumb_func_start sub_0801D6E0
sub_0801D6E0: @ 0x0801D6E0
push {lr}
adds r2, r0, #0
ldrh r0, [r2]
adds r3, r1, #0
bics r3, r0
strh r3, [r2, #2]
cmp r1, r0
bne _0801D70A
ldrb r0, [r2, #7]
subs r0, #1
strb r0, [r2, #7]
lsls r0, r0, #0x18
cmp r0, #0
bne _0801D704
movs r0, #4
strb r0, [r2, #7]
strh r1, [r2, #4]
b _0801D710
_0801D704:
movs r0, #0
strh r0, [r2, #4]
b _0801D710
_0801D70A:
movs r0, #0x14
strb r0, [r2, #7]
strh r3, [r2, #4]
_0801D710:
strh r1, [r2]
pop {pc}

View File

@ -6,85 +6,6 @@
.text .text
thumb_func_start TingleSiblings
TingleSiblings: @ 0x08064D58
push {lr}
adds r2, r0, #0
ldrb r1, [r2, #0x10]
movs r0, #2
ands r0, r1
cmp r0, #0
beq _08064D6E
adds r0, r2, #0
bl sub_08064DE4
b _08064D74
_08064D6E:
adds r0, r2, #0
bl sub_08064D78
_08064D74:
pop {pc}
.align 2, 0
thumb_func_start sub_08064D78
sub_08064D78: @ 0x08064D78
push {lr}
ldr r2, _08064D8C @ =gUnk_0810FBFC
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_08064D8C: .4byte gUnk_0810FBFC
thumb_func_start sub_08064D90
sub_08064D90: @ 0x08064D90
push {r4, lr}
adds r4, r0, #0
movs r1, #2
bl InitAnimationForceUpdate
movs r0, #1
strb r0, [r4, #0xf]
pop {r4, pc}
thumb_func_start sub_08064DA0
sub_08064DA0: @ 0x08064DA0
push {r4, lr}
adds r4, r0, #0
bl sub_08064EE8
adds r0, r4, #0
adds r0, #0x39
ldrb r0, [r0]
lsls r0, r0, #0x18
asrs r0, r0, #0x18
cmp r0, #0
beq _08064DC8
movs r0, #2
strb r0, [r4, #0xc]
adds r0, r4, #0
movs r1, #6
bl InitAnimationForceUpdate
movs r0, #0
bl TextboxNoOverlapFollow
_08064DC8:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08064DCC
sub_08064DCC: @ 0x08064DCC
push {r4, lr}
adds r4, r0, #0
bl sub_08064EE8
adds r0, r4, #0
movs r1, #2
bl InitAnimationForceUpdate
movs r0, #1
strb r0, [r4, #0xc]
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08064DE4 thumb_func_start sub_08064DE4
sub_08064DE4: @ 0x08064DE4 sub_08064DE4: @ 0x08064DE4
push {r4, r5, lr} push {r4, r5, lr}

View File

@ -50,7 +50,7 @@ typedef struct Entity {
/*0x10*/ u8 flags; /*0x10*/ u8 flags;
/*0x11*/ u8 scriptedScene : 4; /*0x11*/ u8 scriptedScene : 4;
/* */ u8 scriptedScene2 : 4; /* */ u8 scriptedScene2 : 4;
/*0x12*/ s16 spriteTileSize; /*0x12*/ s16 spriteIndex;
/*0x14*/ u8 animationState; /*0x14*/ u8 animationState;
/*0x15*/ u8 direction; /*0x15*/ u8 direction;
/*0x16*/ u8 possibleBool; /*0x16*/ u8 possibleBool;

View File

@ -319,7 +319,7 @@ SECTIONS {
src/_dmaFill32.o(.text); src/_dmaFill32.o(.text);
asm/sub_0801D630.o(.text); asm/sub_0801D630.o(.text);
asm/sub_0801D66C.o(.text); asm/sub_0801D66C.o(.text);
asm/readKeyInput.o(.text); src/input.o(.text);
asm/code_0801D714.o(.text); asm/code_0801D714.o(.text);
asm/code_0801D79C.o(.text); asm/code_0801D79C.o(.text);
/* enemies */ /* enemies */
@ -333,7 +333,6 @@ SECTIONS {
src/enemy/hangingSeed.o(.text); src/enemy/hangingSeed.o(.text);
asm/beetle.o(.text); asm/beetle.o(.text);
src/enemy/keese.o(.text); src/enemy/keese.o(.text);
asm/keese.o(.text);
asm/doorMimic.o(.text); asm/doorMimic.o(.text);
asm/rockChuchu.o(.text); asm/rockChuchu.o(.text);
asm/spinyChuchu.o(.text); asm/spinyChuchu.o(.text);
@ -560,6 +559,7 @@ SECTIONS {
asm/nayru.o(.text); asm/nayru.o(.text);
asm/farore.o(.text); asm/farore.o(.text);
asm/sturgeon.o(.text); asm/sturgeon.o(.text);
src/npc/tingleSiblings.o(.text);
asm/tingleSiblings.o(.text); asm/tingleSiblings.o(.text);
asm/stockwell.o(.text); asm/stockwell.o(.text);
src/npc/talon.o(.text); src/npc/talon.o(.text);

View File

@ -18,7 +18,7 @@ void sub_08077DF4(Entity *ent, u32 arg1)
if ((arg1 & 0xff) > 0xb8) { if ((arg1 & 0xff) > 0xb8) {
arg1 += (ent->entityType).form >> 1; arg1 += (ent->entityType).form >> 1;
} }
gLinkEntity.spriteTileSize = (short)(arg1 >> 8); gLinkEntity.spriteIndex = (short)(arg1 >> 8);
InitAnimationForceUpdate(&gLinkEntity, (u8)arg1); InitAnimationForceUpdate(&gLinkEntity, (u8)arg1);
sub_08077E54(ent); sub_08077E54(ent);
} }
@ -38,7 +38,7 @@ void sub_08077E3C(Entity *ent)
void sub_08077E54(Entity *ent) void sub_08077E54(Entity *ent)
{ {
ent->action = gLinkEntity.animIndex; ent->action = gLinkEntity.animIndex;
*(u8 *)&ent->spriteTileSize = gLinkEntity.frameIndex; *(u8 *)&ent->spriteIndex = gLinkEntity.frameIndex;
ent->previousActionFlag = gLinkEntity.frameDuration; ent->previousActionFlag = gLinkEntity.frameDuration;
ent->actionDelay = gLinkEntity.frames.all; ent->actionDelay = gLinkEntity.frames.all;
} }

View File

@ -14,6 +14,8 @@ extern void sub_08021EF0(Entity*);
extern void sub_080AEFB4(Entity*); extern void sub_080AEFB4(Entity*);
extern void sub_08021F24(Entity*); extern void sub_08021F24(Entity*);
extern u32 sub_0806FCB8(Entity*, s32, s32, u32); extern u32 sub_0806FCB8(Entity*, s32, s32, u32);
extern u32 sub_08049FA0(Entity*);
extern u32 sub_08049EE4(Entity*);
extern void (*gUnk_080CB69C[])(Entity*); extern void (*gUnk_080CB69C[])(Entity*);
extern void (*gUnk_080CB6B4[])(Entity*); extern void (*gUnk_080CB6B4[])(Entity*);
@ -21,9 +23,7 @@ extern void (*gUnk_080CB6C4[])(Entity*);
extern u8 gUnk_080CB6D0[]; extern u8 gUnk_080CB6D0[];
extern u16 gUnk_080CB6D6[]; extern u16 gUnk_080CB6D6[];
extern u8 gUnk_080CB6F6[];
extern u8 gUnk_080CB6D0[];
void Keese(Entity *this) void Keese(Entity *this)
{ {
@ -129,3 +129,28 @@ void sub_08021EF0(Entity *this)
this->field_0x7a = 0x3c; this->field_0x7a = 0x3c;
InitializeAnimation(this, 0); InitializeAnimation(this, 0);
} }
void sub_08021F24(Entity *this)
{
u32 bVar1;
if (this->field_0x78.HWORD == 0) {
this->action = 2;
this->actionDelay = gUnk_080CB6F6[Random() & 0xf];
InitializeAnimation(this, 1);
}
else if (!this->field_0x7a && !(sub_0806FCB8(this, gLinkEntity.x.HALF.HI, gLinkEntity.y.HALF.HI, 0x70))) {
this->action = 3;
this->actionDelay = 0x1e;
InitializeAnimation(this, 1);
}
else {
if (sub_08049FA0(this) != 0) {
this->direction = Random() & 0x1f;
}
else {
this->direction = sub_08049EE4(this);
}
InitializeAnimation(this, 0);
}
}

44
src/input.c Normal file
View File

@ -0,0 +1,44 @@
#include "global.h"
#include "entity.h"
typedef struct {
u16 field_0x0;
u16 field_0x2;
u16 field_0x4;
u8 field_0x6;
u8 field_0x7;
} Input;
void StoreKeyInput(Input *pkeyInput, u32 ioKeyInput);
extern Input gUnk_03000FF0;
void ReadKeyInput(void)
{
u32 reg = ~*(u16*)0x04000130 & 0x3FF;
Input* input = &gUnk_03000FF0;
StoreKeyInput(input, reg);
}
void StoreKeyInput(Input *input, u32 ioKeyInput)
{
u32 difference;
u32 temp = input->field_0x0;
difference = ioKeyInput & ~temp;
input->field_0x2 = difference;
if (ioKeyInput == temp) {
if (--input->field_0x7 == 0) {
input->field_0x7 = 4;
input->field_0x4 = ioKeyInput;
}
else {
input->field_0x4 = 0;
}
}
else {
input->field_0x7 = 0x14;
input->field_0x4 = difference;
}
input->field_0x0 = ioKeyInput;
}

View File

@ -56,7 +56,7 @@ void sub_08018CBC(Entity *this)
} }
this->action = 2; this->action = 2;
this->spriteSettings.b.draw = 1; this->spriteSettings.b.draw = 1;
this->spriteTileSize = 0xa6; this->spriteIndex = 0xa6;
this->palette = 0x33; this->palette = 0x33;
this->spriteVramOffset = 0; this->spriteVramOffset = 0;
(this->entityType).form = gLinkState.field_0x1d[0] - 1; (this->entityType).form = gLinkState.field_0x1d[0] - 1;

43
src/npc/tingleSiblings.c Normal file
View File

@ -0,0 +1,43 @@
#include "global.h"
#include "entity.h"
#include "npc.h"
#include "textbox.h"
extern void sub_08064DE4(Entity*);
extern void sub_08064D78(Entity*);
extern void sub_08064EE8(Entity*);
extern void (*const gUnk_0810FBFC[])(Entity*);
void TingleSiblings(Entity* this) {
if ((this->flags & 2) != 0) {
sub_08064DE4(this);
}
else {
sub_08064D78(this);
}
}
void sub_08064D78(Entity* this) {
gUnk_0810FBFC[this->action](this);
}
void sub_08064D90(Entity* this) {
InitAnimationForceUpdate(this, 2);
this->field_0xf = 1;
}
void sub_08064DA0(Entity* this) {
sub_08064EE8(this);
if (this->interactType != 0) {
this->action = 2;
InitAnimationForceUpdate(this, 6);
TextboxNoOverlapFollow(0);
}
}
void sub_08064DCC(Entity* this) {
sub_08064EE8(this);
InitAnimationForceUpdate(this, 2);
this->action = 1;
}

View File

@ -192,7 +192,7 @@ void sub_08061E90(Entity* this, Entity* arg1) {
if (arg1->spriteSettings.raw == 0) { if (arg1->spriteSettings.raw == 0) {
arg1->spriteSettings.raw++; arg1->spriteSettings.raw++;
arg1->spriteTileSize = (Random() & 0x3f) + 0x20; arg1->spriteIndex = (Random() & 0x3f) + 0x20;
animIndex = Random() & 0x18; animIndex = Random() & 0x18;
switch (this->direction) { switch (this->direction) {
case 0x0: case 0x0:
@ -227,23 +227,23 @@ void sub_08061E90(Entity* this, Entity* arg1) {
iVar4 = this->x.HALF.HI - *(s16*)&this->field_0x6a.HWORD; iVar4 = this->x.HALF.HI - *(s16*)&this->field_0x6a.HWORD;
if (0x10 < iVar4) { if (0x10 < iVar4) {
this->x.HALF.HI = this->field_0x6a.HWORD + 0x10; this->x.HALF.HI = this->field_0x6a.HWORD + 0x10;
arg1->spriteTileSize = 1; arg1->spriteIndex = 1;
} }
if (iVar4 < -0x10) { if (iVar4 < -0x10) {
this->x.HALF.HI = *(s16*)&this->field_0x6a.HWORD - 0x10; this->x.HALF.HI = *(s16*)&this->field_0x6a.HWORD - 0x10;
arg1->spriteTileSize = 1; arg1->spriteIndex = 1;
} }
iVar4 = this->y.HALF.HI - *(s16*)&this->field_0x6c; iVar4 = this->y.HALF.HI - *(s16*)&this->field_0x6c;
if (0x10 < iVar4) { if (0x10 < iVar4) {
this->y.HALF.HI = *(s16*)&this->field_0x6c + 0x10; this->y.HALF.HI = *(s16*)&this->field_0x6c + 0x10;
arg1->spriteTileSize = 1; arg1->spriteIndex = 1;
} }
if (iVar4 < -0x10) { if (iVar4 < -0x10) {
this->y.HALF.HI = *(s16*)&this->field_0x6c - 0x10; this->y.HALF.HI = *(s16*)&this->field_0x6c - 0x10;
arg1->spriteTileSize = 1; arg1->spriteIndex = 1;
} }
if (--arg1->spriteTileSize != 0) { if (--arg1->spriteIndex != 0) {
gUnk_02033280[6] = 0; gUnk_02033280[6] = 0;
} }
} }