Kevin Doyle
The AMPLE Screen Designer is a utility to allow the creation
of Mode 7 screens for inclusion in AMPLE programs. It is written in AMPLE and incorporates
a comprehensive MODE 7 screen designer, screen filing system and conversion facility
to create AMPLE words which will display all or part of a MODE 7 screen.
Note
If you are not familiar with the use of MODE 7 (Teletext)
control codes it would be advisable to read the relevant chapter in your BBC Micro
User Guide.
To follow the examples in this guide you should also have on
the same disc as the ASD program, the example file ASDdemo.
Getting started
To use the utility go into AMPLE in the usual way, LOAD the
file ASD and then RUN. As ASD uses only AMPLE Nucleus words it can be run without
any Modules present (i.e. from the *AMPLE command).
After the title has come and gone you will be presented with
a blank screen and the cursor in the top left corner.
Moving around the screen
If you try the cursor keys you will find that these move the
cursor in the usual way except that the screen is 'wrapped' in all directions so
that cursor movement is continuous but the screen is static. You may also
notice that the cursor will not move to the bottom right hand corner of the screen.
This last position is protected to avoid the screen scrolling hardware being
activated. All other positions on the screen are available.
By pressing the SHIFT key at the same time as a cursor key
you can move the cursor to the edge of the screen in the direction you select. This
can often save time when moving about the screen.
Writing to the screen
If you use the standard typewriter keys they will write to the
screen in the usual way. Pressing RETURN will move to the beginning of the next
line. The use of screen 'wrapping' means that attempting to write beyond the
bottom of the screen will return you to the top.
The DELETE key has its usual function of backspacing and deleting
the previous character.
Pause now to fill a few lines with text - it doesn't matter
what. This will help in demonstrating the next section.
Teletext control codes
The special control codes used in MODE 7 screens are accessible
using the function keys. You should have received a function key card for this program
which shows the keys used to produce these codes. Try pressing SHIFT key with
some of the functions keys (f0-f9) amongst the text you have written to create coloured,
flashing and double height text.
The double/normal height key is different from the others in
that it can produce either the code for double height or the code for normal
height. Which of these two codes it produces depends on which option (double or
normal height) is currently in use. If double height is the current option it produces
a normal height code and vice versa. If there are no previous height control codes
on the line a double height code is produced.
Graphics control codes can be produced using the function
keys (CTRL f0-f6). The subsequent characters will then be displayed as graphics
where appropriate. Most of the graphics characters are produced using lower case
letters - see the BBC Micro User Guide Appendix for the full table.
To make things easier when designing graphics symbols, you can
use the function keys (f0-f5) which allow you to switch the individual graphics
blocks within a character on and off. Try using these keys on an existing graphics
character or on a blank space following a graphics control code.
As an alternative you can use CTRL and the keys Q,W,A,S,Z,X.
These keys reflect the position of the blocks they alter.
If the character you wish alter is not already a graphics
one, you can set it to a graphics blank by pressing CTRL and the SPACE bar.
A full block character can be obtained by using SHIFT and
the SPACE bar.
Identifying characters
As you may have noticed, the cursor on the screen is sometimes
a line, sometimes a block. The block cursor indicates that it is on a control character.
The line cursor is used when it on any other character. Its main purpose is to distinguish
positions containing control codes from those containing spaces.
To identify the character at the cursor you can press the
TAB key. This displays, at the top of the screen, the character's code and either
the character itself (in both its alpha or graphics form) or its description.
The display stays on the screen for one second - to remove it
more quickly, press a key.
Menu options
The AMPLE Screen Designer has several functions which are
accessible through its menu system. To access the menu press the ESCAPE key.
The choices are then displayed at the top of the screen. Each menu has a title
which is displayed on the left (in white) - in this case it is "Main".
The menu options are then displayed (in magenta) with the first option highlighted
(in yellow).
An option can be selected by pressing the RETURN key when it
is highlighted. You can highlight the different options by using the left and
right cursor keys.
Pressing the ESCAPE key takes you out of the menu and back
to the editing screen no matter which menu you are in.
Try using the cursor keys now, and then select the option "Screen"
by pressing RETURN when it is highlighted.
Some menu options lead to further menus. In the case of the
"Screen" option there is a second menu giving the options
"Memory, "Disc", "Convert" and "New". In
this case we will select the option "Disc" but using the alternate selection
method available. This is to press the key which corresponds to the first
letter of the option you require. So, in this case, you should press the 'D' key.
It doesn't matter whether the key is set to produce upper or lower case. Pressing
a key which does not correspond to a menu option will produce a lower pitch
beep.
Loading a screen from disc
The "Disc" menu has the options "Save", "Load",
"Catalogue" and "Drive". Make sure you have the disc containing
the sample file ASDdemo in the currently selected disc drive. (If you need to change
your drive selection then choose the "Drive" menu option and select
the drive number which contains the ASDdemo file. Then retrace your steps back to
the "Disc" menu.)
You should now choose the "Load" option. At the
"filename:" prompt type in "ASDdemo" and press RETURN. The screen
should now start to change as ASDdemo is read in from disc. When it is loaded a
message will appear at the top of the screen - this can be removed by pressing
RETURN.
The procedure for saving a screen is very similar, except
that the 'Save' option is selected from the 'Disc' menu. Before you try saving
a screen you should read the notes in the section 'Some cautions on disc
filing' below.
The sample screen you have just loaded can now be used to
demonstrate some of the screen editing facilities.
Screen editing
Several screen editing facilities are provided to allow you to
manipulate information on the screen.
Using the CTRL key in conjunction with the left cursor key removes
the character at the cursor. To demonstrate this, position the cursor in the middle
of a full line of text and press CTRL and the left cursor key. Notice that the
rest of the line moves to the left leaving a blank character at the end of the
line.
Using the CTRL key in conjunction with the right cursor key
inserts a blank character at the cursor. To demonstrate this, position the
cursor in the middle of a full line of text and press CTRL and the right cursor
key. Notice that the rest of the line moves to the right losing the character
at the end of the line.
Using the CTRL key in conjunction with the down cursor key
inserts a blank line at the cursor. To demonstrate this, position the cursor in
the middle of the page and press CTRL and the down cursor key. Notice that the rest
of page, below the cursor, moves down losing the bottom line.
Using the CTRL key in conjunction with the up cursor key
removes the line at the cursor. To demonstrate this, position the cursor in the
middle of the page and press CTRL and the up cursor key. Notice that the rest
of page, below the cursor, moves up leaving a blank line at the bottom.
As mentioned earlier, the DELETE key performs its usual function
of backspace to, and deletion of, the previous character. In combination with
the SHIFT key, however, it has the effect of deleting all characters from the cursor
to the end of the line.
Copying
The copy facility in the AMPLE Screen Designer allows the
copying of blocks of the screen. This is essential in graphics work. To copy a block
you need first to define the area to be copied and then the place to copy to.
To mark the area to be copied, simply position the cursor over
the first character and press COPY. Then move to the last character and press
SHIFT and COPY. The area could be just a group of consecutive characters on the
same line or a large block in the centre of the screen. If you are marking an
area spanning several lines, it does not matter which corners of the block you mark
- top-left and bottom-right or top-right and bottom left.
Now move the cursor to where you want the copy to be put. If
you are copying a multi-line block of characters, the cursor should be where the
top left of the block is to be copied. Then press CTRL and COPY and the block you
defined will be copied.
The positions of the markers you defined using COPY and
SHIFT COPY are stored so that the same block can be copied again using only
CTRL and COPY.
Some cautions about copying
The copy function is not 'wrapped' and so any part of the marked
area which cannot be copied within the boundaries of the screen is lost.
The markers are stored as absolute screen references - that
is, they are not affected by screen editing activities such as line insertion
or removal. Care should therefore be taken when screen editing has taken place
since the copy area was marked.
If when CTRL and COPY are pressed, both markers are found to
be in the same position, it is assumed that they have not been correctly set and
the message 'No copy area defined' is shown.
The copying is performed starting at the top left of the copy
area, and proceeds left to right, top to bottom. Placing the cursor within the
copy area before copying will thus lead to part of the copy area being overwritten
before it can be copied.
To help with the copying process there is a facility to
enable you to keep track of the two copy area markers. Pressing SHIFT and TAB will
display the current positions of these markers at the top of the screen. If you
press the COPY or SHIFT and COPY keys while the positions are being displayed,
the block cursor will move to the relevant position on the screen. If another
key is pressed or if no key is pressed for one second the display is removed.
Use of screen memory
The AMPLE Screen Designer provides for two screens in memory
at any one time. This allows the copying of elements in one screen to another.
By careful use of the two screens a new screen can be constructed from many
existing ones.
To illustrate this, we can firstly store the current screen
in memory. To do this call up the menu by pressing ESCAPE. Then select
"Screen" followed by "Memory" followed by
"Store". After a few seconds a message will appear at the top of the screen
to inform you that the screen has been stored. Press RETURN to remove this message.
Now alter the screen by, for example, deleting some lines or adding new text. You
can then restore the screen from memory by selecting "Screen", "Memory"
and "Restore" from the menu.
Your original screen should now be displayed.
You can now re-load the sample screen from disc (which should
look quite different from the current screen if you have been trying out the
editing and copy functions). Select "Screen", "Disc", "Load"
as before and then enter the filename "ASDdemo".
When the screen has loaded, select "Screen", "Memory",
"Exchange" from the menu. This swaps the screen in memory with the
one displayed. Thus, the screen you saved earlier will gradually be displayed and
the screen you have just loaded will be transferred to memory.
If you select "Restore" or "Exchange" when
no screen is in memory the message "No screen has been stored" will be
displayed. You can check whether a screen is in memory by selecting "Screen",
"Memory", "Check" from the menu.
Copying from screen memory
The copy markers which were used earlier to copy areas
within a screen can also be used to copy from memory to the screen. To
demonstrate this, mark an area on the screen displayed now. You can check the results
by pressing SHIFT and TAB.
Then select "Screen", "Memory", "Exchange"
as before. As well as swapping the screen in memory with the screen displayed it
also swaps the copy markers into memory.
If you press SHIFT and TAB now, you will see that the copy
markers are shown as 'Memory' rather than 'Screen'. The display option using
the SHIFT and COPY keys is not available.
Now position the cursor in a suitable place on the screen to
copy to. Then press CTRL and COPY and the area marked on the previous screen
will be copied.
Once either of the markers are reset, the positions are
assumed to refer to the displayed screen rather than memory.
Converting to AMPLE
Once you have created a screen (or part of a screen) which you
wish to use in an AMPLE program, you are ready to use the AMPLE conversion
facility.
If you wish to use only part of the screen, you must mark the
area you wish to convert using the copy markers (COPY, SHIFT and COPY) before
starting the conversion process. Do this now if you wish.
To start the conversion process, select 'Convert' from the
Main menu. You will then be given two choices - 'Full screen' or 'Copy area'.
After choosing the appropriate one you will be prompted for an AMPLE word in
which to store the AMPLE definition generated. This can be up to 15 characters long.
Your will then be prompted for the filename in which the AMPLE definition is to
be stored.
Once this has been entered the conversion process will
begin. To show how it is progressing, a block cursor is displayed at the character
being converted. When the conversion is complete a message will be displayed which
can be removed by pressing RETURN.
To use the AMPLE word in your programs, load your existing
program as usual, and then type "*EXEC filename" where filename is the
name you gave to the file during the conversion process. The definition will then
be loaded and stored in the word which you specified at the start of the
conversion.
For flexibility, the definition does not include any command
to switch to MODE 7. You should therefore ensure that this mode is selected
before the word is used (the AMPLE command is 7MODE). If you type the word at
the "%" prompt when in MODE 7 the screen (or part screen) should be
displayed exactly as it was within the AMPLE Screen Designer.
If you convert part of a screen and find the AMPLE word does
not produce the expected results, this may be because you have not included
some of necessary control codes within your copy area. If this happens, return
to the AMPLE Screen Designer and check for control codes to the left of the area
which you specified.
Disc facilities
Apart from the ability to load and save screens, other options
in the 'Disc' menu allow the current disc to be catalogued and for another
drive to be selected.
When the disc catalogue option is selected the program checks
whether any information has been written to the screen which needs to be
stored.
The top line is always stored and restored by the menu, but any
other characters written below the top line will cause the screen to be stored before
the disc catalogue is displayed. Similarly, if a screen has been loaded or restored
form memory, this will cause the screen to be stored.
Once the screen has been stored (if necessary) the disc catalogue
is displayed.
The 'paged' mode of screen display is used so that each screenful
of information is held waiting for the SHIFT key to be pressed.
Once the disc catalogue is complete, a message appears at the
top of the screen which can be removed by pressing RETURN. The screen is then restored
to its previous state.
Operating system commands
Commands can be passed to the operating system using the 'OS
Command' option in the Main menu. With this option you can either use a single line
or the full screen to display any system response. This allows you to avoid delay
due to saving of the screen where this is unnecessary.
If the full screen option is selected, the 'paged' mode of
screen display is used (see previous section).
Some cautions on disc and OS commands
Because AMPLE does not provide any operating system error trapping
routine, some errors are 'fatal'. That is, the program will stop and screen information
will be lost. To guard against this, the following points should be noted.
Ensure that all filenames entered during screen saving and
loading to disc or operating system commands are valid. Illegal filenames will
generate the error message "! Bad filename in ...".
Ensure that the disc to which you are saving has enough room
to accommodate the file. Be particularly careful when using 'Convert' to
replace an existing file - if the new file is longer than the old one, and you have
saved another file in the meantime, you may get the message "! Can't extend
in ...". Other disc capacity errors may generate the messages "! Disc
full" or "Catalogue full".
Similarly, invalid operating system commands will generate the
error message "! Bad command".
If you have any doubt about a disc command working, store the
current screen to memory first. It can then be recovered in case of a 'fatal'
error (see 'Leaving the AMPLE Screen Designer' below).
Help
In the Main menu the 'Help' option displays a list of the
special keys used in the AMPLE Screen Designer. If necessary the contents of
the screen are stored before this is displayed.
The help screen can also be accessed by pressing CTRL and
TAB.
Clearing the screen
To clear the screen to start on a new design, select
"Screen", "New" from the menu. You will be asked to confirm
this action before the screen is cleared. Any screen in memory is unaffected.
Leaving the AMPLE Screen Designer
To leave the AMPLE Screen Designer and return to AMPLE, select
'Exit' from the Main menu. You will be asked to confirm your choice before the
screen information is lost. The title will then be redisplayed and the message "AMPLE
Screen Designer - session ended" displayed. If you ran the program from
the Studio 5000 Main Menu you will be returned to it. If not you will return
the AMPLE "%" prompt.
In case of errors, a facility is provided to enable the screen
in memory to be preserved after the AMPLE Screen Designer session has been ended.
If you wish to retain the screen memory on start-up of a new session, you should
press down the CTRL key as the title screen is displayed and release it once the
blank screen appears.
The screen memory will not be correctly preserved if any
actions are taken which alter memory. These include the addition, deletion or change
of words, programs or modules or use of the COMPACT command.
Function keys
Because the AMPLE Screen Designer redefines the function
keys f0-f9 for its own use, there is a facility included which resets the key definitions
at the end of the program. The key definitions are those which are provided as
standard in the Studio 5000 software. If you have changed these for your own
use, you should alter the program to match.
To do this, you need to change the word 'keyreset'. Using 'Notepad'
change the key definitions as required, then MAKE the word and re-save the ASD
program.
Technical notes
The AMPLE Screen Designer uses only 'legal' operating system
calls to address the screen. This results in a slower execution speed when reading
from and writing to the screen but ensures that the program will work on any BBC
micro whether or not 'shadow' memory is in use.
The AMPLE conversion part of the program is fairly simple
and does not necessarily result in the most compact AMPLE definition. The
conversion does remove all trailing spaces from each line, except where a line is
empty when one space remains to force the ALIGN function to move down a line.
The last character on the screen (at the bottom right) is
not converted and the last line converted does not have an ALIGN command appended.
This ensures that screen scrolling is not activated if the last line on the screen
is used in 'paged' mode.
If you wish to display a series of screens you can create a
word which calls up series of screens and waits for a keypress to move from one
screen to the next.
For example, if you had created 3 full screen display words -
screen1, screen2 and screen3:
"screenshow" [ 7 MODE
screen1 #IN #2
screen2 #IN #2
screen3 #IN #2
]
screen1 #IN #2
screen2 #IN #2
screen3 #IN #2
]
would do this. (#IN waits for and gets a key code, #2
discards it).
Program use
If you find the program useful, and would like to suggest
enhancements or changes, please contact me through AMPLINEX.
Published in AMPLINEX 002, November
1987