Skip to content

Commit c9b7300

Browse files
authoredDec 10, 2016
Merge pull request libxmp#10 from sezero/sezero1
os2 / watcom support
2 parents eb27cca + 91d3e09 commit c9b7300

9 files changed

+84
-10
lines changed
 

‎Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
SUBDIRS = src
44

5-
EXTRA_DIST = CREDITS Changelog girl_from_mars.xm
5+
EXTRA_DIST = CREDITS Changelog girl_from_mars.xm os2/Makefile.os2 os2/unistd.h os2/usleep.c

‎os2/Makefile.os2

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Makefile for OS/2 using Watcom compiler.
2+
#
3+
# wmake -f Makefile.os2
4+
5+
CC=wcc386
6+
INCLUDES=-I..\os2 -I..\src
7+
CPPFLAGS=-DHAVE_SIGNAL_H -DHAVE_SYS_TIME_H
8+
CPPFLAGS+= -DSOUND_OS2DART
9+
CPPFLAGS+= -DVERSION="4.2.0"
10+
# for an exe using libxmp.dll: link to libxmp.lib
11+
# for a statically linked exe: link to xmp_static.lib
12+
LIBS=libxmp.lib mmpm2.lib
13+
#LIBS=xmp_static.lib mmpm2.lib
14+
CFLAGS = -bt=os2 -bm -fp5 -fpi87 -mf -oeatxh -w4 -zp8 -ei -q
15+
# -5s : Pentium stack calling conventions.
16+
# -5r : Pentium register calling conventions.
17+
CFLAGS+= -5s
18+
19+
.SUFFIXES:
20+
.SUFFIXES: .obj .c
21+
22+
AOUT=xmp.exe
23+
COMPILE=$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES)
24+
25+
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
26+
27+
all: $(AOUT)
28+
29+
$(AOUT): $(OBJ)
30+
wlink N $(AOUT) SYS OS2V2 LIBR {$(LIBS)} F {$(OBJ)}
31+
32+
clean:
33+
FOR %F IN ( $(AOUT) $(OBJ) $(EXTRA_OBJ) ) DO IF EXIST %F ERASE %F
34+
35+
.c: ..\src
36+
.c.obj:
37+
$(COMPILE) -fo=$^@ $<

‎os2/unistd.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _XMP_OS2_UNISTD_H
2+
#define _XMP_OS2_UNISTD_H
3+
4+
#include <io.h> /* do not want Watcom unistd.h */
5+
6+
void usleep (unsigned long usec);
7+
8+
#endif

‎os2/usleep.c

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define INCL_DOSPROCESS
2+
#include <os2.h>
3+
void usleep (unsigned long usec)
4+
{
5+
DosSleep(usec ? (usec/1000l) : 1l);
6+
}

‎src/commands.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
#include <unistd.h>
10-
#ifdef WIN32
10+
#if defined(_WIN32) || defined(__OS2__)
1111
#include <conio.h>
1212
#endif
1313
#include <xmp.h>
@@ -65,7 +65,7 @@ static int read_key(void)
6565
if (stdin_ready_for_reading())
6666
#endif
6767
ret = read(0, &key, 1);
68-
#elif defined WIN32
68+
#elif defined(_WIN32) || defined(__OS2__)
6969
if (kbhit()) {
7070
key = getch();
7171
ret = 1;

‎src/list.h

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#ifdef _MSC_VER
88
#define __inline__ __inline
99
#endif
10+
#ifdef __WATCOMC__
11+
#define __inline__ inline
12+
#endif
1013

1114
/*
1215
* Simple doubly linked list implementation.

‎src/read_config.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ int read_config(struct options *o)
4343
char *hash, *var, *val, line[256];
4444
char cparm[512];
4545

46-
#if defined __EMX__
47-
char *home = getenv("HOME");
46+
#if defined(__OS2__) || defined(__EMX__)
47+
const char *home = getenv("HOME");
48+
if (!home) home = "C:";
4849

49-
snprintf(myrc, PATH_MAX, "%s\\.xmp\\xmp.conf", home);
50+
snprintf(myrc, PATH_MAX, "%s\\xmp.conf", home);
5051

5152
if ((rc = fopen(myrc, "r")) == NULL) {
5253
if ((rc = fopen("xmp.conf", "r")) == NULL) {
@@ -280,11 +281,12 @@ static void parse_modconf(struct options *o, char *confname, unsigned char *md5)
280281

281282
void read_modconf(struct options *o, unsigned char *md5)
282283
{
283-
#if defined __EMX__
284+
#if defined(__OS2__) || defined(__EMX__)
284285
char myrc[PATH_MAX];
285-
char *home = getenv("HOME");
286+
const char *home = getenv("HOME");
287+
if (!home) home = "C:";
286288

287-
snprintf(myrc, PATH_MAX, "%s\\.xmp\\modules.conf", home);
289+
snprintf(myrc, PATH_MAX, "%s\\modules.conf", home);
288290
parse_modconf(o, "xmp-modules.conf", md5);
289291
parse_modconf(o, myrc, md5);
290292
#elif defined __AMIGA__

‎src/sound.c

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extern struct sound_driver sound_qnx;
1818
extern struct sound_driver sound_alsa05;
1919
extern struct sound_driver sound_oss;
2020
extern struct sound_driver sound_alsa;
21+
extern struct sound_driver sound_os2dart;
2122
extern struct sound_driver sound_win32;
2223
extern struct sound_driver sound_pulseaudio;
2324
extern struct sound_driver sound_coreaudio;
@@ -70,6 +71,9 @@ void init_sound_drivers(void)
7071
#ifdef SOUND_COREAUDIO
7172
register_sound_driver(&sound_coreaudio);
7273
#endif
74+
#ifdef SOUND_OS2DART
75+
register_sound_driver(&sound_os2dart);
76+
#endif
7377
#ifdef SOUND_WIN32
7478
register_sound_driver(&sound_win32);
7579
#endif

‎src/sound_dart.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
1919
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
2020

21+
#undef VERSION /* stop conflict with os2medef.h */
22+
2123
#include <stdlib.h>
2224
#include <unistd.h>
2325
#include <string.h>
@@ -74,7 +76,7 @@ static int init(struct options *options)
7476
int flags;
7577
int i;
7678
MCI_AMP_OPEN_PARMS AmpOpenParms;
77-
char *token, **parm;
79+
char *token;
7880

7981
parm_init(parm);
8082
chkparm1("sharing", sharing = *token);
@@ -210,6 +212,18 @@ static void deinit(void)
210212
}
211213
}
212214

215+
static void flush(void)
216+
{
217+
}
218+
219+
static void onpause(void)
220+
{
221+
}
222+
223+
static void onresume(void)
224+
{
225+
}
226+
213227
static const char *const help[] = {
214228
"sharing={Y,N}", "Device Sharing (default is N)",
215229
"device=val", "OS/2 Audio Device (default is 0 auto-detect)",

0 commit comments

Comments
 (0)
Please sign in to comment.