The AMAL Editor

The AMAL Editor accessory allows you to pack your AMAL programs into a single memory bank, so that routines can be entered directly from the keyboard and edited on screen. All of the AMAL Editor features are called up via drop-down menus, which include a built-in monitoring system for rapid debugging, and a movement-pattern recorder.

The AMAL Editor can be used as an accessory, in which case memory banks defined by your main program will be grabbed automatically, or it can be used as a normal AMOS Professional program.

Please select the AMAL Editor now, from the AMOSPro_Accessories disc.

The AMAL String Editor Screen

After loading, the AMAL Editor displays its main String Editor Screen, which is always allocated to screen number seven, and which is where AMAL program strings are created for storing in the AMAL bank. Please remember not to use this screen number for your own programs, when using the Editor. The screen is divided into three horizontal zones, as follows:

The Information Line
At the top of the screen, a black Information Line lists the current mode and also displays the AMAL channel number currently being edited. All of the drop-down menus are triggered by clicking in this Information Line, using the right mouse button. By using the left mouse button and then dragging the Information Line up and down, the entire String Editor Screen can be moved vertically, to reveal the current program display.

The Selection Window
Below the Information Line, there is a grey Selection Window. This is where any of the AMAL programs that are stored in memory can be selected for editing. In the centre of this window there are two rows of characters, one above the other. These items are read vertically, so the item on the left-hand side reads EE, which refers to the Environment Editor, which is explained at the end of this Chapter. The Next item refers to channel 00, then channel 01, all the way along to channel 15.

When one of these programs is selected with the left mouse button, it is highlighted in inverse video, and loaded to the Editor Window. There is a [Synchro On/Off] feature, which is explained later, and if the [Synchro Off] option is selected, the number of channels is extended from 16 to 62. In this case, only the first 16 of these routines can be performed using the standard AMAL interrupt system.

The Editor Window
This is the large orange panel that occupies most of the screen, and it operates in a similar way to a normal AMOS Professional Edit window. AMAL programs can be entered at the current cursor position directly from the keyboard, and the mouse can be used to move the position of the editing cursor directly.

Here is a list of the editing controls:

Return                   Insert a line
Ctrl + Y                 Delete a line
[Tab]                      Jump to next Tab position
[Cursor arrows]            Move cursor one place up, down, left or right
Shift + Cursor arrows    Move cursor to start / end of line, or top / bottom of screen

Lower drag bar
At the bottom of the String Editor Screen, there is a black bar, which can be dragged vertically using the left mouse button, to reveal the current program display.

The AMAL Editor Menus

There are five drop-down menus, located along the left-hand side of the Information Line. These are called up and activated using the right mouse button. Here is a guided tour of all the menu options, from left to right.

AMOS menu

This simple menu offers the following three options:

[About AMAL Editor]
This displays a memory status report, showing the current text buffer free space, free chip memory and free fast memory.

