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. 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). 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<>oldbank THEN switchbank(x,y) kind of code. <br> 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> oldbank=getbank(Y,0)<br> FOR x=1 to MAX_X<br> currentbank=getbank(X,Y)<br> IF currentbank<>oldbank THEN<br> bankinfo(Y,bank1)=oldbank<br> bankinfo(Y,bank2)=currentbank<br> bankinfo(Y,switchx)=X<br> END IF<br> NEXT<br>NEXT<br>END SUB<br><br> <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>' strength reduction for further speedups<br> FOR Y=y1 TO y2<br> bank=bankinfo(Y,bank1)<br> CALL switchbank(bank)<br> IF bank=bankinfo(Y,bank2) THEN<br> 'blit this scanline<br> CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,width)<br> ELSE<br> IF bankinfo(Y,switchx)<x1 AND bankinfo(Y,switchx)>x1+width THEN<br> 'blit this scanline<br> CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,width)<br> ELSE <br> 'blit this scanline in two pieces...<br> CALL Memcopy(windowbuffer(Y*MAX_X+x1), Y*MAX_X+x1,switchx-x1)<br> CALL switchbank(bankinfo(T,bank2))<br> CALL Memcopy(windowbuffer(Y*MAX_X+(switchx-x1)), Y*MAX_X+x1,x1+width-(switchx-x1))<br> ENDIF<br> ENDIF<br> NEXT<br>END SUB<br><br> 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> The ultimate way for speed-up is to use hardware-specific assembly language drivers, which is what Windows, Linux, and every major OS does.