From b030f8285d45c782c427b9ed8146fb47d6633d1e Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Thu, 4 Aug 2022 17:33:36 +1000 Subject: [PATCH 1/3] Bugfix for OPM file load - correctly handle AM-ENA where value is arbitrarily nonzero --- src/engine/fileOpsIns.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index b7ca22c1..369b1238 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -1262,7 +1262,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector& ret, St patchNameRead = lfoRead = characteristicRead = m1Read = c1Read = m2Read = c2Read = false; newPatch = NULL; }; - auto readIntStrWithinRange = [](String&& input, int limitLow, int limitHigh) -> int { + auto readIntStrWithinRange = [](String&& input, int limitLow = INT_MIN, int limitHigh = INT_MAX) -> int { int x = std::stoi(input.c_str()); if (x > limitHigh || x < limitLow) { throw std::invalid_argument(fmt::sprintf("%s is out of bounds of range [%d..%d]", input, limitLow, limitHigh)); @@ -1280,7 +1280,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector& ret, St op.mult = readIntStrWithinRange(reader.readStringToken(), 0, 15); op.dt = fmDtRegisterToFurnace(readIntStrWithinRange(reader.readStringToken(), 0, 7)); op.dt2 = readIntStrWithinRange(reader.readStringToken(), 0, 3); - op.am = readIntStrWithinRange(reader.readStringToken(), 0, 1); + op.am = readIntStrWithinRange(reader.readStringToken(), 0) > 0 ? 1 : 0; }; auto seekGroupValStart = [](SafeReader& reader, int pos) { // Seek to position then move to next ':' character From edb0f51131215cfb0b3b53b54c566e7a6b5ffef7 Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Thu, 4 Aug 2022 17:43:42 +1000 Subject: [PATCH 2/3] stdint required --- src/engine/fileOpsIns.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index 369b1238..e5ea58ab 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -21,6 +21,7 @@ #include "../ta-log.h" #include "../fileutils.h" #include +#include enum DivInsFormats { DIV_INSFORMAT_DMP, From 810eabca99851f6b769540c17169e0ee0bf79491 Mon Sep 17 00:00:00 2001 From: James Alan Nguyen Date: Thu, 4 Aug 2022 17:50:33 +1000 Subject: [PATCH 3/3] derp limits --- src/engine/fileOpsIns.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/fileOpsIns.cpp b/src/engine/fileOpsIns.cpp index e5ea58ab..54e0eefc 100644 --- a/src/engine/fileOpsIns.cpp +++ b/src/engine/fileOpsIns.cpp @@ -21,7 +21,7 @@ #include "../ta-log.h" #include "../fileutils.h" #include -#include +#include enum DivInsFormats { DIV_INSFORMAT_DMP,