toSetCodePage function switches codepages in non-TTF mode and in non-DBCS codepages

This commit is contained in:
maron2000 2024-10-05 10:35:34 +09:00
parent b55bb2a8b1
commit f3847d7df9

View File

@ -140,7 +140,9 @@ extern void MAPPER_AutoType(std::vector<std::string> &sequence, const uint32_t w
extern void DOS_SetCountry(uint16_t countryNo), DOSV_FillScreen(void); extern void DOS_SetCountry(uint16_t countryNo), DOSV_FillScreen(void);
std::string GetDOSBoxXPath(bool withexe=false); std::string GetDOSBoxXPath(bool withexe=false);
FILE *testLoadLangFile(const char *fname); FILE *testLoadLangFile(const char *fname);
Bitu DOS_ChangeCodepage(int32_t codepage, const char* codepagefile);
bool CheckDBCSCP(int32_t codepage); bool CheckDBCSCP(int32_t codepage);
static int32_t lastsetcp = 0;
/* support functions */ /* support functions */
static char empty_char = 0; static char empty_char = 0;
@ -4527,14 +4529,16 @@ extern bool jfont_init, isDBCSCP();
extern Bitu DOS_LoadKeyboardLayout(const char * layoutname, int32_t codepage, const char * codepagefile); 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(); void runRescan(const char *str), MSG_Init(), JFONT_Init(), InitFontHandle(), ShutFontHandle(), initcodepagefont(), DOSBox_SetSysMenu();
int toSetCodePage(DOS_Shell *shell, int newCP, int opt) { int toSetCodePage(DOS_Shell *shell, int newCP, int opt) {
if (isSupportedCP(newCP)) { if((TTF_using() && isSupportedCP(newCP)) || !TTF_using()) {
dos.loaded_codepage = newCP; if(!CheckDBCSCP(newCP)) DOS_ChangeCodepage(newCP, "auto");
dos.loaded_codepage = newCP;
int missing = 0; int missing = 0;
#if defined(USE_TTF) #if defined(USE_TTF)
missing = TTF_using() ? setTTFCodePage() : 0; missing = TTF_using() ? setTTFCodePage() : 0;
#endif #endif
if (!TTF_using()) initcodepagefont(); if (!TTF_using()) initcodepagefont();
if (dos.loaded_codepage==437) DOS_LoadKeyboardLayout("us", 437, "auto"); //if (dos.loaded_codepage==437) DOS_LoadKeyboardLayout("us", 437, "auto");
//LOG_MSG("toSetCodePage opt=%d, loadlangnew=%d", opt, loadlangnew?1:0);
if (opt==-1) { if (opt==-1) {
MSG_Init(); MSG_Init();
#if DOSBOXMENU_TYPE == DOSBOXMENU_HMENU #if DOSBOXMENU_TYPE == DOSBOXMENU_HMENU
@ -4550,8 +4554,8 @@ int toSetCodePage(DOS_Shell *shell, int newCP, int opt) {
ShutFontHandle(); ShutFontHandle();
InitFontHandle(); InitFontHandle();
JFONT_Init(); JFONT_Init();
SetupDBCSTable();
} }
SetupDBCSTable();
runRescan("-A -Q"); runRescan("-A -Q");
#if defined(USE_TTF) #if defined(USE_TTF)
if ((opt==-1||opt==-2)&&TTF_using()) { if ((opt==-1||opt==-2)&&TTF_using()) {
@ -4565,6 +4569,10 @@ int toSetCodePage(DOS_Shell *shell, int newCP, int opt) {
} }
} }
#endif #endif
if(newCP != lastsetcp) {
LOG_MSG("Codepage set to %d", newCP);
lastsetcp = newCP;
}
return missing; return missing;
} else if (opt<1 && shell) { } else if (opt<1 && shell) {
shell->WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), std::to_string(newCP).c_str()); shell->WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), std::to_string(newCP).c_str());