home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d9xx / d969 / ace.lha / ACE / ACE-2.0.lha / PRGS.lha / MC / ledfade.b < prev    next >
Text File  |  1994-01-10  |  1KB  |  56 lines

  1. '...Calling a machine code subroutine from ACE with AllocMem. 
  2.  
  3. '...Thanks goes to Juergen Weinelt for the fade algorithm.
  4.  
  5. library exec
  6. declare function AllocMem& library exec
  7. declare function FreeMem library exec
  8. declare function Delay library dos
  9.  
  10. const bytes=50&
  11. const flags=1&
  12.  
  13. power&=AllocMem&(bytes,flags)
  14.  
  15. '...store machine code
  16. for i&=0 to 39
  17.  read a%
  18.  poke power&+i&,a% 
  19. next
  20.  
  21. data &H2f,0,&H20,&H2f,0,8,&Hb0,&H3c,0,1,&H67,0,0,&He,0,&H39,0,2,0,&Hbf
  22. data &He0,1,&H60,0,0,&Ha,2,&H39,0,&Hfd,0,&Hbf,&He0,1,&H20,&H1f,&H4e,&H75,0,0
  23.  
  24. '..cause the power LED to fade out and back in
  25. '..until the left mouse button is pressed.
  26. repeat
  27.   '..fade out.
  28.   counter%=0
  29.   repeat
  30.     call power&(0&)
  31.     for a%=0 to 255
  32.       if a%=counter% then call power&(1&)
  33.     next
  34.     ++counter%
  35.     finished&=mouse(0)
  36.   until counter%=256 or finished&
  37.  
  38.   '..fade in.
  39.   counter%=255
  40.   repeat
  41.     call power&(0&)
  42.     for a%=0 to 255
  43.       if a%=counter% then call power&(1&)
  44.     next
  45.     --counter%
  46.     finished&=mouse(0)
  47.   until counter%=-1 or finished&
  48. until finished&
  49.  
  50. '..make sure LED is left ON.
  51. call power&(1&)
  52.  
  53. FreeMem(power&,bytes)
  54.  
  55. library close exec
  56.