Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Sep 3, 2018
2 parents f2a6218 + 5c9eb9c commit 9efe770
Show file tree
Hide file tree
Showing 12 changed files with 641 additions and 626 deletions.
2 changes: 1 addition & 1 deletion banks.ini
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ name = "WOPL (DMXOPL3 bank by Sneakernets)"
; file = "fm_banks/doom2/DMXOPL-by-sneakernets.op2"
format = WOPL
file = "fm_banks/wopl_files/DMXOPL3-by-sneakernets-GS.wopl"
prefix = "skeakernets"
prefix = "sneakernets"

; Special bank required to play MUS-files from Cartooners game
[bank-73]
Expand Down
Binary file modified fm_banks/adldata-cache.dat
Binary file not shown.
1,110 changes: 491 additions & 619 deletions src/adldata.cpp

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/adlmidi_opl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ OPL3::OPL3() :
m_musicMode(MODE_MIDI),
m_volumeScale(VOLUME_Generic)
{
m_insBankSetup.volumeModel = OPL3::VOLUME_Generic;
m_insBankSetup.deepTremolo = false;
m_insBankSetup.deepVibrato = false;
m_insBankSetup.adLibPercussions = false;
m_insBankSetup.scaleModulators = false;

#ifdef DISABLE_EMBEDDED_BANKS
m_embeddedBank = CustomBankTag;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/chips/dosbox_opl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ void DosBoxOPL3::nativeGenerateN(int16_t *output, size_t frames)

const char *DosBoxOPL3::emulatorName()
{
return "DosBox 0.74-r4111 OPL3";
return "DOSBox 0.74-r4111 OPL3";
}
10 changes: 7 additions & 3 deletions src/wopl/wopl_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ int WOPL_LoadInstFromMem(WOPIFile *file, void *mem, size_t length)
GO_FORWARD(2);
}

file->version = version;

{/* is drum flag */
if(length < 1)
return WOPL_ERR_UNEXPECTED_ENDING;
Expand Down Expand Up @@ -434,11 +436,13 @@ size_t WOPL_CalculateInstFileSize(WOPIFile *file, uint16_t version)
* is percussive instrument
*/

if(version >= 3)
ins_size = WOPL_INST_SIZE_V3;
if(version > 2)
/* Skip sounding delays are not part of single-instrument file
* two sizes of uint16_t will be subtracted */
ins_size = WOPL_INST_SIZE_V3 - (sizeof(uint16_t) * 2);
else
ins_size = WOPL_INST_SIZE_V2;
final_size += ins_size * 128;
final_size += ins_size;

return final_size;
}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(CMAKE_CXX_STANDARD 11)

add_subdirectory(bankmap)
add_subdirectory(conversion)
add_subdirectory(wopl-file)

add_library(Catch-objects OBJECT "common/catch_main.cpp")
target_include_directories(Catch-objects PRIVATE "common")
15 changes: 15 additions & 0 deletions test/wopl-file/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

set(CMAKE_CXX_STANDARD 11)

include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src)

add_executable(WoplFile
wopl_file.cpp
${libADLMIDI_SOURCE_DIR}/src/wopl/wopl_file.c
$<TARGET_OBJECTS:Catch-objects>)

set_target_properties(WoplFile PROPERTIES COMPILE_DEFINITIONS "GSL_THROW_ON_CONTRACT_VIOLATION")
add_test(NAME WoplFileTest COMMAND WoplFile)

116 changes: 116 additions & 0 deletions test/wopl-file/wopl_file.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#include <catch.hpp>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "wopl/wopl_file.h"

static const char *test_files[] = {
"fm_banks/wopl_files/Apogee-IMF-90.wopl",
"fm_banks/wopl_files/DMXOPL3-by-sneakernets-GS.wopl",
"fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl",
"fm_banks/wopl_files/lostvik.wopl",
"fm_banks/wopl_files/Wohlstand's-modded-FatMan.wopl"
};

static WOPLFile *LoadBankFromFile(const char *path);

