From c657b0cdc28efc6ebae06970e81a38288a843bc5 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:07:27 +0900 Subject: [PATCH] test3 --- src/dos/dos.cpp | 2 +- src/dos/dos_programs.cpp | 3 +-- src/gui/menu_callback.cpp | 2 +- src/gui/render.cpp | 6 +++++- src/gui/sdl_mapper.cpp | 2 +- src/gui/sdlmain.cpp | 19 +++++++++++++++++++ src/misc/messages.cpp | 6 +++--- src/misc/programs.cpp | 2 +- src/output/output_ttf.cpp | 10 +++++++--- src/shell/shell_cmds.cpp | 18 +++++++----------- 10 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index e95dfea0ff..2b10f524e2 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -2818,7 +2818,7 @@ static Bitu DOS_21Handler(void) { int cpbak = dos.loaded_codepage; dos.loaded_codepage = reg_bx; #if defined(USE_TTF) - setTTFCodePage(); + if(TTF_using()) setTTFCodePage(); #endif if (loadlang) { MSG_Init(); diff --git a/src/dos/dos_programs.cpp b/src/dos/dos_programs.cpp index 349ca4dc44..90db0fcae4 100644 --- a/src/dos/dos_programs.cpp +++ b/src/dos/dos_programs.cpp @@ -107,8 +107,7 @@ extern bool addovl, addipx, addne2k, prepared, inshell, usecon, uao, loadlang, m extern bool clear_screen(), OpenGL_using(void), DOS_SetAnsiAttr(uint8_t attr), isDBCSCP(); extern int lastcp, lastmsgcp, tryconvertcp, FileDirExistCP(const char *name), FileDirExistUTF8(std::string &localname, const char *name); extern uint8_t DOS_GetAnsiAttr(void); -extern int toSetCodePage(DOS_Shell *shell, int newCP, int opt); -void MSG_Init(), JFONT_Init(), InitFontHandle(), ShutFontHandle(), DOSBox_SetSysMenu(), Load_Language(std::string name); +int toSetCodePage(DOS_Shell *shell, int newCP, int opt); void DOS_EnableDriveMenu(char drv), GFX_SetTitle(int32_t cycles, int frameskip, Bits timing, bool paused), UpdateSDLDrawTexture(); void runBoot(const char *str), runMount(const char *str), runImgmount(const char *str), runRescan(const char *str), show_prompt(), ttf_reset(void); void getdrivezpath(std::string &path, std::string const& dirname), drivezRegister(std::string const& path, std::string const& dir, bool usecp), UpdateDefaultPrinterFont(void); diff --git a/src/gui/menu_callback.cpp b/src/gui/menu_callback.cpp index f65c0d3c3b..3114731abb 100644 --- a/src/gui/menu_callback.cpp +++ b/src/gui/menu_callback.cpp @@ -1650,7 +1650,7 @@ bool ttf_halfwidth_katakana_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * halfwidthkana=!halfwidthkana; SetVal("ttf", "halfwidthkana", halfwidthkana?"true":"false"); mainMenu.get_item("ttf_halfwidthkana").check(halfwidthkana).refresh_item(mainMenu); - setTTFCodePage(); + if(TTF_using()) setTTFCodePage(); resetFontSize(); return true; } diff --git a/src/gui/render.cpp b/src/gui/render.cpp index b72a191ecf..cc8a2dce93 100644 --- a/src/gui/render.cpp +++ b/src/gui/render.cpp @@ -471,6 +471,7 @@ std::string RENDER_GetScaler(void) { return prop->GetSection()->Get_string("type"); } +Bitu srcAspect_x = 0, srcAspect_y = 0; void RENDER_Reset( void ) { Bitu width=render.src.width; Bitu height=render.src.height; @@ -750,7 +751,10 @@ void RENDER_Reset( void ) { sdl.srcAspect.y = aspect_ratio_y>0?aspect_ratio_y:(int)floor((render.src.height * (render.src.dblh ? 2 : 1) * render.src.ratio) + 0.5); sdl.srcAspect.xToY = (double)sdl.srcAspect.x / sdl.srcAspect.y; sdl.srcAspect.yToX = (double)sdl.srcAspect.y / sdl.srcAspect.x; - LOG_MSG("Aspect ratio: %u x %u xToY=%.3f yToX=%.3f",sdl.srcAspect.x,sdl.srcAspect.y,sdl.srcAspect.xToY,sdl.srcAspect.yToX); + if(sdl.srcAspect.x != srcAspect_x || sdl.srcAspect.y != srcAspect_y) + LOG_MSG("Aspect ratio: %u x %u xToY=%.3f yToX=%.3f",sdl.srcAspect.x,sdl.srcAspect.y,sdl.srcAspect.xToY,sdl.srcAspect.yToX); + srcAspect_x = sdl.srcAspect.x; + srcAspect_y = sdl.srcAspect.y; /* Setup the scaler variables */ #if C_OPENGL GFX_SetShader(render.shader_src); diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 52cb83beef..b2d4ed2c36 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -5273,7 +5273,7 @@ void MAPPER_LosingFocus(void) { void MAPPER_ReleaseAllKeys(void) { for (CEventVector_it evit=events.begin();evit!=events.end();++evit) { if ((*evit)->active) { - LOG_MSG("Release"); + LOG(LOG_GUI,LOG_DEBUG)("Mapper: Release all keys"); (*evit)->Active(false); } } diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 4d98ad02a4..449882d4de 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -701,6 +701,7 @@ void UpdateWindowDimensions(Bitu width, Bitu height) currentWindowHeight = height; } +double pixels_width=0, pixels_height=0, mm_width=0, mm_height=0, pixels_x=0, pixels_y=0, dpi_width=0, dpi_height=0; void PrintScreenSizeInfo(void) { #if 1 const char *method = "?"; @@ -714,6 +715,15 @@ void PrintScreenSizeInfo(void) { default: break; } + if (screen_size_info.screen_dimensions_pixels.width != pixels_width || + screen_size_info.screen_dimensions_pixels.height != pixels_height || + screen_size_info.screen_position_pixels.x != pixels_x || + screen_size_info.screen_position_pixels.y != pixels_y || + screen_size_info.screen_dimensions_mm.width != mm_width || + screen_size_info.screen_dimensions_mm.height != mm_height || + screen_size_info.screen_dpi.width != dpi_width || + screen_size_info.screen_dpi.height != dpi_height + ) LOG_MSG("Screen report: Method '%s' (%.3f x %.3f pixels) at (%.3f x %.3f) (%.3f x %.3f mm) (%.3f x %.3f in) (%.3f x %.3f DPI)", method, @@ -731,6 +741,15 @@ void PrintScreenSizeInfo(void) { screen_size_info.screen_dpi.width, screen_size_info.screen_dpi.height); + pixels_width = screen_size_info.screen_dimensions_pixels.width; + pixels_height = screen_size_info.screen_dimensions_pixels.height; + pixels_x = screen_size_info.screen_position_pixels.x; + pixels_y = screen_size_info.screen_position_pixels.y; + mm_width = screen_size_info.screen_dimensions_mm.width; + mm_height = screen_size_info.screen_dimensions_mm.height; + dpi_width = screen_size_info.screen_dpi.width; + dpi_height = screen_size_info.screen_dpi.height; + #endif } diff --git a/src/misc/messages.cpp b/src/misc/messages.cpp index b0067f6f0f..51532846fc 100644 --- a/src/misc/messages.cpp +++ b/src/misc/messages.cpp @@ -348,7 +348,7 @@ void LoadMessageFile(const char * fname) { if(control->opt_langcp || uselangcp || CHCPChangecodepage || !loadlang || (loadlang && systemmessagebox("DOSBox-X language file", msg.c_str(), "yesno", "question", 1))){ loadlangcp = true; msgcodepage = c; - if((TTF_using() && isSupportedCP(c))|| !TTF_using()) int missing = toSetCodePage(NULL, c, (loadlangnew && dos.loaded_codepage != msgcodepage)?-1:0); + if((TTF_using() && isSupportedCP(c))|| !TTF_using()) int missing = toSetCodePage(NULL, c, loadlangnew?-1:-2); if (c == 950 && !chinasea) makestdcp950table(); if (c == 951 && chinasea) makeseacp951table(); lastmsgcp = c; @@ -409,7 +409,7 @@ void LoadMessageFile(const char * fname) { if (loadlangcp && msgcodepage>0) { if (!IS_DOSV && !IS_JEGA_ARCH) { if(!TTF_using() || (TTF_using() && isSupportedCP(msgcodepage))) { - toSetCodePage(NULL, msgcodepage, (loadlangnew && msgcodepage != dos.loaded_codepage)?-1:-2); + toSetCodePage(NULL, msgcodepage, loadlangnew?-1:-2); } DOSBox_SetSysMenu(); #if C_OPENGL && DOSBOXMENU_TYPE == DOSBOXMENU_SDLDRAW @@ -439,7 +439,7 @@ void SwitchLanguage(int oldcp, int newcp, bool confirm) { loadlangnew = true; lastmsgcp = newcp; control->opt_lang = langnew.c_str(); - Load_Language(langnew.c_str()); + //Load_Language(langnew.c_str()); } } } diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 9efd7e8fb4..a8ec4fff1b 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -749,7 +749,7 @@ void Load_Language(std::string name) { // if (!uselangcp && !incall) { // int oldmsgcp = msgcodepage; // msgcodepage = dos.loaded_codepage; - SetKEYBCP(); +// SetKEYBCP(); // msgcodepage = oldmsgcp; // } } diff --git a/src/output/output_ttf.cpp b/src/output/output_ttf.cpp index 110efdcf3e..c3a19b4cb6 100644 --- a/src/output/output_ttf.cpp +++ b/src/output/output_ttf.cpp @@ -529,12 +529,14 @@ int setTTFMap(bool changecp) { return notMapped; } +int oldcp = 0; int setTTFCodePage() { + int cp = dos.loaded_codepage; + if (cp && cp == oldcp) return 0; if (!copied) { memcpy(cpMap_copy,cpMap,sizeof(cpMap[0])*256); copied=true; } - int cp = dos.loaded_codepage; if (IS_PC98_ARCH) { static_assert(sizeof(cpMap[0])*256 >= sizeof(cpMap_PC98), "sizeof err 1"); static_assert(sizeof(cpMap[0]) == sizeof(cpMap_PC98[0]), "sizeof err 2"); @@ -543,7 +545,7 @@ int setTTFCodePage() { } if (cp) { - LOG_MSG("Loaded system codepage: %d\n", cp); + LOG_MSG("output_ttf: Loaded system codepage: %d\n", cp); int notMapped = setTTFMap(true); if (strcmp(RunningProgram, "LOADLIN") && !dos_kernel_disabled) initcodepagefont(); @@ -553,6 +555,7 @@ int setTTFCodePage() { if(IS_JEGA_ARCH) memcpy(cpMap,cpMap_AX,sizeof(cpMap[0])*32); if (cp == 932 && halfwidthkana) resetFontSize(); refreshExtChar(); + oldcp = cp; return notMapped; } else return -1; @@ -626,6 +629,7 @@ void OUTPUT_TTF_Select(int fsize) { change_output(switchoutput == -1 ? 0 : switchoutput); return; } + initttf = true; int fontSize = 0; int winPerc = 0; if (fsize==3) @@ -638,7 +642,6 @@ void OUTPUT_TTF_Select(int fsize) { const char * fbName = ttf_section->Get_string("fontbold"); const char * fiName = ttf_section->Get_string("fontital"); const char * fbiName = ttf_section->Get_string("fontboit"); - LOG_MSG("SDL: TTF activated %s", fName); force_conversion = true; int cp = dos.loaded_codepage; bool trysgf = false; @@ -646,6 +649,7 @@ void OUTPUT_TTF_Select(int fsize) { std::string mtype(static_cast(control->GetSection("dosbox"))->Get_string("machine")); if (IS_PC98_ARCH||mtype.substr(0, 4)=="pc98"||(!notrysgf&&InitCodePage()&&isDBCSCP())) trysgf = true; } + LOG_MSG("SDL: TTF activated %s", fName); force_conversion = false; dos.loaded_codepage = cp; if (trysgf) failName = "SarasaGothicFixed"; diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index 8c046a20c4..0ab8c1c9f2 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -4530,10 +4530,11 @@ void DOS_Shell::CMD_COUNTRY(char * args) { extern bool jfont_init, isDBCSCP(); extern Bitu DOS_LoadKeyboardLayout(const char * layoutname, int32_t codepage, const char * codepagefile); void runRescan(const char *str), MSG_Init(), JFONT_Init(), InitFontHandle(), ShutFontHandle(), initcodepagefont(), DOSBox_SetSysMenu(); +static int32_t lastsetcp = 0; int toSetCodePage(DOS_Shell *shell, int newCP, int opt) { + //if(dos.loaded_codepage == newCP) return 0; if ((TTF_using() && isSupportedCP(newCP))|| !TTF_using()){ if(!CheckDBCSCP(newCP)) DOS_ChangeCodepage(newCP, "auto"); - int32_t oldcp = dos.loaded_codepage; dos.loaded_codepage = newCP; int missing = 0; #if defined(USE_TTF) @@ -4541,6 +4542,7 @@ int toSetCodePage(DOS_Shell *shell, int newCP, int opt) { #endif if (!TTF_using()) initcodepagefont(); //if (dos.loaded_codepage==437 && DOS_GetLoadedLayout() == NULL) DOS_LoadKeyboardLayout("us", 437, "auto"); + //LOG_MSG("toSetCodePage opt=%d, loadlangnew=%d", opt, loadlangnew?1:0); if (opt==-1) { MSG_Init(); #if DOSBOXMENU_TYPE == DOSBOXMENU_HMENU @@ -4571,6 +4573,10 @@ int toSetCodePage(DOS_Shell *shell, int newCP, int opt) { } } #endif + if (newCP != lastsetcp) { + LOG_MSG("Codepage set to %d", newCP); + lastsetcp = newCP; + } return missing; } else if (opt<1 && shell) { shell->WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), std::to_string(newCP).c_str()); @@ -4652,16 +4658,6 @@ void DOS_Shell::CMD_CHCP(char * args) { } } #endif - else { - keyb_error = DOS_ChangeCodepage(newCP, "auto"); - if(keyb_error == KEYB_NOERROR) { - if(layout_name != NULL) { - keyb_error = DOS_ChangeKeyboardLayout(layout_name, cp); - } - } - else - WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), StripArg(args)); - } if(name.size() && dos.loaded_codepage == newCP) { SetVal("dosbox", "language", name); Load_Language(name);