想提高字符显示的速度吗?想在常驻程序中使用字符显示功能吗?用过C的朋友可能会推荐使用直接写屏(所谓直接写屏既是指在VGA
彩色80列文本方式下,显示内存从b800h 开始,屏幕上的每一个字符都对应显示内存的2个字节,偶字节为字符的ASCⅡ码,奇字节为该字符的属性。在显示内存里写入字符和属性即可在屏幕相对应处显示字符)实现上述功能。
可是QB的爱好者该怎么办?用Print 语句显示字符实在太慢太慢,自然不可取。其实QB 也可以实现直接写屏功能,且看以下程序,本程序直接针对硬件编程,在屏幕第一行第一列显示1个绿色的字母B。
源程序如下:
declare function directwrite !(x!,y!,A$,
icolor !)
cls
k =directwrite(1,1,“B”,2)
while inkey$=“”
wend
if k =0then print“参数不符合要求”
end
function directwrite !(x!,y!,A$,icolor !)
direct =1
def shg =&hb800
if x >80or y >25or x <1or y <1
then direct =0
end if
iflen(A$)<>1then
direct =0
end if
if directwrite
t =(x -1)*2+(y -1)*80*2
poke t ,asc(A$)
poke t +1,icolor
directwrite =1
else directwrite =0
end if
end function
directwrite !()函数的四个参数分别为行、列、字符、颜色。如果成功执行返回值为1,否则为0。在程序中加入此函数,可以提高显示速度,特别在编写TSR
驻留程序时,使用本函数的优越性就更明显了。(浙江省瑞安市场桥电信局程控机房陈宏宇325205)