delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/06/08:05:10

From: tomstdenis AT my-dejanews DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need for speed
Date: Tue, 06 Oct 1998 11:46:46 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 60
Message-ID: <6vcvv7$a83$1@nnrp1.dejanews.com>
References: <6vbb5d$1fc$1 AT equila DOT wfpa DOT acad DOT bg>
NNTP-Posting-Host: 206.222.81.179
X-Article-Creation-Date: Tue Oct 06 11:46:46 1998 GMT
X-Http-User-Agent: Mozilla/4.07 [en] (Win95; I ;Nav)
X-Http-Proxy: 1.0 x13.dejanews.com:80 (Squid/1.1.22) for client 206.222.81.179
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>     I need really fast way to copy 640x480 bytes from one place to another.
> Something like movedata(), but I need some more... It have to copy the bytes
> not equal to 1 (the transperant pixel). Can you help me to make assembler
> program or whatever for that?
> I tried:
> for(i = 0; i < 640*480; i++)
> --then check every byte...
> but it's too slow

Well this is what you do, you make a pixel mask of the pixels you want to
keep, then you set the ones you want to keep to FF, and the ones you don't
want to 0. SDo you will beed one 640x480 array for pixel data and one for
masks.

; esi = pixel data
; edi = destination
; ebx = pixel masks
   mov ecx,640*480/4
m_loop:
   mov eax,[esi]
   and eax,[ebx]
   add esi,4
   mov [edi],eax
   add ebx,4
   add edi,4

   dec ecx
   jnz m_loop

Now you draw and mask 4 pixels at a time.  It might be better to read maybe
2X4 pixel data and pixel maps, that way you make better use of the cache, try
this...

; edi = destination
; esi = source pixel map
; ebp = source pixel mask
; assumes ds=ss
;
   mov ecx,640*480/8
m_loop:
   mov eax,[esi]
   mov ebx,[esi+4]
   add esi,8
   and eax,[ebp]
   and ebx,[ebp+4]
   add ebp,8
   mov [edi],eax
   mov [edi+4],ebx
   add edi,8

   dec ecx
   jnz m_loop



Try those.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019