Skip to content

Commit

Permalink
RetroShell message cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 29, 2024
1 parent a2cd66c commit 5110519
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 42 deletions.
22 changes: 12 additions & 10 deletions Emulator/Base/MsgQueueTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ enum_long(MSG_TYPE)
MSG_POWER_LED_OFF,

// Retro shell
MSG_CONSOLE_CLOSE, ///< RetroShell has been closed
MSG_CONSOLE_UPDATE, ///< RetroShell has generated new output
MSG_CONSOLE_DEBUGGER, ///< The RetroShell debugger has been opend or closed
MSG_SCRIPT_DONE, ///< A RetroShell script has been successfully executed
MSG_SCRIPT_ABORT, ///< The execution of a RetroShell ccript has been aborted
MSG_RSH_CLOSE, ///< RetroShell has been closed
MSG_RSH_UPDATE, ///< RetroShell has generated new output
MSG_RSH_DEBUGGER, ///< The RetroShell debugger has been opend or closed
MSG_RSH_EXEC, ///< Commands have been executed
MSG_RSH_WAIT, ///< Execution has peen postponed due to a wait command
MSG_RSH_ERROR, ///< Command execution has been aborted due to an error

// Amiga
MSG_VIDEO_FORMAT,
Expand Down Expand Up @@ -152,11 +153,12 @@ struct MsgTypeEnum : util::Reflection<MsgTypeEnum, MsgType>
case MSG_POWER_LED_DIM: return "POWER_LED_DIM";
case MSG_POWER_LED_OFF: return "POWER_LED_OFF";

case MSG_CONSOLE_CLOSE: return "CONSOLE_CLOSE";
case MSG_CONSOLE_UPDATE: return "CONSOLE_UPDATE";
case MSG_CONSOLE_DEBUGGER: return "CONSOLE_DEBUGGER";
case MSG_SCRIPT_DONE: return "SCRIPT_DONE";
case MSG_SCRIPT_ABORT: return "SCRIPT_ABORT";
case MSG_RSH_CLOSE: return "RSH_CLOSE";
case MSG_RSH_UPDATE: return "RSH_UPDATE";
case MSG_RSH_DEBUGGER: return "RSH_DEBUGGER";
case MSG_RSH_EXEC: return "RSH_EXEC";
case MSG_RSH_WAIT: return "RSH_WAIT";
case MSG_RSH_ERROR: return "RSH_ERROR";

case MSG_VIDEO_FORMAT: return "VIDEO_FORMAT";

Expand Down
4 changes: 2 additions & 2 deletions Emulator/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ Headless::process(Message msg)

switch (msg.type) {

case MSG_SCRIPT_DONE:
case MSG_RSH_EXEC:

returnCode = 0;
barrier.unlock();
break;

case MSG_SCRIPT_ABORT:
case MSG_RSH_ERROR:
case MSG_ABORT:

returnCode = 1;
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Misc/RetroShell/CommandConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Console::initCommands(Command &root)
"Hide the console window",
[this](Arguments& argv, long value) {

msgQueue.put(MSG_CONSOLE_CLOSE);
msgQueue.put(MSG_RSH_CLOSE);
});

root.add({"help"}, { }, {Arg::command},
Expand Down
21 changes: 6 additions & 15 deletions Emulator/Misc/RetroShell/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Console::setStream(std::ostream &os)
void
Console::needsDisplay()
{
msgQueue.put(MSG_CONSOLE_UPDATE);
msgQueue.put(MSG_RSH_UPDATE);
}

void
Expand Down Expand Up @@ -538,9 +538,6 @@ Console::exec()
{
SYNCHRONIZED

// Indicates if we're executing commands from a script
bool scriptMode = false;

// Only proceed if there is anything to process
if (commands.empty()) return;

Expand All @@ -552,26 +549,20 @@ Console::exec()

cmd = commands.front();
commands.erase(commands.begin());

// Commands from a script carry a line number
scriptMode |= cmd.first != 0;

exec(cmd);

if (commands.empty() && scriptMode) {
msgQueue.put(MSG_SCRIPT_DONE);
}
}
msgQueue.put(MSG_RSH_EXEC);

} catch (ScriptInterruption &) {

} catch (...) {
msgQueue.put(MSG_RSH_WAIT);

} catch (...) {

// Remove all remaining commands
commands = { };

// Inform the GUI if a script had been executed
if (scriptMode) msgQueue.put(MSG_SCRIPT_ABORT);
msgQueue.put(MSG_RSH_ERROR);
}

// Print prompt
Expand Down
4 changes: 2 additions & 2 deletions Emulator/Misc/RetroShell/RetroShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ RetroShell::switchConsole() {

current = &debugger;
emulator.trackOn(1);
msgQueue.put(MSG_CONSOLE_DEBUGGER, true);
msgQueue.put(MSG_RSH_DEBUGGER, true);

} else {

current = &commander;
emulator.trackOff(1);
msgQueue.put(MSG_CONSOLE_DEBUGGER, false);
msgQueue.put(MSG_RSH_DEBUGGER, false);
}
}

Expand Down
6 changes: 0 additions & 6 deletions Emulator/Peripherals/Joystick/Joystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ Joystick::reload(isize bullets)
bulletCounter = bullets;
}

void
Joystick::scheduleNextShot()
{
nextAutofireFrame = agnus.pos.frame + config.autofireDelay;
}

void
Joystick::changePotgo(u16 &potgo) const
{
Expand Down
3 changes: 0 additions & 3 deletions Emulator/Peripherals/Joystick/Joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ class Joystick : public SubComponent, public Inspectable<JoystickInfo> {
// Reloads the autofire magazine
void reload();
void reload(isize bullets);

// Updates variable nextAutofireFrame
void scheduleNextShot();
};

}
15 changes: 12 additions & 3 deletions GUI/MyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,17 +403,26 @@ extension MyController {
case .RESET:
inspector?.reset()

case .CONSOLE_CLOSE:
case .RSH_CLOSE:
renderer.console.close(delay: 0.25)

case .CONSOLE_UPDATE:
case .RSH_UPDATE:
renderer.console.isDirty = true

case .CONSOLE_DEBUGGER:
case .RSH_DEBUGGER:
break

case .RSH_EXEC, .RSH_WAIT:
renderer.console.isDirty = true

case .RSH_ERROR:
NSSound.beep()
renderer.console.isDirty = true

/*
case .SCRIPT_DONE, .SCRIPT_ABORT:
renderer.console.isDirty = true
*/

case .SHUTDOWN:
shutDown()
Expand Down

0 comments on commit 5110519

Please sign in to comment.