TEST_CASE("[WOPLFile] Load, Save, Load")
{
for (int version : {1, 2}) {
for (const char *test_file : test_files) {
fprintf(stderr, "--- Test '%s' with version %d\n", test_file, version);

WOPLFile *wopl = LoadBankFromFile(test_file);
REQUIRE(wopl != nullptr);

size_t size = WOPL_CalculateBankFileSize(wopl, version);
char *mem = new char[size];

REQUIRE(WOPL_SaveBankToMem(wopl, mem, size, version, 0) == 0);

{
int error;
WOPLFile *wopl2 = WOPL_LoadBankFromMem(mem, size, &error);
if(!wopl2)
fprintf(stderr, "--- Loading error %d\n", error);
REQUIRE(wopl2);

if(wopl->version == version)
REQUIRE(WOPL_BanksCmp(wopl, wopl2) == 1);
else {
REQUIRE(wopl->banks_count_melodic == wopl2->banks_count_melodic);
REQUIRE(wopl->banks_count_percussion == wopl2->banks_count_percussion);
REQUIRE(wopl->opl_flags == wopl2->opl_flags);
REQUIRE(wopl->volume_model == wopl2->volume_model);
}

WOPL_Free(wopl2);
}

delete[] mem;

{
unsigned melo_banks = wopl->banks_count_melodic;
unsigned drum_banks = wopl->banks_count_percussion;

for(unsigned Bi = 0; Bi < melo_banks + drum_banks; ++Bi)
{
const WOPLBank &bank = (Bi < melo_banks) ?
wopl->banks_melodic[Bi] : wopl->banks_percussive[Bi - melo_banks];

for(unsigned Pi = 0; Pi < 128; ++Pi)
{
WOPIFile opli = {};
opli.version = version;
opli.is_drum = Bi >= melo_banks;
opli.inst = bank.ins[Pi];

size = WOPL_CalculateInstFileSize(&opli, version);
mem = new char[size];

REQUIRE(WOPL_SaveInstToMem(&opli, mem, size, version) == 0);

WOPIFile opli2 = {};
int error = WOPL_LoadInstFromMem(&opli2, mem, size);
if(error != 0)
fprintf(stderr, "--- Loading error %d\n", error);
REQUIRE(error == 0);

size_t compare_size = sizeof(WOPIFile) - 2 * sizeof(uint16_t);
REQUIRE(memcmp(&opli, &opli2, compare_size) == 0);

delete[] mem;
}
}
}

WOPL_Free(wopl);
}
}
}

static WOPLFile *LoadBankFromFile(const char *path)
{
WOPLFile *file = nullptr;
FILE *fh;
struct stat st;
char *mem = nullptr;

if(!(fh = fopen(path, "rb")) || fstat(fileno(fh), &st) != 0)
goto fail;

mem = new char[st.st_size];
if(fread(mem, st.st_size, 1, fh) != 1)
goto fail;

int error;
file = WOPL_LoadBankFromMem(mem, st.st_size, &error);
if(!file)
fprintf(stderr, "--- Loading error %d\n", error);

fail:
delete[] mem;
if (fh) fclose(fh);
return file;
}
1 change: 1 addition & 0 deletions utils/gen_adldata/file_formats/load_bnk2.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static bool LoadBNK2(const char *fn, unsigned bank, const char *prefix,
if(xxP24NNN & 8)
{
// dual-op
tmp2.real4op = true;
tmp[1].diff = true;
size_t resno = InsertIns(tmp[0], tmp[1], tmp2, std::string(1, '\377') + name, name2);
SetBank(bank, (unsigned int)gmno, resno);
Expand Down
2 changes: 1 addition & 1 deletion utils/gen_adldata/scrapped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ LoadTMB("fm_banks/tmb_files/bloodtmb.tmb", 69, "apgblood");
LoadTMB("fm_banks/tmb_files/lee.tmb", 70, "apglee");
LoadTMB("fm_banks/tmb_files/nam.tmb", 71, "apgnam");

LoadDoom("fm_banks/doom2/DMXOPL-by-sneakernets.op2", 72, "skeakernets");
LoadDoom("fm_banks/doom2/DMXOPL-by-sneakernets.op2", 72, "sneakernets");

//LoadBNK("bnk_files/grassman1.bnk", 63, "b63", false);
//LoadBNK("bnk_files/grassman2.bnk", 64, "b64", false);
Expand Down
2 changes: 1 addition & 1 deletion utils/vlc_codec/libadlmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static const char * const emulator_type_descriptions[] =
{
N_("Nuked OPL3 1.8"),
N_("Nuked OPL3 1.7.4 (Optimized)"),
N_("DosBox"),
N_("DOSBox"),
NULL
};

Expand Down

0 comments on commit 9efe770

Please sign in to comment.