trade source done

This commit is contained in:
Diegoisawesome 2018-12-29 13:50:24 -06:00
parent 2fb9f490fb
commit c22a12d8d6
3 changed files with 150 additions and 411 deletions

View File

@ -1,410 +0,0 @@
.include "asm/macros.inc"
.include "constants/gba_constants.inc"
.include "constants/misc_constants.inc"
.syntax unified
.text
thumb_func_start sub_807F39C
sub_807F39C: @ 807F39C
push {r4-r6,lr}
lsls r0, 24
lsrs r0, 24
adds r6, r0, 0
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r5, r0, r1
movs r1, 0
ldrsh r0, [r5, r1]
cmp r0, 0
bne _0807F3D8
ldr r2, =gUnknown_020322A0
ldr r0, [r2]
adds r0, 0xFB
movs r1, 0x50
strb r1, [r0]
ldr r0, [r2]
adds r0, 0xFD
movs r1, 0xA0
strb r1, [r0]
movs r0, 0x4A
movs r1, 0x10
bl SetGpuReg
movs r0, 0x48
movs r1, 0x13
bl SetGpuReg
_0807F3D8:
ldr r4, =gUnknown_020322A0
ldr r0, [r4]
adds r1, r0, 0
adds r1, 0xFD
ldrb r1, [r1]
adds r0, 0xFB
ldrb r0, [r0]
lsls r0, 8
orrs r1, r0
movs r0, 0x40
bl SetGpuReg
ldr r0, [r4]
adds r1, r0, 0
adds r1, 0xFE
ldrb r1, [r1]
adds r0, 0xFC
ldrb r0, [r0]
lsls r0, 8
orrs r1, r0
movs r0, 0x44
bl SetGpuReg
ldr r0, [r4]
adds r0, 0xFB
ldrb r0, [r0]
cmp r0, 0x78
beq _0807F44C
ldrh r0, [r5]
adds r0, 0x1
strh r0, [r5]
ldr r1, [r4]
adds r1, 0xFB
ldrb r0, [r1]
adds r0, 0x5
strb r0, [r1]
ldr r1, [r4]
adds r1, 0xFD
ldrb r0, [r1]
subs r0, 0x5
strb r0, [r1]
ldr r0, [r4]
adds r0, 0xFB
ldrb r0, [r0]
cmp r0, 0x73
bls _0807F45C
ldr r2, =0x0000ffff
movs r0, 0x8
movs r1, 0
bl BlendPalettes
b _0807F45C
.pool
_0807F44C:
movs r1, 0x80
lsls r1, 6
movs r0, 0
bl ClearGpuRegBits
adds r0, r6, 0
bl DestroyTask
_0807F45C:
pop {r4-r6}
pop {r0}
bx r0
thumb_func_end sub_807F39C
thumb_func_start sub_807F464
sub_807F464: @ 807F464
push {r4,r5,lr}
sub sp, 0x4
ldr r1, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r1, r2
ldrb r0, [r0]
adds r2, r1, 0
cmp r0, 0xC
bls _0807F47A
b _0807F70C
_0807F47A:
lsls r0, 2
ldr r1, =_0807F48C
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_0807F48C:
.4byte _0807F4C0
.4byte _0807F4E8
.4byte _0807F500
.4byte _0807F550
.4byte _0807F570
.4byte _0807F5AC
.4byte _0807F5D0
.4byte _0807F620
.4byte _0807F64E
.4byte _0807F66C
.4byte _0807F694
.4byte _0807F6C4
.4byte _0807F6F8
_0807F4C0:
movs r0, 0x87
lsls r0, 3
adds r1, r2, r0
movs r0, 0x1
strb r0, [r1]
ldr r4, =gStringVar4
ldr r1, =gText_CommunicationStandby5
adds r0, r4, 0
bl StringExpandPlaceholders
movs r0, 0
adds r1, r4, 0
movs r2, 0
bl sub_807F1A8
b _0807F70C
.pool
_0807F4E8:
movs r0, 0
bl sub_8077288
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r2, 0
movs r1, 0x2
b _0807F5BC
.pool
_0807F500:
bl IsLinkTaskFinished
cmp r0, 0
bne _0807F50A
b _0807F70C
_0807F50A:
ldr r0, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r2
movs r5, 0
movs r1, 0x3
strb r1, [r0]
ldr r4, =gStringVar4
ldr r1, =gText_SavingDontTurnOffPower
adds r0, r4, 0
bl StringExpandPlaceholders
movs r0, 0
adds r1, r4, 0
movs r2, 0
bl sub_807F1A8
movs r0, 0x15
bl IncrementGameStat
bl sub_8153380
ldr r0, =gUnknown_020322A0
ldr r0, [r0]
str r5, [r0, 0x64]
b _0807F70C
.pool
_0807F550:
ldr r0, =gUnknown_020322A0
ldr r1, [r0]
ldr r0, [r1, 0x64]
adds r0, 0x1
str r0, [r1, 0x64]
cmp r0, 0x5
beq _0807F560
b _0807F70C
_0807F560:
movs r0, 0x87
lsls r0, 3
adds r1, r2, r0
movs r0, 0x4
strb r0, [r1]
b _0807F70C
.pool
_0807F570:
bl sub_81533AC
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0
beq _0807F590
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r1, 0x5
strb r1, [r0]
b _0807F70C
.pool
_0807F590:
ldr r0, =gUnknown_020322A0
ldr r0, [r0]
str r1, [r0, 0x64]
ldr r0, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r2
movs r1, 0x3
strb r1, [r0]
b _0807F70C
.pool
_0807F5AC:
bl sub_81533E0
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r2, 0
movs r1, 0x6
_0807F5BC:
strb r1, [r0]
ldr r0, =gUnknown_020322A0
ldr r0, [r0]
str r2, [r0, 0x64]
b _0807F70C
.pool
_0807F5D0:
ldr r4, =gUnknown_020322A0
ldr r1, [r4]
ldr r0, [r1, 0x64]
adds r0, 0x1
str r0, [r1, 0x64]
cmp r0, 0xA
bhi _0807F5E0
b _0807F70C
_0807F5E0:
bl GetMultiplayerId
lsls r0, 24
cmp r0, 0
bne _0807F608
bl Random
ldr r4, [r4]
lsls r0, 16
lsrs r0, 16
movs r1, 0x1E
bl __umodsi3
lsls r0, 16
lsrs r0, 16
str r0, [r4, 0x64]
b _0807F60E
.pool
_0807F608:
ldr r1, [r4]
movs r0, 0
str r0, [r1, 0x64]
_0807F60E:
ldr r0, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r2
movs r1, 0x7
strb r1, [r0]
b _0807F70C
.pool
_0807F620:
ldr r0, =gUnknown_020322A0
ldr r1, [r0]
ldr r0, [r1, 0x64]
cmp r0, 0
bne _0807F648
movs r0, 0x1
bl sub_8077288
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r1, 0x8
strb r1, [r0]
b _0807F70C
.pool
_0807F648:
subs r0, 0x1
str r0, [r1, 0x64]
b _0807F70C
_0807F64E:
bl IsLinkTaskFinished
cmp r0, 0
beq _0807F70C
bl sub_8153408
ldr r0, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r2
movs r1, 0x9
strb r1, [r0]
b _0807F70C
.pool
_0807F66C:
ldr r0, =gUnknown_020322A0
ldr r1, [r0]
ldr r0, [r1, 0x64]
adds r0, 0x1
str r0, [r1, 0x64]
cmp r0, 0x3C
bls _0807F70C
movs r0, 0x87
lsls r0, 3
adds r1, r2, r0
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
movs r0, 0x2
bl sub_8077288
b _0807F70C
.pool
_0807F694:
bl IsLinkTaskFinished
cmp r0, 0
beq _0807F70C
movs r0, 0x3
bl FadeOutBGM
movs r0, 0x1
negs r0, r0
movs r1, 0
str r1, [sp]
movs r2, 0
movs r3, 0x10
bl BeginNormalPaletteFade
ldr r0, =gMain
movs r1, 0x87
lsls r1, 3
adds r0, r1
movs r1, 0xB
strb r1, [r0]
b _0807F70C
.pool
_0807F6C4:
ldr r0, =gPaletteFade
ldrb r1, [r0, 0x7]
movs r0, 0x80
ands r0, r1
cmp r0, 0
bne _0807F70C
bl IsBGMStopped
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _0807F70C
movs r0, 0x3
bl sub_8077288
ldr r0, =gMain
movs r2, 0x87
lsls r2, 3
adds r0, r2
movs r1, 0xC
strb r1, [r0]
b _0807F70C
.pool
_0807F6F8:
bl IsLinkTaskFinished
cmp r0, 0
beq _0807F70C
ldr r0, =gSoftResetDisabled
movs r1, 0
strb r1, [r0]
ldr r0, =c2_080543C4
bl SetMainCallback2
_0807F70C:
bl HasLinkErrorOccurred
lsls r0, 24
cmp r0, 0
bne _0807F71A
bl RunTasks
_0807F71A:
bl AnimateSprites
bl BuildOamBuffer
bl UpdatePaletteFade
add sp, 0x4
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_807F464
.align 2, 0 @ Don't pad with nop.

