sub_8009AA0

This commit is contained in:
PikalaxALT 2017-11-09 21:14:43 -05:00
parent 6192cb2eea
commit d94f74d261
4 changed files with 148 additions and 369 deletions

View File

@ -5,349 +5,6 @@
.text
thumb_func_start sub_8009AA0
sub_8009AA0: @ 8009AA0
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x4
movs r6, 0
_08009AAE:
ldr r0, =gUnknown_03003020
lsls r1, r6, 1
adds r3, r1, r0
movs r0, 0
strh r0, [r3]
lsls r4, r6, 4
ldr r5, =gUnknown_03003090
adds r2, r4, r5
ldrh r0, [r2]
mov r12, r1
adds r7, r6, 0x1
str r7, [sp]
cmp r0, 0
bne _08009ACC
b _08009D6E
_08009ACC:
ldrh r1, [r2]
ldr r0, =0x00005fff
cmp r1, r0
bne _08009AD6
b _08009D20
_08009AD6:
cmp r1, r0
bgt _08009B24
ldr r0, =0x00004444
cmp r1, r0
bne _08009AE2
b _08009D64
_08009AE2:
cmp r1, r0
bgt _08009B10
ldr r0, =0x00002222
cmp r1, r0
beq _08009B68
ldr r0, =0x00002ffe
cmp r1, r0
bne _08009AF4
b _08009D28
_08009AF4:
b _08009D6E
.pool
_08009B10:
ldr r0, =0x00005555
cmp r1, r0
beq _08009BB8
adds r0, 0x11
cmp r1, r0
beq _08009BB8
b _08009D6E
.pool
_08009B24:
ldr r0, =0x0000bbbb
cmp r1, r0
beq _08009BC4
cmp r1, r0
bgt _08009B4C
ldr r0, =0x00008888
cmp r1, r0
beq _08009BF0
ldr r0, =0x0000aaaa
cmp r1, r0
bne _08009B3C
b _08009D38
_08009B3C:
b _08009D6E
.pool
_08009B4C:
ldr r0, =0x0000cafe
cmp r1, r0
bne _08009B54
b _08009D64
_08009B54:
ldr r0, =0x0000cccc
cmp r1, r0
bne _08009B5C
b _08009D3E
_08009B5C:
b _08009D6E
.pool
_08009B68:
bl sub_8009638
ldr r0, =gUnknown_03003030
adds r2, r0, 0
adds r2, 0x10
ldr r1, =gUnknown_020229CC
ldm r1!, {r3-r5}
stm r2!, {r3-r5}
ldm r1!, {r3,r6,r7}
stm r2!, {r3,r6,r7}
ldr r1, [r1]
str r1, [r2]
ldr r4, =gASCIIGameFreakInc
adds r2, r0, 0
adds r1, r4, 0
ldm r1!, {r5-r7}
stm r2!, {r5-r7}
ldrh r3, [r1]
strh r3, [r2]
ldrb r1, [r1, 0x2]
strb r1, [r2, 0x2]
adds r1, r0, 0
adds r1, 0x2C
ldm r4!, {r2,r3,r5}
stm r1!, {r2,r3,r5}
ldrh r2, [r4]
strh r2, [r1]
ldrb r2, [r4, 0x2]
strb r2, [r1, 0x2]
movs r1, 0x3C
bl sub_800A2F4
b _08009D6E
.pool
_08009BB8:
ldr r1, =gUnknown_030030E8
movs r0, 0x1
strb r0, [r1]
b _08009D6E
.pool
_08009BC4:
mov r7, r12
adds r1, r7, r6
lsls r1, 2
ldr r0, =gUnknown_03000D20
adds r1, r0
movs r2, 0
strh r2, [r1]
ldr r0, =gUnknown_03003090
adds r0, 0x2
adds r0, r4, r0
ldrh r0, [r0]
strh r0, [r1, 0x2]
ldr r0, =gUnknown_03003090
adds r0, 0x4
adds r0, r4, r0
ldrh r0, [r0]
strb r0, [r1, 0x9]
b _08009D6E
.pool
_08009BF0:
mov r3, r12
adds r0, r3, r6
lsls r0, 2
ldr r5, =gUnknown_03000D20
adds r3, r0, r5
ldrh r1, [r3, 0x2]
movs r0, 0x80
lsls r0, 1
adds r7, r5, 0
mov r10, r7
cmp r1, r0
bls _08009C40
ldr r0, =0x0201c000
mov r8, r0
movs r2, 0
adds r5, r3, 0
ldr r7, =gUnknown_03003090
adds r3, r4, 0
_08009C14:
ldrh r1, [r5]
lsrs r1, 1
adds r1, r2
lsls r1, 1
add r1, r8
adds r2, 0x1
lsls r0, r2, 1
adds r0, r3
adds r0, r7
ldrh r0, [r0]
strh r0, [r1]
lsls r2, 16
lsrs r2, 16
cmp r2, 0x6
bls _08009C14
b _08009C70
.pool
_08009C40:
movs r2, 0
ldr r1, =gBlockRecvBuffer
mov r9, r1
adds r7, r3, 0
ldr r3, =gUnknown_03003090
mov r8, r3
lsls r5, r6, 8
adds r3, r4, 0
_08009C50:
ldrh r1, [r7]
lsrs r1, 1
adds r1, r2
lsls r1, 1
adds r1, r5
add r1, r9
adds r2, 0x1
lsls r0, r2, 1
adds r0, r3
add r0, r8
ldrh r0, [r0]
strh r0, [r1]
lsls r2, 16
lsrs r2, 16
cmp r2, 0x6
bls _08009C50
_08009C70:
mov r4, r12
adds r1, r4, r6
lsls r1, 2
add r1, r10
ldrh r0, [r1]
adds r0, 0xE
movs r3, 0
strh r0, [r1]
lsls r0, 16
lsrs r0, 16
ldrh r1, [r1, 0x2]
cmp r0, r1
bcc _08009D6E
ldr r0, =gUnknown_03003078
adds r0, r6, r0
ldrb r0, [r0]
cmp r0, 0x1
bne _08009D16
lsls r1, r6, 8
ldr r0, =gBlockRecvBuffer
adds r1, r0
mov r8, r1
lsls r0, r6, 3
subs r0, r6
lsls r0, 2
ldr r1, =gLinkPlayers
adds r2, r0, r1
adds r1, r2, 0
mov r0, r8
adds r0, 0x10
ldm r0!, {r4,r5,r7}
stm r1!, {r4,r5,r7}
ldm r0!, {r4,r5,r7}
stm r1!, {r4,r5,r7}
ldr r0, [r0]
str r0, [r1]
ldrb r0, [r2]
subs r0, 0x1
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1
bhi _08009CCA
strb r3, [r2, 0x12]
strb r3, [r2, 0x11]
strb r3, [r2, 0x10]
_08009CCA:
adds r0, r2, 0
bl sub_800B524
ldr r5, =gASCIIGameFreakInc
mov r0, r8
adds r1, r5, 0
bl strcmp
cmp r0, 0
bne _08009CEC
mov r0, r8
adds r0, 0x2C
adds r1, r5, 0
bl strcmp
cmp r0, 0
beq _08009D0C
_08009CEC:
ldr r0, =c2_800ACD4
bl SetMainCallback2
b _08009D6E
.pool
_08009D0C:
lsls r0, r6, 24
lsrs r0, 24
bl sub_8009A58
b _08009D6E
_08009D16:
lsls r0, r6, 24
lsrs r0, 24
bl sub_800A588
b _08009D6E
_08009D20:
ldr r0, =gUnknown_030030F0
b _08009D2A
.pool
_08009D28:
ldr r0, =gUnknown_030030EC
_08009D2A:
adds r0, r6, r0
movs r1, 0x1
strb r1, [r0]
b _08009D6E
.pool
_08009D38:
bl sub_800A418
b _08009D6E
_08009D3E:
ldr r3, =gUnknown_082ED1A8
ldr r0, =gUnknown_03003090
adds r0, 0x2
adds r0, r4, r0
ldrh r2, [r0]
lsls r2, 3
adds r0, r2, r3
ldr r1, [r0]
adds r3, 0x4
adds r2, r3
ldrh r2, [r2]
movs r0, 0
bl SendBlock
b _08009D6E
.pool
_08009D64:
ldr r0, =gUnknown_03003090
adds r0, 0x2
adds r0, r4, r0
ldrh r0, [r0]
strh r0, [r3]
_08009D6E:
ldr r5, [sp]
lsls r0, r5, 16
lsrs r6, r0, 16
cmp r6, 0x3
bhi _08009D7A
b _08009AAE
_08009D7A:
add sp, 0x4
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_8009AA0
thumb_func_start sub_8009D90
sub_8009D90: @ 8009D90
push {lr}

