『楼 主』:
查寄存器值检测直接写屏汉字系统启动状态及显示状态
使用 LLM 解释/回答一下
查寄存器值检测直接写屏汉字系统启动状态及汉字显示状态本是<img src="images/smilies/face-cool.png" align="absmiddle" border="0">原创!]
如果以现在大家基本上都在用支持直接写屏(所以不再考虑CGA/MDA/HGA)的汉字系统为前提,思考检测汉字系统的存在与否(注意:是指汉字dos是否启动,而不是汉字是否能够显示(比如揿过CtrlF7键切换到西文状态))及汉字显示状态的激活与否,就比较简单了。
1。要支持直接写屏(现在通常都是置图形屏然后修改E/VGA寄存器值以打开本来只有文本屏才有的视频缓冲,允许写入B800:0000h(或B000:0000h),即看起来是文本屏,实质上还是图形屏--又称伪字符型直接写屏),就一定要修改图形控制器端口3CEh索引号为6的混合寄存器值,以设定存储器地址映射到主机存储器的相应地址范围。
jzEnDos6: ;check Chinese Character System Status
mov dx,3CEh;端口3C4/5h, EGA图形控制器 索引/功能 al=6, 混合寄存器
mov al,06 ;索引号=6
out dx,al
inc dx ;dx=3CFh
in al,dx
mov ah,al
and al,00000001B ;图形允许位
and ah,00001000B ;存储器地址选择位的高位: 置1为映射Bx00:0000h文本屏址
not ah ;反其值, 置1变置0
or ah,al ;拼接
or ah,ah ;不允许图形+置0?
;jz EnDos;jnz CcDos
ret
2。要支持汉字提示行定位在屏幕底部,又必定要修改CRT控制器3D4/5h(或3B4/5h)的18h号线比较寄存器(附带09h号最大扫描线数目寄存器)、0Ch/0Dh号起始地址寄存器高低字节等的值。
jzEnDos18: ;check Chinese Character System Status
mov dx,3D4h;端口3D4/5h, EGA CRT控制器 索引/功能 al=18h, 线比较寄存器
mov al,18h ;索引号=18h
out dx,al
inc dx ;dx=3D5h
in al,dx
cmp al,0FFh;=缺省值0FFh?
;jz EnDos;jnz CcDos
ret
jzEnDosCD: ;check Chinese Character System Status
mov dx,3D4h;端口3D4/5h, EGA CRT控制器 索引/功能 al=0C/0Dh, 起始地址寄存器高低字节
mov cx,0C0Dh
mov al,ch ;索引号=0Ch
out dx,al
inc dx ;dx=3D5h
in al,dx ;缺省值=0
mov ah,al
dec dx
mov al,cl ;索引号=0Dh
out dx,al
inc dx ;dx=3D5h
in al,dx ;缺省值=0
or al,ah ;拼接
or al,al ;2个=缺省值0?
;jz EnDos;jnz CcDos
ret
3。要支持直接写屏,还要修改时序发生器3C4/5h的颜色平面允许写寄存器02h,因为是伪字符型直接写屏,所以真正写字模上屏,又必定是写入图形视频缓冲,所以颜色平面允许写寄存器的值就不可能再是文本屏时的值3,而必是其它,这就成了可靠的是否在汉字显示状态的判断标准。--非直接写屏汉字系统也是如此--本来就是图形显示。
jzEnDisp2: ;check Chinese Character Display Status
mov dx,3C4h;端口3C4/5h, EGA时序发生器 索引/功能 al=2, 颜色平面允许写寄存器
mov al,02 ;索引号=2
out dx,al
inc dx ;dx=3C5h
in al,dx
cmp al,03 ;文本屏的缺省值
;jz EnDisp;jnz CcDisp
ret
这样去思考检测汉字系统的存在及汉字显示状态,应该是切中要害的。
请高手<img src="images/smilies/face-smile-big.png" align="absmiddle" border="0">指正!
请大家<img src="images/smilies/face-wink.png" align="absmiddle" border="0">测试,并反馈信息!
Check Register Values to Detect Direct Screen Writing Chinese Character System Startup Status and Chinese Character Display Status Originally Created by:cool:!]
Assuming that most people are currently using Chinese character systems that support direct screen writing (so CGA/MDA/HGA are no longer considered), it is relatively simple to think about detecting the existence of the Chinese character system (note: it refers to whether the Chinese character DOS is started, not whether Chinese characters can be displayed (such as pressing the Ctrl+F7 key to switch to the Western character state)) and whether the activation of the Chinese character display status.
1. To support direct screen writing (now usually setting the graphics screen and then modifying the E/VGA register values to open the video buffer that was originally only available for the text screen, allowing writing to B800:0000h (or B000:0000h), that is, it looks like a text screen, but essentially it is still a graphics screen - also known as pseudo-character direct screen writing), it is necessary to modify the value of the mixed register with index 6 of the graphics controller port 3CEh to set the memory address to map to the corresponding address range of the host memory.
jzEnDos6: ;check Chinese Character System Status
mov dx,3CEh;Port 3C4/5h, EGA graphics controller index/function al=6, mixed register
mov al,06 ;Index number=6
out dx,al
inc dx ;dx=3CFh
in al,dx
mov ah,al
and al,00000001B ;Graphics enable bit
and ah,00001000B ;High bit of memory address selection bit: set to 1 to map to the text screen address of Bx00:0000h
not ah ;Invert its value, set 1 to 0
or ah,al ;Concatenate
or ah,ah ;Not allowed to be graphics + set to 0?
;jz EnDos;jnz CcDos
ret
2. To support the Chinese character prompt line to be positioned at the bottom of the screen, it is necessary to modify the value of the 18h line comparison register (accompanied by the 09h maximum scan line number register), the high and low bytes of the 0Ch/0Dh start address registers, etc., of the CRT controller 3D4/5h (or 3B4/5h).
jzEnDos18: ;check Chinese Character System Status
mov dx,3D4h;Port 3D4/5h, EGA CRT controller index/function al=18h, line comparison register
mov al,18h ;Index number=18h
out dx,al
inc dx ;dx=3D5h
in al,dx
cmp al,0FFh;=default value 0FFh?
;jz EnDos;jnz CcDos
ret
jzEnDosCD: ;check Chinese Character System Status
mov dx,3D4h;Port 3D4/5h, EGA CRT controller index/function al=0C/0Dh, high and low bytes of start address registers
mov cx,0C0Dh
mov al,ch ;Index number=0Ch
out dx,al
inc dx ;dx=3D5h
in al,dx ;Default value=0
mov ah,al
dec dx
mov al,cl ;Index number=0Dh
out dx,al
inc dx ;dx=3D5h
in al,dx ;Default value=0
or al,ah ;Concatenate
or al,al ;Both=default value 0?
;jz EnDos;jnz CcDos
ret
3. To support direct screen writing, it is also necessary to modify the color plane write enable register 02h of the timing generator 3C4/5h. Because it is pseudo-character direct screen writing, when actually writing the character pattern to the screen, it is necessarily writing to the graphics video buffer, so the value of the color plane write enable register cannot be the value 3 when it is the text screen, but must be something else, which becomes a reliable judgment standard for whether it is in the Chinese character display status. - The same is true for non-direct screen writing Chinese character systems - it is originally graphics display.
jzEnDisp2: ;check Chinese Character Display Status
mov dx,3C4h;Port 3C4/5h, EGA timing generator index/function al=2, color plane write enable register
mov al,02 ;Index number=2
out dx,al
inc dx ;dx=3C5h
in al,dx
cmp al,03 ;Default value of text screen
;jz EnDisp;jnz CcDisp
ret
Thinking about detecting the existence of the Chinese character system and the Chinese character display status in this way should be hitting the nail on the head.
Please experts :D correct!
Please everyone ;) test and feedback information!
|