From 2f96282c7f56ae90bc62b2710c8430abd2b345f3 Mon Sep 17 00:00:00 2001 From: Edouard Veyrier Date: Tue, 3 Apr 2018 00:07:55 +0200 Subject: [PATCH] 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 4f0a6abb4b..5500f5a587 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 6ab2ba6f48..034d689d42 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 0f5063faeb..addae6a385 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(); - }