* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().
| ... | ... |
@@ -6,12 +6,17 @@ |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 | 8 |
#include <bitset> |
| 9 |
-#include "XSFPlayer.h" |
|
| 9 |
+#include <sstream> |
|
| 10 |
+#include <string> |
|
| 11 |
+#include <cstddef> |
|
| 12 |
+#include "windowsh_wrapper.h" |
|
| 10 | 13 |
#include "XSFConfig.h" |
| 11 | 14 |
#include "convert.h" |
| 12 | 15 |
#include "desmume/NDSSystem.h" |
| 13 | 16 |
#include "desmume/version.h" |
| 14 | 17 |
|
| 18 |
+class XSFPlayer; |
|
| 19 |
+ |
|
| 15 | 20 |
enum |
| 16 | 21 |
{
|
| 17 | 22 |
idInterpolation = 1000, |
| ... | ... |
@@ -71,11 +76,11 @@ void XSFConfig_2SF::SaveSpecificConfig() |
| 71 | 76 |
|
| 72 | 77 |
void XSFConfig_2SF::GenerateSpecificDialogs() |
| 73 | 78 |
{
|
| 74 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 75 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idInterpolation).IsDropDownList(). |
|
| 79 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 80 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idInterpolation).IsDropDownList(). |
|
| 76 | 81 |
WithTabStop()); |
| 77 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 78 |
- this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 82 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 83 |
+ this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 79 | 84 |
WithVerticalScrollbar().WithMultipleSelect().WithTabStop()); |
| 80 | 85 |
} |
| 81 | 86 |
|
| ... | ... |
@@ -91,7 +96,7 @@ INT_PTR CALLBACK XSFConfig_2SF::ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM |
| 91 | 96 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Sharp Interpolation")); |
| 92 | 97 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, this->interpolation, 0); |
| 93 | 98 |
// Mutes |
| 94 |
- for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 99 |
+ for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 95 | 100 |
{
|
| 96 | 101 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((L"SPU " + std::to_wstring(x + 1)).c_str())); |
| 97 | 102 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, this->mutes[x], x); |
| ... | ... |
@@ -108,14 +113,14 @@ void XSFConfig_2SF::ResetSpecificConfigDefaults(HWND hwndDlg) |
| 108 | 113 |
{
|
| 109 | 114 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, XSFConfig_2SF::initInterpolation, 0); |
| 110 | 115 |
auto tmpMutes = std::bitset<16>(XSFConfig_2SF::initMutes); |
| 111 |
- for (size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x) |
|
| 116 |
+ for (std::size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x) |
|
| 112 | 117 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, tmpMutes[x], x); |
| 113 | 118 |
} |
| 114 | 119 |
|
| 115 | 120 |
void XSFConfig_2SF::SaveSpecificConfigDialog(HWND hwndDlg) |
| 116 | 121 |
{
|
| 117 | 122 |
this->interpolation = static_cast<unsigned>(SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_GETCURSEL, 0, 0)); |
| 118 |
- for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 123 |
+ for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 119 | 124 |
this->mutes[x] = !!SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_GETSEL, x, 0); |
| 120 | 125 |
} |
| 121 | 126 |
|
| ... | ... |
@@ -124,7 +129,7 @@ void XSFConfig_2SF::CopySpecificConfigToMemory(XSFPlayer *, bool preLoad) |
| 124 | 129 |
if (!preLoad) |
| 125 | 130 |
{
|
| 126 | 131 |
CommonSettings.spuInterpolationMode = static_cast<SPUInterpolationMode>(this->interpolation); |
| 127 |
- for (size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 132 |
+ for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 128 | 133 |
CommonSettings.spu_muteChannels[x] = this->mutes[x]; |
| 129 | 134 |
} |
| 130 | 135 |
} |
| ... | ... |
@@ -10,19 +10,22 @@ |
| 10 | 10 |
* http://desmume.org/ |
| 11 | 11 |
*/ |
| 12 | 12 |
|
| 13 |
+#include <algorithm> |
|
| 13 | 14 |
#include <filesystem> |
| 14 | 15 |
#include <memory> |
| 16 |
+#include <string> |
|
| 17 |
+#include <vector> |
|
| 18 |
+#include <cstdint> |
|
| 15 | 19 |
#include <zlib.h> |
| 16 |
-#include "convert.h" |
|
| 17 |
-#include "XSFPlayer.h" |
|
| 18 | 20 |
#include "XSFCommon.h" |
| 21 |
+#include "XSFPlayer.h" |
|
| 19 | 22 |
#include "desmume/NDSSystem.h" |
| 20 | 23 |
|
| 21 | 24 |
class XSFPlayer_2SF : public XSFPlayer |
| 22 | 25 |
{
|
| 23 |
- std::vector<uint8_t> rom; |
|
| 26 |
+ std::vector<std::uint8_t> rom; |
|
| 24 | 27 |
|
| 25 |
- void Map2SFSection(const std::vector<uint8_t> §ion); |
|
| 28 |
+ void Map2SFSection(const std::vector<std::uint8_t> §ion); |
|
| 26 | 29 |
bool Map2SF(XSFFile *xSFToLoad); |
| 27 | 30 |
bool RecursiveLoad2SF(XSFFile *xSFToLoad, int level); |
| 28 | 31 |
bool Load2SF(XSFFile *xSFToLoad); |
| ... | ... |
@@ -33,7 +36,7 @@ public: |
| 33 | 36 |
#endif |
| 34 | 37 |
~XSFPlayer_2SF() { this->Terminate(); }
|
| 35 | 38 |
bool Load(); |
| 36 |
- void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 39 |
+ void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 37 | 40 |
void Terminate(); |
| 38 | 41 |
}; |
| 39 | 42 |
|
| ... | ... |
@@ -56,17 +59,17 @@ volatile bool execute = false; |
| 56 | 59 |
|
| 57 | 60 |
static struct |
| 58 | 61 |
{
|
| 59 |
- std::vector<uint8_t> buf; |
|
| 62 |
+ std::vector<std::uint8_t> buf; |
|
| 60 | 63 |
unsigned filled, used; |
| 61 |
- uint32_t bufferbytes, cycles; |
|
| 64 |
+ std::uint32_t bufferbytes, cycles; |
|
| 62 | 65 |
int xfs_load, sync_type; |
| 63 |
-} sndifwork = { std::vector<uint8_t>(), 0, 0, 0, 0, 0, 0 };
|
|
| 66 |
+} sndifwork = { std::vector<std::uint8_t>(), 0, 0, 0, 0, 0, 0 };
|
|
| 64 | 67 |
|
| 65 | 68 |
static void SNDIFDeInit() { }
|
| 66 | 69 |
|
| 67 | 70 |
static int SNDIFInit(int buffersize) |
| 68 | 71 |
{
|
| 69 |
- uint32_t bufferbytes = buffersize * sizeof(int16_t); |
|
| 72 |
+ std::uint32_t bufferbytes = buffersize * sizeof(std::int16_t); |
|
| 70 | 73 |
SNDIFDeInit(); |
| 71 | 74 |
sndifwork.buf.resize(bufferbytes + 3); |
| 72 | 75 |
sndifwork.bufferbytes = bufferbytes; |
| ... | ... |
@@ -79,17 +82,17 @@ static void SNDIFMuteAudio() { }
|
| 79 | 82 |
static void SNDIFUnMuteAudio() { }
|
| 80 | 83 |
static void SNDIFSetVolume(int) { }
|
| 81 | 84 |
|
| 82 |
-static uint32_t SNDIFGetAudioSpace() |
|
| 85 |
+static std::uint32_t SNDIFGetAudioSpace() |
|
| 83 | 86 |
{
|
| 84 | 87 |
return sndifwork.bufferbytes >> 2; // bytes to samples |
| 85 | 88 |
} |
| 86 | 89 |
|
| 87 |
-static void SNDIFUpdateAudio(int16_t *buffer, uint32_t num_samples) |
|
| 90 |
+static void SNDIFUpdateAudio(std::int16_t *buffer, std::uint32_t num_samples) |
|
| 88 | 91 |
{
|
| 89 |
- uint32_t num_bytes = num_samples << 2; |
|
| 92 |
+ std::uint32_t num_bytes = num_samples << 2; |
|
| 90 | 93 |
if (num_bytes > sndifwork.bufferbytes) |
| 91 | 94 |
num_bytes = sndifwork.bufferbytes; |
| 92 |
- std::copy_n(reinterpret_cast<uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]); |
|
| 95 |
+ std::copy_n(reinterpret_cast<std::uint8_t *>(buffer), num_bytes, &sndifwork.buf[0]); |
|
| 93 | 96 |
sndifwork.filled = num_bytes; |
| 94 | 97 |
sndifwork.used = 0; |
| 95 | 98 |
} |
| ... | ... |
@@ -118,9 +121,9 @@ SoundInterface_struct *SNDCoreList[] = |
| 118 | 121 |
nullptr |
| 119 | 122 |
}; |
| 120 | 123 |
|
| 121 |
-void XSFPlayer_2SF::Map2SFSection(const std::vector<uint8_t> §ion) |
|
| 124 |
+void XSFPlayer_2SF::Map2SFSection(const std::vector<std::uint8_t> §ion) |
|
| 122 | 125 |
{
|
| 123 |
- uint32_t offset = Get32BitsLE(§ion[0]), size = Get32BitsLE(§ion[4]), finalSize = size + offset; |
|
| 126 |
+ std::uint32_t offset = Get32BitsLE(§ion[0]), size = Get32BitsLE(§ion[4]), finalSize = size + offset; |
|
| 124 | 127 |
finalSize = NextHighestPowerOf2(finalSize); |
| 125 | 128 |
if (this->rom.empty()) |
| 126 | 129 |
this->rom.resize(finalSize + 10, 0); |
| ... | ... |
@@ -244,15 +247,15 @@ bool XSFPlayer_2SF::Load() |
| 244 | 247 |
return XSFPlayer::Load(); |
| 245 | 248 |
} |
| 246 | 249 |
|
| 247 |
-void XSFPlayer_2SF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 250 |
+void XSFPlayer_2SF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 248 | 251 |
{
|
| 249 | 252 |
static const double HBASE_CYCLES = 33509300.322234; |
| 250 | 253 |
static const int HLINE_CYCLES = 6 * (99 + 256); |
| 251 |
- static const uint32_t HSAMPLES = static_cast<uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES) / HBASE_CYCLES); |
|
| 254 |
+ std::uint32_t HSAMPLES = static_cast<std::uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES) / HBASE_CYCLES); |
|
| 252 | 255 |
static const int VDIVISION = 100; |
| 253 | 256 |
static const int VLINES = 263; |
| 254 | 257 |
static const double VBASE_CYCLES = HBASE_CYCLES / VDIVISION; |
| 255 |
- static const uint32_t VSAMPLES = static_cast<uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES * VLINES) / HBASE_CYCLES); |
|
| 258 |
+ std::uint32_t VSAMPLES = static_cast<std::uint32_t>(static_cast<double>(this->sampleRate * HLINE_CYCLES * VLINES) / HBASE_CYCLES); |
|
| 256 | 259 |
|
| 257 | 260 |
if (!sndifwork.xfs_load) |
| 258 | 261 |
return; |
| ... | ... |
@@ -286,19 +289,19 @@ void XSFPlayer_2SF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 286 | 289 |
{
|
| 287 | 290 |
/* vsync */ |
| 288 | 291 |
sndifwork.cycles += (this->sampleRate / VDIVISION) * HLINE_CYCLES * VLINES; |
| 289 |
- if (sndifwork.cycles >= static_cast<uint32_t>(VBASE_CYCLES * (VSAMPLES + 1))) |
|
| 290 |
- sndifwork.cycles -= static_cast<uint32_t>(VBASE_CYCLES * (VSAMPLES + 1)); |
|
| 292 |
+ if (sndifwork.cycles >= static_cast<std::uint32_t>(VBASE_CYCLES * (VSAMPLES + 1))) |
|
| 293 |
+ sndifwork.cycles -= static_cast<std::uint32_t>(VBASE_CYCLES * (VSAMPLES + 1)); |
|
| 291 | 294 |
else |
| 292 |
- sndifwork.cycles -= static_cast<uint32_t>(VBASE_CYCLES * VSAMPLES); |
|
| 295 |
+ sndifwork.cycles -= static_cast<std::uint32_t>(VBASE_CYCLES * VSAMPLES); |
|
| 293 | 296 |
} |
| 294 | 297 |
else |
| 295 | 298 |
{
|
| 296 | 299 |
/* hsync */ |
| 297 | 300 |
sndifwork.cycles += this->sampleRate * HLINE_CYCLES; |
| 298 |
- if (sndifwork.cycles >= static_cast<uint32_t>(HBASE_CYCLES * (HSAMPLES + 1))) |
|
| 299 |
- sndifwork.cycles -= static_cast<uint32_t>(HBASE_CYCLES * (HSAMPLES + 1)); |
|
| 301 |
+ if (sndifwork.cycles >= static_cast<std::uint32_t>(HBASE_CYCLES * (HSAMPLES + 1))) |
|
| 302 |
+ sndifwork.cycles -= static_cast<std::uint32_t>(HBASE_CYCLES * (HSAMPLES + 1)); |
|
| 300 | 303 |
else |
| 301 |
- sndifwork.cycles -= static_cast<uint32_t>(HBASE_CYCLES * HSAMPLES); |
|
| 304 |
+ sndifwork.cycles -= static_cast<std::uint32_t>(HBASE_CYCLES * HSAMPLES); |
|
| 302 | 305 |
} |
| 303 | 306 |
NDS_exec<false>(); |
| 304 | 307 |
SPU_Emulate_user(); |
| ... | ... |
@@ -6,11 +6,15 @@ |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 | 8 |
#include <bitset> |
| 9 |
-#include "XSFPlayer.h" |
|
| 9 |
+#include <sstream> |
|
| 10 |
+#include <string> |
|
| 11 |
+#include "windowsh_wrapper.h" |
|
| 10 | 12 |
#include "XSFConfig.h" |
| 11 | 13 |
#include "convert.h" |
| 12 | 14 |
#include "vbam/gba/Sound.h" |
| 13 | 15 |
|
| 16 |
+class XSFPlayer; |
|
| 17 |
+ |
|
| 14 | 18 |
enum |
| 15 | 19 |
{
|
| 16 | 20 |
idLowPassFiltering = 1000, |
| ... | ... |
@@ -80,10 +84,10 @@ void XSFConfig_GSF::SaveSpecificConfig() |
| 80 | 84 |
|
| 81 | 85 |
void XSFConfig_GSF::GenerateSpecificDialogs() |
| 82 | 86 |
{
|
| 83 |
- this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Low-Pass Filtering").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop(). |
|
| 87 |
+ this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Low-Pass Filtering").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop(). |
|
| 84 | 88 |
WithID(idLowPassFiltering)); |
| 85 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10)).IsLeftJustified()); |
|
| 86 |
- this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 89 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10)).IsLeftJustified()); |
|
| 90 |
+ this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 87 | 91 |
WithVerticalScrollbar().WithMultipleSelect().WithTabStop()); |
| 88 | 92 |
} |
| 89 | 93 |
|
| ... | ... |
@@ -10,12 +10,16 @@ |
| 10 | 10 |
* http://vba-m.com/ |
| 11 | 11 |
*/ |
| 12 | 12 |
|
| 13 |
+#include <algorithm> |
|
| 13 | 14 |
#include <filesystem> |
| 14 | 15 |
#include <memory> |
| 16 |
+#include <string> |
|
| 17 |
+#include <vector> |
|
| 18 |
+#include <cstddef> |
|
| 19 |
+#include <cstdint> |
|
| 15 | 20 |
#include <zlib.h> |
| 16 |
-#include "convert.h" |
|
| 17 |
-#include "XSFPlayer.h" |
|
| 18 | 21 |
#include "XSFCommon.h" |
| 22 |
+#include "XSFPlayer.h" |
|
| 19 | 23 |
#include "vbam/gba/Globals.h" |
| 20 | 24 |
#include "vbam/gba/Sound.h" |
| 21 | 25 |
#include "vbam/common/SoundDriver.h" |
| ... | ... |
@@ -29,7 +33,7 @@ public: |
| 29 | 33 |
#endif |
| 30 | 34 |
~XSFPlayer_GSF() { this->Terminate(); }
|
| 31 | 35 |
bool Load(); |
| 32 |
- void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 36 |
+ void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 33 | 37 |
void Terminate(); |
| 34 | 38 |
}; |
| 35 | 39 |
|
| ... | ... |
@@ -50,13 +54,13 @@ XSFPlayer *XSFPlayer::Create(const std::wstring &fn) |
| 50 | 54 |
|
| 51 | 55 |
static struct |
| 52 | 56 |
{
|
| 53 |
- std::vector<uint8_t> rom; |
|
| 57 |
+ std::vector<std::uint8_t> rom; |
|
| 54 | 58 |
unsigned entry; |
| 55 |
-} loaderwork = { std::vector<uint8_t>(), 0 };
|
|
| 59 |
+} loaderwork = { std::vector<std::uint8_t>(), 0 };
|
|
| 56 | 60 |
|
| 57 |
-int mapgsf(uint8_t *d, int l, int &s) |
|
| 61 |
+int mapgsf(std::uint8_t *d, int l, int &s) |
|
| 58 | 62 |
{
|
| 59 |
- if (static_cast<size_t>(l) > loaderwork.rom.size()) |
|
| 63 |
+ if (static_cast<std::size_t>(l) > loaderwork.rom.size()) |
|
| 60 | 64 |
l = loaderwork.rom.size(); |
| 61 | 65 |
if (l) |
| 62 | 66 |
std::copy_n(&loaderwork.rom[0], l, d); |
| ... | ... |
@@ -66,9 +70,9 @@ int mapgsf(uint8_t *d, int l, int &s) |
| 66 | 70 |
|
| 67 | 71 |
static struct |
| 68 | 72 |
{
|
| 69 |
- std::vector<uint8_t> buf; |
|
| 70 |
- uint32_t len, fil, cur; |
|
| 71 |
-} buffer = { std::vector<uint8_t>(), 0, 0, 0 };
|
|
| 73 |
+ std::vector<std::uint8_t> buf; |
|
| 74 |
+ std::uint32_t len, fil, cur; |
|
| 75 |
+} buffer = { std::vector<std::uint8_t>(), 0, 0, 0 };
|
|
| 72 | 76 |
|
| 73 | 77 |
class GSFSoundDriver : public SoundDriver |
| 74 | 78 |
{
|
| ... | ... |
@@ -81,7 +85,7 @@ public: |
| 81 | 85 |
bool init(long sampleRate) |
| 82 | 86 |
{
|
| 83 | 87 |
freebuffer(); |
| 84 |
- uint32_t len = (sampleRate / 10) << 2; |
|
| 88 |
+ std::int32_t len = (sampleRate / 10) << 2; |
|
| 85 | 89 |
buffer.buf.resize(len); |
| 86 | 90 |
buffer.len = len; |
| 87 | 91 |
return true; |
| ... | ... |
@@ -99,13 +103,13 @@ public: |
| 99 | 103 |
{
|
| 100 | 104 |
} |
| 101 | 105 |
|
| 102 |
- void write(uint16_t *finalWave, int length) |
|
| 106 |
+ void write(std::uint16_t *finalWave, int length) |
|
| 103 | 107 |
{
|
| 104 |
- if (static_cast<uint32_t>(length) > buffer.len - buffer.fil) |
|
| 108 |
+ if (static_cast<std::uint32_t>(length) > buffer.len - buffer.fil) |
|
| 105 | 109 |
length = buffer.len - buffer.fil; |
| 106 | 110 |
if (length > 0) |
| 107 | 111 |
{
|
| 108 |
- std::copy_n(reinterpret_cast<uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]); |
|
| 112 |
+ std::copy_n(reinterpret_cast<std::uint8_t *>(finalWave), length, &buffer.buf[buffer.fil]); |
|
| 109 | 113 |
buffer.fil += length; |
| 110 | 114 |
} |
| 111 | 115 |
} |
| ... | ... |
@@ -120,11 +124,11 @@ SoundDriver *systemSoundInit() |
| 120 | 124 |
return new GSFSoundDriver(); |
| 121 | 125 |
} |
| 122 | 126 |
|
| 123 |
-static void MapGSFSection(const std::vector<uint8_t> §ion, int level) |
|
| 127 |
+static void MapGSFSection(const std::vector<std::uint8_t> §ion, int level) |
|
| 124 | 128 |
{
|
| 125 | 129 |
auto &data = loaderwork.rom; |
| 126 | 130 |
|
| 127 |
- uint32_t entry = Get32BitsLE(§ion[0]), offset = Get32BitsLE(§ion[4]) & 0x1FFFFFF, size = Get32BitsLE(§ion[8]), finalSize = size + offset; |
|
| 131 |
+ std::uint32_t entry = Get32BitsLE(§ion[0]), offset = Get32BitsLE(§ion[4]) & 0x1FFFFFF, size = Get32BitsLE(§ion[8]), finalSize = size + offset; |
|
| 128 | 132 |
if (level == 1) |
| 129 | 133 |
loaderwork.entry = entry; |
| 130 | 134 |
finalSize = NextHighestPowerOf2(finalSize); |
| ... | ... |
@@ -226,7 +230,7 @@ bool XSFPlayer_GSF::Load() |
| 226 | 230 |
return XSFPlayer::Load(); |
| 227 | 231 |
} |
| 228 | 232 |
|
| 229 |
-void XSFPlayer_GSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 233 |
+void XSFPlayer_GSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 230 | 234 |
{
|
| 231 | 235 |
unsigned bytes = samples << 2; |
| 232 | 236 |
while (bytes) |
| ... | ... |
@@ -10,10 +10,19 @@ |
| 10 | 10 |
* http://desmume.org/ |
| 11 | 11 |
*/ |
| 12 | 12 |
|
| 13 |
-#include "XSFCommon.h" |
|
| 13 |
+#include <algorithm> |
|
| 14 |
+#include <vector> |
|
| 15 |
+#define _USE_MATH_DEFINES |
|
| 16 |
+#include <cmath> |
|
| 17 |
+#include <cstddef> |
|
| 18 |
+#include <cstdint> |
|
| 14 | 19 |
#include "Channel.h" |
| 15 | 20 |
#include "Player.h" |
| 21 |
+#include "SWAV.h" |
|
| 22 |
+#include "Track.h" |
|
| 23 |
+#include "XSFCommon.h" |
|
| 16 | 24 |
#include "common.h" |
| 25 |
+#include "consts.h" |
|
| 17 | 26 |
|
| 18 | 27 |
NDSSoundRegister::NDSSoundRegister() : volumeMul(0), volumeDiv(0), panning(0), waveDuty(0), repeatMode(0), format(0), enable(false), |
| 19 | 28 |
source(nullptr), timer(0), psgX(0), psgLast(0), psgLastCount(0), samplePosition(0), sampleIncrease(0), loopStart(0), length(0), totalLength(0) |
| ... | ... |
@@ -26,7 +35,7 @@ void NDSSoundRegister::ClearControlRegister() |
| 26 | 35 |
this->enable = false; |
| 27 | 36 |
} |
| 28 | 37 |
|
| 29 |
-void NDSSoundRegister::SetControlRegister(uint32_t reg) |
|
| 38 |
+void NDSSoundRegister::SetControlRegister(std::uint32_t reg) |
|
| 30 | 39 |
{
|
| 31 | 40 |
this->volumeMul = reg & 0x7F; |
| 32 | 41 |
this->volumeDiv = (reg >> 8) & 0x03; |
| ... | ... |
@@ -54,7 +63,7 @@ static inline double sinc(double x) |
| 54 | 63 |
return fEqual(x, 0.0) ? 1.0 : std::sin(x * M_PI) / (x * M_PI); |
| 55 | 64 |
} |
| 56 | 65 |
|
| 57 |
-Channel::Channel() : chnId(-1), tempReg(), state(CS_NONE), trackId(-1), prio(0), manualSweep(false), flags(), pan(0), extAmpl(0), velocity(0), extPan(0), |
|
| 66 |
+Channel::Channel() : chnId(-1), tempReg(), state(ChannelState::None), trackId(-1), prio(0), manualSweep(false), flags(), pan(0), extAmpl(0), velocity(0), extPan(0), |
|
| 58 | 67 |
key(0), ampl(0), extTune(0), orgKey(0), modType(0), modSpeed(0), modDepth(0), modRange(0), modDelay(0), modDelayCnt(0), modCounter(0), |
| 59 | 68 |
sweepLen(0), sweepCnt(0), sweepPitch(0), attackLvl(0), sustainLvl(0x7F), decayRate(0), releaseRate(0xFFFF), noteLength(-1), vol(0), ply(nullptr), reg(), |
| 60 | 69 |
ringBuffer() |
| ... | ... |
@@ -114,7 +123,7 @@ void Channel::UpdatePorta(const Track &trk) |
| 114 | 123 |
this->manualSweep = false; |
| 115 | 124 |
this->sweepPitch = trk.sweepPitch; |
| 116 | 125 |
this->sweepCnt = 0; |
| 117 |
- if (!trk.state[TS_PORTABIT]) |
|
| 126 |
+ if (!trk.state[ToIntegral(TrackState::PortamentoBit)]) |
|
| 118 | 127 |
{
|
| 119 | 128 |
this->sweepLen = 0; |
| 120 | 129 |
return; |
| ... | ... |
@@ -130,7 +139,7 @@ void Channel::UpdatePorta(const Track &trk) |
| 130 | 139 |
} |
| 131 | 140 |
else |
| 132 | 141 |
{
|
| 133 |
- int sq_time = static_cast<uint32_t>(trk.portaTime) * static_cast<uint32_t>(trk.portaTime); |
|
| 142 |
+ int sq_time = static_cast<std::uint32_t>(trk.portaTime) * static_cast<std::uint32_t>(trk.portaTime); |
|
| 134 | 143 |
int abs_sp = std::abs(this->sweepPitch); |
| 135 | 144 |
this->sweepLen = (abs_sp * sq_time) >> 11; |
| 136 | 145 |
} |
| ... | ... |
@@ -141,13 +150,13 @@ void Channel::Release() |
| 141 | 150 |
{
|
| 142 | 151 |
this->noteLength = -1; |
| 143 | 152 |
this->prio = 1; |
| 144 |
- this->state = CS_RELEASE; |
|
| 153 |
+ this->state = ChannelState::Release; |
|
| 145 | 154 |
} |
| 146 | 155 |
|
| 147 | 156 |
// Original FSS Function: Chn_Kill |
| 148 | 157 |
void Channel::Kill() |
| 149 | 158 |
{
|
| 150 |
- this->state = CS_NONE; |
|
| 159 |
+ this->state = ChannelState::None; |
|
| 151 | 160 |
this->trackId = -1; |
| 152 | 161 |
this->prio = 0; |
| 153 | 162 |
this->reg.ClearControlRegister(); |
| ... | ... |
@@ -155,18 +164,16 @@ void Channel::Kill() |
| 155 | 164 |
this->noteLength = -1; |
| 156 | 165 |
} |
| 157 | 166 |
|
| 158 |
-static inline int getModFlag(int type) |
|
| 167 |
+static inline ChannelFlag getModFlag(int type) |
|
| 159 | 168 |
{
|
| 160 | 169 |
switch (type) |
| 161 | 170 |
{
|
| 162 | 171 |
case 0: |
| 163 |
- return CF_UPDTMR; |
|
| 164 |
- case 1: |
|
| 165 |
- return CF_UPDVOL; |
|
| 172 |
+ return ChannelFlag::UpdateTimer; |
|
| 166 | 173 |
case 2: |
| 167 |
- return CF_UPDPAN; |
|
| 168 |
- default: |
|
| 169 |
- return 0; |
|
| 174 |
+ return ChannelFlag::UpdatePan; |
|
| 175 |
+ default: // basically 1 |
|
| 176 |
+ return ChannelFlag::UpdateVolume; |
|
| 170 | 177 |
} |
| 171 | 178 |
} |
| 172 | 179 |
|
| ... | ... |
@@ -185,46 +192,46 @@ void Channel::UpdateTrack() |
| 185 | 192 |
if (trackFlags.none()) |
| 186 | 193 |
return; |
| 187 | 194 |
|
| 188 |
- if (trackFlags[TUF_LEN]) |
|
| 195 |
+ if (trackFlags[ToIntegral(TrackUpdateFlag::Length)]) |
|
| 189 | 196 |
{
|
| 190 |
- int st = this->state; |
|
| 191 |
- if (st > CS_START) |
|
| 197 |
+ ChannelState st = this->state; |
|
| 198 |
+ if (st > ChannelState::Start) |
|
| 192 | 199 |
{
|
| 193 |
- if (st < CS_RELEASE && !--this->noteLength) |
|
| 200 |
+ if (st < ChannelState::Release && !--this->noteLength) |
|
| 194 | 201 |
this->Release(); |
| 195 | 202 |
if (this->manualSweep && this->sweepCnt < this->sweepLen) |
| 196 | 203 |
++this->sweepCnt; |
| 197 | 204 |
} |
| 198 | 205 |
} |
| 199 |
- if (trackFlags[TUF_VOL]) |
|
| 206 |
+ if (trackFlags[ToIntegral(TrackUpdateFlag::Volume)]) |
|
| 200 | 207 |
{
|
| 201 | 208 |
this->UpdateVol(trk); |
| 202 |
- this->flags.set(CF_UPDVOL); |
|
| 209 |
+ this->flags.set(ToIntegral(ChannelFlag::UpdateVolume)); |
|
| 203 | 210 |
} |
| 204 |
- if (trackFlags[TUF_PAN]) |
|
| 211 |
+ if (trackFlags[ToIntegral(TrackUpdateFlag::Pan)]) |
|
| 205 | 212 |
{
|
| 206 | 213 |
this->UpdatePan(trk); |
| 207 |
- this->flags.set(CF_UPDPAN); |
|
| 214 |
+ this->flags.set(ToIntegral(ChannelFlag::UpdatePan)); |
|
| 208 | 215 |
} |
| 209 |
- if (trackFlags[TUF_TIMER]) |
|
| 216 |
+ if (trackFlags[ToIntegral(TrackUpdateFlag::Timer)]) |
|
| 210 | 217 |
{
|
| 211 | 218 |
this->UpdateTune(trk); |
| 212 |
- this->flags.set(CF_UPDTMR); |
|
| 219 |
+ this->flags.set(ToIntegral(ChannelFlag::UpdateTimer)); |
|
| 213 | 220 |
} |
| 214 |
- if (trackFlags[TUF_MOD]) |
|
| 221 |
+ if (trackFlags[ToIntegral(TrackUpdateFlag::Modulation)]) |
|
| 215 | 222 |
{
|
| 216 | 223 |
int oldType = this->modType; |
| 217 | 224 |
int newType = trk.modType; |
| 218 | 225 |
this->UpdateMod(trk); |
| 219 | 226 |
if (oldType != newType) |
| 220 | 227 |
{
|
| 221 |
- this->flags.set(getModFlag(oldType)); |
|
| 222 |
- this->flags.set(getModFlag(newType)); |
|
| 228 |
+ this->flags.set(ToIntegral(getModFlag(oldType))); |
|
| 229 |
+ this->flags.set(ToIntegral(getModFlag(newType))); |
|
| 223 | 230 |
} |
| 224 | 231 |
} |
| 225 | 232 |
} |
| 226 | 233 |
|
| 227 |
-static const uint16_t getpitchtbl[] = |
|
| 234 |
+static const std::uint16_t getpitchtbl[] = |
|
| 228 | 235 |
{
|
| 229 | 236 |
0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F, |
| 230 | 237 |
0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D, |
| ... | ... |
@@ -324,7 +331,7 @@ static const uint16_t getpitchtbl[] = |
| 324 | 331 |
0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A |
| 325 | 332 |
}; |
| 326 | 333 |
|
| 327 |
-static const uint8_t getvoltbl[] = |
|
| 334 |
+static const std::uint8_t getvoltbl[] = |
|
| 328 | 335 |
{
|
| 329 | 336 |
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| 330 | 337 |
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, |
| ... | ... |
@@ -375,7 +382,7 @@ static const uint8_t getvoltbl[] = |
| 375 | 382 |
}; |
| 376 | 383 |
|
| 377 | 384 |
// This function was obtained through disassembly of Ninty's sound driver |
| 378 |
-static inline uint16_t Timer_Adjust(uint16_t basetmr, int pitch) |
|
| 385 |
+static inline std::uint16_t Timer_Adjust(std::uint16_t basetmr, int pitch) |
|
| 379 | 386 |
{
|
| 380 | 387 |
int shift = 0; |
| 381 | 388 |
pitch = -pitch; |
| ... | ... |
@@ -392,7 +399,7 @@ static inline uint16_t Timer_Adjust(uint16_t basetmr, int pitch) |
| 392 | 399 |
pitch -= 0x300; |
| 393 | 400 |
} |
| 394 | 401 |
|
| 395 |
- uint64_t tmr = static_cast<uint64_t>(basetmr) * (static_cast<uint32_t>(getpitchtbl[pitch]) + 0x10000); |
|
| 402 |
+ std::uint64_t tmr = static_cast<std::uint64_t>(basetmr) * (static_cast<std::uint32_t>(getpitchtbl[pitch]) + 0x10000); |
|
| 396 | 403 |
shift -= 16; |
| 397 | 404 |
if (shift <= 0) |
| 398 | 405 |
tmr >>= -shift; |
| ... | ... |
@@ -409,7 +416,7 @@ static inline uint16_t Timer_Adjust(uint16_t basetmr, int pitch) |
| 409 | 416 |
return 0x10; |
| 410 | 417 |
if (tmr > 0xFFFF) |
| 411 | 418 |
return 0xFFFF; |
| 412 |
- return static_cast<uint16_t>(tmr); |
|
| 419 |
+ return static_cast<std::uint16_t>(tmr); |
|
| 413 | 420 |
} |
| 414 | 421 |
|
| 415 | 422 |
static inline int calcVolDivShift(int x) |
| ... | ... |
@@ -427,35 +434,35 @@ static inline int calcVolDivShift(int x) |
| 427 | 434 |
void Channel::Update() |
| 428 | 435 |
{
|
| 429 | 436 |
// Kill active channels that aren't physically active |
| 430 |
- if (this->state > CS_START && !this->reg.enable) |
|
| 437 |
+ if (this->state > ChannelState::Start && !this->reg.enable) |
|
| 431 | 438 |
{
|
| 432 | 439 |
this->Kill(); |
| 433 | 440 |
return; |
| 434 | 441 |
} |
| 435 | 442 |
|
| 436 |
- bool bNotInSustain = this->state != CS_SUSTAIN; |
|
| 437 |
- bool bInStart = this->state == CS_START; |
|
| 443 |
+ bool bNotInSustain = this->state != ChannelState::Sustain; |
|
| 444 |
+ bool bInStart = this->state == ChannelState::Start; |
|
| 438 | 445 |
bool bPitchSweep = this->sweepPitch && this->sweepLen && this->sweepCnt <= this->sweepLen; |
| 439 | 446 |
bool bModulation = !!this->modDepth; |
| 440 |
- bool bVolNeedUpdate = this->flags[CF_UPDVOL] || bNotInSustain; |
|
| 441 |
- bool bPanNeedUpdate = this->flags[CF_UPDPAN] || bInStart; |
|
| 442 |
- bool bTmrNeedUpdate = this->flags[CF_UPDTMR] || bInStart || bPitchSweep; |
|
| 447 |
+ bool bVolNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdateVolume)] || bNotInSustain; |
|
| 448 |
+ bool bPanNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdatePan)] || bInStart; |
|
| 449 |
+ bool bTmrNeedUpdate = this->flags[ToIntegral(ChannelFlag::UpdateTimer)] || bInStart || bPitchSweep; |
|
| 443 | 450 |
int modParam = 0; |
| 444 | 451 |
|
| 445 | 452 |
switch (this->state) |
| 446 | 453 |
{
|
| 447 |
- case CS_NONE: |
|
| 454 |
+ case ChannelState::None: |
|
| 448 | 455 |
return; |
| 449 |
- case CS_START: |
|
| 456 |
+ case ChannelState::Start: |
|
| 450 | 457 |
this->reg.ClearControlRegister(); |
| 451 | 458 |
this->reg.source = this->tempReg.SOURCE; |
| 452 | 459 |
this->reg.loopStart = this->tempReg.REPEAT_POINT; |
| 453 | 460 |
this->reg.length = this->tempReg.LENGTH; |
| 454 | 461 |
this->reg.totalLength = this->reg.loopStart + this->reg.length; |
| 455 | 462 |
this->ampl = AMPL_THRESHOLD; |
| 456 |
- this->state = CS_ATTACK; |
|
| 463 |
+ this->state = ChannelState::Attack; |
|
| 457 | 464 |
// fallthrough |
| 458 |
- case CS_ATTACK: |
|
| 465 |
+ case ChannelState::Attack: |
|
| 459 | 466 |
{
|
| 460 | 467 |
int newAmpl = this->ampl; |
| 461 | 468 |
int oldAmpl = this->ampl >> 7; |
| ... | ... |
@@ -464,21 +471,21 @@ void Channel::Update() |
| 464 | 471 |
while ((newAmpl >> 7) == oldAmpl); |
| 465 | 472 |
this->ampl = newAmpl; |
| 466 | 473 |
if (!this->ampl) |
| 467 |
- this->state = CS_DECAY; |
|
| 474 |
+ this->state = ChannelState::Decay; |
|
| 468 | 475 |
break; |
| 469 | 476 |
} |
| 470 |
- case CS_DECAY: |
|
| 477 |
+ case ChannelState::Decay: |
|
| 471 | 478 |
{
|
| 472 | 479 |
this->ampl -= static_cast<int>(this->decayRate); |
| 473 | 480 |
int sustLvl = Cnv_Sust(this->sustainLvl) << 7; |
| 474 | 481 |
if (this->ampl <= sustLvl) |
| 475 | 482 |
{
|
| 476 | 483 |
this->ampl = sustLvl; |
| 477 |
- this->state = CS_SUSTAIN; |
|
| 484 |
+ this->state = ChannelState::Sustain; |
|
| 478 | 485 |
} |
| 479 | 486 |
break; |
| 480 | 487 |
} |
| 481 |
- case CS_RELEASE: |
|
| 488 |
+ case ChannelState::Release: |
|
| 482 | 489 |
this->ampl -= static_cast<int>(this->releaseRate); |
| 483 | 490 |
if (this->ampl <= AMPL_THRESHOLD) |
| 484 | 491 |
{
|
| ... | ... |
@@ -511,12 +518,12 @@ void Channel::Update() |
| 511 | 518 |
modParam = Cnv_Sine(this->modCounter >> 8) * this->modRange * this->modDepth; // 7.14 |
| 512 | 519 |
|
| 513 | 520 |
if (this->modType == 1) |
| 514 |
- modParam = static_cast<int64_t>(modParam * 60) >> 14; // vol: adjust range to 6dB = 60cB (no fractional bits) |
|
| 521 |
+ modParam = static_cast<std::int64_t>(modParam * 60) >> 14; // vol: adjust range to 6dB = 60cB (no fractional bits) |
|
| 515 | 522 |
else |
| 516 | 523 |
modParam >>= 8; // tmr/pan: adjust to 7.6 |
| 517 | 524 |
|
| 518 | 525 |
// Update the modulation variables |
| 519 |
- uint32_t counter = this->modCounter + (this->modSpeed << 6); |
|
| 526 |
+ std::uint32_t counter = this->modCounter + (this->modSpeed << 6); |
|
| 520 | 527 |
while (counter >= 0x8000) |
| 521 | 528 |
counter -= 0x8000; |
| 522 | 529 |
this->modCounter = counter; |
| ... | ... |
@@ -531,22 +538,22 @@ void Channel::Update() |
| 531 | 538 |
{
|
| 532 | 539 |
int len = this->sweepLen; |
| 533 | 540 |
int cnt = this->sweepCnt; |
| 534 |
- totalAdj += (static_cast<int64_t>(this->sweepPitch) * (len - cnt)) / len; |
|
| 541 |
+ totalAdj += (static_cast<std::int64_t>(this->sweepPitch) * (len - cnt)) / len; |
|
| 535 | 542 |
if (!this->manualSweep) |
| 536 | 543 |
++this->sweepCnt; |
| 537 | 544 |
} |
| 538 |
- uint16_t tmr = this->tempReg.TIMER; |
|
| 545 |
+ std::uint16_t tmr = this->tempReg.TIMER; |
|
| 539 | 546 |
|
| 540 | 547 |
if (totalAdj) |
| 541 | 548 |
tmr = Timer_Adjust(tmr, totalAdj); |
| 542 | 549 |
this->reg.timer = -tmr; |
| 543 | 550 |
this->reg.sampleIncrease = (ARM7_CLOCK / static_cast<double>(this->ply->sampleRate * 2)) / (0x10000 - this->reg.timer); |
| 544 |
- this->flags.reset(CF_UPDTMR); |
|
| 551 |
+ this->flags.reset(ToIntegral(ChannelFlag::UpdateTimer)); |
|
| 545 | 552 |
} |
| 546 | 553 |
|
| 547 | 554 |
if (bVolNeedUpdate || bPanNeedUpdate) |
| 548 | 555 |
{
|
| 549 |
- uint32_t cr = this->tempReg.CR; |
|
| 556 |
+ std::uint32_t cr = this->tempReg.CR; |
|
| 550 | 557 |
if (bVolNeedUpdate) |
| 551 | 558 |
{
|
| 552 | 559 |
int totalVol = this->ampl >> 7; |
| ... | ... |
@@ -569,7 +576,7 @@ void Channel::Update() |
| 569 | 576 |
|
| 570 | 577 |
this->vol = ((cr & SOUND_VOL(0x7F)) << 4) >> calcVolDivShift((cr & SOUND_VOLDIV(3)) >> 8); |
| 571 | 578 |
|
| 572 |
- this->flags.reset(CF_UPDVOL); |
|
| 579 |
+ this->flags.reset(ToIntegral(ChannelFlag::UpdateVolume)); |
|
| 573 | 580 |
} |
| 574 | 581 |
|
| 575 | 582 |
if (bPanNeedUpdate) |
| ... | ... |
@@ -583,7 +590,7 @@ void Channel::Update() |
| 583 | 590 |
|
| 584 | 591 |
cr &= ~SOUND_PAN(0x7F); |
| 585 | 592 |
cr |= SOUND_PAN(realPan); |
| 586 |
- this->flags.reset(CF_UPDPAN); |
|
| 593 |
+ this->flags.reset(ToIntegral(ChannelFlag::UpdatePan)); |
|
| 587 | 594 |
} |
| 588 | 595 |
|
| 589 | 596 |
this->tempReg.CR = cr; |
| ... | ... |
@@ -591,7 +598,7 @@ void Channel::Update() |
| 591 | 598 |
} |
| 592 | 599 |
} |
| 593 | 600 |
|
| 594 |
-static const int16_t wavedutytbl[8][8] = |
|
| 601 |
+static const std::int16_t wavedutytbl[8][8] = |
|
| 595 | 602 |
{
|
| 596 | 603 |
{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF },
|
| 597 | 604 |
{ -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF },
|
| ... | ... |
@@ -606,14 +613,14 @@ static const int16_t wavedutytbl[8][8] = |
| 606 | 613 |
// Linear interpolation code originally from DeSmuME |
| 607 | 614 |
// Legrange comes from Olli Niemitalo: |
| 608 | 615 |
// http://www.student.oulu.fi/~oniemita/dsp/deip.pdf |
| 609 |
-int32_t Channel::Interpolate() |
|
| 616 |
+std::int32_t Channel::Interpolate() |
|
| 610 | 617 |
{
|
| 611 | 618 |
double ratio = this->reg.samplePosition; |
| 612 |
- ratio -= static_cast<int32_t>(ratio); |
|
| 619 |
+ ratio -= static_cast<std::int32_t>(ratio); |
|
| 613 | 620 |
|
| 614 | 621 |
const auto &data = this->ringBuffer.GetBuffer(); |
| 615 | 622 |
|
| 616 |
- if (this->ply->interpolation == INTERPOLATION_SINC) |
|
| 623 |
+ if (this->ply->interpolation == Interpolation::Sinc) |
|
| 617 | 624 |
{
|
| 618 | 625 |
double kernel[SINC_WIDTH * 2], kernel_sum = 0.0; |
| 619 | 626 |
int i = SINC_WIDTH, shift = static_cast<int>(std::floor(ratio * SINC_RESOLUTION)); |
| ... | ... |
@@ -629,13 +636,13 @@ int32_t Channel::Interpolate() |
| 629 | 636 |
double sum = 0.0; |
| 630 | 637 |
for (i = 0; i < static_cast<int>(SINC_WIDTH * 2); ++i) |
| 631 | 638 |
sum += data[i - static_cast<int>(SINC_WIDTH) + 1] * kernel[i]; |
| 632 |
- return static_cast<int32_t>(sum / kernel_sum); |
|
| 639 |
+ return static_cast<std::int32_t>(sum / kernel_sum); |
|
| 633 | 640 |
} |
| 634 |
- else if (this->ply->interpolation > INTERPOLATION_LINEAR) |
|
| 641 |
+ else if (this->ply->interpolation > Interpolation::Linear) |
|
| 635 | 642 |
{
|
| 636 | 643 |
double c0, c1, c2, c3, c4, c5; |
| 637 | 644 |
|
| 638 |
- if (this->ply->interpolation == INTERPOLATION_6POINTLEGRANGE) |
|
| 645 |
+ if (this->ply->interpolation == Interpolation::SixPointLegrange) |
|
| 639 | 646 |
{
|
| 640 | 647 |
ratio -= 0.5; |
| 641 | 648 |
double even1 = data[-2] + data[3], odd1 = data[-2] - data[3]; |
| ... | ... |
@@ -647,30 +654,30 @@ int32_t Channel::Interpolate() |
| 647 | 654 |
c3 = 1 / 48.0 * odd1 - 13 / 48.0 * odd2 + 17 / 24.0 * odd3; |
| 648 | 655 |
c4 = 1 / 48.0 * even1 - 0.0625 * even2 + 1 / 24.0 * even3; |
| 649 | 656 |
c5 = 1 / 24.0 * odd2 - 1 / 12.0 * odd3 - 1 / 120.0 * odd1; |
| 650 |
- return static_cast<int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0); |
|
| 657 |
+ return static_cast<std::int32_t>(((((c5 * ratio + c4) * ratio + c3) * ratio + c2) * ratio + c1) * ratio + c0); |
|
| 651 | 658 |
} |
| 652 |
- else // INTERPOLATION_4POINTLEAGRANGE |
|
| 659 |
+ else // 4-Point Legrange |
|
| 653 | 660 |
{
|
| 654 | 661 |
c0 = data[0]; |
| 655 | 662 |
c1 = data[1] - 1 / 3.0 * data[-1] - 0.5 * data[0] - 1 / 6.0 * data[2]; |
| 656 | 663 |
c2 = 0.5 * (data[-1] + data[1]) - data[0]; |
| 657 | 664 |
c3 = 1 / 6.0 * (data[2] - data[-1]) + 0.5 * (data[0] - data[1]); |
| 658 |
- return static_cast<int32_t>(((c3 * ratio + c2) * ratio + c1) * ratio + c0); |
|
| 665 |
+ return static_cast<std::int32_t>(((c3 * ratio + c2) * ratio + c1) * ratio + c0); |
|
| 659 | 666 |
} |
| 660 | 667 |
} |
| 661 |
- else // INTERPOLATION_LINEAR |
|
| 662 |
- return static_cast<int32_t>(data[0] + ratio * (data[1] - data[0])); |
|
| 668 |
+ else // Linear |
|
| 669 |
+ return static_cast<std::int32_t>(data[0] + ratio * (data[1] - data[0])); |
|
| 663 | 670 |
} |
| 664 | 671 |
|
| 665 |
-int32_t Channel::GenerateSample() |
|
| 672 |
+std::int32_t Channel::GenerateSample() |
|
| 666 | 673 |
{
|
| 667 | 674 |
if (this->reg.samplePosition < 0) |
| 668 | 675 |
return 0; |
| 669 | 676 |
|
| 670 | 677 |
if (this->reg.format != 3) |
| 671 | 678 |
{
|
| 672 |
- if (this->ply->interpolation == INTERPOLATION_NONE) |
|
| 673 |
- return this->reg.source->dataptr[static_cast<uint32_t>(this->reg.samplePosition)]; |
|
| 679 |
+ if (this->ply->interpolation == Interpolation::None) |
|
| 680 |
+ return this->reg.source->dataptr[static_cast<std::uint32_t>(this->reg.samplePosition)]; |
|
| 674 | 681 |
else |
| 675 | 682 |
return this->Interpolate(); |
| 676 | 683 |
} |
| ... | ... |
@@ -679,13 +686,13 @@ int32_t Channel::GenerateSample() |
| 679 | 686 |
if (this->chnId < 8) |
| 680 | 687 |
return 0; |
| 681 | 688 |
else if (this->chnId < 14) |
| 682 |
- return wavedutytbl[this->reg.waveDuty][static_cast<uint32_t>(this->reg.samplePosition) & 0x7]; |
|
| 689 |
+ return wavedutytbl[this->reg.waveDuty][static_cast<std::uint32_t>(this->reg.samplePosition) & 0x7]; |
|
| 683 | 690 |
else |
| 684 | 691 |
{
|
| 685 |
- if (this->reg.psgLastCount != static_cast<uint32_t>(this->reg.samplePosition)) |
|
| 692 |
+ if (this->reg.psgLastCount != static_cast<std::uint32_t>(this->reg.samplePosition)) |
|
| 686 | 693 |
{
|
| 687 |
- uint32_t max = static_cast<uint32_t>(this->reg.samplePosition); |
|
| 688 |
- for (uint32_t i = this->reg.psgLastCount; i < max; ++i) |
|
| 694 |
+ std::uint32_t max = static_cast<std::uint32_t>(this->reg.samplePosition); |
|
| 695 |
+ for (std::uint32_t i = this->reg.psgLastCount; i < max; ++i) |
|
| 689 | 696 |
{
|
| 690 | 697 |
if (this->reg.psgX & 0x1) |
| 691 | 698 |
{
|
| ... | ... |
@@ -699,7 +706,7 @@ int32_t Channel::GenerateSample() |
| 699 | 706 |
} |
| 700 | 707 |
} |
| 701 | 708 |
|
| 702 |
- this->reg.psgLastCount = static_cast<uint32_t>(this->reg.samplePosition); |
|
| 709 |
+ this->reg.psgLastCount = static_cast<std::uint32_t>(this->reg.samplePosition); |
|
| 703 | 710 |
} |
| 704 | 711 |
|
| 705 | 712 |
return this->reg.psgLast; |
| ... | ... |
@@ -717,17 +724,17 @@ void Channel::IncrementSample() |
| 717 | 724 |
{
|
| 718 | 725 |
this->ringBuffer.Clear(); |
| 719 | 726 |
this->ringBuffer.bufferPos += SINC_WIDTH + 1; |
| 720 |
- auto preData = std::vector<int16_t>(SINC_WIDTH + 1, this->reg.source->dataptr[0]); |
|
| 727 |
+ auto preData = std::vector<std::int16_t>(SINC_WIDTH + 1, this->reg.source->dataptr[0]); |
|
| 721 | 728 |
this->ringBuffer.PushSamples(&preData[0], SINC_WIDTH + 1); |
| 722 | 729 |
if (this->reg.totalLength < SINC_WIDTH + 1) |
| 723 | 730 |
{
|
| 724 | 731 |
this->ringBuffer.PushSamples(&this->reg.source->dataptr[0], this->reg.totalLength); |
| 725 | 732 |
if (this->reg.repeatMode == 1) |
| 726 | 733 |
{
|
| 727 |
- size_t samplesLeft = SINC_WIDTH + 1 - this->reg.totalLength; |
|
| 734 |
+ std::size_t samplesLeft = SINC_WIDTH + 1 - this->reg.totalLength; |
|
| 728 | 735 |
while (samplesLeft) |
| 729 | 736 |
{
|
| 730 |
- size_t samplesToPush = std::min(samplesLeft, this->reg.length); |
|
| 737 |
+ std::size_t samplesToPush = std::min(samplesLeft, this->reg.length); |
|
| 731 | 738 |
this->ringBuffer.PushSamples(&this->reg.source->dataptr[this->reg.loopStart], samplesToPush); |
| 732 | 739 |
samplesLeft -= samplesToPush; |
| 733 | 740 |
} |
| ... | ... |
@@ -738,8 +745,8 @@ void Channel::IncrementSample() |
| 738 | 745 |
} |
| 739 | 746 |
if (this->reg.samplePosition >= 0) |
| 740 | 747 |
{
|
| 741 |
- uint32_t loc = static_cast<uint32_t>(this->reg.samplePosition) + SINC_WIDTH + 1; |
|
| 742 |
- uint32_t newloc = static_cast<uint32_t>(samplePosition) + SINC_WIDTH + 1; |
|
| 748 |
+ std::uint32_t loc = static_cast<std::uint32_t>(this->reg.samplePosition) + SINC_WIDTH + 1; |
|
| 749 |
+ std::uint32_t newloc = static_cast<std::uint32_t>(samplePosition) + SINC_WIDTH + 1; |
|
| 743 | 750 |
|
| 744 | 751 |
if (this->reg.repeatMode == 1) |
| 745 | 752 |
{
|
| ... | ... |
@@ -14,9 +14,13 @@ |
| 14 | 14 |
|
| 15 | 15 |
#include <algorithm> |
| 16 | 16 |
#include <bitset> |
| 17 |
+#include <cstddef> |
|
| 17 | 18 |
#include <cstdint> |
| 18 |
-#include "SWAV.h" |
|
| 19 |
-#include "Track.h" |
|
| 19 |
+#include "common.h" |
|
| 20 |
+#include "consts.h" |
|
| 21 |
+ |
|
| 22 |
+struct SWAV; |
|
| 23 |
+struct Track; |
|
| 20 | 24 |
|
| 21 | 25 |
/* |
| 22 | 26 |
* This structure is meant to be similar to what is stored in the actual |
| ... | ... |
@@ -27,41 +31,41 @@ |
| 27 | 31 |
struct NDSSoundRegister |
| 28 | 32 |
{
|
| 29 | 33 |
// Control Register |
| 30 |
- uint8_t volumeMul; |
|
| 31 |
- uint8_t volumeDiv; |
|
| 32 |
- uint8_t panning; |
|
| 33 |
- uint8_t waveDuty; |
|
| 34 |
- uint8_t repeatMode; |
|
| 35 |
- uint8_t format; |
|
| 34 |
+ std::uint8_t volumeMul; |
|
| 35 |
+ std::uint8_t volumeDiv; |
|
| 36 |
+ std::uint8_t panning; |
|
| 37 |
+ std::uint8_t waveDuty; |
|
| 38 |
+ std::uint8_t repeatMode; |
|
| 39 |
+ std::uint8_t format; |
|
| 36 | 40 |
bool enable; |
| 37 | 41 |
|
| 38 | 42 |
// Data Source Register |
| 39 | 43 |
const SWAV *source; |
| 40 | 44 |
|
| 41 | 45 |
// Timer Register |
| 42 |
- uint16_t timer; |
|
| 46 |
+ std::uint16_t timer; |
|
| 43 | 47 |
|
| 44 | 48 |
// PSG Handling, not a DS register |
| 45 |
- uint16_t psgX; |
|
| 46 |
- int16_t psgLast; |
|
| 47 |
- uint32_t psgLastCount; |
|
| 49 |
+ std::uint16_t psgX; |
|
| 50 |
+ std::int16_t psgLast; |
|
| 51 |
+ std::uint32_t psgLastCount; |
|
| 48 | 52 |
|
| 49 | 53 |
// The following are taken from DeSmuME |
| 50 | 54 |
double samplePosition; |
| 51 | 55 |
double sampleIncrease; |
| 52 | 56 |
|
| 53 | 57 |
// Loopstart Register |
| 54 |
- uint32_t loopStart; |
|
| 58 |
+ std::uint32_t loopStart; |
|
| 55 | 59 |
|
| 56 | 60 |
// Length Register |
| 57 |
- uint32_t length; |
|
| 61 |
+ std::uint32_t length; |
|
| 58 | 62 |
|
| 59 |
- uint32_t totalLength; |
|
| 63 |
+ std::uint32_t totalLength; |
|
| 60 | 64 |
|
| 61 | 65 |
NDSSoundRegister(); |
| 62 | 66 |
|
| 63 | 67 |
void ClearControlRegister(); |
| 64 |
- void SetControlRegister(uint32_t reg); |
|
| 68 |
+ void SetControlRegister(std::uint32_t reg); |
|
| 65 | 69 |
}; |
| 66 | 70 |
|
| 67 | 71 |
/* |
| ... | ... |
@@ -72,10 +76,10 @@ struct NDSSoundRegister |
| 72 | 76 |
*/ |
| 73 | 77 |
struct TempSndReg |
| 74 | 78 |
{
|
| 75 |
- uint32_t CR; |
|
| 79 |
+ std::uint32_t CR; |
|
| 76 | 80 |
const SWAV *SOURCE; |
| 77 |
- uint16_t TIMER; |
|
| 78 |
- uint32_t REPEAT_POINT, LENGTH; |
|
| 81 |
+ std::uint16_t TIMER; |
|
| 82 |
+ std::uint32_t REPEAT_POINT, LENGTH; |
|
| 79 | 83 |
|
| 80 | 84 |
TempSndReg(); |
| 81 | 85 |
}; |
| ... | ... |
@@ -95,10 +99,10 @@ struct Player; |
| 95 | 99 |
* accessing the SWAVs samples and also doesn't use 0s before the |
| 96 | 100 |
* start of the SWAV or use 0s after the end of a non-looping SWAV. |
| 97 | 101 |
*/ |
| 98 |
-template<size_t N> struct RingBuffer |
|
| 102 |
+template<std::size_t N> struct RingBuffer |
|
| 99 | 103 |
{
|
| 100 |
- int16_t buffer[N * 2]; |
|
| 101 |
- size_t bufferPos, getPos; |
|
| 104 |
+ std::int16_t buffer[N * 2]; |
|
| 105 |
+ std::size_t bufferPos, getPos; |
|
| 102 | 106 |
|
| 103 | 107 |
RingBuffer() : bufferPos(N / 2), getPos(N / 2) |
| 104 | 108 |
{
|
| ... | ... |
@@ -109,7 +113,7 @@ template<size_t N> struct RingBuffer |
| 109 | 113 |
std::fill_n(&this->buffer[0], N * 2, 0); |
| 110 | 114 |
this->bufferPos = this->getPos = N / 2; |
| 111 | 115 |
} |
| 112 |
- void PushSample(int16_t sample) |
|
| 116 |
+ void PushSample(std::int16_t sample) |
|
| 113 | 117 |
{
|
| 114 | 118 |
this->buffer[this->bufferPos] = sample; |
| 115 | 119 |
if (this->bufferPos >= N) |
| ... | ... |
@@ -120,23 +124,23 @@ template<size_t N> struct RingBuffer |
| 120 | 124 |
if (this->bufferPos >= N * 3 / 2) |
| 121 | 125 |
this->bufferPos -= N; |
| 122 | 126 |
} |
| 123 |
- void PushSamples(const int16_t *samples, size_t size) |
|
| 127 |
+ void PushSamples(const std::int16_t *samples, std::size_t size) |
|
| 124 | 128 |
{
|
| 125 | 129 |
if (this->bufferPos + size > N * 3 / 2) |
| 126 | 130 |
{
|
| 127 |
- size_t free = N * 3 / 2 - this->bufferPos; |
|
| 131 |
+ std::size_t free = N * 3 / 2 - this->bufferPos; |
|
| 128 | 132 |
std::copy_n(&samples[0], free, &this->buffer[this->bufferPos]); |
| 129 | 133 |
std::copy(&samples[free], &samples[size], &this->buffer[N / 2]); |
| 130 | 134 |
} |
| 131 | 135 |
else |
| 132 | 136 |
std::copy_n(&samples[0], size, &this->buffer[this->bufferPos]); |
| 133 |
- size_t rightFree = this->bufferPos < N ? N - this->bufferPos : 0; |
|
| 137 |
+ std::size_t rightFree = this->bufferPos < N ? N - this->bufferPos : 0; |
|
| 134 | 138 |
if (rightFree < size) |
| 135 | 139 |
{
|
| 136 | 140 |
if (!rightFree) |
| 137 | 141 |
{
|
| 138 |
- size_t leftStart = this->bufferPos - N; |
|
| 139 |
- size_t leftSize = std::min(N / 2 - leftStart, size); |
|
| 142 |
+ std::size_t leftStart = this->bufferPos - N; |
|
| 143 |
+ std::size_t leftSize = std::min(N / 2 - leftStart, size); |
|
| 140 | 144 |
std::copy_n(&samples[0], leftSize, &this->buffer[leftStart]); |
| 141 | 145 |
if (leftSize < size) |
| 142 | 146 |
std::copy(&samples[leftSize], &samples[size], &this->buffer[N * 3 / 2]); |
| ... | ... |
@@ -153,7 +157,7 @@ template<size_t N> struct RingBuffer |
| 153 | 157 |
if (this->bufferPos >= N * 3 / 2) |
| 154 | 158 |
this->bufferPos -= N; |
| 155 | 159 |
} |
| 156 |
- const int16_t *GetBuffer() const |
|
| 160 |
+ const std::int16_t *GetBuffer() const |
|
| 157 | 161 |
{
|
| 158 | 162 |
return &this->buffer[this->getPos]; |
| 159 | 163 |
} |
| ... | ... |
@@ -167,35 +171,35 @@ template<size_t N> struct RingBuffer |
| 167 | 171 |
|
| 168 | 172 |
struct Channel |
| 169 | 173 |
{
|
| 170 |
- int8_t chnId; |
|
| 174 |
+ std::int8_t chnId; |
|
| 171 | 175 |
|
| 172 | 176 |
TempSndReg tempReg; |
| 173 |
- uint8_t state; |
|
| 174 |
- int8_t trackId; // -1 = none |
|
| 175 |
- uint8_t prio; |
|
| 177 |
+ ChannelState state; |
|
| 178 |
+ std::int8_t trackId; // -1 = none |
|
| 179 |
+ std::uint8_t prio; |
|
| 176 | 180 |
bool manualSweep; |
| 177 | 181 |
|
| 178 |
- std::bitset<CF_BITS> flags; |
|
| 179 |
- int8_t pan; // -64 .. 63 |
|
| 180 |
- int16_t extAmpl; |
|
| 182 |
+ std::bitset<ToIntegral(ChannelFlag::Bits)> flags; |
|
| 183 |
+ std::int8_t pan; // -64 .. 63 |
|
| 184 |
+ std::int16_t extAmpl; |
|
| 181 | 185 |
|
| 182 |
- int16_t velocity; |
|
| 183 |
- int8_t extPan; |
|
| 184 |
- uint8_t key; |
|
| 186 |
+ std::int16_t velocity; |
|
| 187 |
+ std::int8_t extPan; |
|
| 188 |
+ std::uint8_t key; |
|
| 185 | 189 |
|
| 186 | 190 |
int ampl; // 7 fractionary bits |
| 187 | 191 |
int extTune; // in 64ths of a semitone |
| 188 | 192 |
|
| 189 |
- uint8_t orgKey; |
|
| 193 |
+ std::uint8_t orgKey; |
|
| 190 | 194 |
|
| 191 |
- uint8_t modType, modSpeed, modDepth, modRange; |
|
| 192 |
- uint16_t modDelay, modDelayCnt, modCounter; |
|
| 195 |
+ std::uint8_t modType, modSpeed, modDepth, modRange; |
|
| 196 |
+ std::uint16_t modDelay, modDelayCnt, modCounter; |
|
| 193 | 197 |
|
| 194 |
- uint32_t sweepLen, sweepCnt; |
|
| 195 |
- int16_t sweepPitch; |
|
| 198 |
+ std::uint32_t sweepLen, sweepCnt; |
|
| 199 |
+ std::int16_t sweepPitch; |
|
| 196 | 200 |
|
| 197 |
- uint8_t attackLvl, sustainLvl; |
|
| 198 |
- uint16_t decayRate, releaseRate; |
|
| 201 |
+ std::uint8_t attackLvl, sustainLvl; |
|
| 202 |
+ std::uint16_t decayRate, releaseRate; |
|
| 199 | 203 |
|
| 200 | 204 |
/* |
| 201 | 205 |
* These were originally global variables in FeOS Sound System, but |
| ... | ... |
@@ -203,7 +207,7 @@ struct Channel |
| 203 | 207 |
* into this class. |
| 204 | 208 |
*/ |
| 205 | 209 |
int noteLength; |
| 206 |
- uint16_t vol; |
|
| 210 |
+ std::uint16_t vol; |
|
| 207 | 211 |
|
| 208 | 212 |
const Player *ply; |
| 209 | 213 |
NDSSoundRegister reg; |
| ... | ... |
@@ -234,7 +238,7 @@ struct Channel |
| 234 | 238 |
void Kill(); |
| 235 | 239 |
void UpdateTrack(); |
| 236 | 240 |
void Update(); |
| 237 |
- int32_t Interpolate(); |
|
| 238 |
- int32_t GenerateSample(); |
|
| 241 |
+ std::int32_t Interpolate(); |
|
| 242 |
+ std::int32_t GenerateSample(); |
|
| 239 | 243 |
void IncrementSample(); |
| 240 | 244 |
}; |
| ... | ... |
@@ -7,7 +7,9 @@ |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 |
+#include <cstdint> |
|
| 10 | 11 |
#include "FATSection.h" |
| 12 |
+#include "common.h" |
|
| 11 | 13 |
|
| 12 | 14 |
FATRecord::FATRecord() : offset(0) |
| 13 | 15 |
{
|
| ... | ... |
@@ -15,9 +17,9 @@ FATRecord::FATRecord() : offset(0) |
| 15 | 17 |
|
| 16 | 18 |
void FATRecord::Read(PseudoFile &file) |
| 17 | 19 |
{
|
| 18 |
- this->offset = file.ReadLE<uint32_t>(); |
|
| 19 |
- file.ReadLE<uint32_t>(); // size |
|
| 20 |
- uint32_t reserved[2]; |
|
| 20 |
+ this->offset = file.ReadLE<std::uint32_t>(); |
|
| 21 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 22 |
+ std::uint32_t reserved[2]; |
|
| 21 | 23 |
file.ReadLE(reserved); |
| 22 | 24 |
} |
| 23 | 25 |
|
| ... | ... |
@@ -27,13 +29,13 @@ FATSection::FATSection() : records() |
| 27 | 29 |
|
| 28 | 30 |
void FATSection::Read(PseudoFile &file) |
| 29 | 31 |
{
|
| 30 |
- int8_t type[4]; |
|
| 32 |
+ std::int8_t type[4]; |
|
| 31 | 33 |
file.ReadLE(type); |
| 32 | 34 |
if (!VerifyHeader(type, "FAT ")) |
| 33 | 35 |
throw std::runtime_error("SDAT FAT Section invalid");
|
| 34 |
- file.ReadLE<uint32_t>(); // size |
|
| 35 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 36 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 37 |
+ std::uint32_t count = file.ReadLE<std::uint32_t>(); |
|
| 36 | 38 |
this->records.resize(count); |
| 37 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 39 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 38 | 40 |
this->records[i].Read(file); |
| 39 | 41 |
} |
| ... | ... |
@@ -6,7 +6,10 @@ |
| 6 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 |
+#include <algorithm> |
|
| 10 |
+#include <cstdint> |
|
| 9 | 11 |
#include "INFOEntry.h" |
| 12 |
+#include "common.h" |
|
| 10 | 13 |
|
| 11 | 14 |
INFOEntrySEQ::INFOEntrySEQ() : fileID(0), bank(0), vol(0), ply(0) |
| 12 | 15 |
{
|
| ... | ... |
@@ -14,14 +17,14 @@ INFOEntrySEQ::INFOEntrySEQ() : fileID(0), bank(0), vol(0), ply(0) |
| 14 | 17 |
|
| 15 | 18 |
void INFOEntrySEQ::Read(PseudoFile &file) |
| 16 | 19 |
{
|
| 17 |
- this->fileID = file.ReadLE<uint32_t>(); |
|
| 18 |
- this->bank = file.ReadLE<uint16_t>(); |
|
| 19 |
- this->vol = file.ReadLE<uint8_t>(); |
|
| 20 |
+ this->fileID = file.ReadLE<std::uint32_t>(); |
|
| 21 |
+ this->bank = file.ReadLE<std::uint16_t>(); |
|
| 22 |
+ this->vol = file.ReadLE<std::uint8_t>(); |
|
| 20 | 23 |
if (!this->vol) |
| 21 | 24 |
this->vol = 0x7F; // Prevents nothing for volume |
| 22 |
- file.ReadLE<uint8_t>(); // cpr |
|
| 23 |
- file.ReadLE<uint8_t>(); // ppr |
|
| 24 |
- this->ply = file.ReadLE<uint8_t>(); |
|
| 25 |
+ file.ReadLE<std::uint8_t>(); // cpr |
|
| 26 |
+ file.ReadLE<std::uint8_t>(); // ppr |
|
| 27 |
+ this->ply = file.ReadLE<std::uint8_t>(); |
|
| 25 | 28 |
} |
| 26 | 29 |
|
| 27 | 30 |
INFOEntryBANK::INFOEntryBANK() : fileID(0) |
| ... | ... |
@@ -31,7 +34,7 @@ INFOEntryBANK::INFOEntryBANK() : fileID(0) |
| 31 | 34 |
|
| 32 | 35 |
void INFOEntryBANK::Read(PseudoFile &file) |
| 33 | 36 |
{
|
| 34 |
- this->fileID = file.ReadLE<uint32_t>(); |
|
| 37 |
+ this->fileID = file.ReadLE<std::uint32_t>(); |
|
| 35 | 38 |
file.ReadLE(this->waveArc); |
| 36 | 39 |
} |
| 37 | 40 |
|
| ... | ... |
@@ -41,7 +44,7 @@ INFOEntryWAVEARC::INFOEntryWAVEARC() : fileID(0) |
| 41 | 44 |
|
| 42 | 45 |
void INFOEntryWAVEARC::Read(PseudoFile &file) |
| 43 | 46 |
{
|
| 44 |
- this->fileID = file.ReadLE<uint32_t>(); |
|
| 47 |
+ this->fileID = file.ReadLE<std::uint32_t>(); |
|
| 45 | 48 |
} |
| 46 | 49 |
|
| 47 | 50 |
INFOEntryPLAYER::INFOEntryPLAYER() : channelMask(0) |
| ... | ... |
@@ -50,7 +53,7 @@ INFOEntryPLAYER::INFOEntryPLAYER() : channelMask(0) |
| 50 | 53 |
|
| 51 | 54 |
void INFOEntryPLAYER::Read(PseudoFile &file) |
| 52 | 55 |
{
|
| 53 |
- file.ReadLE<uint16_t>(); // maxSeqs |
|
| 54 |
- this->channelMask = file.ReadLE<uint16_t>(); |
|
| 55 |
- file.ReadLE<uint32_t>(); // heapSize |
|
| 56 |
+ file.ReadLE<std::uint16_t>(); // maxSeqs |
|
| 57 |
+ this->channelMask = file.ReadLE<std::uint16_t>(); |
|
| 58 |
+ file.ReadLE<std::uint32_t>(); // heapSize |
|
| 56 | 59 |
} |
| ... | ... |
@@ -8,7 +8,9 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include "common.h" |
|
| 11 |
+#include <cstdint> |
|
| 12 |
+ |
|
| 13 |
+struct PseudoFile; |
|
| 12 | 14 |
|
| 13 | 15 |
struct INFOEntry |
| 14 | 16 |
{
|
| ... | ... |
@@ -21,10 +23,10 @@ struct INFOEntry |
| 21 | 23 |
|
| 22 | 24 |
struct INFOEntrySEQ : INFOEntry |
| 23 | 25 |
{
|
| 24 |
- uint32_t fileID; |
|
| 25 |
- uint16_t bank; |
|
| 26 |
- uint8_t vol; |
|
| 27 |
- uint8_t ply; |
|
| 26 |
+ std::uint32_t fileID; |
|
| 27 |
+ std::uint16_t bank; |
|
| 28 |
+ std::uint8_t vol; |
|
| 29 |
+ std::uint8_t ply; |
|
| 28 | 30 |
|
| 29 | 31 |
INFOEntrySEQ(); |
| 30 | 32 |
|
| ... | ... |
@@ -33,8 +35,8 @@ struct INFOEntrySEQ : INFOEntry |
| 33 | 35 |
|
| 34 | 36 |
struct INFOEntryBANK : INFOEntry |
| 35 | 37 |
{
|
| 36 |
- uint32_t fileID; |
|
| 37 |
- uint16_t waveArc[4]; |
|
| 38 |
+ std::uint32_t fileID; |
|
| 39 |
+ std::uint16_t waveArc[4]; |
|
| 38 | 40 |
|
| 39 | 41 |
INFOEntryBANK(); |
| 40 | 42 |
|
| ... | ... |
@@ -43,7 +45,7 @@ struct INFOEntryBANK : INFOEntry |
| 43 | 45 |
|
| 44 | 46 |
struct INFOEntryWAVEARC : INFOEntry |
| 45 | 47 |
{
|
| 46 |
- uint32_t fileID; |
|
| 48 |
+ std::uint32_t fileID; |
|
| 47 | 49 |
|
| 48 | 50 |
INFOEntryWAVEARC(); |
| 49 | 51 |
|
| ... | ... |
@@ -52,7 +54,7 @@ struct INFOEntryWAVEARC : INFOEntry |
| 52 | 54 |
|
| 53 | 55 |
struct INFOEntryPLAYER : INFOEntry |
| 54 | 56 |
{
|
| 55 |
- uint16_t channelMask; |
|
| 57 |
+ std::uint16_t channelMask; |
|
| 56 | 58 |
|
| 57 | 59 |
INFOEntryPLAYER(); |
| 58 | 60 |
|
| ... | ... |
@@ -8,18 +8,20 @@ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 | 10 |
#include <vector> |
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "INFOSection.h" |
| 13 |
+#include "common.h" |
|
| 12 | 14 |
|
| 13 | 15 |
template<typename T> INFORecord<T>::INFORecord() : entries() |
| 14 | 16 |
{
|
| 15 | 17 |
} |
| 16 | 18 |
|
| 17 |
-template<typename T> void INFORecord<T>::Read(PseudoFile &file, uint32_t startOffset) |
|
| 19 |
+template<typename T> void INFORecord<T>::Read(PseudoFile &file, std::uint32_t startOffset) |
|
| 18 | 20 |
{
|
| 19 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 20 |
- auto entryOffsets = std::vector<uint32_t>(count); |
|
| 21 |
+ std::uint32_t count = file.ReadLE<std::uint32_t>(); |
|
| 22 |
+ auto entryOffsets = std::vector<std::uint32_t>(count); |
|
| 21 | 23 |
file.ReadLE(entryOffsets); |
| 22 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 24 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 23 | 25 |
if (entryOffsets[i]) |
| 24 | 26 |
{
|
| 25 | 27 |
file.pos = startOffset + entryOffsets[i]; |
| ... | ... |
@@ -34,13 +36,13 @@ INFOSection::INFOSection() : SEQrecord(), BANKrecord(), WAVEARCrecord(), PLAYERr |
| 34 | 36 |
|
| 35 | 37 |
void INFOSection::Read(PseudoFile &file) |
| 36 | 38 |
{
|
| 37 |
- uint32_t startOfINFO = file.pos; |
|
| 38 |
- int8_t type[4]; |
|
| 39 |
+ std::uint32_t startOfINFO = file.pos; |
|
| 40 |
+ std::int8_t type[4]; |
|
| 39 | 41 |
file.ReadLE(type); |
| 40 | 42 |
if (!VerifyHeader(type, "INFO")) |
| 41 | 43 |
throw std::runtime_error("SDAT INFO Section invalid");
|
| 42 |
- file.ReadLE<uint32_t>(); // size |
|
| 43 |
- uint32_t recordOffsets[8]; |
|
| 44 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 45 |
+ std::uint32_t recordOffsets[8]; |
|
| 44 | 46 |
file.ReadLE(recordOffsets); |
| 45 | 47 |
if (recordOffsets[REC_SEQ]) |
| 46 | 48 |
{
|
| ... | ... |
@@ -9,16 +9,18 @@ |
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 | 11 |
#include <map> |
| 12 |
+#include <cstdint> |
|
| 12 | 13 |
#include "INFOEntry.h" |
| 13 |
-#include "common.h" |
|
| 14 |
+ |
|
| 15 |
+struct PseudoFile; |
|
| 14 | 16 |
|
| 15 | 17 |
template<typename T> struct INFORecord |
| 16 | 18 |
{
|
| 17 |
- std::map<uint32_t, T> entries; |
|
| 19 |
+ std::map<std::uint32_t, T> entries; |
|
| 18 | 20 |
|
| 19 | 21 |
INFORecord(); |
| 20 | 22 |
|
| 21 |
- void Read(PseudoFile &file, uint32_t startOffset); |
|
| 23 |
+ void Read(PseudoFile &file, std::uint32_t startOffset); |
|
| 22 | 24 |
}; |
| 23 | 25 |
|
| 24 | 26 |
struct INFOSection |
| ... | ... |
@@ -6,8 +6,11 @@ |
| 6 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 |
+#include <algorithm> |
|
| 9 | 10 |
#include <stdexcept> |
| 11 |
+#include <cstdint> |
|
| 10 | 12 |
#include "NDSStdHeader.h" |
| 13 |
+#include "common.h" |
|
| 11 | 14 |
|
| 12 | 15 |
NDSStdHeader::NDSStdHeader() : magic(0) |
| 13 | 16 |
{
|
| ... | ... |
@@ -17,13 +20,13 @@ NDSStdHeader::NDSStdHeader() : magic(0) |
| 17 | 20 |
void NDSStdHeader::Read(PseudoFile &file) |
| 18 | 21 |
{
|
| 19 | 22 |
file.ReadLE(this->type); |
| 20 |
- this->magic = file.ReadLE<uint32_t>(); |
|
| 21 |
- file.ReadLE<uint32_t>(); // file size |
|
| 22 |
- file.ReadLE<uint16_t>(); // structure size |
|
| 23 |
- file.ReadLE<uint16_t>(); // # of blocks |
|
| 23 |
+ this->magic = file.ReadLE<std::uint32_t>(); |
|
| 24 |
+ file.ReadLE<std::uint32_t>(); // file size |
|
| 25 |
+ file.ReadLE<std::uint16_t>(); // structure size |
|
| 26 |
+ file.ReadLE<std::uint16_t>(); // # of blocks |
|
| 24 | 27 |
} |
| 25 | 28 |
|
| 26 |
-void NDSStdHeader::Verify(const std::string &typeToCheck, uint32_t magicToCheck) |
|
| 29 |
+void NDSStdHeader::Verify(const std::string &typeToCheck, std::uint32_t magicToCheck) |
|
| 27 | 30 |
{
|
| 28 | 31 |
if (!VerifyHeader(this->type, typeToCheck) || this->magic != magicToCheck) |
| 29 | 32 |
throw std::runtime_error("NDS Standard Header for " + typeToCheck + " invalid");
|
| ... | ... |
@@ -8,15 +8,18 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include "common.h" |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <cstdint> |
|
| 13 |
+ |
|
| 14 |
+struct PseudoFile; |
|
| 12 | 15 |
|
| 13 | 16 |
struct NDSStdHeader |
| 14 | 17 |
{
|
| 15 |
- int8_t type[4]; |
|
| 16 |
- uint32_t magic; |
|
| 18 |
+ std::int8_t type[4]; |
|
| 19 |
+ std::uint32_t magic; |
|
| 17 | 20 |
|
| 18 | 21 |
NDSStdHeader(); |
| 19 | 22 |
|
| 20 | 23 |
void Read(PseudoFile &file); |
| 21 |
- void Verify(const std::string &typeToCheck, uint32_t magicToCheck); |
|
| 24 |
+ void Verify(const std::string &typeToCheck, std::uint32_t magicToCheck); |
|
| 22 | 25 |
}; |
| ... | ... |
@@ -7,14 +7,18 @@ |
| 7 | 7 |
* https://github.com/fincs/FSS |
| 8 | 8 |
*/ |
| 9 | 9 |
|
| 10 |
+#include <algorithm> |
|
| 11 |
+#include <cstdint> |
|
| 10 | 12 |
#include "Player.h" |
| 13 |
+#include "SSEQ.h" |
|
| 11 | 14 |
#include "common.h" |
| 15 |
+#include "consts.h" |
|
| 12 | 16 |
|
| 13 | 17 |
Player::Player() : prio(0), nTracks(0), tempo(0), tempoCount(0), tempoRate(0), masterVol(0), sseqVol(0), sseq(nullptr), allowedChannels(0), sampleRate(0), |
| 14 |
- interpolation(INTERPOLATION_NONE) |
|
| 18 |
+ interpolation(Interpolation::None) |
|
| 15 | 19 |
{
|
| 16 | 20 |
std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, 0); |
| 17 |
- for (int8_t i = 0; i < 16; ++i) |
|
| 21 |
+ for (std::int8_t i = 0; i < 16; ++i) |
|
| 18 | 22 |
{
|
| 19 | 23 |
this->channels[i].chnId = i; |
| 20 | 24 |
this->channels[i].ply = this; |
| ... | ... |
@@ -55,7 +59,7 @@ void Player::ClearState() |
| 55 | 59 |
// Original FSS Function: Player_FreeTracks |
| 56 | 60 |
void Player::FreeTracks() |
| 57 | 61 |
{
|
| 58 |
- for (uint8_t i = 0; i < this->nTracks; ++i) |
|
| 62 |
+ for (std::uint8_t i = 0; i < this->nTracks; ++i) |
|
| 59 | 63 |
this->tracks[this->trackIds[i]].Free(); |
| 60 | 64 |
this->nTracks = 0; |
| 61 | 65 |
} |
| ... | ... |
@@ -64,14 +68,14 @@ void Player::FreeTracks() |
| 64 | 68 |
void Player::Stop(bool bKillSound) |
| 65 | 69 |
{
|
| 66 | 70 |
this->ClearState(); |
| 67 |
- for (uint8_t i = 0; i < this->nTracks; ++i) |
|
| 71 |
+ for (std::uint8_t i = 0; i < this->nTracks; ++i) |
|
| 68 | 72 |
{
|
| 69 |
- uint8_t trackId = this->trackIds[i]; |
|
| 73 |
+ std::uint8_t trackId = this->trackIds[i]; |
|
| 70 | 74 |
this->tracks[trackId].ClearState(); |
| 71 | 75 |
for (int j = 0; j < 16; ++j) |
| 72 | 76 |
{
|
| 73 | 77 |
Channel &chn = this->channels[j]; |
| 74 |
- if (chn.state != CS_NONE && chn.trackId == trackId) |
|
| 78 |
+ if (chn.state != ChannelState::None && chn.trackId == trackId) |
|
| 75 | 79 |
{
|
| 76 | 80 |
if (bKillSound) |
| 77 | 81 |
chn.Kill(); |
| ... | ... |
@@ -84,16 +88,16 @@ void Player::Stop(bool bKillSound) |
| 84 | 88 |
} |
| 85 | 89 |
|
| 86 | 90 |
// Original FSS Function: Chn_Alloc |
| 87 |
-int Player::ChannelAlloc(int type, int priority) |
|
| 91 |
+int Player::ChannelAlloc(ChannelAllocateType type, int priority) |
|
| 88 | 92 |
{
|
| 89 |
- static const uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
|
|
| 90 |
- static const uint8_t psgChnArray[] = { 8, 9, 10, 11, 12, 13 };
|
|
| 91 |
- static const uint8_t noiseChnArray[] = { 14, 15 };
|
|
| 92 |
- static const uint8_t arraySizes[] = { sizeof(pcmChnArray), sizeof(psgChnArray), sizeof(noiseChnArray) };
|
|
| 93 |
- static const uint8_t *const arrayArray[] = { pcmChnArray, psgChnArray, noiseChnArray };
|
|
| 93 |
+ static const std::uint8_t pcmChnArray[] = { 4, 5, 6, 7, 2, 0, 3, 1, 8, 9, 10, 11, 14, 12, 15, 13 };
|
|
| 94 |
+ static const std::uint8_t psgChnArray[] = { 8, 9, 10, 11, 12, 13 };
|
|
| 95 |
+ static const std::uint8_t noiseChnArray[] = { 14, 15 };
|
|
| 96 |
+ static const std::uint8_t arraySizes[] = { sizeof(pcmChnArray), sizeof(psgChnArray), sizeof(noiseChnArray) };
|
|
| 97 |
+ static const std::uint8_t *const arrayArray[] = { pcmChnArray, psgChnArray, noiseChnArray };
|
|
| 94 | 98 |
|
| 95 |
- auto chnArray = arrayArray[type]; |
|
| 96 |
- int arraySize = arraySizes[type]; |
|
| 99 |
+ auto chnArray = arrayArray[ToIntegral(type)]; |
|
| 100 |
+ int arraySize = arraySizes[ToIntegral(type)]; |
|
| 97 | 101 |
|
| 98 | 102 |
int curChnNo = -1; |
| 99 | 103 |
for (int i = 0; i < arraySize; ++i) |
| ... | ... |
@@ -126,10 +130,10 @@ int Player::TrackAlloc() |
| 126 | 130 |
for (int i = 0; i < FSS_MAXTRACKS; ++i) |
| 127 | 131 |
{
|
| 128 | 132 |
Track &thisTrk = this->tracks[i]; |
| 129 |
- if (!thisTrk.state[TS_ALLOCBIT]) |
|
| 133 |
+ if (!thisTrk.state[ToIntegral(TrackState::AllocateBit)]) |
|
| 130 | 134 |
{
|
| 131 | 135 |
thisTrk.Zero(); |
| 132 |
- thisTrk.state.set(TS_ALLOCBIT); |
|
| 136 |
+ thisTrk.state.set(ToIntegral(TrackState::AllocateBit)); |
|
| 133 | 137 |
thisTrk.updateFlags.reset(); |
| 134 | 138 |
return i; |
| 135 | 139 |
} |
| ... | ... |
@@ -143,7 +147,7 @@ void Player::Run() |
| 143 | 147 |
while (this->tempoCount >= 240) |
| 144 | 148 |
{
|
| 145 | 149 |
this->tempoCount -= 240; |
| 146 |
- for (uint8_t i = 0; i < this->nTracks; ++i) |
|
| 150 |
+ for (std::uint8_t i = 0; i < this->nTracks; ++i) |
|
| 147 | 151 |
this->tracks[this->trackIds[i]].Run(); |
| 148 | 152 |
} |
| 149 | 153 |
this->tempoCount += (static_cast<int>(this->tempo) * static_cast<int>(this->tempoRate)) >> 8; |
| ... | ... |
@@ -10,26 +10,29 @@ |
| 10 | 10 |
#pragma once |
| 11 | 11 |
|
| 12 | 12 |
#include <bitset> |
| 13 |
-#include "SSEQ.h" |
|
| 14 |
-#include "Track.h" |
|
| 13 |
+#include <cstdint> |
|
| 15 | 14 |
#include "Channel.h" |
| 15 |
+#include "Track.h" |
|
| 16 | 16 |
#include "consts.h" |
| 17 | 17 |
|
| 18 |
+enum class ChannelAllocateType; |
|
| 19 |
+struct SSEQ; |
|
| 20 |
+ |
|
| 18 | 21 |
struct Player |
| 19 | 22 |
{
|
| 20 |
- uint8_t prio, nTracks; |
|
| 21 |
- uint16_t tempo, tempoCount, tempoRate /* 8.8 fixed point */; |
|
| 22 |
- int16_t masterVol, sseqVol; |
|
| 23 |
+ std::uint8_t prio, nTracks; |
|
| 24 |
+ std::uint16_t tempo, tempoCount, tempoRate /* 8.8 fixed point */; |
|
| 25 |
+ std::int16_t masterVol, sseqVol; |
|
| 23 | 26 |
|
| 24 | 27 |
const SSEQ *sseq; |
| 25 | 28 |
|
| 26 |
- uint8_t trackIds[FSS_TRACKCOUNT]; |
|
| 29 |
+ std::uint8_t trackIds[FSS_TRACKCOUNT]; |
|
| 27 | 30 |
Track tracks[FSS_MAXTRACKS]; |
| 28 | 31 |
Channel channels[16]; |
| 29 | 32 |
std::bitset<16> allowedChannels; |
| 30 |
- int16_t variables[32]; |
|
| 33 |
+ std::int16_t variables[32]; |
|
| 31 | 34 |
|
| 32 |
- uint32_t sampleRate; |
|
| 35 |
+ std::uint32_t sampleRate; |
|
| 33 | 36 |
Interpolation interpolation; |
| 34 | 37 |
|
| 35 | 38 |
Player(); |
| ... | ... |
@@ -38,7 +41,7 @@ struct Player |
| 38 | 41 |
void ClearState(); |
| 39 | 42 |
void FreeTracks(); |
| 40 | 43 |
void Stop(bool bKillSound); |
| 41 |
- int ChannelAlloc(int type, int prio); |
|
| 44 |
+ int ChannelAlloc(ChannelAllocateType type, int prio); |
|
| 42 | 45 |
int TrackAlloc(); |
| 43 | 46 |
void Run(); |
| 44 | 47 |
void UpdateTracks(); |
| ... | ... |
@@ -6,48 +6,51 @@ |
| 6 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 |
+#include <algorithm> |
|
| 9 | 10 |
#include <stdexcept> |
| 10 |
-#include "SBNK.h" |
|
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "NDSStdHeader.h" |
| 13 |
+#include "SBNK.h" |
|
| 14 |
+#include "common.h" |
|
| 12 | 15 |
|
| 13 |
-SBNKInstrumentRange::SBNKInstrumentRange(uint8_t lowerNote, uint8_t upperNote, int recordType) : lowNote(lowerNote), highNote(upperNote), |
|
| 16 |
+SBNKInstrumentRange::SBNKInstrumentRange(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType) : lowNote(lowerNote), highNote(upperNote), |
|
| 14 | 17 |
record(recordType), swav(0), swar(0), noteNumber(0), attackRate(0), decayRate(0), sustainLevel(0), releaseRate(0), pan(0) |
| 15 | 18 |
{
|
| 16 | 19 |
} |
| 17 | 20 |
|
| 18 | 21 |
void SBNKInstrumentRange::Read(PseudoFile &file) |
| 19 | 22 |
{
|
| 20 |
- this->swav = file.ReadLE<uint16_t>(); |
|
| 21 |
- this->swar = file.ReadLE<uint16_t>(); |
|
| 22 |
- this->noteNumber = file.ReadLE<uint8_t>(); |
|
| 23 |
- this->attackRate = file.ReadLE<uint8_t>(); |
|
| 24 |
- this->decayRate = file.ReadLE<uint8_t>(); |
|
| 25 |
- this->sustainLevel = file.ReadLE<uint8_t>(); |
|
| 26 |
- this->releaseRate = file.ReadLE<uint8_t>(); |
|
| 27 |
- this->pan = file.ReadLE<uint8_t>(); |
|
| 23 |
+ this->swav = file.ReadLE<std::uint16_t>(); |
|
| 24 |
+ this->swar = file.ReadLE<std::uint16_t>(); |
|
| 25 |
+ this->noteNumber = file.ReadLE<std::uint8_t>(); |
|
| 26 |
+ this->attackRate = file.ReadLE<std::uint8_t>(); |
|
| 27 |
+ this->decayRate = file.ReadLE<std::uint8_t>(); |
|
| 28 |
+ this->sustainLevel = file.ReadLE<std::uint8_t>(); |
|
| 29 |
+ this->releaseRate = file.ReadLE<std::uint8_t>(); |
|
| 30 |
+ this->pan = file.ReadLE<std::uint8_t>(); |
|
| 28 | 31 |
} |
| 29 | 32 |
|
| 30 | 33 |
SBNKInstrument::SBNKInstrument() : record(0), ranges() |
| 31 | 34 |
{
|
| 32 | 35 |
} |
| 33 | 36 |
|
| 34 |
-void SBNKInstrument::Read(PseudoFile &file, uint32_t startOffset) |
|
| 37 |
+void SBNKInstrument::Read(PseudoFile &file, std::uint32_t startOffset) |
|
| 35 | 38 |
{
|
| 36 |
- this->record = file.ReadLE<uint8_t>(); |
|
| 37 |
- uint16_t offset = file.ReadLE<uint16_t>(); |
|
| 38 |
- file.ReadLE<uint8_t>(); |
|
| 39 |
- uint32_t endOfInst = file.pos; |
|
| 39 |
+ this->record = file.ReadLE<std::uint8_t>(); |
|
| 40 |
+ std::uint16_t offset = file.ReadLE<std::uint16_t>(); |
|
| 41 |
+ file.ReadLE<std::uint8_t>(); |
|
| 42 |
+ std::uint32_t endOfInst = file.pos; |
|
| 40 | 43 |
file.pos = startOffset + offset; |
| 41 | 44 |
if (this->record) |
| 42 | 45 |
{
|
| 43 | 46 |
if (this->record == 16) |
| 44 | 47 |
{
|
| 45 |
- uint8_t lowNote = file.ReadLE<uint8_t>(); |
|
| 46 |
- uint8_t highNote = file.ReadLE<uint8_t>(); |
|
| 47 |
- uint8_t num = highNote - lowNote + 1; |
|
| 48 |
- for (uint8_t i = 0; i < num; ++i) |
|
| 48 |
+ std::uint8_t lowNote = file.ReadLE<std::uint8_t>(); |
|
| 49 |
+ std::uint8_t highNote = file.ReadLE<std::uint8_t>(); |
|
| 50 |
+ std::uint8_t num = highNote - lowNote + 1; |
|
| 51 |
+ for (std::uint8_t i = 0; i < num; ++i) |
|
| 49 | 52 |
{
|
| 50 |
- uint16_t thisRecord = file.ReadLE<uint16_t>(); |
|
| 53 |
+ std::uint16_t thisRecord = file.ReadLE<std::uint16_t>(); |
|
| 51 | 54 |
auto range = SBNKInstrumentRange(lowNote + i, lowNote + i, thisRecord); |
| 52 | 55 |
range.Read(file); |
| 53 | 56 |
this->ranges.push_back(range); |
| ... | ... |
@@ -55,14 +58,14 @@ void SBNKInstrument::Read(PseudoFile &file, uint32_t startOffset) |
| 55 | 58 |
} |
| 56 | 59 |
else if (this->record == 17) |
| 57 | 60 |
{
|
| 58 |
- uint8_t thisRanges[8]; |
|
| 61 |
+ std::uint8_t thisRanges[8]; |
|
| 59 | 62 |
file.ReadLE(thisRanges); |
| 60 |
- uint8_t i = 0; |
|
| 63 |
+ std::uint8_t i = 0; |
|
| 61 | 64 |
while (i < 8 && thisRanges[i]) |
| 62 | 65 |
{
|
| 63 |
- uint16_t thisRecord = file.ReadLE<uint16_t>(); |
|
| 64 |
- uint8_t lowNote = i ? thisRanges[i - 1] + 1 : 0; |
|
| 65 |
- uint8_t highNote = thisRanges[i]; |
|
| 66 |
+ std::uint16_t thisRecord = file.ReadLE<std::uint16_t>(); |
|
| 67 |
+ std::uint8_t lowNote = i ? thisRanges[i - 1] + 1 : 0; |
|
| 68 |
+ std::uint8_t highNote = thisRanges[i]; |
|
| 66 | 69 |
auto range = SBNKInstrumentRange(lowNote, highNote, thisRecord); |
| 67 | 70 |
range.Read(file); |
| 68 | 71 |
this->ranges.push_back(range); |
| ... | ... |
@@ -86,19 +89,19 @@ SBNK::SBNK(const std::string &fn) : filename(fn), instruments(), info() |
| 86 | 89 |
|
| 87 | 90 |
void SBNK::Read(PseudoFile &file) |
| 88 | 91 |
{
|
| 89 |
- uint32_t startOfSBNK = file.pos; |
|
| 92 |
+ std::uint32_t startOfSBNK = file.pos; |
|
| 90 | 93 |
NDSStdHeader header; |
| 91 | 94 |
header.Read(file); |
| 92 | 95 |
header.Verify("SBNK", 0x0100FEFF);
|
| 93 |
- int8_t type[4]; |
|
| 96 |
+ std::int8_t type[4]; |
|
| 94 | 97 |
file.ReadLE(type); |
| 95 | 98 |
if (!VerifyHeader(type, "DATA")) |
| 96 | 99 |
throw std::runtime_error("SBNK DATA structure invalid");
|
| 97 |
- file.ReadLE<uint32_t>(); // size |
|
| 98 |
- uint32_t reserved[8]; |
|
| 100 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 101 |
+ std::uint32_t reserved[8]; |
|
| 99 | 102 |
file.ReadLE(reserved); |
| 100 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 103 |
+ std::uint32_t count = file.ReadLE<std::uint32_t>(); |
|
| 101 | 104 |
this->instruments.resize(count); |
| 102 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 105 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 103 | 106 |
this->instruments[i].Read(file, startOfSBNK); |
| 104 | 107 |
} |
| ... | ... |
@@ -8,37 +8,41 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include "SWAR.h" |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <vector> |
|
| 13 |
+#include <cstdint> |
|
| 12 | 14 |
#include "INFOEntry.h" |
| 13 |
-#include "common.h" |
|
| 15 |
+ |
|
| 16 |
+struct PseudoFile; |
|
| 17 |
+struct SWAR; |
|
| 14 | 18 |
|
| 15 | 19 |
struct SBNKInstrumentRange |
| 16 | 20 |
{
|
| 17 |
- uint8_t lowNote; |
|
| 18 |
- uint8_t highNote; |
|
| 19 |
- uint16_t record; |
|
| 20 |
- uint16_t swav; |
|
| 21 |
- uint16_t swar; |
|
| 22 |
- uint8_t noteNumber; |
|
| 23 |
- uint8_t attackRate; |
|
| 24 |
- uint8_t decayRate; |
|
| 25 |
- uint8_t sustainLevel; |
|
| 26 |
- uint8_t releaseRate; |
|
| 27 |
- uint8_t pan; |
|
| 28 |
- |
|
| 29 |
- SBNKInstrumentRange(uint8_t lowerNote, uint8_t upperNote, int recordType); |
|
| 21 |
+ std::uint8_t lowNote; |
|
| 22 |
+ std::uint8_t highNote; |
|
| 23 |
+ std::uint16_t record; |
|
| 24 |
+ std::uint16_t swav; |
|
| 25 |
+ std::uint16_t swar; |
|
| 26 |
+ std::uint8_t noteNumber; |
|
| 27 |
+ std::uint8_t attackRate; |
|
| 28 |
+ std::uint8_t decayRate; |
|
| 29 |
+ std::uint8_t sustainLevel; |
|
| 30 |
+ std::uint8_t releaseRate; |
|
| 31 |
+ std::uint8_t pan; |
|
| 32 |
+ |
|
| 33 |
+ SBNKInstrumentRange(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType); |
|
| 30 | 34 |
|
| 31 | 35 |
void Read(PseudoFile &file); |
| 32 | 36 |
}; |
| 33 | 37 |
|
| 34 | 38 |
struct SBNKInstrument |
| 35 | 39 |
{
|
| 36 |
- uint8_t record; |
|
| 40 |
+ std::uint8_t record; |
|
| 37 | 41 |
std::vector<SBNKInstrumentRange> ranges; |
| 38 | 42 |
|
| 39 | 43 |
SBNKInstrument(); |
| 40 | 44 |
|
| 41 |
- void Read(PseudoFile &file, uint32_t startOffset); |
|
| 45 |
+ void Read(PseudoFile &file, std::uint32_t startOffset); |
|
| 42 | 46 |
}; |
| 43 | 47 |
|
| 44 | 48 |
struct SBNK |
| ... | ... |
@@ -6,25 +6,31 @@ |
| 6 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 |
-#include "SDAT.h" |
|
| 9 |
+#include <stdexcept> |
|
| 10 |
+#include <string> |
|
| 11 |
+#include <cstdint> |
|
| 12 |
+#include "FATSection.h" |
|
| 13 |
+#include "INFOSection.h" |
|
| 10 | 14 |
#include "NDSStdHeader.h" |
| 15 |
+#include "SBNK.h" |
|
| 16 |
+#include "SDAT.h" |
|
| 17 |
+#include "SSEQ.h" |
|
| 18 |
+#include "SWAR.h" |
|
| 11 | 19 |
#include "SYMBSection.h" |
| 12 |
-#include "INFOSection.h" |
|
| 13 |
-#include "FATSection.h" |
|
| 14 |
-#include "convert.h" |
|
| 20 |
+#include "common.h" |
|
| 15 | 21 |
|
| 16 |
-SDAT::SDAT(PseudoFile &file, uint32_t sseqToLoad) : sseq(), sbnk(), player() |
|
| 22 |
+SDAT::SDAT(PseudoFile &file, std::uint32_t sseqToLoad) : sseq(), sbnk(), player() |
|
| 17 | 23 |
{
|
| 18 | 24 |
// Read sections |
| 19 | 25 |
NDSStdHeader header; |
| 20 | 26 |
header.Read(file); |
| 21 | 27 |
header.Verify("SDAT", 0x0100FEFF);
|
| 22 |
- uint32_t SYMBOffset = file.ReadLE<uint32_t>(); |
|
| 23 |
- file.ReadLE<uint32_t>(); // SYMB size |
|
| 24 |
- uint32_t INFOOffset = file.ReadLE<uint32_t>(); |
|
| 25 |
- file.ReadLE<uint32_t>(); // INFO size |
|
| 26 |
- uint32_t FATOffset = file.ReadLE<uint32_t>(); |
|
| 27 |
- file.ReadLE<uint32_t>(); // FAT Size |
|
| 28 |
+ std::uint32_t SYMBOffset = file.ReadLE<std::uint32_t>(); |
|
| 29 |
+ file.ReadLE<std::uint32_t>(); // SYMB size |
|
| 30 |
+ std::uint32_t INFOOffset = file.ReadLE<std::uint32_t>(); |
|
| 31 |
+ file.ReadLE<std::uint32_t>(); // INFO size |
|
| 32 |
+ std::uint32_t FATOffset = file.ReadLE<std::uint32_t>(); |
|
| 33 |
+ file.ReadLE<std::uint32_t>(); // FAT Size |
|
| 28 | 34 |
SYMBSection symbSection; |
| 29 | 35 |
if (SYMBOffset) |
| 30 | 36 |
{
|
| ... | ... |
@@ -47,7 +53,7 @@ SDAT::SDAT(PseudoFile &file, uint32_t sseqToLoad) : sseq(), sbnk(), player() |
| 47 | 53 |
// Read SSEQ |
| 48 | 54 |
if (infoSection.SEQrecord.entries.count(sseqToLoad)) |
| 49 | 55 |
{
|
| 50 |
- uint16_t fileID = infoSection.SEQrecord.entries[sseqToLoad].fileID; |
|
| 56 |
+ std::uint32_t fileID = infoSection.SEQrecord.entries[sseqToLoad].fileID; |
|
| 51 | 57 |
std::string name = "SSEQ" + NumToHexString(fileID).substr(2); |
| 52 | 58 |
if (SYMBOffset) |
| 53 | 59 |
name = NumToHexString(sseqToLoad).substr(6) + " - " + symbSection.SEQrecord.entries[sseqToLoad]; |
| ... | ... |
@@ -58,7 +64,7 @@ SDAT::SDAT(PseudoFile &file, uint32_t sseqToLoad) : sseq(), sbnk(), player() |
| 58 | 64 |
this->sseq.reset(newSSEQ); |
| 59 | 65 |
|
| 60 | 66 |
// Read SBNK for this SSEQ |
| 61 |
- uint16_t bank = newSSEQ->info.bank; |
|
| 67 |
+ std::uint16_t bank = newSSEQ->info.bank; |
|
| 62 | 68 |
fileID = infoSection.BANKrecord.entries[bank].fileID; |
| 63 | 69 |
name = "SBNK" + NumToHexString(fileID).substr(2); |
| 64 | 70 |
if (SYMBOffset) |
| ... | ... |
@@ -74,7 +80,7 @@ SDAT::SDAT(PseudoFile &file, uint32_t sseqToLoad) : sseq(), sbnk(), player() |
| 74 | 80 |
for (int i = 0; i < 4; ++i) |
| 75 | 81 |
if (newSBNK->info.waveArc[i] != 0xFFFF) |
| 76 | 82 |
{
|
| 77 |
- uint16_t waveArc = newSBNK->info.waveArc[i]; |
|
| 83 |
+ std::uint16_t waveArc = newSBNK->info.waveArc[i]; |
|
| 78 | 84 |
fileID = infoSection.WAVEARCrecord.entries[waveArc].fileID; |
| 79 | 85 |
name = "SWAR" + NumToHexString(fileID).substr(2); |
| 80 | 86 |
if (SYMBOffset) |
| ... | ... |
@@ -9,10 +9,13 @@ |
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 | 11 |
#include <memory> |
| 12 |
-#include "SSEQ.h" |
|
| 12 |
+#include <cstdint> |
|
| 13 |
+#include "INFOEntry.h" |
|
| 13 | 14 |
#include "SBNK.h" |
| 15 |
+#include "SSEQ.h" |
|
| 14 | 16 |
#include "SWAR.h" |
| 15 |
-#include "common.h" |
|
| 17 |
+ |
|
| 18 |
+struct PseudoFile; |
|
| 16 | 19 |
|
| 17 | 20 |
struct SDAT |
| 18 | 21 |
{
|
| ... | ... |
@@ -21,5 +24,5 @@ struct SDAT |
| 21 | 24 |
std::unique_ptr<SWAR> swar[4]; |
| 22 | 25 |
INFOEntryPLAYER player; |
| 23 | 26 |
|
| 24 |
- SDAT(PseudoFile &file, uint32_t sseqToLoad); |
|
| 27 |
+ SDAT(PseudoFile &file, std::uint32_t sseqToLoad); |
|
| 25 | 28 |
}; |
| ... | ... |
@@ -7,8 +7,11 @@ |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 |
-#include "SSEQ.h" |
|
| 10 |
+#include <string> |
|
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "NDSStdHeader.h" |
| 13 |
+#include "SSEQ.h" |
|
| 14 |
+#include "common.h" |
|
| 12 | 15 |
|
| 13 | 16 |
SSEQ::SSEQ(const std::string &fn) : filename(fn), data(), bank(nullptr), info() |
| 14 | 17 |
{
|
| ... | ... |
@@ -16,16 +19,16 @@ SSEQ::SSEQ(const std::string &fn) : filename(fn), data(), bank(nullptr), info() |
| 16 | 19 |
|
| 17 | 20 |
void SSEQ::Read(PseudoFile &file) |
| 18 | 21 |
{
|
| 19 |
- uint32_t startOfSSEQ = file.pos; |
|
| 22 |
+ std::uint32_t startOfSSEQ = file.pos; |
|
| 20 | 23 |
NDSStdHeader header; |
| 21 | 24 |
header.Read(file); |
| 22 | 25 |
header.Verify("SSEQ", 0x0100FEFF);
|
| 23 |
- int8_t type[4]; |
|
| 26 |
+ std::int8_t type[4]; |
|
| 24 | 27 |
file.ReadLE(type); |
| 25 | 28 |
if (!VerifyHeader(type, "DATA")) |
| 26 | 29 |
throw std::runtime_error("SSEQ DATA structure invalid");
|
| 27 |
- uint32_t size = file.ReadLE<uint32_t>(); |
|
| 28 |
- uint32_t dataOffset = file.ReadLE<uint32_t>(); |
|
| 30 |
+ std::uint32_t size = file.ReadLE<std::uint32_t>(); |
|
| 31 |
+ std::uint32_t dataOffset = file.ReadLE<std::uint32_t>(); |
|
| 29 | 32 |
this->data.resize(size - 12, 0); |
| 30 | 33 |
file.pos = startOfSSEQ + dataOffset; |
| 31 | 34 |
file.ReadLE(this->data); |
| ... | ... |
@@ -8,14 +8,18 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include "SBNK.h" |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <vector> |
|
| 13 |
+#include <cstdint> |
|
| 12 | 14 |
#include "INFOEntry.h" |
| 13 |
-#include "common.h" |
|
| 15 |
+ |
|
| 16 |
+struct PseudoFile; |
|
| 17 |
+struct SBNK; |
|
| 14 | 18 |
|
| 15 | 19 |
struct SSEQ |
| 16 | 20 |
{
|
| 17 | 21 |
std::string filename; |
| 18 |
- std::vector<uint8_t> data; |
|
| 22 |
+ std::vector<std::uint8_t> data; |
|
| 19 | 23 |
|
| 20 | 24 |
const SBNK *bank; |
| 21 | 25 |
INFOEntrySEQ info; |
| ... | ... |
@@ -7,9 +7,13 @@ |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 |
+#include <string> |
|
| 10 | 11 |
#include <vector> |
| 11 |
-#include "SWAR.h" |
|
| 12 |
+#include <cstdint> |
|
| 12 | 13 |
#include "NDSStdHeader.h" |
| 14 |
+#include "SWAR.h" |
|
| 15 |
+#include "SWAV.h" |
|
| 16 |
+#include "common.h" |
|
| 13 | 17 |
|
| 14 | 18 |
SWAR::SWAR(const std::string &fn) : filename(fn), swavs(), info() |
| 15 | 19 |
{
|
| ... | ... |
@@ -17,21 +21,21 @@ SWAR::SWAR(const std::string &fn) : filename(fn), swavs(), info() |
| 17 | 21 |
|
| 18 | 22 |
void SWAR::Read(PseudoFile &file) |
| 19 | 23 |
{
|
| 20 |
- uint32_t startOfSWAR = file.pos; |
|
| 24 |
+ std::uint32_t startOfSWAR = file.pos; |
|
| 21 | 25 |
NDSStdHeader header; |
| 22 | 26 |
header.Read(file); |
| 23 | 27 |
header.Verify("SWAR", 0x0100FEFF);
|
| 24 |
- int8_t type[4]; |
|
| 28 |
+ std::int8_t type[4]; |
|
| 25 | 29 |
file.ReadLE(type); |
| 26 | 30 |
if (!VerifyHeader(type, "DATA")) |
| 27 | 31 |
throw std::runtime_error("SWAR DATA structure invalid");
|
| 28 |
- file.ReadLE<uint32_t>(); // size |
|
| 29 |
- uint32_t reserved[8]; |
|
| 32 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 33 |
+ std::uint32_t reserved[8]; |
|
| 30 | 34 |
file.ReadLE(reserved); |
| 31 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 32 |
- auto offsets = std::vector<uint32_t>(count); |
|
| 35 |
+ std::uint32_t count = file.ReadLE<std::uint32_t>(); |
|
| 36 |
+ auto offsets = std::vector<std::uint32_t>(count); |
|
| 33 | 37 |
file.ReadLE(offsets); |
| 34 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 38 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 35 | 39 |
if (offsets[i]) |
| 36 | 40 |
{
|
| 37 | 41 |
file.pos = startOfSWAR + offsets[i]; |
| ... | ... |
@@ -9,14 +9,17 @@ |
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 | 11 |
#include <map> |
| 12 |
-#include "SWAV.h" |
|
| 12 |
+#include <string> |
|
| 13 |
+#include <cstdint> |
|
| 13 | 14 |
#include "INFOEntry.h" |
| 14 |
-#include "common.h" |
|
| 15 |
+#include "SWAV.h" |
|
| 16 |
+ |
|
| 17 |
+struct PseudoFile; |
|
| 15 | 18 |
|
| 16 | 19 |
struct SWAR |
| 17 | 20 |
{
|
| 18 | 21 |
std::string filename; |
| 19 |
- std::map<uint32_t, SWAV> swavs; |
|
| 22 |
+ std::map<std::uint32_t, SWAV> swavs; |
|
| 20 | 23 |
|
| 21 | 24 |
INFOEntryWAVEARC info; |
| 22 | 25 |
|
| ... | ... |
@@ -6,7 +6,11 @@ |
| 6 | 6 |
* http://www.feshrine.net/hacking/doc/nds-sdat.html |
| 7 | 7 |
*/ |
| 8 | 8 |
|
| 9 |
+#include <vector> |
|
| 10 |
+#include <cstddef> |
|
| 11 |
+#include <cstdint> |
|
| 9 | 12 |
#include "SWAV.h" |
| 13 |
+#include "common.h" |
|
| 10 | 14 |
|
| 11 | 15 |
static int ima_index_table[] = |
| 12 | 16 |
{
|
| ... | ... |
@@ -31,9 +35,9 @@ SWAV::SWAV() : waveType(0), loop(0), sampleRate(0), time(0), loopOffset(0), nonL |
| 31 | 35 |
{
|
| 32 | 36 |
} |
| 33 | 37 |
|
| 34 |
-static inline void DecodeADPCMNibble(int32_t nibble, int32_t &stepIndex, int32_t &predictedValue) |
|
| 38 |
+static inline void DecodeADPCMNibble(std::int32_t nibble, std::int32_t &stepIndex, std::int32_t &predictedValue) |
|
| 35 | 39 |
{
|
| 36 |
- int32_t step = ima_step_table[stepIndex]; |
|
| 40 |
+ std::int32_t step = ima_step_table[stepIndex]; |
|
| 37 | 41 |
|
| 38 | 42 |
stepIndex += ima_index_table[nibble]; |
| 39 | 43 |
|
| ... | ... |
@@ -42,7 +46,7 @@ static inline void DecodeADPCMNibble(int32_t nibble, int32_t &stepIndex, int32_t |
| 42 | 46 |
else if (stepIndex > 88) |
| 43 | 47 |
stepIndex = 88; |
| 44 | 48 |
|
| 45 |
- int32_t diff = step >> 3; |
|
| 49 |
+ std::int32_t diff = step >> 3; |
|
| 46 | 50 |
|
| 47 | 51 |
if (nibble & 4) |
| 48 | 52 |
diff += step; |
| ... | ... |
@@ -61,15 +65,15 @@ static inline void DecodeADPCMNibble(int32_t nibble, int32_t &stepIndex, int32_t |
| 61 | 65 |
predictedValue = 0x7FFF; |
| 62 | 66 |
} |
| 63 | 67 |
|
| 64 |
-void SWAV::DecodeADPCM(const uint8_t *origData, uint32_t len) |
|
| 68 |
+void SWAV::DecodeADPCM(const std::uint8_t *origData, std::uint32_t len) |
|
| 65 | 69 |
{
|
| 66 |
- int32_t predictedValue = origData[0] | (origData[1] << 8); |
|
| 67 |
- int32_t stepIndex = origData[2] | (origData[3] << 8); |
|
| 70 |
+ std::int32_t predictedValue = origData[0] | (origData[1] << 8); |
|
| 71 |
+ std::int32_t stepIndex = origData[2] | (origData[3] << 8); |
|
| 68 | 72 |
auto finalData = &this->data[0]; |
| 69 | 73 |
|
| 70 |
- for (uint32_t i = 0; i < len; ++i) |
|
| 74 |
+ for (std::uint32_t i = 0; i < len; ++i) |
|
| 71 | 75 |
{
|
| 72 |
- int32_t nibble = origData[i + 4] & 0x0F; |
|
| 76 |
+ std::int32_t nibble = origData[i + 4] & 0x0F; |
|
| 73 | 77 |
DecodeADPCMNibble(nibble, stepIndex, predictedValue); |
| 74 | 78 |
finalData[2 * i] = predictedValue; |
| 75 | 79 |
|
| ... | ... |
@@ -81,14 +85,14 @@ void SWAV::DecodeADPCM(const uint8_t *origData, uint32_t len) |
| 81 | 85 |
|
| 82 | 86 |
void SWAV::Read(PseudoFile &file) |
| 83 | 87 |
{
|
| 84 |
- this->waveType = file.ReadLE<uint8_t>(); |
|
| 85 |
- this->loop = file.ReadLE<uint8_t>(); |
|
| 86 |
- this->sampleRate = file.ReadLE<uint16_t>(); |
|
| 87 |
- this->time = file.ReadLE<uint16_t>(); |
|
| 88 |
- this->loopOffset = file.ReadLE<uint16_t>(); |
|
| 89 |
- this->nonLoopLength = file.ReadLE<uint32_t>(); |
|
| 90 |
- uint32_t size = (this->loopOffset + this->nonLoopLength) * 4; |
|
| 91 |
- auto origData = std::vector<uint8_t>(size); |
|
| 88 |
+ this->waveType = file.ReadLE<std::uint8_t>(); |
|
| 89 |
+ this->loop = file.ReadLE<std::uint8_t>(); |
|
| 90 |
+ this->sampleRate = file.ReadLE<std::uint16_t>(); |
|
| 91 |
+ this->time = file.ReadLE<std::uint16_t>(); |
|
| 92 |
+ this->loopOffset = file.ReadLE<std::uint16_t>(); |
|
| 93 |
+ this->nonLoopLength = file.ReadLE<std::uint32_t>(); |
|
| 94 |
+ std::uint32_t size = (this->loopOffset + this->nonLoopLength) * 4; |
|
| 95 |
+ auto origData = std::vector<std::uint8_t>(size); |
|
| 92 | 96 |
file.ReadLE(origData); |
| 93 | 97 |
|
| 94 | 98 |
// Convert data accordingly |
| ... | ... |
@@ -96,7 +100,7 @@ void SWAV::Read(PseudoFile &file) |
| 96 | 100 |
{
|
| 97 | 101 |
// PCM 8-bit -> PCM signed 16-bit |
| 98 | 102 |
this->data.resize(size, 0); |
| 99 |
- for (size_t i = 0; i < size; ++i) |
|
| 103 |
+ for (std::size_t i = 0; i < size; ++i) |
|
| 100 | 104 |
this->data[i] = origData[i] << 8; |
| 101 | 105 |
this->loopOffset *= 4; |
| 102 | 106 |
this->nonLoopLength *= 4; |
| ... | ... |
@@ -105,8 +109,8 @@ void SWAV::Read(PseudoFile &file) |
| 105 | 109 |
{
|
| 106 | 110 |
// PCM signed 16-bit, no conversion |
| 107 | 111 |
this->data.resize(size / 2, 0); |
| 108 |
- for (size_t i = 0; i < size / 2; ++i) |
|
| 109 |
- this->data[i] = ReadLE<int16_t>(&origData[2 * i]); |
|
| 112 |
+ for (std::size_t i = 0; i < size / 2; ++i) |
|
| 113 |
+ this->data[i] = ReadLE<std::int16_t>(&origData[2 * i]); |
|
| 110 | 114 |
this->loopOffset *= 2; |
| 111 | 115 |
this->nonLoopLength *= 2; |
| 112 | 116 |
} |
| ... | ... |
@@ -8,21 +8,24 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include "common.h" |
|
| 11 |
+#include <vector> |
|
| 12 |
+#include <cstdint> |
|
| 13 |
+ |
|
| 14 |
+struct PseudoFile; |
|
| 12 | 15 |
|
| 13 | 16 |
struct SWAV |
| 14 | 17 |
{
|
| 15 |
- uint8_t waveType; |
|
| 16 |
- uint8_t loop; |
|
| 17 |
- uint16_t sampleRate; |
|
| 18 |
- uint16_t time; |
|
| 19 |
- uint32_t loopOffset; |
|
| 20 |
- uint32_t nonLoopLength; |
|
| 21 |
- std::vector<int16_t> data; |
|
| 22 |
- const int16_t *dataptr; |
|
| 18 |
+ std::uint8_t waveType; |
|
| 19 |
+ std::uint8_t loop; |
|
| 20 |
+ std::uint16_t sampleRate; |
|
| 21 |
+ std::uint16_t time; |
|
| 22 |
+ std::uint32_t loopOffset; |
|
| 23 |
+ std::uint32_t nonLoopLength; |
|
| 24 |
+ std::vector<std::int16_t> data; |
|
| 25 |
+ const std::int16_t *dataptr; |
|
| 23 | 26 |
|
| 24 | 27 |
SWAV(); |
| 25 | 28 |
|
| 26 | 29 |
void Read(PseudoFile &file); |
| 27 |
- void DecodeADPCM(const uint8_t *origData, uint32_t len); |
|
| 30 |
+ void DecodeADPCM(const std::uint8_t *origData, std::uint32_t len); |
|
| 28 | 31 |
}; |
| ... | ... |
@@ -8,18 +8,20 @@ |
| 8 | 8 |
|
| 9 | 9 |
#include <stdexcept> |
| 10 | 10 |
#include <vector> |
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "SYMBSection.h" |
| 13 |
+#include "common.h" |
|
| 12 | 14 |
|
| 13 | 15 |
SYMBRecord::SYMBRecord() : entries() |
| 14 | 16 |
{
|
| 15 | 17 |
} |
| 16 | 18 |
|
| 17 |
-void SYMBRecord::Read(PseudoFile &file, uint32_t startOffset) |
|
| 19 |
+void SYMBRecord::Read(PseudoFile &file, std::uint32_t startOffset) |
|
| 18 | 20 |
{
|
| 19 |
- uint32_t count = file.ReadLE<uint32_t>(); |
|
| 20 |
- auto entryOffsets = std::vector<uint32_t>(count); |
|
| 21 |
+ std::uint32_t count = file.ReadLE<uint32_t>(); |
|
| 22 |
+ auto entryOffsets = std::vector<std::uint32_t>(count); |
|
| 21 | 23 |
file.ReadLE(entryOffsets); |
| 22 |
- for (uint32_t i = 0; i < count; ++i) |
|
| 24 |
+ for (std::uint32_t i = 0; i < count; ++i) |
|
| 23 | 25 |
if (entryOffsets[i]) |
| 24 | 26 |
{
|
| 25 | 27 |
file.pos = startOffset + entryOffsets[i]; |
| ... | ... |
@@ -33,13 +35,13 @@ SYMBSection::SYMBSection() : SEQrecord(), BANKrecord(), WAVEARCrecord(), PLAYERr |
| 33 | 35 |
|
| 34 | 36 |
void SYMBSection::Read(PseudoFile &file) |
| 35 | 37 |
{
|
| 36 |
- uint32_t startOfSYMB = file.pos; |
|
| 37 |
- int8_t type[4]; |
|
| 38 |
+ std::uint32_t startOfSYMB = file.pos; |
|
| 39 |
+ std::int8_t type[4]; |
|
| 38 | 40 |
file.ReadLE(type); |
| 39 | 41 |
if (!VerifyHeader(type, "SYMB")) |
| 40 | 42 |
throw std::runtime_error("SDAT SYMB Section invalid");
|
| 41 |
- file.ReadLE<uint32_t>(); // size |
|
| 42 |
- uint32_t recordOffsets[8]; |
|
| 43 |
+ file.ReadLE<std::uint32_t>(); // size |
|
| 44 |
+ std::uint32_t recordOffsets[8]; |
|
| 43 | 45 |
file.ReadLE(recordOffsets); |
| 44 | 46 |
if (recordOffsets[REC_SEQ]) |
| 45 | 47 |
{
|
| ... | ... |
@@ -9,15 +9,17 @@ |
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 | 11 |
#include <map> |
| 12 |
-#include "common.h" |
|
| 12 |
+#include <cstdint> |
|
| 13 |
+ |
|
| 14 |
+struct PseudoFile; |
|
| 13 | 15 |
|
| 14 | 16 |
struct SYMBRecord |
| 15 | 17 |
{
|
| 16 |
- std::map<uint32_t, std::string> entries; |
|
| 18 |
+ std::map<std::uint32_t, std::string> entries; |
|
| 17 | 19 |
|
| 18 | 20 |
SYMBRecord(); |
| 19 | 21 |
|
| 20 |
- void Read(PseudoFile &file, uint32_t startOffset); |
|
| 22 |
+ void Read(PseudoFile &file, std::uint32_t startOffset); |
|
| 21 | 23 |
}; |
| 22 | 24 |
|
| 23 | 25 |
struct SYMBSection |
| ... | ... |
@@ -7,10 +7,18 @@ |
| 7 | 7 |
* https://github.com/fincs/FSS |
| 8 | 8 |
*/ |
| 9 | 9 |
|
| 10 |
-#include <cstdlib> |
|
| 11 |
-#include "Track.h" |
|
| 10 |
+#include <algorithm> |
|
| 11 |
+#include <functional> |
|
| 12 |
+#include <cstddef> |
|
| 13 |
+#include <cstdint> |
|
| 12 | 14 |
#include "Player.h" |
| 15 |
+#include "SBNK.h" |
|
| 16 |
+#include "SSEQ.h" |
|
| 17 |
+#include "SWAR.h" |
|
| 18 |
+#include "SWAV.h" |
|
| 19 |
+#include "Track.h" |
|
| 13 | 20 |
#include "common.h" |
| 21 |
+#include "consts.h" |
|
| 14 | 22 |
|
| 15 | 23 |
Track::Track() |
| 16 | 24 |
{
|
| ... | ... |
@@ -18,7 +26,7 @@ Track::Track() |
| 18 | 26 |
} |
| 19 | 27 |
|
| 20 | 28 |
// Original FSS Function: Player_InitTrack |
| 21 |
-void Track::Init(uint8_t handle, Player *player, const uint8_t *dataPos, int n) |
|
| 29 |
+void Track::Init(std::uint8_t handle, Player *player, const std::uint8_t *dataPos, int n) |
|
| 22 | 30 |
{
|
| 23 | 31 |
this->trackId = handle; |
| 24 | 32 |
this->num = n; |
| ... | ... |
@@ -63,8 +71,8 @@ void Track::Zero() |
| 63 | 71 |
void Track::ClearState() |
| 64 | 72 |
{
|
| 65 | 73 |
this->state.reset(); |
| 66 |
- this->state.set(TS_ALLOCBIT); |
|
| 67 |
- this->state.set(TS_NOTEWAIT); |
|
| 74 |
+ this->state.set(ToIntegral(TrackState::AllocateBit)); |
|
| 75 |
+ this->state.set(ToIntegral(TrackState::NoteWait)); |
|
| 68 | 76 |
this->prio = this->ply->prio + 64; |
| 69 | 77 |
|
| 70 | 78 |
this->pos = this->startPos; |
| ... | ... |
@@ -122,7 +130,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 122 | 130 |
} |
| 123 | 131 |
else if (fRecord == 17) |
| 124 | 132 |
{
|
| 125 |
- size_t reg, ranges; |
|
| 133 |
+ std::size_t reg, ranges; |
|
| 126 | 134 |
for (reg = 0, ranges = instrument.ranges.size(); reg < ranges; ++reg) |
| 127 | 135 |
if (key <= instrument.ranges[reg].highNote) |
| 128 | 136 |
break; |
| ... | ... |
@@ -150,7 +158,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 150 | 158 |
noteDef = &instrument.ranges[0]; |
| 151 | 159 |
if (fRecord == 3) |
| 152 | 160 |
{
|
| 153 |
- nCh = this->ply->ChannelAlloc(TYPE_NOISE, this->prio); |
|
| 161 |
+ nCh = this->ply->ChannelAlloc(ChannelAllocateType::Noise, this->prio); |
|
| 154 | 162 |
if (nCh < 0) |
| 155 | 163 |
return -1; |
| 156 | 164 |
chn = &this->ply->channels[nCh]; |
| ... | ... |
@@ -158,7 +166,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 158 | 166 |
} |
| 159 | 167 |
else |
| 160 | 168 |
{
|
| 161 |
- nCh = this->ply->ChannelAlloc(TYPE_PSG, this->prio); |
|
| 169 |
+ nCh = this->ply->ChannelAlloc(ChannelAllocateType::PSG, this->prio); |
|
| 162 | 170 |
if (nCh < 0) |
| 163 | 171 |
return -1; |
| 164 | 172 |
chn = &this->ply->channels[nCh]; |
| ... | ... |
@@ -171,7 +179,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 171 | 179 |
|
| 172 | 180 |
if (bIsPCM) |
| 173 | 181 |
{
|
| 174 |
- nCh = this->ply->ChannelAlloc(TYPE_PCM, this->prio); |
|
| 182 |
+ nCh = this->ply->ChannelAlloc(ChannelAllocateType::PCM, this->prio); |
|
| 175 | 183 |
if (nCh < 0) |
| 176 | 184 |
return -1; |
| 177 | 185 |
chn = &this->ply->channels[nCh]; |
| ... | ... |
@@ -185,7 +193,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 185 | 193 |
chn->reg.samplePosition = -3; |
| 186 | 194 |
} |
| 187 | 195 |
|
| 188 |
- chn->state = CS_START; |
|
| 196 |
+ chn->state = ChannelState::Start; |
|
| 189 | 197 |
chn->trackId = this->trackId; |
| 190 | 198 |
chn->flags.reset(); |
| 191 | 199 |
chn->prio = this->prio; |
| ... | ... |
@@ -223,7 +231,7 @@ int Track::NoteOnTie(int key, int vel) |
| 223 | 231 |
for (i = 0; i < 16; ++i) |
| 224 | 232 |
{
|
| 225 | 233 |
chn = &this->ply->channels[i]; |
| 226 |
- if (chn->state > CS_NONE && chn->trackId == this->trackId && chn->state != CS_RELEASE) |
|
| 234 |
+ if (chn->state > ChannelState::None && chn->trackId == this->trackId && chn->state != ChannelState::Release) |
|
| 227 | 235 |
break; |
| 228 | 236 |
} |
| 229 | 237 |
|
| ... | ... |
@@ -245,7 +253,7 @@ int Track::NoteOnTie(int key, int vel) |
| 245 | 253 |
chn->UpdatePorta(*this); |
| 246 | 254 |
|
| 247 | 255 |
this->portaKey = key; |
| 248 |
- chn->flags.set(CF_UPDTMR); |
|
| 256 |
+ chn->flags.set(ToIntegral(ChannelFlag::UpdateTimer)); |
|
| 249 | 257 |
|
| 250 | 258 |
return i; |
| 251 | 259 |
} |
| ... | ... |
@@ -256,145 +264,145 @@ void Track::ReleaseAllNotes() |
| 256 | 264 |
for (int i = 0; i < 16; ++i) |
| 257 | 265 |
{
|
| 258 | 266 |
Channel &chn = this->ply->channels[i]; |
| 259 |
- if (chn.state > CS_NONE && chn.trackId == this->trackId && chn.state != CS_RELEASE) |
|
| 267 |
+ if (chn.state > ChannelState::None && chn.trackId == this->trackId && chn.state != ChannelState::Release) |
|
| 260 | 268 |
chn.Release(); |
| 261 | 269 |
} |
| 262 | 270 |
} |
| 263 | 271 |
|
| 264 |
-enum SseqCommand |
|
| 272 |
+enum class SSEQCommand |
|
| 265 | 273 |
{
|
| 266 |
- SSEQ_CMD_ALLOCTRACK = 0xFE, // Silently ignored |
|
| 267 |
- SSEQ_CMD_OPENTRACK = 0x93, |
|
| 268 |
- |
|
| 269 |
- SSEQ_CMD_REST = 0x80, |
|
| 270 |
- SSEQ_CMD_PATCH = 0x81, |
|
| 271 |
- SSEQ_CMD_PAN = 0xC0, |
|
| 272 |
- SSEQ_CMD_VOL = 0xC1, |
|
| 273 |
- SSEQ_CMD_MASTERVOL = 0xC2, |
|
| 274 |
- SSEQ_CMD_PRIO = 0xC6, |
|
| 275 |
- SSEQ_CMD_NOTEWAIT = 0xC7, |
|
| 276 |
- SSEQ_CMD_TIE = 0xC8, |
|
| 277 |
- SSEQ_CMD_EXPR = 0xD5, |
|
| 278 |
- SSEQ_CMD_TEMPO = 0xE1, |
|
| 279 |
- SSEQ_CMD_END = 0xFF, |
|
| 280 |
- |
|
| 281 |
- SSEQ_CMD_GOTO = 0x94, |
|
| 282 |
- SSEQ_CMD_CALL = 0x95, |
|
| 283 |
- SSEQ_CMD_RET = 0xFD, |
|
| 284 |
- SSEQ_CMD_LOOPSTART = 0xD4, |
|
| 285 |
- SSEQ_CMD_LOOPEND = 0xFC, |
|
| 286 |
- |
|
| 287 |
- SSEQ_CMD_TRANSPOSE = 0xC3, |
|
| 288 |
- SSEQ_CMD_PITCHBEND = 0xC4, |
|
| 289 |
- SSEQ_CMD_PITCHBENDRANGE = 0xC5, |
|
| 290 |
- |
|
| 291 |
- SSEQ_CMD_ATTACK = 0xD0, |
|
| 292 |
- SSEQ_CMD_DECAY = 0xD1, |
|
| 293 |
- SSEQ_CMD_SUSTAIN = 0xD2, |
|
| 294 |
- SSEQ_CMD_RELEASE = 0xD3, |
|
| 295 |
- |
|
| 296 |
- SSEQ_CMD_PORTAKEY = 0xC9, |
|
| 297 |
- SSEQ_CMD_PORTAFLAG = 0xCE, |
|
| 298 |
- SSEQ_CMD_PORTATIME = 0xCF, |
|
| 299 |
- SSEQ_CMD_SWEEPPITCH = 0xE3, |
|
| 300 |
- |
|
| 301 |
- SSEQ_CMD_MODDEPTH = 0xCA, |
|
| 302 |
- SSEQ_CMD_MODSPEED = 0xCB, |
|
| 303 |
- SSEQ_CMD_MODTYPE = 0xCC, |
|
| 304 |
- SSEQ_CMD_MODRANGE = 0xCD, |
|
| 305 |
- SSEQ_CMD_MODDELAY = 0xE0, |
|
| 306 |
- |
|
| 307 |
- SSEQ_CMD_RANDOM = 0xA0, |
|
| 308 |
- SSEQ_CMD_PRINTVAR = 0xD6, |
|
| 309 |
- SSEQ_CMD_IF = 0xA2, |
|
| 310 |
- SSEQ_CMD_FROMVAR = 0xA1, |
|
| 311 |
- SSEQ_CMD_SETVAR = 0xB0, |
|
| 312 |
- SSEQ_CMD_ADDVAR = 0xB1, |
|
| 313 |
- SSEQ_CMD_SUBVAR = 0xB2, |
|
| 314 |
- SSEQ_CMD_MULVAR = 0xB3, |
|
| 315 |
- SSEQ_CMD_DIVVAR = 0xB4, |
|
| 316 |
- SSEQ_CMD_SHIFTVAR = 0xB5, |
|
| 317 |
- SSEQ_CMD_RANDVAR = 0xB6, |
|
| 318 |
- SSEQ_CMD_CMP_EQ = 0xB8, |
|
| 319 |
- SSEQ_CMD_CMP_GE = 0xB9, |
|
| 320 |
- SSEQ_CMD_CMP_GT = 0xBA, |
|
| 321 |
- SSEQ_CMD_CMP_LE = 0xBB, |
|
| 322 |
- SSEQ_CMD_CMP_LT = 0xBC, |
|
| 323 |
- SSEQ_CMD_CMP_NE = 0xBD, |
|
| 324 |
- |
|
| 325 |
- SSEQ_CMD_MUTE = 0xD7 // Unsupported |
|
| 274 |
+ AllocateTrack = 0xFE, // Silently ignored |
|
| 275 |
+ OpenTrack = 0x93, |
|
| 276 |
+ |
|
| 277 |
+ Rest = 0x80, |
|
| 278 |
+ Patch = 0x81, |
|
| 279 |
+ Pan = 0xC0, |
|
| 280 |
+ Volume = 0xC1, |
|
| 281 |
+ MasterVolume = 0xC2, |
|
| 282 |
+ Priority = 0xC6, |
|
| 283 |
+ NoteWait = 0xC7, |
|
| 284 |
+ Tie = 0xC8, |
|
| 285 |
+ Expression = 0xD5, |
|
| 286 |
+ Tempo = 0xE1, |
|
| 287 |
+ End = 0xFF, |
|
| 288 |
+ |
|
| 289 |
+ Goto = 0x94, |
|
| 290 |
+ Call = 0x95, |
|
| 291 |
+ Return = 0xFD, |
|
| 292 |
+ LoopStart = 0xD4, |
|
| 293 |
+ LoopEnd = 0xFC, |
|
| 294 |
+ |
|
| 295 |
+ Transpose = 0xC3, |
|
| 296 |
+ PitchBend = 0xC4, |
|
| 297 |
+ PitchBendRange = 0xC5, |
|
| 298 |
+ |
|
| 299 |
+ Attack = 0xD0, |
|
| 300 |
+ Decay = 0xD1, |
|
| 301 |
+ Sustain = 0xD2, |
|
| 302 |
+ Release = 0xD3, |
|
| 303 |
+ |
|
| 304 |
+ PortamentoKey = 0xC9, |
|
| 305 |
+ PortamentoFlag = 0xCE, |
|
| 306 |
+ PortamentoTime = 0xCF, |
|
| 307 |
+ SweepPitch = 0xE3, |
|
| 308 |
+ |
|
| 309 |
+ ModulationDepth = 0xCA, |
|
| 310 |
+ ModulationSpeed = 0xCB, |
|
| 311 |
+ ModulationType = 0xCC, |
|
| 312 |
+ ModulationRange = 0xCD, |
|
| 313 |
+ ModulationDelay = 0xE0, |
|
| 314 |
+ |
|
| 315 |
+ Random = 0xA0, |
|
| 316 |
+ PrintVariable = 0xD6, |
|
| 317 |
+ If = 0xA2, |
|
| 318 |
+ FromVariable = 0xA1, |
|
| 319 |
+ SetVariable = 0xB0, |
|
| 320 |
+ AddVariable = 0xB1, |
|
| 321 |
+ SubtractVariable = 0xB2, |
|
| 322 |
+ MultiplyVariable = 0xB3, |
|
| 323 |
+ DivideVariable = 0xB4, |
|
| 324 |
+ ShiftVariable = 0xB5, |
|
| 325 |
+ RandomVariable = 0xB6, |
|
| 326 |
+ CompareEqualTo = 0xB8, |
|
| 327 |
+ CompareGreaterThanOrEqualTo = 0xB9, |
|
| 328 |
+ CompareGreaterThan = 0xBA, |
|
| 329 |
+ CompareLessThanOrEqualTo = 0xBB, |
|
| 330 |
+ CompareLessThan = 0xBC, |
|
| 331 |
+ CompareNotEqualTo = 0xBD, |
|
| 332 |
+ |
|
| 333 |
+ Mute = 0xD7 // Unsupported |
|
| 326 | 334 |
}; |
| 327 | 335 |
|
| 328 |
-static const uint8_t VariableByteCount = 1 << 7; |
|
| 329 |
-static const uint8_t ExtraByteOnNoteOrVarOrCmp = 1 << 6; |
|
| 336 |
+static const std::uint8_t VariableByteCount = 1 << 7; |
|
| 337 |
+static const std::uint8_t ExtraByteOnNoteOrVarOrCmp = 1 << 6; |
|
| 330 | 338 |
|
| 331 |
-static inline uint8_t SseqCommandByteCount(int cmd) |
|
| 339 |
+static inline std::uint8_t SseqCommandByteCount(int cmd) |
|
| 332 | 340 |
{
|
| 333 | 341 |
if (cmd < 0x80) |
| 334 | 342 |
return 1 | VariableByteCount; |
| 335 | 343 |
else |
| 336 |
- switch (cmd) |
|
| 344 |
+ switch (static_cast<SSEQCommand>(cmd)) |
|
| 337 | 345 |
{
|
| 338 |
- case SSEQ_CMD_REST: |
|
| 339 |
- case SSEQ_CMD_PATCH: |
|
| 346 |
+ case SSEQCommand::Rest: |
|
| 347 |
+ case SSEQCommand::Patch: |
|
| 340 | 348 |
return VariableByteCount; |
| 341 | 349 |
|
| 342 |
- case SSEQ_CMD_PAN: |
|
| 343 |
- case SSEQ_CMD_VOL: |
|
| 344 |
- case SSEQ_CMD_MASTERVOL: |
|
| 345 |
- case SSEQ_CMD_PRIO: |
|
| 346 |
- case SSEQ_CMD_NOTEWAIT: |
|
| 347 |
- case SSEQ_CMD_TIE: |
|
| 348 |
- case SSEQ_CMD_EXPR: |
|
| 349 |
- case SSEQ_CMD_LOOPSTART: |
|
| 350 |
- case SSEQ_CMD_TRANSPOSE: |
|
| 351 |
- case SSEQ_CMD_PITCHBEND: |
|
| 352 |
- case SSEQ_CMD_PITCHBENDRANGE: |
|
| 353 |
- case SSEQ_CMD_ATTACK: |
|
| 354 |
- case SSEQ_CMD_DECAY: |
|
| 355 |
- case SSEQ_CMD_SUSTAIN: |
|
| 356 |
- case SSEQ_CMD_RELEASE: |
|
| 357 |
- case SSEQ_CMD_PORTAKEY: |
|
| 358 |
- case SSEQ_CMD_PORTAFLAG: |
|
| 359 |
- case SSEQ_CMD_PORTATIME: |
|
| 360 |
- case SSEQ_CMD_MODDEPTH: |
|
| 361 |
- case SSEQ_CMD_MODSPEED: |
|
| 362 |
- case SSEQ_CMD_MODTYPE: |
|
| 363 |
- case SSEQ_CMD_MODRANGE: |
|
| 364 |
- case SSEQ_CMD_PRINTVAR: |
|
| 365 |
- case SSEQ_CMD_MUTE: |
|
| 350 |
+ case SSEQCommand::Pan: |
|
| 351 |
+ case SSEQCommand::Volume: |
|
| 352 |
+ case SSEQCommand::MasterVolume: |
|
| 353 |
+ case SSEQCommand::Priority: |
|
| 354 |
+ case SSEQCommand::NoteWait: |
|
| 355 |
+ case SSEQCommand::Tie: |
|
| 356 |
+ case SSEQCommand::Expression: |
|
| 357 |
+ case SSEQCommand::LoopStart: |
|
| 358 |
+ case SSEQCommand::Transpose: |
|
| 359 |
+ case SSEQCommand::PitchBend: |
|
| 360 |
+ case SSEQCommand::PitchBendRange: |
|
| 361 |
+ case SSEQCommand::Attack: |
|
| 362 |
+ case SSEQCommand::Decay: |
|
| 363 |
+ case SSEQCommand::Sustain: |
|
| 364 |
+ case SSEQCommand::Release: |
|
| 365 |
+ case SSEQCommand::PortamentoKey: |
|
| 366 |
+ case SSEQCommand::PortamentoFlag: |
|
| 367 |
+ case SSEQCommand::PortamentoTime: |
|
| 368 |
+ case SSEQCommand::ModulationDepth: |
|
| 369 |
+ case SSEQCommand::ModulationSpeed: |
|
| 370 |
+ case SSEQCommand::ModulationType: |
|
| 371 |
+ case SSEQCommand::ModulationRange: |
|
| 372 |
+ case SSEQCommand::PrintVariable: |
|
| 373 |
+ case SSEQCommand::Mute: |
|
| 366 | 374 |
return 1; |
| 367 | 375 |
|
| 368 |
- case SSEQ_CMD_ALLOCTRACK: |
|
| 369 |
- case SSEQ_CMD_TEMPO: |
|
| 370 |
- case SSEQ_CMD_SWEEPPITCH: |
|
| 371 |
- case SSEQ_CMD_MODDELAY: |
|
| 376 |
+ case SSEQCommand::AllocateTrack: |
|
| 377 |
+ case SSEQCommand::Tempo: |
|
| 378 |
+ case SSEQCommand::SweepPitch: |
|
| 379 |
+ case SSEQCommand::ModulationDelay: |
|
| 372 | 380 |
return 2; |
| 373 | 381 |
|
| 374 |
- case SSEQ_CMD_GOTO: |
|
| 375 |
- case SSEQ_CMD_CALL: |
|
| 376 |
- case SSEQ_CMD_SETVAR: |
|
| 377 |
- case SSEQ_CMD_ADDVAR: |
|
| 378 |
- case SSEQ_CMD_SUBVAR: |
|
| 379 |
- case SSEQ_CMD_MULVAR: |
|
| 380 |
- case SSEQ_CMD_DIVVAR: |
|
| 381 |
- case SSEQ_CMD_SHIFTVAR: |
|
| 382 |
- case SSEQ_CMD_RANDVAR: |
|
| 383 |
- case SSEQ_CMD_CMP_EQ: |
|
| 384 |
- case SSEQ_CMD_CMP_GE: |
|
| 385 |
- case SSEQ_CMD_CMP_GT: |
|
| 386 |
- case SSEQ_CMD_CMP_LE: |
|
| 387 |
- case SSEQ_CMD_CMP_LT: |
|
| 388 |
- case SSEQ_CMD_CMP_NE: |
|
| 382 |
+ case SSEQCommand::Goto: |
|
| 383 |
+ case SSEQCommand::Call: |
|
| 384 |
+ case SSEQCommand::SetVariable: |
|
| 385 |
+ case SSEQCommand::AddVariable: |
|
| 386 |
+ case SSEQCommand::SubtractVariable: |
|
| 387 |
+ case SSEQCommand::MultiplyVariable: |
|
| 388 |
+ case SSEQCommand::DivideVariable: |
|
| 389 |
+ case SSEQCommand::ShiftVariable: |
|
| 390 |
+ case SSEQCommand::RandomVariable: |
|
| 391 |
+ case SSEQCommand::CompareEqualTo: |
|
| 392 |
+ case SSEQCommand::CompareGreaterThanOrEqualTo: |
|
| 393 |
+ case SSEQCommand::CompareGreaterThan: |
|
| 394 |
+ case SSEQCommand::CompareLessThanOrEqualTo: |
|
| 395 |
+ case SSEQCommand::CompareLessThan: |
|
| 396 |
+ case SSEQCommand::CompareNotEqualTo: |
|
| 389 | 397 |
return 3; |
| 390 | 398 |
|
| 391 |
- case SSEQ_CMD_OPENTRACK: |
|
| 399 |
+ case SSEQCommand::OpenTrack: |
|
| 392 | 400 |
return 4; |
| 393 | 401 |
|
| 394 |
- case SSEQ_CMD_FROMVAR: |
|
| 402 |
+ case SSEQCommand::FromVariable: |
|
| 395 | 403 |
return 1 | ExtraByteOnNoteOrVarOrCmp; // Technically 2 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed |
| 396 | 404 |
|
| 397 |
- case SSEQ_CMD_RANDOM: |
|
| 405 |
+ case SSEQCommand::Random: |
|
| 398 | 406 |
return 4 | ExtraByteOnNoteOrVarOrCmp; // Technically 5 bytes with an additional 1, leaving 1 off because we will be reading it to determine if the additional byte is needed |
| 399 | 407 |
|
| 400 | 408 |
default: |
| ... | ... |
@@ -410,19 +418,19 @@ static std::uint16_t CalcRandom() |
| 410 | 418 |
return static_cast<std::uint16_t>(RandomU >> 16); |
| 411 | 419 |
} |
| 412 | 420 |
|
| 413 |
-static auto varFuncSet = [](int16_t, int16_t value) { return value; };
|
|
| 414 |
-static auto varFuncAdd = [](int16_t var, int16_t value) -> int16_t { return var + value; };
|
|
| 415 |
-static auto varFuncSub = [](int16_t var, int16_t value) -> int16_t { return var - value; };
|
|
| 416 |
-static auto varFuncMul = [](int16_t var, int16_t value) -> int16_t { return var * value; };
|
|
| 417 |
-static auto varFuncDiv = [](int16_t var, int16_t value) -> int16_t { return var / value; };
|
|
| 418 |
-static auto varFuncShift = [](int16_t var, int16_t value) -> int16_t |
|
| 421 |
+static auto varFuncSet = [](std::int16_t, std::int16_t value) { return value; };
|
|
| 422 |
+static auto varFuncAdd = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var + value; };
|
|
| 423 |
+static auto varFuncSub = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var - value; };
|
|
| 424 |
+static auto varFuncMul = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var * value; };
|
|
| 425 |
+static auto varFuncDiv = [](std::int16_t var, std::int16_t value) -> std::int16_t { return var / value; };
|
|
| 426 |
+static auto varFuncShift = [](std::int16_t var, std::int16_t value) -> std::int16_t |
|
| 419 | 427 |
{
|
| 420 | 428 |
if (value < 0) |
| 421 | 429 |
return var >> -value; |
| 422 | 430 |
else |
| 423 | 431 |
return var << value; |
| 424 | 432 |
}; |
| 425 |
-static auto varFuncRand = [](int16_t, int16_t value) -> int16_t |
|
| 433 |
+static auto varFuncRand = [](std::int16_t, std::int16_t value) -> std::int16_t |
|
| 426 | 434 |
{
|
| 427 | 435 |
if (value < 0) |
| 428 | 436 |
return -(CalcRandom() % (-value + 1)); |
| ... | ... |
@@ -430,51 +438,51 @@ static auto varFuncRand = [](int16_t, int16_t value) -> int16_t |
| 430 | 438 |
return CalcRandom() % (value + 1); |
| 431 | 439 |
}; |
| 432 | 440 |
|
| 433 |
-static inline std::function<int16_t (int16_t, int16_t)> VarFunc(int cmd) |
|
| 441 |
+static inline std::function<std::int16_t (std::int16_t, std::int16_t)> VarFunc(int cmd) |
|
| 434 | 442 |
{
|
| 435 |
- switch (cmd) |
|
| 443 |
+ switch (static_cast<SSEQCommand>(cmd)) |
|
| 436 | 444 |
{
|
| 437 |
- case SSEQ_CMD_SETVAR: |
|
| 445 |
+ case SSEQCommand::SetVariable: |
|
| 438 | 446 |
return varFuncSet; |
| 439 |
- case SSEQ_CMD_ADDVAR: |
|
| 447 |
+ case SSEQCommand::AddVariable: |
|
| 440 | 448 |
return varFuncAdd; |
| 441 |
- case SSEQ_CMD_SUBVAR: |
|
| 449 |
+ case SSEQCommand::SubtractVariable: |
|
| 442 | 450 |
return varFuncSub; |
| 443 |
- case SSEQ_CMD_MULVAR: |
|
| 451 |
+ case SSEQCommand::MultiplyVariable: |
|
| 444 | 452 |
return varFuncMul; |
| 445 |
- case SSEQ_CMD_DIVVAR: |
|
| 453 |
+ case SSEQCommand::DivideVariable: |
|
| 446 | 454 |
return varFuncDiv; |
| 447 |
- case SSEQ_CMD_SHIFTVAR: |
|
| 455 |
+ case SSEQCommand::ShiftVariable: |
|
| 448 | 456 |
return varFuncShift; |
| 449 |
- case SSEQ_CMD_RANDVAR: |
|
| 457 |
+ case SSEQCommand::RandomVariable: |
|
| 450 | 458 |
return varFuncRand; |
| 451 | 459 |
default: |
| 452 | 460 |
return nullptr; |
| 453 | 461 |
} |
| 454 | 462 |
} |
| 455 | 463 |
|
| 456 |
-static auto compareFuncEq = [](int16_t a, int16_t b) { return a == b; };
|
|
| 457 |
-static auto compareFuncGe = [](int16_t a, int16_t b) { return a >= b; };
|
|
| 458 |
-static auto compareFuncGt = [](int16_t a, int16_t b) { return a > b; };
|
|
| 459 |
-static auto compareFuncLe = [](int16_t a, int16_t b) { return a <= b; };
|
|
| 460 |
-static auto compareFuncLt = [](int16_t a, int16_t b) { return a < b; };
|
|
| 461 |
-static auto compareFuncNe = [](int16_t a, int16_t b) { return a != b; };
|
|
| 464 |
+static auto compareFuncEq = [](std::int16_t a, std::int16_t b) { return a == b; };
|
|
| 465 |
+static auto compareFuncGe = [](std::int16_t a, std::int16_t b) { return a >= b; };
|
|
| 466 |
+static auto compareFuncGt = [](std::int16_t a, std::int16_t b) { return a > b; };
|
|
| 467 |
+static auto compareFuncLe = [](std::int16_t a, std::int16_t b) { return a <= b; };
|
|
| 468 |
+static auto compareFuncLt = [](std::int16_t a, std::int16_t b) { return a < b; };
|
|
| 469 |
+static auto compareFuncNe = [](std::int16_t a, std::int16_t b) { return a != b; };
|
|
| 462 | 470 |
|
| 463 |
-static inline std::function<bool (int16_t, int16_t)> CompareFunc(int cmd) |
|
| 471 |
+static inline std::function<bool (std::int16_t, std::int16_t)> CompareFunc(int cmd) |
|
| 464 | 472 |
{
|
| 465 |
- switch (cmd) |
|
| 473 |
+ switch (static_cast<SSEQCommand>(cmd)) |
|
| 466 | 474 |
{
|
| 467 |
- case SSEQ_CMD_CMP_EQ: |
|
| 475 |
+ case SSEQCommand::CompareEqualTo: |
|
| 468 | 476 |
return compareFuncEq; |
| 469 |
- case SSEQ_CMD_CMP_GE: |
|
| 477 |
+ case SSEQCommand::CompareGreaterThanOrEqualTo: |
|
| 470 | 478 |
return compareFuncGe; |
| 471 |
- case SSEQ_CMD_CMP_GT: |
|
| 479 |
+ case SSEQCommand::CompareGreaterThan: |
|
| 472 | 480 |
return compareFuncGt; |
| 473 |
- case SSEQ_CMD_CMP_LE: |
|
| 481 |
+ case SSEQCommand::CompareLessThanOrEqualTo: |
|
| 474 | 482 |
return compareFuncLe; |
| 475 |
- case SSEQ_CMD_CMP_LT: |
|
| 483 |
+ case SSEQCommand::CompareLessThan: |
|
| 476 | 484 |
return compareFuncLt; |
| 477 |
- case SSEQ_CMD_CMP_NE: |
|
| 485 |
+ case SSEQCommand::CompareNotEqualTo: |
|
| 478 | 486 |
return compareFuncNe; |
| 479 | 487 |
default: |
| 480 | 488 |
return nullptr; |
| ... | ... |
@@ -485,10 +493,10 @@ static inline std::function<bool (int16_t, int16_t)> CompareFunc(int cmd) |
| 485 | 493 |
void Track::Run() |
| 486 | 494 |
{
|
| 487 | 495 |
// Indicate "heartbeat" for this track |
| 488 |
- this->updateFlags.set(TUF_LEN); |
|
| 496 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Length)); |
|
| 489 | 497 |
|
| 490 | 498 |
// Exit if the track has already ended |
| 491 |
- if (this->state[TS_END]) |
|
| 499 |
+ if (this->state[ToIntegral(TrackState::End)]) |
|
| 492 | 500 |
return; |
| 493 | 501 |
|
| 494 | 502 |
if (this->wait) |
| ... | ... |
@@ -513,9 +521,9 @@ void Track::Run() |
| 513 | 521 |
int key = cmd + this->transpose; |
| 514 | 522 |
int vel = this->overriding.val(pData, read8, true); |
| 515 | 523 |
int len = this->overriding.val(pData, readvl); |
| 516 |
- if (this->state[TS_NOTEWAIT]) |
|
| 524 |
+ if (this->state[ToIntegral(TrackState::NoteWait)]) |
|
| 517 | 525 |
this->wait = len; |
| 518 |
- if (this->state[TS_TIEBIT]) |
|
| 526 |
+ if (this->state[ToIntegral(TrackState::TieBit)]) |
|
| 519 | 527 |
this->NoteOnTie(key, vel); |
| 520 | 528 |
else |
| 521 | 529 |
this->NoteOn(key, vel, len); |
| ... | ... |
@@ -523,13 +531,13 @@ void Track::Run() |
| 523 | 531 |
else |
| 524 | 532 |
{
|
| 525 | 533 |
int value; |
| 526 |
- switch (cmd) |
|
| 534 |
+ switch (static_cast<SSEQCommand>(cmd)) |
|
| 527 | 535 |
{
|
| 528 | 536 |
//----------------------------------------------------------------- |
| 529 | 537 |
// Main commands |
| 530 | 538 |
//----------------------------------------------------------------- |
| 531 | 539 |
|
| 532 |
- case SSEQ_CMD_OPENTRACK: |
|
| 540 |
+ case SSEQCommand::OpenTrack: |
|
| 533 | 541 |
{
|
| 534 | 542 |
int tNum = read8(pData); |
| 535 | 543 |
auto trackPos = &this->ply->sseq->data[read24(pData)]; |
| ... | ... |
@@ -542,91 +550,91 @@ void Track::Run() |
| 542 | 550 |
break; |
| 543 | 551 |
} |
| 544 | 552 |
|
| 545 |
- case SSEQ_CMD_REST: |
|
| 553 |
+ case SSEQCommand::Rest: |
|
| 546 | 554 |
this->wait = this->overriding.val(pData, readvl); |
| 547 | 555 |
break; |
| 548 | 556 |
|
| 549 |
- case SSEQ_CMD_PATCH: |
|
| 557 |
+ case SSEQCommand::Patch: |
|
| 550 | 558 |
this->patch = this->overriding.val(pData, readvl); |
| 551 | 559 |
break; |
| 552 | 560 |
|
| 553 |
- case SSEQ_CMD_GOTO: |
|
| 561 |
+ case SSEQCommand::Goto: |
|
| 554 | 562 |
*pData = &this->ply->sseq->data[read24(pData)]; |
| 555 | 563 |
break; |
| 556 | 564 |
|
| 557 |
- case SSEQ_CMD_CALL: |
|
| 565 |
+ case SSEQCommand::Call: |
|
| 558 | 566 |
value = read24(pData); |
| 559 | 567 |
if (this->stackPos < FSS_TRACKSTACKSIZE) |
| 560 | 568 |
{
|
| 561 |
- const uint8_t *dest = &this->ply->sseq->data[value]; |
|
| 562 |
- this->stack[this->stackPos++] = StackValue(STACKTYPE_CALL, *pData); |
|
| 569 |
+ const std::uint8_t *dest = &this->ply->sseq->data[value]; |
|
| 570 |
+ this->stack[this->stackPos++] = StackValue(StackType::Call, *pData); |
|
| 563 | 571 |
*pData = dest; |
| 564 | 572 |
} |
| 565 | 573 |
break; |
| 566 | 574 |
|
| 567 |
- case SSEQ_CMD_RET: |
|
| 568 |
- if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_CALL) |
|
| 575 |
+ case SSEQCommand::Return: |
|
| 576 |
+ if (this->stackPos && this->stack[this->stackPos - 1].type == StackType::Call) |
|
| 569 | 577 |
*pData = this->stack[--this->stackPos].dest; |
| 570 | 578 |
break; |
| 571 | 579 |
|
| 572 |
- case SSEQ_CMD_PAN: |
|
| 580 |
+ case SSEQCommand::Pan: |
|
| 573 | 581 |
this->pan = this->overriding.val(pData, read8) - 64; |
| 574 |
- this->updateFlags.set(TUF_PAN); |
|
| 582 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Pan)); |
|
| 575 | 583 |
break; |
| 576 | 584 |
|
| 577 |
- case SSEQ_CMD_VOL: |
|
| 585 |
+ case SSEQCommand::Volume: |
|
| 578 | 586 |
this->vol = this->overriding.val(pData, read8); |
| 579 |
- this->updateFlags.set(TUF_VOL); |
|
| 587 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
|
| 580 | 588 |
break; |
| 581 | 589 |
|
| 582 |
- case SSEQ_CMD_MASTERVOL: |
|
| 590 |
+ case SSEQCommand::MasterVolume: |
|
| 583 | 591 |
this->ply->masterVol = Cnv_Sust(this->overriding.val(pData, read8)); |
| 584 |
- for (uint8_t i = 0; i < this->ply->nTracks; ++i) |
|
| 585 |
- this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(TUF_VOL); |
|
| 592 |
+ for (std::uint8_t i = 0; i < this->ply->nTracks; ++i) |
|
| 593 |
+ this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
|
| 586 | 594 |
break; |
| 587 | 595 |
|
| 588 |
- case SSEQ_CMD_PRIO: |
|
| 596 |
+ case SSEQCommand::Priority: |
|
| 589 | 597 |
this->prio = this->ply->prio + read8(pData); |
| 590 | 598 |
// Update here? |
| 591 | 599 |
break; |
| 592 | 600 |
|
| 593 |
- case SSEQ_CMD_NOTEWAIT: |
|
| 594 |
- this->state.set(TS_NOTEWAIT, !!read8(pData)); |
|
| 601 |
+ case SSEQCommand::NoteWait: |
|
| 602 |
+ this->state.set(ToIntegral(TrackState::NoteWait), !!read8(pData)); |
|
| 595 | 603 |
break; |
| 596 | 604 |
|
| 597 |
- case SSEQ_CMD_TIE: |
|
| 598 |
- this->state.set(TS_TIEBIT, !!read8(pData)); |
|
| 605 |
+ case SSEQCommand::Tie: |
|
| 606 |
+ this->state.set(ToIntegral(TrackState::TieBit), !!read8(pData)); |
|
| 599 | 607 |
this->ReleaseAllNotes(); |
| 600 | 608 |
break; |
| 601 | 609 |
|
| 602 |
- case SSEQ_CMD_EXPR: |
|
| 610 |
+ case SSEQCommand::Expression: |
|
| 603 | 611 |
this->expr = this->overriding.val(pData, read8); |
| 604 |
- this->updateFlags.set(TUF_VOL); |
|
| 612 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
|
| 605 | 613 |
break; |
| 606 | 614 |
|
| 607 |
- case SSEQ_CMD_TEMPO: |
|
| 615 |
+ case SSEQCommand::Tempo: |
|
| 608 | 616 |
this->ply->tempo = read16(pData); |
| 609 | 617 |
break; |
| 610 | 618 |
|
| 611 |
- case SSEQ_CMD_END: |
|
| 612 |
- this->state.set(TS_END); |
|
| 619 |
+ case SSEQCommand::End: |
|
| 620 |
+ this->state.set(ToIntegral(TrackState::End)); |
|
| 613 | 621 |
return; |
| 614 | 622 |
|
| 615 |
- case SSEQ_CMD_LOOPSTART: |
|
| 623 |
+ case SSEQCommand::LoopStart: |
|
| 616 | 624 |
value = this->overriding.val(pData, read8); |
| 617 | 625 |
if (this->stackPos < FSS_TRACKSTACKSIZE) |
| 618 | 626 |
{
|
| 619 | 627 |
this->loopCount[this->stackPos] = value; |
| 620 |
- this->stack[this->stackPos++] = StackValue(STACKTYPE_LOOP, *pData); |
|
| 628 |
+ this->stack[this->stackPos++] = StackValue(StackType::Loop, *pData); |
|
| 621 | 629 |
} |
| 622 | 630 |
break; |
| 623 | 631 |
|
| 624 |
- case SSEQ_CMD_LOOPEND: |
|
| 625 |
- if (this->stackPos && this->stack[this->stackPos - 1].type == STACKTYPE_LOOP) |
|
| 632 |
+ case SSEQCommand::LoopEnd: |
|
| 633 |
+ if (this->stackPos && this->stack[this->stackPos - 1].type == StackType::Loop) |
|
| 626 | 634 |
{
|
| 627 |
- const uint8_t *rPos = this->stack[this->stackPos - 1].dest; |
|
| 628 |
- uint8_t &nR = this->loopCount[this->stackPos - 1]; |
|
| 629 |
- uint8_t prevR = nR; |
|
| 635 |
+ const std::uint8_t *rPos = this->stack[this->stackPos - 1].dest; |
|
| 636 |
+ std::uint8_t &nR = this->loopCount[this->stackPos - 1]; |
|
| 637 |
+ std::uint8_t prevR = nR; |
|
| 630 | 638 |
if (!prevR || --nR) |
| 631 | 639 |
*pData = rPos; |
| 632 | 640 |
else |
| ... | ... |
@@ -638,37 +646,37 @@ void Track::Run() |
| 638 | 646 |
// Tuning commands |
| 639 | 647 |
//----------------------------------------------------------------- |
| 640 | 648 |
|
| 641 |
- case SSEQ_CMD_TRANSPOSE: |
|
| 649 |
+ case SSEQCommand::Transpose: |
|
| 642 | 650 |
this->transpose = this->overriding.val(pData, read8); |
| 643 | 651 |
break; |
| 644 | 652 |
|
| 645 |
- case SSEQ_CMD_PITCHBEND: |
|
| 653 |
+ case SSEQCommand::PitchBend: |
|
| 646 | 654 |
this->pitchBend = this->overriding.val(pData, read8); |
| 647 |
- this->updateFlags.set(TUF_TIMER); |
|
| 655 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Timer)); |
|
| 648 | 656 |
break; |
| 649 | 657 |
|
| 650 |
- case SSEQ_CMD_PITCHBENDRANGE: |
|
| 658 |
+ case SSEQCommand::PitchBendRange: |
|
| 651 | 659 |
this->pitchBendRange = read8(pData); |
| 652 |
- this->updateFlags.set(TUF_TIMER); |
|
| 660 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Timer)); |
|
| 653 | 661 |
break; |
| 654 | 662 |
|
| 655 | 663 |
//----------------------------------------------------------------- |
| 656 | 664 |
// Envelope-related commands |
| 657 | 665 |
//----------------------------------------------------------------- |
| 658 | 666 |
|
| 659 |
- case SSEQ_CMD_ATTACK: |
|
| 667 |
+ case SSEQCommand::Attack: |
|
| 660 | 668 |
this->a = this->overriding.val(pData, read8); |
| 661 | 669 |
break; |
| 662 | 670 |
|
| 663 |
- case SSEQ_CMD_DECAY: |
|
| 671 |
+ case SSEQCommand::Decay: |
|
| 664 | 672 |
this->d = this->overriding.val(pData, read8); |
| 665 | 673 |
break; |
| 666 | 674 |
|
| 667 |
- case SSEQ_CMD_SUSTAIN: |
|
| 675 |
+ case SSEQCommand::Sustain: |
|
| 668 | 676 |
this->s = this->overriding.val(pData, read8); |
| 669 | 677 |
break; |
| 670 | 678 |
|
| 671 |
- case SSEQ_CMD_RELEASE: |
|
| 679 |
+ case SSEQCommand::Release: |
|
| 672 | 680 |
this->r = this->overriding.val(pData, read8); |
| 673 | 681 |
break; |
| 674 | 682 |
|
| ... | ... |
@@ -676,26 +684,26 @@ void Track::Run() |
| 676 | 684 |
// Portamento-related commands |
| 677 | 685 |
//----------------------------------------------------------------- |
| 678 | 686 |
|
| 679 |
- case SSEQ_CMD_PORTAKEY: |
|
| 687 |
+ case SSEQCommand::PortamentoKey: |
|
| 680 | 688 |
this->portaKey = read8(pData) + this->transpose; |
| 681 |
- this->state.set(TS_PORTABIT); |
|
| 689 |
+ this->state.set(ToIntegral(TrackState::PortamentoBit)); |
|
| 682 | 690 |
// Update here? |
| 683 | 691 |
break; |
| 684 | 692 |
|
| 685 |
- case SSEQ_CMD_PORTAFLAG: |
|
| 686 |
- this->state.set(TS_PORTABIT, !!read8(pData)); |
|
| 693 |
+ case SSEQCommand::PortamentoFlag: |
|
| 694 |
+ this->state.set(ToIntegral(TrackState::PortamentoBit), !!read8(pData)); |
|
| 687 | 695 |
// Update here? |
| 688 | 696 |
break; |
| 689 | 697 |
|
| 690 |
- case SSEQ_CMD_PORTATIME: |
|
| 698 |
+ case SSEQCommand::PortamentoTime: |
|
| 691 | 699 |
this->portaTime = this->overriding.val(pData, read8); |
| 692 |
- this->state.set(TS_PORTABIT); |
|
| 700 |
+ this->state.set(ToIntegral(TrackState::PortamentoBit)); |
|
| 693 | 701 |
// Update here? |
| 694 | 702 |
break; |
| 695 | 703 |
|
| 696 |
- case SSEQ_CMD_SWEEPPITCH: |
|
| 704 |
+ case SSEQCommand::SweepPitch: |
|
| 697 | 705 |
this->sweepPitch = this->overriding.val(pData, read16); |
| 698 |
- this->state.set(TS_PORTABIT); |
|
| 706 |
+ this->state.set(ToIntegral(TrackState::PortamentoBit)); |
|
| 699 | 707 |
// Update here? |
| 700 | 708 |
break; |
| 701 | 709 |
|
| ... | ... |
@@ -703,43 +711,43 @@ void Track::Run() |
| 703 | 711 |
// Modulation-related commands |
| 704 | 712 |
//----------------------------------------------------------------- |
| 705 | 713 |
|
| 706 |
- case SSEQ_CMD_MODDEPTH: |
|
| 714 |
+ case SSEQCommand::ModulationDepth: |
|
| 707 | 715 |
this->modDepth = this->overriding.val(pData, read8); |
| 708 |
- this->updateFlags.set(TUF_MOD); |
|
| 716 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
|
| 709 | 717 |
break; |
| 710 | 718 |
|
| 711 |
- case SSEQ_CMD_MODSPEED: |
|
| 719 |
+ case SSEQCommand::ModulationSpeed: |
|
| 712 | 720 |
this->modSpeed = this->overriding.val(pData, read8); |
| 713 |
- this->updateFlags.set(TUF_MOD); |
|
| 721 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
|
| 714 | 722 |
break; |
| 715 | 723 |
|
| 716 |
- case SSEQ_CMD_MODTYPE: |
|
| 724 |
+ case SSEQCommand::ModulationType: |
|
| 717 | 725 |
this->modType = read8(pData); |
| 718 |
- this->updateFlags.set(TUF_MOD); |
|
| 726 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
|
| 719 | 727 |
break; |
| 720 | 728 |
|
| 721 |
- case SSEQ_CMD_MODRANGE: |
|
| 729 |
+ case SSEQCommand::ModulationRange: |
|
| 722 | 730 |
this->modRange = read8(pData); |
| 723 |
- this->updateFlags.set(TUF_MOD); |
|
| 731 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
|
| 724 | 732 |
break; |
| 725 | 733 |
|
| 726 |
- case SSEQ_CMD_MODDELAY: |
|
| 734 |
+ case SSEQCommand::ModulationDelay: |
|
| 727 | 735 |
this->modDelay = this->overriding.val(pData, read16); |
| 728 |
- this->updateFlags.set(TUF_MOD); |
|
| 736 |
+ this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
|
| 729 | 737 |
break; |
| 730 | 738 |
|
| 731 | 739 |
//----------------------------------------------------------------- |
| 732 | 740 |
// Randomness-related commands |
| 733 | 741 |
//----------------------------------------------------------------- |
| 734 | 742 |
|
| 735 |
- case SSEQ_CMD_RANDOM: |
|
| 743 |
+ case SSEQCommand::Random: |
|
| 736 | 744 |
{
|
| 737 | 745 |
this->overriding() = true; |
| 738 | 746 |
this->overriding.cmd = read8(pData); |
| 739 |
- if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80) |
|
| 747 |
+ if ((this->overriding.cmd >= ToIntegral(SSEQCommand::SetVariable) && this->overriding.cmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || this->overriding.cmd < 0x80) |
|
| 740 | 748 |
this->overriding.extraValue = read8(pData); |
| 741 |
- int16_t minVal = read16(pData); |
|
| 742 |
- int16_t maxVal = read16(pData); |
|
| 749 |
+ std::int16_t minVal = read16(pData); |
|
| 750 |
+ std::int16_t maxVal = read16(pData); |
|
| 743 | 751 |
this->overriding.value = (CalcRandom() % (maxVal - minVal + 1)) + minVal; |
| 744 | 752 |
break; |
| 745 | 753 |
} |
| ... | ... |
@@ -748,25 +756,25 @@ void Track::Run() |
| 748 | 756 |
// Variable-related commands |
| 749 | 757 |
//----------------------------------------------------------------- |
| 750 | 758 |
|
| 751 |
- case SSEQ_CMD_FROMVAR: |
|
| 759 |
+ case SSEQCommand::FromVariable: |
|
| 752 | 760 |
this->overriding() = true; |
| 753 | 761 |
this->overriding.cmd = read8(pData); |
| 754 |
- if ((this->overriding.cmd >= SSEQ_CMD_SETVAR && this->overriding.cmd <= SSEQ_CMD_CMP_NE) || this->overriding.cmd < 0x80) |
|
| 762 |
+ if ((this->overriding.cmd >= ToIntegral(SSEQCommand::SetVariable) && this->overriding.cmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || this->overriding.cmd < 0x80) |
|
| 755 | 763 |
this->overriding.extraValue = read8(pData); |
| 756 | 764 |
this->overriding.value = this->ply->variables[read8(pData)]; |
| 757 | 765 |
break; |
| 758 | 766 |
|
| 759 |
- case SSEQ_CMD_SETVAR: |
|
| 760 |
- case SSEQ_CMD_ADDVAR: |
|
| 761 |
- case SSEQ_CMD_SUBVAR: |
|
| 762 |
- case SSEQ_CMD_MULVAR: |
|
| 763 |
- case SSEQ_CMD_DIVVAR: |
|
| 764 |
- case SSEQ_CMD_SHIFTVAR: |
|
| 765 |
- case SSEQ_CMD_RANDVAR: |
|
| 767 |
+ case SSEQCommand::SetVariable: |
|
| 768 |
+ case SSEQCommand::AddVariable: |
|
| 769 |
+ case SSEQCommand::SubtractVariable: |
|
| 770 |
+ case SSEQCommand::MultiplyVariable: |
|
| 771 |
+ case SSEQCommand::DivideVariable: |
|
| 772 |
+ case SSEQCommand::ShiftVariable: |
|
| 773 |
+ case SSEQCommand::RandomVariable: |
|
| 766 | 774 |
{
|
| 767 |
- int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 775 |
+ std::int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 768 | 776 |
value = this->overriding.val(pData, read16); |
| 769 |
- if (cmd == SSEQ_CMD_DIVVAR && !value) // Division by 0, skip it to prevent crashing |
|
| 777 |
+ if (cmd == ToIntegral(SSEQCommand::DivideVariable) && !value) // Division by 0, skip it to prevent crashing |
|
| 770 | 778 |
break; |
| 771 | 779 |
this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], value); |
| 772 | 780 |
break; |
| ... | ... |
@@ -776,31 +784,31 @@ void Track::Run() |
| 776 | 784 |
// Conditional-related commands |
| 777 | 785 |
//----------------------------------------------------------------- |
| 778 | 786 |
|
| 779 |
- case SSEQ_CMD_CMP_EQ: |
|
| 780 |
- case SSEQ_CMD_CMP_GE: |
|
| 781 |
- case SSEQ_CMD_CMP_GT: |
|
| 782 |
- case SSEQ_CMD_CMP_LE: |
|
| 783 |
- case SSEQ_CMD_CMP_LT: |
|
| 784 |
- case SSEQ_CMD_CMP_NE: |
|
| 787 |
+ case SSEQCommand::CompareEqualTo: |
|
| 788 |
+ case SSEQCommand::CompareGreaterThanOrEqualTo: |
|
| 789 |
+ case SSEQCommand::CompareGreaterThan: |
|
| 790 |
+ case SSEQCommand::CompareLessThanOrEqualTo: |
|
| 791 |
+ case SSEQCommand::CompareLessThan: |
|
| 792 |
+ case SSEQCommand::CompareNotEqualTo: |
|
| 785 | 793 |
{
|
| 786 |
- int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 794 |
+ std::int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 787 | 795 |
value = this->overriding.val(pData, read16); |
| 788 | 796 |
this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], value); |
| 789 | 797 |
break; |
| 790 | 798 |
} |
| 791 | 799 |
|
| 792 |
- case SSEQ_CMD_IF: |
|
| 800 |
+ case SSEQCommand::If: |
|
| 793 | 801 |
if (!this->lastComparisonResult) |
| 794 | 802 |
{
|
| 795 | 803 |
int nextCmd = read8(pData); |
| 796 |
- uint8_t cmdBytes = SseqCommandByteCount(nextCmd); |
|
| 804 |
+ std::uint8_t cmdBytes = SseqCommandByteCount(nextCmd); |
|
| 797 | 805 |
bool variableBytes = !!(cmdBytes & VariableByteCount); |
| 798 | 806 |
bool extraByte = !!(cmdBytes & ExtraByteOnNoteOrVarOrCmp); |
| 799 | 807 |
cmdBytes &= ~(VariableByteCount | ExtraByteOnNoteOrVarOrCmp); |
| 800 | 808 |
if (extraByte) |
| 801 | 809 |
{
|
| 802 | 810 |
int extraCmd = read8(pData); |
| 803 |
- if ((extraCmd >= SSEQ_CMD_SETVAR && extraCmd <= SSEQ_CMD_CMP_NE) || extraCmd < 0x80) |
|
| 811 |
+ if ((extraCmd >= ToIntegral(SSEQCommand::SetVariable) && extraCmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || extraCmd < 0x80) |
|
| 804 | 812 |
++cmdBytes; |
| 805 | 813 |
} |
| 806 | 814 |
*pData += cmdBytes; |
| ... | ... |
@@ -814,7 +822,7 @@ void Track::Run() |
| 814 | 822 |
} |
| 815 | 823 |
} |
| 816 | 824 |
|
| 817 |
- if (cmd != SSEQ_CMD_RANDOM && cmd != SSEQ_CMD_FROMVAR) |
|
| 825 |
+ if (cmd != ToIntegral(SSEQCommand::Random) && cmd != ToIntegral(SSEQCommand::FromVariable)) |
|
| 818 | 826 |
this->overriding() = false; |
| 819 | 827 |
} |
| 820 | 828 |
} |
| ... | ... |
@@ -9,25 +9,27 @@ |
| 9 | 9 |
|
| 10 | 10 |
#pragma once |
| 11 | 11 |
|
| 12 |
-#include <functional> |
|
| 13 | 12 |
#include <bitset> |
| 13 |
+#include <functional> |
|
| 14 |
+#include <cstdint> |
|
| 15 |
+#include "common.h" |
|
| 14 | 16 |
#include "consts.h" |
| 15 | 17 |
|
| 16 | 18 |
struct Player; |
| 17 | 19 |
|
| 18 |
-enum StackType |
|
| 20 |
+enum class StackType |
|
| 19 | 21 |
{
|
| 20 |
- STACKTYPE_CALL, |
|
| 21 |
- STACKTYPE_LOOP |
|
| 22 |
+ Call, |
|
| 23 |
+ Loop |
|
| 22 | 24 |
}; |
| 23 | 25 |
|
| 24 | 26 |
struct StackValue |
| 25 | 27 |
{
|
| 26 | 28 |
StackType type; |
| 27 |
- const uint8_t *dest; |
|
| 29 |
+ const std::uint8_t *dest; |
|
| 28 | 30 |
|
| 29 |
- StackValue() : type(STACKTYPE_CALL), dest(nullptr) { }
|
|
| 30 |
- StackValue(StackType newType, const uint8_t *newDest) : type(newType), dest(newDest) { }
|
|
| 31 |
+ StackValue() : type(StackType::Call), dest(nullptr) { }
|
|
| 32 |
+ StackValue(StackType newType, const std::uint8_t *newDest) : type(newType), dest(newDest) { }
|
|
| 31 | 33 |
}; |
| 32 | 34 |
|
| 33 | 35 |
struct Override |
| ... | ... |
@@ -40,7 +42,7 @@ struct Override |
| 40 | 42 |
Override() : overriding(false), cmd(0), value(0), extraValue(0) { }
|
| 41 | 43 |
bool operator()() const { return this->overriding; }
|
| 42 | 44 |
bool &operator()() { return this->overriding; }
|
| 43 |
- int val(const uint8_t **pData, std::function<int (const uint8_t **)> reader, bool returnExtra = false) |
|
| 45 |
+ int val(const std::uint8_t **pData, std::function<int (const std::uint8_t **)> reader, bool returnExtra = false) |
|
| 44 | 46 |
{
|
| 45 | 47 |
if (this->overriding) |
| 46 | 48 |
return returnExtra ? this->extraValue : this->value; |
| ... | ... |
@@ -51,40 +53,40 @@ struct Override |
| 51 | 53 |
|
| 52 | 54 |
struct Track |
| 53 | 55 |
{
|
| 54 |
- int8_t trackId; |
|
| 56 |
+ std::int8_t trackId; |
|
| 55 | 57 |
|
| 56 |
- std::bitset<TS_BITS> state; |
|
| 57 |
- uint8_t num, prio; |
|
| 58 |
+ std::bitset<ToIntegral(TrackState::Bits)> state; |
|
| 59 |
+ std::uint8_t num, prio; |
|
| 58 | 60 |
Player *ply; |
| 59 | 61 |
|
| 60 |
- const uint8_t *startPos; |
|
| 61 |
- const uint8_t *pos; |
|
| 62 |
+ const std::uint8_t *startPos; |
|
| 63 |
+ const std::uint8_t *pos; |
|
| 62 | 64 |
StackValue stack[FSS_TRACKSTACKSIZE]; |
| 63 |
- uint8_t stackPos; |
|
| 64 |
- uint8_t loopCount[FSS_TRACKSTACKSIZE]; |
|
| 65 |
+ std::uint8_t stackPos; |
|
| 66 |
+ std::uint8_t loopCount[FSS_TRACKSTACKSIZE]; |
|
| 65 | 67 |
Override overriding; |
| 66 | 68 |
bool lastComparisonResult; |
| 67 | 69 |
|
| 68 | 70 |
int wait; |
| 69 |
- uint16_t patch; |
|
| 70 |
- uint8_t portaKey, portaTime; |
|
| 71 |
- int16_t sweepPitch; |
|
| 72 |
- uint8_t vol, expr; |
|
| 73 |
- int8_t pan; // -64..63 |
|
| 74 |
- uint8_t pitchBendRange; |
|
| 75 |
- int8_t pitchBend; |
|
| 76 |
- int8_t transpose; |
|
| 71 |
+ std::uint16_t patch; |
|
| 72 |
+ std::uint8_t portaKey, portaTime; |
|
| 73 |
+ std::int16_t sweepPitch; |
|
| 74 |
+ std::uint8_t vol, expr; |
|
| 75 |
+ std::int8_t pan; // -64..63 |
|
| 76 |
+ std::uint8_t pitchBendRange; |
|
| 77 |
+ std::int8_t pitchBend; |
|
| 78 |
+ std::int8_t transpose; |
|
| 77 | 79 |
|
| 78 |
- uint8_t a, d, s, r; |
|
| 80 |
+ std::uint8_t a, d, s, r; |
|
| 79 | 81 |
|
| 80 |
- uint8_t modType, modSpeed, modDepth, modRange; |
|
| 81 |
- uint16_t modDelay; |
|
| 82 |
+ std::uint8_t modType, modSpeed, modDepth, modRange; |
|
| 83 |
+ std::uint16_t modDelay; |
|
| 82 | 84 |
|
| 83 |
- std::bitset<TUF_BITS> updateFlags; |
|
| 85 |
+ std::bitset<ToIntegral(TrackUpdateFlag::Bits)> updateFlags; |
|
| 84 | 86 |
|
| 85 | 87 |
Track(); |
| 86 | 88 |
|
| 87 |
- void Init(uint8_t handle, Player *ply, const uint8_t *pos, int n); |
|
| 89 |
+ void Init(std::uint8_t handle, Player *ply, const std::uint8_t *pos, int n); |
|
| 88 | 90 |
void Zero(); |
| 89 | 91 |
void ClearState(); |
| 90 | 92 |
void Free(); |
| ... | ... |
@@ -9,9 +9,12 @@ |
| 9 | 9 |
|
| 10 | 10 |
#pragma once |
| 11 | 11 |
|
| 12 |
+#include <algorithm> |
|
| 12 | 13 |
#include <string> |
| 14 |
+#include <type_traits> |
|
| 13 | 15 |
#include <vector> |
| 14 | 16 |
#include <cstring> |
| 17 |
+#include <cstddef> |
|
| 15 | 18 |
#include <cstdint> |
| 16 | 19 |
|
| 17 | 20 |
/* |
| ... | ... |
@@ -19,8 +22,8 @@ |
| 19 | 22 |
*/ |
| 20 | 23 |
struct PseudoFile |
| 21 | 24 |
{
|
| 22 |
- std::vector<uint8_t> *data; |
|
| 23 |
- uint32_t pos; |
|
| 25 |
+ std::vector<std::uint8_t> *data; |
|
| 26 |
+ std::uint32_t pos; |
|
| 24 | 27 |
|
| 25 | 28 |
PseudoFile() : data(nullptr), pos(0) |
| 26 | 29 |
{
|
| ... | ... |
@@ -29,18 +32,18 @@ struct PseudoFile |
| 29 | 32 |
template<typename T> T ReadLE() |
| 30 | 33 |
{
|
| 31 | 34 |
T finalVal = 0; |
| 32 |
- for (size_t i = 0; i < sizeof(T); ++i) |
|
| 35 |
+ for (std::size_t i = 0; i < sizeof(T); ++i) |
|
| 33 | 36 |
finalVal |= (*this->data)[this->pos++] << (i * 8); |
| 34 | 37 |
return finalVal; |
| 35 | 38 |
} |
| 36 | 39 |
|
| 37 |
- template<typename T, size_t N> void ReadLE(T (&arr)[N]) |
|
| 40 |
+ template<typename T, std::size_t N> void ReadLE(T (&arr)[N]) |
|
| 38 | 41 |
{
|
| 39 |
- for (size_t i = 0; i < N; ++i) |
|
| 42 |
+ for (std::size_t i = 0; i < N; ++i) |
|
| 40 | 43 |
arr[i] = this->ReadLE<T>(); |
| 41 | 44 |
} |
| 42 | 45 |
|
| 43 |
- template<size_t N> void ReadLE(uint8_t arr[N]) |
|
| 46 |
+ template<std::size_t N> void ReadLE(std::uint8_t arr[N]) |
|
| 44 | 47 |
{
|
| 45 | 48 |
std::copy_n(&(*this->data)[this->pos], N, &arr[0]); |
| 46 | 49 |
this->pos += N; |
| ... | ... |
@@ -48,11 +51,11 @@ struct PseudoFile |
| 48 | 51 |
|
| 49 | 52 |
template<typename T> void ReadLE(std::vector<T> &arr) |
| 50 | 53 |
{
|
| 51 |
- for (size_t i = 0, len = arr.size(); i < len; ++i) |
|
| 54 |
+ for (std::size_t i = 0, len = arr.size(); i < len; ++i) |
|
| 52 | 55 |
arr[i] = this->ReadLE<T>(); |
| 53 | 56 |
} |
| 54 | 57 |
|
| 55 |
- void ReadLE(std::vector<uint8_t> &arr) |
|
| 58 |
+ void ReadLE(std::vector<std::uint8_t> &arr) |
|
| 56 | 59 |
{
|
| 57 | 60 |
std::copy_n(&(*this->data)[this->pos], arr.size(), &arr[0]); |
| 58 | 61 |
this->pos += arr.size(); |
| ... | ... |
@@ -64,7 +67,7 @@ struct PseudoFile |
| 64 | 67 |
std::string str; |
| 65 | 68 |
do |
| 66 | 69 |
{
|
| 67 |
- chr = static_cast<char>(this->ReadLE<uint8_t>()); |
|
| 70 |
+ chr = static_cast<char>(this->ReadLE<std::uint8_t>()); |
|
| 68 | 71 |
if (chr) |
| 69 | 72 |
str += chr; |
| 70 | 73 |
} while (chr); |
| ... | ... |
@@ -80,10 +83,10 @@ struct PseudoFile |
| 80 | 83 |
* as little-endian formating. |
| 81 | 84 |
*/ |
| 82 | 85 |
|
| 83 |
-template<typename T> inline T ReadLE(const uint8_t *arr) |
|
| 86 |
+template<typename T> inline T ReadLE(const std::uint8_t *arr) |
|
| 84 | 87 |
{
|
| 85 | 88 |
T finalVal = 0; |
| 86 |
- for (size_t i = 0; i < sizeof(T); ++i) |
|
| 89 |
+ for (std::size_t i = 0; i < sizeof(T); ++i) |
|
| 87 | 90 |
finalVal |= arr[i] << (i * 8); |
| 88 | 91 |
return finalVal; |
| 89 | 92 |
} |
| ... | ... |
@@ -97,10 +100,10 @@ template<typename T> inline T ReadLE(const uint8_t *arr) |
| 97 | 100 |
template<typename T> inline std::string NumToHexString(const T &num) |
| 98 | 101 |
{
|
| 99 | 102 |
std::string hex; |
| 100 |
- uint8_t len = sizeof(T) * 2; |
|
| 101 |
- for (uint8_t i = 0; i < len; ++i) |
|
| 103 |
+ std::uint8_t len = sizeof(T) * 2; |
|
| 104 |
+ for (std::uint8_t i = 0; i < len; ++i) |
|
| 102 | 105 |
{
|
| 103 |
- uint8_t tmp = (num >> (i * 4)) & 0xF; |
|
| 106 |
+ std::uint8_t tmp = (num >> (i * 4)) & 0xF; |
|
| 104 | 107 |
hex = static_cast<char>(tmp < 10 ? tmp + '0' : tmp - 10 + 'a') + hex; |
| 105 | 108 |
} |
| 106 | 109 |
return "0x" + hex; |
| ... | ... |
@@ -120,7 +123,13 @@ inline constexpr int REC_GROUP = 5; |
| 120 | 123 |
inline constexpr int REC_PLAYER2 = 6; |
| 121 | 124 |
inline constexpr int REC_STRM = 7; |
| 122 | 125 |
|
| 123 |
-template<size_t N> inline bool VerifyHeader(int8_t (&arr)[N], const std::string &header) |
|
| 126 |
+// Comes from https://stackoverflow.com/a/14589519 |
|
| 127 |
+template<typename T> inline constexpr auto ToIntegral(const T &e) -> typename std::underlying_type_t<T> |
|
| 128 |
+{
|
|
| 129 |
+ return static_cast<std::underlying_type_t<T>>(e); |
|
| 130 |
+} |
|
| 131 |
+ |
|
| 132 |
+template<std::size_t N> inline bool VerifyHeader(std::int8_t (&arr)[N], const std::string &header) |
|
| 124 | 133 |
{
|
| 125 | 134 |
std::string arrHeader = std::string(&arr[0], &arr[N]); |
| 126 | 135 |
return arrHeader == header; |
| ... | ... |
@@ -131,7 +140,7 @@ template<size_t N> inline bool VerifyHeader(int8_t (&arr)[N], const std::string |
| 131 | 140 |
*/ |
| 132 | 141 |
inline int Cnv_Attack(int attk) |
| 133 | 142 |
{
|
| 134 |
- static const uint8_t lut[] = |
|
| 143 |
+ static const std::uint8_t lut[] = |
|
| 135 | 144 |
{
|
| 136 | 145 |
0x00, 0x01, 0x05, 0x0E, 0x1A, 0x26, 0x33, 0x3F, 0x49, 0x54, |
| 137 | 146 |
0x5C, 0x64, 0x6D, 0x74, 0x7B, 0x7F, 0x84, 0x89, 0x8F |
| ... | ... |
@@ -158,7 +167,7 @@ inline int Cnv_Fall(int fall) |
| 158 | 167 |
|
| 159 | 168 |
inline int Cnv_Scale(int scale) |
| 160 | 169 |
{
|
| 161 |
- static const int16_t lut[] = |
|
| 170 |
+ static const std::int16_t lut[] = |
|
| 162 | 171 |
{
|
| 163 | 172 |
-32768, -421, -361, -325, -300, -281, -265, -252, |
| 164 | 173 |
-240, -230, -221, -212, -205, -198, -192, -186, |
| ... | ... |
@@ -185,7 +194,7 @@ inline int Cnv_Scale(int scale) |
| 185 | 194 |
|
| 186 | 195 |
inline int Cnv_Sust(int sust) |
| 187 | 196 |
{
|
| 188 |
- static const int16_t lut[] = |
|
| 197 |
+ static const std::int16_t lut[] = |
|
| 189 | 198 |
{
|
| 190 | 199 |
-32768, -722, -721, -651, -601, -562, -530, -503, |
| 191 | 200 |
-480, -460, -442, -425, -410, -396, -383, -371, |
| ... | ... |
@@ -212,12 +221,12 @@ inline int Cnv_Sust(int sust) |
| 212 | 221 |
|
| 213 | 222 |
inline int Cnv_Sine(int arg) |
| 214 | 223 |
{
|
| 215 |
- static const int8_t lut[] = |
|
| 224 |
+ static const std::int8_t lut[] = |
|
| 216 | 225 |
{
|
| 217 | 226 |
0, 6, 12, 19, 25, 31, 37, 43, 49, 54, 60, 65, 71, 76, 81, 85, 90, 94, |
| 218 | 227 |
98, 102, 106, 109, 112, 115, 117, 120, 122, 123, 125, 126, 126, 127, 127 |
| 219 | 228 |
}; |
| 220 |
- static const int lut_size = sizeof(lut) / sizeof(int8_t); |
|
| 229 |
+ static const int lut_size = sizeof(lut) / sizeof(std::int8_t); |
|
| 221 | 230 |
|
| 222 | 231 |
if (arg < lut_size) |
| 223 | 232 |
return lut[arg]; |
| ... | ... |
@@ -229,7 +238,7 @@ inline int Cnv_Sine(int arg) |
| 229 | 238 |
return -lut[4 * lut_size - arg]; |
| 230 | 239 |
} |
| 231 | 240 |
|
| 232 |
-inline int read8(const uint8_t **ppData) |
|
| 241 |
+inline int read8(const std::uint8_t **ppData) |
|
| 233 | 242 |
{
|
| 234 | 243 |
auto pData = *ppData; |
| 235 | 244 |
int x = *pData; |
| ... | ... |
@@ -237,14 +246,14 @@ inline int read8(const uint8_t **ppData) |
| 237 | 246 |
return x; |
| 238 | 247 |
} |
| 239 | 248 |
|
| 240 |
-inline int read16(const uint8_t **ppData) |
|
| 249 |
+inline int read16(const std::uint8_t **ppData) |
|
| 241 | 250 |
{
|
| 242 | 251 |
int x = read8(ppData); |
| 243 | 252 |
x |= read8(ppData) << 8; |
| 244 | 253 |
return x; |
| 245 | 254 |
} |
| 246 | 255 |
|
| 247 |
-inline int read24(const uint8_t **ppData) |
|
| 256 |
+inline int read24(const std::uint8_t **ppData) |
|
| 248 | 257 |
{
|
| 249 | 258 |
int x = read8(ppData); |
| 250 | 259 |
x |= read8(ppData) << 8; |
| ... | ... |
@@ -252,7 +261,7 @@ inline int read24(const uint8_t **ppData) |
| 252 | 261 |
return x; |
| 253 | 262 |
} |
| 254 | 263 |
|
| 255 |
-inline int readvl(const uint8_t **ppData) |
|
| 264 |
+inline int readvl(const std::uint8_t **ppData) |
|
| 256 | 265 |
{
|
| 257 | 266 |
int x = 0; |
| 258 | 267 |
for (;;) |
| ... | ... |
@@ -14,46 +14,81 @@ |
| 14 | 14 |
|
| 15 | 15 |
#include <cstdint> |
| 16 | 16 |
|
| 17 |
-const uint32_t ARM7_CLOCK = 33513982; |
|
| 18 |
-const double SecondsPerClockCycle = 64.0 * 2728.0 / ARM7_CLOCK; |
|
| 17 |
+inline constexpr std::uint32_t ARM7_CLOCK = 33513982; |
|
| 18 |
+inline constexpr double SecondsPerClockCycle = 64.0 * 2728.0 / ARM7_CLOCK; |
|
| 19 | 19 |
|
| 20 |
-inline uint32_t BIT(uint32_t n) { return 1 << n; }
|
|
| 20 |
+inline std::uint32_t BIT(std::uint32_t n) { return 1 << n; }
|
|
| 21 | 21 |
|
| 22 |
-enum { TS_ALLOCBIT, TS_NOTEWAIT, TS_PORTABIT, TS_TIEBIT, TS_END, TS_BITS };
|
|
| 22 |
+enum class TrackState |
|
| 23 |
+{
|
|
| 24 |
+ AllocateBit, |
|
| 25 |
+ NoteWait, |
|
| 26 |
+ PortamentoBit, |
|
| 27 |
+ TieBit, |
|
| 28 |
+ End, |
|
| 29 |
+ Bits |
|
| 30 |
+}; |
|
| 23 | 31 |
|
| 24 |
-enum { TUF_VOL, TUF_PAN, TUF_TIMER, TUF_MOD, TUF_LEN, TUF_BITS };
|
|
| 32 |
+enum class TrackUpdateFlag |
|
| 33 |
+{
|
|
| 34 |
+ Volume, |
|
| 35 |
+ Pan, |
|
| 36 |
+ Timer, |
|
| 37 |
+ Modulation, |
|
| 38 |
+ Length, |
|
| 39 |
+ Bits |
|
| 40 |
+}; |
|
| 25 | 41 |
|
| 26 |
-enum { CS_NONE, CS_START, CS_ATTACK, CS_DECAY, CS_SUSTAIN, CS_RELEASE };
|
|
| 42 |
+enum class ChannelState |
|
| 43 |
+{
|
|
| 44 |
+ None, |
|
| 45 |
+ Start, |
|
| 46 |
+ Attack, |
|
| 47 |
+ Decay, |
|
| 48 |
+ Sustain, |
|
| 49 |
+ Release |
|
| 50 |
+}; |
|
| 27 | 51 |
|
| 28 |
-enum { CF_UPDVOL, CF_UPDPAN, CF_UPDTMR, CF_BITS };
|
|
| 52 |
+enum class ChannelFlag |
|
| 53 |
+{
|
|
| 54 |
+ UpdateVolume, |
|
| 55 |
+ UpdatePan, |
|
| 56 |
+ UpdateTimer, |
|
| 57 |
+ Bits |
|
| 58 |
+}; |
|
| 29 | 59 |
|
| 30 |
-enum { TYPE_PCM, TYPE_PSG, TYPE_NOISE };
|
|
| 60 |
+enum class ChannelAllocateType |
|
| 61 |
+{
|
|
| 62 |
+ PCM, |
|
| 63 |
+ PSG, |
|
| 64 |
+ Noise |
|
| 65 |
+}; |
|
| 31 | 66 |
|
| 32 |
-const int FSS_TRACKCOUNT = 16; |
|
| 33 |
-const int FSS_MAXTRACKS = 32; |
|
| 34 |
-const int FSS_TRACKSTACKSIZE = 3; |
|
| 35 |
-const int AMPL_K = 723; |
|
| 36 |
-const int AMPL_MIN = -AMPL_K; |
|
| 37 |
-const int AMPL_THRESHOLD = AMPL_MIN * 128; |
|
| 67 |
+inline constexpr int FSS_TRACKCOUNT = 16; |
|
| 68 |
+inline constexpr int FSS_MAXTRACKS = 32; |
|
| 69 |
+inline constexpr int FSS_TRACKSTACKSIZE = 3; |
|
| 70 |
+inline constexpr int AMPL_K = 723; |
|
| 71 |
+inline constexpr int AMPL_MIN = -AMPL_K; |
|
| 72 |
+inline constexpr int AMPL_THRESHOLD = AMPL_MIN * 128; |
|
| 38 | 73 |
|
| 39 | 74 |
inline int SOUND_FREQ(int n) { return -0x1000000 / n; }
|
| 40 | 75 |
|
| 41 |
-inline uint32_t SOUND_VOL(int n) { return n; }
|
|
| 42 |
-inline uint32_t SOUND_VOLDIV(int n) { return n << 8; }
|
|
| 43 |
-inline uint32_t SOUND_PAN(int n) { return n << 16; }
|
|
| 44 |
-inline uint32_t SOUND_DUTY(int n) { return n << 24; }
|
|
| 45 |
-const uint32_t SOUND_REPEAT = BIT(27); |
|
| 46 |
-const uint32_t SOUND_ONE_SHOT = BIT(28); |
|
| 47 |
-inline uint32_t SOUND_LOOP(bool a) { return a ? SOUND_REPEAT : SOUND_ONE_SHOT; }
|
|
| 48 |
-const uint32_t SOUND_FORMAT_PSG = 3 << 29; |
|
| 49 |
-inline uint32_t SOUND_FORMAT(int n) { return n << 29; }
|
|
| 50 |
-const uint32_t SCHANNEL_ENABLE = BIT(31); |
|
| 51 |
- |
|
| 52 |
-enum Interpolation |
|
| 76 |
+inline std::uint32_t SOUND_VOL(int n) { return n; }
|
|
| 77 |
+inline std::uint32_t SOUND_VOLDIV(int n) { return n << 8; }
|
|
| 78 |
+inline std::uint32_t SOUND_PAN(int n) { return n << 16; }
|
|
| 79 |
+inline std::uint32_t SOUND_DUTY(int n) { return n << 24; }
|
|
| 80 |
+inline const std::uint32_t SOUND_REPEAT = BIT(27); |
|
| 81 |
+inline const std::uint32_t SOUND_ONE_SHOT = BIT(28); |
|
| 82 |
+inline std::uint32_t SOUND_LOOP(bool a) { return a ? SOUND_REPEAT : SOUND_ONE_SHOT; }
|
|
| 83 |
+inline constexpr std::uint32_t SOUND_FORMAT_PSG = 3 << 29; |
|
| 84 |
+inline std::uint32_t SOUND_FORMAT(int n) { return n << 29; }
|
|
| 85 |
+inline const std::uint32_t SCHANNEL_ENABLE = BIT(31); |
|
| 86 |
+ |
|
| 87 |
+enum class Interpolation |
|
| 53 | 88 |
{
|
| 54 |
- INTERPOLATION_NONE, |
|
| 55 |
- INTERPOLATION_LINEAR, |
|
| 56 |
- INTERPOLATION_4POINTLEGRANGE, |
|
| 57 |
- INTERPOLATION_6POINTLEGRANGE, |
|
| 58 |
- INTERPOLATION_SINC |
|
| 89 |
+ None, |
|
| 90 |
+ Linear, |
|
| 91 |
+ FourPointLegrange, |
|
| 92 |
+ SixPointLegrange, |
|
| 93 |
+ Sinc |
|
| 59 | 94 |
}; |
| ... | ... |
@@ -5,9 +5,19 @@ |
| 5 | 5 |
* Partially based on the vio*sf framework |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 |
+#include <bitset> |
|
| 9 |
+#include <sstream> |
|
| 10 |
+#include <string> |
|
| 11 |
+#include <cstddef> |
|
| 12 |
+#include "windowsh_wrapper.h" |
|
| 13 |
+#include <windowsx.h> |
|
| 8 | 14 |
#include "XSFConfig_NCSF.h" |
| 15 |
+#include "XSFPlayer_NCSF.h" |
|
| 9 | 16 |
#include "convert.h" |
| 10 | 17 |
#ifdef _DEBUG |
| 18 |
+# include <cstdint> |
|
| 19 |
+# include "SSEQPlayer/common.h" |
|
| 20 |
+# include "SSEQPlayer/consts.h" |
|
| 11 | 21 |
# include "resource.h" |
| 12 | 22 |
# include <CommCtrl.h> |
| 13 | 23 |
#endif |
| ... | ... |
@@ -62,11 +72,11 @@ void XSFConfig_NCSF::SaveSpecificConfig() |
| 62 | 72 |
|
| 63 | 73 |
void XSFConfig_NCSF::GenerateSpecificDialogs() |
| 64 | 74 |
{
|
| 65 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 66 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(110, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idInterpolation). |
|
| 75 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Interpolation").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 76 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(110, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idInterpolation). |
|
| 67 | 77 |
IsDropDownList().WithTabStop()); |
| 68 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 69 |
- this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes). |
|
| 78 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 79 |
+ this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes). |
|
| 70 | 80 |
WithBorder().WithVerticalScrollbar().WithMultipleSelect().WithTabStop()); |
| 71 | 81 |
} |
| 72 | 82 |
|
| ... | ... |
@@ -83,7 +93,7 @@ INT_PTR CALLBACK XSFConfig_NCSF::ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARA |
| 83 | 93 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"16-point Sinc (Nuttall 3-term Window)")); |
| 84 | 94 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, this->interpolation, 0); |
| 85 | 95 |
// Mutes |
| 86 |
- for (int x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 96 |
+ for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 87 | 97 |
{
|
| 88 | 98 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_ADDSTRING, 0, reinterpret_cast<LPARAM>((L"SPU " + std::to_wstring(x + 1)).c_str())); |
| 89 | 99 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, this->mutes[x], x); |
| ... | ... |
@@ -100,14 +110,14 @@ void XSFConfig_NCSF::ResetSpecificConfigDefaults(HWND hwndDlg) |
| 100 | 110 |
{
|
| 101 | 111 |
SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_SETCURSEL, XSFConfig_NCSF::initInterpolation, 0); |
| 102 | 112 |
auto tmpMutes = std::bitset<16>(XSFConfig_NCSF::initMutes); |
| 103 |
- for (int x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x) |
|
| 113 |
+ for (std::size_t x = 0, numMutes = tmpMutes.size(); x < numMutes; ++x) |
|
| 104 | 114 |
SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_SETSEL, tmpMutes[x], x); |
| 105 | 115 |
} |
| 106 | 116 |
|
| 107 | 117 |
void XSFConfig_NCSF::SaveSpecificConfigDialog(HWND hwndDlg) |
| 108 | 118 |
{
|
| 109 | 119 |
this->interpolation = static_cast<unsigned>(SendMessageW(GetDlgItem(hwndDlg, idInterpolation), CB_GETCURSEL, 0, 0)); |
| 110 |
- for (int x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 120 |
+ for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x) |
|
| 111 | 121 |
this->mutes[x] = !!SendMessageW(GetDlgItem(hwndDlg, idMutes), LB_GETSEL, x, 0); |
| 112 | 122 |
} |
| 113 | 123 |
|
| ... | ... |
@@ -235,7 +245,7 @@ static inline void ProgressSetPosImmediate(HWND hDlg, int nIDDlgItem, int nPos) |
| 235 | 245 |
} |
| 236 | 246 |
} |
| 237 | 247 |
|
| 238 |
-static inline int32_t muldiv7(int32_t val, uint8_t mul) |
|
| 248 |
+static inline std::int32_t muldiv7(std::int32_t val, std::uint8_t mul) |
|
| 239 | 249 |
{
|
| 240 | 250 |
return mul == 127 ? val : ((val * mul) >> 7); |
| 241 | 251 |
} |
| ... | ... |
@@ -245,17 +255,17 @@ void XSFConfig_NCSF::RefreshSoundView() |
| 245 | 255 |
auto player = this->soundViewData->player; |
| 246 | 256 |
auto hDlg = this->soundViewData->hDlg; |
| 247 | 257 |
std::wstring buf; |
| 248 |
- for (size_t chanId = 0; chanId < 16; ++chanId) |
|
| 258 |
+ for (std::size_t chanId = 0; chanId < 16; ++chanId) |
|
| 249 | 259 |
{
|
| 250 | 260 |
const auto &chn = player->GetChannel(chanId); |
| 251 | 261 |
|
| 252 |
- if (chn.state > CS_START) |
|
| 262 |
+ if (chn.state > ChannelState::Start) |
|
| 253 | 263 |
{
|
| 254 | 264 |
ProgressSetPosImmediate(hDlg, IDC_SOUND0PANBAR + chanId, muldiv7(128, chn.reg.panning)); |
| 255 |
- uint8_t datashift = chn.reg.volumeDiv; |
|
| 265 |
+ std::uint8_t datashift = chn.reg.volumeDiv; |
|
| 256 | 266 |
if (datashift == 3) |
| 257 | 267 |
datashift = 4; |
| 258 |
- int32_t vol = muldiv7(128, chn.reg.volumeMul) >> datashift; |
|
| 268 |
+ std::int32_t vol = muldiv7(128, chn.reg.volumeMul) >> datashift; |
|
| 259 | 269 |
ProgressSetPosImmediate(hDlg, IDC_SOUND0VOLBAR + chanId, vol); |
| 260 | 270 |
|
| 261 | 271 |
if (this->soundViewData->volModeAlternative) |
| ... | ... |
@@ -298,7 +308,7 @@ void XSFConfig_NCSF::RefreshSoundView() |
| 298 | 308 |
} |
| 299 | 309 |
|
| 300 | 310 |
static const std::wstring states[] = { L"NONE", L"START", L"ATTACK", L"DECAY", L"SUSTAIN", L"RELEASE" };
|
| 301 |
- SetDlgItemTextW(hDlg, IDC_SOUND0STATE + chanId, states[chn.state].c_str()); |
|
| 311 |
+ SetDlgItemTextW(hDlg, IDC_SOUND0STATE + chanId, states[ToIntegral(chn.state)].c_str()); |
|
| 302 | 312 |
|
| 303 | 313 |
SetDlgItemTextW(hDlg, IDC_SOUND0PNT + chanId, (L"samp #" + std::to_wstring(chn.reg.loopStart)).c_str()); |
| 304 | 314 |
|
| ... | ... |
@@ -310,9 +320,9 @@ void XSFConfig_NCSF::RefreshSoundView() |
| 310 | 320 |
buf += tmpBuf + L" Hz)"; |
| 311 | 321 |
SetDlgItemTextW(hDlg, IDC_SOUND0TMR + chanId, buf.c_str()); |
| 312 | 322 |
|
| 313 |
- SetDlgItemTextW(hDlg, IDC_SOUND0POSLEN + chanId, (L"samp #" + std::to_wstring(static_cast<uint32_t>(chn.reg.samplePosition)) + L" / " + std::to_wstring(chn.reg.totalLength)).c_str()); |
|
| 323 |
+ SetDlgItemTextW(hDlg, IDC_SOUND0POSLEN + chanId, (L"samp #" + std::to_wstring(static_cast<std::uint32_t>(chn.reg.samplePosition)) + L" / " + std::to_wstring(chn.reg.totalLength)).c_str()); |
|
| 314 | 324 |
} |
| 315 |
- else if (this->soundViewData->channelLastStates[chanId] != CS_NONE) |
|
| 325 |
+ else if (this->soundViewData->channelLastStates[chanId] != ChannelState::None) |
|
| 316 | 326 |
{
|
| 317 | 327 |
ProgressSetPosImmediate(hDlg, IDC_SOUND0PANBAR + chanId, 0); |
| 318 | 328 |
ProgressSetPosImmediate(hDlg, IDC_SOUND0VOLBAR + chanId, 0); |
| ... | ... |
@@ -8,26 +8,32 @@ |
| 8 | 8 |
#pragma once |
| 9 | 9 |
|
| 10 | 10 |
#include <bitset> |
| 11 |
-#include <memory> |
|
| 12 |
-#include "XSFConfig.h" |
|
| 13 |
-#include "XSFPlayer_NCSF.h" |
|
| 11 |
+#include <string> |
|
| 12 |
+#ifdef _DEBUG |
|
| 13 |
+# include <algorithm> |
|
| 14 |
+# include <memory> |
|
| 15 |
+# include <cstdint> |
|
| 16 |
+# include "SSEQPlayer/consts.h" |
|
| 17 |
+#endif |
|
| 14 | 18 |
#include "windowsh_wrapper.h" |
| 19 |
+#include "XSFConfig.h" |
|
| 15 | 20 |
|
| 16 | 21 |
class XSFConfig_NCSF; |
| 22 |
+class XSFPlayer_NCSF; |
|
| 17 | 23 |
|
| 18 | 24 |
#ifdef _DEBUG |
| 19 | 25 |
struct SoundViewData |
| 20 | 26 |
{
|
| 21 | 27 |
XSFConfig_NCSF *config; |
| 22 | 28 |
XSFPlayer_NCSF *player; |
| 23 |
- uint8_t channelLastStates[16]; |
|
| 29 |
+ ChannelState channelLastStates[16]; |
|
| 24 | 30 |
HWND hDlg; |
| 25 | 31 |
|
| 26 | 32 |
bool volModeAlternative; |
| 27 | 33 |
|
| 28 | 34 |
SoundViewData() : config(nullptr), player(nullptr), hDlg(nullptr), volModeAlternative(false) |
| 29 | 35 |
{
|
| 30 |
- std::fill_n(&this->channelLastStates[0], sizeof(this->channelLastStates), CS_START); |
|
| 36 |
+ std::fill_n(&this->channelLastStates[0], sizeof(this->channelLastStates), ChannelState::Start); |
|
| 31 | 37 |
} |
| 32 | 38 |
}; |
| 33 | 39 |
#endif |
| ... | ... |
@@ -8,17 +8,22 @@ |
| 8 | 8 |
* https://github.com/fincs/FSS |
| 9 | 9 |
*/ |
| 10 | 10 |
|
| 11 |
+#include <algorithm> |
|
| 12 |
+#include <bitset> |
|
| 11 | 13 |
#include <filesystem> |
| 12 | 14 |
#include <memory> |
| 13 |
-#include <cstdlib> |
|
| 14 |
-#include <ctime> |
|
| 15 |
+#include <string> |
|
| 16 |
+#include <vector> |
|
| 17 |
+#include <cstddef> |
|
| 18 |
+#include <cstdint> |
|
| 15 | 19 |
#include <zlib.h> |
| 16 |
-#include "convert.h" |
|
| 17 |
-#include "XSFPlayer_NCSF.h" |
|
| 18 |
-#include "XSFConfig_NCSF.h" |
|
| 19 | 20 |
#include "XSFCommon.h" |
| 21 |
+#include "XSFConfig_NCSF.h" |
|
| 22 |
+#include "XSFPlayer_NCSF.h" |
|
| 20 | 23 |
#include "SSEQPlayer/SDAT.h" |
| 21 | 24 |
#include "SSEQPlayer/Player.h" |
| 25 |
+#include "SSEQPlayer/common.h" |
|
| 26 |
+#include "SSEQPlayer/consts.h" |
|
| 22 | 27 |
|
| 23 | 28 |
const char *XSFPlayer::WinampDescription = "NCSF Decoder"; |
| 24 | 29 |
const char *XSFPlayer::WinampExts = "ncsf;minincsf\0DS Nitro Composer Sound Format files (*.ncsf;*.minincsf)\0"; |
| ... | ... |
@@ -37,9 +42,9 @@ XSFPlayer *XSFPlayer::Create(const std::wstring &fn) |
| 37 | 42 |
} |
| 38 | 43 |
#endif |
| 39 | 44 |
|
| 40 |
-void XSFPlayer_NCSF::MapNCSFSection(const std::vector<uint8_t> §ion) |
|
| 45 |
+void XSFPlayer_NCSF::MapNCSFSection(const std::vector<std::uint8_t> §ion) |
|
| 41 | 46 |
{
|
| 42 |
- uint32_t size = Get32BitsLE(§ion[8]), finalSize = size; |
|
| 47 |
+ std::uint32_t size = Get32BitsLE(§ion[8]), finalSize = size; |
|
| 43 | 48 |
if (this->sdatData.empty()) |
| 44 | 49 |
this->sdatData.resize(finalSize, 0); |
| 45 | 50 |
else if (this->sdatData.size() < size) |
| ... | ... |
@@ -183,12 +188,12 @@ bool XSFPlayer_NCSF::Load() |
| 183 | 188 |
return XSFPlayer::Load(); |
| 184 | 189 |
} |
| 185 | 190 |
|
| 186 |
-static inline int32_t muldiv7(int32_t val, uint8_t mul) |
|
| 191 |
+static inline std::int32_t muldiv7(std::int32_t val, std::uint8_t mul) |
|
| 187 | 192 |
{
|
| 188 | 193 |
return mul == 127 ? val : ((val * mul) >> 7); |
| 189 | 194 |
} |
| 190 | 195 |
|
| 191 |
-void XSFPlayer_NCSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 196 |
+void XSFPlayer_NCSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 192 | 197 |
{
|
| 193 | 198 |
unsigned long mute = this->mutes.to_ulong(); |
| 194 | 199 |
|
| ... | ... |
@@ -196,22 +201,22 @@ void XSFPlayer_NCSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, |
| 196 | 201 |
{
|
| 197 | 202 |
this->secondsIntoPlayback += this->secondsPerSample; |
| 198 | 203 |
|
| 199 |
- int32_t leftChannel = 0, rightChannel = 0; |
|
| 204 |
+ std::int32_t leftChannel = 0, rightChannel = 0; |
|
| 200 | 205 |
|
| 201 | 206 |
// I need to advance the sound channels here |
| 202 | 207 |
for (int i = 0; i < 16; ++i) |
| 203 | 208 |
{
|
| 204 | 209 |
Channel &chn = this->player.channels[i]; |
| 205 | 210 |
|
| 206 |
- if (chn.state > CS_NONE) |
|
| 211 |
+ if (chn.state > ChannelState::None) |
|
| 207 | 212 |
{
|
| 208 |
- int32_t sample = chn.GenerateSample(); |
|
| 213 |
+ std::int32_t sample = chn.GenerateSample(); |
|
| 209 | 214 |
chn.IncrementSample(); |
| 210 | 215 |
|
| 211 | 216 |
if (mute & BIT(i)) |
| 212 | 217 |
continue; |
| 213 | 218 |
|
| 214 |
- uint8_t datashift = chn.reg.volumeDiv; |
|
| 219 |
+ std::uint8_t datashift = chn.reg.volumeDiv; |
|
| 215 | 220 |
if (datashift == 3) |
| 216 | 221 |
datashift = 4; |
| 217 | 222 |
sample = muldiv7(sample, chn.reg.volumeMul) >> datashift; |
| ... | ... |
@@ -254,7 +259,7 @@ void XSFPlayer_NCSF::SetMutes(const std::bitset<16> &newMutes) |
| 254 | 259 |
} |
| 255 | 260 |
|
| 256 | 261 |
#ifdef _DEBUG |
| 257 |
-const Channel &XSFPlayer_NCSF::GetChannel(size_t chanNum) const |
|
| 262 |
+const Channel &XSFPlayer_NCSF::GetChannel(std::size_t chanNum) const |
|
| 258 | 263 |
{
|
| 259 | 264 |
return this->player.channels[chanNum]; |
| 260 | 265 |
} |
| ... | ... |
@@ -10,22 +10,28 @@ |
| 10 | 10 |
|
| 11 | 11 |
#pragma once |
| 12 | 12 |
|
| 13 |
-#include <memory> |
|
| 14 | 13 |
#include <bitset> |
| 14 |
+#include <memory> |
|
| 15 |
+#include <string> |
|
| 16 |
+#include <vector> |
|
| 17 |
+#ifdef _DEBUG |
|
| 18 |
+# include <cstddef> |
|
| 19 |
+#endif |
|
| 20 |
+#include <cstdint> |
|
| 15 | 21 |
#include "XSFPlayer.h" |
| 16 | 22 |
#include "SSEQPlayer/SDAT.h" |
| 17 | 23 |
#include "SSEQPlayer/Player.h" |
| 18 | 24 |
|
| 19 | 25 |
class XSFPlayer_NCSF : public XSFPlayer |
| 20 | 26 |
{
|
| 21 |
- uint32_t sseq; |
|
| 22 |
- std::vector<uint8_t> sdatData; |
|
| 27 |
+ std::uint32_t sseq; |
|
| 28 |
+ std::vector<std::uint8_t> sdatData; |
|
| 23 | 29 |
std::unique_ptr<SDAT> sdat; |
| 24 | 30 |
Player player; |
| 25 | 31 |
double secondsPerSample, secondsIntoPlayback, secondsUntilNextClock; |
| 26 | 32 |
std::bitset<16> mutes; |
| 27 | 33 |
|
| 28 |
- void MapNCSFSection(const std::vector<uint8_t> §ion); |
|
| 34 |
+ void MapNCSFSection(const std::vector<std::uint8_t> §ion); |
|
| 29 | 35 |
bool MapNCSF(XSFFile *xSFToLoad); |
| 30 | 36 |
bool RecursiveLoadNCSF(XSFFile *xSFToLoad, int level); |
| 31 | 37 |
bool LoadNCSF(); |
| ... | ... |
@@ -36,12 +42,12 @@ public: |
| 36 | 42 |
#endif |
| 37 | 43 |
~XSFPlayer_NCSF(); |
| 38 | 44 |
bool Load(); |
| 39 |
- void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 45 |
+ void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 40 | 46 |
void Terminate(); |
| 41 | 47 |
|
| 42 | 48 |
void SetInterpolation(unsigned interpolation); |
| 43 | 49 |
void SetMutes(const std::bitset<16> &newMutes); |
| 44 | 50 |
#ifdef _DEBUG |
| 45 |
- const Channel &GetChannel(size_t chanNum) const; |
|
| 51 |
+ const Channel &GetChannel(std::size_t chanNum) const; |
|
| 46 | 52 |
#endif |
| 47 | 53 |
}; |
| ... | ... |
@@ -9,6 +9,11 @@ |
| 9 | 9 |
* snes9x. |
| 10 | 10 |
*/ |
| 11 | 11 |
|
| 12 |
+#include <bitset> |
|
| 13 |
+#include <sstream> |
|
| 14 |
+#include <string> |
|
| 15 |
+#include <cstdint> |
|
| 16 |
+#include "windowsh_wrapper.h" |
|
| 12 | 17 |
#include "XSFConfig_SNSF.h" |
| 13 | 18 |
#include "convert.h" |
| 14 | 19 |
#include "snes9x/apu/apu.h" |
| ... | ... |
@@ -68,15 +73,15 @@ void XSFConfig_SNSF::SaveSpecificConfig() |
| 68 | 73 |
|
| 69 | 74 |
void XSFConfig_SNSF::GenerateSpecificDialogs() |
| 70 | 75 |
{
|
| 71 |
- /*this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Sixteen-Bit Sound").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop(). |
|
| 76 |
+ /*this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Sixteen-Bit Sound").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop(). |
|
| 72 | 77 |
WithID(idSixteenBitSound));*/ |
| 73 |
- this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Reverse Stereo").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7), 2).WithTabStop(). |
|
| 78 |
+ this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Reverse Stereo").WithSize(80, 10).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7), 2).WithTabStop(). |
|
| 74 | 79 |
WithID(idReverseStereo)); |
| 75 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Resampler").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10)).IsLeftJustified()); |
|
| 76 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithTabStop().IsDropDownList(). |
|
| 80 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Resampler").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10)).IsLeftJustified()); |
|
| 81 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithTabStop().IsDropDownList(). |
|
| 77 | 82 |
WithID(idResampler)); |
| 78 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 79 |
- this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 83 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Mute").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 84 |
+ this->configDialog.AddListBoxControl(DialogListBoxBuilder().WithSize(78, 45).WithExactHeight().InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idMutes).WithBorder(). |
|
| 80 | 85 |
WithVerticalScrollbar().WithMultipleSelect().WithTabStop()); |
| 81 | 86 |
} |
| 82 | 87 |
|
| ... | ... |
@@ -140,7 +145,7 @@ void XSFConfig_SNSF::CopySpecificConfigToMemory(XSFPlayer *, bool preLoad) |
| 140 | 145 |
Settings.ReverseStereo = this->reverseStereo; |
| 141 | 146 |
} |
| 142 | 147 |
else |
| 143 |
- S9xSetSoundControl(static_cast<uint8_t>(this->mutes.to_ulong()) ^ 0xFF); |
|
| 148 |
+ S9xSetSoundControl(static_cast<std::uint8_t>(this->mutes.to_ulong()) ^ 0xFF); |
|
| 144 | 149 |
} |
| 145 | 150 |
|
| 146 | 151 |
void XSFConfig_SNSF::About(HWND parent) |
| ... | ... |
@@ -11,12 +11,17 @@ |
| 11 | 11 |
* http://www.snes9x.com/ |
| 12 | 12 |
*/ |
| 13 | 13 |
|
| 14 |
+#include <algorithm> |
|
| 14 | 15 |
#include <filesystem> |
| 16 |
+#include <memory> |
|
| 17 |
+#include <string> |
|
| 18 |
+#include <vector> |
|
| 19 |
+#include <cstddef> |
|
| 20 |
+#include <cstdint> |
|
| 15 | 21 |
#include <zlib.h> |
| 16 |
-#include "convert.h" |
|
| 17 |
-#include "XSFPlayer.h" |
|
| 18 |
-#include "XSFConfig_SNSF.h" |
|
| 19 | 22 |
#include "XSFCommon.h" |
| 23 |
+#include "XSFConfig_SNSF.h" |
|
| 24 |
+#include "XSFPlayer.h" |
|
| 20 | 25 |
|
| 21 | 26 |
#undef min |
| 22 | 27 |
#undef max |
| ... | ... |
@@ -38,7 +43,7 @@ public: |
| 38 | 43 |
#endif |
| 39 | 44 |
~XSFPlayer_SNSF() { this->Terminate(); }
|
| 40 | 45 |
bool Load(); |
| 41 |
- void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 46 |
+ void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples); |
|
| 42 | 47 |
void Terminate(); |
| 43 | 48 |
}; |
| 44 | 49 |
|
| ... | ... |
@@ -61,15 +66,15 @@ XSFPlayer *XSFPlayer::Create(const std::wstring &fn) |
| 61 | 66 |
|
| 62 | 67 |
static struct |
| 63 | 68 |
{
|
| 64 |
- std::vector<uint8_t> rom, sram; |
|
| 69 |
+ std::vector<std::uint8_t> rom, sram; |
|
| 65 | 70 |
bool first; |
| 66 | 71 |
unsigned base; |
| 67 |
-} loaderwork = { std::vector<uint8_t>(), std::vector<uint8_t>(), false, 0 };
|
|
| 72 |
+} loaderwork = { std::vector<std::uint8_t>(), std::vector<std::uint8_t>(), false, 0 };
|
|
| 68 | 73 |
|
| 69 | 74 |
class BUFFER |
| 70 | 75 |
{
|
| 71 | 76 |
public: |
| 72 |
- std::vector<uint8_t> buf; |
|
| 77 |
+ std::vector<std::uint8_t> buf; |
|
| 73 | 78 |
unsigned fil, cur, len; |
| 74 | 79 |
BUFFER() : buf(), fil(0), cur(0), len(0) { }
|
| 75 | 80 |
bool Init() |
| ... | ... |
@@ -107,11 +112,11 @@ bool S9xOpenSoundDevice() |
| 107 | 112 |
return true; |
| 108 | 113 |
} |
| 109 | 114 |
|
| 110 |
-static void MapSNSFSection(const std::vector<uint8_t> §ion) |
|
| 115 |
+static void MapSNSFSection(const std::vector<std::uint8_t> §ion) |
|
| 111 | 116 |
{
|
| 112 | 117 |
auto &data = loaderwork.rom; |
| 113 | 118 |
|
| 114 |
- uint32_t offset = Get32BitsLE(§ion[0]), size = Get32BitsLE(§ion[4]), finalSize = size + offset; |
|
| 119 |
+ std::uint32_t offset = Get32BitsLE(§ion[0]), size = Get32BitsLE(§ion[4]), finalSize = size + offset; |
|
| 115 | 120 |
if (!loaderwork.first) |
| 116 | 121 |
{
|
| 117 | 122 |
loaderwork.first = true; |
| ... | ... |
@@ -136,17 +141,17 @@ static bool MapSNSF(XSFFile *xSF) |
| 136 | 141 |
|
| 137 | 142 |
if (!reservedSection.empty()) |
| 138 | 143 |
{
|
| 139 |
- size_t reservedPosition = 0, reservedSize = reservedSection.size(); |
|
| 144 |
+ std::size_t reservedPosition = 0, reservedSize = reservedSection.size(); |
|
| 140 | 145 |
while (reservedPosition + 8 < reservedSize) |
| 141 | 146 |
{
|
| 142 |
- uint32_t type = Get32BitsLE(&reservedSection[reservedPosition]), size = Get32BitsLE(&reservedSection[reservedPosition + 4]); |
|
| 147 |
+ std::uint32_t type = Get32BitsLE(&reservedSection[reservedPosition]), size = Get32BitsLE(&reservedSection[reservedPosition + 4]); |
|
| 143 | 148 |
if (!type) |
| 144 | 149 |
{
|
| 145 | 150 |
if (loaderwork.sram.empty()) |
| 146 | 151 |
loaderwork.sram.resize(0x20000, 0xFF); |
| 147 | 152 |
if (reservedPosition + 8 + size > reservedSize) |
| 148 | 153 |
return false; |
| 149 |
- uint32_t offset = Get32BitsLE(&reservedSection[reservedPosition + 8]); |
|
| 154 |
+ std::uint32_t offset = Get32BitsLE(&reservedSection[reservedPosition + 8]); |
|
| 150 | 155 |
if (size > 4 && loaderwork.sram.size() > offset) |
| 151 | 156 |
{
|
| 152 | 157 |
auto len = std::min(size - 4, loaderwork.sram.size() - offset); |
| ... | ... |
@@ -264,7 +269,7 @@ bool XSFPlayer_SNSF::Load() |
| 264 | 269 |
return XSFPlayer::Load(); |
| 265 | 270 |
} |
| 266 | 271 |
|
| 267 |
-void XSFPlayer_SNSF::GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 272 |
+void XSFPlayer_SNSF::GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) |
|
| 268 | 273 |
{
|
| 269 | 274 |
unsigned bytes = samples << 2; |
| 270 | 275 |
while (bytes) |
| ... | ... |
@@ -3,13 +3,20 @@ |
| 3 | 3 |
* By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com] |
| 4 | 4 |
*/ |
| 5 | 5 |
|
| 6 |
+#include <algorithm> |
|
| 7 |
+#include <memory> |
|
| 8 |
+#include <utility> |
|
| 9 |
+#include <vector> |
|
| 10 |
+#include <cstdint> |
|
| 11 |
+#include "windowsh_wrapper.h" |
|
| 6 | 12 |
#include "DialogBuilder.h" |
| 13 |
+#include "XSFCommon.h" |
|
| 7 | 14 |
|
| 8 | 15 |
// Code modified from the following answer on Stack Overflow: |
| 9 | 16 |
// http://stackoverflow.com/a/3407254 |
| 10 |
-static inline uint32_t getNextMultipleOf4(uint32_t origNum) |
|
| 17 |
+static inline std::uint32_t getNextMultipleOf4(std::uint32_t origNum) |
|
| 11 | 18 |
{
|
| 12 |
- uint32_t remainder = origNum % 4; |
|
| 19 |
+ std::uint32_t remainder = origNum % 4; |
|
| 13 | 20 |
if (!remainder) |
| 14 | 21 |
return origNum; |
| 15 | 22 |
return origNum + 4 - remainder; |
| ... | ... |
@@ -20,16 +27,16 @@ Point<short> RelativePosition::CalculatePosition(const Rect<short> &child, const |
| 20 | 27 |
Point<short> newPosition = child.position; |
| 21 | 28 |
if (this->relativePosition.y != -1) |
| 22 | 29 |
{
|
| 23 |
- if (this->positionType == FROM_TOP || this->positionType == FROM_TOPLEFT || this->positionType == FROM_TOPRIGHT) |
|
| 30 |
+ if (this->positionType == PositionType::FromTop || this->positionType == PositionType::FromTopLeft || this->positionType == PositionType::FromTopRight) |
|
| 24 | 31 |
newPosition.y = other.position.y + this->relativePosition.y; |
| 25 |
- if (this->positionType == FROM_BOTTOM || this->positionType == FROM_BOTTOMLEFT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 32 |
+ if (this->positionType == PositionType::FromBottom || this->positionType == PositionType::FromBottomLeft || this->positionType == PositionType::FromBottomRight) |
|
| 26 | 33 |
newPosition.y = other.position.y + other.size.height + this->relativePosition.y; |
| 27 | 34 |
} |
| 28 | 35 |
if (this->relativePosition.x != -1) |
| 29 | 36 |
{
|
| 30 |
- if (this->positionType == FROM_LEFT || this->positionType == FROM_TOPLEFT || this->positionType == FROM_BOTTOMLEFT) |
|
| 37 |
+ if (this->positionType == PositionType::FromLeft || this->positionType == PositionType::FromTopLeft || this->positionType == PositionType::FromBottomLeft) |
|
| 31 | 38 |
newPosition.x = other.position.x + this->relativePosition.x; |
| 32 |
- if (this->positionType == FROM_RIGHT || this->positionType == FROM_TOPRIGHT || this->positionType == FROM_BOTTOMRIGHT) |
|
| 39 |
+ if (this->positionType == PositionType::FromRight || this->positionType == PositionType::FromTopRight || this->positionType == PositionType::FromBottomRight) |
|
| 33 | 40 |
newPosition.x = other.position.x + other.size.width + this->relativePosition.x; |
| 34 | 41 |
} |
| 35 | 42 |
return newPosition; |
| ... | ... |
@@ -44,15 +51,15 @@ void DialogTemplate::DialogGroup::CalculatePositions(bool doRightAndBottom) |
| 44 | 51 |
if (control->relativePosition) |
| 45 | 52 |
{
|
| 46 | 53 |
bool valid = true; |
| 47 |
- if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT) |
|
| 54 |
+ if (!doRightAndBottom && control->relativePosition->type == RelativePosition::BaseType::ToParent) |
|
| 48 | 55 |
{
|
| 49 | 56 |
switch (control->relativePosition->positionType) |
| 50 | 57 |
{
|
| 51 |
- case RelativePosition::FROM_BOTTOM: |
|
| 52 |
- case RelativePosition::FROM_BOTTOMLEFT: |
|
| 53 |
- case RelativePosition::FROM_BOTTOMRIGHT: |
|
| 54 |
- case RelativePosition::FROM_RIGHT: |
|
| 55 |
- case RelativePosition::FROM_TOPRIGHT: |
|
| 58 |
+ case RelativePosition::PositionType::FromBottom: |
|
| 59 |
+ case RelativePosition::PositionType::FromBottomLeft: |
|
| 60 |
+ case RelativePosition::PositionType::FromBottomRight: |
|
| 61 |
+ case RelativePosition::PositionType::FromRight: |
|
| 62 |
+ case RelativePosition::PositionType::FromTopRight: |
|
| 56 | 63 |
valid = false; |
| 57 | 64 |
break; |
| 58 | 65 |
default: |
| ... | ... |
@@ -62,7 +69,7 @@ void DialogTemplate::DialogGroup::CalculatePositions(bool doRightAndBottom) |
| 62 | 69 |
if (valid) |
| 63 | 70 |
{
|
| 64 | 71 |
Rect<short> other = this->rect; |
| 65 |
- if (control->relativePosition->type == RelativePosition::TO_SIBLING) |
|
| 72 |
+ if (control->relativePosition->type == RelativePosition::BaseType::ToSibling) |
|
| 66 | 73 |
{
|
| 67 | 74 |
short siblingsBack = dynamic_cast<const RelativePositionToSibling *>(control->relativePosition.get())->siblingsBack; |
| 68 | 75 |
if (x - siblingsBack >= 0) |
| ... | ... |
@@ -82,15 +89,15 @@ void DialogTemplate::DialogGroup::CalculateSize() |
| 82 | 89 |
bool usePosition = true; |
| 83 | 90 |
if (control->relativePosition) |
| 84 | 91 |
{
|
| 85 |
- if (control->relativePosition->type == RelativePosition::TO_PARENT) |
|
| 92 |
+ if (control->relativePosition->type == RelativePosition::BaseType::ToParent) |
|
| 86 | 93 |
{
|
| 87 | 94 |
switch (control->relativePosition->positionType) |
| 88 | 95 |
{
|
| 89 |
- case RelativePosition::FROM_BOTTOM: |
|
| 90 |
- case RelativePosition::FROM_BOTTOMLEFT: |
|
| 91 |
- case RelativePosition::FROM_BOTTOMRIGHT: |
|
| 92 |
- case RelativePosition::FROM_RIGHT: |
|
| 93 |
- case RelativePosition::FROM_TOPRIGHT: |
|
| 96 |
+ case RelativePosition::PositionType::FromBottom: |
|
| 97 |
+ case RelativePosition::PositionType::FromBottomLeft: |
|
| 98 |
+ case RelativePosition::PositionType::FromBottomRight: |
|
| 99 |
+ case RelativePosition::PositionType::FromRight: |
|
| 100 |
+ case RelativePosition::PositionType::FromTopRight: |
|
| 94 | 101 |
usePosition = false; |
| 95 | 102 |
/*if (control->relativePosition->relativePosition.x != -1 && control->rect.size.width + control->relativePosition->relativePosition.x > maxOtherWidth) |
| 96 | 103 |
maxOtherWidth = control->rect.size.width + control->relativePosition->relativePosition.x; |
| ... | ... |
@@ -114,27 +121,27 @@ void DialogTemplate::DialogGroup::CalculateSize() |
| 114 | 121 |
this->rect.size.height = (maxY - this->rect.position.y) + maxOtherHeight + 7; |
| 115 | 122 |
} |
| 116 | 123 |
|
| 117 |
-uint16_t DialogTemplate::DialogGroup::GetControlCount() const |
|
| 124 |
+std::uint16_t DialogTemplate::DialogGroup::GetControlCount() const |
|
| 118 | 125 |
{
|
| 119 |
- uint16_t count = 1; |
|
| 126 |
+ std::uint16_t count = 1; |
|
| 120 | 127 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) { count += control->GetControlCount(); });
|
| 121 | 128 |
return count; |
| 122 | 129 |
} |
| 123 | 130 |
|
| 124 |
-std::vector<uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() const |
|
| 131 |
+std::vector<std::uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() const |
|
| 125 | 132 |
{
|
| 126 |
- auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->groupName.length() + 1)), 0); |
|
| 133 |
+ auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->groupName.length() + 1)), 0); |
|
| 127 | 134 |
|
| 128 |
- *reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | BS_GROUPBOX | this->style; |
|
| 129 |
- *reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle; |
|
| 130 |
- *reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 131 |
- *reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 132 |
- *reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 133 |
- *reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 134 |
- *reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
|
| 135 |
- *reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF; |
|
| 136 |
- *reinterpret_cast<uint16_t *>(&data[20]) = 0x0080; |
|
| 137 |
- std::copy_n(this->groupName.c_str(), this->groupName.length(), reinterpret_cast<wchar_t *>(&data[22])); |
|
| 135 |
+ *reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | BS_GROUPBOX | this->style; |
|
| 136 |
+ *reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle; |
|
| 137 |
+ *reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 138 |
+ *reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 139 |
+ *reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 140 |
+ *reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 141 |
+ *reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<std::uint16_t>(this->id); |
|
| 142 |
+ *reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF; |
|
| 143 |
+ *reinterpret_cast<std::uint16_t *>(&data[20]) = 0x0080; |
|
| 144 |
+ CopyToString(this->groupName, reinterpret_cast<wchar_t *>(&data[22])); |
|
| 138 | 145 |
|
| 139 | 146 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| 140 | 147 |
{
|
| ... | ... |
@@ -145,44 +152,44 @@ std::vector<uint8_t> DialogTemplate::DialogGroup::GenerateControlTemplate() cons |
| 145 | 152 |
return data; |
| 146 | 153 |
} |
| 147 | 154 |
|
| 148 |
-std::vector<uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlTemplate() const |
|
| 155 |
+std::vector<std::uint8_t> DialogTemplate::DialogControlWithoutLabel::GenerateControlTemplate() const |
|
| 149 | 156 |
{
|
| 150 |
- auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t)), 0); |
|
| 157 |
+ auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t)), 0); |
|
| 151 | 158 |
|
| 152 |
- *reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
|
| 153 |
- *reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle; |
|
| 154 |
- *reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 155 |
- *reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 156 |
- *reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 157 |
- *reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 158 |
- *reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
|
| 159 |
- *reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF; |
|
| 160 |
- *reinterpret_cast<uint16_t *>(&data[20]) = this->type; |
|
| 159 |
+ *reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
|
| 160 |
+ *reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle; |
|
| 161 |
+ *reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 162 |
+ *reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 163 |
+ *reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 164 |
+ *reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 165 |
+ *reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
|
| 166 |
+ *reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF; |
|
| 167 |
+ *reinterpret_cast<std::uint16_t *>(&data[20]) = this->type; |
|
| 161 | 168 |
|
| 162 | 169 |
return data; |
| 163 | 170 |
} |
| 164 | 171 |
|
| 165 |
-std::vector<uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemplate() const |
|
| 172 |
+std::vector<std::uint8_t> DialogTemplate::DialogControlWithLabel::GenerateControlTemplate() const |
|
| 166 | 173 |
{
|
| 167 |
- auto data = std::vector<uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->label.length() + 1)), 0); |
|
| 174 |
+ auto data = std::vector<std::uint8_t>(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->label.length() + 1)), 0); |
|
| 168 | 175 |
|
| 169 |
- *reinterpret_cast<uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
|
| 170 |
- *reinterpret_cast<uint32_t *>(&data[4]) = this->exstyle; |
|
| 171 |
- *reinterpret_cast<uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 172 |
- *reinterpret_cast<uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 173 |
- *reinterpret_cast<uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 174 |
- *reinterpret_cast<uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 175 |
- *reinterpret_cast<uint16_t *>(&data[16]) = static_cast<uint16_t>(this->id); |
|
| 176 |
- *reinterpret_cast<uint16_t *>(&data[18]) = 0xFFFF; |
|
| 177 |
- *reinterpret_cast<uint16_t *>(&data[20]) = this->type; |
|
| 178 |
- std::copy_n(this->label.c_str(), this->label.length(), reinterpret_cast<wchar_t *>(&data[22])); |
|
| 176 |
+ *reinterpret_cast<std::uint32_t *>(&data[0]) = WS_CHILD | WS_VISIBLE | this->style; |
|
| 177 |
+ *reinterpret_cast<std::uint32_t *>(&data[4]) = this->exstyle; |
|
| 178 |
+ *reinterpret_cast<std::uint16_t *>(&data[8]) = this->rect.position.x; |
|
| 179 |
+ *reinterpret_cast<std::uint16_t *>(&data[10]) = this->rect.position.y; |
|
| 180 |
+ *reinterpret_cast<std::uint16_t *>(&data[12]) = this->rect.size.width; |
|
| 181 |
+ *reinterpret_cast<std::uint16_t *>(&data[14]) = this->rect.size.height; |
|
| 182 |
+ *reinterpret_cast<std::uint16_t *>(&data[16]) = static_cast<std::uint16_t>(this->id); |
|
| 183 |
+ *reinterpret_cast<std::uint16_t *>(&data[18]) = 0xFFFF; |
|
| 184 |
+ *reinterpret_cast<std::uint16_t *>(&data[20]) = this->type; |
|
| 185 |
+ CopyToString(this->label, reinterpret_cast<wchar_t *>(&data[22])); |
|
| 179 | 186 |
|
| 180 | 187 |
return data; |
| 181 | 188 |
} |
| 182 | 189 |
|
| 183 |
-uint16_t DialogTemplate::GetTotalControlCount() const |
|
| 190 |
+std::uint16_t DialogTemplate::GetTotalControlCount() const |
|
| 184 | 191 |
{
|
| 185 |
- uint16_t count = 0; |
|
| 192 |
+ std::uint16_t count = 0; |
|
| 186 | 193 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) { count += control->GetControlCount(); });
|
| 187 | 194 |
return count; |
| 188 | 195 |
} |
| ... | ... |
@@ -198,32 +205,32 @@ void DialogTemplate::AddGroupControl(const DialogControlBuilder<DialogGroupBuild |
| 198 | 205 |
|
| 199 | 206 |
void DialogTemplate::AddEditBoxControl(const DialogControlBuilder<DialogEditBoxBuilder> &builder) |
| 200 | 207 |
{
|
| 201 |
- this->AddControlToGroup(std::move(DialogEditBox::CreateControl(builder)), builder); |
|
| 208 |
+ this->AddControlToGroup(DialogEditBox::CreateControl(builder), builder); |
|
| 202 | 209 |
} |
| 203 | 210 |
|
| 204 | 211 |
void DialogTemplate::AddLabelControl(const DialogControlBuilder<DialogLabelBuilder> &builder) |
| 205 | 212 |
{
|
| 206 |
- this->AddControlToGroup(std::move(DialogLabel::CreateControl(builder)), builder); |
|
| 213 |
+ this->AddControlToGroup(DialogLabel::CreateControl(builder), builder); |
|
| 207 | 214 |
} |
| 208 | 215 |
|
| 209 | 216 |
void DialogTemplate::AddCheckBoxControl(const DialogControlBuilder<DialogCheckBoxBuilder> &builder) |
| 210 | 217 |
{
|
| 211 |
- this->AddControlToGroup(std::move(DialogButton::CreateControl(builder)), builder); |
|
| 218 |
+ this->AddControlToGroup(DialogButton::CreateControl(builder), builder); |
|
| 212 | 219 |
} |
| 213 | 220 |
|
| 214 | 221 |
void DialogTemplate::AddButtonControl(const DialogControlBuilder<DialogButtonBuilder> &builder) |
| 215 | 222 |
{
|
| 216 |
- this->AddControlToGroup(std::move(DialogButton::CreateControl(builder)), builder); |
|
| 223 |
+ this->AddControlToGroup(DialogButton::CreateControl(builder), builder); |
|
| 217 | 224 |
} |
| 218 | 225 |
|
| 219 | 226 |
void DialogTemplate::AddListBoxControl(const DialogControlBuilder<DialogListBoxBuilder> &builder) |
| 220 | 227 |
{
|
| 221 |
- this->AddControlToGroup(std::move(DialogListBox::CreateControl(builder)), builder); |
|
| 228 |
+ this->AddControlToGroup(DialogListBox::CreateControl(builder), builder); |
|
| 222 | 229 |
} |
| 223 | 230 |
|
| 224 | 231 |
void DialogTemplate::AddComboBoxControl(const DialogControlBuilder<DialogComboBoxBuilder> &builder) |
| 225 | 232 |
{
|
| 226 |
- this->AddControlToGroup(std::move(DialogComboBox::CreateControl(builder)), builder); |
|
| 233 |
+ this->AddControlToGroup(DialogComboBox::CreateControl(builder), builder); |
|
| 227 | 234 |
} |
| 228 | 235 |
|
| 229 | 236 |
bool DialogTemplate::CalculateControlPosition(short index, bool doRightAndBottom) |
| ... | ... |
@@ -232,15 +239,15 @@ bool DialogTemplate::CalculateControlPosition(short index, bool doRightAndBottom |
| 232 | 239 |
bool valid = true; |
| 233 | 240 |
if (control->relativePosition) |
| 234 | 241 |
{
|
| 235 |
- if (!doRightAndBottom && control->relativePosition->type == RelativePosition::TO_PARENT) |
|
| 242 |
+ if (!doRightAndBottom && control->relativePosition->type == RelativePosition::BaseType::ToParent) |
|
| 236 | 243 |
{
|
| 237 | 244 |
switch (control->relativePosition->positionType) |
| 238 | 245 |
{
|
| 239 |
- case RelativePosition::FROM_BOTTOM: |
|
| 240 |
- case RelativePosition::FROM_BOTTOMLEFT: |
|
| 241 |
- case RelativePosition::FROM_BOTTOMRIGHT: |
|
| 242 |
- case RelativePosition::FROM_RIGHT: |
|
| 243 |
- case RelativePosition::FROM_TOPRIGHT: |
|
| 246 |
+ case RelativePosition::PositionType::FromBottom: |
|
| 247 |
+ case RelativePosition::PositionType::FromBottomLeft: |
|
| 248 |
+ case RelativePosition::PositionType::FromBottomRight: |
|
| 249 |
+ case RelativePosition::PositionType::FromRight: |
|
| 250 |
+ case RelativePosition::PositionType::FromTopRight: |
|
| 244 | 251 |
valid = false; |
| 245 | 252 |
break; |
| 246 | 253 |
default: |
| ... | ... |
@@ -250,7 +257,7 @@ bool DialogTemplate::CalculateControlPosition(short index, bool doRightAndBottom |
| 250 | 257 |
if (valid) |
| 251 | 258 |
{
|
| 252 | 259 |
Rect<short> other = Rect<short>(Point<short>(), this->size); |
| 253 |
- if (control->relativePosition->type == RelativePosition::TO_SIBLING) |
|
| 260 |
+ if (control->relativePosition->type == RelativePosition::BaseType::ToSibling) |
|
| 254 | 261 |
{
|
| 255 | 262 |
short siblingsBack = dynamic_cast<const RelativePositionToSibling *>(control->relativePosition.get())->siblingsBack; |
| 256 | 263 |
if (index - siblingsBack >= 0) |
| ... | ... |
@@ -270,15 +277,15 @@ void DialogTemplate::CalculateSize() |
| 270 | 277 |
bool usePosition = true; |
| 271 | 278 |
if (control->relativePosition) |
| 272 | 279 |
{
|
| 273 |
- if (control->relativePosition->type == RelativePosition::TO_PARENT) |
|
| 280 |
+ if (control->relativePosition->type == RelativePosition::BaseType::ToParent) |
|
| 274 | 281 |
{
|
| 275 | 282 |
switch (control->relativePosition->positionType) |
| 276 | 283 |
{
|
| 277 |
- case RelativePosition::FROM_BOTTOM: |
|
| 278 |
- case RelativePosition::FROM_BOTTOMLEFT: |
|
| 279 |
- case RelativePosition::FROM_BOTTOMRIGHT: |
|
| 280 |
- case RelativePosition::FROM_RIGHT: |
|
| 281 |
- case RelativePosition::FROM_TOPRIGHT: |
|
| 284 |
+ case RelativePosition::PositionType::FromBottom: |
|
| 285 |
+ case RelativePosition::PositionType::FromBottomLeft: |
|
| 286 |
+ case RelativePosition::PositionType::FromBottomRight: |
|
| 287 |
+ case RelativePosition::PositionType::FromRight: |
|
| 288 |
+ case RelativePosition::PositionType::FromTopRight: |
|
| 282 | 289 |
usePosition = false; |
| 283 | 290 |
/*if (control->relativePosition->relativePosition.x != -1 && control->rect.size.width + control->relativePosition->relativePosition.x > maxOtherWidth) |
| 284 | 291 |
maxOtherWidth = control->rect.size.width + control->relativePosition->relativePosition.x; |
| ... | ... |
@@ -310,7 +317,7 @@ void DialogTemplate::AutoSize() |
| 310 | 317 |
{
|
| 311 | 318 |
auto &control = this->controls[x]; |
| 312 | 319 |
bool valid = this->CalculateControlPosition(x, false); |
| 313 |
- if (valid && control->controlType == GROUP_CONTROL) |
|
| 320 |
+ if (valid && control->controlType == DialogControlType::Group) |
|
| 314 | 321 |
{
|
| 315 | 322 |
dynamic_cast<DialogGroup *>(control.get())->CalculatePositions(false); |
| 316 | 323 |
// Technically step 2, but calculate the size of the group |
| ... | ... |
@@ -323,7 +330,7 @@ void DialogTemplate::AutoSize() |
| 323 | 330 |
for (x = 0; x < num; ++x) |
| 324 | 331 |
{
|
| 325 | 332 |
auto &control = this->controls[x]; |
| 326 |
- if (control->controlType != GROUP_CONTROL) |
|
| 333 |
+ if (control->controlType != DialogControlType::Group) |
|
| 327 | 334 |
continue; |
| 328 | 335 |
control->rect.size.width = maxGroupWidth; |
| 329 | 336 |
dynamic_cast<DialogGroup *>(control.get())->CalculatePositions(true); |
| ... | ... |
@@ -338,19 +345,19 @@ void DialogTemplate::AutoSize() |
| 338 | 345 |
const DLGTEMPLATE *DialogTemplate::GenerateTemplate() |
| 339 | 346 |
{
|
| 340 | 347 |
this->templateData.clear(); |
| 341 |
- uint16_t controlCount = this->GetTotalControlCount(); |
|
| 348 |
+ std::uint16_t controlCount = this->GetTotalControlCount(); |
|
| 342 | 349 |
this->templateData.resize(getNextMultipleOf4(24 + sizeof(wchar_t) * (this->title.length() + 1 + (this->fontName.empty() ? 0 : this->fontName.length() + 1))), 0); |
| 343 | 350 |
|
| 344 |
- *reinterpret_cast<uint32_t *>(&this->templateData[0]) = this->style | (this->fontName.empty() ? 0 : DS_SETFONT); |
|
| 345 |
- *reinterpret_cast<uint32_t *>(&this->templateData[4]) = this->exstyle; |
|
| 346 |
- *reinterpret_cast<uint16_t *>(&this->templateData[8]) = controlCount; |
|
| 347 |
- *reinterpret_cast<uint16_t *>(&this->templateData[14]) = this->size.width; |
|
| 348 |
- *reinterpret_cast<uint16_t *>(&this->templateData[16]) = this->size.height; |
|
| 349 |
- std::copy_n(this->title.c_str(), this->title.length(), reinterpret_cast<wchar_t *>(&this->templateData[22])); |
|
| 351 |
+ *reinterpret_cast<std::uint32_t *>(&this->templateData[0]) = this->style | (this->fontName.empty() ? 0 : DS_SETFONT); |
|
| 352 |
+ *reinterpret_cast<std::uint32_t *>(&this->templateData[4]) = this->exstyle; |
|
| 353 |
+ *reinterpret_cast<std::uint16_t *>(&this->templateData[8]) = controlCount; |
|
| 354 |
+ *reinterpret_cast<std::uint16_t *>(&this->templateData[14]) = this->size.width; |
|
| 355 |
+ *reinterpret_cast<std::uint16_t *>(&this->templateData[16]) = this->size.height; |
|
| 356 |
+ CopyToString(this->title, reinterpret_cast<wchar_t *>(&this->templateData[22])); |
|
| 350 | 357 |
if (!this->fontName.empty()) |
| 351 | 358 |
{
|
| 352 |
- *reinterpret_cast<uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts; |
|
| 353 |
- std::copy_n(this->fontName.c_str(), this->fontName.length(), reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)])); |
|
| 359 |
+ *reinterpret_cast<std::uint16_t *>(&this->templateData[22 + sizeof(wchar_t) * (this->title.length() + 1)]) = this->fontSizeInPts; |
|
| 360 |
+ CopyToString(this->fontName, reinterpret_cast<wchar_t *>(&this->templateData[24 + sizeof(wchar_t) * (this->title.length() + 1)])); |
|
| 354 | 361 |
} |
| 355 | 362 |
|
| 356 | 363 |
std::for_each(this->controls.begin(), this->controls.end(), [&](const std::unique_ptr<DialogControl> &control) |
| ... | ... |
@@ -5,14 +5,15 @@ |
| 5 | 5 |
|
| 6 | 6 |
#pragma once |
| 7 | 7 |
|
| 8 |
-#include <string> |
|
| 9 |
-#include <memory> |
|
| 10 |
-#include <vector> |
|
| 11 | 8 |
#include <algorithm> |
| 9 |
+#include <memory> |
|
| 12 | 10 |
#include <stdexcept> |
| 11 |
+#include <string> |
|
| 12 |
+#include <utility> |
|
| 13 |
+#include <vector> |
|
| 13 | 14 |
#include <cstdint> |
| 14 |
-#include "XSFCommon.h" |
|
| 15 | 15 |
#include "windowsh_wrapper.h" |
| 16 |
+#include "convert.h" |
|
| 16 | 17 |
|
| 17 | 18 |
template<typename T> struct Point |
| 18 | 19 |
{
|
| ... | ... |
@@ -44,21 +45,21 @@ class RelativePosition |
| 44 | 45 |
{
|
| 45 | 46 |
public: |
| 46 | 47 |
Point<short> relativePosition; |
| 47 |
- enum BaseType |
|
| 48 |
+ enum class BaseType |
|
| 48 | 49 |
{
|
| 49 |
- TO_PARENT, |
|
| 50 |
- TO_SIBLING |
|
| 50 |
+ ToParent, |
|
| 51 |
+ ToSibling |
|
| 51 | 52 |
} type; |
| 52 |
- enum PositionType |
|
| 53 |
+ enum class PositionType |
|
| 53 | 54 |
{
|
| 54 |
- FROM_TOP, |
|
| 55 |
- FROM_BOTTOM, |
|
| 56 |
- FROM_LEFT, |
|
| 57 |
- FROM_RIGHT, |
|
| 58 |
- FROM_TOPLEFT, |
|
| 59 |
- FROM_BOTTOMLEFT, |
|
| 60 |
- FROM_TOPRIGHT, |
|
| 61 |
- FROM_BOTTOMRIGHT |
|
| 55 |
+ FromTop, |
|
| 56 |
+ FromBottom, |
|
| 57 |
+ FromLeft, |
|
| 58 |
+ FromRight, |
|
| 59 |
+ FromTopLeft, |
|
| 60 |
+ FromBottomLeft, |
|
| 61 |
+ FromTopRight, |
|
| 62 |
+ FromBottomRight |
|
| 62 | 63 |
} positionType; |
| 63 | 64 |
|
| 64 | 65 |
RelativePosition(const Point<short> &RelPosition, BaseType Type, PositionType PosType) : relativePosition(RelPosition), type(Type), positionType(PosType) { }
|
| ... | ... |
@@ -70,7 +71,7 @@ public: |
| 70 | 71 |
class RelativePositionToParent : public RelativePosition |
| 71 | 72 |
{
|
| 72 | 73 |
public: |
| 73 |
- RelativePositionToParent(const Point<short> &RelPosition, PositionType PosType) : RelativePosition(RelPosition, TO_PARENT, PosType) { }
|
|
| 74 |
+ RelativePositionToParent(const Point<short> &RelPosition, PositionType PosType) : RelativePosition(RelPosition, BaseType::ToParent, PosType) { }
|
|
| 74 | 75 |
RelativePositionToParent *Clone() const { return new RelativePositionToParent(this->relativePosition, this->positionType); }
|
| 75 | 76 |
}; |
| 76 | 77 |
|
| ... | ... |
@@ -79,20 +80,20 @@ class RelativePositionToSibling : public RelativePosition |
| 79 | 80 |
public: |
| 80 | 81 |
short siblingsBack; |
| 81 | 82 |
|
| 82 |
- RelativePositionToSibling(const Point<short> &RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, TO_SIBLING, PosType), siblingsBack(SiblingsBack) { }
|
|
| 83 |
+ RelativePositionToSibling(const Point<short> &RelPosition, PositionType PosType, short SiblingsBack = 1) : RelativePosition(RelPosition, BaseType::ToSibling, PosType), siblingsBack(SiblingsBack) { }
|
|
| 83 | 84 |
RelativePositionToSibling *Clone() const { return new RelativePositionToSibling(this->relativePosition, this->positionType, this->siblingsBack); }
|
| 84 | 85 |
}; |
| 85 | 86 |
|
| 86 |
-enum DialogControlType |
|
| 87 |
+enum class DialogControlType |
|
| 87 | 88 |
{
|
| 88 |
- NO_CONTROL, |
|
| 89 |
- GROUP_CONTROL, |
|
| 90 |
- EDITBOX_CONTROL, |
|
| 91 |
- LABEL_CONTROL, |
|
| 92 |
- CHECKBOX_CONTROL, |
|
| 93 |
- BUTTON_CONTROL, |
|
| 94 |
- LISTBOX_CONTROL, |
|
| 95 |
- COMBOBOX_CONTROL |
|
| 89 |
+ None, |
|
| 90 |
+ Group, |
|
| 91 |
+ EditBox, |
|
| 92 |
+ Label, |
|
| 93 |
+ CheckBox, |
|
| 94 |
+ Button, |
|
| 95 |
+ ListBox, |
|
| 96 |
+ ComboBox |
|
| 96 | 97 |
}; |
| 97 | 98 |
|
| 98 | 99 |
class DialogTemplate; |
| ... | ... |
@@ -102,14 +103,14 @@ class DialogBuilder |
| 102 | 103 |
protected: |
| 103 | 104 |
friend class DialogTemplate; |
| 104 | 105 |
std::wstring title, fontName; |
| 105 |
- uint32_t style, exstyle; |
|
| 106 |
- uint16_t fontSizeInPts; |
|
| 106 |
+ std::uint32_t style, exstyle; |
|
| 107 |
+ std::uint16_t fontSizeInPts; |
|
| 107 | 108 |
Size<short> size; |
| 108 | 109 |
bool resetControls; |
| 109 | 110 |
public: |
| 110 | 111 |
DialogBuilder() : title(L""), fontName(L""), style(0), exstyle(0), fontSizeInPts(0), size(), resetControls(false) { }
|
| 111 | 112 |
DialogBuilder &WithTitle(const std::wstring &Title) { this->title = Title; return *this; }
|
| 112 |
- DialogBuilder &WithFont(const std::wstring &FontName, uint16_t FontSizeInPts) { this->fontName = FontName; this->fontSizeInPts = FontSizeInPts; return *this; }
|
|
| 113 |
+ DialogBuilder &WithFont(const std::wstring &FontName, std::uint16_t FontSizeInPts) { this->fontName = FontName; this->fontSizeInPts = FontSizeInPts; return *this; }
|
|
| 113 | 114 |
DialogBuilder &WithSize(short Width, short Height) { this->size.width = Width; this->size.height = Height; return *this; }
|
| 114 | 115 |
DialogBuilder &WithSize(const Size<short> &Sz) { this->size = Sz; return *this; }
|
| 115 | 116 |
DialogBuilder &ResetControls(bool Reset = true) { this->resetControls = Reset; return *this; }
|
| ... | ... |
@@ -139,7 +140,7 @@ template<class T> class DialogControlBuilder |
| 139 | 140 |
protected: |
| 140 | 141 |
friend class DialogTemplate; |
| 141 | 142 |
DialogControlType controlType; |
| 142 |
- uint32_t style, exstyle; |
|
| 143 |
+ std::uint32_t style, exstyle; |
|
| 143 | 144 |
Rect<short> rect; |
| 144 | 145 |
short id; |
| 145 | 146 |
int index; |
| ... | ... |
@@ -147,7 +148,7 @@ protected: |
| 147 | 148 |
|
| 148 | 149 |
T &me() { return dynamic_cast<T &>(*this); }
|
| 149 | 150 |
public: |
| 150 |
- DialogControlBuilder(DialogControlType Type = NO_CONTROL) : controlType(Type), style(0), exstyle(0), rect(), id(-1), index(-1), relativePosition() { }
|
|
| 151 |
+ DialogControlBuilder(DialogControlType Type = DialogControlType::None) : controlType(Type), style(0), exstyle(0), rect(), id(-1), index(-1), relativePosition() { }
|
|
| 151 | 152 |
virtual ~DialogControlBuilder() { }
|
| 152 | 153 |
T &WithPosition(short X, short Y) { this->rect.position.x = X; this->rect.position.y = Y; return this->me(); }
|
| 153 | 154 |
T &WithPosition(const Point<short> &Position) { this->rect.position = Position; return this->me(); }
|
| ... | ... |
@@ -182,7 +183,7 @@ protected: |
| 182 | 183 |
friend class DialogTemplate; |
| 183 | 184 |
std::wstring groupName; |
| 184 | 185 |
public: |
| 185 |
- DialogGroupBuilder(const std::wstring &newGroupName) : DialogControlBuilder(GROUP_CONTROL), groupName(newGroupName) { }
|
|
| 186 |
+ DialogGroupBuilder(const std::wstring &newGroupName) : DialogControlBuilder(DialogControlType::Group), groupName(newGroupName) { }
|
|
| 186 | 187 |
}; |
| 187 | 188 |
|
| 188 | 189 |
template<class T> class DialogInGroupBuilder : public DialogControlBuilder<T> |
| ... | ... |
@@ -200,7 +201,7 @@ class DialogEditBoxBuilder : public DialogInGroupBuilder<DialogEditBoxBuilder> |
| 200 | 201 |
protected: |
| 201 | 202 |
friend class DialogTemplate; |
| 202 | 203 |
public: |
| 203 |
- DialogEditBoxBuilder() : DialogInGroupBuilder(EDITBOX_CONTROL) { }
|
|
| 204 |
+ DialogEditBoxBuilder() : DialogInGroupBuilder(DialogControlType::EditBox) { }
|
|
| 204 | 205 |
DialogEditBoxBuilder &IsLeftJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_LEFT; return this->me(); }
|
| 205 | 206 |
DialogEditBoxBuilder &IsCenterJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_CENTER; return this->me(); }
|
| 206 | 207 |
DialogEditBoxBuilder &IsRightJustified() { this->style &= ~(ES_LEFT | ES_CENTER | ES_RIGHT); this->style |= ES_RIGHT; return this->me(); }
|
| ... | ... |
@@ -229,7 +230,7 @@ class DialogLabelBuilder : public DialogControlWithLabelBuilder<DialogLabelBuild |
| 229 | 230 |
protected: |
| 230 | 231 |
friend class DialogTemplate; |
| 231 | 232 |
public: |
| 232 |
- DialogLabelBuilder(const std::wstring &Label) : DialogControlWithLabelBuilder(LABEL_CONTROL, Label) { }
|
|
| 233 |
+ DialogLabelBuilder(const std::wstring &Label) : DialogControlWithLabelBuilder(DialogControlType::Label, Label) { }
|
|
| 233 | 234 |
DialogLabelBuilder &IsLeftJustified(bool WithWordWrap = false) |
| 234 | 235 |
{
|
| 235 | 236 |
this->style &= ~(SS_LEFT | SS_CENTER | SS_RIGHT | SS_LEFTNOWORDWRAP); |
| ... | ... |
@@ -311,7 +312,7 @@ class DialogButtonBuilder : public DialogButtonBaseBuilder<DialogButtonBuilder> |
| 311 | 312 |
protected: |
| 312 | 313 |
friend class DialogTemplate; |
| 313 | 314 |
public: |
| 314 |
- DialogButtonBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(BUTTON_CONTROL, Label) { }
|
|
| 315 |
+ DialogButtonBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(DialogControlType::Button, Label) { }
|
|
| 315 | 316 |
DialogButtonBuilder &IsDefault(bool Default = true) { if (Default) this->style |= BS_DEFPUSHBUTTON; else this->style &= ~BS_DEFPUSHBUTTON; return this->me(); }
|
| 316 | 317 |
}; |
| 317 | 318 |
|
| ... | ... |
@@ -320,7 +321,7 @@ class DialogCheckBoxBuilder : public DialogButtonBaseBuilder<DialogCheckBoxBuild |
| 320 | 321 |
protected: |
| 321 | 322 |
friend class DialogTemplate; |
| 322 | 323 |
public: |
| 323 |
- DialogCheckBoxBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(CHECKBOX_CONTROL, Label) { this->style |= BS_AUTOCHECKBOX; }
|
|
| 324 |
+ DialogCheckBoxBuilder(const std::wstring &Label) : DialogButtonBaseBuilder(DialogControlType::CheckBox, Label) { this->style |= BS_AUTOCHECKBOX; }
|
|
| 324 | 325 |
DialogCheckBoxBuilder &WithTextOnLeft(bool TextOnLeft = true) { if (TextOnLeft) this->style |= BS_LEFTTEXT; else this->style &= ~BS_LEFTTEXT; return this->me(); }
|
| 325 | 326 |
DialogCheckBoxBuilder &LikePushButton(bool PushButton = true) { if (PushButton) this->style |= BS_PUSHLIKE; else this->style &= ~BS_PUSHLIKE; return this->me(); }
|
| 326 | 327 |
}; |
| ... | ... |
@@ -330,7 +331,7 @@ class DialogListBoxBuilder : public DialogInGroupBuilder<DialogListBoxBuilder> |
| 330 | 331 |
protected: |
| 331 | 332 |
friend class DialogTemplate; |
| 332 | 333 |
public: |
| 333 |
- DialogListBoxBuilder() : DialogInGroupBuilder(LISTBOX_CONTROL) { }
|
|
| 334 |
+ DialogListBoxBuilder() : DialogInGroupBuilder(DialogControlType::ListBox) { }
|
|
| 334 | 335 |
DialogListBoxBuilder &WithNotify(bool Notify = true) { if (Notify) this->style |= LBS_NOTIFY; else this->style &= ~LBS_NOTIFY; return this->me(); }
|
| 335 | 336 |
DialogListBoxBuilder &WithSort(bool Sort = true) { if (Sort) this->style |= LBS_SORT; else this->style &= ~LBS_SORT; return this->me(); }
|
| 336 | 337 |
DialogListBoxBuilder &WithMultipleSelect(bool MultipleSelect = true) { if (MultipleSelect) this->style |= LBS_MULTIPLESEL; else this->style &= ~LBS_MULTIPLESEL; return this->me(); }
|
| ... | ... |
@@ -348,7 +349,7 @@ class DialogComboBoxBuilder : public DialogInGroupBuilder<DialogComboBoxBuilder> |
| 348 | 349 |
protected: |
| 349 | 350 |
friend class DialogTemplate; |
| 350 | 351 |
public: |
| 351 |
- DialogComboBoxBuilder() : DialogInGroupBuilder(COMBOBOX_CONTROL) { }
|
|
| 352 |
+ DialogComboBoxBuilder() : DialogInGroupBuilder(DialogControlType::ComboBox) { }
|
|
| 352 | 353 |
DialogComboBoxBuilder &IsSimple() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_SIMPLE; return this->me(); }
|
| 353 | 354 |
DialogComboBoxBuilder &IsDropDown() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_DROPDOWN; return this->me(); }
|
| 354 | 355 |
DialogComboBoxBuilder &IsDropDownList() { this->style &= ~(CBS_SIMPLE | CBS_DROPDOWN | CBS_DROPDOWNLIST); this->style |= CBS_DROPDOWNLIST; return this->me(); }
|
| ... | ... |
@@ -372,13 +373,13 @@ class DialogTemplate |
| 372 | 373 |
{
|
| 373 | 374 |
protected: |
| 374 | 375 |
DialogControlType controlType; |
| 375 |
- uint32_t style, exstyle; |
|
| 376 |
+ std::uint32_t style, exstyle; |
|
| 376 | 377 |
Rect<short> rect; |
| 377 | 378 |
short id; |
| 378 | 379 |
std::unique_ptr<RelativePosition> relativePosition; |
| 379 | 380 |
|
| 380 | 381 |
friend class DialogTemplate; |
| 381 |
- DialogControl() : controlType(NO_CONTROL), style(0), exstyle(0), rect(), id(-1), relativePosition() { }
|
|
| 382 |
+ DialogControl() : controlType(DialogControlType::None), style(0), exstyle(0), rect(), id(-1), relativePosition() { }
|
|
| 382 | 383 |
DialogControl(const DialogControl &control) : controlType(control.controlType), style(control.style), exstyle(control.exstyle), rect(control.rect), id(control.id), |
| 383 | 384 |
relativePosition(control.relativePosition ? control.relativePosition->Clone() : nullptr) { }
|
| 384 | 385 |
DialogControl &operator=(const DialogControl &control) |
| ... | ... |
@@ -411,9 +412,9 @@ class DialogTemplate |
| 411 | 412 |
|
| 412 | 413 |
return control; |
| 413 | 414 |
} |
| 414 |
- virtual uint16_t GetControlCount() const { return 1; }
|
|
| 415 |
+ virtual std::uint16_t GetControlCount() const { return 1; }
|
|
| 415 | 416 |
virtual short GetControlHeight() const { return this->rect.size.height; }
|
| 416 |
- virtual std::vector<uint8_t> GenerateControlTemplate() const = 0; |
|
| 417 |
+ virtual std::vector<std::uint8_t> GenerateControlTemplate() const = 0; |
|
| 417 | 418 |
virtual DialogControl *Clone() const = 0; |
| 418 | 419 |
}; |
| 419 | 420 |
|
| ... | ... |
@@ -452,15 +453,15 @@ class DialogTemplate |
| 452 | 453 |
} |
| 453 | 454 |
void CalculatePositions(bool doRightAndBottom = false); |
| 454 | 455 |
void CalculateSize(); |
| 455 |
- uint16_t GetControlCount() const; |
|
| 456 |
- std::vector<uint8_t> GenerateControlTemplate() const; |
|
| 456 |
+ std::uint16_t GetControlCount() const; |
|
| 457 |
+ std::vector<std::uint8_t> GenerateControlTemplate() const; |
|
| 457 | 458 |
DialogGroup *Clone() const { return new DialogGroup(*this); }
|
| 458 | 459 |
}; |
| 459 | 460 |
|
| 460 | 461 |
class DialogControlWithoutLabel : public DialogControl |
| 461 | 462 |
{
|
| 462 | 463 |
protected: |
| 463 |
- uint16_t type; |
|
| 464 |
+ std::uint16_t type; |
|
| 464 | 465 |
|
| 465 | 466 |
friend class DialogTemplate; |
| 466 | 467 |
friend class DialogControl; |
| ... | ... |
@@ -475,7 +476,7 @@ class DialogTemplate |
| 475 | 476 |
return *this; |
| 476 | 477 |
} |
| 477 | 478 |
public: |
| 478 |
- template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, uint16_t Type) |
|
| 479 |
+ template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, std::uint16_t Type) |
|
| 479 | 480 |
{
|
| 480 | 481 |
auto control = DialogControl::CreateControl<Control>(builder); |
| 481 | 482 |
|
| ... | ... |
@@ -483,14 +484,14 @@ class DialogTemplate |
| 483 | 484 |
|
| 484 | 485 |
return control; |
| 485 | 486 |
} |
| 486 |
- virtual std::vector<uint8_t> GenerateControlTemplate() const; |
|
| 487 |
+ virtual std::vector<std::uint8_t> GenerateControlTemplate() const; |
|
| 487 | 488 |
virtual DialogControlWithoutLabel *Clone() const { return new DialogControlWithoutLabel(*this); }
|
| 488 | 489 |
}; |
| 489 | 490 |
|
| 490 | 491 |
class DialogControlWithLabel : public DialogControl |
| 491 | 492 |
{
|
| 492 | 493 |
protected: |
| 493 |
- uint16_t type; |
|
| 494 |
+ std::uint16_t type; |
|
| 494 | 495 |
std::wstring label; |
| 495 | 496 |
|
| 496 | 497 |
friend class DialogTemplate; |
| ... | ... |
@@ -507,7 +508,7 @@ class DialogTemplate |
| 507 | 508 |
return *this; |
| 508 | 509 |
} |
| 509 | 510 |
public: |
| 510 |
- template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, uint16_t Type) |
|
| 511 |
+ template<typename Control, typename Builder> static std::unique_ptr<Control> CreateControl(const DialogControlBuilder<Builder> &builder, std::uint16_t Type) |
|
| 511 | 512 |
{
|
| 512 | 513 |
auto control = DialogControl::CreateControl<Control>(builder); |
| 513 | 514 |
|
| ... | ... |
@@ -516,7 +517,7 @@ class DialogTemplate |
| 516 | 517 |
|
| 517 | 518 |
return control; |
| 518 | 519 |
} |
| 519 |
- virtual std::vector<uint8_t> GenerateControlTemplate() const; |
|
| 520 |
+ virtual std::vector<std::uint8_t> GenerateControlTemplate() const; |
|
| 520 | 521 |
virtual DialogControlWithLabel *Clone() const { return new DialogControlWithLabel(*this); }
|
| 521 | 522 |
}; |
| 522 | 523 |
|
| ... | ... |
@@ -587,12 +588,12 @@ class DialogTemplate |
| 587 | 588 |
}; |
| 588 | 589 |
|
| 589 | 590 |
std::wstring title; |
| 590 |
- uint32_t style, exstyle; |
|
| 591 |
+ std::uint32_t style, exstyle; |
|
| 591 | 592 |
std::wstring fontName; |
| 592 |
- uint16_t fontSizeInPts; |
|
| 593 |
+ std::uint16_t fontSizeInPts; |
|
| 593 | 594 |
Size<short> size; |
| 594 | 595 |
DialogTemplate::Controls controls; |
| 595 |
- std::vector<uint8_t> templateData; |
|
| 596 |
+ std::vector<std::uint8_t> templateData; |
|
| 596 | 597 |
|
| 597 | 598 |
template<typename Builder> void AddControlToGroup(std::unique_ptr<DialogControl> &&control, const DialogControlBuilder<Builder> &builder) |
| 598 | 599 |
{
|
| ... | ... |
@@ -608,7 +609,7 @@ class DialogTemplate |
| 608 | 609 |
{
|
| 609 | 610 |
for (auto curr = this->controls.begin(), end = this->controls.end(); curr != end; ++curr) |
| 610 | 611 |
{
|
| 611 |
- if ((*curr)->controlType != GROUP_CONTROL) |
|
| 612 |
+ if ((*curr)->controlType != DialogControlType::Group) |
|
| 612 | 613 |
continue; |
| 613 | 614 |
DialogGroup *group = dynamic_cast<DialogGroup *>(curr->get()); |
| 614 | 615 |
if (group->groupName == groupBuilder.groupName) |
| ... | ... |
@@ -623,7 +624,7 @@ class DialogTemplate |
| 623 | 624 |
throw std::runtime_error("Group " + ConvertFuncs::WStringToString(groupBuilder.groupName) + " was not found.");
|
| 624 | 625 |
} |
| 625 | 626 |
} |
| 626 |
- uint16_t GetTotalControlCount() const; |
|
| 627 |
+ std::uint16_t GetTotalControlCount() const; |
|
| 627 | 628 |
bool CalculateControlPosition(short index, bool doRightAndBottom = false); |
| 628 | 629 |
void CalculateSize(); |
| 629 | 630 |
public: |
| ... | ... |
@@ -12,6 +12,7 @@ |
| 12 | 12 |
#include <string> |
| 13 | 13 |
#define _USE_MATH_DEFINES |
| 14 | 14 |
#include <cmath> |
| 15 |
+#include <cstddef> |
|
| 15 | 16 |
#include <cstdint> |
| 16 | 17 |
#include <cwchar> |
| 17 | 18 |
#include <cstring> |
| ... | ... |
@@ -25,14 +26,14 @@ template<typename T> inline bool fEqual(T x, T y, int N = 1) |
| 25 | 26 |
return diff <= tolerance * std::abs(x) && diff <= tolerance * std::abs(y); |
| 26 | 27 |
} |
| 27 | 28 |
|
| 28 |
-inline uint32_t Get32BitsLE(const uint8_t *input) |
|
| 29 |
+inline std::uint32_t Get32BitsLE(const std::uint8_t *input) |
|
| 29 | 30 |
{
|
| 30 | 31 |
return input[0] | (input[1] << 8) | (input[2] << 16) | (input[3] << 24); |
| 31 | 32 |
} |
| 32 | 33 |
|
| 33 |
-inline uint32_t Get32BitsLE(std::ifstream &input) |
|
| 34 |
+inline std::uint32_t Get32BitsLE(std::ifstream &input) |
|
| 34 | 35 |
{
|
| 35 |
- uint8_t bytes[4]; |
|
| 36 |
+ std::uint8_t bytes[4]; |
|
| 36 | 37 |
input.read(reinterpret_cast<char *>(bytes), 4); |
| 37 | 38 |
return Get32BitsLE(bytes); |
| 38 | 39 |
} |
| ... | ... |
@@ -44,7 +45,7 @@ template<typename T> inline T NextHighestPowerOf2(T value) |
| 44 | 45 |
if (value < 1) |
| 45 | 46 |
return 1; |
| 46 | 47 |
--value; |
| 47 |
- for (size_t i = 1; i < sizeof(T) * std::numeric_limits<unsigned char>::digits; i <<= 1) |
|
| 48 |
+ for (std::size_t i = 1; i < sizeof(T) * std::numeric_limits<unsigned char>::digits; i <<= 1) |
|
| 48 | 49 |
value |= value >> i; |
| 49 | 50 |
return value + 1; |
| 50 | 51 |
} |
| ... | ... |
@@ -60,20 +61,20 @@ template<typename T1, typename T2> inline void clamp(T1 &valueToClamp, const T2 |
| 60 | 61 |
|
| 61 | 62 |
inline void CopyToString(const std::wstring &src, wchar_t *dst) |
| 62 | 63 |
{
|
| 63 |
- wcscpy(dst, src.c_str()); |
|
| 64 |
+ std::wcscpy(dst, src.c_str()); |
|
| 64 | 65 |
} |
| 65 | 66 |
|
| 66 | 67 |
inline void CopyToString(const std::string &src, wchar_t *dst) |
| 67 | 68 |
{
|
| 68 |
- wcscpy(dst, ConvertFuncs::StringToWString(src).c_str()); |
|
| 69 |
+ std::wcscpy(dst, ConvertFuncs::StringToWString(src).c_str()); |
|
| 69 | 70 |
} |
| 70 | 71 |
|
| 71 | 72 |
inline void CopyToString(const std::string &src, char *dst) |
| 72 | 73 |
{
|
| 73 |
- strcpy(dst, src.c_str()); |
|
| 74 |
+ std::strcpy(dst, src.c_str()); |
|
| 74 | 75 |
} |
| 75 | 76 |
|
| 76 | 77 |
inline void CopyToString(const std::wstring &src, char *dst) |
| 77 | 78 |
{
|
| 78 |
- strcpy(dst, ConvertFuncs::WStringToString(src).c_str()); |
|
| 79 |
+ std::strcpy(dst, ConvertFuncs::WStringToString(src).c_str()); |
|
| 79 | 80 |
} |
| ... | ... |
@@ -5,7 +5,13 @@ |
| 5 | 5 |
* Partially based on the vio*sf framework |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 |
+#include <algorithm> |
|
| 9 |
+#include <string> |
|
| 10 |
+#include <vector> |
|
| 11 |
+#include "windowsh_wrapper.h" |
|
| 12 |
+#include <windowsx.h> |
|
| 8 | 13 |
#include "XSFConfig.h" |
| 14 |
+#include "XSFFile.h" |
|
| 9 | 15 |
#include "XSFPlayer.h" |
| 10 | 16 |
#include "convert.h" |
| 11 | 17 |
|
| ... | ... |
@@ -38,10 +44,10 @@ std::string XSFConfig::initDefaultLength = "1:55"; |
| 38 | 44 |
std::string XSFConfig::initDefaultFade = "5"; |
| 39 | 45 |
std::string XSFConfig::initTitleFormat = "%game%[ - [%disc%.]%track%] - %title%"; |
| 40 | 46 |
double XSFConfig::initVolume = 1.0; |
| 41 |
-VolumeType XSFConfig::initVolumeType = VOLUMETYPE_REPLAYGAIN_ALBUM; |
|
| 42 |
-PeakType XSFConfig::initPeakType = PEAKTYPE_REPLAYGAIN_TRACK; |
|
| 47 |
+VolumeType XSFConfig::initVolumeType = VolumeType::ReplayGainAlbum; |
|
| 48 |
+PeakType XSFConfig::initPeakType = PeakType::ReplayGainTrack; |
|
| 43 | 49 |
|
| 44 |
-XSFConfig::XSFConfig() : playInfinitely(false), skipSilenceOnStartSec(0), detectSilenceSec(0), defaultLength(0), defaultFade(0), volume(0.0), volumeType(VOLUMETYPE_NONE), peakType(PEAKTYPE_NONE), |
|
| 50 |
+XSFConfig::XSFConfig() : playInfinitely(false), skipSilenceOnStartSec(0), detectSilenceSec(0), defaultLength(0), defaultFade(0), volume(0.0), volumeType(VolumeType::None), peakType(PeakType::None), |
|
| 45 | 51 |
sampleRate(0), titleFormat(""), configDialog(), configDialogProperty(), infoDialog(), supportedSampleRates(), configIO(XSFConfigIO::Create())
|
| 46 | 52 |
{
|
| 47 | 53 |
} |
| ... | ... |
@@ -95,84 +101,84 @@ void XSFConfig::SaveConfig() |
| 95 | 101 |
void XSFConfig::GenerateDialogs() |
| 96 | 102 |
{
|
| 97 | 103 |
this->infoDialog = DialogBuilder().IsPopup().WithBorder().WithDialogFrame().WithDialogModalFrame().WithSystemMenu().WithFont(L"MS Shell Dlg", 8); |
| 98 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Title:").WithSize(50, 8).WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(7, 10)).IsRightJustified()); |
|
| 99 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 104 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Title:").WithSize(50, 8).WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(7, 10)).IsRightJustified()); |
|
| 105 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 100 | 106 |
WithTabStop().WithID(idInfoTitle)); |
| 101 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Artist:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 102 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 107 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Artist:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 108 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 103 | 109 |
WithTabStop().WithID(idInfoArtist)); |
| 104 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Game:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 105 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 110 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Game:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 111 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 106 | 112 |
WithTabStop().WithID(idInfoGame)); |
| 107 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Year:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 108 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 113 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Year:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 114 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 109 | 115 |
WithTabStop().WithID(idInfoYear)); |
| 110 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Genre:").WithSize(25, 8).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, 3)).IsRightJustified()); |
|
| 111 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(140, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 116 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Genre:").WithSize(25, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, 3)).IsRightJustified()); |
|
| 117 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(140, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 112 | 118 |
WithTabStop().WithID(idInfoGenre)); |
| 113 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Copyright:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 4).IsRightJustified()); |
|
| 114 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 119 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Copyright:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 4).IsRightJustified()); |
|
| 120 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoHScroll().WithBorder(). |
|
| 115 | 121 |
WithTabStop().WithID(idInfoCopyright)); |
| 116 |
- this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Comment:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 117 |
- this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 54).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified().WithAutoVScroll().WithBorder(). |
|
| 122 |
+ this->infoDialog.AddLabelControl(DialogLabelBuilder(L"Comment:").WithSize(50, 8).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsRightJustified()); |
|
| 123 |
+ this->infoDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(200, 54).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified().WithAutoVScroll().WithBorder(). |
|
| 118 | 124 |
WithTabStop().WithID(idInfoComment).WithVerticalScrollbar().WithWantReturn().IsMultiline()); |
| 119 | 125 |
|
| 120 | 126 |
this->configDialog = DialogBuilder().WithTitle(ConvertFuncs::StringToWString(XSFConfig::commonName + " v" + XSFConfig::versionNumber)).IsPopup().WithBorder().WithDialogFrame().WithDialogModalFrame().WithSystemMenu().WithFont(L"MS Shell Dlg", 8); |
| 121 |
- this->configDialog.AddGroupControl(DialogGroupBuilder(L"General").WithRelativePositionToParent(RelativePositionToParent::FROM_TOPLEFT, Point<short>(7, 7))); |
|
| 122 |
- this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Play infinitely").WithSize(60, 10).InGroup(L"General").WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 11)).WithTabStop(). |
|
| 127 |
+ this->configDialog.AddGroupControl(DialogGroupBuilder(L"General").WithRelativePositionToParent(RelativePositionToParent::PositionType::FromTopLeft, Point<short>(7, 7))); |
|
| 128 |
+ this->configDialog.AddCheckBoxControl(DialogCheckBoxBuilder(L"Play infinitely").WithSize(60, 10).InGroup(L"General").WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 11)).WithTabStop(). |
|
| 123 | 129 |
WithID(idPlayInfinitely)); |
| 124 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default play length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7)). |
|
| 130 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default play length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7)). |
|
| 125 | 131 |
IsLeftJustified()); |
| 126 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified(). |
|
| 132 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified(). |
|
| 127 | 133 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idDefaultLength)); |
| 128 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default fadeout length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2). |
|
| 134 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Default fadeout length (m:s)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2). |
|
| 129 | 135 |
IsLeftJustified()); |
| 130 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified(). |
|
| 136 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified(). |
|
| 131 | 137 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idDefaultFade)); |
| 132 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Skip silence on start (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2). |
|
| 138 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Skip silence on start (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2). |
|
| 133 | 139 |
IsLeftJustified()); |
| 134 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified(). |
|
| 140 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified(). |
|
| 135 | 141 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idSkipSilenceOnStartSec)); |
| 136 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Detect silence (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2). |
|
| 142 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Detect silence (sec)").WithSize(85, 8).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2). |
|
| 137 | 143 |
IsLeftJustified()); |
| 138 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified(). |
|
| 144 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"General").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified(). |
|
| 139 | 145 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idDetectSilenceSec)); |
| 140 |
- this->configDialog.AddGroupControl(DialogGroupBuilder(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7))); |
|
| 141 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Volume").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 14)).IsLeftJustified()); |
|
| 142 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).IsLeftJustified(). |
|
| 146 |
+ this->configDialog.AddGroupControl(DialogGroupBuilder(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7))); |
|
| 147 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Volume").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 14)).IsLeftJustified()); |
|
| 148 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(25, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).IsLeftJustified(). |
|
| 143 | 149 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idVolume)); |
| 144 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"ReplayGain").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 145 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idReplayGain). |
|
| 150 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"ReplayGain").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 151 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idReplayGain). |
|
| 146 | 152 |
IsDropDownList().WithTabStop()); |
| 147 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Clip Protect").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 148 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idClipProtect). |
|
| 153 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Clip Protect").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 154 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(78, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idClipProtect). |
|
| 149 | 155 |
IsDropDownList().WithTabStop()); |
| 150 |
- this->configDialog.AddLabelControl(DialogLabelBuilder(L"Sample Rate").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 151 |
- this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(50, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(5, -3)).WithID(idSampleRate). |
|
| 156 |
+ this->configDialog.AddLabelControl(DialogLabelBuilder(L"Sample Rate").WithSize(50, 8).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 10), 2).IsLeftJustified()); |
|
| 157 |
+ this->configDialog.AddComboBoxControl(DialogComboBoxBuilder().WithSize(50, 14).InGroup(L"Output").WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(5, -3)).WithID(idSampleRate). |
|
| 152 | 158 |
IsDropDownList().WithTabStop()); |
| 153 |
- this->configDialog.AddGroupControl(DialogGroupBuilder(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 7))); |
|
| 159 |
+ this->configDialog.AddGroupControl(DialogGroupBuilder(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 7))); |
|
| 154 | 160 |
this->configDialog.AddLabelControl(DialogLabelBuilder(L"NOTE: This is only used if Advanced Title Formatting is disabled in Winamp.").WithSize(150, 16).InGroup(L"Title Format"). |
| 155 |
- WithRelativePositionToParent(RelativePosition::FROM_TOPLEFT, Point<short>(6, 11)).IsLeftJustified()); |
|
| 156 |
- this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(150, 14).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 4)).IsLeftJustified(). |
|
| 161 |
+ WithRelativePositionToParent(RelativePosition::PositionType::FromTopLeft, Point<short>(6, 11)).IsLeftJustified()); |
|
| 162 |
+ this->configDialog.AddEditBoxControl(DialogEditBoxBuilder().WithSize(150, 14).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 4)).IsLeftJustified(). |
|
| 157 | 163 |
WithAutoHScroll().WithBorder().WithTabStop().WithID(idTitleFormat)); |
| 158 | 164 |
this->configDialog.AddLabelControl(DialogLabelBuilder(L"Names between percent symbols (e.g. %game%, %title%) will be replaced with the respective value from the file's tags. Using square brackets around any " |
| 159 | 165 |
L"items will cause them to only be displayed if there was a replacement done (e.g. [%disc%.] will display 01. if disc was in the tags as 01, but will display nothing if disc was not in the tags). Square " |
| 160 |
- L"bracket blocks can be nested.").WithSize(150, 72).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMLEFT, Point<short>(0, 4)).IsLeftJustified()); |
|
| 166 |
+ L"bracket blocks can be nested.").WithSize(150, 72).InGroup(L"Title Format").WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomLeft, Point<short>(0, 4)).IsLeftJustified()); |
|
| 161 | 167 |
|
| 162 | 168 |
this->GenerateSpecificDialogs(); |
| 163 | 169 |
|
| 164 |
- this->infoDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop()); |
|
| 165 |
- this->infoDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop()); |
|
| 170 |
+ this->infoDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop()); |
|
| 171 |
+ this->infoDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop()); |
|
| 166 | 172 |
this->infoDialog.AutoSize(); |
| 167 | 173 |
|
| 168 | 174 |
this->configDialogProperty = this->configDialog; |
| 169 | 175 |
this->configDialogProperty = DialogBuilder().IsChild().IsControlWindow().WithFont(L"MS Shell Dlg", 8); |
| 170 | 176 |
this->configDialogProperty.AutoSize(); |
| 171 | 177 |
|
| 172 |
- this->configDialog.AddButtonControl(DialogButtonBuilder(L"Reset Defaults").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-50, 7)).WithID(idResetDefaults). |
|
| 178 |
+ this->configDialog.AddButtonControl(DialogButtonBuilder(L"Reset Defaults").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-50, 7)).WithID(idResetDefaults). |
|
| 173 | 179 |
WithTabStop()); |
| 174 |
- this->configDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_BOTTOMRIGHT, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop()); |
|
| 175 |
- this->configDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::FROM_TOPRIGHT, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop()); |
|
| 180 |
+ this->configDialog.AddButtonControl(DialogButtonBuilder(L"OK").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromBottomRight, Point<short>(-104, 7)).WithID(IDOK).IsDefault().WithTabStop()); |
|
| 181 |
+ this->configDialog.AddButtonControl(DialogButtonBuilder(L"Cancel").WithSize(50, 14).WithRelativePositionToSibling(RelativePosition::PositionType::FromTopRight, Point<short>(4, 0)).WithID(IDCANCEL).WithTabStop()); |
|
| 176 | 182 |
this->configDialog.AutoSize(); |
| 177 | 183 |
} |
| 178 | 184 |
|
| ... | ... |
@@ -233,11 +239,11 @@ INT_PTR CALLBACK XSFConfig::ConfigDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wPa |
| 233 | 239 |
SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Use Volume Tag")); |
| 234 | 240 |
SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Track")); |
| 235 | 241 |
SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Album")); |
| 236 |
- SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, this->volumeType, 0); |
|
| 242 |
+ SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, static_cast<WPARAM>(this->volumeType), 0); |
|
| 237 | 243 |
SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Disabled")); |
| 238 | 244 |
SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Track")); |
| 239 | 245 |
SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Album")); |
| 240 |
- SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, this->peakType, 0); |
|
| 246 |
+ SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, static_cast<WPARAM>(this->peakType), 0); |
|
| 241 | 247 |
for (unsigned x = 0, rates = this->supportedSampleRates.size(); x < rates; ++x) |
| 242 | 248 |
{
|
| 243 | 249 |
unsigned rate = this->supportedSampleRates[x]; |
| ... | ... |
@@ -336,8 +342,8 @@ void XSFConfig::ResetConfigDefaults(HWND hwndDlg) |
| 336 | 342 |
SetWindowTextW(GetDlgItem(hwndDlg, idSkipSilenceOnStartSec), ConvertFuncs::StringToWString(XSFConfig::initSkipSilenceOnStartSec).c_str()); |
| 337 | 343 |
SetWindowTextW(GetDlgItem(hwndDlg, idDetectSilenceSec), ConvertFuncs::StringToWString(XSFConfig::initDetectSilenceSec).c_str()); |
| 338 | 344 |
SetWindowTextW(GetDlgItem(hwndDlg, idVolume), ConvertFuncs::TrimDoubleString(std::to_wstring(XSFConfig::initVolume)).c_str()); |
| 339 |
- SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, XSFConfig::initVolumeType, 0); |
|
| 340 |
- SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, XSFConfig::initPeakType, 0); |
|
| 345 |
+ SendMessageW(GetDlgItem(hwndDlg, idReplayGain), CB_SETCURSEL, static_cast<WPARAM>(XSFConfig::initVolumeType), 0); |
|
| 346 |
+ SendMessageW(GetDlgItem(hwndDlg, idClipProtect), CB_SETCURSEL, static_cast<WPARAM>(XSFConfig::initPeakType), 0); |
|
| 341 | 347 |
auto found = std::find(this->supportedSampleRates.begin(), this->supportedSampleRates.end(), XSFConfig::initSampleRate); |
| 342 | 348 |
SendMessageW(GetDlgItem(hwndDlg, idSampleRate), CB_SETCURSEL, found - this->supportedSampleRates.begin(), 0); |
| 343 | 349 |
SetWindowTextW(GetDlgItem(hwndDlg, idTitleFormat), ConvertFuncs::StringToWString(XSFConfig::initTitleFormat).c_str()); |
| ... | ... |
@@ -8,11 +8,16 @@ |
| 8 | 8 |
#pragma once |
| 9 | 9 |
|
| 10 | 10 |
#include <memory> |
| 11 |
-#include "XSFPlayer.h" |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <type_traits> |
|
| 13 |
+#include <vector> |
|
| 12 | 14 |
#include "DialogBuilder.h" |
| 13 | 15 |
#include "convert.h" |
| 14 | 16 |
#include "windowsh_wrapper.h" |
| 15 |
-#include <windowsx.h> |
|
| 17 |
+ |
|
| 18 |
+enum class PeakType; |
|
| 19 |
+enum class VolumeType; |
|
| 20 |
+class XSFPlayer; |
|
| 16 | 21 |
|
| 17 | 22 |
class XSFConfigIO |
| 18 | 23 |
{
|
| ... | ... |
@@ -28,11 +33,11 @@ private: |
| 28 | 33 |
} |
| 29 | 34 |
|
| 30 | 35 |
// non-enum versions |
| 31 |
- template<typename T> typename std::enable_if_t<!std::is_enum_v<T> &&std::is_arithmetic_v<T>, T> GetValueInternal(const std::string &name, const T &defaultValue) const |
|
| 36 |
+ template<typename T> typename std::enable_if_t<!std::is_enum_v<T> && std::is_arithmetic_v<T>, T> GetValueInternal(const std::string &name, const T &defaultValue) const |
|
| 32 | 37 |
{
|
| 33 | 38 |
return convertTo<T>(this->GetValueString(name, std::to_string(defaultValue))); |
| 34 | 39 |
} |
| 35 |
- template<typename T> typename std::enable_if_t<!std::is_enum_v<T> &&std::is_arithmetic_v<T>> SetValueInternal(const std::string &name, const T &value) |
|
| 40 |
+ template<typename T> typename std::enable_if_t<!std::is_enum_v<T> && std::is_arithmetic_v<T>> SetValueInternal(const std::string &name, const T &value) |
|
| 36 | 41 |
{
|
| 37 | 42 |
this->SetValueString(name, std::to_string(value)); |
| 38 | 43 |
} |
| ... | ... |
@@ -6,8 +6,12 @@ |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 | 8 |
#include <filesystem> |
| 9 |
+#include <stdexcept> |
|
| 10 |
+#include <string> |
|
| 11 |
+#include <vector> |
|
| 12 |
+#include "windowsh_wrapper.h" |
|
| 9 | 13 |
#include "XSFConfig.h" |
| 10 |
-#include "XSFCommon.h" |
|
| 14 |
+#include "convert.h" |
|
| 11 | 15 |
#include "winamp/in2.h" |
| 12 | 16 |
#include "winamp/wa_ipc.h" |
| 13 | 17 |
|
| ... | ... |
@@ -7,17 +7,22 @@ |
| 7 | 7 |
|
| 8 | 8 |
#include <algorithm> |
| 9 | 9 |
#include <filesystem> |
| 10 |
-#include <functional> |
|
| 10 |
+#include <fstream> |
|
| 11 | 11 |
#include <stdexcept> |
| 12 |
+#include <string> |
|
| 13 |
+#include <vector> |
|
| 14 |
+#include <cmath> |
|
| 15 |
+#include <cstddef> |
|
| 16 |
+#include <cstdint> |
|
| 17 |
+#include "XSFCommon.h" |
|
| 18 |
+#include "XSFFile.h" |
|
| 19 |
+#include "convert.h" |
|
| 12 | 20 |
#if defined(_WIN32) && !defined(_MSC_VER) |
| 13 | 21 |
# include "fstream_wfopen.h" |
| 14 | 22 |
#endif |
| 15 | 23 |
#include "zlib.h" |
| 16 |
-#include "XSFFile.h" |
|
| 17 |
-#include "XSFCommon.h" |
|
| 18 |
-#include "convert.h" |
|
| 19 | 24 |
|
| 20 |
-static inline void Set32BitsLE(uint32_t input, uint8_t *output) |
|
| 25 |
+static inline void Set32BitsLE(std::uint32_t input, std::uint8_t *output) |
|
| 21 | 26 |
{
|
| 22 | 27 |
output[0] = input & 0xFF; |
| 23 | 28 |
output[1] = (input >> 8) & 0xFF; |
| ... | ... |
@@ -65,7 +70,7 @@ XSFFile::XSFFile(const std::string &filename) : xSFType(0), hasFile(false), rawD |
| 65 | 70 |
this->ReadXSF(filename, 0, 0, true); |
| 66 | 71 |
} |
| 67 | 72 |
|
| 68 |
-XSFFile::XSFFile(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(filename) |
|
| 73 |
+XSFFile::XSFFile(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(filename) |
|
| 69 | 74 |
{
|
| 70 | 75 |
this->ReadXSF(filename, programSizeOffset, programHeaderSize); |
| 71 | 76 |
} |
| ... | ... |
@@ -76,13 +81,13 @@ XSFFile::XSFFile(const std::wstring &filename) : xSFType(0), hasFile(false), raw |
| 76 | 81 |
this->ReadXSF(filename, 0, 0, true); |
| 77 | 82 |
} |
| 78 | 83 |
|
| 79 |
-XSFFile::XSFFile(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(ConvertFuncs::WStringToString(filename)) |
|
| 84 |
+XSFFile::XSFFile(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize) : xSFType(0), hasFile(false), rawData(), reservedSection(), programSection(), tags(), fileName(ConvertFuncs::WStringToString(filename)) |
|
| 80 | 85 |
{
|
| 81 | 86 |
this->ReadXSF(filename, programSizeOffset, programHeaderSize); |
| 82 | 87 |
} |
| 83 | 88 |
#endif |
| 84 | 89 |
|
| 85 |
-void XSFFile::ReadXSF(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly) |
|
| 90 |
+void XSFFile::ReadXSF(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly) |
|
| 86 | 91 |
{
|
| 87 | 92 |
if (!std::filesystem::is_regular_file(filename)) |
| 88 | 93 |
throw std::logic_error("File " + filename + " does not exist.");
|
| ... | ... |
@@ -97,7 +102,7 @@ void XSFFile::ReadXSF(const std::string &filename, uint32_t programSizeOffset, u |
| 97 | 102 |
} |
| 98 | 103 |
|
| 99 | 104 |
#ifdef _WIN32 |
| 100 |
-void XSFFile::ReadXSF(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly) |
|
| 105 |
+void XSFFile::ReadXSF(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly) |
|
| 101 | 106 |
{
|
| 102 | 107 |
if (!std::filesystem::is_regular_file(filename)) |
| 103 | 108 |
throw std::logic_error("File " + ConvertFuncs::WStringToString(filename) + " does not exist.");
|
| ... | ... |
@@ -116,7 +121,7 @@ void XSFFile::ReadXSF(const std::wstring &filename, uint32_t programSizeOffset, |
| 116 | 121 |
} |
| 117 | 122 |
#endif |
| 118 | 123 |
|
| 119 |
-void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly) |
|
| 124 |
+void XSFFile::ReadXSF(std::ifstream &xSF, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly) |
|
| 120 | 125 |
{
|
| 121 | 126 |
xSF.seekg(0, std::ifstream::end); |
| 122 | 127 |
auto filesize = xSF.tellg(); |
| ... | ... |
@@ -139,7 +144,7 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 139 | 144 |
if (filesize < 16) |
| 140 | 145 |
throw std::runtime_error("File is too small.");
|
| 141 | 146 |
|
| 142 |
- uint32_t reservedSize = Get32BitsLE(xSF), programCompressedSize = Get32BitsLE(xSF); |
|
| 147 |
+ std::uint32_t reservedSize = Get32BitsLE(xSF), programCompressedSize = Get32BitsLE(xSF); |
|
| 143 | 148 |
this->rawData.resize(reservedSize + programCompressedSize + 16); |
| 144 | 149 |
Set32BitsLE(reservedSize, &this->rawData[4]); |
| 145 | 150 |
Set32BitsLE(programCompressedSize, &this->rawData[8]); |
| ... | ... |
@@ -169,11 +174,11 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 169 | 174 |
xSF.read(reinterpret_cast<char *>(&this->rawData[reservedSize + 16]), programCompressedSize); |
| 170 | 175 |
else |
| 171 | 176 |
{
|
| 172 |
- auto programSectionCompressed = std::vector<uint8_t>(programCompressedSize); |
|
| 177 |
+ auto programSectionCompressed = std::vector<std::uint8_t>(programCompressedSize); |
|
| 173 | 178 |
xSF.read(reinterpret_cast<char *>(&programSectionCompressed[0]), programCompressedSize); |
| 174 | 179 |
std::copy_n(&programSectionCompressed[0], programCompressedSize, &this->rawData[reservedSize + 16]); |
| 175 | 180 |
|
| 176 |
- auto programSectionUncompressed = std::vector<uint8_t>(programHeaderSize); |
|
| 181 |
+ auto programSectionUncompressed = std::vector<std::uint8_t>(programHeaderSize); |
|
| 177 | 182 |
unsigned long programUncompressedSize = programHeaderSize; |
| 178 | 183 |
uncompress(&programSectionUncompressed[0], &programUncompressedSize, &programSectionCompressed[0], programCompressedSize); |
| 179 | 184 |
programUncompressedSize = Get32BitsLE(&programSectionUncompressed[programSizeOffset]) + programHeaderSize; |
| ... | ... |
@@ -231,7 +236,7 @@ void XSFFile::ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t p |
| 231 | 236 |
this->hasFile = true; |
| 232 | 237 |
} |
| 233 | 238 |
|
| 234 |
-bool XSFFile::IsValidType(uint8_t type) const |
|
| 239 |
+bool XSFFile::IsValidType(std::uint8_t type) const |
|
| 235 | 240 |
{
|
| 236 | 241 |
return this->xSFType == type; |
| 237 | 242 |
} |
| ... | ... |
@@ -250,22 +255,22 @@ bool XSFFile::HasFile() const |
| 250 | 255 |
return this->hasFile; |
| 251 | 256 |
} |
| 252 | 257 |
|
| 253 |
-std::vector<uint8_t> &XSFFile::GetReservedSection() |
|
| 258 |
+std::vector<std::uint8_t> &XSFFile::GetReservedSection() |
|
| 254 | 259 |
{
|
| 255 | 260 |
return this->reservedSection; |
| 256 | 261 |
} |
| 257 | 262 |
|
| 258 |
-std::vector<uint8_t> XSFFile::GetReservedSection() const |
|
| 263 |
+std::vector<std::uint8_t> XSFFile::GetReservedSection() const |
|
| 259 | 264 |
{
|
| 260 | 265 |
return this->reservedSection; |
| 261 | 266 |
} |
| 262 | 267 |
|
| 263 |
-std::vector<uint8_t> &XSFFile::GetProgramSection() |
|
| 268 |
+std::vector<std::uint8_t> &XSFFile::GetProgramSection() |
|
| 264 | 269 |
{
|
| 265 | 270 |
return this->programSection; |
| 266 | 271 |
} |
| 267 | 272 |
|
| 268 |
-std::vector<uint8_t> XSFFile::GetProgramSection() const |
|
| 273 |
+std::vector<std::uint8_t> XSFFile::GetProgramSection() const |
|
| 269 | 274 |
{
|
| 270 | 275 |
return this->programSection; |
| 271 | 276 |
} |
| ... | ... |
@@ -322,19 +327,19 @@ unsigned long XSFFile::GetFadeMS(unsigned long defaultFade) const |
| 322 | 327 |
|
| 323 | 328 |
double XSFFile::GetVolume(VolumeType preferredVolumeType, PeakType preferredPeakType) const |
| 324 | 329 |
{
|
| 325 |
- if (preferredVolumeType == VOLUMETYPE_NONE) |
|
| 330 |
+ if (preferredVolumeType == VolumeType::None) |
|
| 326 | 331 |
return 1.0; |
| 327 | 332 |
std::string replaygain_album_gain = this->GetTagValue("replaygain_album_gain"), replaygain_album_peak = this->GetTagValue("replaygain_album_peak");
|
| 328 | 333 |
std::string replaygain_track_gain = this->GetTagValue("replaygain_track_gain"), replaygain_track_peak = this->GetTagValue("replaygain_track_peak");
|
| 329 | 334 |
std::string volume = this->GetTagValue("volume");
|
| 330 | 335 |
double gain = 0.0; |
| 331 | 336 |
bool hadReplayGain = false; |
| 332 |
- if (preferredVolumeType == VOLUMETYPE_REPLAYGAIN_ALBUM && !replaygain_album_gain.empty()) |
|
| 337 |
+ if (preferredVolumeType == VolumeType::ReplayGainAlbum && !replaygain_album_gain.empty()) |
|
| 333 | 338 |
{
|
| 334 | 339 |
gain = convertTo<double>(replaygain_album_gain); |
| 335 | 340 |
hadReplayGain = true; |
| 336 | 341 |
} |
| 337 |
- if (!hadReplayGain && preferredVolumeType != VOLUMETYPE_VOLUME && !replaygain_track_gain.empty()) |
|
| 342 |
+ if (!hadReplayGain && preferredVolumeType != VolumeType::Volume && !replaygain_track_gain.empty()) |
|
| 338 | 343 |
{
|
| 339 | 344 |
gain = convertTo<double>(replaygain_track_gain); |
| 340 | 345 |
hadReplayGain = true; |
| ... | ... |
@@ -342,9 +347,9 @@ double XSFFile::GetVolume(VolumeType preferredVolumeType, PeakType preferredPeak |
| 342 | 347 |
if (hadReplayGain) |
| 343 | 348 |
{
|
| 344 | 349 |
double vol = std::pow(10.0, gain / 20.0), peak = 1.0; |
| 345 |
- if (preferredPeakType == PEAKTYPE_REPLAYGAIN_ALBUM && !replaygain_album_peak.empty()) |
|
| 350 |
+ if (preferredPeakType == PeakType::ReplayGainAlbum && !replaygain_album_peak.empty()) |
|
| 346 | 351 |
peak = convertTo<double>(replaygain_album_peak); |
| 347 |
- else if (preferredPeakType != PEAKTYPE_NONE && !replaygain_track_peak.empty()) |
|
| 352 |
+ else if (preferredPeakType != PeakType::None && !replaygain_track_peak.empty()) |
|
| 348 | 353 |
peak = convertTo<double>(replaygain_track_peak); |
| 349 | 354 |
return !fEqual(peak, 1.0) ? std::min(vol, 1.0 / peak) : vol; |
| 350 | 355 |
} |
| ... | ... |
@@ -354,12 +359,12 @@ double XSFFile::GetVolume(VolumeType preferredVolumeType, PeakType preferredPeak |
| 354 | 359 |
std::string XSFFile::FormattedTitleOptionalBlock(const std::string &block, bool &hadReplacement, unsigned level) const |
| 355 | 360 |
{
|
| 356 | 361 |
std::string formattedBlock; |
| 357 |
- for (size_t x = 0, len = block.length(); x < len; ++x) |
|
| 362 |
+ for (std::size_t x = 0, len = block.length(); x < len; ++x) |
|
| 358 | 363 |
{
|
| 359 | 364 |
char c = block[x]; |
| 360 | 365 |
if (c == '%') |
| 361 | 366 |
{
|
| 362 |
- size_t origX = x; |
|
| 367 |
+ std::size_t origX = x; |
|
| 363 | 368 |
for (++x; x < len; ++x) |
| 364 | 369 |
if (block[x] == '%') |
| 365 | 370 |
break; |
| ... | ... |
@@ -377,7 +382,7 @@ std::string XSFFile::FormattedTitleOptionalBlock(const std::string &block, bool |
| 377 | 382 |
} |
| 378 | 383 |
if (c == '[' && level + 1 < 10) |
| 379 | 384 |
{
|
| 380 |
- size_t origX = x; |
|
| 385 |
+ std::size_t origX = x; |
|
| 381 | 386 |
unsigned nests = 0; |
| 382 | 387 |
for (++x; x < len; ++x) |
| 383 | 388 |
{
|
| ... | ... |
@@ -408,12 +413,12 @@ std::string XSFFile::FormattedTitleOptionalBlock(const std::string &block, bool |
| 408 | 413 |
std::string XSFFile::GetFormattedTitle(const std::string &format) const |
| 409 | 414 |
{
|
| 410 | 415 |
std::string formattedTitle; |
| 411 |
- for (size_t x = 0, len = format.length(); x < len; ++x) |
|
| 416 |
+ for (std::size_t x = 0, len = format.length(); x < len; ++x) |
|
| 412 | 417 |
{
|
| 413 | 418 |
char c = format[x]; |
| 414 | 419 |
if (c == '%') |
| 415 | 420 |
{
|
| 416 |
- size_t origX = x; |
|
| 421 |
+ std::size_t origX = x; |
|
| 417 | 422 |
for (++x; x < len; ++x) |
| 418 | 423 |
if (format[x] == '%') |
| 419 | 424 |
break; |
| ... | ... |
@@ -429,7 +434,7 @@ std::string XSFFile::GetFormattedTitle(const std::string &format) const |
| 429 | 434 |
} |
| 430 | 435 |
else if (c == '[') |
| 431 | 436 |
{
|
| 432 |
- size_t origX = x; |
|
| 437 |
+ std::size_t origX = x; |
|
| 433 | 438 |
unsigned nests = 0; |
| 434 | 439 |
for (++x; x < len; ++x) |
| 435 | 440 |
{
|
| ... | ... |
@@ -7,54 +7,57 @@ |
| 7 | 7 |
|
| 8 | 8 |
#pragma once |
| 9 | 9 |
|
| 10 |
+#include <fstream> |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <vector> |
|
| 10 | 13 |
#include <cstdint> |
| 11 | 14 |
#include "convert.h" |
| 12 | 15 |
#include "TagList.h" |
| 13 | 16 |
|
| 14 |
-enum VolumeType |
|
| 17 |
+enum class VolumeType |
|
| 15 | 18 |
{
|
| 16 |
- VOLUMETYPE_NONE, |
|
| 17 |
- VOLUMETYPE_VOLUME, |
|
| 18 |
- VOLUMETYPE_REPLAYGAIN_TRACK, |
|
| 19 |
- VOLUMETYPE_REPLAYGAIN_ALBUM |
|
| 19 |
+ None, |
|
| 20 |
+ Volume, |
|
| 21 |
+ ReplayGainTrack, |
|
| 22 |
+ ReplayGainAlbum |
|
| 20 | 23 |
}; |
| 21 | 24 |
|
| 22 |
-enum PeakType |
|
| 25 |
+enum class PeakType |
|
| 23 | 26 |
{
|
| 24 |
- PEAKTYPE_NONE, |
|
| 25 |
- PEAKTYPE_REPLAYGAIN_TRACK, |
|
| 26 |
- PEAKTYPE_REPLAYGAIN_ALBUM |
|
| 27 |
+ None, |
|
| 28 |
+ ReplayGainTrack, |
|
| 29 |
+ ReplayGainAlbum |
|
| 27 | 30 |
}; |
| 28 | 31 |
|
| 29 | 32 |
class XSFFile |
| 30 | 33 |
{
|
| 31 | 34 |
protected: |
| 32 |
- uint8_t xSFType; |
|
| 35 |
+ std::uint8_t xSFType; |
|
| 33 | 36 |
bool hasFile; |
| 34 |
- std::vector<uint8_t> rawData, reservedSection, programSection; |
|
| 37 |
+ std::vector<std::uint8_t> rawData, reservedSection, programSection; |
|
| 35 | 38 |
TagList tags; |
| 36 | 39 |
std::string fileName; |
| 37 |
- void ReadXSF(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 40 |
+ void ReadXSF(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 38 | 41 |
#ifdef _WIN32 |
| 39 |
- void ReadXSF(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 42 |
+ void ReadXSF(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 40 | 43 |
#endif |
| 41 |
- void ReadXSF(std::ifstream &xSF, uint32_t programSizeOffset, uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 44 |
+ void ReadXSF(std::ifstream &xSF, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize, bool readTagsOnly = false); |
|
| 42 | 45 |
std::string FormattedTitleOptionalBlock(const std::string &block, bool &hadReplacement, unsigned level) const; |
| 43 | 46 |
public: |
| 44 | 47 |
XSFFile(); |
| 45 | 48 |
XSFFile(const std::string &filename); |
| 46 |
- XSFFile(const std::string &filename, uint32_t programSizeOffset, uint32_t programHeaderSize); |
|
| 49 |
+ XSFFile(const std::string &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize); |
|
| 47 | 50 |
#ifdef _WIN32 |
| 48 | 51 |
XSFFile(const std::wstring &filename); |
| 49 |
- XSFFile(const std::wstring &filename, uint32_t programSizeOffset, uint32_t programHeaderSize); |
|
| 52 |
+ XSFFile(const std::wstring &filename, std::uint32_t programSizeOffset, std::uint32_t programHeaderSize); |
|
| 50 | 53 |
#endif |
| 51 |
- bool IsValidType(uint8_t type) const; |
|
| 54 |
+ bool IsValidType(std::uint8_t type) const; |
|
| 52 | 55 |
void Clear(); |
| 53 | 56 |
bool HasFile() const; |
| 54 |
- std::vector<uint8_t> &GetReservedSection(); |
|
| 55 |
- std::vector<uint8_t> GetReservedSection() const; |
|
| 56 |
- std::vector<uint8_t> &GetProgramSection(); |
|
| 57 |
- std::vector<uint8_t> GetProgramSection() const; |
|
| 57 |
+ std::vector<std::uint8_t> &GetReservedSection(); |
|
| 58 |
+ std::vector<std::uint8_t> GetReservedSection() const; |
|
| 59 |
+ std::vector<std::uint8_t> &GetProgramSection(); |
|
| 60 |
+ std::vector<std::uint8_t> GetProgramSection() const; |
|
| 58 | 61 |
const TagList &GetAllTags() const; |
| 59 | 62 |
void SetAllTags(const TagList &newTags); |
| 60 | 63 |
void SetTag(const std::string &name, const std::string &value); |
| ... | ... |
@@ -5,10 +5,13 @@ |
| 5 | 5 |
* Partially based on the vio*sf framework |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 |
-#include <cstring> |
|
| 9 |
-#include "XSFPlayer.h" |
|
| 10 |
-#include "XSFConfig.h" |
|
| 8 |
+#include <algorithm> |
|
| 9 |
+#include <limits> |
|
| 10 |
+#include <vector> |
|
| 11 |
+#include <cstdint> |
|
| 11 | 12 |
#include "XSFCommon.h" |
| 13 |
+#include "XSFConfig.h" |
|
| 14 |
+#include "XSFPlayer.h" |
|
| 12 | 15 |
|
| 13 | 16 |
extern XSFConfig *xSFConfig; |
| 14 | 17 |
|
| ... | ... |
@@ -50,26 +53,26 @@ XSFPlayer &XSFPlayer::operator=(const XSFPlayer &xSFPlayer) |
| 50 | 53 |
return *this; |
| 51 | 54 |
} |
| 52 | 55 |
|
| 53 |
-bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
|
| 56 |
+bool XSFPlayer::FillBuffer(std::vector<std::uint8_t> &buf, unsigned &samplesWritten) |
|
| 54 | 57 |
{
|
| 55 | 58 |
bool endFlag = false; |
| 56 | 59 |
unsigned detectSilence = xSFConfig->GetDetectSilenceSec(); |
| 57 | 60 |
unsigned pos = 0, bufsize = buf.size() >> 2; |
| 58 |
- auto trueBuffer = std::vector<uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2)); |
|
| 59 |
- auto longBuffer = std::vector<uint8_t>(bufsize << 3); |
|
| 60 |
- auto bufLong = reinterpret_cast<int32_t *>(&longBuffer[0]); |
|
| 61 |
+ auto trueBuffer = std::vector<std::uint8_t>(bufsize << (this->uses32BitSamplesClampedTo16Bit ? 3 : 2)); |
|
| 62 |
+ auto longBuffer = std::vector<std::uint8_t>(bufsize << 3); |
|
| 63 |
+ auto bufLong = reinterpret_cast<std::int32_t *>(&longBuffer[0]); |
|
| 61 | 64 |
while (pos < bufsize) |
| 62 | 65 |
{
|
| 63 | 66 |
unsigned remain = bufsize - pos, offset = pos; |
| 64 | 67 |
this->GenerateSamples(trueBuffer, pos << (this->uses32BitSamplesClampedTo16Bit ? 2 : 1), remain); |
| 65 | 68 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 66 | 69 |
{
|
| 67 |
- auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 70 |
+ auto trueBufLong = reinterpret_cast<std::int32_t *>(&trueBuffer[0]); |
|
| 68 | 71 |
std::copy_n(&trueBufLong[0], bufsize << 1, &bufLong[0]); |
| 69 | 72 |
} |
| 70 | 73 |
else |
| 71 | 74 |
{
|
| 72 |
- auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 75 |
+ auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]); |
|
| 73 | 76 |
std::copy_n(&trueBufShort[0], bufsize << 1, &bufLong[0]); |
| 74 | 77 |
} |
| 75 | 78 |
if (detectSilence || skipSilenceOnStartSec) |
| ... | ... |
@@ -77,7 +80,7 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 77 | 80 |
unsigned skipOffset = 0; |
| 78 | 81 |
for (unsigned ofs = 0; ofs < remain; ++ofs) |
| 79 | 82 |
{
|
| 80 |
- uint32_t sampleL = bufLong[2 * (offset + ofs)], sampleR = bufLong[2 * (offset + ofs) + 1]; |
|
| 83 |
+ std::uint32_t sampleL = bufLong[2 * (offset + ofs)], sampleR = bufLong[2 * (offset + ofs) + 1]; |
|
| 81 | 84 |
bool silence = (sampleL + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleL <= CHECK_SILENCE_LEVEL * 2 && |
| 82 | 85 |
(sampleR + CHECK_SILENCE_BIAS + CHECK_SILENCE_LEVEL) - this->prevSampleR <= CHECK_SILENCE_LEVEL * 2; |
| 83 | 86 |
|
| ... | ... |
@@ -114,7 +117,7 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 114 | 117 |
{
|
| 115 | 118 |
if (skipOffset) |
| 116 | 119 |
{
|
| 117 |
- auto tmpBuf = std::vector<int32_t>((bufsize - skipOffset) << 1); |
|
| 120 |
+ auto tmpBuf = std::vector<std::int32_t>((bufsize - skipOffset) << 1); |
|
| 118 | 121 |
std::copy(&bufLong[(offset + skipOffset) << 1], &bufLong[bufsize << 1], &tmpBuf[0]); |
| 119 | 122 |
std::copy_n(&tmpBuf[0], (bufsize - skipOffset) << 1, &bufLong[offset << 1]); |
| 120 | 123 |
pos += skipOffset; |
| ... | ... |
@@ -129,12 +132,12 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 129 | 132 |
{
|
| 130 | 133 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 131 | 134 |
{
|
| 132 |
- auto trueBufLong = reinterpret_cast<int32_t *>(&trueBuffer[0]); |
|
| 135 |
+ auto trueBufLong = reinterpret_cast<std::int32_t *>(&trueBuffer[0]); |
|
| 133 | 136 |
std::copy_n(&bufLong[0], bufsize << 1, &trueBufLong[0]); |
| 134 | 137 |
} |
| 135 | 138 |
else |
| 136 | 139 |
{
|
| 137 |
- auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 140 |
+ auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]); |
|
| 138 | 141 |
std::copy_n(&bufLong[0], bufsize << 1, &trueBufShort[0]); |
| 139 | 142 |
} |
| 140 | 143 |
} |
| ... | ... |
@@ -164,29 +167,29 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 164 | 167 |
double s1 = bufLong[2 * ofs] * scale, s2 = bufLong[2 * ofs + 1] * scale; |
| 165 | 168 |
if (!this->uses32BitSamplesClampedTo16Bit) |
| 166 | 169 |
{
|
| 167 |
- clamp(s1, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()); |
|
| 168 |
- clamp(s2, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()); |
|
| 170 |
+ clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max()); |
|
| 171 |
+ clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max()); |
|
| 169 | 172 |
} |
| 170 |
- bufLong[2 * ofs] = static_cast<int32_t>(s1); |
|
| 171 |
- bufLong[2 * ofs + 1] = static_cast<int32_t>(s2); |
|
| 173 |
+ bufLong[2 * ofs] = static_cast<std::int32_t>(s1); |
|
| 174 |
+ bufLong[2 * ofs + 1] = static_cast<std::int32_t>(s2); |
|
| 172 | 175 |
} |
| 173 | 176 |
} |
| 174 | 177 |
|
| 175 | 178 |
if (this->uses32BitSamplesClampedTo16Bit) |
| 176 | 179 |
{
|
| 177 |
- auto bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 180 |
+ auto bufShort = reinterpret_cast<std::int16_t *>(&buf[0]); |
|
| 178 | 181 |
for (unsigned ofs = 0; ofs < bufsize; ++ofs) |
| 179 | 182 |
{
|
| 180 |
- int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1]; |
|
| 181 |
- clamp(s1, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()); |
|
| 182 |
- clamp(s2, std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max()); |
|
| 183 |
- bufShort[2 * ofs] = static_cast<int16_t>(s1); |
|
| 184 |
- bufShort[2 * ofs + 1] = static_cast<int16_t>(s2); |
|
| 183 |
+ std::int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1]; |
|
| 184 |
+ clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max()); |
|
| 185 |
+ clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max()); |
|
| 186 |
+ bufShort[2 * ofs] = static_cast<std::int16_t>(s1); |
|
| 187 |
+ bufShort[2 * ofs + 1] = static_cast<std::int16_t>(s2); |
|
| 185 | 188 |
} |
| 186 | 189 |
} |
| 187 | 190 |
else |
| 188 | 191 |
{
|
| 189 |
- auto trueBufShort = reinterpret_cast<int16_t *>(&trueBuffer[0]); |
|
| 192 |
+ auto trueBufShort = reinterpret_cast<std::int16_t *>(&trueBuffer[0]); |
|
| 190 | 193 |
std::copy_n(&bufLong[0], bufsize << 1, &trueBufShort[0]); |
| 191 | 194 |
std::copy(&trueBuffer[0], &trueBuffer[bufsize << 2], &buf[0]); |
| 192 | 195 |
} |
| ... | ... |
@@ -194,12 +197,12 @@ bool XSFPlayer::FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten) |
| 194 | 197 |
/* Fading */ |
| 195 | 198 |
if (!xSFConfig->GetPlayInfinitely() && this->fadeSample && this->currentSample + bufsize >= this->lengthSample) |
| 196 | 199 |
{
|
| 197 |
- auto bufShort = reinterpret_cast<int16_t *>(&buf[0]); |
|
| 200 |
+ auto bufShort = reinterpret_cast<std::int16_t *>(&buf[0]); |
|
| 198 | 201 |
for (unsigned ofs = 0; ofs < bufsize; ++ofs) |
| 199 | 202 |
{
|
| 200 | 203 |
if (this->currentSample + ofs >= this->lengthSample && this->currentSample + ofs < this->lengthSample + this->fadeSample) |
| 201 | 204 |
{
|
| 202 |
- int scale = static_cast<uint64_t>(this->lengthSample + this->fadeSample - (this->currentSample + ofs)) * 0x10000 / this->fadeSample; |
|
| 205 |
+ int scale = static_cast<std::uint64_t>(this->lengthSample + this->fadeSample - (this->currentSample + ofs)) * 0x10000 / this->fadeSample; |
|
| 203 | 206 |
bufShort[2 * ofs] = (bufShort[2 * ofs] * scale) >> 16; |
| 204 | 207 |
bufShort[2 * ofs + 1] = (bufShort[2 * ofs + 1] * scale) >> 16; |
| 205 | 208 |
} |
| ... | ... |
@@ -217,8 +220,8 @@ bool XSFPlayer::Load() |
| 217 | 220 |
{
|
| 218 | 221 |
this->lengthInMS = this->xSF->GetLengthMS(xSFConfig->GetDefaultLength()); |
| 219 | 222 |
this->fadeInMS = this->xSF->GetFadeMS(xSFConfig->GetDefaultFade()); |
| 220 |
- this->lengthSample = static_cast<uint64_t>(this->lengthInMS) * this->sampleRate / 1000; |
|
| 221 |
- this->fadeSample = static_cast<uint64_t>(this->fadeInMS) * this->sampleRate / 1000; |
|
| 223 |
+ this->lengthSample = static_cast<std::uint64_t>(this->lengthInMS) * this->sampleRate / 1000; |
|
| 224 |
+ this->fadeSample = static_cast<std::uint64_t>(this->fadeInMS) * this->sampleRate / 1000; |
|
| 222 | 225 |
this->volume = this->xSF->GetVolume(xSFConfig->GetVolumeType(), xSFConfig->GetPeakType()); |
| 223 | 226 |
return true; |
| 224 | 227 |
} |
| ... | ... |
@@ -233,9 +236,9 @@ void XSFPlayer::SeekTop() |
| 233 | 236 |
#ifdef WINAMP_PLUGIN |
| 234 | 237 |
static inline DWORD TicksDiff(DWORD prev, DWORD cur) { return cur >= prev ? cur - prev : 0xFFFFFFFF - prev + cur; }
|
| 235 | 238 |
|
| 236 |
-int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod) |
|
| 239 |
+int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector<std::uint8_t> &buf, Out_Module *outMod) |
|
| 237 | 240 |
{
|
| 238 |
- unsigned bufsize = buf.size() >> 2, seekSample = static_cast<uint64_t>(seekPosition) * this->sampleRate / 1000; |
|
| 241 |
+ unsigned bufsize = buf.size() >> 2, seekSample = static_cast<std::uint64_t>(seekPosition) * this->sampleRate / 1000; |
|
| 239 | 242 |
DWORD prevTick = outMod ? GetTickCount() : 0; |
| 240 | 243 |
if (seekSample < this->currentSample) |
| 241 | 244 |
{
|
| ... | ... |
@@ -253,7 +256,7 @@ int XSFPlayer::Seek(unsigned seekPosition, volatile int *killswitch, std::vector |
| 253 | 256 |
if (TicksDiff(prevTick, curTick) >= 500) |
| 254 | 257 |
{
|
| 255 | 258 |
prevTick = curTick; |
| 256 |
- unsigned cur = static_cast<uint64_t>(this->currentSample) * 1000 / this->sampleRate; |
|
| 259 |
+ unsigned cur = static_cast<std::uint64_t>(this->currentSample) * 1000 / this->sampleRate; |
|
| 257 | 260 |
outMod->Flush(cur); |
| 258 | 261 |
} |
| 259 | 262 |
} |
| ... | ... |
@@ -8,8 +8,10 @@ |
| 8 | 8 |
#pragma once |
| 9 | 9 |
|
| 10 | 10 |
#include <memory> |
| 11 |
+#include <string> |
|
| 12 |
+#include <vector> |
|
| 13 |
+#include <cstdint> |
|
| 11 | 14 |
#include "XSFFile.h" |
| 12 |
- |
|
| 13 | 15 |
#ifdef WINAMP_PLUGIN |
| 14 | 16 |
# include "windowsh_wrapper.h" |
| 15 | 17 |
# include "winamp/out.h" |
| ... | ... |
@@ -19,12 +21,12 @@ |
| 19 | 21 |
class XSFPlayer |
| 20 | 22 |
{
|
| 21 | 23 |
protected: |
| 22 |
- static const uint32_t CHECK_SILENCE_BIAS = 0x8000000; |
|
| 23 |
- static const uint32_t CHECK_SILENCE_LEVEL = 7; |
|
| 24 |
+ static const std::uint32_t CHECK_SILENCE_BIAS = 0x8000000; |
|
| 25 |
+ static const std::uint32_t CHECK_SILENCE_LEVEL = 7; |
|
| 24 | 26 |
|
| 25 | 27 |
std::unique_ptr<XSFFile> xSF; |
| 26 | 28 |
unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample; |
| 27 |
- uint32_t prevSampleL, prevSampleR; |
|
| 29 |
+ std::uint32_t prevSampleL, prevSampleR; |
|
| 28 | 30 |
int lengthInMS, fadeInMS; |
| 29 | 31 |
double volume; |
| 30 | 32 |
bool ignoreVolume, uses32BitSamplesClampedTo16Bit; |
| ... | ... |
@@ -49,11 +51,11 @@ public: |
| 49 | 51 |
void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
|
| 50 | 52 |
void IgnoreVolume() { this->ignoreVolume = true; }
|
| 51 | 53 |
virtual bool Load(); |
| 52 |
- bool FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten); |
|
| 53 |
- virtual void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) = 0; |
|
| 54 |
+ bool FillBuffer(std::vector<std::uint8_t> &buf, unsigned &samplesWritten); |
|
| 55 |
+ virtual void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) = 0; |
|
| 54 | 56 |
void SeekTop(); |
| 55 | 57 |
#ifdef WINAMP_PLUGIN |
| 56 |
- int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod); |
|
| 58 |
+ int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<std::uint8_t> &buf, Out_Module *outMod); |
|
| 57 | 59 |
#endif |
| 58 | 60 |
virtual void Terminate() = 0; |
| 59 | 61 |
}; |
| ... | ... |
@@ -5,13 +5,12 @@ |
| 5 | 5 |
|
| 6 | 6 |
#pragma once |
| 7 | 7 |
|
| 8 |
-#include <string> |
|
| 9 |
-#include <sstream> |
|
| 10 | 8 |
#include <locale> |
| 11 |
-#include <vector> |
|
| 12 |
-#include <memory> |
|
| 9 |
+#include <string> |
|
| 13 | 10 |
#include <type_traits> |
| 11 |
+#include <vector> |
|
| 14 | 12 |
#include <cmath> |
| 13 |
+#include <cstddef> |
|
| 15 | 14 |
#include "windowsh_wrapper.h" |
| 16 | 15 |
|
| 17 | 16 |
/* |
| ... | ... |
@@ -62,10 +61,10 @@ private: |
| 62 | 61 |
template<typename T> static bool IsDigitsOnly(const std::basic_string<T> &input, const std::locale &loc = std::locale::classic()) |
| 63 | 62 |
{
|
| 64 | 63 |
auto inputChars = std::vector<T>(input.begin(), input.end()); |
| 65 |
- size_t length = inputChars.size(); |
|
| 64 |
+ std::size_t length = inputChars.size(); |
|
| 66 | 65 |
auto masks = std::vector<typename std::ctype<T>::mask>(length); |
| 67 | 66 |
std::use_facet<std::ctype<T>>(loc).is(&inputChars[0], &inputChars[length], &masks[0]); |
| 68 |
- for (size_t x = 0; x < length; ++x) |
|
| 67 |
+ for (std::size_t x = 0; x < length; ++x) |
|
| 69 | 68 |
if (inputChars[x] != '.' && !(masks[x] & std::ctype<T>::digit)) |
| 70 | 69 |
return false; |
| 71 | 70 |
return true; |
| ... | ... |
@@ -77,10 +76,10 @@ public: |
| 77 | 76 |
unsigned long hours = 0, minutes = 0; |
| 78 | 77 |
double seconds = 0.0; |
| 79 | 78 |
std::string hoursStr, minutesStr, secondsStr; |
| 80 |
- size_t firstcolon = time.find(':');
|
|
| 79 |
+ std::size_t firstcolon = time.find(':');
|
|
| 81 | 80 |
if (firstcolon != std::string::npos) |
| 82 | 81 |
{
|
| 83 |
- size_t secondcolon = time.substr(firstcolon + 1).find(':');
|
|
| 82 |
+ std::size_t secondcolon = time.substr(firstcolon + 1).find(':');
|
|
| 84 | 83 |
if (secondcolon != std::string::npos) |
| 85 | 84 |
{
|
| 86 | 85 |
secondcolon = firstcolon + secondcolon + 1; |
| ... | ... |
@@ -112,7 +111,7 @@ public: |
| 112 | 111 |
{
|
| 113 | 112 |
if (!ConvertFuncs::IsDigitsOnly(secondsStr)) |
| 114 | 113 |
return 0; |
| 115 |
- size_t comma = secondsStr.find(',');
|
|
| 114 |
+ std::size_t comma = secondsStr.find(',');
|
|
| 116 | 115 |
if (comma != std::string::npos) |
| 117 | 116 |
secondsStr[comma] = '.'; |
| 118 | 117 |
seconds = convertTo<double>(secondsStr); |
| ... | ... |
@@ -8,11 +8,10 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include <functional> |
|
| 11 |
+#include <algorithm> |
|
| 12 |
+#include <limits> |
|
| 12 | 13 |
#include <locale> |
| 13 | 14 |
#include <string> |
| 14 |
-#include <algorithm> |
|
| 15 |
-#include <climits> |
|
| 16 | 15 |
|
| 17 | 16 |
struct eq_str |
| 18 | 17 |
{
|
| ... | ... |
@@ -20,16 +19,16 @@ struct eq_str |
| 20 | 19 |
{
|
| 21 | 20 |
const char *tab; |
| 22 | 21 |
eq_char(const char *t) : tab(t) { }
|
| 23 |
- bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] == this->tab[y - CHAR_MIN]; }
|
|
| 22 |
+ bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] == this->tab[y - std::numeric_limits<char>::min()]; }
|
|
| 24 | 23 |
}; |
| 25 | 24 |
|
| 26 |
- char tab[CHAR_MAX - CHAR_MIN + 1]; |
|
| 25 |
+ char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1]; |
|
| 27 | 26 |
|
| 28 | 27 |
eq_str(const std::locale &L = std::locale::classic()) |
| 29 | 28 |
{
|
| 30 |
- for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) |
|
| 31 |
- this->tab[i - CHAR_MIN] = static_cast<char>(i); |
|
| 32 |
- std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 29 |
+ for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i) |
|
| 30 |
+ this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i); |
|
| 31 |
+ std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1)); |
|
| 33 | 32 |
} |
| 34 | 33 |
|
| 35 | 34 |
bool operator()(const std::string &x, const std::string &y) const |
| ... | ... |
@@ -5,10 +5,20 @@ |
| 5 | 5 |
* Partially based on the vio*sf framework |
| 6 | 6 |
*/ |
| 7 | 7 |
|
| 8 |
-#include "XSFPlayer.h" |
|
| 9 |
-#include "XSFConfig.h" |
|
| 10 |
-#include "XSFCommon.h" |
|
| 8 |
+#include <algorithm> |
|
| 9 |
+#include <memory> |
|
| 10 |
+#include <stdexcept> |
|
| 11 |
+#include <string> |
|
| 12 |
+#include <utility> |
|
| 13 |
+#include <vector> |
|
| 14 |
+#include <cstddef> |
|
| 15 |
+#include <cstdint> |
|
| 11 | 16 |
#include "windowsh_wrapper.h" |
| 17 |
+#include "XSFCommon.h" |
|
| 18 |
+#include "XSFConfig.h" |
|
| 19 |
+#include "XSFFile.h" |
|
| 20 |
+#include "XSFPlayer.h" |
|
| 21 |
+#include "convert.h" |
|
| 12 | 22 |
#include "winamp/in2.h" |
| 13 | 23 |
#include "winamp/wa_ipc.h" |
| 14 | 24 |
|
| ... | ... |
@@ -35,7 +45,7 @@ DWORD WINAPI playThread(void *b) |
| 35 | 45 |
{
|
| 36 | 46 |
decode_pos_ms = seek_needed - (seek_needed % 1000); |
| 37 | 47 |
seek_needed = -1; |
| 38 |
- auto dummyBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 48 |
+ auto dummyBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 39 | 49 |
xSFPlayer->Seek(static_cast<unsigned>(decode_pos_ms), nullptr, dummyBuffer, inMod.outMod); |
| 40 | 50 |
} |
| 41 | 51 |
|
| ... | ... |
@@ -51,7 +61,7 @@ DWORD WINAPI playThread(void *b) |
| 51 | 61 |
} |
| 52 | 62 |
else if (static_cast<unsigned>(inMod.outMod->CanWrite()) >= ((576 * NumChannels * (BitsPerSample / 8)) << (inMod.dsp_isactive() ? 1 : 0))) |
| 53 | 63 |
{
|
| 54 |
- auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 64 |
+ auto sampleBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 55 | 65 |
unsigned samplesWritten = 0; |
| 56 | 66 |
done = xSFPlayer->FillBuffer(sampleBuffer, samplesWritten); |
| 57 | 67 |
if (samplesWritten) |
| ... | ... |
@@ -305,7 +315,7 @@ extern "C" __declspec(dllexport) In_Module *winampGetInModule2() |
| 305 | 315 |
|
| 306 | 316 |
static eq_str eqstr; |
| 307 | 317 |
|
| 308 |
-template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, const char *data, T *dest, size_t destlen) |
|
| 318 |
+template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, const char *data, T *dest, std::size_t destlen) |
|
| 309 | 319 |
{
|
| 310 | 320 |
if (eqstr(data, "type")) |
| 311 | 321 |
{
|
| ... | ... |
@@ -343,7 +353,7 @@ template<typename T> int wrapperWinampGetExtendedFileInfo(const XSFFile &file, c |
| 343 | 353 |
} |
| 344 | 354 |
} |
| 345 | 355 |
|
| 346 |
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, size_t destlen) |
|
| 356 |
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, const char *data, char *dest, std::size_t destlen) |
|
| 347 | 357 |
{
|
| 348 | 358 |
try |
| 349 | 359 |
{
|
| ... | ... |
@@ -356,7 +366,7 @@ extern "C" __declspec(dllexport) int winampGetExtendedFileInfo(const char *fn, c |
| 356 | 366 |
} |
| 357 | 367 |
} |
| 358 | 368 |
|
| 359 |
-extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, size_t destlen) |
|
| 369 |
+extern "C" __declspec(dllexport) int winampGetExtendedFileInfoW(const wchar_t *fn, const char *data, wchar_t *dest, std::size_t destlen) |
|
| 360 | 370 |
{
|
| 361 | 371 |
try |
| 362 | 372 |
{
|
| ... | ... |
@@ -418,7 +428,7 @@ extern "C" __declspec(dllexport) int winampClearExtendedFileInfoW(const wchar_t |
| 418 | 428 |
return 0; |
| 419 | 429 |
} |
| 420 | 430 |
|
| 421 |
-intptr_t wrapperWinampGetExtendedRead_open(std::unique_ptr<XSFPlayer> tmpxSFPlayer, int *size, int *bps, int *nch, int *srate) |
|
| 431 |
+std::intptr_t wrapperWinampGetExtendedRead_open(std::unique_ptr<XSFPlayer> &&tmpxSFPlayer, int *size, int *bps, int *nch, int *srate) |
|
| 422 | 432 |
{
|
| 423 | 433 |
xSFConfig->CopyConfigToMemory(tmpxSFPlayer.get(), true); |
| 424 | 434 |
if (!tmpxSFPlayer->Load()) |
| ... | ... |
@@ -433,10 +443,10 @@ intptr_t wrapperWinampGetExtendedRead_open(std::unique_ptr<XSFPlayer> tmpxSFPlay |
| 433 | 443 |
*nch = NumChannels; |
| 434 | 444 |
if (srate) |
| 435 | 445 |
*srate = tmpxSFPlayer->GetSampleRate(); |
| 436 |
- return reinterpret_cast<intptr_t>(tmpxSFPlayer.release()); |
|
| 446 |
+ return reinterpret_cast<std::intptr_t>(tmpxSFPlayer.release()); |
|
| 437 | 447 |
} |
| 438 | 448 |
|
| 439 |
-extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate) |
|
| 449 |
+extern "C" __declspec(dllexport) std::intptr_t winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate) |
|
| 440 | 450 |
{
|
| 441 | 451 |
try |
| 442 | 452 |
{
|
| ... | ... |
@@ -449,7 +459,7 @@ extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_open(const char |
| 449 | 459 |
} |
| 450 | 460 |
} |
| 451 | 461 |
|
| 452 |
-extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate) |
|
| 462 |
+extern "C" __declspec(dllexport) std::intptr_t winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate) |
|
| 453 | 463 |
{
|
| 454 | 464 |
try |
| 455 | 465 |
{
|
| ... | ... |
@@ -464,14 +474,14 @@ extern "C" __declspec(dllexport) intptr_t winampGetExtendedRead_openW(const wcha |
| 464 | 474 |
|
| 465 | 475 |
static int extendedSeekNeeded = -1; |
| 466 | 476 |
|
| 467 |
-extern "C" __declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t handle, char *dest, size_t len, int *killswitch) |
|
| 477 |
+extern "C" __declspec(dllexport) std::size_t winampGetExtendedRead_getData(std::intptr_t handle, char *dest, std::size_t len, int *killswitch) |
|
| 468 | 478 |
{
|
| 469 | 479 |
XSFPlayer *tmpxSFPlayer = reinterpret_cast<XSFPlayer *>(handle); |
| 470 | 480 |
if (!tmpxSFPlayer) |
| 471 | 481 |
return 0; |
| 472 | 482 |
if (extendedSeekNeeded != -1) |
| 473 | 483 |
{
|
| 474 |
- auto dummyBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 484 |
+ auto dummyBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 475 | 485 |
if (tmpxSFPlayer->Seek(static_cast<unsigned>(extendedSeekNeeded), killswitch, dummyBuffer, nullptr)) |
| 476 | 486 |
return 0; |
| 477 | 487 |
extendedSeekNeeded = -1; |
| ... | ... |
@@ -480,7 +490,7 @@ extern "C" __declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t h |
| 480 | 490 |
bool done = false; |
| 481 | 491 |
while (copied + (576 * NumChannels * (BitsPerSample / 8)) < len && !done) |
| 482 | 492 |
{
|
| 483 |
- auto sampleBuffer = std::vector<uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 493 |
+ auto sampleBuffer = std::vector<std::uint8_t>(576 * NumChannels * (BitsPerSample / 8)); |
|
| 484 | 494 |
unsigned samplesWritten = 0; |
| 485 | 495 |
done = tmpxSFPlayer->FillBuffer(sampleBuffer, samplesWritten); |
| 486 | 496 |
std::copy_n(&sampleBuffer[0], samplesWritten * NumChannels * (BitsPerSample / 8), &dest[copied]); |
| ... | ... |
@@ -491,13 +501,13 @@ extern "C" __declspec(dllexport) size_t winampGetExtendedRead_getData(intptr_t h |
| 491 | 501 |
return copied; |
| 492 | 502 |
} |
| 493 | 503 |
|
| 494 |
-extern "C" __declspec(dllexport) int winampGetExtendedRead_setTime(intptr_t, int millisecs) |
|
| 504 |
+extern "C" __declspec(dllexport) int winampGetExtendedRead_setTime(std::intptr_t, int millisecs) |
|
| 495 | 505 |
{
|
| 496 | 506 |
extendedSeekNeeded = millisecs; |
| 497 | 507 |
return 1; |
| 498 | 508 |
} |
| 499 | 509 |
|
| 500 |
-extern "C" __declspec(dllexport) void winampGetExtendedRead_close(intptr_t handle) |
|
| 510 |
+extern "C" __declspec(dllexport) void winampGetExtendedRead_close(std::intptr_t handle) |
|
| 501 | 511 |
{
|
| 502 | 512 |
XSFPlayer *tmpxSFPlayer = reinterpret_cast<XSFPlayer *>(handle); |
| 503 | 513 |
if (tmpxSFPlayer) |
| ... | ... |
@@ -8,11 +8,10 @@ |
| 8 | 8 |
|
| 9 | 9 |
#pragma once |
| 10 | 10 |
|
| 11 |
-#include <functional> |
|
| 11 |
+#include <algorithm> |
|
| 12 |
+#include <limits> |
|
| 12 | 13 |
#include <locale> |
| 13 | 14 |
#include <string> |
| 14 |
-#include <algorithm> |
|
| 15 |
-#include <climits> |
|
| 16 | 15 |
|
| 17 | 16 |
struct lt_str |
| 18 | 17 |
{
|
| ... | ... |
@@ -20,16 +19,16 @@ struct lt_str |
| 20 | 19 |
{
|
| 21 | 20 |
const char *tab; |
| 22 | 21 |
lt_char(const char *t) : tab(t) { }
|
| 23 |
- bool operator()(char x, char y) const { return this->tab[x - CHAR_MIN] < this->tab[y - CHAR_MIN]; }
|
|
| 22 |
+ bool operator()(char x, char y) const { return this->tab[x - std::numeric_limits<char>::min()] < this->tab[y - std::numeric_limits<char>::min()]; }
|
|
| 24 | 23 |
}; |
| 25 | 24 |
|
| 26 |
- char tab[CHAR_MAX - CHAR_MIN + 1]; |
|
| 25 |
+ char tab[std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1]; |
|
| 27 | 26 |
|
| 28 | 27 |
lt_str(const std::locale &L = std::locale::classic()) |
| 29 | 28 |
{
|
| 30 |
- for (int i = CHAR_MIN; i <= CHAR_MAX; ++i) |
|
| 31 |
- this->tab[i - CHAR_MIN] = static_cast<char>(i); |
|
| 32 |
- std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (CHAR_MAX - CHAR_MIN + 1)); |
|
| 29 |
+ for (int i = std::numeric_limits<char>::min(); i <= std::numeric_limits<char>::max(); ++i) |
|
| 30 |
+ this->tab[i - std::numeric_limits<char>::min()] = static_cast<char>(i); |
|
| 31 |
+ std::use_facet<std::ctype<char>>(L).toupper(this->tab, this->tab + (std::numeric_limits<char>::max() - std::numeric_limits<char>::min() + 1)); |
|
| 33 | 32 |
} |
| 34 | 33 |
|
| 35 | 34 |
bool operator()(const std::string &x, const std::string &y) const |