China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-25 07:39
中国DOS联盟论坛 » DOS汉化世界 & 中文系统 (中文化室) » [Repost] Making a Graphical Prompt Interface in Text Mode View 1,854 Replies 5
Original Poster Posted 2006-01-10 22:34 ·  中国 山西 运城 中移铁通
元老会员
★★★★
Batchinger
Credits 4,432
Posts 1,512
Joined 2002-10-18 00:00
23-year member
UID 19
Gender Male
Status Offline
### Title: Making a Graphical Prompt Interface in Text Mode
Transferred from: Randomly selected Baidu search results
Author: Liu Wenguang, Dong Chunping

In commercial software, there are a large number of prompt information interfaces to make users aware of the status and operation of the software. Using Chinese character prompts can greatly facilitate users who do not understand Western prompts. However, if a small number of Chinese character prompts are implemented in graphical mode, it will complicate the program design, and the graphical mode is much slower to implement than the text mode. This article uses the principle of Chinese character display in EGA text mode to design and make a cover prompt message of a microcomputer resident alarm system, which prompts information such as the maker, copyright, and company logo, and realizes a colorful prompt interface for Chinese characters, graphics, and characters. The following discusses the specific methods and principles of implementation.

### I. Extraction of Chinese Character Glyph Data
Chinese character display in text mode is achieved by rewriting Western character glyphs with Chinese character glyphs, so the Chinese character glyph data should be obtained first.

Various Chinese character operating systems can provide Chinese character glyphs of different sizes and fonts. As an example, this article obtains 16×16 dot matrix data of the desired regular script Chinese character glyphs from the font library of cclibj.dot in Kingsoft DOS.

The reading of the font library is implemented in C language. The specific method is as follows.

(1) Assign the Chinese character to be displayed as a string treated the same as characters to a memory variable f. The value of the Chinese character string is input under the N command in WPS, and then transferred to C language for programming.

(2) In the C language environment, the value of the Chinese character string is the GB code. The reading of the glyphs is to use the GB code of the Chinese character to be displayed to calculate the position of the corresponding glyph in the font library, and then read 32 bytes of glyph data from the font library into the memory buffer buf.

There is the following correspondence between the GB code of the Chinese character string in C language and a character record in the cclibj.dot font library: C1 and C2 are integer auxiliary variables, ihi and ilo represent the high two digits and low two digits of the GB code respectively. l is a long integer used for glyph search positioning.

C1 = (i - 0xa0) + 94

C2 = i - 0xa0 + c1 - 659

l = C2 * 32L

Using the function:

lseek(fp, l, seek-set); read (fp, buf, 32); find the start position of the glyphs and read 32 bytes of glyph data into the memory buffer buf.

(3) Use the hexadecimal output format of the output function to output and record the content of the buffer buf. The obtained glyph data of "Tian Jiao" in this example is as follows:

Tian: 087ffc 1 010 1014fffe 10 280 280440 4 40820 101020 e o4

Jiao: 8cfdfo 8 2048 204bfe 48 5048 887e8c4 8 81c 88e48844 88 148898 2 8

The implementation program is in Appendix Program 1.

### II. Design of Graphical Glyphs
Since there is no unified standard for graphics, the glyph data for displaying graphics is designed manually. The graphic in this example is the company logo, which is represented by 11 8×16 Western character dot matrices. The glyph data represented by 11 Western character dot matrices is in the row1-graph, row2-graph, row3-graph in the program, which respectively represent the glyph data of the first row, second row, and third row in Figure 1.

@@T5S08500.GIF; Figure 1@@

### III. Writing of Glyph and Graphic Data
1. Modifiable Glyph Table The display memory equipped with EGA is divided into 4 independent sections, called 4 pages. In text mode, pages 0 and 1 store the ASCII codes and attribute bytes of screen characters, while page 2 is used to store the glyph table. The glyph table of EGA was originally stored in ROM, but when initializing the text mode each time, the BIOS of EGA will copy the glyph table to page 2 of the display memory. Since the glyph table has been moved to RAM, the user program can access and modify the glyphs.

2. Structure of Glyph Table The character width of EGA is fixed at 8 pixels, and the character height can be取值 from 1 to 32. The glyph table is stored in blocks according to different character sets, and within each character set, it is arranged in ascending order of the ASCII code values of the characters. Each character occupies 32B, corresponding to 32 scan lines of the glyph from top to bottom. However, not all scan lines are used, and some of them are used depending on the display mode.

