Skip to content

Commit

Permalink
New features, sync with upstream (#4)
Browse files Browse the repository at this point in the history
* ignore stuff

* ignore more

* add ROL support

* fix bug which is also still in adplug HEAD.

* list descriptions of file formats

* add example LDS file

* add example D00 file

* add AdLib MIDI Music Format sample file

* set either YM3812 clock or YMF262 clock, depending on mode

* Update README.md

* RIX test file

* note on standard.bnk, which is needed to convert ROL files

* script to extract Softstar RIX files from MUS.MKF

* remove duplicate

* add missing LDS entry to list

* support LAA Lucas Arts Adlib music files

* add LAA and CMF sample files

* support Sierra SCI files

* put extreme verbosity under command line option

* change boolean from int to bool

* suppress input file format debug information unless -d option is
specified

* show which file format driver we are using. we cannot use gettype()
because that might depend on values read from the header which we have
not read yet.

* enable -DDEBUG (some LogWrite in some drivers were not compiled)
separate debug log messages from error log messages

* globals are always initialized to 0

* fix compiler warnings

* only ignore build directory, always use out-of-tree builds!

* useful tool to check which a2m files can be converted (or played with
adplay)

* add A2M: AdLib Tracker 2 support

* proper error reporting when a2m version is not supported

* version 1 and version 5 sample files. I cannot find 2,3,6,7 (with
different compression) and 4,8 (without compression).

* add S3M Scream Tracker 3 AdLib support

* oops, fix left over half baked test code

* also support .as3m extensions

* (A)S3M sample tune

* add RAW support

* add Ultima 6 support

* add u6m support

* add u6m sample file

* fix compiler warnings

* static link and strip for release binaries

* add SA2/SAT Surprise AdLib Tracker support

* use std::map which appears sorted because it's a tree

* fix compiler warnings (long types)

* enable all warnings, fix dangling else, const on return type,
possible uninitialized variables

* fix compiler warnings. unused variables, uninitialized, dangling-else,
different signedness, differnt size

* sync with adplug HEAD. buffer overflow fix, unused variabes commented
out, normal .h extension

* fix unsigned long types, .h extension, case fallthroughs, unused
variables

* compiler fixes: unused variables, case fallthroughs

* actually enforce C++17 and disable GNU extensions. before, there was no
-std=c++17 option added to the command line.

* fix: modernize-use-override

* remove dependency on IODash for simply writing a file. IODash also has
an unsafe strcpy, although the socket code is not used.

* do not download stuff we have no control over. include cxxopts.hpp
directly, simplify build.

* as per the C++ Core Guidelines, use .h for header files and be
consistent with the rest of the project.

* add timbre bank for demo1.mus

* add AMUSIC Adlib Tracker support

* add IMF/WLF Apogee/id/3D Realms music file support

* Sync with latest adplug upstream. We lose all the compiler warning fixes
I wasted an hour of time on, but we gain very easy updating of loaders
when upstream changes. Only rad2.c (global_use_opl3 variable) and imf.c
(comment out database code) are changed now!

* Sync with adplug HEAD at Sat Oct 7 06:05:10 AM CEST 2023

* add missing debug.h and player.h

* remove linking with stdc++fs

* change %d to %ld for long ints

* add missing argument comlo

* add -W -Wall command line options again, except for unused variables and
case fallthroughs. Both should be fixed upstream. Compiles cleanly now.
All type related stuff (signed/unsigned comparissons) and other compiler
warnings were fixed in the last two years since when adlib2vgm forked the
library.

* update list of supported formats, change -l output to match that of
README.md which makes it easier to keep them in sync.

* add AdLib Tracker 1.0 support. One line added to Formats.h, one entry
added to main.cpp.

* add BAM, Bob's Adlib Music Player support

* add Easy AdLib 1.0 (aka FMPlay) by The Brain support

* add CMF2: SoundFX Macs Opera CMF Player support

* do not enforce .cmf extension

* add forgotten cff files

* Update README.md with latest additions.

* add support for all XAD players, add support for DeFy AdLib Tracker

* add Faust Music Tracker and God Of Thunder support

* add HERAD Herbulot AdLib Player support

* Update README.md with newly added formats

* add support for HSC Adlib Composer and Johannes Bjerregaard's JBM Adlib Music
Format.

* skip detection of C compiler

* add support for Ken Silverman Music, Mlat Adlib Tracker, and AdLib
Visual Composer MIDIPlay Files.

* only (over)write output file if a proper loader was found.

* Update README.md with newly added formats

* add support for Beni Tracker PIS module, add plumbing to force certain
loaders to use OPL3. PIS sounds wrong on OPL2.

* print using loader....

* add support for SNGPlay

* add support for Note Sequencer v1.0 by sopepos. Even though it is
properly forced to OPL3, it still doesn't sound the same as adplay. It
seems that some writes are lost during the conversion.

* final update of supported format list

* write end of sound data marker at end of sound data

* sort includes

* consistent all tab style, add vi modeline at the bottom

* make everything endian-proof. the old code did not work on big-endian
systems. add defines for common constants.

* simplify opl3 writes

* refactor store_sleep. use push_back on vector for a single item.

* remove stray spaces

* expand store_sleep to also emit shorter codes for short sleep times.

* further simplify store_sleep usage

* update credits

* decrease indentation by 1 by inverting condition

* replace stray spaces

* simplify. note that toupper() does nothing if !isalpha()

* during rounding of sleep_samples, keep track of the residue for slightly
better timing.

* add GD3 Tag support

* Update README.md, metadata is done.

* Revert commit 289193b
This accidentally broke KSM conversion, and probably others. Back to
leaving an empty output file when no proper loader was found.

* RIX loader can also demux MKF files directly. One of the few formats
that support subsongs.

* support subsong selection for the few formats that support multiple
songs in one file.

* add looping support. adplug does not return any loop points, so this
basically enables looping the whole file.

* Update README.md, remove looping todo.

* exit with error on unmatched command line arguments

* add auto-detect if 1) there is no extension, 2) the extension is
unknown, or 3) the format is overridden with -f detect or a similar
unknown format.

* add two "unknown" example files.

* Update README.md. File detection is implemented.

* add test to detect possible future regressions

* test: error if adlib2vgm is not found, and report if the results are
identical.

* also keep track of file sizes

* ignore test results

* invert diffs, reference first

* emit more shorter (2 bytes) wait commands instead of the full 3 byte
command.

* test/island is slightly shorter now we emit more optimal wait codes.

* simplify emitting wait n samples

* do not write empty files if something went wrong. only open en write the
output file if we have a successful conversion.

* also test exit codes (0,1, or 2)

* more robust error handling during save()

* eliminate need for file/filename as class variables.

* spaces back to tabs in CMakeLists, only include cpp files in sources
(dependencies on h files are automatic wit CMake), add utfcpp to include
directories.

* add gzip support.

* Update README.md, add zstr

* add forgotten zstr header files

* add check for static zlib

* Update README.md add zlib at the bottom, build instructions

* Update README.md compact usage examples, add examples of compression, looping and forced detection

* Update README.md add example with longopts and subsong

* Update README.md remove paths

---------

Co-authored-by: Ivo van Poorten <[email protected]>
  • Loading branch information
ivop and ivop authored Oct 12, 2023
1 parent 79cc13c commit 31210b5
Show file tree
Hide file tree
Showing 175 changed files with 23,151 additions and 2,043 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
*~
tools/test/*
tools/test.md5sum
tools/test.size
tools/test.exit
55 changes: 22 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,32 @@
cmake_minimum_required(VERSION 3.14)
project(adlib2vgm)
project(adlib2vgm LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CPM_DOWNLOAD_VERSION 0.27.5)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
set (CMAKE_CXX_FLAGS "-DDEBUG -O3 -W -Wall -Wno-unused-parameter -Wno-implicit-fallthrough")
set (CMAKE_EXE_LINKER_FLAGS "-static -s")

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake")
file(DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()

include(${CPM_DOWNLOAD_LOCATION})

CPMAddPackage(
NAME cxxopts
GITHUB_REPOSITORY jarro2783/cxxopts
VERSION 3.0.0
GIT_TAG 2d8e17c4f88efce80e274cb03eeb902e055a91d3
)
include_directories("binio" "utfcpp" "zstr")

CPMAddPackage(
NAME IODash
GITHUB_REPOSITORY YukiWorkshop/IODash
VERSION 0.1.8
)

include_directories(${cxxopts_SOURCE_DIR}/include)
file(GLOB_RECURSE SOURCES_BINIO "binio/*.cpp")
file(GLOB_RECURSE SOURCES_FMTS "Formats/*.cpp")
file(GLOB_RECURSE SOURCES_FAKE_ADPLUG "FakeAdplug/*.cpp")

file(GLOB_RECURSE SOURCES_BINIO "binio/*.*")
file(GLOB_RECURSE SOURCES_FMTS "Formats/*.*")
file(GLOB_RECURSE SOURCES_FAKE_ADPLUG "FakeAdplug/*.*")
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
find_library(ZLIB "z")
if(NOT ZLIB)
message(FATAL_ERROR "static zlib library not found")
endif()

add_executable(adlib2vgm
${SOURCES_BINIO}
${SOURCES_FAKE_ADPLUG}
${SOURCES_FMTS}
main.cpp CommonIncludes.hpp
VgmOpl.cpp VgmOpl.hpp
)
${SOURCES_BINIO}
${SOURCES_GZSTREAM}
${SOURCES_FAKE_ADPLUG}
${SOURCES_FMTS}
main.cpp
VgmOpl.cpp
)

target_link_libraries(adlib2vgm IODash stdc++fs)
target_link_libraries(adlib2vgm ${ZLIB})
13 changes: 8 additions & 5 deletions CommonIncludes.hpp → CommonIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@
#include <unistd.h>
#include <fcntl.h>

#include <cxxopts.hpp>
#include <IODash.hpp>

#define stricmp strcasecmp
#define AdPlug_LogWrite printf
#define AdPlug_LogWrite(...) if (global_debug) printf(__VA_ARGS__)
#define AdPlug_LogError(...) fprintf(stderr, __VA_ARGS__)

extern bool global_use_opl3;
extern bool global_verbose;
extern bool global_debug;

extern int global_use_opl3;
// portable unused
#define UNUSED(x) (void)(x)
6 changes: 3 additions & 3 deletions FakeAdplug/FakeAdplug.hpp → FakeAdplug/FakeAdplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

#pragma once

#include "FakeFprovide.hpp"
#include "FakePlayer.hpp"
#include "FakeOpl.hpp"
#include "FakeFprovide.h"
#include "FakePlayer.h"
#include "FakeOpl.h"
2 changes: 1 addition & 1 deletion FakeAdplug/FakeFprovide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* fprovide.cpp - File provider class framework, by Simon Peter <[email protected]>
*/

