GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_sprite_start.c Lines: 18 18 100.0 %
Date: 2026-03-06 19:21:09 Branches: 10 10 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Sprite Management (Sprite)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_display.h"
30
#include "gx_context.h"
31
#include "gx_canvas.h"
32
#include "gx_widget.h"
33
#include "gx_sprite.h"
34
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_sprite_start                                    PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This service starts the sprite widget from a given frame number.    */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    sprite                                Pointer to sprite widget      */
53
/*                                           control block                */
54
/*    frame_number                          The frame number to start     */
55
/*                                            with                        */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    status                                Completion status             */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    _gx_system_timer_stop                 Stop an active GUIX timer     */
64
/*    _gx_system_timer_start                Start a GUIX timer            */
65
/*    _gx_system_dirty_mark                 Mark the widget as dirty      */
66
/*                                                                        */
67
/*  CALLED BY                                                             */
68
/*                                                                        */
69
/*    Application Code                                                    */
70
/*                                                                        */
71
/**************************************************************************/
72
242
UINT  _gx_sprite_start(GX_SPRITE *sprite, USHORT frame_number)
73
{
74
242
GX_WIDGET       *widget = (GX_WIDGET *)sprite;
75
GX_SPRITE_FRAME *frame;
76
UINT             delayval;
77
78
242
    if (sprite -> gx_sprite_run_state == GX_SPRITE_RUNNING)
79
    {
80
154
        _gx_system_timer_stop(widget, GX_SPRITE_TIMER);
81
154
        sprite -> gx_sprite_run_state = GX_SPRITE_IDLE;
82
    }
83
84
242
    if (sprite -> gx_sprite_frame_list &&
85
241
        (widget -> gx_widget_status & GX_STATUS_VISIBLE))
86
    {
87
240
        if (frame_number < sprite -> gx_sprite_frame_count)
88
        {
89
239
            sprite -> gx_sprite_current_frame = frame_number;
90
91
239
            frame = &sprite -> gx_sprite_frame_list[sprite -> gx_sprite_current_frame];
92
239
            if (frame -> gx_sprite_frame_delay > 0)
93
            {
94
237
                delayval = frame -> gx_sprite_frame_delay;
95
            }
96
            else
97
            {
98
2
                delayval = 1;
99
            }
100
239
            _gx_system_timer_start(widget, GX_SPRITE_TIMER, delayval, 0);
101
239
            sprite -> gx_sprite_run_state = GX_SPRITE_RUNNING;
102
239
            _gx_system_dirty_mark(widget);
103
239
            return(GX_SUCCESS);
104
        }
105
    }
106
3
    return(GX_FAILURE);
107
}
108