Hi,
Dex4u wrote:With nothing eles running using this code
Dex4u wrote:I am only getting 19 FPS.
This code is broken anyway - it writes one byte too many at the end of visible display memory and won't work if the video mode has an unseen part. For e.g. video display memory could look like this:
[t]XXXXXX---
XXXXXX---
XXXXXX---
XXXXXX---[/tt]
The other problem is that VGA display memory doesn't like unaligned accesses.
To fix it, try something like this:
Code: Select all
;----------------------------------------------------;
; PutBmp24 24bpp ;
;----------------------------------------------------;
FillScreen:
pushad
push es
mov ax,8h
mov es,ax
mov ebp,480 ;this hard coded is temp
lea eax,[ebp*2+ebp]
mov edx,[ModeInfo_BytesPerLine]
mov edi,[ModeInfo_PhysBasePtr]
sub edx,eax
mov esi,ScreenBuffer
cld
.l1:
mov ecx,640/4 ;this hard coded is temp
.l2:
mov eax,[esi] ;eax = -- R1 G1 B1
mov ebx,[esi+4] ;ebx = -- R2 G2 B2
shl eax,8 ;eax = R1 G1 B1 --
shrd eax,ebx,8 ;eax = B2 R1 G1 B1
stosd
mov ax,[esi+8] ;eax = -- -- G3 B3
shr ebx,8 ;ebx = -- -- R2 G2
shl eax,16 ;eax = G3 B3 -- --
or eax,ebx ;eax = G3 B3 R2 G2
stosd
mov bl,[esi+10] ;ebx = -- -- -- R3
mov eax,[esi+12] ;eax = -- R4 G4 B4
shr eax,8 ;eax = R4 G4 B4 --
mov al,bl ;eax = R4 G4 B4 R3
stosd
add esi,16
loop .l2
add edi,edx
sub ebp,1
ja .l1
pop es
popad
ret
This does 4 pixels at a time (three 32-bit writes that are always aligned, instead of four 32 bit writes that are unaligned 75% of the time). It won't work for extremely unusual video modes - the horizontal resolution must be a multiple of 4 (but it's very unlikely this matters).
It's hard to predict the speed difference this will make - I'm curious!
Dex4u wrote:The mouse pointer is a compiled sprites based on info i got here:
http://www.nondot.org/sabre/graphpro/sprite4.html
Which works real well, but i see a problem, if you use this to draw direct to screen, its works well, but if you then blits the offscreen buff to screen, then move the mouse you may draw the backup of the old screen.
From the web site you've mentioned:
- # They can be very large
# Clipping is impossible
# They are not very portable
For a GUI or something "no clipping" means you're screwed if the mouse pointer is near the (left or bottom?) edge of the screen, and "not portable" means you need a different compiled sprite for each variation of each video mode.
Also, often a GUI will allow the application to supply it's own mouse pointer - it might look like a sniper's cross-hairs in a game, an hourglass in windows, a hand if the user is moving things (scroll bars, etc), a magnifying glass for zooming in and out, etc.
For hardware accelerated mouse pointers the mouse pointer data often consists of a pair of 32*32 (or 64*64) bitmaps. One bitmap is a mask of which pixels are changed, and the other bitmap determines if a pixel will be black or white (if it's changed). This varies though (different video cards do it differently).
For these reasons I'd recommend inventing a "standard mouse pointer format" (somthing that can be converted to the format used for hardware acceleration, but supports colour too). I wouldn't use compiled sprites - they'd save a little CPU time, but it shouldn't take long to copy and update a 32*32 square of screen memory anyway and it's not like you'll be having hundreds of mouse pointers displayed on the screen....
Cheers,
Brendan