From 6ea590909fffe3cc902ed896b00c4ad007306134 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:21:41 +0300 Subject: [PATCH 1/6] src/list.h: define __inline__ as inline for Watcom. --- src/list.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/list.h b/src/list.h index d608deb..256cb30 100644 --- a/src/list.h +++ b/src/list.h @@ -7,6 +7,9 @@ #ifdef _MSC_VER #define __inline__ __inline #endif +#ifdef __WATCOMC__ +#define __inline__ inline +#endif /* * Simple doubly linked list implementation. From c76c2d5eef968a6b9e8a109eb9ec08de6ebdb245 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:22:10 +0300 Subject: [PATCH 2/6] src/commands.c: use conio.h / kbhit() for OS/2 builds, as well. --- src/commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands.c b/src/commands.c index fc10926..889aeef 100644 --- a/src/commands.c +++ b/src/commands.c @@ -7,7 +7,7 @@ */ #include -#ifdef WIN32 +#if defined(_WIN32) || defined(__OS2__) #include #endif #include @@ -65,7 +65,7 @@ static int read_key(void) if (stdin_ready_for_reading()) #endif ret = read(0, &key, 1); -#elif defined WIN32 +#elif defined(_WIN32) || defined(__OS2__) if (kbhit()) { key = getch(); ret = 1; From 6441eea079aabb08d631d515b960792b2df48b41 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:22:51 +0300 Subject: [PATCH 3/6] src/read_config.c: update read_config() and read_modconf() for OS/2 --- src/read_config.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/read_config.c b/src/read_config.c index 6b2c211..ff657db 100644 --- a/src/read_config.c +++ b/src/read_config.c @@ -43,10 +43,11 @@ int read_config(struct options *o) char *hash, *var, *val, line[256]; char cparm[512]; -#if defined __EMX__ - char *home = getenv("HOME"); +#if defined(__OS2__) || defined(__EMX__) + const char *home = getenv("HOME"); + if (!home) home = "C:"; - snprintf(myrc, PATH_MAX, "%s\\.xmp\\xmp.conf", home); + snprintf(myrc, PATH_MAX, "%s\\xmp.conf", home); if ((rc = fopen(myrc, "r")) == NULL) { if ((rc = fopen("xmp.conf", "r")) == NULL) { @@ -280,11 +281,12 @@ static void parse_modconf(struct options *o, char *confname, unsigned char *md5) void read_modconf(struct options *o, unsigned char *md5) { -#if defined __EMX__ +#if defined(__OS2__) || defined(__EMX__) char myrc[PATH_MAX]; - char *home = getenv("HOME"); + const char *home = getenv("HOME"); + if (!home) home = "C:"; - snprintf(myrc, PATH_MAX, "%s\\.xmp\\modules.conf", home); + snprintf(myrc, PATH_MAX, "%s\\modules.conf", home); parse_modconf(o, "xmp-modules.conf", md5); parse_modconf(o, myrc, md5); #elif defined __AMIGA__ From 0959a93acbe9f97add4607916acab2a14ec763f1 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:28:02 +0300 Subject: [PATCH 4/6] src/sound_dart.c: make it to build. it is actually functional too. --- src/sound_dart.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sound_dart.c b/src/sound_dart.c index 7f95883..6bb6e26 100644 --- a/src/sound_dart.c +++ b/src/sound_dart.c @@ -18,6 +18,8 @@ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\// //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\// +#undef VERSION /* stop conflict with os2medef.h */ + #include #include #include @@ -74,7 +76,7 @@ static int init(struct options *options) int flags; int i; MCI_AMP_OPEN_PARMS AmpOpenParms; - char *token, **parm; + char *token; parm_init(parm); chkparm1("sharing", sharing = *token); @@ -210,6 +212,18 @@ static void deinit(void) } } +static void flush(void) +{ +} + +static void onpause(void) +{ +} + +static void onresume(void) +{ +} + static const char *const help[] = { "sharing={Y,N}", "Device Sharing (default is N)", "device=val", "OS/2 Audio Device (default is 0 auto-detect)", From c9c2095479e4123dc090b659b444c4842e1cb719 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:28:50 +0300 Subject: [PATCH 5/6] src/sound.c: add os/2 dart driver registration, guarded by a SOUND_OS2DART ifdef --- src/sound.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sound.c b/src/sound.c index 1aedcf1..9056610 100644 --- a/src/sound.c +++ b/src/sound.c @@ -18,6 +18,7 @@ extern struct sound_driver sound_qnx; extern struct sound_driver sound_alsa05; extern struct sound_driver sound_oss; extern struct sound_driver sound_alsa; +extern struct sound_driver sound_os2dart; extern struct sound_driver sound_win32; extern struct sound_driver sound_pulseaudio; extern struct sound_driver sound_coreaudio; @@ -70,6 +71,9 @@ void init_sound_drivers(void) #ifdef SOUND_COREAUDIO register_sound_driver(&sound_coreaudio); #endif +#ifdef SOUND_OS2DART + register_sound_driver(&sound_os2dart); +#endif #ifdef SOUND_WIN32 register_sound_driver(&sound_win32); #endif From 91d3e09d944b116a7d0ff63837d0609314331a55 Mon Sep 17 00:00:00 2001 From: sezero Date: Sat, 3 Dec 2016 01:37:32 +0300 Subject: [PATCH 6/6] provide a Makefile.os2 (to be used with Watcom, tested with OpenWatcom 1.9) --- Makefile.am | 2 +- os2/Makefile.os2 | 37 +++++++++++++++++++++++++++++++++++++ os2/unistd.h | 8 ++++++++ os2/usleep.c | 6 ++++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 os2/Makefile.os2 create mode 100644 os2/unistd.h create mode 100644 os2/usleep.c diff --git a/Makefile.am b/Makefile.am index d920600..8eaf85e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,4 +2,4 @@ SUBDIRS = src -EXTRA_DIST = CREDITS Changelog girl_from_mars.xm +EXTRA_DIST = CREDITS Changelog girl_from_mars.xm os2/Makefile.os2 os2/unistd.h os2/usleep.c diff --git a/os2/Makefile.os2 b/os2/Makefile.os2 new file mode 100644 index 0000000..05ba15d --- /dev/null +++ b/os2/Makefile.os2 @@ -0,0 +1,37 @@ +# Makefile for OS/2 using Watcom compiler. +# +# wmake -f Makefile.os2 + +CC=wcc386 +INCLUDES=-I..\os2 -I..\src +CPPFLAGS=-DHAVE_SIGNAL_H -DHAVE_SYS_TIME_H +CPPFLAGS+= -DSOUND_OS2DART +CPPFLAGS+= -DVERSION="4.2.0" +# for an exe using libxmp.dll: link to libxmp.lib +# for a statically linked exe: link to xmp_static.lib +LIBS=libxmp.lib mmpm2.lib +#LIBS=xmp_static.lib mmpm2.lib +CFLAGS = -bt=os2 -bm -fp5 -fpi87 -mf -oeatxh -w4 -zp8 -ei -q +# -5s : Pentium stack calling conventions. +# -5r : Pentium register calling conventions. +CFLAGS+= -5s + +.SUFFIXES: +.SUFFIXES: .obj .c + +AOUT=xmp.exe +COMPILE=$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) + +OBJ = commands.obj getopt.obj getopt1.obj info.obj main.obj options.obj read_config.obj sound.obj sound_aiff.obj sound_file.obj sound_null.obj sound_wav.obj sound_dart.obj terminal.obj usleep.obj + +all: $(AOUT) + +$(AOUT): $(OBJ) + wlink N $(AOUT) SYS OS2V2 LIBR {$(LIBS)} F {$(OBJ)} + +clean: + FOR %F IN ( $(AOUT) $(OBJ) $(EXTRA_OBJ) ) DO IF EXIST %F ERASE %F + +.c: ..\src +.c.obj: + $(COMPILE) -fo=$^@ $< diff --git a/os2/unistd.h b/os2/unistd.h new file mode 100644 index 0000000..5c3cea0 --- /dev/null +++ b/os2/unistd.h @@ -0,0 +1,8 @@ +#ifndef _XMP_OS2_UNISTD_H +#define _XMP_OS2_UNISTD_H + +#include /* do not want Watcom unistd.h */ + +void usleep (unsigned long usec); + +#endif diff --git a/os2/usleep.c b/os2/usleep.c new file mode 100644 index 0000000..f0e8a2b --- /dev/null +++ b/os2/usleep.c @@ -0,0 +1,6 @@ +#define INCL_DOSPROCESS +#include +void usleep (unsigned long usec) +{ + DosSleep(usec ? (usec/1000l) : 1l); +}