diff --git a/CMakeLists.txt b/CMakeLists.txt index d9b63ee..4bf6dbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,9 +167,9 @@ target_sources(system3 PRIVATE src/sys/ags_vsp2l.cpp src/sys/ags_window.cpp src/sys/dri.cpp + src/sys/game_id.cpp src/sys/msgskip.cpp src/sys/nact.cpp - src/sys/nact_crc32.cpp src/sys/nact_input.cpp src/sys/nact_sys1.cpp src/sys/nact_sys2.cpp diff --git a/src/emscripten/mako.cpp b/src/emscripten/mako.cpp index 252f1d5..ff491a2 100644 --- a/src/emscripten/mako.cpp +++ b/src/emscripten/mako.cpp @@ -20,11 +20,11 @@ EM_ASYNC_JS(int, muspcm_load_data, (uint8_t *buf, uint32_t len), { } // namespace -MAKO::MAKO(NACT* parent, const Config& config) : +MAKO::MAKO(const Config& config, const GameId& game_id) : use_fm(true), current_music(0), next_loop(0), - nact(parent) + game_id(game_id) { g_mako = this; amus.open("AMUS.DAT"); diff --git a/src/generic/mako.cpp b/src/generic/mako.cpp index 7c99029..00e2904 100644 --- a/src/generic/mako.cpp +++ b/src/generic/mako.cpp @@ -32,11 +32,11 @@ void FMHook(void*, Uint8* stream, int len) { } // namespace -MAKO::MAKO(NACT* parent, const Config& config) : +MAKO::MAKO(const Config& config, const GameId& game_id) : use_fm(config.use_fm), current_music(0), next_loop(0), - nact(parent) + game_id(game_id) { int mix_init_flags = 0; @@ -130,7 +130,7 @@ void MAKO::play_music(int page) SDL_UnlockMutex(fm_mutex); Mix_HookMusic(&FMHook, this); } else if (midi->is_available()) { - if (!midi->play(nact, amus, mda, page, next_loop)) + if (!midi->play(game_id, amus, mda, page, next_loop)) return; } diff --git a/src/sdlmain.cpp b/src/sdlmain.cpp index 196af19..3ba7773 100644 --- a/src/sdlmain.cpp +++ b/src/sdlmain.cpp @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) romfsInit(); #endif Config config(argc, argv); + GameId game_id(config); SDL_Init(SDL_INIT_VIDEO); SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); @@ -52,15 +53,14 @@ int main(int argc, char *argv[]) g_renderer = SDL_CreateRenderer(g_window, -1, 0); // system3 初期化 - g_nact = NACT::create(config); + g_nact = NACT::create(config, game_id); if (!config.save_dir.empty()) { std::string path = config.save_dir; if (path[path.size() - 1] == '@') { path.pop_back(); - const char* gid = g_nact->get_game_id(); - if (gid) { - path += gid; + if (game_id.name) { + path += game_id.name; #ifdef WIN32 mkdir(path.c_str()); #else @@ -71,17 +71,16 @@ int main(int argc, char *argv[]) FILEIO::set_savedir(path); } - const char* title = g_nact->get_title(); - if (title) { + if (game_id.title) { char buf[128]; - snprintf(buf, 128, "System3-sdl2 " SYSTEM3_VERSION ": %s", title); + snprintf(buf, 128, "System3-sdl2 " SYSTEM3_VERSION ": %s", game_id.title); #ifdef __EMSCRIPTEN__ EM_ASM_ARGS({ xsystem35.shell.setWindowTitle(UTF8ToString($0)); }, buf); #else SDL_SetWindowTitle(g_window, buf); #endif } else { - WARNING("Cannot determine game id. crc32_a: %08x, crc32_b: %08x", g_nact->crc32_a, g_nact->crc32_b); + WARNING("Cannot determine game id. crc32_a: %08x, crc32_b: %08x", game_id.crc32_a, game_id.crc32_b); SDL_ShowSimpleMessageBox( SDL_MESSAGEBOX_WARNING, "system3", "Unable to determine game ID.\n" @@ -105,7 +104,7 @@ int main(int argc, char *argv[]) exit_code = g_nact->mainloop(); delete g_nact; if (exit_code == NACT_RESTART) - g_nact = NACT::create(config); + g_nact = NACT::create(config, game_id); } SDL_DestroyRenderer(g_renderer); diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index 8993be5..564972f 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -6,7 +6,7 @@ #include "ags.h" #include -#include "crc32.h" +#include "game_id.h" #include "../config.h" #include "../fileio.h" @@ -58,10 +58,10 @@ SDL_Texture* create_scanline_texture(SDL_Renderer* renderer, int width, int heig } // namespace -AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) +AGS::AGS(NACT* parent, const Config& config) : nact(parent), game_id(parent->game_id), dirty(false) { // 画面サイズ - if (nact->crc32_a == CRC32_GAKUEN || nact->crc32_a == CRC32_GAKUEN_ENG) { + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) { window_width = 582; screen_width = 512; window_height = screen_height = 424; @@ -178,7 +178,7 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) program_palette[0x0d] = SETPALETTE16(0x0, 0xf, 0xf); program_palette[0x0e] = SETPALETTE16(0xf, 0xf, 0x0); program_palette[0x0f] = SETPALETTE16(0xf, 0xf, 0xf); - if (nact->sys_ver == 1) { + if (game_id.sys_ver == 1) { program_palette[0x10] = SETPALETTE16(0x0, 0x0, 0x0); program_palette[0x11] = SETPALETTE16(0x0, 0x0, 0xf); program_palette[0x12] = SETPALETTE16(0xf, 0x0, 0x0); @@ -228,7 +228,7 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) // Bコマンド for(int i = 0; i < 10; i++) { // ウィンドウの初期位置はシステムによって異なる - switch (nact->crc32_a) { + switch (game_id.crc32_a) { case CRC32_BUNKASAI: SET_TEXT(i, 24, 304, 616, 384, false); SET_MENU(i, 440, 18, 620, 178, true); @@ -312,10 +312,10 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) // SET_BOX(i, 0, 0, 0, 631, 399); SET_BOX(i, 0, 0, 0, 639, 399); } - if (nact->sys_ver == 2) { - if(nact->crc32_a == CRC32_SDPS && (nact->crc32_b == CRC32_SDPS_TONO || nact->crc32_b == CRC32_SDPS_KAIZOKU)) { + if (game_id.sys_ver == 2) { + if (game_id.crc32_a == CRC32_SDPS && (game_id.crc32_b == CRC32_SDPS_TONO || game_id.crc32_b == CRC32_SDPS_KAIZOKU)) { SET_BOX(0, 0, 40, 8, 598, 271); - } else if(nact->crc32_a == CRC32_PROSTUDENTG_FD) { + } else if (game_id.crc32_a == CRC32_PROSTUDENTG_FD) { SET_BOX(0, 0, 64, 13, 407, 289); SET_BOX(1, 0, 24, 298, 111, 390); SET_BOX(2, 0, 0, 0, 639, 307); @@ -338,7 +338,7 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) text_font_maxsize = 0; text_space = 2; text_font_size = 16; - if (nact->sys_ver == 1) { + if (game_id.sys_ver == 1) { text_font_color = 15 + 16; text_frame_color = 15 + 16; text_back_color = 0 + 16; @@ -352,7 +352,7 @@ AGS::AGS(NACT* parent, const Config& config) : nact(parent), dirty(false) menu_dest_x = 2; menu_dest_y = 0; menu_font_size = 16; - if (nact->sys_ver == 1) { + if (game_id.sys_ver == 1) { menu_font_color = 15 + 16; menu_frame_color = 15 + 16; menu_back_color = 0 + 16; @@ -430,7 +430,7 @@ AGS::~AGS() void AGS::set_cg_file(const char *file_name) { bmp_prefix = NULL; - if (nact->sys_ver == 3) { + if (game_id.sys_ver == 3) { // あゆみちゃん物語 フルカラー実写版 if (!strcmp(file_name, "CGA000.BMP")) { bmp_prefix = "CGA"; @@ -505,7 +505,7 @@ void AGS::flush_screen(bool update) uint32* src = vram[0][y]; uint32* dest = surface_line(hBmpDest, y); for(int x = 0; x < screen_width; x++) { - if (nact->sys_ver == 3 && src[x] & 0x80000000) { + if (game_id.sys_ver == 3 && src[x] & 0x80000000) { // あゆみちゃん物語 フルカラー実写版 dest[x] = src[x] & 0xffffff; } else { @@ -524,7 +524,7 @@ void AGS::draw_screen(int sx, int sy, int width, int height) uint32* dest = surface_line(hBmpDest, y); for(int x = sx; x < (sx + width) && x < 640; x++) { uint32 a=src[x]; - if (nact->sys_ver == 3 && src[x] & 0x80000000) { + if (game_id.sys_ver == 3 && src[x] & 0x80000000) { // あゆみちゃん物語 フルカラー実写版 dest[x] = src[x] & 0xffffff; } else { @@ -611,9 +611,9 @@ void AGS::save_screenshot(const char* path) } int AGS::calculate_menu_max(int window) { - if (nact->crc32_a == CRC32_INTRUDER) + if (game_id.crc32_a == CRC32_INTRUDER) return 6; - if (nact->crc32_a == CRC32_GAKUEN || nact->crc32_a == CRC32_GAKUEN_ENG) + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) return (menu_w[window - 1].ey - menu_w[window - 1].sy) / (menu_font_size + 4); return 11; } diff --git a/src/sys/ags.h b/src/sys/ags.h index fa893a2..b9f4756 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -40,6 +40,7 @@ class AGS { protected: NACT* nact; + const GameId& game_id; private: SDL_Texture* sdlTexture; SDL_Texture* scanline_texture; diff --git a/src/sys/ags_draw.cpp b/src/sys/ags_draw.cpp index 81c9885..f7e3f56 100644 --- a/src/sys/ags_draw.cpp +++ b/src/sys/ags_draw.cpp @@ -11,7 +11,7 @@ #include #include #include "dri.h" -#include "crc32.h" +#include "game_id.h" void AGS::load_cg(int page, int transparent) { @@ -24,9 +24,9 @@ void AGS::load_cg(int page, int transparent) std::vector data = acg.load(page); if (data.empty()) return; - switch (nact->sys_ver) { + switch (game_id.sys_ver) { case 1: - switch (nact->crc32_a) { + switch (game_id.crc32_a) { case CRC32_BUNKASAI: case CRC32_GAKUEN: case CRC32_GAKUEN_ENG: @@ -46,13 +46,13 @@ void AGS::load_cg(int page, int transparent) } break; case 2: - if(nact->crc32_a == CRC32_AYUMI_PROTO) { + if (game_id.crc32_a == CRC32_AYUMI_PROTO) { // あゆみちゃん物語 PROTO load_gl3(data.data(), page, transparent); - } else if(nact->crc32_a == CRC32_AYUMI_FD || nact->crc32_a == CRC32_AYUMI_HINT) { + } else if (game_id.crc32_a == CRC32_AYUMI_FD || game_id.crc32_a == CRC32_AYUMI_HINT) { // あゆみちゃん物語 load_vsp(data.data(), page, transparent); - } else if(nact->crc32_a == CRC32_SDPS) { + } else if (game_id.crc32_a == CRC32_SDPS) { // Super D.P.S load_pms(data.data(), page, transparent); } else { diff --git a/src/sys/ags_pms.cpp b/src/sys/ags_pms.cpp index 923d9b8..99b0046 100644 --- a/src/sys/ags_pms.cpp +++ b/src/sys/ags_pms.cpp @@ -5,7 +5,7 @@ */ #include "ags.h" -#include "crc32.h" +#include "game_id.h" #include void AGS::load_pms(uint8* data, int page, int transparent) @@ -41,11 +41,11 @@ void AGS::load_pms(uint8* data, int page, int transparent) tmp_palette[i * 16 + j] = SETPALETTE256(r, g, b); } } - if(nact->crc32_a == CRC32_RANCE41 || - nact->crc32_a == CRC32_RANCE41_ENG || - nact->crc32_a == CRC32_RANCE42 || - nact->crc32_a == CRC32_RANCE42_ENG || - nact->crc32_a == CRC32_HASHIRIONNA2) { + if (game_id.crc32_a == CRC32_RANCE41 || + game_id.crc32_a == CRC32_RANCE41_ENG || + game_id.crc32_a == CRC32_RANCE42 || + game_id.crc32_a == CRC32_RANCE42_ENG || + game_id.crc32_a == CRC32_HASHIRIONNA2) { // 上下16色は取得しない for(int i = 1; i < 15; i++) { for(int j = 0; j < 16; j++) { @@ -54,7 +54,7 @@ void AGS::load_pms(uint8* data, int page, int transparent) } } } - } else if(nact->crc32_a == CRC32_MUGENHOUYOU && transparent != -1) { + } else if (game_id.crc32_a == CRC32_MUGENHOUYOU && transparent != -1) { // Uコマンドでは上下32色は取得しない for(int i = 2; i < 14; i++) { for(int j = 0; j < 16; j++) { @@ -75,13 +75,13 @@ void AGS::load_pms(uint8* data, int page, int transparent) } // パレット展開 - if (nact->sys_ver == 3) { - if((extract_palette && extract_palette_cg[page]) || nact->crc32_a == CRC32_FUNNYBEE_CD) { - if(nact->crc32_a == CRC32_RANCE41 || - nact->crc32_a == CRC32_RANCE41_ENG || - nact->crc32_a == CRC32_RANCE42 || - nact->crc32_a == CRC32_RANCE42_ENG || - nact->crc32_a == CRC32_HASHIRIONNA2) { + if (game_id.sys_ver == 3) { + if ((extract_palette && extract_palette_cg[page]) || game_id.crc32_a == CRC32_FUNNYBEE_CD) { + if (game_id.crc32_a == CRC32_RANCE41 || + game_id.crc32_a == CRC32_RANCE41_ENG || + game_id.crc32_a == CRC32_RANCE42 || + game_id.crc32_a == CRC32_RANCE42_ENG || + game_id.crc32_a == CRC32_HASHIRIONNA2) { // 上下16色は展開しない for(int i = 1; i < 15; i++) { for(int j = 0; j < 16; j++) { @@ -90,7 +90,7 @@ void AGS::load_pms(uint8* data, int page, int transparent) } } } - } else if(nact->crc32_a == CRC32_MUGENHOUYOU && transparent != -1) { + } else if (game_id.crc32_a == CRC32_MUGENHOUYOU && transparent != -1) { // Uコマンドでは上下32色は展開しない for(int i = 2; i < 14; i++) { for(int j = 0; j < 16; j++) { diff --git a/src/sys/ags_vsp.cpp b/src/sys/ags_vsp.cpp index a0d3ea0..a3f4200 100644 --- a/src/sys/ags_vsp.cpp +++ b/src/sys/ags_vsp.cpp @@ -5,7 +5,7 @@ */ #include "ags.h" -#include "crc32.h" +#include "game_id.h" #include void AGS::load_vsp(uint8* data, int page, int transparent) @@ -29,7 +29,7 @@ void AGS::load_vsp(uint8* data, int page, int transparent) } // Zコマンドの処理 - if(nact->crc32_a == CRC32_AMBIVALENZ_FD || nact->crc32_a == CRC32_AMBIVALENZ_CD) { + if (game_id.crc32_a == CRC32_AMBIVALENZ_FD || game_id.crc32_a == CRC32_AMBIVALENZ_CD) { // Z 0,numを無視する } else { if(palette_bank != -1) { @@ -49,7 +49,7 @@ void AGS::load_vsp(uint8* data, int page, int transparent) } // パレット展開 - if(nact->crc32_a == CRC32_FUNNYBEE_FD || nact->crc32_a == CRC32_FUNNYBEE_CD || nact->crc32_a == CRC32_FUNNYBEE_PATCH) { + if (game_id.crc32_a == CRC32_FUNNYBEE_FD || game_id.crc32_a == CRC32_FUNNYBEE_CD || game_id.crc32_a == CRC32_FUNNYBEE_PATCH) { if(extract_palette_cg[page]) { for(int i = 0; i < 16; i++) { screen_palette[base + i] = program_palette[base + i]; @@ -143,7 +143,7 @@ void AGS::load_vsp(uint8* data, int page, int transparent) uint32* dest; // Gakuen Senki uses exact sx values rather than 8x. - if (nact->crc32_a == CRC32_GAKUEN || nact->crc32_a == CRC32_GAKUEN_ENG) + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) dest = &vram[dest_screen][y + sy][(x * 8) + sx]; else dest = &vram[dest_screen][y + sy][(x + sx) * 8]; @@ -165,7 +165,7 @@ void AGS::load_vsp(uint8* data, int page, int transparent) // 画面更新 if(dest_screen == 0 && extract_cg) { - if (nact->crc32_a == CRC32_GAKUEN || nact->crc32_a == CRC32_GAKUEN_ENG) { + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) { // Gakuen Senki's images were converted to VSP for the modern port, but don't always adhere to VSP's width restrictions, which demand // every image width be a factor of 8. Thankfully, the exceptions are designed to fit into specific parts of the GUI, and so have // consistent widths for each output position. diff --git a/src/sys/dri.cpp b/src/sys/dri.cpp index 1753ecc..6923749 100644 --- a/src/sys/dri.cpp +++ b/src/sys/dri.cpp @@ -7,7 +7,7 @@ #include "dri.h" #include #include -#include "crc32.h" +#include "game_id.h" #include "../fileio.h" void Dri::open(const char* file_name) diff --git a/src/sys/nact_crc32.cpp b/src/sys/game_id.cpp similarity index 85% rename from src/sys/nact_crc32.cpp rename to src/sys/game_id.cpp index ebe2e10..ab0d60b 100644 --- a/src/sys/nact_crc32.cpp +++ b/src/sys/game_id.cpp @@ -1,12 +1,5 @@ -/* - ALICE SOFT SYSTEM 3 for Win32 - - [ NACT - crc32 ] -*/ - -#include "nact.h" #include -#include "crc32.h" +#include "game_id.h" #include "../fileio.h" #include "config.h" @@ -92,17 +85,8 @@ const CRCTable* lookup(uint32 crc32_a, uint32 crc32_b) return NULL; } -} // namespace - -uint32 NACT::calc_crc32(const char* file_name, const std::string& game_id) +uint32 calc_crc32(const char* file_name) { - if (!game_id.empty()) { - for (const CRCTable* t = crc_table; t->id; t++) { - if (t->id == game_id) - return file_name[0] == 'A' ? t->crc32_a : t->crc32_b; - } - } - uint32 crc = 0; auto fio = FILEIO::open(file_name, FILEIO_READ_BINARY); @@ -130,41 +114,33 @@ uint32 NACT::calc_crc32(const char* file_name, const std::string& game_id) return crc; } -const char* NACT::get_game_id() -{ - if (const CRCTable* entry = lookup(crc32_a, crc32_b)) - return entry->id; - return NULL; -} +} // namespace -const int NACT::get_sys_ver(uint32 crc32_a, uint32 crc32_b) -{ - if (const CRCTable* entry = lookup(crc32_a, crc32_b)) - return entry->sys_ver; - return 3; -} - -const char* NACT::get_title() +GameId::GameId(const Config& config) + : crc32_a(0), crc32_b(0), name(NULL), sys_ver(3), title(NULL), language(JAPANESE), encoding("Shift_JIS") { + if (!config.game_id.empty()) { + for (const CRCTable* t = crc_table; t->id; t++) { + if (t->id == config.game_id) { + crc32_a = t->crc32_a; + crc32_b = t->crc32_b; + break; + } + } + } else { + crc32_a = calc_crc32("ADISK.DAT"); + crc32_b = calc_crc32("BDISK.DAT"); + } + const CRCTable* entry = lookup(crc32_a, crc32_b); + if (entry) { + name = entry->id; + sys_ver = entry->sys_ver; + title = entry->title; + language = entry->language; + // TODO: Determine encoding from crc32 + } if (!config.title.empty()) - return config.title.c_str(); - if (const CRCTable* entry = lookup(crc32_a, crc32_b)) - return entry->title; - return NULL; -} - -Language NACT::get_language() -{ - if (const CRCTable* entry = lookup(crc32_a, crc32_b)) - return entry->language; - return JAPANESE; -} - -const char* NACT::get_encoding_name() -{ + title = config.title.c_str(); if (!config.encoding.empty()) - return config.encoding.c_str(); - - // TODO: Determine encoding from crc32 - return "Shift_JIS"; + encoding = config.encoding.c_str(); } diff --git a/src/sys/crc32.h b/src/sys/game_id.h similarity index 91% rename from src/sys/crc32.h rename to src/sys/game_id.h index 0f60c78..7baa291 100644 --- a/src/sys/crc32.h +++ b/src/sys/game_id.h @@ -1,11 +1,7 @@ -/* - ALICE SOFT SYSTEM 3 for Win32 +#ifndef _GAMEID_H_ +#define _GAMEID_H_ - [ crc32 database ] -*/ - -#ifndef _CRC32_H_ -#define _CRC32_H_ +#include // ADISK.DATの先頭256bytes // SYSTEM1 @@ -78,4 +74,23 @@ #define CRC32_NINGYO 0xd491e7ab // 人魚 -蘿子- #define CRC32_MUGENHOUYOU 0xbb27d1ba // 夢幻泡影 -#endif +struct Config; + +enum Language { + JAPANESE = 0, + ENGLISH = 1, +}; + +struct GameId { + uint32_t crc32_a; // ADISK + uint32_t crc32_b; // BDISK for D.P.S -SG- and Super D.P.S + const char* name; + int sys_ver; + const char* title; + Language language; + const char* encoding; + + explicit GameId(const Config& config); +}; + +#endif // _GAMEID_H_ diff --git a/src/sys/mako.h b/src/sys/mako.h index cda2a3a..89f2223 100644 --- a/src/sys/mako.h +++ b/src/sys/mako.h @@ -13,7 +13,7 @@ #include #include #include "../common.h" -#include "nact.h" +#include "game_id.h" #include "dri.h" enum BGMDevice { @@ -27,7 +27,7 @@ struct Config; class MAKO { public: - MAKO(NACT* parent, const Config& config); + MAKO(const Config& config, const GameId& game_id); ~MAKO(); void play_music(int page); @@ -57,7 +57,7 @@ public: int next_loop; // Y19 private: - NACT* nact; + const GameId& game_id; int cd_track[100]; // Z #ifndef __EMSCRIPTEN__ diff --git a/src/sys/mako_midi.cpp b/src/sys/mako_midi.cpp index 14b5c16..003d600 100644 --- a/src/sys/mako_midi.cpp +++ b/src/sys/mako_midi.cpp @@ -10,9 +10,9 @@ #include #include "mako_midi.h" -#include "nact.h" +#include "game_id.h" #include "dri.h" -#include "crc32.h" +#include "game_id.h" namespace { @@ -93,7 +93,7 @@ void stop_midi() class Playback { public: - static std::unique_ptr create(NACT* nact, Dri& amus, Dri& mda, int page, int loop, int seq); + static std::unique_ptr create(const GameId& game_id, Dri& amus, Dri& mda, int page, int loop, int seq); Playback(uint32_t crc32_a, int loop, int seq) : crc32_a(crc32_a), loop_(loop), seq_(seq) {} bool load_mml(const std::vector& data); void load_mda(const std::vector& data); @@ -379,9 +379,9 @@ bool Playback::play_midi(SDL_atomic_t* current_loop, SDL_atomic_t* current_mark) } //static -std::unique_ptr Playback::create(NACT* nact, Dri& amus, Dri& mda, int page, int loop, int seq) +std::unique_ptr Playback::create(const GameId& game_id, Dri& amus, Dri& mda, int page, int loop, int seq) { - auto playback = std::make_unique(nact->crc32_a, loop, seq); + auto playback = std::make_unique(game_id.crc32_a, loop, seq); std::vector data = amus.load(page); if (data.empty()) @@ -392,7 +392,7 @@ std::unique_ptr Playback::create(NACT* nact, Dri& amus, Dri& mda, int // Load MDA data = mda.load(page); if (data.empty()) - data = Dri::load_mda(nact->crc32_a, nact->crc32_b, page); + data = Dri::load_mda(game_id.crc32_a, game_id.crc32_b, page); playback->load_mda(data); return playback; @@ -660,10 +660,10 @@ bool MAKOMidi::is_available() return !!midiout; } -bool MAKOMidi::play(NACT* nact, Dri& amus, Dri& mda, int page, int loop) +bool MAKOMidi::play(const GameId& game_id, Dri& amus, Dri& mda, int page, int loop) { int seq = ++next_seq; - auto playback = Playback::create(nact, amus, mda, page, loop, seq); + auto playback = Playback::create(game_id, amus, mda, page, loop, seq); if (!playback) return false; SDL_AtomicSet(¤t_seq, seq); diff --git a/src/sys/mako_midi.h b/src/sys/mako_midi.h index 41a0712..f64ef19 100644 --- a/src/sys/mako_midi.h +++ b/src/sys/mako_midi.h @@ -6,7 +6,7 @@ #include #include "../common.h" -class NACT; +struct GameId; class Dri; #ifdef USE_MIDI @@ -16,7 +16,7 @@ public: explicit MAKOMidi(int device); ~MAKOMidi(); bool is_available(); - bool play(NACT* nact, Dri& amus, Dri& mda, int page, int loop); + bool play(const GameId& game_id, Dri& amus, Dri& mda, int page, int loop); void stop(); bool is_playing(); void get_mark(int* mark, int* loop); @@ -41,7 +41,7 @@ class MAKOMidi { public: explicit MAKOMidi(int device) {} bool is_available() { return false; } - bool play(NACT* nact, Dri& amus, Dri& mda, int page, int loop) { return false; } + bool play(const GameId& game_id, Dri& amus, Dri& mda, int page, int loop) { return false; } void stop() {} bool is_playing() { return false; } void get_mark(int* mark, int* loop) { *mark = *loop = 0; } diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index ee6fe56..2cc5c96 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -14,19 +14,17 @@ #include "dri.h" #include "../config.h" #include "../fileio.h" -#include "crc32.h" +#include "game_id.h" extern SDL_Window* g_window; // 初期化 -NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const Config& config) - : sys_ver(sys_ver), - crc32_a(crc32_a), - crc32_b(crc32_b), - config(config), - encoding(Encoding::create(get_encoding_name())), - strings(config.get_strings(encoding.get(), get_language() == ENGLISH)) +NACT::NACT(const Config& config, const GameId& game_id) + : config(config), + game_id(game_id), + encoding(Encoding::create(game_id.encoding)), + strings(config.get_strings(encoding.get(), game_id.language == ENGLISH)) { platform_initialize(); @@ -52,7 +50,7 @@ NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const Config& config) } // ADISK.DAT - if (crc32_a == CRC32_PROG_OMAKE) + if (game_id.crc32_a == CRC32_PROG_OMAKE) sco.open("AGAME.DAT"); else sco.open("ADISK.DAT"); @@ -91,7 +89,7 @@ NACT::NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const Config& config) // 各種クラス生成 ags = new AGS(this, config); - mako = new MAKO(this, config); + mako = new MAKO(config, game_id); msgskip = new MsgSkip(this); SDL_Init(SDL_INIT_GAMECONTROLLER); @@ -156,7 +154,7 @@ void NACT::execute() return; } - if(sys_ver == 1 && sco.page() == 0 && sco.addr() == 2) { + if (game_id.sys_ver == 1 && sco.page() == 0 && sco.addr() == 2) { opening(); } @@ -351,7 +349,7 @@ void NACT::message(uint8 terminator) ags->draw_text(buf, text_wait_enb); - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { if(!ags->draw_menu) { text_refresh = false; } @@ -533,16 +531,13 @@ void NACT::select_cursor() ags->select_cursor(); } -NACT* NACT::create(const Config& config) { - uint32 crc32_a = NACT::calc_crc32("ADISK.DAT", config.game_id); - uint32 crc32_b = NACT::calc_crc32("BDISK.DAT", config.game_id); - int sys_ver = NACT::get_sys_ver(crc32_a, crc32_b); - switch (sys_ver) { +NACT* NACT::create(const Config& config, const GameId& game_id) { + switch (game_id.sys_ver) { case 1: - return new NACT_Sys1(crc32_a, crc32_b, config); + return new NACT_Sys1(config, game_id); case 2: - return new NACT_Sys2(crc32_a, crc32_b, config); + return new NACT_Sys2(config, game_id); default: - return new NACT_Sys3(crc32_a, crc32_b, config); + return new NACT_Sys3(config, game_id); } } diff --git a/src/sys/nact.h b/src/sys/nact.h index a435de8..c2e2b06 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -14,6 +14,7 @@ #include "../common.h" #include "config.h" #include "dri.h" +#include "game_id.h" #include "scenario.h" #define RND var[ 0] @@ -87,11 +88,6 @@ class MAKO; class MsgSkip; class Encoding; -enum Language { - JAPANESE = 0, - ENGLISH = 1, -}; - // special codes for NACT::exit_code const int NACT_HALT = -1; const int NACT_RESTART = -2; @@ -99,8 +95,8 @@ const int NACT_RESTART = -2; class NACT { public: - static NACT* create(const Config& config); - NACT(int sys_ver, uint32 crc32_a, uint32 crc32_b, const Config& config); + static NACT* create(const Config& config, const GameId& game_id); + NACT(const Config& config, const GameId& game_id); virtual ~NACT(); protected: @@ -217,8 +213,6 @@ protected: int mouse_x = 0, mouse_y = 0; - static uint32 calc_crc32(const char* file_name, const std::string& game_id); - // Y27 ダイアログ void text_dialog(); @@ -239,20 +233,13 @@ public: void select_cursor(); - const char* get_game_id(); - static const int get_sys_ver(uint32 crc32_a, uint32 crc32_b); - const char* get_title(); - Language get_language(); - const char* get_encoding_name(); void text_wait(); void set_skip_menu_state(bool enabled, bool checked); bool text_wait_enb; // テキスト表示のウェイト有効/無効 bool mouse_move_enabled = true; - int sys_ver; - uint32 crc32_a; // ADISK - uint32 crc32_b; // BDISK for D.P.S -SG- and Super D.P.S const Config& config; + const GameId& game_id; std::unique_ptr encoding; Strings strings; @@ -272,7 +259,7 @@ private: class NACT_Sys1 final : public NACT { public: - NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const Config& config); + NACT_Sys1(const Config& config, const GameId& game_id); protected: void cmd_calc() override; void cmd_branch() override; @@ -319,7 +306,7 @@ private: class NACT_Sys2 final : public NACT { public: - NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const Config& config); + NACT_Sys2(const Config& config, const GameId& game_id) : NACT(config, game_id) {} protected: void cmd_calc() override; void cmd_branch() override; @@ -360,7 +347,7 @@ protected: class NACT_Sys3 final : public NACT { public: - NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const Config& config); + NACT_Sys3(const Config& config, const GameId& game_id) : NACT(config, game_id) {} protected: void cmd_calc() override; void cmd_branch() override; diff --git a/src/sys/nact_sys1.cpp b/src/sys/nact_sys1.cpp index 24da926..0a91494 100644 --- a/src/sys/nact_sys1.cpp +++ b/src/sys/nact_sys1.cpp @@ -15,7 +15,7 @@ #include "ags.h" #include "mako.h" #include "msgskip.h" -#include "crc32.h" +#include "game_id.h" #include "../fileio.h" #include "encoding.h" #include "texthook.h" @@ -63,10 +63,10 @@ } \ } -NACT_Sys1::NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const Config& config) - : NACT(1, crc32_a, crc32_b, config) +NACT_Sys1::NACT_Sys1(const Config& config, const GameId& game_id) + : NACT(config, game_id) { - switch (crc32_a) { + switch (game_id.crc32_a) { case CRC32_DPS: case CRC32_DPS_SG: //case CRC32_DPS_SG2: @@ -88,7 +88,7 @@ NACT_Sys1::NACT_Sys1(uint32 crc32_a, uint32 crc32_b, const Config& config) void NACT_Sys1::opening() { - switch (crc32_a) { + switch (game_id.crc32_a) { case CRC32_CRESCENT: mako->play_music(2); ags->load_cg(1, -1); @@ -248,7 +248,7 @@ void NACT_Sys1::cmd_set_menu() ags->menu_dest_y += 2; ags->draw_menu = true; - if (crc32_a == CRC32_GAKUEN || crc32_a == CRC32_GAKUEN_ENG) + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) menu_window = 2; output_console("\n$%x,", menu_addr[menu_index - 1]); @@ -264,7 +264,7 @@ void NACT_Sys1::cmd_open_menu() return; } - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { if(!text_refresh) { cmd_a(); } @@ -320,7 +320,7 @@ void NACT_Sys1::cmd_open_verb() // 表示する動詞のチェック int chk[MAX_VERB], page = 0, cnt = 0; - if (crc32_a == CRC32_GAKUEN || crc32_a == CRC32_GAKUEN_ENG) + if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) menu_window = 1; int menu_max = ags->calculate_menu_max(menu_window); @@ -538,7 +538,7 @@ void NACT_Sys1::cmd_a() // ウィンドウ更新 ags->clear_text_window(text_window, true); - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { text_refresh = true; } } @@ -574,16 +574,16 @@ void NACT_Sys1::cmd_g() output_console("\nG %d:", page); - if (crc32_a == CRC32_INTRUDER) { + if (game_id.crc32_a == CRC32_INTRUDER) { page = (page == 97) ? 96 : (page == 98) ? 97 : page; - } else if (crc32_a == CRC32_GAKUEN || crc32_a == CRC32_GAKUEN_ENG) { + } else if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) { page = (page == 3) ? 94 : page; } if (enable_graphics) ags->load_cg(page, -1); - if(crc32_a == CRC32_INTRUDER) { + if (game_id.crc32_a == CRC32_INTRUDER) { if(page == 94) { WAIT(400); } @@ -876,7 +876,7 @@ void NACT_Sys1::cmd_u() output_console("\nU %d,%d:", page, transparent); - if(crc32_a == CRC32_INTRUDER) { + if (game_id.crc32_a == CRC32_INTRUDER) { ags->load_cg(page, 11); if(page == 5) { @@ -917,7 +917,7 @@ void NACT_Sys1::cmd_y() output_console("\nY %d,%d:", cmd, param); - if(crc32_a == CRC32_INTRUDER) { + if (game_id.crc32_a == CRC32_INTRUDER) { switch(cmd) { case 0: ags->clear_text_window(text_window, true); @@ -961,7 +961,7 @@ void NACT_Sys1::cmd_y() quit(NACT_HALT); break; } - } else if (crc32_a == CRC32_GAKUEN || crc32_a == CRC32_GAKUEN_ENG) { + } else if (game_id.crc32_a == CRC32_GAKUEN || game_id.crc32_a == CRC32_GAKUEN_ENG) { switch (cmd) { case 1: RND = (param == 0 || param == 1) ? 0 : random(param); @@ -1025,11 +1025,11 @@ void NACT_Sys1::cmd_y() } break; case 2: - if(crc32_a == CRC32_CRESCENT) { + if (game_id.crc32_a == CRC32_CRESCENT) { for(int i = 39; i <= 48; i++) { var[i] = 0; } - } else if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + } else if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { for(int i = 0; i <= 20; i++) { var[i] = 0; } @@ -1046,14 +1046,14 @@ void NACT_Sys1::cmd_y() RND = (param == 0 || param == 1) ? 0 : random(param); break; case 7: - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { if(param == 1) { ags->box_fill(0, 40, 8, 598, 270, 0); } } break; case 130: - if(crc32_a == CRC32_TENGU) { + if (game_id.crc32_a == CRC32_TENGU) { WAIT(2000) ags->load_cg(180, -1); @@ -1090,7 +1090,7 @@ void NACT_Sys1::cmd_y() RND = 0; break; case 255: - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { + if (game_id.crc32_a == CRC32_DPS || game_id.crc32_a == CRC32_DPS_SG || game_id.crc32_a == CRC32_DPS_SG2 || game_id.crc32_a == CRC32_DPS_SG3) { quit(0); } else { quit(NACT_HALT); @@ -1102,7 +1102,7 @@ void NACT_Sys1::cmd_y() void NACT_Sys1::cmd_z() { - if (crc32_a == CRC32_CRESCENT) { + if (game_id.crc32_a == CRC32_CRESCENT) { cmd_y(); return; } @@ -1111,7 +1111,7 @@ void NACT_Sys1::cmd_z() output_console("\nZ %d,%d:", cmd, param); - switch (crc32_a) { + switch (game_id.crc32_a) { case CRC32_INTRUDER: if(cmd == 1 && 1 <= param && param <= 4) { const char* buf[4] = { diff --git a/src/sys/nact_sys2.cpp b/src/sys/nact_sys2.cpp index e32fba7..c1cfb4a 100644 --- a/src/sys/nact_sys2.cpp +++ b/src/sys/nact_sys2.cpp @@ -10,7 +10,7 @@ #include "ags.h" #include "mako.h" #include "msgskip.h" -#include "crc32.h" +#include "game_id.h" #include "../fileio.h" #include "encoding.h" #include "texthook.h" @@ -58,11 +58,6 @@ } \ } -NACT_Sys2::NACT_Sys2(uint32 crc32_a, uint32 crc32_b, const Config& config) - : NACT(2, crc32_a, crc32_b, config) -{ -} - void NACT_Sys2::cmd_calc() { int index = sco.getd(); @@ -199,7 +194,7 @@ void NACT_Sys2::cmd_branch() cali(); cali(); } else if(cmd == 'U') { - if(crc32_a == CRC32_YAKATA2) { + if (game_id.crc32_a == CRC32_YAKATA2) { cali(); cali(); } else { @@ -494,7 +489,7 @@ void NACT_Sys2::cmd_b() output_console("\nB %d,%d,%d,%d,%d,%d,%d:", cmd, index, p1, p2, p3, p4, p5); if(cmd == 1) { - if(crc32_a == CRC32_AYUMI_FD || crc32_a == CRC32_AYUMI_HINT || crc32_a == CRC32_DRSTOP) { + if (game_id.crc32_a == CRC32_AYUMI_FD || game_id.crc32_a == CRC32_AYUMI_HINT || game_id.crc32_a == CRC32_DRSTOP) { p5 = 1; } ags->menu_w[index - 1].sx = p1 * 8; @@ -509,10 +504,10 @@ void NACT_Sys2::cmd_b() ags->menu_w[index - 1].screen = NULL; } } else if(cmd == 2) { - if(crc32_a == CRC32_AYUMI_FD || crc32_a == CRC32_AYUMI_HINT || crc32_a == CRC32_DRSTOP) { + if (game_id.crc32_a == CRC32_AYUMI_FD || game_id.crc32_a == CRC32_AYUMI_HINT || game_id.crc32_a == CRC32_DRSTOP) { p1 = 1; } -// if(crc32_a == CRC32_PROSTUDENTG_FD) { +// if (game_id.crc32_a == CRC32_PROSTUDENTG_FD) { // ags->menu_w[index - 1].frame = (index == 1 || index == 3) ? true : false; // } else ags->menu_w[index - 1].frame = p1 ? true : false; @@ -535,16 +530,16 @@ void NACT_Sys2::cmd_b() ags->text_w[index - 1].window = NULL; } } else if(cmd == 4) { - if(crc32_a == CRC32_AYUMI_FD || crc32_a == CRC32_AYUMI_HINT) { + if (game_id.crc32_a == CRC32_AYUMI_FD || game_id.crc32_a == CRC32_AYUMI_HINT) { p1 = 1; //p5 ? 0 : 1; // 逆? p5 = 0; - } else if(crc32_a == CRC32_DRSTOP) { + } else if (game_id.crc32_a == CRC32_DRSTOP) { p1 = 1; } if(p5 == 0) { // ウィンドウ退避 -// if(crc32_a == CRC32_PROSTUDENTG_FD) { +// if (game_id.crc32_a == CRC32_PROSTUDENTG_FD) { // ags->text_w[index - 1].frame = (index == 1 || index == 3) ? true : false; // } else ags->text_w[index - 1].frame = p1 ? true : false; @@ -593,18 +588,18 @@ void NACT_Sys2::cmd_g() output_console("\nG %d:", page); - if(crc32_a == CRC32_SDPS && (crc32_b == CRC32_SDPS_TONO || crc32_b == CRC32_SDPS_KAIZOKU)) { + if (game_id.crc32_a == CRC32_SDPS && (game_id.crc32_b == CRC32_SDPS_TONO || game_id.crc32_b == CRC32_SDPS_KAIZOKU)) { if(20 <= page && page <= 100) { page--; } } ags->load_cg(page, -1); - if(crc32_a == CRC32_DALK_HINT) { + if (game_id.crc32_a == CRC32_DALK_HINT) { if(page == 3) { WAIT(2000) } - } else if(crc32_a == CRC32_RANCE3_HINT) { + } else if (game_id.crc32_a == CRC32_RANCE3_HINT) { if(page == 25) { WAIT(2000) } @@ -825,7 +820,7 @@ void NACT_Sys2::cmd_p() { int param = sco.getd(); - if(crc32_a != CRC32_YAKATA2 && crc32_a != CRC32_DALK_HINT && crc32_a != CRC32_RANCE3_HINT) { + if (game_id.crc32_a != CRC32_YAKATA2 && game_id.crc32_a != CRC32_DALK_HINT && game_id.crc32_a != CRC32_RANCE3_HINT) { ags->text_font_color = (uint8)((param & 0x7) + 16); } @@ -966,7 +961,7 @@ void NACT_Sys2::cmd_u() { int page, transparent; - if(crc32_a == CRC32_YAKATA2) { + if (game_id.crc32_a == CRC32_YAKATA2) { page = cali(); transparent = cali(); } else { @@ -1087,7 +1082,7 @@ void NACT_Sys2::cmd_y() RND = (param == 0 || param == 1) ? 0 : random(param); break; case 7: - if(!(crc32_a == CRC32_SDPS && crc32_b == CRC32_SDPS_MARIA)) { + if (!(game_id.crc32_a == CRC32_SDPS && game_id.crc32_b == CRC32_SDPS_MARIA)) { ags->draw_box(param); } break; diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index d2e89a0..0269532 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -10,16 +10,11 @@ #include "ags.h" #include "mako.h" #include "msgskip.h" -#include "crc32.h" +#include "game_id.h" #include "../fileio.h" #include "encoding.h" #include "texthook.h" -NACT_Sys3::NACT_Sys3(uint32 crc32_a, uint32 crc32_b, const Config& config) - : NACT(3, crc32_a, crc32_b, config) -{ -} - void NACT_Sys3::cmd_calc() { int index = sco.getd(); @@ -272,7 +267,7 @@ void NACT_Sys3::cmd_b() if(cmd == 1) { // あゆみちゃん物語 - if(crc32_a == CRC32_AYUMI_CD || crc32_a == CRC32_AYUMI_JISSHA_256 || crc32_a == CRC32_AYUMI_JISSHA_FULL) { + if (game_id.crc32_a == CRC32_AYUMI_CD || game_id.crc32_a == CRC32_AYUMI_JISSHA_256 || game_id.crc32_a == CRC32_AYUMI_JISSHA_FULL) { p5 = 1; } ags->menu_w[index - 1].sx = column ? p1 * 8 : p1 & 0xfff8; @@ -309,7 +304,7 @@ void NACT_Sys3::cmd_b() } else if(cmd == 4) { if(p5 == 0) { // ウィンドウ退避 - if(crc32_a == CRC32_PROSTUDENTG_CD && p4) { + if (game_id.crc32_a == CRC32_PROSTUDENTG_CD && p4) { // prostudent G オープニング画面化け対策 if(ags->text_w[index - 1].window) { free(ags->text_w[index - 1].window); @@ -426,7 +421,7 @@ void NACT_Sys3::cmd_i() // X方向はカラム単位で切り捨て sx = column ? sx * 8 : sx & 0xfff8; - ex = column ? ex * 8 - 1 : (crc32_a == CRC32_NINGYO) ? (ex & 0xfff8) + 7 : (ex & 0xfff8) - 1; + ex = column ? ex * 8 - 1 : (game_id.crc32_a == CRC32_NINGYO) ? (ex & 0xfff8) + 7 : (ex & 0xfff8) - 1; dx = column ? dx * 8 : dx & 0xfff8; ags->copy(sx, sy, ex, ey, dx, dy); } @@ -457,7 +452,7 @@ void NACT_Sys3::cmd_k() } if (cmd == 3) { - switch (crc32_a) { + switch (game_id.crc32_a) { case CRC32_YAKATA3_CD: if (k3_hack(yakata3cd_k3_hack_table)) return; @@ -923,8 +918,8 @@ void NACT_Sys3::cmd_u() output_console("\nU %d,%d:", page, transparent); - if(crc32_a == CRC32_RANCE41 || crc32_a == CRC32_RANCE41_ENG || - crc32_a == CRC32_RANCE42 || crc32_a == CRC32_RANCE42_ENG) { + if (game_id.crc32_a == CRC32_RANCE41 || game_id.crc32_a == CRC32_RANCE41_ENG || + game_id.crc32_a == CRC32_RANCE42 || game_id.crc32_a == CRC32_RANCE42_ENG) { transparent = (transparent == 28) ? 12 : transparent; } ags->load_cg(page, transparent); @@ -1236,7 +1231,7 @@ void NACT_Sys3::cmd_y() case 231: D01 = 640; D02 = (param == 1) ? ags->screen_height : 480; - D03 = (crc32_a == CRC32_YAKATA3_FD) ? 16 : 256; + D03 = (game_id.crc32_a == CRC32_YAKATA3_FD) ? 16 : 256; break; case 232: if(ags->screen_height != (param ? 480 : 400)) { @@ -1323,13 +1318,13 @@ void NACT_Sys3::cmd_y() column = param ? false : true; break; case 252: - RND = (crc32_a == CRC32_YAKATA3_FD) ? 4 : 8; + RND = (game_id.crc32_a == CRC32_YAKATA3_FD) ? 4 : 8; break; case 253: show_push = (param == 0) ? true : false; break; case 254: - RND = (crc32_a == CRC32_YAKATA3_CD || crc32_a == CRC32_YAKATA3_FD || crc32_a == CRC32_NINGYO) ? 1 : 0; + RND = (game_id.crc32_a == CRC32_YAKATA3_CD || game_id.crc32_a == CRC32_YAKATA3_FD || game_id.crc32_a == CRC32_NINGYO) ? 1 : 0; break; case 255: quit(param == 1 ? NACT_HALT : RND); diff --git a/src/win/mako.cpp b/src/win/mako.cpp index 8015789..39f3e1a 100644 --- a/src/win/mako.cpp +++ b/src/win/mako.cpp @@ -17,7 +17,7 @@ #include "fm/mako_ymfm.h" #include "../config.h" #include "dri.h" -#include "crc32.h" +#include "game_id.h" extern SDL_Window* g_window; @@ -50,7 +50,7 @@ const char* mci_geterror(DWORD err) class MCIThread { public: - MCIThread(NACT* nact, HWND hwnd_notify) : hwnd_notify(hwnd_notify) { + MCIThread(HWND hwnd_notify) : hwnd_notify(hwnd_notify) { if (!_beginthreadex(NULL, 0, &MCIThread::run, this, 0, &thread_id)) sys_error("Cannot create thread: %s", strerror(errno)); } @@ -200,11 +200,11 @@ void audio_callback(void*, Uint8* stream, int len) { } // namespace -MAKO::MAKO(NACT* parent, const Config& config) : +MAKO::MAKO(const Config& config, const GameId& game_id) : use_fm(config.use_fm), current_music(0), next_loop(0), - nact(parent) + game_id(game_id) { if (!config.playlist.empty()) load_playlist(config.playlist.c_str()); @@ -236,7 +236,7 @@ MAKO::MAKO(NACT* parent, const Config& config) : SDL_VERSION(&info.version); if (!SDL_GetWindowWMInfo(g_window, &info)) sys_error("SDL_GetWindowWMInfo failed: %s", SDL_GetError()); - mci_thread = new MCIThread(parent, info.info.win.window); + mci_thread = new MCIThread(info.info.win.window); midi = std::make_unique(config.midi_device); if (!midi->is_available()) @@ -299,7 +299,7 @@ void MAKO::play_music(int page) SDL_UnlockMutex(fm_mutex); SDL_PauseAudio(0); } else if (midi->is_available()) { - if (!midi->play(nact, amus, mda, page, next_loop)) + if (!midi->play(game_id, amus, mda, page, next_loop)) return; } current_music = page; @@ -360,7 +360,7 @@ void MAKO::select_sound(BGMDevice dev) case BGM_CD: const int8* tracks; - switch (nact->crc32_a) { + switch (game_id.crc32_a) { case CRC32_RANCE41: case CRC32_RANCE41_ENG: tracks = RANCE41_tracks; diff --git a/src/win/nact_win.cpp b/src/win/nact_win.cpp index e623ce0..d11369f 100644 --- a/src/win/nact_win.cpp +++ b/src/win/nact_win.cpp @@ -138,7 +138,7 @@ void NACT::text_dialog() void NACT::platform_initialize() { init_menu(mouse_move_enabled, config); - init_console(sys_ver); + init_console(game_id.sys_ver); SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); }