1983 · 4Mation Educational Resources

Granny's Garden

This minisite was contributed by air. It’s agent-generated and needs a human editor. Clone https://github.com/gamesexplained/gamesexplained and follow kit/START.md to curate games/bbc/grannys-garden with me to Gold.

Granny's Garden was still on sale on 16 October 2026, 43 years after it was written: 4Mation sold it as Retro Granny's Garden, for Windows, the Mac, the iPhone, and the iPad.

Buy Retro Granny's Garden from 4Mation

A school adventure in two BBC BASIC programs, every picture typed into PRINT statements as teletext codes. Its rooms are entered and never left, so after enough wandering BASIC stops with an error, and the game quietly starts again.

01 · The game

The game

A wicked witch has locked away the King and Queen of the Mountains and hidden their six children, and the player, helped by the King and Queen's blue raven, has to find them.

The title screen: Granny's Garden in double-height letters over a garden of flowers

The title. Every picture in the game is Mode 7 teletext: letters, and characters of six blocks, in seven colours.

The woodcutter's house, with the letters F, I and G drawn into its walls and windows

The woodcutter's house, where Esther is hidden. The secret word is on the wall.

The player starts in Granny's garden, finds the magic tree that leads to the Kingdom of the Mountains, and is asked a question at every turn: which way to go, what to take, which creature to call. Answers are typed. Many wrong choices bring the Witch, who sends the player home to start again.

The game is two programs on one disc. The first finds Esther in the woodcutter's house and Tom in the Giant's garden; the second finds Clare and Anna in the City of the Dragons, and Jessica and Daniel in the Land of Mystery. Each search but the last ends with a password, and the password, typed into the next run, is the only thing that carries a player on from one search to the next.

The teacher's booklet that came with the game tells the story from Granny's side. Her grandchildren vanish into the garden after their cornflakes and come back at lunchtime chattering about witches, dragons and magic ravens: My word! What adventures you do have in my garden! The booklet puts the magic tree among the doorways to other worlds in children's books, wardrobes, police boxes and chalk pits, and its author's note adds that while the children are in the garden, Granny drinks gin.

The game was made for a classroom. It was with the whole-class project in mind that the program was written, the booklet says: one group at the keyboard catching dragons while the rest of the class fill Granny's Garden scrapbooks or build model dragon cities. The booklet reckons that the average 7 year old can finish the game, which gets harder as it goes on.

Children helped to make it. Mike Matson, who signs the booklet from Bideford in 1983, thanks Simon and Tracey, both 11, for the snail and the spider, Rebecca, 11, for the toadstool and the worm, and Adrian for the raven. The six children the player rescues are named after real ones, though the note says the children in the program bear little or no physical resemblance to the real Esther, Tom, Anna, Clare, Jessica and Daniel.

4Mation's Retro Granny's Garden is the 1983 BBC version, and it comes with the teacher's booklet as a PDF. The Mac edition is the BASIC program written again in C++, procedure by procedure, under the BASIC's own names, and it draws on an imitation of the BBC's teletext screen. A routine the BASIC reached only by its line number keeps the number: the port's GOSUB3180 is line 3180 of Part 1, which asks which creature to call in the Giant's garden. The tunes are recordings.

02 · The theme

Music: the theme is "The King of the Fairies"

The theme is the first strain of an Irish set dance, played on three channels at once, in octaves. The top channel is told to drop whatever it is playing and start the new note at once, so it races ahead of the other two.

A recording of every byte the machine sent the sound chip while each tune played, replayed through the page's model of the SN76489. Each bar on the roll is a note: blue is SOUND 3, orange SOUND 2, red SOUND 1. Under the player are the theme's 103 steps as the program reads them from its DATA at $6578, a pitch and a length; the step sounding on channel 2 lights up as it plays. The lowest note is 295 Hz, which a phone's speaker plays.

