From 48a41b9f8239e7698439fcf68b71d0eeee5ea1a3 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 28 Jan 2024 08:55:16 +0900 Subject: [PATCH] Require SDL2_mixer on non-Emscripten platforms --- CMakeLists.txt | 29 ++++++------------ config.h.in | 4 --- src/CMakeLists.txt | 17 ++++------- src/bgm.dummy.c | 75 ---------------------------------------------- src/cdrom.c | 63 -------------------------------------- src/cdrom.empty.c | 69 ------------------------------------------ src/cdrom.h | 2 -- src/music_cdrom.c | 13 +++++--- src/pcm.dummy.c | 40 ------------------------- 9 files changed, 23 insertions(+), 289 deletions(-) delete mode 100644 src/bgm.dummy.c delete mode 100644 src/cdrom.c delete mode 100644 src/cdrom.empty.c delete mode 100644 src/pcm.dummy.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 24a1540..0216fe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ elseif (ANDROID) add_library(sdl2 ALIAS SDL2) add_library(sdl2_ttf ALIAS SDL2_ttf) add_library(sdl2_mixer ALIAS SDL2_mixer) - set(SDL2MIXER_FOUND 1) find_library(ndk_log log) find_library(ndk_zlib z) add_library(zlib INTERFACE) @@ -66,22 +65,18 @@ else() # non-emscripten, non-android pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2) pkg_check_modules(SDL2TTF REQUIRED IMPORTED_TARGET SDL2_ttf) - optional_pkg_check_modules(SDL2MIXER IMPORTED_TARGET SDL2_mixer) + pkg_check_modules(SDL2MIXER REQUIRED IMPORTED_TARGET SDL2_mixer) if (WIN32) add_static_library(sdl2 SDL2) add_static_library(sdl2_ttf SDL2TTF) # Workaround for linking error set_property(TARGET sdl2_ttf PROPERTY INTERFACE_LINK_LIBRARIES $) - if (SDL2MIXER_FOUND) - add_static_library(sdl2_mixer SDL2MIXER) - endif() + add_static_library(sdl2_mixer SDL2MIXER) else() add_library(sdl2 ALIAS PkgConfig::SDL2) add_library(sdl2_ttf ALIAS PkgConfig::SDL2TTF) - if (SDL2MIXER_FOUND) - add_library(sdl2_mixer ALIAS PkgConfig::SDL2MIXER) - endif() + add_library(sdl2_mixer ALIAS PkgConfig::SDL2MIXER) set(DEFAULT_FONT_PATH ${CMAKE_INSTALL_PREFIX}/share/xsystem35/fonts/) endif() @@ -138,20 +133,16 @@ endif() if (EMSCRIPTEN) list(APPEND SUMMARY_AUDIO "Emscripten") -elseif (SDL2MIXER_FOUND) +else() list(APPEND SUMMARY_AUDIO "SDL_mixer") - set(ENABLE_SDLMIXER 1) endif() # CDROM -if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") +if (EMSCRIPTEN) list(APPEND SUMMARY_CDROM "Emscripten") - set(ENABLE_CDROM_EMSCRIPTEN 1) -endif() -if (SDL2MIXER_FOUND) +else() list(APPEND SUMMARY_CDROM "SDL_mixer (wav|mp3|ogg...)") - set(ENABLE_CDROM_MP3 1) endif() set(CDROM_DEVICE "playlist.txt" CACHE STRING "CDROM Device Name") @@ -162,6 +153,9 @@ if (EMSCRIPTEN) elseif (ANDROID) list(APPEND SUMMARY_MIDI "Android") else() + list(APPEND SUMMARY_MIDI "SDL_mixer") + set(ENABLE_MIDI_SDLMIXER 1) + if (HAVE_SIGACTION) list(APPEND SUMMARY_MIDI "raw") set(MIDI_DEVICE "/dev/midi" CACHE STRING "midi device") @@ -181,11 +175,6 @@ else() set(SEQ_DEVICE "/dev/sequencer" CACHE STRING "sequencer device") endif() - if (SDL2MIXER_FOUND) - list(APPEND SUMMARY_MIDI "SDL_mixer") - set(ENABLE_MIDI_SDLMIXER 1) - endif() - if (HAVE_PORTMIDI) list(APPEND SUMMARY_MIDI "PortMidi") set(ENABLE_MIDI_PORTMIDI 1) diff --git a/config.h.in b/config.h.in index ef325b2..153bc7c 100644 --- a/config.h.in +++ b/config.h.in @@ -3,9 +3,6 @@ #cmakedefine CACHE_TOTALSIZE @CACHE_TOTALSIZE@ -#cmakedefine ENABLE_CDROM_ANDROID @ENABLE_CDROM_ANDROID@ -#cmakedefine ENABLE_CDROM_EMSCRIPTEN @ENABLE_CDROM_EMSCRIPTEN@ -#cmakedefine ENABLE_CDROM_MP3 @ENABLE_CDROM_MP3@ #cmakedefine ENABLE_DEBUGGER @ENABLE_DEBUGGER@ #cmakedefine ENABLE_GTK @ENABLE_GTK@ #cmakedefine ENABLE_MIDI_RAWMIDI @ENABLE_MIDI_RAWMIDI@ @@ -13,7 +10,6 @@ #cmakedefine ENABLE_MIDI_SEQMIDI @ENABLE_MIDI_SEQMIDI@ #cmakedefine ENABLE_MIDI_PORTMIDI @ENABLE_MIDI_PORTMIDI@ #cmakedefine ENABLE_NLS @ENABLE_NLS@ -#cmakedefine ENABLE_SDLMIXER @ENABLE_SDLMIXER@ #cmakedefine CDROM_DEVICE "@CDROM_DEVICE@" #cmakedefine JOY_DEVICE "@JOY_DEVICE@" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ca7c86..5753cbe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,11 +24,11 @@ target_sources(xsystem35 PRIVATE ags.c ald_manager.c alpha_plane.c + bgi.c bmp.c cache.c cali.c cdrom.bgm.c - cdrom.c cg.c cmd2F.c cmd2F60.c @@ -95,19 +95,14 @@ target_sources(xsystem35 PRIVATE ) if (EMSCRIPTEN) - target_sources(xsystem35 PRIVATE pcm.emscripten.c bgm.emscripten.c bgi.c) -elseif (SDL2MIXER_FOUND) - target_sources(xsystem35 PRIVATE pcm.sdlmixer.c bgm.sdlmixer.c bgi.c) + target_sources(xsystem35 PRIVATE pcm.emscripten.c bgm.emscripten.c) else() - target_sources(xsystem35 PRIVATE pcm.dummy.c bgm.dummy.c) + target_sources(xsystem35 PRIVATE pcm.sdlmixer.c bgm.sdlmixer.c) endif() -if (ENABLE_CDROM_EMSCRIPTEN) +if (EMSCRIPTEN) target_sources(xsystem35 PRIVATE cdrom.emscripten.c) else() - target_sources(xsystem35 PRIVATE cdrom.empty.c) -endif() -if (ENABLE_CDROM_MP3) target_sources(xsystem35 PRIVATE cdrom.mp3.c) endif() @@ -116,12 +111,10 @@ if (EMSCRIPTEN) elseif (ANDROID) target_sources(xsystem35 PRIVATE midi.android.c) else() + target_sources(xsystem35 PRIVATE midi.sdlmixer.c) if (ENABLE_MIDI_RAWMIDI) target_sources(xsystem35 PRIVATE midi.rawmidi.c midifile.c) endif() - if (ENABLE_MIDI_SDLMIXER) - target_sources(xsystem35 PRIVATE midi.sdlmixer.c) - endif() if (ENABLE_MIDI_PORTMIDI) target_sources(xsystem35 PRIVATE midi.portmidi.c) endif() diff --git a/src/bgm.dummy.c b/src/bgm.dummy.c deleted file mode 100644 index 7d31e50..0000000 --- a/src/bgm.dummy.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * bgm.dummy.c BGM (*BA.ALD) dummy implementation - * - * Copyright (C) 2019 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#include -#include "portab.h" -#include "bgm.h" - -int musbgm_init(DRIFILETYPE type, int base_no) { - return NG; -} - -int musbgm_exit(void) { - return NG; -} - -int musbgm_reset(void) { - return NG; -} - -int musbgm_play(int no, int time, int vol) { - WARNING("not implemented"); - return NG; -} - -int musbgm_stop(int no, int time) { - WARNING("not implemented"); - return NG; -} - -int musbgm_fade(int no, int time, int vol) { - WARNING("not implemented"); - return NG; -} - -int musbgm_getpos(int no) { - WARNING("not implemented"); - return 0; -} - -int musbgm_getlen(int no) { - WARNING("not implemented"); - return 0; -} - -int musbgm_isplaying(int no) { - WARNING("not implemented"); - return 0; -} - -int musbgm_stopall(int time) { - WARNING("not implemented"); - return NG; -} - -int musbgm_wait(int no, int timeout) { - WARNING("not implemented"); - return NG; -} diff --git a/src/cdrom.c b/src/cdrom.c deleted file mode 100644 index c0c5049..0000000 --- a/src/cdrom.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * cdrom.c CD-ROM control wrapper - * - * Copyright (C) 2000- Masaki Chikama (Wren) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ -/* $Id: cdrom.c,v 1.20 2002/08/18 09:35:29 chikama Exp $ */ - -#include "config.h" - -#include -#include -#include -#include - -#include "portab.h" -#include "cdrom.h" -#include "system.h" - -#if defined(ENABLE_CDROM_EMSCRIPTEN) -extern cdromdevice_t cdrom_emscripten; -#define NATIVE_CD_DEVICE &cdrom_emscripten - -#else - -extern cdromdevice_t cdrom_empty; -#define NATIVE_CD_DEVICE &cdrom_empty -#endif - -#ifdef ENABLE_CDROM_MP3 -extern cdromdevice_t cdrom_mp3; -#endif - -cdromdevice_t *cd_init(const char *dev) { -#if defined(ENABLE_CDROM_EMSCRIPTEN) - return NATIVE_CD_DEVICE; -#else - struct stat st; - if (dev && stat(dev, &st) && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))) - return NATIVE_CD_DEVICE; - -#ifdef ENABLE_CDROM_MP3 - return &cdrom_mp3; -#else - WARNING("no cdrom device available"); - return NULL; -#endif -#endif // ENABLE_CDROM_EMSCRIPTEN -} diff --git a/src/cdrom.empty.c b/src/cdrom.empty.c deleted file mode 100644 index 1780acd..0000000 --- a/src/cdrom.empty.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * cdrom.empty.c CD-ROMアクセス - * - * Copyright (C) 1997-1998 Masaki Chikama (Wren) - * 1998- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ -/* $Id: cdrom.empty.c,v 1.8 2002/08/18 09:35:29 chikama Exp $ */ - -#include -#include "portab.h" -#include "cdrom.h" - -static int cdrom_init(char *); -static int cdrom_exit(void); -static int cdrom_reset(void); -static int cdrom_start(int, int); -static int cdrom_stop(); -static int cdrom_getPlayingInfo(cd_time *); - -#define cdrom cdrom_empty -cdromdevice_t cdrom = { - cdrom_init, - cdrom_exit, - cdrom_reset, - cdrom_start, - cdrom_stop, - cdrom_getPlayingInfo, - NULL, - NULL -}; - -int cdrom_init(char *name) { - return NG; -} - -int cdrom_exit(void) { - return OK; -} - -int cdrom_reset(void) { - return OK; -} - -int cdrom_start(int trk, int loop) { - return OK; -} - -int cdrom_stop() { - return OK; -} - -int cdrom_getPlayingInfo (cd_time *info) { - return NG; -} diff --git a/src/cdrom.h b/src/cdrom.h index c3584f5..ce53d1b 100644 --- a/src/cdrom.h +++ b/src/cdrom.h @@ -51,8 +51,6 @@ typedef struct _cdromdevice cdromdevice_t; extern cdromdevice_t cdrom_bgm; -extern cdromdevice_t *cd_init(const char *dev); - #define CD_FPS 75 #define FRAMES_TO_MSF(f, M,S,F) { \ int value = f; \ diff --git a/src/music_cdrom.c b/src/music_cdrom.c index 2bb6d4c..130023a 100644 --- a/src/music_cdrom.c +++ b/src/music_cdrom.c @@ -30,6 +30,14 @@ #include "music_cdrom.h" #include "cdrom.h" +#ifdef __EMSCRIPTEN__ +extern cdromdevice_t cdrom_emscripten; +#define NATIVE_CD_DEVICE &cdrom_emscripten +#else +extern cdromdevice_t cdrom_mp3; +#define NATIVE_CD_DEVICE &cdrom_mp3 +#endif + static char *dev = CDROM_DEVICE; void muscd_set_devicename(const char *name) { @@ -42,10 +50,7 @@ int muscd_init(void) { if (ald_get_maxno(DRIFILE_BGM) > 0) { prv.cddev = &cdrom_bgm; } else { - prv.cddev = cd_init(dev); - if (!prv.cddev) { - return NG; - } + prv.cddev = NATIVE_CD_DEVICE; } prv.cddev->init(dev); prv.cd_current_track = 0; diff --git a/src/pcm.dummy.c b/src/pcm.dummy.c deleted file mode 100644 index 6340991..0000000 --- a/src/pcm.dummy.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * pcm.dummy.c Dummy PCM implementation - * - * Copyright (C) 2019 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -#include "portab.h" -#include "music_pcm.h" - -int muspcm_init(int audio_buffer_size) { return NG; } -int muspcm_exit(void) { return NG; } -int muspcm_reset(void) { return NG; } -int muspcm_load_no(int slot, int no) { return NG; } -int muspcm_load_mixlr(int slot, int noL, int noR) { return NG; } -int muspcm_load_data(int slot, uint8_t *buf, uint32_t len) { return NG; } -int muspcm_unload(int slot) { return NG; } -int muspcm_start(int slot, int loop) { return NG; } -int muspcm_stop(int slot) { return NG; } -int muspcm_fadeout(int slot, int msec) { return NG; } -int muspcm_pause(int slot) { return NG; } -int muspcm_unpause(int slot) { return NG; } -int muspcm_getpos(int slot) { return NG; } -int muspcm_setvol(int dev, int slot, int lv) { return NG; } -int muspcm_getwavelen(int slot) { return NG; } -boolean muspcm_isplaying(int slot) { return FALSE; } -int muspcm_waitend(int slot) { return NG; }