/* * Copyright (C) 2020 - Vito Caputo - * * 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 . */ #ifndef _PLAY_H #define _PLAY_H #include 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(play_t *play, int context); unsigned play_ticks(play_t *play, play_ticks_t timer); void 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_quit(play_t *play); #endif