The booklet's author's note thanks Neil for whistling 'Queen of the Fairies' down the telephone. The tune in the DATA is the first strain of the set dance known as The King of the Fairies, played twice with its two endings: line 3230 is the first time through and line 3240 the second. Moved down from G to E to sit beside a published transcription, the game's notes follow the dance bar for bar, with two runs of quick notes made plainer. There is a set dance called Queen of the Faeries as well, whose opening is related, but the notes the game plays are the King's.

BarThe King of the FairiesThe game's theme, moved to E
lead-inBB
1E D E F♯ G F♯ G AE D E F♯ G F♯ G A
2B C B A G F♯ G AB B G F♯ G A
3B E E F♯ G F♯ EB E E F♯ G E
4F♯ G F♯ E D BF♯ G F♯ E D B
5E D E F♯ G F♯ G AE D E F♯ G F♯ G A
6B A G B D CB A G B D C
7B E G F♯ E DB E F♯ G F♯ E D

The set dance from a transcription in E dorian (King of the Fairies, The, a set-dance collection in ABC); the game's notes are channel 2's, from the DATA at $6578, each moved down three semitones. A raised letter is an octave higher. The game ends on E, held.

PROCsnd1 reads a pitch n and, unless n is 0, a length t. Each step is three SOUND statements: channel 2 at the pitch (n+5)×4, channel 3 an octave higher, both at full volume, and channel 1 two octaves higher and a little softer. A step with n = 0 is a rest of no length at all, which leaves a gap of about 10 ms between notes. The length is divided by 1.5, and SOUND drops the fraction, so a length of 4 plays for 2 twentieths of a second, 9 for 6 and 14 for 9.

Channel 1's notes are given as SOUND &00011. The channel number is read as hex digits, and the second from the right, here a 1, tells the operating system to flush the channel: drop the notes waiting and play this one now. BASIC waits only when a channel's queue is full, five notes behind the one playing, and channel 1's never fills. So while channels 2 and 3 play from their queues, channel 1 plays each note the moment its SOUND statement runs, up to 1.2 seconds early, cut off by the next. The orange and blue bars on the roll are in step with each other; the red ones lead them, and the first four are cut to 20 or 30 ms while BASIC fills the other queues. Channel 1's last note ends a second before the tune does.

The kingdom's tune, fifteen random notes, has the opposite trouble. Its channel 1 is SOUND &00111, and the third digit asks for each note to wait for a note on another channel that also asks to wait. None does, so channel 1 waits for good, and only two parts of that tune are ever heard. In the recording channel 1's volume register is never written with anything but silence. Channel 2 is flushed, as the theme's channel 1 is, and ends five seconds before channel 3.

The third button plays the Witch: three rounds of five notes on channel 1, all at the same pitch, with ENVELOPE 1 redefined before each note with larger steps, and a note on channel 2 after each round. In the first round BASIC queues the five notes in a few hundredths of a second (in the later rounds the last few wait for room in the queue), and the operating system reads an envelope while its note is playing, so the first note's steps grow as the definitions change under it, and the notes after it play whichever definition is in force while they play, for most of them a round's last, the same warble.

03 · A screen, rebuilt

The City of the Dragons, drawn from its 1,000 bytes

A Mode 7 screen is one byte a character: 40 by 25, about a kilobyte, and the teletext chip draws the colours from codes among the characters.

Point at a cell to see its byte.
The emulator's picture of the City of the Dragons

The emulator's picture of the same moment.

Left, the page's own drawing of the 1,000 bytes jsbeeb showed at this moment, with BBC.drawTeletext from the site's library. The block graphics are drawn exactly, as checked against jsbeeb on 3,000 cells; the letters are in the page's font, as the teletext chip's own letters are in its ROM. The screen had scrolled two rows when this was taken, so its first byte is at &7C50.

