diff --git a/Emulator/Base/CmdQueueTypes.h b/Emulator/Base/CmdQueueTypes.h index 73e029f50..a1de2e87a 100644 --- a/Emulator/Base/CmdQueueTypes.h +++ b/Emulator/Base/CmdQueueTypes.h @@ -191,7 +191,7 @@ struct CmdTypeEnum : util::Reflection { typedef struct { Option option; - isize value; + i64 value; isize id; } ConfigCmd; diff --git a/Emulator/Base/Option.h b/Emulator/Base/Option.h index b20a1a6a4..8e32584a8 100644 --- a/Emulator/Base/Option.h +++ b/Emulator/Base/Option.h @@ -90,8 +90,8 @@ class EnumParser : public OptionParser { using OptionParser::OptionParser; virtual i64 parse(const string &s) override { return (arg = util::parseEnum(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(); } }; diff --git a/Emulator/Components/C64.cpp b/Emulator/Components/C64.cpp index 4b720d24e..690eb7dce 100644 --- a/Emulator/Components/C64.cpp +++ b/Emulator/Components/C64.cpp @@ -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); diff --git a/Emulator/Components/CPU/CPU.cpp b/Emulator/Components/CPU/CPU.cpp index 4a735087e..4d7421bfe 100755 --- a/Emulator/Components/CPU/CPU.cpp +++ b/Emulator/Components/CPU/CPU.cpp @@ -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; } diff --git a/Emulator/Components/Ports/AudioPort.cpp b/Emulator/Components/Ports/AudioPort.cpp index d61618e26..1431a5863 100644 --- a/Emulator/Components/Ports/AudioPort.cpp +++ b/Emulator/Components/Ports/AudioPort.cpp @@ -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 void @@ -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 diff --git a/Emulator/Components/Ports/ExpansionPort.cpp b/Emulator/Components/Ports/ExpansionPort.cpp index 4693f37a2..234352dcf 100644 --- a/Emulator/Components/Ports/ExpansionPort.cpp +++ b/Emulator/Components/Ports/ExpansionPort.cpp @@ -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; diff --git a/Emulator/Components/SID/SID.cpp b/Emulator/Components/SID/SID.cpp index 3572fb37c..674b0424d 100644 --- a/Emulator/Components/SID/SID.cpp +++ b/Emulator/Components/SID/SID.cpp @@ -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 { diff --git a/Emulator/Components/SID/SIDConfig.cpp b/Emulator/Components/SID/SIDConfig.cpp index d0d090c46..82aa6ade7 100644 --- a/Emulator/Components/SID/SIDConfig.cpp +++ b/Emulator/Components/SID/SIDConfig.cpp @@ -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(); } @@ -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)); diff --git a/Emulator/Components/VICII/VICII.h b/Emulator/Components/VICII/VICII.h index e32eb0d19..63a37ed71 100755 --- a/Emulator/Components/VICII/VICII.h +++ b/Emulator/Components/VICII/VICII.h @@ -1345,11 +1345,11 @@ class VICII final : public SubComponent, public Inspectable (3); } diff --git a/Emulator/Misc/Debugger/Debugger.cpp b/Emulator/Misc/Debugger/Debugger.cpp index a6b874097..1c4c1f154 100644 --- a/Emulator/Misc/Debugger/Debugger.cpp +++ b/Emulator/Misc/Debugger/Debugger.cpp @@ -79,15 +79,15 @@ Debugger::ascDump(std::ostream& os, u16 addr, isize lines) current = addr; for (isize i = 0; i < lines; i++) { - - current += dump(os, current, - "%p: " - "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" - "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" - "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" - "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c\n"); + + current += (u16)dump(os, current, + "%p: " + "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" + "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" + "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c" + "%c%c%c%c%c%c%c%c" "%c%c%c%c%c%c%c%c\n"); } - + return isize(current - addr); } @@ -98,9 +98,9 @@ Debugger::hexDump(std::ostream& os, u16 addr, isize lines) for (isize i = 0; i < lines; i++) { - current += dump(os, current, - "%p: " - "%b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b\n"); + current += (u16)dump(os, current, + "%p: " + "%b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b\n"); } return isize(current - addr); @@ -113,10 +113,10 @@ Debugger::memDump(std::ostream& os, u16 addr, isize lines) for (isize i = 0; i < lines; i++) { - current += dump(os, current, - "%p: " - "%b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b " - "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n"); + current += (u16)dump(os, current, + "%p: " + "%b %b %b %b %b %b %b %b %b %b %b %b %b %b %b %b " + "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n"); } return isize(current - addr); diff --git a/Emulator/Misc/Debugger/Debugger.h b/Emulator/Misc/Debugger/Debugger.h index b2ddd7520..8141f4640 100644 --- a/Emulator/Misc/Debugger/Debugger.h +++ b/Emulator/Misc/Debugger/Debugger.h @@ -41,30 +41,9 @@ class Debugger : public SubComponent { using SubComponent::SubComponent; const Descriptions &getDescriptions() const override { return descriptions; } const char *objectName() const override { return "Debugger"; } -// void _dump(Category category, std::ostream& os) const override { } template void serialize(T& worker) { } SERIALIZERS(serialize); - // - // Controlling program execution - // - -public: - - /* - // Pauses or continues the emulation - void stopAndGo(); - - // Executes one CPU instruction - void stepInto(); - - // Executes to the instruction below the current PC - void stepOver(); - - // Continues execution at the specified address - void jump(u32 addr); - */ - // // Managing memory diff --git a/Emulator/Misc/RetroShell/Command.cpp b/Emulator/Misc/RetroShell/Command.cpp index 7578b8f9e..5ca25d964 100644 --- a/Emulator/Misc/RetroShell/Command.cpp +++ b/Emulator/Misc/RetroShell/Command.cpp @@ -25,7 +25,7 @@ Command::pushGroup(const string &description, const string &postfix) { auto name = description.empty() ? "" : description + postfix; - groupStack.push(groups.size()); + groupStack.push(isize(groups.size())); groups.push_back(name); } diff --git a/Emulator/Misc/RetroShell/Interpreter.cpp b/Emulator/Misc/RetroShell/Interpreter.cpp index 0fccfa246..7c6d6ae46 100644 --- a/Emulator/Misc/RetroShell/Interpreter.cpp +++ b/Emulator/Misc/RetroShell/Interpreter.cpp @@ -361,9 +361,9 @@ Interpreter::configure(Option option, i64 value) } void -Interpreter::configure(Option option, long id, i64 value) +Interpreter::configure(Option option, i64 value, isize id) { - emulator.set(option, id, value); + emulator.set(option, value, id); } diff --git a/Emulator/Misc/RetroShell/Interpreter.h b/Emulator/Misc/RetroShell/Interpreter.h index 4db40eca4..900856fb1 100644 --- a/Emulator/Misc/RetroShell/Interpreter.h +++ b/Emulator/Misc/RetroShell/Interpreter.h @@ -185,7 +185,7 @@ class Interpreter: public SubComponent // void configure(Option opt, i64 value) throws; - void configure(Option opt, long id, i64 value) throws; + void configure(Option opt, i64 value, isize id) throws; }; } diff --git a/Emulator/Peripherals/Joystick/Joystick.cpp b/Emulator/Peripherals/Joystick/Joystick.cpp index a1e3b114d..68c5f5b02 100644 --- a/Emulator/Peripherals/Joystick/Joystick.cpp +++ b/Emulator/Peripherals/Joystick/Joystick.cpp @@ -183,7 +183,7 @@ void Joystick::processEvent() { // Get the number of remaining bullets - auto shots = objid == PORT_1 ? c64.data[SLOT_AFI1] : c64.data[SLOT_AFI2]; + auto shots = objid == PORT_1 ? (isize)c64.data[SLOT_AFI1] : (isize)c64.data[SLOT_AFI2]; assert(shots > 0); // Cancel the current event