diff --git a/asm/battle_1.s b/asm/battle_1.s index 9665b0d11..379f38515 100644 --- a/asm/battle_1.s +++ b/asm/battle_1.s @@ -1433,13 +1433,13 @@ DrawMainBattleBackground: @ 8035770 ands r0, r1 cmp r0, 0 beq _080357B0 - ldr r0, =gUnknown_08D7C440 + ldr r0, =gBattleTerrainTiles_Building ldr r1, =0x06008000 bl LZDecompressVram ldr r0, =gUnknown_08D7CA28 ldr r1, =0x0600d000 bl LZDecompressVram - ldr r0, =gUnknown_08D7C9EC + ldr r0, =gBattleTerrainPalette_Frontier b _08035A52 .pool _080357B0: @@ -1502,7 +1502,7 @@ _0803584C: ldrb r0, [r0, 0x1] cmp r0, 0x20 bne _08035898 - ldr r0, =gUnknown_08D7C440 + ldr r0, =gBattleTerrainTiles_Building ldr r1, =0x06008000 bl LZDecompressVram ldr r0, =gUnknown_08D7CA28 @@ -1576,7 +1576,7 @@ _08035904: b _08035A52 .pool _08035950: - ldr r0, =gUnknown_08D7C440 + ldr r0, =gBattleTerrainTiles_Building ldr r1, =0x06008000 bl LZDecompressVram ldr r0, =gUnknown_08D7CA28 @@ -1650,13 +1650,13 @@ _08035A52: b _08035A8A .pool _08035A70: - ldr r0, =gUnknown_08D7C440 + ldr r0, =gBattleTerrainTiles_Building ldr r1, =0x06008000 bl LZDecompressVram ldr r0, =gUnknown_08D7CA28 ldr r1, =0x0600d000 bl LZDecompressVram - ldr r0, =gUnknown_08D7C9EC + ldr r0, =gBattleTerrainPalette_Frontier movs r1, 0x20 movs r2, 0x60 bl LoadCompressedPalette @@ -2813,7 +2813,7 @@ _08036510: b _0803651A .pool _08036518: - ldr r0, =gUnknown_08D7C440 + ldr r0, =gBattleTerrainTiles_Building _0803651A: ldr r1, =0x06008000 bl LZDecompressVram @@ -3043,7 +3043,7 @@ _08036738: b _08036742 .pool _08036740: - ldr r0, =gUnknown_08D7C9EC + ldr r0, =gBattleTerrainPalette_Frontier _08036742: movs r1, 0x20 movs r2, 0x60 diff --git a/asm/berry_tag_screen.s b/asm/berry_tag_screen.s index 422f5f3d6..75e50f88d 100644 --- a/asm/berry_tag_screen.s +++ b/asm/berry_tag_screen.s @@ -115,7 +115,7 @@ _08177CD8: .4byte _08177DC2 _08177D18: bl SetVBlankHBlankCallbacksToNull - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs bl clear_scheduled_bg_copies_to_vram b _08177DDC _08177D26: @@ -246,7 +246,7 @@ sub_8177E14: @ 8177E14 adds r1, r0 movs r0, 0x3 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0x2 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x3 diff --git a/asm/item_menu.s b/asm/item_menu.s index 61bd5c6e9..b762e8fed 100755 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -568,7 +568,7 @@ _081AB046: thumb_func_start bag_menu_init_bgs bag_menu_init_bgs: @ 81AB050 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs ldr r4, =gUnknown_0203CE54 ldr r0, [r4] adds r0, 0x4 @@ -586,7 +586,7 @@ bag_menu_init_bgs: @ 81AB050 adds r1, 0x4 movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0x2 bl schedule_bg_copy_tilemap_to_vram movs r1, 0x82 diff --git a/asm/learn_move.s b/asm/learn_move.s index 159b16f7e..6d500d7f6 100755 --- a/asm/learn_move.s +++ b/asm/learn_move.s @@ -175,14 +175,14 @@ sub_8160740: @ 8160740 thumb_func_start sub_81607EC sub_81607EC: @ 81607EC push {lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_085CEC28 movs r0, 0 movs r2, 0x2 bl InitBgsFromTemplates - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r1, 0x82 lsls r1, 5 movs r0, 0 diff --git a/asm/menu_helpers.s b/asm/menu_helpers.s index 423f653d9..c21ddee78 100644 --- a/asm/menu_helpers.s +++ b/asm/menu_helpers.s @@ -5,8 +5,8 @@ .text - thumb_func_start sub_8121DA0 -sub_8121DA0: @ 8121DA0 + thumb_func_start ResetVramOamAndBgCntRegs +ResetVramOamAndBgCntRegs: @ 8121DA0 push {r4,lr} sub sp, 0xC movs r0, 0 @@ -50,10 +50,10 @@ sub_8121DA0: @ 8121DA0 pop {r0} bx r0 .pool - thumb_func_end sub_8121DA0 + thumb_func_end ResetVramOamAndBgCntRegs - thumb_func_start sub_8121E10 -sub_8121E10: @ 8121E10 + thumb_func_start ResetAllBgsCoordinates +ResetAllBgsCoordinates: @ 8121E10 push {lr} movs r0, 0 movs r1, 0 @@ -89,7 +89,7 @@ sub_8121E10: @ 8121E10 bl ChangeBgY pop {r0} bx r0 - thumb_func_end sub_8121E10 + thumb_func_end ResetAllBgsCoordinates thumb_func_start SetVBlankHBlankCallbacksToNull @ void SetVBlankHBlankCallbacksToNull() @@ -177,8 +177,8 @@ _08121EC0: .pool thumb_func_end DisplayMessageAndContinueTask - thumb_func_start sub_8121F20 -sub_8121F20: @ 8121F20 + thumb_func_start RunTextPrintersRetIsActive +RunTextPrintersRetIsActive: @ 8121F20 push {r4,lr} adds r4, r0, 0 lsls r4, 24 @@ -191,7 +191,7 @@ sub_8121F20: @ 8121F20 pop {r4} pop {r1} bx r1 - thumb_func_end sub_8121F20 + thumb_func_end RunTextPrintersRetIsActive thumb_func_start Task_ContinueTaskAfterMessagePrints @ void Task_ContinueTaskAfterMessagePrints(u8 taskId) @@ -201,7 +201,7 @@ Task_ContinueTaskAfterMessagePrints: @ 8121F3C lsrs r4, r0, 24 ldr r0, =gUnknown_0203A140 ldrb r0, [r0] - bl sub_8121F20 + bl RunTextPrintersRetIsActive lsls r0, 16 cmp r0, 0 bne _08121F5A diff --git a/asm/party_menu.s b/asm/party_menu.s index 4ae689d4d..4214b06fc 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -98,7 +98,7 @@ _081B0234: .4byte _081B0474 _081B0290: bl SetVBlankHBlankCallbacksToNull - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs bl clear_scheduled_bg_copies_to_vram ldr r1, =gMain movs r0, 0x87 @@ -429,7 +429,7 @@ sub_81B0550: @ 81B0550 ldr r1, [r5] movs r0, 0x1 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0x1 bl schedule_bg_copy_tilemap_to_vram movs r1, 0x82 @@ -3161,7 +3161,7 @@ sub_81B1B8C: @ 81B1B8C lsrs r4, r0, 24 adds r5, r4, 0 movs r0, 0x6 - bl sub_8121F20 + bl RunTextPrintersRetIsActive lsls r0, 16 lsrs r0, 16 cmp r0, 0x1 diff --git a/asm/pokeblock_feed.s b/asm/pokeblock_feed.s index aef726c16..47e20f1a8 100644 --- a/asm/pokeblock_feed.s +++ b/asm/pokeblock_feed.s @@ -5,1132 +5,13 @@ .text - thumb_func_start sub_8179B68 -sub_8179B68: @ 8179B68 - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_8179B68 + - thumb_func_start sub_8179B84 -sub_8179B84: @ 8179B84 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8179B84 - - thumb_func_start sub_8179B98 -sub_8179B98: @ 8179B98 - push {r4,lr} - sub sp, 0x4 - ldr r0, =gMain - movs r1, 0x87 - lsls r1, 3 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xD - bls _08179BAC - b _08179D4C -_08179BAC: - lsls r0, 2 - ldr r1, =_08179BC0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08179BC0: - .4byte _08179BF8 - .4byte _08179C20 - .4byte _08179C34 - .4byte _08179C48 - .4byte _08179C4E - .4byte _08179C60 - .4byte _08179C66 - .4byte _08179C78 - .4byte _08179C98 - .4byte _08179CB0 - .4byte _08179CDC - .4byte _08179CF8 - .4byte _08179CFE - .4byte _08179D18 -_08179BF8: - ldr r4, =gUnknown_0203BD18 - ldr r0, =0x00001084 - bl AllocZeroed - str r0, [r4] - bl SetVBlankHBlankCallbacksToNull - bl clear_scheduled_bg_copies_to_vram - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179C20: - bl ResetPaletteFade - ldr r2, =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - b _08179D30 - .pool -_08179C34: - bl ResetSpriteData - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179C48: - bl FreeAllSpritePalettes - b _08179D32 -_08179C4E: - bl AllocateMonSpritesGfx - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179C60: - bl sub_8179D9C - b _08179D32 -_08179C66: - bl sub_8179FAC - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179C78: - ldr r0, =gUnknown_0203BC9C - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - bl sub_8179DF4 - lsls r0, 24 - cmp r0, 0 - beq _08179D64 - b _08179D32 - .pool -_08179C98: - bl sub_817A4A4 - ldr r1, =gUnknown_0203BD18 - ldr r1, [r1] - ldr r2, =0x0000105e - adds r1, r2 - strb r0, [r1] - b _08179D32 - .pool -_08179CB0: - ldr r0, =gUnknown_0203BC9C - ldrb r1, [r0] - movs r0, 0x64 - muls r0, r1 - ldr r1, =gPlayerParty - adds r0, r1 - bl sub_817A358 - ldr r1, =gUnknown_0203BD18 - ldr r1, [r1] - ldr r2, =0x0000105d - adds r1, r2 - strb r0, [r1] - b _08179D32 - .pool -_08179CDC: - movs r0, 0 - movs r1, 0x1 - movs r2, 0x1 - movs r3, 0xE - bl SetWindowBorderStyle - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179CF8: - bl sub_817A168 - b _08179D32 -_08179CFE: - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _08179D3A - .pool -_08179D18: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 -_08179D30: - strb r0, [r2, 0x8] -_08179D32: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_08179D3A: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08179D64 - .pool -_08179D4C: - ldr r0, =sub_8179B84 - bl SetVBlankCallback - ldr r0, =sub_8179B68 - bl SetMainCallback2 - movs r0, 0x1 - b _08179D66 - .pool -_08179D64: - movs r0, 0 -_08179D66: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8179B98 - - thumb_func_start sub_8179D70 -sub_8179D70: @ 8179D70 - push {lr} -_08179D72: - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08179D96 - bl sub_8179B98 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08179D96 - bl sub_81221AC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08179D72 -_08179D96: - pop {r0} - bx r0 - thumb_func_end sub_8179D70 - - thumb_func_start sub_8179D9C -sub_8179D9C: @ 8179D9C - push {lr} - bl sub_8121DA0 - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085F0550 - movs r0, 0 - movs r2, 0x2 - bl InitBgsFromTemplates - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - adds r1, 0x48 - movs r0, 0x1 - bl SetBgTilemapBuffer - bl sub_8121E10 - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179D9C - - thumb_func_start sub_8179DF4 -sub_8179DF4: @ 8179DF4 - push {r4-r6,lr} - sub sp, 0x4 - adds r6, r0, 0 - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - ldr r1, =0x0000107e - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x8 - bls _08179E0C - b _08179FA0 -_08179E0C: - lsls r0, 2 - ldr r1, =_08179E24 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08179E24: - .4byte _08179E48 - .4byte _08179E84 - .4byte _08179EC4 - .4byte _08179ED8 - .4byte _08179EEC - .4byte _08179F00 - .4byte _08179F20 - .4byte _08179F44 - .4byte _08179F78 -_08179E48: - adds r0, r6, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r6, 0 - movs r1, 0 - bl GetMonData - adds r4, r0, 0 - lsls r0, r5, 3 - ldr r1, =gMonFrontPicTable - adds r0, r1 - ldr r1, =gMonSpritesGfxPtr - ldr r1, [r1] - ldr r1, [r1, 0x8] - adds r2, r5, 0 - adds r3, r4, 0 - bl HandleLoadSpecialPokePic_2 - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179E84: - adds r0, r6, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r6, 0 - movs r1, 0 - bl GetMonData - adds r4, r0, 0 - adds r0, r6, 0 - movs r1, 0x1 - bl GetMonData - adds r1, r0, 0 - adds r0, r5, 0 - adds r2, r4, 0 - bl GetMonSpritePalStructFromOtIdPersonality - adds r4, r0, 0 - bl LoadCompressedObjectPalette - ldrh r0, [r4, 0x4] - movs r1, 0x1 - bl sub_806A068 - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179EC4: - ldr r0, =gUnknown_085B26F4 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179ED8: - ldr r0, =gUnknown_085B26FC - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179EEC: - ldr r0, =gUnknown_085F06A0 - bl LoadCompressedObjectPic - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179F00: - ldr r0, =gSpecialVar_ItemId - ldrb r0, [r0] - bl sub_8179FEC - ldr r0, =gUnknown_0203BD1C - bl LoadCompressedObjectPalette - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179F20: - bl reset_temp_tile_data_buffers - ldr r1, =gUnknown_08D7C440 - movs r0, 0 - str r0, [sp] - movs r0, 0x1 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - b _08179F5E - .pool -_08179F44: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _08179FA0 - ldr r0, =gUnknown_08D9BA44 - ldr r4, =gUnknown_0203BD18 - ldr r1, [r4] - adds r1, 0x48 - bl LZDecompressWram - ldr r1, [r4] -_08179F5E: - ldr r0, =0x0000107e - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _08179FA0 - .pool -_08179F78: - ldr r0, =gUnknown_08D7C9EC - movs r1, 0x20 - movs r2, 0x60 - bl LoadCompressedPalette - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - ldr r1, =0x0000107e - adds r0, r1 - movs r1, 0 - strh r1, [r0] - movs r0, 0x1 - b _08179FA2 - .pool -_08179FA0: - movs r0, 0 -_08179FA2: - add sp, 0x4 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_8179DF4 - - thumb_func_start sub_8179FAC -sub_8179FAC: @ 8179FAC - push {lr} - ldr r0, =gUnknown_085F0558 - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - movs r1, 0x1 - movs r2, 0xE0 - bl sub_809882C - ldr r0, =gUnknown_0860F074 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r0, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179FAC - - thumb_func_start sub_8179FEC -sub_8179FEC: @ 8179FEC - push {lr} - lsls r0, 24 - ldr r1, =gSaveBlock1Ptr - lsrs r0, 21 - ldr r2, =0x00000848 - adds r0, r2 - ldr r1, [r1] - adds r1, r0 - adds r0, r1, 0 - movs r1, 0 - bl sub_8136F9C - lsls r0, 24 - ldr r2, =gUnknown_0203BD1C - ldr r1, =gUnknown_085F0568 - lsrs r0, 22 - subs r0, 0x4 - adds r0, r1 - ldr r0, [r0] - str r0, [r2] - ldr r0, =0x000039e2 - strh r0, [r2, 0x4] - pop {r0} - bx r0 - .pool - thumb_func_end sub_8179FEC - - thumb_func_start sub_817A030 -sub_817A030: @ 817A030 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _0817A044 - b _0817A154 -_0817A044: - ldr r0, =gTasks - lsls r2, r4, 2 - adds r1, r2, r4 - lsls r1, 3 - adds r1, r0 - movs r0, 0x8 - ldrsh r3, [r1, r0] - ldr r0, =0x0000010d - adds r5, r2, 0 - cmp r3, r0 - beq _0817A0C8 - cmp r3, r0 - bgt _0817A074 - cmp r3, 0 - beq _0817A088 - cmp r3, 0xFF - beq _0817A0AC - b _0817A104 - .pool -_0817A074: - ldr r0, =0x00000119 - cmp r3, r0 - beq _0817A0E0 - adds r0, 0x10 - cmp r3, r0 - beq _0817A0F8 - b _0817A104 - .pool -_0817A088: - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - ldr r2, =0x00001050 - adds r1, r2 - strb r3, [r1] - ldr r0, [r0] - ldr r1, =0x00001058 - adds r0, r1 - strh r3, [r0] - bl sub_817A5CC - b _0817A104 - .pool -_0817A0AC: - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - ldr r2, =0x0000105e - adds r0, r2 - ldrb r0, [r0] - ldrb r1, [r1, 0xA] - bl sub_817A4F8 - b _0817A104 - .pool -_0817A0C8: - bl sub_817A56C - ldr r1, =gUnknown_0203BD18 - ldr r1, [r1] - ldr r2, =0x0000105f - adds r1, r2 - strb r0, [r1] - b _0817A104 - .pool -_0817A0E0: - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - ldr r1, =0x0000105d - adds r0, r1 - ldrb r0, [r0] - bl sub_817A434 - b _0817A104 - .pool -_0817A0F8: - ldr r0, =sub_817A1C4 - str r0, [r1] - b _0817A154 - .pool -_0817A104: - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - ldr r2, =0x00001058 - adds r1, r0, r2 - subs r2, 0x2 - adds r0, r2 - ldrh r1, [r1] - ldrh r0, [r0] - cmp r1, r0 - bcs _0817A128 - bl sub_817A634 - b _0817A138 - .pool -_0817A128: - cmp r1, r0 - bne _0817A138 - ldr r0, =gTasks - adds r1, r5, r4 - lsls r1, 3 - adds r1, r0 - movs r0, 0xFE - strh r0, [r1, 0x8] -_0817A138: - ldr r0, =gUnknown_0203BD18 - ldr r1, [r0] - ldr r0, =0x00001058 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - ldr r0, =gTasks - adds r1, r5, r4 - lsls r1, 3 - adds r1, r0 - ldrh r0, [r1, 0x8] - adds r0, 0x1 - strh r0, [r1, 0x8] -_0817A154: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A030 - - thumb_func_start sub_817A168 -sub_817A168: @ 817A168 - push {lr} - ldr r0, =sub_817A030 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - movs r0, 0 - strh r0, [r1, 0x8] - movs r0, 0x1 - strh r0, [r1, 0xA] - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A168 - - thumb_func_start sub_817A194 -sub_817A194: @ 817A194 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - movs r0, 0 - bl sub_8121F20 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - beq _0817A1B6 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_817A320 - str r0, [r1] -_0817A1B6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A194 - - thumb_func_start sub_817A1C4 -sub_817A1C4: @ 817A1C4 - push {r4-r7,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r7, r0, 24 - ldr r0, =gUnknown_0203BC9C - ldrb r1, [r0] - movs r0, 0x64 - adds r5, r1, 0 - muls r5, r0 - ldr r0, =gPlayerParty - adds r5, r0 - ldr r1, =gSaveBlock1Ptr - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - lsls r0, 3 - ldr r2, =0x00000848 - adds r0, r2 - ldr r4, [r1] - adds r4, r0 - adds r0, r5, 0 - bl GetNature - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - bl PokeblockGetGain - ldr r6, =gUnknown_0203BC9E - strh r0, [r6] - ldr r1, =gStringVar1 - adds r0, r5, 0 - bl GetMonNickname - ldr r1, =gStringVar2 - adds r0, r4, 0 - bl sub_8137044 - movs r1, 0 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0817A248 - ldr r0, =gStringVar4 - ldr r1, =gText_Var1AteTheVar2 - bl StringExpandPlaceholders - b _0817A268 - .pool -_0817A248: - cmp r0, 0 - ble _0817A260 - ldr r0, =gStringVar4 - ldr r1, =gText_Var1HappilyAteVar2 - bl StringExpandPlaceholders - b _0817A268 - .pool -_0817A260: - ldr r0, =gStringVar4 - ldr r1, =gText_Var1DisdainfullyAteVar2 - bl StringExpandPlaceholders -_0817A268: - ldr r2, =gTextFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - bl GetPlayerTextSpeed - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - ldr r2, =gStringVar4 - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - str r0, [sp, 0x4] - movs r0, 0x1 - str r0, [sp, 0x8] - movs r0, 0x3 - str r0, [sp, 0xC] - movs r0, 0 - movs r1, 0x1 - bl AddTextPrinterParametrized - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_817A194 - str r1, [r0] - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A1C4 - - thumb_func_start sub_817A2C0 -sub_817A2C0: @ 817A2C0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0817A304 - bl ResetSpriteData - bl FreeAllSpritePalettes - ldr r0, =gMPlay_BGM - ldr r1, =0x0000ffff - movs r2, 0x80 - lsls r2, 1 - bl m4aMPlayVolumeControl - ldr r0, =gMain - ldr r0, [r0, 0x8] - bl SetMainCallback2 - adds r0, r4, 0 - bl DestroyTask - bl FreeAllWindowBuffers - ldr r0, =gUnknown_0203BD18 - ldr r0, [r0] - bl Free - bl FreeMonSpritesGfx -_0817A304: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A2C0 - - thumb_func_start sub_817A320 -sub_817A320: @ 817A320 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_817A2C0 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A320 - - thumb_func_start sub_817A358 -sub_817A358: @ 817A358 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r5, r0, 0 - movs r1, 0x41 - bl GetMonData - adds r4, r0, 0 - lsls r4, 16 - lsrs r4, 16 - ldr r0, =gUnknown_0202499C - movs r1, 0x30 - movs r2, 0x50 - movs r3, 0x2 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =gUnknown_0203BD18 - mov r9, r0 - ldr r0, [r0] - ldr r2, =0x00001054 - adds r1, r0, r2 - strh r4, [r1] - ldr r1, =0x0000105b - adds r0, r1 - mov r2, r8 - strb r2, [r0] - adds r0, r5, 0 - bl GetNature - mov r2, r9 - ldr r1, [r2] - ldr r2, =0x0000105a - adds r1, r2 - strb r0, [r1] - ldr r7, =gSprites - mov r1, r8 - lsls r0, r1, 4 - add r0, r8 - lsls r5, r0, 2 - adds r6, r5, r7 - strh r4, [r6, 0x32] - adds r0, r7, 0 - adds r0, 0x1C - adds r0, r5, r0 - ldr r1, =SpriteCallbackDummy - str r1, [r0] - mov r2, r9 - ldr r0, [r2] - ldr r1, =0x00001053 - adds r0, r1 - movs r1, 0x1 - strb r1, [r0] - adds r0, r4, 0 - bl IsPokeSpriteNotFlipped - lsls r0, 24 - cmp r0, 0 - bne _0817A402 - adds r0, r7, 0 - adds r0, 0x10 - adds r0, r5, r0 - ldr r1, =gUnknown_085F05B0 - str r1, [r0] - ldrb r3, [r6, 0x1] - movs r0, 0x3 - orrs r3, r0 - strb r3, [r6, 0x1] - lsrs r1, r3, 6 - ldrb r2, [r6, 0x3] - lsrs r2, 6 - lsls r3, 30 - lsrs r3, 30 - adds r0, r6, 0 - bl CalcCenterToCornerVec - mov r2, r9 - ldr r0, [r2] - ldr r1, =0x00001053 - adds r0, r1 - movs r1, 0 - strb r1, [r0] -_0817A402: - mov r0, r8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end sub_817A358 - - thumb_func_start sub_817A434 -sub_817A434: @ 817A434 - lsls r0, 24 - lsrs r0, 24 - ldr r3, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r2, r1, r3 - movs r0, 0x30 - strh r0, [r2, 0x20] - movs r0, 0x50 - strh r0, [r2, 0x22] - ldr r0, =0x0000fff8 - strh r0, [r2, 0x2E] - movs r0, 0x1 - strh r0, [r2, 0x30] - adds r3, 0x1C - adds r1, r3 - ldr r0, =sub_817A468 - str r0, [r1] - bx lr - .pool - thumb_func_end sub_817A434 - - thumb_func_start sub_817A468 -sub_817A468: @ 817A468 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x20] - adds r0, 0x4 - strh r0, [r4, 0x20] - ldrh r0, [r4, 0x2E] - ldrh r2, [r4, 0x22] - adds r1, r0, r2 - strh r1, [r4, 0x22] - ldrh r1, [r4, 0x30] - adds r0, r1 - strh r0, [r4, 0x2E] - lsls r0, 16 - cmp r0, 0 - bne _0817A48E - ldrh r0, [r4, 0x32] - movs r1, 0 - bl PlayCry1 -_0817A48E: - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0x9 - bne _0817A49A - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_0817A49A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A468 - - thumb_func_start sub_817A4A4 -sub_817A4A4: @ 817A4A4 - push {r4,r5,lr} - movs r0, 0xBC - movs r1, 0x64 - movs r2, 0x2 - bl sub_8136444 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gSprites - lsls r3, r4, 4 - adds r3, r4 - lsls r3, 2 - adds r0, r3, r5 - ldrb r2, [r0, 0x1] - movs r1, 0x4 - negs r1, r1 - ands r1, r2 - movs r2, 0x1 - orrs r1, r2 - strb r1, [r0, 0x1] - adds r1, r5, 0 - adds r1, 0x10 - adds r1, r3, r1 - ldr r2, =gUnknown_085F0664 - str r2, [r1] - adds r5, 0x1C - adds r3, r5 - ldr r1, =SpriteCallbackDummy - str r1, [r3] - bl InitSpriteAffineAnim - adds r0, r4, 0 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_817A4A4 - - thumb_func_start sub_817A4F8 -sub_817A4F8: @ 817A4F8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r1, 0 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gSprites - mov r8, r0 - lsls r0, r7, 4 - adds r0, r7 - lsls r6, r0, 2 - mov r0, r8 - adds r4, r6, r0 - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix - ldrb r0, [r4, 0x1] - movs r1, 0x3 - orrs r0, r1 - strb r0, [r4, 0x1] - cmp r5, 0 - bne _0817A540 - mov r0, r8 - adds r0, 0x10 - adds r0, r6, r0 - ldr r1, =gUnknown_085F0668 - b _0817A548 - .pool -_0817A540: - mov r0, r8 - adds r0, 0x10 - adds r0, r6, r0 - ldr r1, =gUnknown_085F066C -_0817A548: - str r1, [r0] - lsls r0, r7, 4 - adds r0, r7 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl InitSpriteAffineAnim - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_817A4F8 - - thumb_func_start sub_817A56C -sub_817A56C: @ 817A56C - push {lr} - ldr r0, =gUnknown_085F06A8 - movs r1, 0xAE - movs r2, 0x54 - movs r3, 0x1 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldr r2, =0x0000fff4 - strh r2, [r1, 0x2E] - movs r2, 0x1 - strh r2, [r1, 0x30] - pop {r1} - bx r1 - .pool - thumb_func_end sub_817A56C - - thumb_func_start sub_817A5A0 -sub_817A5A0: @ 817A5A0 - push {lr} - adds r2, r0, 0 - ldrh r0, [r2, 0x20] - subs r0, 0x4 - strh r0, [r2, 0x20] - ldrh r0, [r2, 0x2E] - ldrh r3, [r2, 0x22] - adds r1, r0, r3 - strh r1, [r2, 0x22] - ldrh r1, [r2, 0x30] - adds r0, r1 - strh r0, [r2, 0x2E] - lsls r0, 16 - asrs r0, 16 - cmp r0, 0xA - bne _0817A5C6 - adds r0, r2, 0 - bl DestroySprite -_0817A5C6: - pop {r0} - bx r0 - thumb_func_end sub_817A5A0 thumb_func_start sub_817A5CC sub_817A5CC: @ 817A5CC push {r4-r7,lr} - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r1, [r0] ldr r0, =0x00001056 adds r3, r1, r0 @@ -1179,7 +60,7 @@ _0817A61A: thumb_func_start sub_817A634 sub_817A634: @ 817A634 push {r4,lr} - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r4, [r0] ldr r1, =0x00001050 adds r0, r4, r1 @@ -1432,7 +313,7 @@ _0817A90E: thumb_func_start sub_817A91C sub_817A91C: @ 817A91C push {r4-r7,lr} - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r5, [r0] movs r4, 0 movs r0, 0x83 @@ -1521,7 +402,7 @@ _0817A9DE: thumb_func_start sub_817A9E4 sub_817A9E4: @ 817A9E4 push {r4,r5,lr} - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r2, [r0] ldr r1, =0x00001078 adds r0, r2, r1 @@ -1566,7 +447,7 @@ _0817AA36: thumb_func_start sub_817AA3C sub_817AA3C: @ 817AA3C push {lr} - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r0, [r0] ldr r0, [r0] bl FreeSpriteOamMatrix @@ -1584,7 +465,7 @@ sub_817AA54: @ 817AA54 mov r5, r8 push {r5-r7} sub sp, 0x14 - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r7, [r0] ldr r1, =0x00001070 adds r0, r7, r1 @@ -1717,7 +598,7 @@ sub_817AB68: @ 817AB68 mov r5, r8 push {r5-r7} sub sp, 0x8 - ldr r0, =gUnknown_0203BD18 + ldr r0, =sPokeblockFeed ldr r6, [r0] movs r0, 0 str r0, [sp] diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index 4441767db..1f9d25c12 100755 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -2351,7 +2351,7 @@ _081C51D6: thumb_func_start sub_81C51DC sub_81C51DC: @ 81C51DC push {lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0861F2B4 @@ -2363,7 +2363,7 @@ sub_81C51DC: @ 81C51DC adds r1, 0x4 movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0x2 bl schedule_bg_copy_tilemap_to_vram movs r1, 0x82 diff --git a/asm/rayquaza_scene.s b/asm/rayquaza_scene.s index f9936f1ca..58380a354 100755 --- a/asm/rayquaza_scene.s +++ b/asm/rayquaza_scene.s @@ -1066,7 +1066,7 @@ sub_81D6FD0: @ 81D6FD0 thumb_func_start sub_81D6FE0 sub_81D6FE0: @ 81D6FE0 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0862A888 @@ -1088,7 +1088,7 @@ sub_81D6FE0: @ 81D6FE0 adds r1, r0 movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x1 @@ -2758,7 +2758,7 @@ _081D7E08: thumb_func_start sub_81D7E10 sub_81D7E10: @ 81D7E10 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0862AA54 @@ -2780,7 +2780,7 @@ sub_81D7E10: @ 81D7E10 adds r1, r0 movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x1 @@ -3292,7 +3292,7 @@ _081D829A: thumb_func_start sub_81D82B0 sub_81D82B0: @ 81D82B0 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0862AACC @@ -3319,7 +3319,7 @@ sub_81D82B0: @ 81D82B0 adds r1, r0 movs r0, 0x3 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x1 @@ -3899,7 +3899,7 @@ _081D8818: thumb_func_start sub_81D8828 sub_81D8828: @ 81D8828 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0862AB44 @@ -3926,7 +3926,7 @@ sub_81D8828: @ 81D8828 adds r1, r0 movs r0, 0x3 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x1 @@ -4354,7 +4354,7 @@ _081D8C26: thumb_func_start sub_81D8C38 sub_81D8C38: @ 81D8C38 push {r4,lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_0862AD08 @@ -4376,7 +4376,7 @@ sub_81D8C38: @ 81D8C38 adds r1, r0 movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0 bl schedule_bg_copy_tilemap_to_vram movs r0, 0x1 diff --git a/asm/rom6.s b/asm/rom6.s index 430ed7ee9..b37a01c1f 100644 --- a/asm/rom6.s +++ b/asm/rom6.s @@ -728,7 +728,7 @@ _08135A9A: movs r0, 0x38 movs r1, 0x40 movs r2, 0 - bl sub_8136444 + bl CreatePokeblockCaseSprite ldr r1, =gUnknown_0203AB50 ldr r1, [r1] ldr r2, =0x00000e74 @@ -859,7 +859,7 @@ _08135BD2: thumb_func_start sub_8135BDC sub_8135BDC: @ 8135BDC push {lr} - bl sub_8121DA0 + bl ResetVramOamAndBgCntRegs movs r0, 0 bl ResetBgsAndClearDma3BusyFlags ldr r1, =gUnknown_085B2620 @@ -870,7 +870,7 @@ sub_8135BDC: @ 8135BDC ldr r1, [r0] movs r0, 0x2 bl SetBgTilemapBuffer - bl sub_8121E10 + bl ResetAllBgsCoordinates movs r0, 0x2 bl schedule_bg_copy_tilemap_to_vram movs r1, 0x82 @@ -949,12 +949,12 @@ _08135CBC: b _08135CDE .pool _08135CCC: - ldr r0, =gUnknown_085B26F4 + ldr r0, =gPokeblockCase_SpriteSheet bl LoadCompressedObjectPic b _08135CDE .pool _08135CD8: - ldr r0, =gUnknown_085B26FC + ldr r0, =gPokeblockCase_SpritePal bl LoadCompressedObjectPalette _08135CDE: ldr r0, =gUnknown_0203AB50 @@ -1313,7 +1313,7 @@ _08136002: lsls r1, r4, 24 lsrs r1, 24 mov r0, r8 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 16 adds r7, r4, 0 cmp r0, 0 @@ -1842,8 +1842,8 @@ _08136436: .pool thumb_func_end sub_8136418 - thumb_func_start sub_8136444 -sub_8136444: @ 8136444 + thumb_func_start CreatePokeblockCaseSprite +CreatePokeblockCaseSprite: @ 8136444 push {r4,r5,lr} adds r4, r0, 0 adds r5, r1, 0 @@ -1864,7 +1864,7 @@ sub_8136444: @ 8136444 pop {r1} bx r1 .pool - thumb_func_end sub_8136444 + thumb_func_end CreatePokeblockCaseSprite thumb_func_start sub_8136470 sub_8136470: @ 8136470 @@ -2549,7 +2549,7 @@ sub_8136A74: @ 8136A74 ldr r0, [r2] adds r0, r1 ldr r1, =sub_8136AA0 - bl sub_8166204 + bl ChooseMonToGivePokeblock pop {r0} bx r0 .pool @@ -3000,7 +3000,7 @@ GetHighestPokeblocksFlavorLevel: @ 8136EA4 push {r4-r6,lr} adds r6, r0, 0 movs r1, 0x1 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 24 lsrs r5, r0, 24 movs r1, 0x1 @@ -3010,7 +3010,7 @@ _08136EB4: lsrs r4, r0, 24 adds r0, r6, 0 adds r1, r4, 0 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 24 lsrs r0, 24 cmp r5, r0 @@ -3030,7 +3030,7 @@ _08136ECC: GetPokeblocksFeel: @ 8136EDC push {lr} movs r1, 0x6 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 24 lsrs r0, 24 cmp r0, 0x63 @@ -3130,8 +3130,8 @@ _08136F96: bx r1 thumb_func_end sub_8136F68 - thumb_func_start sub_8136F9C -sub_8136F9C: @ 8136F9C + thumb_func_start GetPokeblockData +GetPokeblockData: @ 8136F9C push {lr} lsls r1, 24 lsrs r1, 24 @@ -3175,7 +3175,7 @@ _08136FDC: _08136FDE: pop {r1} bx r1 - thumb_func_end sub_8136F9C + thumb_func_end GetPokeblockData thumb_func_start PokeblockGetGain PokeblockGetGain: @ 8136FE4 @@ -3198,7 +3198,7 @@ _08136FFE: lsrs r5, r0, 24 mov r0, r8 adds r1, r5, 0 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 16 asrs r1, r0, 16 cmp r1, 0 @@ -3229,12 +3229,12 @@ _0813702A: .pool thumb_func_end PokeblockGetGain - thumb_func_start sub_8137044 -sub_8137044: @ 8137044 + thumb_func_start PokeblockCopyName +PokeblockCopyName: @ 8137044 push {r4,lr} adds r4, r1, 0 movs r1, 0 - bl sub_8136F9C + bl GetPokeblockData lsls r0, 24 ldr r1, =gPokeblockNames lsrs r0, 22 @@ -3246,7 +3246,7 @@ sub_8137044: @ 8137044 pop {r0} bx r0 .pool - thumb_func_end sub_8137044 + thumb_func_end PokeblockCopyName thumb_func_start sub_8137068 sub_8137068: @ 8137068 @@ -3298,13 +3298,13 @@ _081370BC: lsls r1, 24 lsrs r1, 24 adds r0, r5, 0 - bl sub_8136F9C + bl GetPokeblockData adds r4, r0, 0 adds r1, r6, 0x1 lsls r1, 24 lsrs r1, 24 adds r0, r5, 0 - bl sub_8136F9C + bl GetPokeblockData lsls r4, 16 lsls r0, 16 lsls r1, r6, 16 diff --git a/asm/roulette.s b/asm/roulette.s index 009f30717..85d857f39 100644 --- a/asm/roulette.s +++ b/asm/roulette.s @@ -425,8 +425,8 @@ _08140618: bl SetVBlankCallback bl remove_some_task bl SetVBlankHBlankCallbacksToNull - bl sub_8121DA0 - bl sub_8121E10 + bl ResetVramOamAndBgCntRegs + bl ResetAllBgsCoordinates b _081407F8 _08140630: bl sub_8140388 @@ -3258,8 +3258,8 @@ sub_8141E7C: @ 8141E7C ldr r0, =gSpriteCoordOffsetY strh r4, [r0] strh r4, [r1] - bl sub_8121DA0 - bl sub_8121E10 + bl ResetVramOamAndBgCntRegs + bl ResetAllBgsCoordinates movs r0, 0x50 movs r1, 0 bl SetGpuReg diff --git a/asm/use_pokeblock.s b/asm/use_pokeblock.s index 4e278a22a..2e96b214a 100755 --- a/asm/use_pokeblock.s +++ b/asm/use_pokeblock.s @@ -6,325 +6,9 @@ .text - thumb_func_start sub_816624C -sub_816624C: @ 816624C - push {r4,r5,lr} - ldr r4, =gUnknown_0203BCAC - ldr r0, =0x0000806c - bl AllocZeroed - str r0, [r4] - ldr r5, =gUnknown_0203BC90 - ldr r1, =0x00007fd0 - adds r0, r1 - str r0, [r5] - ldr r1, =gUnknown_0203BC98 - ldr r1, [r1] - str r1, [r0, 0x8] - ldr r1, =gUnknown_0203BC94 - ldr r1, [r1] - str r1, [r0, 0x4] - ldr r4, =gUnknown_0203BC9C - ldrb r0, [r4] - bl sub_81672E4 - strb r0, [r4] - ldr r5, [r5] - movs r1, 0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x3 - bls _08166284 - movs r1, 0x1 -_08166284: - adds r0, r5, 0 - adds r0, 0x56 - strb r1, [r0] - ldr r0, =sub_8166380 - bl sub_816636C - ldr r0, =sub_81662C0 - bl SetMainCallback2 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816624C - thumb_func_start sub_81662C0 -sub_81662C0: @ 81662C0 - push {r4,lr} - ldr r4, =gUnknown_0203BC90 - ldr r0, [r4] - ldr r0, [r0] - bl _call_via_r0 - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - ldr r4, [r4] - ldr r1, [r4] - ldr r0, =map_warp_consider_1_to_outside_or_stair_or_dive - cmp r1, r0 - bne _081662F0 - adds r0, r4, 0 - adds r0, 0x50 - movs r1, 0 - strb r1, [r0] - ldr r0, =sub_8166304 - bl SetMainCallback2 -_081662F0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81662C0 - - thumb_func_start sub_8166304 -sub_8166304: @ 8166304 - push {lr} - bl sub_81668F8 - bl AnimateSprites - bl BuildOamBuffer - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end sub_8166304 - - thumb_func_start sub_816631C -sub_816631C: @ 816631C - push {lr} - ldr r0, =gUnknown_0203BC90 - ldr r0, [r0] - ldr r0, [r0] - bl _call_via_r0 - bl AnimateSprites - bl BuildOamBuffer - bl RunTextPrinters - bl UpdatePaletteFade - pop {r0} - bx r0 - .pool - thumb_func_end sub_816631C - - thumb_func_start sub_8166340 -sub_8166340: @ 8166340 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007c58 - adds r0, r1 - bl sub_81D2108 - bl sub_80BA0A8 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166340 - - thumb_func_start sub_816636C -sub_816636C: @ 816636C - ldr r1, =gUnknown_0203BC90 - ldr r1, [r1] - str r0, [r1] - adds r1, 0x50 - movs r0, 0 - strb r0, [r1] - bx lr - .pool - thumb_func_end sub_816636C - - thumb_func_start sub_8166380 -sub_8166380: @ 8166380 - push {r4,r5,lr} - sub sp, 0x4 - ldr r1, =gUnknown_0203BC90 - ldr r0, [r1] - adds r0, 0x50 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0xF - bls _08166394 - b _08166556 -_08166394: - lsls r0, 2 - ldr r1, =_081663A8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081663A8: - .4byte _081663E8 - .4byte _0816640C - .4byte _08166416 - .4byte _08166434 - .4byte _08166464 - .4byte _08166468 - .4byte _08166474 - .4byte _08166484 - .4byte _08166490 - .4byte _0816649C - .4byte _081664B8 - .4byte _081664BC - .4byte _081664E4 - .4byte _08166510 - .4byte _08166528 - .4byte _08166550 -_081663E8: - ldr r2, =gUnknown_0203BCAC - ldr r0, [r2] - ldr r1, =0x00007b10 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldr r0, [r2] - ldr r2, =0x00007c58 - adds r0, r2 - bl sub_81D1ED4 - b _0816653C - .pool -_0816640C: - bl ResetSpriteData - bl FreeAllSpritePalettes - b _0816653C -_08166416: - movs r0, 0 - bl SetVBlankCallback - movs r0, 0 - str r0, [sp] - movs r1, 0xC0 - lsls r1, 19 - ldr r2, =0x05006000 - mov r0, sp - bl CpuSet - b _0816653C - .pool -_08166434: - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_085DFCCC - movs r0, 0 - movs r2, 0x4 - bl InitBgsFromTemplates - ldr r0, =gUnknown_085DFCDC - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - movs r1, 0x97 - movs r2, 0xE0 - bl sub_809882C - b _0816653C - .pool -_08166464: - ldr r1, [r2] - b _08166540 -_08166468: - bl sub_8168328 - lsls r0, 24 - cmp r0, 0 - bne _08166556 - b _0816653C -_08166474: - ldr r1, =gKeyRepeatStartDelay - movs r0, 0x14 - strh r0, [r1] - bl sub_8167420 - b _0816653C - .pool -_08166484: - bl sub_8167930 - lsls r0, 24 - cmp r0, 0 - bne _08166556 - b _0816653C -_08166490: - movs r0, 0 - bl sub_8167608 - bl sub_8167760 - b _0816653C -_0816649C: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r1, =0x00007b0e - adds r0, r1 - bl sub_81D312C - lsls r0, 24 - cmp r0, 0 - bne _08166556 - b _0816653C - .pool -_081664B8: - ldr r1, [r2] - b _08166540 -_081664BC: - ldr r5, =gUnknown_0203BCAC - ldr r1, [r5] - ldr r4, =0x00007c58 - adds r0, r1, r4 - ldr r2, =0x00007c6c - adds r1, r2 - bl sub_81D2754 - ldr r0, [r5] - adds r0, r4 - bl sub_81D20AC - b _0816653C - .pool -_081664E4: - ldr r4, =gUnknown_0203BCAC - ldr r0, [r4] - ldr r1, =0x00007c58 - adds r0, r1 - bl sub_81D20BC - lsls r0, 24 - cmp r0, 0 - bne _08166556 - ldr r2, [r4] - ldr r1, =0x00007c58 - adds r0, r2, r1 - adds r1, 0x14 - adds r2, r1 - adds r1, r2, 0 - bl sub_81D1F84 - b _0816653C - .pool -_08166510: - ldr r0, =gUnknown_0203BCAC - ldr r0, [r0] - ldr r2, =0x00007c58 - adds r0, r2 - bl sub_81D2230 - b _0816653C - .pool -_08166528: - movs r0, 0 - bl PutWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0 - movs r1, 0x1 - bl sub_8167BA0 -_0816653C: - ldr r0, =gUnknown_0203BC90 - ldr r1, [r0] -_08166540: - adds r1, 0x50 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _08166556 - .pool -_08166550: - ldr r0, =map_warp_consider_1_to_outside_or_stair_or_dive - bl sub_816636C -_08166556: - add sp, 0x4 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8166380 - - thumb_func_start map_warp_consider_1_to_outside_or_stair_or_dive -map_warp_consider_1_to_outside_or_stair_or_dive: @ 8166564 + thumb_func_start sub_8166564 +sub_8166564: @ 8166564 push {r4,lr} sub sp, 0x4 ldr r4, =gUnknown_0203BC90 @@ -407,7 +91,7 @@ _08166610: pop {r0} bx r0 .pool - thumb_func_end map_warp_consider_1_to_outside_or_stair_or_dive + thumb_func_end sub_8166564 thumb_func_start sub_8166634 sub_8166634: @ 8166634 @@ -632,7 +316,7 @@ _08166838: adds r0, r1 ldrb r0, [r0] bl sub_81672A4 - ldr r1, =gUnknown_0203BC9C + ldr r1, =gPokeblockMonId strb r0, [r1] ldr r1, =gUnknown_0203BC94 ldr r2, [r5] @@ -684,9 +368,9 @@ _08166888: str r5, [r4] bl FreeAllWindowBuffers ldr r1, =gMain - ldr r0, =sub_816624C + ldr r0, =CB2_ReturnAndChooseMonToGivePokeblock str r0, [r1, 0x8] - bl sub_8179D70 + bl CB2_PreparePokeblockFeedScene _081668D4: add sp, 0x4 pop {r4,r5} @@ -728,7 +412,7 @@ _0816693C: ldr r0, [r0] ldr r1, =0x00008041 adds r0, r1 - ldr r1, =gUnknown_0203BC9C + ldr r1, =gPokeblockMonId ldrb r0, [r0] ldrb r1, [r1] cmp r0, r1 @@ -1695,7 +1379,7 @@ sub_8167184: @ 8167184 adds r0, r3, 0 adds r0, 0x6E strh r1, [r0] - ldr r0, =gUnknown_0203BC9E + ldr r0, =gPokeblockGain movs r1, 0 ldrsh r0, [r0, r1] cmp r0, 0 diff --git a/data/data2b.s b/data/data2b.s index e723b4c97..a08461825 100644 --- a/data/data2b.s +++ b/data/data2b.s @@ -4803,14 +4803,14 @@ gBattleTerrainTable:: @ 831ABA8 .4byte gUnknown_08D7C10C @ building - .4byte gUnknown_08D7C440 + .4byte gBattleTerrainTiles_Building .4byte gUnknown_08D7CA28 .4byte gUnknown_08D820D4 .4byte gUnknown_08D824E4 .4byte gUnknown_08D7DEB4 @ plain - .4byte gUnknown_08D7C440 + .4byte gBattleTerrainTiles_Building .4byte gUnknown_08D7CA28 .4byte gUnknown_08D820D4 .4byte gUnknown_08D824E4 diff --git a/data/data4c.s b/data/data4c.s index b86cd2add..d6580c085 100644 --- a/data/data4c.s +++ b/data/data4c.s @@ -68,10 +68,10 @@ gUnknown_085B26A4:: @ 85B26A4 gUnknown_085B26F0:: @ 85B26F0 .incbin "baserom.gba", 0x5b26f0, 0x4 -gUnknown_085B26F4:: @ 85B26F4 +gPokeblockCase_SpriteSheet:: @ 85B26F4 .incbin "baserom.gba", 0x5b26f4, 0x8 -gUnknown_085B26FC:: @ 85B26FC +gPokeblockCase_SpritePal:: @ 85B26FC .incbin "baserom.gba", 0x5b26fc, 0x8 gUnknown_085B2704:: @ 85B2704 diff --git a/data/graphics.s b/data/graphics.s index 72daf144f..7296ed0cc 100644 --- a/data/graphics.s +++ b/data/graphics.s @@ -331,10 +331,10 @@ gUnknown_08D7C154:: @ 8D7C154 gUnknown_08D7C404:: @ 8D7C404 .incbin "baserom.gba", 0xd7c404, 0x3c -gUnknown_08D7C440:: @ 8D7C440 +gBattleTerrainTiles_Building:: @ 8D7C440 .incbin "baserom.gba", 0xd7c440, 0x5ac -gUnknown_08D7C9EC:: @ 8D7C9EC +gBattleTerrainPalette_Frontier:: @ 8D7C9EC .incbin "baserom.gba", 0xd7c9ec, 0x3c gUnknown_08D7CA28:: @ 8D7CA28 diff --git a/data/pokeblock_feed.s b/data/pokeblock_feed.s index b4d3d192d..bbb429b03 100644 --- a/data/pokeblock_feed.s +++ b/data/pokeblock_feed.s @@ -21,23 +21,23 @@ gUnknown_085F0550:: @ 85F0550 gUnknown_085F0558:: @ 85F0558 .incbin "baserom.gba", 0x5f0558, 0x10 -gUnknown_085F0568:: @ 85F0568 +sPokeblocksPals:: @ 85F0568 .incbin "baserom.gba", 0x5f0568, 0x48 -gUnknown_085F05B0:: @ 85F05B0 +sSpriteAffineAnimTable_85F05B0:: @ 85F05B0 .incbin "baserom.gba", 0x5f05b0, 0xb4 -gUnknown_085F0664:: @ 85F0664 +sSpriteAffineAnimTable_85F0664:: @ 85F0664 .incbin "baserom.gba", 0x5f0664, 0x4 -gUnknown_085F0668:: @ 85F0668 +sSpriteAffineAnimTable_85F0668:: @ 85F0668 .incbin "baserom.gba", 0x5f0668, 0x4 -gUnknown_085F066C:: @ 85F066C +sSpriteAffineAnimTable_85F066C:: @ 85F066C .incbin "baserom.gba", 0x5f066c, 0x34 -gUnknown_085F06A0:: @ 85F06A0 +gPokeblock_SpriteSheet:: @ 85F06A0 .incbin "baserom.gba", 0x5f06a0, 0x8 -gUnknown_085F06A8:: @ 85F06A8 +sThrownPokeblockSpriteTemplate:: @ 85F06A8 .incbin "baserom.gba", 0x5f06a8, 0x18 diff --git a/include/menu_helpers.h b/include/menu_helpers.h index f083a10e2..4abe5c006 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -16,5 +16,9 @@ void sub_812225C(u16 *, u16 *, u8, u8); void sub_8122298(u16 *, u16 *, u8, u8, u8); void sub_8121F68(u8 taskId, const struct YesNoFuncTable *data); bool8 sub_81221AC(void); +void ResetVramOamAndBgCntRegs(void); +void SetVBlankHBlankCallbacksToNull(void); +void ResetAllBgsCoordinates(void); +bool16 RunTextPrintersRetIsActive(u8 textPrinterId); #endif //GUARD_MENU_HELPERS_H diff --git a/include/party_menu.h b/include/party_menu.h index c787bafb1..3756ef569 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -1,7 +1,8 @@ #ifndef GUARD_PARTY_MENU_H #define GUARD_PARTY_MENU_H -enum { +enum +{ AILMENT_NONE, AILMENT_PSN, AILMENT_PRZ, @@ -14,5 +15,6 @@ bool8 pokemon_has_move(struct Pokemon *, u16); void sub_81B58A8(void); void DoWallyTutorialBagMenu(void); u8 pokemon_ailments_get_primary(u32 status); +u8 *GetMonNickname(struct Pokemon *mon, u8 *dst); #endif // GUARD_PARTY_MENU_H diff --git a/include/pokeblock.h b/include/pokeblock.h index a145cbada..4d869df86 100644 --- a/include/pokeblock.h +++ b/include/pokeblock.h @@ -1,6 +1,8 @@ #ifndef GUARD_POKEBLOCK_H #define GUARD_POKEBLOCK_H +#define TAG_POKEBLOCK_GFX 0x39E2 + enum { PBLOCK_CLR_BLACK, @@ -22,12 +24,22 @@ enum PBLOCK_FEEL, }; +// use pokeblock +void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void)); + +// pokeblock feed +void CB2_PreparePokeblockFeedScene(void); + +// pokeblock +u8 CreatePokeblockCaseSprite(s16 x, s16 y, u8 subpriority); +u8 GetPokeblockData(const struct Pokeblock *pokeblock, u8 dataId); void ClearPokeblocks(void); s8 GetFirstFreePokeblockSlot(void); bool32 AddPokeblock(struct Pokeblock *pokeblock); u8 GetHighestPokeblocksFlavorLevel(const struct Pokeblock *pokeblock); u8 GetPokeblocksFeel(const struct Pokeblock *pokeblock); u8 GetPokeblocksFlavor(const struct Pokeblock *pokeblock); -s16 PokeblockGetGain(u8, const struct Pokeblock *); +s16 PokeblockGetGain(u8, const struct Pokeblock *pokeblock); +void PokeblockCopyName(const struct Pokeblock *pokeblock, u8 *dst); #endif // GUARD_POKEBLOCK_H diff --git a/include/pokenav.h b/include/pokenav.h index 06676610a..8e1ec52bd 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -2,5 +2,15 @@ #define GUARD_POKENAV_H bool8 sub_81D5C18(void); +bool8 sub_81D20BC(void *arg0); +bool8 sub_81D312C(void *arg0); +void sub_81D1ED4(void *arg0); +void sub_81D2108(void *arg0); +void sub_81D20AC(void *arg0); +void sub_81D2230(void *arg0); +void sub_81D3464(void *arg0); +void sub_81D3480(void *arg0, u8 arg1); +void sub_81D2754(void *arg0, void *arg1); +void sub_81D1F84(void *arg0, void *arg1, void *arg2); #endif //GUARD_POKENAV_H diff --git a/include/strings.h b/include/strings.h index a2745d382..d9e5921a1 100644 --- a/include/strings.h +++ b/include/strings.h @@ -84,5 +84,8 @@ extern const u8 gText_RegisteredDataDeleted[]; extern const u8 gUnknown_085EA79D[]; extern const u8 gText_PkmnFainted3[]; extern const u8 gText_Coins[]; +extern const u8 gText_Var1AteTheVar2[]; +extern const u8 gText_Var1HappilyAteVar2[]; +extern const u8 gText_Var1DisdainfullyAteVar2[]; #endif //GUARD_STRINGS_H diff --git a/include/text_window.h b/include/text_window.h index da3fb301e..0af007397 100644 --- a/include/text_window.h +++ b/include/text_window.h @@ -3,8 +3,8 @@ struct TilesPal { - u32* tiles; - u16* pal; + u32 *tiles; + u16 *pal; }; const struct TilesPal* sub_8098758(u8 id); diff --git a/ld_script.txt b/ld_script.txt index 3d28740b1..3c1959482 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -222,6 +222,7 @@ SECTIONS { asm/mystery_event_menu.o(.text); src/save_failed_screen.o(.text); src/braille_puzzles.o(.text); + src/pokeblock_feed.o(.text); asm/pokeblock_feed.o(.text); src/clear_save_data_screen.o(.text); asm/intro_credits_graphics.o(.text); diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c new file mode 100644 index 000000000..1f2125016 --- /dev/null +++ b/src/pokeblock_feed.c @@ -0,0 +1,472 @@ +#include "global.h" +#include "pokeblock.h" +#include "sprite.h" +#include "task.h" +#include "palette.h" +#include "menu.h" +#include "malloc.h" +#include "pokemon.h" +#include "blend_palette.h" +#include "main.h" +#include "menu_helpers.h" +#include "bg.h" +#include "gpu_regs.h" +#include "data2.h" +#include "decompress.h" +#include "event_data.h" +#include "strings.h" +#include "string_util.h" +#include "new_menu_helpers.h" +#include "party_menu.h" +#include "m4a.h" +#include "sound.h" +#include "battle.h" // to get rid of once gMonSpritesGfxPtr is put elsewhere + +struct PokeblockFeedStruct +{ + u8 field_0[0x48]; + u8 tilemapBuffer[0x1008]; + u8 field_1050; + u8 field_1051; + u8 field_1052; + bool8 noMonFlip; + u16 species; + u16 field_1056; + u16 field_1058; + u8 nature; + u8 monSpriteId_; + u8 field_105C; + u8 monSpriteId; + u8 pokeblockCaseSpriteId; + u8 pokeblockSpriteId; + u8 field_1060[0x1E]; + s16 loadGfxState; + u8 somefield[2]; +}; + +extern u8 gPokeblockMonId; +extern u16 gSpecialVar_ItemId; +extern s16 gPokeblockGain; +extern struct MusicPlayerInfo gMPlay_BGM; +extern struct SpriteTemplate gUnknown_0202499C; + +extern struct PokeblockFeedStruct *sPokeblockFeed; +extern struct CompressedSpritePalette sPokeblockSpritePal; + +extern bool8 sub_81221EC(void); +extern void sub_806A068(u16, u8); + +// this file's functions +static void HandleInitBackgrounds(void); +static void HandleInitWindows(void); +static bool8 LoadMonAndSceneGfx(struct Pokemon *mon); +u8 CreatePokeblockCaseSpriteForFeeding(void); +static u8 CreateMonSprite(struct Pokemon *mon); +void LaunchPokeblockFeedTask(void); +static void SetPokeblockSpritePal(u8 pokeblockCaseId); +void sub_817A5CC(void); +void sub_8148108(u8 spriteId, bool8 a1); +u8 CreatePokeblockSprite(void); +void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 arg1); +static void PrepareMonToMoveToPokeblock(u8 spriteId); +void Task_HandleMonAtePokeblock(u8 taskId); +void Task_PaletteFadeToReturn(u8 taskId); +void sub_817A634(void); +static void sub_817A468(struct Sprite *sprite); + +static void CB2_PokeblockFeed(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +static void VBlankCB_PokeblockFeed(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +bool8 TransitionToPokeblockFeedScene(void) +{ + switch (gMain.state) + { + case 0: + sPokeblockFeed = AllocZeroed(sizeof(*sPokeblockFeed)); + SetVBlankHBlankCallbacksToNull(); + clear_scheduled_bg_copies_to_vram(); + gMain.state++; + break; + case 1: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = 1; + gMain.state++; + break; + case 2: + ResetSpriteData(); + gMain.state++; + break; + case 3: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 4: + AllocateMonSpritesGfx(); + gMain.state++; + break; + case 5: + HandleInitBackgrounds(); + gMain.state++; + break; + case 6: + HandleInitWindows(); + gMain.state++; + break; + case 7: + if (LoadMonAndSceneGfx(&gPlayerParty[gPokeblockMonId])) + { + gMain.state++; + } + break; + case 8: + sPokeblockFeed->pokeblockCaseSpriteId = CreatePokeblockCaseSpriteForFeeding(); + gMain.state++; + break; + case 9: + sPokeblockFeed->monSpriteId = CreateMonSprite(&gPlayerParty[gPokeblockMonId]); + gMain.state++; + break; + case 10: + SetWindowBorderStyle(0, 1, 1, 14); + gMain.state++; + break; + case 11: + LaunchPokeblockFeedTask(); + gMain.state++; + break; + case 12: + BlendPalettes(-1, 0x10, 0); + gMain.state++; + break; + case 13: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gPaletteFade.bufferTransferDisabled = 0; + gMain.state++; + break; + default: + SetVBlankCallback(VBlankCB_PokeblockFeed); + SetMainCallback2(CB2_PokeblockFeed); + return TRUE; + } + return FALSE; +} + +void CB2_PreparePokeblockFeedScene(void) +{ + while (1) + { + if (sub_81221EC() == TRUE) + break; + if (TransitionToPokeblockFeedScene() == TRUE) + break; + if (sub_81221AC() == TRUE) + break; + } +} + +extern const struct BgTemplate gUnknown_085F0550[2]; +extern const u8 gBattleTerrainPalette_Frontier[]; +extern const u8 gBattleTerrainTiles_Building[]; +extern const u8 gUnknown_08D9BA44[]; +extern const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet; +extern const struct CompressedSpriteSheet gPokeblock_SpriteSheet; +extern const struct CompressedSpritePalette gPokeblockCase_SpritePal; +extern const struct CompressedSpriteSheet gMonFrontPicTable[]; +extern const struct WindowTemplate gUnknown_085F0558[]; +extern const u16 gUnknown_0860F074[]; +extern const u8 *sPokeblocksPals[]; +extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F05B0[]; +extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0664[]; +extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F0668[]; +extern const union AffineAnimCmd * const sSpriteAffineAnimTable_85F066C[]; +extern const struct SpriteTemplate sThrownPokeblockSpriteTemplate; + +static void HandleInitBackgrounds(void) +{ + ResetVramOamAndBgCntRegs(); + + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085F0550, ARRAY_COUNT(gUnknown_085F0550)); + SetBgTilemapBuffer(1, sPokeblockFeed->tilemapBuffer); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(1); + + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); + + ShowBg(0); + ShowBg(1); + + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) +{ + u16 species; + u32 personality, trainerId; + const struct CompressedSpritePalette *palette; + + switch (sPokeblockFeed->loadGfxState) + { + case 0: + species = GetMonData(mon, MON_DATA_SPECIES2); + personality = GetMonData(mon, MON_DATA_PERSONALITY); + HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality); + sPokeblockFeed->loadGfxState++; + break; + case 1: + species = GetMonData(mon, MON_DATA_SPECIES2); + personality = GetMonData(mon, MON_DATA_PERSONALITY); + trainerId = GetMonData(mon, MON_DATA_OT_ID); + palette = GetMonSpritePalStructFromOtIdPersonality(species, trainerId, personality); + + LoadCompressedObjectPalette(palette); + sub_806A068(palette->tag, 1); + sPokeblockFeed->loadGfxState++; + break; + case 2: + LoadCompressedObjectPic(&gPokeblockCase_SpriteSheet); + sPokeblockFeed->loadGfxState++; + break; + case 3: + LoadCompressedObjectPalette(&gPokeblockCase_SpritePal); + sPokeblockFeed->loadGfxState++; + break; + case 4: + LoadCompressedObjectPic(&gPokeblock_SpriteSheet); + sPokeblockFeed->loadGfxState++; + break; + case 5: + SetPokeblockSpritePal(gSpecialVar_ItemId); + LoadCompressedObjectPalette(&sPokeblockSpritePal); + sPokeblockFeed->loadGfxState++; + break; + case 6: + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(1, gBattleTerrainTiles_Building, 0, 0, 0); + sPokeblockFeed->loadGfxState++; + break; + case 7: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + LZDecompressWram(gUnknown_08D9BA44, sPokeblockFeed->tilemapBuffer); + sPokeblockFeed->loadGfxState++; + } + break; + case 8: + LoadCompressedPalette(gBattleTerrainPalette_Frontier, 0x20, 0x60); + sPokeblockFeed->loadGfxState = 0; + return TRUE; + } + + return FALSE; +} + +extern void sub_809882C(u8, u16, u8); + +static void HandleInitWindows(void) +{ + InitWindows(gUnknown_085F0558); + DeactivateAllTextPrinters(); + sub_809882C(0, 1, 0xE0); + LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + FillWindowPixelBuffer(0, 0); + PutWindowTilemap(0); + schedule_bg_copy_tilemap_to_vram(0); +} + +static void SetPokeblockSpritePal(u8 pokeblockCaseId) +{ + u8 colorId = GetPokeblockData(&gSaveBlock1Ptr->pokeblocks[pokeblockCaseId], PBLOCK_COLOR); + sPokeblockSpritePal.data = sPokeblocksPals[colorId - 1]; + sPokeblockSpritePal.tag = TAG_POKEBLOCK_GFX; +} + +#define tFrames data[0] +#define tData1 data[1] + +void Task_HandlePokeblockFeed(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (gTasks[taskId].tFrames) + { + case 0: + sPokeblockFeed->field_1050 = 0; + sPokeblockFeed->field_1058 = 0; + sub_817A5CC(); + break; + case 255: + DoPokeblockCaseThrowEffect(sPokeblockFeed->pokeblockCaseSpriteId, gTasks[taskId].tData1); + break; + case 269: + sPokeblockFeed->pokeblockSpriteId = CreatePokeblockSprite(); + break; + case 281: + PrepareMonToMoveToPokeblock(sPokeblockFeed->monSpriteId); + break; + case 297: + gTasks[taskId].func = Task_HandleMonAtePokeblock; + return; + } + + if (sPokeblockFeed->field_1058 < sPokeblockFeed->field_1056) + sub_817A634(); + else if (sPokeblockFeed->field_1058 == sPokeblockFeed->field_1056) + gTasks[taskId].tFrames = 254; + + sPokeblockFeed->field_1058++; + gTasks[taskId].tFrames++; + } +} + +void LaunchPokeblockFeedTask(void) +{ + u8 taskId = CreateTask(Task_HandlePokeblockFeed, 0); + gTasks[taskId].tFrames = 0; + gTasks[taskId].tData1 = 1; +} + +void Task_WaitForAtePokeblockText(u8 taskId) +{ + if (RunTextPrintersRetIsActive(0) != TRUE) + gTasks[taskId].func = Task_PaletteFadeToReturn; +} + +void Task_HandleMonAtePokeblock(u8 taskId) +{ + struct Pokemon *mon = &gPlayerParty[gPokeblockMonId]; + struct Pokeblock *pokeblock = &gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId]; + + gPokeblockGain = PokeblockGetGain(GetNature(mon), pokeblock); + GetMonNickname(mon, gStringVar1); + PokeblockCopyName(pokeblock, gStringVar2); + + if (gPokeblockGain == 0) + StringExpandPlaceholders(gStringVar4, gText_Var1AteTheVar2); + else if (gPokeblockGain > 0) + StringExpandPlaceholders(gStringVar4, gText_Var1HappilyAteVar2); + else + StringExpandPlaceholders(gStringVar4, gText_Var1DisdainfullyAteVar2); + + gTextFlags.flag_0 = 1; + AddTextPrinterParametrized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); + gTasks[taskId].func = Task_WaitForAtePokeblockText; +} + +void Task_ReturnAfterPaletteFade(u8 taskId) +{ + if (!gPaletteFade.active) + { + ResetSpriteData(); + FreeAllSpritePalettes(); + m4aMPlayVolumeControl(&gMPlay_BGM, -1, 256); + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskId); + FreeAllWindowBuffers(); + Free(sPokeblockFeed); + FreeMonSpritesGfx(); + } +} + +void Task_PaletteFadeToReturn(u8 taskId) +{ + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskId].func = Task_ReturnAfterPaletteFade; +} + +static u8 CreateMonSprite(struct Pokemon* mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2); + u8 spriteId = CreateSprite(&gUnknown_0202499C, 48, 80, 2); + + sPokeblockFeed->species = species; + sPokeblockFeed->monSpriteId_ = spriteId; + sPokeblockFeed->nature = GetNature(mon); + gSprites[spriteId].data2 = species; + gSprites[spriteId].callback = SpriteCallbackDummy; + + sPokeblockFeed->noMonFlip = TRUE; + if (!IsPokeSpriteNotFlipped(species)) + { + gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_85F05B0; + gSprites[spriteId].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[spriteId], gSprites[spriteId].oam.shape, gSprites[spriteId].oam.size, gSprites[spriteId].oam.affineMode); + sPokeblockFeed->noMonFlip = FALSE; + } + + return spriteId; +} + +static void PrepareMonToMoveToPokeblock(u8 spriteId) +{ + gSprites[spriteId].pos1.x = 48; + gSprites[spriteId].pos1.y = 80; + gSprites[spriteId].data0 = -8; + gSprites[spriteId].data1 = 1; + gSprites[spriteId].callback = sub_817A468; +} + +static void sub_817A468(struct Sprite* sprite) +{ + sprite->pos1.x += 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + + if (sprite->data0 == 0) + PlayCry1(sprite->data2, 0); + if (sprite->data0 == 9) + sprite->callback = SpriteCallbackDummy; +} + +u8 CreatePokeblockCaseSpriteForFeeding(void) +{ + u8 spriteId = CreatePokeblockCaseSprite(188, 100, 2); + gSprites[spriteId].oam.affineMode = 1; + gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_85F0664; + gSprites[spriteId].callback = SpriteCallbackDummy; + InitSpriteAffineAnim(&gSprites[spriteId]); + return spriteId; +} + +void DoPokeblockCaseThrowEffect(u8 spriteId, bool8 a1) +{ + FreeOamMatrix(gSprites[spriteId].oam.matrixNum); + gSprites[spriteId].oam.affineMode = 3; + + if (!a1) + gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_85F0668; + else + gSprites[spriteId].affineAnims = sSpriteAffineAnimTable_85F066C; + + InitSpriteAffineAnim(&gSprites[spriteId]); +} + +u8 CreatePokeblockSprite(void) +{ + u8 spriteId = CreateSprite(&sThrownPokeblockSpriteTemplate, 174, 84, 1); + gSprites[spriteId].data0 = -12; + gSprites[spriteId].data1 = 1; + return spriteId; +} + +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite) +{ + sprite->pos1.x -= 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + if (sprite->data0 == 10) + DestroySprite(sprite); +} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index e9cd3e215..f45e1f07e 100755 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -73,7 +73,7 @@ extern void do_scheduled_bg_tilemap_copies_to_vram(void); extern u8 sub_81221EC(); extern u8 sub_81221AC(); extern void SetVBlankHBlankCallbacksToNull(); -extern void sub_8121DA0(); +extern void ResetVramOamAndBgCntRegs(); extern void clear_scheduled_bg_copies_to_vram(); extern void remove_some_task(); extern void ResetBgsAndClearDma3BusyFlags(u32 leftoverFireRedLeafGreenVariable); @@ -193,7 +193,7 @@ void sub_81C4A88(); void sub_81C4280(); void sub_81C0510(u8 taskId); void sub_81C171C(u8 taskId); -void sub_8121E10(); +void ResetAllBgsCoordinates(); u8 sub_81B205C(struct Pokemon* a); void sub_81C1DA4(u16 a, s16 b); void sub_81C1EFC(u16 a, s16 b, u16 c); @@ -450,7 +450,7 @@ bool8 sub_81BFB10(void) { case 0: SetVBlankHBlankCallbacksToNull(); - sub_8121DA0(); + ResetVramOamAndBgCntRegs(); clear_scheduled_bg_copies_to_vram(); gMain.state++; break; @@ -578,7 +578,7 @@ void sub_81BFE24() SetBgTilemapBuffer(1, &gUnknown_0203CF1C->unkTilemap2); SetBgTilemapBuffer(2, &gUnknown_0203CF1C->unkTilemap1); SetBgTilemapBuffer(3, &gUnknown_0203CF1C->unkTilemap0); - sub_8121E10(); + ResetAllBgsCoordinates(); schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(2); schedule_bg_copy_tilemap_to_vram(3); diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 7057b0528..64d1cb4a5 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -2,29 +2,69 @@ #include "main.h" #include "pokeblock.h" #include "malloc.h" +#include "palette.h" +#include "pokenav.h" +#include "unknown_task.h" +#include "text.h" +#include "bg.h" +#include "window.h" +#include "text_window.h" struct UsePokeblockSubStruct { - void *field_0; + void (*field_0)(void); void (*callback)(void); struct Pokeblock *pokeblock; + struct Pokemon *pokemon; + u8 stringBuffer[0x40]; + u8 field_50; + u8 field_51; + u8 field_52; + u8 field_53; + u8 field_54; + u8 field_55; + u8 field_56; + u8 field_57[5]; + u8 field_5c[5]; + u8 field_61[5]; + s16 field_66[5]; }; -struct UsePokeblockStruct1 +struct UsePokeblockStruct { - u8 field_0[0x7FD0]; + u8 field_0[0x7C58]; + u8 field_7C58[0x378]; struct UsePokeblockSubStruct info; }; -extern struct UsePokeblockStruct1 *gUnknown_0203BCAC; +extern struct UsePokeblockStruct *gUnknown_0203BCAC; extern struct UsePokeblockSubStruct *gUnknown_0203BC90; +extern struct Pokeblock *gUnknown_0203BC98; +extern void (*gUnknown_0203BC94)(void); +extern u8 gPokeblockMonId; + +extern u16 gKeyRepeatStartDelay; // this file's functions -void sub_816636C(void *arg0); +void sub_816636C(void (*func)(void)); void sub_8166380(void); void sub_816631C(void); +void sub_81662C0(void); +void sub_8166564(void); +void sub_8166304(void); +void sub_81668F8(void); +void sub_8167420(void); +void sub_8167760(void); +u8 sub_81672E4(u8 arg0); +bool8 sub_8168328(void); +bool8 sub_8167930(void); +void sub_8167608(u8 arg0); +void sub_8167BA0(u16 arg0, u8 copyToVramMode); -void sub_8166204(struct Pokeblock *pokeblock, void (*callback)(void)) +extern const struct BgTemplate gUnknown_085DFCCC[4]; +extern const struct WindowTemplate gUnknown_085DFCDC[]; + +void ChooseMonToGivePokeblock(struct Pokeblock *pokeblock, void (*callback)(void)) { gUnknown_0203BCAC = AllocZeroed(0x806C); gUnknown_0203BC90 = &gUnknown_0203BCAC->info; @@ -33,3 +73,149 @@ void sub_8166204(struct Pokeblock *pokeblock, void (*callback)(void)) sub_816636C(sub_8166380); SetMainCallback2(sub_816631C); } + +void CB2_ReturnAndChooseMonToGivePokeblock(void) +{ + gUnknown_0203BCAC = AllocZeroed(0x806C); + gUnknown_0203BC90 = &gUnknown_0203BCAC->info; + gUnknown_0203BC90->pokeblock = gUnknown_0203BC98; + gUnknown_0203BC90->callback = gUnknown_0203BC94; + gPokeblockMonId = sub_81672E4(gPokeblockMonId); + gUnknown_0203BC90->field_56 = gPokeblockMonId < 4 ? 0 : 1; + sub_816636C(sub_8166380); + SetMainCallback2(sub_81662C0); +} + +void sub_81662C0(void) +{ + gUnknown_0203BC90->field_0(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); + if (gUnknown_0203BC90->field_0 == sub_8166564) + { + gUnknown_0203BC90->field_50 = 0; + SetMainCallback2(sub_8166304); + } +} + +void sub_8166304(void) +{ + sub_81668F8(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +void sub_816631C(void) +{ + gUnknown_0203BC90->field_0(); + AnimateSprites(); + BuildOamBuffer(); + RunTextPrinters(); + UpdatePaletteFade(); +} + +void sub_8166340(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + sub_81D2108(gUnknown_0203BCAC->field_7C58); + sub_80BA0A8(); +} + +void sub_816636C(void (*func)(void)) +{ + gUnknown_0203BC90->field_0 = func; + gUnknown_0203BC90->field_50 = 0; +} + +void sub_8166380(void) +{ + switch (gUnknown_0203BC90->field_50) + { + case 0: + gUnknown_0203BCAC->field_0[0x7B10] = 0xFF; + sub_81D1ED4(gUnknown_0203BCAC->field_7C58); + gUnknown_0203BC90->field_50++; + break; + case 1: + ResetSpriteData(); + FreeAllSpritePalettes(); + gUnknown_0203BC90->field_50++; + break; + case 2: + SetVBlankCallback(NULL); + CpuFill32(0, (void*)(VRAM), VRAM_SIZE); + gUnknown_0203BC90->field_50++; + break; + case 3: + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_085DFCCC, ARRAY_COUNT(gUnknown_085DFCCC)); + InitWindows(gUnknown_085DFCDC); + DeactivateAllTextPrinters(); + sub_809882C(0, 0x97, 0xE0); + gUnknown_0203BC90->field_50++; + break; + case 4: + gUnknown_0203BC90->field_50++; + break; + case 5: + if (!sub_8168328()) + { + gUnknown_0203BC90->field_50++; + } + break; + case 6: + gKeyRepeatStartDelay = 20; + sub_8167420(); + gUnknown_0203BC90->field_50++; + break; + case 7: + if (!sub_8167930()) + { + gUnknown_0203BC90->field_50++; + } + break; + case 8: + sub_8167608(0); + sub_8167760(); + gUnknown_0203BC90->field_50++; + break; + case 9: + if (!sub_81D312C(&gUnknown_0203BCAC->field_0[0x7B0E])) + { + gUnknown_0203BC90->field_50++; + } + break; + case 10: + gUnknown_0203BC90->field_50++; + break; + case 11: + sub_81D2754(gUnknown_0203BCAC->field_7C58, &gUnknown_0203BCAC->field_0[0x7C6C]); + sub_81D20AC(gUnknown_0203BCAC->field_7C58); + gUnknown_0203BC90->field_50++; + break; + case 12: + if (!sub_81D20BC(gUnknown_0203BCAC->field_7C58)) + { + sub_81D1F84(gUnknown_0203BCAC->field_7C58, &gUnknown_0203BCAC->field_7C58[0x14], &gUnknown_0203BCAC->field_7C58[0x14]); + gUnknown_0203BC90->field_50++; + } + break; + case 13: + sub_81D2230(gUnknown_0203BCAC->field_7C58); + gUnknown_0203BC90->field_50++; + break; + case 14: + PutWindowTilemap(0); + PutWindowTilemap(1); + sub_8167BA0(0, 1); + gUnknown_0203BC90->field_50++; + break; + case 15: + sub_816636C(sub_8166564); + break; + } +} diff --git a/sym_ewram.txt b/sym_ewram.txt index ee47f8e37..2e7538615 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1315,10 +1315,10 @@ gUnknown_0203BC94: @ 203BC94 gUnknown_0203BC98: @ 203BC98 .space 0x4 -gUnknown_0203BC9C: @ 203BC9C +gPokeblockMonId: @ 203BC9C .space 0x2 -gUnknown_0203BC9E: @ 203BC9E +gPokeblockGain: @ 203BC9E .space 0x2 gUnknown_0203BCA0: @ 203BCA0 @@ -1393,10 +1393,10 @@ gUnknown_0203BCF8: @ 203BCF8 gBraillePuzzleCallbackFlag: @ 203BD14 .space 0x4 -gUnknown_0203BD18: @ 203BD18 +sPokeblockFeed: @ 203BD18 .space 0x4 -gUnknown_0203BD1C: @ 203BD1C +sPokeblockSpritePal: @ 203BD1C .space 0x8 gUnknown_0203BD24: @ 203BD24