HandleLinkConnection

This commit is contained in:
PikalaxALT 2017-11-13 01:01:27 -05:00
parent abec2b9340
commit 7e4cb5f332
11 changed files with 94 additions and 91 deletions

View File

@ -5,57 +5,6 @@
.text
thumb_func_start HandleLinkConnection
HandleLinkConnection: @ 800B40C
push {r4,r5,lr}
ldr r0, =gWirelessCommType
ldrb r0, [r0]
cmp r0, 0
bne _0800B45C
ldr r0, =gShouldAdvanceLinkState
ldr r1, =gSendCmd
ldr r2, =gRecvCmds
bl sub_800B638
ldr r4, =gLinkStatus
str r0, [r4]
ldr r0, =gMain+0x2c
bl LinkMain2
ldr r0, [r4]
movs r1, 0x80
lsls r1, 1
ands r0, r1
cmp r0, 0
beq _0800B480
bl sub_808766C
cmp r0, 0x1
bne _0800B480
_0800B43E:
movs r0, 0x1
b _0800B482
.pool
_0800B45C:
bl sub_8010EC0
adds r4, r0, 0
bl sub_8010F1C
adds r5, r0, 0
bl sub_808766C
cmp r0, 0x1
bne _0800B480
cmp r4, 0x1
beq _0800B43E
bl sub_800F0B8
cmp r0, 0
bne _0800B43E
cmp r5, 0
bne _0800B43E
_0800B480:
movs r0, 0
_0800B482:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end HandleLinkConnection
thumb_func_start sub_800B488
sub_800B488: @ 800B488
push {lr}

12
include/agb_flash.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_AGB_FLASH_H
#define GUARD_AGB_FLASH_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
#endif //GUARD_AGB_FLASH_H

11
include/crt0.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef GUARD_CRT0_H
#define GUARD_CRT0_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
extern u32 IntrMain[];
#endif //GUARD_CRT0_H

11
include/intro.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef GUARD_INTRO_H
#define GUARD_INTRO_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void c2_copyright_1(void);
#endif //GUARD_INTRO_H

View File

@ -159,7 +159,6 @@ extern u16 gLinkType;
extern u32 gLinkStatus;
extern u16 gBlockRecvBuffer[MAX_RFU_PLAYERS][BLOCK_BUFFER_SIZE / 2];
extern u16 gSendCmd[CMD_LENGTH];
extern u8 gShouldAdvanceLinkState;
extern struct LinkPlayer gLinkPlayers[];
extern u16 word_3002910[];
extern bool8 gReceivedRemoteLinkPlayers;
@ -200,7 +199,6 @@ void LinkVSync(void);
void Timer3Intr(void);
void SerialCB(void);
u8 GetLinkPlayerCount(void);
void sub_800E0E8(void);
bool8 sub_800A520(void);
void sub_800DFB4(u8, u8);
@ -210,7 +208,7 @@ void sub_800A620(void);
void sub_8011BD0(void);
u8 IsLinkMaster(void);
void sub_800AC34(void);
bool8 HandleLinkConnection(void);
void SetLinkDebugValues(u32 seed, u32 flags);
void sub_800A418(void);
void SetSuppressLinkErrorMessage(bool8 flag);
@ -218,6 +216,7 @@ void sub_800B524(struct LinkPlayer *linkPlayer);
u8 sub_800B2E8(void);
u8 sub_800B320(void);
u8 sub_800B33C(void);
void sub_800B9B8(void);
extern u16 gUnknown_03003020[6];
extern u32 gLinkDebugSeed;

View File

@ -25,5 +25,10 @@ bool8 Rfu_IsMaster(void);
void task_add_05_task_del_08FA224_when_no_RfuFunc(void);
void sub_8010434(void);
void sub_800E604(void);
void sub_800E174(void);
void sub_800E6D0(void);
bool32 sub_8010EC0(void);
bool32 sub_8010F1C(void);
bool32 sub_800F0B8(void);
#endif //GUARD_LINK_RFU_H

View File

@ -2,6 +2,8 @@
#define GUARD_LOAD_SAVE_H
extern bool32 gFlashMemoryPresent;
extern struct SaveBlock2 gSaveblock2;
extern struct PokemonStorage gPokemonStorage;
void ClearSav2(void);
void ClearSav1(void);
@ -19,6 +21,5 @@ void LoadSerializedGame(void);
void LoadPlayerBag(void);
void SavePlayerBag(void);
void SetSaveBlocksPointers(u16);
void MoveSaveBlocks_ResetHeap(void);
#endif // GUARD_LOAD_SAVE_H