View File

@ -7,13 +7,6 @@
.align 2
gASCIIGameFreakInc:: @ 82ED1D4
.ascii "GameFreak inc."
.align 2
gASCIITestPrint:: @ 82ED1E4
.ascii "TEST PRINT\nP0\nP1\nP2\nP3"
.align 2
gUnknown_082ED1FC:: @ 82ED1FC BgTemplate
.4byte 0x000001F8

View File

@ -26,4 +26,6 @@ void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, void *dest, s32
void LoadSpecialPokePic_2(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic);
void LoadSpecialPokePic_DontHandleDeoxys(const struct CompressedSpriteSheet *src, void *dest, s32 species, u32 personality, bool8 isFrontPic);
extern u8 gDecompressionBuffer[];
#endif // GUARD_DECOMPRESS_H

View File

@ -5,6 +5,7 @@
#include "save.h"
#include "librfu.h"
#include "rng.h"
#include "decompress.h"
#include "string_util.h"
#include "event_data.h"
#include "gpu_regs.h"
@ -42,14 +43,14 @@ struct SIOCnt {
IWRAM_DATA struct BlockTransfer gUnknown_03000D10;
IWRAM_DATA u32 link_c_unused_03000d1c;
IWRAM_DATA struct BlockTransfer gUnknown_03000D20[4];
IWRAM_DATA struct BlockTransfer gUnknown_03000D20[MAX_LINK_PLAYERS];
IWRAM_DATA u32 gUnknown_03000D50;
IWRAM_DATA u32 gUnknown_03000D54;
IWRAM_DATA u8 gUnknown_03000D58;
IWRAM_DATA u32 gUnknown_03000D5C;
IWRAM_DATA u32 gUnknown_03000D60;
IWRAM_DATA u8 gUnknown_03000D64;
ALIGNED() IWRAM_DATA u8 gUnknown_03000D68[4];
ALIGNED() IWRAM_DATA u8 gUnknown_03000D68[MAX_LINK_PLAYERS];
IWRAM_DATA u8 gUnknown_03000D6C;
IWRAM_DATA bool8 gUnknown_03000D6D;
IWRAM_DATA u16 gUnknown_03000D6E;
@ -71,15 +72,15 @@ u32 gUnknown_0300302C;
struct LinkPlayerBlock gUnknown_03003030;
bool8 gUnknown_0300306C;
u32 gUnknown_03003070;
bool8 gUnknown_03003078[4];
u8 gUnknown_0300307C[4];
bool8 gUnknown_03003078[MAX_LINK_PLAYERS];
u8 gUnknown_0300307C[MAX_LINK_PLAYERS];
u16 gUnknown_03003084;
u16 gUnknown_03003090[4][8];
u16 gUnknown_03003090[MAX_LINK_PLAYERS][8];
u32 gUnknown_030030E0;
u8 gUnknown_030030E4;
bool8 gUnknown_030030E8;
u8 gUnknown_030030EC[4];
u8 gUnknown_030030F0[4];
u8 gUnknown_030030EC[MAX_LINK_PLAYERS];
u8 gUnknown_030030F0[MAX_LINK_PLAYERS];
u16 gUnknown_030030F4;
u8 gUnknown_030030F8;
bool8 gLinkVSyncDisabled;
@ -90,7 +91,7 @@ bool8 gReceivedRemoteLinkPlayers;
struct LinkTestBGInfo gUnknown_03003130;
void (*gUnknown_03003140)(void);
bool8 gUnknown_03003144;
u16 gUnknown_03003148[4];
u16 gUnknown_03003148[MAX_LINK_PLAYERS];
u8 gUnknown_03003150;
u8 gUnknown_03003160;
@ -104,17 +105,21 @@ struct LinkPlayer gUnknown_020229CC = {};
void sub_8009638(void);
void sub_80096BC(void);
void c2_08009A8C(void);
void sub_8009AA0(u8 unused);
static void c2_08009A8C(void);
static void sub_8009AA0(u8 unused);
void sub_800A2E0(void);
void sub_800A2F4(void *heapptr, size_t src);
void sub_800A418(void);
void task00_link_test(u8 taskId);
void sub_800A588(u8 who);
u16 sub_800A648(u16 *src, u16 size);
void sub_800A6E8(u32 pos, u8 a0, u8 a1, u8 a2);
void sub_800A824(void);
void c2_800ACD4(void);
void sub_800AEB4(void);
void sub_800B330(bool8 flag);
void sub_800B4A4(void);
void sub_800B524(struct LinkPlayer *linkPlayer);
void sub_800B53C(void);
void sub_800B594(void);
u32 sub_800BEC0(void);
@ -130,10 +135,7 @@ const u16 gLinkTestDigitsPal[] = INCBIN_U16("graphics/interface/link_test_digits
const u16 gLinkTestDigitsGfx[] = INCBIN_U16("graphics/interface/link_test_digits.4bpp");
const u8 unkstring_82ed160[] = _("{HIGHLIGHT TRANSPARENT}{COLOR WHITE}");
const u16 g2BlankTilesGfx[] = INCBIN_U16("graphics/interface/blank_1x2.4bpp");
const struct {
void *data;
u16 size;
} gUnknown_082ED1A8[] = {
const struct BlockRequest gUnknown_082ED1A8[] = {
{gUnknown_020228C4, 200},
{gUnknown_020228C4, 200},
{gUnknown_020228C4, 100},
@ -146,6 +148,9 @@ const u8 gUnknown_082ED1D0[] = {
REG_OFFSET_BG2CNT,
REG_OFFSET_BG3CNT
};
const char gASCIIGameFreakInc[] = "GameFreak inc.";
const char gASCIITestPrint[] = "TEST PRINT\nP0\nP1\nP2\nP3";
// .text
@ -215,7 +220,7 @@ void sub_8009570(void)
gUnknown_020229C6 = 0x1111;
sub_8009734();
SeedRng(gMain.vblankCounter2);
for (i = 0; i < 4; i ++)
for (i = 0; i < MAX_LINK_PLAYERS; i ++)
{
gSaveBlock2Ptr->playerTrainerId[i] = Random() % 256;
}
@ -306,7 +311,7 @@ void sub_8009734(void)
sub_800E700();
}
gReceivedRemoteLinkPlayers = 0;
for (i = 0; i < 4; i ++)
for (i = 0; i < MAX_LINK_PLAYERS; i ++)
{
gUnknown_03003078[i] = 1;
gUnknown_030030F0[i] = 0;
@ -335,7 +340,7 @@ static void sub_8009818(u8 nothing, u8 is, u8 used)
sub_800A6E8(gUnknown_03000D10.pos, 2, 3, 2);
gUnknown_03000D64 = gUnknown_03000D10.pos;
}
for (i = 0; i < 4; i ++)
for (i = 0; i < MAX_LINK_PLAYERS; i ++)
{
if (gUnknown_03000D68[i] != gUnknown_03000D20[i].pos)
{
@ -346,7 +351,7 @@ static void sub_8009818(u8 nothing, u8 is, u8 used)
status = GetBlockReceivedStatus();
if (status == 0xF) // 0b1111
{
for (i = 0; i < 4; i ++)
for (i = 0; i < MAX_LINK_PLAYERS; i ++)
{
if ((status >> i) & 1)
{
@ -394,7 +399,7 @@ void sub_8009900(void)
}
}
void c2_08009A8C(void)
static void c2_08009A8C(void)
{
sub_8009900();
sub_8009818(1, 1, 0);
@ -445,3 +450,125 @@ void sub_8009A58(u8 who)
gReceivedRemoteLinkPlayers = 1;
}
}
static void sub_8009AA0(u8 unused)
{
u16 i;
for (i = 0; i < MAX_LINK_PLAYERS; i ++)
{
gUnknown_03003020[i] = 0;
if (gUnknown_03003090[i][0] == 0)
{
continue;
}
switch (gUnknown_03003090[i][0])
{
case 0x2222:
{
struct LinkPlayerBlock *block;
sub_8009638();
block = &gUnknown_03003030;
block->linkPlayer = gUnknown_020229CC;
memcpy(block->magic1, gASCIIGameFreakInc, sizeof(block->magic1) - 1);
memcpy(block->magic2, gASCIIGameFreakInc, sizeof(block->magic2) - 1);
sub_800A2F4(block, sizeof(*block));
break;
}
case 0x4444:
gUnknown_03003020[i] = gUnknown_03003090[i][1];
break;
case 0x5555:
gUnknown_030030E8 = 1;
break;
case 0x5566:
gUnknown_030030E8 = 1;
break;
case 0xBBBB:
{
struct BlockTransfer *blockRecv;
blockRecv = &gUnknown_03000D20[i];
blockRecv->pos = 0;
blockRecv->size = gUnknown_03003090[i][1];
blockRecv->multiplayerId = gUnknown_03003090[i][2];
break;
}
case 0x8888:
{
if (gUnknown_03000D20[i].size > BLOCK_BUFFER_SIZE)
{
u16 *buffer;
u16 j;
buffer = (u16 *)gDecompressionBuffer;
for (j = 0; j < CMD_LENGTH - 1; j ++)
{
buffer[(gUnknown_03000D20[i].pos / 2) + j] = gUnknown_03003090[i][j + 1];
}
}
else
{
u16 j;
for (j = 0; j < CMD_LENGTH - 1; j ++)
{
gBlockRecvBuffer[i][(gUnknown_03000D20[i].pos / 2) + j] = gUnknown_03003090[i][j + 1];
}
}
gUnknown_03000D20[i].pos += (CMD_LENGTH - 1) * 2;
if (gUnknown_03000D20[i].pos >= gUnknown_03000D20[i].size)
{
if (gUnknown_03003078[i] == TRUE)
{
struct LinkPlayerBlock *block;
struct LinkPlayer *linkPlayer;
block = (struct LinkPlayerBlock *)&gBlockRecvBuffer[i];
linkPlayer = &gLinkPlayers[i];
*linkPlayer = block->linkPlayer;
if ((linkPlayer->version & 0xFF) == VERSION_RUBY || (linkPlayer->version & 0xFF) == VERSION_SAPPHIRE)
{
linkPlayer->name[10] = 0;
linkPlayer->name[9] = 0;
linkPlayer->name[8] = 0;
}
sub_800B524(linkPlayer);
if (strcmp(block->magic1, gASCIIGameFreakInc) != 0
|| strcmp(block->magic2, gASCIIGameFreakInc) != 0)
{
SetMainCallback2(c2_800ACD4);
}
else
{
sub_8009A58(i);
}
}
else
{
sub_800A588(i);
}
}
}
break;
case 0x5FFF:
gUnknown_030030F0[i] = 1;
break;
case 0x2FFE:
gUnknown_030030EC[i] = 1;
break;
case 0xAAAA:
sub_800A418();
break;
case 0xCCCC:
SendBlock(0, gUnknown_082ED1A8[gUnknown_03003090[i][1]].address, gUnknown_082ED1A8[gUnknown_03003090[i][1]].size);
break;
case 0xCAFE:
gUnknown_03003020[i] = gUnknown_03003090[i][1];
break;
}
}
}