Therefore, a 16×16 dot matrix Chinese character glyph occupies 2 Western characters, and the graphic implementation occupies several Western characters depending on the situation.

3. Loading of Glyphs The writing of glyph and graphic data can be implemented through BIOS INT 10H sub-function 11h.

Input parameters: AH = 11H

AL = 0

ES: BP = address of glyph data

CX = number of characters to load (1-256)

DX = starting character (0-255)

BL = character set number (0-3)

BH = character height (1-32)

Among them, the glyph data address is the starting address of the glyph data area in the program. And the starting character is the position where the glyph data is written to the display buffer.

### IV. Color Display of Chinese Characters and Graphics
1. Display Principle of Western Characters When outputting text, page 0 stores the ASCII code values of the characters to be output, and page 1 stores the character attributes. The ASCII code value in page 0 is indexed to the character generator in page 2, and combined with the attributes in page 1, the corresponding character can be displayed on the screen, as shown in Figure 2 @@T5S08501.GIF; Figure 2@@ 2. Display of Chinese Characters and Graphics Using the display principle of Western characters, the Western characters that should be displayed before the glyphs are modified are displayed as the modified Chinese character glyphs or graphic glyphs, and Chinese characters or graphics are displayed by using several modified Western character glyphs.

3. Display Output The sub-function 13H of BIOS INT10 completes the output of characters.

Input parameters: AH = 13H

AL = 1

BL = character attribute

CX = number of characters to display

DH = row number of characters to display

DL = column number of characters to display

ES: BP = starting address of the display string

Among them, the starting character of the display string can be arbitrarily taken within the ASCII code space of page 0, and the character attribute can set the display color. The implementation program is in Program 2.

Program 1

#include "stdio.h"
#include "fcntl.h"
unsigned char *f = "天骄";
int fp;
main()
{
unsigned int i, c1, c2, t = 0;
int i1, i2, i3;
long L;
unsigned char buf;
fp = open("g:\wps\cclibj.dot", O - RDWR | O - BINARY);
if (fp == - 1)
{
cputs("error on open cclib !");
exit(0);
}
while ((i = *f++) != 0)
{
if (i > 0xa0)
if (t == 0)
{
c1 = (i - 0xa0) *94;
t++;
}
else
{
c2 = i - 0xa0 + c1 - 659;
t = 0;
l = c2 * 32L;
lseek(fp, l, SEEK - SET);
read(fp, buf, 32);
printf("hex code:\n");
for (i = 0; i < 32; i++)
if (i == 16)
{
printf("%\n", buf);
}
else
printf("%x", buf);
printf("\n");
getch();
};
}
}


Program 2

