summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscnorton <scnorton@biociphers.org>2017-06-28 12:33:11 -0400
committerscnorton <scnorton@biociphers.org>2017-06-28 12:33:11 -0400
commit180a1aba1687423fadca8f7d19567f95b47ecb73 (patch)
tree4086c8afe6ab42d87e482d0148ea467ce17425fd
parent0197921d32ac4af5a4290fa3bdcb65a275e8067c (diff)
Finish decompilation of pokeblock.s
-rwxr-xr-xasm/pokeblock.s485
-rwxr-xr-xinclude/pokeblock.h13
-rwxr-xr-xld_script.txt1
-rwxr-xr-xsrc/pokeblock.c238
4 files changed, 216 insertions, 521 deletions
diff --git a/asm/pokeblock.s b/asm/pokeblock.s
deleted file mode 100755
index 2f0f42e51..000000000
--- a/asm/pokeblock.s
+++ /dev/null
@@ -1,485 +0,0 @@
- .include "constants/gba_constants.inc"
- .include "constants/species_constants.inc"
- .include "asm/macros.inc"
-
- .syntax unified
-
- .text
-
- thumb_func_start sub_810C854
-sub_810C854: @ 810C854
- push {r4,r5,lr}
- sub sp, 0x4
- adds r5, r0, 0
- lsls r5, 24
- lsrs r5, 24
- ldr r4, _0810C8B8 @ =gScriptItemId
- ldrb r0, [r4]
- bl SafariZoneActivatePokeblockFeeder
- ldr r0, _0810C8BC @ =gStringVar1
- ldr r3, _0810C8C0 @ =gPokeblockNames
- ldr r2, _0810C8C4 @ =gSaveBlock1
- ldrh r1, [r4]
- lsls r1, 3
- adds r1, r2
- movs r2, 0xFF
- lsls r2, 3
- adds r1, r2
- ldrb r1, [r1]
- lsls r1, 2
- adds r1, r3
- ldr r1, [r1]
- bl StringCopy
- ldr r1, _0810C8C8 @ =gScriptResult
- ldrh r0, [r4]
- strh r0, [r1]
- lsls r0, 24
- lsrs r0, 24
- bl sub_810CA6C
- movs r0, 0x1
- negs r0, r0
- movs r1, 0
- str r1, [sp]
- movs r2, 0
- movs r3, 0x10
- bl BeginNormalPaletteFade
- ldr r1, _0810C8CC @ =gTasks
- lsls r0, r5, 2
- adds r0, r5
- lsls r0, 3
- adds r0, r1
- ldr r1, _0810C8D0 @ =sub_810C2C8
- str r1, [r0]
- add sp, 0x4
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_0810C8B8: .4byte gScriptItemId
-_0810C8BC: .4byte gStringVar1
-_0810C8C0: .4byte gPokeblockNames
-_0810C8C4: .4byte gSaveBlock1
-_0810C8C8: .4byte gScriptResult
-_0810C8CC: .4byte gTasks
-_0810C8D0: .4byte sub_810C2C8
- thumb_func_end sub_810C854
-
- thumb_func_start sub_810C8D4
-sub_810C8D4: @ 810C8D4
- push {r4,r5,lr}
- adds r4, r0, 0
- movs r1, 0x2E
- ldrsh r0, [r4, r1]
- cmp r0, 0x1
- ble _0810C8E4
- movs r0, 0
- strh r0, [r4, 0x2E]
-_0810C8E4:
- movs r0, 0x2E
- ldrsh r5, [r4, r0]
- cmp r5, 0
- beq _0810C8F2
- cmp r5, 0x1
- beq _0810C918
- b _0810C944
-_0810C8F2:
- ldrb r1, [r4, 0x1]
- movs r0, 0x4
- negs r0, r0
- ands r0, r1
- movs r1, 0x1
- orrs r0, r1
- strb r0, [r4, 0x1]
- ldr r0, _0810C914 @ =gSpriteAffineAnimTable_83F7F70
- str r0, [r4, 0x10]
- adds r0, r4, 0
- bl InitSpriteAffineAnim
- movs r0, 0x1
- strh r0, [r4, 0x2E]
- strh r5, [r4, 0x30]
- b _0810C944
- .align 2, 0
-_0810C914: .4byte gSpriteAffineAnimTable_83F7F70
-_0810C918:
- ldrh r0, [r4, 0x30]
- adds r0, 0x1
- movs r2, 0
- strh r0, [r4, 0x30]
- lsls r0, 16
- asrs r0, 16
- cmp r0, 0xB
- ble _0810C944
- ldrb r1, [r4, 0x1]
- movs r0, 0x4
- negs r0, r0
- ands r0, r1
- strb r0, [r4, 0x1]
- strh r2, [r4, 0x2E]
- strh r2, [r4, 0x30]
- ldrb r0, [r4, 0x3]
- lsls r0, 26
- lsrs r0, 27
- bl FreeOamMatrix
- ldr r0, _0810C94C @ =SpriteCallbackDummy
- str r0, [r4, 0x1C]
-_0810C944:
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_0810C94C: .4byte SpriteCallbackDummy
- thumb_func_end sub_810C8D4
-
- thumb_func_start ClearPokeblock
-ClearPokeblock: @ 810C950
- lsls r0, 24
- ldr r1, _0810C988 @ =gSaveBlock1
- lsrs r0, 21
- adds r0, r1
- movs r2, 0xFF
- lsls r2, 3
- adds r1, r0, r2
- movs r2, 0
- strb r2, [r1]
- ldr r3, _0810C98C @ =0x000007f9
- adds r1, r0, r3
- strb r2, [r1]
- adds r3, 0x1
- adds r1, r0, r3
- strb r2, [r1]
- adds r3, 0x1
- adds r1, r0, r3
- strb r2, [r1]
- adds r3, 0x1
- adds r1, r0, r3
- strb r2, [r1]
- adds r3, 0x1
- adds r1, r0, r3
- strb r2, [r1]
- ldr r1, _0810C990 @ =0x000007fe
- adds r0, r1
- strb r2, [r0]
- bx lr
- .align 2, 0
-_0810C988: .4byte gSaveBlock1
-_0810C98C: .4byte 0x000007f9
-_0810C990: .4byte 0x000007fe
- thumb_func_end ClearPokeblock
-
- thumb_func_start ClearPokeblocks
-ClearPokeblocks: @ 810C994
- push {r4,lr}
- movs r4, 0
-_0810C998:
- adds r0, r4, 0
- bl ClearPokeblock
- adds r0, r4, 0x1
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0x27
- bls _0810C998
- pop {r4}
- pop {r0}
- bx r0
- thumb_func_end ClearPokeblocks
-
- thumb_func_start sub_810C9B0
-sub_810C9B0: @ 810C9B0
- push {r4-r6,lr}
- adds r6, r0, 0
- movs r1, 0x1
- bl sub_810CA9C
- lsls r0, 24
- lsrs r5, r0, 24
- movs r1, 0x1
-_0810C9C0:
- adds r0, r1, 0x1
- lsls r0, 24
- lsrs r4, r0, 24
- adds r0, r6, 0
- adds r1, r4, 0
- bl sub_810CA9C
- lsls r0, 24
- lsrs r0, 24
- cmp r5, r0
- bcs _0810C9D8
- adds r5, r0, 0
-_0810C9D8:
- adds r1, r4, 0
- cmp r1, 0x4
- bls _0810C9C0
- adds r0, r5, 0
- pop {r4-r6}
- pop {r1}
- bx r1
- thumb_func_end sub_810C9B0
-
- thumb_func_start sub_810C9E8
-sub_810C9E8: @ 810C9E8
- push {lr}
- movs r1, 0x6
- bl sub_810CA9C
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x63
- bls _0810C9FA
- movs r0, 0x63
-_0810C9FA:
- pop {r1}
- bx r1
- thumb_func_end sub_810C9E8
-
- thumb_func_start sub_810CA00
-sub_810CA00: @ 810CA00
- push {lr}
- movs r1, 0
- ldr r3, _0810CA1C @ =gSaveBlock1
- movs r2, 0xFF
- lsls r2, 3
-_0810CA0A:
- lsls r0, r1, 3
- adds r0, r3
- adds r0, r2
- ldrb r0, [r0]
- cmp r0, 0
- bne _0810CA20
- lsls r0, r1, 24
- asrs r0, 24
- b _0810CA2E
- .align 2, 0
-_0810CA1C: .4byte gSaveBlock1
-_0810CA20:
- adds r0, r1, 0x1
- lsls r0, 24
- lsrs r1, r0, 24
- cmp r1, 0x27
- bls _0810CA0A
- movs r0, 0x1
- negs r0, r0
-_0810CA2E:
- pop {r1}
- bx r1
- thumb_func_end sub_810CA00
-
- thumb_func_start sub_810CA34
-sub_810CA34: @ 810CA34
- push {r4,lr}
- adds r4, r0, 0
- bl sub_810CA00
- lsls r0, 24
- asrs r2, r0, 24
- movs r0, 0x1
- negs r0, r0
- cmp r2, r0
- beq _0810CA64
- ldr r0, _0810CA60 @ =gSaveBlock1
- lsls r2, 3
- movs r1, 0xFF
- lsls r1, 3
- adds r0, r1
- adds r2, r0
- ldr r0, [r4]
- ldr r1, [r4, 0x4]
- str r0, [r2]
- str r1, [r2, 0x4]
- movs r0, 0x1
- b _0810CA66
- .align 2, 0
-_0810CA60: .4byte gSaveBlock1
-_0810CA64:
- movs r0, 0
-_0810CA66:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_810CA34
-
- thumb_func_start sub_810CA6C
-sub_810CA6C: @ 810CA6C
- push {lr}
- lsls r0, 24
- lsrs r2, r0, 24
- ldr r1, _0810CA90 @ =gSaveBlock1
- lsls r0, r2, 3
- adds r0, r1
- movs r1, 0xFF
- lsls r1, 3
- adds r0, r1
- ldrb r0, [r0]
- cmp r0, 0
- beq _0810CA94
- adds r0, r2, 0
- bl ClearPokeblock
- movs r0, 0x1
- b _0810CA96
- .align 2, 0
-_0810CA90: .4byte gSaveBlock1
-_0810CA94:
- movs r0, 0
-_0810CA96:
- pop {r1}
- bx r1
- thumb_func_end sub_810CA6C
-
- thumb_func_start sub_810CA9C
-sub_810CA9C: @ 810CA9C
- push {lr}
- lsls r1, 24
- lsrs r1, 24
- adds r2, r1, 0
- cmp r1, 0
- bne _0810CAAC
- ldrb r0, [r0]
- b _0810CADE
-_0810CAAC:
- cmp r1, 0x1
- bne _0810CAB4
- ldrb r0, [r0, 0x1]
- b _0810CADE
-_0810CAB4:
- cmp r1, 0x2
- bne _0810CABC
- ldrb r0, [r0, 0x2]
- b _0810CADE
-_0810CABC:
- cmp r1, 0x3
- bne _0810CAC4
- ldrb r0, [r0, 0x3]
- b _0810CADE
-_0810CAC4:
- cmp r1, 0x4
- bne _0810CACC
- ldrb r0, [r0, 0x4]
- b _0810CADE
-_0810CACC:
- cmp r1, 0x5
- bne _0810CAD4
- ldrb r0, [r0, 0x5]
- b _0810CADE
-_0810CAD4:
- cmp r2, 0x6
- beq _0810CADC
- movs r0, 0
- b _0810CADE
-_0810CADC:
- ldrb r0, [r0, 0x6]
-_0810CADE:
- pop {r1}
- bx r1
- thumb_func_end sub_810CA9C
-
- thumb_func_start sub_810CAE4
-sub_810CAE4: @ 810CAE4
- push {r4-r7,lr}
- mov r7, r9
- mov r6, r8
- push {r6,r7}
- mov r8, r1
- lsls r0, 24
- lsrs r0, 24
- movs r6, 0
- movs r4, 0
- ldr r1, _0810CB40 @ =gPokeblockFlavorCompatibilityTable
- mov r9, r1
- lsls r1, r0, 2
- adds r7, r1, r0
-_0810CAFE:
- adds r0, r4, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
- mov r0, r8
- adds r1, r5, 0
- bl sub_810CA9C
- lsls r0, 16
- asrs r1, r0, 16
- cmp r1, 0
- ble _0810CB2A
- adds r0, r7, r4
- add r0, r9
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- muls r1, r0
- lsls r0, r6, 16
- asrs r0, 16
- adds r0, r1
- lsls r0, 16
- lsrs r6, r0, 16
-_0810CB2A:
- adds r4, r5, 0
- cmp r4, 0x4
- bls _0810CAFE
- lsls r0, r6, 16
- asrs r0, 16
- pop {r3,r4}
- mov r8, r3
- mov r9, r4
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0810CB40: .4byte gPokeblockFlavorCompatibilityTable
- thumb_func_end sub_810CAE4
-
- thumb_func_start sub_810CB44
-sub_810CB44: @ 810CB44
- push {r4,lr}
- adds r4, r1, 0
- movs r1, 0
- bl sub_810CA9C
- lsls r0, 24
- ldr r1, _0810CB64 @ =gPokeblockNames
- lsrs r0, 22
- adds r0, r1
- ldr r1, [r0]
- adds r0, r4, 0
- bl StringCopy
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_0810CB64: .4byte gPokeblockNames
- thumb_func_end sub_810CB44
-
- thumb_func_start sub_810CB68
-sub_810CB68: @ 810CB68
- push {r4-r7,lr}
- adds r6, r1, 0
- lsls r0, 24
- lsrs r5, r0, 24
- movs r4, 0
- ldr r7, _0810CB98 @ =gPokeblockNames
-_0810CB74:
- lsls r1, r4, 3
- ldr r0, _0810CB9C @ =gUnknown_083F7F9C
- adds r1, r0
- adds r0, r5, 0
- bl sub_810CAE4
- lsls r0, 16
- cmp r0, 0
- ble _0810CBA0
- adds r0, r4, 0x1
- lsls r0, 2
- adds r0, r7
- ldr r1, [r0]
- adds r0, r6, 0
- bl StringCopy
- movs r0, 0x1
- b _0810CBAC
- .align 2, 0
-_0810CB98: .4byte gPokeblockNames
-_0810CB9C: .4byte gUnknown_083F7F9C
-_0810CBA0:
- adds r0, r4, 0x1
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0x4
- bls _0810CB74
- movs r0, 0
-_0810CBAC:
- pop {r4-r7}
- pop {r1}
- bx r1
- thumb_func_end sub_810CB68
-
- .align 2, 0 @ Don't pad with nop.
diff --git a/include/pokeblock.h b/include/pokeblock.h
index 008734a69..fdaaf5fc2 100755
--- a/include/pokeblock.h
+++ b/include/pokeblock.h
@@ -6,6 +6,15 @@ struct YesNoCBTable {
void (*noFunc)(void);
};
+enum {
+ PBLOCK_CLR_BLACK,
+ PBLOCK_CLR_RED,
+ PBLOCK_CLR_BLUE,
+ PBLOCK_CLR_PINK,
+ PBLOCK_CLR_GREEN,
+ PBLOCK_CLR_YELLOW
+};
+
extern u8 ewram[];
extern u8 gUnknown_02039244;
extern u8 gUnknown_02039248[4];
@@ -15,7 +24,7 @@ extern const u8 *gUnknown_03000758;
void sub_810B96C(void);
void sub_810BA7C(u8);
void ClearPokeblocks(void);
-void sub_810CA6C(u8);
-s16 sub_810CAE4(u8, struct Pokeblock *);
+bool8 sub_810CA6C(u8);
+s16 sub_810CAE4(u8, const struct Pokeblock *);
#endif // GUARD_POKEBLOCK_H
diff --git a/ld_script.txt b/ld_script.txt
index 6c4894d1e..c12d7a39a 100755
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -213,7 +213,6 @@ SECTIONS {
src/wallclock.o(.text);
src/rom6.o(.text);
src/pokeblock.o(.text);
- asm/pokeblock.o(.text);
asm/fldeff_flash.o(.text);
src/post_battle_event_funcs.o(.text);
src/time_events.o(.text);
diff --git a/src/pokeblock.c b/src/pokeblock.c
index 9c6ccfc9f..fd2e2acde 100755
--- a/src/pokeblock.c
+++ b/src/pokeblock.c
@@ -23,37 +23,38 @@
#include "items.h"
#include "sound.h"
#include "songs.h"
+#include "safari_zone.h"
#include "pokeblock.h"
// rodata
-const s8 gPokeblockFlavorCompatibilityTable[][5] = {
+const s8 gPokeblockFlavorCompatibilityTable[] = {
// Cool, Beauty, Cute, Smart, Tough
- { 0, 0, 0, 0, 0}, // Hardy
- { 1, 0, 0, 0, -1}, // Lonely
- { 1, 0, -1, 0, 0}, // Brave
- { 1, -1, 0, 0, 0}, // Adamant
- { 1, 0, 0, -1, 0}, // Naughty
- { -1, 0, 0, 0, 1}, // Bold
- { 0, 0, 0, 0, 0}, // Docile
- { 0, 0, -1, 0, 1}, // Relaxed
- { 0, -1, 0, 0, 1}, // Impish
- { 0, 0, 0, -1, 1}, // Lax
- { -1, 0, 1, 0, 0}, // Timid
- { 0, 0, 1, 0, -1}, // Hasty
- { 0, 0, 0, 0, 0}, // Serious
- { 0, -1, 1, 0, 0}, // Jolly
- { 0, 0, 1, -1, 0}, // Naive
- { -1, 1, 0, 0, 0}, // Modest
- { 0, 1, 0, 0, -1}, // Mild
- { 0, 1, -1, 0, 0}, // Quiet
- { 0, 0, 0, 0, 0}, // Bashful
- { 0, 1, 0, -1, 0}, // Rash
- { -1, 0, 0, 1, 0}, // Calm
- { 0, 0, 0, 1, -1}, // Gentle
- { 0, 0, -1, 1, 0}, // Sassy
- { 0, -1, 0, 1, 0}, // Careful
- { 0, 0, 0, 0, 0} // Quirky
+ 0, 0, 0, 0, 0, // Hardy
+ 1, 0, 0, 0, -1, // Lonely
+ 1, 0, -1, 0, 0, // Brave
+ 1, -1, 0, 0, 0, // Adamant
+ 1, 0, 0, -1, 0, // Naughty
+ -1, 0, 0, 0, 1, // Bold
+ 0, 0, 0, 0, 0, // Docile
+ 0, 0, -1, 0, 1, // Relaxed
+ 0, -1, 0, 0, 1, // Impish
+ 0, 0, 0, -1, 1, // Lax
+ -1, 0, 1, 0, 0, // Timid
+ 0, 0, 1, 0, -1, // Hasty
+ 0, 0, 0, 0, 0, // Serious
+ 0, -1, 1, 0, 0, // Jolly
+ 0, 0, 1, -1, 0, // Naive
+ -1, 1, 0, 0, 0, // Modest
+ 0, 1, 0, 0, -1, // Mild
+ 0, 1, -1, 0, 0, // Quiet
+ 0, 0, 0, 0, 0, // Bashful
+ 0, 1, 0, -1, 0, // Rash
+ -1, 0, 0, 1, 0, // Calm
+ 0, 0, 0, 1, -1, // Gentle
+ 0, 0, -1, 1, 0, // Sassy
+ 0, -1, 0, 1, 0, // Careful
+ 0, 0, 0, 0, 0 // Quirky
};
void (*const gUnknown_083F7EA8[])(void) = {
@@ -153,12 +154,12 @@ const struct SpriteTemplate gSpriteTemplate_83F7F84 = {
SpriteCallbackDummy
};
-const u8 gUnknown_083F7F9C[][8] = {
- { 1, 20, 0, 0, 0, 0, 20, 0},
- { 2, 0, 20, 0, 0, 0, 20, 0},
- { 3, 0, 0, 20, 0, 0, 20, 0},
- { 4, 0, 0, 0, 20, 0, 20, 0},
- { 5, 0, 0, 0, 0, 20, 20, 0}
+const struct Pokeblock gUnknown_083F7F9C[] = {
+ { PBLOCK_CLR_RED, 20, 0, 0, 0, 0, 20},
+ { PBLOCK_CLR_BLUE, 0, 20, 0, 0, 0, 20},
+ { PBLOCK_CLR_PINK, 0, 0, 20, 0, 0, 20},
+ { PBLOCK_CLR_GREEN, 0, 0, 0, 20, 0, 20},
+ { PBLOCK_CLR_YELLOW, 0, 0, 0, 0, 20, 20}
};
// text
@@ -490,7 +491,7 @@ void sub_810BD64(u16 a0, u16 a1)
}
}
-s16 sub_810CA9C(struct Pokeblock *, u8);
+s16 sub_810CA9C(const struct Pokeblock *, u8);
u8 sub_810C9E8(struct Pokeblock *);
void sub_810BDAC(bool8 flag)
@@ -922,3 +923,174 @@ void sub_810C788(u8 taskId)
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
gTasks[taskId].func = sub_810C2C8;
}
+
+void sub_810C854(u8 taskId)
+{
+ SafariZoneActivatePokeblockFeeder(gScriptItemId);
+ StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1.pokeblocks[gScriptItemId].color]);
+ gScriptResult = gScriptItemId;
+ sub_810CA6C(gScriptItemId);
+ BeginNormalPaletteFade(-1, 0, 0, 16, 0);
+ gTasks[taskId].func = sub_810C2C8;
+}
+
+void sub_810C8D4(struct Sprite *sprite)
+{
+ if (sprite->data0 > 1)
+ {
+ sprite->data0 = 0;
+ }
+ switch (sprite->data0)
+ {
+ case 0:
+ sprite->oam.affineMode = 1;
+ sprite->affineAnims = gSpriteAffineAnimTable_83F7F70;
+ InitSpriteAffineAnim(sprite);
+ sprite->data0 = 1;
+ sprite->data1 = 0;
+ break;
+ case 1:
+ if (++sprite->data1 > 11)
+ {
+ sprite->oam.affineMode = 0;
+ sprite->data0 = 0;
+ sprite->data1 = 0;
+ FreeOamMatrix(sprite->oam.matrixNum);
+ sprite->callback = SpriteCallbackDummy;
+ }
+ break;
+ }
+}
+
+void ClearPokeblock(u8 pokeblockIdx)
+{
+ gSaveBlock1.pokeblocks[pokeblockIdx].color = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].spicy = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].dry = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].sweet = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].bitter = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].sour = 0;
+ gSaveBlock1.pokeblocks[pokeblockIdx].feel = 0;
+}
+
+void ClearPokeblocks(void)
+{
+ u8 pokeblockIdx;
+ for (pokeblockIdx=0; pokeblockIdx<ARRAY_COUNT(gSaveBlock1.pokeblocks); pokeblockIdx++)
+ {
+ ClearPokeblock(pokeblockIdx);
+ }
+}
+
+u8 sub_810C9B0(struct Pokeblock *pokeblock)
+{
+ u8 contestStat;
+ u8 maxRating;
+ u8 rating = sub_810CA9C(pokeblock, 1);
+ for (contestStat=1; contestStat<5; contestStat++)
+ {
+ maxRating = sub_810CA9C(pokeblock, contestStat + 1);
+ if (rating < maxRating)
+ {
+ rating = maxRating;
+ }
+ }
+ return rating;
+}
+
+u8 sub_810C9E8(struct Pokeblock *pokeblock)
+{
+ u8 feel = sub_810CA9C(pokeblock, 6);
+ if (feel > 99)
+ feel = 99;
+ return feel;
+}
+
+s8 sub_810CA00(void)
+{
+ u8 i;
+ for (i=0; i<ARRAY_COUNT(gSaveBlock1.pokeblocks); i++)
+ {
+ if (gSaveBlock1.pokeblocks[i].color == 0)
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+bool8 sub_810CA34(struct Pokeblock *pokeblock)
+{
+ s8 idx = sub_810CA00();
+ if (idx == -1)
+ {
+ return FALSE;
+ }
+ gSaveBlock1.pokeblocks[idx] = *pokeblock;
+ return TRUE;
+}
+
+bool8 sub_810CA6C(u8 pokeblockIdx)
+{
+ if (gSaveBlock1.pokeblocks[pokeblockIdx].color == 0)
+ {
+ return FALSE;
+ }
+ ClearPokeblock(pokeblockIdx);
+ return TRUE;
+}
+
+s16 sub_810CA9C(const struct Pokeblock *pokeblock, u8 field)
+{
+ if (field == 0)
+ return pokeblock->color;
+ if (field == 1)
+ return pokeblock->spicy;
+ if (field == 2)
+ return pokeblock->dry;
+ if (field == 3)
+ return pokeblock->sweet;
+ if (field == 4)
+ return pokeblock->bitter;
+ if (field == 5)
+ return pokeblock->sour;
+ if (field == 6)
+ return pokeblock->feel;
+ return 0;
+}
+
+s16 sub_810CAE4(u8 nature, const struct Pokeblock *pokeblock)
+{
+ u8 flavor;
+ s16 curGain;
+ s16 totalGain = 0;
+ for (flavor=0; flavor<5; flavor++)
+ {
+ curGain = sub_810CA9C(pokeblock, flavor + 1);
+ if (curGain > 0)
+ {
+ totalGain += curGain * gPokeblockFlavorCompatibilityTable[5 * nature + flavor];
+ }
+ }
+ return totalGain;
+}
+
+void sub_810CB44(struct Pokeblock *pokeblock, u8 *dest)
+{
+ u8 color = sub_810CA9C(pokeblock, 0);
+ StringCopy(dest, gPokeblockNames[color]);
+}
+
+bool8 sub_810CB68(u8 nature, u8 *dest)
+{
+ u8 flavor;
+ for (flavor=0; flavor<5; flavor++)
+ {
+ if (sub_810CAE4(nature, &gUnknown_083F7F9C[flavor]) > 0)
+ {
+ StringCopy(dest, gPokeblockNames[flavor + 1]);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}