REM AmigaBASIC (Microsoft) Tutorials REM Installment #1 (SCREENS) REM Tim Jones AmSoft Developement REM Copyright (C) 1986 ' Also includes WINDOW, PALETTE and RANDOMIZE ' AmSoft Developement does not take responsibility for any misinformation ' in this file nor are there any warrantees as to the usefulness of the ' information presented. The information that IS presented has been ' researched and is thought to be correct and true. ' The following is an example of how to ' program Screens in Amiga (MS) BASIC MENU OFF ' MENUS will be covered in installment #2. DefineScreen: ' Labels are just to let you know what the sections do SCREEN 1,320,200,5,1 ' The above entry defines SCREEN #1 as being Low Resolution (320x200) ' pixels, to allow 32 colors ( 2^5 = 32 ) and the 1 at the end ' defines the screen mode ( 1-4 ). The 1 indicates low resolution, ' non-interlaced output. ' Please keep in mind, with a screen depth of 5, you have eaten up ' 64K of memory. Now, if you open a window to the screen, it will ' use a minimum of 1K (no gadgets or title) to an additional 64K, if ' you specify a type which includes 16 (SMART_REFRESH), or 68K, if ' you shoot for a type 31 (Everything, including the ANCHOVIES!). DefineWindow: ' Now, we open a window to see the results of our SCREEN. Title$ = "SCREEN/WINDOW Tim Jones " ' By placing your title in a string variable, it's easier ' to change as the need arises. WINDOW 2,Title$,(0,0)-(268,98),31,1 ' This entry defines WINDOW #2 (we don't want to use the BASIC ' WINDOW, which is #1) with the title 'Title$'. It opens it ' with a starting location of 10,35 (upper left-hand corner) and ' an ending location of 268,98 (lower right-hand corner). One ' special note about actual window size versus screen defined size; ' In High-Res, Non-Interlaced mode, max window size is 617 x 186 and, ' if you are using the SUPERBITMAP (window type 16), you may only ' have 3 bit planes (8 colors) deep on a 512K machine to use this ' size. In Low-Res, Non-Interlaced mode, max WINDOW size is 303 x 187. ' be sure to keep this in mind when you start to set up your window ' displays. The 31 means that the following options are allowed: ' ' Size can be changed with the sizing gadget (1) ' It can be moved using the Title (drag) bar (2) ' Relative location (front to back) is active (4) ' It can be closed using the CLOSE gadget (8) ' Window is reprinted after being changed (16) ' TOTAL 31 ' ' This window CHEWS up memory. If you don't have the extra 256K, it ' will crash your system very nicely! DefineColors: ' Let's make things colorful PALETTE 0,0,0,0 ' This is to give us a Known color as the background RANDOMIZE TIMER ' seed the RND function with the current timer setting FOR ii = 1 TO 31 ' We've already defined PALETTE 0 (Background) PALETTE ii,RND,RND,RND FOR Delay = 1 TO INT(RND * 10) : NEXT Delay NEXT ii ' I didn't want to get too picky with the color selections. ' Hopefully, the background won't be too rediculous. ' The syntax for the PALETTE command is as follows: ' PALETTE #,R,G,B ' where # is the color # (0-31) ' and R,G,B are the Red-Green-Blue levels (decimal value between ' 0 and 1. 0 is all off and one is full.) ' RND was used because it returns a value between 0 and 1 SendOutput: ' Now we put information into the window WINDOW OUTPUT 2 ' Tell BASIC to send all print statements to window #2 COLOR 3,0 LOCATE 3,1 : PRINT "Now, use the mouse to make" COLOR 7,0 PRINT "changes to the Window." COLOR 4,0 PRINT "Hit the CLOSE Gadget to END!" COLOR 6,0 PRINT "Notice that we opened the window" PRINT "with an ending coordinate of" PRINT "268,98. The numbers DON'T always" PRINT "match." ' The data is printed in our newly created window. WaitLoop: ' Let's give you some time to play with the window. WHILE WINDOW(7) <> 0 COLOR 2,0 : LOCATE 1,1 : PRINT WINDOW(2);"Pixels wide,";WINDOW(3); PRINT "Pixels high. " ' By placing this inside of the WHILE-WEND loop, we keep the numbers ' current. WEND ' This just waits for the user to close the window. If the window ' is open, WINDOW(7) returns a non-zero value and the WHILE-WEND ' loop repeats forever. ' ' The other WINDOW(X) commands are: ' ' 0 -> Returns the ID of the currently SELECTED window. ' 1 -> Returns the ID of the current OUTPUT window. This isn't ' necessarily the currently selected window. I would use ' WINDOW(0) to find out which window the user has selected, ' by monitoring the MOUSE(0) for a value of 1 ( to be covered ' in another installment ), and then change the value of my ' WINDOW OUTPUT statement at the best time (i.e. not in the ' middle of printing something) to that new window. ' 2 -> Returns the WIDTH of the current OUTPUT window. ' 3 -> Returns the HEIGHT of the current OUTPUT window. ' 4 -> Returns the X COORDINATE in the current OUTPUT where the ' NEXT CHARACTER will be drawn. ' 5 -> Returns the Y COORDINATE in the current OUTPUT where the ' NEXT CHARACTER will be drawn. ' 6 -> Returns the MAXIMUM legal color for the current OUTPUT window. ' (i.e. SCREEN DEPTH of 4 will place a 15 in WINDOW(6)) ' 7 -> Points to the INTUITION WINDOW record for the current OUTPUT ' window. If a 0 is present in WINDOW(7), all windows have been ' closed. this value is a pointer to the actual memory location ' of the window's bitmap. ' 8 -> Points to the RASTPORT record for the current OUTPUT window. ' This value is the pointer to the memory address of the ' window's RASTPORT. For more information, see the Intuition ' interface manual. CleanUpAndEnd: ' Okay, now let's close things up and exit WINDOW CLOSE 2 SCREEN CLOSE 1 WINDOW OUTPUT 1 ' Redirect output to the default BASIC window. ' Always close ALL WINDOWS first and finally, the SCREEN. STOP ' This file is being presented as an aid to prospective AmigaBASIC ' programmers. I am interested in spreading the use of the language ' because of its extreme versatility. ' This file is the first of the tutorials series. This series has ' been developed, in what I consider, a logical flow pattern. If you ' insure that you understand what is presented in one tutorial before ' you proceed to the next, your confusion level should remain low. ' I hope that the information presented here has aided you in some ' way.