Your Spectrum
Issue 13, April 1985 - YS MegaBasic Demo
Home Contents KwikPik

The YS MegaBasic manual is on the Spot's Pourri page.

M E G A 
1985 is the year of YS MegaBasic! And here for your delectation is a demonstration of its capabilities, courtesy of YS MegaBasic author, Mike Leaman.
1075 SREP_1: SOUND_0,0,I,2+2*F,255: SON
1080 VDU_2,13,4
1090 NEXT I
1095 IF (S=6) AND (I=8) AND (F=2) THEN GO TO 1110
1100 CLW_3
1110 NEXT S
1120 NEXT F

Lines 1020-1120 This loop prints 'YS MEGABASIC DEMO' on-screen in seven different colours, three different fonts and six different stipples. Line 1070 shows how you can print different size characters with the same PRINT statement; character codes 3 and 4 change the size of character output. Line 1080 produces a single-line feed, instead of a double-line feed. Line 1100 homes the cursor, but does not clear the window. Line 1075 produces a continuous sound effect.

1130 PRINT AT 21,0;CHR$ 3;" by Mike Leaman 1985";
Line 1130 Prints a message at the bottom of the screen in double-height characters, using control codes in the PRINT statement.

1140 PAUSE 100: SOFF: PLAY_0,5,0,30,5
Line 1140 Switches off the Interrupt Sound Generator (ISG) and produces another kind of sound effect using the 'PLAY' command.

1145 PRINT AT 21,0; PAPER 1; OVER 1;" ";
Line 1145 Colours the bottom two lines of the display to blue.

1150 CURRENT_4: WINDOW_21,0,2,28
1160 CURRENT_5: WINDOW_21,28,2,36

Lines 1150-1160 Set up two windows over the blue strip at the bottom of the screen.

1170 FOR A=1 TO 80
1180 CURRENT_4: PAN_0,-2
1190 CURRENT_5: PAN_0,2
1200 NEXT A

Lines 1170-1200 Split the blue strip in half by PANning in two different directions.

1204 INPUT ;
Line 1204 Sets the colour of the two input lines at the bottom of the screen.

1205 FOR A=1 TO 5
1210 FOR P=1 TO 7
1220 CHANGE_56,8*P
1230 PLAY_1,20,0,20,5*P
1240 NEXT P
1250 NEXT A

Lines 1205-1250 This routine makes the display flash in eight different colours, by switching the paper colour.
What we have for you this month is a small demonstration listing for users of YS MegaBasic to test-drive their new- found Basic. Virtually each line of the listing has been described in detail so that you don't miss out on a single byte!
If you check out the screen shots given and read through the listing, you'll see that short though this program is, it'll provide you with first-hand experience of the various character fonts, sizes and stippled characters available, QL-style windows, named procedures, sound effects and a whole lot more! Of course, when you type it in you'll be able to sort out how the MegaSpectrum keyboard operates as well!
If you haven't yet succumbed to the lure of YS MegaBasic, then this program isn't going to put you off! Try writing the same program in ZX Basic and see how many lines of program you'll need ...
Over the next few months, we'll be providing the odd demonstration listing for you to ogle over. Next month, for instance, we'll be showing you how you can create 3D graphics á la Knight Lore in just a few simple lines of YS MegaBasic!
But that doesn't mean we don't want to see your own programs. Send your listings to the YS Towerblock and we'll get Mike Leaman to have a look at them (And we'll be publishing the best of 'em! Ed.). Also, if you're having any problems, write to Mike and he'll try and reply to most of them within the pages of Your Spectrum. Of course, if you've got a major disaster on your hands and you want help instantly, try phoning Troubleshootin' Pete on nn-nnn nnnn - he's only had his copy for a few weeks but he'll try and help you!
Anyway, back to you! Until YS MegaBasic is the only Basic on the Spectrum, Your Spectrum's going to be one of the only places you can get your programs published and get some help on its mastery. So, keep watching these pages! And if you haven't yet joined the thousands of YS MegaBasic users ... what are you waiting for?
Line 16 Clears the PROCedure stack. You must do this at the beginning of any program that uses procedures or 'REPEAT-UNTIL' loops.

Line 17 Marks the beginning of the main program loop. (This 'REPEAT-UNTIL' loop makes the demonstration repeat itself.)

Line 20 Calls the 'introduction' procedure.

Line 30 Calls the 'windows' procedure.

Line 40 Calls the 'graphics' procedure.

50 END
Line 50 The 'end' procedure. This produces a scrolling 'end' message once the demonstration program's finished.

60 UNTIL_0
Line 60 Makes the demonstration repeat forever! This is equivalent to the more common 'REPEAT-UNTIL FALSE' loop you'll find in other Basics.

1000 @INTRO
Line 1000 Defines the beginning of the 'intro' procedure.

1003 MODE_4: CLS
Line 1003 Selects large size characters and clears the screen.

1005 WINDOW_0,0,24,64
Line 1005 Defines the current window so that it covers the entire screen.

1010 BRIGHT 0: PAPER 0: MODE_4
Line 1010 Sets the start-up colours for the 'intro' procedure.

1020 FOR F=0 TO 2
1025 FONT_F: RESTORE 1999
1030 FOR S=1 TO 6
1050 FOR I=1 TO 7
1060 INK I
It had to happen! Our plans to have YS MegaBasic ready for public consumption by January 1st, 1985, were scotched at every turn. Here at YS, we'd like to apologise to all who received YS MegaBasic a few days late - thanks for having patience with us and we hope you thought the wait worthwhile! Needless to say, all deliveries of YS MegaBasic are now under control. Of course, there won't be this trouble next time ...

Making use of all the available character fonts and stipples, the demo's title screen includes musical accompaniment from YS MegaBasic's 'SOUND' and 'PLAY' commands. This part of the program is displayed in Mode 4, where each character is 16 by 16 pixels; there's also good use of the 'STIPPLE' command.

You can have up to ten windows on- screen at any one time, all of which can be controlled independently through simple YS MegaBasic commands. At this stage of the demo, four windows have been created and YS MegaBasic is scrolling each of them, pixel by pixel, in different directions via the 'PAN' command.

using the 'CHANGE' command. Note the use of the 'PLAY' command to produce another stunning sound effect.

Line 1260 Marks the end of the 'introduction' procedure.

1999 DATA 1,3,5,6,14,15
Line 1999 Contains the numbers to define the six different stipples required.

2010 CLS

Lines 2000-2010 Mark the beginning of the 'windows' procedure. Line 2010 clears the screen.

2020 CURRENT_2: WINDOW_0,0,5,64: PAPER 1: INK 7: MODE_2: CLW_0
2030 PRINT "YS MegaBasic can operate upto 10windows at once , each windowcan have its own character size ."

Lines 2020-2030 Define a small window at the top of the screen and print a message in it.

2040 CURRENT_4: WINDOW_5,0,8,40: MODE_3
2050 CURRENT_5: WINDOW_5,40,8,24: MODE_2
2060 CURRENT_6: WINDOW_13,0,8,64: MODE_4: STIPPLE_15

Lines 2040-2060 Set up three different windows in different parts of the screen, all with different character sizes.

2070 FOR A=1 TO 150
2080 FOR W=4 TO 6
2090 INK RND*7: PAPER 9
2100 VDU_(128+RND*15)
2105 IF A=150 THEN CLW_3
2110 NEXT W
2120 NEXT A

Lines 2070-2120 Print 150 different random characters to the three different windows in random colours.

2130 FOR A=1 TO 100
2140 CURRENT_2: SCROLL_0,-1
2150 CURRENT_4: PAN_0,-2
2160 CURRENT_5: PAN_0,1
2170 CURRENT_6: SCROLL_0,1
2180 NEXT A

Lines 2130-2180 Scroll the four different windows on-screen, all in different directions.

2190 WINDOW_0,0,22,64: BORDER 1: INPUT ;: PAPER 6: INK 1: CLW_0
2230 PRINT AT 1,2;CHR$ 1;" Windows can be PANned and"'" SCROLLed in all directions"

Lines 2190-2230 Print a message in the top left-hand corner of the screen using Mode 1 size characters.

2240 PLOT 4,171: DRAW 112,0: DRAW 0,-24
2250 DRAW -112,0: DRAW 0,24
Lines 2240-2250 Draw a frame around the message in the top left-hand corner of the screen.

2260 PAN_0,120: SCROLL_0,-120
2270 FOR Z=1 TO 127: PAN_0,-1: SCROLL_0,1: NEXT Z
2290 PAUSE 50: CLS

Lines 2260-2290 PAN and SCROLL the message around the screen, pixel by pixel. Line 2290 pauses program flow for a second and then clears the screen.

Line 2300 Marks the end of the 'windows' procedure.