View File

@ -82,7 +82,6 @@ SECTIONS {
src/pokeball.o(.text);
src/load_save.o(.text);
src/trade.o(.text);
asm/trade.o(.text);
src/berry_blender.o(.text);
src/play_time.o(.text);
src/new_game.o(.text);

View File

@ -5271,3 +5271,153 @@ void c3_0805465C(u8 taskId)
DestroyTask(taskId);
}
}
void sub_807F39C(u8 taskId)
{
s16 *data = gTasks[taskId].data;
if (data[0] == 0)
{
gUnknown_020322A0->unk_FB = 80;
gUnknown_020322A0->unk_FD = 160;
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_OBJ);
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG0 |
WININ_WIN0_BG1 |
WININ_WIN0_OBJ);
}
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE2(gUnknown_020322A0->unk_FB, gUnknown_020322A0->unk_FD));
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE2(gUnknown_020322A0->unk_FC, gUnknown_020322A0->unk_FE));
if (gUnknown_020322A0->unk_FB != 120)
{
data[0]++;
gUnknown_020322A0->unk_FB += 5;
gUnknown_020322A0->unk_FD -= 5;
if (gUnknown_020322A0->unk_FB >= 116)
BlendPalettes(0x8, 0, RGB_WHITEALPHA);
}
else
{
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON);
DestroyTask(taskId);
}
}
void sub_807F464(void)
{
switch (gMain.state)
{
case 0:
gMain.state = 1;
StringExpandPlaceholders(gStringVar4, gText_CommunicationStandby5);
sub_807F1A8(0, gStringVar4, 0);
break;
case 1:
sub_8077288(0);
gMain.state = 2;
gUnknown_020322A0->unk_64 = 0;
break;
case 2:
if (IsLinkTaskFinished())
{
gMain.state = 3;
StringExpandPlaceholders(gStringVar4, gText_SavingDontTurnOffPower);
sub_807F1A8(0, gStringVar4, 0);
IncrementGameStat(GAME_STAT_POKEMON_TRADES);
sub_8153380();
gUnknown_020322A0->unk_64 = 0;
}
break;
case 3:
if (++gUnknown_020322A0->unk_64 == 5)
{
gMain.state = 4;
}
break;
case 4:
if (sub_81533AC())
{
gMain.state = 5;
}
else
{
gUnknown_020322A0->unk_64 = 0;
gMain.state = 3;
}
break;
case 5:
sub_81533E0();
gMain.state = 6;
gUnknown_020322A0->unk_64 = 0;
break;
case 6:
if (++gUnknown_020322A0->unk_64 > 10)
{
if (GetMultiplayerId() == 0)
{
gUnknown_020322A0->unk_64 = Random() % 30;
}
else
{
gUnknown_020322A0->unk_64 = 0;
}
gMain.state = 7;
}
break;
case 7:
if (gUnknown_020322A0->unk_64 == 0)
{
sub_8077288(1);
gMain.state = 8;
}
else
{
gUnknown_020322A0->unk_64--;
}
break;
case 8:
if (IsLinkTaskFinished())
{
sub_8153408();
gMain.state = 9;
}
break;
case 9:
if (++gUnknown_020322A0->unk_64 > 60)
{
gMain.state++;
sub_8077288(2);
}
break;
case 10:
if (IsLinkTaskFinished())
{
FadeOutBGM(3);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
gMain.state = 11;
}
break;
case 11:
if (!gPaletteFade.active && IsBGMStopped() == TRUE)
{
sub_8077288(3);
gMain.state = 12;
}
break;
case 12:
if (IsLinkTaskFinished())
{
gSoftResetDisabled = FALSE;
SetMainCallback2(c2_080543C4);
}
break;
}
if (!HasLinkErrorOccurred())
RunTasks();
AnimateSprites();
BuildOamBuffer();
UpdatePaletteFade();
}