View File

@ -20,5 +20,6 @@ void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo);
extern struct MusicPlayerInfo gMPlay_SE1;
extern struct MusicPlayerInfo gMPlay_SE2;
extern struct MusicPlayerInfo gMPlay_SE3;
extern struct SoundInfo gSoundInfo;
#endif //GUARD_M4A_H

View File

@ -66,4 +66,8 @@ void c2_load_new_map(void);
void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused);
void mapldr_default(void);
bool32 sub_80875C8(void);
bool32 sub_8087634(void);
bool32 sub_808766C(void);
#endif //GUARD_ROM4_H

View File

@ -152,6 +152,7 @@ static void sub_800AE5C(void);
static void sub_800AEB4(void);
static void sub_800B1A0(void);
u8 sub_800B2F8(void);
u32 sub_800B638(bool8 *shouldAdvanceLinkState, u16 *sendCmd, u16 (*recvCmds)[8]);
void sub_800B4A4(void);
void DisableSerial(void);
void EnableSerial(void);
@ -1812,3 +1813,32 @@ void sub_800B3A4(u8 who)
SetMainCallback2(CB2_LinkError);
}
}
bool8 HandleLinkConnection(void)
{
bool32 r4;
bool32 r5;
if (gWirelessCommType == 0)
{
gLinkStatus = sub_800B638(&gShouldAdvanceLinkState, gSendCmd, gRecvCmds);
LinkMain2(&gMain.heldKeys);
if ((gLinkStatus & LINK_STAT_RECEIVED_NOTHING) && sub_808766C() == TRUE)
{
return TRUE;
}
}
else
{
r4 = sub_8010EC0();
r5 = sub_8010F1C();
if (sub_808766C() == TRUE)
{
if (r4 == TRUE || sub_800F0B8() || r5)
{
return TRUE;
}
}
}
return FALSE;
}

View File

@ -1,50 +1,30 @@
#include "global.h"
#include "main.h"
#include "crt0.h"
#include "malloc.h"
#include "link.h"
#include "link_rfu.h"
#include "librfu.h"
#include "m4a.h"
#include "bg.h"
#include "rtc.h"
#include "unknown_task.h"
#include "rng.h"
#include "overworld.h"
#include "play_time.h"
#include "dma3.h"
#include "gba/flash_internal.h"
#include "load_save.h"
#include "gpu_regs.h"
#include "agb_flash.h"
#include "sound.h"
#include "battle.h"
#include "battle_controllers.h"
#include "text.h"
#include "intro.h"
#include "main.h"
extern u16 GetGpuReg(u8);
extern void SetGpuReg(u8, u16);
extern void LinkVSync(void);
extern void sub_800E174(void);
extern void sub_800B9B8(void);
extern void InitGpuRegManager(void);
extern void sub_800E6D0(void);
extern void CheckForFlashMemory(void);
extern void InitMapMusic(void);
extern void ResetBgs(void);
extern void SetDefaultFontsPointer(void);
extern void InitHeap(void *heapStart, u32 heapSize); // malloc.h
extern void rfu_REQ_stopMode(void);
extern void rfu_waitREQComplete(void);
extern bool32 sub_8087634(void);
extern bool32 sub_80875C8(void);
extern void ClearSpriteCopyRequests(void);
extern void PlayTimeCounter_Update(void);
extern void MapMusicMain(void);
extern void EnableInterrupts(u16);
extern void sub_8033648(void);
extern u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void));
extern void remove_some_task(void);
extern struct SoundInfo gSoundInfo;
extern u32 gFlashMemoryPresent;
extern u32 IntrMain[];
extern u8 gHeap[];
extern struct SaveBlock2 gSaveblock2;
extern struct PokemonStorage gPokemonStorage;
extern u32 gBattleTypeFlags;
extern u32 *gUnknown_0203CF5C;
void Timer3Intr(void);
bool8 HandleLinkConnection(void);
void c2_copyright_1(void);
static void VBlankIntr(void);
static void HBlankIntr(void);
static void VCountIntr(void);