From df6c1d79523feab9863ec1741ff84039d4f474b5 Mon Sep 17 00:00:00 2001 From: Wengier Date: Sun, 25 Jul 2021 13:51:20 -0400 Subject: [PATCH] update CHCP and config ref etc --- CHANGELOG | 7 +-- .../com.dosbox_x.DOSBox-X.metainfo.xml.in | 2 +- contrib/translations/en/en_US.lng | 5 +- contrib/translations/es/es_ES.lng | 7 +-- contrib/translations/fr/fr_FR.lng | 7 +-- contrib/translations/ja/ja_JP.lng | 7 +-- contrib/translations/zh/zh_CN.lng | 5 +- contrib/translations/zh/zh_TW.lng | 5 +- .../installer/dosbox-x.reference.setup.conf | 8 +++- dosbox-x.reference.conf | 4 +- dosbox-x.reference.full.conf | 6 +++ include/build_timestamp.h | 4 +- src/dos/dos.cpp | 2 +- src/dos/drive_local.cpp | 8 +++- src/gui/sdlmain.cpp | 5 +- src/shell/shell.cpp | 2 +- src/shell/shell_cmds.cpp | 46 +++++++++++++++++-- 17 files changed, 96 insertions(+), 34 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 313db31e5..668fe8371 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -57,9 +57,10 @@ current logging text in debug builds. (Wengier) - Added config option "customcodepage" in the [dos] section to allow a custom code page, in the format - "customcodepage=nnn,codepagefile" for CHCP command - in TrueType font (TTF) output. Also added built-in - support for code pages 1250-1258. (Wengier) + "customcodepage=nnn,codepagefile" in TrueType font + (TTF) output. CHCP command also supports additional + parameter to specify a code page file. Also added + builtin support for code pages 1250-1258. (Wengier) - Added config option "transparency" in [sdl] section to change the DOSBox-X window transparency (from 0 to 90, low to high transparency) on the Linux/macOS diff --git a/contrib/linux/com.dosbox_x.DOSBox-X.metainfo.xml.in b/contrib/linux/com.dosbox_x.DOSBox-X.metainfo.xml.in index 49600e753..12fe715dd 100644 --- a/contrib/linux/com.dosbox_x.DOSBox-X.metainfo.xml.in +++ b/contrib/linux/com.dosbox_x.DOSBox-X.metainfo.xml.in @@ -10,7 +10,7 @@ Emulation - + diff --git a/contrib/translations/en/en_US.lng b/contrib/translations/en/en_US.lng index c0a8dad6b..a4529d441 100644 --- a/contrib/translations/en/en_US.lng +++ b/contrib/translations/en/en_US.lng @@ -2086,12 +2086,13 @@ Displays or changes the current DOS code page. . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [file]] nnn Specifies a code page number. + file Specifies a code page file. Supported code pages for changing in the TrueType font output: -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 Also double-byte code pages including 932, 936, 949, and 950. diff --git a/contrib/translations/es/es_ES.lng b/contrib/translations/es/es_ES.lng index 926aaa55d..e781d0ba1 100644 --- a/contrib/translations/es/es_ES.lng +++ b/contrib/translations/es/es_ES.lng @@ -2077,12 +2077,13 @@ Muestra o cambia el código de página DOS actual. . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [fichero]] - nnn Especifica un nº de código de página. + nnn Especifica un nº de código de página. + fichero Especifica un fichero de código de página. Códigos de página compatibles para la salida de fuente TrueType: -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 También páginas de códigos de doble byte incluyendo 932,936,949,950. diff --git a/contrib/translations/fr/fr_FR.lng b/contrib/translations/fr/fr_FR.lng index 71a8a4c67..a8c9842d9 100644 --- a/contrib/translations/fr/fr_FR.lng +++ b/contrib/translations/fr/fr_FR.lng @@ -2071,12 +2071,13 @@ Affiche ou modifie la page de code DOS actuelle. . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [fichier]] - nnn Spécifie un numéro de page de code. + nnn Spécifie un numéro de page de code. + fichier Spécifie un fichier de page de code. Pages de code prises en charge pour être modifiées dans la sortie de la police TrueType : -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 Également des pages de code à double octet, notamment 932, 936, 949 et 950. . diff --git a/contrib/translations/ja/ja_JP.lng b/contrib/translations/ja/ja_JP.lng index 45640534b..a229d2c5d 100644 --- a/contrib/translations/ja/ja_JP.lng +++ b/contrib/translations/ja/ja_JP.lng @@ -2048,12 +2048,13 @@ ALIAS [name[=value] ... ] . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [file]] - nnn コードページ番号を指定します。 + nnn コードページ番号を指定します。 + [file] コードページファイルを指定します。 TrueType フォント出力への変更をサポートするコードページ: -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 932, 936, 949, 950 等の2バイト言語のコードページもサポートします。 diff --git a/contrib/translations/zh/zh_CN.lng b/contrib/translations/zh/zh_CN.lng index eebabc5af..d3e7385d1 100644 --- a/contrib/translations/zh/zh_CN.lng +++ b/contrib/translations/zh/zh_CN.lng @@ -2023,12 +2023,13 @@ ALIAS [名称[=值] ... ] . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [文件]] nnn 指定代码页. + 文件 指定代码页文件. TTF 输出方式所支持的代码页包括: -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 以及双字节代码页,包括: 932, 936, 949, 950 diff --git a/contrib/translations/zh/zh_TW.lng b/contrib/translations/zh/zh_TW.lng index a3d2bc968..d6d1249bf 100644 --- a/contrib/translations/zh/zh_TW.lng +++ b/contrib/translations/zh/zh_TW.lng @@ -2023,12 +2023,13 @@ ALIAS [名稱[=值] ... ] . :SHELL_CMD_CHCP_HELP_LONG -CHCP [nnn] +CHCP [nnn [檔案]] nnn 指定字碼頁. + 檔案 指定字碼頁檔案. TTF 輸出方式所支援的字碼頁包括: -437,808,850,852,853,855,857,858,860,861,862,863,864,865,866,869,872,874 +437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258 以及雙位元組字碼頁,包括: 932, 936, 949, 950 diff --git a/contrib/windows/installer/dosbox-x.reference.setup.conf b/contrib/windows/installer/dosbox-x.reference.setup.conf index eb6288ef3..92fd8086d 100644 --- a/contrib/windows/installer/dosbox-x.reference.setup.conf +++ b/contrib/windows/installer/dosbox-x.reference.setup.conf @@ -728,6 +728,8 @@ fepcontrol = both # use triple buffering and thus won't flicker. # # vmemsizekb: Amount of video memory in kilobytes, in addition to vmemsize. +#DOSBOX-X-ADV:# vbe window granularity: Controls VESA BIOS non-linear framebuffer window granularity in KB. This affects ONLY the VESA BIOS extensions. Set 0 to functional normally. +#DOSBOX-X-ADV:# vbe window size: Controls VESA BIOS non-linear framebuffer window size in KB. This affects ONLY the VESA BIOS extensions. Set 0 to functional normally. #DOSBOX-X-ADV:# enable 8-bit dac: If set, allow VESA BIOS calls in IBM PC mode to set DAC width. Has no effect in PC-98 mode. # high intensity blinking: Set to false if you want to see high-intensity background colors instead of blinking foreground text. # This option has no effect in PC-98 and some other video modes. @@ -892,11 +894,13 @@ fepcontrol = both #DOSBOX-X-ADV:# This option forces VGA emulation to ignore odd/even mode except in text and CGA modes. #DOSBOX-X-ADV-SEE:# #DOSBOX-X-ADV-SEE:# Advanced options (see full configuration reference file [dosbox-x.reference.full.conf] for more details): -#DOSBOX-X-ADV-SEE:# -> vmemdelay; enable 8-bit dac; svga lfb base; pci vga; vga attribute controller mapping; vga bios use rom image; vga bios rom image; vga bios size override; video bios dont duplicate cga first half rom font; video bios always offer 14-pixel high rom font; video bios always offer 16-pixel high rom font; video bios enable cga second half rom font; forcerate; sierra ramdac; sierra ramdac lock 565; page flip debug line; vertical retrace poll debug line; cgasnow; vga 3da undefined bits; rom bios 8x8 CGA font; rom bios video parameter table; int 10h points at vga bios; unmask timer on int 10 setmode; vesa bank switching window mirroring; vesa bank switching window range check; vesa zero buffer on get information; vesa set display vsync; vesa lfb base scanline adjust; vesa map non-lfb modes to 128kb region; ega per scanline hpel; allow hpel effects; allow hretrace effects; hretrace effect weight; vesa modelist cap; vesa modelist width limit; vesa modelist height limit; vesa vbe put modelist in vesa information; vesa vbe 1.2 modes are 32bpp; allow low resolution vesa modes; allow explicit 24bpp vesa modes; allow high definition vesa modes; allow unusual vesa modes; allow 32bpp vesa modes; allow 24bpp vesa modes; allow 16bpp vesa modes; allow 15bpp vesa modes; allow 8bpp vesa modes; allow 4bpp vesa modes; allow 4bpp packed vesa modes; allow tty vesa modes; double-buffered line compare; ignore vblank wraparound; ignore extended memory bit; enable vga resize delay; resize only on vga active display width increase; vga palette update on full load; ignore odd-even mode in non-cga modes +#DOSBOX-X-ADV-SEE:# -> vmemdelay; vbe window granularity; vbe window size; enable 8-bit dac; svga lfb base; pci vga; vga attribute controller mapping; vga bios use rom image; vga bios rom image; vga bios size override; video bios dont duplicate cga first half rom font; video bios always offer 14-pixel high rom font; video bios always offer 16-pixel high rom font; video bios enable cga second half rom font; forcerate; sierra ramdac; sierra ramdac lock 565; page flip debug line; vertical retrace poll debug line; cgasnow; vga 3da undefined bits; rom bios 8x8 CGA font; rom bios video parameter table; int 10h points at vga bios; unmask timer on int 10 setmode; vesa bank switching window mirroring; vesa bank switching window range check; vesa zero buffer on get information; vesa set display vsync; vesa lfb base scanline adjust; vesa map non-lfb modes to 128kb region; ega per scanline hpel; allow hpel effects; allow hretrace effects; hretrace effect weight; vesa modelist cap; vesa modelist width limit; vesa modelist height limit; vesa vbe put modelist in vesa information; vesa vbe 1.2 modes are 32bpp; allow low resolution vesa modes; allow explicit 24bpp vesa modes; allow high definition vesa modes; allow unusual vesa modes; allow 32bpp vesa modes; allow 24bpp vesa modes; allow 16bpp vesa modes; allow 15bpp vesa modes; allow 8bpp vesa modes; allow 4bpp vesa modes; allow 4bpp packed vesa modes; allow tty vesa modes; double-buffered line compare; ignore vblank wraparound; ignore extended memory bit; enable vga resize delay; resize only on vga active display width increase; vga palette update on full load; ignore odd-even mode in non-cga modes #DOSBOX-X-ADV-SEE:# #DOSBOX-X-ADV:vmemdelay = 0 vmemsize = -1 vmemsizekb = 0 +#DOSBOX-X-ADV:vbe window granularity = 0 +#DOSBOX-X-ADV:vbe window size = 0 #DOSBOX-X-ADV:enable 8-bit dac = true high intensity blinking = true #DOSBOX-X-ADV:svga lfb base = 0 @@ -2107,6 +2111,7 @@ timeout = 0 #DOSBOX-X-ADV:# int15 mouse callback does not preserve registers: Set to true if the guest OS or DOS program assigns an INT 15h mouse callback, #DOSBOX-X-ADV:# but does not properly preserve CPU registers. Diagnostic function only (default off). # keyboardlayout: Language code of the keyboard layout (or none). +# customcodepage: Set a custom code page for CHCP command and specify a SBCS code page file. # dbcs: Enable DBCS table and Chinese, Japanese, Korean support for the TrueType font (TTF) output. # CAUTION: Some software will crash without the DBCS table, including the Open Watcom installer. #DOSBOX-X-ADV:# filenamechar: Enable filename char table @@ -2198,6 +2203,7 @@ int33 = true #DOSBOX-X-ADV:int15 wait force unmask irq = true #DOSBOX-X-ADV:int15 mouse callback does not preserve registers = false keyboardlayout = auto +customcodepage = dbcs = true #DOSBOX-X-ADV:filenamechar = true #DOSBOX-X-ADV:collating and uppercase = true diff --git a/dosbox-x.reference.conf b/dosbox-x.reference.conf index 44a1d95cf..7880604d8 100644 --- a/dosbox-x.reference.conf +++ b/dosbox-x.reference.conf @@ -349,7 +349,7 @@ fepcontrol = both # This option has no effect in PC-98 and some other video modes. # # Advanced options (see full configuration reference file [dosbox-x.reference.full.conf] for more details): -# -> vmemdelay; enable 8-bit dac; svga lfb base; pci vga; vga attribute controller mapping; vga bios use rom image; vga bios rom image; vga bios size override; video bios dont duplicate cga first half rom font; video bios always offer 14-pixel high rom font; video bios always offer 16-pixel high rom font; video bios enable cga second half rom font; forcerate; sierra ramdac; sierra ramdac lock 565; page flip debug line; vertical retrace poll debug line; cgasnow; vga 3da undefined bits; rom bios 8x8 CGA font; rom bios video parameter table; int 10h points at vga bios; unmask timer on int 10 setmode; vesa bank switching window mirroring; vesa bank switching window range check; vesa zero buffer on get information; vesa set display vsync; vesa lfb base scanline adjust; vesa map non-lfb modes to 128kb region; ega per scanline hpel; allow hpel effects; allow hretrace effects; hretrace effect weight; vesa modelist cap; vesa modelist width limit; vesa modelist height limit; vesa vbe put modelist in vesa information; vesa vbe 1.2 modes are 32bpp; allow low resolution vesa modes; allow explicit 24bpp vesa modes; allow high definition vesa modes; allow unusual vesa modes; allow 32bpp vesa modes; allow 24bpp vesa modes; allow 16bpp vesa modes; allow 15bpp vesa modes; allow 8bpp vesa modes; allow 4bpp vesa modes; allow 4bpp packed vesa modes; allow tty vesa modes; double-buffered line compare; ignore vblank wraparound; ignore extended memory bit; enable vga resize delay; resize only on vga active display width increase; vga palette update on full load; ignore odd-even mode in non-cga modes +# -> vmemdelay; vbe window granularity; vbe window size; enable 8-bit dac; svga lfb base; pci vga; vga attribute controller mapping; vga bios use rom image; vga bios rom image; vga bios size override; video bios dont duplicate cga first half rom font; video bios always offer 14-pixel high rom font; video bios always offer 16-pixel high rom font; video bios enable cga second half rom font; forcerate; sierra ramdac; sierra ramdac lock 565; page flip debug line; vertical retrace poll debug line; cgasnow; vga 3da undefined bits; rom bios 8x8 CGA font; rom bios video parameter table; int 10h points at vga bios; unmask timer on int 10 setmode; vesa bank switching window mirroring; vesa bank switching window range check; vesa zero buffer on get information; vesa set display vsync; vesa lfb base scanline adjust; vesa map non-lfb modes to 128kb region; ega per scanline hpel; allow hpel effects; allow hretrace effects; hretrace effect weight; vesa modelist cap; vesa modelist width limit; vesa modelist height limit; vesa vbe put modelist in vesa information; vesa vbe 1.2 modes are 32bpp; allow low resolution vesa modes; allow explicit 24bpp vesa modes; allow high definition vesa modes; allow unusual vesa modes; allow 32bpp vesa modes; allow 24bpp vesa modes; allow 16bpp vesa modes; allow 15bpp vesa modes; allow 8bpp vesa modes; allow 4bpp vesa modes; allow 4bpp packed vesa modes; allow tty vesa modes; double-buffered line compare; ignore vblank wraparound; ignore extended memory bit; enable vga resize delay; resize only on vga active display width increase; vga palette update on full load; ignore odd-even mode in non-cga modes # vmemsize = -1 vmemsizekb = 0 @@ -982,6 +982,7 @@ timeout = 0 # startquiet: If set, before launching host system applications to run on the host DOSBox-X will not show messages like "Now run it as a Windows application". # int33: Enable INT 33H for mouse support. # keyboardlayout: Language code of the keyboard layout (or none). +# customcodepage: Set a custom code page for CHCP command and specify a SBCS code page file. # dbcs: Enable DBCS table and Chinese, Japanese, Korean support for the TrueType font (TTF) output. # CAUTION: Some software will crash without the DBCS table, including the Open Watcom installer. # dos clipboard device enable: If enabled, a DOS device will be added for bidirectional communications with the shared clipboard. @@ -1022,6 +1023,7 @@ startwait = true startquiet = false int33 = true keyboardlayout = auto +customcodepage = dbcs = true dos clipboard device enable = false dos clipboard device name = CLIP$ diff --git a/dosbox-x.reference.full.conf b/dosbox-x.reference.full.conf index 6e3d64620..cd8c20d5d 100644 --- a/dosbox-x.reference.full.conf +++ b/dosbox-x.reference.full.conf @@ -704,6 +704,8 @@ vtext2 = xga # use triple buffering and thus won't flicker. # # vmemsizekb: Amount of video memory in kilobytes, in addition to vmemsize. +# vbe window granularity: Controls VESA BIOS non-linear framebuffer window granularity in KB. This affects ONLY the VESA BIOS extensions. Set 0 to functional normally. +# vbe window size: Controls VESA BIOS non-linear framebuffer window size in KB. This affects ONLY the VESA BIOS extensions. Set 0 to functional normally. # enable 8-bit dac: If set, allow VESA BIOS calls in IBM PC mode to set DAC width. Has no effect in PC-98 mode. # high intensity blinking: Set to false if you want to see high-intensity background colors instead of blinking foreground text. # This option has no effect in PC-98 and some other video modes. @@ -869,6 +871,8 @@ vtext2 = xga vmemdelay = 0 vmemsize = -1 vmemsizekb = 0 +vbe window granularity = 0 +vbe window size = 0 enable 8-bit dac = true high intensity blinking = true svga lfb base = 0 @@ -2051,6 +2055,7 @@ timeout = 0 # int15 mouse callback does not preserve registers: Set to true if the guest OS or DOS program assigns an INT 15h mouse callback, # but does not properly preserve CPU registers. Diagnostic function only (default off). # keyboardlayout: Language code of the keyboard layout (or none). +# customcodepage: Set a custom code page for CHCP command and specify a SBCS code page file. # dbcs: Enable DBCS table and Chinese, Japanese, Korean support for the TrueType font (TTF) output. # CAUTION: Some software will crash without the DBCS table, including the Open Watcom installer. # filenamechar: Enable filename char table @@ -2138,6 +2143,7 @@ biosps2 = true int15 wait force unmask irq = true int15 mouse callback does not preserve registers = false keyboardlayout = auto +customcodepage = dbcs = true filenamechar = true collating and uppercase = true diff --git a/include/build_timestamp.h b/include/build_timestamp.h index 9068450ca..4d7846374 100644 --- a/include/build_timestamp.h +++ b/include/build_timestamp.h @@ -1,4 +1,4 @@ /*auto-generated*/ -#define UPDATED_STR "Jul 20, 2021 5:48:33am" -#define GIT_COMMIT_HASH "6354445" +#define UPDATED_STR "Jul 25, 2021 1:22:57pm" +#define GIT_COMMIT_HASH "6956f4e" #define COPYRIGHT_END_YEAR "2021" diff --git a/src/dos/dos.cpp b/src/dos/dos.cpp index 471b4d57c..d7313f748 100644 --- a/src/dos/dos.cpp +++ b/src/dos/dos.cpp @@ -65,7 +65,7 @@ extern bool log_int21, log_fileio; extern bool sync_time, manualtime; extern int lfn_filefind_handle, autofixwarn; extern uint16_t customcp_to_unicode[256]; -int customcp; +int customcp = 0, altcp = 0; unsigned long totalc, freec; uint16_t countryNo = 0; Bitu INT29_HANDLER(void); diff --git a/src/dos/drive_local.cpp b/src/dos/drive_local.cpp index 7d95d3c1b..d9d9d94ac 100644 --- a/src/dos/drive_local.cpp +++ b/src/dos/drive_local.cpp @@ -143,9 +143,9 @@ static std::string ldir[256]; static std::string hostname = ""; extern bool rsize, morelen, force_sfn, enable_share_exe; extern bool isDBCSCP(), isKanji1(uint8_t chr), shiftjis_lead_byte(int c); -extern int lfn_filefind_handle, freesizecap, file_access_tries, customcp; +extern int lfn_filefind_handle, freesizecap, file_access_tries, customcp, altcp; extern unsigned long totalc, freec; -uint16_t customcp_to_unicode[256]; +uint16_t customcp_to_unicode[256], altcp_to_unicode[256]; bool String_ASCII_TO_HOST_UTF16(uint16_t *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) { const uint16_t* df = d + CROSS_LEN - 1; @@ -472,6 +472,7 @@ bool String_HOST_TO_ASCII_UTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) bool cpwarn_once = false; bool CodePageHostToGuestUTF16(char *d/*CROSS_LEN*/,const uint16_t *s/*CROSS_LEN*/) { + if (altcp && dos.loaded_codepage == altcp) return String_HOST_TO_SBCS_UTF16(d,s,altcp_to_unicode,sizeof(altcp_to_unicode)/sizeof(altcp_to_unicode[0])); if (customcp && dos.loaded_codepage == customcp) return String_HOST_TO_SBCS_UTF16(d,s,customcp_to_unicode,sizeof(customcp_to_unicode)/sizeof(customcp_to_unicode[0])); switch (dos.loaded_codepage) { case 437: @@ -549,6 +550,7 @@ bool CodePageHostToGuestUTF16(char *d/*CROSS_LEN*/,const uint16_t *s/*CROSS_LEN* } bool CodePageHostToGuestUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) { + if (altcp && dos.loaded_codepage == altcp) return String_HOST_TO_SBCS_UTF8(d,s,altcp_to_unicode,sizeof(altcp_to_unicode)/sizeof(altcp_to_unicode[0])); if (customcp && dos.loaded_codepage == customcp) return String_HOST_TO_SBCS_UTF8(d,s,customcp_to_unicode,sizeof(customcp_to_unicode)/sizeof(customcp_to_unicode[0])); switch (dos.loaded_codepage) { case 437: @@ -626,6 +628,7 @@ bool CodePageHostToGuestUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) { } bool CodePageGuestToHostUTF16(uint16_t *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) { + if (altcp && dos.loaded_codepage == altcp) return String_SBCS_TO_HOST_UTF16(d,s,altcp_to_unicode,sizeof(altcp_to_unicode)/sizeof(altcp_to_unicode[0])); if (customcp && dos.loaded_codepage == customcp) return String_SBCS_TO_HOST_UTF16(d,s,customcp_to_unicode,sizeof(customcp_to_unicode)/sizeof(customcp_to_unicode[0])); switch (dos.loaded_codepage) { case 437: @@ -703,6 +706,7 @@ bool CodePageGuestToHostUTF16(uint16_t *d/*CROSS_LEN*/,const char *s/*CROSS_LEN* } bool CodePageGuestToHostUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/) { + if (altcp && dos.loaded_codepage == altcp) return String_SBCS_TO_HOST_UTF8(d,s,altcp_to_unicode,sizeof(altcp_to_unicode)/sizeof(altcp_to_unicode[0])); if (customcp && dos.loaded_codepage == customcp) return String_SBCS_TO_HOST_UTF8(d,s,customcp_to_unicode,sizeof(customcp_to_unicode)/sizeof(customcp_to_unicode[0])); switch (dos.loaded_codepage) { case 437: diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 204386bdc..29b693138 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -52,8 +52,9 @@ int switchoutput=-1; int selsrow = -1, selscol = -1; int selerow = -1, selecol = -1; bool selmark = false; +extern int enablelfn; extern int autosave_second; -extern int enablelfn, customcp; +extern int customcp, altcp; extern bool swapad; extern bool blinking; extern bool dpi_aware_enable; @@ -5243,7 +5244,7 @@ int setTTFCodePage() { } uint16_t unimap; int notMapped = 0; - for (int y = (customcp&&dos.loaded_codepage==customcp?0:8); y < 16; y++) + for (int y = (customcp&&dos.loaded_codepage==customcp||altcp&&dos.loaded_codepage==altcp?0:8); y < 16; y++) for (int x = 0; x < 16; x++) { unimap = wcTest[y*16+x]; if (!TTF_GlyphIsProvided(ttf.SDL_font, unimap)) { diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index ce151ad6f..14c532f9d 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -1498,7 +1498,7 @@ void SHELL_Init() { MSG_Add("SHELL_CMD_ALIAS_HELP", "Defines or displays aliases.\n"); MSG_Add("SHELL_CMD_ALIAS_HELP_LONG", "ALIAS [name[=value] ... ]\n\nType ALIAS without parameters to display the list of aliases in the form:\n`ALIAS NAME = VALUE'\n"); MSG_Add("SHELL_CMD_CHCP_HELP", "Displays or changes the current DOS code page.\n"); - MSG_Add("SHELL_CMD_CHCP_HELP_LONG", "CHCP [nnn]\n\n nnn Specifies a code page number.\n\nSupported code pages for changing in the TrueType font output:\n437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258\n\nAlso double-byte code pages including 932, 936, 949, and 950.\n"); + MSG_Add("SHELL_CMD_CHCP_HELP_LONG", "CHCP [nnn [file]]\n\n nnn Specifies a code page number.\n file Specifies a code page file.\n\nSupported code pages for changing in the TrueType font output:\n437,808,850,852,853,855,857,858,860-866,869,872,874,1250-1258\n\nAlso double-byte code pages including 932, 936, 949, and 950.\n"); MSG_Add("SHELL_CMD_CHCP_ACTIVE", "Active code page: %d\n"); MSG_Add("SHELL_CMD_CHCP_MISSING", "Characters not defined in TTF font: %d\n"); MSG_Add("SHELL_CMD_CHCP_INVALID", "Invalid code page number - %s\n"); diff --git a/src/shell/shell_cmds.cpp b/src/shell/shell_cmds.cpp index ef1ae8692..682d9ff6a 100644 --- a/src/shell/shell_cmds.cpp +++ b/src/shell/shell_cmds.cpp @@ -114,14 +114,16 @@ SHELL_Cmd cmd_list[]={ {0,0,0,0} }; -extern int enablelfn, lfn_filefind_handle, file_access_tries, customcp; +extern int enablelfn, lfn_filefind_handle, file_access_tries, customcp, altcp; extern bool date_host_forced, usecon, rsize, sync_time, manualtime, inshell; extern unsigned long freec; -extern uint16_t countryNo; +extern uint16_t countryNo, altcp_to_unicode[256]; void GetExpandedPath(std::string &path); bool Network_IsNetworkResource(const char * filename); void DOS_SetCountry(uint16_t countryNo), DOSV_FillScreen(); extern bool isDBCSCP(), isKanji1(uint8_t chr), shiftjis_lead_byte(int c); +void ResolvePath(std::string& in); +std::string GetDOSBoxXPath(bool withexe=false); /* support functions */ static char empty_char = 0; @@ -4057,7 +4059,7 @@ void DOS_Shell::CMD_COUNTRY(char * args) { } bool isSupportedCP(int newCP) { - return newCP == 437 || newCP == 808 || newCP == 850 || newCP == 852 || newCP == 853 || newCP == 855 || newCP == 857 || newCP == 858 || (newCP >= 860 && newCP <= 866) || newCP == 869 || newCP == 872 || newCP == 874 || newCP == 932 || newCP == 936 || newCP == 949 || newCP == 950 || (newCP >= 1250 && newCP <= 1258 || (customcp > 0 && newCP == customcp)); + return newCP == 437 || newCP == 808 || newCP == 850 || newCP == 852 || newCP == 853 || newCP == 855 || newCP == 857 || newCP == 858 || (newCP >= 860 && newCP <= 866) || newCP == 869 || newCP == 872 || newCP == 874 || newCP == 932 || newCP == 936 || newCP == 949 || newCP == 950 || (newCP >= 1250 && newCP <= 1258 || (customcp > 0 && newCP == customcp) || (altcp > 0 && newCP == altcp)); } #if defined(USE_TTF) @@ -4104,8 +4106,42 @@ void DOS_Shell::CMD_CHCP(char * args) { } #if defined(USE_TTF) int newCP; - char buff[256]; - if (sscanf(args, "%d%s", &newCP, buff) == 1) toSetCodePage(this, newCP, -1); + char buff[256], *r; + int n = sscanf(args, "%d%s", &newCP, buff); + if (n == 1) toSetCodePage(this, newCP, -1); + else if (n == 2 && strlen(buff)) { + altcp = 0; + for (int i=0; i<256; i++) altcp_to_unicode[i] = 0; + std::string cpfile = buff; + ResolvePath(cpfile); + FILE* file = fopen(cpfile.c_str(), "r"); /* should check the result */ + std::string exepath = GetDOSBoxXPath(); + if (!file && exepath.size()) file = fopen((exepath+CROSS_FILESPLIT+cpfile).c_str(), "r"); + if (file && newCP > 0 && newCP != 932 && newCP != 936 && newCP != 949 && newCP != 950) { + altcp = newCP; + char line[256], *l=line; + while (fgets(line, sizeof(line), file)) { + l=trim(l); + if (!strlen(l)) continue; + r = strchr(l, '#'); + if (r) *r = 0; + l=trim(l); + if (!strlen(l)||strncasecmp(l, "0x", 2)) continue; + r = strchr(l, ' '); + if (!r) r = strchr(l, '\t'); + if (!r) continue; + *r = 0; + int ind = (int)strtol(l+2, NULL, 16); + r = trim(r+1); + if (ind>0xFF||strncasecmp(r, "0x", 2)) continue; + int map = (int)strtol(r+2, NULL, 16); + altcp_to_unicode[ind] = map; + } + toSetCodePage(this, newCP, -1); + } else + WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), StripArg(args)); + if (file) fclose(file); + } else WriteOut(MSG_Get("SHELL_CMD_CHCP_INVALID"), StripArg(args)); #endif return;