mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
through CB2_LinkError
This commit is contained in:
parent
e6b38426b7
commit
344a71d347
179
asm/link.s
179
asm/link.s
@ -5,169 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_800AEB4
|
||||
sub_800AEB4: @ 800AEB4
|
||||
push {lr}
|
||||
ldr r0, =gLinkOpen
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
beq _0800AEF4
|
||||
ldr r0, =gLinkStatus
|
||||
ldr r2, [r0]
|
||||
movs r0, 0xFE
|
||||
lsls r0, 11
|
||||
ands r0, r2
|
||||
cmp r0, 0
|
||||
beq _0800AEF4
|
||||
ldr r0, =gSuppressLinkErrorMessage
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _0800AEEA
|
||||
ldr r1, =gUnknown_02022B00
|
||||
str r2, [r1]
|
||||
ldr r0, =gUnknown_03004130
|
||||
ldrb r0, [r0]
|
||||
strb r0, [r1, 0x4]
|
||||
ldr r0, =gUnknown_03003160
|
||||
ldrb r0, [r0]
|
||||
strb r0, [r1, 0x5]
|
||||
ldr r0, =CB2_LinkError
|
||||
bl SetMainCallback2
|
||||
_0800AEEA:
|
||||
ldr r1, =gLinkErrorOccurred
|
||||
movs r0, 0x1
|
||||
strb r0, [r1]
|
||||
bl CloseLink
|
||||
_0800AEF4:
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_800AEB4
|
||||
|
||||
thumb_func_start sub_800AF18
|
||||
sub_800AF18: @ 800AF18
|
||||
push {r4,lr}
|
||||
ldr r4, =gUnknown_02022B00
|
||||
str r0, [r4]
|
||||
strb r1, [r4, 0x5]
|
||||
strb r2, [r4, 0x4]
|
||||
strb r3, [r4, 0x6]
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_800AF18
|
||||
|
||||
thumb_func_start CB2_LinkError
|
||||
CB2_LinkError: @ 800AF30
|
||||
push {r4,lr}
|
||||
movs r0, 0
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
ldr r0, =gMPlay_SE1
|
||||
bl m4aMPlayStop
|
||||
ldr r0, =gMPlay_SE2
|
||||
bl m4aMPlayStop
|
||||
ldr r0, =gMPlay_SE3
|
||||
bl m4aMPlayStop
|
||||
ldr r0, =0x02000000
|
||||
movs r1, 0xE0
|
||||
lsls r1, 9
|
||||
bl InitHeap
|
||||
bl ResetSpriteData
|
||||
bl FreeAllSpritePalettes
|
||||
bl ResetPaletteFadeControl
|
||||
movs r0, 0
|
||||
movs r1, 0
|
||||
movs r2, 0x2
|
||||
bl FillPalette
|
||||
bl ResetTasks
|
||||
bl remove_some_task
|
||||
ldr r1, =gSerialIsRFU
|
||||
ldrb r0, [r1]
|
||||
cmp r0, 0
|
||||
beq _0800AF8C
|
||||
ldr r0, =gUnknown_02022B00
|
||||
ldrb r0, [r0, 0x6]
|
||||
cmp r0, 0
|
||||
bne _0800AF88
|
||||
movs r0, 0x3
|
||||
strb r0, [r1]
|
||||
_0800AF88:
|
||||
bl sub_800E604
|
||||
_0800AF8C:
|
||||
ldr r0, =sub_80096BC
|
||||
bl SetVBlankCallback
|
||||
movs r0, 0
|
||||
bl ResetBgsAndClearDma3BusyFlags
|
||||
ldr r1, =gUnknown_082ED1FC
|
||||
movs r0, 0
|
||||
movs r2, 0x2
|
||||
bl InitBgsFromTemplates
|
||||
ldr r4, =gUnknown_02022B0C
|
||||
movs r0, 0x80
|
||||
lsls r0, 4
|
||||
bl Alloc
|
||||
adds r1, r0, 0
|
||||
str r1, [r4]
|
||||
movs r0, 0x1
|
||||
bl SetBgTilemapBuffer
|
||||
ldr r0, =gUnknown_082ED204
|
||||
bl InitWindows
|
||||
lsls r0, 16
|
||||
cmp r0, 0
|
||||
beq _0800B03C
|
||||
bl DeactivateAllTextPrinters
|
||||
bl reset_temp_tile_data_buffers
|
||||
movs r0, 0x50
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r0, 0x52
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r0, 0x10
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r0, 0x12
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r0, 0x14
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r0, 0x16
|
||||
movs r1, 0
|
||||
bl SetGpuReg
|
||||
movs r1, 0xE0
|
||||
lsls r1, 8
|
||||
movs r0, 0
|
||||
bl ClearGpuRegBits
|
||||
ldr r0, =gUnknown_0860F074
|
||||
movs r1, 0xF0
|
||||
movs r2, 0x20
|
||||
bl LoadPalette
|
||||
ldr r1, =gSoftResetDisabled
|
||||
movs r0, 0
|
||||
strb r0, [r1]
|
||||
ldr r0, =Task_DestroySelf
|
||||
movs r1, 0
|
||||
bl CreateTask
|
||||
bl StopMapMusic
|
||||
ldr r1, =gMain
|
||||
movs r0, 0
|
||||
str r0, [r1]
|
||||
bl RunTasks
|
||||
bl AnimateSprites
|
||||
bl BuildOamBuffer
|
||||
bl UpdatePaletteFade
|
||||
ldr r0, =sub_800B1A0
|
||||
bl SetMainCallback2
|
||||
_0800B03C:
|
||||
pop {r4}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end CB2_LinkError
|
||||
|
||||
thumb_func_start sub_800B080
|
||||
sub_800B080: @ 800B080
|
||||
push {r4,r5,lr}
|
||||
@ -311,7 +148,7 @@ _0800B1D2:
|
||||
beq _0800B214
|
||||
b _0800B260
|
||||
_0800B1D8:
|
||||
ldr r0, =gUnknown_02022B00
|
||||
ldr r0, =sLinkErrorBuffer
|
||||
ldrb r0, [r0, 0x6]
|
||||
cmp r0, 0
|
||||
beq _0800B1EC
|
||||
@ -324,7 +161,7 @@ _0800B1EC:
|
||||
_0800B1F2:
|
||||
movs r0, 0
|
||||
bl ShowBg
|
||||
ldr r0, =gUnknown_02022B00
|
||||
ldr r0, =sLinkErrorBuffer
|
||||
ldrb r0, [r0, 0x6]
|
||||
cmp r0, 0
|
||||
beq _0800B260
|
||||
@ -388,7 +225,7 @@ _0800B260:
|
||||
bl PlaySE
|
||||
movs r0, 0
|
||||
strb r0, [r4]
|
||||
ldr r1, =gUnknown_02022B00
|
||||
ldr r1, =sLinkErrorBuffer
|
||||
movs r0, 0
|
||||
strb r0, [r1, 0x6]
|
||||
bl sub_81700F8
|
||||
@ -803,9 +640,9 @@ EnableSerial: @ 800B594
|
||||
strb r4, [r0]
|
||||
ldr r0, =gUnknown_03000D73
|
||||
strb r4, [r0]
|
||||
ldr r0, =gUnknown_03003160
|
||||
ldr r0, =gLastSendQueueCount
|
||||
strb r4, [r0]
|
||||
ldr r0, =gUnknown_03004130
|
||||
ldr r0, =gLastRecvQueueCount
|
||||
strb r4, [r0]
|
||||
add sp, 0x4
|
||||
pop {r4,r5}
|
||||
@ -1051,7 +888,7 @@ _0800B7FE:
|
||||
movs r2, 0
|
||||
ldr r4, =gUnknown_03000D6E
|
||||
mov r9, r4
|
||||
ldr r1, =gUnknown_03003160
|
||||
ldr r1, =gLastSendQueueCount
|
||||
mov r10, r1
|
||||
lsls r5, r0, 1
|
||||
movs r0, 0x18
|
||||
@ -1084,7 +921,7 @@ _0800B850:
|
||||
strb r0, [r6, 0x12]
|
||||
ldr r2, =gUnknown_03000D6E
|
||||
mov r9, r2
|
||||
ldr r4, =gUnknown_03003160
|
||||
ldr r4, =gLastSendQueueCount
|
||||
mov r10, r4
|
||||
_0800B85C:
|
||||
mov r1, r9
|
||||
@ -1374,7 +1211,7 @@ _0800BA8A:
|
||||
asrs r0, 24
|
||||
cmp r0, 0x8
|
||||
bne _0800BAAA
|
||||
ldr r0, =gUnknown_03004130
|
||||
ldr r0, =gLastRecvQueueCount
|
||||
ldr r2, =0x00000fbd
|
||||
adds r1, r3, r2
|
||||
ldrb r1, [r1]
|
||||
|
@ -29,9 +29,9 @@ gBlockRequestType
|
||||
gFiller_03003154
|
||||
gFiller_03003158
|
||||
gFiller_0300315c
|
||||
gUnknown_03003160
|
||||
gLastSendQueueCount
|
||||
gLink
|
||||
gUnknown_03004130
|
||||
gLastRecvQueueCount
|
||||
gUnknown_03004134
|
||||
gFiller_03004138
|
||||
gFiller_0300413C
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define LINK_STAT_RECEIVED_NOTHING 0x00000100
|
||||
#define LINK_STAT_RECEIVED_NOTHING_SHIFT 8
|
||||
#define LINK_STAT_ERRORS 0x0007F000
|
||||
#define LINK_STAT_ERRORS_SHIFT 12
|
||||
|
||||
#define EXTRACT_PLAYER_COUNT(status) \
|
||||
(((status) & LINK_STAT_PLAYER_COUNT) >> LINK_STAT_PLAYER_COUNT_SHIFT)
|
||||
@ -26,6 +27,8 @@
|
||||
(((status) >> LINK_STAT_CONN_ESTABLISHED_SHIFT) & 1)
|
||||
#define EXTRACT_RECEIVED_NOTHING(status) \
|
||||
(((status) >> LINK_STAT_RECEIVED_NOTHING_SHIFT) & 1)
|
||||
#define EXTRACT_LINK_ERRORS(status) \
|
||||
(((status) & LINK_STAT_ERRORS) >> LINK_STAT_ERRORS_SHIFT)
|
||||
|
||||
struct LinkStatus
|
||||
{
|
||||
@ -239,8 +242,8 @@ extern void (*gLinkCallback)(void);
|
||||
extern bool8 gShouldAdvanceLinkState;
|
||||
extern u16 gLinkTestBlockChecksums[MAX_LINK_PLAYERS];
|
||||
extern u8 gBlockRequestType;
|
||||
extern u8 gUnknown_03003160;
|
||||
extern u8 gUnknown_03004130;
|
||||
extern u8 gLastSendQueueCount;
|
||||
extern u8 gLastRecvQueueCount;
|
||||
extern u16 gUnknown_03004134;
|
||||
extern u32 gUnknown_03003074;
|
||||
extern u32 gFiller_03003154;
|
||||
|
@ -24,5 +24,6 @@ bool8 sub_8010500(void);
|
||||
bool8 Rfu_IsMaster(void);
|
||||
void task_add_05_task_del_08FA224_when_no_RfuFunc(void);
|
||||
void sub_8010434(void);
|
||||
void sub_800E604(void);
|
||||
|
||||
#endif //GUARD_LINK_RFU_H
|
||||
|
@ -17,4 +17,8 @@ void m4aMPlayFadeOutTemporarily(struct MusicPlayerInfo *mplayInfo, u16 speed);
|
||||
void m4aMPlayFadeIn(struct MusicPlayerInfo *mplayInfo, u16 speed);
|
||||
void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo);
|
||||
|
||||
extern struct MusicPlayerInfo gMPlay_SE1;
|
||||
extern struct MusicPlayerInfo gMPlay_SE2;
|
||||
extern struct MusicPlayerInfo gMPlay_SE3;
|
||||
|
||||
#endif //GUARD_M4A_H
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef GUARD_MALLOC_H
|
||||
#define GUARD_MALLOC_H
|
||||
|
||||
#define HEAP_SIZE 0x1C000
|
||||
#define malloc Alloc
|
||||
#define calloc(ct, sz) AllocZeroed((ct) * (sz))
|
||||
#define free Free
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "text.h"
|
||||
#include "task.h"
|
||||
|
||||
extern const u16 gUnknown_0860F074[];
|
||||
|
||||
void sub_81973A4(void);
|
||||
void sub_81973C4(u8, u8);
|
||||
void sub_819746C(u8 windowId, bool8 copyToVram);
|
||||
|
105
src/link.c
105
src/link.c
@ -1,6 +1,7 @@
|
||||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "m4a.h"
|
||||
#include "malloc.h"
|
||||
#include "save.h"
|
||||
#include "bg.h"
|
||||
@ -15,6 +16,11 @@
|
||||
#include "gpu_regs.h"
|
||||
#include "palette.h"
|
||||
#include "task.h"
|
||||
#include "unknown_task.h"
|
||||
#include "menu.h"
|
||||
#include "new_menu_helpers.h"
|
||||
#include "text.h"
|
||||
#include "sound.h"
|
||||
#include "trade.h"
|
||||
#include "battle.h"
|
||||
#include "link_rfu.h"
|
||||
@ -90,9 +96,9 @@ u8 gBlockRequestType;
|
||||
u32 gFiller_03003154;
|
||||
u32 gFiller_03003158;
|
||||
u32 gFiller_0300315c;
|
||||
u8 gUnknown_03003160;
|
||||
u8 gLastSendQueueCount;
|
||||
struct Link gLink;
|
||||
u8 gUnknown_03004130;
|
||||
u8 gLastRecvQueueCount;
|
||||
u16 gUnknown_03004134;
|
||||
u32 gFiller_03004138;
|
||||
u32 gFiller_0300413C;
|
||||
@ -110,8 +116,10 @@ EWRAM_DATA struct LinkPlayer gLinkPlayers[MAX_RFU_PLAYERS] = {};
|
||||
EWRAM_DATA struct LinkPlayer gSavedLinkPlayers[MAX_RFU_PLAYERS] = {};
|
||||
EWRAM_DATA struct {
|
||||
u32 status;
|
||||
u8 unk_04;
|
||||
} gUnknown_02022B00 = {};
|
||||
u8 lastRecvQueueCount;
|
||||
u8 lastSendQueueCount;
|
||||
u8 unk_06;
|
||||
} sLinkErrorBuffer = {};
|
||||
EWRAM_DATA u16 gUnknown_02022B08 = 0;
|
||||
EWRAM_DATA void *gUnknown_02022B0C = NULL;
|
||||
|
||||
@ -138,7 +146,8 @@ static void sub_800AD5C(void);
|
||||
static void sub_800AD88(void);
|
||||
static void sub_800AE30(void);
|
||||
static void sub_800AE5C(void);
|
||||
void sub_800AEB4(void);
|
||||
static void sub_800AEB4(void);
|
||||
void sub_800B1A0(void);
|
||||
u8 sub_800B2F8(void);
|
||||
void sub_800B4A4(void);
|
||||
void DisableSerial(void);
|
||||
@ -1243,8 +1252,8 @@ static void Task_PrintTestData(u8 taskId)
|
||||
LinkTest_prnthex(gLink.state, 2, 10, 2);
|
||||
LinkTest_prnthex(EXTRACT_PLAYER_COUNT(gLinkStatus), 15, 10, 2);
|
||||
LinkTest_prnthex(GetMultiplayerId(), 15, 12, 2);
|
||||
LinkTest_prnthex(gUnknown_03003160, 25, 1, 2);
|
||||
LinkTest_prnthex(gUnknown_03004130, 25, 2, 2);
|
||||
LinkTest_prnthex(gLastSendQueueCount, 25, 1, 2);
|
||||
LinkTest_prnthex(gLastRecvQueueCount, 25, 2, 2);
|
||||
LinkTest_prnthex(GetBlockReceivedStatus(), 15, 5, 2);
|
||||
LinkTest_prnthex(gLinkDebugSeed, 2, 12, 8);
|
||||
LinkTest_prnthex(gLinkDebugFlags, 2, 13, 8);
|
||||
@ -1436,7 +1445,7 @@ void sub_800AC34(void)
|
||||
|
||||
static void sub_800AC80(void)
|
||||
{
|
||||
if (gUnknown_03004130 == 0)
|
||||
if (gLastRecvQueueCount == 0)
|
||||
{
|
||||
BuildSendCmd(0x5fff);
|
||||
gLinkCallback = sub_800ACAC;
|
||||
@ -1491,7 +1500,7 @@ void sub_800AD10(void)
|
||||
|
||||
static void sub_800AD5C(void)
|
||||
{
|
||||
if (gUnknown_03004130 == 0)
|
||||
if (gLastRecvQueueCount == 0)
|
||||
{
|
||||
BuildSendCmd(0x5fff);
|
||||
gLinkCallback = sub_800AD88;
|
||||
@ -1545,7 +1554,7 @@ void sub_800ADF8(void)
|
||||
|
||||
static void sub_800AE30(void)
|
||||
{
|
||||
if (gUnknown_03004130 == 0)
|
||||
if (gLastRecvQueueCount == 0)
|
||||
{
|
||||
BuildSendCmd(0x2ffe);
|
||||
gLinkCallback = sub_800AE5C;
|
||||
@ -1574,3 +1583,79 @@ static void sub_800AE5C(void)
|
||||
gLinkCallback = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_800AEB4(void)
|
||||
{
|
||||
if (gLinkOpen && EXTRACT_LINK_ERRORS(gLinkStatus))
|
||||
{
|
||||
if (!gSuppressLinkErrorMessage)
|
||||
{
|
||||
sLinkErrorBuffer.status = gLinkStatus;
|
||||
sLinkErrorBuffer.lastRecvQueueCount = gLastRecvQueueCount;
|
||||
sLinkErrorBuffer.lastSendQueueCount = gLastSendQueueCount;
|
||||
SetMainCallback2(CB2_LinkError);
|
||||
}
|
||||
gLinkErrorOccurred = TRUE;
|
||||
CloseLink();
|
||||
}
|
||||
}
|
||||
|
||||
void sub_800AF18(u32 status, u8 lastSendQueueCount, u8 lastRecvQueueCount, u8 unk_06)
|
||||
{
|
||||
sLinkErrorBuffer.status = status;
|
||||
sLinkErrorBuffer.lastSendQueueCount = lastSendQueueCount;
|
||||
sLinkErrorBuffer.lastRecvQueueCount = lastRecvQueueCount;
|
||||
sLinkErrorBuffer.unk_06 = unk_06;
|
||||
}
|
||||
|
||||
void CB2_LinkError(void)
|
||||
{
|
||||
u8 *tilemapBuffer;
|
||||
|
||||
SetGpuReg(REG_OFFSET_DISPCNT, 0);
|
||||
m4aMPlayStop(&gMPlay_SE1);
|
||||
m4aMPlayStop(&gMPlay_SE2);
|
||||
m4aMPlayStop(&gMPlay_SE3);
|
||||
InitHeap(gHeap, HEAP_SIZE);
|
||||
ResetSpriteData();
|
||||
FreeAllSpritePalettes();
|
||||
ResetPaletteFadeControl();
|
||||
FillPalette(0, 0, 2);
|
||||
ResetTasks();
|
||||
remove_some_task();
|
||||
if (gSerialIsRFU)
|
||||
{
|
||||
if (!sLinkErrorBuffer.unk_06)
|
||||
{
|
||||
gSerialIsRFU = 3;
|
||||
}
|
||||
sub_800E604();
|
||||
}
|
||||
SetVBlankCallback(sub_80096BC);
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, gUnknown_082ED1FC, 2);
|
||||
gUnknown_02022B0C = tilemapBuffer = malloc(0x800);
|
||||
SetBgTilemapBuffer(1, tilemapBuffer);
|
||||
if (InitWindows(gUnknown_082ED204))
|
||||
{
|
||||
DeactivateAllTextPrinters();
|
||||
reset_temp_tile_data_buffers();
|
||||
SetGpuReg(REG_OFFSET_BLDCNT, 0);
|
||||
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG0VOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1HOFS, 0);
|
||||
SetGpuReg(REG_OFFSET_BG1VOFS, 0);
|
||||
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON);
|
||||
LoadPalette(gUnknown_0860F074, 0xf0, 0x20);
|
||||
gSoftResetDisabled = FALSE;
|
||||
CreateTask(Task_DestroySelf, 0);
|
||||
StopMapMusic();
|
||||
gMain.callback1 = NULL;
|
||||
RunTasks();
|
||||
AnimateSprites();
|
||||
BuildOamBuffer();
|
||||
UpdatePaletteFade();
|
||||
SetMainCallback2(sub_800B1A0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user