diff --git a/asm/item_menu_icons.s b/asm/item_menu_icons.s deleted file mode 100644 index 8068e37c2..000000000 --- a/asm/item_menu_icons.s +++ /dev/null @@ -1,637 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start RemoveBagObject -@ void RemoveBagObject(u8 a1) -RemoveBagObject: @ 80D4CA8 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_0203CE54 - ldr r2, =0x00000804 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - beq _080D4CEE - adds r4, 0x64 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl FreeSpriteOamMatrix - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - movs r0, 0xFF - strb r0, [r5] -_080D4CEE: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end RemoveBagObject - - thumb_func_start AddBagVisualObject -@ void AddBagVisualObject(u8 bagPocketId) -AddBagVisualObject: @ 80D4D00 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gUnknown_0203CE54 - ldr r4, [r0] - ldr r0, =0x00000804 - adds r4, r0 - ldr r0, =gUnknown_0857FB4C - movs r1, 0x44 - movs r2, 0x42 - movs r3, 0 - bl CreateSprite - strb r0, [r4] - adds r0, r5, 0 - movs r1, 0 - bl SetBagVisualPocketId - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AddBagVisualObject - - thumb_func_start SetBagVisualPocketId -@ void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) -SetBagVisualPocketId: @ 80D4D38 - push {lr} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r1, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r2, =0x00000804 - adds r0, r2 - ldrb r2, [r0] - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - ldr r2, =gSprites - adds r2, r0, r2 - cmp r1, 0 - beq _080D4D84 - ldr r0, =0x0000fffb - strh r0, [r2, 0x26] - ldr r0, =ObjectCB_BagVisualSwitchingPockets - str r0, [r2, 0x1C] - adds r0, r3, 0x1 - strh r0, [r2, 0x2E] - adds r0, r2, 0 - movs r1, 0 - bl StartSpriteAnim - b _080D4D90 - .pool -_080D4D84: - adds r1, r3, 0x1 - lsls r1, 24 - lsrs r1, 24 - adds r0, r2, 0 - bl StartSpriteAnim -_080D4D90: - pop {r0} - bx r0 - thumb_func_end SetBagVisualPocketId - - thumb_func_start ObjectCB_BagVisualSwitchingPockets -@ void ObjectCB_BagVisualSwitchingPockets(struct obj *object) -ObjectCB_BagVisualSwitchingPockets: @ 80D4D94 - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x26] - movs r2, 0x26 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _080D4DA8 - adds r0, r1, 0x1 - strh r0, [r4, 0x26] - b _080D4DB8 -_080D4DA8: - ldrh r1, [r4, 0x2E] - lsls r1, 24 - lsrs r1, 24 - adds r0, r4, 0 - bl StartSpriteAnim - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_080D4DB8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_BagVisualSwitchingPockets - - thumb_func_start ShakeBagVisual -@ void ShakeBagVisual() -ShakeBagVisual: @ 80D4DC4 - push {r4,lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000804 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080D4DF4 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r0, =ObjectCB_ShakeBagVisual - str r0, [r4, 0x1C] -_080D4DF4: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ShakeBagVisual - - thumb_func_start ObjectCB_ShakeBagVisual -@ void ObjectCB_ShakeBagVisual(struct obj *object) -ObjectCB_ShakeBagVisual: @ 80D4E0C - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _080D4E28 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_080D4E28: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_ShakeBagVisual - - thumb_func_start AddSwitchPocketRotatingBallObject -@ void AddSwitchPocketRotatingBallObject(u16 rotationDirection) -AddSwitchPocketRotatingBallObject: @ 80D4E34 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 16 - lsrs r5, 16 - ldr r0, =gUnknown_0203CE54 - ldr r4, [r0] - ldr r0, =0x00000805 - adds r4, r0 - ldr r0, =gUnknown_0857FBA0 - bl LoadSpriteSheet - ldr r0, =gUnknown_0857FBA8 - bl LoadSpritePalette - ldr r0, =gUnknown_0857FBB0 - movs r1, 0x10 - movs r2, 0x10 - movs r3, 0 - bl CreateSprite - strb r0, [r4] - ldr r2, =gSprites - ldrb r1, [r4] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - strh r5, [r0, 0x2E] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end AddSwitchPocketRotatingBallObject - - thumb_func_start update_switch_pocket_rotating_ball_coords -@ void update_switch_pocket_rotating_ball_coords(struct obj *object) -update_switch_pocket_rotating_ball_coords: @ 80D4E8C - ldrh r2, [r0, 0x30] - ldrh r1, [r0, 0x34] - adds r1, 0x1 - movs r3, 0x1 - ands r1, r3 - subs r2, r1 - adds r1, r0, 0 - adds r1, 0x28 - strb r2, [r1] - ldrh r2, [r0, 0x30] - ldrh r1, [r0, 0x34] - adds r1, 0x1 - ands r1, r3 - subs r2, r1 - adds r0, 0x29 - strb r2, [r0] - bx lr - thumb_func_end update_switch_pocket_rotating_ball_coords - - thumb_func_start ObjectCB_SwitchPocketRotatingBallInit -@ void ObjectCB_SwitchPocketRotatingBallInit(struct obj *object) -ObjectCB_SwitchPocketRotatingBallInit: @ 80D4EB0 - push {r4,lr} - adds r4, r0, 0 - ldrb r1, [r4, 0x1] - movs r0, 0x4 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r4, 0x1] - movs r0, 0x2E - ldrsh r1, [r4, r0] - movs r0, 0x1 - negs r0, r0 - cmp r1, r0 - bne _080D4ED8 - ldr r0, =gUnknown_0857FB98 - b _080D4EDA - .pool -_080D4ED8: - ldr r0, =gUnknown_0857FB9C -_080D4EDA: - str r0, [r4, 0x10] - adds r0, r4, 0 - bl InitSpriteAffineAnim - adds r0, r4, 0 - adds r0, 0x28 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - strh r0, [r4, 0x30] - adds r0, r4, 0 - adds r0, 0x29 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - strh r0, [r4, 0x30] - adds r0, r4, 0 - bl update_switch_pocket_rotating_ball_coords - ldr r0, =ObjectCB_SwitchPocketRotatingBallContinue - str r0, [r4, 0x1C] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ObjectCB_SwitchPocketRotatingBallInit - - thumb_func_start ObjectCB_SwitchPocketRotatingBallContinue -@ void ObjectCB_SwitchPocketRotatingBallContinue(struct obj *object) -ObjectCB_SwitchPocketRotatingBallContinue: @ 80D4F14 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x34] - adds r0, 0x1 - strh r0, [r4, 0x34] - adds r0, r4, 0 - bl update_switch_pocket_rotating_ball_coords - movs r1, 0x34 - ldrsh r0, [r4, r1] - cmp r0, 0x10 - bne _080D4F32 - movs r0, 0x1 - bl RemoveBagObject -_080D4F32: - pop {r4} - pop {r0} - bx r0 - thumb_func_end ObjectCB_SwitchPocketRotatingBallContinue - - thumb_func_start AddBagItemIconObject -@ void AddBagItemIconObject(u16 itemId, u8 a2) -AddBagItemIconObject: @ 80D4F38 - push {r4-r6,lr} - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r0, =gUnknown_0203CE54 - ldr r2, =0x00000806 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - bne _080D4F86 - adds r4, 0x66 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - adds r1, r4, 0 - adds r2, r6, 0 - bl AddItemIconSprite - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _080D4F86 - strb r2, [r5] - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r1, 0x18 - strh r1, [r0, 0x24] - movs r1, 0x58 - strh r1, [r0, 0x26] -_080D4F86: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end AddBagItemIconObject - - thumb_func_start RemoveBagItemIconObject -@ void RemoveBagItemIconObject(u8 a1) -RemoveBagItemIconObject: @ 80D4F98 - push {lr} - lsls r0, 24 - movs r1, 0x80 - lsls r1, 18 - adds r0, r1 - lsrs r0, 24 - bl RemoveBagObject - pop {r0} - bx r0 - thumb_func_end RemoveBagItemIconObject - - thumb_func_start sub_80D4FAC -sub_80D4FAC: @ 80D4FAC - push {lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - movs r1, 0x8 - bl sub_8122344 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FAC - - thumb_func_start sub_80D4FC8 -sub_80D4FC8: @ 80D4FC8 - push {lr} - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - movs r1, 0x8 - bl sub_81223FC - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FC8 - - thumb_func_start sub_80D4FEC -sub_80D4FEC: @ 80D4FEC - push {lr} - adds r3, r0, 0 - lsls r3, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000808 - adds r0, r1 - lsrs r3, 4 - movs r1, 0x80 - lsls r1, 13 - adds r3, r1 - lsrs r3, 16 - movs r1, 0x88 - movs r2, 0x78 - bl sub_8122448 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D4FEC - - thumb_func_start sub_80D5018 -sub_80D5018: @ 80D5018 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - adds r4, r1, 0 - movs r2, 0x80 - lsls r2, 4 - adds r0, r4, 0 - movs r1, 0 - bl memset - movs r0, 0x80 - lsls r0, 1 - adds r4, r0 - movs r7, 0 -_080D5036: - adds r4, 0x20 - movs r5, 0 - adds r1, r7, 0x1 - mov r8, r1 -_080D503E: - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0x20 - bl memcpy - adds r4, 0x20 - adds r6, 0x20 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x5 - bls _080D503E - cmp r7, 0x5 - beq _080D505C - adds r4, 0x20 -_080D505C: - mov r1, r8 - lsls r0, r1, 24 - lsrs r7, r0, 24 - cmp r7, 0x5 - bls _080D5036 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80D5018 - - thumb_func_start sub_80D5070 -sub_80D5070: @ 80D5070 - push {r4,r5,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - adds r4, r0, 0 - cmp r4, 0x2A - bne _080D5082 - bl IsEnigmaBerryValid -_080D5082: - ldr r5, =gBerryPicTable - lsls r4, 3 - adds r0, r5, 0x4 - adds r0, r4, r0 - ldr r0, [r0] - str r0, [sp] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - ldr r1, =0x00007544 - orrs r0, r1 - str r0, [sp, 0x4] - mov r0, sp - bl LoadCompressedObjectPalette - adds r4, r5 - ldr r0, [r4] - ldr r4, =0x0201d000 - adds r1, r4, 0 - bl LZDecompressWram - ldr r0, =0xfffff000 - adds r1, r4, r0 - adds r0, r4, 0 - bl sub_80D5018 - add sp, 0x8 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80D5070 - - thumb_func_start CreateBerryTagSprite -CreateBerryTagSprite: @ 80D50D4 - push {r4,r5,lr} - adds r4, r1, 0 - adds r5, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - bl sub_80D5070 - ldr r0, =gUnknown_0857FBEC - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r1, r4, 0 - adds r2, r5, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end CreateBerryTagSprite - - thumb_func_start FreeBerryTagSpritePalette -FreeBerryTagSpritePalette: @ 80D510C - push {lr} - ldr r0, =0x00007544 - bl FreeSpritePaletteByTag - pop {r0} - bx r0 - .pool - thumb_func_end FreeBerryTagSpritePalette - - thumb_func_start sub_80D511C -sub_80D511C: @ 80D511C - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - mov r8, r3 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - mov r0, r8 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldr r0, =0x00007544 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - bl sub_80D5070 - ldr r0, =gUnknown_0857FC7C - adds r1, r5, 0 - adds r2, r6, 0 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r1, r0, 24 - adds r4, r1, 0 - mov r0, r8 - cmp r0, 0x1 - bne _080D5172 - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - movs r1, 0x1 - bl StartSpriteAffineAnim -_080D5172: - adds r0, r4, 0 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80D511C - - thumb_func_start CreateBerryFlavorCircleSprite -CreateBerryFlavorCircleSprite: @ 80D518C - push {lr} - adds r1, r0, 0 - ldr r0, =gUnknown_0857FE10 - lsls r1, 16 - asrs r1, 16 - movs r2, 0x74 - movs r3, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end CreateBerryFlavorCircleSprite - - .align 2, 0 @ Don't pad with nop. diff --git a/data/graphics/berries/berry_pic_table.inc b/data/graphics/berries/berry_pic_table.inc deleted file mode 100644 index 12d4267a0..000000000 --- a/data/graphics/berries/berry_pic_table.inc +++ /dev/null @@ -1,45 +0,0 @@ - .align 2 -gBerryPicTable:: @ 857FC94 - .4byte gBerryPic_Cheri, gBerryPalette_Cheri - .4byte gBerryPic_Chesto, gBerryPalette_Chesto - .4byte gBerryPic_Pecha, gBerryPalette_Pecha - .4byte gBerryPic_Rawst, gBerryPalette_Rawst - .4byte gBerryPic_Aspear, gBerryPalette_Aspear - .4byte gBerryPic_Leppa, gBerryPalette_Leppa - .4byte gBerryPic_Oran, gBerryPalette_Oran - .4byte gBerryPic_Persim, gBerryPalette_Persim - .4byte gBerryPic_Lum, gBerryPalette_Lum - .4byte gBerryPic_Sitrus, gBerryPalette_Sitrus - .4byte gBerryPic_Figy, gBerryPalette_Figy - .4byte gBerryPic_Wiki, gBerryPalette_Wiki - .4byte gBerryPic_Mago, gBerryPalette_Mago - .4byte gBerryPic_Aguav, gBerryPalette_Aguav - .4byte gBerryPic_Iapapa, gBerryPalette_Iapapa - .4byte gBerryPic_Razz, gBerryPalette_Razz - .4byte gBerryPic_Bluk, gBerryPalette_Bluk - .4byte gBerryPic_Nanab, gBerryPalette_Nanab - .4byte gBerryPic_Wepear, gBerryPalette_Wepear - .4byte gBerryPic_Pinap, gBerryPalette_Pinap - .4byte gBerryPic_Pomeg, gBerryPalette_Pomeg - .4byte gBerryPic_Kelpsy, gBerryPalette_Kelpsy - .4byte gBerryPic_Qualot, gBerryPalette_Qualot - .4byte gBerryPic_Hondew, gBerryPalette_Hondew - .4byte gBerryPic_Grepa, gBerryPalette_Grepa - .4byte gBerryPic_Tamato, gBerryPalette_Tamato - .4byte gBerryPic_Cornn, gBerryPalette_Cornn - .4byte gBerryPic_Magost, gBerryPalette_Magost - .4byte gBerryPic_Rabuta, gBerryPalette_Rabuta - .4byte gBerryPic_Nomel, gBerryPalette_Nomel - .4byte gBerryPic_Spelon, gBerryPalette_Spelon - .4byte gBerryPic_Pamtre, gBerryPalette_Pamtre - .4byte gBerryPic_Watmel, gBerryPalette_Watmel - .4byte gBerryPic_Durin, gBerryPalette_Durin - .4byte gBerryPic_Belue, gBerryPalette_Belue - .4byte gBerryPic_Liechi, gBerryPalette_Liechi - .4byte gBerryPic_Ganlon, gBerryPalette_Ganlon - .4byte gBerryPic_Salac, gBerryPalette_Salac - .4byte gBerryPic_Petaya, gBerryPalette_Petaya - .4byte gBerryPic_Apicot, gBerryPalette_Apicot - .4byte gBerryPic_Lansat, gBerryPalette_Lansat - .4byte gBerryPic_Starf, gBerryPalette_Starf - .4byte gBerryPic_Enigma, gBerryPalette_Enigma diff --git a/data/item_menu_icons.s b/data/item_menu_icons.s index 36f339b09..aaf242dc2 100644 --- a/data/item_menu_icons.s +++ b/data/item_menu_icons.s @@ -4,175 +4,6 @@ .section .rodata - .align 2 -gUnknown_0857F564:: @ 857F564 - .incbin "graphics/interface/bag_spinner.gbapal" - - .align 2 -gUnknown_0857F584:: @ 857F584 - .incbin "graphics/interface/bag_spinner.4bpp" - - .align 2 -gUnknown_0857F604:: @ 857F604 - .incbin "graphics/unused/cherry.4bpp" - - .align 2 -gUnknown_0857FA84:: @ 857FA84 - .incbin "graphics/unused/cherry.gbapal" - - .align 2 -gOamData_857FAA4:: @ 857FAA4 - .2byte 0x0100, 0xc000, 0x0400, 0x0000 - - .align 2 -gSpriteAnim_857FAAC:: @ 857FAAC - .2byte 0x0000, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAB4:: @ 857FAB4 - .2byte 0x0040, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FABC:: @ 857FABC - .2byte 0x0080, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAC4:: @ 857FAC4 - .2byte 0x00c0, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FACC:: @ 857FACC - .2byte 0x0100, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_857FAD4:: @ 857FAD4 - .2byte 0x0140, 0x0004, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FADC:: @ 857FADC - .4byte gSpriteAnim_857FAAC - .4byte gSpriteAnim_857FAB4 - .4byte gSpriteAnim_857FAC4 - .4byte gSpriteAnim_857FACC - .4byte gSpriteAnim_857FAD4 - .4byte gSpriteAnim_857FABC - - .align 2 -gSpriteAffineAnim_857FAF4:: @ 857FAF4 - .2byte 0x0100, 0x0100, 0x0000, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FB04:: @ 857FB04 - .2byte 0x0000, 0x0000, 0x02fe, 0x0000, 0x0000, 0x0000, 0x0402, 0x0000, 0x0000, 0x0000, 0x04fe, 0x0000, 0x0000, 0x0000, 0x0202, 0x0000 - .2byte 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnimTable_857FB2C:: @ 857FB2C - .4byte gSpriteAffineAnim_857FAF4 - .4byte gSpriteAffineAnim_857FB04 - - .align 2 -gUnknown_0857FB34:: @ 857FB34 - obj_tiles gBagMaleTiles, 0x3000, 0x0064 - - .align 2 -gUnknown_0857FB3C:: @ 857FB3C - obj_tiles gBagFemaleTiles, 0x3000, 0x0064 - - .align 2 -gUnknown_0857FB44:: @ 857FB44 - obj_pal gBagPalette, 0x0064 - - .align 2 -gUnknown_0857FB4C:: @ 857FB4C - spr_template 0x0064, 0x0064, gOamData_857FAA4, gSpriteAnimTable_857FADC, NULL, gSpriteAffineAnimTable_857FB2C, SpriteCallbackDummy - - .align 2 -gOamData_857FB64:: @ 857FB64 - .2byte 0x0000, 0x4800, 0x0800, 0x0000 - - .align 2 -gSpriteAnim_857FB6C:: @ 857FB6C - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FB74:: @ 857FB74 - .4byte gSpriteAnim_857FB6C - - .align 2 -gSpriteAffineAnim_857FB78:: @ 857FB78 - .2byte 0x0000, 0x0000, 0x1008, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FB88:: @ 857FB88 - .2byte 0x0000, 0x0000, 0x10f8, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gUnknown_0857FB98:: @ 857FB98 - .4byte gSpriteAffineAnim_857FB78 - - .align 2 -gUnknown_0857FB9C:: @ 857FB9C - .4byte gSpriteAffineAnim_857FB88 - - .align 2 -gUnknown_0857FBA0:: @ 857FBA0 - obj_tiles gUnknown_0857F584, 0x0080, 0x0065 - - .align 2 -gUnknown_0857FBA8:: @ 857FBA8 - obj_pal gUnknown_0857F564, 0x0065 - - .align 2 -gUnknown_0857FBB0:: @ 857FBB0 - spr_template 0x0065, 0x0065, gOamData_857FB64, gSpriteAnimTable_857FB74, NULL, gUnknown_0857FB98, ObjectCB_SwitchPocketRotatingBallInit - - .align 2 -gOamData_857FBC8:: @ 857FBC8 - .2byte 0x0000, 0xc000, 0x7400, 0x0000 - - .align 2 -gOamData_857FBD0:: @ 857FBD0 - .2byte 0x0300, 0xc000, 0x7000, 0x0000 - - .align 2 -gSpriteAnim_857FBD8:: @ 857FBD8 - .2byte 0x0000, 0x0000, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_857FBE0:: @ 857FBE0 - .4byte gSpriteAnim_857FBD8 - - .align 2 -gOamData_857FBE4:: @ 857FBE4 - .2byte 0xc000, 0x0201, 0x0800, 0x0000 - - .align 2 -gUnknown_0857FBEC:: @ 857FBEC - spr_template 0xffff, 0x7544, gOamData_857FBC8, gSpriteAnimTable_857FBE0, gOamData_857FBE4, gDummySpriteAffineAnimTable, SpriteCallbackDummy - - .align 2 -gSpriteAffineAnim_857FC04:: @ 857FC04 - .2byte 0xffff, 0xffff, 0x60fd, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0xfffe, 0xfffe, 0x40ff, 0x0000, 0xfff8, 0x0000, 0x1000, 0x0000 - .2byte 0x0000, 0xfff8, 0x1000, 0x0000, 0x0100, 0x0100, 0x0000, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_857FC3C:: @ 857FC3C - .2byte 0xffff, 0xffff, 0x6003, 0x0000, 0x0000, 0x0000, 0x1000, 0x0000, 0xfffe, 0xfffe, 0x4001, 0x0000, 0xfff8, 0x0000, 0x1000, 0x0000 - .2byte 0x0000, 0xfff8, 0x1000, 0x0000, 0x0100, 0x0100, 0x0000, 0x0000, 0x7ffe, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnimTable_857FC74:: @ 857FC74 - .4byte gSpriteAffineAnim_857FC04 - .4byte gSpriteAffineAnim_857FC3C - - .align 2 -gUnknown_0857FC7C:: @ 857FC7C - spr_template 0xffff, 0x7544, gOamData_857FBD0, gSpriteAnimTable_857FBE0, gOamData_857FBE4, gSpriteAffineAnimTable_857FC74, SpriteCallbackDummy - -@ 857FC94 - .include "data/graphics/berries/berry_pic_table.inc" - .align 2 gUnknown_0857FDEC:: @ 857FDEC obj_tiles gBerryCheckCircle_Gfx, 0x0800, 0x2710 diff --git a/include/graphics.h b/include/graphics.h index e0c9431ac..88d19ceb4 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2719,12 +2719,17 @@ extern const u16 gFireRedMenuElements2_Pal[16]; extern const u16 gFireRedMenuElements3_Pal[16]; extern const u8 gFireRedMenuElements_Gfx[]; -//item menu graphics +// item menu graphics extern const u8 gBagScreen_Gfx[]; extern const u16 gBagScreenFemale_Pal[]; extern const u16 gBagScreenMale_Pal[]; extern const u8 gBagMenuHMIcon_Gfx[]; +// item menu icons graphics +extern const u8 gBagMaleTiles[]; +extern const u8 gBagFemaleTiles[]; +extern const u8 gBagPalette[]; + //intro graphics extern const u8 gIntro1SparkleGfx[]; extern const u8 gIntro1FlygonGfx[]; @@ -2767,6 +2772,94 @@ extern const u16 gIntro2BrendanNoTurnPal[]; extern const u16 gIntro2FlygonPal[]; extern const u8 gIntro2FlygonGfx[]; +// berry pics +extern const u8 gBerryPic_Cheri[]; +extern const u8 gBerryPalette_Cheri[]; +extern const u8 gBerryPic_Chesto[]; +extern const u8 gBerryPalette_Chesto[]; +extern const u8 gBerryPic_Pecha[]; +extern const u8 gBerryPalette_Pecha[]; +extern const u8 gBerryPic_Rawst[]; +extern const u8 gBerryPalette_Rawst[]; +extern const u8 gBerryPic_Aspear[]; +extern const u8 gBerryPalette_Aspear[]; +extern const u8 gBerryPic_Leppa[]; +extern const u8 gBerryPalette_Leppa[]; +extern const u8 gBerryPic_Oran[]; +extern const u8 gBerryPalette_Oran[]; +extern const u8 gBerryPic_Persim[]; +extern const u8 gBerryPalette_Persim[]; +extern const u8 gBerryPic_Lum[]; +extern const u8 gBerryPalette_Lum[]; +extern const u8 gBerryPic_Sitrus[]; +extern const u8 gBerryPalette_Sitrus[]; +extern const u8 gBerryPic_Figy[]; +extern const u8 gBerryPalette_Figy[]; +extern const u8 gBerryPic_Wiki[]; +extern const u8 gBerryPalette_Wiki[]; +extern const u8 gBerryPic_Mago[]; +extern const u8 gBerryPalette_Mago[]; +extern const u8 gBerryPic_Aguav[]; +extern const u8 gBerryPalette_Aguav[]; +extern const u8 gBerryPic_Iapapa[]; +extern const u8 gBerryPalette_Iapapa[]; +extern const u8 gBerryPic_Razz[]; +extern const u8 gBerryPalette_Razz[]; +extern const u8 gBerryPic_Bluk[]; +extern const u8 gBerryPalette_Bluk[]; +extern const u8 gBerryPic_Nanab[]; +extern const u8 gBerryPalette_Nanab[]; +extern const u8 gBerryPic_Wepear[]; +extern const u8 gBerryPalette_Wepear[]; +extern const u8 gBerryPic_Pinap[]; +extern const u8 gBerryPalette_Pinap[]; +extern const u8 gBerryPic_Pomeg[]; +extern const u8 gBerryPalette_Pomeg[]; +extern const u8 gBerryPic_Kelpsy[]; +extern const u8 gBerryPalette_Kelpsy[]; +extern const u8 gBerryPic_Qualot[]; +extern const u8 gBerryPalette_Qualot[]; +extern const u8 gBerryPic_Hondew[]; +extern const u8 gBerryPalette_Hondew[]; +extern const u8 gBerryPic_Grepa[]; +extern const u8 gBerryPalette_Grepa[]; +extern const u8 gBerryPic_Tamato[]; +extern const u8 gBerryPalette_Tamato[]; +extern const u8 gBerryPic_Cornn[]; +extern const u8 gBerryPalette_Cornn[]; +extern const u8 gBerryPic_Magost[]; +extern const u8 gBerryPalette_Magost[]; +extern const u8 gBerryPic_Rabuta[]; +extern const u8 gBerryPalette_Rabuta[]; +extern const u8 gBerryPic_Nomel[]; +extern const u8 gBerryPalette_Nomel[]; +extern const u8 gBerryPic_Spelon[]; +extern const u8 gBerryPalette_Spelon[]; +extern const u8 gBerryPic_Pamtre[]; +extern const u8 gBerryPalette_Pamtre[]; +extern const u8 gBerryPic_Watmel[]; +extern const u8 gBerryPalette_Watmel[]; +extern const u8 gBerryPic_Durin[]; +extern const u8 gBerryPalette_Durin[]; +extern const u8 gBerryPic_Belue[]; +extern const u8 gBerryPalette_Belue[]; +extern const u8 gBerryPic_Liechi[]; +extern const u8 gBerryPalette_Liechi[]; +extern const u8 gBerryPic_Ganlon[]; +extern const u8 gBerryPalette_Ganlon[]; +extern const u8 gBerryPic_Salac[]; +extern const u8 gBerryPalette_Salac[]; +extern const u8 gBerryPic_Petaya[]; +extern const u8 gBerryPalette_Petaya[]; +extern const u8 gBerryPic_Apicot[]; +extern const u8 gBerryPalette_Apicot[]; +extern const u8 gBerryPic_Lansat[]; +extern const u8 gBerryPalette_Lansat[]; +extern const u8 gBerryPic_Starf[]; +extern const u8 gBerryPalette_Starf[]; +extern const u8 gBerryPic_Enigma[]; +extern const u8 gBerryPalette_Enigma[]; + //credits extern const u8 gCreditsCopyrightEnd_Gfx[]; diff --git a/include/item_menu.h b/include/item_menu.h index 5c1b26faa..9cffaa6c7 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -4,17 +4,48 @@ // Exported type declarations struct BagStruct { - void *func; - u8 unk4; + void (*bagCallback)(void); + u8 location; u8 pocket; u8 unk6[2]; - u16 unk8[5]; - u16 unk12[5]; - void *unk1C; + u16 cursorPosition[5]; + u16 scrollPosition[5]; }; extern struct BagStruct gUnknown_0203CE58; +struct UnkBagStruct +{ + void (*unk0)(void); + u8 unk4[0x800]; + u8 unk804[12]; + u8 unk810[7]; + u8 unk817; + u8 unk818; + u8 unk819; + u8 unk81A; + u8 unk81B:4; + u8 unk81B_1:2; + u8 unk81B_3:1; + u8 unk81B_2:1; + u8 filler3[2]; + u8 unk81E; + u8 unk81F; + const u8* unk820; + u8 unk824; + u8 unk825; + u8 filler[2]; + u8 unk828; + u8 unk829[5]; + u8 unk82E[6]; + s16 unk834; + u8 filler4[0xE]; + u8 unk844[32][32]; + u8 filler2[4]; +}; + +extern struct UnkBagStruct *gUnknown_0203CE54; + // Exported RAM declarations extern u16 gSpecialVar_ItemId; diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index 56e012421..0347e8f94 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -9,7 +9,7 @@ u8 CreateBerryTagSprite(u8 id, s16 x, s16 y); void FreeBerryTagSpritePalette(void); u8 CreateBerryFlavorCircleSprite(s16 x); void sub_80D4FAC(void); -void RemoveBagItemIconObject(u8); +void RemoveBagItemIconSprite(u8); void sub_80D4FEC(u8); void sub_80D4FC8(u8); diff --git a/ld_script.txt b/ld_script.txt index 7dcf21569..ceb12540c 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -136,7 +136,7 @@ SECTIONS { asm/fldeff_cut.o(.text); src/mail_data.o(.text); asm/map_name_popup.o(.text); - asm/item_menu_icons.o(.text); + src/item_menu_icons.o(.text); asm/battle_anim_80D51AC.o(.text); src/item.o(.text); asm/item.o(.text); @@ -433,6 +433,7 @@ SECTIONS { src/pokemon_icon.o(.rodata); data/fldeff_cut.o(.rodata); data/map_name_popup.o(.rodata); + src/item_menu_icons.o(.rodata); data/item_menu_icons.o(.rodata); data/contest.o(.rodata); data/shop.o(.rodata); diff --git a/src/item_menu.c b/src/item_menu.c index 9090a39c5..fe756c2bb 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1,4 +1,5 @@ #include "global.h" +#include "item_menu.h" #include "battle.h" #include "battle_controllers.h" #include "battle_frontier_2.h" @@ -58,7 +59,7 @@ void load_bag_item_list_buffers(u8); void bag_menu_print_pocket_names(u8*, u8*); void bag_menu_copy_pocket_name_to_window(u32); void bag_menu_draw_pocket_indicator_square(u8, u8); -void AddBagVisualObject(u8); +void AddBagVisualSprite(u8); void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); void bag_menu_add_list_scroll_arrow_indicators_maybe(void); void bag_menu_prepare_tmhm_move_window(void); @@ -69,7 +70,7 @@ void get_name(s8*, u16); u16 ItemIdToBattleMoveId(u16); void ShakeBagVisual(void); u16 BagGetItemIdByPocketPosition(u8, u16); -void AddBagItemIconObject(u16, u8); +void AddBagItemIconSprite(u16, u8); void bag_menu_print_description_box_text(int); void bag_menu_print_cursor(u8, u8); void bag_menu_print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8); @@ -87,8 +88,8 @@ void SwitchBagPocket(u8, s16, u16); bool8 sub_81AC2C0(void); void bag_menu_swap_items(u8); void SetBagVisualPocketId(u8, u8); -void RemoveBagObject(u8); -void AddSwitchPocketRotatingBallObject(s16); +void RemoveBagSprite(u8); +void AddSwitchPocketRotatingBallSprite(s16); void sub_81AC10C(u8); void sub_81AC3C0(u8); void sub_81AC498(u8); @@ -251,46 +252,6 @@ const struct WindowTemplate gUnknown_086141AC[] = { // .text -struct BagStruct { - void (*bagCallback)(void); - u8 location; - u8 pocket; - u8 unk6[2]; - u16 cursorPosition[5]; - u16 scrollPosition[5]; -}; - -struct UnkBagStruct { - MainCallback unk0; - u8 unk4[0x800]; - u8 unk804; - u8 unk805; - u8 unk806[10]; - u8 unk810[7]; - u8 unk817; - u8 unk818; - u8 unk819; - u8 unk81A; - u8 unk81B:4; - u8 unk81B_1:2; - u8 unk81B_3:1; - u8 unk81B_2:1; - u8 filler3[2]; - u8 unk81E; - u8 unk81F; - const u8* unk820; - u8 unk824; - u8 unk825; - u8 filler[2]; - u8 unk828; - u8 unk829[5]; - u8 unk82E[6]; - s16 unk834; - u8 filler4[0xE]; - u8 unk844[32][32]; - u8 filler2[4]; -}; - struct ListBuffer1 { struct ListMenuItem subBuffers[65]; }; @@ -411,7 +372,7 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2) gUnknown_0203CE54->unk81A = 0xFF; gUnknown_0203CE54->unk81E = -1; gUnknown_0203CE54->unk81F = -1; - memset(&gUnknown_0203CE54->unk804, 0xFF, 12); + memset(gUnknown_0203CE54->unk804, 0xFF, sizeof(gUnknown_0203CE54->unk804)); memset(gUnknown_0203CE54->unk810, 0xFF, 10); SetMainCallback2(CB2_Bag); } @@ -517,7 +478,7 @@ bool8 setup_bag_menu(void) gMain.state++; break; case 15: - AddBagVisualObject(gUnknown_0203CE58.pocket); + AddBagVisualSprite(gUnknown_0203CE58.pocket); gMain.state++; break; case 16: @@ -697,11 +658,11 @@ void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused) } if (gUnknown_0203CE54->unk81A == 0xFF) { - RemoveBagItemIconObject(1 ^ gUnknown_0203CE54->unk81B_1); + RemoveBagItemIconSprite(1 ^ gUnknown_0203CE54->unk81B_1); if (a != -2) - AddBagItemIconObject(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a), gUnknown_0203CE54->unk81B_1); + AddBagItemIconSprite(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a), gUnknown_0203CE54->unk81B_1); else - AddBagItemIconObject(-1, gUnknown_0203CE54->unk81B_1); + AddBagItemIconSprite(-1, gUnknown_0203CE54->unk81B_1); gUnknown_0203CE54->unk81B_1 ^= 1; if (!gUnknown_0203CE54->unk81B_3) bag_menu_print_description_box_text(a); @@ -1085,8 +1046,8 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); schedule_bg_copy_tilemap_to_vram(2); SetBagVisualPocketId(pocketId, 1); - RemoveBagObject(1); - AddSwitchPocketRotatingBallObject(deltaBagPocketId); + RemoveBagSprite(1); + AddSwitchPocketRotatingBallSprite(deltaBagPocketId); SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func); } #else @@ -1219,9 +1180,9 @@ _081AC09A:\n\ movs r1, 0x1\n\ bl SetBagVisualPocketId\n\ movs r0, 0x1\n\ - bl RemoveBagObject\n\ + bl RemoveBagSprite\n\ asrs r0, r5, 16\n\ - bl AddSwitchPocketRotatingBallObject\n\ + bl AddSwitchPocketRotatingBallSprite\n\ ldr r1, =sub_81AC10C\n\ ldr r2, =gTasks\n\ lsls r0, r6, 2\n\ diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c new file mode 100644 index 000000000..001731727 --- /dev/null +++ b/src/item_menu_icons.c @@ -0,0 +1,570 @@ +#include "global.h" +#include "sprite.h" +#include "decompress.h" +#include "item_menu.h" +#include "item_icon.h" +#include "item_menu_icons.h" +#include "window.h" +#include "menu_helpers.h" +#include "berry.h" +#include "graphics.h" +#include "constants/items.h" + +struct CompressedTilesPal +{ + const u8 *tiles; + const u8 *pal; +}; + +// this file's functions +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets); +void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite); +void SpriteCB_ShakeBagVisual(struct Sprite *sprite); +void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite); +void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite); + +// const rom data +const u16 gUnknown_0857F564[] = INCBIN_U16("graphics/interface/bag_spinner.gbapal"); +const u8 gUnknown_0857F584[] = INCBIN_U8("graphics/interface/bag_spinner.4bpp"); +const u8 gUnknown_0857F604[] = INCBIN_U8("graphics/unused/cherry.4bpp"); +const u16 gUnknown_0857FA84[] = INCBIN_U16("graphics/unused/cherry.gbapal"); + +static const struct OamData sOamData_857FAA4 = +{ + .y = 0, + .affineMode = 1, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FAAC[] = +{ + ANIMCMD_FRAME(0, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAB4[] = +{ + ANIMCMD_FRAME(64, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FABC[] = +{ + ANIMCMD_FRAME(128, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAC4[] = +{ + ANIMCMD_FRAME(192, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FACC[] = +{ + ANIMCMD_FRAME(256, 4), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_857FAD4[] = +{ + ANIMCMD_FRAME(320, 4), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FADC[] = +{ + sSpriteAnim_857FAAC, + sSpriteAnim_857FAB4, + sSpriteAnim_857FAC4, + sSpriteAnim_857FACC, + sSpriteAnim_857FAD4, + sSpriteAnim_857FABC +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FAF4[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB04[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 254, 2), + AFFINEANIMCMD_FRAME(0, 0, 2, 4), + AFFINEANIMCMD_FRAME(0, 0, 254, 4), + AFFINEANIMCMD_FRAME(0, 0, 2, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB2C[] = +{ + sSpriteAffineAnim_857FAF4, + sSpriteAffineAnim_857FB04 +}; + +const struct CompressedSpriteSheet gUnknown_0857FB34 = +{ + gBagMaleTiles, 0x3000, 100 +}; + +const struct CompressedSpriteSheet gUnknown_0857FB3C = +{ + gBagFemaleTiles, 0x3000, 100 +}; + +const struct CompressedSpritePalette gUnknown_0857FB44 = +{ + gBagPalette, 100 +}; + +const struct SpriteTemplate gUnknown_0857FB4C = +{ + .tileTag = 100, + .paletteTag = 100, + .oam = &sOamData_857FAA4, + .anims = sSpriteAnimTable_857FADC, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_857FB2C, + .callback = SpriteCallbackDummy, +}; + +static const struct OamData sOamData_857FB64 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 4, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FB6C[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FB74[] = +{ + sSpriteAnim_857FB6C +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB78[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 8, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FB88[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 248, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB98[] = +{ + sSpriteAffineAnim_857FB78, +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FB9C[] = +{ + sSpriteAffineAnim_857FB88, +}; + +const struct SpriteSheet gUnknown_0857FBA0 = +{ + gUnknown_0857F584, 0x80, 101 +}; + +const struct SpritePalette gUnknown_0857FBA8 = +{ + gUnknown_0857F564, 101 +}; + +const struct SpriteTemplate gUnknown_0857FBB0 = +{ + .tileTag = 101, + .paletteTag = 101, + .oam = &sOamData_857FB64, + .anims = sSpriteAnimTable_857FB74, + .images = NULL, + .affineAnims = sSpriteAffineAnimTable_857FB98, + .callback = SpriteCB_SwitchPocketRotatingBallInit, +}; + +static const struct OamData sOamData_857FBC8 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 1, + .paletteNum = 7, + .affineParam = 0 +}; + +static const struct OamData sOamData_857FBD0 = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 3, + .tileNum = 0, + .priority = 0, + .paletteNum = 7, + .affineParam = 0 +}; + +static const union AnimCmd sSpriteAnim_857FBD8[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_857FBE0[] = +{ + sSpriteAnim_857FBD8 +}; + +static const struct SpriteFrameImage sSpriteImageTable_857FBE4[] = +{ + {&gDecompressionBuffer[0], 0x800}, +}; + +const struct SpriteTemplate gUnknown_0857FBEC = +{ + .tileTag = 65535, + .paletteTag = 30020, + .oam = &sOamData_857FBC8, + .anims = sSpriteAnimTable_857FBE0, + .images = sSpriteImageTable_857FBE4, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FC04[] = +{ + AFFINEANIMCMD_FRAME(-1, -1, 253, 96), + AFFINEANIMCMD_FRAME(0, 0, 0, 16), + AFFINEANIMCMD_FRAME(-2, -2, 255, 64), + AFFINEANIMCMD_FRAME(-8, 0, 0, 16), + AFFINEANIMCMD_FRAME(0, -8, 0, 16), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd sSpriteAffineAnim_857FC3C[] = +{ + AFFINEANIMCMD_FRAME(-1, -1, 3, 96), + AFFINEANIMCMD_FRAME(0, 0, 0, 16), + AFFINEANIMCMD_FRAME(-2, -2, 1, 64), + AFFINEANIMCMD_FRAME(-8, 0, 0, 16), + AFFINEANIMCMD_FRAME(0, -8, 0, 16), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_JUMP(0) +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] = +{ + sSpriteAffineAnim_857FC04, + sSpriteAffineAnim_857FC3C +}; + +const struct SpriteTemplate gUnknown_0857FC7C = +{ + .tileTag = 0xFFFF, + .paletteTag = 0x7544, + .oam = &sOamData_857FBD0, + .anims = sSpriteAnimTable_857FBE0, + .images = sSpriteImageTable_857FBE4, + .affineAnims = sSpriteAffineAnimTable_857FC74, + .callback = SpriteCallbackDummy, +}; + +static const struct CompressedTilesPal gBerryPicTable[] = +{ + {gBerryPic_Cheri, gBerryPalette_Cheri}, + {gBerryPic_Chesto, gBerryPalette_Chesto}, + {gBerryPic_Pecha, gBerryPalette_Pecha}, + {gBerryPic_Rawst, gBerryPalette_Rawst}, + {gBerryPic_Aspear, gBerryPalette_Aspear}, + {gBerryPic_Leppa, gBerryPalette_Leppa}, + {gBerryPic_Oran, gBerryPalette_Oran}, + {gBerryPic_Persim, gBerryPalette_Persim}, + {gBerryPic_Lum, gBerryPalette_Lum}, + {gBerryPic_Sitrus, gBerryPalette_Sitrus}, + {gBerryPic_Figy, gBerryPalette_Figy}, + {gBerryPic_Wiki, gBerryPalette_Wiki}, + {gBerryPic_Mago, gBerryPalette_Mago}, + {gBerryPic_Aguav, gBerryPalette_Aguav}, + {gBerryPic_Iapapa, gBerryPalette_Iapapa}, + {gBerryPic_Razz, gBerryPalette_Razz}, + {gBerryPic_Bluk, gBerryPalette_Bluk}, + {gBerryPic_Nanab, gBerryPalette_Nanab}, + {gBerryPic_Wepear, gBerryPalette_Wepear}, + {gBerryPic_Pinap, gBerryPalette_Pinap}, + {gBerryPic_Pomeg, gBerryPalette_Pomeg}, + {gBerryPic_Kelpsy, gBerryPalette_Kelpsy}, + {gBerryPic_Qualot, gBerryPalette_Qualot}, + {gBerryPic_Hondew, gBerryPalette_Hondew}, + {gBerryPic_Grepa, gBerryPalette_Grepa}, + {gBerryPic_Tamato, gBerryPalette_Tamato}, + {gBerryPic_Cornn, gBerryPalette_Cornn}, + {gBerryPic_Magost, gBerryPalette_Magost}, + {gBerryPic_Rabuta, gBerryPalette_Rabuta}, + {gBerryPic_Nomel, gBerryPalette_Nomel}, + {gBerryPic_Spelon, gBerryPalette_Spelon}, + {gBerryPic_Pamtre, gBerryPalette_Pamtre}, + {gBerryPic_Watmel, gBerryPalette_Watmel}, + {gBerryPic_Durin, gBerryPalette_Durin}, + {gBerryPic_Belue, gBerryPalette_Belue}, + {gBerryPic_Liechi, gBerryPalette_Liechi}, + {gBerryPic_Ganlon, gBerryPalette_Ganlon}, + {gBerryPic_Salac, gBerryPalette_Salac}, + {gBerryPic_Petaya, gBerryPalette_Petaya}, + {gBerryPic_Apicot, gBerryPalette_Apicot}, + {gBerryPic_Lansat, gBerryPalette_Lansat}, + {gBerryPic_Starf, gBerryPalette_Starf}, + {gBerryPic_Enigma, gBerryPalette_Enigma}, +}; + +extern const struct SpriteTemplate gUnknown_0857FBEC; +extern const struct SpriteTemplate gUnknown_0857FE10; + +// code +void RemoveBagSprite(u8 id) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[id]; + if (*spriteId != 0xFF) + { + FreeSpriteTilesByTag(id + 100); + FreeSpritePaletteByTag(id + 100); + FreeSpriteOamMatrix(&gSprites[*spriteId]); + DestroySprite(&gSprites[*spriteId]); + *spriteId = 0xFF; + } +} + +void AddBagVisualSprite(u8 bagPocketId) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[0]; + *spriteId = CreateSprite(&gUnknown_0857FB4C, 68, 66, 0); + SetBagVisualPocketId(bagPocketId, FALSE); +} + +void SetBagVisualPocketId(u8 bagPocketId, bool8 isSwitchingPockets) +{ + struct Sprite *sprite = &gSprites[gUnknown_0203CE54->unk804[0]]; + if (isSwitchingPockets) + { + sprite->pos2.y = -5; + sprite->callback = SpriteCB_BagVisualSwitchingPockets; + sprite->data[0] = bagPocketId + 1; + StartSpriteAnim(sprite, 0); + } + else + { + StartSpriteAnim(sprite, bagPocketId + 1); + } +} + +void SpriteCB_BagVisualSwitchingPockets(struct Sprite *sprite) +{ + if (sprite->pos2.y != 0) + { + sprite->pos2.y++; + } + else + { + StartSpriteAnim(sprite, sprite->data[0]); + sprite->callback = SpriteCallbackDummy; + } +} + +void ShakeBagVisual(void) +{ + struct Sprite *sprite = &gSprites[gUnknown_0203CE54->unk804[0]]; + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 1); + sprite->callback = SpriteCB_ShakeBagVisual; + } +} + +void SpriteCB_ShakeBagVisual(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 0); + sprite->callback = SpriteCallbackDummy; + } +} + +void AddSwitchPocketRotatingBallSprite(u16 rotationDirection) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[1]; + LoadSpriteSheet(&gUnknown_0857FBA0); + LoadSpritePalette(&gUnknown_0857FBA8); + *spriteId = CreateSprite(&gUnknown_0857FBB0, 16, 16, 0); + gSprites[*spriteId].data[0] = rotationDirection; +} + +void update_switch_pocket_rotating_ball_coords(struct Sprite *sprite) +{ + sprite->centerToCornerVecX = sprite->data[1] - ((sprite->data[3] + 1) & 1); + sprite->centerToCornerVecY = sprite->data[1] - ((sprite->data[3] + 1) & 1); +} + +void SpriteCB_SwitchPocketRotatingBallInit(struct Sprite *sprite) +{ + sprite->oam.affineMode = 1; + if (sprite->data[0] == -1) + sprite->affineAnims = sSpriteAffineAnimTable_857FB98; + else + sprite->affineAnims = sSpriteAffineAnimTable_857FB9C; + + InitSpriteAffineAnim(sprite); + sprite->data[1] = sprite->centerToCornerVecX; + sprite->data[1] = sprite->centerToCornerVecY; + update_switch_pocket_rotating_ball_coords(sprite); + sprite->callback = SpriteCB_SwitchPocketRotatingBallContinue; +} + +void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite) +{ + sprite->data[3]++; + update_switch_pocket_rotating_ball_coords(sprite); + if (sprite->data[3] == 16) + RemoveBagSprite(1); +} + +void AddBagItemIconSprite(u16 itemId, u8 id) +{ + u8 *spriteId = &gUnknown_0203CE54->unk804[id + 2]; + if (*spriteId == 0xFF) + { + u8 iconSpriteId; + + FreeSpriteTilesByTag(id + 102); + FreeSpritePaletteByTag(id + 102); + iconSpriteId = AddItemIconSprite(id + 102, id + 102, itemId); + if (iconSpriteId != MAX_SPRITES) + { + *spriteId = iconSpriteId; + gSprites[iconSpriteId].pos2.x = 24; + gSprites[iconSpriteId].pos2.y = 88; + } + } +} + +void RemoveBagItemIconSprite(u8 id) +{ + RemoveBagSprite(id + 2); +} + +void sub_80D4FAC(void) +{ + sub_8122344(&gUnknown_0203CE54->unk804[4], 8); +} + +void sub_80D4FC8(u8 arg0) +{ + sub_81223FC(&gUnknown_0203CE54->unk804[4], 8, arg0); +} + +void sub_80D4FEC(u8 arg0) +{ + sub_8122448(&gUnknown_0203CE54->unk804[4], 136, 120, (arg0 + 1) * 16); +} + +void sub_80D5018(void *mem0, void *mem1) +{ + u8 i, j; + + memset(mem1, 0, 0x800); + mem1 += 0x100; + for (i = 0; i < 6; i++) + { + mem1 += 0x20; + for (j = 0; j < 6; j++) + { + memcpy(mem1, mem0, 0x20); + mem1 += 0x20; + mem0 += 0x20; + } + if (i != 5) + mem1 += 0x20; + } +} + +void sub_80D5070(u8 berryId) +{ + struct CompressedSpritePalette pal; + + if (berryId == ITEM_TO_BERRY(ITEM_ENIGMA_BERRY) - 1) + IsEnigmaBerryValid(); // what's the point of calling it if the return value is ignored? + + pal.data = gBerryPicTable[berryId].pal; + pal.tag = 0x7544; + LoadCompressedObjectPalette(&pal); + LZDecompressWram(gBerryPicTable[berryId].tiles, &gDecompressionBuffer[0x1000]); + sub_80D5018(&gDecompressionBuffer[0x1000], &gDecompressionBuffer[0]); +} + +u8 CreateBerryTagSprite(u8 id, s16 x, s16 y) +{ + sub_80D5070(id); + return CreateSprite(&gUnknown_0857FBEC, x, y, 0); +} + +void FreeBerryTagSpritePalette(void) +{ + FreeSpritePaletteByTag(0x7544); +} + +u8 sub_80D511C(u8 berryId, u8 x, u8 y, bool8 startAffine) +{ + u8 spriteId; + + FreeSpritePaletteByTag(0x7544); + sub_80D5070(berryId); + spriteId = CreateSprite(&gUnknown_0857FC7C, x, y, 0); + if (startAffine == TRUE) + StartSpriteAffineAnim(&gSprites[spriteId], 1); + + return spriteId; +} + +u8 CreateBerryFlavorCircleSprite(s16 x) +{ + return CreateSprite(&gUnknown_0857FE10, x, 116, 0); +}