dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Support config files #809

Closed dirkwhoffmann closed 5 months ago

dirkwhoffmann commented 6 months ago

Supporting config files was a feature request that popped up several times. I never implemented it because I wanted to avoid inventing another file format, thus adding more complexity.

However, since everything can be configured in RetroShell via shell commands, supporting config files through simple scripts is easy and does not require an additional file format.

TODO:

Exporting the configuration as a script also helps debugging as it makes it easier to tell other people about the configuration needed to reproduce a bug.

DidierMalenfant commented 5 months ago

I'm interested in contributing on this since it would be useful for my little project (see #812).

DidierMalenfant commented 5 months ago

It looks like something is already loading and saving ini files but those don't seem to support all the retroshell command/features.

Is the goal still to replace this with something that simply load/save retroshell scripts similar to the ones used in the test suite?

dirkwhoffmann commented 5 months ago

Every issue labeled with v2.5 is already completed.

The path to the Kickstart or the ADFs is not saved because the emulator doesn't know them. When an ADF is attached, it converts it into the internal disk format and forgets about the original file.

DidierMalenfant commented 5 months ago

So would it be feasible to implement something like the original idea above and support launching the emulator using a script like the one the unit tests use?

The idea would be to be able to launch it from an IDE and make it automatically boot up with the right config/disk/kickstart. Maybe there is a better way to approach this though?

dirkwhoffmann commented 5 months ago

Launching the emulator with a script is already supported. It is used, e.g., by the regression test suite:

To run a regression test, vAmiga is launched in a Makefile with a script that looks like this:

# Regression testing script for vAmiga
# Dirk W. Hoffmann, 2022

# Setup the test environment
regression setup A500_ECS_1MB /tmp/kick13.rom

# Run the test
regression run /tmp/sprdma1_ECS.adf
wait 9 seconds

# Exit with a screenshot
screenshot save sprdma1_ECS

The path to the scrips is provided as command line parameter.

DidierMalenfant commented 5 months ago

Yeah that's what I meant above:

So would it be feasible to implement something like the original idea above and support >launching the emulator using a script like the one the unit tests use?

Does this run the Amiga at regular speed? I see the Mhz counter in the corner get to some crazy values when I use this method.

dirkwhoffmann commented 5 months ago

Does this run the Amiga at regular speed?

It usually does.

I see the Mhz counter in the corner get to some crazy values when I use this method.

This is because of the regression run command which turns on warp mode beside other things. In your own script, you would not use this command.

dirkwhoffmann commented 5 months ago

BTW, you can get an overview of all available commands inside RetroShell. Hitting the tab key twice will print all possible extensions of the typed in (partial) command. E.g., typing amiga and hitting tab twice shows the following:

Bildschirmfoto 2024-01-18 um 19 27 46

Alternatively, have a look at files InterpreterCmds.cpp and InterpreterDebugCmds.cpp. This is where all commands are registered:

    ...
    root.add({"help"}, { }, {Arg::command},
             "Prints usage information",
             [this](Arguments& argv, long value) {

        retroShell.help(argv.empty() ? "" : argv.front());
    });

    root.add({"joshua"},
             "",
             [this](Arguments& argv, long value) {

        retroShell << "\nGREETINGS PROFESSOR HOFFMANN.\n";
        retroShell << "THE ONLY WINNING MOVE IS NOT TO PLAY.\n";
        retroShell << "HOW ABOUT A NICE GAME OF CHESS?\n\n";
    });

    root.add({"source"}, {Arg::path},
             "Processes a command script",
             [this](Arguments& argv, long value) {

        auto stream = std::ifstream(argv.front());
        if (!stream.is_open()) throw VAError(ERROR_FILE_NOT_FOUND, argv.front());
        retroShell.execScript(stream);
    });
    ...
dirkwhoffmann commented 5 months ago

Fixed in v2.5b1