Skip to content

Commit

Permalink
Fixed some MSVC compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed May 31, 2024
1 parent 0146794 commit f190d5e
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 165 deletions.
2 changes: 1 addition & 1 deletion Emulator/Base/CmdQueueTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct CmdTypeEnum : util::Reflection<CmdType, CmdType> {
typedef struct
{
Option option;
isize value;
i64 value;
isize id;
}
ConfigCmd;
Expand Down
4 changes: 2 additions & 2 deletions Emulator/Base/Option.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ class EnumParser : public OptionParser {
using OptionParser::OptionParser;

virtual i64 parse(const string &s) override { return (arg = util::parseEnum<T>(s)); }
virtual string asPlainString() override { return T::plainkey(arg); }
virtual string asString() override { return T::key(arg); }
virtual string asPlainString() override { return T::plainkey(isize(arg)); }
virtual string asString() override { return T::key(isize(arg)); }
virtual string keyList() override { return T::keyList(); }
virtual string argList() override { return T::argList(); }
};
Expand Down
61 changes: 25 additions & 36 deletions Emulator/Components/C64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,44 +974,33 @@ C64::process(const Cmd &cmd)
switch (cmd.type) {

case CMD_CPU_BRK:

cpu.next = BRK;
cpu.reg.pc0 = cpu.reg.pc - 1;
break;

case CMD_CPU_NMI:

if (cmd.value) {
cpu.pullDownNmiLine(INTSRC_EXP);
} else {
cpu.releaseNmiLine(INTSRC_EXP);
}
case CMD_BP_SET_AT:
case CMD_BP_MOVE_TO:
case CMD_BP_REMOVE_NR:
case CMD_BP_REMOVE_AT:
case CMD_BP_REMOVE_ALL:
case CMD_BP_ENABLE_NR:
case CMD_BP_ENABLE_AT:
case CMD_BP_ENABLE_ALL:
case CMD_BP_DISABLE_NR:
case CMD_BP_DISABLE_AT:
case CMD_BP_DISABLE_ALL:
case CMD_WP_SET_AT:
case CMD_WP_MOVE_TO:
case CMD_WP_REMOVE_NR:
case CMD_WP_REMOVE_AT:
case CMD_WP_REMOVE_ALL:
case CMD_WP_ENABLE_NR:
case CMD_WP_ENABLE_AT:
case CMD_WP_ENABLE_ALL:
case CMD_WP_DISABLE_NR:
case CMD_WP_DISABLE_AT:
case CMD_WP_DISABLE_ALL:

cpu.processCommand(cmd);
break;

case CMD_BP_SET_AT: cpu.setBreakpoint(u32(cmd.value)); break;
case CMD_BP_MOVE_TO: cpu.moveBreakpoint(cmd.value, u32(cmd.value2)); break;
case CMD_BP_REMOVE_NR: cpu.deleteBreakpoint(cmd.value); break;
case CMD_BP_REMOVE_AT: cpu.deleteBreakpointAt(u32(cmd.value)); break;
case CMD_BP_REMOVE_ALL: cpu.deleteAllBreakpoints(); break;
case CMD_BP_ENABLE_NR: cpu.enableBreakpoint(cmd.value); break;
case CMD_BP_ENABLE_AT: cpu.enableBreakpoint(u32(cmd.value)); break;
case CMD_BP_ENABLE_ALL: cpu.enableAllBreakpoints(); break;
case CMD_BP_DISABLE_NR: cpu.disableBreakpoint(cmd.value); break;
case CMD_BP_DISABLE_AT: cpu.disableBreakpoint(u32(cmd.value)); break;
case CMD_BP_DISABLE_ALL: cpu.disableAllBreakpoints(); break;

case CMD_WP_SET_AT: cpu.setWatchpoint(u32(cmd.value)); break;
case CMD_WP_MOVE_TO: cpu.moveWatchpoint(cmd.value, u32(cmd.value2)); break;
case CMD_WP_REMOVE_NR: cpu.deleteWatchpoint(cmd.value); break;
case CMD_WP_REMOVE_AT: cpu.deleteWatchpointAt(u32(cmd.value)); break;
case CMD_WP_REMOVE_ALL: cpu.deleteAllWatchpoints(); break;
case CMD_WP_ENABLE_NR: cpu.enableWatchpoint(cmd.value); break;
case CMD_WP_ENABLE_AT: cpu.enableWatchpoint(u32(cmd.value)); break;
case CMD_WP_ENABLE_ALL: cpu.enableAllWatchpoints(); break;
case CMD_WP_DISABLE_NR: cpu.disableWatchpoint(cmd.value); break;
case CMD_WP_DISABLE_AT: cpu.disableWatchpoint(u32(cmd.value)); break;
case CMD_WP_DISABLE_ALL: cpu.disableAllWatchpoints(); break;


case CMD_ALARM_ABS:

setAlarmAbs(cmd.alarm.cycle, cmd.alarm.value);
Expand Down
28 changes: 14 additions & 14 deletions Emulator/Components/CPU/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,29 +221,29 @@ CPU::processCommand(const Cmd &cmd)
break;

case CMD_BP_SET_AT: cpu.setBreakpoint(u32(cmd.value)); break;
case CMD_BP_MOVE_TO: cpu.moveBreakpoint(cmd.value, u32(cmd.value2)); break;
case CMD_BP_REMOVE_NR: cpu.deleteBreakpoint(cmd.value); break;
case CMD_BP_MOVE_TO: cpu.moveBreakpoint(isize(cmd.value), u32(cmd.value2)); break;
case CMD_BP_REMOVE_NR: cpu.deleteBreakpoint(isize(cmd.value)); break;
case CMD_BP_REMOVE_AT: cpu.deleteBreakpointAt(u32(cmd.value)); break;
case CMD_BP_REMOVE_ALL: cpu.deleteAllBreakpoints(); break;
case CMD_BP_ENABLE_NR: cpu.enableBreakpoint(cmd.value); break;
case CMD_BP_ENABLE_AT: cpu.enableBreakpointAt(u32(cmd.value)); break;
case CMD_BP_ENABLE_NR: cpu.enableBreakpoint(isize(cmd.value)); break;
case CMD_BP_ENABLE_AT: cpu.enableBreakpoint(u32(cmd.value)); break;
case CMD_BP_ENABLE_ALL: cpu.enableAllBreakpoints(); break;
case CMD_BP_DISABLE_NR: cpu.disableBreakpoint(cmd.value); break;
case CMD_BP_DISABLE_AT: cpu.disableBreakpointAt(u32(cmd.value)); break;
case CMD_BP_DISABLE_NR: cpu.disableBreakpoint(isize(cmd.value)); break;
case CMD_BP_DISABLE_AT: cpu.disableBreakpoint(u32(cmd.value)); break;
case CMD_BP_DISABLE_ALL: cpu.disableAllBreakpoints(); break;

case CMD_WP_SET_AT: cpu.setWatchpoint(u32(cmd.value)); break;
case CMD_WP_MOVE_TO: cpu.moveWatchpoint(cmd.value, u32(cmd.value2)); break;
case CMD_WP_REMOVE_NR: cpu.deleteWatchpoint(cmd.value); break;
case CMD_WP_MOVE_TO: cpu.moveWatchpoint(isize(cmd.value), u32(cmd.value2)); break;
case CMD_WP_REMOVE_NR: cpu.deleteWatchpoint(isize(cmd.value)); break;
case CMD_WP_REMOVE_AT: cpu.deleteWatchpointAt(u32(cmd.value)); break;
case CMD_WP_REMOVE_ALL: cpu.deleteAllWatchpoints(); break;
case CMD_WP_ENABLE_NR: cpu.enableWatchpoint(cmd.value); break;
case CMD_WP_ENABLE_AT: cpu.enableWatchpointAt(u32(cmd.value)); break;
case CMD_WP_ENABLE_NR: cpu.enableWatchpoint(isize(cmd.value)); break;
case CMD_WP_ENABLE_AT: cpu.enableWatchpoint(u32(cmd.value)); break;
case CMD_WP_ENABLE_ALL: cpu.enableAllWatchpoints(); break;
case CMD_WP_DISABLE_NR: cpu.disableWatchpoint(cmd.value); break;
case CMD_WP_DISABLE_AT: cpu.disableWatchpointAt(u32(cmd.value)); break;
case CMD_WP_DISABLE_NR: cpu.disableWatchpoint(isize(cmd.value)); break;
case CMD_WP_DISABLE_AT: cpu.disableWatchpoint(u32(cmd.value)); break;
case CMD_WP_DISABLE_ALL: cpu.disableAllWatchpoints(); break;

default:
fatalError;
}
Expand Down
128 changes: 66 additions & 62 deletions Emulator/Components/Ports/AudioPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,45 +254,47 @@ AudioPort::mixSingleSID(isize numSamples)
// Check for buffer overflow
if (free() < numSamples) handleBufferOverflow();

if (!fading && (curL + curR == 0.0 || vol0 == 0.0)) {
if constexpr (fading == false) {

// Fast path: All samples are zero
for (isize i = 0; i < numSamples; i++) (void)sid0.stream.read();
for (isize i = 0; i < numSamples; i++) write(SamplePair { 0, 0 } );
if (curL + curR == 0.0 || vol0 == 0.0) {

// Send a MUTE message if applicable
if (!muted) { muted = true; msgQueue.put(MSG_MUTE, true); }
// Fast path: All samples are zero
for (isize i = 0; i < numSamples; i++) (void)sid0.stream.read();
for (isize i = 0; i < numSamples; i++) write(SamplePair { 0, 0 } );

} else {

// Slow path: There is something to hear
for (isize i = 0; i < numSamples; i++) {
// Send a MUTE message if applicable
if (!muted) { muted = true; msgQueue.put(MSG_MUTE, true); }
return;
}
}

// Read SID sample from ring buffer
float ch0 = (float)sidBridge.sid0.stream.read() * vol0;
// Slow path: There is something to hear
for (isize i = 0; i < numSamples; i++) {

// Compute left and right channel output
float l = ch0 * (1 - pan0);
float r = ch0 * pan0;
// Read SID sample from ring buffer
float ch0 = (float)sidBridge.sid0.stream.read() * vol0;

// Modulate the master volume
if constexpr (fading) { volL.shift(); curL = volL.current; }
if constexpr (fading) { volR.shift(); curR = volR.current; }
// Compute left and right channel output
float l = ch0 * (1 - pan0);
float r = ch0 * pan0;

// Apply master volume
l *= curL;
r *= curR;
// Modulate the master volume
if constexpr (fading) { volL.shift(); curL = volL.current; }
if constexpr (fading) { volR.shift(); curR = volR.current; }

// Prevent hearing loss
assert(abs(l) < 1.0);
assert(abs(r) < 1.0);
// Apply master volume
l *= curL;
r *= curR;

write(SamplePair { l, r } );
}
// Prevent hearing loss
assert(abs(l) < 1.0);
assert(abs(r) < 1.0);

// Send a MUTE message if applicable
if (muted) { muted = false; msgQueue.put(MSG_MUTE, false); }
write(SamplePair { l, r } );
}

// Send a MUTE message if applicable
if (muted) { muted = false; msgQueue.put(MSG_MUTE, false); }
}

template <bool fading> void
Expand All @@ -312,52 +314,54 @@ AudioPort::mixMultiSID(isize numSamples)
// Check for buffer overflow
if (free() < numSamples) handleBufferOverflow();

if (!fading && (curL + curR == 0.0 || vol0 + vol1 + vol2 + vol3 == 0.0)) {
if constexpr (fading == false) {

// Fast path: All samples are zero
for (isize i = 0; i < numSamples; i++) (void)sid0.stream.read();
for (isize i = 0; i < numSamples; i++) (void)sid1.stream.read(0);
for (isize i = 0; i < numSamples; i++) (void)sid2.stream.read(0);
for (isize i = 0; i < numSamples; i++) (void)sid3.stream.read(0);
for (isize i = 0; i < numSamples; i++) write(SamplePair { 0, 0 } );
if (curL + curR == 0.0 || vol0 + vol1 + vol2 + vol3 == 0.0) {

// Send a MUTE message if applicable
if (!muted) { muted = true; msgQueue.put(MSG_MUTE, true); }
// Fast path: All samples are zero
for (isize i = 0; i < numSamples; i++) (void)sid0.stream.read();
for (isize i = 0; i < numSamples; i++) (void)sid1.stream.read(0);
for (isize i = 0; i < numSamples; i++) (void)sid2.stream.read(0);
for (isize i = 0; i < numSamples; i++) (void)sid3.stream.read(0);
for (isize i = 0; i < numSamples; i++) write(SamplePair { 0, 0 } );

} else {

// Slow path: There is something to hear
for (isize i = 0; i < numSamples; i++) {
// Send a MUTE message if applicable
if (!muted) { muted = true; msgQueue.put(MSG_MUTE, true); }
return;
}
}

float ch0, ch1, ch2, ch3, l, r;
// Slow path: There is something to hear
for (isize i = 0; i < numSamples; i++) {

ch0 = (float)sid0.stream.read() * vol0;
ch1 = (float)sid1.stream.read(0) * vol1;
ch2 = (float)sid2.stream.read(0) * vol2;
ch3 = (float)sid3.stream.read(0) * vol3;
float ch0, ch1, ch2, ch3, l, r;

// Compute left and right channel output
l = ch0 * (1 - pan0) + ch1 * (1 - pan1) + ch2 * (1 - pan2) + ch3 * (1 - pan3);
r = ch0 * pan0 + ch1 * pan1 + ch2 * pan2 + ch3 * pan3;
ch0 = (float)sid0.stream.read() * vol0;
ch1 = (float)sid1.stream.read(0) * vol1;
ch2 = (float)sid2.stream.read(0) * vol2;
ch3 = (float)sid3.stream.read(0) * vol3;

// Modulate the master volume
if constexpr (fading) { volL.shift(); curL = volL.current; }
if constexpr (fading) { volR.shift(); curR = volR.current; }
// Compute left and right channel output
l = ch0 * (1 - pan0) + ch1 * (1 - pan1) + ch2 * (1 - pan2) + ch3 * (1 - pan3);
r = ch0 * pan0 + ch1 * pan1 + ch2 * pan2 + ch3 * pan3;

// Apply master volume
l *= curL;
r *= curR;
// Modulate the master volume
if constexpr (fading) { volL.shift(); curL = volL.current; }
if constexpr (fading) { volR.shift(); curR = volR.current; }

// Prevent hearing loss
assert(abs(l) < 1.0);
assert(abs(r) < 1.0);
// Apply master volume
l *= curL;
r *= curR;

write(SamplePair { l, r } );
}
// Prevent hearing loss
assert(abs(l) < 1.0);
assert(abs(r) < 1.0);

// Send a MUTE message if applicable
if (muted) { muted = false; msgQueue.put(MSG_MUTE, false); }
write(SamplePair { l, r } );
}

// Send a MUTE message if applicable
if (muted) { muted = false; msgQueue.put(MSG_MUTE, false); }
}

void
Expand Down
4 changes: 2 additions & 2 deletions Emulator/Components/Ports/ExpansionPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ ExpansionPort::processCommand(const Cmd &cmd)
{
switch (cmd.type) {

case CMD_CRT_BUTTON_PRESS: pressButton(cmd.value); break;
case CMD_CRT_BUTTON_RELEASE: releaseButton(cmd.value); break;
case CMD_CRT_BUTTON_PRESS: pressButton(isize(cmd.value)); break;
case CMD_CRT_BUTTON_RELEASE: releaseButton(isize(cmd.value)); break;
case CMD_CRT_SWITCH_LEFT: setSwitch(-1); break;
case CMD_CRT_SWITCH_NEUTRAL: setSwitch(0); break;
case CMD_CRT_SWITCH_RIGHT: setSwitch(1); break;
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Components/SID/SID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ SID::executeUntil(Cycle targetCycle)
if (missing < 1) missing = 1;

// Compute the missing samples
auto numSamples = resid.executeCycles(missing, stream);
auto numSamples = resid.executeCycles(isize(missing), stream);
debug(SID_EXEC, "%ld: target: %lld missing: %lld generated: %ld", objid, targetCycle, missing, numSamples);
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions Emulator/Components/SID/SIDConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ SID::setOption(Option opt, i64 value)

case OPT_SID_ENABLE:

if (config.enabled != value) {
if (config.enabled != bool(value)) {

config.enabled = value;
config.enabled = bool(value);
stream.clear(0);
c64.sidBridge.hardReset();
}
Expand All @@ -176,7 +176,7 @@ SID::setOption(Option opt, i64 value)

case OPT_SID_FILTER:

if (config.filter != value) {
if (config.filter != bool(value)) {

config.filter = bool(value);
setAudioFilter(bool(value));
Expand Down
4 changes: 2 additions & 2 deletions Emulator/Components/VICII/VICII.h
Original file line number Diff line number Diff line change
Expand Up @@ -1345,11 +1345,11 @@ class VICII final : public SubComponent, public Inspectable<VICIIInfo, VICIIStat

#define DRAW_SPRITES_DMA1 \
assert(isFirstDMAcycle); assert(!isSecondDMAcycle); \
if (!(flags & HEADLESS_CYCLE)) { drawSpritesSlowPath(); }
if constexpr (!(flags & HEADLESS_CYCLE)) { drawSpritesSlowPath(); }

#define DRAW_SPRITES_DMA2 \
assert(!isFirstDMAcycle); assert(isSecondDMAcycle); \
if (!(flags & HEADLESS_CYCLE)) { drawSpritesSlowPath(); }
if constexpr (!(flags & HEADLESS_CYCLE)) { drawSpritesSlowPath(); }

#define DRAW_SPRITES \
assert(!isFirstDMAcycle && !isSecondDMAcycle); \
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Components/VICII/VICIICycles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ VICII::cycle1()
}

// Phi1.2 Draw sprites (invisible area)
if (!(flags & HEADLESS_CYCLE)) drawSpritesSlowPath();
if constexpr (!(flags & HEADLESS_CYCLE)) drawSpritesSlowPath();

// Phi1.3 Fetch
PAL { sFinalize(2); pAccess <flags> (3); }
Expand Down
Loading

0 comments on commit f190d5e

Please sign in to comment.