Skip to content

Commit

Permalink
test3
Browse files Browse the repository at this point in the history
  • Loading branch information
maron2000 committed Oct 1, 2024
1 parent 4a6fcf8 commit c657b0c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/dos/dos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/dos/dos_programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/menu_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/gui/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/sdl_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "?";
Expand All @@ -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,

Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions src/misc/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/misc/programs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ void Load_Language(std::string name) {
// if (!uselangcp && !incall) {
// int oldmsgcp = msgcodepage;
// msgcodepage = dos.loaded_codepage;
SetKEYBCP();
// SetKEYBCP();
// msgcodepage = oldmsgcp;
// }
}
Expand Down
10 changes: 7 additions & 3 deletions src/output/output_ttf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -638,14 +642,14 @@ 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;
if (!*fName) {
std::string mtype(static_cast<Section_prop *>(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";
Expand Down
18 changes: 7 additions & 11 deletions src/shell/shell_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4530,17 +4530,19 @@ 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)
missing = TTF_using() ? setTTFCodePage() : 0;
#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
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c657b0c

Please sign in to comment.