#include "FakeFprovide.hpp"
#include "FakeFprovide.h"

/***** CFileProvider *****/

Expand Down
9 changes: 5 additions & 4 deletions FakeAdplug/FakeFprovide.hpp → FakeAdplug/FakeFprovide.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@

#pragma once

#include "../CommonIncludes.hpp"
#include "../CommonIncludes.h"

#include "../binio/binio.h"
#include "../binio/binfile.h"
#include "../binio/binstr.h"

class CFileProvider
{
Expand All @@ -44,6 +45,6 @@ class CFileProvider
class CProvider_Filesystem: public CFileProvider
{
public:
virtual binistream *open(std::string filename) const;
virtual void close(binistream *f) const;
};
binistream *open(std::string filename) const override;
void close(binistream *f) const override;
};
8 changes: 4 additions & 4 deletions FakeAdplug/FakeOpl.hpp → FakeAdplug/FakeOpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#pragma once

#include "../CommonIncludes.hpp"
#include "../CommonIncludes.h"

class Copl
{
Expand Down Expand Up @@ -67,12 +67,12 @@ class Copl
}

// Emulation only: fill buffer
virtual void update(short *buf, int samples) {}
virtual void update(short *buf, int samples) {UNUSED(buf);UNUSED(samples);}

// Set surroundopl offset
virtual void set_offset(double offset) {}
virtual void set_offset(double offset) { UNUSED(offset); }

protected:
int currChip; // currently selected OPL chip number
ChipType currType; // this OPL chip's type
};
};
3 changes: 2 additions & 1 deletion FakeAdplug/FakePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* player.cpp - Replayer base class, by Simon Peter <[email protected]>
*/

#include "FakePlayer.hpp"
#include "FakePlayer.h"

const unsigned short CPlayer::note_table[12] =
{363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647, 686};
Expand All @@ -38,6 +38,7 @@ CPlayer::~CPlayer()

unsigned long CPlayer::songlength(int subsong)
{
UNUSED(subsong);
return 0;
}

Expand Down
10 changes: 5 additions & 5 deletions FakeAdplug/FakePlayer.hpp → FakeAdplug/FakePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

#pragma once

#include "../CommonIncludes.hpp"
#include "../CommonIncludes.h"

#include "FakeFprovide.hpp"
#include "FakeOpl.hpp"
#include "FakeFprovide.h"
#include "FakeOpl.h"

class CPlayer
{
Expand Down Expand Up @@ -70,12 +70,12 @@ class CPlayer
virtual unsigned int getinstruments() // returns number of instruments
{ return 0; }
virtual std::string getinstrument(unsigned int n) // returns n-th instrument name
{ return std::string(); }
{ UNUSED(n); return std::string(); }

protected:
Copl *opl; // our OPL chip
void *db; // AdPlug Database

static const unsigned short note_table[12]; // standard adlib note table
static const unsigned char op_table[9]; // the 9 operators as expected by the OPL
};
};
42 changes: 36 additions & 6 deletions Formats/Formats.hpp → Formats/Formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,42 @@

#pragma once

#include "d00.hpp"
#include "rad2.hpp"
#include "dro.h"
#include "a2m.h"
#include "adtrack.h"
#include "amd.h"
#include "bam.h"
#include "bmf.h"
#include "cff.h"
#include "cmf.h"
#include "cmfmcsop.h"
#include "d00.h"
#include "dro2.h"
#include "rix.h"
#include "dro.h"
#include "dtm.h"
#include "flash.h"
#include "fmc.h"
#include "got.h"
#include "herad.h"
#include "hsc.h"
#include "hybrid.h"
#include "hyp.h"
#include "imf.h"
#include "jbm.h"
#include "ksm.h"
#include "lds.h"
#include "mad.h"
#include "mdi.h"
#include "mid.h"
#include "cmf.h"
#include "mus.h"
#include "lds.h"
#include "pis.h"
#include "psi.h"
#include "rad2.h"
#include "rat.h"
#include "raw.h"
#include "rix.h"
#include "rol.h"
#include "s3m.h"
#include "sa2.h"
#include "sng.h"
#include "sop.h"
#include "u6m.h"
Loading

0 comments on commit 31210b5

Please sign in to comment.