mirror of
https://github.com/zeldaret/tmc
synced 2026-09-07 11:21:35 -04:00
Decompile some more of mainLoop.c
This commit is contained in:
+1
-18
@@ -1,26 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "entity.h"
|
||||
#include "area.h"
|
||||
#include "main.h"
|
||||
#include "functions.h"
|
||||
#include "screen.h"
|
||||
|
||||
typedef struct {
|
||||
u8 interruptFlag;
|
||||
u8 field_0x1;
|
||||
u8 loadType;
|
||||
u8 funcIndex;
|
||||
u8 transition;
|
||||
u16 field_0x5;
|
||||
u8 muteAudio;
|
||||
u8 field_0x8;
|
||||
u8 countdown;
|
||||
u8 field_0xa;
|
||||
u8 field_0xb;
|
||||
u8 ticks;
|
||||
u8 field_0xe;
|
||||
u8 field_0xf;
|
||||
} Main;
|
||||
|
||||
typedef struct {
|
||||
u8 filler [18];
|
||||
u32 unk;
|
||||
@@ -32,7 +16,6 @@ extern void (*const gUnk_080D4120[])();
|
||||
extern void (*const gUnk_080D412C[])();
|
||||
|
||||
|
||||
extern Main gUnk_03001000;
|
||||
extern struct_02018EB0 gUnk_02018EB0;
|
||||
extern u8 gUnk_03000FD0;
|
||||
|
||||
|
||||
+9
-12
@@ -2,26 +2,23 @@
|
||||
#include "entity.h"
|
||||
#include "readKeyInput.h"
|
||||
|
||||
void StoreKeyInput(Input *pkeyInput, u32 ioKeyInput);
|
||||
static void StoreKeyInput(Input*, u32);
|
||||
|
||||
void ReadKeyInput(void)
|
||||
{
|
||||
u32 reg = ~*(u16*)0x04000130 & 0x3FF;
|
||||
Input* input = &gUnk_03000FF0;
|
||||
StoreKeyInput(input, reg);
|
||||
u32 keyInput = ~REG_KEYINPUT & KEYS_MASK;
|
||||
StoreKeyInput(&gUnk_03000FF0, keyInput);
|
||||
}
|
||||
|
||||
void StoreKeyInput(Input *input, u32 ioKeyInput)
|
||||
static void StoreKeyInput(Input *input, u32 keyInput)
|
||||
{
|
||||
u32 difference;
|
||||
u32 temp = input->heldKeys;
|
||||
|
||||
difference = ioKeyInput & ~temp;
|
||||
u32 heldKeys = input->heldKeys;
|
||||
u32 difference = keyInput & ~heldKeys;
|
||||
input->newKeys = difference;
|
||||
if (ioKeyInput == temp) {
|
||||
if (keyInput == heldKeys) {
|
||||
if (--input->unk7 == 0) {
|
||||
input->unk7 = 4;
|
||||
input->unk4 = ioKeyInput;
|
||||
input->unk4 = keyInput;
|
||||
}
|
||||
else {
|
||||
input->unk4 = 0;
|
||||
@@ -31,5 +28,5 @@ void StoreKeyInput(Input *input, u32 ioKeyInput)
|
||||
input->unk7 = 0x14;
|
||||
input->unk4 = difference;
|
||||
}
|
||||
input->heldKeys = ioKeyInput;
|
||||
input->heldKeys = keyInput;
|
||||
}
|
||||
+73
-6
@@ -2,13 +2,18 @@
|
||||
#include "functions.h"
|
||||
#include "main.h"
|
||||
#include "random.h"
|
||||
#include "readKeyInput.h"
|
||||
|
||||
extern void sub_0804FF84(u32);
|
||||
extern void _DmaZero(void*, u32);
|
||||
|
||||
extern u32 gUnk_020176A0;
|
||||
extern const void (*gUnk_08100CBC[])();
|
||||
extern void VBlankInterruptWait(void);
|
||||
extern void DisableInterruptsAndDMA(void);
|
||||
extern void sub_0801D66C(void*, u8*, int);
|
||||
extern void sub_08016B34(void);
|
||||
|
||||
static void sub_08055F70(void);
|
||||
static bool32 SoftResetKeysPressed(void);
|
||||
|
||||
void MainLoop(void) {
|
||||
int var0;
|
||||
@@ -27,11 +32,11 @@ void MainLoop(void) {
|
||||
sub_080ADD30();
|
||||
gRand = 0x1234567;
|
||||
_DmaZero(&gUnk_03001000, 16);
|
||||
sub_08056010(0);
|
||||
InitScreen(SCREEN_INTRO);
|
||||
while (1) {
|
||||
ReadKeyInput();
|
||||
if (sub_08055FF4()) {
|
||||
sub_080560A8();
|
||||
if (SoftResetKeysPressed()) {
|
||||
DoSoftReset();
|
||||
}
|
||||
|
||||
switch (gUnk_03001000.field_0x1) {
|
||||
@@ -55,7 +60,7 @@ void MainLoop(void) {
|
||||
}
|
||||
|
||||
gUnk_03001000.ticks++;
|
||||
gUnk_08100CBC[gUnk_03001000.loadType]();
|
||||
gUnk_08100CBC[gUnk_03001000.screen]();
|
||||
sub_08056458();
|
||||
sub_08050154();
|
||||
sub_080A3480();
|
||||
@@ -65,3 +70,65 @@ void MainLoop(void) {
|
||||
sub_08016E78();
|
||||
}
|
||||
}
|
||||
|
||||
// Interrupt handlers that are loaded into RAM.
|
||||
extern u8 sub_080B197C[];
|
||||
extern u8 gUnk_030056F0[];
|
||||
extern u8 gUnk_02038560[];
|
||||
extern u8 gUnk_080B2CD8[];
|
||||
extern u8 gUnk_080B2CD8_2[];
|
||||
extern u8 gUnk_080B2CD8_3[];
|
||||
extern u8 gUnk_02000030[];
|
||||
|
||||
static void sub_08055F70(void) {
|
||||
u32 size;
|
||||
|
||||
DisableInterruptsAndDMA();
|
||||
RegisterRamReset(RESET_ALL & ~RESET_EWRAM);
|
||||
*(vu16 *)BG_PLTT = 0x7FFF;
|
||||
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;
|
||||
size = 0x3FFD0;
|
||||
_DmaZero(gUnk_02000030, size);
|
||||
size = (u32)gUnk_080B2CD8 - (u32)sub_080B197C;
|
||||
if (size != 0) {
|
||||
sub_0801D66C(sub_080B197C, gUnk_030056F0, size);
|
||||
}
|
||||
|
||||
size = (u32)gUnk_080B2CD8_2 - (u32)gUnk_080B2CD8_3;
|
||||
if (size != 0) {
|
||||
sub_0801D66C(gUnk_080B2CD8_3, gUnk_02038560, size);
|
||||
}
|
||||
|
||||
sub_0801DA90(0);
|
||||
sub_08016B34();
|
||||
}
|
||||
|
||||
#define SOFT_RESET_KEYS (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON)
|
||||
|
||||
static bool32 SoftResetKeysPressed(void) {
|
||||
return (gUnk_03000FF0.heldKeys & SOFT_RESET_KEYS) == SOFT_RESET_KEYS;
|
||||
}
|
||||
|
||||
void InitScreen(u32 screen) {
|
||||
gUnk_03001000.screen = screen;
|
||||
gUnk_03001000.funcIndex = 0;
|
||||
gUnk_03001000.transition = 0;
|
||||
}
|
||||
|
||||
void DisableInterruptsAndDMA(void) {
|
||||
REG_IME = 0;
|
||||
REG_IE = 0;
|
||||
REG_DISPSTAT = 0;
|
||||
REG_IF = 0;
|
||||
REG_IME = 0;
|
||||
|
||||
DmaStop(0);
|
||||
DmaStop(1);
|
||||
DmaStop(2);
|
||||
DmaStop(3);
|
||||
}
|
||||
|
||||
void DoSoftReset(void) {
|
||||
DisableInterruptsAndDMA();
|
||||
SoftReset(RESET_ALL & ~(RESET_EWRAM | RESET_SIO_REGS));
|
||||
}
|
||||
|
||||
+4
-7
@@ -1,13 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
|
||||
extern void sub_08056010(u32);
|
||||
extern u8 gUnk_03000FD0;
|
||||
|
||||
void sub_080AD834(void)
|
||||
|
||||
{
|
||||
if (gUnk_03000FD0 == '\0') {
|
||||
sub_08056010(1);
|
||||
void sub_080AD834(void) {
|
||||
if (gUnk_03000FD0 == 0) {
|
||||
InitScreen(SCREEN_CHOOSE_FILE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user