1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*
* Copyright (C) 2020 - Vito Caputo - <vcaputo@pengaru.com>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _PLAY_H
#define _PLAY_H
#include <SDL.h>
typedef enum play_ticks_t {
PLAY_TICKS_TIMER0,
PLAY_TICKS_TIMER1,
PLAY_TICKS_TIMER2,
PLAY_TICKS_TIMER3,
PLAY_TICKS_TIMER4,
PLAY_TICKS_TIMER5,
PLAY_TICKS_TIMER6,
PLAY_TICKS_TIMER7,
PLAY_TICKS_TIMER8,
PLAY_TICKS_TIMER9,
PLAY_TICKS_CNT
} play_ticks_t;
#define PLAY_FLAG_NOAUDIO (1L)
#define PLAY_FLAG_NOVIDEO (1L << 1)
#define PLAY_FLAG_NOGAMEPAD (1L << 2)
#define PLAY_MUSIC_FLAG_LOOP (1L)
#define PLAY_MUSIC_FLAG_FADEIN (1L << 1)
#define PLAY_MUSIC_FLAG_OPTIONAL (1L << 2)
#define PLAY_MUSIC_FLAG_QUEUE (1L << 3)
#define PLAY_MUSIC_FLAG_IDEMPOTENT (1L << 4)
typedef struct play_t play_t;
typedef struct play_ops_t {
void * (*init)(play_t *play, int argc, char *argv[], unsigned flags);
void (*destroy)(play_t *play, void *context);
void (*enter)(play_t *play, void *context);
void (*leave)(play_t *play, void *context);
void (*update)(play_t *play, void *context);
void (*render)(play_t *play, void *context);
void (*dispatch)(play_t *play, void *context, SDL_Event *event);
} play_ops_t;
play_t * play_startup(int argc, char *argv[], unsigned flags, const play_ops_t *ops[]);
int play_shutdown(play_t *play);
void play_run(play_t *play);
void play_music_set(play_t *play, unsigned flags, const char *fmt, ...);
void play_music_pause(play_t *play);
void play_music_resume(play_t *play);
void play_context_enter(play_t *play, int context);
void * play_context(const play_t *play, int context);
unsigned play_ticks(play_t *play, play_ticks_t timer);
unsigned play_ticks_reset(play_t *play, play_ticks_t timer);
void play_ticks_pause(play_t *play);
int play_ticks_elapsed(play_t *play, play_ticks_t timer, unsigned duration);
void play_pointer_own(play_t *play);
void play_pointer_disown(play_t *play);
int play_pointer_owned(const play_t *play);
void play_quit(play_t *play);
#endif
|