Start porting cable_club.c

This commit is contained in:
Diegoisawesome 2018-10-11 16:02:58 -05:00
parent 3d50d01a93
commit 04836db167
5 changed files with 142 additions and 356 deletions

View File

@ -5,361 +5,6 @@
.text
thumb_func_start sub_80B236C
sub_80B236C: @ 80B236C
push {r4-r6,lr}
lsls r0, 24
lsrs r6, r0, 24
lsls r1, 24
lsrs r5, r1, 24
ldr r4, =sub_80B2634
adds r0, r4, 0
bl FindTaskIdByFunc
lsls r0, 24
lsrs r0, 24
cmp r0, 0xFF
bne _080B23A0
adds r0, r4, 0
movs r1, 0x50
bl CreateTask
lsls r0, 24
lsrs r0, 24
ldr r2, =gTasks
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
adds r1, r2
strh r6, [r1, 0xA]
strh r5, [r1, 0xC]
_080B23A0:
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end sub_80B236C
thumb_func_start sub_80B23B0
sub_80B23B0: @ 80B23B0
push {r4,r5,lr}
sub sp, 0xC
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
ldr r0, =gStringVar1
movs r2, 0
movs r3, 0x1
bl ConvertIntToDecimalStringN
lsls r4, 24
lsrs r4, 24
adds r0, r4, 0
movs r1, 0
bl SetStandardWindowBorderStyle
ldr r5, =gStringVar4
ldr r1, =gText_XPLink
adds r0, r5, 0
bl StringExpandPlaceholders
movs r0, 0x1
adds r1, r5, 0
movs r2, 0x58
bl GetStringCenterAlignXOffset
adds r3, r0, 0
lsls r3, 24
lsrs r3, 24
movs r0, 0x1
str r0, [sp]
movs r0, 0xFF
str r0, [sp, 0x4]
movs r0, 0
str r0, [sp, 0x8]
adds r0, r4, 0
movs r1, 0x1
adds r2, r5, 0
bl AddTextPrinterParameterized
adds r0, r4, 0
movs r1, 0x3
bl CopyWindowToVram
add sp, 0xC
pop {r4,r5}
pop {r0}
bx r0
.pool
thumb_func_end sub_80B23B0
thumb_func_start sub_80B241C
sub_80B241C: @ 80B241C
push {r4,lr}
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
adds r0, r4, 0
movs r1, 0
bl sub_819746C
adds r0, r4, 0
movs r1, 0x3
bl CopyWindowToVram
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_80B241C
thumb_func_start sub_80B243C
sub_80B243C: @ 80B243C
push {r4,r5,lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r5, r1, 24
lsls r1, r0, 2
adds r1, r0
lsls r1, 3
ldr r0, =gTasks + 0x8
adds r4, r1, r0
movs r1, 0x6
ldrsh r0, [r4, r1]
cmp r5, r0
beq _080B2472
cmp r5, 0x1
bhi _080B2468
ldrh r0, [r4, 0xA]
bl sub_80B241C
b _080B2470
.pool
_080B2468:
ldrh r0, [r4, 0xA]
adds r1, r5, 0
bl sub_80B23B0
_080B2470:
strh r5, [r4, 0x6]
_080B2472:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80B243C
thumb_func_start sub_80B2478
sub_80B2478: @ 80B2478
push {r4,lr}
lsls r0, 24
lsrs r0, 24
lsls r1, 24
lsrs r1, 24
bl GetLinkPlayerDataExchangeStatusTimed
lsls r0, 24
lsrs r0, 24
subs r0, 0x1
cmp r0, 0x6
bhi _080B24F0
lsls r0, 2
ldr r1, =_080B24A0
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_080B24A0:
.4byte _080B24BC
.4byte _080B24F0
.4byte _080B24C0
.4byte _080B24C4
.4byte _080B24C8
.4byte _080B24CC
.4byte _080B24EC
_080B24BC:
movs r0, 0x1
b _080B24F2
_080B24C0:
movs r0, 0x3
b _080B24F2
_080B24C4:
movs r0, 0x7
b _080B24F2
_080B24C8:
movs r0, 0x9
b _080B24F2
_080B24CC:
ldr r4, =gStringVar1
bl GetLinkPlayerCount_2
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r4, 0
movs r2, 0
movs r3, 0x1
bl ConvertIntToDecimalStringN
movs r0, 0x4
b _080B24F2
.pool
_080B24EC:
movs r0, 0xA
b _080B24F2
_080B24F0:
movs r0, 0
_080B24F2:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80B2478
thumb_func_start sub_80B24F8
sub_80B24F8: @ 80B24F8
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
bl HasLinkErrorOccurred
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _080B250E
movs r0, 0
b _080B251E
_080B250E:
ldr r0, =gTasks
lsls r1, r4, 2
adds r1, r4
lsls r1, 3
adds r1, r0
ldr r0, =sub_80B2D2C
str r0, [r1]
movs r0, 0x1
_080B251E:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_80B24F8
thumb_func_start sub_80B252C
sub_80B252C: @ 80B252C
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x2
ands r0, r1
cmp r0, 0
beq _080B2570
bl IsLinkConnectionEstablished
lsls r0, 24
lsrs r1, r0, 24
cmp r1, 0
bne _080B2570
ldr r0, =gLinkType
strh r1, [r0]
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldr r1, =sub_80B2CEC
str r1, [r0]
movs r0, 0x1
b _080B2572
.pool
_080B2570:
movs r0, 0
_080B2572:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80B252C
thumb_func_start sub_80B2578
sub_80B2578: @ 80B2578
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
bl IsLinkConnectionEstablished
lsls r0, 24
cmp r0, 0
beq _080B258E
movs r0, 0x1
bl SetSuppressLinkErrorMessage
_080B258E:
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x2
ands r0, r1
cmp r0, 0
bne _080B25A4
movs r0, 0
b _080B25BA
.pool
_080B25A4:
ldr r1, =gLinkType
movs r0, 0
strh r0, [r1]
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldr r1, =sub_80B2CEC
str r1, [r0]
movs r0, 0x1
_080B25BA:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_80B2578
thumb_func_start sub_80B25CC
sub_80B25CC: @ 80B25CC
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
bl GetSioMultiSI
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _080B25E2
movs r0, 0
b _080B25F2
_080B25E2:
ldr r0, =gTasks
lsls r1, r4, 2
adds r1, r4
lsls r1, 3
adds r1, r0
ldr r0, =sub_80B2D2C
str r0, [r1]
movs r0, 0x1
_080B25F2:
pop {r4}
pop {r1}
bx r1
.pool
thumb_func_end sub_80B25CC
thumb_func_start sub_80B2600
sub_80B2600: @ 80B2600
push {r4,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r0, =gTasks
lsls r1, r4, 2
adds r1, r4
lsls r1, 3
adds r1, r0
ldrh r0, [r1, 0x8]
adds r0, 0x1
strh r0, [r1, 0x8]
lsls r0, 16
asrs r0, 16
cmp r0, 0xA
bne _080B262A
movs r0, 0x2
bl sub_800A4D8
adds r0, r4, 0
bl DestroyTask
_080B262A:
pop {r4}
pop {r0}
bx r0
.pool
thumb_func_end sub_80B2600
thumb_func_start sub_80B2634
sub_80B2634: @ 80B2634
push {r4,lr}

View File

@ -97,7 +97,8 @@ enum
EXCHANGE_IN_PROGRESS,
EXCHANGE_STAT_4,
EXCHANGE_STAT_5,
EXCHANGE_STAT_6
EXCHANGE_STAT_6,
EXCHANGE_STAT_7
};
enum

View File

@ -843,4 +843,6 @@ extern const u8 gText_TwoDashes[];
extern const u8 *const gReturnToXStringsTable2[];
extern const u8 gText_XPLink[];
#endif //GUARD_STRINGS_H

View File

@ -118,6 +118,7 @@ SECTIONS {
src/title_screen.o(.text);
asm/field_screen.o(.text);
src/battle_setup.o(.text);
src/cable_club.o(.text);
asm/cable_club.o(.text);
src/trainer_see.o(.text);
src/wild_encounter.o(.text);

137
src/cable_club.c Normal file
View File

@ -0,0 +1,137 @@
#include "global.h"
#include "main.h"
#include "international_string_util.h"
#include "link.h"
#include "menu.h"
#include "task.h"
#include "string_util.h"
#include "strings.h"
extern void sub_80B2634(u8 taskId);
extern void sub_80B2CEC(u8 taskId);
extern void sub_80B2D2C(u8 taskId);
void sub_80B236C(u8 arg0, u8 arg1)
{
if (FindTaskIdByFunc(sub_80B2634) == 0xFF)
{
u8 taskId1;
taskId1 = CreateTask(sub_80B2634, 80);
gTasks[taskId1].data[1] = arg0;
gTasks[taskId1].data[2] = arg1;
}
}
void sub_80B23B0(u16 windowId, u32 value)
{
u8 xPos;
ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEFT_ALIGN, 1);
SetStandardWindowBorderStyle(windowId, 0);
StringExpandPlaceholders(gStringVar4, gText_XPLink);
xPos = GetStringCenterAlignXOffset(1, gStringVar4, 88);
AddTextPrinterParameterized(windowId, 1, gStringVar4, xPos, 1, 0xFF, NULL);
CopyWindowToVram(windowId, 3);
}
void sub_80B241C(u16 windowId)
{
sub_819746C(windowId, FALSE);
CopyWindowToVram(windowId, 3);
}
void sub_80B243C(u8 taskId, u8 arg1)
{
s16 *data = gTasks[taskId].data;
if (arg1 != data[3])
{
if (arg1 <= 1)
sub_80B241C(data[5]);
else
sub_80B23B0(data[5], arg1);
data[3] = arg1;
}
}
u32 sub_80B2478(u8 lower, u8 upper)
{
int playerCount;
switch (GetLinkPlayerDataExchangeStatusTimed(lower, upper))
{
case EXCHANGE_COMPLETE:
return 1;
case EXCHANGE_IN_PROGRESS:
return 3;
case EXCHANGE_STAT_4:
return 7;
case EXCHANGE_STAT_5:
return 9;
case EXCHANGE_STAT_6:
ConvertIntToDecimalStringN(gStringVar1, GetLinkPlayerCount_2(), STR_CONV_MODE_LEFT_ALIGN, 1);
return 4;
case EXCHANGE_STAT_7:
return 10;
case EXCHANGE_TIMED_OUT:
default:
return 0;
}
}
bool32 sub_80B24F8(u8 taskId)
{
if (HasLinkErrorOccurred() == TRUE)
{
gTasks[taskId].func = sub_80B2D2C;
return TRUE;
}
return FALSE;
}
bool32 sub_80B252C(u8 taskId)
{
if ((gMain.newKeys & B_BUTTON)
&& IsLinkConnectionEstablished() == FALSE)
{
gLinkType = 0;
gTasks[taskId].func = sub_80B2CEC;
return TRUE;
}
return FALSE;
}
bool32 sub_80B2578(u8 taskId)
{
if (IsLinkConnectionEstablished())
SetSuppressLinkErrorMessage(TRUE);
if (gMain.newKeys & B_BUTTON)
{
gLinkType = 0;
gTasks[taskId].func = sub_80B2CEC;
return TRUE;
}
return FALSE;
}
bool32 sub_80B25CC(u8 taskId)
{
if (GetSioMultiSI() == 1)
{
gTasks[taskId].func = sub_80B2D2C;
return TRUE;
}
return FALSE;
}
void sub_80B2600(u8 taskId)
{
gTasks[taskId].data[0]++;
if (gTasks[taskId].data[0] == 10)
{
sub_800A4D8(2);
DestroyTask(taskId);
}
}