diff --git a/asm/field_effect.s b/asm/field_effect.s index 91cd0c972..bcab215c9 100644 --- a/asm/field_effect.s +++ b/asm/field_effect.s @@ -5,1941 +5,6 @@ .text - thumb_func_start FieldEffectStart -@ u8 FieldEffectStart(u8 id) -FieldEffectStart: @ 80B5B18 - push {r4,r5,lr} - sub sp, 0x8 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl FieldEffectActiveListAdd - ldr r0, =gFieldEffectScriptPointers - lsls r4, 2 - adds r4, r0 - ldr r0, [r4] - str r0, [sp] - add r4, sp, 0x4 - ldr r5, =gUnknown_0855C1F0 -_080B5B36: - ldr r0, [sp] - ldrb r0, [r0] - lsls r0, 2 - adds r0, r5 - ldr r2, [r0] - mov r0, sp - adds r1, r4, 0 - bl _call_via_r2 - lsls r0, 24 - cmp r0, 0 - bne _080B5B36 - ldr r0, [sp, 0x4] - add sp, 0x8 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end FieldEffectStart - - thumb_func_start FieldEffectCmd_loadtiles -@ bool8 FieldEffectCmd_loadtiles(u8 **script, u8 *returnValue) -FieldEffectCmd_loadtiles: @ 80B5B60 - push {lr} - ldr r1, [r0] - adds r1, 0x1 - str r1, [r0] - bl FieldEffectScript_LoadTiles - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadtiles - - thumb_func_start FieldEffectCmd_loadfadedpal -@ bool8 FieldEffectCmd_loadfadedpal(u8 **script, u8 *returnValue) -FieldEffectCmd_loadfadedpal: @ 80B5B74 - push {lr} - ldr r1, [r0] - adds r1, 0x1 - str r1, [r0] - bl FieldEffectScript_LoadFadedPalette - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadfadedpal - - thumb_func_start FieldEffectCmd_loadpal -@ bool8 FieldEffectCmd_loadpal(u8 **script, u8 *returnValue) -FieldEffectCmd_loadpal: @ 80B5B88 - push {lr} - ldr r1, [r0] - adds r1, 0x1 - str r1, [r0] - bl FieldEffectScript_LoadPalette - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadpal - - thumb_func_start FieldEffectCmd_callnative -@ bool8 FieldEffectCmd_callnative(u8 **script, u8 *returnValue) -FieldEffectCmd_callnative: @ 80B5B9C - push {lr} - ldr r2, [r0] - adds r2, 0x1 - str r2, [r0] - bl FieldEffectScript_CallNative - movs r0, 0x1 - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_callnative - - thumb_func_start FieldEffectCmd_end -@ bool8 FieldEffectCmd_end(u8 **script, u8 *returnValue) -FieldEffectCmd_end: @ 80B5BB0 - movs r0, 0 - bx lr - thumb_func_end FieldEffectCmd_end - - thumb_func_start FieldEffectCmd_loadgfx_callnative -@ bool8 FieldEffectCmd_loadgfx_callnative(u8 **script, u8 *returnValue) -FieldEffectCmd_loadgfx_callnative: @ 80B5BB4 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] - adds r0, r4, 0 - bl FieldEffectScript_LoadTiles - adds r0, r4, 0 - bl FieldEffectScript_LoadFadedPalette - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldEffectScript_CallNative - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadgfx_callnative - - thumb_func_start FieldEffectCmd_loadtiles_callnative -@ bool8 FieldEffectCmd_loadtiles_callnative(u8 **script, u8 *returnValue) -FieldEffectCmd_loadtiles_callnative: @ 80B5BDC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] - adds r0, r4, 0 - bl FieldEffectScript_LoadTiles - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldEffectScript_CallNative - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadtiles_callnative - - thumb_func_start FieldEffectCmd_loadfadedpal_callnative -@ bool8 FieldEffectCmd_loadfadedpal_callnative(u8 **script, u8 *returnValue) -FieldEffectCmd_loadfadedpal_callnative: @ 80B5C00 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] - adds r0, r4, 0 - bl FieldEffectScript_LoadFadedPalette - adds r0, r4, 0 - adds r1, r5, 0 - bl FieldEffectScript_CallNative - movs r0, 0x1 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end FieldEffectCmd_loadfadedpal_callnative - - thumb_func_start FieldEffectScript_ReadWord -@ u32 FieldEffectScript_ReadWord(u8 **script) -FieldEffectScript_ReadWord: @ 80B5C24 - ldr r2, [r0] - ldrb r0, [r2] - ldrb r1, [r2, 0x1] - lsls r1, 8 - adds r0, r1 - ldrb r1, [r2, 0x2] - lsls r1, 16 - adds r0, r1 - ldrb r1, [r2, 0x3] - lsls r1, 24 - adds r0, r1 - bx lr - thumb_func_end FieldEffectScript_ReadWord - - thumb_func_start FieldEffectScript_LoadTiles -@ void FieldEffectScript_LoadTiles(u8 **script) -FieldEffectScript_LoadTiles: @ 80B5C3C - push {r4,r5,lr} - adds r4, r0, 0 - bl FieldEffectScript_ReadWord - adds r5, r0, 0 - ldrh r0, [r5, 0x6] - bl GetSpriteTileStartByTag - lsls r0, 16 - ldr r1, =0xffff0000 - cmp r0, r1 - bne _080B5C5A - adds r0, r5, 0 - bl LoadSpriteSheet -_080B5C5A: - ldr r0, [r4] - adds r0, 0x4 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FieldEffectScript_LoadTiles - - thumb_func_start FieldEffectScript_LoadFadedPalette -@ void FieldEffectScript_LoadFadedPalette(u8 **script) -FieldEffectScript_LoadFadedPalette: @ 80B5C6C - push {r4,r5,lr} - adds r5, r0, 0 - bl FieldEffectScript_ReadWord - adds r4, r0, 0 - bl LoadSpritePalette - ldrh r0, [r4, 0x4] - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 24 - bl sub_80ABE18 - ldr r0, [r5] - adds r0, 0x4 - str r0, [r5] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldEffectScript_LoadFadedPalette - - thumb_func_start FieldEffectScript_LoadPalette -@ void FieldEffectScript_LoadPalette(u8 **script) -FieldEffectScript_LoadPalette: @ 80B5C94 - push {r4,lr} - adds r4, r0, 0 - bl FieldEffectScript_ReadWord - bl LoadSpritePalette - ldr r0, [r4] - adds r0, 0x4 - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldEffectScript_LoadPalette - - thumb_func_start FieldEffectScript_CallNative -@ void FieldEffectScript_CallNative(u8 **script, u8 *returnValue) -FieldEffectScript_CallNative: @ 80B5CAC - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - bl FieldEffectScript_ReadWord - bl _call_via_r0 - str r0, [r5] - ldr r0, [r4] - adds r0, 0x4 - str r0, [r4] - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldEffectScript_CallNative - - thumb_func_start FieldEffectFreeGraphicsResources -@ void FieldEffectFreeGraphicsResources(struct obj *object) -FieldEffectFreeGraphicsResources: @ 80B5CC8 - push {r4,r5,lr} - adds r1, r0, 0 - adds r1, 0x40 - ldrh r5, [r1] - ldrb r4, [r0, 0x5] - lsrs r4, 4 - bl DestroySprite - adds r0, r5, 0 - bl FieldEffectFreeTilesIfUnused - adds r0, r4, 0 - bl FieldEffectFreePaletteIfUnused - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldEffectFreeGraphicsResources - - thumb_func_start FieldEffectStop -@ void FieldEffectStop(struct obj *object, u8 id) -FieldEffectStop: @ 80B5CEC - push {r4,lr} - lsls r4, r1, 24 - lsrs r4, 24 - bl FieldEffectFreeGraphicsResources - adds r0, r4, 0 - bl FieldEffectActiveListRemove - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldEffectStop - - thumb_func_start FieldEffectFreeTilesIfUnused -@ void FieldEffectFreeTilesIfUnused(u16 tileRangeStart) -FieldEffectFreeTilesIfUnused: @ 80B5D04 - push {r4,r5,lr} - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - bl GetSpriteTileTagByTileStart - lsls r0, 16 - lsrs r3, r0, 16 - ldr r0, =0x0000ffff - cmp r3, r0 - beq _080B5D58 - movs r2, 0 - ldr r5, =gSprites -_080B5D1E: - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r5 - adds r0, r1, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _080B5D48 - adds r0, r1, 0 - adds r0, 0x3F - ldrb r0, [r0] - lsls r0, 25 - cmp r0, 0 - bge _080B5D48 - adds r0, r1, 0 - adds r0, 0x40 - ldrh r0, [r0] - cmp r4, r0 - beq _080B5D58 -_080B5D48: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3F - bls _080B5D1E - adds r0, r3, 0 - bl FreeSpriteTilesByTag -_080B5D58: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end FieldEffectFreeTilesIfUnused - - thumb_func_start FieldEffectFreePaletteIfUnused -@ void FieldEffectFreePaletteIfUnused(u8 paletteSlot) -FieldEffectFreePaletteIfUnused: @ 80B5D68 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl GetSpritePaletteTagByPaletteNum - lsls r0, 16 - lsrs r5, r0, 16 - ldr r0, =0x0000ffff - cmp r5, r0 - beq _080B5DB0 - movs r2, 0 - ldr r6, =gSprites - adds r3, r4, 0 -_080B5D84: - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r1, r0, r6 - adds r0, r1, 0 - adds r0, 0x3E - ldrb r0, [r0] - lsls r0, 31 - cmp r0, 0 - beq _080B5DA0 - ldrb r0, [r1, 0x5] - lsrs r0, 4 - cmp r0, r3 - beq _080B5DB0 -_080B5DA0: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3F - bls _080B5D84 - adds r0, r5, 0 - bl FreeSpritePaletteByTag -_080B5DB0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end FieldEffectFreePaletteIfUnused - - thumb_func_start FieldEffectActiveListClear -@ void FieldEffectActiveListClear() -FieldEffectActiveListClear: @ 80B5DC0 - push {r4,lr} - movs r2, 0 - ldr r4, =gUnknown_03000F58 - movs r3, 0xFF -_080B5DC8: - adds r0, r2, r4 - ldrb r1, [r0] - orrs r1, r3 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1F - bls _080B5DC8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end FieldEffectActiveListClear - - thumb_func_start FieldEffectActiveListAdd -@ void FieldEffectActiveListAdd(u8 id) -FieldEffectActiveListAdd: @ 80B5DE4 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - movs r2, 0 - ldr r4, =gUnknown_03000F58 -_080B5DEE: - adds r1, r2, r4 - ldrb r0, [r1] - cmp r0, 0xFF - bne _080B5E00 - strb r3, [r1] - b _080B5E0A - .pool -_080B5E00: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1F - bls _080B5DEE -_080B5E0A: - pop {r4} - pop {r0} - bx r0 - thumb_func_end FieldEffectActiveListAdd - - thumb_func_start FieldEffectActiveListRemove -@ void FieldEffectActiveListRemove(u8 id) -FieldEffectActiveListRemove: @ 80B5E10 - push {r4,r5,lr} - lsls r0, 24 - lsrs r3, r0, 24 - movs r2, 0 - ldr r4, =gUnknown_03000F58 - movs r5, 0xFF -_080B5E1C: - adds r1, r2, r4 - ldrb r0, [r1] - cmp r0, r3 - bne _080B5E30 - orrs r0, r5 - strb r0, [r1] - b _080B5E3A - .pool -_080B5E30: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x1F - bls _080B5E1C -_080B5E3A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end FieldEffectActiveListRemove - - thumb_func_start FieldEffectActiveListContains -@ void FieldEffectActiveListContains(u8 id) -FieldEffectActiveListContains: @ 80B5E40 - push {lr} - lsls r0, 24 - lsrs r2, r0, 24 - movs r1, 0 - ldr r3, =gUnknown_03000F58 -_080B5E4A: - adds r0, r1, r3 - ldrb r0, [r0] - cmp r0, r2 - bne _080B5E5C - movs r0, 0x1 - b _080B5E68 - .pool -_080B5E5C: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x1F - bls _080B5E4A - movs r0, 0 -_080B5E68: - pop {r1} - bx r1 - thumb_func_end FieldEffectActiveListContains - - thumb_func_start CreateTrainerSprite -CreateTrainerSprite: @ 80B5E6C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x18 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - mov r9, r3 - ldr r7, [sp, 0x34] - lsls r4, 24 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - mov r0, r9 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsrs r4, 21 - ldr r3, =gTrainerFrontPicPaletteTable - mov r8, r3 - add r8, r4 - mov r0, r8 - adds r1, r7, 0 - bl LoadCompressedObjectPaletteOverrideBuffer - ldr r0, =gTrainerFrontPicTable - adds r4, r0 - adds r0, r4, 0 - adds r1, r7, 0 - bl LoadCompressedObjectPicOverrideBuffer - mov r1, sp - ldrh r0, [r4, 0x6] - movs r2, 0 - strh r0, [r1] - mov r3, r8 - ldrh r0, [r3, 0x4] - strh r0, [r1, 0x2] - ldr r0, =gNewGameBirchOamAttributes - str r0, [sp, 0x4] - ldr r0, =gDummySpriteAnimTable - str r0, [sp, 0x8] - str r2, [sp, 0xC] - ldr r0, =gDummySpriteAffineAnimTable - str r0, [sp, 0x10] - ldr r0, =SpriteCallbackDummy - str r0, [sp, 0x14] - lsls r5, 16 - asrs r5, 16 - lsls r6, 16 - asrs r6, 16 - mov r0, sp - adds r1, r5, 0 - adds r2, r6, 0 - mov r3, r9 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - add sp, 0x18 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end CreateTrainerSprite - - thumb_func_start sub_80B5F0C -sub_80B5F0C: @ 80B5F0C - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r1, r2, 0 - lsls r4, 24 - lsls r5, 16 - lsrs r5, 16 - ldr r0, =gTrainerFrontPicTable - lsrs r4, 21 - adds r0, r4, r0 - ldr r0, [r0] - bl LZDecompressVram - ldr r0, =gTrainerFrontPicPaletteTable - adds r4, r0 - ldr r0, [r4] - adds r1, r5, 0 - movs r2, 0x20 - bl LoadCompressedPalette - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B5F0C - - thumb_func_start AddNewGameBirchObject -AddNewGameBirchObject: @ 80B5F44 - push {r4-r6,lr} - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 24 - lsrs r6, 24 - ldr r0, =gNewGameBirchObjectPaletteInfo - bl LoadSpritePalette - ldr r0, =gNewGameBirchObjectTemplate - lsls r4, 16 - asrs r4, 16 - lsls r5, 16 - asrs r5, 16 - adds r1, r4, 0 - adds r2, r5, 0 - adds r3, r6, 0 - bl CreateSprite - lsls r0, 24 - lsrs r0, 24 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end AddNewGameBirchObject - - thumb_func_start sub_80B5F84 -sub_80B5F84: @ 80B5F84 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 16 - lsrs r0, 16 - movs r3, 0x80 - lsls r3, 8 - lsls r1, 16 - asrs r1, 16 - str r1, [sp] - lsls r2, 16 - asrs r2, 16 - str r2, [sp, 0x4] - movs r1, 0 - str r1, [sp, 0x8] - ldr r1, =gMonPaletteTable - lsls r4, r0, 3 - adds r4, r1 - ldrh r1, [r4, 0x4] - str r1, [sp, 0xC] - movs r1, 0 - adds r2, r3, 0 - movs r3, 0x1 - bl sub_818D7D8 - lsls r0, 16 - lsrs r5, r0, 16 - ldrh r0, [r4, 0x4] - bl IndexOfSpritePaletteTag - adds r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - bl sub_80AC3F8 - ldr r0, =0x0000ffff - cmp r5, r0 - beq _080B5FDC - lsls r0, r5, 24 - lsrs r0, 24 - b _080B5FDE - .pool -_080B5FDC: - movs r0, 0x40 -_080B5FDE: - add sp, 0x10 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80B5F84 - - thumb_func_start sub_80B5FE8 -sub_80B5FE8: @ 80B5FE8 - push {r4-r6,lr} - mov r6, r10 - mov r5, r9 - mov r4, r8 - push {r4-r6} - sub sp, 0x10 - adds r6, r0, 0 - mov r9, r1 - mov r10, r2 - adds r4, r3, 0 - ldr r5, [sp, 0x2C] - lsls r6, 16 - lsrs r6, 16 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - adds r0, r6, 0 - bl GetMonSpritePalStructFromOtIdPersonality - mov r8, r0 - lsls r4, 16 - asrs r4, 16 - str r4, [sp] - lsls r5, 16 - asrs r5, 16 - str r5, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - mov r1, r8 - ldrh r0, [r1, 0x4] - str r0, [sp, 0xC] - adds r0, r6, 0 - mov r1, r9 - mov r2, r10 - movs r3, 0x1 - bl sub_818D7D8 - lsls r0, 16 - lsrs r4, r0, 16 - mov r1, r8 - ldrh r0, [r1, 0x4] - bl IndexOfSpritePaletteTag - adds r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - bl sub_80AC3F8 - ldr r0, =0x0000ffff - cmp r4, r0 - beq _080B605C - lsls r0, r4, 24 - lsrs r0, 24 - b _080B605E - .pool -_080B605C: - movs r0, 0x40 -_080B605E: - add sp, 0x10 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80B5FE8 - - thumb_func_start sub_80B6070 -sub_80B6070: @ 80B6070 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r5, r1, 24 - bl sub_80AC428 - ldrb r0, [r4, 0x1] - lsls r0, 30 - cmp r0, 0 - beq _080B608E - ldrb r0, [r4, 0x3] - lsls r0, 26 - lsrs r0, 27 - bl FreeOamMatrix -_080B608E: - adds r0, r5, 0 - bl sub_818D820 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_80B6070 - - thumb_func_start MultiplyInvertedPaletteRGBComponents -MultiplyInvertedPaletteRGBComponents: @ 80B609C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - lsls r0, 16 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r4, =gPlttBufferUnfaded - lsrs r0, 15 - adds r4, r0, r4 - ldrh r4, [r4] - movs r5, 0x1F - mov r9, r5 - mov r8, r4 - mov r6, r8 - ands r6, r5 - mov r8, r6 - movs r6, 0xF8 - lsls r6, 2 - ands r6, r4 - lsrs r6, 5 - movs r5, 0xF8 - lsls r5, 7 - ands r4, r5 - lsrs r4, 10 - mov r7, r9 - mov r5, r8 - subs r7, r5 - mov r12, r7 - mov r7, r12 - muls r7, r1 - adds r1, r7, 0 - asrs r1, 4 - add r8, r1 - mov r5, r9 - subs r1, r5, r6 - muls r1, r2 - asrs r1, 4 - adds r6, r1 - subs r5, r4 - mov r9, r5 - mov r1, r9 - muls r1, r3 - asrs r1, 4 - adds r4, r1 - mov r7, r8 - lsls r7, 16 - lsls r6, 21 - orrs r6, r7 - lsls r4, 26 - orrs r4, r6 - lsrs r4, 16 - ldr r1, =gPlttBufferFaded - adds r0, r1 - strh r4, [r0] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end MultiplyInvertedPaletteRGBComponents - - thumb_func_start sub_80B6128 -sub_80B6128: @ 80B6128 - push {r4-r6,lr} - mov r6, r8 - push {r6} - lsls r0, 16 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r4, =gPlttBufferUnfaded - lsrs r0, 15 - adds r4, r0, r4 - ldrh r4, [r4] - movs r5, 0x1F - mov r8, r5 - mov r6, r8 - ands r6, r4 - mov r8, r6 - movs r5, 0xF8 - lsls r5, 2 - ands r5, r4 - lsrs r5, 5 - movs r6, 0xF8 - lsls r6, 7 - ands r4, r6 - lsrs r4, 10 - mov r6, r8 - muls r6, r1 - adds r1, r6, 0 - asrs r1, 4 - mov r6, r8 - subs r6, r1 - adds r1, r5, 0 - muls r1, r2 - asrs r1, 4 - subs r5, r1 - adds r1, r4, 0 - muls r1, r3 - asrs r1, 4 - subs r4, r1 - lsls r6, 16 - lsls r5, 21 - orrs r5, r6 - lsls r4, 26 - orrs r4, r5 - lsrs r4, 16 - ldr r1, =gPlttBufferFaded - adds r0, r1 - strh r4, [r0] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6128 - - thumb_func_start sub_80B61A0 -sub_80B61A0: @ 80B61A0 - push {r4,lr} - bl CalculatePlayerPartyCount - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80B61E4 - movs r1, 0xFF - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - strh r4, [r1, 0xA] - movs r0, 0x5D - strh r0, [r1, 0xC] - movs r0, 0x24 - strh r0, [r1, 0xE] - movs r0, 0x7C - strh r0, [r1, 0x10] - movs r0, 0x18 - strh r0, [r1, 0x12] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B61A0 - - thumb_func_start sub_80B61E4 -sub_80B61E4: @ 80B61E4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - ldr r2, =gUnknown_0855C364 - movs r3, 0x8 - ldrsh r0, [r1, r3] - lsls r0, 2 - adds r0, r2 - ldr r2, [r0] - adds r0, r1, 0 - bl _call_via_r2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B61E4 - - thumb_func_start sub_80B6214 -sub_80B6214: @ 80B6214 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r1, 0xA - ldrsh r0, [r4, r1] - movs r2, 0xC - ldrsh r1, [r4, r2] - movs r3, 0xE - ldrsh r2, [r4, r3] - movs r3, 0x1 - bl sub_80B646C - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x14] - movs r1, 0x10 - ldrsh r0, [r4, r1] - movs r2, 0x12 - ldrsh r1, [r4, r2] - bl sub_80B6850 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x16] - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80B6214 - - thumb_func_start sub_80B6250 -sub_80B6250: @ 80B6250 - push {r4,lr} - adds r2, r0, 0 - ldr r3, =gSprites - movs r1, 0x14 - ldrsh r0, [r2, r1] - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r3 - movs r4, 0x2E - ldrsh r0, [r1, r4] - cmp r0, 0x1 - ble _080B6282 - movs r0, 0x16 - ldrsh r1, [r2, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - ldrh r1, [r0, 0x2E] - adds r1, 0x1 - strh r1, [r0, 0x2E] - ldrh r0, [r2, 0x8] - adds r0, 0x1 - strh r0, [r2, 0x8] -_080B6282: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6250 - - thumb_func_start sub_80B628C -sub_80B628C: @ 80B628C - push {lr} - adds r3, r0, 0 - ldr r2, =gSprites - movs r0, 0x14 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x2E - ldrsh r0, [r0, r1] - cmp r0, 0x4 - ble _080B62AC - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] -_080B62AC: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B628C - - thumb_func_start sub_80B62B4 -sub_80B62B4: @ 80B62B4 - push {lr} - ldr r2, =gSprites - movs r3, 0x14 - ldrsh r1, [r0, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - movs r2, 0x2E - ldrsh r0, [r1, r2] - cmp r0, 0x6 - ble _080B62E6 - adds r0, r1, 0 - bl DestroySprite - movs r0, 0x19 - bl FieldEffectActiveListRemove - ldr r0, =sub_80B61E4 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask -_080B62E6: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B62B4 - - thumb_func_start sub_80B62F4 -sub_80B62F4: @ 80B62F4 - push {r4,lr} - bl CalculatePlayerPartyCount - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =sub_80B6330 - movs r1, 0xFF - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - strh r4, [r1, 0xA] - movs r0, 0x75 - strh r0, [r1, 0xC] - movs r0, 0x34 - strh r0, [r1, 0xE] - movs r0, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B62F4 - - thumb_func_start sub_80B6330 -sub_80B6330: @ 80B6330 - push {lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - ldr r0, =gTasks - adds r1, r0 - ldr r2, =gUnknown_0855C374 - movs r3, 0x8 - ldrsh r0, [r1, r3] - lsls r0, 2 - adds r0, r2 - ldr r2, [r0] - adds r0, r1, 0 - bl _call_via_r2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6330 - - thumb_func_start sub_80B6360 -sub_80B6360: @ 80B6360 - push {r4,lr} - adds r4, r0, 0 - ldrh r0, [r4, 0x8] - adds r0, 0x1 - strh r0, [r4, 0x8] - movs r1, 0xA - ldrsh r0, [r4, r1] - movs r2, 0xC - ldrsh r1, [r4, r2] - movs r3, 0xE - ldrsh r2, [r4, r3] - movs r3, 0 - bl sub_80B646C - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x14] - ldr r0, =sub_80B6330 - bl FindTaskIdByFunc - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - movs r1, 0x78 - movs r2, 0x18 - movs r3, 0 - bl sub_80B68EC - adds r0, r4, 0 - movs r1, 0x28 - movs r2, 0x8 - movs r3, 0x1 - bl sub_80B68EC - adds r0, r4, 0 - movs r1, 0x48 - movs r2, 0x8 - movs r3, 0x1 - bl sub_80B68EC - adds r0, r4, 0 - movs r1, 0xA8 - movs r2, 0x8 - movs r3, 0x1 - bl sub_80B68EC - adds r0, r4, 0 - movs r1, 0xC8 - movs r2, 0x8 - movs r3, 0x1 - bl sub_80B68EC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6360 - - thumb_func_start sub_80B63D4 -sub_80B63D4: @ 80B63D4 - push {lr} - adds r3, r0, 0 - ldr r2, =gSprites - movs r0, 0x14 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x2E - ldrsh r0, [r0, r1] - cmp r0, 0x1 - ble _080B63FA - ldrh r0, [r3, 0x26] - adds r0, 0x1 - strh r0, [r3, 0x26] - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] -_080B63FA: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B63D4 - - thumb_func_start sub_80B6404 -sub_80B6404: @ 80B6404 - push {lr} - adds r3, r0, 0 - ldr r2, =gSprites - movs r0, 0x14 - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x2E - ldrsh r0, [r0, r1] - cmp r0, 0x4 - ble _080B6424 - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] -_080B6424: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6404 - - thumb_func_start sub_80B642C -sub_80B642C: @ 80B642C - push {lr} - ldr r2, =gSprites - movs r3, 0x14 - ldrsh r1, [r0, r3] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r1, r0, r2 - movs r2, 0x2E - ldrsh r0, [r1, r2] - cmp r0, 0x6 - ble _080B645E - adds r0, r1, 0 - bl DestroySprite - movs r0, 0x3E - bl FieldEffectActiveListRemove - ldr r0, =sub_80B6330 - bl FindTaskIdByFunc - lsls r0, 24 - lsrs r0, 24 - bl DestroyTask -_080B645E: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B642C - - thumb_func_start sub_80B646C -sub_80B646C: @ 80B646C - push {r4-r6,lr} - mov r6, r8 - push {r6} - mov r8, r0 - adds r4, r1, 0 - adds r5, r2, 0 - adds r6, r3, 0 - lsls r0, 16 - lsrs r0, 16 - mov r8, r0 - lsls r4, 16 - lsrs r4, 16 - lsls r5, 16 - lsrs r5, 16 - lsls r6, 16 - lsrs r6, 16 - ldr r0, =sub_80B64C0 - bl CreateInvisibleSprite - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - ldr r2, =gSprites - adds r1, r2 - strh r4, [r1, 0x24] - strh r5, [r1, 0x26] - strh r6, [r1, 0x38] - mov r2, r8 - strh r2, [r1, 0x3A] - strh r0, [r1, 0x3C] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B646C - - thumb_func_start sub_80B64C0 -sub_80B64C0: @ 80B64C0 - push {lr} - ldr r2, =gUnknown_0855C384 - movs r3, 0x2E - ldrsh r1, [r0, r3] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B64C0 - - thumb_func_start sub_80B64DC -sub_80B64DC: @ 80B64DC - push {r4,lr} - adds r4, r0, 0 - ldrh r1, [r4, 0x30] - movs r2, 0x30 - ldrsh r0, [r4, r2] - cmp r0, 0 - beq _080B64F4 - subs r0, r1, 0x1 - strh r0, [r4, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _080B6550 -_080B64F4: - movs r0, 0x19 - strh r0, [r4, 0x30] - ldr r0, =gUnknown_0855C304 - ldr r1, =gUnknown_0855C3A4 - movs r2, 0x32 - ldrsh r3, [r4, r2] - lsls r3, 2 - adds r3, r1 - ldrh r1, [r4, 0x24] - ldrh r2, [r3] - adds r1, r2 - lsls r1, 16 - asrs r1, 16 - ldrh r2, [r4, 0x26] - ldrh r3, [r3, 0x2] - adds r2, r3 - lsls r2, 16 - asrs r2, 16 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gSprites - lsls r1, r0, 4 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - movs r2, 0x8 - orrs r0, r2 - strb r0, [r1, 0x5] - ldrh r0, [r4, 0x3C] - strh r0, [r1, 0x2E] - ldrh r0, [r4, 0x32] - adds r0, 0x1 - strh r0, [r4, 0x32] - ldrh r0, [r4, 0x3A] - subs r0, 0x1 - strh r0, [r4, 0x3A] - movs r0, 0x17 - bl PlaySE -_080B6550: - movs r1, 0x3A - ldrsh r0, [r4, r1] - cmp r0, 0 - bne _080B6562 - movs r0, 0x20 - strh r0, [r4, 0x30] - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] -_080B6562: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B64DC - - thumb_func_start sub_80B6574 -sub_80B6574: @ 80B6574 - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x30] - subs r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - asrs r2, r0, 16 - cmp r2, 0 - bne _080B65A4 - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] - movs r0, 0x8 - strh r0, [r1, 0x30] - strh r2, [r1, 0x32] - strh r2, [r1, 0x34] - movs r2, 0x38 - ldrsh r0, [r1, r2] - cmp r0, 0 - beq _080B65A4 - movs r0, 0xB8 - lsls r0, 1 - bl PlayFanfare -_080B65A4: - pop {r0} - bx r0 - thumb_func_end sub_80B6574 - - thumb_func_start sub_80B65A8 -sub_80B65A8: @ 80B65A8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - adds r7, r0, 0 - ldrh r0, [r7, 0x30] - subs r0, 0x1 - strh r0, [r7, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _080B65D8 - movs r0, 0x8 - strh r0, [r7, 0x30] - ldrh r0, [r7, 0x32] - adds r0, 0x1 - movs r1, 0x3 - ands r0, r1 - strh r0, [r7, 0x32] - cmp r0, 0 - bne _080B65D8 - ldrh r0, [r7, 0x34] - adds r0, 0x1 - strh r0, [r7, 0x34] -_080B65D8: - ldrh r4, [r7, 0x32] - adds r4, 0x3 - movs r0, 0x3 - mov r8, r0 - mov r1, r8 - ands r4, r1 - ldr r3, =0x00001007 - mov r10, r3 - mov r0, r10 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x84 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - ldr r6, =gUnknown_0855C3BC - adds r1, r4, r6 - ldrb r1, [r1] - ldr r5, =gUnknown_0855C3C0 - adds r2, r4, r5 - ldrb r2, [r2] - ldr r3, =gUnknown_0855C3C4 - mov r9, r3 - add r4, r9 - ldrb r3, [r4] - bl MultiplyInvertedPaletteRGBComponents - ldrh r4, [r7, 0x32] - adds r4, 0x2 - mov r0, r8 - ands r4, r0 - mov r0, r10 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x83 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - adds r1, r4, r6 - ldrb r1, [r1] - adds r2, r4, r5 - ldrb r2, [r2] - add r4, r9 - ldrb r3, [r4] - bl MultiplyInvertedPaletteRGBComponents - ldrh r4, [r7, 0x32] - adds r4, 0x1 - mov r3, r8 - ands r4, r3 - mov r0, r10 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x81 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - adds r1, r4, r6 - ldrb r1, [r1] - adds r2, r4, r5 - ldrb r2, [r2] - add r4, r9 - ldrb r3, [r4] - bl MultiplyInvertedPaletteRGBComponents - ldrh r4, [r7, 0x32] - lsls r4, 24 - lsrs r4, 24 - mov r0, r10 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - ldr r3, =0x01050000 - adds r0, r3 - lsrs r0, 16 - adds r6, r4, r6 - ldrb r6, [r6] - adds r5, r4, r5 - ldrb r5, [r5] - add r4, r9 - ldrb r4, [r4] - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - mov r0, r10 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - ldr r1, =0x01030000 - adds r0, r1 - lsrs r0, 16 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - movs r3, 0x34 - ldrsh r0, [r7, r3] - cmp r0, 0x2 - ble _080B66C2 - ldrh r0, [r7, 0x2E] - adds r0, 0x1 - movs r1, 0 - strh r0, [r7, 0x2E] - movs r0, 0x8 - strh r0, [r7, 0x30] - strh r1, [r7, 0x32] -_080B66C2: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B65A8 - - thumb_func_start sub_80B66E8 -sub_80B66E8: @ 80B66E8 - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r2, r0, 0 - ldrh r0, [r2, 0x30] - subs r0, 0x1 - strh r0, [r2, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _080B6718 - movs r0, 0x8 - strh r0, [r2, 0x30] - ldrh r0, [r2, 0x32] - adds r0, 0x1 - movs r1, 0x3 - ands r0, r1 - strh r0, [r2, 0x32] - cmp r0, 0x3 - bne _080B6718 - ldrh r0, [r2, 0x2E] - adds r0, 0x1 - strh r0, [r2, 0x2E] - movs r0, 0x1E - strh r0, [r2, 0x30] -_080B6718: - ldrh r4, [r2, 0x32] - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x00001007 - mov r8, r0 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x84 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - ldr r1, =gUnknown_0855C3BC - adds r1, r4, r1 - ldrb r6, [r1] - ldr r1, =gUnknown_0855C3C0 - adds r1, r4, r1 - ldrb r5, [r1] - ldr r1, =gUnknown_0855C3C4 - adds r4, r1 - ldrb r4, [r4] - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - mov r0, r8 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x83 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - mov r0, r8 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - movs r1, 0x81 - lsls r1, 17 - adds r0, r1 - lsrs r0, 16 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - mov r0, r8 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - ldr r1, =0x01050000 - adds r0, r1 - lsrs r0, 16 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - mov r0, r8 - bl IndexOfSpritePaletteTag - lsls r0, 24 - lsrs r0, 4 - ldr r1, =0x01030000 - adds r0, r1 - lsrs r0, 16 - adds r1, r6, 0 - adds r2, r5, 0 - adds r3, r4, 0 - bl MultiplyInvertedPaletteRGBComponents - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B66E8 - - thumb_func_start sub_80B67DC -sub_80B67DC: @ 80B67DC - push {lr} - adds r1, r0, 0 - ldrh r0, [r1, 0x30] - subs r0, 0x1 - strh r0, [r1, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _080B67F2 - ldrh r0, [r1, 0x2E] - adds r0, 0x1 - strh r0, [r1, 0x2E] -_080B67F2: - pop {r0} - bx r0 - thumb_func_end sub_80B67DC - - thumb_func_start sub_80B67F8 -sub_80B67F8: @ 80B67F8 - ldrh r1, [r0, 0x2E] - adds r1, 0x1 - strh r1, [r0, 0x2E] - bx lr - thumb_func_end sub_80B67F8 - - thumb_func_start sub_80B6800 -sub_80B6800: @ 80B6800 - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x38 - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080B6816 - bl IsFanfareTaskInactive - lsls r0, 24 - cmp r0, 0 - beq _080B681C -_080B6816: - ldrh r0, [r4, 0x2E] - adds r0, 0x1 - strh r0, [r4, 0x2E] -_080B681C: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80B6800 - - thumb_func_start nullsub_97 -nullsub_97: @ 80B6824 - bx lr - thumb_func_end nullsub_97 - - thumb_func_start sub_80B6828 -sub_80B6828: @ 80B6828 - push {lr} - adds r3, r0, 0 - ldr r2, =gSprites - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0x2E - ldrsh r0, [r0, r1] - cmp r0, 0x4 - ble _080B6848 - adds r0, r3, 0 - bl FieldEffectFreeGraphicsResources -_080B6848: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6828 - - thumb_func_start sub_80B6850 -sub_80B6850: @ 80B6850 - push {r4,lr} - adds r3, r0, 0 - adds r2, r1, 0 - ldr r0, =gUnknown_0855C31C - lsls r3, 16 - asrs r3, 16 - lsls r2, 16 - asrs r2, 16 - adds r1, r3, 0 - movs r3, 0 - bl CreateSpriteAtEnd - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldrb r2, [r0, 0x5] - movs r1, 0xD - negs r1, r1 - ands r1, r2 - movs r2, 0x8 - orrs r1, r2 - strb r1, [r0, 0x5] - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r3] - ldr r1, =gUnknown_0855C2AC - bl SetSubspriteTables - adds r0, r4, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_80B6850 - - thumb_func_start sub_80B68AC -sub_80B68AC: @ 80B68AC - push {r4,lr} - adds r4, r0, 0 - movs r1, 0x2E - ldrsh r0, [r4, r1] - cmp r0, 0 - beq _080B68D0 - movs r0, 0 - strh r0, [r4, 0x2E] - adds r2, r4, 0 - adds r2, 0x3E - ldrb r1, [r2] - subs r0, 0x5 - ands r0, r1 - strb r0, [r2] - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAnim -_080B68D0: - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080B68E4 - adds r0, r4, 0 - bl FieldEffectFreeGraphicsResources -_080B68E4: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_80B68AC - - thumb_func_start sub_80B68EC -sub_80B68EC: @ 80B68EC - push {r4,r5,lr} - lsls r0, 16 - lsrs r5, r0, 16 - lsls r1, 16 - lsrs r1, 16 - lsls r2, 16 - lsrs r2, 16 - lsls r3, 24 - cmp r3, 0 - bne _080B6934 - ldr r0, =gUnknown_0855C334 - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - ldr r1, =gUnknown_0855C2C4 - bl SetSubspriteTables - b _080B6948 - .pool -_080B6934: - ldr r0, =gUnknown_0855C34C - lsls r1, 16 - asrs r1, 16 - lsls r2, 16 - asrs r2, 16 - movs r3, 0 - bl CreateSpriteAtEnd - lsls r0, 24 - lsrs r4, r0, 24 -_080B6948: - ldr r1, =gSprites - lsls r0, r4, 4 - adds r0, r4 - lsls r0, 2 - adds r0, r1 - adds r3, r0, 0 - adds r3, 0x3E - ldrb r1, [r3] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r3] - strh r5, [r0, 0x2E] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B68EC - - thumb_func_start sub_80B6970 -sub_80B6970: @ 80B6970 - push {lr} - adds r3, r0, 0 - ldr r2, =gTasks - movs r0, 0x2E - ldrsh r1, [r3, r0] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r0, r2 - movs r1, 0x26 - ldrsh r0, [r0, r1] - cmp r0, 0 - beq _080B69C6 - ldrh r1, [r3, 0x30] - movs r2, 0x30 - ldrsh r0, [r3, r2] - cmp r0, 0 - beq _080B699E - subs r0, r1, 0x1 - strh r0, [r3, 0x30] - lsls r0, 16 - cmp r0, 0 - bne _080B69C0 -_080B699E: - movs r0, 0x10 - strh r0, [r3, 0x30] - movs r0, 0x3E - adds r0, r3 - mov r12, r0 - ldrb r2, [r0] - lsls r0, r2, 29 - lsrs r0, 31 - movs r1, 0x1 - eors r1, r0 - lsls r1, 2 - movs r0, 0x5 - negs r0, r0 - ands r0, r2 - orrs r0, r1 - mov r1, r12 - strb r0, [r1] -_080B69C0: - ldrh r0, [r3, 0x32] - adds r0, 0x1 - strh r0, [r3, 0x32] -_080B69C6: - movs r2, 0x32 - ldrsh r0, [r3, r2] - cmp r0, 0x7F - ble _080B69D4 - adds r0, r3, 0 - bl FieldEffectFreeGraphicsResources -_080B69D4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80B6970 - thumb_func_start sub_80B69DC sub_80B69DC: @ 80B69DC push {lr} @@ -5609,7 +3674,7 @@ overworld_bg_setup_2: @ 80B87B8 ldrh r1, [r4, 0x26] lsls r1, 24 lsrs r1, 24 - bl sub_80B6070 + bl FreeResourcesAndDestroySprite movs r0, 0x6 bl FieldEffectActiveListRemove ldr r0, =sub_80B8554 @@ -5939,7 +4004,7 @@ sub_80B8A64: @ 80B8A64 ldrh r1, [r4, 0x26] lsls r1, 24 lsrs r1, 24 - bl sub_80B6070 + bl FreeResourcesAndDestroySprite movs r0, 0x6 bl FieldEffectActiveListRemove ldr r0, =sub_80B88B4 @@ -6177,7 +4242,7 @@ sub_80B8C60: @ 80B8C60 str r4, [sp] movs r4, 0 str r4, [sp, 0x4] - bl sub_80B5FE8 + bl CreateMonSprite_FieldMove lsls r0, 24 lsrs r0, 24 lsls r2, r0, 4 diff --git a/asm/field_effect_helpers.s b/asm/field_effect_helpers.s index 754a8f7ff..77f8213b3 100644 --- a/asm/field_effect_helpers.s +++ b/asm/field_effect_helpers.s @@ -204,7 +204,7 @@ _0815405A: bl pal_patch_for_npc _0815406A: adds r0, r4, 0 - bl sub_80ABE18 + bl UpdateSpritePaletteWithWeather _08154070: pop {r4} pop {r0} @@ -227,7 +227,7 @@ npc_pal_op_A: @ 8154078 adds r1, r4, 0 bl pal_patch_for_npc adds r0, r4, 0 - bl sub_80ABE18 + bl UpdateSpritePaletteWithWeather _0815409C: pop {r4} pop {r0} diff --git a/asm/field_screen.s b/asm/field_screen.s index e3d48f882..d07fafbe4 100644 --- a/asm/field_screen.s +++ b/asm/field_screen.s @@ -1779,9 +1779,9 @@ sub_80ABDFC: @ 80ABDFC .pool thumb_func_end sub_80ABDFC - thumb_func_start sub_80ABE18 -@ void sub_80ABE18(u8 a1) -sub_80ABE18: @ 80ABE18 + thumb_func_start UpdateSpritePaletteWithWeather +@ void UpdateSpritePaletteWithWeather(u8 a1) +UpdateSpritePaletteWithWeather: @ 80ABE18 push {r4-r6,lr} lsls r0, 24 lsrs r0, 8 @@ -1882,7 +1882,7 @@ _080ABEF4: pop {r0} bx r0 .pool - thumb_func_end sub_80ABE18 + thumb_func_end UpdateSpritePaletteWithWeather thumb_func_start ApplyWeatherGammaShiftToPal ApplyWeatherGammaShiftToPal: @ 80ABF00 @@ -1939,7 +1939,7 @@ sub_80ABF4C: @ 80ABF4C movs r2, 0x20 bl LoadPalette ldrb r0, [r4] - bl sub_80ABE18 + bl UpdateSpritePaletteWithWeather pop {r4} pop {r0} bx r0 @@ -2504,8 +2504,8 @@ sub_80AC3E4: @ 80AC3E4 .pool thumb_func_end sub_80AC3E4 - thumb_func_start sub_80AC3F8 -sub_80AC3F8: @ 80AC3F8 + thumb_func_start PreservePaletteInWeather +PreservePaletteInWeather: @ 80AC3F8 push {r4,r5,lr} adds r4, r0, 0 lsls r4, 24 @@ -2524,16 +2524,16 @@ sub_80AC3F8: @ 80AC3F8 pop {r0} bx r0 .pool - thumb_func_end sub_80AC3F8 + thumb_func_end PreservePaletteInWeather - thumb_func_start sub_80AC428 -sub_80AC428: @ 80AC428 + thumb_func_start ResetPreservedPalettesInWeather +ResetPreservedPalettesInWeather: @ 80AC428 ldr r1, =gUnknown_03000F50 ldr r0, =gUnknown_0854C250 str r0, [r1] bx lr .pool - thumb_func_end sub_80AC428 + thumb_func_end ResetPreservedPalettesInWeather thumb_func_start sub_80AC438 sub_80AC438: @ 80AC438 diff --git a/asm/pokenav.s b/asm/pokenav.s index 9c42ed730..c36dfbeca 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -26676,7 +26676,7 @@ _081D4B3A: bl IndexOfSpritePaletteTag lsls r0, 24 lsrs r0, 24 - bl sub_80ABE18 + bl UpdateSpritePaletteWithWeather ldrh r1, [r5, 0x10] mov r0, sp strh r1, [r0] diff --git a/asm/script_menu.s b/asm/script_menu.s index 0624dba83..a2e2ec59e 100644 --- a/asm/script_menu.s +++ b/asm/script_menu.s @@ -1316,7 +1316,7 @@ _080E28CA: ldr r1, =gSprites adds r0, r1 ldrb r1, [r4, 0xC] - bl sub_80B6070 + bl FreeResourcesAndDestroySprite _080E28DE: ldrh r0, [r4, 0x8] adds r0, 0x1 @@ -1363,7 +1363,7 @@ ScriptMenu_ShowPokemonPic: @ 80E2900 asrs r2, 16 mov r0, r8 movs r3, 0 - bl sub_80B5F84 + bl CreateMonSprite_PicBox adds r5, r0, 0 lsls r5, 24 lsrs r5, 24 diff --git a/asm/slot_machine.s b/asm/slot_machine.s index 88f73fe2c..fc475c2e3 100644 --- a/asm/slot_machine.s +++ b/asm/slot_machine.s @@ -5583,7 +5583,7 @@ _0812D08E: lsrs r3, 24 adds r1, r3, 0 adds r2, r3, 0 - bl sub_80B6128 + bl MultiplyPaletteRGBComponents _0812D0A6: pop {r4-r7} pop {r0} diff --git a/data/field_effect.s b/data/field_effect.s index e6f8a558e..2cedc4a91 100644 --- a/data/field_effect.s +++ b/data/field_effect.s @@ -81,7 +81,7 @@ gUnknown_0855C170:: @ 855C170 .incbin "graphics/unknown/unknown_55C170.4bpp" .align 2 -gUnknown_0855C1F0:: @ 855C1F0 +gFieldEffectScriptFuncs:: @ 855C1F0 .4byte FieldEffectCmd_loadtiles .4byte FieldEffectCmd_loadfadedpal .4byte FieldEffectCmd_loadpal @@ -196,45 +196,45 @@ gUnknown_0855C300:: @ 855C300 .4byte gUnknown_0855C2CC .align 2 -gUnknown_0855C304:: @ 855C304 - spr_template 0xffff, 0x1007, gOamData_855C218, gUnknown_0855C2F8, gUnknown_855C274, gDummySpriteAffineAnimTable, sub_80B6828 +gSpriteTemplate_855C304:: @ 855C304 + spr_template 0xffff, 0x1007, gOamData_855C218, gUnknown_0855C2F8, gUnknown_855C274, gDummySpriteAffineAnimTable, SpriteCB_PokeballGlow .align 2 -gUnknown_0855C31C:: @ 855C31C - spr_template 0xffff, 0x1004, gOamData_855C220, gUnknown_0855C2F8, gUnknown_855C27C, gDummySpriteAffineAnimTable, sub_80B68AC +gSpriteTemplate_855C31C:: @ 855C31C + spr_template 0xffff, 0x1004, gOamData_855C220, gUnknown_0855C2F8, gUnknown_855C27C, gDummySpriteAffineAnimTable, SpriteCB_PokecenterMonitor .align 2 -gUnknown_0855C334:: @ 855C334 - spr_template 0xffff, 0x1010, gOamData_855C220, gUnknown_0855C300, gUnknown_855C28C, gDummySpriteAffineAnimTable, sub_80B6970 +gSpriteTemplate_855C334:: @ 855C334 + spr_template 0xffff, 0x1010, gOamData_855C220, gUnknown_0855C300, gUnknown_855C28C, gDummySpriteAffineAnimTable, SpriteCB_HallOfFameMonitor .align 2 -gUnknown_0855C34C:: @ 855C34C - spr_template 0xffff, 0x1010, gOamData_855C26C, gUnknown_0855C300, gUnknown_855C294, gDummySpriteAffineAnimTable, sub_80B6970 +gSpriteTemplate_855C34C:: @ 855C34C + spr_template 0xffff, 0x1010, gOamData_855C26C, gUnknown_0855C300, gUnknown_855C294, gDummySpriteAffineAnimTable, SpriteCB_HallOfFameMonitor .align 2 gUnknown_0855C364:: @ 855C364 - .4byte sub_80B6214 - .4byte sub_80B6250 - .4byte sub_80B628C - .4byte sub_80B62B4 + .4byte PokecenterHealEffect_0 + .4byte PokecenterHealEffect_1 + .4byte PokecenterHealEffect_2 + .4byte PokecenterHealEffect_3 .align 2 gUnknown_0855C374:: @ 855C374 - .4byte sub_80B6360 - .4byte sub_80B63D4 - .4byte sub_80B6404 - .4byte sub_80B642C + .4byte HallOfFameRecordEffect_0 + .4byte HallOfFameRecordEffect_1 + .4byte HallOfFameRecordEffect_2 + .4byte HallOfFameRecordEffect_3 .align 2 gUnknown_0855C384:: @ 855C384 - .4byte sub_80B64DC - .4byte sub_80B6574 - .4byte sub_80B65A8 - .4byte sub_80B66E8 - .4byte sub_80B67DC - .4byte sub_80B67F8 - .4byte sub_80B6800 - .4byte nullsub_97 + .4byte PokeballGlowEffect_0 + .4byte PokeballGlowEffect_1 + .4byte PokeballGlowEffect_2 + .4byte PokeballGlowEffect_3 + .4byte PokeballGlowEffect_4 + .4byte PokeballGlowEffect_5 + .4byte PokeballGlowEffect_6 + .4byte PokeballGlowEffect_7 .align 1 gUnknown_0855C3A4:: @ 855C3A4 diff --git a/data/field_effect_scripts.s b/data/field_effect_scripts.s index c06497093..db8a2b339 100644 --- a/data/field_effect_scripts.s +++ b/data/field_effect_scripts.s @@ -175,7 +175,7 @@ gFieldEffectScript_DeepSandFootprints:: @ 82DBBAC gFieldEffectScript_Unknown25:: @ 82DBBB6 field_eff_loadfadedpal gFieldEffectObjectPaletteInfo4 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, sub_80B61A0 + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo0, FldEff_PokecenterHeal field_eff_end gFieldEffectScript_Unknown26:: @ 82DBBC5 @@ -325,7 +325,7 @@ gFieldEffectScript_Unknown61:: @ 82DBCD8 gFieldEffectScript_Unknown62:: @ 82DBCDE field_eff_loadfadedpal gFieldEffectObjectPaletteInfo4 - field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo5, sub_80B62F4 + field_eff_loadfadedpal_callnative gFieldEffectObjectPaletteInfo5, FldEff_HallOfFameRecord field_eff_end gFieldEffectScript_Unknown63:: @ 82DBCED diff --git a/include/field_effect.h b/include/field_effect.h index 700256f30..d7eea08f4 100644 --- a/include/field_effect.h +++ b/include/field_effect.h @@ -1,6 +1,12 @@ #ifndef GUARD_FIELD_EFFECTS_H #define GUARD_FIELD_EFFECTS_H +extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[2]; +extern const struct SpritePalette gNewGameBirchObjectPaletteInfo; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[2]; +extern const struct SpriteTemplate gNewGameBirchObjectTemplate; +extern const struct OamData gNewGameBirchOamAttributes; + enum FieldEffectScriptIdx { FLDEFF_EXCLAMATION_MARK_ICON_1, @@ -70,6 +76,8 @@ enum FieldEffectScriptIdx }; extern u32 gFieldEffectArguments[8]; +extern void (*gUnknown_0203CEEC)(void); +extern bool8 (*gUnknown_03005DB0)(void); u32 FieldEffectStart(u8); bool8 FieldEffectActiveListContains(u8 id); @@ -80,7 +88,12 @@ u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buf void sub_80B7FC8(void); void FieldEffectActiveListRemove(u8 id); void MultiplyInvertedPaletteRGBComponents(u16, u8, u8, u8); -extern void (*gUnknown_0203CEEC)(void); -extern bool8 (*gUnknown_03005DB0)(void); +void FieldEffectActiveListAdd(u8 id); +void FieldEffectScript_LoadTiles(u8 **script); +void FieldEffectScript_LoadFadedPalette(u8 **script); +void FieldEffectScript_LoadPalette(u8 **script); +void FieldEffectScript_CallNative(u8 **script, u32 *val); +void FieldEffectFreeTilesIfUnused(u16 tileStart); +void FieldEffectFreePaletteIfUnused(u8 paletteNum); #endif //GUARD_FIELD_EFFECTS_H diff --git a/include/field_screen.h b/include/field_screen.h index 02e0a0a91..36afac53d 100644 --- a/include/field_screen.h +++ b/include/field_screen.h @@ -12,5 +12,6 @@ void sub_80AF168(void); void UpdateWeatherPerDay(u16 days); void sub_80AC3D0(void); void sub_80AC3E4(void); +void PreservePaletteInWeather(u8); #endif //GUARD_FIELD_SCREEN_H diff --git a/include/pokemon.h b/include/pokemon.h index cd79a217d..b6b0d6d36 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -482,6 +482,7 @@ extern const u8 gUnknown_08329D2A[]; extern const u8 gStatStageRatios[][2]; extern const u16 gUnknown_08329D54[]; extern const struct SpriteTemplate gUnknown_08329D98[]; +extern const struct CompressedSpritePalette gMonPaletteTable[]; void ZeroBoxMonData(struct BoxPokemon *boxMon); void ZeroMonData(struct Pokemon *mon); diff --git a/ld_script.txt b/ld_script.txt index 99633e2fa..14c76e117 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -121,6 +121,7 @@ SECTIONS { asm/cable_club.o(.text); src/trainer_see.o(.text); src/wild_encounter.o(.text); + src/field_effect.o(.text); asm/field_effect.o(.text); src/scanline_effect.o(.text); src/option_menu.o(.text); diff --git a/src/field_effect.c b/src/field_effect.c index 628dc776a..4c5c7cf54 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,15 +1,922 @@ // Includes #include "global.h" +#include "field_effect.h" +#include "battle_dome_cards.h" +#include "decompress.h" +#include "field_screen.h" +#include "field_weather.h" +#include "palette.h" +#include "pokemon.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "constants/rgb.h" +#include "constants/songs.h" // Static type declarations // Static RAM declarations -IWRAM_DATA u8 gUnknown_03000F58[32]; +IWRAM_DATA u8 sActiveList[32]; // Static ROM declarations +extern u8 *gFieldEffectScriptPointers[]; + // .rodata +extern const struct SubspriteTable gUnknown_0855C2AC;// = subsprite_table(Unknown_39F180); + +extern const struct SubspriteTable gUnknown_0855C2C4;// = subsprite_table(Unknown_39F1A8); + +extern const struct SpriteTemplate gSpriteTemplate_855C304/* = { + .tileTag = 0xffff, + .paletteTag = 4103, + .oam = &gOamData_839F0FC, + .anims = gSpriteAnimTable_839F1FC, + .images = gSpriteImageTable_839F158, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PokeballGlow +}*/; + +extern const struct SpriteTemplate gSpriteTemplate_855C31C/* = { + .tileTag = 0xffff, + .paletteTag = 4100, + .oam = &gOamData_839F104, + .anims = gSpriteAnimTable_839F1FC, + .images = gSpriteImageTable_839F160, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_PokecenterMonitor +}*/; + +extern const struct SpriteTemplate gSpriteTemplate_855C334/* = { + .tileTag = 0xffff, + .paletteTag = 4112, + .oam = &gOamData_839F104, + .anims = gSpriteAnimTable_839F204, + .images = gSpriteImageTable_839F170, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_HallOfFameMonitor +}*/; + +extern const struct SpriteTemplate gSpriteTemplate_855C34C/* = { + .tileTag = 0xffff, + .paletteTag = 4112, + .oam = &gOamData_839F150, + .anims = gSpriteAnimTable_839F204, + .images = gSpriteImageTable_839F178, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_HallOfFameMonitor +}*/; + +extern bool8 (*const gFieldEffectScriptFuncs[])(u8 **, u32 *)/* = { + FieldEffectCmd_loadtiles, + FieldEffectCmd_loadfadedpal, + FieldEffectCmd_loadpal, + FieldEffectCmd_callnative, + FieldEffectCmd_end, + FieldEffectCmd_loadgfx_callnative, + FieldEffectCmd_loadtiles_callnative, + FieldEffectCmd_loadfadedpal_callnative, +}*/; + +extern void (*const gUnknown_0855C364[])(struct Task *)/* = { + PokecenterHealEffect_0, + PokecenterHealEffect_1, + PokecenterHealEffect_2, + PokecenterHealEffect_3 +}*/; + +extern void (*const gUnknown_0855C374[])(struct Task *)/* = { + HallOfFameRecordEffect_0, + HallOfFameRecordEffect_1, + HallOfFameRecordEffect_2, + HallOfFameRecordEffect_3 +}*/; + +extern void (*const gUnknown_0855C384[])(struct Sprite *)/* = { + PokeballGlowEffect_0, + PokeballGlowEffect_1, + PokeballGlowEffect_2, + PokeballGlowEffect_3, + PokeballGlowEffect_4, + PokeballGlowEffect_5, + PokeballGlowEffect_6, + PokeballGlowEffect_7 +}*/; + +extern const struct Coords16 gUnknown_0855C3A4[]/* = { + {.x = 0, .y = 0}, + {.x = 6, .y = 0}, + {.x = 0, .y = 4}, + {.x = 6, .y = 4}, + {.x = 0, .y = 8}, + {.x = 6, .y = 8} +}*/; + +extern const u8 gUnknown_0855C3BC[];// = {16, 12, 8, 0}; +extern const u8 gUnknown_0855C3C0[];// = {16, 12, 8, 0}; +extern const u8 gUnknown_0855C3C4[];// = { 0, 0, 0, 0}; + // .text + +u32 FieldEffectStart(u8 id) +{ + u8 *script; + u32 val; + + FieldEffectActiveListAdd(id); + + script = gFieldEffectScriptPointers[id]; + + while (gFieldEffectScriptFuncs[*script](&script, &val)) + ; + + return val; +} + +bool8 FieldEffectCmd_loadtiles(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadTiles(script); + return TRUE; +} + +bool8 FieldEffectCmd_loadfadedpal(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadFadedPalette(script); + return TRUE; +} + +bool8 FieldEffectCmd_loadpal(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadPalette(script); + return TRUE; +} + +bool8 FieldEffectCmd_callnative(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_CallNative(script, val); + return TRUE; +} + +bool8 FieldEffectCmd_end(u8 **script, u32 *val) +{ + return FALSE; +} + +bool8 FieldEffectCmd_loadgfx_callnative(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadTiles(script); + FieldEffectScript_LoadFadedPalette(script); + FieldEffectScript_CallNative(script, val); + return TRUE; +} + +bool8 FieldEffectCmd_loadtiles_callnative(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadTiles(script); + FieldEffectScript_CallNative(script, val); + return TRUE; +} + +bool8 FieldEffectCmd_loadfadedpal_callnative(u8 **script, u32 *val) +{ + (*script)++; + FieldEffectScript_LoadFadedPalette(script); + FieldEffectScript_CallNative(script, val); + return TRUE; +} + +u32 FieldEffectScript_ReadWord(u8 **script) +{ + return (*script)[0] + + ((*script)[1] << 8) + + ((*script)[2] << 16) + + ((*script)[3] << 24); +} + +void FieldEffectScript_LoadTiles(u8 **script) +{ + struct SpriteSheet *sheet = (struct SpriteSheet *)FieldEffectScript_ReadWord(script); + if (GetSpriteTileStartByTag(sheet->tag) == 0xFFFF) + LoadSpriteSheet(sheet); + (*script) += 4; +} + +void FieldEffectScript_LoadFadedPalette(u8 **script) +{ + struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); + LoadSpritePalette(palette); + UpdateSpritePaletteWithWeather(IndexOfSpritePaletteTag(palette->tag)); + (*script) += 4; +} + +void FieldEffectScript_LoadPalette(u8 **script) +{ + struct SpritePalette *palette = (struct SpritePalette *)FieldEffectScript_ReadWord(script); + LoadSpritePalette(palette); + (*script) += 4; +} + +void FieldEffectScript_CallNative(u8 **script, u32 *val) +{ + u32 (*func)(void) = (u32 (*)(void))FieldEffectScript_ReadWord(script); + *val = func(); + (*script) += 4; +} + +void FieldEffectFreeGraphicsResources(struct Sprite *sprite) +{ + u16 sheetTileStart = sprite->sheetTileStart; + u32 paletteNum = sprite->oam.paletteNum; + DestroySprite(sprite); + FieldEffectFreeTilesIfUnused(sheetTileStart); + FieldEffectFreePaletteIfUnused(paletteNum); +} + +void FieldEffectStop(struct Sprite *sprite, u8 id) +{ + FieldEffectFreeGraphicsResources(sprite); + FieldEffectActiveListRemove(id); +} + +void FieldEffectFreeTilesIfUnused(u16 tileStart) +{ + u8 i; + u16 tag = GetSpriteTileTagByTileStart(tileStart); + + if (tag != 0xFFFF) + { + for (i = 0; i < MAX_SPRITES; i++) + if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart) + return; + FreeSpriteTilesByTag(tag); + } +} + +void FieldEffectFreePaletteIfUnused(u8 paletteNum) +{ + u8 i; + u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum); + + if (tag != 0xFFFF) + { + for (i = 0; i < MAX_SPRITES; i++) + if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum) + return; + FreeSpritePaletteByTag(tag); + } +} + +void FieldEffectActiveListClear(void) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sActiveList); i++) + sActiveList[i] = 0xFF; +} + +void FieldEffectActiveListAdd(u8 id) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sActiveList); i++) + { + if (sActiveList[i] == 0xFF) + { + sActiveList[i] = id; + return; + } + } +} + +void FieldEffectActiveListRemove(u8 id) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sActiveList); i++) + { + if (sActiveList[i] == id) + { + sActiveList[i] = 0xFF; + return; + } + } +} + +bool8 FieldEffectActiveListContains(u8 id) +{ + u8 i; + for (i = 0; i < ARRAY_COUNT(sActiveList); i++) + if (sActiveList[i] == id) + return TRUE; + return FALSE; +} + +u8 CreateTrainerSprite(u8 trainerSpriteID, s16 x, s16 y, u8 subpriority, u8 *buffer) +{ + struct SpriteTemplate spriteTemplate; + LoadCompressedObjectPaletteOverrideBuffer(&gTrainerFrontPicPaletteTable[trainerSpriteID], buffer); + LoadCompressedObjectPicOverrideBuffer(&gTrainerFrontPicTable[trainerSpriteID], buffer); + spriteTemplate.tileTag = gTrainerFrontPicTable[trainerSpriteID].tag; + spriteTemplate.paletteTag = gTrainerFrontPicPaletteTable[trainerSpriteID].tag; + spriteTemplate.oam = &gNewGameBirchOamAttributes; + spriteTemplate.anims = gDummySpriteAnimTable; + spriteTemplate.images = NULL; + spriteTemplate.affineAnims = gDummySpriteAffineAnimTable; + spriteTemplate.callback = SpriteCallbackDummy; + return CreateSprite(&spriteTemplate, x, y, subpriority); +} + +void LoadTrainerGfx_TrainerCard(u8 gender, u16 palOffset, u8 *dest) +{ + LZDecompressVram(gTrainerFrontPicTable[gender].data, dest); + LoadCompressedPalette(gTrainerFrontPicPaletteTable[gender].data, palOffset, 0x20); +} + +u8 AddNewGameBirchObject(s16 x, s16 y, u8 subpriority) +{ + LoadSpritePalette(&gNewGameBirchObjectPaletteInfo); + return CreateSprite(&gNewGameBirchObjectTemplate, x, y, subpriority); +} + +#ifdef NONMATCHING +u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y) +{ + u16 spriteId = sub_818D7D8(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag); + PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10); + if (spriteId == 0xFFFF) + return 0x40; + + return spriteId; +} +#else +ASM_DIRECT +u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y) +{ + asm_unified("push {r4,r5,lr}\n\ + sub sp, 0x10\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + movs r3, 0x80\n\ + lsls r3, 8\n\ + lsls r1, 16\n\ + asrs r1, 16\n\ + str r1, [sp]\n\ + lsls r2, 16\n\ + asrs r2, 16\n\ + str r2, [sp, 0x4]\n\ + movs r1, 0\n\ + str r1, [sp, 0x8]\n\ + ldr r1, =gMonPaletteTable\n\ + lsls r4, r0, 3\n\ + adds r4, r1\n\ + ldrh r1, [r4, 0x4]\n\ + str r1, [sp, 0xC]\n\ + movs r1, 0\n\ + adds r2, r3, 0\n\ + movs r3, 0x1\n\ + bl sub_818D7D8\n\ + lsls r0, 16\n\ + lsrs r5, r0, 16\n\ + ldrh r0, [r4, 0x4]\n\ + bl IndexOfSpritePaletteTag\n\ + adds r0, 0x10\n\ + lsls r0, 24\n\ + lsrs r0, 24\n\ + bl PreservePaletteInWeather\n\ + ldr r0, =0x0000ffff\n\ + cmp r5, r0\n\ + beq _080B5FDC\n\ + lsls r0, r5, 24\n\ + lsrs r0, 24\n\ + b _080B5FDE\n\ + .pool\n\ +_080B5FDC:\n\ + movs r0, 0x40\n\ +_080B5FDE:\n\ + add sp, 0x10\n\ + pop {r4,r5}\n\ + pop {r1}\n\ + bx r1"); +} +#endif //NONMATCHING + +u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y) +{ + const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g); + u16 spriteId = sub_818D7D8(species, d, g, 1, x, y, 0, spritePalette->tag); + PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); + if (spriteId == 0xFFFF) + return 0x40; + + return spriteId; +} + +void FreeResourcesAndDestroySprite(struct Sprite *sprite, u8 spriteId) +{ + ResetPreservedPalettesInWeather(); + if (sprite->oam.affineMode != 0) + { + FreeOamMatrix(sprite->oam.matrixNum); + } + sub_818D820(spriteId); +} + +#ifdef NONMATCHING +void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + int curRed; + int curGreen; + int curBlue; + + curRed = gPlttBufferUnfaded[i] & 0x1f; + curGreen = (gPlttBufferUnfaded[i] & (0x1f << 5)) >> 5; + curBlue = (gPlttBufferUnfaded[i] & (0x1f << 10)) >> 10; + curRed += (((0x1f - curRed) * r) >> 4); + curGreen += (((0x1f - curGreen) * g) >> 4); + curBlue += (((0x1f - curBlue) * b) >> 4); + gPlttBufferFaded[i] = RGB(curRed, curGreen, curBlue); +} + +void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + int curRed; + int curGreen; + int curBlue; + + curRed = gPlttBufferUnfaded[i] & 0x1f; + curGreen = (gPlttBufferUnfaded[i] & (0x1f << 5)) >> 5; + curBlue = (gPlttBufferUnfaded[i] & (0x1f << 10)) >> 10; + curRed -= ((curRed * r) >> 4); + curGreen -= ((curGreen * g) >> 4); + curBlue -= ((curBlue * b) >> 4); + gPlttBufferFaded[i] = RGB(curRed, curGreen, curBlue); +} +#else +ASM_DIRECT +void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + asm(".syntax unified\n" + "\tpush {r4-r7,lr}\n" + "\tmov r7, r9\n" + "\tmov r6, r8\n" + "\tpush {r6,r7}\n" + "\tlsls r0, 16\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tlsls r3, 24\n" + "\tlsrs r3, 24\n" + "\tldr r4, _08085D00 @ =gPlttBufferUnfaded\n" + "\tlsrs r0, 15\n" + "\tadds r4, r0, r4\n" + "\tldrh r4, [r4]\n" + "\tmovs r5, 0x1F\n" + "\tmov r9, r5\n" + "\tmov r8, r4\n" + "\tmov r6, r8\n" + "\tands r6, r5\n" + "\tmov r8, r6\n" + "\tmovs r6, 0xF8\n" + "\tlsls r6, 2\n" + "\tands r6, r4\n" + "\tlsrs r6, 5\n" + "\tmovs r5, 0xF8\n" + "\tlsls r5, 7\n" + "\tands r4, r5\n" + "\tlsrs r4, 10\n" + "\tmov r7, r9\n" + "\tmov r5, r8\n" + "\tsubs r7, r5\n" + "\tmov r12, r7\n" + "\tmov r7, r12\n" + "\tmuls r7, r1\n" + "\tadds r1, r7, 0\n" + "\tasrs r1, 4\n" + "\tadd r8, r1\n" + "\tmov r5, r9\n" + "\tsubs r1, r5, r6\n" + "\tmuls r1, r2\n" + "\tasrs r1, 4\n" + "\tadds r6, r1\n" + "\tsubs r5, r4\n" + "\tmov r9, r5\n" + "\tmov r1, r9\n" + "\tmuls r1, r3\n" + "\tasrs r1, 4\n" + "\tadds r4, r1\n" + "\tmov r7, r8\n" + "\tlsls r7, 16\n" + "\tlsls r6, 21\n" + "\torrs r6, r7\n" + "\tlsls r4, 26\n" + "\torrs r4, r6\n" + "\tlsrs r4, 16\n" + "\tldr r1, _08085D04 @ =gPlttBufferFaded\n" + "\tadds r0, r1\n" + "\tstrh r4, [r0]\n" + "\tpop {r3,r4}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_08085D00: .4byte gPlttBufferUnfaded\n" + "_08085D04: .4byte gPlttBufferFaded\n" + ".syntax divided"); +} + +ASM_DIRECT +void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) +{ + asm(".syntax unified\n" + "\tpush {r4-r6,lr}\n" + "\tmov r6, r8\n" + "\tpush {r6}\n" + "\tlsls r0, 16\n" + "\tlsls r1, 24\n" + "\tlsrs r1, 24\n" + "\tlsls r2, 24\n" + "\tlsrs r2, 24\n" + "\tlsls r3, 24\n" + "\tlsrs r3, 24\n" + "\tldr r4, _08085D78 @ =gPlttBufferUnfaded\n" + "\tlsrs r0, 15\n" + "\tadds r4, r0, r4\n" + "\tldrh r4, [r4]\n" + "\tmovs r5, 0x1F\n" + "\tmov r8, r5\n" + "\tmov r6, r8\n" + "\tands r6, r4\n" + "\tmov r8, r6\n" + "\tmovs r5, 0xF8\n" + "\tlsls r5, 2\n" + "\tands r5, r4\n" + "\tlsrs r5, 5\n" + "\tmovs r6, 0xF8\n" + "\tlsls r6, 7\n" + "\tands r4, r6\n" + "\tlsrs r4, 10\n" + "\tmov r6, r8\n" + "\tmuls r6, r1\n" + "\tadds r1, r6, 0\n" + "\tasrs r1, 4\n" + "\tmov r6, r8\n" + "\tsubs r6, r1\n" + "\tadds r1, r5, 0\n" + "\tmuls r1, r2\n" + "\tasrs r1, 4\n" + "\tsubs r5, r1\n" + "\tadds r1, r4, 0\n" + "\tmuls r1, r3\n" + "\tasrs r1, 4\n" + "\tsubs r4, r1\n" + "\tlsls r6, 16\n" + "\tlsls r5, 21\n" + "\torrs r5, r6\n" + "\tlsls r4, 26\n" + "\torrs r4, r5\n" + "\tlsrs r4, 16\n" + "\tldr r1, _08085D7C @ =gPlttBufferFaded\n" + "\tadds r0, r1\n" + "\tstrh r4, [r0]\n" + "\tpop {r3}\n" + "\tmov r8, r3\n" + "\tpop {r4-r6}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.align 2, 0\n" + "_08085D78: .4byte gPlttBufferUnfaded\n" + "_08085D7C: .4byte gPlttBufferFaded\n" + ".syntax divided"); +} +#endif + +void Task_PokecenterHeal(u8 taskId); +u8 CreatePokeballGlowSprite(s16, s16, s16, u16); +u8 PokecenterHealEffectHelper(s16, s16); + +bool8 FldEff_PokecenterHeal(void) +{ + u8 nPokemon; + struct Task *task; + + nPokemon = CalculatePlayerPartyCount(); + task = &gTasks[CreateTask(Task_PokecenterHeal, 0xff)]; + task->data[1] = nPokemon; + task->data[2] = 0x5d; + task->data[3] = 0x24; + task->data[4] = 0x7c; + task->data[5] = 0x18; + return FALSE; +} + +void Task_PokecenterHeal(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + gUnknown_0855C364[task->data[0]](task); +} + +void PokecenterHealEffect_0(struct Task *task) +{ + task->data[0]++; + task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 1); + task->data[7] = PokecenterHealEffectHelper(task->data[4], task->data[5]); +} + +void PokecenterHealEffect_1(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 1) + { + gSprites[task->data[7]].data[0]++; + task->data[0]++; + } +} + +void PokecenterHealEffect_2(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 4) + { + task->data[0]++; + } +} + +void PokecenterHealEffect_3(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 6) + { + DestroySprite(&gSprites[task->data[6]]); + FieldEffectActiveListRemove(FLDEFF_POKECENTER_HEAL); + DestroyTask(FindTaskIdByFunc(Task_PokecenterHeal)); + } +} + +void Task_HallOfFameRecord(u8 taskId); +void HallOfFameRecordEffectHelper(s16, s16, s16, u8); + +bool8 FldEff_HallOfFameRecord(void) +{ + u8 nPokemon; + struct Task *task; + + nPokemon = CalculatePlayerPartyCount(); + task = &gTasks[CreateTask(Task_HallOfFameRecord, 0xff)]; + task->data[1] = nPokemon; + task->data[2] = 0x75; + task->data[3] = 0x34; + return FALSE; +} + +void Task_HallOfFameRecord(u8 taskId) +{ + struct Task *task; + task = &gTasks[taskId]; + gUnknown_0855C374[task->data[0]](task); +} + +void HallOfFameRecordEffect_0(struct Task *task) +{ + u8 taskId; + task->data[0]++; + task->data[6] = CreatePokeballGlowSprite(task->data[1], task->data[2], task->data[3], 0); + taskId = FindTaskIdByFunc(Task_HallOfFameRecord); + HallOfFameRecordEffectHelper(taskId, 0x78, 0x18, 0); + HallOfFameRecordEffectHelper(taskId, 0x28, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0x48, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0xa8, 0x08, 1); + HallOfFameRecordEffectHelper(taskId, 0xc8, 0x08, 1); +} + +void HallOfFameRecordEffect_1(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 1) + { + task->data[15]++; // was this ever initialized? is this ever used? + task->data[0]++; + } +} + +void HallOfFameRecordEffect_2(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 4) + { + task->data[0]++; + } +} + +void HallOfFameRecordEffect_3(struct Task *task) +{ + if (gSprites[task->data[6]].data[0] > 6) + { + DestroySprite(&gSprites[task->data[6]]); + FieldEffectActiveListRemove(FLDEFF_HALL_OF_FAME_RECORD); + DestroyTask(FindTaskIdByFunc(Task_HallOfFameRecord)); + } +} + +void SpriteCB_PokeballGlowEffect(struct Sprite *); + +u8 CreatePokeballGlowSprite(s16 data6, s16 x, s16 y, u16 data5) +{ + u8 spriteId; + struct Sprite *sprite; + spriteId = CreateInvisibleSprite(SpriteCB_PokeballGlowEffect); + sprite = &gSprites[spriteId]; + sprite->pos2.x = x; + sprite->pos2.y = y; + sprite->data[5] = data5; + sprite->data[6] = data6; + sprite->data[7] = spriteId; + return spriteId; +} + +void SpriteCB_PokeballGlowEffect(struct Sprite *sprite) +{ + gUnknown_0855C384[sprite->data[0]](sprite); +} + +void PokeballGlowEffect_0(struct Sprite *sprite) +{ + u8 endSpriteId; + if (sprite->data[1] == 0 || (--sprite->data[1]) == 0) + { + sprite->data[1] = 25; + endSpriteId = CreateSpriteAtEnd(&gSpriteTemplate_855C304, gUnknown_0855C3A4[sprite->data[2]].x + sprite->pos2.x, gUnknown_0855C3A4[sprite->data[2]].y + sprite->pos2.y, 0); + gSprites[endSpriteId].oam.priority = 2; + gSprites[endSpriteId].data[0] = sprite->data[7]; + sprite->data[2]++; + sprite->data[6]--; + PlaySE(SE_BOWA); + } + if (sprite->data[6] == 0) + { + sprite->data[1] = 32; + sprite->data[0]++; + } +} + +void PokeballGlowEffect_1(struct Sprite *sprite) +{ + if ((--sprite->data[1]) == 0) + { + sprite->data[0]++; + sprite->data[1] = 8; + sprite->data[2] = 0; + sprite->data[3] = 0; + if (sprite->data[5]) + { + PlayFanfare(MUS_ME_ASA); + } + } +} + +void PokeballGlowEffect_2(struct Sprite *sprite) +{ + u8 phase; + if ((--sprite->data[1]) == 0) + { + sprite->data[1] = 8; + sprite->data[2]++; + sprite->data[2] &= 3; + if (sprite->data[2] == 0) + { + sprite->data[3]++; + } + } + phase = (sprite->data[2] + 3) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + phase = (sprite->data[2] + 2) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + phase = (sprite->data[2] + 1) & 3; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + phase = sprite->data[2]; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + if (sprite->data[3] > 2) + { + sprite->data[0]++; + sprite->data[1] = 8; + sprite->data[2] = 0; + } +} + +void PokeballGlowEffect_3(struct Sprite *sprite) +{ + u8 phase; + if ((--sprite->data[1]) == 0) + { + sprite->data[1] = 8; + sprite->data[2]++; + sprite->data[2] &= 3; + if (sprite->data[2] == 3) + { + sprite->data[0]++; + sprite->data[1] = 30; + } + } + phase = sprite->data[2]; + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x108, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x106, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x102, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x105, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); + MultiplyInvertedPaletteRGBComponents((IndexOfSpritePaletteTag(0x1007) << 4) + 0x103, gUnknown_0855C3BC[phase], gUnknown_0855C3C0[phase], gUnknown_0855C3C4[phase]); +} + +void PokeballGlowEffect_4(struct Sprite *sprite) +{ + if ((--sprite->data[1]) == 0) + { + sprite->data[0]++; + } +} + +void PokeballGlowEffect_5(struct Sprite *sprite) +{ + sprite->data[0]++; +} + +void PokeballGlowEffect_6(struct Sprite *sprite) +{ + if (sprite->data[5] == 0 || IsFanfareTaskInactive()) + { + sprite->data[0]++; + } +} + +void PokeballGlowEffect_7(struct Sprite *sprite) +{ +} + +void SpriteCB_PokeballGlow(struct Sprite *sprite) +{ + if (gSprites[sprite->data[0]].data[0] > 4) + { + FieldEffectFreeGraphicsResources(sprite); + } +} + +u8 PokecenterHealEffectHelper(s16 x, s16 y) +{ + u8 spriteIdAtEnd; + struct Sprite *sprite; + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C31C, x, y, 0); + sprite = &gSprites[spriteIdAtEnd]; + sprite->oam.priority = 2; + sprite->invisible = 1; + SetSubspriteTables(sprite, &gUnknown_0855C2AC); + return spriteIdAtEnd; +} + +void SpriteCB_PokecenterMonitor(struct Sprite *sprite) +{ + if (sprite->data[0] != 0) + { + sprite->data[0] = 0; + sprite->invisible = 0; + StartSpriteAnim(sprite, 1); + } + if (sprite->animEnded) + { + FieldEffectFreeGraphicsResources(sprite); + } +} + +void HallOfFameRecordEffectHelper(s16 a0, s16 a1, s16 a2, u8 a3) +{ + u8 spriteIdAtEnd; + if (!a3) + { + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C334, a1, a2, 0); + SetSubspriteTables(&gSprites[spriteIdAtEnd], &gUnknown_0855C2C4); + } else + { + spriteIdAtEnd = CreateSpriteAtEnd(&gSpriteTemplate_855C34C, a1, a2, 0); + } + gSprites[spriteIdAtEnd].invisible = 1; + gSprites[spriteIdAtEnd].data[0] = a0; +} + +void SpriteCB_HallOfFameMonitor(struct Sprite *sprite) +{ + if (gTasks[sprite->data[0]].data[15]) + { + if (sprite->data[1] == 0 || (--sprite->data[1]) == 0) + { + sprite->data[1] = 16; + sprite->invisible ^= 1; + } + sprite->data[2]++; + } + if (sprite->data[2] > 127) + { + FieldEffectFreeGraphicsResources(sprite); + } +}