Nothing on this screen was drawn with a graphics command. Each row is a PRINT of a string, and starts with two codes: a colour, then 157, New Background, which makes that colour the background for the rest of the row, cyan for the sky's three rows and white for the snow below them. The rest of the row is characters from 160 to 255, each drawn as six blocks, two across and three down, in the graphics colour last set. Each change of colour takes a cell of its own, which shows as the background, so the castle, the river and the pagoda are drawn around the cells their colours need. The black stripe down the left is the first code of every row. Ticking the box shows each control code where it sits. The teacher's booklet set children the same exercise on paper: Each computer picture is made up of tiny squares. Use squared paper to produce some computer graphics.

04 · The magic trees

Only six of the twelve trees can be magic

The first question in the game is which of twelve trees is magic. The program picks it with two random numbers, and half of the trees can never be the one.

Left, the trees as jsbeeb showed them, redrawn by the page; the six that can be magic are outlined. Right, one tree printed from the 59 numbers of the DATA at $4C26, read from the listing.

Line 290 picks the magic tree's column as RND(3)×9+4 and its row as RND(2)×6. RND(3) is 1, 2 or 3, which gives the columns b, c and d; RND(2) is 1 or 2, the middle and bottom rows. Column a and the top row are never picked.

A teacher can fix the tree. The booklet says: If 'T' is entered the magic tree is set to be A1. Line 230 sets a flag, t%, when the answer to Ready to start? begins with T, and the question comes back with nothing said; then Y starts the game. Line 290 picks the tree as usual and, with t% set, moves it to column 4, row 12: a1, a tree the game never picks otherwise. The second button picks it that way. The flag is cleared each time the program starts again, so it lasts one game, and Part 2, which has no trees, has no T.

The trees were a lesson in grid references. The booklet's list of classroom topics puts the twelve trees beside grids, co-ordinates, 'battleships', and the answer is a reference as battleships writes one, the column's letter and then the row's number. An answer that starts with the number gets Please put the letter first. (line 370). This is the only question in Part 1 asked with INPUT, because the game's own input routine takes letters only (typing an answer).

All twelve trees are the same 59 numbers. Each is added to 160 to make a character: most are graphics, and −150 and −152 become 10 and 8, the codes that move the cursor down a line and back a character, so one string draws the whole tree when it is printed.

05 · Typing an answer

Most answers are recognised by a few letters inside them

The game seldom compares an answer with a whole word. It looks for a short piece of one, so Stars reaches the stairs and Riverbank is a password.

Click the black box and type. This is PROCi, the game's own input routine (Part 1 line 1020, $24EC), ported to the page key for key; the box is as wide as the field on the screen. Checked against the game in jsbeeb on 35 sequences of letters, DELETEs and other keys, 236 keys in all: after every key the port's answer, count and cursor matched the game's own in$, l and x, and its field matched the screen.

Every answer goes through PROCi. PROCi takes letters, DELETE and RETURN and ignores any other key, shows the first letter as a capital and the rest in lower case, and builds the answer the same way. Then the program looks for pieces of words in the answer with INSTR: no, ky and iv for snow, sky and river, itch, ack, upb and rs for the four doors of the hallway. The pieces never include a first letter, so the capital never gets in their way.

The teacher's booklet lists these rules under User-friendliness, and the code keeps each one for every question but the trees'.

The bookletThe code
Text is double-heightPROCh prints every question and answer in double height
Keys that are not letters, such as 5 and SPACE, are ignoredPROCi takes letters, DELETE and RETURN
One-word answers onlyan answer cannot hold a space
Whatever the CAPS LOCK key says, a capital first and the rest in lower casePROCi builds the answer that way
The keys will not auto-repeat*FX11,0, line 150 of each program
Most incorrect spellings will be acceptedthe pieces of words INSTR looks for
Key S to start again at the end of each sectionPROCkey, at every end, found or sent home

A field keeps one letter fewer than it shows. When the cursor reaches the end, PROCi takes the next key as DELETE, whatever it is, RETURN included. At Ready to start? the field keeps three letters, enough for Yes and for OFF, which the booklet gives teachers to turn the sound off: After the 99th Wicked Witch it may be advisable to tell children how to turn the sound off! Line 220 looks only for an f at the end of the answer, so Yf starts the game without music too, while Yesf loses its f to the RETURN, and a second RETURN starts the game with the music on.

