mirror of
https://github.com/zeldaret/tmc
synced 2026-06-05 19:28:20 -04:00
finish main.c
This commit is contained in:
+1
-1
@@ -42,7 +42,7 @@ u32 sub_0807CDE8(u32 arg0) {
|
||||
temp = 1;
|
||||
break;
|
||||
case 2:
|
||||
temp = sub_0807CF10((u8*)gUnk_02000000->header);
|
||||
temp = sub_0807CF10((u8*)&gUnk_02000000->signature);
|
||||
break;
|
||||
}
|
||||
gMenu.field_0xa = temp;
|
||||
|
||||
@@ -337,7 +337,7 @@ bool32 sub_0802C0E8(Entity* this) {
|
||||
u32 ret = FALSE;
|
||||
if (!sub_0806FC24(TILE(x, y), 9)) {
|
||||
u32 tmp = sub_080AE4CC(ent, x, y, 0);
|
||||
ret = (-tmp | tmp) >> 0x1f;
|
||||
ret = BOOLCAST(tmp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#include "global.h"
|
||||
#include "functions.h"
|
||||
#include "structures.h"
|
||||
#include "main.h"
|
||||
#include "screen.h"
|
||||
#include "random.h"
|
||||
#include "readKeyInput.h"
|
||||
|
||||
extern u8 gUnk_03003DE4;
|
||||
|
||||
extern void sub_0804FF84(u32);
|
||||
extern u16 gPaletteBuffer[];
|
||||
extern void VBlankInterruptWait(void);
|
||||
@@ -137,3 +141,128 @@ void DoSoftReset(void) {
|
||||
DisableInterruptsAndDMA();
|
||||
SoftReset(RESET_ALL & ~(RESET_EWRAM | RESET_SIO_REGS));
|
||||
}
|
||||
|
||||
const int sDefaultSettings[] = { SIGNATURE, '\1\1\1\0', 'KNIL', '\0\0\0\0' };
|
||||
|
||||
// single misplaced ldr
|
||||
NONMATCH("asm/non_matching/sub_080560B8.inc", void sub_080560B8(void)) {
|
||||
u32 temp;
|
||||
u32 b;
|
||||
|
||||
if (!sub_08056134()) {
|
||||
switch ((s32)sub_0807CF30((void*)0x2000000)) {
|
||||
case 1:
|
||||
if (sub_08056134())
|
||||
break;
|
||||
case 0:
|
||||
case -1:
|
||||
default:
|
||||
_DmaCopy(&sDefaultSettings, (void*)0x2000000, 16);
|
||||
sub_0807CF10((u8*)0x2000000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
temp = gUnk_02000010.signature ^ SIGNATURE;
|
||||
b = BOOLCAST(temp);
|
||||
|
||||
if ((gUnk_02000010.field_0x4 != 0) && (gUnk_02000010.field_0x4 != 0xc1)) {
|
||||
b = 1;
|
||||
}
|
||||
if (b != 0) {
|
||||
_DmaZero((u8*)&gUnk_02000010.signature, 0x20);
|
||||
gUnk_02000010.signature = SIGNATURE;
|
||||
}
|
||||
}
|
||||
END_NONMATCH
|
||||
|
||||
u32 sub_08056134(void) {
|
||||
if ((gUnk_02000000->signature != SIGNATURE) || (gUnk_02000000->saveFileId >= MAX_SAVE_FILES) ||
|
||||
(gUnk_02000000->messageSpeed >= MAX_MSG_SPEED) || (gUnk_02000000->brightnessPref >= MAX_BRIGHTNESS) ||
|
||||
(gUnk_02000000->gameLanguage != GAME_LANGUAGE) || (gUnk_02000000->_e != 0))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void sub_0805616C() {
|
||||
PlaySFX(0x80040000);
|
||||
gScreen._6d = gScreen._6c;
|
||||
gScreen._6c = 0;
|
||||
|
||||
DmaStop(0);
|
||||
|
||||
DmaWait(0);
|
||||
DmaWait(1);
|
||||
DmaWait(2);
|
||||
DmaWait(3);
|
||||
}
|
||||
|
||||
void sub_08056208() {
|
||||
PlaySFX(0x80060000);
|
||||
gScreen._6c = gScreen._6d;
|
||||
gScreen._6d = 0;
|
||||
}
|
||||
|
||||
void sub_0805622C(u32 a1, u32 a2, u32 a3) {
|
||||
gScreen._70 = a1;
|
||||
gScreen._74 = a2;
|
||||
gScreen._78 = a3;
|
||||
gScreen._6c = 1;
|
||||
gUnk_03003DE4 ^= 1;
|
||||
}
|
||||
|
||||
void sub_08056250() {
|
||||
gScreen._6c = 0;
|
||||
}
|
||||
|
||||
void sub_08056260(void) {
|
||||
u32 temp;
|
||||
Main* temp2;
|
||||
|
||||
REG_DISPCNT = 0x80;
|
||||
REG_KEYCNT = 0x8304;
|
||||
REG_IME = 0;
|
||||
temp = REG_IE;
|
||||
REG_IE = 0x3000;
|
||||
REG_IME = 1;
|
||||
Stop();
|
||||
REG_IME = 0;
|
||||
REG_IE = temp;
|
||||
REG_IME = 1;
|
||||
temp2 = &gUnk_03001000;
|
||||
asm("ldrb r1, [r0, #0x1]");
|
||||
temp2->field_0x1 = 0;
|
||||
}
|
||||
|
||||
// Convert in-game 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);
|
||||
u32 y = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) - y0 + DISPLAY_HEIGHT);
|
||||
u32 a = x1 + DISPLAY_WIDTH;
|
||||
u32 b = y1 + DISPLAY_HEIGHT;
|
||||
if ((x < a) && (y < b))
|
||||
result = TRUE;
|
||||
else
|
||||
result = FALSE;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Iterate over array of AABBs and check if any fit on screen
|
||||
u16 sub_08056300(u16* arr) {
|
||||
u16* i;
|
||||
for (i = arr; *i != 0xff; i += 5) {
|
||||
if (sub_080562CC(i[1], i[2], i[3], i[4]) != 0)
|
||||
return *i;
|
||||
}
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
void NulledItem() {
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
void sub_08056330() {
|
||||
DeleteThisEntity();
|
||||
}
|
||||
+1
-1
@@ -159,5 +159,5 @@ void sub_08063504(Entity* this, u32* param_2) {
|
||||
u32 uVar1;
|
||||
|
||||
uVar1 = sub_080544DC(gUnk_0810C88C[this->entityType.parameter]);
|
||||
param_2[5] = (-uVar1 | uVar1) >> 0x1F;
|
||||
param_2[5] = BOOLCAST(uVar1);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void sub_080601D4(Entity* this) {
|
||||
uVar2 = 2;
|
||||
} else {
|
||||
temp = CheckKinstoneFused(0x17);
|
||||
uVar2 = (-temp | temp) >> 0x1f;
|
||||
uVar2 = BOOLCAST(temp);
|
||||
}
|
||||
TextboxNoOverlap(gUnk_0810A354[uVar2], this);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ void sub_0806021C(Entity* this) {
|
||||
|
||||
// jabber nut
|
||||
uVar1 = GetInventoryValue(0x5B);
|
||||
uVar2 = (-uVar1 | uVar1) >> 0x1f;
|
||||
uVar2 = BOOLCAST(uVar1);
|
||||
|
||||
// earth element
|
||||
if (GetInventoryValue(0x40)) {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ void sub_080693D0(Entity* this) {
|
||||
sub_0807DD94(this, 0);
|
||||
if (this->animIndex == 8) {
|
||||
u32 var0 = this->field_0x82.HWORD & 0xF;
|
||||
bool32 createFx65 = ((-var0) | var0) >> 0x1F; // = !var0
|
||||
bool32 createFx65 = BOOLCAST(var0); // = !var0
|
||||
|
||||
if (this->frames.all == 1) {
|
||||
this->frames.all = 0;
|
||||
|
||||
@@ -114,7 +114,7 @@ u32 sub_080696BC(Entity* this) {
|
||||
}
|
||||
|
||||
temp = CheckGlobalFlag(0x3e);
|
||||
uVar1 = (-temp | temp) >> 0x1f;
|
||||
uVar1 = BOOLCAST(temp);
|
||||
|
||||
if (CheckGlobalFlag(0x3f)) {
|
||||
uVar1 = 2;
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ void sub_08063D44(Entity* this) {
|
||||
|
||||
temp = this->entityType.subtype;
|
||||
temp ^= 0x15;
|
||||
idx = ((-temp | temp) >> 0x1f) * 4;
|
||||
idx = BOOLCAST(temp) * 4;
|
||||
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
|
||||
return;
|
||||
|
||||
@@ -132,7 +132,7 @@ void sub_08063E90(Entity* this) {
|
||||
|
||||
temp = this->entityType.subtype;
|
||||
temp ^= 0x15;
|
||||
idx = ((-temp | temp) >> 0x1f) * 4;
|
||||
idx = BOOLCAST(temp) * 4;
|
||||
if (!LoadExtraSpriteData(this, &gUnk_0810F524[idx]))
|
||||
return;
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ void sub_080670B4(Entity* this) {
|
||||
uVar2 = 0;
|
||||
if (GetInventoryValue(0x11) == 0) {
|
||||
uVar1 = CheckGlobalFlag(TABIDACHI);
|
||||
uVar2 = (-uVar1 | uVar1) >> 0x1f;
|
||||
uVar2 = BOOLCAST(uVar1);
|
||||
}
|
||||
TextboxNoOverlap(gUnk_08110C0C[uVar2], this);
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ void sub_0806B098(Entity* this) {
|
||||
idx = 1;
|
||||
if (CheckGlobalFlag(0x29)) {
|
||||
f = CheckGlobalFlag(0x2a);
|
||||
idx = (-f | f) >> 0x1f;
|
||||
idx = BOOLCAST(f);
|
||||
}
|
||||
}
|
||||
TextboxNoOverlap(gUnk_08112C50[(this->entityType.parameter - 7) * 3 + idx], this);
|
||||
|
||||
@@ -60,7 +60,7 @@ void sub_0809EABC(Entity* this) {
|
||||
u32 f;
|
||||
|
||||
f = CheckFlags(this->field_0x86.HWORD);
|
||||
anySet = (-f | f) >> 0x1F;
|
||||
anySet = BOOLCAST(f);
|
||||
if (this->frameIndex != anySet) {
|
||||
this->frameIndex = anySet;
|
||||
}
|
||||
|
||||
+1
-1
@@ -4489,7 +4489,7 @@ void sub_0804E3C4() {
|
||||
u32 index;
|
||||
u32 tmp;
|
||||
tmp = CheckGlobalFlag(LV4_CLEAR);
|
||||
index = (-tmp | tmp) >> 0x1F;
|
||||
index = BOOLCAST(tmp);
|
||||
if (CheckGlobalFlag(LV5_CLEAR)) {
|
||||
index = 2;
|
||||
}
|
||||
|
||||
+15
-20
@@ -2,6 +2,7 @@
|
||||
#include "room.h"
|
||||
#include "entity.h"
|
||||
#include "textbox.h"
|
||||
#include "structures.h"
|
||||
|
||||
void _DmaZero();
|
||||
void ShowTextbox();
|
||||
@@ -10,31 +11,31 @@ void TextboxAtPosition();
|
||||
extern u32 gUnk_02022780;
|
||||
extern u32 gUnk_02036A40;
|
||||
extern u32 gUnk_02036A38;
|
||||
extern u32 gUnk_02000040;
|
||||
|
||||
void sub_08056360(void)
|
||||
s32 sub_08056338(void) {
|
||||
s32 result;
|
||||
|
||||
{
|
||||
if ((gTextBox.doTextBox & 127) != 0) {
|
||||
gTextBox.doTextBox = 136;
|
||||
}
|
||||
return;
|
||||
result = -1;
|
||||
if (((gTextBox.doTextBox & 0x7f) == 0) && (gUnk_02000040.unk_00 == 3))
|
||||
result = gUnk_02000040.unk_01;
|
||||
return result;
|
||||
}
|
||||
|
||||
void TextboxNoOverlapFollow(u32 index)
|
||||
void sub_08056360(void) {
|
||||
if ((gTextBox.doTextBox & 0x7f) != 0) {
|
||||
gTextBox.doTextBox = 0x80 | 0x8;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
void TextboxNoOverlapFollow(u32 index) {
|
||||
if (gRoomControls.cameraTarget != NULL) {
|
||||
TextboxNoOverlap(index, gRoomControls.cameraTarget);
|
||||
} else {
|
||||
ShowTextbox(index);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void TextboxNoOverlap(u32 index, Entity* ent)
|
||||
|
||||
{
|
||||
void TextboxNoOverlap(u32 index, Entity* ent) {
|
||||
s16 y;
|
||||
s16 h;
|
||||
|
||||
@@ -43,22 +44,19 @@ void TextboxNoOverlap(u32 index, Entity* ent)
|
||||
y = ent->y.HALF.HI;
|
||||
h = ent->height.HALF.HI;
|
||||
|
||||
if (88 < ((y + h) - gRoomControls.roomScrollY)) {
|
||||
if (((y + h) - gRoomControls.roomScrollY) > 0x58) {
|
||||
gTextBox.textWindowPosY = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void sub_080563C8(u32 param_1, u32 param_2) {
|
||||
TextboxAtPosition(param_1, 1, param_2);
|
||||
return;
|
||||
}
|
||||
|
||||
void TextboxAtPosition(u32 index, u32 x, u32 y) {
|
||||
ShowTextbox(index);
|
||||
gTextBox.textWindowPosX = x;
|
||||
gTextBox.textWindowPosY = y;
|
||||
return;
|
||||
}
|
||||
|
||||
void ShowTextbox(u32 index, u32 param_2, u32* dest) {
|
||||
@@ -70,15 +68,12 @@ void ShowTextbox(u32 index, u32 param_2, u32* dest) {
|
||||
gTextBox.textWindowPosX = 1;
|
||||
gTextBox.textWindowPosY = 12;
|
||||
gTextBox.doTextBox = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
void sub_08056418(void) {
|
||||
|
||||
_DmaZero(&gTextBox, 32);
|
||||
_DmaZero(&gUnk_02022780, 168);
|
||||
_DmaZero(&gUnk_02036A40, 8);
|
||||
_DmaZero(&gUnk_02036A38, 8);
|
||||
_DmaZero(&gUnk_02000040, 4);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{
|
||||
"folders" : [ { "path" : ".." } ], "settings" : {
|
||||
"files.associations" : {
|
||||
"algorithm" : "cpp", "ios" : "c"
|
||||
"algorithm": "cpp",
|
||||
"ios": "c",
|
||||
"functions.h": "c"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user