1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   Sprite Management (Sprite)                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_display.h"
29 #include "gx_context.h"
30 #include "gx_canvas.h"
31 #include "gx_widget.h"
32 #include "gx_sprite.h"
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _gx_sprite_frame_list_set                           PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Kenneth Maxwell, Microsoft Corporation                              */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This service assigns the frame list to the sprite widget.           */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    sprite                                Pointer to sprite widget      */
52 /*                                            control block               */
53 /*    frame_list                            The frame list to be assigned */
54 /*    frame_count                           Number of frames in the frame */
55 /*                                            list                        */
56 /*                                                                        */
57 /*  OUTPUT                                                                */
58 /*                                                                        */
59 /*    status                                Completion status             */
60 /*                                                                        */
61 /*  CALLS                                                                 */
62 /*                                                                        */
63 /*    _gx_sprite_stop                       Stop a sprite widget          */
64 /*    _gx_system_dirty_mark                 Mark the widget as dirty      */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application Code                                                    */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
75 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_gx_sprite_frame_list_set(GX_SPRITE * sprite,GX_SPRITE_FRAME * frame_list,USHORT frame_count)79 UINT  _gx_sprite_frame_list_set(GX_SPRITE *sprite, GX_SPRITE_FRAME *frame_list, USHORT frame_count)
80 {
81 GX_WIDGET *widget = (GX_WIDGET *)sprite;
82 
83     if (sprite -> gx_sprite_run_state == GX_SPRITE_RUNNING)
84     {
85         _gx_sprite_stop(sprite);
86     }
87     sprite -> gx_sprite_current_frame = 0;
88     sprite -> gx_sprite_frame_count = frame_count;
89     sprite -> gx_sprite_frame_list = frame_list;
90 
91     if (sprite -> gx_widget_status & GX_STATUS_VISIBLE)
92     {
93         _gx_system_dirty_mark(widget);
94     }
95     return(GX_SUCCESS);
96 }
97 
98