[Quit Esc]
To get back to the AMOS Professional Edit window, click on the [Quit] option, or press the Esc key. You will be asked to confirm your action with a [Y/N1.

[Back to system]
This will leave AMOS Professional altogether, and take you to the Workbench screen. If you insist on leaving the comforts of AMOS Professional, you should trigger the [Really?] option.

Edit menu

Once AMAL programs have been loaded into memory, they can be run using one of the options in the Edit menu, triggered by the right mouse button, as before. Here is the choice of available options:

[Run All] or F1
This calls the AMAL Environment string, which is explained later, and executes all existing AMAL programs simultaneously.

[Run Current] or F2
Trigger this option to initialise the screen and execute the single AMAL program that is currently being edited. Once the program is running, you may return to the AMAL Editor window at any time by pressing a key.

[Run Selected] or F3
This performs the same task as [Run Current] or F2, but instead of the current single program, the highlighted program in the Selection Window will be run.

[Monitor] or F4 The AMAL Monitor
As soon as this option is selected, a new screen is displayed featuring all of the AMAL Monitor options. This monitoring device allows you to step through your program one instruction at a time. At the top of the Monitor screen there is a selection window, showing the list of currently active programs. All of these programs will be executed simultaneously, so you must de-activate any that you are not immediately interested in. Click on any of these, to turn off the highlight selection.

Because all of the AMAL registers can be accessed directly from this screen, it is very simple to isolate any errors and cure them. All options are selected by clicking on the screen, or by pressing the associated key. To cancel a selection, simply press the Esc key. Here are the operating steps for using the AMAL Monitor:

[R] or [Run until key press]
[G] or [Go until Reg=Value]
[S] or [Perform one step]
Esc or [Quit Monitor]

We will now examine the final option in the [Edit] menu, which is to be found below the [Monitor] option.

[Play Editor] or F5
Two sub-menus are offered here, [Back to String Editor Esc] will take you straight back to the main String Editor Window. The alternative option allows you to exploit some AMAL magic! This [Movement] menu is explained next.

[Movement]
Here are the options available from this sub-menu, from top to bottom:

[Record] or F1
This records a movement pattern and stores it in the AMAL memory bank. A full explanation of recording and playing movement patterns is explained below.

[Playback] or F2
Use this option to replay a pre-recorded movement pattern.

[Insert] or F3
This option is used to insert a new pattern at the current position. Any patterns after this insertion point will be shifted one place to the right, unless it is the 48th pattern in the list, in which case it will fall off the end of the list and be lost!

Delete or F4
Use this to erase the current movement pattern. All subsequent patterns in the list will now be shifted one position to the left.

Recording and playing movement patterns

The [Play Editor] option allows you to record a complex movement pattern, by repeatedly logging the position of the mouse cursor as it is moved across the screen, and storing this movement data in the AMAL memory bank. The movement pattern can then be used to animate almost any Object you like! Here is the procedure for using this technique:

The Disc Menu

This simple menu is called from the Information Line, using the right mouse button. It offers three self-explanatory options, as follows:

[Load AMAL bank]
This calls the File Selector, from which the selected AMAL bank can be loaded.

[Save AMAL bank]
The current bank will be saved to an appropriate disc, whose directory is read into the File Selector on screen.

[Save As]
To change the name of the current AMAL bank before saving to disc, use this option.

The Option Menu

This simple menu is employed to control the SYNCHRO facility, used to bypass the limitations of the Amiga's, interrupt system. If you need reminding of how this works, please refer to the SYNCHRO ON and SYNCHRO OFF section in Chapter 7.6 of this User Guide.

[Synchro On]
This option is toggled with the [SYNCHRO OFF] setting, when triggered by the right mouse button.

[Set Period]
This allows the period between each SYNCHRO to be set for all AMAL programs, and is prompted by on-screen instructions.

[Set Selected]
This works as above, but only affects the highlighted selection of AMAL programs.

The Block Menu

The last of the five menus in the AMAL Editor is a straightforward utility for manipulating blocks of your AMAL string, rapidly and simply. As with the Blocks menu available from the AMOS Professional Edit Screen, the start and end positions of the block are first marked, and then manipulated by cutting, pasting, hiding or printing. Here is the Block Menu layout:

[Block Start] or F6
[Block End] or F7
[Block Hide] or F8
[Block Cut] or F9
[Block Paste] or F10
[Block Print]
[String Print]

The Environment Generator

The vast majority of AMAL routines will normally need initialisation from the main AMOS Professional program. To make operations more convenient, the AMAL Editor includes a stripped-down version of the AMOS Professional interpreter called the Environment Generator. This allows you to perform all of the initialisation routines directly from the AMAL Editor, without the need to return to the main AMOS Professional program.

A program written with the Environment Generator can be entered from the AMAL Editor exactly as if it is a normal AMOS Professional program, as follows:

These AMAL Editor commands are similar to their AMOS Professional equivalents, except for the fact that they have been simplified to save memory. Here is a full list of commands that can be used by the AMAL Editor system:

AMAL Environment Command     Notes
'                            REM, used at the start of a line
SCREEN OPEN                  same as AMOS Professional
SCREEN DISPLAY               same as AMOS Professional
SCREEN OFFSET                same as AMOS Professional
SCREEN                       same as AMOS Professional
SCREEN CLOSE                 close all screens
SCREEN CLONE                 same as AMOS Professional
DOUBLE BUFFER                same as AMOS Professional
DUAL PLAY FIELD              same as AMOS Professional
DUAL PRIORITY                same as AMOS Professional
LOAD IFF "filename",screen   the screen number MUST be given
LOAD "filename",bank         the bank number MUST be given
ERASE bank                   same as AMOS Professional
HIDE ON                      same as AMOS Professional
UPDATE EVERY                 same as AMOS Professional
FLASH                        same as AMOS Professional
FLASH OFF                    same as AMOS Professional
SET RAINBOW                  same as AMOS Professional
RAINBOW                      same as AMOS Professional
RAINBOW DEL                  delete any RAINBOW effects
BOB                          same as AMOS Professional
SET BOB                      same as AMOS Professional
BOB OFF                      remove all Bobs from screen
SPRITE                       same as AMOS Professional
SPRITE OFF                   remove all Sprites from screen
SET SPRITE BUFFER            same as AMOS Professional
SET REG number,value         set AMAL register A to Z or 0 to 25
CHANNEL TO SPRITE channel,Sprite
CHANNEL TO BOB channel,Bob
CHANNEL TO SCREEN OFFSET channel,screen
CHANNEL TO SCREEN SIZE channel,screen
CHANNEL TO RAINBOW channel,rainbow

A range of useful Test instructions is available, and they all use the same general syntax, as follows:

INSTRUCTION condition : list of statements

The statements after the condition will only be executed if the condition is True, otherwise the following commands will be completely ignored and the program will jump directly to the next line of this Environment routine:

AMAL Environment Command                     Notes

IF SCREEN number                             True if the screen has been opened
IF NOT SCREEN number                         True if the screen is currently closed
IF BANK number                               True if the bank has been reserved
IF NOT BANK number                           True if the bank is not reserved
IF REG number,value                          True if Reg A to Z or 0 to 25 equals value

To get you started, type in these texts:

E> Screen Open 0,320,200,16,Lowres
   Double Buffer
   Load "AMOSPro_Tutorial:Objects/Bobs.Abk",1
   Channel To Bob 0,1
   Screen 0
   Bob 1,100,100,1
   AMAL Channel 0
   Let X=0;
   Let Y=0;
   L:
   Let X=X+1;
   Let Y=Y+1;
   Pause;
   Jump;