Push functions matched on decomp.me by various people

This commit is contained in:
Tal Hayon
2022-07-11 01:33:43 +03:00
parent 021e77b203
commit 3259c71966
17 changed files with 362 additions and 1318 deletions
+4 -6
View File
@@ -10,15 +10,13 @@ extern void ram_DrawEntities(void);
extern void ram_sub_080ADA04(OAMCommand*, void*);
extern void ram_DrawDirect(OAMCommand*, u32, u32);
// regalloc
NONMATCH("asm/non_matching/vram/sub_080AD8F0.inc", void* sub_080AD8F0(u32 sprite, u32 frame)) {
void* sub_080AD8F0(u32 sprite, u32 frame) {
u32* temp = &gFrameObjLists[0];
u32 x = gFrameObjLists[sprite];
u8* y = (u8*)&gFrameObjLists[frame];
u32 tmp = *(u32*)&y[x];
temp = (u32*)((uintptr_t)(((u32*)((uintptr_t)temp + x))[frame]) + (uintptr_t)temp);
return (u8*)gFrameObjLists + tmp;
return temp;
}
END_NONMATCH
void FlushSprites(void) {
gOAMControls.updated = 0;
+13 -17
View File
@@ -154,28 +154,24 @@ u32 sub_080176E4(Entity* this) {
}
}
// Several issues:
// 1. b2 mask value is set before the loop even begins
// 2. data is allocated mid function
// 3. regalloc
NONMATCH("asm/non_matching/arm_proxy/sub_08017744.inc", void sub_08017744(Entity* this)) {
LinkedList2* i;
LinkedList2* end;
for (i = gUnk_03003C70, end = gUnk_03003C70 + 16; end > i; ++i) {
if (i->node == this) {
void sub_08017744(Entity* this) {
LinkedList2* ll = gUnk_03003C70;
LinkedList2* end = &gUnk_03003C70[16];
do {
if (this == ll->node) {
if (this->spritePriority.b2 != 0) {
this->spritePriority.b2 = 0;
i->node = NULL;
((LinkedList2*)i->last)->first = i->first;
((LinkedList2*)i->first)->last = i->last;
if (i != gUnk_02018EA0)
return;
gUnk_02018EA0 = i->first;
ll->node = NULL;
((LinkedList2*)ll->last)->first = ll->first;
((LinkedList2*)ll->first)->last = ll->last;
if (ll == gUnk_02018EA0)
gUnk_02018EA0 = ll->first;
break;
}
}
}
} while (end > ++ll);
}
END_NONMATCH
bool32 IsColliding(Entity* this, Entity* that) {
u32 this_d;
+49 -47
View File
@@ -107,15 +107,16 @@ u16 EEPROMWrite1(u16 address, const u16* data) {
}
// reading from EEPROM like a status register
#define REG_EEPROM (*(u16*)0xd000000)
// this is the furthest I could get
// 0x080B16AC
NONMATCH("asm/non_matching/code_080B1520/EEPROMWrite.inc", u16 EEPROMWrite(u16 address, const u16* data, u8 unk_3)) {
#define REG_EEPROM (*(vu16*)0xd000000)
u16 EEPROMWrite(u16 address, const u16* data, u8 unk_3) {
u16 buffer[0x52]; // this is one too large?
vu16 stack_a4;
vu16 timeout_flag;
vu16 prev_vcount; // stack + a6
vu16 current_vcount; // stack + a6
vu16 current_vcount; // stack + a8
vu32 passed_scanlines; // stack + ac
u16 ret;
vu16* temp2;
u32 r2;
@@ -125,64 +126,65 @@ NONMATCH("asm/non_matching/code_080B1520/EEPROMWrite.inc", u16 EEPROMWrite(u16 a
if (address >= gEEPROMConfig->size)
return EEPROM_OUT_OF_RANGE;
ptr = buffer + gEEPROMConfig->address_width + 0x42;
*ptr = 0;
ptr--;
ptr = (u16*)(0x42 + (uintptr_t)&buffer + (uintptr_t)(gEEPROMConfig->address_width * 2) + 0x42);
*ptr-- = 0;
// copy data into buffer
for (i = 0; i <= 3; i++) {
r2 = *data;
data++;
for (j = 0; j <= 0xf; j++) {
for (i = 0; i < 4; i++) {
r2 = *data++;
for (j = 0; j < 16; j++) {
*ptr = r2;
ptr--;
r2 = r2 >> 1;
}
}
// copy address to buffer
for (i = 0; i < gEEPROMConfig->address_width; i++) {
*ptr = address;
ptr--;
address = address >> 1;
}
*ptr = 0;
ptr--;
*ptr = 1;
*ptr-- = 0;
*ptr-- = 1;
DMA3Transfer(buffer, (u16*)0xd000000, gEEPROMConfig->address_width + 0x43);
stack_a4 = 0;
ret = 0;
timeout_flag = 0;
prev_vcount = REG_VCOUNT;
passed_scanlines = 0;
if (stack_a4 == 0) {
if ((REG_EEPROM & 1) != 0)
goto bad;
}
// before here its only regalloc, but after I cant get it to work
do {
do {
do {
current_vcount = REG_VCOUNT;
if (current_vcount != prev_vcount) {
if (current_vcount >= prev_vcount) {
passed_scanlines += current_vcount - prev_vcount;
} else {
passed_scanlines += (current_vcount + 0xe4) - prev_vcount;
}
if (passed_scanlines > 0x88) {
if (stack_a4 != 0)
return 0;
if ((REG_EEPROM & 1) != 0)
return 0;
return 0xc001;
}
prev_vcount = current_vcount;
while (1) {
if (!timeout_flag) {
if (REG_EEPROM & 1) {
timeout_flag++;
if (!unk_3)
break;
}
}
current_vcount = REG_VCOUNT;
if (current_vcount != prev_vcount) {
if (current_vcount > prev_vcount) {
passed_scanlines += (current_vcount - prev_vcount);
} else {
passed_scanlines += (current_vcount - (prev_vcount - 0xE4));
}
if (passed_scanlines > 0x88) {
if (timeout_flag)
break;
if ((REG_EEPROM & 1)) {
break;
}
} while (stack_a4 != 0);
} while ((REG_EEPROM & 1) != 0);
bad:
stack_a4++;
} while (unk_3 != 0);
return 0;
ret = 0xc001;
break;
}
prev_vcount = current_vcount;
}
}
return ret;
}
END_NONMATCH
u16 EEPROMCompare(u16 address, const u16* data) {
u16 ret;
+61 -64
View File
@@ -757,81 +757,78 @@ void sub_08050EB8(void) {
SetMenuType(1);
}
NONMATCH("asm/non_matching/fileScreen/sub_08050EF4.inc", void sub_08050EF4(void)) {
void sub_08050EF4(void) {
u8* p_option;
u32 option;
char column_idx;
int mode;
u8 mode;
if (gMapDataBottomSpecial.isTransitioning)
return;
if (gMapDataBottomSpecial.isTransitioning == 0) {
SaveFile* currentFile = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6];
column_idx = gMenu.column_idx;
p_option = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].brightness;
if (gMenu.column_idx == 0) {
p_option = &gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed;
}
if (column_idx == 0) {
p_option = &currentFile->msg_speed;
} else {
p_option = &currentFile->brightness;
}
mode = 0;
option = *p_option;
column_idx = gMenu.column_idx;
switch (gInput.newKeys) {
case DPAD_RIGHT:
if (*p_option < 2) {
option = *p_option + 1;
}
break;
case DPAD_LEFT:
if (*p_option != 0) {
option = *p_option - 1;
}
break;
case DPAD_UP:
column_idx = 0;
break;
case DPAD_DOWN:
column_idx = 1;
break;
case A_BUTTON:
case START_BUTTON:
mode = 2;
if (*(u16*)&gMapDataBottomSpecial.unk4 !=
*(u16*)&gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed)
option = *p_option;
mode = 0;
switch (gInput.newKeys) {
case DPAD_UP:
column_idx = 0;
break;
case DPAD_DOWN:
column_idx = 1;
break;
case DPAD_LEFT:
if (option != 0) {
option--;
}
break;
case DPAD_RIGHT:
if (option < 2) {
option++;
}
break;
case A_BUTTON:
case START_BUTTON:
if (gMapDataBottomSpecial.unk4 != currentFile->msg_speed ||
gMapDataBottomSpecial.unk5 != currentFile->brightness) {
mode = 2;
break;
}
case B_BUTTON:
mode = 3;
break;
case B_BUTTON:
mode = 2;
break;
}
break;
}
switch (mode) {
case 3:
gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].msg_speed = gMapDataBottomSpecial.unk4;
gMapDataBottomSpecial.saves[gMapDataBottomSpecial.unk6].brightness = gMapDataBottomSpecial.unk5;
SoundReq(SFX_MENU_CANCEL);
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
break;
case 2:
CreateDialogBox(8, 0);
SoundReq(SFX_TEXTBOX_SELECT);
default:
case 1:
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
break;
case 0:
if (gMenu.column_idx != column_idx) {
gMenu.column_idx = column_idx;
SoundReq(SFX_TEXTBOX_CHOICE);
} else if (option != *p_option) {
*p_option = option;
LoadOptionsFromSave(gMapDataBottomSpecial.unk6);
SoundReq(SFX_TEXTBOX_CHOICE);
if (mode != 0) {
switch (mode) {
case 2:
CreateDialogBox(8, 0);
SoundReq(SFX_TEXTBOX_SELECT);
break;
case 3:
currentFile->msg_speed = gMapDataBottomSpecial.unk4;
currentFile->brightness = gMapDataBottomSpecial.unk5;
SoundReq(SFX_MENU_CANCEL);
break;
}
break;
SetMenuType(mode);
SetActiveSave(gMapDataBottomSpecial.unk6);
} else if (gMenu.column_idx != column_idx) {
gMenu.column_idx = column_idx;
SoundReq(SFX_TEXTBOX_CHOICE);
} else if (option != *p_option) {
*p_option = option;
LoadOptionsFromSave(gMapDataBottomSpecial.unk6);
SoundReq(SFX_TEXTBOX_CHOICE);
}
}
}
END_NONMATCH
void sub_08050FFC(void) {
switch (HandleSave(0)) {
+31 -26
View File
@@ -226,8 +226,7 @@ u8* const gUnk_08107BE0[] = {
&gUnk_020227DC, &gUnk_020227E8, &gUnk_020227F0, &gUnk_020227F8, &gUnk_02022800,
};
// regalloc in loop
NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
u32 MsgInit(void) {
char* dest;
u32 i;
@@ -240,20 +239,21 @@ NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
}
gTextRender._9c = 0xff;
sub_0805EEB4(&gTextRender.curToken, gTextRender.message.textIndex);
gTextRender.player_name[0] = 2;
gTextRender.player_name[1] = 0xe; // Green text color
dest = &gTextRender.player_name[2];
dest = &gTextRender.player_name[0];
dest[0] = 2;
dest[1] = 0xe; // Green text color
dest += 2;
for (i = 0; i < FILENAME_LENGTH; ++i) {
char c = gSave.name[i];
if (c == 0)
if (c == '\0')
break;
*dest++ = c;
}
dest[0] = 2;
dest[1] = 0xf; // White text color
dest[2] = 0;
dest[2] = '\0';
sub_08056FBC(&gTextRender);
gTextRender.curToken._c = &gUnk_08107BE0;
gTextRender._50.unk8 = gTextGfxBuffer;
@@ -263,7 +263,6 @@ NONMATCH("asm/non_matching/textbox/MsgInit.inc", /*static*/ u32 MsgInit(void)) {
StatusUpdate(MSG_UPDATE);
return 1;
}
END_NONMATCH
/*static*/ u32 MsgOpen(void) {
if (gTextRender.renderStatus == RENDER_INIT) {
@@ -366,9 +365,12 @@ static void TextDispUpdate(TextRender* this) {
}
}
NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCommand(TextRender* this)) {
s32 palette;
u16 RunTextCommand(TextRender* this) {
u32 chr = this->curToken.extended;
s32 temp;
u32 tmp2;
u32 tmp3;
u32* ptr;
if (chr == 0) {
s32 r1;
@@ -377,7 +379,9 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
case 0:
if (gUnk_02000040.unk_00 == 1) {
this->renderStatus = RENDER_ENQUIRY;
#ifndef EU
SwitchChoice(0, 0);
#endif
} else {
this->renderStatus = RENDER_DIE;
}
@@ -397,29 +401,31 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
StatusUpdate(MSG_CLOSE);
break;
case 4:
this->_50.unk6 += (this->_50.unk4 - this->_50.unk6 - GetFontStrWith(&this->curToken, 0)) / 2;
temp = GetFontStrWith(&this->curToken, 0);
this->_50.unk6 = this->_50.unk6 + (this->_50.unk4 - this->_50.unk6 - temp) / 2;
break;
case 5:
gMessage.unk = this->curToken.param;
break;
case 6:
WriteBit(&gMessage.field_0xc, this->curToken.param & 0x1f);
ptr = &gMessage.field_0xc;
tmp3 = this->curToken.param;
tmp3 &= 0x1f;
WriteBit(ptr, tmp3);
break;
case 7:
switch (this->curToken.param) {
temp = this->curToken.param;
switch (temp) {
case 0xe:
this->_91 = this->_8f;
palette = 2;
temp = 2;
break;
case 0xf:
palette = this->_91;
break;
default:
palette = this->curToken.param;
temp = this->_91;
break;
}
this->_90 = 0;
PaletteChange(this, palette);
PaletteChange(this, temp);
break;
case 8:
SoundReq(this->curToken.param);
@@ -447,7 +453,8 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
this->_50.unk6 += 8;
break;
case 13:
switch (this->curToken.param) {
temp = this->curToken.param;
switch (temp) {
case 0xff:
this->_8e = 1;
break;
@@ -455,13 +462,12 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
this->_8e = 2;
break;
default:
this->delay = this->curToken.param;
this->delay = temp;
break;
}
break;
case 14:
r1 = this->curToken.param;
this->_94 = r1;
this->_94 = this->curToken.param;
break;
default:
break;
@@ -482,14 +488,13 @@ NONMATCH("asm/non_matching/textbox/RunTextCommand.inc", /*static*/ u16 RunTextCo
PaletteChange(this, 0);
} else {
if ((this->_90 & 0x80) != 0) {
palette = this->_90;
temp = this->_90;
this->_90 = 0;
PaletteChange(this, palette);
PaletteChange(this, temp);
}
}
return sub_0805F7DC(chr, &this->_50);
}
END_NONMATCH
/*static*/ void PaletteChange(TextRender* this, u32 id) {
u32 temp = id % 8;
+32 -144
View File
@@ -3,140 +3,6 @@
#include "room.h"
#include "npc.h"
//clang-format off
void (*const gNPCFunctions[][3])(Entity* ent) = {
[NPC_NONE_0] = { DeleteEntity, NULL, NULL },
[GENTARI] = { Gentari, NULL, Gentari_Fusion },
[FESTARI] = { Festari, NULL, Festari_Fusion },
[FOREST_MINISH] = { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
[POSTMAN] = { Postman, NULL, Postman_Fusion },
[NPC_UNK_5] = { NPC5, NULL, NULL },
[TPWNSPERSON] = { Townsperson, Townsperson_Head, Townsperson_Fusion },
[KID] = { Kid, Kid_Head, Kid_Fusion },
[GUARD] = { Guard, Guard_Head, NULL },
[NPC_UNK_9] = { NPC9, NULL, NULL },
[STAMP] = { Stamp, NULL, NULL },
[MAID] = { Maid, Maid_Head, NULL },
[MARCY] = { Marcy, NULL, NULL },
[WHEATON] = { Wheaton, NULL, NULL },
[PITA] = { Pita, NULL, NULL },
[MINISH_EZLO] = { MinishEzlo, MinishEzlo_Head, NULL },
[MAILBOX] = { Mailbox, NULL, NULL },
[BEEDLE] = { Beedle, Beedle_Head, NULL },
[BROCCO] = { Brocco, NULL, Brocco_Fusion },
[SITTING_PERSON] = { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
[PINA] = { Pina, NULL, Pina_Fusion },
[GUARD_1] = { Guard, Guard_Head, NULL },
[MAID_1] = { Maid, Maid_Head, NULL },
[DIN] = { Din, NULL, Din_Fusion },
[NAYRU] = { Nayru, NULL, Nayru_Fusion },
[FARORE] = { Farore, NULL, Farore_Fusion },
[STURGEON] = { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
[TINGLE_SIBLINGS] = { TingleSiblings, NULL, TingleSiblings_Fusion },
[STOCKWELL] = { Stockwell, NULL, NULL },
[TALON] = { Talon, Talon_Head, Talon_Fusion },
[MALON] = { Malon, NULL, Malon_Fusion },
[EPONA] = { Epona, NULL, Epona_Fusion },
[MILK_CART] = { MilkCart, NULL, NULL },
[GHOST_BROTHERS] = { GhostBrothers, NULL, GhostBrothers_Fusion },
[SMITH] = { Smith, Smith_Head, Smith_Fusion },
[NPC_UNK_23] = { NPC23, NULL, NULL },
[KING_DALTUS] = { KingDaltus, NULL, KingDaltus_Fusion },
[MINISTER_POTHO] = { MinisterPotho, NULL, MinisterPotho_Fusion },
[NPC_UNK_26] = { NPC26, NULL, NULL },
[VAATI] = { Vaati, NULL, NULL },
[ZELDA] = { Zelda, NULL, NULL },
[MUTOH] = { Mutoh, Mutoh_Head, Mutoh_Fusion },
[CARPENTER] = { Carpenter, Carpenter_Head, Carpenter_Fusion },
[CASTOR_WILDS_STATUE] = { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
[CAT] = { Cat, NULL, Cat_Fusion },
[MOUNTAIN_MINISH] = { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
[ZELDA_FOLLOWER] = { ZeldaFollower, NULL, NULL },
[MELARI] = { Melari, Melari_Head, Melari_Fusion },
[BLADE_BROTHERS] = { BladeBrothers, NULL, BladeBrothers_Fusion },
[COW] = { Cow, NULL, Cow_Fusion },
[GORON] = { Goron, NULL, Goron_Fusion },
[GORON_MERCHANT] = { GoronMerchant, NULL, NULL },
[GORMAN] = { Gorman, Gorman_Head, NULL },
[DOG] = { Dog, Dog_Head, Dog_Fusion },
[SYRUP] = { Syrup, Syrup_Head, NULL },
[REM] = { Rem, NULL, NULL },
[TOWN_MINISH] = { TownMinish, TownMinish_Head, TownMinish_Fusion },
[LIBRARI] = { Librari, NULL, Librari_Fusion },
[PERCY] = { Percy, Percy_Head, Percy_Fusion },
[VAATI_REBORN] = { VaatiReborn, NULL, NULL },
[MOBLIN_LADY] = { MoblinLady, NULL, NULL },
[LIBRARIANS] = { Librarians, NULL, NULL },
[FARMERS] = { Farmers, Farmers_Head, Farmers_Fusion },
[CARLOV] = { Carlov, NULL, NULL },
[DAMPE] = { Dampe, NULL, Dampe_Fusion },
[DR_LEFT] = { DrLeft, NULL, NULL },
[KING_GUSTAF] = { KingGustaf, NULL, NULL },
[GINA] = { Gina, NULL, Gina_Fusion },
[SIMON] = { Simon, NULL, NULL },
[ANJU] = { Anju, NULL, Anju_Fusion },
[MAMA] = { Mama, Mama_Head, Mama_Fusion },
[EMMA] = { Emma, NULL, NULL },
[TEACHERS] = { Teachers, Teachers_Head, Teachers_Fusion },
[WIND_TRIBESPEOPLE] = { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
[GREGAL] = { Gregal, NULL, Gregal_Fusion },
[MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion },
[BIG_GORON] = { BigGoron, NULL, NULL },
[EZLO] = { Ezlo, NULL, NULL },
[NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion },
[NPC_UNK_4F] = { NPC4F, NULL, NULL },
[CLOTHES_RACK] = { ClothesRack, NULL, NULL },
[PICOLYTE_BOTTLE] = { PicolyteBottle, NULL, NULL },
[SMALL_TOWN_MINISH] = { SmallTownMinish, NULL, NULL },
[HURDY_GURDY_MAN] = { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
[CUCCO] = { Cucco, NULL, Cucco_Fusion },
[CUCCO_CHICK] = { CuccoChick, NULL, CuccoChick_Fusion },
[FUSION_MENU_NPC] = { FusionMenuNPC, FusionMenuNPC_Head, NULL },
[PHONOGRAPH] = { Phonograph, NULL, NULL },
[NPC_UNK_58] = { NPC58, NPC58_Head, NULL },
[NPC_NONE_1] = { DeleteEntity, NULL, NULL },
[NPC_NONE_2] = { DeleteEntity, NULL, NULL },
[NPC_NONE_3] = { DeleteEntity, NULL, NULL },
[NPC_NONE_4] = { DeleteEntity, NULL, NULL },
[NPC_NONE_5] = { DeleteEntity, NULL, NULL },
[NPC_NONE_6] = { DeleteEntity, NULL, NULL },
[NPC_NONE_7] = { DeleteEntity, NULL, NULL },
[NPC_NONE_8] = { DeleteEntity, NULL, NULL },
[NPC_NONE_9] = { DeleteEntity, NULL, NULL },
[NPC_NONE_10] = { DeleteEntity, NULL, NULL },
[NPC_NONE_11] = { DeleteEntity, NULL, NULL },
[NPC_NONE_12] = { DeleteEntity, NULL, NULL },
[NPC_NONE_13] = { DeleteEntity, NULL, NULL },
[NPC_NONE_14] = { DeleteEntity, NULL, NULL },
[NPC_NONE_15] = { DeleteEntity, NULL, NULL },
[NPC_NONE_16] = { DeleteEntity, NULL, NULL },
[NPC_NONE_17] = { DeleteEntity, NULL, NULL },
[NPC_NONE_18] = { DeleteEntity, NULL, NULL },
[NPC_NONE_19] = { DeleteEntity, NULL, NULL },
[NPC_NONE_20] = { DeleteEntity, NULL, NULL },
[NPC_NONE_21] = { DeleteEntity, NULL, NULL },
[NPC_NONE_22] = { DeleteEntity, NULL, NULL },
[NPC_NONE_23] = { DeleteEntity, NULL, NULL },
[NPC_NONE_24] = { DeleteEntity, NULL, NULL },
[NPC_NONE_25] = { DeleteEntity, NULL, NULL },
[NPC_NONE_26] = { DeleteEntity, NULL, NULL },
[NPC_NONE_27] = { DeleteEntity, NULL, NULL },
[NPC_NONE_28] = { DeleteEntity, NULL, NULL },
[NPC_NONE_29] = { DeleteEntity, NULL, NULL },
[NPC_NONE_30] = { DeleteEntity, NULL, NULL },
[NPC_NONE_31] = { DeleteEntity, NULL, NULL },
[NPC_NONE_32] = { DeleteEntity, NULL, NULL },
[NPC_NONE_33] = { DeleteEntity, NULL, NULL },
[NPC_NONE_34] = { DeleteEntity, NULL, NULL },
[NPC_NONE_35] = { DeleteEntity, NULL, NULL },
[NPC_NONE_36] = { DeleteEntity, NULL, NULL },
[NPC_NONE_37] = { DeleteEntity, NULL, NULL },
[NPC_NONE_38] = { DeleteEntity, NULL, NULL },
[NPC_NONE_39] = { DeleteEntity, NULL, NULL }
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
extern u32 gUnk_020342F8;
typedef struct {
u16 unk0;
@@ -146,25 +12,47 @@ typedef struct {
} NPCStruct;
extern NPCStruct gNPCData[100];
void InitNPC(Entity*);
extern void InitNPC(Entity*);
// regalloc
NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
if ((this->health & 0x7f) && !ReadBit(&gUnk_020342F8, this->health - 1))
// NONMATCH("asm/non_matching/arm_proxy/NPCUpdate.inc", void NPCUpdate(Entity* this)) {
// if ((this->health & 0x7f) && !ReadBit(&gUnk_020342F8, this->health - 1))
// DeleteThisEntity();
// if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
// InitNPC(this);
// if (!EntityIsDeleted(this))
// gNPCFunctions[this->id][0](this);
// if (this->next != NULL) {
// if (gNPCFunctions[this->id][1] != NULL)
// gNPCFunctions[this->id][1](this);
// if ((this->health & 0x7f) != 0) {
// u32 temp = this->health & 0x7f;
// gNPCData[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x;
// gNPCData[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y;
// }
// DrawEntity(this);
// }
// }
// END_NONMATCH
void NPCUpdate(Entity* this) {
u32 health = this->health;
u32 temp;
if ((health & 0x7f) && !ReadBit(&gUnk_020342F8, health - 1))
DeleteThisEntity();
if (this->action == 0 && (this->flags & ENT_DID_INIT) == 0)
InitNPC(this);
NPCInit(this);
if (!EntityIsDeleted(this))
gNPCFunctions[this->id][0](this);
if (this->next != NULL) {
if (gNPCFunctions[this->id][1] != NULL)
gNPCFunctions[this->id][1](this);
if ((this->health & 0x7f) != 0) {
u32 temp = this->health & 0x7f;
gNPCData[temp * 2 - 2].x = this->x.HALF.HI - gRoomControls.origin_x;
gNPCData[temp * 2 - 2].y = this->y.HALF.HI - gRoomControls.origin_y;
if (this->health % 0x80) {
NPCStruct* npc = gNPCData;
npc += (this->health * 2 - 2);
npc->x = this->x.HALF.HI - gRoomControls.origin_x;
npc->y = this->y.HALF.HI - gRoomControls.origin_y;
}
DrawEntity(this);
}
}
END_NONMATCH
+135
View File
@@ -0,0 +1,135 @@
#include "npc.h"
//clang-format off
void (*const gNPCFunctions[][3])(Entity* ent) = {
[NPC_NONE_0] = { DeleteEntity, NULL, NULL },
[GENTARI] = { Gentari, NULL, Gentari_Fusion },
[FESTARI] = { Festari, NULL, Festari_Fusion },
[FOREST_MINISH] = { ForestMinish, ForestMinish_Head, ForestMinish_Fusion },
[POSTMAN] = { Postman, NULL, Postman_Fusion },
[NPC_UNK_5] = { NPC5, NULL, NULL },
[TPWNSPERSON] = { Townsperson, Townsperson_Head, Townsperson_Fusion },
[KID] = { Kid, Kid_Head, Kid_Fusion },
[GUARD] = { Guard, Guard_Head, NULL },
[NPC_UNK_9] = { NPC9, NULL, NULL },
[STAMP] = { Stamp, NULL, NULL },
[MAID] = { Maid, Maid_Head, NULL },
[MARCY] = { Marcy, NULL, NULL },
[WHEATON] = { Wheaton, NULL, NULL },
[PITA] = { Pita, NULL, NULL },
[MINISH_EZLO] = { MinishEzlo, MinishEzlo_Head, NULL },
[MAILBOX] = { Mailbox, NULL, NULL },
[BEEDLE] = { Beedle, Beedle_Head, NULL },
[BROCCO] = { Brocco, NULL, Brocco_Fusion },
[SITTING_PERSON] = { SittingPerson, SittingPerson_Head, SittingPerson_Fusion },
[PINA] = { Pina, NULL, Pina_Fusion },
[GUARD_1] = { Guard, Guard_Head, NULL },
[MAID_1] = { Maid, Maid_Head, NULL },
[DIN] = { Din, NULL, Din_Fusion },
[NAYRU] = { Nayru, NULL, Nayru_Fusion },
[FARORE] = { Farore, NULL, Farore_Fusion },
[STURGEON] = { Sturgeon, Sturgeon_Head, Sturgeon_Fusion },
[TINGLE_SIBLINGS] = { TingleSiblings, NULL, TingleSiblings_Fusion },
[STOCKWELL] = { Stockwell, NULL, NULL },
[TALON] = { Talon, Talon_Head, Talon_Fusion },
[MALON] = { Malon, NULL, Malon_Fusion },
[EPONA] = { Epona, NULL, Epona_Fusion },
[MILK_CART] = { MilkCart, NULL, NULL },
[GHOST_BROTHERS] = { GhostBrothers, NULL, GhostBrothers_Fusion },
[SMITH] = { Smith, Smith_Head, Smith_Fusion },
[NPC_UNK_23] = { NPC23, NULL, NULL },
[KING_DALTUS] = { KingDaltus, NULL, KingDaltus_Fusion },
[MINISTER_POTHO] = { MinisterPotho, NULL, MinisterPotho_Fusion },
[NPC_UNK_26] = { NPC26, NULL, NULL },
[VAATI] = { Vaati, NULL, NULL },
[ZELDA] = { Zelda, NULL, NULL },
[MUTOH] = { Mutoh, Mutoh_Head, Mutoh_Fusion },
[CARPENTER] = { Carpenter, Carpenter_Head, Carpenter_Fusion },
[CASTOR_WILDS_STATUE] = { CastorWildsStatue, NULL, CastorWildsStatue_Fusion },
[CAT] = { Cat, NULL, Cat_Fusion },
[MOUNTAIN_MINISH] = { MountainMinish, MountainMinish_Head, MountainMinish_Fusion },
[ZELDA_FOLLOWER] = { ZeldaFollower, NULL, NULL },
[MELARI] = { Melari, Melari_Head, Melari_Fusion },
[BLADE_BROTHERS] = { BladeBrothers, NULL, BladeBrothers_Fusion },
[COW] = { Cow, NULL, Cow_Fusion },
[GORON] = { Goron, NULL, Goron_Fusion },
[GORON_MERCHANT] = { GoronMerchant, NULL, NULL },
[GORMAN] = { Gorman, Gorman_Head, NULL },
[DOG] = { Dog, Dog_Head, Dog_Fusion },
[SYRUP] = { Syrup, Syrup_Head, NULL },
[REM] = { Rem, NULL, NULL },
[TOWN_MINISH] = { TownMinish, TownMinish_Head, TownMinish_Fusion },
[LIBRARI] = { Librari, NULL, Librari_Fusion },
[PERCY] = { Percy, Percy_Head, Percy_Fusion },
[VAATI_REBORN] = { VaatiReborn, NULL, NULL },
[MOBLIN_LADY] = { MoblinLady, NULL, NULL },
[LIBRARIANS] = { Librarians, NULL, NULL },
[FARMERS] = { Farmers, Farmers_Head, Farmers_Fusion },
[CARLOV] = { Carlov, NULL, NULL },
[DAMPE] = { Dampe, NULL, Dampe_Fusion },
[DR_LEFT] = { DrLeft, NULL, NULL },
[KING_GUSTAF] = { KingGustaf, NULL, NULL },
[GINA] = { Gina, NULL, Gina_Fusion },
[SIMON] = { Simon, NULL, NULL },
[ANJU] = { Anju, NULL, Anju_Fusion },
[MAMA] = { Mama, Mama_Head, Mama_Fusion },
[EMMA] = { Emma, NULL, NULL },
[TEACHERS] = { Teachers, Teachers_Head, Teachers_Fusion },
[WIND_TRIBESPEOPLE] = { WindTribespeople, WindTribespeople_Head, WindTribespeople_Fusion },
[GREGAL] = { Gregal, NULL, Gregal_Fusion },
[MAYOR_HAGEN] = { MayorHagen, NULL, MayorHagen_Fusion },
[BIG_GORON] = { BigGoron, NULL, NULL },
[EZLO] = { Ezlo, NULL, NULL },
[NPC_UNK_4E] = { NPC4E, NULL, NPC4E_Fusion },
[NPC_UNK_4F] = { NPC4F, NULL, NULL },
[CLOTHES_RACK] = { ClothesRack, NULL, NULL },
[PICOLYTE_BOTTLE] = { PicolyteBottle, NULL, NULL },
[SMALL_TOWN_MINISH] = { SmallTownMinish, NULL, NULL },
[HURDY_GURDY_MAN] = { HurdyGurdyMan, HurdyGurdyMan_Head, HurdyGurdyMan_Fusion },
[CUCCO] = { Cucco, NULL, Cucco_Fusion },
[CUCCO_CHICK] = { CuccoChick, NULL, CuccoChick_Fusion },
[FUSION_MENU_NPC] = { FusionMenuNPC, FusionMenuNPC_Head, NULL },
[PHONOGRAPH] = { Phonograph, NULL, NULL },
[NPC_UNK_58] = { NPC58, NPC58_Head, NULL },
[NPC_NONE_1] = { DeleteEntity, NULL, NULL },
[NPC_NONE_2] = { DeleteEntity, NULL, NULL },
[NPC_NONE_3] = { DeleteEntity, NULL, NULL },
[NPC_NONE_4] = { DeleteEntity, NULL, NULL },
[NPC_NONE_5] = { DeleteEntity, NULL, NULL },
[NPC_NONE_6] = { DeleteEntity, NULL, NULL },
[NPC_NONE_7] = { DeleteEntity, NULL, NULL },
[NPC_NONE_8] = { DeleteEntity, NULL, NULL },
[NPC_NONE_9] = { DeleteEntity, NULL, NULL },
[NPC_NONE_10] = { DeleteEntity, NULL, NULL },
[NPC_NONE_11] = { DeleteEntity, NULL, NULL },
[NPC_NONE_12] = { DeleteEntity, NULL, NULL },
[NPC_NONE_13] = { DeleteEntity, NULL, NULL },
[NPC_NONE_14] = { DeleteEntity, NULL, NULL },
[NPC_NONE_15] = { DeleteEntity, NULL, NULL },
[NPC_NONE_16] = { DeleteEntity, NULL, NULL },
[NPC_NONE_17] = { DeleteEntity, NULL, NULL },
[NPC_NONE_18] = { DeleteEntity, NULL, NULL },
[NPC_NONE_19] = { DeleteEntity, NULL, NULL },
[NPC_NONE_20] = { DeleteEntity, NULL, NULL },
[NPC_NONE_21] = { DeleteEntity, NULL, NULL },
[NPC_NONE_22] = { DeleteEntity, NULL, NULL },
[NPC_NONE_23] = { DeleteEntity, NULL, NULL },
[NPC_NONE_24] = { DeleteEntity, NULL, NULL },
[NPC_NONE_25] = { DeleteEntity, NULL, NULL },
[NPC_NONE_26] = { DeleteEntity, NULL, NULL },
[NPC_NONE_27] = { DeleteEntity, NULL, NULL },
[NPC_NONE_28] = { DeleteEntity, NULL, NULL },
[NPC_NONE_29] = { DeleteEntity, NULL, NULL },
[NPC_NONE_30] = { DeleteEntity, NULL, NULL },
[NPC_NONE_31] = { DeleteEntity, NULL, NULL },
[NPC_NONE_32] = { DeleteEntity, NULL, NULL },
[NPC_NONE_33] = { DeleteEntity, NULL, NULL },
[NPC_NONE_34] = { DeleteEntity, NULL, NULL },
[NPC_NONE_35] = { DeleteEntity, NULL, NULL },
[NPC_NONE_36] = { DeleteEntity, NULL, NULL },
[NPC_NONE_37] = { DeleteEntity, NULL, NULL },
[NPC_NONE_38] = { DeleteEntity, NULL, NULL },
[NPC_NONE_39] = { DeleteEntity, NULL, NULL }
};
//clang-format on
const u8 npc_unk[] = { 0x04, 0x05, 0x06, 0x06 };
+35 -27
View File
@@ -47,44 +47,52 @@ void LoadRoomEntityList(const EntityData* listPtr) {
}
}
NONMATCH("asm/non_matching/LoadRoomEntity.inc", Entity* LoadRoomEntity(const EntityData* dat)) {
Entity* LoadRoomEntity(const EntityData* dat) {
int kind;
Entity* v4;
Entity* v5;
Entity* entity;
// r4/r5 regalloc
#ifndef NON_MATCHING
asm("" ::: "r5");
#endif
kind = dat->kind & 0xF;
if ((dat->flags & 0xF0) == 0x50 && DeepFindEntityByID(kind, dat->id))
return NULL;
v4 = GetEmptyEntityByKind(kind);
v5 = v4;
if (v4 != NULL) {
v4->kind = kind;
v4->id = dat->id;
v4->type = dat->type;
RegisterRoomEntity(v4, dat);
entity = GetEmptyEntityByKind(kind);
if (entity != NULL) {
entity->kind = kind;
entity->id = dat->id;
entity->type = dat->type;
RegisterRoomEntity(entity, dat);
if ((dat->flags & 0xF0) != 16) {
v5->type2 = dat->type2;
v5->timer = (dat->type2 & 0xFF00) >> 8;
if (kind == MANAGER)
return v5;
sub_0804AF0C(v5, dat);
if (v5->next == NULL)
return v5;
if ((dat->kind & 0x10) == 0) {
if ((dat->kind & 0x20) != 0) {
v5->collisionLayer = 2;
return v5;
}
if ((gRoomControls.scroll_flags & 2) == 0) {
ResolveCollisionLayer(v5);
u8 kind2;
entity->type2 = *(u8*)&dat->type2;
entity->timer = (dat->type2 & 0xFF00) >> 8;
if (kind == 9)
return entity;
sub_0804AF0C(entity, dat);
if (!entity->next)
return entity;
kind2 = dat->kind & 0xF0;
if ((kind2 & 0x10) == 0) {
if ((kind2 & 0x20) != 0) {
entity->collisionLayer = 2;
return entity;
}
}
v5->collisionLayer = 1;
if ((kind2 & 0x10) || (gRoomControls.scroll_flags & 2)) {
entity->collisionLayer = 1;
return entity;
}
ResolveCollisionLayer(entity);
return entity;
}
}
return v5;
return entity;
}
END_NONMATCH
void RegisterRoomEntity(Entity* ent, const EntityData* dat) {
u32 list;