home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff239.lzh / JGoodies / HAMmmm2 / mmm_control < prev    next >
Text File  |  1989-08-21  |  2KB  |  89 lines

  1. \ Top level control of HAMmmm program which
  2. \ demonstrates Amiga HAM graphics, double buffering,
  3. \ and local sound.
  4. \
  5. \ Author: Phil Burk
  6. \ Copyright 1987 Phil Burk
  7. \ This code is considered to be in the public domain and
  8. \ may be freely distributed but may not be sold for profit.
  9.  
  10. ANEW TASK-MMM_CONTROL
  11.  
  12. : HAM.CHECK.EVENTS { | rmessage mcode -- , process any events }
  13. \ Check for an IntuiMesssage
  14.     gr-curwindow @ ..@ wd_userport call exec_lib GetMsg ?dup
  15.     IF  >rel -> rmessage
  16.         rmessage ..@ im_code -> mcode
  17.         rmessage ..@ im_class
  18.         rmessage >abs call exec_lib ReplyMsg drop
  19.         CASE
  20.             MENUPICK
  21.             OF  mcode dup MENUNULL =
  22.                 IF drop ham.continue  ( restart graphics )
  23.                 ELSE control-menu ezmenu.exec ( DO MENU! )
  24.                 THEN
  25.             ENDOF
  26. \
  27. \ Make sure double buffering is turned off because it would
  28. \ make the menus flash.
  29.             MENUVERIFY  
  30.             OF  ham-enable-graphics off
  31.             ENDOF
  32.         ENDCASE
  33.     THEN
  34. ;
  35.     
  36. : HAM.LOOP ( -- , Create drawings until key hit. )
  37.     false ham-demo-quit !
  38.     BEGIN
  39.         ham-enable-graphics @
  40.         IF  ham.moving.lines
  41.             change.sound
  42. \
  43. \ Randomly change drawing modes and sound.
  44.             50 choose 0=
  45.             IF ham.change.mode
  46.                change.chord
  47.             THEN
  48.         THEN
  49.         ham.check.events
  50.         ?terminal ham-demo-quit @ or
  51.     UNTIL
  52. ;
  53.  
  54. \ Seed the random number generator with the current time
  55. \ so that HAMmmm will always produce different animation.
  56. : RANDOM.INIT ( -- , seed random number generator with time )
  57. \ CurrentTime will write current time into variable.
  58.     rand-seed >abs dup callvoid intuition_lib CurrentTime
  59. ;
  60.  
  61. : HAM.INIT  ( -- window | NULL , Initialize HAMmmm system )
  62.     ham.open dup
  63.     IF  ham.set.colors
  64.         random.init
  65.         ham.setup.pos
  66.         ham.setup.vel
  67.         buffers.init
  68.         ham.menu.init
  69.         sound.init
  70.         ham-enable-graphics on
  71.     THEN
  72. ;
  73.  
  74. : HAM.TERM ( -- , Cleanup afterwards. )
  75.     ham.menu.term
  76.     sound.term
  77.     buffers.term
  78.     ham.close
  79. ;
  80.  
  81. : HAMmmm  ( -- , top word of demo, does all )
  82.     ham.init
  83.     IF ham.loop
  84.     THEN
  85.     ham.term
  86. ;
  87.  
  88. cr ." Enter:     HAMmmm     to see demo!" cr
  89.