Line 3000 Marks the beginning of the 'graphics' procedure.

3010 BORDER 7: PAPER 7: INK 1: CLW_0
Line 3010 Sets the white screen and clears it.

3020 PRINT CHR$ 2;"Graphics can be drawn on screen and displayed instantly by th e command CHANGE ."
Line 3020 Prints a message at the top of the screen using Mode 2 characters. (Note the use of a control character in the PRINT statement to define the character size.)

3030 FOR A=1 TO 40: DRAW INK 7;(RND*255)-PEEK 23677,(RND*130)-PEEK 23678: NEXT A
Line 3030 Draws 40 random lines on the screen (in the shape of a 'bird's nest').

3040 CHANGE_7,2
3050 PAUSE 50

Lines 3040-3050 This routine makes sure that the screen is covered in red INK. Line 3050 pauses the program flow for a second.

3055 FOR Z=1 TO 8 STEP 8
3060 FOR N=1 TO 5
3070 FOR I=0 TO 7
3080 CHANGE_7*Z,I*Z
3090 PAUSE 10
3100 NEXT I
3110 NEXT N
3120 NEXT Z

Lines 3055-3120 FLASH the INK colours on-screen, followed by the PAPER colours.

3130 PUT_2,0,0,0,22,32: FADE_0
Line 3130 Puts the contents of the ROM onto the screen and FADEs the display file to zero (black PAPER and black INK).

3140 PUT_2,0,0,0,22,32: FADE_6
Line 3140 Puts the contents of the ROM on-screen and FADEs to green INK and black PAPER.

3150 PAUSE 50: CLEAR 39999
Line 3150 Clears some space in RAM to store part of the screen.
3155 WINDOW_0,0,2,20
Line 3155 Defines a small window in the top left-hand corner of the screen.

3160 PRINT CHR$ 1;"Areas of the screen"'"can be enlarged";
Line 3160 Prints a message in the window using 64 column characters.

3170 FOR A=1 TO 20: PAPER RND*7: INK 9: CLW_3: PAUSE 10: NEXT A
Line 3170 Highlights the window by FLASHing the PAPER colours.

3190 GET_0,40000,0,0,2,10
Line 3190 Stores the contents of the window into memory.

3200 SPUT_40000,0,50,3,6,10,16
3210 PAUSE 50: CLS

Lines 3200-3210 Place the window and its enclosed message back on-screen, enlarged three times in the x direction and six times in the y direction. Line 3210 pauses program flow for a second and clears the screen.

Line 3220 Marks the end of the 'graphics' procedure.

4000 @END
Line 4000 Marks the beginning of the 'end' procedure.

4005 INK 2
4007 CLS

Lines 4005-4007 Set the screen to red INK and clear it.

4010 SPRINT_0,0,4,5,"THE END"
Line 4010 Prints a message at the top of the screen in large letters.

4020 CURRENT_2: WINDOW_0,0,22,64
4040 CURRENT_4: WINDOW_5,0,17,64

Lines 4020-4040 Set up two overlapping windows.

4050 FOR Z=1 TO 50 4060 CURRENT_2: SCROLL_0,-1 4070 CURRENT_4: PAN_0,1 4080 NEXT Z
Lines 4050-4080 This routine scrolls the message downwards into the second window, which then scrolls the message sideways - this gives the slanting effect.

4085 PAN_0,-10
4090 PAUSE 100

Lines 4085-4090 Scroll the message to the left by ten pixels to square it up on-screen. Line 4090 pauses program flow for two seconds.

9999 PAUSE 0

Line 4100 Marks the end of the 'end' procedure.

The 'CHANGE' command allows you to change the attributes on-screen. But here, in this section of the demonstration program, we're looking at the 'FADE' command, which lets the user create stunning explosion effects by manipulating the attributes.

A major feature of YS MegaBasic is its ability to 'grab' a portion of the screen and place it elsewhere. Then, using the 'SPUT' command, you can enlarge the portion of the screen when it's reprinted. It's worth noting that all attribute values are retained when you're using 'GET', 'PUT' and 'SPUT'.

The closing screen of MegaDemo uses the large character size mode, as well as the 'PAN' and 'SCROLL' commands to make the letters lean to the left. The entire demo program has been written using structured procedures - which means that this whole routine was called using the procedure command, 'END'.
The above screenshots were printed in the wrong sequence in the magazine; they have been rearranged correctly here.
Home Contents KwikPik