Skip to content

Commit

Permalink
Fixed Headless app
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Jul 24, 2024
1 parent 96a56d1 commit a0da665
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 48 deletions.
4 changes: 3 additions & 1 deletion Emulator/Components/Denise/FrameBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ using util::Buffer;

namespace vamiga {

struct FrameBuffer {
class FrameBuffer {

public:

// Predefined colors
static constexpr Texel black = TEXEL(0xFF000000);
static constexpr Texel grey2 = TEXEL(0xFF222222);
Expand Down
13 changes: 5 additions & 8 deletions Emulator/Headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ int main(int argc, char *argv[])

namespace vamiga {

Headless::Headless() { // }: amiga(&vamiga.emu->main) {

}

int
Headless::main(int argc, char *argv[])
{
Expand Down Expand Up @@ -279,18 +275,19 @@ Headless::execScript()
VAmiga vamiga;

// Redirect shell output to the console in verbose mode
if (keys.find("verbose") != keys.end()) vamiga.amiga.amiga->retroShell.setStream(std::cout);
if (keys.find("verbose") != keys.end()) vamiga.retroShell.setStream(std::cout);

// Read the input script
Script script(keys["arg1"]);

// Launch the emulator thread
vamiga.launch(this, vamiga::process);

// Execute the script
// Execute scripts
barrier.lock();
script.execute(*vamiga.amiga.amiga);

vamiga.retroShell.execScript(script);
barrier.lock();

return *returnCode;
}

Expand Down
24 changes: 8 additions & 16 deletions Emulator/Headless.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ class Headless {
// Return code
std::optional<int> returnCode;


//
// Initializing
//

public:

Headless();


//
// Launching
Expand Down Expand Up @@ -85,7 +76,7 @@ class Headless {
};

//
// Self-test script
// Self-test scripts
//

static const char *script[] = {
Expand Down Expand Up @@ -145,6 +136,8 @@ static const char *script[] = {
"mem set SAVE_ROMS false",
"mem set SLOW_RAM_DELAY true",
"mem set SLOW_RAM_DELAY false",
"mem set SLOW_RAM_MIRROR true",
"mem set SLOW_RAM_MIRROR false",
"mem set BANKMAP A500",
"mem set BANKMAP A1000",
"mem set BANKMAP A2000A",
Expand Down Expand Up @@ -209,8 +202,6 @@ static const char *script[] = {
"agnus set REVISION OCS",
"agnus set REVISION ECS_1MB",
"agnus set REVISION ECS_2MB",
"agnus set SLOW_RAM_MIRROR true",
"agnus set SLOW_RAM_MIRROR false",
"agnus set PTR_DROPS true",
"agnus set PTR_DROPS false",

Expand Down Expand Up @@ -426,11 +417,11 @@ static const char *script[] = {
"server gdb",
"server gdb set PORT 8000",
"server gdb set VERBOSE true",
"server gdb set VERBOSE false",
"server gdb set VERBOSE false"
};

"",
"# Entering the debugger...",
".",
/*
static const char *debugScript[] = {
"",
"break",
Expand Down Expand Up @@ -540,5 +531,6 @@ static const char *script[] = {
"i host",
"i server"
};
*/

}
4 changes: 2 additions & 2 deletions Emulator/Media/MediaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class MediaFile {
static MediaFile *make(const fs::path &path, FileType type);
static MediaFile *make(const u8 *buf, isize len, FileType type);
static MediaFile *make(class MutableFileSystem &fs, FileType type);
static MediaFile *make(struct FloppyDriveAPI &drive, FileType type);
static MediaFile *make(struct HardDriveAPI &drive, FileType type);
static MediaFile *make(class FloppyDriveAPI &drive, FileType type);
static MediaFile *make(class HardDriveAPI &drive, FileType type);


//
Expand Down
32 changes: 20 additions & 12 deletions Emulator/Misc/RetroShell/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ 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 @@ -550,10 +553,26 @@ 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);
}
}

} catch (...) { }
} catch (ScriptInterruption &) {

} catch (...) {

// Remove all remaining commands
commands = { };

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

// Print prompt
*this << getPrompt();
Expand Down Expand Up @@ -620,17 +639,6 @@ Console::asyncExecScript(const string &contents)
asyncExecScript(ss);
}

/*
void
Console::asyncExecScript(const MediaFile &file)
{
if (file.type() != FILETYPE_SCRIPT) throw Error(ERROR_FILE_TYPE_MISMATCH);
string s((char *)file.getData(), file.getSize());
try { execScript(s); } catch (util::Exception &) { }
}
*/

void
Console::abortScript()
{
Expand Down
21 changes: 14 additions & 7 deletions Emulator/Misc/RetroShell/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,20 @@ class Console : public SubComponent {
friend class RshServer;
friend class Interpreter;

Descriptions descriptions = {{

.type = COMP_CONSOLE,
.name = "Console",
.description = "Command shell",
.shell = ""
}};
Descriptions descriptions = {
{
.type = COMP_CONSOLE,
.name = "CmdConsole",
.description = "Command shell",
.shell = ""
},
{
.type = COMP_CONSOLE,
.name = "DbgConsole",
.description = "Debug shell",
.shell = ""
}
};

ConfigOptions options = {

Expand Down
4 changes: 2 additions & 2 deletions Emulator/Misc/RetroShell/RetroShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class RetroShell : public SubComponent {
};

// Consoles
CommandConsole commander = CommandConsole(amiga);
DebugConsole debugger = DebugConsole(amiga);
CommandConsole commander = CommandConsole(amiga, 0);
DebugConsole debugger = DebugConsole(amiga, 1);

// The currently active console
Console *current = &commander;
Expand Down

0 comments on commit a0da665

Please sign in to comment.