>From News server: news.freesoft.cei.gov.cn

From: "Miao YuCheng" <[EMAIL PROTECTED]>
Newsgroups: chinese.comp.linux.development
Subject: 也談漢字的快速顯示
Date: Fri, 17 Dec 1999 22:30:33 +0800


[posted and mailed]

On 17 Dec 1999, you wrote in chinese.comp.linux.development:

>最近正在看Michael Abrash's Graphics Programming黑皮書,
>深受啟發. 聯系以前對yact, [EMAIL PROTECTED], 做了
>[EMAIL PROTECTED], 發現如果用寫模式3避開out指令的話, 可以使單字
>顯示的速度明顯加快. [EMAIL PROTECTED], 用通常意義上的快速方
>法, 即通過每次寫位屏蔽寄存器顯示8個pixel的方案最少也要
>15000microseconds(1 microseconds = 1000 ns), 而用寫模
>式3可以達到5000microsends的速度以單字顯示調用寫滿全屏
>([EMAIL PROTECTED]
>幕, 也就是包括了push, pop的時間, [EMAIL PROTECTED]
>會[EMAIL PROTECTED]). 如果說寫模式3用的不多的原因在于和EGA不兼容
>的話, 那么按照現在VGA如此普及的情形, 我想該不用再考慮和
>EGA間的兼容性了吧. 我修改了cce中的顯示ascii字符的過程,
>重新編譯后, [EMAIL PROTECTED]
>ASCII ART 文件, 比如earth([EMAIL PROTECTED],
>還有許多其他好玩的東西, 如聖誕動畫等, 很經典),
>速度明顯快了許多, 和gce相比還是快(想來, gce不會是用寫模
>式3顯示字符的). [EMAIL PROTECTED]
>有明顯的速度增加, cce之所以慢看來要歸咎于卷屏的問題了,
>cce通過拷貝顯存實現卷屏, 約要占去40000microseconds的時
>間, [EMAIL PROTECTED], 優化后速度無怪沒有明顯的增加.
>考慮用起始行掃描寄存器(估計gce也是這么做的), 還是有些問
>題的, [EMAIL PROTECTED], 約只能卷18行, 18行后還
>[EMAIL PROTECTED], 如果能避免, 當然最好.
>二是用起始掃描寄存器的話, 每次卷屏, 都要重畫狀態條, 該
>如何避免? 拆分屏幕是否能解決此問題. 如果上述兩者都不能
>避免的話, [EMAIL PROTECTED], 每卷屏18行, 平均每次卷屏所化時間
>4500microseconds, 雖然還是遠遠小于cce的時間, 但卻不是
>最理想的. 我在這里討論, 希望有過漢字或圖形編程經驗的朋
>友能說說解決之道.
>
>另附利用寫模式3實現單字顯示的過程:
>#void hz16_draw (int row, int col, char** hzbm);
>#row -- 行
>#col -- 列
>#hzbm - 漢字位圖
>
>hz16_draw:
>     pushl %ebp
>     movl %esp, %ebp
>     pushl %ecx
>     pushl %edx
>     pushl %esi
>     pushl %edi
>
>    # 用offset_table表的方法增加速度,
>    # 等效于下面注釋的代碼
>     movl 8(%ebp), %eax
>     shll $2, %eax
>     movl offset_table(%eax), %edi
>     movl 12(%ebp),%edx
>     shll $1, %edx
>     addl %edx, %edi
>
>    # simpliest but slowest
>    # movl 8(%ebp), %eax
>    # imul $1440, %eax
>    # movl %eax, %edi
>
>    movl 16(%ebp), %esi
>    addl graph_mem, %edi
>
>    #draw background
>     movw $0x3CE, %dx
>     movw $0xf00, %ax # replace 0xf with background
>     outw %ax, %dx
>
>     movw $0xffff, (%edi)
>
>    #draw foreground
>     movw $0x0000, %ax # replace 0x0 with foreground
>     outw %ax, %dx
>
>    # [EMAIL PROTECTED], [EMAIL PROTECTED]
>    # 節約2000microseconds :-)
>     movw (%edi), %ax
>     movl $18, %ecx
>draw2:
>     movw (%esi), %ax
>     movw %ax, (%edi)
>     addl $80, %edi
>     inc %esi
>     inc %esi
>     loop draw2
>
>     popl %edi
>     popl %esi
>     popl %edx
>     popl %ecx
>     popl %ebp
>     ret
>
>
>
>


-- 
[ [EMAIL PROTECTED] is the mailing-list that ]
[ this mail was originally sent to,  and was forwarded to this list   ]
[ automatically. GB characters are also converted to Big5 at the same ]
[ time.  Note that there may be errors  during the conversion as this ]
[ is not done by a human!                                             ]

Reply via email to