diff options
-rw-r--r-- | cmake/openwattcom/Linux-OpenWatcom-C.cmake | 1 | ||||
-rw-r--r-- | cmake/openwattcom/Linux-OpenWatcom-CXX.cmake | 1 | ||||
-rw-r--r-- | cmake/openwattcom/Linux-OpenWatcom.cmake | 129 | ||||
-rwxr-xr-x | cmake/openwattcom/ow-cmake.sh | 35 | ||||
-rw-r--r-- | cmake/openwattcom/toolchain-ow.cmake | 40 | ||||
-rw-r--r-- | src/adlmidi.cpp | 20 | ||||
-rw-r--r-- | src/adlmidi_load.cpp | 8 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 1 | ||||
-rw-r--r-- | src/nukedopl3.h | 1 |
9 files changed, 227 insertions, 9 deletions
diff --git a/cmake/openwattcom/Linux-OpenWatcom-C.cmake b/cmake/openwattcom/Linux-OpenWatcom-C.cmake new file mode 100644 index 0000000..ce9bc45 --- /dev/null +++ b/cmake/openwattcom/Linux-OpenWatcom-C.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom) diff --git a/cmake/openwattcom/Linux-OpenWatcom-CXX.cmake b/cmake/openwattcom/Linux-OpenWatcom-CXX.cmake new file mode 100644 index 0000000..ce9bc45 --- /dev/null +++ b/cmake/openwattcom/Linux-OpenWatcom-CXX.cmake @@ -0,0 +1 @@ +include(Platform/Windows-OpenWatcom) diff --git a/cmake/openwattcom/Linux-OpenWatcom.cmake b/cmake/openwattcom/Linux-OpenWatcom.cmake new file mode 100644 index 0000000..d38d616 --- /dev/null +++ b/cmake/openwattcom/Linux-OpenWatcom.cmake @@ -0,0 +1,129 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__WINDOWS_OPENWATCOM) + return() +endif() +set(__WINDOWS_OPENWATCOM 1) + +set(CMAKE_LIBRARY_PATH_FLAG "libpath ") +set(CMAKE_LINK_LIBRARY_FLAG "library ") +set(CMAKE_LINK_LIBRARY_FILE_FLAG "library") + +if(CMAKE_VERBOSE_MAKEFILE) + set(CMAKE_WCL_QUIET) + set(CMAKE_WLINK_QUIET) + set(CMAKE_LIB_QUIET) +else() + set(CMAKE_WCL_QUIET "-zq") + set(CMAKE_WLINK_QUIET "option quiet") + set(CMAKE_LIB_QUIET "-q") +endif() + +string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ") +set(CMAKE_CREATE_WIN32_EXE "system nt_win" ) +set(CMAKE_CREATE_CONSOLE_EXE "system nt" ) +string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system nt_dll") +string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system nt_dll") +foreach(type SHARED MODULE EXE) + string(APPEND CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT " debug all opt map") + string(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT " debug all opt map") +endforeach() + +set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string. + +set(CMAKE_RC_COMPILER "rc" ) + +set(CMAKE_BUILD_TYPE_INIT Debug) + +# single/multi-threaded /-bm +# static/DLL run-time libraries /-br +# default is setup for multi-threaded + DLL run-time libraries +string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -w3 -dWIN32 -br -bm") +string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -w3 -dWIN32 -br -bm") +foreach(lang C CXX) + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -d2") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -s -os -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -s -ot -d0 -dNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -s -ot -d1 -dNDEBUG") +endforeach() + +foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) + set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1) + set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1) +endforeach() + +set(CMAKE_C_CREATE_IMPORT_LIBRARY + "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>") +set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) + +set(CMAKE_C_LINK_EXECUTABLE + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + + +set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) + +# compile a C++ file into an object file +set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") + +# compile a C file into an object file +set(CMAKE_C_COMPILE_OBJECT + "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}") + +# preprocess a C source file +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE + "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}") + +# preprocess a C++ source file +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE + "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") + +set(CMAKE_CXX_CREATE_SHARED_LIBRARY + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") +string(REPLACE " option implib=<TARGET_IMPLIB>" "" + CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") + +# create a C shared library +set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared module +set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) + +# create a C++ static library +set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ") + +# create a C static library +set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) + +if(NOT _CMAKE_WATCOM_VERSION) + set(_CMAKE_WATCOM_VERSION 1) + if(CMAKE_C_COMPILER_VERSION) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + set(_compiler_id ${CMAKE_C_COMPILER_ID}) + else() + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + set(_compiler_id ${CMAKE_CXX_COMPILER_ID}) + endif() + set(WATCOM16) + set(WATCOM17) + set(WATCOM18) + set(WATCOM19) + if("${_compiler_id}" STREQUAL "OpenWatcom") + if("${_compiler_version}" VERSION_LESS 1.7) + set(WATCOM16 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.7) + set(WATCOM17 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.8) + set(WATCOM18 1) + endif() + if("${_compiler_version}" VERSION_EQUAL 1.9) + set(WATCOM19 1) + endif() + endif() +endif() diff --git a/cmake/openwattcom/ow-cmake.sh b/cmake/openwattcom/ow-cmake.sh new file mode 100755 index 0000000..cbccba0 --- /dev/null +++ b/cmake/openwattcom/ow-cmake.sh @@ -0,0 +1,35 @@ +#!/bin/bash +export WATCOM=/home/wohlstand/Qt/Tools/ow-snapshot-2.0/ +export EDPATH=$WATCOM/eddat +export WIPFC=$WATCOM/wipfc +export INCLUDE="$djgpp_prefix/lh" +WATCOM_FLAGS="-blinux" +export CFLAGS="$WATCOM_FLAGS -xc -std=wc" +export CXXFLAGS="$WATCOM_FLAGS -xc++ -xs -feh -std=c++11" + +# export PKG_CONFIG_LIBDIR="${WATCOM}/lib/pkgconfig" +# djgpp_c_flags="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" + + +CUSTOM_PATH=/home/wohlstand/_git_repos/libADLMIDI/cmake/openwattcom:${WATCOM}/binl:$PATH + +if [[ "$1" != '--build' ]]; then + echo "KEK [${CUSTOM_PATH}]" + + PATH=${CUSTOM_PATH} cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=${WATCOM} \ + -DCMAKE_INSTALL_LIBDIR:PATH=${WATCOM}/lib386 \ + -DINCLUDE_INSTALL_DIR:PATH=${WATCOM}/lib386 \ + -DLIB_INSTALL_DIR:PATH=${WATCOM}/lib \ + -DSYSCONF_INSTALL_DIR:PATH=${WATCOM}/etc \ + -DSHARE_INSTALL_DIR:PATH=${WATCOM}/share \ + -DBUILD_SHARED_LIBS:BOOL=OFF \ + -DCMAKE_TOOLCHAIN_FILE=/home/wohlstand/_git_repos/libADLMIDI/cmake/openwattcom/toolchain-ow.cmake \ + "$@" + +else + PATH=${CUSTOM_PATH} cmake "$@" +fi + +#-DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/i686-pc-msdosdjgpp-wine + diff --git a/cmake/openwattcom/toolchain-ow.cmake b/cmake/openwattcom/toolchain-ow.cmake new file mode 100644 index 0000000..4f8b8f6 --- /dev/null +++ b/cmake/openwattcom/toolchain-ow.cmake @@ -0,0 +1,40 @@ +set (CMAKE_SYSTEM_NAME linux) + +set (OPENWATTCOM TRUE) + +set (WATCOM_PREFIX "/home/wohlstand/Qt/Tools/ow-snapshot-2.0") + +set (ENV{PATH} ${WATCOM_PREFIX}/binl:$ENV{PATH}) +set (ENV{WATCOM} ${WATCOM_PREFIX}) +set (ENV{INCLUDE} ${WATCOM_PREFIX}/lh) +set (ENV{EDPATH} ${WATCOM_PREFIX}/eddat) +set (ENV{WIPFC} ${WATCOM_PREFIX}/wipfc) + +# specify the cross compiler +set (CMAKE_C_COMPILER ${WATCOM_PREFIX}/binl/owcc) +set (CMAKE_CXX_COMPILER ${WATCOM_PREFIX}/binl/owcc) + +# where is the target environment +set (CMAKE_FIND_ROOT_PATH ${WATCOM_PREFIX}) + +# search for programs in the build host directories +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# for libraries and headers in the target directories +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set (CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +include_directories(${WATCOM_PREFIX}/lh) + +# Make sure Qt can be detected by CMake +set (QT_BINARY_DIR ${WATCOM_PREFIX}/binl /usr/bin) +set (QT_INCLUDE_DIRS_NO_SYSTEM ON) + +# These are needed for compiling lapack (RHBZ #753906) +#set (CMAKE_Fortran_COMPILER /home/wohlstand/Qt/Tools/ow-snapshot-2.0/binl/wfc) +#set (CMAKE_AR:FILEPATH /usr/local/djgpp/bin/i586-pc-msdosdjgpp-ar) +#set (CMAKE_RANLIB:FILEPATH /usr/local/djgpp/bin/i586-pc-msdosdjgpp-ranlib) + +# include(Linux-OpenWatcom.cmake) + + diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index e2d2730..50163ac 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -24,11 +24,14 @@ #include "adlmidi_private.hpp" #ifdef ADLMIDI_HW_OPL -static const unsigned MaxCards = 1; +#define MaxCards 1 +#define MaxCards_STR "1" //Why not just "#MaxCards" ? Watcom fails to pass this with "syntax error" :-P #else -static const unsigned MaxCards = 100; +#define MaxCards 100 +#define MaxCards_STR "100" #endif + /*---------------------------EXPORTS---------------------------*/ ADLMIDI_EXPORT struct ADL_MIDIPlayer *adl_init(long sample_rate) @@ -67,9 +70,7 @@ ADLMIDI_EXPORT int adl_setNumChips(ADL_MIDIPlayer *device, int numCards) play->m_setup.NumCards = static_cast<unsigned int>(numCards); if(play->m_setup.NumCards < 1 || play->m_setup.NumCards > MaxCards) { - std::stringstream s; - s << "number of cards may only be 1.." << MaxCards << ".\n"; - play->setErrorString(s.str()); + play->setErrorString("number of chips may only be 1.." MaxCards_STR ".\n"); return -1; } @@ -105,9 +106,13 @@ ADLMIDI_EXPORT int adl_setBank(ADL_MIDIPlayer *device, int bank) MIDIplay *play = reinterpret_cast<MIDIplay *>(device->adl_midiPlayer); if(static_cast<uint32_t>(bankno) >= NumBanks) { + #ifndef __WATCOMC__ std::stringstream s; s << "bank number may only be 0.." << (NumBanks - 1) << ".\n"; play->setErrorString(s.str()); + #else + play->setErrorString("Selected embedded bank is not exists!\n"); + #endif return -1; } @@ -135,9 +140,14 @@ ADLMIDI_EXPORT int adl_setNumFourOpsChn(ADL_MIDIPlayer *device, int ops4) MIDIplay *play = reinterpret_cast<MIDIplay *>(device->adl_midiPlayer); if((unsigned int)ops4 > 6 * play->m_setup.NumCards) { + #ifndef __WATCOMC__ std::stringstream s; s << "number of four-op channels may only be 0.." << (6 * (play->m_setup.NumCards)) << " when " << play->m_setup.NumCards << " OPL3 cards are used.\n"; play->setErrorString(s.str()); + #else + play->setErrorString("number of four-op channels may not be more than 6 channels per each OPL3 chip!\n"); + #endif + return -1; } diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp index 359536a..afe0610 100644 --- a/src/adlmidi_load.cpp +++ b/src/adlmidi_load.cpp @@ -181,7 +181,7 @@ bool MIDIplay::LoadBank(MIDIplay::fileReader &fr) } char magic[32]; - memset(magic, 0, 32); + std::memset(magic, 0, 32); uint16_t version = 0; @@ -194,7 +194,7 @@ bool MIDIplay::LoadBank(MIDIplay::fileReader &fr) return false; } - if(strncmp(magic, wopl3_magic, 11) != 0) + if(std::strncmp(magic, wopl3_magic, 11) != 0) { errorStringOut = "Custom bank: Invalid magic number!"; return false; @@ -215,7 +215,7 @@ bool MIDIplay::LoadBank(MIDIplay::fileReader &fr) } uint8_t head[6]; - memset(head, 0, 6); + std::memset(head, 0, 6); if(fr.read(head, 1, 6) != 6) { errorStringOut = "Custom bank: Can't read header!"; @@ -288,7 +288,7 @@ tryAgain: for(uint16_t i = 0; i < total; i++) { WOPL_Inst ins; - memset(&ins, 0, sizeof(WOPL_Inst)); + std::memset(&ins, 0, sizeof(WOPL_Inst)); if(!readInstrument(fr, ins, readPercussion)) { opl.setEmbeddedBank(m_setup.AdlBank); diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 27cfdb0..c860a88 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -77,6 +77,7 @@ typedef __int32 ssize_t; #include <deque> // deque #include <cmath> // exp, log, ceil #include <stdio.h> +#include <stdlib.h> #include <limits> // numeric_limit #ifndef _WIN32 diff --git a/src/nukedopl3.h b/src/nukedopl3.h index 0a686e2..5a92d05 100644 --- a/src/nukedopl3.h +++ b/src/nukedopl3.h @@ -28,6 +28,7 @@ #define OPL_OPL3_H #include <inttypes.h> +#include <stdint.h> #ifdef __cplusplus extern "C" { |