From 75b07292c99bdae7efe539bbe797aa4c381c880e Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Wed, 28 Mar 2018 19:20:20 +0200 Subject: [PATCH 1/8] Translate first functions of learn move --- asm/learn_move.s | 14 ++++-- graphics/pokedex/arrows.png | Bin 0 -> 303 bytes include/learn_move.h | 36 ++++++++++++++++ src/learn_move.c | 83 ++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 graphics/pokedex/arrows.png create mode 100644 include/learn_move.h create mode 100644 src/learn_move.c diff --git a/asm/learn_move.s b/asm/learn_move.s index a33bd11b6..1faff5637 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -5,6 +5,7 @@ .text +/* thumb_func_start sub_8160624 sub_8160624: @ 8160624 push {lr} @@ -14,7 +15,9 @@ sub_8160624: @ 8160624 pop {r0} bx r0 thumb_func_end sub_8160624 +*/ +/* thumb_func_start sub_8160638 sub_8160638: @ 8160638 push {lr} @@ -35,7 +38,9 @@ sub_8160638: @ 8160638 bx r0 .pool thumb_func_end sub_8160638 +*/ +/* thumb_func_start sub_8160664 sub_8160664: @ 8160664 push {r4,lr} @@ -60,7 +65,9 @@ _08160688: bx r0 .pool thumb_func_end sub_8160664 +*/ +/* thumb_func_start sub_81606A0 sub_81606A0: @ 81606A0 push {r4-r6,lr} @@ -75,7 +82,7 @@ sub_81606A0: @ 81606A0 str r0, [r6] ldr r1, =gSpecialVar_0x8004 ldrh r1, [r1] - adds r0, 0x44 + adds r0, 0x44 partymon movs r5, 0 strb r1, [r0] ldr r0, =sub_8160624 @@ -100,8 +107,8 @@ sub_81606A0: @ 81606A0 bl ListMenuInit ldr r1, [r6] movs r2, 0x89 - lsls r2, 1 - adds r1, r2 + lsls r2, 1 //0x112 + adds r1, r2 //partymon + 0x112 strb r0, [r1] movs r0, 0 movs r1, 0 @@ -114,6 +121,7 @@ sub_81606A0: @ 81606A0 bx r0 .pool thumb_func_end sub_81606A0 +*/ thumb_func_start sub_8160740 sub_8160740: @ 8160740 diff --git a/graphics/pokedex/arrows.png b/graphics/pokedex/arrows.png new file mode 100644 index 0000000000000000000000000000000000000000..2abf39366e45e76afedc93ae41fc57b59253f68b GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^96+4F!VDxYwdwT(DT4r?5Lbr(K*;cnf#E6x!%?6h z4si4+Nb>*x|MI(%ZGfy@o-U3d5>sm@9OOEpz~jPxe%*bAo!kG{e__@+F>iaop4a9% zYFoRPZjh6E<)fx};BQNF1gB-k)C;Q@eT)?8owg`LNApLuRom{UwTu2G_zU}STYaoj zYrB`rw>NC#!ynPUv#Lwy&TKx^RN45{j-5B$VTY6MJ*mX|{=(B4^_XMWcJLHP-db_d zG^ZfYdwO|iL<1xHa^A;IJI~k&b_&noaNqm0=G1|2nw-)G4<3g4Nk5&f|9ppartyMon = gSpecialVar_0x8004; + + SetVBlankCallback(sub_8160624); + sub_81607EC(); + sub_81D2824(0); + + //pointer to ? + (&gUnknown_0203BC38)[0] = 0; + (&gUnknown_0203BC38)[2] = 0; + (&gUnknown_0203BC38)[4] = 0; + + sub_8161280(); + LoadSpriteSheet(&gUnknown_085CEBB0); + LoadSpritePalette(&gUnknown_085CEBB8); + sub_81610B8(); + + ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); + FillPalette(0, 0, 2); + SetMainCallback2(sub_816082C); +} From 990784a6d91a9b119ff974e3594a7bd5070549fc Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Wed, 28 Mar 2018 21:45:35 +0200 Subject: [PATCH 2/8] Improve comments --- src/learn_move.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/learn_move.c b/src/learn_move.c index 3a1ac72f4..36bf76eff 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -14,7 +14,7 @@ extern void (*gFieldCallback)(void); extern struct LearnMoveStruct *gUnknown_0203BC34; -// Ew, just copied from poeruby... +// Ew, just copied from pokeruby... const u16 gDexArrows_Pal[] = INCBIN_U16("graphics/pokedex/arrows.gbapal"); const u8 gDexArrows_Gfx[] = INCBIN_U8("graphics/pokedex/arrows.4bpp"); const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; @@ -50,6 +50,7 @@ void sub_8160664(u8 taskId) void sub_81606A0(void) //CB2_InitLearnMove { + //Less calls than pokeruby, is it normal ? ResetSpriteData(); FreeAllSpritePalettes(); ResetTasks(); @@ -57,17 +58,17 @@ void sub_81606A0(void) //CB2_InitLearnMove //LearnMoveStruct** - gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? //r1 = &gSpecialVar_0x8004; //What is this global ? //u8* partyMon = gUnknown_0203BC34 + 0x44 //partyMon ? //*partyMon = r1; + gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; SetVBlankCallback(sub_8160624); sub_81607EC(); sub_81D2824(0); - //pointer to ? + //gUnknown_0203BC38 ? (&gUnknown_0203BC38)[0] = 0; (&gUnknown_0203BC38)[2] = 0; (&gUnknown_0203BC38)[4] = 0; From cfacd23248ba56f5bca30895154625a06761ab45 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Thu, 29 Mar 2018 11:56:10 +0200 Subject: [PATCH 3/8] Fix temporarily --- include/learn_move.h | 8 +++++++- src/learn_move.c | 18 +++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/learn_move.h b/include/learn_move.h index 951cd6cb0..da03fe5ae 100644 --- a/include/learn_move.h +++ b/include/learn_move.h @@ -31,6 +31,12 @@ struct LearnMoveStruct *gUnknown_0203BC34 = NULL; void sub_8160624(void); void sub_8160638(void); -const struct SpritePalette gUnknown_08402D88 = {gDexArrows_Pal, 5526}; +// Ew, just copied from pokeruby... +//const u16 gDexArrows_Pal[] = INCBIN_U16("graphics/pokedex/arrows.gbapal"); +//const u8 gDexArrows_Gfx[] = INCBIN_U8("graphics/pokedex/arrows.4bpp"); +//const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; +//const struct SpriteSheet gUnknown_085CEBB0 = {gDexArrows_Gfx, sizeof(gDexArrows_Gfx), 5525}; + +void *gUnknown_0203BC38 = (void*)0x0203BC38; #endif //GUARD_LEAN_MOVE_H diff --git a/src/learn_move.c b/src/learn_move.c index 36bf76eff..d75e0a460 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -14,12 +14,6 @@ extern void (*gFieldCallback)(void); extern struct LearnMoveStruct *gUnknown_0203BC34; -// Ew, just copied from pokeruby... -const u16 gDexArrows_Pal[] = INCBIN_U16("graphics/pokedex/arrows.gbapal"); -const u8 gDexArrows_Gfx[] = INCBIN_U8("graphics/pokedex/arrows.4bpp"); -const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; -const struct SpriteSheet gUnknown_085CEBB0 = {gDexArrows_Gfx, sizeof(gDexArrows_Gfx), 5525}; - static struct LearnMoveStruct *sLearnMoveStruct; static void sub_8160664(u8 taskId); void sub_81606A0(void); //CB2_InitLearnMove @@ -50,6 +44,12 @@ void sub_8160664(u8 taskId) void sub_81606A0(void) //CB2_InitLearnMove { + //FIXME + void (*sub_81607EC)(void) = (void*)0x081607EC; + void (*sub_81D2824)(void*) = (void*)0x081D2824; + void (*sub_81610B8)(void) = (void*)0x081610B8; + void (*sub_8161280)(void) = (void*)0x08161280; + //Less calls than pokeruby, is it normal ? ResetSpriteData(); FreeAllSpritePalettes(); @@ -74,11 +74,11 @@ void sub_81606A0(void) //CB2_InitLearnMove (&gUnknown_0203BC38)[4] = 0; sub_8161280(); - LoadSpriteSheet(&gUnknown_085CEBB0); - LoadSpritePalette(&gUnknown_085CEBB8); + LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); + LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); sub_81610B8(); ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); FillPalette(0, 0, 2); - SetMainCallback2(sub_816082C); + SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); } From 17b9f5d892ad34e4af3b407e2ee44a83506ee2f3 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Thu, 29 Mar 2018 15:46:10 +0200 Subject: [PATCH 4/8] Fix compile error --- asm/learn_move.s | 4 ++-- include/learn_move.h | 6 +++--- ld_script.txt | 1 + src/learn_move.c | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/asm/learn_move.s b/asm/learn_move.s index 1faff5637..ab3c84ec2 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -82,7 +82,7 @@ sub_81606A0: @ 81606A0 str r0, [r6] ldr r1, =gSpecialVar_0x8004 ldrh r1, [r1] - adds r0, 0x44 partymon + adds r0, 0x44 movs r5, 0 strb r1, [r0] ldr r0, =sub_8160624 @@ -129,7 +129,7 @@ sub_8160740: @ 8160740 bl ResetSpriteData bl FreeAllSpritePalettes bl ResetTasks - bl clear_scheduled_bg_copies_to_vram + bl clear_scheduled_bg_copies_to_vram // ldr r5, =gUnknown_0203BC34 movs r0, 0x8C lsls r0, 1 diff --git a/include/learn_move.h b/include/learn_move.h index da03fe5ae..ed95b6206 100644 --- a/include/learn_move.h +++ b/include/learn_move.h @@ -1,5 +1,5 @@ -#ifndef GUARD_LEAN_MOVE_H -#define GUARD_LEAN_MOVE_H +#ifndef GUARD_LEARN_MOVE_H +#define GUARD_LEARN_MOVE_H struct LearnMoveStruct { @@ -39,4 +39,4 @@ void sub_8160638(void); void *gUnknown_0203BC38 = (void*)0x0203BC38; -#endif //GUARD_LEAN_MOVE_H +#endif //GUARD_LEARN_MOVE_H diff --git a/ld_script.txt b/ld_script.txt index 7ead2a863..cbc58dc8d 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -210,6 +210,7 @@ SECTIONS { src/fldeff_sweetscent.o(.text); asm/battle_anim_815A0D4.o(.text); asm/learn_move.o(.text); + src/learn_move.o(.text); src/fldeff_softboiled.o(.text); src/decoration_inventory.o(.text); src/roamer.o(.text); diff --git a/src/learn_move.c b/src/learn_move.c index d75e0a460..f83707624 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -17,6 +17,7 @@ extern struct LearnMoveStruct *gUnknown_0203BC34; static struct LearnMoveStruct *sLearnMoveStruct; static void sub_8160664(u8 taskId); void sub_81606A0(void); //CB2_InitLearnMove +void sub_8160740(void); void sub_8160624(void) //VBlankCB_LearnMove { @@ -56,7 +57,6 @@ void sub_81606A0(void) //CB2_InitLearnMove ResetTasks(); clear_scheduled_bg_copies_to_vram(); - //LearnMoveStruct** //r1 = &gSpecialVar_0x8004; //What is this global ? //u8* partyMon = gUnknown_0203BC34 + 0x44 //partyMon ? @@ -82,3 +82,17 @@ void sub_81606A0(void) //CB2_InitLearnMove FillPalette(0, 0, 2); SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); } + +/* +void sub_8160740(void) +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + clear_scheduled_bg_copies_to_vram(); + + gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? + gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; + gUnknown_0203BC34->unk2C6 = gSpecialVar_0x8005; +} +*/ From 6e919da4aad94338e5d8132c3808f122bf5b7c79 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Thu, 29 Mar 2018 20:41:29 +0200 Subject: [PATCH 5/8] Change order in ld_script.txt --- ld_script.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ld_script.txt b/ld_script.txt index cbc58dc8d..464dc7841 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -209,8 +209,8 @@ SECTIONS { src/battle_controller_safari.o(.text); src/fldeff_sweetscent.o(.text); asm/battle_anim_815A0D4.o(.text); - asm/learn_move.o(.text); src/learn_move.o(.text); + asm/learn_move.o(.text); src/fldeff_softboiled.o(.text); src/decoration_inventory.o(.text); src/roamer.o(.text); From 09e29a5cf8695cf43fe8ac18004049b07a59ccc5 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Sun, 1 Apr 2018 18:22:09 +0200 Subject: [PATCH 6/8] Fix three functions to have the right checksum --- asm/learn_move.s | 6 +- include/learn_move.h | 2 +- src/learn_move.c | 129 +++++++++++++++++++++++++------------------ 3 files changed, 78 insertions(+), 59 deletions(-) diff --git a/asm/learn_move.s b/asm/learn_move.s index ab3c84ec2..5fd507c2d 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -67,7 +67,6 @@ _08160688: thumb_func_end sub_8160664 */ -/* thumb_func_start sub_81606A0 sub_81606A0: @ 81606A0 push {r4-r6,lr} @@ -121,7 +120,6 @@ sub_81606A0: @ 81606A0 bx r0 .pool thumb_func_end sub_81606A0 -*/ thumb_func_start sub_8160740 sub_8160740: @ 8160740 @@ -148,7 +146,7 @@ sub_8160740: @ 8160740 adds r0, 0x45 strb r1, [r0] ldr r0, =sub_8160624 - bl SetVBlankCallback + bl SetVBlankCallback // bl sub_81607EC ldr r4, =gUnknown_0203BC38 ldrb r0, [r4, 0x4] @@ -157,7 +155,7 @@ sub_8160740: @ 8160740 ldr r0, =gUnknown_085CEBB0 bl LoadSpriteSheet ldr r0, =gUnknown_085CEBB8 - bl LoadSpritePalette + bl LoadSpritePalette // bl sub_81610B8 ldr r0, =gMultiuseListMenuTemplate ldrh r1, [r4] diff --git a/include/learn_move.h b/include/learn_move.h index ed95b6206..7779e85a0 100644 --- a/include/learn_move.h +++ b/include/learn_move.h @@ -37,6 +37,6 @@ void sub_8160638(void); //const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; //const struct SpriteSheet gUnknown_085CEBB0 = {gDexArrows_Gfx, sizeof(gDexArrows_Gfx), 5525}; -void *gUnknown_0203BC38 = (void*)0x0203BC38; +u8 *gUnknown_0203BC38 = (void*)0x0203BC38; #endif //GUARD_LEARN_MOVE_H diff --git a/src/learn_move.c b/src/learn_move.c index f83707624..faa73a2d0 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -30,7 +30,7 @@ void sub_8160638(void) //TeachMoveTutorMove { ScriptContext2_Enable(); CreateTask(sub_8160664, 0xA); - BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); } void sub_8160664(u8 taskId) @@ -43,56 +43,77 @@ void sub_8160664(u8 taskId) } } -void sub_81606A0(void) //CB2_InitLearnMove -{ - //FIXME - void (*sub_81607EC)(void) = (void*)0x081607EC; - void (*sub_81D2824)(void*) = (void*)0x081D2824; - void (*sub_81610B8)(void) = (void*)0x081610B8; - void (*sub_8161280)(void) = (void*)0x08161280; - - //Less calls than pokeruby, is it normal ? - ResetSpriteData(); - FreeAllSpritePalettes(); - ResetTasks(); - clear_scheduled_bg_copies_to_vram(); - - //LearnMoveStruct** - //r1 = &gSpecialVar_0x8004; //What is this global ? - //u8* partyMon = gUnknown_0203BC34 + 0x44 //partyMon ? - //*partyMon = r1; - gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? - gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; - - SetVBlankCallback(sub_8160624); - sub_81607EC(); - sub_81D2824(0); - - //gUnknown_0203BC38 ? - (&gUnknown_0203BC38)[0] = 0; - (&gUnknown_0203BC38)[2] = 0; - (&gUnknown_0203BC38)[4] = 0; - - sub_8161280(); - LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); - LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); - sub_81610B8(); - - ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); - FillPalette(0, 0, 2); - SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); -} - -/* -void sub_8160740(void) -{ - ResetSpriteData(); - FreeAllSpritePalettes(); - ResetTasks(); - clear_scheduled_bg_copies_to_vram(); - - gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? - gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; - gUnknown_0203BC34->unk2C6 = gSpecialVar_0x8005; -} -*/ +// void sub_81606A0(void) //CB2_InitLearnMove +// { +// //FIXME +// void (*sub_81607EC)(void) = (void*)0x081607EC; +// void (*sub_81D2824)(u16) = (void*)0x081D2824; +// void (*sub_81610B8)(void) = (void*)0x081610B8; +// void (*sub_8161280)(void) = (void*)0x08161280; +// +// //Less calls than pokeruby, is it normal ? +// ResetSpriteData(); +// FreeAllSpritePalettes(); +// ResetTasks(); +// clear_scheduled_bg_copies_to_vram(); +// +// //LearnMoveStruct** +// //r1 = &gSpecialVar_0x8004; //What is this global ? +// //u8* partyMon = gUnknown_0203BC34 + 0x44 //partyMon ? +// //*partyMon = r1; +// gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? +// gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; +// +// SetVBlankCallback(sub_8160624); +// sub_81607EC(); +// sub_81D2824(0); +// +// //gUnknown_0203BC38 ? +// (gUnknown_0203BC38)[0] = 0; +// (gUnknown_0203BC38)[2] = 0; +// (gUnknown_0203BC38)[4] = 0; +// +// sub_8161280(); +// LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); +// LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); +// sub_81610B8(); +// +// ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); +// FillPalette(0, 0, 2); +// SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); +// } +// +// void sub_8160740(void) +// { +// void (*sub_81607EC)(void) = (void*)0x081607EC; +// void (*sub_81D2824)(u16) = (void*)0x081D2824; +// void (*sub_81610B8)(void) = (void*)0x081610B8; +// void (*sub_8161280)(void) = (void*)0x08161280; +// +// u8 data; +// +// ResetSpriteData(); +// FreeAllSpritePalettes(); +// ResetTasks(); +// clear_scheduled_bg_copies_to_vram(); +// +// gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? +// gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; //gUnknown_0203BC34 + 68 +// gUnknown_0203BC34->unk2C6 = gSpecialVar_0x8005; //gUnknown_0203BC34 + 69 +// +// SetVBlankCallback(sub_8160624); +// sub_81607EC(); +// +// //gUnknown_0203BC38 ? +// sub_81D2824(*((u8*)&gUnknown_0203BC38 + 4)); +// sub_8161280(); +// +// LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); +// LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); +// +// data = ListMenuInit(&gMultiuseListMenuTemplate, *gUnknown_0203BC38, *((u8*)gUnknown_0203BC38 + 2)); +// *(u8*)(gUnknown_0203BC34 + 274) = data; +// FillPalette(0, 0, 2); +// SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); +// } +// */ From b2e8ee836d6334e525df3163d7b018b64f68ec95 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Mon, 2 Apr 2018 20:06:40 +0200 Subject: [PATCH 7/8] sub_81607EC and sub_816082C --- asm/learn_move.s | 4 ++ include/learn_move.h | 9 +++- ld_script.txt | 1 + src/learn_move.c | 100 ++++++++++++++++++++++++++++++++----------- sym_ewram.txt | 11 ++--- 5 files changed, 90 insertions(+), 35 deletions(-) diff --git a/asm/learn_move.s b/asm/learn_move.s index 5fd507c2d..4f0a6abb4 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -178,6 +178,7 @@ sub_8160740: @ 8160740 .pool thumb_func_end sub_8160740 +/* thumb_func_start sub_81607EC sub_81607EC: @ 81607EC push {lr} @@ -204,7 +205,9 @@ sub_81607EC: @ 81607EC bx r0 .pool thumb_func_end sub_81607EC +*/ +/* thumb_func_start sub_816082C sub_816082C: @ 816082C push {lr} @@ -217,6 +220,7 @@ sub_816082C: @ 816082C pop {r0} bx r0 thumb_func_end sub_816082C +*/ thumb_func_start sub_816084C sub_816084C: @ 816084C diff --git a/include/learn_move.h b/include/learn_move.h index 7779e85a0..6ab2ba6f4 100644 --- a/include/learn_move.h +++ b/include/learn_move.h @@ -1,6 +1,7 @@ #ifndef GUARD_LEARN_MOVE_H #define GUARD_LEARN_MOVE_H +//this struct is probably wrong struct LearnMoveStruct { u8 state; @@ -26,7 +27,9 @@ struct LearnMoveStruct u8 unk2C6; }; -struct LearnMoveStruct *gUnknown_0203BC34 = NULL; +//struct LearnMoveStruct *gUnknown_0203BC34 = NULL; + +//extern u8 *gUnknown_0203BC34; void sub_8160624(void); void sub_8160638(void); @@ -37,6 +40,8 @@ void sub_8160638(void); //const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; //const struct SpriteSheet gUnknown_085CEBB0 = {gDexArrows_Gfx, sizeof(gDexArrows_Gfx), 5525}; -u8 *gUnknown_0203BC38 = (void*)0x0203BC38; +//u8 *gUnknown_0203BC38 = (void*)0x0203BC38; +//extern u8 gUnknown_0203BC38[8]; +//u8 gUnknown_0203BC38; #endif //GUARD_LEARN_MOVE_H diff --git a/ld_script.txt b/ld_script.txt index 464dc7841..ac1c80c22 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -490,6 +490,7 @@ SECTIONS { src/battle_controller_safari.o(.rodata); data/battle_anim_815A0D4.o(.rodata); data/learn_move.o(.rodata); + src/learn_move.o(.rodata); src/roamer.o(.rodata); data/battle_tower.o(.rodata); src/use_pokeblock.o(.rodata); diff --git a/src/learn_move.c b/src/learn_move.c index faa73a2d0..0f5063fae 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -5,20 +5,34 @@ #include "sprite.h" #include "palette.h" #include "menu.h" +#include "menu_helpers.h" #include "list_menu.h" #include "malloc.h" #include "field_screen.h" #include "event_data.h" +#include "bg.h" +#include "gpu_regs.h" #include "learn_move.h" -extern void (*gFieldCallback)(void); -extern struct LearnMoveStruct *gUnknown_0203BC34; +EWRAM_DATA u8 *gUnknown_0203BC34 = 0; +EWRAM_DATA u8 gUnknown_0203BC38[8] = {0}; + +extern void (*gFieldCallback)(void); +extern const struct SpritePalette gUnknown_085CEBB8; +extern const struct SpriteSheet gUnknown_085CEBB0; +extern const struct BgTemplate gUnknown_085CEC28; +extern void sub_81D2824(u16); +//extern struct LearnMoveStruct *gUnknown_0203BC34; + +//static struct LearnMoveStruct *sLearnMoveStruct; -static struct LearnMoveStruct *sLearnMoveStruct; static void sub_8160664(u8 taskId); void sub_81606A0(void); //CB2_InitLearnMove void sub_8160740(void); +void sub_81607EC(void); +void sub_816082C(void); + void sub_8160624(void) //VBlankCB_LearnMove { LoadOam(); @@ -45,12 +59,9 @@ void sub_8160664(u8 taskId) // void sub_81606A0(void) //CB2_InitLearnMove // { -// //FIXME -// void (*sub_81607EC)(void) = (void*)0x081607EC; -// void (*sub_81D2824)(u16) = (void*)0x081D2824; -// void (*sub_81610B8)(void) = (void*)0x081610B8; -// void (*sub_8161280)(void) = (void*)0x08161280; -// +// //AGBPrint("test\n"); +// //AGBPrintFlush(); +// //NoCashGBAPrint("test\n"); // //Less calls than pokeruby, is it normal ? // ResetSpriteData(); // FreeAllSpritePalettes(); @@ -58,34 +69,46 @@ void sub_8160664(u8 taskId) // clear_scheduled_bg_copies_to_vram(); // // //LearnMoveStruct** -// //r1 = &gSpecialVar_0x8004; //What is this global ? -// //u8* partyMon = gUnknown_0203BC34 + 0x44 //partyMon ? -// //*partyMon = r1; // gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? -// gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; +// //gUnknown_0203BC34->movesToLearn[0] = gSpecialVar_0x8004; +// ((u8*)gUnknown_0203BC34)[68] = gSpecialVar_0x8004; // // SetVBlankCallback(sub_8160624); +// //SetVBlankCallback(/*FIXME sub_8160624*/ (void()(u16))0x081D2824); // sub_81607EC(); // sub_81D2824(0); // // //gUnknown_0203BC38 ? +// // weird instruction // (gUnknown_0203BC38)[0] = 0; // (gUnknown_0203BC38)[2] = 0; // (gUnknown_0203BC38)[4] = 0; // -// sub_8161280(); -// LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); -// LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); -// sub_81610B8(); +// //FIXME +// //sub_8161280(); +// __asm__("bl sub_8161280"); // -// ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); +// //LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); +// //LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); +// LoadSpriteSheet(&gUnknown_085CEBB0); +// LoadSpritePalette(&gUnknown_085CEBB8); +// //sub_81610B8(); +// //FIXME +// __asm__("bl sub_81610B8"); +// +// ((u8*)gUnknown_0203BC34)[274] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203BC38[0], gUnknown_0203BC38[2]); // FillPalette(0, 0, 2); -// SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); +// //SetMainCallback2(sub_816082C/*(void*)0x0816082C()*/); +// //SetMainCallback2(sub_816082C/*(void*)0x0816082C()*/); +// //FIXME +// __asm__( +// "ldr r0, =sub_816082C", +// "bl SetMainCallback2" +// ); // } -// + // void sub_8160740(void) // { -// void (*sub_81607EC)(void) = (void*)0x081607EC; // void (*sub_81D2824)(u16) = (void*)0x081D2824; // void (*sub_81610B8)(void) = (void*)0x081610B8; // void (*sub_8161280)(void) = (void*)0x08161280; @@ -105,15 +128,42 @@ void sub_8160664(u8 taskId) // sub_81607EC(); // // //gUnknown_0203BC38 ? -// sub_81D2824(*((u8*)&gUnknown_0203BC38 + 4)); +// sub_81D2824(gUnknown_0203BC38[4]); // sub_8161280(); // -// LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); -// LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); +// LoadSpriteSheet(&gUnknown_085CEBB0); +// LoadSpritePalette(&gUnknown_085CEBB8); +// //LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); +// //LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); // // data = ListMenuInit(&gMultiuseListMenuTemplate, *gUnknown_0203BC38, *((u8*)gUnknown_0203BC38 + 2)); // *(u8*)(gUnknown_0203BC34 + 274) = data; // FillPalette(0, 0, 2); // SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); // } -// */ + +void sub_81607EC(void) +{ + ResetVramOamAndBgCntRegs(); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, &gUnknown_085CEC28, 2); + ResetAllBgsCoordinates(); + SetGpuReg(0, 0x1040); + ShowBg(0); + ShowBg(1); + SetGpuReg(0x50, 0); +} +void sub_816082C(void) +{ + //FIXME + //sub_8160868(); + //void(*sub_8160868)(void) = (void (*)(void))0x08160868; + //sub_8160868(); + __asm__("bl sub_8160868"); + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); + +} diff --git a/sym_ewram.txt b/sym_ewram.txt index 96862ccd5..b88df9b0f 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -784,19 +784,14 @@ gUnknown_0203ABB8: @ 203ABB8 .space 0x4 .include "src/save.o" - + .space 0x4 /*unused var?*/ .include "src/mystery_event_script.o" -gUnknown_0203BC34: @ 203BC34 - .space 0x4 - -gUnknown_0203BC38: @ 203BC38 - .space 0x8 - + .include "src/learn_move.o" .include "src/decoration_inventory.o" - .include "src/roamer.o" + .include "src/roamer.o" gUnknown_0203BC88: @ 203BC88 .space 0x4 From 2f96282c7f56ae90bc62b2710c8430abd2b345f3 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Tue, 3 Apr 2018 00:07:55 +0200 Subject: [PATCH 8/8] cleaner --- asm/learn_move.s | 10 ++- include/learn_move.h | 40 ----------- src/learn_move.c | 154 +++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 135 deletions(-) diff --git a/asm/learn_move.s b/asm/learn_move.s index 4f0a6abb4..5500f5a58 100644 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -67,6 +67,7 @@ _08160688: thumb_func_end sub_8160664 */ +/* thumb_func_start sub_81606A0 sub_81606A0: @ 81606A0 push {r4-r6,lr} @@ -120,14 +121,16 @@ sub_81606A0: @ 81606A0 bx r0 .pool thumb_func_end sub_81606A0 +*/ +/* thumb_func_start sub_8160740 sub_8160740: @ 8160740 push {r4,r5,lr} bl ResetSpriteData bl FreeAllSpritePalettes bl ResetTasks - bl clear_scheduled_bg_copies_to_vram // + bl clear_scheduled_bg_copies_to_vram ldr r5, =gUnknown_0203BC34 movs r0, 0x8C lsls r0, 1 @@ -146,7 +149,7 @@ sub_8160740: @ 8160740 adds r0, 0x45 strb r1, [r0] ldr r0, =sub_8160624 - bl SetVBlankCallback // + bl SetVBlankCallback bl sub_81607EC ldr r4, =gUnknown_0203BC38 ldrb r0, [r4, 0x4] @@ -155,7 +158,7 @@ sub_8160740: @ 8160740 ldr r0, =gUnknown_085CEBB0 bl LoadSpriteSheet ldr r0, =gUnknown_085CEBB8 - bl LoadSpritePalette // + bl LoadSpritePalette bl sub_81610B8 ldr r0, =gMultiuseListMenuTemplate ldrh r1, [r4] @@ -177,6 +180,7 @@ sub_8160740: @ 8160740 bx r0 .pool thumb_func_end sub_8160740 +*/ /* thumb_func_start sub_81607EC diff --git a/include/learn_move.h b/include/learn_move.h index 6ab2ba6f4..034d689d4 100644 --- a/include/learn_move.h +++ b/include/learn_move.h @@ -1,47 +1,7 @@ #ifndef GUARD_LEARN_MOVE_H #define GUARD_LEARN_MOVE_H -//this struct is probably wrong -struct LearnMoveStruct -{ - u8 state; - u8 filler1; - u8 unk2; - u8 spriteIDs[20]; - u8 filler17[1]; - u8 unk18; - u8 unk19; - u8 numMenuChoices; - u8 menuSelection; - u8 unk1C; - bool8 unk1D; - u8 unk1E; - u8 filler1F; - /*0x020*/ u16 movesToLearn[20]; - u8 filler48[0x52-0x48]; - u8 moveNames[6][0x19]; - u8 fillerE8[0x2C3-0xE8]; - bool8 unk2C3; - bool8 showContestInfo; - /*0x2C5*/ u8 partyMon; - u8 unk2C6; -}; - -//struct LearnMoveStruct *gUnknown_0203BC34 = NULL; - -//extern u8 *gUnknown_0203BC34; - void sub_8160624(void); void sub_8160638(void); -// Ew, just copied from pokeruby... -//const u16 gDexArrows_Pal[] = INCBIN_U16("graphics/pokedex/arrows.gbapal"); -//const u8 gDexArrows_Gfx[] = INCBIN_U8("graphics/pokedex/arrows.4bpp"); -//const struct SpritePalette gUnknown_085CEBB8 = {gDexArrows_Pal, 5526}; -//const struct SpriteSheet gUnknown_085CEBB0 = {gDexArrows_Gfx, sizeof(gDexArrows_Gfx), 5525}; - -//u8 *gUnknown_0203BC38 = (void*)0x0203BC38; -//extern u8 gUnknown_0203BC38[8]; -//u8 gUnknown_0203BC38; - #endif //GUARD_LEARN_MOVE_H diff --git a/src/learn_move.c b/src/learn_move.c index 0f5063fae..addae6a38 100644 --- a/src/learn_move.c +++ b/src/learn_move.c @@ -22,14 +22,15 @@ extern const struct SpritePalette gUnknown_085CEBB8; extern const struct SpriteSheet gUnknown_085CEBB0; extern const struct BgTemplate gUnknown_085CEC28; extern void sub_81D2824(u16); -//extern struct LearnMoveStruct *gUnknown_0203BC34; -//static struct LearnMoveStruct *sLearnMoveStruct; +void sub_8160868(void); +void sub_8161280(void); +void sub_81610B8(void); +void sub_816082C(void); static void sub_8160664(u8 taskId); void sub_81606A0(void); //CB2_InitLearnMove void sub_8160740(void); - void sub_81607EC(void); void sub_816082C(void); @@ -57,90 +58,63 @@ void sub_8160664(u8 taskId) } } -// void sub_81606A0(void) //CB2_InitLearnMove -// { -// //AGBPrint("test\n"); -// //AGBPrintFlush(); -// //NoCashGBAPrint("test\n"); -// //Less calls than pokeruby, is it normal ? -// ResetSpriteData(); -// FreeAllSpritePalettes(); -// ResetTasks(); -// clear_scheduled_bg_copies_to_vram(); -// -// //LearnMoveStruct** -// gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? -// //gUnknown_0203BC34->movesToLearn[0] = gSpecialVar_0x8004; -// ((u8*)gUnknown_0203BC34)[68] = gSpecialVar_0x8004; -// -// SetVBlankCallback(sub_8160624); -// //SetVBlankCallback(/*FIXME sub_8160624*/ (void()(u16))0x081D2824); -// sub_81607EC(); -// sub_81D2824(0); -// -// //gUnknown_0203BC38 ? -// // weird instruction -// (gUnknown_0203BC38)[0] = 0; -// (gUnknown_0203BC38)[2] = 0; -// (gUnknown_0203BC38)[4] = 0; -// -// //FIXME -// //sub_8161280(); -// __asm__("bl sub_8161280"); -// -// //LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); -// //LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); -// LoadSpriteSheet(&gUnknown_085CEBB0); -// LoadSpritePalette(&gUnknown_085CEBB8); -// //sub_81610B8(); -// //FIXME -// __asm__("bl sub_81610B8"); -// -// ((u8*)gUnknown_0203BC34)[274] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203BC38[0], gUnknown_0203BC38[2]); -// FillPalette(0, 0, 2); -// //SetMainCallback2(sub_816082C/*(void*)0x0816082C()*/); -// //SetMainCallback2(sub_816082C/*(void*)0x0816082C()*/); -// //FIXME -// __asm__( -// "ldr r0, =sub_816082C", -// "bl SetMainCallback2" -// ); -// } +// Doesn't match +void sub_81606A0(void) //CB2_InitLearnMove +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + clear_scheduled_bg_copies_to_vram(); -// void sub_8160740(void) -// { -// void (*sub_81D2824)(u16) = (void*)0x081D2824; -// void (*sub_81610B8)(void) = (void*)0x081610B8; -// void (*sub_8161280)(void) = (void*)0x08161280; -// -// u8 data; -// -// ResetSpriteData(); -// FreeAllSpritePalettes(); -// ResetTasks(); -// clear_scheduled_bg_copies_to_vram(); -// -// gUnknown_0203BC34 = AllocZeroed(0x118);//gUnknown_0203BC34 is a global pointer to LearnMoveStruct ? -// gUnknown_0203BC34->partyMon = gSpecialVar_0x8004; //gUnknown_0203BC34 + 68 -// gUnknown_0203BC34->unk2C6 = gSpecialVar_0x8005; //gUnknown_0203BC34 + 69 -// -// SetVBlankCallback(sub_8160624); -// sub_81607EC(); -// -// //gUnknown_0203BC38 ? -// sub_81D2824(gUnknown_0203BC38[4]); -// sub_8161280(); -// -// LoadSpriteSheet(&gUnknown_085CEBB0); -// LoadSpritePalette(&gUnknown_085CEBB8); -// //LoadSpriteSheet(/*FIXME &gUnknown_085CEBB0*/(void*)0x085CEBB0); -// //LoadSpritePalette(/*FIXME &gUnknown_085CEBB8*/(void*)0x085CEBB8); -// -// data = ListMenuInit(&gMultiuseListMenuTemplate, *gUnknown_0203BC38, *((u8*)gUnknown_0203BC38 + 2)); -// *(u8*)(gUnknown_0203BC34 + 274) = data; -// FillPalette(0, 0, 2); -// SetMainCallback2(/*FIXME sub_816082C*/(void*)0x0816082C); -// } + gUnknown_0203BC34 = AllocZeroed(0x118); //gUnknown_0203BC34 ? + gUnknown_0203BC34[68] = gSpecialVar_0x8004; + + SetVBlankCallback(sub_8160624); + sub_81607EC(); + sub_81D2824(0); + + //gUnknown_0203BC38 ? + gUnknown_0203BC38[0] = 0; + gUnknown_0203BC38[2] = 0; + gUnknown_0203BC38[4] = 0; + + sub_8161280(); + + LoadSpriteSheet(&gUnknown_085CEBB0); + LoadSpritePalette(&gUnknown_085CEBB8); + sub_81610B8(); + + gUnknown_0203BC34[274] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203BC38[0], gUnknown_0203BC38[2]); + FillPalette(0, 0, 2); + SetMainCallback2(sub_816082C); +} + +// Doesn't match +void sub_8160740(void) +{ + ResetSpriteData(); + FreeAllSpritePalettes(); + ResetTasks(); + clear_scheduled_bg_copies_to_vram(); + + gUnknown_0203BC34 = AllocZeroed(0x118); //gUnknown_0203BC34 ? + gUnknown_0203BC34[68] = gSpecialVar_0x8004; + gUnknown_0203BC34[69] = gSpecialVar_0x8005; + + SetVBlankCallback(sub_8160624); + sub_81607EC(); + + //gUnknown_0203BC38 ? + sub_81D2824(gUnknown_0203BC38[4]); + sub_8161280(); + + LoadSpriteSheet(&gUnknown_085CEBB0); + LoadSpritePalette(&gUnknown_085CEBB8); + + gUnknown_0203BC34[274] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203BC38[0], gUnknown_0203BC38[2]); + FillPalette(0, 0, 2); + SetMainCallback2(sub_816082C); +} void sub_81607EC(void) { @@ -153,17 +127,13 @@ void sub_81607EC(void) ShowBg(1); SetGpuReg(0x50, 0); } + void sub_816082C(void) { - //FIXME - //sub_8160868(); - //void(*sub_8160868)(void) = (void (*)(void))0x08160868; - //sub_8160868(); - __asm__("bl sub_8160868"); + sub_8160868(); RunTasks(); AnimateSprites(); BuildOamBuffer(); do_scheduled_bg_tilemap_copies_to_vram(); UpdatePaletteFade(); - }