Board index » delphi » Help! VirtualScreen to VideoRam.

Help! VirtualScreen to VideoRam.

Hello all,

I am currently trying to write a game that uses a static background bitmap
with a scrolling bitmap layered on top of that with sprites layered on all of
that.  
The problem I cam across was that when I copied all the relevant data to
a virtual screen, It was much to slow.  What should have taken a second to
draw sixty frames, took three seconds.  
I tried just flipping screens with just plotting to the virtual screen, but
still It took too long.
I tried without checking V_Sync and with V_Sync.
Im currently using Borland Pascal 7 to do this game, and if I get past this
one big problem I would be happy to distribute copies to people who can help
me with this.
Here is a sample of my ASM code for the original copying of
 Static BMP -> Scrolling BMP -> Sprites -> Virtual Screen <Check V_Sync> ->
VRAM.

Begin
             Asm
             push ax
             push cx
             push ds
             push si
             push es
             push di
             cld
             mov cx,$FFFF
             mov di,0
             mov si,0          
             mov ds,StaticBMP
             mov es,VirtualScreen
             rep movsw
             pop di
             pop es
             pop si
             pop ds
             pop cx
             pop ax
          end;
          Asm
                      push ax
                      push cx
                      push ds
                      push si
                      push es
                      push di
                      cld
                      Xor CX,CX
                      Mov SI,0
                      Mov DI,0
                      Mov DS,ScrollingBMP
                      Mov ES,VirtualScreen
@Round0:     Mov AX,DS:[SI]
                      Cmp AX,0
                      Je @Next0
                      Mov ES:[DI],AX
@Next0:        Inc SI
                      inc DI
                      Inc CX
                      Cmp CX,$FFFF
                      Jne @Round0
                      pop di
                      pop es
                      pop si
                      pop ds
                      pop cx
                      pop ax
          end;
{* Do the sprite thing here*}
     VidRam := segA000;
     Asm
        push cx
        push es
        push ds
        push si
        push di
        mov di,0
        mov si,0
        mov ds,VirtualScreen
        mov es,VidRam
        mov cx,$FFFF
        rep movsw
        pop di
        pop si
        pop ds
        pop es
        pop cx
     end;
End;

StaticBMP is the start address of the static bitmap.
ScrollingBMP is the start address of the scrolling bitmap.
VirtualScreen is the start address of the virtual screen.

Im also using Protected mode for compiling target, if that means anything to
anyone.
Any ideas to speed up the FPS or just redoing the whole thing is most welcome
either at my Email address w...@southern.co.nz or in this news group.
        Thanx.

 

Re:Help! VirtualScreen to VideoRam.


I don't know anything about ASM, I'm afraid, so I couldn't check your
code, but I have a couple of suggestions (probably useless but worth a
try)

A) Are you using MODE-X?

B) If so, are you using inbuilt virtual screen handlers, or storing the
entire screen in RAM then dumping to the screen?  The latter is slower!

Sorry if I insulted you with completely obvious and probably
already-thought-of suggestions, but it's worth a try!

-Sam McGrath

Re:Help! VirtualScreen to VideoRam.


Raoul & Kyle & Deb & Jeremy (w...@southern.co.nz) wrote:

Tru do optimize your code ...
I am not a real ASM-Coder, but I think it should help a bit...

: Begin
:              Asm
:              push ax
:              push cx
:              push ds
:              push si
:              push es
:              push di

Are you sure, that you must PUSH these Registers ? I think that pushing AX
is not important... and in normal it should be enough to "push ds"or just
pusha and to pop them popa ...

:              cld
:              mov cx,$FFFF
:              mov di,0
:              mov si,0        
:              mov ds,StaticBMP
:              mov es,VirtualScreen
:              rep movsw
:              pop di
:              pop es
:              pop si
:              pop ds
:              pop cx
:              pop ax

Oh .. I think, that you don't nedd to push and pop everythink, just for
copying a screen ... and if you want to get it really faster, than halve CX
and use DB $66; REP MOVSW instead, but you would loose ONE Point ..

CU

--
Our Project should be  | A Salam Aleikum |     /   |  _     \ |        | |
to rescue the whole    |                 |  _o_\_,_;_(_  '_o_\;__,_,_,_; |
World          {NUSI}  |                 | (    ..       (

Other Threads