summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarijn van der Werf <marijn.vanderwerf@gmail.com>2017-05-08 22:37:45 +0200
committerYamaArashi <YamaArashi@users.noreply.github.com>2017-05-08 14:19:49 -0700
commitf6e3598f5efbda472c6605c94b5597d1196ea619 (patch)
treef1d812acfac3534c42685d88016d5f3eb6e5d85a /src
parent64412ee4c45a53712dd94410966ec68771b83fdd (diff)
Decompile ShowPokedexCryScreen
Diffstat (limited to 'src')
-rw-r--r--src/pokedex.c28
-rw-r--r--src/pokedex_cry_screen.c85
2 files changed, 91 insertions, 22 deletions
diff --git a/src/pokedex.c b/src/pokedex.c
index a5dcfe049..3ef1de51e 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -51,15 +51,6 @@ struct PokedexEntry
/*0x20*/ u16 trainerOffset;
}; /*size = 0x24*/
-struct CryRelatedStruct
-{
- u16 unk0;
- u8 unk2;
- u8 unk3;
- u8 unk4;
- u8 unk5;
-};
-
extern struct MusicPlayerInfo gMPlay_BGM;
extern u8 gReservedSpritePaletteCount;
extern struct PokedexView *gPokedexView;
@@ -124,13 +115,6 @@ u16 NationalPokedexNumToSpecies(u16);
// asm/pokedex_area_screen
void ShowPokedexAreaScreen(u16 species, u8 *string);
-// asm/pokedex_cry_screen
-u8 sub_8119E3C(struct CryRelatedStruct *, u8);
-void sub_8119F88(u8 a);
-void sub_811A050(u16 species);
-u8 ShowPokedexCryScreen(struct CryRelatedStruct *, u8);
-void DestroyCryMeterNeedleSprite();
-
void sub_808C02C(void)
{
u16 i;
@@ -2526,9 +2510,9 @@ void Task_InitCryScreenMultistep(u8 taskId)
sp8.unk0 = 0x4020;
sp8.unk2 = 0x1F;
- sp8.unk3 = 8;
- sp8.unk5 = 0x1E;
- sp8.unk4 = 0xC;
+ sp8.paletteNo = 8;
+ sp8.yPos = 0x1E;
+ sp8.xPos = 0xC;
if (sub_8119E3C(&sp8, 0) != 0)
{
gMain.state++;
@@ -2542,9 +2526,9 @@ void Task_InitCryScreenMultistep(u8 taskId)
sp10.unk0 = 0x3000;
sp10.unk2 = 0xE;
- sp10.unk3 = 9;
- sp10.unk4 = 0x12;
- sp10.unk5 = 3;
+ sp10.paletteNo = 9;
+ sp10.xPos = 0x12;
+ sp10.yPos = 3;
if (ShowPokedexCryScreen(&sp10, 1) != 0)
{
gMain.state++;
diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c
new file mode 100644
index 000000000..53807befc
--- /dev/null
+++ b/src/pokedex_cry_screen.c
@@ -0,0 +1,85 @@
+#include "global.h"
+#include "asm.h"
+#include "palette.h"
+#include "sprite.h"
+
+struct Unk201C800 {
+ u8 unk_0;
+ u8 unk_1;
+ u8 unk_2;
+ u8 filler_3;
+ u16 unk_4;
+};
+
+#define EWRAM_1C800 (*(struct Unk201C800 *)(unk_201C000 + 0x800))
+
+extern u8 unk_201C000[];
+
+extern u8 gUnknown_03005E98;
+
+// data/pokedex_cry_screen.o
+extern const u16 gUnknown_083FAE7C[];
+extern const u16 gUnknown_083FAF1C[];
+extern const u8 gUnknown_083FAF3C[];
+extern struct SpriteTemplate gSpriteTemplate_83FB774;
+extern const struct SpriteSheet gCryMeterNeedleSpriteSheets[];
+extern const struct SpritePalette gCryMeterNeedleSpritePalettes[];
+
+#if ENGLISH
+#define CRY_METER_MAP_WIDTH 10
+#elif GERMAN
+#define CRY_METER_MAP_WIDTH 32
+#endif
+
+u8 ShowPokedexCryScreen(struct CryRelatedStruct *cry, u8 arg1) {
+ int returnVal = FALSE;
+
+ switch (gUnknown_03005E98)
+ {
+ case 0:
+ LZ77UnCompVram(gUnknown_083FAF3C, (void *) (VRAM + cry->unk0));
+ LoadPalette(&gUnknown_083FAF1C, cry->paletteNo * 16, 0x20);
+ gUnknown_03005E98 += 1;
+ break;
+
+ case 1:
+ {
+ void *vram;
+ u8 row, col;
+ u32 r12;
+ int x, y;
+
+ vram = (void *) BG_SCREEN_ADDR(cry->unk2);
+
+ r12 = (u32) (cry->unk0 << 18) >> 23;
+
+ for (row = 0; row < 8; row++)
+ {
+ for (col = 0; col < 10; col++)
+ {
+ y = row + cry->yPos;
+ x = col + cry->xPos;
+ *(u16 *) (vram + (y * 64 + x * 2)) = (gUnknown_083FAE7C[row * CRY_METER_MAP_WIDTH + col] | (cry->paletteNo << 12)) + r12;
+ }
+ }
+
+ gUnknown_03005E98 += 1;
+ break;
+ }
+
+ case 2:
+ {
+ LoadSpriteSheets(gCryMeterNeedleSpriteSheets);
+ LoadSpritePalettes(gCryMeterNeedleSpritePalettes);
+ EWRAM_1C800.unk_4 = CreateSprite(&gSpriteTemplate_83FB774, 40 + cry->xPos * 8, 56 + cry->yPos * 8, 1);
+ EWRAM_1C800.unk_0 = 0x20;
+ EWRAM_1C800.unk_1 = 0x20;
+ EWRAM_1C800.unk_2 = 0;
+
+ returnVal = TRUE;
+ break;
+ }
+ }
+
+ return returnVal;
+}