home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / 351-375 / apd375 / progs / dual_play.amos / dual_play.amosSourceCode
AMOS Source Code  |  1992-05-23  |  12KB  |  303 lines

  1. 'DATE: 07/01/92
  2. 'TIME: 22:07 
  3. 'NAME: DUAL_PLAY.AMOS  
  4. 'CODE: UNCLE SIME
  5. 'NOTE: YOU NEED THE CTEXT EXTENSIONS TO RUN THIS UN-COMPILED!
  6. 'THOUGHT FOR THE DAY: Life Is Like A Barbequed Sausage --  
  7. '                     Small, Burnt 'n Crispy 'n Not Very Tasty At All! 
  8. '                  I really enjoyed doing this one!  
  9. '     Wotcher One and all,   
  10. ' Once again if you are a beginner this piece of code may be on the  
  11. ' side of complex but try reading through it, if only to get a feel for
  12. ' what is going on.  
  13. '            "I Have Seen Things You People Wouldn't believe.    
  14. '             Attack Ships On Fire Off The Shoulder Of Orion.
  15. '             I've Watched Sea Beams Glitter In The Darkness At
  16. '             Ten Hauser Gate. All Those Moments Will Be Lost
  17. '             In Time Like Tears In Rain." 
  18. '             Time To Die... 
  19. ' If any AMOS coders (beginners in particular) need help then drop me a line 
  20. ' and I'll try to help - After all thats what the TOTALLY AMOS disk is all about.  
  21. ' IF YOU WANT A REPLY INCLUDE POSTAGE ETC OTHERWISE I WON'T REPLY SO THERE!
  22. ' The Address:       Uncle Simes 
  23. '                    The Warehouse,  
  24. '                    118 Hiltingbury Rd, 
  25. '                    Chandlers Ford, 
  26. '                    Eastleigh,
  27. '                    Hants.
  28. '                    S05 1NT   
  29. '                       * MODULE LEVEL CODE *
  30. ' 1] Set the correct disk path / Directory 
  31. ' 2] Kill system environment 
  32. ' 3] Setup our environment 
  33. ' 4] Do the main thing   
  34. ' 5] Quit back to editor 
  35. Dir$="SIMES_PROGS1:"
  36. Close Workbench 
  37. Close Editor 
  38. Screen Close 0
  39. INITIALISE
  40. MAIN
  41. End 
  42. '                      * PROCEDURE LEVEL CODE *
  43. Procedure MAIN
  44.     ' This is the main procedure. First I set up all the scroll text stuff   
  45.     ' then I call the rainbow procedures. I then initialise the scroll text  
  46.     ' variables, these variables do the following. 
  47.     ' LOCATION  - The position where we are in TTEXT$ i.e if location = 1 we   
  48.     '             would be on the character H. 2 and we would be on character O etc
  49.     ' SCRCOUNT  - Keeps a track of how far the screen has scrolled so we know when 
  50.     '             to place the next character on the screen. 
  51.     ' SCRSPEED  - The speed at which we wish to scroll the text e.g 1or 2 or 4 or 8 etc pixels 
  52.     '             at a time (the larger the number the jerkier the movement) 
  53.     ' COUNT     - Controls the update of the dual playfield. Works in conjunction with the   
  54.     '             Screen Offset command. (AMOS manual page 126) In this case I am updating 
  55.     '             the X position (left / right) where a +ve number causes a right to left
  56.     '             scroll and a -ve number a left to right scroll.  
  57.     ' Next I define a scroll zone for the scrolly text. (AMOS manual page 133) 
  58.     ' The screens are then displayed one after the other (could have neater).
  59.     ' Then were into the Repeat loop which constantly scrolls the text and playfields
  60.     ' until the left mouse button is pressed. Note the line Ctext 349,44,Mid$(TTEXT$,LOCATION,1),  
  61.     ' this is the piece of code that places the correct letter on the screen . Try typing  
  62.     ' the following in DIRECT mode NOTE: <Rtn> means press the return key! 
  63.     '     Default <Rtn>
  64.     '     A$="ZARDOZ" <Rtn>
  65.     '     PRINT Mid$(A$,1,1) <Rtn>       System Should reply - Z i.e  1st character of string is a Z 
  66.     '     PRINT Mid$(A$,3,1) <Rtn>       System Should reply - R i.e  3rd character of string is an R
  67.     '     See AMOS manual page 54 for full example of Mid$ 
  68.     ' Once the left mouse button has been pressed I delete all rainbows, close all screens   
  69.     ' erase all memory banks, Call the MUZAK_DOWN procedure to fade out the music and then   
  70.     ' return to the MAIN MODULE level code were an end statement is encountered. 
  71.     ' This instruction kills multitasking! 
  72.     Dreg(0)=Execall(-132)
  73.     TTEXT$="             10 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0 -       ID - AMOS         STATUS - BONKERS! "
  74.     TTEXT$=TTEXT$+"           HOLY ZARDOZ! AND SINGING FISH! - - - - UNCLE SIMES IS BACK ON LINE! - - - - AND "
  75.     TTEXT$=TTEXT$+"WOW! COP A LOAD OF THIS THEN! IF YOU HAVE BEEN HAVING A BIT OF BOTHER "
  76.     TTEXT$=TTEXT$+"WITH YOUR DUAL PLAYFIELDS THEN THIS COULD BE YOUR LUCKY DAY BECAUSE THIS CODE "
  77.     TTEXT$=TTEXT$+"IS A DEMONSTRATION OF HOW TO SET UP AND SCROLL A DUAL PLAYFIELD USING "
  78.     TTEXT$=TTEXT$+"HARDWARE SCROLLING RATHER THAN AMAL! - - - - THE MUSIC YOU "
  79.     TTEXT$=TTEXT$+"CAN HEAR IS FROM BENSON DEMO II (APD 125) AN EXCELLENT EXAMPLE OF HOW "
  80.     TTEXT$=TTEXT$+"TO CODE PROPERLY! - BENSON HOPE YOU DONT MIND ME USING "
  81.     TTEXT$=TTEXT$+"YOUR MUSIC AS ITS ALL I HAVE AT PRESENT (ANY BUDDING MUSICIANS "
  82.     TTEXT$=TTEXT$+"OUT THERE TAKE NOTE!) ANYWAY WHEN ARE WE GOING TO SEE ANOTHER BENSON DEMO? "
  83.     TTEXT$=TTEXT$+"SOON I HOPE - - - - SQUEEZE YOUR LEFT BUTTOCK TO GET OUT OF HERE! - - - - "
  84.     TTEXT$=TTEXT$+"THANKS FOR THE PHONE CALL AND THE COMMENTS LEN HOPE YOU LIKE THIS ONE! - - - - "
  85.     TTEXT$=TTEXT$+"GREETINGS TO ALL AMOS PROGRAMMERS OUT THERE - - - - SYNTEX TELL ME IS THE RUMOR "
  86.     TTEXT$=TTEXT$+"TRUE THAT YOU ARE NOT GOING TO DO ANY MORE DEMOS? - - - - IF SO ITS A GREAT LOSS!!!! - - - - "
  87.     TTEXT$=TTEXT$+"- - - - HAVE FUN WITH THE CODE PEPS - - - - FINALLY GREETINGS TO - AARON (THANKS FOR THE HELP "
  88.     TTEXT$=TTEXT$+" WITH THE COMPILER PROBLEM) - LEN AND ANNE - FRANCOIS AND DAISY! (WOOF! RUFF! WOOF!) - "
  89.     TTEXT$=TTEXT$+"PHIL SOUTH (LIKE THE NEW LOOK COLUMN - 4 PAGES WOW!) - SANDRA (MY DISKS ARRIVED IN 24 HRS - BRILLIANT! - ) "
  90.     TTEXT$=TTEXT$+"PETER HICKMAN (GREAT NEW MAG MR EDITOR SIR - GROVEL! GROVEL!) - AND ANY BOUNCERS THAT HAVE TO WEAR PINK THESE DAYS! - "
  91.     TTEXT$=TTEXT$+"- - - - SIMES OUT - - - -                    - - - - REPEATING - - - -              "
  92.     SKY_RBOW
  93.     Wait Vbl 
  94.     WATER_RBOW
  95.     Wait Vbl 
  96.     Screen 3
  97.     LOCATION=0
  98.     SCRCOUNT=0
  99.     SCRSPEED=4
  100.     COUNT=0
  101.     Def Scroll 1,0,0 To 382,45,-SCRSPEED,0
  102.     For LOP=1 To 2
  103.         Screen Show LOP
  104.         Wait Vbl 
  105.     Next LOP
  106.     Wait Vbl 
  107.     Repeat 
  108.         Scroll 1
  109.         Add SCRCOUNT,SCRSPEED
  110.         If SCRCOUNT>16
  111.             Inc LOCATION
  112.             SCRCOUNT=0
  113.             If LOCATION>Len(TTEXT$)
  114.                 LOCATION=1
  115.             End If 
  116.              Extension_8_0006 349,44,Mid$(TTEXT$,LOCATION,1)
  117.         End If 
  118.         Inc COUNT
  119.         If COUNT>159 Then COUNT=0
  120.         Screen Offset 2,320-COUNT*2,0
  121.         Screen Offset 1,COUNT*2,0
  122.         Wait Vbl 
  123.     Until Mouse Key=1
  124.     Rainbow Del 
  125.     For LOP=0 To 3
  126.         Screen Close LOP
  127.     Next LOP
  128.     Erase 10
  129.     MUZAK_DOWN
  130.     Wait 100
  131.     ' Restore multitasking 
  132.     Dreg(0)=Execall(-138)
  133. End Proc
  134. Procedure INITIALISE
  135.     ' This procedure sets everything up. Does the following... 
  136.     ' 1] Calls FONT_SET procedure to grab CTEXT font 
  137.     ' 2] Calls MUZAK_UP procedure to fade in music 
  138.     ' 3] Opens screen 1 and 2, positions them in the Y axis (up and down)  
  139.     '    and declares them to be a dual playfield. 
  140.     ' 4] I then Set the correct screen to work with and call the procedures
  141.     '    that draw the foreground (procedure PILLARS) and the background 
  142.     '    (procedure MOUNTAINS) images. 
  143.     ' 5] Next I set the palette. I obtained the colour settings from Delux Paint 
  144.     '    as I was drawing each of the images. All you need to do is decide   
  145.     '    on your resolutions (see AMOS manual pages 127-129) and remember
  146.     '    that colour 0 is transparent (i.e if you draw in colour 0 on the  
  147.     '    image that is going to be in the foreground you will see through to 
  148.     '    the background image). I always set colour 0 of both pictures to $000 
  149.     '    (black) in this way I always remember what's happening. Finally to  
  150.     '    get a copy of the colours I use the palette requester from the colour 
  151.     '    control menu option in Delux Paint and write them down. 
  152.     ' 6] Finally I open screen 3 and position it in the y axis again. This screen
  153.     '    is used to display the bottom scroll text and has only 2 colours. I then  
  154.     '    create a clone of screen 3 (screen 0 see AMOS manual page 127) and position 
  155.     '    it at the top of the screen.  
  156.     FONT_SET
  157.     MUZAK_UP
  158.     Wait Vbl 
  159.     Screen Open 1,640,104,8,Lowres
  160.     Screen Hide 1
  161.     SET_SCREEN
  162.     Screen Open 2,640,104,8,Lowres
  163.     SET_SCREEN
  164.     Screen Display 1,,135,,
  165.     Screen Display 2,,135,,
  166.     Wait Vbl 
  167.     Dual Playfield 1,2
  168.     Screen 1
  169.     MOUNTAINS
  170.     Screen 2
  171.     PILLARS
  172.     Screen 1
  173.     Palette $0,$FFF,$DDD,$BBB,$AAA,$888,$666,$80,$0,$FFF,$DDF,$AAF,$88F,$55F,$33F,$F
  174.     Wait Vbl 
  175.     Screen Open 3,384,45,2,Lowres
  176.     SET_SCREEN
  177.     Screen Display 3,,251,,
  178.     Palette $0,$F00
  179.     Screen Clone 0
  180.     Screen Display 0,,60,,
  181.     Wait Vbl 
  182. End Proc
  183. Procedure PILLARS
  184.     ' This little procedure loads the picture of the pillars (foreground 
  185.     ' screen on the dual playfield) into memory bank 14 and is then unpacked   
  186.     ' to screen 3 (which dosen't need to be set up as AMOS does this). I 
  187.     ' then hide the screen and switch to screen 1.   
  188.     '     Next I copy the picture twice to screen 1 (screen 1 is a 640 * 104 
  189.     ' bitmap but screen 3 is a 320 * 104 bitmap therefore we need to get the same  
  190.     ' image twice from screen 3 to fill screen 1. i.e 2 * 320 = 640 ). I then erase  
  191.     ' the memory bank (14) and close screen 3 as I won't need the image again  
  192.     ' and chip memory should be used carefully.
  193.     Load Dir$+"PICS/ARCHES.ABK",14
  194.     Unpack 14 To 3
  195.     Screen Hide 3
  196.     Screen Copy 3,0,0,320,104 To 1,0,0
  197.     Wait 10
  198.     Screen Copy 3,0,0,320,104 To 1,320,0
  199.     Wait 10
  200.     Erase 14
  201.     Screen Close 3
  202. End Proc
  203. Procedure MOUNTAINS
  204.     ' Same as PILLARS procedure except this time we are working with the   
  205.     ' background dual playfield screen.  
  206.     Load Dir$+"PICS/MNT_REFLECT.ABK",13
  207.     Unpack 13 To 4
  208.     Screen Hide 4
  209.     Screen Copy 4,0,0,320,102 To 2,0,0
  210.     Wait 10
  211.     Screen Copy 4,0,0,320,102 To 2,320,0
  212.     Wait 10
  213.     Erase 13
  214.     Screen Close 4
  215. End Proc
  216. Procedure SET_SCREEN
  217.     ' The old screen set procedure. Every disk of ascii procedures should
  218.     ' have one.
  219.     Curs Off 
  220.     Flash Off 
  221.     Hide On 
  222.     Cls 0
  223. End Proc
  224. Procedure FONT_SET
  225.     ' This procedure sets up the system so it can use CTEXT fonts. If you
  226.     ' want to know more about CTEXT get a copy of Feburary 1992's Amiga  
  227.     ' Shopper, turn to page 109 and read Phil South's AMOS ACTION collum.
  228.     ' Nice review Phil.
  229.     Load Dir$+"FONTS/TRANS_DOUB_FNT.ABK"
  230.     No Icon Mask 
  231.     Wait 1
  232.     Bank Swap 2,10
  233.     Wait 1
  234.     Bload Dir$+"FONTS/TRANS_DOUB_FNT.ABK.CFNT", Extension_8_0044 
  235.      Extension_8_0016 0,0
  236.     Erase 2
  237.     Wait 1
  238. End Proc
  239. Procedure MUZAK_UP
  240.     ' This one fades in the music slowly. Thanks Benson Hope its ok to 
  241.     ' use the music. 
  242.     Load Dir$+"MUSIC/BENSON.ABK"
  243.     Wait 1
  244.     Mvolume 0
  245.     Music 1
  246.     Tempo 18
  247.     Led Off 
  248.     For M=0 To 63 Step 1
  249.        Wait 5
  250.        Mvolume M
  251.     Next M
  252. End Proc
  253. Procedure MUZAK_DOWN
  254.     ' Guess what this procedure does.... 
  255.     For M=63 To 0 Step -1
  256.         Wait 5
  257.         Mvolume M
  258.     Next M
  259.     Music Off 
  260.     Erase 3
  261. End Proc
  262. Procedure SKY_RBOW
  263.     ' This is the rainbow that appears behind the mountains. Was created 
  264.     ' using good old Spages Rainbow Warrior. Available from Sandra at the  
  265.     ' AMOS PD Library (APD 77 & every copy includes a free limpet mine)  
  266.     Set Rainbow 0,0,65,"","",""
  267.     Rainbow 0,0,114,65
  268.     Colour Back 0
  269.     Restore RDATA
  270.     For C=0 To 64
  271.         Read CVA
  272.         Rain(0,C)=CVA
  273.     Next C
  274.     View 
  275.     RDATA:
  276.     Data $0,$16,$16,$16,$27,$27,$27,$27
  277.     Data $38,$38,$38,$38,$49,$49,$5A,$49
  278.     Data $5A,$6B,$5A,$6B,$7C,$6B,$7C,$7C
  279.     Data $8D,$8D,$8D,$8D,$9E,$9E,$AF,$AF
  280.     Data $AF,$AF,$AF,$1BF,$1BF,$2CF,$2CF,$3DF
  281.     Data $3DF,$4EF,$4EF,$5EF,$5EF,$6EF,$6EF,$7EF
  282.     Data $7EF,$8EF,$8EF,$9EF,$9EF,$AEF,$AEF,$BEF
  283.     Data $BEF,$CEF,$CEF,$DEF,$DEF,$EEF,$EEF,$EEF
  284.     Data $EEF,$0,$0,$0,$0,$0,$0,$0
  285. End Proc
  286. Procedure WATER_RBOW
  287.     ' See SKY_RBOW for details. Draws rainbow that acts as water reflection. 
  288.     Set Rainbow 1,0,39,"","",""
  289.     Rainbow 1,0,188,39
  290.     Colour Back 0
  291.     Restore RDATA
  292.     For C=0 To 38
  293.         Read CVA
  294.         Rain(1,C)=CVA
  295.     Next C
  296.     View 
  297.     RDATA:
  298.     Data $8D,$8D,$8D,$8D,$9E,$9E,$AF,$AF
  299.     Data $AF,$AF,$AF,$1BF,$1BF,$2CF,$2CF,$3DF
  300.     Data $3DF,$4EF,$4EF,$5EF,$5EF,$6EF,$6EF,$7EF
  301.     Data $7EF,$8EF,$8EF,$9EF,$9EF,$AEF,$AEF,$BEF
  302.     Data $BEF,$CEF,$CEF,$DEF,$DEF,$EEF,$EEF,$EEF
  303. End Proc