Add -fm command line option

This commit is contained in:
kichikuou
2020-11-21 14:01:38 +09:00
parent 893f716ef3
commit 4b4053cf1e
12 changed files with 42 additions and 30 deletions
+3
View File
@@ -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.
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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");
+7 -4
View File
@@ -3,6 +3,7 @@
#include "common.h"
#include "fileio.h"
#include "sys/nact.h"
#include "sys/mako.h"
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/html5.h>
@@ -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);
+6 -1
View File
@@ -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);
+6 -6
View File
@@ -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);
}
}
+6 -5
View File
@@ -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;
+2 -2
View File
@@ -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:
+2 -2
View File
@@ -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)
{
}
+2 -2
View File
@@ -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)
{
}
+3 -3
View File
@@ -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"); // 実際には使わない