Qbasicnews.com

Full Version: my first palette and asm program :P
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
sry, felt like sharing... maybesome someone might find it even useful Tongue
Code:
option explicit
   option static
   declare sub asmtest( )
   defint a-z
   asmtest
   end

'******************************************************************************'
sub asmtest ( )

   dim pal(255) as integer, k as integer ptr
   dim i, t, counter
   dim ts#, te#
   dim c!
  
   screenres 640, 480, 8
   setmouse , , 0
   k = @pal(255)
  
   'set up palette
   pal(0) = rgb(63,63,63)
   for i = 1 to 64
      t = iif(i<=32, t+1, t-1)
      pal(i)       = rgb(t-1, 0,   0)
      pal(64  + i) = rgb(0,   t-1, 0)
      pal(128 + i) = rgb(0,   0,   t-1)
      pal(192 + i) = rgb(t-1, t-1, t-1)
   next i
  
   'Set up image
   c! = 1
   for i = 0 to 400
      c! +=  (255! / 402!)
      circle (320, 240), i, c!
      circle (320, 241), i, c!
   next
  
   ts# = timer
   do

      'rotate palette
      asm
        
         mov ecx, 253
         mov edi, dword ptr [k]
        
         rotpal:
            mov eax, dword ptr [edi-4]
            mov dword ptr [edi], eax
            sub edi, 4
         dec ecx
         jnz rotpal
        
         mov esi, dword ptr [k]
         mov eax, dword ptr [esi]
         mov dword ptr [edi], eax
        
      end asm

      'FPS counter
      counter += 1
      sleep 15
      palette using pal
      
   loop until len( inkey$ )
   te# = timer
  
   color 0, 1
   print "FPS: "; counter / (te# - ts#)
   sleep
  
end sub
That's cool!
To VonGodric:

Man, that is a truly and *uniquely* good way of rotating your palette in a custom group of colors and using ASM features on that as well to make it all work in FB. Very nicely done! Big Grin=b

Catch you again, and you keep it up now!! :king:



[Image: file.php?id=32]
- Adigun Azikiwe Polack
One of the Founders of “Aura Flow” ::: Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger” ::: Webmaster of the “AAP Official Projects Squad”
Original Creator of the “The New FreeBASIC 8-Bit Palette Machine”



P.S. By the way, VonGodric, my wonderful congrats to you on your 20th birthday today!!! ;*) !
tnx Adigun!
Cool!!!