![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-01 22:10 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS开发编程 & 发展交流 (开发室) » Speed Considerations for GUI Design in VGA12h Mode |
| Printable Version 1,902 / 7 |
| Floor1 本是 | Posted 2006-08-18 14:48 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
### Speed Considerations in VGA12h Mode GUI Design
1. Time Consumption Comparison of Drawing Lines in Various Ways in VGA12h Mode: ============================================== Line Drawing Method Time Consumption (seconds) Running Program* Number of Writes Linear Address Calculation REG Settings ----------------------------------------------------------------------------------------------------- Scan Block Drawing (REG) 0.046343422 lineff.com L*P/8 Non-repetitive between lines Non-repetitive Scan Line Drawing (REG) 0.061104584 linehh.com L*P/8 Repetitive between lines Repetitive between lines Vertical Line Drawing (REG) 0.326120375 linev.com L*P Non-repetitive between points Repetitive between lines Normal Line Drawing (REG) 0.823882125 linen.com L*P Repetitive between points Repetitive between lines ----------------------------------------------------------------------------------------------------- Normal Point Drawing (BIOS) 3.899710625 lineb.com L*P Repetitive between points Repetitive between points ============================================== Note: REG -- VGA registers BIOS -- BIOS interrupts L -- Number of lines P -- Number of pixels * -- lineff.com, linehh.com draw 100*16 screen, others.com draw 16 screen It can be seen that BIOS point drawing and line drawing are too slow (time consumption is about 64 times that of the scan line method), and are not considered in GUI programming. Even when using VGA register programming, the time consumption of normal line drawing is about 13.5 times that of the scan line method, and the time consumption of normal line drawing is about 2.53 times that of the vertical line method. Note: The methods of lineff.com and linehh.com are both drawing scan lines, and because the start and end of the lines fall on pixels that are multiples of 8, each time 8 pixels are written, block drawing and line drawing are the fastest. lineff.com is faster because it does not repeat address calculation between lines, so it is faster, and the time consumption is 2/3 of linehh.com! linev.com is the fastest way to draw vertical lines, for the same reason as scan line block drawing -- no repeated address calculation! For other lines that are not horizontal or vertical, only the normal line drawing method can be used. Therefore, in GUI design requiring speed, block drawing should use the lineff.com method, frame line drawing should use the linehh.com and linev.com methods, not the linen.com normal line drawing method! 2. Considerations for Absolute Speed Optimization: When using the VGA register method to draw lines, it is necessary to go through several stages: first ① calculate the linear address of the video buffer, ② calculate the bit mask value, set the bit mask and other registers, then ③ draw points and lines, and finally ④ restore the default values of the modified registers. In the first link ①, multiplication and division may be used, but multiplication and division are generally considered to be operations with high overhead. When encountering multiplication and division that need to be executed repeatedly, they should be replaced with shifts and additions. Shifting left by 1 bit is equivalent to multiplying by 2, and shifting right by 2 bits is equivalent to dividing by 4. In many drawing algorithms, calculating the address often requires multiplying by 80, which can be calculated as follows: 80*y=(64+16)*y=(y shl 6)+(y shl 4) Assembly code: mov ax,y mov cx,4 shl ax,cl ;y*16 mov bx,ax shl bx,1 shl bx,1 ;y*64 add ax,bx ;(y*64)+(y*16) In the register operations that are necessarily used in stages ②③④, the efficiency is also different between using out dx,al or out dx,ax. The following code segment: mov dx,3CEh xor al,al out dx,al inc dx mov ax,Color out dx,al dec dx mov al,1 out dx,al mov al,0Fh out dx,al Can be considered to be changed to: mov dx,3CEh xor al,al mov ah,Color out dx,ax mov ax,0F01h out dx,ax In each stage of line drawing, you can pay attention to whether this operation is necessary to be repeated. If there is a fixed incremental relationship, etc., it can be simplified. If it is not necessary, it can be omitted. You can refer to the program code in line?.com. Attachments Linex.rar (14.5 KiB) |
|
| Floor2 JonePeng | Posted 2006-08-18 23:55 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
VGA12h feels to me like just one word -- slow.
And there are only 16 colors, and the resolution is only 640×480. I used to study VESA programming for 256-color 800×600, 1024×768 interfaces, and I have no interest in VGA12H. |
|
| Floor3 本是 | Posted 2006-08-20 00:27 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
JonePeng, if you have relatively comprehensive and practical materials on VESA, please provide some URLs!
|
|
| Floor4 zyl910 | Posted 2006-09-03 09:53 |
| 中级用户 Posts 126 Credits 282 | |
|
If the color of the line is fixed, it is better to use write mode 3. In write mode 3, the CPU data will be used as a bit mask, which can avoid inefficient IO operations.
In fact, VGA has 256KB video memory. By modifying some key registers, a high-resolution 8-bit color mode can be achieved: 320*240*8 // The so-called Mode X. Many games use this resolution 320*400*8 // The Windows 9X startup screen uses this resolution 320*480*8 360*350*8 // Some video playback software uses this resolution because it is closest to the QCF resolution of 352*288 360*480*8 // So far, the highest resolution VGA 8-bit color mode ... Horizontal resolution options: 320, 360 Vertical resolution options: 200, 240, 350, 400, 480 Theoretically, the parameters of the CRT controller can be modified to get any resolution, but I dare not try it randomly. For example, the resolution of 400*300 is very good, and I hope someone can figure it out. Recommendation: Title: Graphics Programmer's Guide (Michael Abrash's Graphics Programming Black Book Special Editior) Author: Michael Abrash Series title: Series of Computer Software Development and Programming ISBN: 7-111-06396-1 Publication and distribution: Beijing - China Machine Press 1998-08-01 Carrier information: 1064 pages 26cm ¥128.00 Personal name - co-author: Abrash Personal name - co-author: Qiandao Studio Chinese Library Classification: TP391.41-62 This book introduces various knowledge and skills of high-performance graphics programming systematically and comprehensively from shallow to deep, from high level to bottom level. The author first discusses in detail the hardware of x86 series computers and their optimization characteristics, graphics programming and step-by-step optimization skills, gives the analysis process, program list and performance comparison of each optimization. Then a general animation graphics package X-Sharp based on Mode X is formed. Finally, the research and implementation technology of Quake is introduced. This book is divided into two parts. The first part mainly introduces assembly optimization; the second part mainly introduces graphics hardware (VGA), high-performance graphics programming and optimization. The programs are written in C language and assembly language. [ Last edited by zyl910 on 2006-9-3 at 09:55 ] |
|
| Floor5 本是 | Posted 2006-09-03 11:12 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
RE:zyl910:
Good book! Where can I buy it? |
|
| Floor6 zyl910 | Posted 2006-09-03 20:35 |
| 中级用户 Posts 126 Credits 282 | |
|
I. Go to a second-hand bookstore and see, maybe you can find it.
II. Go to Chaoxing to view the electronic version. English version: http://public.planetmirror.com/pub/gpbb/ Translated (Chaoxing scanned version converted to PDF): http://www.netyi.net/book/933a25cf-fa0e-4dab-b9d7-e58a0ea8f52e.aspx |
|
| Floor7 本是 | Posted 2006-09-04 11:03 |
| 银牌会员 Posts 790 Credits 2,227 | |
|
Why are there so many English version files? Does the Chinese version require points to download? But still, thank you ZYL910!!!
|
|
| Floor8 zyl910 | Posted 2006-09-04 21:11 |
| 中级用户 Posts 126 Credits 282 | |
|
That book has many chapters:
As for the Chinese version —— It's uploaded by me In order to earn some points to download other e - books, so set 5 points, please forgive me
[ Last edited by zyl910 on 2006 - 9 - 4 at 21:13 ] |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |