summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm/pokedex.s277
-rw-r--r--include/global.h1
-rw-r--r--src/pokedex.c150
3 files changed, 151 insertions, 277 deletions
diff --git a/asm/pokedex.s b/asm/pokedex.s
index b1ddaa0d0..2745593e5 100644
--- a/asm/pokedex.s
+++ b/asm/pokedex.s
@@ -5,283 +5,6 @@
.text
- thumb_func_start ResetPokedex
-ResetPokedex: @ 80BB2D0
- push {r4-r6,lr}
- ldr r0, =gUnknown_02039B50
- movs r2, 0
- strh r2, [r0]
- ldr r1, =gUnknown_02039B52
- movs r0, 0x40
- strb r0, [r1]
- ldr r0, =gUnknown_030060B0
- strb r2, [r0]
- ldr r4, =gSaveBlock2Ptr
- ldr r0, [r4]
- movs r1, 0
- strb r2, [r0, 0x19]
- ldr r0, [r4]
- strb r2, [r0, 0x18]
- ldr r0, [r4]
- strb r2, [r0, 0x1A]
- ldr r0, [r4]
- strb r2, [r0, 0x1B]
- ldr r0, [r4]
- str r1, [r0, 0x1C]
- str r1, [r0, 0x20]
- str r1, [r0, 0x24]
- bl DisableNationalPokedex
- movs r1, 0
- movs r2, 0
- ldr r3, =gSaveBlock1Ptr
- ldr r6, =0x00000988
- ldr r5, =0x00003b24
-_080BB30C:
- ldr r0, [r4]
- adds r0, 0x28
- adds r0, r1
- strb r2, [r0]
- ldr r0, [r4]
- adds r0, 0x5C
- adds r0, r1
- strb r2, [r0]
- ldr r0, [r3]
- adds r0, r6
- adds r0, r1
- strb r2, [r0]
- ldr r0, [r3]
- adds r0, r5
- adds r0, r1
- strb r2, [r0]
- adds r0, r1, 0x1
- lsls r0, 16
- lsrs r1, r0, 16
- cmp r1, 0x33
- bls _080BB30C
- pop {r4-r6}
- pop {r0}
- bx r0
- .pool
- thumb_func_end ResetPokedex
-
- thumb_func_start sub_80BB358
-sub_80BB358: @ 80BB358
- ldr r1, =gUnknown_02039B50
- movs r0, 0
- strh r0, [r1]
- ldr r1, =gUnknown_02039B52
- movs r0, 0x40
- strb r0, [r1]
- bx lr
- .pool
- thumb_func_end sub_80BB358
-
- thumb_func_start sub_80BB370
-sub_80BB370: @ 80BB370
- push {lr}
- bl LoadOam
- bl ProcessSpriteCopyRequests
- bl TransferPlttBuffer
- pop {r0}
- bx r0
- thumb_func_end sub_80BB370
-
- thumb_func_start sub_80BB384
-sub_80BB384: @ 80BB384
- push {r4-r7,lr}
- adds r4, r0, 0
- movs r3, 0
- ldr r0, =0x0000ffff
- adds r7, r0, 0
- movs r1, 0x2
- negs r1, r1
- mov r12, r1
- movs r6, 0x3
- negs r6, r6
- ldr r5, =0x00000181
-_080BB39A:
- lsls r1, r3, 2
- adds r1, r4, r1
- ldrh r0, [r1]
- orrs r0, r7
- strh r0, [r1]
- ldrb r2, [r1, 0x2]
- mov r0, r12
- ands r0, r2
- ands r0, r6
- strb r0, [r1, 0x2]
- adds r0, r3, 0x1
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, r5
- bls _080BB39A
- movs r2, 0xC1
- lsls r2, 3
- adds r0, r4, r2
- movs r2, 0
- strh r2, [r0]
- ldr r0, =0x0000060a
- adds r3, r4, r0
- ldrb r1, [r3]
- movs r0, 0x2
- negs r0, r0
- ands r0, r1
- movs r1, 0x3
- negs r1, r1
- ands r0, r1
- strb r0, [r3]
- ldr r1, =0x0000060c
- adds r0, r4, r1
- strh r2, [r0]
- ldr r3, =0x0000060e
- adds r0, r4, r3
- strh r2, [r0]
- adds r1, 0x4
- adds r0, r4, r1
- strh r2, [r0]
- adds r3, 0x4
- adds r0, r4, r3
- strh r2, [r0]
- adds r1, 0x4
- adds r0, r4, r1
- strh r2, [r0]
- adds r3, 0x4
- adds r0, r4, r3
- strh r2, [r0]
- adds r1, 0x4
- adds r0, r4, r1
- strh r2, [r0]
- adds r3, 0x4
- adds r0, r4, r3
- strh r2, [r0]
- adds r1, 0x4
- adds r0, r4, r1
- strh r2, [r0]
- movs r3, 0
- ldr r0, =0x0000061e
- adds r2, r4, r0
- ldr r1, =0x0000ffff
- adds r5, r1, 0
-_080BB416:
- lsls r0, r3, 1
- adds r0, r2, r0
- ldrh r1, [r0]
- orrs r1, r5
- strh r1, [r0]
- adds r0, r3, 0x1
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, 0x3
- bls _080BB416
- movs r2, 0xC5
- lsls r2, 3
- adds r0, r4, r2
- movs r2, 0
- movs r1, 0
- strh r1, [r0]
- ldr r3, =0x0000062a
- adds r0, r4, r3
- strh r1, [r0]
- adds r3, 0x2
- adds r0, r4, r3
- strb r2, [r0]
- adds r3, 0x1
- adds r0, r4, r3
- strb r2, [r0]
- adds r3, 0x1
- adds r0, r4, r3
- strb r2, [r0]
- adds r3, 0x1
- adds r0, r4, r3
- strb r2, [r0]
- movs r2, 0xC6
- lsls r2, 3
- adds r0, r4, r2
- strh r1, [r0]
- adds r3, 0x3
- adds r0, r4, r3
- strh r1, [r0]
- adds r2, 0x4
- adds r0, r4, r2
- strh r1, [r0]
- adds r3, 0x4
- adds r0, r4, r3
- strh r1, [r0]
- adds r2, 0x4
- adds r0, r4, r2
- strh r1, [r0]
- movs r3, 0
- ldr r0, =0x0000063a
- adds r1, r4, r0
- movs r2, 0
-_080BB47C:
- lsls r0, r3, 1
- adds r0, r1, r0
- strh r2, [r0]
- adds r0, r3, 0x1
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, 0x3
- bls _080BB47C
- ldr r1, =0x0000064a
- adds r0, r4, r1
- movs r1, 0
- strb r1, [r0]
- ldr r2, =0x0000064b
- adds r0, r4, r2
- strb r1, [r0]
- ldr r0, =0x0000064c
- adds r3, r4, r0
- ldrb r2, [r3]
- movs r0, 0x2
- negs r0, r0
- ands r0, r2
- strb r0, [r3]
- ldr r2, =0x0000064d
- adds r0, r4, r2
- strb r1, [r0]
- ldr r3, =0x0000064e
- adds r0, r4, r3
- strb r1, [r0]
- adds r2, 0x2
- adds r0, r4, r2
- strb r1, [r0]
- adds r3, 0x2
- adds r0, r4, r3
- strh r1, [r0]
- adds r2, 0x3
- adds r0, r4, r2
- strh r1, [r0]
- movs r3, 0
- ldr r0, =0x00000654
- adds r1, r4, r0
- movs r2, 0
-_080BB4CE:
- adds r0, r1, r3
- strb r2, [r0]
- adds r0, r3, 0x1
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, 0x7
- bls _080BB4CE
- movs r3, 0
- ldr r2, =0x0000065c
- adds r1, r4, r2
- movs r2, 0
-_080BB4E4:
- adds r0, r1, r3
- strb r2, [r0]
- adds r0, r3, 0x1
- lsls r0, 16
- lsrs r3, r0, 16
- cmp r3, 0x7
- bls _080BB4E4
- pop {r4-r7}
- pop {r0}
- bx r0
- .pool
- thumb_func_end sub_80BB384
-
thumb_func_start sub_80BB534
sub_80BB534: @ 80BB534
push {r4-r7,lr}
diff --git a/include/global.h b/include/global.h
index 8c56c0a58..8ffa16cb7 100644
--- a/include/global.h
+++ b/include/global.h
@@ -37,6 +37,7 @@
#define PARTY_SIZE 6
+#define POKEMON_SLOTS_NUMBER 412
#define POKEMON_NAME_LENGTH 10
#define OT_NAME_LENGTH 7
diff --git a/src/pokedex.c b/src/pokedex.c
index a74594865..8acc36efb 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -6,6 +6,65 @@
#include "decompress.h"
#include "bg.h"
#include "window.h"
+#include "event_data.h"
+#include "palette.h"
+
+extern u16 gUnknown_02039B50;
+extern u8 gUnknown_02039B52;
+
+extern u8 gUnknown_030060B0;
+
+#define NATIONAL_DEX_COUNT 386
+
+struct PokedexListItem
+{
+ u16 dexNum;
+ u16 seen:1;
+ u16 owned:1;
+};
+
+struct PokedexView
+{
+ struct PokedexListItem unk0[NATIONAL_DEX_COUNT];
+ u16 unk608;
+ u8 unk60A_1:1;
+ u8 unk60A_2:1;
+ u8 unk60B;
+ u16 pokemonListCount;
+ u16 selectedPokemon;
+ u16 unk610;
+ u16 dexMode;
+ u16 unk614;
+ u16 dexOrder;
+ u16 unk618;
+ u16 unk61A;
+ u16 unk61C;
+ u16 unk61E[4];
+ u16 selectedMonSpriteId;
+ u16 unk628;
+ u16 unk62A;
+ u8 unk62C;
+ u8 unk62D;
+ u8 unk62E;
+ u8 unk62F;
+ s16 unk630;
+ s16 unk632;
+ u16 unk634;
+ u16 unk636;
+ u16 unk638;
+ u16 unk63A[4];
+ u8 filler642[8];
+ u8 unk64A;
+ u8 unk64B;
+ u8 unk64C_1:1;
+ u8 selectedScreen;
+ u8 unk64E;
+ u8 menuIsOpen; //menuIsOpen
+ u16 menuCursorPos; //Menu cursor position
+ s16 menuY; //Menu Y position (inverted because we use REG_BG0VOFS for this)
+ u8 unk654[8];
+ u8 unk65C[8];
+};
// this file's functions
void sub_80BE604(struct Sprite *sprite);
@@ -540,3 +599,94 @@ const struct WindowTemplate sWindowTemplates_0855D2A8[] =
DUMMY_WIN_TEMPLATE
};
+// .text
+
+#define DEX_FLAGS_NO ((POKEMON_SLOTS_NUMBER / 8) + ((POKEMON_SLOTS_NUMBER % 8) ? 1 : 0))
+
+void ResetPokedex(void)
+{
+ u16 i;
+
+ gUnknown_02039B50 = 0;
+ gUnknown_02039B52 = 64;
+ gUnknown_030060B0 = 0;
+ gSaveBlock2Ptr->pokedex.unknown1 = 0;
+ gSaveBlock2Ptr->pokedex.order = 0;
+ gSaveBlock2Ptr->pokedex.nationalMagic = 0;
+ gSaveBlock2Ptr->pokedex.unknown2 = 0;
+ gSaveBlock2Ptr->pokedex.unownPersonality = 0;
+ gSaveBlock2Ptr->pokedex.spindaPersonality = 0;
+ gSaveBlock2Ptr->pokedex.unknown3 = 0;
+ DisableNationalPokedex();
+ for (i = 0; i < DEX_FLAGS_NO; i++)
+ {
+ gSaveBlock2Ptr->pokedex.owned[i] = 0;
+ gSaveBlock2Ptr->pokedex.seen[i] = 0;
+ gSaveBlock1Ptr->seen1[i] = 0;
+ gSaveBlock1Ptr->seen2[i] = 0;
+ }
+}
+
+void sub_80BB358(void)
+{
+ gUnknown_02039B50 = 0;
+ gUnknown_02039B52 = 64;
+}
+
+void sub_80BB370(void)
+{
+ LoadOam();
+ ProcessSpriteCopyRequests();
+ TransferPlttBuffer();
+}
+
+void sub_80BB384(struct PokedexView *pokedexView)
+{
+ u16 i;
+
+ for (i = 0; i < NATIONAL_DEX_COUNT; i++)
+ {
+ pokedexView->unk0[i].dexNum |= 0xFFFF;
+ pokedexView->unk0[i].seen = 0;
+ pokedexView->unk0[i].owned = 0;
+ }
+ pokedexView->unk608 = 0;
+ pokedexView->unk60A_1 = 0;
+ pokedexView->unk60A_2 = 0;
+ pokedexView->pokemonListCount = 0;
+ pokedexView->selectedPokemon = 0;
+ pokedexView->unk610 = 0;
+ pokedexView->dexMode = 0;
+ pokedexView->unk614 = 0;
+ pokedexView->dexOrder = 0;
+ pokedexView->unk618 = 0;
+ pokedexView->unk61A = 0;
+ pokedexView->unk61C = 0;
+ for (i = 0; i <= 3; i++)
+ pokedexView->unk61E[i] |= 0xFFFF;
+ pokedexView->unk628 = 0;
+ pokedexView->unk62A = 0;
+ pokedexView->unk62C = 0;
+ pokedexView->unk62D = 0;
+ pokedexView->unk62E = 0;
+ pokedexView->unk62F = 0;
+ pokedexView->unk630 = 0;
+ pokedexView->unk632 = 0;
+ pokedexView->unk634 = 0;
+ pokedexView->unk636 = 0;
+ pokedexView->unk638 = 0;
+ for (i = 0; i <= 3; i++)
+ pokedexView->unk63A[i] = 0;
+ pokedexView->unk64A = 0;
+ pokedexView->unk64B = 0;
+ pokedexView->unk64C_1 = 0;
+ pokedexView->selectedScreen = 0;
+ pokedexView->unk64E = 0;
+ pokedexView->menuIsOpen = 0;
+ pokedexView->menuCursorPos = 0;
+ pokedexView->menuY = 0;
+ for (i = 0; i <= 7; i++)
+ pokedexView->unk654[i] = 0;
+ for (i = 0; i <= 7; i++)
+ pokedexView->unk65C[i] = 0;
+}