
DRIFT works. This section makes it feel finished: a title screen to start it, a sound when the power comes on and a tune when you win, and now and then a noise from the ship to remind you that you are alone on it.
PROCTITLE clears the screen, prints the name in yellow and a subtitle in white, and waits for a key with GET$. Then it clears the screen again, and the game begins.
S16's RND made numbers; SOUND makes notes. On the Einstein it takes four numbers:
SOUND 1,-15,100,TRUE
That last one is the thing to know. A note, once started, goes on sounding until you stop it - the fourth number is not how long it lasts. So PROCBEEP(P%) starts a note, waits 30 hundredths of a second by watching TIME, and stops it. PROCTUNE plays four beeps: C, E, G, C.
PROCNOISE runs after most turns. One time in six - RND(6) is 1 - it picks one of three messages from DATA at random and prints it: THE HULL CREAKS. It uses RESTORE 3400 and reads 1, 2 or 3 of them, printing the last.
LOAD "ADV8". Add these lines, replacing 4210:
30 PROCTITLE
105 IF OVER%=0 THEN PROCNOISE
2850 PROCBEEP(148)
3400 DATA THE HULL CREAKS.,SOMETHING TAPS ON THE HULL.,A LIGHT FLICKERS AND DIES.
4210 IF OVER%=1 THEN PROCWRAP("THE ENGINES ROAR INTO LIFE. THE SHIP TURNS FOR HOME. YOU HAVE MADE IT."):PRINT "AIR TO SPARE: ";AIR%:PROCTUNE
4400 DEF PROCTITLE
4410 CLS:COLOUR 11:PRINT TAB(15,6);"D R I F T"
4420 COLOUR 15:PRINT TAB(9,10);"A SHIP ADRIFT IN SPACE"
4430 PRINT TAB(11,16);"PRESS ANY KEY";
4440 K$=GET$:CLS
4450 ENDPROC
4500 DEF PROCBEEP(P%)
4510 LOCAL T%
4520 SOUND 1,-15,P%,TRUE:T%=TIME:REPEAT UNTIL TIME>T%+30:SOUND 1,0,P%,FALSE
4530 ENDPROC
4600 DEF PROCTUNE
4610 PROCBEEP(100):PROCBEEP(116):PROCBEEP(128):PROCBEEP(148)
4620 ENDPROC
4700 DEF PROCNOISE
4710 LOCAL I%,M$
4720 IF RND(6)>1 THEN ENDPROC
4730 RESTORE 3400:FOR I%=1 TO RND(3):READ M$:NEXT
4740 PRINT M$
4750 ENDPROC
Starting from
LOAD "ADV8" from S27. When it works, SAVE "ADV9". That is the finished game: the whole listing, 211 lines, is in Appendix III, and the course disc carries it as GAME - CHAIN "GAME" plays it.
What you should see
The title screen first. Press a key, and the game begins as before. Somewhere along the way the ship makes a noise. Fitting the cell beeps; winning plays four rising notes.

IF RND(2)>1 THEN ENDPROC. How chatty is the ship now?COLOUR 11 to COLOUR 9. What colour is the title?28.1 Add a fourth noise of your own. (Two lines change: the DATA, and the RND in 4730.)
28.2 Make the tune longer, with a note at pitch 136 - the A between the G and the top C.
Worked solutions are in Appendix II.
| Symptom | Cause |
|---|---|
| A note never stops | Its SOUND ... FALSE is missing. ESC stops the program and the note together. |
SOUND 1,-15,100,20 just clicks | The fourth number is start or stop, not a length. Use TRUE, and stop it yourself. |
| No noise ever appears | It only comes one turn in six. Play longer, or change 4720. |
PROCTITLE shows a title and waits for a key. SOUND starts and stops notes: channel, loudness, pitch, TRUE or FALSE - and every 4 in the pitch is a semitone. RND picks when the ship speaks and what it says. Save it as ADV9: DRIFT is finished.
S29, Reading A Real Program - a 1984 program from the disc.