CHRISTMAS CARD
Why not send the Electron fans among your family and friends an Electronic Christmas card?
This program creates a lovely graphic display to the accompaniment of some festive tunes and gently falling snow. There's even a snowman and a Christmas tree decorated with colourful fairy lights.
Of course you'll want to personalise your card. Line 40 holds the key. Place your name in from$ and the recipient's in to$.
When the card has been drawn, pressing the Q key will switch the carols off. S will switch them back on.
Procedures | |
assemble | Assembles a short machine code routine to play the carols |
snow | Draws the snow |
chars | Defines the characters |
bell(E,F) | Prints a bell |
move | Moves the snow be redefining the colours |
GET SET SANTA
By Stephen Martin
To stop all the good (?) little children of the world seeing what gifts they will receive before Christmas, Santa hid them all in a vast maze.
During the long summer months some extremely crafty characters have gained illegal entry into the maze and are having a wonderful time playing with presents they don't deserve.
You have to guide Santa through the maze and collect the presents.
But be careful. There is no telling what the frustrated little fiends will do to Santa if they get hold of him!
Variables | |
keys% | Number of keys left to collect |
loc% | Location holding the start address of the maze segment currently being printed in the window |
man% | Location of man in maze |
X% | X coordinate of man |
Y% | Y coordinate of man |
xman% | Maximum distance scrolling can continue right |
ymax% | Maximum distance of downwards scrolling |
xmin% | Minimum distance scrolling can continue left |
ymin% | Minimum distance of upwards scrolling |
score% | Score |
level% | Level reached |
lives% | Number of lives left |
Arrays |
|
nm$() | Holds top ten names |
hi%() | Holds top ten scores |
Procedures |
|
assemble | Pokes in machine code |
up | Moves man up and scrolls |
down | Moves man down and scrolls |
left | Moves man left and scrolls |
right | Moves man right and scrolls |
key | Updates the number of keys left and increases score |
screen | Sets up the screen display |
dead | Lose a life. All gone? Hiscore? |
table | Prints high score table |
initmaze | Pokes in the maze |
initvari | Initialise variables |
initgame | Sets up memory locations used |
game | Calls the machine code and updates your man until you are dead |
input | Name input routine (uses OSWORD with A=0) |
welldone | Congratulations and increment level |
Note: The BREAK key definition is corrupted because I have used the page of memory allocated to the function key definitions. Press ESCAPE after BREAK or CTRL-BREAK at the same time then OLD (RETURN) to enable normal editing. Type in the data carefully otherwise you may have an impossible game.
MISSILE ATTACK
MISSILE ATTACK is a version of the popular arcade game in which you must destroy incoming missiles with your laser bases.
If enough missiles get through - five or more - your city is destroyed and you along with it.
If you clear one screen you do to another with more and faster missiles and fewer shots with your lasers.
The program is run mainly in Mode 4 for speed but still uses colour and sound to good effect. The top ten hi-scores are displayed at the end of each game.
The program uses integer variables to increase speed. For this reason REM statements are also omitted.
The number of missiles can be changed by altering the value of N% at line 410 and their speed changed by altering the value of U% at line 510.
The title page and other double height characters are achieved by poking into the Mode 4 screen memory, which starts at &5800.
The micro looks at the character generator in ROM and pokes the value that it finds into the screen.
Each character square is defined by 8 bytes. PROCbigchars is used to do the screen poking.
The letters are held in data statements at line 2390 and 2400.
Three different short tunes are played in the game. The notes to be used and their lengths are also stored in data statements.
To give the ten highest scores a short bubble routine is used - PROCsort, lines 2440 to 2510.
Variables | |
A% | Number of shots left on laser |
B% | Number of shots left on laser |
C% | Number of shots left on laser |
D% | Number of shots left on laser |
E% | Number of missiles let through in a level |
F% | Used for recursive lopos |
H% | Horizontal position of gun sights |
V% | Vertical position of gun sights |
J% | Total number of missiles let through |
L% | Level number |
N% | Number of missiles |
I% | One third of N% |
O% | One third of N% |
R% | Decides missiles' path |
U% | Speed of missiles |
W% | Flag to indicate whether laser can fire |
Q% | Horizontal position of base which is firing missiles |
m% | Starting address in screen memory for double height characters |
M% | Position in screen memory in which the computer is currently poking |
h% | Increment for M% |
S% | Start of character generator in ROM |
SCORE% | Total score |
X() | x coordinate of missiles |
Y() | y coordinate of missiles |
hi() | Keeps hi scores |
NA$() | Keeps names of hi scores |
Z% | Sound flag |
Procedures |
|
lose | Inputs name, calculates and displays hi score, restarts program keys |
Checks key pressed, takes appropriate action | |
fire | Fires laser from selected missile base and checks for hits |
one, two, three | Keeps tabs on number of missiles left |
win | Called when you destroy all the missiles. |
prints running score and level number | |
bigchars | Pokes double height characters on to the screen |
NOTEST
Mike Plummer offers teachers and pupils an interesting aid to mastering musical notation
When my son started to learn to play the recorder, I wondered if there was any way in which he could use our Electron to help him.
At about the same time his music teacher at school asked if I could transform an idea of hers into a computer program for the school's BBC Micros.
I had already written a program to show the fingering on a recorder and how it relates to the musical notes. NOTEST is the result of combining these ideas.
The program has three distinct phases. The first is when the graphics characters, title strings and plotting data are initialised and the various options available during the test are selected.
The options are selected from a menu page which can be recalled at any time by pressing ESCAPE.
Firstly, a starting and finishing level of difficulty are selected. The notes which are available at any level of the test are shown.
Other options include whether the sound effects are to be on or off, and whether the program will automatically go on to the next level of difficulty when a test has been completed successfully.
Also you can choose how many tries you will have to get a test at any level correct before being put out of your misery.
The next phase is the test itself. A treble stave is drawn on the screen and ten notes, selected from all of those available at the current difficulty, are drawn at random on the stave.
All the notes available are shown by name above the stave and the program will only accept one of these as an answer.
You get three attempts to get the name of the note being pointed at correct.
If the answer is right the note is played; if wrong a rude noise is made and the answer is written under the note. This process is repeated for all the notes.
Finally the program checks if all of the answers are crrect and, if so, it moves to the next level - unless it is at the final level, when it prompts for another person to try.
If the test was not correct and the total number of attempts at that level has been exceeded, the program also asks for another user.
If the manual mode has been selected the program will ask if you want to go to the next level.
I know it sounds complicated, but children seem to be able to cope with it very well, and they enjoy using it.
The notes are stored as user defined characters, and plotted on the stave with VDU 5 using positions stored in a byte array called ypos% and accessed using byte indirection. This leads both to a faster executing program and more economical use of memory.
The notes can be one of six orientations, depending on whether they are between the lines of the stave, across them, above or below them.
This data is stored in the byte array bnt% and accessed in the same way.
Each note is assigned a number from 1 to 25 and a test is set up by setting the string array quest$(10) to a random selection of notes from the string array diff$. The actual string being used is indexed by diff%, the level of difficulty.
String arrays are used because it is easier to use the Basic function INSTR to see if the answer given is a valid one.
One improvement I suggest would be to enable the test to be carried out in a different key signature, but you would have to generate a different version of bnt% for each one. Over to you, maestro...
Variables | |
ok | TRUE if test was correct |
tries% | Attempts so far |
atmp% | Maximum number of tries allowed |
auto% | TRUE if level raised automatically |
diff% | Current level |
strd%,find% | Starting and final difficulty |
name$ | User name |
num$() | Describes n'th lest |
key$ | Key press |
diff$() | Stores available notes for any level |
i%,p%,n% | General counters |
deg$() | Describes the degree of difficulty |
quest$() | Stores the questions for any test |
ypos% | Byte array for note position on stave |
ptr% | Offset to byte arrays |
byte% | Byte read from byte array |
crt$ | Characters for a crotchet |
vnt$() | Characters for any note on the stave |
rnt%() | Names of notes |
bnt% | Byte array storing type of note to draw |
pntr$ | Pointer to note under test |
blnk$ | Blanks out pointer |
tot% | Score |
lquest% | Note being pointed at |
lgo% | Counts number of tries at any note |
nt% | True if answer is correct |
valid% | True if note is valid for current level |
lans$,li%,lch$ | Local variables for FNgetnote |
Procedures |
|
instructions | Display instructions and current level of test |
setup | Set up graphics and plotting data. Also the user options are set up here |
getname | Get user's name |
playnote(n%,l%) | Play note number n% for time l% |
stave | Draw a treble stave |
shownote(tnt%,xpos%) | Draw note number tnt% at position along the stave of xpos% |
setquestion | Set up the array quest$ with a random selection of notes answer |
Get answers until the test is complete successfully or set number of attempts is exceeded | |
FNgetnote | Returns a string describing a valid note |
rasp | Make a rude noise |
score | Assess score and move on to next level if OK |
nextgo | Invite next user to try |
SPACE COUNT
By Steve Lucas
SPACE COUNT is a simple educational game aimed at five to seven year olds.
When the program is run a number of coloured objects will be displayed on the screen and the aim is to count them.
To make life a little more exciting the counting must be done before Cedric flies his plane across the bottom of the screen.
Each correct answer makes Cedric fly his plane faster, making the next question more difficult.
If very young children are playing you may want to remove this by deleting the end of line 1290.
Each wrong answer makes Cedric slow down for the next question.
Two attempts are given for each question and the child has three lives in each game.
The game was written for the Electron. If it is run on the BBC Micro, Cedric will fly across the screen far too fast and you should make the changes suggested in line 130.
Variables | |
S% | Score |
lives% | Number of lives |
U% | Position of plane |
col% | Colour |
V% | Random number |
X%,Y% | General variables |
gra$ | Graphics |
A$ | Keyboard input |
B$ | String value of answer |
ans% | Correct answer |
col$(X) | Words for the numbers |
val%(x,y) | Array to hold positions for screen locations |
speed% | Speed of game |
try% | Attempt |
guess% | Answer selected |
Procedures |
|
setup | Chooses random numbers and stored this in the array |
game | Main control loop |
highscore | Deals with end of game |
top | Defines top window |
middle | Defines middle window |
bottom | Defines bottom window |
tries | Allows you to answer the question |
get | Tests the keyboard input |
win | Correct answer |
close | Wrong answer |
error | Error handling |
move | Move plane |