obj = $(src:.c=.o)
bin = demo
-inc = -Isrc -Isrc/sdl -Ilibs/imago/src
+inc = -Isrc -Isrc/sdl -Ilibs/imago/src -Ilibs/mikmod/include
CFLAGS = -pedantic -Wall -g $(inc) `sdl-config --cflags`
-LDFLAGS = -Llibs/imago -limago `sdl-config --libs` -lm
+LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm
-$(bin): $(obj) imago
+$(bin): $(obj) imago mikmod
$(CC) -o $@ $(obj) $(LDFLAGS)
.PHONY: imago
imago:
$(MAKE) -C libs/imago
+.PHONY: mikmod
+mikmod:
+ $(MAKE) -C libs/mikmod
+
.PHONY: clean
clean:
rm -f $(obj) $(bin)
src = $(wildcard drivers/*.c) \
$(wildcard loaders/*.c) \
$(wildcard mmio/*.c) \
- $(wildcard deackers/*.c) \
+ $(wildcard depackers/*.c) \
$(wildcard posix/*.c) \
$(wildcard playercode/*.c)
obj = $(src:.c=.o)
--- /dev/null
+/* MikMod sound library
+ (c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS for
+ complete list.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library 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 Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+/*==============================================================================
+
+ $Id$
+
+ Driver for no output
+
+==============================================================================*/
+
+/*
+
+ Written by Jean-Paul Mikkers <mikmak@via.nl>
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "mikmod_internals.h"
+
+#define ZEROLEN 32768
+
+static SBYTE *zerobuf=NULL;
+
+static BOOL NS_IsThere(void)
+{
+ return 1;
+}
+
+static int NS_Init(void)
+{
+ zerobuf=(SBYTE*)MikMod_malloc(ZEROLEN);
+ return VC_Init();
+}
+
+static void NS_Exit(void)
+{
+ VC_Exit();
+ MikMod_free(zerobuf);
+ zerobuf=NULL;
+}
+
+static void NS_Update(void)
+{
+ if (zerobuf)
+ VC_WriteBytes(zerobuf,ZEROLEN);
+}
+
+MIKMODAPI MDRIVER drv_nos={
+ NULL,
+ "No Sound",
+ "Nosound Driver v3.0",
+ 255,255,
+ "nosound",
+ NULL,
+ NULL,
+ NS_IsThere,
+ VC_SampleLoad,
+ VC_SampleUnload,
+ VC_SampleSpace,
+ VC_SampleLength,
+ NS_Init,
+ NS_Exit,
+ NULL,
+ VC_SetNumVoices,
+ VC_PlayStart,
+ VC_PlayStop,
+ NS_Update,
+ NULL,
+ VC_VoiceSetVolume,
+ VC_VoiceGetVolume,
+ VC_VoiceSetFrequency,
+ VC_VoiceGetFrequency,
+ VC_VoiceSetPanning,
+ VC_VoiceGetPanning,
+ VC_VoicePlay,
+ VC_VoiceStop,
+ VC_VoiceStopped,
+ VC_VoiceGetPosition,
+ VC_VoiceRealVolume
+};
+
+/* ex:set ts=4: */
static void MikMod_RegisterAllLoaders_internal(void)
{
- _mm_registerloader(&load_669);
- _mm_registerloader(&load_amf);
- _mm_registerloader(&load_asy);
- _mm_registerloader(&load_dsm);
- _mm_registerloader(&load_far);
- _mm_registerloader(&load_gdm);
-/* _mm_registerloader(&load_gt2);*/ /* load_gt2 isn't complete */
_mm_registerloader(&load_it);
- _mm_registerloader(&load_imf);
_mm_registerloader(&load_mod);
- _mm_registerloader(&load_med);
- _mm_registerloader(&load_mtm);
- _mm_registerloader(&load_okt);
_mm_registerloader(&load_s3m);
- _mm_registerloader(&load_stm);
- _mm_registerloader(&load_stx);
- _mm_registerloader(&load_ult);
- _mm_registerloader(&load_umx);
- _mm_registerloader(&load_uni);
_mm_registerloader(&load_xm);
-
- _mm_registerloader(&load_m15);
}
MIKMODAPI void MikMod_RegisterAllLoaders(void)
#include "demo.h"
#include "screen.h"
#include "3dgfx.h"
+#include "music.h"
int fb_width = 320;
int fb_height = 240;
}
g3d_framebuffer(fb_width, fb_height, fb_pixels);
+ if(music_open("data/test.mod") == -1) {
+ fprintf(stderr, "failed to open music: data/test.mod\n");
+ return -1;
+ }
+
if(scr_init() == -1) {
return -1;
}
/* clear the framebuffer at least once */
memset(fb_pixels, 0, fb_width * fb_height * fb_bpp / CHAR_BIT);
+
+ music_play();
return 0;
}
void demo_cleanup(void)
{
+ music_close();
scr_shutdown();
g3d_destroy();
void demo_draw(void)
{
+ music_update();
scr_update();
scr_draw();
--- /dev/null
+#include "music.h"
+#include "mikmod.h"
+
+static MODULE *mod;
+static int initialized;
+
+
+static int init(void)
+{
+ MikMod_RegisterAllDrivers();
+ MikMod_RegisterAllLoaders();
+
+ md_mode |= DMODE_SOFT_MUSIC;
+ if(MikMod_Init("") != 0) {
+ fprintf(stderr, "mikmod init failed: %s\n",
+ MikMod_strerror(MikMod_errno));
+ return -1;
+ }
+ return 0;
+}
+
+int music_open(const char *fname)
+{
+ if(!initialized) {
+ if(init() == -1) {
+ return -1;
+ }
+ initialized = 1;
+ }
+
+ if(!(mod = Player_Load(fname, 64, 0))) {
+ fprintf(stderr, "failed to load music: %s: %s\n", fname,
+ MikMod_strerror(MikMod_errno));
+ return -1;
+ }
+ return 0;
+}
+
+void music_close(void)
+{
+ if(mod) {
+ music_stop();
+ Player_Free(mod);
+ }
+}
+
+void music_play(void)
+{
+ Player_Start(mod);
+}
+
+void music_stop(void)
+{
+ Player_Stop();
+}
+
+void music_update(void)
+{
+ if(Player_Active()) {
+ MikMod_Update();
+ }
+}
--- /dev/null
+#ifndef MUSIC_H_
+#define MUSIC_H_
+
+int music_open(const char *fname);
+void music_close(void);
+void music_play(void);
+void music_update(void);
+
+#endif /* MUSIC_H_ */