* Fix the ones in my code where I could use a proper type or valid casts.
* Ignore the designer-time and compiler-time warnings in vendor code or in my code where I am unable to suppress them via casting.
(Most of these were ignored already before introducing the CMake scripts, because they were in vendor code or were annoying to deal with.)
| ... | ... |
@@ -117,5 +117,7 @@ set(SOURCES |
| 117 | 117 |
add_library(in_2sf SHARED ${HEADERS} ${SOURCES})
|
| 118 | 118 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Header Files" FILES ${HEADERS})
|
| 119 | 119 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Source Files" FILES ${SOURCES})
|
| 120 |
+target_compile_options(in_2sf PUBLIC |
|
| 121 |
+ $<$<CXX_COMPILER_ID:MSVC>:/wd4018 /wd4100 /wd4146 /wd4127 /wd4189 /wd4201 /wd4245 /wd4456 /wd4459 /wd4701 /wd4703 /wd4706 /wd4996 /wd6001 /wd6011 /wd6297 /wd6308 /wd6385 /wd6386 /wd26454 /wd26495 /wd26812 /wd26819 /wd28112>) |
|
| 120 | 122 |
target_link_libraries(in_2sf |
| 121 | 123 |
in_xsf_framework) |
| ... | ... |
@@ -45,7 +45,7 @@ public: |
| 45 | 45 |
void About(HWND parent); |
| 46 | 46 |
}; |
| 47 | 47 |
|
| 48 |
-unsigned XSFConfig::initSampleRate = DESMUME_SAMPLE_RATE; |
|
| 48 |
+unsigned XSFConfig::initSampleRate = static_cast<unsigned>(DESMUME_SAMPLE_RATE); |
|
| 49 | 49 |
std::string XSFConfig::commonName = "2SF Decoder"; |
| 50 | 50 |
std::string XSFConfig::versionNumber = "0.9b"; |
| 51 | 51 |
unsigned XSFConfig_2SF::initInterpolation = 2; |
| ... | ... |
@@ -58,7 +58,7 @@ XSFConfig *XSFConfig::Create() |
| 58 | 58 |
|
| 59 | 59 |
XSFConfig_2SF::XSFConfig_2SF() : XSFConfig(), interpolation(0), mutes() |
| 60 | 60 |
{
|
| 61 |
- this->supportedSampleRates.push_back(DESMUME_SAMPLE_RATE); |
|
| 61 |
+ this->supportedSampleRates.push_back(static_cast<unsigned>(DESMUME_SAMPLE_RATE)); |
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
void XSFConfig_2SF::LoadSpecificConfig() |
| ... | ... |
@@ -214,7 +214,7 @@ bool XSFPlayer_2SF::Load() |
| 214 | 214 |
if (NDS_Init()) |
| 215 | 215 |
return false; |
| 216 | 216 |
|
| 217 |
- static const int BUFFERSIZE = DESMUME_SAMPLE_RATE / 59.837; // truncates to 737, the traditional value, for 44100 |
|
| 217 |
+ static const int BUFFERSIZE = static_cast<int>(DESMUME_SAMPLE_RATE / 59.837); // truncates to 737, the traditional value, for 44100 |
|
| 218 | 218 |
SPU_ChangeSoundCore(SNDIFID_2SF, BUFFERSIZE); |
| 219 | 219 |
|
| 220 | 220 |
execute = false; |
| ... | ... |
@@ -30,5 +30,7 @@ set(SOURCES |
| 30 | 30 |
add_library(in_gsf SHARED ${HEADERS} ${SOURCES})
|
| 31 | 31 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Header Files" FILES ${HEADERS})
|
| 32 | 32 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Source Files" FILES ${SOURCES})
|
| 33 |
+target_compile_options(in_gsf PUBLIC |
|
| 34 |
+ $<$<CXX_COMPILER_ID:MSVC>:/wd4127 /wd4189 /wd26495 /wd26812>) |
|
| 33 | 35 |
target_link_libraries(in_gsf |
| 34 | 36 |
in_xsf_framework) |
| ... | ... |
@@ -40,5 +40,7 @@ add_library(in_ncsf SHARED ${HEADERS} ${RESOURCES} ${SOURCES})
|
| 40 | 40 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Header Files" FILES ${HEADERS})
|
| 41 | 41 |
source_group("Resource Files" FILES ${RESOURCES})
|
| 42 | 42 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Source Files" FILES ${SOURCES})
|
| 43 |
+target_compile_options(in_ncsf PUBLIC |
|
| 44 |
+ $<$<CXX_COMPILER_ID:MSVC>:/wd6011 /wd6385 /wd26819>) |
|
| 43 | 45 |
target_link_libraries(in_ncsf |
| 44 | 46 |
in_xsf_framework) |
| ... | ... |
@@ -90,7 +90,7 @@ void Channel::UpdateVol(const Track &trk) |
| 90 | 90 |
finalVol += Cnv_Sust(trk.expr); |
| 91 | 91 |
if (finalVol < -AMPL_K) |
| 92 | 92 |
finalVol = -AMPL_K; |
| 93 |
- this->extAmpl = finalVol; |
|
| 93 |
+ this->extAmpl = static_cast<std::int16_t>(finalVol); |
|
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 | 96 |
// Original FSS Function: Chn_UpdatePan |
| ... | ... |
@@ -526,7 +526,7 @@ void Channel::Update() |
| 526 | 526 |
std::uint32_t counter = this->modCounter + (this->modSpeed << 6); |
| 527 | 527 |
while (counter >= 0x8000) |
| 528 | 528 |
counter -= 0x8000; |
| 529 |
- this->modCounter = counter; |
|
| 529 |
+ this->modCounter = static_cast<std::uint16_t>(counter); |
|
| 530 | 530 |
} |
| 531 | 531 |
|
| 532 | 532 |
if (bTmrNeedUpdate) |
| ... | ... |
@@ -574,7 +574,7 @@ void Channel::Update() |
| 574 | 574 |
else if (totalVol < AMPL_K - 60) |
| 575 | 575 |
cr |= SOUND_VOLDIV(1); |
| 576 | 576 |
|
| 577 |
- this->vol = ((cr & SOUND_VOL(0x7F)) << 4) >> calcVolDivShift((cr & SOUND_VOLDIV(3)) >> 8); |
|
| 577 |
+ this->vol = static_cast<std::uint16_t>(((cr & SOUND_VOL(0x7F)) << 4) >> calcVolDivShift((cr & SOUND_VOLDIV(3)) >> 8)); |
|
| 578 | 578 |
|
| 579 | 579 |
this->flags.reset(ToIntegral(ChannelFlag::UpdateVolume)); |
| 580 | 580 |
} |
| ... | ... |
@@ -106,11 +106,11 @@ template<std::size_t N> struct RingBuffer |
| 106 | 106 |
|
| 107 | 107 |
RingBuffer() : bufferPos(N / 2), getPos(N / 2) |
| 108 | 108 |
{
|
| 109 |
- std::fill_n(&this->buffer[0], N * 2, 0); |
|
| 109 |
+ std::fill_n(&this->buffer[0], N * 2, static_cast<std::int16_t>(0)); |
|
| 110 | 110 |
} |
| 111 | 111 |
void Clear() |
| 112 | 112 |
{
|
| 113 |
- std::fill_n(&this->buffer[0], N * 2, 0); |
|
| 113 |
+ std::fill_n(&this->buffer[0], N * 2, static_cast<std::int16_t>(0)); |
|
| 114 | 114 |
this->bufferPos = this->getPos = N / 2; |
| 115 | 115 |
} |
| 116 | 116 |
void PushSample(std::int16_t sample) |
| ... | ... |
@@ -29,7 +29,7 @@ void INFOEntrySEQ::Read(PseudoFile &file) |
| 29 | 29 |
|
| 30 | 30 |
INFOEntryBANK::INFOEntryBANK() : fileID(0) |
| 31 | 31 |
{
|
| 32 |
- std::fill_n(&this->waveArc[0], 4, 0); |
|
| 32 |
+ std::fill_n(&this->waveArc[0], 4, static_cast<std::uint16_t>(0)); |
|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
void INFOEntryBANK::Read(PseudoFile &file) |
| ... | ... |
@@ -17,13 +17,13 @@ |
| 17 | 17 |
Player::Player() : prio(0), nTracks(0), tempo(0), tempoCount(0), tempoRate(0), masterVol(0), sseqVol(0), sseq(nullptr), allowedChannels(0), sampleRate(0), |
| 18 | 18 |
interpolation(Interpolation::None) |
| 19 | 19 |
{
|
| 20 |
- std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, 0); |
|
| 20 |
+ std::fill_n(&this->trackIds[0], FSS_TRACKCOUNT, static_cast<std::uint8_t>(0)); |
|
| 21 | 21 |
for (std::int8_t i = 0; i < 16; ++i) |
| 22 | 22 |
{
|
| 23 | 23 |
this->channels[i].chnId = i; |
| 24 | 24 |
this->channels[i].ply = this; |
| 25 | 25 |
} |
| 26 |
- std::fill_n(&this->variables[0], 32, -1); |
|
| 26 |
+ std::fill_n(&this->variables[0], 32, static_cast<std::int16_t>(-1)); |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
// Original FSS Function: Player_Setup |
| ... | ... |
@@ -34,10 +34,10 @@ bool Player::Setup(const SSEQ *sseqToPlay) |
| 34 | 34 |
int firstTrack = this->TrackAlloc(); |
| 35 | 35 |
if (firstTrack == -1) |
| 36 | 36 |
return false; |
| 37 |
- this->tracks[firstTrack].Init(firstTrack, this, nullptr, 0); |
|
| 37 |
+ this->tracks[firstTrack].Init(static_cast<std::uint8_t>(firstTrack), this, nullptr, 0); |
|
| 38 | 38 |
|
| 39 | 39 |
this->nTracks = 1; |
| 40 |
- this->trackIds[0] = firstTrack; |
|
| 40 |
+ this->trackIds[0] = static_cast<std::uint8_t>(firstTrack); |
|
| 41 | 41 |
|
| 42 | 42 |
this->tracks[firstTrack].startPos = this->tracks[firstTrack].pos = &this->sseq->data[0]; |
| 43 | 43 |
|
| ... | ... |
@@ -53,7 +53,7 @@ void Player::ClearState() |
| 53 | 53 |
this->tempoCount = 0; |
| 54 | 54 |
this->tempoRate = 0x100; |
| 55 | 55 |
this->masterVol = 0; // this is actually the highest level |
| 56 |
- std::fill_n(&this->variables[0], 32, -1); |
|
| 56 |
+ std::fill_n(&this->variables[0], 32, static_cast<std::int16_t>(-1)); |
|
| 57 | 57 |
} |
| 58 | 58 |
|
| 59 | 59 |
// Original FSS Function: Player_FreeTracks |
| ... | ... |
@@ -13,7 +13,7 @@ |
| 13 | 13 |
#include "SBNK.h" |
| 14 | 14 |
#include "common.h" |
| 15 | 15 |
|
| 16 |
-SBNKInstrument::SBNKInstrument(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType) : lowNote(lowerNote), highNote(upperNote), |
|
| 16 |
+SBNKInstrument::SBNKInstrument(std::uint8_t lowerNote, std::uint8_t upperNote, std::uint16_t recordType) : lowNote(lowerNote), highNote(upperNote), |
|
| 17 | 17 |
record(recordType), swav(0), swar(0), noteNumber(0), attackRate(0), decayRate(0), sustainLevel(0), releaseRate(0), pan(0) |
| 18 | 18 |
{
|
| 19 | 19 |
} |
| ... | ... |
@@ -30,7 +30,7 @@ struct SBNKInstrument |
| 30 | 30 |
std::uint8_t releaseRate; |
| 31 | 31 |
std::uint8_t pan; |
| 32 | 32 |
|
| 33 |
- SBNKInstrument(std::uint8_t lowerNote, std::uint8_t upperNote, int recordType); |
|
| 33 |
+ SBNKInstrument(std::uint8_t lowerNote, std::uint8_t upperNote, std::uint16_t recordType); |
|
| 34 | 34 |
|
| 35 | 35 |
void Read(PseudoFile &file); |
| 36 | 36 |
}; |
| ... | ... |
@@ -75,11 +75,11 @@ void SWAV::DecodeADPCM(const std::uint8_t *origData, std::uint32_t len) |
| 75 | 75 |
{
|
| 76 | 76 |
std::int32_t nibble = origData[i + 4] & 0x0F; |
| 77 | 77 |
DecodeADPCMNibble(nibble, stepIndex, predictedValue); |
| 78 |
- finalData[2 * i] = predictedValue; |
|
| 78 |
+ finalData[2 * i] = static_cast<std::int16_t>(predictedValue); |
|
| 79 | 79 |
|
| 80 | 80 |
nibble = (origData[i + 4] >> 4) & 0x0F; |
| 81 | 81 |
DecodeADPCMNibble(nibble, stepIndex, predictedValue); |
| 82 |
- finalData[2 * i + 1] = predictedValue; |
|
| 82 |
+ finalData[2 * i + 1] = static_cast<std::int16_t>(predictedValue); |
|
| 83 | 83 |
} |
| 84 | 84 |
} |
| 85 | 85 |
|
| ... | ... |
@@ -26,7 +26,7 @@ Track::Track() |
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// Original FSS Function: Player_InitTrack |
| 29 |
-void Track::Init(std::uint8_t handle, Player *player, const std::uint8_t *dataPos, int n) |
|
| 29 |
+void Track::Init(std::uint8_t handle, Player *player, const std::uint8_t *dataPos, std::uint8_t n) |
|
| 30 | 30 |
{
|
| 31 | 31 |
this->trackId = handle; |
| 32 | 32 |
this->num = n; |
| ... | ... |
@@ -46,7 +46,7 @@ void Track::Zero() |
| 46 | 46 |
this->startPos = this->pos = nullptr; |
| 47 | 47 |
std::fill_n(&this->stack[0], FSS_TRACKSTACKSIZE, StackValue()); |
| 48 | 48 |
this->stackPos = 0; |
| 49 |
- std::fill_n(&this->loopCount[0], FSS_TRACKSTACKSIZE, 0); |
|
| 49 |
+ std::fill_n(&this->loopCount[0], FSS_TRACKSTACKSIZE, static_cast<std::uint8_t>(0)); |
|
| 50 | 50 |
this->overriding() = false; |
| 51 | 51 |
this->lastComparisonResult = true; |
| 52 | 52 |
|
| ... | ... |
@@ -105,7 +105,7 @@ void Track::Free() |
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
// Original FSS Function: Note_On |
| 108 |
-int Track::NoteOn(int key, int vel, int len) |
|
| 108 |
+int Track::NoteOn(std::uint8_t key, int vel, int len) |
|
| 109 | 109 |
{
|
| 110 | 110 |
auto sbnk = this->ply->sseq->bank; |
| 111 | 111 |
|
| ... | ... |
@@ -172,7 +172,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 172 | 172 |
chn = &this->ply->channels[nCh]; |
| 173 | 173 |
chn->tempReg.CR = SOUND_FORMAT_PSG | SCHANNEL_ENABLE | SOUND_DUTY(noteDef->swav & 0x7); |
| 174 | 174 |
} |
| 175 |
- chn->tempReg.TIMER = -SOUND_FREQ(262 * 8); // key #60 (C4) |
|
| 175 |
+ chn->tempReg.TIMER = static_cast<std::uint16_t>(-SOUND_FREQ(262 * 8)); // key #60 (C4) |
|
| 176 | 176 |
chn->reg.samplePosition = -1; |
| 177 | 177 |
chn->reg.psgX = 0x7FFF; |
| 178 | 178 |
} |
| ... | ... |
@@ -223,7 +223,7 @@ int Track::NoteOn(int key, int vel, int len) |
| 223 | 223 |
} |
| 224 | 224 |
|
| 225 | 225 |
// Original FSS Function: Note_On_Tie |
| 226 |
-int Track::NoteOnTie(int key, int vel) |
|
| 226 |
+int Track::NoteOnTie(std::uint8_t key, int vel) |
|
| 227 | 227 |
{
|
| 228 | 228 |
// Find an existing note |
| 229 | 229 |
int i; |
| ... | ... |
@@ -518,9 +518,9 @@ void Track::Run() |
| 518 | 518 |
if (cmd < 0x80) |
| 519 | 519 |
{
|
| 520 | 520 |
// Note on |
| 521 |
- int key = cmd + this->transpose; |
|
| 522 |
- int vel = this->overriding.val(pData, read8, true); |
|
| 523 |
- int len = this->overriding.val(pData, readvl); |
|
| 521 |
+ std::uint8_t key = static_cast<std::uint8_t>(cmd + this->transpose); |
|
| 522 |
+ int vel = this->overriding.val<std::uint8_t>(pData, read8, true); |
|
| 523 |
+ int len = this->overriding.val<int>(pData, readvl); |
|
| 524 | 524 |
if (this->state[ToIntegral(TrackState::NoteWait)]) |
| 525 | 525 |
this->wait = len; |
| 526 | 526 |
if (this->state[ToIntegral(TrackState::TieBit)]) |
| ... | ... |
@@ -539,23 +539,23 @@ void Track::Run() |
| 539 | 539 |
|
| 540 | 540 |
case SSEQCommand::OpenTrack: |
| 541 | 541 |
{
|
| 542 |
- int tNum = read8(pData); |
|
| 542 |
+ std::uint8_t tNum = read8(pData); |
|
| 543 | 543 |
auto trackPos = &this->ply->sseq->data[read24(pData)]; |
| 544 | 544 |
int newTrack = this->ply->TrackAlloc(); |
| 545 | 545 |
if (newTrack != -1) |
| 546 | 546 |
{
|
| 547 |
- this->ply->tracks[newTrack].Init(newTrack, this->ply, trackPos, tNum); |
|
| 548 |
- this->ply->trackIds[this->ply->nTracks++] = newTrack; |
|
| 547 |
+ this->ply->tracks[newTrack].Init(static_cast<std::uint8_t>(newTrack), this->ply, trackPos, tNum); |
|
| 548 |
+ this->ply->trackIds[this->ply->nTracks++] = static_cast<std::uint8_t>(newTrack); |
|
| 549 | 549 |
} |
| 550 | 550 |
break; |
| 551 | 551 |
} |
| 552 | 552 |
|
| 553 | 553 |
case SSEQCommand::Rest: |
| 554 |
- this->wait = this->overriding.val(pData, readvl); |
|
| 554 |
+ this->wait = this->overriding.val<int>(pData, readvl); |
|
| 555 | 555 |
break; |
| 556 | 556 |
|
| 557 | 557 |
case SSEQCommand::Patch: |
| 558 |
- this->patch = this->overriding.val(pData, readvl); |
|
| 558 |
+ this->patch = this->overriding.val<std::uint16_t>(pData, readvl); |
|
| 559 | 559 |
break; |
| 560 | 560 |
|
| 561 | 561 |
case SSEQCommand::Goto: |
| ... | ... |
@@ -578,23 +578,23 @@ void Track::Run() |
| 578 | 578 |
break; |
| 579 | 579 |
|
| 580 | 580 |
case SSEQCommand::Pan: |
| 581 |
- this->pan = this->overriding.val(pData, read8) - 64; |
|
| 581 |
+ this->pan = this->overriding.val<std::uint8_t>(pData, read8) - 64; |
|
| 582 | 582 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Pan)); |
| 583 | 583 |
break; |
| 584 | 584 |
|
| 585 | 585 |
case SSEQCommand::Volume: |
| 586 |
- this->vol = this->overriding.val(pData, read8); |
|
| 586 |
+ this->vol = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 587 | 587 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
| 588 | 588 |
break; |
| 589 | 589 |
|
| 590 | 590 |
case SSEQCommand::MasterVolume: |
| 591 |
- this->ply->masterVol = Cnv_Sust(this->overriding.val(pData, read8)); |
|
| 591 |
+ this->ply->masterVol = Cnv_Sust(this->overriding.val<std::uint8_t>(pData, read8)); |
|
| 592 | 592 |
for (std::uint8_t i = 0; i < this->ply->nTracks; ++i) |
| 593 | 593 |
this->ply->tracks[this->ply->trackIds[i]].updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
| 594 | 594 |
break; |
| 595 | 595 |
|
| 596 | 596 |
case SSEQCommand::Priority: |
| 597 |
- this->prio = this->ply->prio + read8(pData); |
|
| 597 |
+ this->prio = static_cast<std::uint8_t>(this->ply->prio + read8(pData)); |
|
| 598 | 598 |
// Update here? |
| 599 | 599 |
break; |
| 600 | 600 |
|
| ... | ... |
@@ -608,7 +608,7 @@ void Track::Run() |
| 608 | 608 |
break; |
| 609 | 609 |
|
| 610 | 610 |
case SSEQCommand::Expression: |
| 611 |
- this->expr = this->overriding.val(pData, read8); |
|
| 611 |
+ this->expr = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 612 | 612 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Volume)); |
| 613 | 613 |
break; |
| 614 | 614 |
|
| ... | ... |
@@ -621,10 +621,10 @@ void Track::Run() |
| 621 | 621 |
return; |
| 622 | 622 |
|
| 623 | 623 |
case SSEQCommand::LoopStart: |
| 624 |
- value = this->overriding.val(pData, read8); |
|
| 624 |
+ value = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 625 | 625 |
if (this->stackPos < FSS_TRACKSTACKSIZE) |
| 626 | 626 |
{
|
| 627 |
- this->loopCount[this->stackPos] = value; |
|
| 627 |
+ this->loopCount[this->stackPos] = static_cast<std::uint8_t>(value); |
|
| 628 | 628 |
this->stack[this->stackPos++] = StackValue(StackType::Loop, *pData); |
| 629 | 629 |
} |
| 630 | 630 |
break; |
| ... | ... |
@@ -647,11 +647,11 @@ void Track::Run() |
| 647 | 647 |
//----------------------------------------------------------------- |
| 648 | 648 |
|
| 649 | 649 |
case SSEQCommand::Transpose: |
| 650 |
- this->transpose = this->overriding.val(pData, read8); |
|
| 650 |
+ this->transpose = this->overriding.val<std::int8_t>(pData, read8); |
|
| 651 | 651 |
break; |
| 652 | 652 |
|
| 653 | 653 |
case SSEQCommand::PitchBend: |
| 654 |
- this->pitchBend = this->overriding.val(pData, read8); |
|
| 654 |
+ this->pitchBend = this->overriding.val<std::int8_t>(pData, read8); |
|
| 655 | 655 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Timer)); |
| 656 | 656 |
break; |
| 657 | 657 |
|
| ... | ... |
@@ -665,19 +665,19 @@ void Track::Run() |
| 665 | 665 |
//----------------------------------------------------------------- |
| 666 | 666 |
|
| 667 | 667 |
case SSEQCommand::Attack: |
| 668 |
- this->a = this->overriding.val(pData, read8); |
|
| 668 |
+ this->a = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 669 | 669 |
break; |
| 670 | 670 |
|
| 671 | 671 |
case SSEQCommand::Decay: |
| 672 |
- this->d = this->overriding.val(pData, read8); |
|
| 672 |
+ this->d = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 673 | 673 |
break; |
| 674 | 674 |
|
| 675 | 675 |
case SSEQCommand::Sustain: |
| 676 |
- this->s = this->overriding.val(pData, read8); |
|
| 676 |
+ this->s = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 677 | 677 |
break; |
| 678 | 678 |
|
| 679 | 679 |
case SSEQCommand::Release: |
| 680 |
- this->r = this->overriding.val(pData, read8); |
|
| 680 |
+ this->r = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 681 | 681 |
break; |
| 682 | 682 |
|
| 683 | 683 |
//----------------------------------------------------------------- |
| ... | ... |
@@ -685,7 +685,7 @@ void Track::Run() |
| 685 | 685 |
//----------------------------------------------------------------- |
| 686 | 686 |
|
| 687 | 687 |
case SSEQCommand::PortamentoKey: |
| 688 |
- this->portaKey = read8(pData) + this->transpose; |
|
| 688 |
+ this->portaKey = static_cast<std::uint8_t>(read8(pData) + this->transpose); |
|
| 689 | 689 |
this->state.set(ToIntegral(TrackState::PortamentoBit)); |
| 690 | 690 |
// Update here? |
| 691 | 691 |
break; |
| ... | ... |
@@ -696,13 +696,13 @@ void Track::Run() |
| 696 | 696 |
break; |
| 697 | 697 |
|
| 698 | 698 |
case SSEQCommand::PortamentoTime: |
| 699 |
- this->portaTime = this->overriding.val(pData, read8); |
|
| 699 |
+ this->portaTime = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 700 | 700 |
this->state.set(ToIntegral(TrackState::PortamentoBit)); |
| 701 | 701 |
// Update here? |
| 702 | 702 |
break; |
| 703 | 703 |
|
| 704 | 704 |
case SSEQCommand::SweepPitch: |
| 705 |
- this->sweepPitch = this->overriding.val(pData, read16); |
|
| 705 |
+ this->sweepPitch = this->overriding.val<std::int16_t>(pData, read16); |
|
| 706 | 706 |
this->state.set(ToIntegral(TrackState::PortamentoBit)); |
| 707 | 707 |
// Update here? |
| 708 | 708 |
break; |
| ... | ... |
@@ -712,12 +712,12 @@ void Track::Run() |
| 712 | 712 |
//----------------------------------------------------------------- |
| 713 | 713 |
|
| 714 | 714 |
case SSEQCommand::ModulationDepth: |
| 715 |
- this->modDepth = this->overriding.val(pData, read8); |
|
| 715 |
+ this->modDepth = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 716 | 716 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
| 717 | 717 |
break; |
| 718 | 718 |
|
| 719 | 719 |
case SSEQCommand::ModulationSpeed: |
| 720 |
- this->modSpeed = this->overriding.val(pData, read8); |
|
| 720 |
+ this->modSpeed = this->overriding.val<std::uint8_t>(pData, read8); |
|
| 721 | 721 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
| 722 | 722 |
break; |
| 723 | 723 |
|
| ... | ... |
@@ -732,7 +732,7 @@ void Track::Run() |
| 732 | 732 |
break; |
| 733 | 733 |
|
| 734 | 734 |
case SSEQCommand::ModulationDelay: |
| 735 |
- this->modDelay = this->overriding.val(pData, read16); |
|
| 735 |
+ this->modDelay = this->overriding.val<std::uint16_t>(pData, read16); |
|
| 736 | 736 |
this->updateFlags.set(ToIntegral(TrackUpdateFlag::Modulation)); |
| 737 | 737 |
break; |
| 738 | 738 |
|
| ... | ... |
@@ -746,8 +746,8 @@ void Track::Run() |
| 746 | 746 |
this->overriding.cmd = read8(pData); |
| 747 | 747 |
if ((this->overriding.cmd >= ToIntegral(SSEQCommand::SetVariable) && this->overriding.cmd <= ToIntegral(SSEQCommand::CompareNotEqualTo)) || this->overriding.cmd < 0x80) |
| 748 | 748 |
this->overriding.extraValue = read8(pData); |
| 749 |
- std::int16_t minVal = read16(pData); |
|
| 750 |
- std::int16_t maxVal = read16(pData); |
|
| 749 |
+ std::int16_t minVal = static_cast<std::int16_t>(read16(pData)); |
|
| 750 |
+ std::int16_t maxVal = static_cast<std::int16_t>(read16(pData)); |
|
| 751 | 751 |
this->overriding.value = (CalcRandom() % (maxVal - minVal + 1)) + minVal; |
| 752 | 752 |
break; |
| 753 | 753 |
} |
| ... | ... |
@@ -772,11 +772,11 @@ void Track::Run() |
| 772 | 772 |
case SSEQCommand::ShiftVariable: |
| 773 | 773 |
case SSEQCommand::RandomVariable: |
| 774 | 774 |
{
|
| 775 |
- std::int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 776 |
- value = this->overriding.val(pData, read16); |
|
| 775 |
+ std::int8_t varNo = this->overriding.val<std::int8_t>(pData, read8, true); |
|
| 776 |
+ value = this->overriding.val<std::int16_t>(pData, read16); |
|
| 777 | 777 |
if (cmd == ToIntegral(SSEQCommand::DivideVariable) && !value) // Division by 0, skip it to prevent crashing |
| 778 | 778 |
break; |
| 779 |
- this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], value); |
|
| 779 |
+ this->ply->variables[varNo] = VarFunc(cmd)(this->ply->variables[varNo], static_cast<std::int16_t>(value)); |
|
| 780 | 780 |
break; |
| 781 | 781 |
} |
| 782 | 782 |
|
| ... | ... |
@@ -791,9 +791,9 @@ void Track::Run() |
| 791 | 791 |
case SSEQCommand::CompareLessThan: |
| 792 | 792 |
case SSEQCommand::CompareNotEqualTo: |
| 793 | 793 |
{
|
| 794 |
- std::int8_t varNo = this->overriding.val(pData, read8, true); |
|
| 795 |
- value = this->overriding.val(pData, read16); |
|
| 796 |
- this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], value); |
|
| 794 |
+ std::int8_t varNo = this->overriding.val<std::int8_t>(pData, read8, true); |
|
| 795 |
+ value = this->overriding.val<std::int16_t>(pData, read16); |
|
| 796 |
+ this->lastComparisonResult = CompareFunc(cmd)(this->ply->variables[varNo], static_cast<std::int16_t>(value)); |
|
| 797 | 797 |
break; |
| 798 | 798 |
} |
| 799 | 799 |
|
| ... | ... |
@@ -42,12 +42,12 @@ struct Override |
| 42 | 42 |
Override() : overriding(false), cmd(0), value(0), extraValue(0) { }
|
| 43 | 43 |
bool operator()() const { return this->overriding; }
|
| 44 | 44 |
bool &operator()() { return this->overriding; }
|
| 45 |
- int val(const std::uint8_t **pData, std::function<int (const std::uint8_t **)> reader, bool returnExtra = false) |
|
| 45 |
+ template<typename T> T val(const std::uint8_t **pData, std::function<int (const std::uint8_t **)> reader, bool returnExtra = false) |
|
| 46 | 46 |
{
|
| 47 | 47 |
if (this->overriding) |
| 48 |
- return returnExtra ? this->extraValue : this->value; |
|
| 48 |
+ return static_cast<T>(returnExtra ? this->extraValue : this->value); |
|
| 49 | 49 |
else |
| 50 |
- return reader(pData); |
|
| 50 |
+ return static_cast<T>(reader(pData)); |
|
| 51 | 51 |
} |
| 52 | 52 |
}; |
| 53 | 53 |
|
| ... | ... |
@@ -86,12 +86,12 @@ struct Track |
| 86 | 86 |
|
| 87 | 87 |
Track(); |
| 88 | 88 |
|
| 89 |
- void Init(std::uint8_t handle, Player *ply, const std::uint8_t *pos, int n); |
|
| 89 |
+ void Init(std::uint8_t handle, Player *ply, const std::uint8_t *pos, std::uint8_t n); |
|
| 90 | 90 |
void Zero(); |
| 91 | 91 |
void ClearState(); |
| 92 | 92 |
void Free(); |
| 93 |
- int NoteOn(int key, int vel, int len); |
|
| 94 |
- int NoteOnTie(int key, int vel); |
|
| 93 |
+ int NoteOn(std::uint8_t key, int vel, int len); |
|
| 94 |
+ int NoteOnTie(std::uint8_t key, int vel); |
|
| 95 | 95 |
void ReleaseAllNotes(); |
| 96 | 96 |
void Run(); |
| 97 | 97 |
}; |
| ... | ... |
@@ -138,7 +138,7 @@ template<std::size_t N> inline bool VerifyHeader(std::int8_t (&arr)[N], const st |
| 138 | 138 |
/* |
| 139 | 139 |
* The remaining functions in this file come from the FeOS Sound System source code. |
| 140 | 140 |
*/ |
| 141 |
-inline int Cnv_Attack(int attk) |
|
| 141 |
+inline std::uint8_t Cnv_Attack(int attk) |
|
| 142 | 142 |
{
|
| 143 | 143 |
static const std::uint8_t lut[] = |
| 144 | 144 |
{
|
| ... | ... |
@@ -151,7 +151,7 @@ inline int Cnv_Attack(int attk) |
| 151 | 151 |
return attk >= 0x6D ? lut[0x7F - attk] : 0xFF - attk; |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 |
-inline int Cnv_Fall(int fall) |
|
| 154 |
+inline std::uint16_t Cnv_Fall(int fall) |
|
| 155 | 155 |
{
|
| 156 | 156 |
if (fall & 0x80) // Supposedly invalid value... |
| 157 | 157 |
fall = 0; // Use apparently correct default |
| ... | ... |
@@ -165,7 +165,7 @@ inline int Cnv_Fall(int fall) |
| 165 | 165 |
return (0x1E00 / (0x7E - fall)) & 0xFFFF; |
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 |
-inline int Cnv_Scale(int scale) |
|
| 168 |
+inline std::int16_t Cnv_Scale(int scale) |
|
| 169 | 169 |
{
|
| 170 | 170 |
static const std::int16_t lut[] = |
| 171 | 171 |
{
|
| ... | ... |
@@ -192,7 +192,7 @@ inline int Cnv_Scale(int scale) |
| 192 | 192 |
return lut[scale]; |
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 |
-inline int Cnv_Sust(int sust) |
|
| 195 |
+inline std::int16_t Cnv_Sust(int sust) |
|
| 196 | 196 |
{
|
| 197 | 197 |
static const std::int16_t lut[] = |
| 198 | 198 |
{
|
| ... | ... |
@@ -238,17 +238,17 @@ inline int Cnv_Sine(int arg) |
| 238 | 238 |
return -lut[4 * lut_size - arg]; |
| 239 | 239 |
} |
| 240 | 240 |
|
| 241 |
-inline int read8(const std::uint8_t **ppData) |
|
| 241 |
+inline std::uint8_t read8(const std::uint8_t **ppData) |
|
| 242 | 242 |
{
|
| 243 | 243 |
auto pData = *ppData; |
| 244 |
- int x = *pData; |
|
| 244 |
+ std::uint8_t x = *pData; |
|
| 245 | 245 |
*ppData = pData + 1; |
| 246 | 246 |
return x; |
| 247 | 247 |
} |
| 248 | 248 |
|
| 249 |
-inline int read16(const std::uint8_t **ppData) |
|
| 249 |
+inline std::uint16_t read16(const std::uint8_t **ppData) |
|
| 250 | 250 |
{
|
| 251 |
- int x = read8(ppData); |
|
| 251 |
+ std::uint16_t x = read8(ppData); |
|
| 252 | 252 |
x |= read8(ppData) << 8; |
| 253 | 253 |
return x; |
| 254 | 254 |
} |
| ... | ... |
@@ -44,5 +44,7 @@ set(SOURCES |
| 44 | 44 |
add_library(in_snsf SHARED ${HEADERS} ${SOURCES})
|
| 45 | 45 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Header Files" FILES ${HEADERS})
|
| 46 | 46 |
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Source Files" FILES ${SOURCES})
|
| 47 |
+target_compile_options(in_snsf PUBLIC |
|
| 48 |
+ $<$<CXX_COMPILER_ID:MSVC>:/wd4127 /wd4245 /wd6385 /wd6386 /wd26453 /wd26495 /wd26812 /wd26819>) |
|
| 47 | 49 |
target_link_libraries(in_snsf |
| 48 | 50 |
in_xsf_framework) |
| ... | ... |
@@ -100,7 +100,7 @@ public: |
| 100 | 100 |
return; |
| 101 | 101 |
if (bytes > bleft) |
| 102 | 102 |
bytes = bleft; |
| 103 |
- std::fill_n(&this->buf[this->fil], bytes, 0); |
|
| 103 |
+ std::fill_n(&this->buf[this->fil], bytes, static_cast<std::uint8_t>(0)); |
|
| 104 | 104 |
S9xMixSamples(&this->buf[this->fil], bytes >> 1); |
| 105 | 105 |
this->fil += bytes; |
| 106 | 106 |
} |
| ... | ... |
@@ -235,7 +235,7 @@ target_compile_definitions(in_xsf_framework PUBLIC |
| 235 | 235 |
UNICODE_INPUT_PLUGIN |
| 236 | 236 |
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<CONFIG:Debug>>:_ITERATOR_DEBUG_LEVEL=0>) |
| 237 | 237 |
target_compile_options(in_xsf_framework PUBLIC |
| 238 |
- $<$<CXX_COMPILER_ID:MSVC>:/W4>) |
|
| 238 |
+ $<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4244 /wd6258 /wd26451 /wd28159>) |
|
| 239 | 239 |
target_include_directories(in_xsf_framework PUBLIC |
| 240 | 240 |
${CMAKE_CURRENT_SOURCE_DIR}
|
| 241 | 241 |
${CMAKE_CURRENT_SOURCE_DIR}/winamp
|