Re : A92: Re: optimization


[Prev][Index][Thread]

Re : A92: Re: optimization




Dans un courrier daté du 31/08/98 19:28:22  , vous avez écrit :

> 
>  For better formatting you can download the 68x00 Programmer's Reference
>  from Motorola's homepages - it contains everything you'd want to know about
>  the 68000 from a technical programmer's point of view, but it doesn't
>  include any actual programming info.
>  
>  
>  Niklas Brunlid - http://www.efd.lth.se/~e96nbr
>  PQF Quote follows:
>

Here is for exemple the optimization i just did on a loop:

before:
\loop
   move.w  d2,d5
   asr.w   #8,d5
   asl.w   #_wall_texture_size,d5
;   ext.l   d5
   btst.b  d3,0(a1,d5)
   beq     \white
\black
   bset.b  d6,(a2)
;   bra     \end_pixel
\white
; nothing...
\end_pixel
   add.w   d4,d2
   add.l   #30,a2
   cmp.l   a2,a3
   bne     \loop

after...
first, two macros...

tex_loop     macro
\@loop                              
   move.w  d2,d5                    
   asr.w   #8-_wall_texture_size,d5 
   and.w   #~(1<<_wall_texture_size-1),d5
   btst.b  d3,0(a1,d5)              
   beq     \@white                  
\@black                             
   bset.b  d6,(a2)                 
\@white                             
   add.w   d4,d2                  
   add.l   #30,a2                  
             endm

repeat   macro                      ;
 \2                                 ;
rcount set \1-1                     ; loop unrolling macro 
 ifne rcount                        ; 
     repeat rcount,<\2>             ;
 endif                              ;
         endm                       ;

Then, the code itself...

   repeat   height,<tex_loop>

The thing i am the most proud of is:
   asr.w   #8-_wall_texture_size,d5 
   and.w   #~(1<<_wall_texture_size-1),d5

It is rather cool... Its gain is of 
(6+_wall_texture_size*2+_wall_texture_size*2 )-8

The values of _wall_texture_size can be : 1,2,3
Thus, thye gain in the current version of my engine is ( 3 ) 10 cycles by each
execution of the loop ... ( not taking into account the cmp and bne ) 

Mathieu