fix merge conflict

This commit is contained in:
theo3
2021-03-21 22:59:52 -07:00
116 changed files with 850 additions and 860 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
#include "functions.h"
#include "object.h"
#include "manager.h"
#include "dma.h"
#include "utils.h"
#include "npc.h"
extern u8 gUnk_03003DE0;
-43
View File
@@ -1,43 +0,0 @@
#include "global.h"
extern void LoadPalettes(const u8*, int, int);
extern u32 gUsedPalettes;
extern u16 gPaletteBuffer[];
typedef struct {
u16 paletteId;
u8 destPaletteNum;
u8 numPalettes;
} PaletteGroup;
extern const PaletteGroup* gPaletteGroups[];
extern const u8 gGlobalGfxAndPalettes[];
void LoadPaletteGroup(u32 group) {
const PaletteGroup* paletteGroup = gPaletteGroups[group];
while (1) {
u32 destPaletteNum = paletteGroup->destPaletteNum;
u32 numPalettes = paletteGroup->numPalettes & 0xF;
if (numPalettes == 0) {
numPalettes = 16;
}
LoadPalettes(&gGlobalGfxAndPalettes[paletteGroup->paletteId * 32], destPaletteNum, numPalettes);
if ((paletteGroup->numPalettes & 0x80) == 0) {
break;
}
paletteGroup++;
}
}
void LoadPalettes(const u8* src, int destPaletteNum, int numPalettes) {
u16* dest;
u32 size = numPalettes * 32;
u32 usedPalettesMask = 1 << destPaletteNum;
while (--numPalettes > 0) {
usedPalettesMask |= (usedPalettesMask << 1);
}
gUsedPalettes |= usedPalettesMask;
dest = &gPaletteBuffer[destPaletteNum * 16];
DmaCopy32(3, src, dest, size);
}
-96
View File
@@ -1,96 +0,0 @@
#include "global.h"
#include "screen.h"
#include "structures.h"
extern u16 gPaletteBuffer[];
extern u32 gUsedPalettes;
typedef struct {
union {
int raw;
struct {
u8 filler0[0x3];
u8 unk3;
} bytes;
} unk0;
u32 dest;
u32 unk8;
} GfxItem;
extern const GfxItem* gUnk_08100AA8[];
extern const u8 gGlobalGfxAndPalettes[];
void sub_0801D79C(u32 colorIndex, u32 color) {
gPaletteBuffer[colorIndex] = color;
gUsedPalettes |= 1 << (colorIndex / 16);
}
void sub_0801D7BC(u32 color, u32 arg1) {
if (arg1) {
gScreen.lcd.unk6 = 0xE0FF;
} else {
gScreen.lcd.unk6 = 0xFFFF;
}
sub_0801D79C(0, color);
}
void LoadGfxGroup(u32 group) {
u32 terminator;
u32 dmaCtrl;
int gfxOffset;
const u8* src;
u32 dest;
int size;
const GfxItem* gfxItem = gUnk_08100AA8[group];
while (1) {
u32 loadGfx = FALSE;
u32 ctrl = gfxItem->unk0.bytes.unk3;
ctrl &= 0xF;
switch (ctrl) {
case 0x7:
loadGfx = TRUE;
break;
case 0xD:
return;
case 0xE:
if (((struct_02000000*)0x2000000)->gameLanguage > 1) {
loadGfx = TRUE;
}
break;
case 0xF:
if (((struct_02000000*)0x2000000)->gameLanguage != 0) {
loadGfx = TRUE;
}
break;
default:
if (ctrl == ((struct_02000000*)0x2000000)->gameLanguage) {
loadGfx = TRUE;
}
break;
}
if (loadGfx) {
gfxOffset = gfxItem->unk0.raw & 0xFFFFFF;
src = &gGlobalGfxAndPalettes[gfxOffset];
dest = gfxItem->dest;
size = gfxItem->unk8;
dmaCtrl = 0x80000000;
if (size < 0) {
if (dest >= VRAM) {
LZ77UnCompVram(src, (void*)dest);
} else {
LZ77UnCompWram(src, (void*)dest);
}
} else {
DmaSet(3, src, dest, dmaCtrl | ((u32)size >> 1));
}
}
terminator = gfxItem->unk0.bytes.unk3;
terminator &= 0x80;
gfxItem++;
if (!terminator) {
break;
}
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {
+1 -1
View File
@@ -2,7 +2,7 @@
#include "entity.h"
#include "area.h"
#include "main.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
#include "screen.h"
+1 -1
View File
@@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "structures.h"
#include "functions.h"
+1 -1
View File
@@ -82,7 +82,7 @@ void* sub_08077C54(UnkItemStruct* unk) {
Entity* sub_08077C94(ItemBehavior* arg0, u32 arg1) {
Entity* iVar1;
iVar1 = FindEntityInListBySubtype(8, gUnk_0811BE48[arg1].unk[3], 2);
iVar1 = FindEntityByID(8, gUnk_0811BE48[arg1].unk[3], 2);
if (iVar1 == NULL) {
return NULL;
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "player.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {
+66 -3
View File
@@ -1,7 +1,71 @@
#include "global.h"
#include "entity.h"
#include "coord.h"
extern u8 gUnk_08114F78[];
extern u8 gUnk_08114F80[];
s16 FixedMul(s16 r0, s16 r1) {
s32 temp = r0 * r1;
if (temp < 0)
return (temp + 255) >> 8;
else
return temp >> 8;
}
s16 FixedDiv(s16 r0, s16 r1) {
if (r1 == 0)
return 0;
else
return (r0 * 256) / r1;
}
void CopyPosition(Entity* param_1, Entity* param_2) {
PositionRelative(param_1, param_2, 0, 0);
}
void PositionEntityOnTop(Entity* ent, Entity* ent2) {
PositionRelative(ent, ent2, 0, 0);
ResolveEntityOnTop(ent, ent2);
}
void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { // r0, r1, r2, r3
s32 x;
s32 y;
x = source->x.WORD;
target->x.WORD = x + offsetX;
y = source->y.WORD;
target->y.WORD = y + offsetY;
target->height = source->height; // ldr
target->collisionLayer = source->collisionLayer;
UpdateSpriteForCollisionLayer(target);
}
void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, 0, 0);
}
void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32);
}
void ResolveEntityOnTop(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0];
}
void sub_0806FAD8(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0];
}
// Values of sin(x*(π/128)) as Q8.8 fixed-point numbers from x = 0 to x = 319
const s16 gSineTable[] = {
const s16 gSineTable[64] = {
Q_8_8(0), // sin(0*(π/128))
Q_8_8(0.0234375), // sin(1*(π/128))
Q_8_8(0.046875), // sin(2*(π/128))
@@ -68,8 +132,7 @@ const s16 gSineTable[] = {
Q_8_8(0.99609375), // sin(63*(π/128))
};
const s16 gCosineTable[] = {
const s16 gCosineTable[256] = {
Q_8_8(1), // sin(64*(π/128))
Q_8_8(0.99609375), // sin(65*(π/128))
Q_8_8(0.99609375), // sin(66*(π/128))
+4 -4
View File
@@ -2,8 +2,8 @@
// #include "entityData.h"
// #include "global.h"
// extern Entity * FindEntityBySubtype(u32, u32);
// extern Entity * GetEmptyEntityByType();
// extern Entity * DeepFindEntityByID(u32, u32);
// extern Entity * GetEmptyEntityByKind();
// extern void RegisterRoomEntity(Entity *, EntityData *);
// extern u32 sub_0804AF0C(Entity *, EntityData *);
// extern void sub_08016A30(Entity *);
@@ -17,11 +17,11 @@
// type = param_1->entityType & 15;
// if (((param_1->field_0x1 & 240) == 80) &&
// (preexisting = FindEntityBySubtype(type,param_1->entitySubtype), preexisting != NULL)) {
// (preexisting = DeepFindEntityByID(type,param_1->entitySubtype), preexisting != NULL)) {
// entity = NULL;
// }
// else {
// entity = GetEmptyEntityByType(); //Get empty entity
// entity = GetEmptyEntityByKind(); //Get empty entity
// if (entity != NULL) {
// (entity->entityType).type = type;
// (entity->entityType).subtype = param_1->entitySubtype;
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "room.h"
#include "createObject.h"
+3 -10
View File
@@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
#include "main.h"
#include "menu.h"
@@ -7,13 +7,6 @@
#include "structures.h"
#include "textbox.h"
typedef struct {
u16 unk0;
u16 unk2;
u16 unk4;
} VStruct;
extern VStruct gInput;
extern u8 gBG3Buffer[];
extern void (*const gUnk_08109A30[])();
@@ -23,7 +16,7 @@ void HandleDebugTextScreen() {
}
void sub_0805FA04(void) {
sub_0801DA90(1);
DispReset(1);
MemClear(&gBG0Buffer, sizeof(BGBuffer));
MemClear(&gBG3Buffer, 0x1000);
gScreen.lcd.displayControl = 0x940;
@@ -47,7 +40,7 @@ void sub_0805FA04(void) {
void sub_0805FA98(void) {
int iVar1;
switch (gInput.unk2) {
switch (gInput.newKeys) {
case 0x40:
gMenu.focusCoords[1] -= 1;
break;
-46
View File
@@ -1,46 +0,0 @@
#include "global.h"
#include "dma.h"
void MemFill16(u32 value, void* dest, u32 size) {
DmaFill16(3, value, dest, size);
}
void MemFill32(u32 value, void* dest, u32 size) {
DmaFill32(3, value, dest, size);
}
void MemClear(void* dest, u32 size) {
u32 zero = 0;
switch (((u32)dest | size) & 3) {
case 0:
MemFill32(0, dest, size);
break;
case 2:
MemFill16(0, dest, size);
break;
default:
do {
*(u8*)dest = zero;
dest++;
size--;
} while (size != 0);
}
}
void MemCopy(const void* src, void* dest, u32 size) {
switch (((u32)src | (u32)dest | size) & 3) {
case 0:
DmaCopy32(3, src, dest, size);
break;
case 2:
DmaCopy16(3, src, dest, size);
break;
default:
do {
*(u8*)dest = *(u8*)src;
src++;
dest++;
} while (--size);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
#include "enemy.h"
#include "player.h"
#include "room.h"
#include "trig.h"
#include "coord.h"
#include "fileScreen.h"
#include "random.h"
#include "functions.h"
+1 -1
View File
@@ -2,7 +2,7 @@
#include "entity.h"
#include "enemy.h"
#include "functions.h"
#include "trig.h"
#include "coord.h"
#include "random.h"
#include "player.h"
+1 -1
View File
@@ -3,12 +3,12 @@
#include "enemy.h"
#include "random.h"
#include "functions.h"
#include "coord.h"
extern u32 sub_080002D4(s32, s32, u32);
extern u32 sub_080002BC(s32, s32, u32);
extern Entity* gUnk_020000B0;
extern s16 gSineTable[];
bool32 Leever_PlayerInRange(Entity*, s32);
void Leever_Move(Entity*);
+1 -2
View File
@@ -6,7 +6,6 @@
void sub_08045374(Entity*);
extern u32 sub_0806FA04(u32, u32);
extern void sub_080452E4();
extern void ReplaceMonitoredEntity(Entity*, Entity*);
@@ -70,7 +69,7 @@ void sub_080452FC(Entity* this) {
this->action = 3;
this->actionDelay = 1;
if (0 < this->speed)
this->actionDelay = sub_0806FA04(0x1000, this->speed) >> 0x8;
this->actionDelay = FixedDiv(0x1000, this->speed) >> 0x8;
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
cVar2 = sub_08049EE4(this);
+5 -5
View File
@@ -10,7 +10,7 @@ extern void sub_0800449C(Entity*, u32);
extern u32 sub_08049F1C(Entity*, Entity*, u32);
extern u32 PlayerInRange(Entity*, u32, u32);
extern void sub_080AEFB4(Entity*);
extern Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex);
extern Entity* FindNextDuplicateID(Entity* ent, int listIndex);
void sub_080249F4(Entity*);
void sub_08024940(Entity*);
@@ -666,7 +666,7 @@ bool32 sub_08024B38(Entity* this) {
}
}
ent = FindEntityInListBySubtype(8, 2, 2);
ent = FindEntityByID(8, 2, 2);
if (ent) {
do {
if (ent->action != 2 && ent->height.HALF.HI == 0 && sub_08049F1C(this, ent, 0xa0)) {
@@ -676,14 +676,14 @@ bool32 sub_08024B38(Entity* this) {
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextEntityOfSameSubtype(ent, 2), ent != NULL);
} while (ent = FindNextDuplicateID(ent, 2), ent != NULL);
}
if (iVar4 != 0) {
return iVar4;
}
ent = FindEntityInListBySubtype(6, 5, 6);
ent = FindEntityByID(6, 5, 6);
if (ent) {
do {
if (ent->action == 1 && sub_08049F1C(this, ent, 0xa0)) {
@@ -693,7 +693,7 @@ bool32 sub_08024B38(Entity* this) {
this->field_0x82.HALF.HI &= ~0x40;
break;
}
} while (ent = FindNextEntityOfSameSubtype(ent, 6), ent != NULL);
} while (ent = FindNextDuplicateID(ent, 6), ent != NULL);
}
if (iVar4 == 0) {
+1 -2
View File
@@ -12,7 +12,6 @@ typedef struct {
void sub_08044FF8(Entity*);
void sub_08045178(Entity*, Entity*, int, int);
extern u32 sub_0806FA04(u32, u32);
extern void sub_0804A4E4(Entity*, Entity*);
extern u32 sub_080002CC(Entity*, s32, s32);
@@ -68,7 +67,7 @@ void sub_08045018(Entity* this) {
this->action = 3;
this->actionDelay = 1;
if (0 < this->speed) {
this->actionDelay = sub_0806FA04(4096, this->speed) >> 8;
this->actionDelay = FixedDiv(4096, this->speed) >> 8;
}
if (sub_08049FA0(this) == 0 && (Random() & 3)) {
this->direction = (sub_08049EE4(this) + 0xfc + (Random() & 8)) & 24;
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "random.h"
#include "functions.h"
+19 -21
View File
@@ -1,6 +1,7 @@
#include "global.h"
#include "area.h"
#include "entity.h"
#include "dma.h"
#include "utils.h"
#include "script.h"
typedef struct OtherEntity {
@@ -28,9 +29,9 @@ OtherEntity* GetEmptyManager(void);
typedef void* (*Getter)(void);
void* GetEmptyEntityByType(int type) {
void* GetEmptyEntityByKind(u32 kind) {
Getter getter = NULL;
if (type == 9) {
if (kind == MANAGER) {
getter = (Getter)GetEmptyManager;
} else {
getter = (Getter)GetEmptyEntity;
@@ -61,7 +62,7 @@ typedef void (*Deleter)(void*);
void DeleteEntityAny(Entity* ent) {
Deleter deleter = NULL;
if (ent->kind == 9) {
if (ent->kind == MANAGER) {
deleter = (Deleter)DeleteManager;
} else {
deleter = (Deleter)DeleteEntity;
@@ -78,7 +79,6 @@ extern void sub_0805EC60();
extern void sub_08017744();
extern void sub_0805E92C();
extern void UnloadHitbox();
extern void sub_0801DA0C();
extern void sub_0804AA1C();
void UnlinkEntity();
@@ -94,9 +94,9 @@ void DeleteEntity(Entity* ent) {
sub_0805E92C(ent);
UnloadCutsceneData(ent);
UnloadHitbox(ent);
sub_0801DA0C(ent->myHeap);
zFree(ent->myHeap);
ent->myHeap = NULL;
if (ent->kind == 3) {
if (ent->kind == ENEMY) {
sub_0804AA1C(ent);
}
ent->flags = ent->flags & 0x7f;
@@ -171,8 +171,6 @@ void DeleteManager(OtherEntity* ent) {
gManagerCount--;
}
#include "area.h"
void sub_0805E92C(u32 param_1) {
if (param_1 == gArea.unk2) {
gArea.unk2 = 0;
@@ -209,7 +207,7 @@ void sub_0805E9A8(void) {
list = &gEntityLists[0];
do {
for (i = list->first; (u32)i != (u32)list; i = i->next) {
i->flags &= 0xfd;
i->flags &= ~2;
if ((i->flags & 0x20) == 0) {
i->flags |= 0x10;
}
@@ -242,7 +240,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) {
entity->prev = list->last;
list->last->next = entity;
list->last = entity;
if (entity->kind != 9) {
if (entity->kind != MANAGER) {
entity->spritePriority.b0 = 4;
gEntCount++;
} else {
@@ -251,7 +249,7 @@ void AppendEntityToList(Entity* entity, u32 listIndex) {
sub_0805E374(entity);
}
void PrependEntityToList(Entity* entity, int listIndex) {
void PrependEntityToList(Entity* entity, u32 listIndex) {
LinkedList* list;
UnlinkEntity(entity);
@@ -270,7 +268,7 @@ void UnlinkEntity(Entity* ent) {
ent->next->prev = ent->prev;
}
bool32 DoesSimilarEntityExist(Entity* ent) {
bool32 EntityHasDuplicateID(Entity* ent) {
Entity* i;
LinkedList* list;
@@ -286,31 +284,31 @@ bool32 DoesSimilarEntityExist(Entity* ent) {
return FALSE;
}
Entity* FindEntityInListBySubtype(u32 type, u32 subtype, u32 listIndex) {
Entity* FindEntityByID(u32 kind, u32 id, u32 listIndex) {
Entity* it;
LinkedList* list;
list = &gEntityLists[listIndex];
for (it = list->first; (u32)it != (u32)list; it = it->next) {
if (type == it->kind && subtype == it->id)
if (kind == it->kind && id == it->id)
return it;
}
return NULL;
}
Entity* FindEntityInListByForm(u32 type, u32 subtype, u32 listIndex, u32 form, u32 parameter) {
Entity* FindEntity(u32 kind, u32 id, u32 listIndex, u32 type, u32 type2) {
Entity* i;
LinkedList* list;
list = &gEntityLists[listIndex];
for (i = list->first; (u32)i != (u32)list; i = i->next) {
if (type == i->kind && subtype == i->id && form == i->type && parameter == i->type2)
if (kind == i->kind && id == i->id && type == i->type && type2 == i->type2)
return i;
}
return NULL;
}
Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) {
Entity* FindNextDuplicateID(Entity* ent, int listIndex) {
Entity* i;
LinkedList* list;
@@ -322,14 +320,14 @@ Entity* FindNextEntityOfSameSubtype(Entity* ent, int listIndex) {
return NULL;
}
Entity* FindEntityBySubtype(int type, int subtype) {
Entity* DeepFindEntityByID(u32 kind, u32 id) {
Entity* i;
LinkedList* list;
list = &gEntityLists[0];
do {
for (i = (Entity*)list->first; (u32)i != (u32)list; i = i->next) {
if (type == i->kind && (subtype == i->id))
if (kind == i->kind && (id == i->id))
return i;
}
} while (++list < &gEntityLists[9]);
@@ -346,7 +344,7 @@ void DeleteAllEnemies(void) {
do {
for (ent = list->first; (u32)ent != (u32)list; ent = next) {
next = ent->next;
if (ent->kind == 3)
if (ent->kind == ENEMY)
DeleteEntity(ent);
}
} while (++list < &gEntityLists[9]);
View File
+3 -3
View File
@@ -1,11 +1,11 @@
#include "fileScreen.h"
#include "main.h"
#include "player.h"
#include "readKeyInput.h"
#include "utils.h"
#include "screen.h"
#include "menu.h"
#include "dma.h"
#include "random.h"
#include "textbox.h"
// copy, erase, start
#define NUM_FILE_OPERATIONS 3
@@ -189,7 +189,7 @@ void HandleChooseFileScreen(void) {
static void HandleFileScreenEnter(void) {
u32 i;
sub_0801DA90(1);
DispReset(1);
sub_080A3210();
MemClear((void*)VRAM, 0x80); // clear palettes
MessageInitialize();
+1 -2
View File
@@ -1,7 +1,6 @@
#include "global.h"
#include "screen.h"
#include "structures.h"
#include "dma.h"
#include "screen.h"
#include "entity.h"
#include "player.h"
@@ -9,7 +8,7 @@
#include "main.h"
#include "flags.h"
#include "save.h"
#include "readKeyInput.h"
#include "utils.h"
#include "fileScreen.h"
#include "functions.h"
-27
View File
@@ -1,27 +0,0 @@
#include "global.h"
#include "readKeyInput.h"
static void StoreKeyInput(Input*, u32);
void ReadKeyInput(void) {
u32 keyInput = ~REG_KEYINPUT & KEYS_MASK;
StoreKeyInput(&gInput, keyInput);
}
static void StoreKeyInput(Input* input, u32 keyInput) {
u32 heldKeys = input->heldKeys;
u32 difference = keyInput & ~heldKeys;
input->newKeys = difference;
if (keyInput == heldKeys) {
if (--input->unk7 == 0) {
input->unk7 = 4;
input->unk4 = keyInput;
} else {
input->unk4 = 0;
}
} else {
input->unk7 = 0x14;
input->unk4 = difference;
}
input->heldKeys = keyInput;
}
+4 -4
View File
@@ -1,11 +1,11 @@
#include "global.h"
#include "main.h"
#include "entity.h"
#include "dma.h"
#include "functions.h"
#include "readKeyInput.h"
#include "utils.h"
#include "screen.h"
#include "structures.h"
#include "textbox.h"
typedef struct {
u8 filler0[0x4];
@@ -74,7 +74,7 @@ void HandleIntroScreen(void) {
if (gFadeControl.active) {
return;
}
sub_0801DA90(1);
DispReset(1);
gMain.funcIndex = 1;
break;
}
@@ -87,7 +87,7 @@ static void HandleNintendoCapcomLogos(void) {
advance = GetAdvanceState();
if (gIntroState.state == 0) {
sub_0801DA90(1);
DispReset(1);
gIntroState.state = 1;
gIntroState.timer = 120;
LoadGfxGroup(16);
+18
View File
@@ -12,6 +12,24 @@ extern void* GetRoomProperty(u32, u32, u32);
extern u32 gUnk_02017654;
extern u32* gAreaEntities;
extern void sub_080186EC();
extern void sub_0804B16C();
void sub_0804AFF4(void) {
void (*func)();
sub_080186EC();
func = (void (*)())GetCurrentRoomProperty(5);
if (func) {
func();
}
func = (void (*)())GetCurrentRoomProperty(7);
if (func) {
func();
}
sub_0804B16C();
}
void LoadRoom(void) {
s32 iVar1;
s32* dat;
+13 -10
View File
@@ -1,12 +1,13 @@
#include "global.h"
#include "dma.h"
#include "functions.h"
#include "structures.h"
#include "main.h"
#include "screen.h"
#include "random.h"
#include "readKeyInput.h"
#include "utils.h"
#include "save.h"
#include "textbox.h"
#include "arm_proxy.h"
extern void HandleIntroScreen(void);
extern void HandleChooseFileScreen(void);
@@ -21,6 +22,8 @@ static void (*const sScreenHandlers[])(void) = {
[SCREEN_CREDITS] = HandleCreditsScreen, [SCREEN_DEBUG_TEXT] = HandleDebugTextScreen,
};
static void sub_080560B8(void);
void AgbMain(void) {
int var0;
@@ -104,7 +107,7 @@ static void sub_08055F70(void) {
MemCopy(gUnk_080B2CD8_3, gUnk_02038560, size);
}
sub_0801DA90(0);
DispReset(0);
sub_08016B34();
}
@@ -147,21 +150,21 @@ typedef struct {
u8 name[6];
u8 _e;
u8 _f;
} test;
} Defaults;
const test sDefaultSettings = {
const Defaults sDefaultSettings = {
.signature = SIGNATURE,
.saveFileId = 0,
.messageSpeed = 1,
.brightnessPref = 1,
.gameLanguage = LANGUAGE_EN,
.gameLanguage = GAME_LANGUAGE,
.name = "LINK",
._e = 0,
._f = 0,
};
// single misplaced ldr
NONMATCH("asm/non_matching/sub_080560B8.inc", void sub_080560B8(void)) {
NONMATCH("asm/non_matching/sub_080560B8.inc", static void sub_080560B8(void)) {
u32 temp;
u32 b;
@@ -183,9 +186,9 @@ NONMATCH("asm/non_matching/sub_080560B8.inc", void sub_080560B8(void)) {
b = BOOLCAST(temp);
if ((gUnk_02000010.field_0x4 != 0) && (gUnk_02000010.field_0x4 != 0xc1)) {
b = 1;
b = TRUE;
}
if (b != 0) {
if (b) {
MemClear((u8*)&gUnk_02000010.signature, 0x20);
gUnk_02000010.signature = SIGNATURE;
}
@@ -251,7 +254,7 @@ void sub_08056260(void) {
temp2->field_0x1 = 0;
}
// Convert in-game AABB to screen coordinates and check if it's within the viewport
// Convert AABB to screen coordinates and check if it's within the viewport
u32 sub_080562CC(u32 x0, u32 y0, u32 x1, u32 y1) {
u32 result;
u32 x = ((gRoomControls.roomScrollX - gRoomControls.roomOriginX) - x0 + DISPLAY_WIDTH);
+1 -1
View File
@@ -86,7 +86,7 @@ void sub_0805A370(Manager15* this) {
void sub_0805A394(Manager15* this) {
Entity* ent;
if ((ent = FindEntityInListBySubtype(0x3, 0x13, 0x4))) {
if ((ent = FindEntityByID(0x3, 0x13, 0x4))) {
if (ent->type != 4) {
return;
}
+1 -1
View File
@@ -4,7 +4,7 @@
#include "entity.h"
#include "room.h"
#include "screen.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
typedef struct {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "screen.h"
#include "area.h"
#include "textbox.h"
#include "dma.h"
#include "utils.h"
#include "game.h"
#include "functions.h"
+1 -1
View File
@@ -4,7 +4,7 @@
#include "entity.h"
#include "room.h"
#include "area.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
/*
+1 -1
View File
@@ -4,7 +4,7 @@
#include "structures.h"
#include "room.h"
#include "screen.h"
#include "trig.h"
#include "coord.h"
#include "functions.h"
#include "save.h"
+1 -1
View File
@@ -56,7 +56,7 @@ void sub_0806CF30(Entity* this) {
void sub_0806D00C(Entity* this) {
Entity* pEVar1;
pEVar1 = FindEntityInListByForm(7, 76, 7, 0, 0);
pEVar1 = FindEntity(7, 76, 7, 0, 0);
if (pEVar1 != NULL) {
this->parent = pEVar1;
}
+1 -1
View File
@@ -225,7 +225,7 @@ void sub_08060318(void) {
int i;
for (i = 2; i >= 0; i--) {
ent = FindEntityInListBySubtype(8, 2, 2);
ent = FindEntityByID(8, 2, 2);
if (ent != NULL) {
CreateDust(ent);
DeleteEntity(ent);
+1 -1
View File
@@ -84,7 +84,7 @@ void sub_08069660(Entity* this) {
void sub_08069684(void) {
Manager* mgr;
if (FindEntityInListBySubtype(9, 0x31, 8) == NULL) {
if (FindEntityByID(9, 0x31, 8) == NULL) {
mgr = GetEmptyManager();
if (mgr != NULL) {
mgr->type = 9;
+2 -2
View File
@@ -57,12 +57,12 @@ void sub_08065900(Entity* this) {
void sub_08065914(Entity* this) {
Entity* target;
target = FindEntityInListBySubtype(7, 0x1F, 7);
target = FindEntityByID(7, 0x1F, 7);
if (target != NULL) {
PositionRelative(this, target, 0x180000, -0x10000);
target->parent = this;
}
target = FindEntityInListBySubtype(7, 0x20, 7);
target = FindEntityByID(7, 0x20, 7);
if (target != NULL) {
PositionRelative(this, target, 0x280000, 0);
target->parent = this;
+3 -3
View File
@@ -5,7 +5,7 @@
#include "flags.h"
#include "script.h"
extern Entity* FindEntityBySubtype(u32, u32);
extern Entity* DeepFindEntityByID(u32, u32);
void sub_08068680(Entity*, Entity*);
void sub_08068694(Entity*, Entity*);
extern Entity* GetEntityByType(u32, u32);
@@ -31,7 +31,7 @@ void sub_08066CF8(Entity* this) {
}
void sub_08066D04(Entity* this) {
this->parent = FindEntityBySubtype(7, 0x2E);
this->parent = DeepFindEntityByID(7, 0x2E);
}
void sub_08066D14(Entity* this, ScriptExecutionContext* context) {
@@ -86,7 +86,7 @@ void sub_08066D94(Entity* this) {
void sub_08066DE4(Entity* this) {
Entity* pEVar1;
pEVar1 = FindEntityBySubtype(7, 0x2E);
pEVar1 = DeepFindEntityByID(7, 0x2E);
if (pEVar1 != NULL) {
CopyPosition(this, pEVar1);
sub_080686C4(this, pEVar1);
+2 -2
View File
@@ -4,9 +4,9 @@
#include "main.h"
#include "menu.h"
#include "npc.h"
#include "position.h"
#include "coord.h"
#include "fileScreen.h"
#include "readKeyInput.h"
#include "utils.h"
#include "structures.h"
#include "functions.h"
+56 -92
View File
@@ -25,11 +25,9 @@ enum {
// Main
void GreatFairy(Entity* this) {
u8 bVar1;
if (this->action == 0) {
bVar1 = __modsi3(this->type, 11);
this->type2 = bVar1;
s32 temp = 11;
this->type2 = this->type % temp;
}
GreatFairy_Main[this->type2](this);
}
@@ -68,20 +66,18 @@ void GreatFairy_DormantUpdate(Entity* this) {
--*pFrame;
}
switch (*pFrame) {
case 0x96:
case 0x82:
goto e;
case 0x0:
case 0:
this->action = 2;
break;
e:
case 0xd2:
case 0xaa:
case 0x121:
case 130:
case 150:
case 170:
case 210:
case 289:
ripple = GreatFairy_CreateForm(this, RIPPLE, 0);
if (ripple) {
PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] << 16,
(s32)GreatFairy_RippleOffsets[this->actionDelay + 1] << 16);
PositionRelative(this, ripple, (s32)GreatFairy_RippleOffsets[this->actionDelay] * 65536,
(s32)GreatFairy_RippleOffsets[this->actionDelay + 1] * 65536);
this->actionDelay += 2;
break;
}
@@ -110,9 +106,8 @@ void GreatFairy_SpawningUpdate(Entity* this) {
DoFade(6, 4);
SoundReq(325);
this->action = 4;
this->actionDelay = 0x3c;
var = this->spriteSettings.raw & ~0x3;
this->spriteSettings.raw = (this->spriteSettings.raw & var) | 1;
this->actionDelay = 60;
this->spriteSettings.b.draw = 1;
}
}
}
@@ -166,10 +161,8 @@ void GreatFairy_WingsInit(Entity* this) {
}
void GreatFairy_WingsUpdate(Entity* this) {
s32 iVar1;
iVar1 = this->speed -= 32;
if (iVar1 * 65536 >> 16 == 256) {
this->speed -= 32;
if (this->speed == 256) {
this->action = 2;
sub_0805EC60(this);
gRoomVars.greatFairyState |= 32;
@@ -237,7 +230,7 @@ void GreatFairy_MiniRisingUpdate(Entity* this) {
void GreatFairy_MiniRemoveMe(Entity* this) {
GetNextFrame(this);
sub_080873D0(this);
if ((gRoomVars.greatFairyState & 1) != 0) {
if (gRoomVars.greatFairyState & 1) {
DeleteEntity(this);
}
}
@@ -270,15 +263,13 @@ void GreatFairy_MiniAffineInit2(Entity* this) {
// Mini great fairy stretch
void GreatFairy_MiniAffineUpdate(Entity* this) {
s32 iVar2;
if (--this->actionDelay == 0) {
gRoomVars.greatFairyState |= 1;
this->action = 3;
sub_0805EC60(this);
} else {
iVar2 = this->speed -= 24;
sub_0805EC9C(this, 256, iVar2 * 0x10000 >> 20, 0);
this->speed -= 24;
sub_0805EC9C(this, 256, this->speed >> 4, 0);
}
}
@@ -297,7 +288,7 @@ void GreatFairy_DropletInit(Entity* this) {
void GreatFairy_DropletUpdate(Entity* this) {
GetNextFrame(this);
if (this->frames.b.f3) {
if (this->frames.all & 0x80) {
DeleteEntity(this);
}
}
@@ -314,7 +305,7 @@ void GreatFairy_RippleInit(Entity* this) {
}
void GreatFairy_RippleUpdate(Entity* this) {
if ((gRoomVars.greatFairyState & 2) != 0) {
if (gRoomVars.greatFairyState & 2) {
DeleteEntity(this);
} else {
GetNextFrame(this);
@@ -363,7 +354,7 @@ void GreatFairy_EnergyInit(Entity* this) {
void GreatFairy_EnergyUpdate(Entity* this) {
GetNextFrame(this);
if (this->frames.b.f3) {
if (this->frames.all & 0x80) {
DeleteEntity(this);
}
}
@@ -377,35 +368,25 @@ void sub_08087114(Entity* this) {
}
}
#ifdef NON_MATCHING
extern u8 gUnk_0812079C;
void sub_08087150(Entity* this) {
NONMATCH("asm/greatFairy/sub_08087150.inc", void sub_08087150(Entity* this)) {
u32 temp;
GreatFairy_InitializeAnimation();
GreatFairy_InitializeAnimation(this);
this->spriteSettings.b.draw = TRUE;
this->spriteOrientation.flipY = 0;
this->spriteRendering.b0 = 0;
this->spritePriority.b0 = 3;
this->speed = 0x80;
this->speed = 128;
this->direction = 0x10;
temp = gUnk_0812079C;
temp = gUnk_0812079C[0];
this->palette.raw = ((temp & 0xf) << 4) | 0xf;
}
#else
NAKED
void sub_08087150(Entity* this) {
asm(".include \"asm/greatFairy/sub_08087150.inc\"");
}
#endif
END_NONMATCH
void nullsub_516(Entity* this) {
}
void sub_080871A8(Entity* this) {
u32 bVar1;
if (--this->actionDelay == 0) {
this->action = 3;
this->actionDelay = 60;
@@ -414,7 +395,6 @@ void sub_080871A8(Entity* this) {
}
void sub_080871D0(Entity* this) {
if (--this->actionDelay == 0) {
gRoomVars.greatFairyState |= 8;
DeleteEntity(this);
@@ -424,16 +404,16 @@ void sub_080871D0(Entity* this) {
void sub_080871F8(Entity* this) {
Entity* temp = this->attachedEntity;
if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 0x20 == this->y.HALF.HI)) {
if ((temp->x.HALF.HI == this->x.HALF.HI) && (temp->y.HALF.HI - 32 == this->y.HALF.HI)) {
this->action = 2;
} else {
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 0x20);
this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, temp->x.HALF.HI, temp->y.HALF.HI - 32);
sub_0806F69C(this);
}
}
void sub_08087240(Entity* this) {
if ((gRoomVars.greatFairyState & 4) != 0) {
if (gRoomVars.greatFairyState & 4) {
this->action = 3;
this->actionDelay = 20;
this->direction = 16;
@@ -448,7 +428,6 @@ void sub_08087264(Entity* this) {
}
void sub_0808727C(Entity* this) {
if (--this->actionDelay == 0) {
DeleteEntity(this);
}
@@ -479,17 +458,16 @@ void sub_080872F8(Entity* this) {
sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, (s16)this->field_0x68.HWORD, (s16)this->field_0x6a.HWORD);
this->direction = (this->direction + gUnk_081207AC[Random() & 3]) & 0x1f;
}
temp = gSineTable[this->actionDelay + 0x40];
temp = gSineTable[this->actionDelay + 64];
this->height.HALF.HI = (temp >> 6) - 8;
this->actionDelay++;
}
void GreatFairy_InitializeAnimation(Entity* this) {
s32 temp;
s32 temp = 11;
this->action = 1;
temp = this->type;
this->type2 = temp % 11;
this->type2 = this->type % temp;
this->collisionLayer = 2;
InitializeAnimation(this, this->type2);
sub_0805E3A0(this, 2);
@@ -515,7 +493,7 @@ void sub_080873D0(Entity* this) {
ent = GreatFairy_CreateForm(this, 8, 0);
if (ent != NULL) {
CopyPosition(this, ent);
this->actionDelay = 0x30;
this->actionDelay = 48;
}
}
}
@@ -526,7 +504,7 @@ void sub_080873FC(void) {
SoundReq(0xf7);
gRoomControls.cameraTarget = NULL;
while (ent = FindEntityInListBySubtype(0x6, 0x1b, 0x6), ent != NULL) {
while (ent = FindEntityByID(0x6, 0x1b, 0x6), ent != NULL) {
DeleteEntity(ent);
}
}
@@ -555,101 +533,87 @@ void sub_08087424(Entity* this, ScriptExecutionContext* context) {
void sub_0808747C(Entity* this, ScriptExecutionContext* context) {
u32 iVar1 = 0;
iVar1 = (u32)FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0);
iVar1 = (u32)FindEntity(0x6, 0xf, 0x6, 0xb, 0x0);
if (iVar1 != 0) {
iVar1 = 1;
}
context->condition = iVar1;
}
// clang-format off
void (*const GreatFairy_Main[])(Entity*) = {
GreatFairy_CallBehavior,
GreatFairy_CallBehavior,
GreatFairy_WingsCallBehavior,
GreatFairy_WakeCallBehavior,
GreatFairy_MiniCallBehavior,
GreatFairy_MiniAffineCallBehavior,
GreatFairy_DropletCallBehavior,
GreatFairy_RippleCallBehavior,
GreatFairy_MiniAffineCallBehavior,
GreatFairy_DropletCallBehavior,
GreatFairy_RippleCallBehavior,
GreatFairy_BigRippleCallBehavior,
GreatFairy_EnergyCallBehavior,
sub_08087114,
sub_08087294
GreatFairy_EnergyCallBehavior,
sub_08087114,
sub_08087294,
};
void (*const GreatFairy_Behaviors[])(Entity*) = {
GreatFairy_Init,
GreatFairy_DormantUpdate,
GreatFairy_CreateBigRipple,
GreatFairy_SpawningUpdate,
GreatFairy_MiniUpdate,
GreatFairy_FinalUpdate
GreatFairy_Init, GreatFairy_DormantUpdate, GreatFairy_CreateBigRipple,
GreatFairy_SpawningUpdate, GreatFairy_MiniUpdate, GreatFairy_FinalUpdate,
};
const s16 GreatFairy_RippleOffsets[10] = {
0, 0,
-32, -8,
16, 20,
24, -12,
-16, 24
0, 0, -32, -8, 16, 20, 24, -12, -16, 24,
};
void (*const GreatFairy_WingsBehaviors[])(Entity*) = {
void (*const GreatFairy_WingsBehaviors[])(Entity*) = {
GreatFairy_WingsInit,
GreatFairy_WingsUpdate,
nullsub_116
nullsub_116,
};
void (*const GreatFairy_WakeBehaviors[])(Entity*) = {
GreatFairy_WakeInit,
GreatFairy_WakeUpdate
GreatFairy_WakeUpdate,
};
void (*const GreatFairy_MiniBehaviors[])(Entity*) = {
GreatFairy_MiniInit,
GreatFairy_MiniRisingUpdate,
GreatFairy_MiniRemoveMe
GreatFairy_MiniRemoveMe,
};
void (*const GreatFairy_MiniAffineBehaviors[])(Entity*) = {
GreatFairy_MiniAffineInit,
GreatFairy_MiniAffineInit2,
GreatFairy_MiniAffineUpdate,
DeleteEntity
DeleteEntity,
};
void (*const GreatFairy_DropletBehaviors[])(Entity*) = {
GreatFairy_DropletInit,
GreatFairy_DropletUpdate
GreatFairy_DropletUpdate,
};
void (*const GreatFairy_RippleBehaviors[])(Entity*) = {
GreatFairy_RippleInit,
GreatFairy_RippleUpdate
GreatFairy_RippleUpdate,
};
void (*const GreatFairy_BigRippleBehaviors[])(Entity*) = {
GreatFairy_BigRippleInit,
GreatFairy_BigRippleUpdate
GreatFairy_BigRippleUpdate,
};
void (*const GreatFairy_EnergyBehaviors[])(Entity*) = {
GreatFairy_EnergyInit,
GreatFairy_EnergyUpdate
GreatFairy_EnergyUpdate,
};
void (*const GreatFairy_Form1Behaviors[])(Entity*) = {
sub_08087150,
nullsub_516,
sub_080871A8,
sub_080871D0
sub_080871D0,
};
void (*const GreatFairy_Form2Behaviors[])(Entity*) = {
sub_08087150,
sub_080871F8,
sub_08087240,
sub_08087264,
sub_0808727C
sub_08087150, sub_080871F8, sub_08087240, sub_08087264, sub_0808727C,
};
// clang-format on
+18
View File
@@ -1,9 +1,13 @@
#include "global.h"
#include "entity.h"
#include "game.h"
#include "player.h"
#include "functions.h"
extern void DoExitTransition(void*);
extern void (*const gUnk_08122254[])(Entity*);
extern u16 gUnk_0812225C[];
void MinishSizedEntrance(Entity* this) {
gUnk_08122254[this->action](this);
@@ -20,3 +24,17 @@ void sub_08090EC0(Entity* this) {
LoadFixedGFX(this, 0x184);
}
}
void sub_08090F00(Entity* this) {
if (this->type == 1) {
Entity* parent = this->parent;
u32 mask = 1 << this->field_0xf;
if (!(parent->field_0x20 & mask)) {
DeleteThisEntity();
}
}
if ((gPlayerState.flags.all & 0x80) && sub_080041A0(this, &gPlayerEntity, 4, 4) &&
(gPlayerEntity.height.HALF.HI == 0) && (((u16)gPlayerState.field_0x90.HALF.LO) & gUnk_0812225C[this->type2])) {
DoExitTransition((Entity*)GetCurrentRoomProperty(this->actionDelay));
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#include "global.h"
#include "entity.h"
#include "functions.h"
#include "position.h"
#include "coord.h"
#include "random.h"
#include "structures.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
void Object7E(Entity* this) {
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "player.h"
#include "flags.h"
#include "functions.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
#include "room.h"
#include "functions.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "global.h"
#include "entity.h"
#include "position.h"
#include "coord.h"
extern void sub_080A0640(Entity*);
+2 -2
View File
@@ -2,7 +2,7 @@
#include "entity.h"
#include "player.h"
#include "textbox.h"
#include "readKeyInput.h"
#include "utils.h"
#include "area.h"
#include "save.h"
#include "game.h"
@@ -92,7 +92,7 @@ void PlayerInit(Entity* this) {
sub_08079938();
gPlayerState.field_0xa8 = 7;
sub_0807ACCC(this);
ent = FindEntityInListByForm(0x6, 0xf, 0x6, 0xb, 0x0);
ent = FindEntity(0x6, 0xf, 0x6, 0xb, 0x0);
if (ent != NULL) {
DeleteEntity(ent);
}
-50
View File
@@ -1,50 +0,0 @@
#include "global.h"
#include "entity.h"
#include "position.h"
extern u8 gUnk_08114F78[];
extern u8 gUnk_08114F80[];
void CopyPosition(Entity* param_1, Entity* param_2) {
PositionRelative(param_1, param_2, 0, 0);
}
void PositionEntityOnTop(Entity* ent, Entity* ent2) {
PositionRelative(ent, ent2, 0, 0);
ResolveEntityOnTop(ent, ent2);
}
void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) { // r0, r1, r2, r3
s32 x;
s32 y;
x = source->x.WORD;
target->x.WORD = x + offsetX;
y = source->y.WORD;
target->y.WORD = y + offsetY;
target->height = source->height; // ldr
target->collisionLayer = source->collisionLayer;
UpdateSpriteForCollisionLayer(target);
}
void CopyPositionAndSpriteOffset(Entity* param_1, Entity* param_2) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, 0, 0);
}
void sub_0806FA90(Entity* param_1, Entity* param_2, s32 offsetX, s32 offsetY) {
param_2->spriteOffsetX = param_1->spriteOffsetX;
param_2->spriteOffsetY = param_1->spriteOffsetY;
PositionRelative(param_1, param_2, offsetX * 64 * 32 * 32, offsetY * 64 * 32 * 32);
}
void ResolveEntityOnTop(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0];
}
void sub_0806FAD8(Entity* param_1, Entity* param_2) {
param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0];
}
+1 -1
View File
@@ -2235,7 +2235,7 @@ void sub_0804CD48(void) {
gFadeControl.active = 0;
gUsedPalettes = 0;
*(u16*)0x5000000 = 0x7fff;
sub_0801DA90(1);
DispReset(1);
}
if (CheckGlobalFlag(LV1_CLEAR)) {
LoadRoomEntityList(&gUnk_080DF94C);
+1 -1
View File
@@ -5,7 +5,7 @@
#include "script.h"
#include "structures.h"
#include "textbox.h"
#include "dma.h"
#include "utils.h"
#include "save.h"
#include "random.h"
#include "functions.h"
-17
View File
@@ -1,17 +0,0 @@
#include "global.h"
extern const u8 gUnk_020176E0[];
extern void sub_0807C960();
extern void LoadPalettes(const u8*, int, int);
void sub_0807C9D8(u32* a1) {
u32* v1; // r5@1
v1 = a1;
sub_0807C960(0x6004000, *a1);
sub_0807C960(0x6000000, v1[1]);
sub_0807C960(0x6008000, v1[2]);
sub_0807C960(gUnk_020176E0, v1[3]);
LoadPalettes(gUnk_020176E0, 2, 13);
}
-20
View File
@@ -1,20 +0,0 @@
#include "global.h"
extern void sub_080186EC();
extern u32* GetCurrentRoomProperty(u8);
extern void sub_0804B16C();
void sub_0804AFF4(void) {
void (*func)();
sub_080186EC();
func = (void (*)())GetCurrentRoomProperty(5);
if (func) {
func();
}
func = (void (*)())GetCurrentRoomProperty(7);
if (func) {
func();
}
sub_0804B16C();
}
+1 -1
View File
@@ -1,5 +1,5 @@
#include "global.h"
#include "dma.h"
#include "utils.h"
#include "structures.h"
extern u32 gUnk_020354C0;
-11
View File
@@ -1,11 +0,0 @@
#include "global.h"
s32 sub_0806F9EC(s16 unk_1, s16 unk_2) {
int temp;
temp = (s32)unk_1 * (s32)unk_2;
if (temp < 0) {
temp = temp + 255;
}
return (temp << 8) >> 16;
}
-14
View File
@@ -1,14 +0,0 @@
#include "global.h"
s16 sub_0806FA04(s16 param_1, s16 param_2) {
s16 sVar1;
s32 iVar2;
if (param_2 != 0) {
sVar1 = ((param_1 << 16) >> 8) / param_2;
iVar2 = sVar1;
} else {
iVar2 = 0;
}
return iVar2;
}
-18
View File
@@ -1,18 +0,0 @@
#include "global.h"
#include "functions.h"
extern void sub_08000152(u32);
extern void sub_0807B778(u32, u32);
void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) {
if (param_1 == 53) {
sub_08000152(53);
sub_0807B778(param_2, param_3);
sub_0807B778(param_2 + 1, param_3);
sub_0807B778(param_2 + -1, param_3);
sub_0807B778(param_2 + 64, param_3);
sub_0807B778(param_2 + -64, param_3);
} else {
SetTileType(param_1, param_2, param_3);
}
}
+40
View File
@@ -1,6 +1,22 @@
#include "global.h"
#include "functions.h"
extern void sub_08000152(u32);
extern void sub_0807B778(u32, u32);
void sub_0807B7D8(u32 param_1, u32 param_2, u32 param_3) {
if (param_1 == 53) {
sub_08000152(53);
sub_0807B778(param_2, param_3);
sub_0807B778(param_2 + 1, param_3);
sub_0807B778(param_2 + -1, param_3);
sub_0807B778(param_2 + 64, param_3);
sub_0807B778(param_2 + -64, param_3);
} else {
SetTileType(param_1, param_2, param_3);
}
}
void sub_0807B820(u32 param_1) {
SetTileType(620, param_1 + -65, 1);
SetTileType(627, param_1 + -65, 2);
@@ -12,3 +28,27 @@ void sub_0807B820(u32 param_1) {
SetTileType(624, param_1, 1);
SetTileType(626, param_1 + 1, 1);
}
void sub_0807B8A8(u32 param_1) {
SetTileType(636, param_1 + -65, 1);
SetTileType(643, param_1 + -65, 2);
SetTileType(637, param_1 + -64, 1);
SetTileType(644, param_1 + -64, 2);
SetTileType(638, param_1 + -63, 1);
SetTileType(645, param_1 + -63, 2);
SetTileType(639, param_1 + -1, 1);
SetTileType(640, param_1, 1);
SetTileType(642, param_1 + 1, 1);
}
void sub_0807B930(int param_1) {
SetTileType(652, param_1 + -65, 1);
SetTileType(659, param_1 + -65, 2);
SetTileType(653, param_1 + -64, 1);
SetTileType(660, param_1 + -64, 2);
SetTileType(654, param_1 + -63, 1);
SetTileType(661, param_1 + -63, 2);
SetTileType(655, param_1 + -1, 1);
SetTileType(656, param_1, 1);
SetTileType(658, param_1 + 1, 1);
}
-14
View File
@@ -1,14 +0,0 @@
#include "global.h"
#include "functions.h"
void sub_0807B8A8(u32 param_1) {
SetTileType(636, param_1 + -65, 1);
SetTileType(643, param_1 + -65, 2);
SetTileType(637, param_1 + -64, 1);
SetTileType(644, param_1 + -64, 2);
SetTileType(638, param_1 + -63, 1);
SetTileType(645, param_1 + -63, 2);
SetTileType(639, param_1 + -1, 1);
SetTileType(640, param_1, 1);
SetTileType(642, param_1 + 1, 1);
}
-14
View File
@@ -1,14 +0,0 @@
#include "global.h"
#include "functions.h"
void sub_0807B930(int param_1) {
SetTileType(652, param_1 + -65, 1);
SetTileType(659, param_1 + -65, 2);
SetTileType(653, param_1 + -64, 1);
SetTileType(660, param_1 + -64, 2);
SetTileType(654, param_1 + -63, 1);
SetTileType(661, param_1 + -63, 2);
SetTileType(655, param_1 + -1, 1);
SetTileType(656, param_1, 1);
SetTileType(658, param_1 + 1, 1);
}
+15
View File
@@ -1,10 +1,14 @@
#include "global.h"
extern void sub_0807C960();
extern void LoadPalettes(const u8*, s32, s32);
extern u16 gMetatilesBottom[];
extern u16 gMetatilesTop[];
extern u8 gUnk_08324AE4;
extern const u8 gUnk_020176E0[];
void sub_0807C960(void* dest, u32 offset) {
void* src;
@@ -24,3 +28,14 @@ void sub_0807C998(u32* a1) {
sub_0807C960(gMetatilesTop, a1[2]);
sub_0807C960(gMetatilesTop - 0x1000, a1[3]);
}
void sub_0807C9D8(u32* a1) {
u32* v1; // r5@1
v1 = a1;
sub_0807C960((u8*)0x6004000, *a1);
sub_0807C960((u8*)0x6000000, v1[1]);
sub_0807C960((u8*)0x6008000, v1[2]);
sub_0807C960((u8*)gUnk_020176E0, v1[3]);
LoadPalettes(gUnk_020176E0, 2, 13);
}
+10 -6
View File
@@ -1,7 +1,7 @@
#include "global.h"
#include "room.h"
#include "entity.h"
#include "dma.h"
#include "utils.h"
#include "functions.h"
#include "textbox.h"
#include "structures.h"
@@ -14,11 +14,14 @@ u32 sub_080565B4(void);
u32 sub_080565F8(void);
u32 sub_08056640(void);
u32 (*const gUnk_08107BC8[])(void) = { sub_080564DC, sub_080564EC, sub_08056654,
sub_080565B4, sub_080565F8, sub_08056640 };
u32 (*const gUnk_08107BC8[])(void) = {
sub_080564DC, sub_080564EC, sub_08056654, sub_080565B4, sub_080565F8, sub_08056640,
};
extern u8 gUnk_020227DC, gUnk_020227E8, gUnk_020227F0, gUnk_020227F8, gUnk_02022800;
u8* const gUnk_08107BE0[] = { &gUnk_020227DC, &gUnk_020227E8, &gUnk_020227F0, &gUnk_020227F8, &gUnk_02022800 };
u8* const gUnk_08107BE0[] = {
&gUnk_020227DC, &gUnk_020227E8, &gUnk_020227F0, &gUnk_020227F8, &gUnk_02022800,
};
void sub_08056684(struct_02022780*);
void sub_080566B8(struct_02022780*);
@@ -27,8 +30,9 @@ void sub_08056B1C(struct_02022780*);
void sub_08056B7C(struct_02022780*);
void sub_080569D4(struct_02022780*);
void (*const gUnk_08107BF4[])(struct_02022780*) = { sub_08056684, sub_080566B8, sub_08056BA0,
sub_08056B1C, sub_08056B7C, sub_080569D4 };
void (*const gUnk_08107BF4[])(struct_02022780*) = {
sub_08056684, sub_080566B8, sub_08056BA0, sub_08056B1C, sub_08056B7C, sub_080569D4,
};
extern u32 gUnk_02036A40;
extern u32 gUnk_02036A38;
+204
View File
@@ -0,0 +1,204 @@
#include "global.h"
#include "utils.h"
#include "structures.h"
#include "screen.h"
static void StoreKeyInput(Input* input, u32 keyInput);
typedef struct {
u16 paletteId;
u8 destPaletteNum;
u8 numPalettes;
} PaletteGroup;
typedef struct {
union {
int raw;
struct {
u8 filler0[0x3];
u8 unk3;
} bytes;
} unk0;
u32 dest;
u32 unk8;
} GfxItem;
extern const PaletteGroup* gPaletteGroups[];
extern const u8 gGlobalGfxAndPalettes[];
extern u32 gUsedPalettes;
extern u16 gPaletteBuffer[];
extern const GfxItem* gUnk_08100AA8[];
void MemFill16(u32 value, void* dest, u32 size) {
DmaFill16(3, value, dest, size);
}
void MemFill32(u32 value, void* dest, u32 size) {
DmaFill32(3, value, dest, size);
}
void MemClear(void* dest, u32 size) {
u32 zero = 0;
switch (((u32)dest | size) & 3) {
case 0:
MemFill32(0, dest, size);
break;
case 2:
MemFill16(0, dest, size);
break;
default:
do {
*(u8*)dest = zero;
dest++;
size--;
} while (size != 0);
}
}
void MemCopy(const void* src, void* dest, u32 size) {
switch (((u32)src | (u32)dest | size) & 3) {
case 0:
DmaCopy32(3, src, dest, size);
break;
case 2:
DmaCopy16(3, src, dest, size);
break;
default:
do {
*(u8*)dest = *(u8*)src;
src++;
dest++;
} while (--size);
}
}
void ReadKeyInput(void) {
u32 keyInput = ~REG_KEYINPUT & KEYS_MASK;
StoreKeyInput(&gInput, keyInput);
}
static void StoreKeyInput(Input* input, u32 keyInput) {
u32 heldKeys = input->heldKeys;
u32 difference = keyInput & ~heldKeys;
input->newKeys = difference;
if (keyInput == heldKeys) {
if (--input->unk7 == 0) {
input->unk7 = 4;
input->unk4 = keyInput;
} else {
input->unk4 = 0;
}
} else {
input->unk7 = 0x14;
input->unk4 = difference;
}
input->heldKeys = keyInput;
}
void LoadPaletteGroup(u32 group) {
const PaletteGroup* paletteGroup = gPaletteGroups[group];
while (1) {
u32 destPaletteNum = paletteGroup->destPaletteNum;
u32 numPalettes = paletteGroup->numPalettes & 0xF;
if (numPalettes == 0) {
numPalettes = 16;
}
LoadPalettes(&gGlobalGfxAndPalettes[paletteGroup->paletteId * 32], destPaletteNum, numPalettes);
if ((paletteGroup->numPalettes & 0x80) == 0) {
break;
}
paletteGroup++;
}
}
void LoadPalettes(const u8* src, int destPaletteNum, int numPalettes) {
u16* dest;
u32 size = numPalettes * 32;
u32 usedPalettesMask = 1 << destPaletteNum;
while (--numPalettes > 0) {
usedPalettesMask |= (usedPalettesMask << 1);
}
gUsedPalettes |= usedPalettesMask;
dest = &gPaletteBuffer[destPaletteNum * 16];
DmaCopy32(3, src, dest, size);
}
void sub_0801D79C(u32 colorIndex, u32 color) {
gPaletteBuffer[colorIndex] = color;
gUsedPalettes |= 1 << (colorIndex / 16);
}
void sub_0801D7BC(u32 color, u32 arg1) {
if (arg1) {
gScreen.lcd.unk6 = 0xE0FF;
} else {
gScreen.lcd.unk6 = 0xFFFF;
}
sub_0801D79C(0, color);
}
void LoadGfxGroup(u32 group) {
u32 terminator;
u32 dmaCtrl;
int gfxOffset;
const u8* src;
u32 dest;
int size;
const GfxItem* gfxItem = gUnk_08100AA8[group];
while (1) {
u32 loadGfx = FALSE;
u32 ctrl = gfxItem->unk0.bytes.unk3;
ctrl &= 0xF;
switch (ctrl) {
case 0x7:
loadGfx = TRUE;
break;
case 0xD:
return;
case 0xE:
if (gUnk_02000000->gameLanguage != 0 && gUnk_02000000->gameLanguage != 1) {
loadGfx = TRUE;
}
break;
case 0xF:
if (gUnk_02000000->gameLanguage != 0) {
loadGfx = TRUE;
}
break;
default:
if (ctrl == gUnk_02000000->gameLanguage) {
loadGfx = TRUE;
}
break;
}
if (loadGfx) {
gfxOffset = gfxItem->unk0.raw & 0xFFFFFF;
src = &gGlobalGfxAndPalettes[gfxOffset];
dest = gfxItem->dest;
size = gfxItem->unk8;
dmaCtrl = 0x80000000;
if (size < 0) {
if (dest >= VRAM) {
LZ77UnCompVram(src, (void*)dest);
} else {
LZ77UnCompWram(src, (void*)dest);
}
} else {
DmaSet(3, src, dest, dmaCtrl | ((u32)size >> 1));
}
}
terminator = gfxItem->unk0.bytes.unk3;
terminator &= 0x80;
gfxItem++;
if (!terminator) {
break;
}
}
}
/* TODO:
clear OAM, zMalloc, etc.
*/