Home | YS MegaBasic Contents |
SCREEN OUTPUTWINDOWSThe size and shape of characters and the way in which they can be output are factors that have been greatly improved by YS MegaBasic. It's now possible, for instance, to confine output to a particular area of the screen; this area can be of any size and, as you'll have seen when loading, it can even cover the whole screen. These areas are referred to as 'windows', each window having a number You can have up to ten windows on the MegaSpectrum - numbered zero to nine - and all can be utilised in your programs (although, as mentioned earlier, windows zero to three are already being used by the system).When you run your program, all PRINT statements use window two automatically. However, it's possible to switch to another window using the command 'CURRENT_'. The command word is followed by a single numeric expression - the number of the window to be used for all subsequent output. If the expression results in a value greater than nine then you'll get the "Illegal window" error message up on-screen. It's also possible using 'CURRENT_' to manipulate three windows at once, switching between each in turn. As mentioned earlier, a window can be any size and take up any position on the screen. The 'WINDOW_' command is used to define the size and position of the current window and it takes the form: WINDOW_y,x,d,w
Where: 'y' (the line position of the top left-hand corner of window 'y') can be from zero to 23; 'x' (the column position of the top left corner of window 'x') can be from zero to 63; 'd' is the depth of the window in character lines; and 'w' is the width of the window in character columns. As YS MegaBasic incorporates 64-column characters the screen can now be thought of as being 64 character columns across and 24 character lines down. The standard Spectrum functions ATTR and SCREEN$ still use |
6.b |
---|
the old
co-ordinate system, but PRINT AT uses the new system. Also, the PRINT AT co-ordinates are relative to the top left-hand corner of the current window,
whereas ATTR and SCREEN$ use absolute screen co-ordinates. Thus, if 'y+d' is greater than 24 or 'x+w' is more than 64, you'll get the error message "Window too large"; if the values of 'd' or 'w' are less than zero, you can expect the "Window too small" error message. After a 'WINDOW_' command has been executed the print position is reset to the top left-hand corner of the window. CLS AND CLWThe standard command CLS is used to clear the whole screen - which isn't much use if you just want to clear a single window. Therefore, a new command 'CLW_' is provided to perform this task. The command word is followed by one or two numbers. If two are supplied, then the first is the number of the window to be cleared and the second shows what type of 'clear' is required; if only one number is supplied then the current window is used. There are four different types of action available from the 'CLW_' command (where 'n' is the window number):
The 'CLW_' command always uses the current permanent attributes. So, for example, if the command 'CLW_0,0' was executed and window three was the current window, then window zero would be cleared using the attributes of window three. PAN AND SCROLLIt's possible, pixel by pixel, to scroll the current window up, down, left and right using the commands' PAN_' and 'SCROLL_'. 'PAN_' scrolls a window sideways and 'SCROLL_' scrolls it vertically. Both commands must be followed by two numbers. The first indicates whether the edge | ||||||||
7 |
---|
of the window
should be filled with INK or PAPER; if it's a one then the edge is filled with INK - if zero, it'll be PAPER. The second number shows in what direction and
by how many pixels, the window should be scrolled. With 'PAN_' if the second
number is positive then the window is scrolled left to right - if negative, right
to left. With 'SCROLL_' if the number is positive the window is scrolled
upwards - if negative, it goes downwards. It's also possible to make the contents of a window wrap around. This is done using 'PANW_' and 'SCROLLW_'. These two commands are followed by a single number specifying the direction and number of pixels to be scrolled - as with 'PAN_' and 'SCROLL_'. 'PAN_', 'PANW ', 'SCROLL_' and 'SCROLLW_' only affect the display file. The 'FX_' command is used to control the way the YS MegaBasic system operates, and a number of 'FX' calls have been set aside to control choice of windows for particular tasks. The 'FX_' command is followed by two numbers, the first being the call required and the second providing any data which the call in question may need. The 'FX_' calls relating to windows are:
10 BORDER 0 You can stop any window scrolling at any time, by pressing the 'M' key. MODECharacters can now be printed on the screen in four different sizes - using the 'MODE_' command: | ||||||||
8 |
---|
When utilising Mode 4, it's possible to introduce a feature called 'stippling', which allows characters to appear shaded. Remember that the characters of Mode 4 are four times the standard size and, as a result, each pixel in the character takes up four pixels on-screen. Thus, using stipples, it's possible to define the pattern of the four dots and to produce a shading effect. The type of pattern used is defined by the command 'STIPPLE_'. The command word is followed by a single numeric expression that indicates the pattern required. Values for the numeric expression should fall between zero and 15, the higher the value the darker the shading; a value of 15 produces solid characters, whereas zero results in the 'printing' of blank spaces. FONTThe MegaSpectrum has three character sets, as compared to the standard Spectrum's one. Selection of the character set is effected by 'FONT_', and this command requires a single numeric expression to define whichever one has been chosen. Here's what you get when you use the expression with values between zero and two:
| ||||||||||||||
9 |
---|
The 'FONT_' command alters the character set used for all printing; it doesn't
just refer to the current window. The two new character sets are stored in RAM and thus can be altered by the user if so desired. Each character uses up eight bytes to define its shape (in much the same way as a user-defined graphic). The RAM character sets store the characters from CHR$32 up to CHR$127, the pseudo-BBC Micro character set starts at address 48000, and the pseudo-Amstrad character set starts at address 45000. If 'a$' is the character to be defined, then the start of the eight bytes for that character is given by: S+8*(CODE a$-32)
Where 'S' is the start of the required character set. CHR$, VDU AND DOWNThe Spectrum's character set consists of printable characters, and others which affect the way characters are printed - called 'control' characters. A number of new control characters have been included in the MegaSpectrum's character set:
VDU_2
This makes all subsequent output appear as standard size characters, whereas the following prints out 'AB': VDU_65,66
Strings of characters can be printed down the screen with the 'DOWN_' command. The command takes the form: DOWN_y,x,a$
Where: 'y' is the line on which the first character is to be printed; 'x' is the column at which the first character is to be printed; and 'a$' is the string to be printed. If the string runs off the bottom of the window then it wraps around and re-appears at the top. | ||||||
10 |
---|
SPRINT AND PRINTERMoving on to the 'SPRINT_' command' it's now possible to print characters on-screen in any size required. The command takes the form: SPRINT_x,y,a,b,a$
Where: 'x' and 'y' mark the pixel position of the first character to be printed; 'a' is the number of times the characters are to be magnified in the x direction; 'b' is the number of times the characters are to be magnified in the y direction; and 'a$' is the string of characters to be printed. If the string goes off the edge of the screen then it'll wrap around and re-appear on the left-hand side. ('SPRINT_' and other YS MegaBasic commands take the screen origin to be the top left-hand corner of the screen, rather than the bottom left.) The 'PRINTER_' command is provided to allow screen output to be diverted to a peripheral, such as a printer. This command is followed by a single numeric expression. If the result of that expression is zero the output will go to the screen; if the result is other than zero, then a user supplied routine will be called every time a character is output to the screen. The address of this machine code routine should be stored in the two bytes starting at address 59934. The character to be printed is supplied in the accumulator and the routine is terminated by a 'RET' instruction. It's most important that the following commands should notbe used when operating YS MegaBasic: 'CLEAR #', 'OPEN #2'and 'CLOSE #2' - othenwise a system crash will result. |
11.a |
---|