cseg segment para public'code'
assume cs:cseg
org 100h
main proc near
start: mov ax, cseg
mov es,ax
mov ax,0003h
int 10h
mov ax,1100h
mov bh,16
mov bl,0
mov cx,3
mov dx,130
lea bp,row1-grahh
int 10h
mov cx,4
mov dx,133
lea bp,row2-graph
int 10h
mov cx,5
mov dx,137
lea bp,row3-graph
int 10h
mov cx,2
mov dx,142
lea bp,tian
int 10h
mvo cx,2
mov dx,144
lea bp,jiao
int 10h
mov ax,1103h
mov bl,00000000b
int 10h
mov ax,1301h
mov bh,0
mov bl,01h
mov dl,2
mov dh,1
mov cx,1
lop: lea bp,hd
int 10h
inc dl
cmp dl,24
jnz lop
mov dl,2
inc dh
cmp dh,7
jnz lop
mov bl,17h
mov cx,3
mov dh,2
mov dl,12
lea bp,str1
int 10h
mov cx,4
mov dh,3
mov dl,12
lea bp,str2
int 10h
mov cx,5
mov dh,4
mov dl,10
lea bp,str3
int 10h
mov cx,2
mov dh,3
mov dl,4
lea bp,ws1
int 10h
mov cx,2
mov dh,3
mov dl,20
lea bp,ws2
int 10h
mov ax,0003h
int 10h
main endp
row1-graph db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,01h
db 00h,00h,00h,04h,04h,0ch,00h,00h,00h,38h,3eh,71h,00h,00h,00h,0f0h
db 00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,00h,0c0h,70h,38h,1ch,0eh
row2-graph db 01h,03h,00h,00h,00h,07h,0fh,0fh,00h,00h,00h,3fh,7fh,7fh,00h,00h
db 0f0h,0f0h,00h,00h,00h,0f0h,0f0h,0e0h,00h,00h,00h,0e0h,0e0h,0c0h,00h,00h
db 0eh,0fh,0fh,07h,07h,03h,03h,03h,07h,07h,0fh,0fh,1fh,1fh,3fh,3fh
db 00h,00h,00h,00h,80h,80h,80h,80h,0c0h,0c0h,0c0h,0c0h,0c0h,80h,80h,80h
row3-graph db 00h,00h,00h,00h,00h,00h,00h,01h,01h,03h,00h,00h,00h,00h,00h,00h
db 00h,7fh,7fh,0ffh,00h,00h,00h,0ffh,0ffh,0ffh,00h,00h,00h,00h,00h,00h
db 00h,0ffh,0ffh,0ffh,00h,00h,00h,0ffh,0ffh,0ffh,00h,00h,00h,00h,00h,00h
db 00h,0c3h,0ffh,09fh,0fh,0fh,07h,83h,81h,01h,00h,00h,00h,00h,00h,00h
db 0ffh,0ffh,0ffh,0feh,0feh,0fch,0f8h,0f0h,0c0h,00h,00h,00h,00h,00h,00h
tian db 00h,7fh,01h,01h,01h,01h,0ffh,01h,02h,02h,04h,04h,08h,10h,20h,0c0h
db 00h,0fch,00h,00h,00h,04h,0feh,00h,80h,80h,40h,40h,20h,10h,0eh,04h
jiao db 08h,0fdh,08h,48h,4bh,48h,48h,49h,7eh,04h,1ch,0e4h,44h,14h,09h,02h
db 0ch,0f0h,20h,20h,0feh,50h,88h,06h,8ch,88h,88h,88h,88h,88h,08h,08h
str1 db 130,131,132
str2 db 133,134,135,136
str3 db 137,138,139,140,141
ws1 db 142,143
ws2 db 144,145
hddb 219
cseg ends
end start
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
Floor 2 Posted 2006-01-10 22:56 ·  中国 广东 广州 海珠区 电信
金牌会员
★★★★
D◎$ Fαп
Credits 4,562
Posts 1,883
Joined 2004-01-19 00:00
22-year member
UID 15812
Gender Male
From 广东广州
Status Offline
Very good! Give it a thumbs up!

I also saw similar articles in some computer magazine from 1994 or 1995 before. Modifying the character font of the BIOS is a very advanced technology. Through it, you can display monochrome small PCX pictures in text mode, and also create arrow-shaped mice in text mode (just like the arrow-shaped mice in DOSShell, VSafe, MSBackup, etc.).
----====≡≡≡≡ 我的至爱,永远是MSDOS!≡≡≡≡====----
Floor 3 Posted 2006-01-10 23:03 ·  中国 湖北 武汉 联通
高级用户
★★★
Credits 587
Posts 302
Joined 2005-07-25 17:31
20-year member
UID 41046
Gender Male
Status Offline
C1=(i-a0H)+94


C1=(i-a0H)*94

Is there a 16×16 GBK dot matrix font library?
欢迎造访DOS的小屋!
http://risky.ik8.com
Floor 4 Posted 2006-01-11 07:41 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 2,227
Posts 790
Joined 2005-01-27 00:00
21-year member
UID 35703
Gender Male
Status Offline
Re wil: Good! Good! Good!

Re fdsiuha: It's the HZK16.GBK that comes with UCWIN gold 1.0!

In addition: I don't understand the format of common graphics, otherwise I could let VTmagic support the display | generation of text graphics!!!

[ Last edited by 本是 on 2006-1-11 at 07:49 ]
my major is english----my love is dos----my teacher is the buddha----my friends--how about U
Floor 5 Posted 2006-01-11 10:44 ·  中国 湖北 武汉 联通
高级用户
★★★
Credits 587
Posts 302
Joined 2005-07-25 17:31
20-year member
UID 41046
Gender Male
Status Offline
Found UCWIN GOLD, it seems to come with a 12×12 dot matrix GBK font.

Post a URL first
http://www.ibiblio.org/pub/packages/ccic/software/ms-win/c-sys/
There are many useful things in it, and you need to explore by yourself

[ Last edited by fdsiuha on 2006-1-11 at 10:51 ]
欢迎造访DOS的小屋!
http://risky.ik8.com
Floor 6 Posted 2006-01-12 20:52 ·  中国 广西 桂林 电信
初级用户
★★
Credits 176
Posts 74
Joined 2005-11-07 16:51
20-year member
UID 44761
Status Offline
It's a great example for learning!
Seems very interesting.
Forum Jump: