\ Note that this example program does not make use of include symbols, \ in order to allow it to be run on any HeliOS system. FORGET **CORE** \ Clear the user dictionary D0 DVARIABLE SCREEN \ Screen handle storage variable D0 DVARIABLE WINDOW \ Window handle storage variable D0 DVARIABLE BITMAP \ Variables to store useful values, which. D0 DVARIABLE RASTPORT \ are collected at startup time in case of D0 DVARIABLE VIEW \ the need to use them later in graphics D0 DVARIABLE VIEWPORT \ related functions. \ OPENSYSTEM - Opens a screen and a window and sets up Input/Output. \ Includes an example of how to make an Amiga library call. \ Returns "1" on the stack for success and "0" for failure : OPENSYSTEM \ Start a word definition, the new word is \ called, appropriately, "OPENSYSTEM" TIMEOFF \ Disable the time display in the Interactive \ HeliOS screen 0 HISTORY \ Disable the line editor's circular buffer 1 BAKSET \ Enable creation of Backup files on all disk \ SAVE operations - a useful safety feature \ These are all "general purpose" startup operations often used 1 STDSCREEN \ Initialises a standard NewScreen structure \ and sets Hires mode LIT$ $Tutorial Screen$ \ Specify the screen title bar text 640 250 \ Specify screen width and height 3 \ Depth of screen (= number of bitplanes) OPENSCREEN \ Open a screen using the initialised structure SCREEN D! \ Store the screen handle/pointer SCREEN D@ \ Get SCREEN 32-bit pointer onto stack D0> \ Test if SCREEN is greater than zero \ This checks to see if screen opened OK \ If SCREEN is zero we have trouble....... IF \ If SCREEN is not zero we are OK......... SCREEN D@ \ Get 32-bit pointer to screen 44. \ Put double length number 44 on stack D+ \ Add this to screen pointer to give \ ViewPort pointer VIEWPORT D! \ Store the ViewPort for the new screen STDWINDOW \ Initialise a standard NewWindow structure HFWINDOW \ Modify the standard window for it to appear \ on the HeliOS Screen SCREEN D@ \ Get screen again WINDOWSTRUCT \ Returns 16-bit pointer to NewWindow 30 + \ Add 30 to this D! \ Store screen pointer into NewWindow structure LIT$ $Tutorial Window$ \ Title bar text for window 0 12 640 238 \ Guess what....Window dimensions! 3 \ 3 BitPlanes 0 \ No SUPERBITMAP OPENWINDOW \ Open the new window WINDOW D! \ and store window pointer/handle WINDOW D@ \ Check if opened OK, like screen above D0> \ See "screen open" check above........ IF WINDOW D@ MAKEGFXWINDOW \ Enable graphics in this window WINDOW D@ MAKEOUTWINDOW \ Enable text output to this window WINDOW D@ MAKEINWINDOW \ Enable user input from this window WINDOW D@ \ Get Window pointer 50. D+ \ Add 50 to Window Pointer to get RastPort D@L \ Get RASTPORT pointer RASTPORT D! \ Get Window's RastPort, and store it in \ variable RASTPORT RASTPORT D@ 4. D+ D@L BITMAP D! \ Get the bitmap from the stored RastPort INTUBASE \ Put on the stack the 16-bit address \ where the 32-bit pointer to Intuition \ library base is stored -294 \ Put on the stack the offset of the library \ call "ViewAddress" LIBRARY \ Call Intuition Library function to get \ VIEW pointer D0RESULT \ Get dummy register D0 value which is the \ View address returned from the library call VIEW D! \ Store pointer in variable VIEW 1 \ Put value "1" on stack to indicate that \ everything opened OK ELSE 0 \ Put "0" on stack to indicate failure THEN ELSE 0 \ Put "0" on stack to indicate failure THEN ; \ End of Colon Definition \ In a similar manner we have a defined a HeliOS word for the related \ close down routine - : CLOSESYSTEM \ Start the colon definition FORTHINWINDOW \ Redirect the input and output from FORTHOUTWINDOW \ program's window back to the HeliOS FWINDOW MAKEGFXWINDOW \ interactive environment WINDOW D@ \ Get contents of window handle store DFLAG \ Check and if Non-Zero put 1 on stack else \ put 0 on stack above window handle IF \ If window is open, ie handle is non zero CLOSEWINDOW \ Close it WINDOW D0! \ then set store to zero ELSE DDROP \ else cleanup stack (drop window handle) THEN \ end of If/Then structure SCREEN D@ \ Look at screen handle DFLAG IF \ If screen is open...... CLOSESCREEN SCREEN D0! ELSE DDROP THEN TIMEON \ Enable time display for the \ Interactive HeliOS screen \ before exiting ; \ End of colon definition \ Now we can use these functions in a small program: : TUTORIALPROGRAM OPENSYSTEM \ Open environment, returning 1 or 0 \ indicating success or failure IF \ If 1 is returned, for "success" 1 GFXSETOPEN \ Set graphics outline pen colour to 1 1 GFXOUTLINE \ Switch on graphics OUTLINE mode 2 GFXSETAPEN \ Set graphics pen to "2" for circle 400 160 80 40 \ Circle coordinates GFXAREAELLIPSE \ Draw circle into off screen buffer GFXAREAEND \ Render circle to screen 0 GFXOUTLINE \ Switch off graphics OUTLINE mode 3 GFXSETAPEN \ Set graphics pen to "3" for text 100 200 GFXMOVE \ Set graphics pen position LIT$ $This is graphic text$ \ Text string COUNT \ Get text start and length GFXTEXT \ Output text 20 10 CURPUT \ Place cursor ." Hello....Press to exit!" \ Some console text output BEGIN \ Start a BEGIN/UNTIL construct KEY \ Wait for a keypress 32 \ ASCII code for is 32 = \ See if KEY value = 32 UNTIL \ Loop until result is TRUE THEN CLOSESYSTEM \ Close environment ; TUTORIALPROGRAM \ Actually execute our new "program" word. \ End of program