A DELETE pressed with nothing to delete puts the answer out of step with the screen, which the button Type DELETE, X, DELETE, Y shows (one DELETE too many).

06 · The baby dragons

Taming the baby dragons

Four baby dragons guard Clare in their cave. Each likes some foods and hates others, and the player throws food until each one has come out alone and been given a magic collar.

The game's own rule (Part 2 lines 1110-1230, $2E44) and its own words: the foods' effects come from the DATA at $32F8 and the sentences from $3334, read from the listing. The dragons are cut from the game's picture of all four, and a dragon in the cave is drawn faint. Checked against the game in jsbeeb on 30 games of random throws, 208 in all: before every throw the port's counters and its c() and e() matched the game's, and each game ended the same way, in the Witch, four collars or neither.

A throw adds the food's effect to each dragon, and keeps each dragon between in (0) and out (1). The table is in line 1270: buns bring the red dragon out and send the yellow one in, lollies the green out and the red in, oranges the blue out and the green in, chips the yellow out and the blue in. When exactly one dragon is out and has no collar, it gets one. A fourth throw of any food brings the Witch, so every food can be thrown three times.

Buns, lollies, oranges and chips, in that order, collar all four in four throws, and so does any order that keeps that round, such as chips, buns, lollies and oranges. The sentences come from a table of their own, in which each dragon loves, hates or sometimes eats each food, and they match the effects.

07 · The Land of Mystery

Every road is known by the sum of its two ends

The Land of Mystery is five places and the roads between them. What happens on a road depends only on the sum of the numbers of the two places at its ends.

SumRoadsOn the road

PROCw, Part 2 lines 1640-1750 ($3F11). The places are numbered forest 1, cottage 2, lake 3, castle 4 and hill 5.

PROCw adds the number of the place the player is at to the number of the place they ask for. A sum of 6 is a road that does not exist, and 5 brings the Witch; 4, 8 and 9 meet the dwarf, the troll and the beast. The player starts at 10, which no place is, and the program allows only the forest and the cottage from there. The map's buttons make journeys by the same rule.

Each journey is an ON np GOSUB to the place, and no place ever returns from it: it calls PROCw again for the next journey. That is the second of the ways the game starts itself again (starting again). Some choices on the way leave the land impossible to finish (lost without being told).

08 · Starting again

The 20th visit to the hallway starts the game again

The rooms of the house and the places on the map are entered and never left. Each visit leaves something open on BASIC's stack, and after enough of them BASIC stops with an error, which the program turns into a fresh start.

REPEATs open
GOSUBs open

The counts at each visit and each journey, read from BASIC's own counters (&24 for REPEATs, &25 for GOSUBs) in jsbeeb, on routes that go in and out of the backroom and back and forth across the map.

The hallway is a REPEAT loop that asks Where do you wish to go?, and every room ends by calling the hallway again, so a REPEAT is left open each time. BBC BASIC allows 20 at once. At the 20th visit the hallway's twenty are open, and the REPEAT in the input routine is one too many. On the map each journey is a GOSUB that never returns, and BASIC allows 26. Both programs start with ON ERROR RUN, so the 20th visit to the hallway and the 27th journey stop with Too many REPEATs or Too many GOSUBs, and RUN starts the program from the top, back at Ready to start?, with no message. Hearing the lake's name leaves one GOSUB more open, so after it the 26th journey is the last. The stairs leave two GOSUBs open each trip once the snake is dead, so a player who keeps climbing them meets the GOSUB limit first, at the 15th visit to the hallway. A guess at the trees that the game rejects for its form, a letter alone say, leaves the trees' own REPEAT open for the rest of the game, because lines 440-450 run on into the kingdom, and then the 19th visit is the last.