From 4b4053cf1ea5ee4159b98dc43a01f041a94301a6 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 21 Nov 2020 14:01:38 +0900 Subject: [PATCH] Add -fm command line option --- README.md | 3 +++ src/android/mako.cpp | 2 +- src/emscripten/mako.cpp | 2 +- src/linux/mako.cpp | 6 +++--- src/sdlmain.cpp | 11 +++++++---- src/sys/mako.h | 7 ++++++- src/sys/nact.cpp | 12 ++++++------ src/sys/nact.h | 11 ++++++----- src/sys/nact_sys1.cpp | 4 ++-- src/sys/nact_sys2.cpp | 4 ++-- src/sys/nact_sys3.cpp | 4 ++-- src/win/mako.cpp | 6 +++--- 12 files changed, 42 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ae56284..c54afc2 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ BGM/track03.mp3 ``` The first line is not used, because track 1 of game CD is usually a data track. +#### `-fm` +Use FM tone generator emulation. If not specified, MIDI sound is used. + #### `-game` _game_id_ Since System1-3 behave slightly differently depending on the game, `system3` uses fingerprint of the scenario file (ADISK.DAT) to determine which game you are playing. This option allows you to override this. This is useful when running patched games. diff --git a/src/android/mako.cpp b/src/android/mako.cpp index 55d0cae..8599b74 100644 --- a/src/android/mako.cpp +++ b/src/android/mako.cpp @@ -5,7 +5,7 @@ #include "mako.h" #include "mako_midi.h" -MAKO::MAKO(NACT* parent, const char* playlist) : +MAKO::MAKO(NACT* parent, const MAKOConfig& config) : current_music(0), next_loop(0), nact(parent) diff --git a/src/emscripten/mako.cpp b/src/emscripten/mako.cpp index 7eabf85..f37adc7 100644 --- a/src/emscripten/mako.cpp +++ b/src/emscripten/mako.cpp @@ -8,7 +8,7 @@ #include "mako.h" #include "mako_midi.h" -MAKO::MAKO(NACT* parent, const char* playlist) : +MAKO::MAKO(NACT* parent, const MAKOConfig& config) : current_music(0), next_loop(0), nact(parent) diff --git a/src/linux/mako.cpp b/src/linux/mako.cpp index 78a7845..1208649 100644 --- a/src/linux/mako.cpp +++ b/src/linux/mako.cpp @@ -35,15 +35,15 @@ void FMHook(void *udata, Uint8 *stream, int len) { } // namespace -MAKO::MAKO(NACT* parent, const char* playlist) : - use_fm(true), +MAKO::MAKO(NACT* parent, const MAKOConfig& config) : + use_fm(config.use_fm), current_music(0), next_loop(0), nact(parent) { int mix_init_flags = MIX_INIT_MID; - if (playlist && load_playlist(playlist)) + if (config.playlist && load_playlist(config.playlist)) mix_init_flags |= MIX_INIT_MP3 | MIX_INIT_OGG; strcpy_s(amus, 16, "AMUS.DAT"); diff --git a/src/sdlmain.cpp b/src/sdlmain.cpp index 3c0f0e7..cfc67c8 100644 --- a/src/sdlmain.cpp +++ b/src/sdlmain.cpp @@ -3,6 +3,7 @@ #include "common.h" #include "fileio.h" #include "sys/nact.h" +#include "sys/mako.h" #ifdef __EMSCRIPTEN__ #include #include @@ -33,7 +34,7 @@ int main(int argc, char *argv[]) g_window = SDL_CreateWindow("Scenario Decoder SYSTEM3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 400, flags); const char* font_file = NULL; - const char* playlist = NULL; + MAKOConfig mako_config; const char* game_id = NULL; const char* save_dir = NULL; @@ -47,13 +48,15 @@ int main(int argc, char *argv[]) else if (strcmp(argv[i], "-fontfile") == 0) font_file = argv[++i]; else if (strcmp(argv[i], "-playlist") == 0) - playlist = argv[++i]; + mako_config.playlist = argv[++i]; + else if (strcmp(argv[i], "-fm") == 0) + mako_config.use_fm = true; else if (strcmp(argv[i], "-game") == 0) game_id = argv[++i]; } // system3 初期化 - NACT* nact = NACT::create(game_id, font_file, playlist); + NACT* nact = NACT::create(game_id, font_file, mako_config); if (save_dir && save_dir[0]) { std::string path(save_dir); @@ -98,7 +101,7 @@ int main(int argc, char *argv[]) restart = nact->mainloop(); delete nact; if (restart) - nact = NACT::create(game_id, font_file, playlist); + nact = NACT::create(game_id, font_file, mako_config); } SDL_DestroyWindow(g_window); diff --git a/src/sys/mako.h b/src/sys/mako.h index 72d3756..96f719a 100644 --- a/src/sys/mako.h +++ b/src/sys/mako.h @@ -19,10 +19,15 @@ enum BGMDevice { BGM_CD }; +struct MAKOConfig { + const char *playlist = nullptr; + bool use_fm = false; +}; + class MAKO { public: - MAKO(NACT* parent, const char* playlist); + MAKO(NACT* parent, const MAKOConfig& config); ~MAKO(); void play_music(int page); diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index efa4d1b..c8e41aa 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -16,7 +16,7 @@ extern SDL_Window* g_window; // 初期化 -NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist) +NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config) : sys_ver(sys_ver), crc32_a(crc32_a), crc32_b(crc32_b) { platform_initialize(); @@ -85,7 +85,7 @@ NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, c // 各種クラス生成 ags = new AGS(this, font_file); - mako = new MAKO(this, playlist); + mako = new MAKO(this, mako_config); #ifdef USE_JOY // 入力初期化 @@ -429,16 +429,16 @@ void NACT::fatal(const char* format, ...) { fatal_error = true; } -NACT* NACT::create(const char* game_id, const char* font_file, const char* playlist) { +NACT* NACT::create(const char* game_id, const char* font_file, const MAKOConfig& mako_config) { uint32 crc32_a = NACT::calc_crc32("ADISK.DAT", game_id); uint32 crc32_b = NACT::calc_crc32("BDISK.DAT", game_id); int sys_ver = NACT::get_sys_ver(crc32_a, crc32_b); switch (sys_ver) { case 1: - return new NACT_Sys1(crc32_a, crc32_b, font_file, playlist); + return new NACT_Sys1(crc32_a, crc32_b, font_file, mako_config); case 2: - return new NACT_Sys2(crc32_a, crc32_b, font_file, playlist); + return new NACT_Sys2(crc32_a, crc32_b, font_file, mako_config); default: - return new NACT_Sys3(crc32_a, crc32_b, font_file, playlist); + return new NACT_Sys3(crc32_a, crc32_b, font_file, mako_config); } } diff --git a/src/sys/nact.h b/src/sys/nact.h index 59c6a38..543ddce 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -82,12 +82,13 @@ constexpr char SJIS_NEXT_PAGE [] = "\x8E\x9F\x82\xCC\x83\x79\x81\x5B\x83\x57"; / class AGS; class MAKO; +class MAKOConfig; class NACT { public: - static NACT* create(const char* game_id, const char* font_file, const char* playlist); - NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist); + static NACT* create(const char* game_id, const char* font_file, const MAKOConfig& mako_config); + NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config); virtual ~NACT(); protected: @@ -270,7 +271,7 @@ private: class NACT_Sys1 final : public NACT { public: - NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist); + NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config); protected: void cmd_calc() override; void cmd_branch() override; @@ -321,7 +322,7 @@ private: class NACT_Sys2 final : public NACT { public: - NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist); + NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config); protected: void cmd_calc() override; void cmd_branch() override; @@ -366,7 +367,7 @@ protected: class NACT_Sys3 final : public NACT { public: - NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist); + NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config); protected: void cmd_calc() override; void cmd_branch() override; diff --git a/src/sys/nact_sys1.cpp b/src/sys/nact_sys1.cpp index f394c82..fab1961 100644 --- a/src/sys/nact_sys1.cpp +++ b/src/sys/nact_sys1.cpp @@ -63,8 +63,8 @@ } \ } -NACT_Sys1::NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist) - : NACT(1, crc32_a, crc32_b, font_file, playlist) +NACT_Sys1::NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config) + : NACT(1, crc32_a, crc32_b, font_file, mako_config) { switch (crc32_a) { case CRC32_DPS: diff --git a/src/sys/nact_sys2.cpp b/src/sys/nact_sys2.cpp index 0cb8122..f91dcb3 100644 --- a/src/sys/nact_sys2.cpp +++ b/src/sys/nact_sys2.cpp @@ -55,8 +55,8 @@ } \ } -NACT_Sys2::NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist) - : NACT(2, crc32_a, crc32_b, font_file, playlist) +NACT_Sys2::NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config) + : NACT(2, crc32_a, crc32_b, font_file, mako_config) { } diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index f93ee8d..1a97744 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -13,8 +13,8 @@ #include "../fileio.h" #include "texthook.h" -NACT_Sys3::NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const char* font_file, const char* playlist) - : NACT(3, crc32_a, crc32_b, font_file, playlist) +NACT_Sys3::NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const char* font_file, const MAKOConfig& mako_config) + : NACT(3, crc32_a, crc32_b, font_file, mako_config) { } diff --git a/src/win/mako.cpp b/src/win/mako.cpp index 0a627bb..377be9e 100644 --- a/src/win/mako.cpp +++ b/src/win/mako.cpp @@ -228,13 +228,13 @@ uint8* wav_buffer; } // namespace -MAKO::MAKO(NACT* parent, const char* playlist) : +MAKO::MAKO(NACT* parent, const MAKOConfig& config) : current_music(0), next_loop(0), nact(parent) { - if (playlist) - load_playlist(playlist); + if (config.playlist) + load_playlist(config.playlist); strcpy_s(amus, 16, "AMUS.DAT"); strcpy_s(amse, 16, "AMSE.DAT"); // 実際には使わない