Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

High Speed Windows!!!! ?How?

Status
Not open for further replies.

dbrown83

Programmer
Jun 28, 2000
3
CA
..... another question???&nbsp;&nbsp;Yup!!<br><br>Well... I'd like to thank ALT255 for helping with my last problem....&nbsp;&nbsp;this is more of a curiousity question...<br><br>I've been programming using interrupts... for high screen resolution and I've noticed that its really slow....1-2 secs. , which is slow compared to windows.&nbsp;&nbsp;Windows (any version) has had high resolutions... say 640x 480 or 1024 x 768.... and these are pretty high....I've been doing the same resolutions with less colours and my speed is still slower..... how do they do it????&nbsp;&nbsp;<br><br>ex.&nbsp;&nbsp;If you click on an executable program the window loads onto the screen pretty fast.... and you don't see the lines and everything being drawn.... in mine you can see the lines being drawn.....<br><br>DO they draw the stuff in video memory then PUT it to the screen???<br><br>How do they do it????<br><br>Daniel Brown
 
um, if you havent noticed qbasic isnt a language used to create anything at all in windows, most of it is in stuff like Assembly, C++, heck sometimes even VB, Qbasic graphic routines dont hardly compare to other languages, Especially when Qbasic can only use VESA modes, and doesnt work with video drivers created by the manufactuer, its all a factor of the way it was written(and definitly not in Qbasic) <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
&nbsp;&nbsp;&nbsp;You can get a moderate to pretty good speedup by using a assembly language memcopy-like routine (using MMX/FPU blits if possible), and don't check for bank switches if at all possible.&nbsp;&nbsp;Because banks are usually at least 4K long (more likely 64K), that means that on most scanlines, the bank number will stay the same. It also means that for currently available resolutions, the bank # can't switch on you more than once per scanline (this is not confirmed).&nbsp;&nbsp;If you draw a rectangular window, that means that most of the time can be spent in block memory copies, instead of slow IF currentbank&lt;&gt;oldbank THEN switchbank(x,y) kind of code.&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;The structure of the pseudocode (this won't compiled, just read it to get the idea) should look like <br><br>'Copyright 2000 Toshihiro Horie<br>MAX_X=639: MAX_Y=479<br>CONST bank1=0<br>CONST bank2=1<br>CONST switchx=2<br>DIM SHARED bankinfo(MAX_Y,0 TO 3) <br>CALL PrecalcBankSwitches<br>CALL InitializeAssemblyMemcopyRoutine<br><br><br>SUB PrecalcBankSwitches()<br>FOR Y=0 to MAX_Y<br>&nbsp;&nbsp;&nbsp;&nbsp;oldbank=getbank(Y,0)<br>&nbsp;&nbsp;&nbsp;&nbsp;FOR x=1 to MAX_X<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currentbank=getbank(X,Y)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF currentbank&lt;&gt;oldbank THEN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bankinfo(Y,bank1)=oldbank<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bankinfo(Y,bank2)=currentbank<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bankinfo(Y,switchx)=X<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;END IF<br>&nbsp;&nbsp;&nbsp;NEXT<br>NEXT<br>END SUB<br><br>&nbsp;&nbsp;&nbsp;<br><br>SUB BlitWindow(x1,y1,width,height)<br>'window buffer contains the pixel data for the window in a linear buffer<br>'switchbank changes the current VESA bank.<br>'use common subexpression elimination and loop induction variable <br>'&nbsp;&nbsp;&nbsp;strength reduction for further speedups<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FOR Y=y1 TO y2<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bank=bankinfo(Y,bank1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL switchbank(bank)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF bank=bankinfo(Y,bank2) THEN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blit this scanline<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,width)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ELSE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF bankinfo(Y,switchx)&lt;x1 AND bankinfo(Y,switchx)&gt;x1+width THEN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blit this scanline<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,width)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ELSE <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'blit this scanline in two pieces...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,switchx-x1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL switchbank(bankinfo(T,bank2))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CALL Memcopy(windowbuffer(Y*MAX_X+(switchx-x1)), Y*MAX_X+x1,x1+width-(switchx-x1))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDIF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDIF<br>&nbsp;&nbsp;&nbsp;&nbsp;NEXT<br>END SUB<br><br>&nbsp;&nbsp;&nbsp;There is also a small speed up if you bypass the BIOS interrupt and do a direct far call to the VESA interface routine.<br>&nbsp;&nbsp;&nbsp;The ultimate way for speed-up is to use hardware-specific assembly language drivers, which is what Windows, Linux, and every major OS does.
 
&nbsp;&nbsp;&nbsp;&nbsp;Toshi, could you post some pseudo assember code to show how the PrecalcBankSwitches, InitializeAssemblyMemcopyRoutine, SwitchBank and MemCopy routines work?<br>&nbsp;&nbsp;&nbsp;&nbsp;It would be better to show us using QB Interrupt calls but, since most of QB's power lies in it's mixed-languages capabilities, some assember code fragments would probably point us in the right direction. I think it would make a wonderful FAQ.<br><br>Thanks!<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top