more work on berry blender

This commit is contained in:
DizzyEggg 2017-11-18 21:38:57 +01:00
parent 8fd3081306
commit 185402fe21
5 changed files with 764 additions and 1899 deletions

File diff suppressed because it is too large Load Diff

View File

@ -339,7 +339,7 @@ sub_80096BC: @ 80096BC
sub_80096D0: @ 80096D0
push {lr}
ldr r3, =gUnknown_020229C4
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
ldr r2, =0x0000efff
adds r0, r1, 0
adds r0, 0xE
@ -685,7 +685,7 @@ sub_80099E0: @ 80099E0
_080099F4:
movs r1, 0
ldr r5, =gUnknown_03003084
ldr r3, =gUnknown_03003110
ldr r3, =gSendCmd
movs r2, 0
_080099FC:
lsls r0, r1, 1
@ -781,7 +781,7 @@ _08009AAE:
movs r0, 0
strh r0, [r3]
lsls r4, r6, 4
ldr r5, =gUnknown_03003090
ldr r5, =gRecvCmds
adds r2, r4, r5
ldrh r0, [r2]
mov r12, r1
@ -901,12 +901,12 @@ _08009BC4:
adds r1, r0
movs r2, 0
strh r2, [r1]
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x2
adds r0, r4, r0
ldrh r0, [r0]
strh r0, [r1, 0x2]
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x4
adds r0, r4, r0
ldrh r0, [r0]
@ -930,7 +930,7 @@ _08009BF0:
mov r8, r0
movs r2, 0
adds r5, r3, 0
ldr r7, =gUnknown_03003090
ldr r7, =gRecvCmds
adds r3, r4, 0
_08009C14:
ldrh r1, [r5]
@ -955,7 +955,7 @@ _08009C40:
ldr r1, =gBlockRecvBuffer
mov r9, r1
adds r7, r3, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
mov r8, r3
lsls r5, r6, 8
adds r3, r4, 0
@ -1069,7 +1069,7 @@ _08009D38:
b _08009D6E
_08009D3E:
ldr r3, =gUnknown_082ED1A8
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x2
adds r0, r4, r0
ldrh r2, [r0]
@ -1084,7 +1084,7 @@ _08009D3E:
b _08009D6E
.pool
_08009D64:
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x2
adds r0, r4, r0
ldrh r0, [r0]
@ -1183,26 +1183,26 @@ _08009E2C:
b _08009F06
.pool
_08009E38:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
ldr r1, =gLinkType
ldrh r1, [r1]
b _08009F04
.pool
_08009E4C:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
ldr r1, =gMain
ldrh r1, [r1, 0x2C]
b _08009F04
.pool
_08009E60:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
movs r1, 0
b _08009F02
.pool
_08009E6C:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
movs r1, 0
adds r3, r0, 0
@ -1219,7 +1219,7 @@ _08009E76:
b _08009F06
.pool
_08009E8C:
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
strh r2, [r1]
ldr r2, =gUnknown_03000D10
ldrh r0, [r2, 0x2]
@ -1230,28 +1230,28 @@ _08009E8C:
b _08009F06
.pool
_08009EA8:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
ldr r1, =gSpecialVar_ItemId
ldrh r1, [r1]
b _08009F04
.pool
_08009EBC:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
ldr r1, =gUnknown_03003150
ldrb r1, [r1]
b _08009F04
.pool
_08009ED0:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
ldr r1, =gUnknown_030030F4
ldrh r1, [r1]
b _08009F04
.pool
_08009EE4:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
strh r2, [r0]
b _08009F06
.pool
@ -1264,7 +1264,7 @@ _08009EF0:
ldrb r0, [r0]
cmp r0, 0
bne _08009F06
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
_08009F02:
strh r2, [r0]
_08009F04:
@ -1863,7 +1863,7 @@ sub_800A388: @ 800A388
push {r4-r6,lr}
ldr r0, =gUnknown_03000D10
ldr r5, [r0, 0x4]
ldr r2, =gUnknown_03003110
ldr r2, =gSendCmd
ldr r1, =0x00008888
strh r1, [r2]
movs r3, 0
@ -3861,8 +3861,8 @@ HandleLinkConnection: @ 800B40C
cmp r0, 0
bne _0800B45C
ldr r0, =gUnknown_03003144
ldr r1, =gUnknown_03003110
ldr r2, =gUnknown_03003090
ldr r1, =gSendCmd
ldr r2, =gRecvCmds
bl sub_800B638
ldr r4, =gUnknown_030030E0
str r0, [r4]
@ -10247,13 +10247,13 @@ _0800E64A:
adds r0, r4, 0
bl sub_800D724
strh r5, [r7]
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
ldr r2, =0x01000008
adds r0, r7, 0
bl CpuSet
mov r0, r8
strh r5, [r0]
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
ldr r2, =0x01000028
bl CpuSet
mov r0, r9
@ -11278,7 +11278,7 @@ sub_800EFB0: @ 800EFB0
push {r4-r7,lr}
sub sp, 0x4
movs r2, 0
ldr r7, =gUnknown_03003090
ldr r7, =gRecvCmds
ldr r0, =gUnknown_03005000
adds r6, r7, 0
ldr r1, =0x00000c87
@ -11323,8 +11323,8 @@ _0800EFD0:
thumb_func_start sub_800F014
sub_800F014: @ 800F014
push {lr}
ldr r3, =gUnknown_03003110
ldr r2, =gUnknown_03003090
ldr r3, =gSendCmd
ldr r2, =gRecvCmds
movs r1, 0x6
_0800F01C:
ldrh r0, [r3]
@ -11334,7 +11334,7 @@ _0800F01C:
subs r1, 0x1
cmp r1, 0
bge _0800F01C
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
movs r2, 0
adds r0, r1, 0
adds r0, 0xC
@ -11413,7 +11413,7 @@ _0800F0C4:
.pool
_0800F0CC:
movs r3, 0
ldr r4, =gUnknown_03003090
ldr r4, =gRecvCmds
_0800F0D0:
movs r2, 0
lsls r0, r3, 4
@ -11681,7 +11681,7 @@ _0800F2E0:
str r2, [sp, 0x4]
adds r5, 0x1
str r5, [sp]
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
mov r9, r1
adds r5, r3, 0
adds r7, r4, 0
@ -11908,7 +11908,7 @@ sub_800F4F0: @ 800F4F0
mov r1, sp
bl sub_800D934
movs r1, 0
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
mov r12, r0
_0800F506:
movs r4, 0
@ -12012,7 +12012,7 @@ _0800F5C0:
ldrb r1, [r2]
strb r0, [r2]
bl sub_8010528
ldr r5, =gUnknown_03003110
ldr r5, =gSendCmd
add r4, sp, 0x48
adds r0, r5, 0
adds r1, r4, 0
@ -12306,7 +12306,7 @@ sub_800F820: @ 800F820
cmp r0, 0
bne _0800F83C
bl sub_8082D18
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
strh r0, [r1, 0xC]
_0800F83C:
ldr r1, =gUnknown_020223C0
@ -12345,7 +12345,7 @@ sub_800F86C: @ 800F86C
_0800F87A:
mov r1, r8
lsls r0, r1, 4
ldr r2, =gUnknown_03003090
ldr r2, =gRecvCmds
adds r1, r0, r2
ldrh r7, [r1]
movs r3, 0xFF
@ -12555,7 +12555,7 @@ _0800FA0E:
adds r2, r4, 0x1
lsls r0, r2, 1
adds r0, r3
ldr r4, =gUnknown_03003090
ldr r4, =gRecvCmds
adds r0, r4
ldrh r0, [r0]
strh r0, [r1]
@ -12686,7 +12686,7 @@ _0800FB10:
adds r0, r7, r2
strb r1, [r0]
_0800FB48:
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x6
adds r0, r5, r0
ldrh r0, [r0]
@ -12699,7 +12699,7 @@ _0800FB78:
movs r0, 0xEE
lsls r0, 8
bl sub_800FD14
ldr r1, =gUnknown_03003110
ldr r1, =gSendCmd
ldr r3, =gUnknown_03003092
adds r0, r5, r3
ldrh r0, [r0]
@ -12708,7 +12708,7 @@ _0800FB78:
adds r0, r5, r4
ldrh r0, [r0]
strh r0, [r1, 0x4]
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
adds r0, 0x6
adds r0, r5, r0
ldrh r0, [r0]
@ -12910,7 +12910,7 @@ sub_800FD14: @ 800FD14
push {r4,r5,lr}
lsls r0, 16
lsrs r1, r0, 16
ldr r5, =gUnknown_03003110
ldr r5, =gSendCmd
strh r1, [r5]
movs r0, 0xF0
lsls r0, 7
@ -13063,7 +13063,7 @@ _0800FE46:
sub_800FE50: @ 800FE50
push {r4,lr}
adds r4, r0, 0
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0800FE76
@ -13097,7 +13097,7 @@ sub_800FE84: @ 800FE84
ldr r0, [r5]
cmp r0, 0
bne _0800FEB8
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0800FEB8
@ -13182,7 +13182,7 @@ _0800FF32:
thumb_func_start rfufunc_80F9F44
rfufunc_80F9F44: @ 800FF4C
push {r4,r5,lr}
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0800FFA0
@ -13207,7 +13207,7 @@ rfufunc_80F9F44: @ 800FF4C
.pool
_0800FF84:
bl GetMultiplayerId
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
lsls r0, 24
lsrs r0, 20
adds r0, r1
@ -13233,7 +13233,7 @@ sub_800FFB0: @ 800FFB0
ldr r0, =gUnknown_03005000
mov r12, r0
ldr r5, [r0, 0x70]
ldr r3, =gUnknown_03003110
ldr r3, =gSendCmd
mov r2, r12
adds r2, 0x6C
ldrh r1, [r2]
@ -13302,7 +13302,7 @@ rfufunc_80FA020: @ 8010028
ldrb r0, [r5, 0xC]
cmp r0, 0
bne _080100F0
ldr r3, =gUnknown_03003110
ldr r3, =gSendCmd
adds r2, r5, 0
adds r2, 0x6E
ldrh r0, [r2]
@ -13313,7 +13313,7 @@ rfufunc_80FA020: @ 8010028
strh r0, [r3]
movs r4, 0
mov r9, r5
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
mov r12, r0
lsls r5, r6, 4
adds r7, r2, 0
@ -13539,7 +13539,7 @@ _08010220:
thumb_func_start sub_801022C
sub_801022C: @ 801022C
push {r4,lr}
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0801024E
@ -13694,7 +13694,7 @@ sub_8010358: @ 8010358
ldrb r0, [r0]
cmp r0, 0
bne _0801037A
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0801037A
@ -13723,7 +13723,7 @@ sub_8010390: @ 8010390
ldrb r0, [r0]
cmp r0, 0
bne _0801041E
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0801041E
@ -13766,7 +13766,7 @@ _080103FA:
ldrb r0, [r0]
cmp r0, 0
bne _0801041E
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _0801041E
@ -14404,7 +14404,7 @@ _080108F0:
b _080109D2
.pool
_08010904:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
bne _080109D2
@ -14676,7 +14676,7 @@ _08010B28:
.4byte _08010C0A
.4byte _08010C94
_08010B40:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
beq _08010B4A
@ -14690,7 +14690,7 @@ _08010B4A:
b _08010C4A
.pool
_08010B60:
ldr r0, =gUnknown_03003110
ldr r0, =gSendCmd
ldrh r0, [r0]
cmp r0, 0
beq _08010B6A
@ -16575,7 +16575,7 @@ sub_8011AC8: @ 8011AC8
sub sp, 0x4
movs r0, 0
str r0, [sp]
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
ldr r2, =0x05000014
mov r0, sp
bl CpuSet
@ -16968,7 +16968,7 @@ sub_8011E2C: @ 8011E2C
push {r4-r6,lr}
lsls r0, 24
lsrs r4, r0, 24
ldr r6, =gUnknown_03003110
ldr r6, =gSendCmd
ldrh r0, [r6]
cmp r0, 0
bne _08011E7A
@ -25082,7 +25082,7 @@ _08016894:
sub_801689C: @ 801689C
push {r4,r5,lr}
adds r2, r0, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
ldrh r5, [r3, 0x12]
adds r4, r5, 0
cmp r4, 0
@ -28045,7 +28045,7 @@ _08017FC6:
sub_8017FD8: @ 8017FD8
push {lr}
adds r2, r0, 0
ldr r0, =gUnknown_03003090
ldr r0, =gRecvCmds
ldrh r1, [r0, 0x2]
cmp r1, 0
beq _08017FFC
@ -50249,7 +50249,7 @@ sub_802339C: @ 802339C
mov r10, r3
_080233C0:
lsls r0, r7, 4
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
adds r2, r0, r1
ldrh r1, [r2]
movs r0, 0xFF
@ -50858,7 +50858,7 @@ sub_802385C: @ 802385C
push {r4,r5,lr}
adds r5, r0, 0
movs r4, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
ldrb r0, [r5, 0x9]
cmp r4, r0
bcs _08023880
@ -59626,7 +59626,7 @@ sub_8027DD0: @ 8027DD0
sub_8027DFC: @ 8027DFC
push {lr}
adds r2, r0, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
ldrh r0, [r3]
movs r1, 0xFF
lsls r1, 8
@ -60082,7 +60082,7 @@ sub_8028164: @ 8028164
mov r9, r0
adds r2, r7, 0
adds r2, 0x14
ldr r4, =gUnknown_03003090
ldr r4, =gRecvCmds
ldrh r0, [r4]
movs r1, 0xFF
lsls r1, 8
@ -60295,7 +60295,7 @@ sub_8028318: @ 8028318
push {r4,lr}
adds r2, r0, 0
adds r4, r1, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
ldrh r0, [r3]
movs r1, 0xFF
lsls r1, 8
@ -60347,7 +60347,7 @@ sub_8028350: @ 8028350
sub_8028374: @ 8028374
push {lr}
adds r2, r0, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
ldrh r0, [r3]
movs r1, 0xFF
lsls r1, 8
@ -71819,7 +71819,7 @@ sub_802E0D0: @ 802E0D0
push {r4,lr}
sub sp, 0xC
adds r4, r1, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
lsls r2, r0, 4
adds r0, r2, r3
ldrh r1, [r0]
@ -71946,7 +71946,7 @@ sub_802E1BC: @ 802E1BC
sub sp, 0xC
adds r5, r0, 0
adds r4, r1, 0
ldr r2, =gUnknown_03003090
ldr r2, =gRecvCmds
ldrh r0, [r2]
movs r1, 0xFF
lsls r1, 8
@ -72036,7 +72036,7 @@ sub_802E264: @ 802E264
adds r4, r0, 0
adds r5, r2, 0
adds r6, r3, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
lsls r2, r1, 4
adds r0, r2, r3
ldrh r1, [r0]
@ -72091,7 +72091,7 @@ sub_802E2D0: @ 802E2D0
push {r4,lr}
sub sp, 0xC
adds r4, r0, 0
ldr r3, =gUnknown_03003090
ldr r3, =gRecvCmds
lsls r2, r1, 4
adds r0, r2, r3
ldrh r1, [r0]
@ -73085,7 +73085,7 @@ sub_802EAB0: @ 802EAB0
ldrb r0, [r0]
cmp r0, 0
beq _0802EB14
ldr r1, =gUnknown_03003090
ldr r1, =gRecvCmds
ldrh r0, [r1, 0x2]
ldr r5, =0x00007fff
cmp r0, r5

View File

@ -2,6 +2,7 @@
#define GUARD_LINK_H
#define MAX_LINK_PLAYERS 4
#define MAX_RFU_PLAYERS 5
#define CMD_LENGTH 8
#define QUEUE_CAPACITY 50
#define BLOCK_BUFFER_SIZE 0x100
@ -131,7 +132,7 @@ struct BlockRequest
extern const struct BlockRequest sBlockRequestLookupTable[5];
extern struct Link gLink;
extern u16 gRecvCmds[CMD_LENGTH][MAX_LINK_PLAYERS];
extern u16 gRecvCmds[MAX_RFU_PLAYERS][CMD_LENGTH];
extern u8 gBlockSendBuffer[BLOCK_BUFFER_SIZE];
extern u16 gLinkType;
extern u32 gLinkStatus;

View File

@ -20,6 +20,8 @@
#include "berry.h"
#include "items.h"
#include "string_util.h"
#include "international_string_util.h"
#include "rng.h"
// Static type declarations
#define BLENDER_SCORE_BEST 0
@ -111,12 +113,10 @@ struct BerryBlenderData
u8 field_41;
u8 field_42;
u8 field_43;
u8 field_44;
u8 field_45;
u16 field_44;
u8 field_46;
u8 field_47;
u8 field_48;
u8 field_49;
u16 field_48;
u16 arrowPos;
s16 field_4C;
s16 field_4E;
@ -165,23 +165,8 @@ struct BerryBlenderData
u8 field_8B;
u8 field_8C;
u8 field_8D;
u8 field_8E;
u8 field_8F;
u8 field_90;
u8 field_91;
u8 field_92;
u8 field_93;
u8 field_94;
u8 field_95;
u8 field_96;
u8 field_97;
u8 field_98;
u8 field_99;
u8 field_9A;
u8 field_9B;
u8 field_9C;
u8 field_9D;
u16 field_8E[BLENDER_MAX_PLAYERS];
u16 field_96[BLENDER_MAX_PLAYERS];
u8 field_9E;
u8 field_9F;
@ -307,9 +292,7 @@ struct BerryBlenderData
s16 field_11C;
s16 field_11E;
u8 field_120;
u8 field_121;
u8 field_122;
u8 field_120[3];
u8 field_123;
u16 scores[BLENDER_MAX_PLAYERS][BLENDER_SCORES_NO];
u8 field_13C;
@ -388,16 +371,19 @@ extern void sub_8197DF8(u8 windowId, bool8 copyToVram);
extern void sub_809882C(u8, u16, u8);
extern void copy_textbox_border_tile_patterns_to_vram(u8, u16, u8);
extern void sub_81AABF0(void (*callback)(void));
extern void sub_800B4C0(void);
// this file's functions
void BerryBlender_SetGpuRegs(void);
void sub_8080EA4(u8 taskId);
void sub_8080FD0(u8 taskId);
void sub_80810F8(u8 taskId);
void sub_8081224(u8 taskId);
void sub_80833F8(struct Sprite *sprite);
void sub_8082F68(struct Sprite *sprite);
void sub_8083010(struct Sprite *sprite);
void sub_80830C0(struct Sprite *sprite);
void sub_8082F9C(struct Sprite *sprite);
void Blender_SetPlayerNamesLocal(u8 opponentsNum);
void sub_807FAC8(void);
void sub_8082D28(void);
@ -410,8 +396,13 @@ void sub_8081898(void);
void sub_8082CB4(struct BgAffineSrcData *bgAffineSrc);
bool8 sub_8083380(void);
void sub_808074C(void);
void sub_80807BC(void);
void Blender_PrintPlayerNames(void);
void sub_8080588(void);
void Blender_SetBankBerryData(u8 bank, u16 itemId);
void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 width, s8 x, s8 y, s32 state);
void sub_8080DF8(void);
void sub_8082E84(void);
void sub_80832BC(s16* a0, u16 a1);
extern struct BerryBlenderData *sBerryBlenderData;
@ -972,12 +963,12 @@ const s16 gUnknown_08339C78[][5] =
{250, 140, 10, -2, -1},
};
const u8 gUnknown_08339CA0[][3] =
static const u8 sOpponentBerrySets[][3] =
{
{4, 3, 2}, {0, 4, 3}, {1, 0, 4}, {2, 1, 0}, {3, 2, 1}, {0, 2, 3}, {1, 3, 4}, {2, 4, 0}, {3, 0, 1}, {4, 1, 2},
};
const u8 gUnknown_08339CBE[] = {30, 31, 32, 33, 34};
static const u8 sSpecialOpponentBerrySets[] = {30, 31, 32, 33, 34};
const u8 gUnknown_08339CC3[] = {1, 1, 2, 3, 4};
@ -1471,7 +1462,7 @@ void sub_8080018(void)
sBerryBlenderData->framesToWait = 0;
PlaySE(SE_TRACK_DOOR);
sub_808074C();
sub_80807BC();
Blender_PrintPlayerNames();
}
sub_8082CB4(&sBerryBlenderData->bgAffineSrc);
break;
@ -1520,3 +1511,642 @@ void sub_8080018(void)
RunTextPrinters();
UpdatePaletteFade();
}
void sub_8080588(void)
{
SetGpuReg(REG_OFFSET_DISPCNT, 0);
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
SetVBlankCallback(VBlankCB0_BerryBlender);
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(1, sBerryBlenderBgTemplates, ARRAY_COUNT(sBerryBlenderBgTemplates));
SetBgTilemapBuffer(1, sBerryBlenderData->tilemapBuffers[0]);
SetBgTilemapBuffer(2, sBerryBlenderData->tilemapBuffers[1]);
sub_809882C(0, 1, 0xD0);
copy_textbox_border_tile_patterns_to_vram(0, 0x14, 0xF0);
InitBerryBlenderWindows();
sBerryBlenderData->field_44 = 0;
sBerryBlenderData->field_4C = 0;
sBerryBlenderData->arrowPos = 0;
sBerryBlenderData->field_4E = 0;
sBerryBlenderData->field_11C = 0;
sBerryBlenderData->field_11E = 0;
}
u8 sub_8080624(u16 arrowPos, u8 playerId)
{
u32 var1 = (arrowPos / 256) + 24;
u8 arrID = sBerryBlenderData->field_96[playerId];
u32 var2 = gUnknown_083399E7[arrID];
if (var1 >= var2 && var1 < var2 + 48)
{
if (var1 >= var2 + 20 && var1 < var2 + 28)
return 2;
else
return 1;
}
return 0;
}
void Blender_SetOpponentsBerryData(u16 playerBerryItemId, u8 playersNum, struct BlenderBerry* playerBerry)
{
u16 opponentSetId = 0;
u16 opponentBerryId;
u16 var;
u16 i;
if (playerBerryItemId == ITEM_ENIGMA_BERRY)
{
for (i = 0; i < FLAVOUR_COUNT; i++)
{
if (playerBerry->flavours[opponentSetId] > playerBerry->flavours[i])
opponentSetId = i;
}
opponentSetId += 5;
}
else
{
opponentSetId = playerBerryItemId - FIRST_BERRY_INDEX;
if (opponentSetId >= 5)
opponentSetId = (opponentSetId % 5) + 5;
}
for (i = 0; i < playersNum - 1; i++)
{
opponentBerryId = sOpponentBerrySets[opponentSetId][i];
var = playerBerryItemId - 163;
if (!FlagGet(0x340) && gSpecialVar_0x8004 == 1)
{
opponentSetId %= 5;
opponentBerryId = sSpecialOpponentBerrySets[opponentSetId];
if (var <= 4)
opponentBerryId -= 5;
}
Blender_SetBankBerryData(i + 1, opponentBerryId + FIRST_BERRY_INDEX);
}
}
void sub_808074C(void)
{
s32 i, j;
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
sBerryBlenderData->field_96[i] = 0xFF;
sBerryBlenderData->field_8E[i] = gUnknown_083399D0[sBerryBlenderData->playersNo - 2][i];
}
for (j = 0; j < BLENDER_MAX_PLAYERS; j++)
{
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
if (sBerryBlenderData->field_8E[i] == j)
sBerryBlenderData->field_96[j] = i;
}
}
}
void Blender_PrintPlayerNames(void)
{
s32 i, width;
u32 multiplayerId = 0;
u8 text[20];
if (gReceivedRemoteLinkPlayers)
multiplayerId = GetMultiplayerId();
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
if (sBerryBlenderData->field_8E[i] != 0xFF)
{
sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]] = sBerryBlenderData->syncArrowSprite2Ids[i];
StartSpriteAnim(&gSprites[sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]]], i);
text[0] = EOS;
StringCopy(text, gLinkPlayers[sBerryBlenderData->field_8E[i]].name);
width = GetStringCenterAlignXOffset(1, text, 0x38);
if (multiplayerId == sBerryBlenderData->field_8E[i])
Blender_AddTextPrinter(i, text, width, 1, 0, 2);
else
Blender_AddTextPrinter(i, text, width, 1, 0, 1);
PutWindowTilemap(i);
CopyWindowToVram(i, 3);
}
}
}
void sub_80808D4(void)
{
s32 i, j;
switch (sBerryBlenderData->mainState)
{
case 0:
sub_800B4C0();
sub_8080588();
Blender_SetBankBerryData(0, gSpecialVar_ItemId);
Blender_CopyBerryData(&sBerryBlenderData->blendedBerries[0], gSpecialVar_ItemId);
Blender_SetOpponentsBerryData(gSpecialVar_ItemId, sBerryBlenderData->playersNo, &sBerryBlenderData->blendedBerries[0]);
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
sBerryBlenderData->field_64[i] = 0;
for (j = 0; j < 3; j++)
{
sBerryBlenderData->scores[i][j] = 0;
}
}
sBerryBlenderData->field_70 = 0;
sBerryBlenderData->loadGfxState = 0;
gLinkType = 0x4422;
sBerryBlenderData->mainState++;
break;
case 1:
if (LoadBerryBlenderGfx())
{
sBerryBlenderData->mainState++;
sub_8082D28();
}
break;
case 2:
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
sBerryBlenderData->syncArrowSprite2Ids[i] = CreateSprite(&sBlenderSyncArrow_SpriteTemplate, sBlenderSyncArrowsPos[i][0], sBlenderSyncArrowsPos[i][1], 1);
StartSpriteAnim(&gSprites[sBerryBlenderData->syncArrowSprite2Ids[i]], i + 8);
}
sBerryBlenderData->mainState++;
break;
case 3:
BeginNormalPaletteFade(-1, 0, 0x10, 0, 0);
sBerryBlenderData->mainState++;
sBerryBlenderData->framesToWait = 0;
break;
case 4:
if (++sBerryBlenderData->framesToWait == 2)
sub_807F9D0();
if (!gPaletteFade.active)
sBerryBlenderData->mainState = 8;
break;
case 8:
sBerryBlenderData->mainState = 11;
sBerryBlenderData->field_114 = 0;
break;
case 11:
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
u32 var = gUnknown_083399D0[sBerryBlenderData->playersNo - 2][i];
if (sBerryBlenderData->field_114 == var)
{
sub_807FD90(sBerryBlenderData->chosenItemId[sBerryBlenderData->field_114], i);
break;
}
}
sBerryBlenderData->framesToWait = 0;
sBerryBlenderData->mainState++;
sBerryBlenderData->field_114++;
break;
case 12:
if (++sBerryBlenderData->framesToWait > 60)
{
if (sBerryBlenderData->field_114 >= sBerryBlenderData->playersNo)
{
sBerryBlenderData->arrowPos = gUnknown_083399DC[gUnknown_083399E4[sBerryBlenderData->playersNo - 2]] - 22528;
sBerryBlenderData->mainState++;
}
else
{
sBerryBlenderData->mainState--;
}
sBerryBlenderData->framesToWait = 0;
}
break;
case 13:
sBerryBlenderData->mainState++;
sub_808074C();
PlaySE(SE_RU_HYUU);
sub_8082CB4(&sBerryBlenderData->bgAffineSrc);
ShowBg(2);
break;
case 14:
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
sBerryBlenderData->arrowPos += 0x200;
sBerryBlenderData->field_11A += 4;
if (sBerryBlenderData->field_11A > 255)
{
sBerryBlenderData->mainState++;
sBerryBlenderData->field_11A = 256;
sBerryBlenderData->arrowPos = gUnknown_083399DC[gUnknown_083399E4[sBerryBlenderData->playersNo - 2]];
SetGpuRegBits(REG_OFFSET_BG2CNT, 2);
sBerryBlenderData->framesToWait = 0;
PlaySE(SE_TRACK_DOOR);
Blender_PrintPlayerNames();
}
sub_8082CB4(&sBerryBlenderData->bgAffineSrc);
break;
case 15:
if (sub_8083380())
{
sBerryBlenderData->mainState++;
}
sub_8082CB4(&sBerryBlenderData->bgAffineSrc);
break;
case 16:
CreateSprite(&gUnknown_08339C2C, 120, -16, 3);
sBerryBlenderData->mainState++;
break;
case 18:
sBerryBlenderData->mainState++;
break;
case 19:
sBerryBlenderData->mainState++;
break;
case 20:
sBerryBlenderData->mainState++;
break;
case 21:
sub_8080DF8();
sBerryBlenderData->field_4C = 128;
sBerryBlenderData->gameFrameTime = 0;
sBerryBlenderData->field_123 = 0;
sBerryBlenderData->field_72 = 0;
SetMainCallback2(sub_8081898);
if (gSpecialVar_0x8004 == 1)
{
if (!FlagGet(FLAG_340))
sBerryBlenderData->field_120[0] = CreateTask(sub_8081224, 10);
else
sBerryBlenderData->field_120[0] = CreateTask(gUnknown_083399EC[0], 10);
}
if (gSpecialVar_0x8004 > 1)
{
for (i = 0; i < gSpecialVar_0x8004; i++)
sBerryBlenderData->field_120[i] = CreateTask(gUnknown_083399EC[i], 10 + i);
}
if (GetCurrentMapMusic() != BGM_CYCLING)
sBerryBlenderData->field_154 = GetCurrentMapMusic();
PlayBGM(BGM_CYCLING);
PlaySE(SE_MOTER);
Blender_ControlHitPitch();
break;
}
Blender_DummiedOutFunc(sBerryBlenderData->field_11C, sBerryBlenderData->field_11E);
RunTasks();
AnimateSprites();
BuildOamBuffer();
RunTextPrinters();
UpdatePaletteFade();
}
void sub_8080DF8(void)
{
s32 i;
for (i = 0; i < 4; i++)
{
gSendCmd[0] = 0;
gSendCmd[2] = 0;
gRecvCmds[i][0] = 0;
gRecvCmds[i][2] = 0;
}
}
void sub_8080E20(u8 taskId)
{
if(++gTasks[taskId].data[0] > gTasks[taskId].data[1])
{
gRecvCmds[gTasks[taskId].data[2]][2] = 0x2345;
DestroyTask(taskId);
}
}
void sub_8080E6C(u8 a0, u8 a1)
{
u8 taskId = CreateTask(sub_8080E20, 80);
gTasks[taskId].data[1] = a1;
gTasks[taskId].data[2] = a0;
}
void sub_8080EA4(u8 taskId)
{
if (sub_8080624(sBerryBlenderData->arrowPos, 1) == 2)
{
if (gTasks[taskId].data[0] == 0)
{
if (sBerryBlenderData->field_123 == 0)
{
u8 rand = Random() / 655;
if (sBerryBlenderData->field_4C < 500)
{
if (rand > 75)
gRecvCmds[1][2] = 0x4523;
else
gRecvCmds[1][2] = 0x5432;
gRecvCmds[1][2] = 0x5432;
}
else if (sBerryBlenderData->field_4C < 1500)
{
if (rand > 80)
{
gRecvCmds[1][2] = 0x4523;
}
else
{
u8 value = rand - 21;
if (value < 60)
gRecvCmds[1][2] = 0x5432;
else if (rand < 10)
sub_8080E6C(1, 5);
}
}
else if (rand <= 90)
{
u8 value = rand - 71;
if (value < 20)
gRecvCmds[1][2] = 0x5432;
else if (rand < 30)
sub_8080E6C(1, 5);
}
else
{
gRecvCmds[1][2] = 0x4523;
}
}
else
{
gRecvCmds[1][2] = 0x4523;
}
gTasks[taskId].data[0] = 1;
}
}
else
{
gTasks[taskId].data[0] = 0;
}
}
void sub_8080FD0(u8 taskId)
{
u32 var1 = (sBerryBlenderData->arrowPos + 0x1800) & 0xFFFF;
u32 var2 = sBerryBlenderData->field_96[2] & 0xFF;
if ((var1 >> 8) > gUnknown_083399E7[var2] + 20 && (var1 >> 8) < gUnknown_083399E7[var2] + 40)
{
if (gTasks[taskId].data[0] == 0)
{
if (sBerryBlenderData->field_123 == 0)
{
u8 rand = Random() / 655;
if (sBerryBlenderData->field_4C < 500)
{
if (rand > 66)
gRecvCmds[2][2] = 0x4523;
else
gRecvCmds[2][2] = 0x5432;
}
else
{
u8 value;
if (rand > 65)
gRecvCmds[2][2] = 0x4523;
value = rand - 41;
if (value < 25)
gRecvCmds[2][2] = 0x5432;
if (rand < 10)
sub_8080E6C(2, 5);
}
gTasks[taskId].data[0] = 1;
}
else
{
gRecvCmds[2][2] = 0x4523;
gTasks[taskId].data[0] = 1;
}
}
}
else
{
gTasks[taskId].data[0] = 0;
}
}
void sub_80810F8(u8 taskId)
{
u32 var1, var2;
var1 = (sBerryBlenderData->arrowPos + 0x1800) & 0xFFFF;
var2 = sBerryBlenderData->field_96[3] & 0xFF;
if ((var1 >> 8) > gUnknown_083399E7[var2] + 20 && (var1 >> 8) < gUnknown_083399E7[var2] + 40)
{
if (gTasks[taskId].data[0] == 0)
{
if (sBerryBlenderData->field_123 == 0)
{
u8 rand = (Random() / 655);
if (sBerryBlenderData->field_4C < 500)
{
if (rand > 88)
gRecvCmds[3][2] = 0x4523;
else
gRecvCmds[3][2] = 0x5432;
}
else
{
if (rand > 60)
{
gRecvCmds[3][2] = 0x4523;
}
else
{
s8 value = rand - 56; // makes me wonder what the original code was
u8 value2 = value;
if (value2 < 5)
gRecvCmds[3][2] = 0x5432;
}
if (rand < 5)
sub_8080E6C(3, 5);
}
gTasks[taskId].data[0] = 1;
}
else
{
gRecvCmds[3][2] = 0x4523;
gTasks[taskId].data[0] = 1;
}
}
}
else
{
gTasks[taskId].data[0] = 0;
}
}
void sub_8081224(u8 taskId)
{
if (sub_8080624(sBerryBlenderData->arrowPos, 1) == 2)
{
if (gTasks[taskId].data[0] == 0)
{
gRecvCmds[1][2] = 0x4523;
gTasks[taskId].data[0] = 1;
}
}
else
{
gTasks[taskId].data[0] = 0;
}
}
void sub_8081288(u16 a0, u8 a1)
{
u8 spriteId;
spriteId = CreateSprite(&gUnknown_08339B40,
sBlenderSyncArrowsPos[a1][0] - (10 * gUnknown_083399C0[a1][0]),
sBlenderSyncArrowsPos[a1][1] - (10 * gUnknown_083399C0[a1][1]),
1);
if (a0 == 0x4523)
{
StartSpriteAnim(&gSprites[spriteId], 2);
gSprites[spriteId].callback = sub_8082F9C;
PlaySE(SE_RU_GASHIN);
}
else if (a0 == 0x5432)
{
StartSpriteAnim(&gSprites[spriteId], 0);
PlaySE(SE_SEIKAI);
}
else if (a0 == 0x2345)
{
StartSpriteAnim(&gSprites[spriteId], 1);
PlaySE(SE_HAZURE);
}
sub_8082E84();
}
void sub_8081370(u16 a0)
{
Blender_ControlHitPitch();
switch (a0)
{
case 0x4523:
if (sBerryBlenderData->field_4C < 1500)
sBerryBlenderData->field_4C += (384 / gUnknown_08339CC3[sBerryBlenderData->playersNo]);
else
{
sBerryBlenderData->field_4C += (128 / gUnknown_08339CC3[sBerryBlenderData->playersNo]);
sub_80832BC(&sBerryBlenderData->field_11C, (sBerryBlenderData->field_4C / 100) - 10);
sub_80832BC(&sBerryBlenderData->field_11E, (sBerryBlenderData->field_4C / 100) - 10);
}
break;
case 0x5432:
if (sBerryBlenderData->field_4C < 1500)
sBerryBlenderData->field_4C += (256 / gUnknown_08339CC3[sBerryBlenderData->playersNo]);
break;
case 0x2345:
sBerryBlenderData->field_4C -= (256 / gUnknown_08339CC3[sBerryBlenderData->playersNo]);
if (sBerryBlenderData->field_4C < 128)
sBerryBlenderData->field_4C = 128;
break;
}
}
bool32 sub_80814B0(u16 arg0, u16 arg1, u16 arg2)
{
if (gReceivedRemoteLinkPlayers != 0 && gLinkVSyncDisabled)
{
if ((arg0 & 0xFF00) == arg2)
return TRUE;
}
else
{
if (arg0 == arg1)
return TRUE;
}
return FALSE;
}
/*
void sub_80814B0(void)
{
s32 i;
if (gSpecialVar_0x8004 != 0)
{
if (gSendCmd[2] != 0)
{
gRecvCmds[2][0] = gSendCmd[2];
gRecvCmds[0][0] = 0x4444;
gSendCmd[2] = 0;
}
for (i = 1; i < 4; i++)
{
if (gRecvCmds[2][i] != 0)
gRecvCmds[0][i] = 0x4444;
}
}
for (i = 0; i < gBerryBlenderData->playersNo; i++)
{
if (gRecvCmds[0][i] == 0x4444)
{
u32 var = gBerryBlenderData->field_A2[i];
if (gRecvCmds[2][i] == 0x4523)
{
sub_804FD30(0x4523);
gBerryBlenderData->field_13E += (gBerryBlenderData->field_56 / 55);
if (gBerryBlenderData->field_13E >= 1000)
gBerryBlenderData->field_13E = 1000;
sub_804FC48(0x4523, var);
gBerryBlenderData->scores[i][BLENDER_SCORE_BEST]++;
}
else if (gRecvCmds[2][i] == 0x5432)
{
sub_804FD30(0x5432);
gBerryBlenderData->field_13E += (gBerryBlenderData->field_56 / 70);
sub_804FC48(0x5432, var);
gBerryBlenderData->scores[i][BLENDER_SCORE_GOOD]++;
}
else if (gRecvCmds[2][i] == 0x2345)
{
sub_804FC48(0x2345, var);
sub_804FD30(0x2345);
if (gBerryBlenderData->field_4.win_field_F > 1000)
gBerryBlenderData->field_13E = 1000;
if (gBerryBlenderData->scores[i][BLENDER_SCORE_MISS] < 999)
gBerryBlenderData->scores[i][BLENDER_SCORE_MISS]++;
}
if (gRecvCmds[2][i] == 0x2345 || gRecvCmds[2][i] == 0x4523 || gRecvCmds[2][i] == 0x5432)
{
if (gBerryBlenderData->field_56 > 1500)
m4aMPlayTempoControl(&gMPlay_BGM, ((gBerryBlenderData->field_56 - 750) / 20) + 256);
else
m4aMPlayTempoControl(&gMPlay_BGM, 256);
}
}
}
if (gSpecialVar_0x8004 != 0)
{
for (i = 0; i < gBerryBlenderData->playersNo; i++)
{
gRecvCmds[0][i] = 0;
gRecvCmds[2][i] = 0;
}
}
}*/

View File

@ -75,7 +75,7 @@ gUnknown_0300307C: @ 300307C
gUnknown_03003084: @ 3003084
.space 0xC
gUnknown_03003090: @ 3003090
gRecvCmds: @ 3003090
.space 0x2
gUnknown_03003092: @ 3003092
@ -111,7 +111,7 @@ gLinkVSyncDisabled: @ 30030FC
gUnknown_03003100: @ 3003100
.space 0x10
gUnknown_03003110: @ 3003110
gSendCmd: @ 3003110
.space 0x10
gUnknown_03003120: @ 3003120