--- nono/lib/mainapp.cpp 2026/04/29 17:05:34 1.1.1.19 +++ nono/lib/mainapp.cpp 2026/04/29 17:05:44 1.1.1.21 @@ -88,6 +88,8 @@ MainApp::ShowHelp(bool all) const printf("usage: %s []\n", getprogname()); p("-c vm directory or configuration file"); p("-f fast mode (same as '-V fast-mode=1')"); + p("--fd[01] specify floppy image (same as '-V fdN-image=' except"); + p(" base directory)"); if (IsGUI()) p("--fontsize fontsize (same as '-V monitor-fontsize=')"); p("-h show brief help message"); @@ -127,6 +129,8 @@ enum { OPT_bi_exg, OPT_console_log, OPT_create_sram, + OPT_fd0, + OPT_fd1, OPT_fontsize, OPT_help, OPT_initrd, @@ -139,6 +143,8 @@ static struct option longopts[] = { { "bi-exg", no_argument, NULL, OPT_bi_exg }, { "console-log", required_argument, NULL, OPT_console_log }, { "create-sram", no_argument, NULL, OPT_create_sram }, + { "fd0", required_argument, NULL, OPT_fd0 }, + { "fd1", required_argument, NULL, OPT_fd1 }, { "fontsize", required_argument, NULL, OPT_fontsize }, { "help", no_argument, NULL, OPT_help }, { "initrd", required_argument, NULL, OPT_initrd }, @@ -257,7 +263,9 @@ MainApp::Init1a(int ac, char *av[]) gConfig->Update("ram-size=16", "-S"); gConfig->Update("luna-video-plane=1", "-S"); // ホスト側には干渉しない。 - gConfig->Update("hostcom-driver=none", "-S"); + gConfig->Update("hostcom0-driver=none", "-S"); + gConfig->Update("hostcom1-driver=none", "-S"); + gConfig->Update("hostcom2-driver=none", "-S"); gConfig->Update("hostnet-driver=none", "-S"); } @@ -491,6 +499,18 @@ MainApp::ParseOpt(int ac, char *av[]) config_options.emplace_back("fast-mode=1", "-f"); break; + case OPT_fd0: + case OPT_fd1: + { + int fd = c - OPT_fd0; + // 相対パスはカレントディレクトリを起点とする。 + std::string line = string_format("fd%u-image=%s", fd, + AbsPath(optarg).c_str()); + std::string from = string_format("--fd%u", fd); + config_options.emplace_back(line, from); + break; + } + case 'H': human_mode = true; break; @@ -520,10 +540,7 @@ MainApp::ParseOpt(int ac, char *av[]) case 'X': { // 相対パスはカレントディレクトリ起点とする。 - char cwd[PATH_MAX]; - getcwd(cwd, sizeof(cwd)); - std::string path = NormalizePath(optarg, std::string(cwd)); - std::string line = "exec-file=" + path; + std::string line = "exec-file=" + AbsPath(optarg); config_options.emplace_back(line, "-X"); // Human68k モードなら後続を引数にする。 @@ -579,10 +596,7 @@ MainApp::ParseOpt(int ac, char *av[]) case OPT_initrd: { // 相対パスはカレントディレクトリを起点とする。 - char cwd[PATH_MAX]; - getcwd(cwd, sizeof(cwd)); - std::string path = NormalizePath(optarg, std::string(cwd)); - std::string line = "exec-initrd=" + path; + std::string line = "exec-initrd=" + AbsPath(optarg); config_options.emplace_back(line, "--initrd"); break; } @@ -674,6 +688,17 @@ MainApp::ParseOpt(int ac, char *av[]) return MainApp::PASS; } +// path を絶対パスにして返す。 +// 相対パスならカレントディレクトリからのパスとする。 +/*static*/ std::string +MainApp::AbsPath(const char *path) +{ + char cwd[PATH_MAX]; + + getcwd(cwd, sizeof(cwd)); + return NormalizePath(optarg, std::string(cwd)); +} + // CPU の機能とかをチェック。 bool MainApp::CheckCPU() @@ -967,33 +992,22 @@ MainApp::SetLogopt1(const std::string& i } return true; } - // "fdd" なら "fdd*" 全部にする - if (name == "fdd") { - for (auto obj : gMainApp.GetObjects()) { - if (strncasecmp(obj->GetName().c_str(), "fdd", 3) == 0) { - obj->SetLogLevel(level); - } - } - return true; - } - // "bankram" も "bankram[01]" 両方にする - if (name == "bankram") { - for (auto obj : gMainApp.GetObjects()) { - if (strncasecmp(obj->GetName().c_str(), "bankram", 7) == 0) { - obj->SetLogLevel(level); - } - } - return true; - } - // "gfpic" も "gfpic*" 全部にする - if (name == "gfpic") { - for (auto obj : gMainApp.GetObjects()) { - if (strncasecmp(obj->GetName().c_str(), "gfpic", 5) == 0) { - obj->SetLogLevel(level); - } - } - return true; - } + + // "" なら "*" 全部に展開する。 +#define EXPAND(key) do { \ + if (name == key) { \ + for (auto obj : gMainApp.GetObjects()) { \ + if (strncasecmp(obj->GetName().c_str(), key, strlen(key)) == 0) \ + obj->SetLogLevel(level); \ + } \ + return true; \ + } \ +} while (0) + EXPAND("bankram"); + EXPAND("fdd"); + EXPAND("gfpic"); + EXPAND("hostcom"); + EXPAND("hostnet"); // エイリアスリストを作る using aliaslist_t = std::vector>; @@ -1153,9 +1167,8 @@ MainApp::NormalizePath(const std::string // path を必要なら絶対パスに展開して返す。 // 相対パスは basedir を起点とする。 -std::string -MainApp::NormalizePath(const std::string& path, - const std::string& basedir) const +/*static*/ std::string +MainApp::NormalizePath(const std::string& path, const std::string& basedir) { // 絶対パスならそのまま返す。 if (path[0] == '/') {