diff --git a/src/sys/ags.h b/src/sys/ags.h index cfcaf76..f62b9d8 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -118,7 +118,7 @@ public: void box_fill(int dest, int sx, int sy, int ex, int ey, uint8 color); void box_line(int dest, int sx, int sy, int ex, int ey, uint8 color); - void draw_text(const char* string); + void draw_text(const char* string, bool text_wait = false); uint16 convert_zenkaku(uint16 code); uint16 convert_hankaku(uint16 code); diff --git a/src/sys/ags_text.cpp b/src/sys/ags_text.cpp index 29e9b10..e3f4d62 100644 --- a/src/sys/ags_text.cpp +++ b/src/sys/ags_text.cpp @@ -11,7 +11,7 @@ static bool antialias = true; -void AGS::draw_text(const char* string) +void AGS::draw_text(const char* string, bool text_wait) { int p = 0; int screen, dest_x, dest_y, font_size; @@ -39,7 +39,8 @@ void AGS::draw_text(const char* string) while(string[p] != '\0') { // 文字コード取得 - uint16 code = (uint8)string[p++]; + uint8 c = (uint8)string[p++]; + uint16 code = c; if(is_2byte_message(code)) { code = (code << 8) | (uint8)string[p++]; } @@ -63,10 +64,19 @@ void AGS::draw_text(const char* string) } // 出力位置の更新 dest_x += (code & 0xff00) ? font_size : (font_size >> 1); + + if (!draw_menu && text_wait && c != ' ') { + // 画面更新 + if(screen == 0) + draw_screen(text_dest_x, dest_y, dest_x - text_dest_x, font_size); + text_dest_x = dest_x; + // Wait + nact->text_wait(); + } } if (draw_menu) menu_dest_x = dest_x; - else { + else if (!text_wait) { // 画面更新 if(screen == 0) draw_screen(text_dest_x, dest_y, dest_x - text_dest_x, font_size); diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index 107e0bf..325b1c6 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -278,69 +278,9 @@ void NACT::execute() cmd_z(); break; default: - if(is_1byte_message(cmd)) { - char string[3]; - string[0] = cmd; - string[1] = '\0'; - ags->draw_text(string); - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { - if(!ags->draw_menu) { - text_refresh = false; - } - } - - if(!ags->draw_menu && text_wait_enb && cmd != 0x20) { - Uint32 dwTime = SDL_GetTicks() + text_wait_time; - for(;;) { - if(terminate) { - return; - } - RND = get_key(); - if(RND && wait_keydown) { - break; - } - if(dwTime <= SDL_GetTicks()) { - break; - } - sys_sleep(16); - } - } - if(!ags->draw_hankaku) { - uint16 code = ags->convert_zenkaku(cmd); - string[0] = code >> 8; - string[1] = code & 0xff; - string[2] = '\0'; - } - output_console(string); - } else if(is_2byte_message(cmd)) { - char string[3]; - string[0] = cmd; - string[1] = getd(); - string[2] = '\0'; - ags->draw_text(string); - if(crc32_a == CRC32_DPS || crc32_a == CRC32_DPS_SG || crc32_a == CRC32_DPS_SG2 || crc32_a == CRC32_DPS_SG3) { - if(!ags->draw_menu) { - text_refresh = false; - } - } - - if(!ags->draw_menu && text_wait_enb) { - Uint32 dwTime = SDL_GetTicks() + text_wait_time; - for(;;) { - if(terminate) { - return; - } - RND = get_key(); - if(RND && wait_keydown) { - break; - } - if(dwTime <= SDL_GetTicks()) { - break; - } - sys_sleep(16); - } - } - output_console(string); + if(is_1byte_message(cmd) || is_2byte_message(cmd)) { + ungetd(); + message(); } else { if(cmd >= 0x20 && cmd < 0x7f) { fatal("Unknown Command: '%c' at page = %d, addr = %d", cmd, scenario_page, prev_addr); @@ -352,6 +292,55 @@ void NACT::execute() } } +void NACT::message() +{ + uint8* begin = &scenario_data[scenario_addr]; + uint8* end = begin; + for (;;) { + if (is_1byte_message(*end)) + end++; + else if (is_2byte_message(*end)) + end += 2; + else + break; + } + int len = end - begin; + scenario_addr += len; + + char* buf = (char*)alloca(len + 1); + strncpy(buf, reinterpret_cast(begin), len); + buf[len] = '\0'; + + 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(!ags->draw_menu) { + text_refresh = false; + } + } + + // TODO: Convert hankaku to zenkaku + output_console(buf); +} + +void NACT::text_wait() +{ + Uint32 dwTime = SDL_GetTicks() + text_wait_time; + for(;;) { + if(terminate) { + return; + } + RND = get_key(); + if(RND && wait_keydown) { + break; + } + if(dwTime <= SDL_GetTicks()) { + break; + } + sys_sleep(16); + } +} + void NACT::load_scenario(int page) { if(scenario_data) { diff --git a/src/sys/nact.h b/src/sys/nact.h index 46057eb..bf9a7c0 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -125,6 +125,8 @@ protected: char tvar_stack[30][10][22]; // int tvar_index; + void message(); + // Commands virtual void cmd_calc() = 0; @@ -207,6 +209,7 @@ protected: scenario_addr += 2; return val; } + void ungetd() { scenario_addr--; } uint16 random(uint16 range); uint32 seed; @@ -247,6 +250,7 @@ public: const char* get_game_id(); static const int get_sys_ver(uint32 crc32_a, uint32 crc32_b); const char* get_title(); + void text_wait(); bool text_skip_enb; // メッセージスキップ bool text_wait_enb; // テキスト表示のウェイト有効/無効